diff options
| author | amankumarsingh77 <amankumarsingh7702@gmal.com> | 2026-04-30 17:52:26 +0530 |
|---|---|---|
| committer | amankumarsingh77 <amankumarsingh7702@gmal.com> | 2026-04-30 17:52:26 +0530 |
| commit | 28578d1d6237cdec3f613a3ed9fa6e888dd71a6b (patch) | |
| tree | c7f69ac2fb286a4551c5f7ecc0e67225b674f945 /src/prompt.ts | |
| parent | b6d752222947229112132ac0fbd87f355fc78974 (diff) | |
Replace dynamic tool registration with browser_run_script
Remove register_tool/remove_tool/list_dynamic_tools and the entire
dynamic-tools.ts module. Replace with a single browser_run_script tool
that executes temporary scripts from disk with daemon access.
Scripts are now written to disk before execution, making them auditable
and re-runnable. Same bindings (daemon, require, params, etc.) as before
via the same AsyncFunction mechanism.
Diffstat (limited to 'src/prompt.ts')
| -rw-r--r-- | src/prompt.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/prompt.ts b/src/prompt.ts index 26c41b5..8e3b727 100644 --- a/src/prompt.ts +++ b/src/prompt.ts @@ -39,6 +39,29 @@ to interact with pages visually, and other tools alongside them. | browser_wait | Wait N seconds | | browser_wait_for_load | Wait for document.readyState === 'complete' | | browser_handle_dialog | Accept or dismiss a JS dialog | +| browser_run_script | Execute a temporary script file with daemon access (write script to disk, then run) | + +### Temporary Scripts + +When the built-in tools aren't enough for a multi-step workflow, write a temporary +script to disk and execute it with browser_run_script. The script runs in the +harness process with direct access to the browser daemon and Node.js APIs. + +\`\`\` +write("/tmp/scrape-pages.js", \` + const results = []; + for (const url of params.urls) { + await daemon.cdp("Page.navigate", { url }); + await new Promise(r => setTimeout(r, 2000)); + const data = await daemon.evaluateJS("document.title"); + results.push({ url, title: data }); + } + return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] }; +\`) +browser_run_script("/tmp/scrape-pages.js", { urls: [...] }) +\`\`\` + +Script bindings: params, daemon, require, signal, onUpdate, ctx, console, fetch, JSON, Buffer, setTimeout, clearTimeout. ### Common Patterns @@ -74,5 +97,10 @@ browser_switch_tab(targetId: "...") → switch to a tab browser_screenshot() → visually inspect the page browser_execute_js("document.querySelector('.main').innerText") → extract content \`\`\` + +**Temporary Scripts (extending the harness):** +\`\`\` +write("/tmp/extract.js", "...script with daemon access...") → browser_run_script("/tmp/extract.js") +\`\`\` `; } |
