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(daemon): log and surface invokes from external MCP clients

Shahriarc152882c1921
diff --git a/components/run-timeline.tsx b/components/run-timeline.tsx
index ba92650..1b402d8 100644
--- a/components/run-timeline.tsx
+++ b/components/run-timeline.tsx
@@ -1,4 +1,4 @@
-import { AlertTriangle, Bot, Check, Info, User, Wrench, X, Zap } from 'lucide-react';
+import { AlertTriangle, Bot, Check, Info, Terminal, User, Wrench, X, Zap } from 'lucide-react';
import { Markdown } from '@/components/markdown';
import { Button } from '@/components/ui/button';
@@ -71,6 +71,9 @@ function ToolRow({
{item.source === 'local' && (
<Zap className="size-3 shrink-0 text-amber-500" aria-label="Handled in the browser" />
)}
+ {item.source === 'external' && (
+ <Terminal className="size-3 shrink-0 text-sky-500" aria-label="Run by a connected MCP client" />
+ )}
{item.summary && (
<span className={cn('min-w-0 truncate', item.ok === false ? 'text-destructive' : 'text-muted-foreground')}>
{item.summary}
diff --git a/lib/actions/protocol.ts b/lib/actions/protocol.ts
index 6216ff2..c82a015 100644
--- a/lib/actions/protocol.ts
+++ b/lib/actions/protocol.ts
@@ -9,6 +9,8 @@ export const BRIDGE_CHANNEL = 'voicelink/bridge';
export const SOCKET_PROTOCOL_VERSION = 7;
+export const EXTERNAL_RUN_ID = 'external';
+
export const DAEMON_PORTS = [8765, 8766, 8767] as const;
export interface ActionInvocation {
@@ -37,7 +39,7 @@ export type ActionResult<T = unknown> =
export type RunEvent =
| { kind: 'started'; skill: string; overlays?: string[] }
| { kind: 'text'; delta: string }
- | { kind: 'tool'; toolId: string; action: string; input: unknown; source?: 'local' }
+ | { kind: 'tool'; toolId: string; action: string; input: unknown; source?: 'local' | 'external' }
| { kind: 'approval'; toolId: string; action: string; input: unknown }
| { kind: 'toolResult'; toolId: string; ok: boolean; summary: string }
| { kind: 'session'; claudeSessionId: string | null }
diff --git a/lib/bridge/run-port.ts b/lib/bridge/run-port.ts
index 86b3b1e..9489cee 100644
--- a/lib/bridge/run-port.ts
+++ b/lib/bridge/run-port.ts
@@ -1,5 +1,11 @@
import { browser, type Browser } from 'wxt/browser';
-import type { AttachedFile, RunContext, RunEvent, SavedRecording } from '@/lib/actions/protocol';
+import {
+ EXTERNAL_RUN_ID,
+ type AttachedFile,
+ type RunContext,
+ type RunEvent,
+ type SavedRecording,
+} from '@/lib/actions/protocol';
import type { RecordingState } from '@/lib/recordings/events';
import type { SiteMapDraft } from '@/lib/skills/site-map';
import { tryFastPath } from './fast-path';
@@ -53,6 +59,7 @@ let pendingDraft: SiteMapDraft | null = null;
export function serveRunPorts(): void {
onRunEvent((runId, event) => {
+ if (runId === EXTERNAL_RUN_ID) return broadcast({ op: 'event', runId, event });
const ends = event.kind === 'done' || event.kind === 'error';
if (ends && (activeRunId === null || activeRunId === runId)) setActiveRun(null);
broadcast({ op: 'event', runId, event });
diff --git a/mcp/src/daemon.ts b/mcp/src/daemon.ts
index 66092f6..1fc676a 100644
--- a/mcp/src/daemon.ts
+++ b/mcp/src/daemon.ts
@@ -1,8 +1,16 @@
-import { randomBytes, timingSafeEqual } from 'node:crypto';
+import { randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
import { createServer, type IncomingMessage, type Server } from 'node:http';
import type { Duplex } from 'node:stream';
import { WebSocketServer, type WebSocket } from 'ws';
-import { DAEMON_PORTS, SOCKET_PROTOCOL_VERSION, failure, parseFrame, type ActionResult } from '@/lib/actions/protocol';
+import {
+ DAEMON_PORTS,
+ EXTERNAL_RUN_ID,
+ SOCKET_PROTOCOL_VERSION,
+ failure,
+ parseFrame,
+ type ActionResult,
+ type RunEvent,
+} from '@/lib/actions/protocol';
import { hashManifest } from '@/lib/actions/manifest';
import { describeActions } from '@/lib/actions/registry';
import { saveScreenshot } from './screenshots';
@@ -73,6 +81,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
let link: ExtensionLink | null = null;
let agent: AgentSession | null = null;
const controls = new Set<WebSocket>();
+ let controlSeq = 0;
const manifestListeners = new Set<() => void>();
let idleTimer: ReturnType<typeof setTimeout> | null = null;
@@ -272,6 +281,7 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
}
function acceptControl(ws: WebSocket): void {
+ const client = `c${++controlSeq}`;
controls.add(ws);
scheduleIdleExit();
ws.on('message', async (raw) => {
@@ -284,10 +294,17 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
if (request.op === 'describe') return send(ws, { id: request.id, op: 'describe', tools });
if (request.op === 'status') return send(ws, { id: request.id, op: 'status', status: statusNow() });
if (request.op === 'invoke') {
- const result = request.runId
- ? ((await agent?.invokeForRun(request.runId, request.action, request.input)) ??
- failure('RUN_INACTIVE', 'This agent run is no longer active'))
- : await invoke(request.action, request.input);
+ let result: ActionResult;
+ if (request.runId) {
+ result =
+ (await agent?.invokeForRun(request.runId, request.action, request.input)) ??
+ failure('RUN_INACTIVE', 'This agent run is no longer active');
+ if (!result.ok && result.error.code === 'RUN_INACTIVE') {
+ log(`control ${client} invoked ${request.action} for inactive run ${request.runId}`);
+ }
+ } else {
+ result = await invokeExternal(request.action, request.input, client);
+ }
return send(ws, { id: request.id, op: 'invoke', result });
}
if (request.op === 'pair') {
@@ -361,6 +378,24 @@ export async function startDaemon({ version, idleExit = true }: DaemonOptions):
return persistScreenshot(action, input, await link.invoke(action, input, opts?.tabId), opts?.saveTo);
}
+ async function invokeExternal(action: string, input: unknown, client: string): Promise<ActionResult> {
+ const target = link;
+ const toolId = randomUUID();
+ const tell = (event: RunEvent) => {
+ if (target?.isOpen) target.send({ t: 'run', id: EXTERNAL_RUN_ID, event });
+ };
+ tell({ kind: 'tool', toolId, action, input, source: 'external' });
+ const result = await invoke(action, input);
+ log(`external ${client} → ${action} ${result.ok ? 'ok' : result.error.code}`);
+ tell({
+ kind: 'toolResult',
+ toolId,
+ ok: result.ok,
+ summary: result.ok ? 'ok' : `${result.error.code}: ${result.error.message}`,
+ });
+ return result;
+ }
+
function scheduleIdleExit(): void {
if (idleTimer) clearTimeout(idleTimer);
if (!idleExit) return;