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(agents): an extension too old to know an agent is never sent it, refused a run with a word to update, and a newer one names an agent it lacks by kind

Shahriara334d81f83dd
diff --git a/src/daemon/agent/service.ts b/src/daemon/agent/service.ts
index 1cb2ac3..8b6de1d 100644
--- a/src/daemon/agent/service.ts
+++ b/src/daemon/agent/service.ts
@@ -23,7 +23,7 @@ import { FOCUS_SHOT_ACTION, READ_SITEMAP_ACTION } from '@/lib/actions/reserved';
import { agentRunToolNames, toolNameFor } from '@/lib/actions/tool-names';
import type { FileReport } from '@/lib/files/report';
import { TASK_APPROVAL_WAIT_MS, TASK_RUN_MAX_MS } from '@/lib/schedules/task';
-import { activeRunner, AGENTS, type AgentKind } from '@/lib/agents/catalog';
+import { activeRunner, AGENTS, needsNewerExtension, type AgentKind } from '@/lib/agents/catalog';
import { SAVE_SITE_MAP_ACTION, SITE_MAPPER_SKILL, validateSiteMapReport } from '@/lib/skills/site-map';
import {
blocked,
@@ -81,6 +81,8 @@ export interface AgentSessionDeps {
actionNames: () => string[];
/** The report on a file the analyst is still reading, or null when nothing is reading it. */
awaitAnalysis?: (fileId: string, signal: AbortSignal) => Promise<FileReport | null>;
+ /** Whether the panel asking knows this agent; one too old for it is refused rather than sent it. */
+ knowsAgent?: (kind: AgentKind) => boolean;
}
interface ActiveRun {
@@ -448,6 +450,9 @@ export class AgentSession {
}
const config = readAgentConfig();
+ if (this.deps.knowsAgent?.(config.agent) === false) {
+ return emit({ kind: 'error', code: 'AGENT_UNUSABLE', message: needsNewerExtension(config.agent) });
+ }
const limit = maxConcurrentRuns(config);
if ((this.deps.running?.() ?? this.runs.size) >= limit) {
return emit({
diff --git a/src/daemon/daemon.ts b/src/daemon/daemon.ts
index 948b87d..ef004d4 100644
--- a/src/daemon/daemon.ts
+++ b/src/daemon/daemon.ts
@@ -5,6 +5,7 @@ import { dirname, join } from 'node:path';
import type { Duplex } from 'node:stream';
import { WebSocketServer, type WebSocket } from 'ws';
import {
+ AGENT_PROTOCOL,
ANDROID_PROTOCOL,
EXTERNAL_RUN_ID,
MIN_EXTENSION_PROTOCOL,
@@ -25,7 +26,7 @@ import { hashManifest, type ToolDescriptor } from '@/lib/actions/manifest';
import { solveCaptcha } from '@/lib/actions/page/solve-captcha';
import { describeActions } from '@/lib/actions/registry';
import { RESERVED_PREFIX } from '@/lib/actions/reserved';
-import { AGENTS, isAgentKind, type AgentState } from '@/lib/agents/catalog';
+import { AGENTS, isAgentKind, needsNewerExtension, type AgentKind, type AgentState } from '@/lib/agents/catalog';
import { sourceOf } from '@/lib/stores';
import { saveScreenshot } from './screenshots';
import { adoptDownload, listDownloads, resolveAttachment, sweepDownloads, type CapturedItem } from './downloads';
@@ -535,7 +536,7 @@ export async function startDaemon({ version, idleExit = true, android = androidO
request.t === 'grantAgent'
) {
void settleAgent(request).then((state) => {
- source.send({ t: 'agentInfo', id: request.id, result: state });
+ source.send({ t: 'agentInfo', id: request.id, result: state.ok ? agentStateFor(source, state.data) : state });
// The catalog's agent-skill half belongs to the agent that just took over.
if (request.t === 'setAgent') pushSkillCatalog(source);
if (request.t === 'grantAgent') announceAgent(source);
@@ -544,7 +545,7 @@ export async function startDaemon({ version, idleExit = true, android = androidO
return;
}
if (request.t === 'listSkills') {
- return source.send({ t: 'skillCatalog', id: request.id, result: skillCatalogNow(request.refresh === true) });
+ return source.send({ t: 'skillCatalog', id: request.id, result: skillCatalogFor(source, request.refresh === true) });
}
if (request.t === 'preferences') {
return source.send({ t: 'preferencesInfo', id: request.id, result: success(preferencesNow()) });
@@ -743,7 +744,22 @@ export async function startDaemon({ version, idleExit = true, android = androidO
async function pushAgentState(target: ExtensionLink): Promise<void> {
const state = await agentState(readAgentConfig());
- if (target.isOpen) target.send({ t: 'agentInfo', id: '', result: success(state) });
+ if (target.isOpen) target.send({ t: 'agentInfo', id: '', result: agentStateFor(target, state) });
+ }
+
+ function knowsAgent(link: ExtensionLink, kind: AgentKind): boolean {
+ return link.speaks(AGENT_PROTOCOL[kind] ?? 0);
+ }
+
+ // An older panel would throw on an agent it cannot look up, so it hears only of those it knows.
+ function agentStateFor(link: ExtensionLink, state: AgentState): ActionResult<AgentState> {
+ if (!knowsAgent(link, state.active)) return failure('UNSUPPORTED', needsNewerExtension(state.active));
+ return success({ ...state, runners: state.runners.filter((runner) => knowsAgent(link, runner.kind)) });
+ }
+
+ function skillCatalogFor(link: ExtensionLink, refresh = false): ActionResult<SkillCatalog> {
+ const catalog = skillCatalogNow(refresh);
+ return catalog.ok && !knowsAgent(link, catalog.data.agent) ? failure('UNSUPPORTED', needsNewerExtension(catalog.data.agent)) : catalog;
}
function skillCatalogNow(refresh = false): ActionResult<SkillCatalog> {
@@ -763,7 +779,7 @@ export async function startDaemon({ version, idleExit = true, android = androidO
}
function pushSkillCatalog(target: ExtensionLink): void {
- if (target.isOpen) target.send({ t: 'skillCatalog', id: '', result: skillCatalogNow() });
+ if (target.isOpen) target.send({ t: 'skillCatalog', id: '', result: skillCatalogFor(target) });
}
function session(source: ExtensionLink): AgentSession {
@@ -776,6 +792,7 @@ export async function startDaemon({ version, idleExit = true, android = androidO
running: () => [...agents.values()].reduce((total, agent) => total + agent.running, 0),
actionNames: () => source.tools.map((tool) => tool.name),
awaitAnalysis: (fileId, signal) => analyses.wait(fileId, signal),
+ knowsAgent: (kind) => knowsAgent(source, kind),
});
agents.set(source, created);
return created;
diff --git a/src/extension/components/agent-chip.tsx b/src/extension/components/agent-chip.tsx
index 01d6587..544ccc5 100644
--- a/src/extension/components/agent-chip.tsx
+++ b/src/extension/components/agent-chip.tsx
@@ -1,7 +1,7 @@
import { ChevronDown } from 'lucide-react';
import { AgentMark } from '@/extension/components/agent-marks';
-import { AGENTS, activeRunner, type AgentState } from '@/lib/agents/catalog';
+import { activeRunner, agentLabel, type AgentState } from '@/lib/agents/catalog';
import { cn } from '@/lib/utils';
/** Which agent a message goes to, and on which model; pressing it opens the picker. */
@@ -16,7 +16,7 @@ export function AgentChip({
}) {
const runner = activeRunner(state);
if (!state || !runner) return null;
- const { label } = AGENTS[state.active];
+ const label = agentLabel(state.active);
return (
<button
type="button"
diff --git a/src/extension/components/agent-marks.tsx b/src/extension/components/agent-marks.tsx
index 392df28..3a49429 100644
--- a/src/extension/components/agent-marks.tsx
+++ b/src/extension/components/agent-marks.tsx
@@ -1,4 +1,4 @@
-import type { AgentKind } from '@/lib/agents/catalog';
+import { isAgentKind, type AgentKind } from '@/lib/agents/catalog';
import { cn } from '@/lib/utils';
// Each vendor's own mark, as published, in one colour. They are trademarks used to say
@@ -38,9 +38,12 @@ const MARKS: Record<AgentKind, { viewBox: string; path: string }> = {
},
};
+/** A plain prompt, for an agent a newer Bridge can run and this build has no mark for. */
+const UNKNOWN_MARK = { viewBox: '0 0 24 24', path: 'M5 6.5 6.5 5l7 7-7 7L5 17.5 10.5 12 5 6.5ZM12 17h7v2h-7v-2Z' };
+
/** The vendor's mark in the current text colour, so it follows the row's state and the theme. */
export function AgentMark({ kind, className }: { kind: AgentKind; className?: string }) {
- const mark = MARKS[kind];
+ const mark = isAgentKind(kind) ? MARKS[kind] : UNKNOWN_MARK;
return (
<svg viewBox={mark.viewBox} fill="currentColor" className={cn('size-3.5 shrink-0', className)} aria-hidden>
<path d={mark.path} />
diff --git a/src/extension/components/agent-picker.tsx b/src/extension/components/agent-picker.tsx
index 4befc37..771cdb3 100644
--- a/src/extension/components/agent-picker.tsx
+++ b/src/extension/components/agent-picker.tsx
@@ -63,7 +63,8 @@ export function AgentPicker() {
if (!daemon?.paired) return null;
- const runners = AGENT_LIST.map(
+ // An older Bridge reports only the agents it can run, and one it never mentions would stay "checking…".
+ const runners = AGENT_LIST.filter((agent) => !state || state.runners.some((runner) => runner.kind === agent.kind)).map(
(agent) => state?.runners.find((runner) => runner.kind === agent.kind) ?? unknownRunner(agent.kind),
);
const active = state?.active;
diff --git a/src/extension/components/context-card.tsx b/src/extension/components/context-card.tsx
index 11be40f..30668e8 100644
--- a/src/extension/components/context-card.tsx
+++ b/src/extension/components/context-card.tsx
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
import { Clapperboard, Cpu, FileText, Globe, Layers, type LucideIcon } from 'lucide-react';
import { AgentMark } from '@/extension/components/agent-marks';
-import { AGENTS } from '@/lib/agents/catalog';
+import { agentLabel as labelOf } from '@/lib/agents/catalog';
import type { ContextBreakdown } from '@/lib/bridge/commands';
import { cn } from '@/lib/utils';
@@ -128,7 +128,7 @@ function Row({ icon: Icon, children }: { icon: LucideIcon; children: ReactNode }
function agentLabel(breakdown: ContextBreakdown): string {
if (!breakdown.agent) return 'no agent yet';
- return `${AGENTS[breakdown.agent].label}${breakdown.resumes ? ' · resumes' : ''}`;
+ return `${labelOf(breakdown.agent)}${breakdown.resumes ? ' · resumes' : ''}`;
}
function compact(n: number): string {
diff --git a/src/extension/components/skill-menu.tsx b/src/extension/components/skill-menu.tsx
index d3b5881..1beddbb 100644
--- a/src/extension/components/skill-menu.tsx
+++ b/src/extension/components/skill-menu.tsx
@@ -2,7 +2,7 @@ import { useEffect, useRef } from 'react';
import { BookOpen, Globe, Sparkles, SquareSlash, Zap } from 'lucide-react';
import type { SkillCatalog } from '@/lib/actions/protocol';
-import { AGENTS } from '@/lib/agents/catalog';
+import { agentLabel } from '@/lib/agents/catalog';
import {
ANDROID_ALIASES,
ANDROID_COMMAND,
@@ -171,7 +171,7 @@ export function SkillMenu({
command: 'Commands',
site: 'On this site',
general: 'Browsentic skills',
- agent: `${agent ? AGENTS[agent].label : 'Agent'} skills`,
+ agent: `${agent ? agentLabel(agent) : 'Agent'} skills`,
'other-site': 'Other sites',
};
diff --git a/src/lib/actions/protocol.ts b/src/lib/actions/protocol.ts
index 1465b59..49a213b 100644
--- a/src/lib/actions/protocol.ts
+++ b/src/lib/actions/protocol.ts
@@ -15,11 +15,17 @@ import type { DeviceNotice } from '@/lib/notices';
export const ACTION_CHANNEL = 'browsentic/action';
export const BRIDGE_CHANNEL = 'browsentic/bridge';
-export const SOCKET_PROTOCOL_VERSION = 24;
+export const SOCKET_PROTOCOL_VERSION = 25;
/** The first protocol with the Android frames: `androidInfo`, the phone requests, `cdpEvent` and `phoneClosed`. */
export const ANDROID_PROTOCOL = 23;
+/**
+ * The first protocol whose extension knows each agent added since the compatibility window opened.
+ * An older panel looks every agent up by kind, so it is never told about one it does not know.
+ */
+export const AGENT_PROTOCOL: Partial<Record<AgentKind, number>> = {};
+
/**
* The oldest extension the daemon lets in. A store copy updates when its browser decides to, so it
* and the daemon are routinely a version apart: a change a peer can do without bumps
diff --git a/src/lib/agents/catalog.ts b/src/lib/agents/catalog.ts
index be6a0dc..997dd04 100644
--- a/src/lib/agents/catalog.ts
+++ b/src/lib/agents/catalog.ts
@@ -108,6 +108,16 @@ export function isAgentKind(value: unknown): value is AgentKind {
return typeof value === 'string' && (AGENT_KINDS as readonly string[]).includes(value);
}
+/** An agent's name, or its kind as sent when it came after this build: a newer Bridge can run one. */
+export function agentLabel(kind: AgentKind): string {
+ return isAgentKind(kind) ? AGENTS[kind].label : String(kind);
+}
+
+/** What a panel too old to know the chosen agent is told instead of being sent it. */
+export function needsNewerExtension(kind: AgentKind): string {
+ return `${agentLabel(kind)} needs a newer Browsentic extension. Update it, or pick another agent with \`browsentic agent claude\`.`;
+}
+
export interface AgentProblem {
code: 'AGENT_MISSING' | 'AGENT_UNUSABLE' | 'AGENT_NEEDS_PERMISSION';
message: string;
diff --git a/src/windows/ui/views/agents.tsx b/src/windows/ui/views/agents.tsx
index a7f81b2..afd1017 100644
--- a/src/windows/ui/views/agents.tsx
+++ b/src/windows/ui/views/agents.tsx
@@ -94,14 +94,26 @@ function AgentCard({ runner, descriptor, active, working, model }: { runner: Run
</div>
</div>
) : (
- <ModelRow runner={runner} active={active} working={working} model={model} />
+ <ModelRow runner={runner} descriptor={descriptor} active={active} working={working} model={model} />
)}
</div>
</Card>
);
}
-function ModelRow({ runner, active, working, model }: { runner: RunnerStatus; active: boolean; working: boolean; model: Model }) {
+function ModelRow({
+ runner,
+ descriptor,
+ active,
+ working,
+ model,
+}: {
+ runner: RunnerStatus;
+ descriptor: AgentDescriptor;
+ active: boolean;
+ working: boolean;
+ model: Model;
+}) {
const list = offered(runner);
const pinned = runner.model && !list.ids.includes(runner.model) ? runner.model : null;
const choose = (next: string | null) => void model.setModel(next, runner.kind);
@@ -113,7 +125,7 @@ function ModelRow({ runner, active, working, model }: { runner: RunnerStatus; ac
<ModelFilter
value={runner.model ?? null}
ids={list.ids}
- suggested={AGENTS[runner.kind].models.filter((id) => list.ids.includes(id))}
+ suggested={descriptor.models.filter((id) => list.ids.includes(id))}
pinned={pinned}
disabled={working}
onModel={choose}