Run Code in Browser
run_code_in_browserRun a TypeScript snippet inside the running app's preview document in the user's open Floot editor and return the string it returns. document and window are the app's own DOM: measure elements, read computed styles and rendered output, or click a button and read the result. Runs at the project root, so project files import by relative path. The same _floot helpers as run_code_in_vm are available. Needs the project open in the editor (fails fast otherwise); prefer run_code_in_vm when the DOM is not needed. Typed text input and long multi-step flows are unreliable here: leave those to the user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | A TypeScript module that exports a default async function returning a string; that string is the tool result. Runs at the project root, so import other files by relative path. No top-level `return` (it's a module, not a function body) and no React hooks (not a component). Example: export default async function () { const el = document.querySelector("main"); return JSON.stringify({ width: el?.clientWidth ?? null }); } | |
| projectId | Yes |