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.

Merge branch 'main' into feat/multi-link

Shahriara00e0e1a20c1
diff --cc src/daemon/agent/service.ts
index 0bcc95c,74d407c..5413562
--- a/src/daemon/agent/service.ts
+++ b/src/daemon/agent/service.ts
@@@ -118,14 -127,22 +129,30 @@@ export class AgentSession
}
}
+ get running(): number {
+ return this.runs.size;
+ }
+
+ owns(runId: string): boolean {
+ return this.runs.has(runId);
+ }
+
+ /**
+ * What a run's tool list should hold. A tool the run would only be refused is left
+ * out: its schema is re-sent on every turn, and listing it invites the call.
+ */
+ offerFor(runId: string): { withheld: string[]; reserved: string[] } | null {
+ const run = this.runs.get(runId);
+ if (!run) return null;
+ const codeListed = run.liveTools || (run.sessionId !== undefined && this.codeListed.has(run.sessionId));
+ return {
+ withheld: codeListed ? [] : [INJECT_ACTION, RUN_CODE_ACTION],
+ // A mapping run never resumes a conversation, so its tool can come and go. A pick
+ // comes and goes between the messages of one, so the tool that shows it stays.
+ reserved: [...(run.map ? [SAVE_SITE_MAP_ACTION] : []), FOCUS_SHOT_ACTION],
+ };
+ }
+
async invokeForRun(runId: string, action: string, input?: unknown): Promise<ActionResult> {
const run = this.runs.get(runId);
if (!run) {
diff --cc src/daemon/daemon.ts
index bcbe41d,d7e27d9..a1b2481
--- a/src/daemon/daemon.ts
+++ b/src/daemon/daemon.ts
@@@ -572,21 -501,22 +574,35 @@@ export async function startDaemon({ ver
broadcast({ event: 'manifest-changed' });
}
+ /**
+ * A caller's tab ids only mean something in the browser that issued them, so a burst of calls
+ * stays with one browser. Once the caller goes quiet, its next call follows the user instead.
+ */
+ function routeFor(binding: Binding): ExtensionLink | null {
+ const held = binding.id ? links.get(binding.id) : undefined;
+ const target = held?.isOpen && Date.now() - binding.usedAt < BINDING_IDLE_MS ? held : activeLink();
+ binding.id = target?.id;
+ binding.usedAt = Date.now();
+ return target;
+ }
+
+ function describeFor(runId?: string): Described {
- const offer = runId ? agent?.offerFor(runId) : null;
++ const offer = runId ? sessionRunning(runId)?.offerFor(runId) : null;
+ if (offer) return { tools: tools.filter(({ name }) => !offer.withheld.includes(name)), reserved: offer.reserved };
+
+ const config = readAgentConfig();
+ const policy = policyFrom(config.guardrails, config.requireApproval);
+ const denied = (action: string) =>
+ decide({ action, input: {}, caller: 'external', scope: ANYWHERE }, policy).effect === 'deny';
+ return {
+ tools: tools.filter(({ name }) => !((name === INJECT_ACTION || name === RUN_CODE_ACTION) && denied(name))),
+ reserved: [],
+ };
+ }
+
function acceptControl(ws: WebSocket): void {
const client = `c${++controlSeq}`;
+ const binding: Binding = { usedAt: 0 };
controls.add(ws);
scheduleIdleExit();
ws.on('message', async (raw) => {
@@@ -596,10 -526,8 +612,10 @@@
} catch {
return log('dropped unparseable control frame');
}
- if (request.op === 'describe') return send(ws, { id: request.id, op: 'describe', tools });
+ if (request.op === 'describe') return send(ws, { id: request.id, op: 'describe', ...describeFor(request.runId) });
- if (request.op === 'status') return send(ws, { id: request.id, op: 'status', status: statusNow() });
+ if (request.op === 'status') {
+ return send(ws, { id: request.id, op: 'status', status: statusNow(routeFor(binding)) });
+ }
if (request.op === 'invoke') {
let result: ActionResult;
if (request.runId) {
@@@ -768,12 -693,11 +784,12 @@@
log('daemon stopped');
}
+ const local: Binding = { usedAt: 0 };
return {
port,
- describe: async () => tools,
+ describe: async () => describeFor(),
- invoke,
- status: async () => statusNow(),
+ invoke: (action, input) => invokeOn(routeFor(local), action, input),
+ status: async () => statusNow(routeFor(local)),
onManifestChanged: (listener) => manifestListeners.add(listener),
close: stop,
stop,