Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

feat(tools): live tools the user reviews before they run

Shahriarfcd3869f0764
diff --git a/README.md b/README.md
index 4067cf2..9b8aeb7 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,8 @@ Hand your real, logged-in browser to the AI agent you already run. Browsentic is
- **Your Real Browser, Not a Headless One**: Drives the tab in front of you, in your own profile, with your own logins and sessions
- **Bring Your Own Agent**: Runs on the agent CLI you already pay for and are already signed in to — switch between Claude Code, Codex and Antigravity with one click, and pick the model each one runs
-- **47 Page Capabilities**: Reading, clicking, typing, dragging, on-site search, form submission, navigation, screenshots, file upload and download, captchas, theming and accessibility, console and network diagnostics, background progress monitoring, scheduled and repeating jobs, and pointing at an element
+- **49 Page Capabilities**: Reading, clicking, typing, dragging, on-site search, form submission, navigation, screenshots, file upload and download, captchas, theming and accessibility, console and network diagnostics, background progress monitoring, scheduled and repeating jobs, and pointing at an element
+- **Live Tools, Off By Default**: For work that repeats twenty times or needs something no tool covers, flip the **Live tool** switch and the agent may write a small script for the page — you read the code in the panel and approve it before a line of it runs
- **Voice, Text, or Demonstration**: Dictate in the side panel, type anywhere, or record yourself doing a job once and later say "do it like last time"
- **Point at What You Mean (A-Eye)**: Press the lens, hover the page, click the thing — the element and its content ride along with your next message, and the agent can hand the lens back when *it* needs you to pick
- **Teach It a Site Once**: Point it at a site and it explores and writes reusable notes, so every later session already knows its way around
@@ -59,7 +60,7 @@ The extension dials out to the daemon, because a Manifest V3 service worker cann
- 📚 [Documentation](docs/)
- 🚀 [Install and Pair](docs/guide/install.md)
- ✨ [Features](docs/guide/features/)
-- 🧰 [All 47 Page Tools](docs/reference/tools.md)
+- 🧰 [All 49 Page Tools](docs/reference/tools.md)
- 🔌 [Use It From Claude Code, Cursor or Zed](docs/guide/mcp-clients.md)
- 🛡️ [Approvals and Guardrails](docs/guide/approvals.md)
- 🏗️ [Architecture](docs/internals/)
diff --git a/docs/guide/approvals.md b/docs/guide/approvals.md
index 8cea1ad..44c919d 100644
--- a/docs/guide/approvals.md
+++ b/docs/guide/approvals.md
@@ -52,12 +52,14 @@ depend on declaration order.
| `file-download` | `page_captureDownload` — letting a page write a file to your disk | confirm |
| `leaves-pinned-tab` | Moving to a tab the run was not pointed at | confirm |
| `captcha-solve` | `page_solveCaptcha` — ticking a site's "I am a human" box | confirm |
+| `code-injection` | `page_injectCode` — installing JavaScript the agent wrote into the page | confirm |
+| `external-code-execution` | `page_runCode` called by an MCP client rather than the side panel | **deny** |
| `secret-in-url` | A saved secret placed in a navigation URL | **deny** |
| `secret-release` | A saved secret about to be typed into the page | confirm |
| `secret-off-scope` | …and it was read on a site outside this run's scope | confirm |
| `config-require-approval` | The action is named in your `requireApproval` list | confirm |
-Three of these are less obvious than they look:
+Five of these are less obvious than they look:
**`form-submission` is smarter than a name match.** It also catches `page_fillInput` and
`page_typeText` with `pressEnter: true`, and `page_pressKey` with `Enter` — because those submit
@@ -68,6 +70,15 @@ What may be *kept* is not a preference: executables, files over 100 MB, and down
outside the run's scope are refused whatever this is set to, and the file the browser already wrote
is deleted. See [Files](features/files.md#what-it-will-not-keep).
+**`code-injection` is the one prompt that shows its work** — and the one capability that is off until
+you switch it on. The composer's **Live tool** switch starts off, and with it off `page_injectCode`
+is refused outright, before this rule is ever consulted. With it on, approving means running
+JavaScript the agent wrote in the page, with your session — so the panel puts a **Review** button on
+the prompt and opens the full source before you decide. There is no "always on this site" for it: that would let
+later, unread code run on your say-so about earlier code. One approval covers every later
+`page_runCode` call into *that* toolkit, on that tab and that site, which is what makes twenty
+repetitions cheap; a different script is a fresh prompt. See [Page actions](features/page-actions.md).
+
**`raw-html-read` is denied by default** because `outerHTML` carries comments, `aria-hidden` nodes
and off-screen text: everything a page can hide from the person looking at it but still hand to the
model. The default rendered-text format has already dropped those. Set it to `allow` if a run
diff --git a/docs/guide/features/page-actions.md b/docs/guide/features/page-actions.md
index 7d28f31..152fef1 100644
--- a/docs/guide/features/page-actions.md
+++ b/docs/guide/features/page-actions.md
@@ -1,6 +1,6 @@
# Page actions
-The 47 things Browsentic can do to a page. You never have to name these — you say what you want and
+The 49 things Browsentic can do to a page. You never have to name these — you say what you want and
the agent picks — but knowing what exists tells you what is worth asking for.
Exact parameters for every one: [reference/tools.md](../../reference/tools.md).
@@ -61,6 +61,32 @@ Tab tools are the only ones that change *which* tab everything else acts on, and
the current window. `closeTab` refuses deliberately in four cases: the only tab in a window, a
pinned tab, a browser page, and a tab being [recorded](recordings.md).
+## Repeating a job, and doing what no tool covers
+
+Two tools exist for the cases the fixed toolset handles badly. When the same sequence is about to
+run twenty times with only the input changing — creating twenty tags, archiving every row — twenty
+rounds of wait, find, click and verify is slow and fragile. And some things no tool covers at all:
+seeking a video to a timestamp, reading pixels off a canvas, driving an editor's own API.
+
+**Both are off unless you switch them on.** The composer has a **Live tool** switch — the `</>` button
+beside the message box — and it starts off. With it off the agent cannot reach these tools at all,
+is not told they exist, and gets `LIVE_TOOLS_OFF` if it tries; nothing but your own click turns it
+on. With it on, the agent decides whether the job actually warrants a script.
+
+`page_injectCode` then asks to install a small toolkit of JavaScript functions in the page. **You
+review the source and approve it** — the prompt in the side panel has a **Review** button that opens
+the full code before you decide. `page_runCode` calls one of those functions with fresh arguments,
+as often as the job needs, without asking again.
+
+What you approve is that code, on that tab, on that site. Later calls can only reach the functions
+you read; only their arguments change. There is no "always on this site" for an injection, because
+that would authorise code you never saw. Navigate to another site and the toolkit stops working
+rather than following you.
+
+The agent is told to reach for this only when a task repeats three or more times or when nothing
+else can do the job — a one-off click is cheaper as a click. See [Approvals](../approvals.md) and
+[reference/tools.md](../../reference/tools.md#scripting).
+
## Everything else
| Group | Tools | See |
diff --git a/docs/guide/mcp-clients.md b/docs/guide/mcp-clients.md
index 78afa04..5c0ab90 100644
--- a/docs/guide/mcp-clients.md
+++ b/docs/guide/mcp-clients.md
@@ -45,7 +45,7 @@ Tools missing from a session you registered mid-flight is the single most common
## What the client gets
-- **45 page tools** — every one listed with its parameters in [reference/tools.md](../reference/tools.md)
+- **49 page tools** — every one listed with its parameters in [reference/tools.md](../reference/tools.md)
- **`browsentic_status`** — whether the extension is connected, its version, the active tab, any
running monitors, and a `hint` naming the fix when something is wrong. Call it first when a page
tool fails.
diff --git a/docs/internals/registry.md b/docs/internals/registry.md
index d2afe07..1ef8baf 100644
--- a/docs/internals/registry.md
+++ b/docs/internals/registry.md
@@ -8,7 +8,7 @@ One definition, compiled into two bundles.
## One array, two consumers
-There are **45 page capabilities**. They are defined once, in
+There are **49 page capabilities**. They are defined once, in
[`src/lib/actions/registry.ts`](../../src/lib/actions/registry.ts), and that array is compiled into **both**
the extension and the daemon.
diff --git a/docs/reference/tools.md b/docs/reference/tools.md
index 2acd828..7b9833d 100644
--- a/docs/reference/tools.md
+++ b/docs/reference/tools.md
@@ -23,6 +23,7 @@ The surface, at a glance:
| [Status](#status) | `browsentic_status` |
| [Reading](#reading) | `page_getPageInfo`, `page_extractText`, `page_waitForElement`, `page_findProgress`, `page_findSearch`, `page_screenshot` |
| [Acting](#acting) | `page_clickElement`, `page_trustedClick`, `page_findCaptcha`, `page_solveCaptcha`, `page_hoverElement`, `page_dragElement`, `page_focusInput`, `page_fillInput`, `page_typeText`, `page_selectOption`, `page_selectText`, `page_pressKey`, `page_submitForm`, `page_highlightElement` |
+| [Scripting](#scripting) | `page_injectCode`, `page_runCode` |
| [Moving](#moving) | `page_searchSite`, `page_navigate`, `page_scrollTo`, `page_openTab`, `page_switchTab`, `page_closeTab` |
| [Theming](#theming) | `page_readTheme`, `page_auditContrast`, `page_applyTheme` |
| [Diagnostics](#diagnostics) | `page_startDiagnostics`, `page_readConsole`, `page_readNetwork`, `page_stopDiagnostics` |
@@ -458,6 +459,87 @@ the user what was found.
---
+## Scripting
+
+Two tools for the jobs the fixed toolset is the wrong shape for: a sequence about to be repeated
+many times with different inputs, and a capability no tool covers. `page_injectCode` installs a
+small toolkit of functions after **you** approve the source; `page_runCode` calls one of them, as
+often as the job needs, without asking again.
+
+**Both require the composer's "Live tool" switch, which starts off.** A side-panel run whose message
+was sent with it off gets `LIVE_TOOLS_OFF` from either tool, and the guidance telling the agent how
+to use them is not even loaded. Only the person at the panel can turn it on.
+
+**Both are side-panel only.** An [MCP client](../guide/mcp-clients.md) cannot install code — it has
+nobody to show it to — and cannot call a toolkit the panel installed either: the approval belonged
+to the conversation whose user read the source, and a client that was not in that room does not
+inherit it.
+
+The approval is the whole security boundary, so it is worth knowing exactly what it covers. The
+prompt in the side panel carries a **Review** button that opens the full source before you decide.
+What you approve is that code, on that tab, on that site — `page_runCode` can only ever call back
+into it, and only its arguments change. There is deliberately no "always on this site" for an
+injection: it would authorise later code you never read. A different script asks again.
+
+Installing goes through Chrome's debugger, so the browser shows its "Browsentic is debugging this
+browser" bar for the moment it takes, it fails on a tab with DevTools open, and it is unavailable on
+Firefox. The calls afterwards use an ordinary event bridge and show nothing.
+
+### page_injectCode
+
+Install a toolkit of JavaScript functions into the page, to be called later with `page_runCode`.
+Gated by the [`code-injection`](../guide/approvals.md) rule, which is why an external MCP client —
+having nobody to show the code to — cannot install any.
+
+The code runs once in the page's **main world**, so it sees the page's own DOM, globals and
+same-origin `fetch`, and nothing of the extension. It is handed a `tools` object and assigns each
+entry point onto it:
+
+```js
+tools.addTag = async (name) => {
+ document.querySelector('#new-tag').value = name;
+ document.querySelector('#new-tag').dispatchEvent(new Event('input', { bubbles: true }));
+ document.querySelector('form.tag-form button[type=submit]').click();
+ await new Promise((done) => setTimeout(done, 400));
+ return [...document.querySelectorAll('.tag-row .name')].some((el) => el.textContent === name);
+};
+```
+
+| Parameter | Type | Default | Purpose |
+| --- | --- | --- | --- |
+| `purpose` | string | required | One sentence, shown to you on the approval prompt, saying what the toolkit does |
+| `code` | string | required | The source, assigning each function onto `tools`. Max 32 KB |
+| `call` | object | — | `{ function, args }` to run immediately after installing, saving a round trip |
+
+Returns `toolkitId`, the `origin` it was approved for, and `functions` — the names it defined.
+
+Values that vary per call belong in `page_runCode`'s arguments, not baked into the source: the code
+is what was approved, so changing it means approving again. Secrets never belong in it either —
+this is the field the approval prompt displays, and it is shown in full.
+
+### page_runCode
+
+Call one function from the installed toolkit. Not gated for the side panel — the approval already
+covered the code — and denied outright for an MCP client by
+[`external-code-execution`](../guide/approvals.md).
+
+| Parameter | Type | Default | Purpose |
+| --- | --- | --- | --- |
+| `function` | string | required | Name of a function the toolkit defined |
+| `args` | array | `[]` | Arguments, in order. JSON values only |
+| `timeoutMs` | integer | `10000` | How long the call may run before it is abandoned |
+
+Returns `{ function, returned }`, where `returned` is the function's JSON value.
+
+A page reload wipes the toolkit out of the page but not the record of what you approved, so the next
+call silently re-installs the same source and proceeds. Four refusals are worth reading rather than
+retrying: `TOOLKIT_MISSING` (nothing installed here — inject first), `TOOLKIT_SCOPE` (the tab has
+moved to a different site than the code was approved on), `UNKNOWN_FUNCTION` (the error lists what
+the toolkit does define), and `CODE_ERROR` (the function threw; the page's own message comes back
+with it).
+
+---
+
## Moving
### page_searchSite
diff --git a/package.json b/package.json
index d43989a..8431d5b 100644
--- a/package.json
+++ b/package.json
@@ -16,9 +16,10 @@
"zip": "wxt zip",
"icons": "node scripts/generate-icons.mjs",
"compile": "tsc --noEmit",
- "check": "yarn compile && yarn daemon:compile && yarn check:intent && yarn check:security",
+ "check": "yarn compile && yarn daemon:compile && yarn check:intent && yarn check:toolkit && yarn check:security",
"check:intent": "node scripts/check-intent.mjs",
"check:security": "node scripts/check-security.mjs",
+ "check:toolkit": "node scripts/check-toolkit.mjs",
"daemon:compile": "yarn --cwd src/daemon compile",
"daemon:build": "yarn --cwd src/daemon build",
"daemon:dev": "yarn --cwd src/daemon dev",
diff --git a/scripts/check-security.mjs b/scripts/check-security.mjs
index 6c3c0cf..d11f079 100644
--- a/scripts/check-security.mjs
+++ b/scripts/check-security.mjs
@@ -139,6 +139,9 @@ check('the download names its rule', agent('page.captureDownload', { target: {}
check('an off-scope download url confirms too', agent('page.captureDownload', { url: 'https://evil.com/f.csv' }).matched.map((r) => r.id), ['off-scope-navigation', 'file-download']);
check('a signed download url is not a payload', agent('page.captureDownload', { url: `https://example.com/f.csv?sig=${'x'.repeat(600)}` }).matched.map((r) => r.id), ['file-download']);
check('a javascript: download is denied', agent('page.captureDownload', { url: 'javascript:alert(1)' }).effect, 'deny');
+check('injecting code confirms', agent('page.injectCode', { purpose: 'p', code: 'tools.x = () => 1;' }).effect, 'confirm');
+check('the injection names its rule', agent('page.injectCode', { purpose: 'p', code: 'x' }).matched.map((r) => r.id), ['code-injection']);
+check('calling already-approved code is not re-gated', agent('page.runCode', { function: 'x', args: [] }).effect, 'allow');
check('switching to another tab confirms', agent('page.switchTab', { tabId: 9 }).effect, 'confirm');
check('switching back to the pinned tab is fine', agent('page.switchTab', { tabId: 3 }).effect, 'allow');
check('listing tabs is not a move', agent('page.switchTab', {}).effect, 'allow');
@@ -157,6 +160,13 @@ check('the waiver is still recorded', external('page.submitForm', {}, policyFrom
check('external reserved action denied regardless', external('browsentic.saveSiteMap', {}).effect, 'deny');
check('external never returns confirm', external('page.attachFile', { fileId: 'f' }, policyFrom({ unattended: 'deny' })).effect, 'deny');
check('external download denied by default', external('page.captureDownload', { url: 'https://example.com/f.csv' }).effect, 'deny');
+// Nobody to show the code to, so nobody can approve it — and a toolkit a person approved
+// in the panel is not thereby available to an MCP client.
+check('external code injection denied by default', external('page.injectCode', { purpose: 'p', code: 'x' }).effect, 'deny');
+check('external code execution denied outright', external('page.runCode', { function: 'x' }).effect, 'deny');
+check('the refusal names its rule', external('page.runCode', { function: 'x' }).matched.map((r) => r.id), ['external-code-execution']);
+check('unattended=allow does not open it', external('page.runCode', { function: 'x' }, policyFrom({ unattended: 'allow' })).effect, 'deny');
+check('the panel is unaffected by that rule', agent('page.runCode', { function: 'x' }).matched.map((r) => r.id), []);
// ── guardrails: policy overrides ─────────────────────────────────────────────────
const strict = policyFrom({ rules: { 'raw-html-read': 'deny', 'off-scope-navigation': 'deny' } });
@@ -413,6 +423,10 @@ const r = redact.redactInput;
check('fillInput value redacted', r('page.fillInput', { value: 'hunter2' }).value, '[redacted]');
check('password key redacted', r('page.x', { password: 'p' }).password, '[redacted]');
check('card number redacted', r('page.x', { note: '4242424242424242' }).note, '[redacted]');
+// The approval asks someone to read this, so it cannot arrive truncated.
+const longCode = `tools.x = () => {${'\n // padding'.repeat(60)}\n};`;
+check('injected code survives redaction whole', r('page.injectCode', { purpose: 'p', code: longCode }).code, longCode);
+check('a long value elsewhere is still capped', r('page.x', { note: 'y'.repeat(400) }).note.length, 201);
check('benign value kept', r('page.x', { target: { text: 'Sign in' } }).target.text, 'Sign in');
check('long string clipped', r('page.x', { s: 'a'.repeat(500) }).s.length, 201);
check('array capped', r('page.x', { a: new Array(100).fill('x') }).a.length, 21);
diff --git a/scripts/check-toolkit.mjs b/scripts/check-toolkit.mjs
new file mode 100644
index 0000000..048f40b
--- /dev/null
+++ b/scripts/check-toolkit.mjs
@@ -0,0 +1,163 @@
+#!/usr/bin/env node
+
+/**
+ * The two-world protocol behind page.injectCode.
+ *
+ * The toolkit is installed into the page's main world and called from the content
+ * script's isolated one, so nothing about it is exercised by `tsc` — a broken installer
+ * string or a dropped reply looks exactly like working code until a real page runs it.
+ * Node has an EventTarget and a CustomEvent, which is all the protocol actually needs,
+ * so the real installer source is evaluated here and called through the real client.
+ */
+
+import { build } from 'esbuild';
+import { mkdir } from 'node:fs/promises';
+import { dirname, join } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+
+const root = dirname(dirname(fileURLToPath(import.meta.url)));
+const outfile = join(root, 'node_modules/.cache/browsentic-toolkit/toolkit.mjs');
+await mkdir(dirname(outfile), { recursive: true });
+await build({
+ entryPoints: [join(root, 'src/lib/actions/page/toolkit.ts')],
+ outfile,
+ bundle: true,
+ format: 'esm',
+ platform: 'node',
+ logLevel: 'warning',
+ alias: { '@': join(root, 'src') },
+});
+const toolkit = await import(pathToFileURL(outfile).href);
+
+let failed = 0;
+let ran = 0;
+function check(label, actual, expected) {
+ ran++;
+ const a = JSON.stringify(actual);
+ const e = JSON.stringify(expected);
+ if (a === e) return console.log(` ok ${label}`);
+ failed++;
+ console.log(`FAIL ${label}\n expected ${e}\n actual ${a}`);
+}
+
+// A stand-in for the two worlds: one shared window/document, the way a real page has one.
+function makeWorld() {
+ const target = new EventTarget();
+ const attributes = new Map();
+ globalThis.window = target;
+ globalThis.document = {
+ documentElement: {
+ setAttribute: (name, value) => attributes.set(name, value),
+ getAttribute: (name) => attributes.get(name) ?? null,
+ hasAttribute: (name) => attributes.has(name),
+ removeAttribute: (name) => attributes.delete(name),
+ },
+ };
+ return { attributes, target };
+}
+
+const world = makeWorld();
+
+// The main world evaluates exactly the string CDP would hand it.
+const install = (id, code) => (0, eval)(toolkit.installerSource(id, code));
+
+// ── installing ───────────────────────────────────────────────────────────────
+const names = install('kit-1', `
+ tools.echo = (value) => value;
+ tools.add = (a, b) => a + b;
+ tools.slow = async (ms) => { await new Promise((d) => setTimeout(d, ms)); return 'late'; };
+ tools.boom = () => { throw new Error('page said no'); };
+ tools.nothing = () => undefined;
+ tools.cyclic = () => { const o = {}; o.self = o; return o; };
+ const helper = 1;
+`);
+check('install reports only the functions', names.sort(), ['add', 'boom', 'cyclic', 'echo', 'nothing', 'slow']);
+check('install stamps the attribute', world.attributes.get('data-browsentic-toolkit'), 'kit-1');
+
+// ── calling across the bridge ────────────────────────────────────────────────
+check('a value round trips', await toolkit.callToolkit('echo', [{ a: [1, 2] }], 1000), { a: [1, 2] });
+check('several arguments arrive in order', await toolkit.callToolkit('add', [2, 40], 1000), 42);
+check('an async function is awaited', await toolkit.callToolkit('slow', [10], 1000), 'late');
+check('undefined comes back as null', await toolkit.callToolkit('nothing', [], 1000), null);
+
+const thrown = await toolkit.callToolkit('boom', [], 1000).catch((e) => e);
+check('a throw surfaces as CODE_ERROR', [thrown.code, thrown.message.includes('page said no')], ['CODE_ERROR', true]);
+
+const missing = await toolkit.callToolkit('nope', [], 1000).catch((e) => e);
+check('an unknown function is rejected by the page', missing.code, 'CODE_ERROR');
+
+const unserializable = await toolkit.callToolkit('cyclic', [], 1000).catch((e) => e);
+check('a non-JSON return is reported, not hung', unserializable.code, 'CODE_ERROR');
+
+const late = await toolkit.callToolkit('slow', [500], 120).catch((e) => e);
+check('a slow call times out', late.code, 'TIMEOUT');
+
+// A timed-out call must not leave its listener behind to catch the next reply.
+await new Promise((done) => setTimeout(done, 600));
+check('the abandoned call did not corrupt the next one', await toolkit.callToolkit('add', [1, 1], 1000), 2);
+
+// ── re-installing over a live toolkit ────────────────────────────────────────
+const second = install('kit-2', `tools.echo = () => 'replaced';`);
+check('re-install swaps the toolkit', second, ['echo']);
+check('re-install restamps the id', world.attributes.get('data-browsentic-toolkit'), 'kit-2');
+check('the new function answers', await toolkit.callToolkit('echo', [], 1000), 'replaced');
+const gone = await toolkit.callToolkit('add', [1, 1], 1000).catch((e) => e);
+check('the old function is gone', gone.code, 'CODE_ERROR');
+
+// ── a page with no toolkit ───────────────────────────────────────────────────
+makeWorld();
+let bare;
+try {
+ await toolkit.callToolkit('echo', [], 1000);
+} catch (error) {
+ bare = error;
+}
+check('calling into a bare page reports TOOLKIT_MISSING', bare.code, 'TOOLKIT_MISSING');
+
+// ── code that defines nothing ────────────────────────────────────────────────
+makeWorld();
+let empty;
+try {
+ install('kit-3', `const x = 1;`);
+} catch (error) {
+ empty = error;
+}
+check('code defining no functions throws at install', empty.message.includes('no functions'), true);
+
+// ── the Live tool switch decides whether the agent is even told ──────────────
+const skillsOut = join(root, 'node_modules/.cache/browsentic-toolkit/skills.mjs');
+await build({
+ entryPoints: [join(root, 'src/daemon/agent/skills.ts')],
+ outfile: skillsOut,
+ bundle: true,
+ format: 'esm',
+ platform: 'node',
+ packages: 'external',
+ logLevel: 'warning',
+ alias: { '@': join(root, 'src') },
+});
+const { routeSkill, SCRIPTING_SKILL } = await import(pathToFileURL(skillsOut).href);
+
+const skill = (name, extra = {}) => ({
+ name,
+ description: '',
+ triggers: ['20', 'every'],
+ isDefault: name === 'browser-control',
+ category: 'general',
+ domains: [],
+ source: 'bundled',
+ provenance: 'authored',
+ body: name,
+ ...extra,
+});
+const library = [skill('browser-control'), skill(SCRIPTING_SKILL)];
+const route = (context) => routeSkill(library, 'create 20 tags, every one of them', context);
+
+check('with the switch off the scripting skill is not attached', route({}).overlays.map((s) => s.name), []);
+check('with the switch off the base skill is unaffected', route({}).base.name, 'browser-control');
+check('with the switch on it rides along as an overlay', route({ liveTools: true }).overlays.map((s) => s.name), [SCRIPTING_SKILL]);
+check('it never replaces the base skill it advises against', route({ liveTools: true }).base.name, 'browser-control');
+check('no context at all means off', routeSkill(library, 'create 20 tags').overlays.map((s) => s.name), []);
+
+console.log(failed ? `\n${failed} of ${ran} failed` : `\n${ran}/${ran} toolkit checks passed`);
+process.exit(failed ? 1 : 0);
diff --git a/src/daemon/agent/service.ts b/src/daemon/agent/service.ts
index 5dc9214..748aaf1 100644
--- a/src/daemon/agent/service.ts
+++ b/src/daemon/agent/service.ts
@@ -20,7 +20,9 @@ import {
decide,
declined,
describe as describeDecision,
+ INJECT_ACTION,
normalizeHost,
+ RUN_CODE_ACTION,
policyFrom,
scopeFor,
sealSecrets,
@@ -74,6 +76,8 @@ interface ActiveRun {
map?: MapRun;
/** The A-Eye pick photographed when the user attached it to this instruction. */
focusShot?: string;
+ /** The composer's “Live tool” switch, as it stood when this instruction was sent. */
+ liveTools: boolean;
}
const FOCUS_SHOT_TOOL_NAME = toolNameFor(FOCUS_SHOT_ACTION);
@@ -144,6 +148,14 @@ export class AgentSession {
return result;
}
+ if (!run.liveTools && (action === INJECT_ACTION || action === RUN_CODE_ACTION)) {
+ emit({ kind: 'toolResult', toolId, ok: false, summary: 'live tools are switched off' });
+ return failure(
+ 'LIVE_TOOLS_OFF',
+ 'Writing and running your own page code is switched off for this message. The user turns it on with the “Live tool” switch beside the message box, and only they can. Do the job with the ordinary page tools, or say that this one needs that switch and why.',
+ );
+ }
+
if (run.map) {
const gate = gateMappingInvoke(run.map, action, input);
if (!gate.allow) {
@@ -268,6 +280,7 @@ export class AgentSession {
pending: new Map(),
ownedTabIds: [],
focusShot: context?.focus?.shot,
+ liveTools: context?.liveTools === true,
};
this.runs.set(runId, run);
diff --git a/src/daemon/agent/skills.ts b/src/daemon/agent/skills.ts
index 8c59310..157f287 100644
--- a/src/daemon/agent/skills.ts
+++ b/src/daemon/agent/skills.ts
@@ -127,9 +127,17 @@ export interface RoutedSkill {
text: string;
}
+/**
+ * Guidance for writing page code, which is only ever an add-on: it rides along with
+ * whatever skill the instruction actually routed to, and only when the user has turned
+ * the composer's “Live tool” switch on. As a base skill it would replace the very
+ * clicking and typing advice the code is meant to be weighed against.
+ */
+export const SCRIPTING_SKILL = 'page-scripting';
+
export function routeSkill(skills: Skill[], instruction: string, context?: RunContext): RoutedSkill | null {
if (!skills.length) return null;
- const bases = skills.filter((skill) => skill.category === 'general');
+ const bases = skills.filter((skill) => skill.category === 'general' && skill.name !== SCRIPTING_SKILL);
const fallback = bases.find((skill) => skill.isDefault) ?? bases[0] ?? skills[0];
let text = instruction;
@@ -168,7 +176,10 @@ function overlaysFor(skills: Skill[], context: RunContext | undefined, forced: S
.sort((a, b) => b.match.length - a.match.length)
.map((entry) => entry.skill)
: [];
- return [...forced, ...matched];
+ const scripting = context?.liveTools
+ ? skills.filter((skill) => skill.name === SCRIPTING_SKILL && !forced.includes(skill))
+ : [];
+ return [...forced, ...matched, ...scripting];
}
function parseSkill(raw: string, fallbackName: string, source: SkillSource): Skill {
diff --git a/src/daemon/guardrails/index.ts b/src/daemon/guardrails/index.ts
index 4e38fa9..eeefd8f 100644
--- a/src/daemon/guardrails/index.ts
+++ b/src/daemon/guardrails/index.ts
@@ -25,7 +25,9 @@ export {
DEFAULT_RULES,
DOWNLOAD_ACTION,
EXTRACT_ACTION,
+ INJECT_ACTION,
POLICY,
+ RUN_CODE_ACTION,
SUBMIT_ACTION,
UPLOAD_ACTION,
policyFrom,
diff --git a/src/daemon/guardrails/policy.ts b/src/daemon/guardrails/policy.ts
index db10a55..f74959c 100644
--- a/src/daemon/guardrails/policy.ts
+++ b/src/daemon/guardrails/policy.ts
@@ -34,6 +34,8 @@ export const DOWNLOAD_ACTION = 'page.captureDownload';
export const EXTRACT_ACTION = 'page.extractText';
export const CAPTCHA_ACTION = 'page.solveCaptcha';
export const NETWORK_ACTION = 'page.readNetwork';
+export const INJECT_ACTION = 'page.injectCode';
+export const RUN_CODE_ACTION = 'page.runCode';
/** One definition, shared with the settings screen that renders it. */
export type Effect = RuleEffect;
@@ -101,6 +103,20 @@ export const CONDITIONS = {
/** Acting on another site's human-verification control. */
answersCaptcha: (request) => request.action === CAPTCHA_ACTION,
+ /**
+ * Installing agent-written JavaScript into the page. The code is the whole of what is
+ * being authorised — `page.runCode` only ever calls back into what this approved.
+ */
+ injectsCode: (request) => request.action === INJECT_ACTION,
+
+ /**
+ * The one place a caller is named in a condition rather than left to `unattended`.
+ * A toolkit is approved by a person reading it in the side panel, for the conversation
+ * they were having; an MCP client was never in that room, and the switch the user
+ * turned off is not one it can see.
+ */
+ runsCodeOutsideThePanel: (request) => request.action === RUN_CODE_ACTION && request.caller === 'external',
+
/**
* Turns a sealed placeholder back into the credential it stands for. The release
* itself happens in the extension, one hop from the page; this is where a person gets
@@ -206,6 +222,27 @@ export const DEFAULT_RULES: readonly Rule[] = [
title: 'Saves a file from the page to disk',
reason: 'That writes a file the page chose into the user’s download folder.',
},
+ {
+ // The most powerful thing an agent can ask for, and the one gate that has to show
+ // its work: the panel puts the source behind a Review button, because "allow this
+ // action?" is not a question anyone can answer about code they have not read. It
+ // confirms rather than denies because a reviewed function is how twenty repetitions
+ // stop being twenty round trips — and `unattended: deny` keeps an external MCP
+ // client, which has nobody to show the code to, from installing any at all.
+ id: 'code-injection',
+ when: 'injectsCode',
+ effect: 'confirm',
+ title: 'Runs code it wrote in the page',
+ reason: 'That installs JavaScript the agent wrote into the page, with your logged-in session.',
+ },
+ {
+ id: 'external-code-execution',
+ when: 'runsCodeOutsideThePanel',
+ effect: 'deny',
+ title: 'Calls injected code from outside the panel',
+ reason:
+ 'Code installed by page.injectCode was reviewed and approved for the side-panel conversation that asked for it. It is not available to an MCP client.',
+ },
{
id: 'leaves-pinned-tab',
when: 'leavesPinnedTab',
diff --git a/src/daemon/skills/page-scripting.md b/src/daemon/skills/page-scripting.md
new file mode 100644
index 0000000..cab7240
--- /dev/null
+++ b/src/daemon/skills/page-scripting.md
@@ -0,0 +1,50 @@
+---
+name: page-scripting
+description: Install a reviewed JavaScript toolkit in the page and call it repeatedly — for batch work and capabilities no tool covers.
+triggers: [each, every, all of them, for all, bulk, batch, repeat, again for, 20, dozens, one by one, tags, rows, entries, items, seek, fast forward, rewind, playback, canvas, video position, inject, script, run code]
+---
+
+The user has turned the **Live tool** switch on for this message. That is what makes these two tools available at all, and it is a deliberate act on their part — they are telling you that writing a small script is a reasonable thing to consider here. It is not an instruction to write one: if the ordinary tools fit, use them.
+
+`page_injectCode` installs a small toolkit of functions in the page after the user approves the code, and `page_runCode` calls one of them with fresh arguments — no further prompts, as many times as the job needs.
+
+## When to reach for it — and when not to
+
+Reach for it in exactly two situations:
+
+1. **The same steps, three or more times, only the input changing.** Creating 20 tags, archiving every message, renaming a list of files. Ten clicks per item times twenty items is two hundred round trips; one injected `addTag(name)` is one approval and twenty cheap calls.
+2. **A capability no tool covers.** Seeking a video to a timestamp, reading pixels off a canvas, driving an editor's own JavaScript API. If you find yourself simulating something the page could do in one line of its own code, write that line.
+
+Do **not** reach for it when the ordinary tools already fit. A one-off click is `page_clickElement`; two repetitions are still cheaper done directly than approved, installed and called. Reading data out of a page is `page_extractText` or `page_getPageInfo`. The injected path costs a user interruption (the approval), a visible "Browsentic is debugging this browser" bar on every call, and it does not work on Firefox or on a tab with DevTools open — so it has to earn its place.
+
+The moment to decide is the moment you notice the repetition: after doing a task once by hand and seeing the same sequence coming again and again, stop and write the function rather than grinding through the loop.
+
+## Writing the toolkit
+
+Your code runs once, in the page's main world, after the user approves it. Assign every entry point onto the `tools` object you are given:
+
+```js
+tools.addTag = async (name) => {
+ document.querySelector('#new-tag').value = name;
+ document.querySelector('#new-tag').dispatchEvent(new Event('input', { bubbles: true }));
+ document.querySelector('form.tag-form button[type=submit]').click();
+ await new Promise((done) => setTimeout(done, 400));
+ return [...document.querySelectorAll('.tag-row .name')].some((el) => el.textContent === name);
+};
+```
+
+Rules that keep it working:
+
+- **Data goes in arguments, never in the code.** The user approves the code once; if a value is baked in, changing it means another approval. `tags.forEach` loops belong in your calls to `page_runCode`, not inside the toolkit.
+- **Secrets never go in the code.** The approval prompt shows every character to the user, and a credential does not belong on that screen. Fill credential fields with `page_fillInput`, which handles sealed secrets properly.
+- **Return JSON, and return proof.** A function that acted should return evidence it worked — the created item's name, the new count — so each `page_runCode` result verifies itself. `undefined` teaches you nothing.
+- **Snapshot first.** Build selectors from a fresh `page_getPageInfo`, exactly as you would for a click. Guessed selectors fail after approval, which wastes the user's attention twice.
+- **Write an honest `purpose`.** The one-line purpose is what the user reads before the code; say what it does in their words ("Create GA tags one by one from a list"), not in yours.
+
+## The lifecycle
+
+`page_injectCode { purpose, code, call? }` triggers the approval — the user can press **Review** and read the code before deciding. Pass `call` to run the first invocation in the same round trip. Then `page_runCode { function, args }` per item. The toolkit survives page reloads (the approved code is re-installed silently) but is bound to the tab and site it was approved on: navigate to another origin and calls refuse with `TOOLKIT_SCOPE` — inject again there if the job follows.
+
+If the approval comes back declined, that is an answer, not an obstacle: fall back to the ordinary tools or ask, never re-submit the same code hoping for a different click. A `CODE_ERROR` result carries the page-side exception — fix the code and inject the corrected version, which is a new approval, so get it right in as few revisions as you can.
+
+`LIVE_TOOLS_OFF` means the switch went off between messages. Only the user can turn it back on; say what you would use it for and why, and carry on with the ordinary tools meanwhile.
diff --git a/src/extension/components/code-review.tsx b/src/extension/components/code-review.tsx
new file mode 100644
index 0000000..179bfa5
--- /dev/null
+++ b/src/extension/components/code-review.tsx
@@ -0,0 +1,71 @@
+import { useEffect } from 'react';
+import { createPortal } from 'react-dom';
+import { Check, ShieldAlert, X } from 'lucide-react';
+
+import { Button } from '@/extension/components/ui/button';
+
+export function CodeReview({
+ purpose,
+ code,
+ site,
+ onAllow,
+ onDeny,
+ onClose,
+}: {
+ purpose: string;
+ code: string;
+ site?: string;
+ onAllow: () => void;
+ onDeny: () => void;
+ onClose: () => void;
+}) {
+ useEffect(() => {
+ const onKey = (event: KeyboardEvent) => {
+ if (event.key === 'Escape') onClose();
+ };
+ window.addEventListener('keydown', onKey);
+ return () => window.removeEventListener('keydown', onKey);
+ }, [onClose]);
+
+ return createPortal(
+ <div className="enters fixed inset-0 z-50 flex flex-col bg-ground/96 backdrop-blur">
+ <div className="flex items-start gap-2 border-b border-ember/30 bg-ember/8 px-3 py-2.5">
+ <ShieldAlert className="mt-0.5 size-3.5 shrink-0 text-ember" />
+ <div className="min-w-0 flex-1">
+ <p className="text-xs font-medium text-ink">Code the agent wrote</p>
+ <p className="mt-0.5 text-[11px] leading-relaxed text-ink-dim">{purpose}</p>
+ </div>
+ <button
+ type="button"
+ onClick={onClose}
+ title="Close without deciding"
+ className="mt-0.5 shrink-0 rounded p-0.5 text-ink-faint transition-colors hover:text-ink"
+ >
+ <X className="size-3.5" />
+ </button>
+ </div>
+
+ <div className="min-h-0 flex-1 overflow-auto bg-ground/70">
+ <pre className="min-w-full p-3 font-mono text-[11px] leading-relaxed whitespace-pre text-ink-dim">
+ <code>{code}</code>
+ </pre>
+ </div>
+
+ <div className="border-t border-line px-3 py-2.5">
+ <p className="mb-2 text-[11px] leading-relaxed text-ink-faint">
+ This runs in {site ? <span className="font-mono text-ink">{site}</span> : 'the page'} with your logged-in
+ session, and can do anything you could do there. Later calls reuse these functions without asking again.
+ </p>
+ <div className="flex gap-1.5">
+ <Button variant="ghost" size="sm" className="flex-1" onClick={onDeny}>
+ <X className="size-3" /> Deny
+ </Button>
+ <Button size="sm" className="flex-1" onClick={onAllow}>
+ <Check className="size-3" /> Allow
+ </Button>
+ </div>
+ </div>
+ </div>,
+ document.body,
+ );
+}
diff --git a/src/extension/components/composer.tsx b/src/extension/components/composer.tsx
index 97a9c2f..eb84236 100644
--- a/src/extension/components/composer.tsx
+++ b/src/extension/components/composer.tsx
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useRef, useState, type MouseEvent } from 'react';
-import { FileText, FileUp, Loader2, Mic, MicOff, Paperclip, ScanEye, Send, Sparkles, Square, X } from 'lucide-react';
+import { Code2, FileText, FileUp, Loader2, Mic, MicOff, Paperclip, ScanEye, Send, Sparkles, Square, X } from 'lucide-react';
import { SkillMenu, skillMenuItems, type SkillMenuItem } from '@/extension/components/skill-menu';
import { Button } from '@/extension/components/ui/button';
@@ -29,6 +29,8 @@ export function Composer({
attachedSkill,
focus,
picking,
+ liveTools,
+ onToggleLiveTools,
onAttachSkill,
onCommand,
onSend,
@@ -51,6 +53,8 @@ export function Composer({
attachedSkill: AttachedSkill | null;
focus: FocusedElement | null;
picking: boolean;
+ liveTools: boolean;
+ onToggleLiveTools: () => void;
onAttachSkill: (skill: AttachedSkill | null) => void;
onCommand: (command: string) => void;
onSend: () => void;
@@ -125,6 +129,24 @@ export function Composer({
</div>
)}
+ {liveTools && (
+ <div className="enters mb-2 flex items-center gap-2 rounded-xl border border-ember/40 bg-ember/8 px-2.5 py-1.5 text-xs">
+ <Code2 className="size-3.5 shrink-0 text-ember" />
+ <span className="min-w-0 flex-1 text-ink-dim">
+ <span className="font-medium text-ink">Live tool on</span> — the agent may write a script for this page.
+ You approve the code first.
+ </span>
+ <button
+ type="button"
+ onClick={onToggleLiveTools}
+ aria-label="Turn live tools off"
+ className="shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink"
+ >
+ <X className="size-3" />
+ </button>
+ </div>
+ )}
+
<FileChips files={files} onRemove={onRemoveFile} />
<VoiceStatus voice={voice} voiceEnabled={voiceEnabled} />
@@ -216,6 +238,23 @@ export function Composer({
>
<FileUp className="size-3.5" />
</Button>
+ <Button
+ variant={liveTools ? 'subtle' : 'ghost'}
+ size="icon-sm"
+ role="switch"
+ aria-checked={liveTools}
+ aria-label={liveTools ? 'Turn live tools off' : 'Turn live tools on'}
+ title={
+ liveTools
+ ? 'Live tool is on — the agent may write a small script for this page and ask you to approve it. Turn it off to keep to the built-in tools.'
+ : 'Live tool — let the agent write a small script for repetitive work or for something no tool covers. You review and approve the code before it runs.'
+ }
+ onClick={onToggleLiveTools}
+ disabled={!connected}
+ className={cn(liveTools ? 'text-ember' : undefined)}
+ >
+ <Code2 className="size-3.5" />
+ </Button>
<Button
variant={voiceEnabled && !voice.error ? 'subtle' : 'ghost'}
size="icon-sm"
diff --git a/src/extension/components/run-timeline.tsx b/src/extension/components/run-timeline.tsx
index d51be6f..f1258ae 100644
--- a/src/extension/components/run-timeline.tsx
+++ b/src/extension/components/run-timeline.tsx
@@ -1,7 +1,10 @@
+import { useEffect, useState } from 'react';
import {
+ Braces,
Camera,
Check,
Clapperboard,
+ Code2,
Compass,
CornerDownLeft,
ExternalLink,
@@ -26,9 +29,11 @@ import {
type LucideIcon,
} from 'lucide-react';
+import { CodeReview } from '@/extension/components/code-review';
import { ContextCard } from '@/extension/components/context-card';
import { Markdown } from '@/extension/components/markdown';
import { Button } from '@/extension/components/ui/button';
+import { injectCode } from '@/lib/actions/page/inject-code';
import { openScreenshot } from '@/lib/bridge/screenshot-preview';
import type { RunItem } from '@/lib/bridge/run-items';
import { cn } from '@/lib/utils';
@@ -115,6 +120,12 @@ function ToolRow({
const name = item.action.replace(/^page\./, '');
const Icon = ICONS[name] ?? Wrench;
const pending = item.ok === undefined && !item.awaiting;
+ const source = item.action === injectCode.name ? sourceOf(item.input) : null;
+ const [reviewing, setReviewing] = useState(false);
+
+ useEffect(() => {
+ if (!item.awaiting) setReviewing(false);
+ }, [item.awaiting]);
return (
<div className="enters flex min-w-0 flex-col gap-1.5">
@@ -183,11 +194,16 @@ function ToolRow({
{item.awaiting && (
<div className="flex flex-wrap items-center gap-1.5 rounded-lg border border-ember/45 bg-ember/10 px-2.5 py-2">
- <p className="flex-1 text-xs text-ink">Allow this action?</p>
+ <p className="flex-1 text-xs text-ink">{source ? 'Allow this code to run?' : 'Allow this action?'}</p>
+ {source && (
+ <Button size="sm" variant="ghost" onClick={() => setReviewing(true)} title="Read the code before deciding">
+ Review
+ </Button>
+ )}
<Button size="sm" variant="ghost" onClick={() => onDecide(item.id, false)}>
Deny
</Button>
- {item.site && (
+ {item.site && !source && (
<Button
size="sm"
variant="ghost"
@@ -202,10 +218,27 @@ function ToolRow({
</Button>
</div>
)}
+
+ {reviewing && source && (
+ <CodeReview
+ purpose={source.purpose}
+ code={source.code}
+ site={item.site}
+ onAllow={() => onDecide(item.id, true)}
+ onDeny={() => onDecide(item.id, false)}
+ onClose={() => setReviewing(false)}
+ />
+ )}
</div>
);
}
+function sourceOf(input: unknown): { purpose: string; code: string } | null {
+ const args = input as { purpose?: unknown; code?: unknown } | null;
+ if (typeof args?.code !== 'string' || !args.code) return null;
+ return { purpose: typeof args.purpose === 'string' ? args.purpose : 'No purpose given.', code: args.code };
+}
+
function Tag({ tone, icon: Icon, label }: { tone: 'amber' | 'magenta'; icon: LucideIcon; label: string }) {
return (
<span
@@ -271,4 +304,6 @@ const ICONS: Record<string, LucideIcon> = {
awaitMonitor: Radar,
listRecordings: Clapperboard,
readRecording: Clapperboard,
+ injectCode: Code2,
+ runCode: Braces,
};
diff --git a/src/extension/entrypoints/background.ts b/src/extension/entrypoints/background.ts
index 1dc469f..926e3fc 100644
--- a/src/extension/entrypoints/background.ts
+++ b/src/extension/entrypoints/background.ts
@@ -3,6 +3,7 @@ import { describeActions } from '@/lib/actions/registry';
import { injectContentScript } from '@/lib/actions/client';
import { invokeForHarness } from '@/lib/bridge/invoke';
import { serveDebuggerEvents } from '@/lib/bridge/cdp';
+import { serveCodeToolkits } from '@/lib/bridge/code-toolkit';
import { serveDiagnostics } from '@/lib/bridge/diagnostics';
import { analyzeStoredFile } from '@/lib/bridge/file-store';
import { pushSkill, removeSkill, resyncSkills } from '@/lib/bridge/skill-store';
@@ -200,6 +201,7 @@ export default defineBackground(() => {
});
serveDiagnostics();
+ serveCodeToolkits();
serveRecorder();
serveMonitor();
serveTimers();
diff --git a/src/extension/entrypoints/sidepanel/App.tsx b/src/extension/entrypoints/sidepanel/App.tsx
index 7e2f198..c140637 100644
--- a/src/extension/entrypoints/sidepanel/App.tsx
+++ b/src/extension/entrypoints/sidepanel/App.tsx
@@ -54,6 +54,7 @@ export default function App() {
const [attachedSkill, setAttachedSkill] = useState<AttachedSkill | null>(null);
const [focus, setFocus] = useState<FocusedElement | null>(null);
const [picking, setPicking] = useState(false);
+ const [liveTools, setLiveTools] = useState(false);
const [tab, setTab] = usePanelTab();
const [connectionOpen, setConnectionOpen] = useState(false);
const [, setCollapsed] = usePanelCollapsed();
@@ -66,7 +67,7 @@ export default function App() {
const voice = useVoiceComposer({
active: voiceEnabled && connected && !run.running,
onSubmit: (text) => {
- run.send(text, { agentSkillId: attachedSkill?.id, focus: focus ?? undefined });
+ run.send(text, { agentSkillId: attachedSkill?.id, focus: focus ?? undefined, liveTools });
setAttachedSkill(null);
setFocus(null);
},
@@ -342,6 +343,8 @@ export default function App() {
attachedSkill={attachedSkill}
focus={focus}
picking={picking}
+ liveTools={liveTools}
+ onToggleLiveTools={() => setLiveTools((on) => !on)}
onAttachSkill={setAttachedSkill}
onCommand={(command) => {
open('chat');
diff --git a/src/lib/actions/page/inject-code.ts b/src/lib/actions/page/inject-code.ts
new file mode 100644
index 0000000..6c11712
--- /dev/null
+++ b/src/lib/actions/page/inject-code.ts
@@ -0,0 +1,36 @@
+import { z } from 'zod';
+import { ActionError, defineAction } from '../core';
+
+export const MAX_CODE_LENGTH = 32_768;
+
+export const injectCode = defineAction({
+ name: 'page.injectCode',
+ description:
+ 'Install a small toolkit of JavaScript functions into the page, to be called later with page.runCode. Reach for it only when the ordinary tools are the wrong shape: a step sequence you are about to repeat three or more times with different inputs (create 20 tags, delete every row), or a capability no tool covers (seek a video, read a canvas, drive a bespoke editor API). The user reviews and approves the code before it runs — one approval covers every later page.runCode call and survives page reloads, so batch work needs no further prompts. The toolkit is bound to the tab and origin it was approved on; navigating to another site voids it. Installing goes through Chrome’s debugger, so the browser shows a “Browsentic is debugging this browser” bar for the moment it takes, it cannot install on a tab that has DevTools open, and it is unavailable on Firefox — the calls afterwards are cheap and show nothing. For a one-off click or fill, the ordinary tools are always the better choice.',
+ input: z.object({
+ purpose: z
+ .string()
+ .min(1)
+ .max(200)
+ .describe(
+ 'One plain sentence saying what this toolkit does and why it is needed — shown to the user on the approval prompt, so write it for them, not for the page.',
+ ),
+ code: z
+ .string()
+ .min(1)
+ .max(MAX_CODE_LENGTH)
+ .describe(
+ 'JavaScript source that assigns each entry point onto the provided `tools` object: `tools.addTag = async (name) => {…}`. It runs once in the page’s main world after the user approves it, so it can use the page’s DOM, globals and same-origin fetch, but nothing of the extension. Keep it pure of data: anything that varies per call arrives as arguments through page.runCode, and secrets never belong in it. Async functions are awaited; return values must be JSON-serializable.',
+ ),
+ call: z
+ .object({
+ function: z.string().min(1).describe('Name of a function the code assigns onto `tools`.'),
+ args: z.array(z.unknown()).default([]).describe('Arguments for that first call, JSON values only.'),
+ })
+ .optional()
+ .describe('Call one of the new functions immediately after installing, saving a round trip when the first use is already known.'),
+ }),
+ execute() {
+ throw new ActionError('page.injectCode is resolved by the Browsentic extension, not in the page', 'UNSUPPORTED');
+ },
+});
diff --git a/src/lib/actions/page/run-code.ts b/src/lib/actions/page/run-code.ts
new file mode 100644
index 0000000..cdcf21a
--- /dev/null
+++ b/src/lib/actions/page/run-code.ts
@@ -0,0 +1,28 @@
+import { z } from 'zod';
+import { defineAction } from '../core';
+import { callToolkit } from './toolkit';
+
+export const runCode = defineAction({
+ name: 'page.runCode',
+ description:
+ 'Call one function from the toolkit page.injectCode installed in this tab, with fresh arguments. This is the cheap, repeatable half of the pair: the user approved the code once, so every call runs without another prompt, and a page reload re-installs the approved toolkit on its own. It refuses if nothing is installed here, or if the tab has moved to a different site than the one the code was approved on — inject again in either case. The function’s return value comes back as JSON.',
+ input: z.object({
+ function: z.string().min(1).describe('Name of a function the installed toolkit assigned onto `tools`.'),
+ args: z
+ .array(z.unknown())
+ .default([])
+ .describe(
+ 'Arguments passed to the function, in order. JSON values only — this is where per-call data like a tag name belongs.',
+ ),
+ timeoutMs: z
+ .number()
+ .int()
+ .min(100)
+ .max(120_000)
+ .default(10_000)
+ .describe('How long the call may run before it is abandoned. Raise it for functions that wait on the page.'),
+ }),
+ async execute({ function: fn, args, timeoutMs }) {
+ return { function: fn, returned: await callToolkit(fn, args, timeoutMs) };
+ },
+});
diff --git a/src/lib/actions/page/toolkit.ts b/src/lib/actions/page/toolkit.ts
new file mode 100644
index 0000000..a9aca7b
--- /dev/null
+++ b/src/lib/actions/page/toolkit.ts
@@ -0,0 +1,136 @@
+/**
+ * The bridge between an approved toolkit and the calls that use it.
+ *
+ * The toolkit itself has to live in the page's main world, where the page's own globals
+ * are — the content script's isolated world cannot see them. Getting it there means
+ * Chrome's debugger: `Runtime.evaluate` is not subject to the page's CSP, while `eval`
+ * and `new Function` inside the page are, so a site with `script-src 'self'` would
+ * otherwise refuse the toolkit outright. That is why the source is embedded textually
+ * here rather than compiled in the page.
+ *
+ * Calls do not go back through the debugger. Attaching per call would flash the
+ * debugging bar on every one of twenty iterations, which is the opposite of what batch
+ * work is for, so the installer leaves an event listener behind and later calls are
+ * ordinary DOM events from the content script. Their payloads cross as JSON strings:
+ * an object built in one world and read in the other is a wrapped foreign object, and a
+ * string is just a string.
+ */
+
+import { ActionError } from '../core';
+
+export const TOOLKIT_ATTRIBUTE = 'data-browsentic-toolkit';
+export const TOOLKIT_CALL_EVENT = 'browsentic:toolkit:call';
+export const TOOLKIT_RESULT_EVENT = 'browsentic:toolkit:result';
+export const TOOLKIT_GLOBAL = '__browsenticToolkit';
+
+export const TOOLKIT_MISSING = 'TOOLKIT_MISSING';
+export const CODE_ERROR = 'CODE_ERROR';
+
+interface ToolkitReply {
+ id: string;
+ ok: boolean;
+ value?: unknown;
+ error?: string;
+}
+
+export function installerSource(toolkitId: string, code: string): string {
+ const key = JSON.stringify(TOOLKIT_GLOBAL);
+ const attribute = JSON.stringify(TOOLKIT_ATTRIBUTE);
+ const callEvent = JSON.stringify(TOOLKIT_CALL_EVENT);
+ const resultEvent = JSON.stringify(TOOLKIT_RESULT_EVENT);
+
+ return `(() => {
+ const tools = {};
+ (function (tools) {
+${code}
+ })(tools);
+
+ const names = Object.keys(tools).filter((name) => typeof tools[name] === 'function');
+ if (!names.length) {
+ throw new Error('The code defined no functions on "tools" — assign each entry point, e.g. tools.addTag = (name) => {…}.');
+ }
+
+ let store = globalThis[${key}];
+ if (!store) {
+ store = globalThis[${key}] = { tools };
+ window.addEventListener(${callEvent}, (event) => {
+ let request;
+ try {
+ request = JSON.parse(event.detail);
+ } catch {
+ return;
+ }
+ const reply = (payload) => {
+ let detail;
+ try {
+ detail = JSON.stringify({ id: request.id, ...payload });
+ } catch {
+ detail = JSON.stringify({
+ id: request.id,
+ ok: false,
+ error: 'That function returned something that is not JSON — return plain data instead.',
+ });
+ }
+ window.dispatchEvent(new CustomEvent(${resultEvent}, { detail }));
+ };
+ const fn = store.tools[request.fn];
+ if (typeof fn !== 'function') {
+ return reply({ ok: false, error: 'This toolkit has no function named "' + request.fn + '".' });
+ }
+ Promise.resolve()
+ .then(() => fn.apply(undefined, request.args || []))
+ .then(
+ (value) => reply({ ok: true, value: value === undefined ? null : value }),
+ (error) => reply({ ok: false, error: String((error && error.message) || error) }),
+ );
+ });
+ }
+
+ store.tools = tools;
+ store.id = ${JSON.stringify(toolkitId)};
+ document.documentElement.setAttribute(${attribute}, ${JSON.stringify(toolkitId)});
+ return names;
+})()`;
+}
+
+export function callToolkit(fn: string, args: readonly unknown[], timeoutMs: number): Promise<unknown> {
+ if (!document.documentElement.hasAttribute(TOOLKIT_ATTRIBUTE)) {
+ throw new ActionError('No toolkit is installed in this page.', TOOLKIT_MISSING);
+ }
+
+ const callId = crypto.randomUUID();
+
+ return new Promise((resolve, reject) => {
+ const onResult = (event: Event) => {
+ const reply = parseReply((event as CustomEvent).detail);
+ if (reply?.id !== callId) return;
+ stop();
+ if (reply.ok) resolve(reply.value ?? null);
+ else reject(new ActionError(reply.error ?? 'The function threw.', CODE_ERROR));
+ };
+
+ const timer = setTimeout(() => {
+ stop();
+ reject(new ActionError(`“${fn}” did not finish within ${timeoutMs}ms.`, 'TIMEOUT'));
+ }, timeoutMs);
+
+ function stop() {
+ clearTimeout(timer);
+ window.removeEventListener(TOOLKIT_RESULT_EVENT, onResult);
+ }
+
+ window.addEventListener(TOOLKIT_RESULT_EVENT, onResult);
+ window.dispatchEvent(
+ new CustomEvent(TOOLKIT_CALL_EVENT, { detail: JSON.stringify({ id: callId, fn, args }) }),
+ );
+ });
+}
+
+function parseReply(detail: unknown): ToolkitReply | null {
+ if (typeof detail !== 'string') return null;
+ try {
+ return JSON.parse(detail) as ToolkitReply;
+ } catch {
+ return null;
+ }
+}
diff --git a/src/lib/actions/protocol.ts b/src/lib/actions/protocol.ts
index ea276a5..72ed42c 100644
--- a/src/lib/actions/protocol.ts
+++ b/src/lib/actions/protocol.ts
@@ -129,6 +129,13 @@ export interface RunContext {
agentSkillId?: string;
/** The element the user pointed at with A-Eye before sending this message. */
focus?: FocusedElement;
+ /**
+ * The composer's “Live tool” switch. Off unless the user turned it on for this
+ * message, and nothing else can turn it on — it is what lets the agent write and run
+ * its own page code, so it stays a deliberate act rather than a capability that is
+ * simply there.
+ */
+ liveTools?: boolean;
}
/** One skill from the active agent CLI's own library. Title and handle only — the file's path and content stay on the daemon's side. */
diff --git a/src/lib/actions/registry.ts b/src/lib/actions/registry.ts
index 3b966b6..9a81c62 100644
--- a/src/lib/actions/registry.ts
+++ b/src/lib/actions/registry.ts
@@ -18,6 +18,7 @@ import { focusInput } from './page/focus-input';
import { getPageInfo } from './page/get-page-info';
import { highlightElement } from './page/highlight-element';
import { hoverElement } from './page/hover-element';
+import { injectCode } from './page/inject-code';
import { listDownloads } from './page/list-downloads';
import { listFiles } from './page/list-files';
import { listRecordings } from './page/list-recordings';
@@ -30,6 +31,7 @@ import { readConsole } from './page/read-console';
import { readNetwork } from './page/read-network';
import { readRecording } from './page/read-recording';
import { readTheme } from './page/read-theme';
+import { runCode } from './page/run-code';
import { screenshot } from './page/screenshot';
import { scrollTo } from './page/scroll-to';
import { searchSite } from './page/search-site';
@@ -70,6 +72,8 @@ export const actions: ReadonlyMap<string, AnyAction> = new Map(
pressKey,
submitForm,
waitForElement,
+ injectCode,
+ runCode,
findProgress,
findSearch,
readTheme,
diff --git a/src/lib/bridge/code-toolkit.ts b/src/lib/bridge/code-toolkit.ts
new file mode 100644
index 0000000..1583bce
--- /dev/null
+++ b/src/lib/bridge/code-toolkit.ts
@@ -0,0 +1,175 @@
+/**
+ * Installing and calling an approved toolkit.
+ *
+ * The store is the extension's record of what the user actually approved: the code, the
+ * tab, and the origin it was approved on. `page.injectCode` is gated by the daemon's
+ * policy and `page.runCode` is not, so this file is what keeps the ungated half honest —
+ * a call can only ever reach code that came from an approved install, on the same tab
+ * and the same site. A page reload wipes the main world but not the record, so the first
+ * call afterwards re-installs the same approved source rather than asking again.
+ */
+
+import { browser } from 'wxt/browser';
+import { z } from 'zod';
+import { invokeInTab } from '@/lib/actions/client';
+import { injectCode } from '@/lib/actions/page/inject-code';
+import { runCode } from '@/lib/actions/page/run-code';
+import { installerSource, TOOLKIT_MISSING } from '@/lib/actions/page/toolkit';
+import { failure, success, type ActionResult } from '@/lib/actions/protocol';
+import { send, withDebugger, type DebuggerSession } from './cdp';
+
+const TOOLKITS_KEY = 'browsentic/codeToolkits';
+
+const FIREFOX_HINT =
+ 'Installing page code needs Chrome’s debugger, which Firefox does not expose — use the ordinary page tools instead.';
+
+const MAX_ERROR_LENGTH = 600;
+
+interface StoredToolkit {
+ id: string;
+ origin: string;
+ purpose: string;
+ code: string;
+ functions: string[];
+ installedAt: number;
+}
+
+type ToolkitMap = Record<string, StoredToolkit>;
+
+interface EvaluateReply {
+ result?: { value?: unknown };
+ exceptionDetails?: { text?: string; exception?: { description?: string } };
+}
+
+async function readToolkits(): Promise<ToolkitMap> {
+ const stored = await browser.storage.session.get(TOOLKITS_KEY);
+ return (stored[TOOLKITS_KEY] as ToolkitMap | undefined) ?? {};
+}
+
+async function writeToolkit(tabId: number, toolkit: StoredToolkit | null): Promise<void> {
+ const map = await readToolkits();
+ if (toolkit) map[String(tabId)] = toolkit;
+ else delete map[String(tabId)];
+ await browser.storage.session.set({ [TOOLKITS_KEY]: map });
+}
+
+async function forgetToolkit(tabId: number): Promise<void> {
+ await writeToolkit(tabId, null);
+}
+
+export function serveCodeToolkits(): void {
+ browser.tabs.onRemoved.addListener((tabId) => void forgetToolkit(tabId));
+}
+
+export function originOf(url: string | undefined): string | undefined {
+ if (!url) return undefined;
+ try {
+ const origin = new URL(url).origin;
+ return origin === 'null' ? undefined : origin;
+ } catch {
+ return undefined;
+ }
+}
+
+export async function installToolkit(tabId: number, url: string | undefined, input: unknown): Promise<ActionResult> {
+ const parsed = injectCode.input.safeParse(input ?? {});
+ if (!parsed.success) return failure('INVALID_INPUT', z.prettifyError(parsed.error));
+
+ const origin = originOf(url);
+ if (!origin) {
+ return failure('UNSUPPORTED', 'Page code can only be installed on an http(s) page.');
+ }
+
+ const { purpose, code, call } = parsed.data;
+ const toolkit: StoredToolkit = {
+ id: crypto.randomUUID(),
+ origin,
+ purpose,
+ code,
+ functions: [],
+ installedAt: Date.now(),
+ };
+
+ const installed = await evaluateInstaller(tabId, toolkit);
+ if (!installed.ok) return installed;
+
+ toolkit.functions = installed.data as string[];
+ await writeToolkit(tabId, toolkit);
+
+ const summary = {
+ toolkitId: toolkit.id,
+ origin,
+ purpose,
+ functions: toolkit.functions,
+ };
+ if (!call) return success(summary);
+
+ const called = await runToolkit(tabId, url, { function: call.function, args: call.args });
+ return called.ok
+ ? success({ ...summary, called: called.data })
+ : success({ ...summary, callFailed: called.error });
+}
+
+export async function runToolkit(tabId: number, url: string | undefined, input: unknown): Promise<ActionResult> {
+ const parsed = runCode.input.safeParse(input ?? {});
+ if (!parsed.success) return failure('INVALID_INPUT', z.prettifyError(parsed.error));
+
+ const toolkit = (await readToolkits())[String(tabId)];
+ if (!toolkit) {
+ return failure(
+ TOOLKIT_MISSING,
+ 'No toolkit is installed in this tab. Call page.injectCode first, and the user will be asked to approve the code.',
+ );
+ }
+
+ const origin = originOf(url);
+ if (origin !== toolkit.origin) {
+ await forgetToolkit(tabId);
+ return failure(
+ 'TOOLKIT_SCOPE',
+ `That toolkit was approved for ${toolkit.origin}, but this tab is on ${origin ?? 'another page'}. Install it again here if the job continues.`,
+ );
+ }
+
+ if (!toolkit.functions.includes(parsed.data.function)) {
+ return failure(
+ 'UNKNOWN_FUNCTION',
+ `This toolkit has no function named “${parsed.data.function}”. It defines: ${toolkit.functions.join(', ')}.`,
+ );
+ }
+
+ const called = await invokeInTab(tabId, runCode.name, parsed.data);
+ if (called.ok || called.error.code !== TOOLKIT_MISSING) return called;
+
+ const reinstalled = await evaluateInstaller(tabId, toolkit);
+ if (!reinstalled.ok) return reinstalled;
+ return invokeInTab(tabId, runCode.name, parsed.data);
+}
+
+function evaluateInstaller(tabId: number, toolkit: StoredToolkit): Promise<ActionResult> {
+ return withDebugger(tabId, FIREFOX_HINT, async (session) => {
+ const reply = await evaluate(session, installerSource(toolkit.id, toolkit.code));
+ const thrown = reply.exceptionDetails;
+ if (thrown) {
+ return failure('CODE_ERROR', `The code failed while installing: ${describeThrow(thrown)}`);
+ }
+ const names = reply.result?.value;
+ if (!Array.isArray(names)) {
+ return failure('CODE_ERROR', 'The code installed but reported no functions.');
+ }
+ return success(names as string[]);
+ });
+}
+
+function evaluate(session: DebuggerSession, expression: string): Promise<EvaluateReply> {
+ return send<EvaluateReply>(session, 'Runtime.evaluate', {
+ expression,
+ returnByValue: true,
+ awaitPromise: true,
+ });
+}
+
+function describeThrow(thrown: NonNullable<EvaluateReply['exceptionDetails']>): string {
+ const detail = thrown.exception?.description ?? thrown.text ?? 'unknown error';
+ return detail.length > MAX_ERROR_LENGTH ? `${detail.slice(0, MAX_ERROR_LENGTH)}…` : detail;
+}
diff --git a/src/lib/bridge/invoke.ts b/src/lib/bridge/invoke.ts
index dc9b9e8..332a487 100644
--- a/src/lib/bridge/invoke.ts
+++ b/src/lib/bridge/invoke.ts
@@ -8,6 +8,7 @@ import { captureDownload } from '@/lib/actions/page/capture-download';
import { closeTab } from '@/lib/actions/page/close-tab';
import { dragElement } from '@/lib/actions/page/drag-element';
import { findCaptcha } from '@/lib/actions/page/find-captcha';
+import { injectCode } from '@/lib/actions/page/inject-code';
import { listFiles } from '@/lib/actions/page/list-files';
import { listRecordings } from '@/lib/actions/page/list-recordings';
import { monitorStatus } from '@/lib/actions/page/monitor-status';
@@ -17,6 +18,7 @@ import { pickElement } from '@/lib/actions/page/pick-element';
import { readConsole } from '@/lib/actions/page/read-console';
import { readNetwork } from '@/lib/actions/page/read-network';
import { readRecording } from '@/lib/actions/page/read-recording';
+import { runCode } from '@/lib/actions/page/run-code';
import { screenshot } from '@/lib/actions/page/screenshot';
import { searchSite } from '@/lib/actions/page/search-site';
import { solveCaptcha } from '@/lib/actions/page/solve-captcha';
@@ -33,6 +35,7 @@ import { failure, success, type ActionResult } from '@/lib/actions/protocol';
import { EXPIRED_MESSAGE, REFUSED_MESSAGE } from '@/lib/secrets';
import { releaseForAction, sealForPage } from '@/lib/bridge/secret-vault';
import { findCaptchaInTab, solveCaptchaInTab } from '@/lib/bridge/captcha';
+import { installToolkit, runToolkit } from '@/lib/bridge/code-toolkit';
import { captureFromPage } from '@/lib/bridge/downloads';
import { listMeta, readBytes } from '@/lib/bridge/file-store';
import {
@@ -128,6 +131,8 @@ async function dispatch(
if (action === pickElement.name) return pickInTab({ id: tab.id, windowId: tab.windowId }, input);
if (action === attachFile.name) return attachStoredFile(tab.id, input);
if (action === captureDownload.name) return captureFromPage(tab.id, input);
+ if (action === injectCode.name) return installToolkit(tab.id, tab.url, input);
+ if (action === runCode.name) return runToolkit(tab.id, tab.url, input);
if (action === trustedClick.name) return trustedClickInTab(tab.id, input);
if (action === dragElement.name && isTrustedDrag(input)) return dragInTab(tab.id, input);
if (action === findCaptcha.name) return findCaptchaInTab(tab.id);
diff --git a/src/lib/bridge/redact.ts b/src/lib/bridge/redact.ts
index 5984032..d51aa5a 100644
--- a/src/lib/bridge/redact.ts
+++ b/src/lib/bridge/redact.ts
@@ -32,6 +32,15 @@ const TYPED_FIELD: Record<string, string> = {
'page.typeText': 'text',
};
+/**
+ * Fields the panel has to show whole. An approval that asks someone to read code cannot
+ * hand them the first two hundred characters of it, so these skip the length cap — which
+ * is also why the code must never carry a secret: this is the field that is shown.
+ */
+const VERBATIM_FIELDS: Record<string, readonly string[]> = {
+ 'page.injectCode': ['purpose', 'code'],
+};
+
/**
* A sealed handle is safe to show and worth showing: it names the kind of credential and
* the site it was read on, which is exactly what someone answering a `secret-release`
@@ -40,6 +49,10 @@ const TYPED_FIELD: Record<string, string> = {
export function redactInput(action: string, input: unknown): unknown {
if (!input || typeof input !== 'object') return redactValue('', input, 0);
const redacted = redactValue('', input, 0) as Record<string, unknown>;
+ for (const field of VERBATIM_FIELDS[action] ?? []) {
+ const original = (input as Record<string, unknown>)[field];
+ if (typeof original === 'string') redacted[field] = original;
+ }
const typed = TYPED_FIELD[action];
if (typed && typed in redacted) {
const typedValue = (input as Record<string, unknown>)[typed];
diff --git a/src/lib/bridge/run-port.ts b/src/lib/bridge/run-port.ts
index ee418a4..24efb56 100644
--- a/src/lib/bridge/run-port.ts
+++ b/src/lib/bridge/run-port.ts
@@ -74,7 +74,7 @@ const PERSIST_DEBOUNCE_MS = 800;
const MAX_EXTERNAL_ITEMS = 100;
export type RunCommand =
- | { op: 'instruct'; text: string; tab: TabAnchor; agentSkillId?: string; focus?: FocusedElement }
+ | { op: 'instruct'; text: string; tab: TabAnchor; agentSkillId?: string; focus?: FocusedElement; liveTools?: boolean }
| { op: 'cancel'; sessionId: string }
| { op: 'decision'; sessionId: string; toolId: string; allow: boolean; remember?: boolean }
| { op: 'endSession'; sessionId: string }
@@ -226,7 +226,7 @@ export function closePanels(): void {
function handle(command: RunCommand): void {
switch (command.op) {
case 'instruct':
- void serialized(() => instruct(command.text, command.tab, command.agentSkillId, command.focus));
+ void serialized(() => instruct(command.text, command.tab, command.agentSkillId, command.focus, command.liveTools));
return;
case 'cancel':
void serialized(() => stopRun(command.sessionId));
@@ -346,6 +346,7 @@ async function instruct(
anchor: TabAnchor,
agentSkillId?: string,
focus?: FocusedElement,
+ liveTools?: boolean,
): Promise<void> {
const ensured = await ensureSessionForTab(anchor);
if (!ensured.ok) {
@@ -365,7 +366,7 @@ async function instruct(
return;
}
- const outcome = await startTurn(ensured.session, text, { agentSkillId, focus, fastPath: true });
+ const outcome = await startTurn(ensured.session, text, { agentSkillId, focus, liveTools, fastPath: true });
if (outcome !== 'busy') return;
await append(
ensured.session.sessionId,
@@ -378,9 +379,9 @@ type TurnOutcome = 'started' | 'local' | 'busy' | 'offline';
async function startTurn(
session: TabSession,
text: string,
- options: { agentSkillId?: string; focus?: FocusedElement; fastPath: boolean },
+ options: { agentSkillId?: string; focus?: FocusedElement; liveTools?: boolean; fastPath: boolean },
): Promise<TurnOutcome> {
- const { agentSkillId, focus, fastPath } = options;
+ const { agentSkillId, focus, liveTools, fastPath } = options;
const { sessionId } = session;
if (session.runId || busy.has(sessionId)) return 'busy';
@@ -404,6 +405,7 @@ async function startTurn(
agentSessionId: session.agentSessionId,
agentSkillId,
focus,
+ liveTools,
files: await attachedFiles(),
recordings: await attachedRecordings(),
});
diff --git a/src/lib/bridge/use-run.ts b/src/lib/bridge/use-run.ts
index df9c76c..494c167 100644
--- a/src/lib/bridge/use-run.ts
+++ b/src/lib/bridge/use-run.ts
@@ -19,6 +19,7 @@ export type { RunItem };
export interface SendOptions {
agentSkillId?: string;
focus?: FocusedElement;
+ liveTools?: boolean;
}
export interface Run {
@@ -166,6 +167,7 @@ export function useRun(): Run {
text: trimmed,
agentSkillId: opts?.agentSkillId,
focus: opts?.focus,
+ liveTools: opts?.liveTools,
tab: { tabId: tab.tabId, url: tab.url, windowId: tab.windowId, title: tab.title },
});
},