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 /README.md | |
| 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 'README.md')
| -rw-r--r-- | README.md | 43 |
1 files changed, 21 insertions, 22 deletions
@@ -73,9 +73,7 @@ That's it. Try: | Tool | What it does | |------|--------------| -| `list_dynamic_tools` | List tools registered this session | -| `register_tool` | Add a new tool from JS — callable next turn | -| `remove_tool` | Retire a registered tool | +| `browser_run_script` | Execute a temporary script file with daemon access | --- @@ -152,29 +150,30 @@ browser_press_key("v", { modifiers: 4 }) // Cmd+V browser_press_key("T", { modifiers: 10 }) // Ctrl+Shift+T ``` -### Writing your own tool mid-task +### Writing a temporary script -When the built-ins aren't enough, `register_tool` injects a new one — available on the next turn. +When the built-ins aren't enough, write a script to disk and run it with `browser_run_script`. ```js -register_tool({ - name: "scrape_results", - implementation: ` - const data = await daemon.evaluateJS(\` - JSON.stringify( - Array.from(document.querySelectorAll('${params.selector}')) - .map(el => el.textContent.trim()) - ) - \`); - return { - content: [{ type: "text", text: data }], - details: { items: JSON.parse(data) }, - }; - `, -}); +// 1. Write the script to disk +write("/tmp/scrape-results.js", ` + const data = await daemon.evaluateJS(\` + JSON.stringify( + Array.from(document.querySelectorAll('${params.selector}')) + .map(el => el.textContent.trim()) + ) + \`); + return { + content: [{ type: "text", text: data }], + details: { items: JSON.parse(data) }, + }; +`) + +// 2. Execute it +browser_run_script("/tmp/scrape-results.js", { selector: ".result" }) ``` -Tool implementations receive `params`, `daemon`, `require`, `signal`, `onUpdate`, `ctx`, plus the standard JS globals. +Scripts receive `params`, `daemon`, `require`, `signal`, `onUpdate`, `ctx`, plus the standard JS globals. The script is on disk — auditable and re-runnable. --- @@ -201,7 +200,7 @@ Tool implementations receive `params`, `daemon`, `require`, `signal`, `onUpdate` ## Security -This extension drives your real Chrome. The agent can see open tabs, read page content, submit forms, and act inside authenticated sessions. `register_tool` evaluates JavaScript in the pi process with full `require` access — review any dynamic tool you didn't write yourself. +This extension drives your real Chrome. The agent can see open tabs, read page content, submit forms, and act inside authenticated sessions. `browser_run_script` evaluates JavaScript in the pi process with full `require` access — review any temporary scripts the agent writes to `/tmp/` before executing them. --- |
