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(actions): map action names to MCP tool names and hash the manifest
Shahriarb32c0ab5a31a
diff --git a/lib/actions/manifest.ts b/lib/actions/manifest.tsnew file mode 100644index 0000000..6dd523f--- /dev/null+++ b/lib/actions/manifest.ts@@ -0,0 +1,25 @@+/** One action as it crosses the wire and becomes an MCP tool. */+export interface ToolDescriptor {+ name: string;+ description: string;+ inputSchema: unknown;+}++/**+ * Fingerprint a manifest so the daemon can spot an extension built from a different registry.+ * FNV-1a: sync and dependency-free, so the browser and Node agree without WebCrypto's async split.+ * Drift detection only — never a security boundary.+ */+export function hashManifest(tools: readonly ToolDescriptor[]): string {+ let hash = 0x811c9dc5;+ const canonical = JSON.stringify(+ [...tools]+ .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))+ .map(({ name, description, inputSchema }) => [name, description, inputSchema]),+ );+ for (let i = 0; i < canonical.length; i++) {+ hash ^= canonical.charCodeAt(i);+ hash = Math.imul(hash, 0x01000193);+ }+ return (hash >>> 0).toString(16).padStart(8, '0');+}diff --git a/lib/actions/tool-names.ts b/lib/actions/tool-names.tsnew file mode 100644index 0000000..c008950--- /dev/null+++ b/lib/actions/tool-names.ts@@ -0,0 +1,39 @@+import { ActionError } from './core';++/** MCP tool names must match this; the dot in `page.clickElement` is not allowed. */+const TOOL_NAME = /^[a-zA-Z0-9_-]{1,64}$/;++/** `page.clickElement` → `page_clickElement`. */+export function toolNameFor(actionName: string): string {+ return actionName.replaceAll('.', '_');+}++/** `page_clickElement` → `page.clickElement`. Only the first underscore is a namespace separator. */+export function actionNameFor(toolName: string): string {+ return toolName.replace('_', '.');+}++/**+ * The mapping is only reversible while no action name segment contains an underscore.+ * Two actions could otherwise collapse onto one tool name, silently shadowing each other.+ */+export function assertToolNamesRoundTrip(actionNames: Iterable<string>): void {+ const seen = new Map<string, string>();+ for (const actionName of actionNames) {+ const tool = toolNameFor(actionName);+ if (!TOOL_NAME.test(tool)) {+ throw new ActionError(`Action "${actionName}" maps to an invalid MCP tool name "${tool}"`, 'INVALID_TOOL_NAME');+ }+ if (actionNameFor(tool) !== actionName) {+ throw new ActionError(+ `Action "${actionName}" does not survive the tool-name round trip (got "${actionNameFor(tool)}") — avoid underscores in action names`,+ 'INVALID_TOOL_NAME',+ );+ }+ const clash = seen.get(tool);+ if (clash) {+ throw new ActionError(`Actions "${clash}" and "${actionName}" both map to tool "${tool}"`, 'INVALID_TOOL_NAME');+ }+ seen.set(tool, actionName);+ }+}