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.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
feat(extension): leave the nine debugger-only tools off a Firefox build's list, and serve each paired browser its own list, because an agent there paid every turn for schemas it could only fail with
Shahriar6123ce6db993
diff --git a/docs/guide/features/diagnostics.md b/docs/guide/features/diagnostics.mdindex f5c3ff0..63549d7 100644--- a/docs/guide/features/diagnostics.md+++ b/docs/guide/features/diagnostics.md@@ -125,8 +125,9 @@ means no bodies regardless of policy.with `DEBUGGER_UNAVAILABLE` and a hint saying so — which is annoying precisely because it is the momenta developer is most likely to ask. Close DevTools and retry.-**Firefox has none of this.** There is no CDP, so all four tools return `UNSUPPORTED`. The same is true-of `page_trustedClick` and the captcha tools.+**Firefox has none of this.** There is no CDP, so a Firefox build leaves all four tools off the list it+offers, along with `page_trustedClick`, the captcha tools and the page-code tools. An older+instruction that still names one gets `UNSUPPORTED`.**Top-level frame only.** What a cross-origin iframe logs to its own console is not collected.diff --git a/docs/guide/limits.md b/docs/guide/limits.mdindex 81b4680..8038acc 100644--- a/docs/guide/limits.md+++ b/docs/guide/limits.md@@ -99,12 +99,14 @@ Full-page capture stitches viewport tiles, capped at 48 tiles and a 16 384 px cathat the bottom is cut off and the result reports `truncated: true`, rather than silently returninga partial image.-## Six tools need Chrome's debugger, and Firefox has none--`page_trustedClick`, the two captcha tools and the four-[diagnostics](features/diagnostics.md) tools are built on the Chrome DevTools Protocol, which-Firefox does not expose. They return `UNSUPPORTED` there, with a hint, and there is no fallback for-the diagnostics ones — a page's console and network activity are not reachable any other way.+## Nine tools need Chrome's debugger, and Firefox has none++`page_trustedClick`, the two captcha tools, the four [diagnostics](features/diagnostics.md) tools+and the two [page-code](features/page-actions.md) tools are built on the Chrome DevTools Protocol,+which Firefox does not expose. A Firefox build leaves them off the list it offers, so an agent+running there never sees them and the daemon reports the shorter list as in sync. A stale skill or+recording that still names one gets `UNSUPPORTED`, with a hint. There is no fallback for the+diagnostics ones — a page's console and network activity are not reachable any other way.On Chrome they carry two visible costs: Chrome shows a **"Browsentic is debugging this browser"**bar for as long as a debugger is attached, and attaching **fails while DevTools is open** on thatdiff --git a/docs/internals/extension.md b/docs/internals/extension.mdindex f367122..cc5dbe3 100644--- a/docs/internals/extension.md+++ b/docs/internals/extension.md@@ -18,6 +18,15 @@ Not every capability can run in the page. The background service worker splits t| `openTab`, `switchTab`, `closeTab`, `screenshot`, `navigate` | Need the `tabs`/`scripting` APIs || Everything else | Forwarded to the content script |+Nine of those need Chrome's `debugger` API, which Firefox has no counterpart for: `trustedClick`,+the two captcha tools, the four diagnostics tools, `injectCode` and `runCode`. Each is marked+`chromiumOnly` in its module, and `describeActions('firefox')` leaves them out, so a Firefox build+never lists them — the agent there is offered a shorter list, and the daemon knows that list by its+hash and reports it as in sync. The actions themselves stay registered on both builds: a stale+skill that names one is answered with `UNSUPPORTED` and a hint, not `UNKNOWN_ACTION`. The+build-time branch lives in one place, `describeOwnActions()` in `src/lib/bridge/own-actions.ts`;+the registry itself never reads `import.meta.env`, because the daemon bundles it under Node.+## The microphone is granted from a tabChromium anchors a permission prompt to a tab. A side panel and a popup have none, sodiff --git a/docs/internals/transport.md b/docs/internals/transport.mdindex 5b16043..eebb542 100644--- a/docs/internals/transport.md+++ b/docs/internals/transport.md@@ -68,7 +68,12 @@ The extension connects to nothing until you pair it.three ports, and sends `hello` — which names *which* secret it holds and a fresh nonce, never thesecret itself.3. The daemon answers `challenge` with a nonce of its own. Both sides now share a transcript:- protocol version, extension version, manifest hash, and the two nonces.+ protocol version, extension version, manifest hash, and the two nonces. The manifest hash+ names the tool list this build offers — a Chromium build's or a Firefox build's, which leaves+ off the nine tools that need Chrome's debugger. The daemon knows both lists and serves the one+ the hash names; an unknown hash is a drifted build, which is asked for its list and served+ that. Either way the list belongs to that browser alone: a run is offered its own browser's+ tools, and a caller outside any run is offered those of the browser its next call would reach.4. The extension replies `prove` with `HMAC(secret, "browsentic/client" ‖ transcript)`. For apairing code the key is not the code but `PBKDF2(code, nonces, 250 000)`, so recording onehandshake does not let anyone grind an 8-character code offline.diff --git a/docs/reference/errors.md b/docs/reference/errors.mdindex 438d6c0..2b074b9 100644--- a/docs/reference/errors.md+++ b/docs/reference/errors.md@@ -46,7 +46,7 @@ repeatedly: failures carry the *fix* in the message, and a failed tool call neve| `DIAGNOSTICS_IN_PROGRESS` | Extension | That tab is already being recorded. Read it, or stop it first || `DIAGNOSTICS_LIMIT` | Extension | Two tabs are already being recorded — stop one || `DEBUGGER_UNAVAILABLE` | Extension | Chrome refused the attach, usually because DevTools is open on that tab. Close it and retry |-| `UNSUPPORTED` | Extension | Firefox exposes no CDP, so the diagnostics tools do not exist there — and there is no fallback |+| `UNSUPPORTED` | Extension | A debugger-only tool was called on Firefox. A Firefox build leaves those nine off its list, so only a stale skill or recording reaches this — and there is no fallback || `BLOCKED` | Policy | `includeBodies: true` without the `network-body-read` rule allowed. Metadata and headers are still available |## Runs and sessionsdiff --git a/docs/reference/tools.md b/docs/reference/tools.mdindex 9a44a29..1020130 100644--- a/docs/reference/tools.md+++ b/docs/reference/tools.md@@ -269,8 +269,8 @@ selector can reach — inside a cross-origin iframe or a closed shadow root —The click is dispatched through Chrome's debugger rather than from the page, so the browser shows a"Browsentic is debugging this browser" bar for the duration, the tool fails with-`DEBUGGER_UNAVAILABLE` on a tab that already has DevTools attached, and it is `UNSUPPORTED` on-Firefox. The extension resolves the click point *after* attaching, so the bar's own reflow is+`DEBUGGER_UNAVAILABLE` on a tab that already has DevTools attached, and a Firefox build leaves it+off its tool list. The extension resolves the click point *after* attaching, so the bar's own reflow isaccounted for, and refuses with `INVALID_TARGET` when something covers that point rather thanclicking whatever is on top. The result adds `trusted: true` and the viewport `point` that wasclicked.@@ -374,7 +374,7 @@ The drop point is measured before the drag starts, so a list that reflows as theit can land a slot out — raise `steps` and `settleMs`, then read `landedOn` back.`trusted: true` routes through Chrome's debugger like [page_trustedClick](#page_trustedclick), with-the same costs: the debugging bar appears, DevTools must be closed, and Firefox is unsupported. It+the same costs: the debugging bar appears, DevTools must be closed, and on Firefox it is `UNSUPPORTED`. Itcannot drive HTML5 drag-and-drop, so it is refused with `INVALID_INPUT` when the mechanism resolvesto `native`.@@ -490,8 +490,8 @@ into it, and only its arguments change. There is deliberately no "always on thisinjection: 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.+browser" bar for the moment it takes, and it fails on a tab with DevTools open; a Firefox build+leaves both tools off its list. The calls afterwards use an ordinary event bridge and show nothing.### page_injectCode@@ -739,7 +739,7 @@ Calls do not stack — each replaces the last, so re-applying with adjusted numbWhat the page **reports** rather than what it renders: `page_startDiagnostics` attaches Chrome'sdebugger and starts buffering, `page_readConsole` and `page_readNetwork` read the buffers, and-`page_stopDiagnostics` detaches. Chrome only — all four return `UNSUPPORTED` on Firefox.+`page_stopDiagnostics` detaches. Chrome only — a Firefox build leaves all four off its tool list.Console and network events are delivered only while attached and are not kept anywhere otherwise, so**start the recording before the thing you are diagnosing happens**. Chrome shows a "Browsentic isdiff --git a/src/daemon/daemon.ts b/src/daemon/daemon.tsindex a1b2481..a3f1134 100644--- a/src/daemon/daemon.ts+++ b/src/daemon/daemon.ts@@ -16,7 +16,7 @@ import {type SocketFrame,} from '@/lib/actions/protocol';import type { GuardrailSettings } from '@/lib/settings/guardrails';-import { hashManifest } from '@/lib/actions/manifest';+import { hashManifest, type ToolDescriptor } from '@/lib/actions/manifest';import { describeActions } from '@/lib/actions/registry';import { RESERVED_PREFIX } from '@/lib/actions/reserved';import { AGENTS, isAgentKind, type AgentState } from '@/lib/agents/catalog';@@ -151,10 +151,16 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):const swept = sweepDownloads();if (swept) log(`swept ${swept} expired download${swept === 1 ? '' : 's'}`);- const bundled = describeActions();+ const bundled = describeActions('chromium');const bundledHash = hashManifest(bundled);-- let tools = bundled;+ const bundledByHash = new Map(+ (['chromium', 'firefox'] as const).map((target) => {+ const list = describeActions(target);+ return [hashManifest(list), list] as const;+ }),+ );++ let offered = bundled;const links = new Map<string, ExtensionLink>();const agents = new Map<ExtensionLink, AgentSession>();const controls = new Set<WebSocket>();@@ -340,7 +346,8 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):): Promise<void> {// Only the same browser profile is superseded: its worker restarted and the old socket lingers.links.get(install.installId)?.close('superseded by a newer connection');- const manifestInSync = hello.manifestHash === bundledHash;+ const known = bundledByHash.get(hello.manifestHash);+ const manifestInSync = known !== undefined;const accepted = new ExtensionLink(ws,{ ...hello, ...install },@@ -350,6 +357,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):if (links.get(closing.id) === closing) links.delete(closing.id);log(`${closing.label} disconnected`);scheduleIdleExit();+ settleOffer();},(request, source) => {if (request.t === 'analyzeFile') {@@ -428,14 +436,20 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):},);links.set(accepted.id, accepted);+ accepted.tools = known ?? bundled;+ settleOffer();log(`extension ${hello.extensionVersion} connected from ${accepted.label} (manifest ${manifestInSync ? 'in sync' : 'DRIFTED'})`);- const welcome = { daemonVersion: version, manifestHash: bundledHash, manifestInSync, sealedSessionKey };+ const welcome = {+ daemonVersion: version,+ manifestHash: known ? hello.manifestHash : bundledHash,+ manifestInSync,+ sealedSessionKey,+ };accepted.send({ t: 'welcome', ...welcome, proof: await serverProof(secret, transcript, welcome) });scheduleIdleExit();void pushAgentState(accepted);pushSkillCatalog(accepted);- if (!manifestInSync) await adoptExtensionManifest(accepted);- else if (openLinks().every(inSync)) restoreBundledManifest();+ if (!known) await adoptExtensionManifest(accepted);}function openLinks(): ExtensionLink[] {@@ -443,7 +457,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):}function inSync(link: ExtensionLink): boolean {- return link.manifestHash === bundledHash;+ return bundledByHash.has(link.manifestHash);}/** The browser the user was last in, for a caller that has no run to say which one it means. */@@ -548,30 +562,35 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):return [...agents.values()].find((agent) => agent.owns(runId));}+ // A drifted build is served its own list, and only its own: the adopted list lives on the+ // link and leaves with it, so a browser that agrees with us again is back on a bundled list+ // the moment it reconnects — the recovery direction of "the newer side wins".async function adoptExtensionManifest(source: ExtensionLink): Promise<void> {const reported = await source.describe();if (!reported?.length) {- log('extension manifest drifted but could not be fetched; keeping the bundled tool list');+ log(`${source.label} drifted but its manifest could not be fetched; serving it the bundled tool list`);return;}- tools = reported;- log(`adopted ${reported.length} tools from the extension (bundled list was ${bundled.length})`);- announceManifest();+ source.tools = reported;+ log(`adopted ${reported.length} tools from ${source.label} (bundled list was ${bundled.length})`);+ settleOffer();}- // An adopted list outlives the connection that justified it, so a reloaded extension that- // agrees with us again would otherwise keep being served the drifted list until the daemon- // restarts — the recovery direction of "the newer side wins".- function restoreBundledManifest(): void {- if (tools === bundled) return;- tools = bundled;- log(`extension back in sync; serving the bundled ${bundled.length} tools again`);- announceManifest();+ /** What a caller with no run of its own is offered: the list of the browser the user was last in. */+ function offeredTools(): ToolDescriptor[] {+ return activeLink()?.tools ?? bundled;}- function announceManifest(): void {- for (const listener of manifestListeners) listener();- broadcast({ event: 'manifest-changed' });+ // A browser's worker restarting closes one link and opens another in the same tick, so the+ // comparison waits for the tick to end rather than announcing a change that has already undone itself.+ function settleOffer(): void {+ setImmediate(() => {+ const now = offeredTools();+ if (now === offered) return;+ offered = now;+ for (const listener of manifestListeners) listener();+ broadcast({ event: 'manifest-changed' });+ });}/**@@ -586,10 +605,16 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):return target;}- function describeFor(runId?: string): Described {- const offer = runId ? sessionRunning(runId)?.offerFor(runId) : null;- if (offer) return { tools: tools.filter(({ name }) => !offer.withheld.includes(name)), reserved: offer.reserved };+ // A tool list belongs to a browser. A run is offered the list of the browser it runs in; a+ // caller with no run is offered the browser its next call would reach, so list and calls agree.+ function describeFor(runId: string | undefined, binding: Binding): Described {+ const running = runId ? [...agents].find(([, agent]) => agent.owns(runId)) : undefined;+ const offer = running && runId ? running[1].offerFor(runId) : null;+ if (offer && running) {+ return { tools: running[0].tools.filter(({ name }) => !offer.withheld.includes(name)), reserved: offer.reserved };+ }+ const tools = routeFor(binding)?.tools ?? bundled;const config = readAgentConfig();const policy = policyFrom(config.guardrails, config.requireApproval);const denied = (action: string) =>@@ -612,7 +637,9 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):} catch {return log('dropped unparseable control frame');}- if (request.op === 'describe') return send(ws, { id: request.id, op: 'describe', ...describeFor(request.runId) });+ if (request.op === 'describe') {+ return send(ws, { id: request.id, op: 'describe', ...describeFor(request.runId, binding) });+ }if (request.op === 'status') {return send(ws, { id: request.id, op: 'status', status: statusNow(routeFor(binding)) });}@@ -787,7 +814,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):const local: Binding = { usedAt: 0 };return {port,- describe: async () => describeFor(),+ describe: async () => describeFor(undefined, local),invoke: (action, input) => invokeOn(routeFor(local), action, input),status: async () => statusNow(routeFor(local)),onManifestChanged: (listener) => manifestListeners.add(listener),diff --git a/src/daemon/extension-link.ts b/src/daemon/extension-link.tsindex b937e20..cc766b3 100644--- a/src/daemon/extension-link.ts+++ b/src/daemon/extension-link.ts@@ -33,6 +33,8 @@ export class ExtensionLink {readonly browser?: string;/** Which connected browser the user was last in, so a caller that names none reaches that one. */lastActiveAt = Date.now();+ /** What this browser offers: a Firefox build lists fewer tools than a Chromium one, and a drifted build its own. */+ tools: ToolDescriptor[] = [];private readonly pending = new Map<string, Pending>();private readonly ping: ReturnType<typeof setTimeout>;private closed = false;diff --git a/src/daemon/skills/browser-control.md b/src/daemon/skills/browser-control.mdindex 9c0b853..13a5eac 100644--- a/src/daemon/skills/browser-control.md+++ b/src/daemon/skills/browser-control.md@@ -30,7 +30,7 @@ Visible text survives redesigns that break CSS paths, so prefer it. Fall back toAfter anything that changes the page, check that it landed. `page_waitForElement` for the state you expect next is the direct way; a fresh `page_getPageInfo` works when you are not sure what to expect. A click that silently did nothing looks exactly like a click that worked, until you look.-When a click verifiably did nothing — the dialog never opened, the file picker never appeared, the page has a handler that checks `event.isTrusted` — `page_trustedClick` is the fallback. It sends a real browser-level mouse event through Chrome's debugger, so the browser shows a "Browsentic is debugging this browser" bar while it runs and it refuses on a tab with DevTools open (`DEBUGGER_UNAVAILABLE` — say so and fall back). It takes the same `target`, plus `button` for a right-click, `clickCount: 2` for a double click and `modifiers` like `["meta"]`. The pointer travels to the target and dwells before pressing, so widgets that only react after real pointer movement get the sequence they wait for. It is slower and visibly intrusive, so `page_clickElement` stays the default: reach for the trusted one only after an ordinary click has already failed.+When a click verifiably did nothing — the dialog never opened, the file picker never appeared, the page has a handler that checks `event.isTrusted` — `page_trustedClick` is the fallback, when it is in your tool list (a Firefox build has no such tool; say so and ask the user to make that click). It sends a real browser-level mouse event through Chrome's debugger, so the browser shows a "Browsentic is debugging this browser" bar while it runs and it refuses on a tab with DevTools open (`DEBUGGER_UNAVAILABLE` — say so and fall back). It takes the same `target`, plus `button` for a right-click, `clickCount: 2` for a double click and `modifiers` like `["meta"]`. The pointer travels to the target and dwells before pressing, so widgets that only react after real pointer movement get the sequence they wait for. It is slower and visibly intrusive, so `page_clickElement` stays the default: reach for the trusted one only after an ordinary click has already failed.A page stuck on "verifying you are human" is a different problem and neither click tool solves it — the checkbox is inside a closed shadow root inside a cross-origin iframe, so no selector reaches it. Use `page_findCaptcha` and `page_solveCaptcha`; the **captcha** skill covers the whole path, including handing an image challenge back to the user.diff --git a/src/daemon/skills/captcha.md b/src/daemon/skills/captcha.mdindex 926c5a4..6a1533c 100644--- a/src/daemon/skills/captcha.md+++ b/src/daemon/skills/captcha.md@@ -42,6 +42,6 @@ The user is sitting at this browser. Handing them ten seconds of clicking is a n`DEBUGGER_UNAVAILABLE` means Chrome's debugger could not attach — almost always DevTools being open on that tab. Tell the user to close DevTools and retry; there is no fallback, because reading a closed shadow root is exactly what the debugger is for.-`UNSUPPORTED` means Firefox, which does not expose a debugger to extensions. Neither tool works there. Say so and ask the user to deal with the captcha themselves.+A Firefox build has neither tool: it exposes no debugger to extensions, so they are left off its tool list rather than offered to fail. If they are not in your list, do not go looking for them — say so and ask the user to deal with the captcha themselves. `UNSUPPORTED` means the same thing when an older instruction or recording still names one.Both are terminal conditions. Report them and move on to whatever else the task needs.diff --git a/src/daemon/skills/page-diagnostics.md b/src/daemon/skills/page-diagnostics.mdindex dc7ad33..6fce3db 100644--- a/src/daemon/skills/page-diagnostics.md+++ b/src/daemon/skills/page-diagnostics.md@@ -40,7 +40,7 @@ A busy page logs hundreds of lines and makes hundreds of requests, and almost no## What you will not get- **Response bodies are refused by default.** `includeBodies` comes back `BLOCKED`, because a response body carries session tokens and other people's personal data wholesale. Status, timing, headers and the browser's own error text answer nearly every real question. If the user genuinely needs bodies they can allow `network-body-read` in the guardrail settings; ask, do not push.-- **Firefox has no CDP**, so all four tools return `UNSUPPORTED` there. There is no fallback — say so plainly.+- **Firefox has no CDP**, so a Firefox build leaves all four tools off its list. If they are not among your tools there is no fallback — say so plainly rather than searching for them. `UNSUPPORTED` means the same when an older instruction still names one.- **DevTools wins.** If the user has DevTools open on that tab, attaching fails with `DEBUGGER_UNAVAILABLE`. Ask them to close it and try again.## Answeringdiff --git a/src/daemon/skills/page-scripting.md b/src/daemon/skills/page-scripting.mdindex d521e0a..e21d8cc 100644--- a/src/daemon/skills/page-scripting.md+++ b/src/daemon/skills/page-scripting.md@@ -17,6 +17,8 @@ Reach for it in exactly two situations: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.+Installing needs Chrome's debugger, so a Firefox build leaves `page_injectCode` and `page_runCode` off its tool list. If they are not among your tools, the loop is done with the ordinary tools, and this skill's advice does not apply.+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 toolkitdiff --git a/src/daemon/test/browsers.test.ts b/src/daemon/test/browsers.test.tsindex b3b55ce..981ffe2 100644--- a/src/daemon/test/browsers.test.ts+++ b/src/daemon/test/browsers.test.ts@@ -11,6 +11,23 @@ import { FakeBrowser, type Profile } from './fake-browser';const unpacked = 'chrome-extension://abcdefghijklmnopabcdefghijklmnop';const chrome: Profile = { origin: unpacked, installId: 'install-chrome-0001', browser: 'Google Chrome' };const brave: Profile = { origin: unpacked, installId: 'install-brave-00001', browser: 'Brave' };+const firefox: Profile = {+ origin: 'moz-extension://0f1e2d3c-4b5a-6978-8796-a5b4c3d2e1f0',+ installId: 'install-firefox-001',+ browser: 'Firefox',+ target: 'firefox',+};+// The nine tools a Firefox build leaves off, less the two page-code tools the default guardrails+// already keep from any caller outside a run.+const DEBUGGER_ONLY = [+ 'page.findCaptcha',+ 'page.readConsole',+ 'page.readNetwork',+ 'page.solveCaptcha',+ 'page.startDiagnostics',+ 'page.stopDiagnostics',+ 'page.trustedClick',+];let daemon: Daemon;let opened: { close(): unknown }[] = [];@@ -157,6 +174,44 @@ describe('a caller outside any browser', () => {});});+describe('the tool list a caller is offered', () => {+ const offeredTo = async (bridge: RemoteBridge) => (await bridge.describe()).tools.map(({ name }) => name);++ test("is the list of the browser it would reach: Firefox's without the debugger tools, Chrome's whole", async () => {+ const fox = await pair(firefox);+ const second = await pair(chrome);+ await settled();+ await fox.focus();+ const viaFirefox = await control();+ const [foxTools, foxStatus] = [await offeredTo(viaFirefox), await viaFirefox.status()];+ await second.focus();+ const chromeTools = await offeredTo(await control());+ expect([+ foxStatus.manifestInSync,+ chromeTools.filter((name) => !foxTools.includes(name)).sort(),+ foxTools.filter((name) => !chromeTools.includes(name)),+ ]).toEqual([true, DEBUGGER_ONLY, []]);+ });++ test('a drifted build is served what it reports, and only it', async () => {+ const drifted: Profile = { ...brave, tools: [{ name: 'page.onlyHere', description: 'from a build we never saw', inputSchema: {} }] };+ const odd = await pair(drifted);+ const second = await pair(chrome);+ await settled();+ await odd.focus();+ const viaDrifted = await control();+ const [oddTools, oddStatus] = [await offeredTo(viaDrifted), await viaDrifted.status()];+ await second.focus();+ const chromeTools = await offeredTo(await control());+ expect([oddStatus.manifestInSync, oddTools, chromeTools.includes('page.onlyHere'), chromeTools.includes('page.getPageInfo')]).toEqual([+ false,+ ['page.onlyHere'],+ false,+ true,+ ]);+ });+});+describe('a browser paired before install ids', () => {test('returns on the key it already holds and is known by its install id from then on', async () => {const key = 'k'.repeat(43);diff --git a/src/daemon/test/fake-browser.ts b/src/daemon/test/fake-browser.tsindex 459275d..5f29f49 100644--- a/src/daemon/test/fake-browser.ts+++ b/src/daemon/test/fake-browser.ts@@ -1,14 +1,18 @@import { randomUUID } from 'node:crypto';import WebSocket from 'ws';import { clientProof, newNonce, openSessionKey, pairingSecret, type Transcript } from '@/lib/actions/handshake';-import { hashManifest } from '@/lib/actions/manifest';+import { hashManifest, type ToolDescriptor } from '@/lib/actions/manifest';import { SOCKET_PROTOCOL_VERSION, parseFrame, type SocketFrame } from '@/lib/actions/protocol';-import { describeActions } from '@/lib/actions/registry';+import { describeActions, type BrowserTarget } from '@/lib/actions/registry';export interface Profile {origin: string;installId: string;browser?: string;+ /** Which build this browser runs; a Firefox build offers fewer tools. */+ target?: BrowserTarget;+ /** What a drifted build reports instead of the registry's list. */+ tools?: ToolDescriptor[];}export type Credential = { kind: 'pair'; code: string } | { kind: 'session'; key: string };@@ -25,9 +29,11 @@ export class FakeBrowser {private readonly socket: WebSocket,readonly profile: Profile,readonly sessionKey: string,+ backlog: (SocketFrame | null)[],) {this.closed = new Promise((resolve) => socket.once('close', (_code, reason) => resolve(String(reason))));socket.on('message', (raw) => this.receive(parseFrame(String(raw))));+ for (const frame of backlog) this.receive(frame);}static async connect(port: number, profile: Profile, credential: Credential): Promise<FakeBrowser> {@@ -35,7 +41,7 @@ export class FakeBrowser {const inbox = frames(socket);await new Promise((resolve, reject) => socket.once('open', resolve).once('error', reject));- const hello = { extensionVersion: EXTENSION_VERSION, manifestHash: hashManifest(describeActions()), nonce: newNonce() };+ const hello = { extensionVersion: EXTENSION_VERSION, manifestHash: hashManifest(toolsOf(profile)), nonce: newNonce() };send(socket, {t: 'hello',protocolVersion: SOCKET_PROTOCOL_VERSION,@@ -60,9 +66,10 @@ export class FakeBrowser {const verdict = await inbox.next();if (verdict?.t === 'unauthorized') throw new Error(verdict.reason);if (verdict?.t !== 'welcome') throw new Error(`expected a welcome, got ${verdict?.t}`);- inbox.stop();const minted = verdict.sealedSessionKey ? await openSessionKey(secret, transcript, verdict.sealedSessionKey) : null;- return new FakeBrowser(socket, profile, minted ?? secret);+ // The daemon asks a drifted build for its manifest right behind the welcome, so whatever+ // arrived while the key was being opened is handed over rather than dropped.+ return new FakeBrowser(socket, profile, minted ?? secret, inbox.stop());}get isOpen(): boolean {@@ -87,17 +94,23 @@ export class FakeBrowser {this.pongs.get(frame.id)?.();this.pongs.delete(frame.id);}+ if (frame?.t === 'describe') return send(this.socket, { t: 'manifest', id: frame.id, tools: toolsOf(this.profile) });if (frame?.t !== 'invoke') return;this.invoked.push(frame.action);send(this.socket, { t: 'result', id: frame.id, result: { ok: true, data: { answeredBy: this.profile.installId } } });}}+function toolsOf(profile: Profile): ToolDescriptor[] {+ return profile.tools ?? describeActions(profile.target);+}+function send(socket: WebSocket, frame: SocketFrame): void {socket.send(JSON.stringify(frame));}-function frames(socket: WebSocket): { next(): Promise<SocketFrame | null>; stop(): void } {+/** Frames in arrival order while the handshake runs; `stop` returns whatever was never read. */+function frames(socket: WebSocket): { next(): Promise<SocketFrame | null>; stop(): (SocketFrame | null)[] } {const queued: (SocketFrame | null)[] = [];const waiting: ((frame: SocketFrame | null) => void)[] = [];const deliver = (frame: SocketFrame | null) => (waiting.length ? waiting.shift()!(frame) : void queued.push(frame));@@ -106,6 +119,9 @@ function frames(socket: WebSocket): { next(): Promise<SocketFrame | null>; stop(socket.on('message', onMessage).once('close', onClose);return {next: () => (queued.length ? Promise.resolve(queued.shift()!) : new Promise((resolve) => waiting.push(resolve))),- stop: () => void socket.off('message', onMessage).off('close', onClose),+ stop: () => {+ socket.off('message', onMessage).off('close', onClose);+ return queued.splice(0);+ },};}diff --git a/src/extension/entrypoints/background.ts b/src/extension/entrypoints/background.tsindex 1992959..b766051 100644--- a/src/extension/entrypoints/background.ts+++ b/src/extension/entrypoints/background.ts@@ -1,6 +1,6 @@import { failure, isBridgeRequest, success } from '@/lib/actions/protocol';-import { describeActions } from '@/lib/actions/registry';import { injectContentScript } from '@/lib/actions/client';+import { describeOwnActions } from '@/lib/bridge/own-actions';import { invokeForHarness } from '@/lib/bridge/invoke';import { serveDebuggerEvents } from '@/lib/bridge/cdp';import { serveCodeToolkits } from '@/lib/bridge/code-toolkit';@@ -42,7 +42,7 @@ export default defineBackground(() => {browser.runtime.onMessage.addListener((message, sender, sendResponse) => {if (!isBridgeRequest(message)) return;if (message.op === 'describe') {- sendResponse(success(describeActions()));+ sendResponse(success(describeOwnActions()));return;}if (message.op === 'invoke' && typeof message.action === 'string') {diff --git a/src/lib/actions/core.ts b/src/lib/actions/core.tsindex 5bdc5e4..23c80de 100644--- a/src/lib/actions/core.ts+++ b/src/lib/actions/core.ts@@ -5,6 +5,8 @@ export interface Action<Input extends z.ZodType = z.ZodType, Output = unknown> {readonly description: string;readonly input: Input;readonly execute: (input: z.output<Input>) => Output | Promise<Output>;+ /** Needs Chrome's debugger, which Firefox has no counterpart for, so a Firefox build leaves it off the list it offers. */+ readonly chromiumOnly?: true;}export type AnyAction = Action<any, any>;diff --git a/src/lib/actions/page/find-captcha.ts b/src/lib/actions/page/find-captcha.tsindex 23a0b04..db1c951 100644--- a/src/lib/actions/page/find-captcha.ts+++ b/src/lib/actions/page/find-captcha.ts@@ -3,6 +3,7 @@ import { ActionError, defineAction } from '../core';export const findCaptcha = defineAction({name: 'page.findCaptcha',+ chromiumOnly: true,description:'Look for a captcha on the page and report what it is, without touching it. Ordinary selectors cannot see one: vendors build the widget inside a closed shadow root holding a cross-origin iframe holding another shadow root, so page.getPageInfo shows nothing where the captcha visibly is. This reads through all of that with Chrome’s debugger and reports the vendor (Cloudflare Turnstile, reCAPTCHA v2/v3, hCaptcha, GeeTest, Arkose, AWS WAF), the widget’s on-screen bounds, whether it is already satisfied, and a viewport point for its checkbox when it has one. Read-only — it never clicks. Call it when a page stalls on “verifying you are human”, refuses a form for no visible reason, or shows a checkbox no selector can find. Chrome only, and it briefly shows the “Browsentic is debugging this browser” bar.',input: z.object({}),diff --git a/src/lib/actions/page/inject-code.ts b/src/lib/actions/page/inject-code.tsindex 6c11712..99c8191 100644--- a/src/lib/actions/page/inject-code.ts+++ b/src/lib/actions/page/inject-code.ts@@ -5,8 +5,9 @@ export const MAX_CODE_LENGTH = 32_768;export const injectCode = defineAction({name: 'page.injectCode',+ chromiumOnly: true,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.',+ '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, and it cannot install on a tab that has DevTools open — 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()diff --git a/src/lib/actions/page/read-console.ts b/src/lib/actions/page/read-console.tsindex 0cb630d..a5aa725 100644--- a/src/lib/actions/page/read-console.ts+++ b/src/lib/actions/page/read-console.ts@@ -4,6 +4,7 @@ import { ActionError, defineAction } from '../core';export const readConsole = defineAction({name: 'page.readConsole',+ chromiumOnly: true,description:'Read the console messages and uncaught exceptions a page has reported since page.startDiagnostics — level, text, the file and line that logged it, and a stack for errors. ' +'Newest last. Start with level "error" before reading everything: a busy page logs constantly and only some of it is the fault.',diff --git a/src/lib/actions/page/read-network.ts b/src/lib/actions/page/read-network.tsindex ae35349..691b80d 100644--- a/src/lib/actions/page/read-network.ts+++ b/src/lib/actions/page/read-network.ts@@ -4,6 +4,7 @@ import { ActionError, defineAction } from '../core';export const readNetwork = defineAction({name: 'page.readNetwork',+ chromiumOnly: true,description:'Read the requests a page has made since page.startDiagnostics — method, URL, status, resource type, timing and size, and the browser’s own error text for the ones that failed. ' +'Newest last. This is how a button that “did nothing” turns into a 500 or a CORS refusal. Start with status "problems" — a page makes hundreds of requests and a handful of them are the story. ' +diff --git a/src/lib/actions/page/run-code.ts b/src/lib/actions/page/run-code.tsindex cdcf21a..6837495 100644--- a/src/lib/actions/page/run-code.ts+++ b/src/lib/actions/page/run-code.ts@@ -4,6 +4,7 @@ import { callToolkit } from './toolkit';export const runCode = defineAction({name: 'page.runCode',+ chromiumOnly: true,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({diff --git a/src/lib/actions/page/solve-captcha.ts b/src/lib/actions/page/solve-captcha.tsindex e910546..ce9706f 100644--- a/src/lib/actions/page/solve-captcha.ts+++ b/src/lib/actions/page/solve-captcha.ts@@ -3,6 +3,7 @@ import { ActionError, defineAction } from '../core';export const solveCaptcha = defineAction({name: 'page.solveCaptcha',+ chromiumOnly: true,description:'Tick a captcha’s “I am a human” checkbox with a real browser-level click and wait for the widget to settle. Works where an ordinary click cannot reach: the checkbox lives inside a closed shadow root inside a cross-origin iframe, and it only responds to genuine pointer input. Returns state "solved" when the widget accepted it. When the vendor escalates to a challenge a person has to answer — an image grid, Arkose, AWS WAF — it returns state "needsHuman" with the widget bounds and does not attempt the challenge; screenshot that region, tell the user it needs them, and poll page.findCaptcha until they are done. State "invisible" means a scoring captcha with nothing to click. Chrome only, shows the debugger bar while it runs, and it is gated for approval because it acts on another site’s security control.',input: z.object({diff --git a/src/lib/actions/page/start-diagnostics.ts b/src/lib/actions/page/start-diagnostics.tsindex 11446d7..8497764 100644--- a/src/lib/actions/page/start-diagnostics.ts+++ b/src/lib/actions/page/start-diagnostics.ts@@ -4,6 +4,7 @@ import { ActionError, defineAction } from '../core';export const startDiagnostics = defineAction({name: 'page.startDiagnostics',+ chromiumOnly: true,description:'Start recording what a page reports rather than what it shows — console messages, uncaught exceptions and every request the tab makes. ' +'Console and network events only exist while Chrome’s debugger is attached, so this has to be running before the thing you are diagnosing happens: start it, then reload or click, then read. ' +diff --git a/src/lib/actions/page/stop-diagnostics.ts b/src/lib/actions/page/stop-diagnostics.tsindex 21612cd..f1ac5f2 100644--- a/src/lib/actions/page/stop-diagnostics.ts+++ b/src/lib/actions/page/stop-diagnostics.ts@@ -3,6 +3,7 @@ import { ActionError, defineAction } from '../core';export const stopDiagnostics = defineAction({name: 'page.stopDiagnostics',+ chromiumOnly: true,description:'Detach the debugger and take Chrome’s “Browsentic is debugging this browser” bar away. What was collected stays readable by page.readConsole and page.readNetwork afterwards, minus response bodies, which only exist while attached. ' +'Call this as soon as you have what you need rather than leaving the bar up.',diff --git a/src/lib/actions/page/trusted-click.ts b/src/lib/actions/page/trusted-click.tsindex 55ea61f..eae21bb 100644--- a/src/lib/actions/page/trusted-click.ts+++ b/src/lib/actions/page/trusted-click.ts@@ -6,7 +6,8 @@ import { approachPoint, assertUncovered, elementAt, elementPoint, pointSchema, vexport const trustedClick = defineAction({name: 'page.trustedClick',description:- 'Click with a real browser-level mouse event — isTrusted is true, exactly as if the user had clicked. The pointer travels to the target over a short path and dwells before pressing, so widgets that only react after genuine pointer movement (drag handles, hover menus, canvas tools, captcha checkboxes) see the sequence they wait for. Use it when page.clickElement was ignored: pages that check event.isTrusted, and the browser features only a genuine gesture unlocks — native file pickers, fullscreen, clipboard reads, popups, WebAuthn prompts. Give it either a "target" or a raw viewport "point". It attaches Chrome’s debugger for the duration, so the browser shows a “Browsentic is debugging this browser” bar while it runs, it cannot run on a tab that has DevTools open, and it is unavailable on Firefox. page.clickElement stays the default for ordinary clicks.',+ 'Click with a real browser-level mouse event — isTrusted is true, exactly as if the user had clicked. The pointer travels to the target over a short path and dwells before pressing, so widgets that only react after genuine pointer movement (drag handles, hover menus, canvas tools, captcha checkboxes) see the sequence they wait for. Use it when page.clickElement was ignored: pages that check event.isTrusted, and the browser features only a genuine gesture unlocks — native file pickers, fullscreen, clipboard reads, popups, WebAuthn prompts. Give it either a "target" or a raw viewport "point". It attaches Chrome’s debugger for the duration, so the browser shows a “Browsentic is debugging this browser” bar while it runs, and it cannot run on a tab that has DevTools open. page.clickElement stays the default for ordinary clicks.',+ chromiumOnly: true,input: z.object({target: targetSchema.optional().describe('Element to click. Give this or "point", never both.'),point: pointSchemadiff --git a/src/lib/actions/registry.test.ts b/src/lib/actions/registry.test.tsindex 0077b4b..938e548 100644--- a/src/lib/actions/registry.test.ts+++ b/src/lib/actions/registry.test.ts@@ -1,5 +1,40 @@import { describe, expect, test } from 'vitest';-import { describeActions } from './registry';+import { actions, describeActions } from './registry';++const DEBUGGER_ONLY = [+ 'page.trustedClick',+ 'page.findCaptcha',+ 'page.solveCaptcha',+ 'page.startDiagnostics',+ 'page.readConsole',+ 'page.readNetwork',+ 'page.stopDiagnostics',+ 'page.injectCode',+ 'page.runCode',+];++const names = (tools: { name: string }[]) => tools.map(({ name }) => name);++describe('the list a build offers', () => {+ test('Chromium is offered every action', () => {+ expect(names(describeActions('chromium'))).toEqual([...actions.keys()]);+ expect(names(describeActions())).toEqual(names(describeActions('chromium')));+ });++ test("Firefox is offered everything but the tools that need Chrome's debugger", () => {+ const offered = names(describeActions('firefox'));+ const hidden = [...actions.keys()].filter((name) => !offered.includes(name));+ expect(hidden.sort()).toEqual([...DEBUGGER_ONLY].sort());+ });++ test('a hidden tool is still invocable, so a stale caller gets its own hint', () => {+ for (const name of DEBUGGER_ONLY) expect(actions.has(name)).toBe(true);+ });++ test('no description still tells Chrome about Firefox', () => {+ expect(JSON.stringify(describeActions('chromium'))).not.toContain('Firefox');+ });+});const schemaOf = (name: string) =>describeActions().find((action) => action.name === name)!.inputSchema as {diff --git a/src/lib/actions/registry.ts b/src/lib/actions/registry.tsindex ed3b3e3..5303eeb 100644--- a/src/lib/actions/registry.ts+++ b/src/lib/actions/registry.ts@@ -113,12 +113,21 @@ export const actions: ReadonlyMap<string, AnyAction> = new Map().map((action) => [action.name, action]),);-export function describeActions(): ToolDescriptor[] {- return [...actions.values()].map(({ name, description, input }) => ({- name,- description,- inputSchema: tidy(z.toJSONSchema(input, { io: 'input' })),- }));+export type BrowserTarget = 'chromium' | 'firefox';++/**+ * The tools a build of the extension offers. Every action stays invocable on either browser —+ * a stale skill that names a hidden one gets its UNSUPPORTED hint, not UNKNOWN_ACTION — but a+ * Firefox build does not list what it can never run.+ */+export function describeActions(target: BrowserTarget = 'chromium'): ToolDescriptor[] {+ return [...actions.values()]+ .filter((action) => target === 'chromium' || !action.chromiumOnly)+ .map(({ name, description, input }) => ({+ name,+ description,+ inputSchema: tidy(z.toJSONSchema(input, { io: 'input' })),+ }));}const UNBOUNDED = new Set([Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER]);diff --git a/src/lib/bridge/own-actions.ts b/src/lib/bridge/own-actions.tsnew file mode 100644index 0000000..319f3d0--- /dev/null+++ b/src/lib/bridge/own-actions.ts@@ -0,0 +1,7 @@+import type { ToolDescriptor } from '@/lib/actions/manifest';+import { describeActions } from '@/lib/actions/registry';++/** The tools this build offers: the registry decides, told which browser it was built for. */+export function describeOwnActions(): ToolDescriptor[] {+ return describeActions(import.meta.env.FIREFOX ? 'firefox' : 'chromium');+}diff --git a/src/lib/bridge/socket.ts b/src/lib/bridge/socket.tsindex 7954a96..be1079f 100644--- a/src/lib/bridge/socket.ts+++ b/src/lib/bridge/socket.ts@@ -1,5 +1,6 @@import { browser } from 'wxt/browser';import { hashManifest } from '@/lib/actions/manifest';+import { describeOwnActions } from '@/lib/bridge/own-actions';import {clientProof,isNonce,@@ -24,7 +25,6 @@ import {type SkillCatalog,type SocketFrame,} from '@/lib/actions/protocol';-import { describeActions } from '@/lib/actions/registry';import type { AgentKind, AgentState } from '@/lib/agents/catalog';import type { GuardrailSettings, GuardrailValue } from '@/lib/settings/guardrails';import type { SkillDraft } from '@/lib/skills/format';@@ -401,7 +401,7 @@ function dial(credential: Credential, portIndex: number, carried?: Refusal): voiport,hello: {extensionVersion: browser.runtime.getManifest().version,- manifestHash: hashManifest(describeActions()),+ manifestHash: hashManifest(describeOwnActions()),nonce: newNonce(),},done() {@@ -547,7 +547,7 @@ async function handle(ws: WebSocket, raw: string, attempt: Attempt): Promise<voi}case 'describe':- return send(ws, { t: 'manifest', id: frame.id, tools: describeActions() });+ return send(ws, { t: 'manifest', id: frame.id, tools: describeOwnActions() });case 'invoke':return send(ws, {