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.

refactor(actions): derive the reserved namespace and its coupled names from one constant

Shahriara9b5eb1a70ec
diff --git a/lib/actions/reserved.ts b/lib/actions/reserved.ts
new file mode 100644
index 0000000..d7a6bcb
--- /dev/null
+++ b/lib/actions/reserved.ts
@@ -0,0 +1,13 @@
+export const RESERVED_PREFIX = 'voicelink.';
+
+export const SAVE_SITE_MAP_ACTION = `${RESERVED_PREFIX}saveSiteMap` as const;
+export const START_RECORDING_ACTION = `${RESERVED_PREFIX}startRecording` as const;
+export const STOP_RECORDING_ACTION = `${RESERVED_PREFIX}stopRecording` as const;
+export const READ_SITEMAP_ACTION = `${RESERVED_PREFIX}readSitemap` as const;
+
+export const RESERVED_ACTIONS = [
+ SAVE_SITE_MAP_ACTION,
+ START_RECORDING_ACTION,
+ STOP_RECORDING_ACTION,
+ READ_SITEMAP_ACTION,
+] as const;
diff --git a/lib/bridge/recorder.ts b/lib/bridge/recorder.ts
index b2e49c8..89c53b6 100644
--- a/lib/bridge/recorder.ts
+++ b/lib/bridge/recorder.ts
@@ -3,6 +3,7 @@ import { failure, success, type ActionResult } from '@/lib/actions/protocol';
import {
MAX_EVENTS,
MAX_RECORDING_MS,
+ RECORD_CHANNEL,
WARN_AT_MS,
hostOf,
type RecordedEvent,
@@ -105,7 +106,7 @@ export async function startRecording(opts: {
await writeActive(active);
await browser.alarms.create(WARN_ALARM, { when: active.startedAt + WARN_AT_MS });
await browser.alarms.create(STOP_ALARM, { when: active.startedAt + MAX_RECORDING_MS });
- await browser.tabs.sendMessage(opts.tabId, { channel: 'voicelink/record', op: 'begin' }).catch(() => undefined);
+ await browser.tabs.sendMessage(opts.tabId, { channel: RECORD_CHANNEL, op: 'begin' }).catch(() => undefined);
const state = stateOf(active);
listener?.(state);
@@ -137,7 +138,7 @@ export async function stopRecording(reason: StopReason): Promise<ActionResult<{
await writeActive(null);
if (reason !== 'tab-closed') {
await browser.tabs
- .sendMessage(active.tabId, { channel: 'voicelink/record', op: 'end' })
+ .sendMessage(active.tabId, { channel: RECORD_CHANNEL, op: 'end' })
.catch(() => undefined);
}
listener?.(null);
diff --git a/lib/recordings/events.ts b/lib/recordings/events.ts
index 95c3021..cac816d 100644
--- a/lib/recordings/events.ts
+++ b/lib/recordings/events.ts
@@ -1,5 +1,6 @@
-export const START_RECORDING_ACTION = 'voicelink.startRecording';
-export const STOP_RECORDING_ACTION = 'voicelink.stopRecording';
+export { START_RECORDING_ACTION, STOP_RECORDING_ACTION } from '@/lib/actions/reserved';
+
+export const RECORD_CHANNEL = 'voicelink/record';
export const MAX_EVENTS = 2000;
export const MAX_RECORDING_MS = 15 * 60_000;
diff --git a/lib/recordings/host.ts b/lib/recordings/host.ts
index fdf71a4..a23bb93 100644
--- a/lib/recordings/host.ts
+++ b/lib/recordings/host.ts
@@ -1,9 +1,9 @@
import { browser } from 'wxt/browser';
import { BRIDGE_CHANNEL } from '@/lib/actions/protocol';
import { startCapture } from './capture';
-import type { RecordedEvent } from './events';
+import { RECORD_CHANNEL, type RecordedEvent } from './events';
-export const RECORD_CHANNEL = 'voicelink/record';
+export { RECORD_CHANNEL };
interface RecordCommand {
channel: typeof RECORD_CHANNEL;
diff --git a/lib/skills/site-map.ts b/lib/skills/site-map.ts
index 9dc2f4f..3c4f693 100644
--- a/lib/skills/site-map.ts
+++ b/lib/skills/site-map.ts
@@ -5,7 +5,7 @@ export { scrub, looksLikeInstruction };
export const SITE_MAPPER_SKILL = 'site-mapper';
-export const SAVE_SITE_MAP_ACTION = 'voicelink.saveSiteMap';
+export { SAVE_SITE_MAP_ACTION } from '@/lib/actions/reserved';
export const MAX_MAP_BODY_BYTES = 16 * 1024;
export const MAX_MAP_PAGES = 24;
diff --git a/mcp/src/agent/mapping.ts b/mcp/src/agent/mapping.ts
index a6da2d5..ef67acf 100644
--- a/mcp/src/agent/mapping.ts
+++ b/mcp/src/agent/mapping.ts
@@ -1,4 +1,5 @@
import { failure, type ActionResult } from '@/lib/actions/protocol';
+import { RESERVED_PREFIX } from '@/lib/actions/reserved';
import { SAVE_SITE_MAP_ACTION } from '@/lib/skills/site-map';
import { log } from '../log';
import type { SiteMapSettings } from './config';
@@ -38,7 +39,7 @@ const deny = (code: string, message: string): Gate => ({ allow: false, result: f
export function gateMappingInvoke(run: MapRun, action: string, input: unknown): Gate {
if (action === SAVE_SITE_MAP_ACTION) return { allow: true };
- if (action.startsWith('voicelink.')) {
+ if (action.startsWith(RESERVED_PREFIX)) {
return deny('UNKNOWN_ACTION', `Unknown action "${action}".`);
}
diff --git a/mcp/src/agent/runner.ts b/mcp/src/agent/runner.ts
index b1e1089..b2dc83e 100644
--- a/mcp/src/agent/runner.ts
+++ b/mcp/src/agent/runner.ts
@@ -26,6 +26,8 @@ export interface RunOutcome {
const cliPath = join(dirname(fileURLToPath(import.meta.url)), 'cli.js');
+const MCP_SERVER_NAME = 'voicelink';
+
const KILL_GRACE_MS = 5_000;
export function spawnClaude(
@@ -172,12 +174,12 @@ export function runInstruction(request: RunRequest): Promise<RunOutcome> {
'--include-partial-messages',
'--verbose',
'--mcp-config',
- JSON.stringify({ mcpServers: { voicelink: { command: process.execPath, args: [cliPath] } } }),
+ JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: { command: process.execPath, args: [cliPath] } } }),
'--strict-mcp-config',
'--tools',
...(request.research ? WEB_TOOLS : ['']),
'--allowedTools',
- 'mcp__voicelink',
+ `mcp__${MCP_SERVER_NAME}`,
...(request.research ? WEB_TOOLS : []),
'--disallowedTools',
...BUILTIN_DENIED,
diff --git a/mcp/src/agent/service.ts b/mcp/src/agent/service.ts
index cea75cf..776ba3c 100644
--- a/mcp/src/agent/service.ts
+++ b/mcp/src/agent/service.ts
@@ -9,6 +9,7 @@ import {
type RunContext,
type RunEvent,
} from '@/lib/actions/protocol';
+import { READ_SITEMAP_ACTION } from '@/lib/actions/reserved';
import { SAVE_SITE_MAP_ACTION, SITE_MAPPER_SKILL, validateSiteMapReport } from '@/lib/skills/site-map';
import { log } from '../log';
import { readAgentConfig, siteMapSettings, type AgentConfig } from './config';
@@ -254,7 +255,7 @@ export class AgentSession {
const staging = prepareStaging();
const toolId = randomUUID();
- emit({ kind: 'tool', toolId, action: 'voicelink.readSitemap', input: { origin: target.target.origin } });
+ emit({ kind: 'tool', toolId, action: READ_SITEMAP_ACTION, input: { origin: target.target.origin } });
let index: SiteIndex;
try {
index = await fetchSiteIndex(target.target.origin, run.abort.signal);
diff --git a/mcp/src/cli.ts b/mcp/src/cli.ts
index dc8ed4a..7a7dc82 100644
--- a/mcp/src/cli.ts
+++ b/mcp/src/cli.ts
@@ -1,6 +1,7 @@
import { readFileSync } from 'node:fs';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { describeActions } from '@/lib/actions/registry';
+import { RESERVED_ACTIONS } from '@/lib/actions/reserved';
import { assertToolNamesRoundTrip, toolNameFor } from '@/lib/actions/tool-names';
import { join } from 'node:path';
import { loadSkills, skillDirNames, uploadedSkillsDir } from './agent/skills';
@@ -96,7 +97,7 @@ async function serve(): Promise<void> {
function printTools(): void {
const actions = describeActions();
- assertToolNamesRoundTrip(actions.map((action) => action.name));
+ assertToolNamesRoundTrip([...actions.map((action) => action.name), ...RESERVED_ACTIONS]);
console.log(
JSON.stringify(
actions.map((action) => ({ ...action, name: toolNameFor(action.name), action: action.name })),
diff --git a/mcp/src/daemon.ts b/mcp/src/daemon.ts
index 1fc676a..d24ac81 100644
--- a/mcp/src/daemon.ts
+++ b/mcp/src/daemon.ts
@@ -13,6 +13,7 @@ import {
} from '@/lib/actions/protocol';
import { hashManifest } from '@/lib/actions/manifest';
import { describeActions } from '@/lib/actions/registry';
+import { RESERVED_PREFIX } from '@/lib/actions/reserved';
import { saveScreenshot } from './screenshots';
import {
consumePairing,
@@ -366,7 +367,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
input?: unknown,
opts?: { saveTo?: { dir: string; filename: string }; tabId?: number },
) {
- if (action.startsWith('voicelink.')) {
+ if (action.startsWith(RESERVED_PREFIX)) {
return failure('UNKNOWN_ACTION', `Unknown action "${action}".`);
}
if (!link?.isOpen) {
diff --git a/mcp/src/server.ts b/mcp/src/server.ts
index ab9ce82..31f3c48 100644
--- a/mcp/src/server.ts
+++ b/mcp/src/server.ts
@@ -6,11 +6,12 @@ import {
ReadResourceRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import type { ActionResult } from '@/lib/actions/protocol';
+import { RESERVED_ACTIONS, RESERVED_PREFIX, SAVE_SITE_MAP_ACTION } from '@/lib/actions/reserved';
import { actionNameFor, assertToolNamesRoundTrip, toolNameFor } from '@/lib/actions/tool-names';
import type { Bridge } from './control';
import { log } from './log';
-const STATUS_TOOL = 'voicelink_status';
+const STATUS_TOOL = toolNameFor(`${RESERVED_PREFIX}status`);
const SCREENSHOT_TOOL = 'page_screenshot';
const RESOURCES = [
@@ -35,7 +36,7 @@ const RESOURCES = [
] as const;
const SAVE_SITE_MAP_TOOL = {
- name: 'voicelink_saveSiteMap',
+ name: toolNameFor(SAVE_SITE_MAP_ACTION),
description:
'Write up a finished site map. Call this exactly once, at the end of a mapping run. The map is staged for the user to review before it takes effect — it does not apply immediately.',
inputSchema: {
@@ -118,7 +119,7 @@ export function createMcpServer(bridge: Bridge, version: string, opts: { agentRu
server.setRequestHandler(ListToolsRequestSchema, async () => {
const actions = await bridge.describe();
- assertToolNamesRoundTrip(actions.map((action) => action.name));
+ assertToolNamesRoundTrip([...actions.map((action) => action.name), ...RESERVED_ACTIONS]);
return {
tools: [
...actions.map((action) => ({
diff --git a/scripts/check-security.mjs b/scripts/check-security.mjs
index 8f68285..6572c3f 100644
--- a/scripts/check-security.mjs
+++ b/scripts/check-security.mjs
@@ -27,6 +27,7 @@ async function bundle(entry, name) {
const sitemap = await bundle('mcp/src/agent/sitemap.ts', 'sitemap');
const effects = await bundle('mcp/src/agent/effects.ts', 'effects');
const redact = await bundle('lib/bridge/redact.ts', 'redact');
+const reserved = await bundle('lib/actions/reserved.ts', 'reserved');
let failed = 0;
let ran = 0;
@@ -85,6 +86,12 @@ for (const [action, input, want] of SUBMITS) check(`submitsForm(${action})`, eff
check('needsApproval fillInput+pressEnter', effects.needsApproval(['page.submitForm'], 'page.fillInput', { pressEnter: true }), true);
check('needsApproval disabled when list empty', effects.needsApproval([], 'page.fillInput', { pressEnter: true }), false);
+check('reserved prefix ends with a dot', reserved.RESERVED_PREFIX.endsWith('.'), true);
+check('reserved prefix has no underscore', reserved.RESERVED_PREFIX.includes('_'), false);
+for (const name of reserved.RESERVED_ACTIONS) {
+ check(`${name} carries the reserved prefix`, name.startsWith(reserved.RESERVED_PREFIX), true);
+}
+
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]');