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): run the side panel on Cursor CLI, in beta, behind deny rules a deny wins over and a sandbox it does not lean on

Shahriar7533ce361c82
diff --git a/src/daemon/agent/config.test.ts b/src/daemon/agent/config.test.ts
index 753a1d5..e958118 100644
--- a/src/daemon/agent/config.test.ts
+++ b/src/daemon/agent/config.test.ts
@@ -32,6 +32,7 @@ const DEFAULTS: AgentConfig = {
antigravity: { bin: 'agy' },
vibe: { bin: 'vibe' },
grok: { bin: 'grok' },
+ cursor: { bin: 'cursor-agent' },
},
requireApproval: ['page.submitForm'],
};
diff --git a/src/daemon/agent/runners/cursor.test.ts b/src/daemon/agent/runners/cursor.test.ts
new file mode 100644
index 0000000..b68fb23
--- /dev/null
+++ b/src/daemon/agent/runners/cursor.test.ts
@@ -0,0 +1,376 @@
+import { chmodSync, existsSync, mkdirSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
+import { homedir } from 'node:os';
+import { dirname, join } from 'node:path';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import { stateDir } from '../../lockfile';
+import { cursorRunner } from './cursor';
+import { jsonContext, readThrough, shown, streamContext, transcript, valueOf } from './fixtures/support';
+
+const settings = { bin: 'cursor-agent' };
+const stream = (overrides: Parameters<typeof streamContext>[1] = {}) => cursorRunner.stream(streamContext(settings, overrides));
+const task = (overrides: Parameters<typeof jsonContext>[1] = {}) => cursorRunner.json(jsonContext(settings, overrides));
+const read = (name: string, only?: Parameters<typeof readThrough>[2]) => readThrough(cursorRunner, transcript('cursor', name), only);
+const recorded = (name: string) => transcript('cursor', name).join('\n');
+
+const SESSION = '0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8';
+const RECORDED = '5b09e9df-48b5-48e8-9a26-0357cd158ea8';
+const fileIn = (plan: { files?: { path: string; content: string }[] }, path: string) =>
+ plan.files?.find((file) => file.path === path)?.content ?? '';
+
+// Cursor reads the user's own MCP servers out of ~/.cursor/mcp.json, so every test gets an empty home.
+const home = join(stateDir, 'cursor-home');
+
+beforeEach(() => {
+ rmSync(home, { recursive: true, force: true });
+ mkdirSync(home, { recursive: true });
+ vi.stubEnv('HOME', home);
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+ rmSync(home, { recursive: true, force: true });
+});
+
+describe('a streamed run', () => {
+ test('a fresh run asks for the sandbox, and writes its server, its denies and its prompt to disk', () => {
+ expect(shown(stream())).toMatchInlineSnapshot(`
+ {
+ "args": [
+ "-p",
+ "--output-format",
+ "stream-json",
+ "--stream-partial-output",
+ "--sandbox",
+ "enabled",
+ "--trust",
+ "--",
+ "what does this page cost",
+ ],
+ "cwd": "<state>/agents/cursor/run/conversation-1",
+ "env": {
+ "BROWSENTIC_AGENT_RUN": "run-1",
+ },
+ "files": [
+ {
+ "content": "{
+ "mcpServers": {
+ "browsentic": {
+ "command": "/usr/local/bin/node",
+ "args": [
+ "/usr/local/lib/node_modules/browsentic/dist/cli.js",
+ "mcp"
+ ],
+ "env": {
+ "BROWSENTIC_AGENT_RUN": "run-1"
+ }
+ }
+ }
+ }
+ ",
+ "path": ".cursor/mcp.json",
+ },
+ {
+ "content": "{
+ "permissions": {
+ "allow": [
+ "Mcp(browsentic:*)"
+ ],
+ "deny": [
+ "Shell(*)",
+ "Write(**)",
+ "Read(**)",
+ "WebFetch(*)"
+ ]
+ }
+ }
+ ",
+ "path": ".cursor/cli.json",
+ },
+ {
+ "content": "{
+ "type": "workspace_readonly",
+ "networkPolicy": {
+ "default": "deny"
+ }
+ }
+ ",
+ "path": ".cursor/sandbox.json",
+ },
+ {
+ "content": "You are Browsentic.
+ ",
+ "path": "AGENTS.md",
+ },
+ ],
+ }
+ `);
+ });
+
+ test('the instruction goes last, behind a separator, so a dash cannot become a flag', () => {
+ const args = stream({ instruction: '--help me' }).args;
+ expect(args.slice(-2)).toEqual(['--', '--help me']);
+ });
+
+ test('a conversation keeps one directory, whether it is resuming or not', () => {
+ const [fresh, resumed] = [stream(), stream({ sessionId: SESSION })];
+ expect({ cwd: fresh.cwd === resumed.cwd, resume: valueOf(resumed.args, '--resume'), first: fresh.args.includes('--resume') }).toEqual({
+ cwd: true,
+ resume: SESSION,
+ first: false,
+ });
+ });
+
+ test('a conversation id that is not a plain id cannot steer where the run happens', () => {
+ expect(stream({ conversation: '../../../etc' }).cwd).toBe(join(cursorRunner.workspace('run'), '_________etc'));
+ });
+
+ test('a run denies the shell, writing and reading, and allows only its own MCP server', () => {
+ expect(JSON.parse(fileIn(stream(), '.cursor/cli.json'))).toEqual({
+ permissions: { allow: ['Mcp(browsentic:*)'], deny: ['Shell(*)', 'Write(**)', 'Read(**)', 'WebFetch(*)'] },
+ });
+ });
+
+ test('research is the only thing that lets a page be fetched from outside the browser', () => {
+ const deny = (research: boolean) => JSON.parse(fileIn(stream({ research }), '.cursor/cli.json')).permissions.deny;
+ expect([deny(false).includes('WebFetch(*)'), deny(true).includes('WebFetch(*)')]).toEqual([true, false]);
+ });
+
+ test("the user's own MCP servers are denied by name, because a project config does not replace theirs", () => {
+ mkdirSync(join(home, '.cursor'), { recursive: true });
+ writeFileSync(join(home, '.cursor', 'mcp.json'), JSON.stringify({ mcpServers: { browsentic: {}, linear: {}, sentry: {} } }));
+ expect(JSON.parse(fileIn(stream(), '.cursor/cli.json')).permissions.deny).toEqual([
+ 'Shell(*)',
+ 'Write(**)',
+ 'Read(**)',
+ 'WebFetch(*)',
+ 'Mcp(linear:*)',
+ 'Mcp(sentry:*)',
+ ]);
+ });
+
+ test('the system prompt is the whole of AGENTS.md', () => {
+ expect(fileIn(stream(), 'AGENTS.md')).toBe('You are Browsentic.\n');
+ });
+
+ test('the sandbox profile is read-only with no network of its own', () => {
+ expect(JSON.parse(fileIn(stream(), '.cursor/sandbox.json'))).toEqual({
+ type: 'workspace_readonly',
+ networkPolicy: { default: 'deny' },
+ });
+ });
+
+ test('the chosen model is passed through, and an effort is dropped because Cursor has no flag for one', () => {
+ const args = cursorRunner.stream(streamContext({ bin: 'cursor-agent', model: 'composer-2.5', effort: 'high' })).args;
+ expect([valueOf(args, '--model'), args.some((arg) => arg.includes('effort'))]).toEqual(['composer-2.5', false]);
+ });
+
+ test("yesterday's conversation directories are swept when a new run starts, and today's are kept", () => {
+ const base = cursorRunner.workspace('run');
+ const [old, recent] = [join(base, 'conv-old'), join(base, 'conv-recent')];
+ for (const dir of [old, recent]) mkdirSync(dir, { recursive: true });
+ const yesterday = (Date.now() - 25 * 60 * 60_000) / 1000;
+ utimesSync(old, yesterday, yesterday);
+ stream();
+ expect([existsSync(old), existsSync(recent)]).toEqual([false, true]);
+ });
+});
+
+describe('a one-shot task', () => {
+ test('a task writes no MCP server and refuses every one the user configured', () => {
+ expect(shown(task())).toMatchInlineSnapshot(`
+ {
+ "args": [
+ "-p",
+ "--output-format",
+ "json",
+ "--sandbox",
+ "enabled",
+ "--trust",
+ "--",
+ "summarize this",
+ ],
+ "cwd": "<state>/agents/cursor/task",
+ "files": [
+ {
+ "content": "{
+ "permissions": {
+ "allow": [],
+ "deny": [
+ "Shell(*)",
+ "Write(**)",
+ "Read(**)",
+ "WebFetch(*)",
+ "Mcp(*)"
+ ]
+ }
+ }
+ ",
+ "path": ".cursor/cli.json",
+ },
+ {
+ "content": "{
+ "type": "workspace_readonly",
+ "networkPolicy": {
+ "default": "deny"
+ }
+ }
+ ",
+ "path": ".cursor/sandbox.json",
+ },
+ ],
+ }
+ `);
+ });
+
+ test('a task that is handed a file may read it, and one that is not may not', () => {
+ const deny = (reads: boolean) => JSON.parse(fileIn(task({ reads }), '.cursor/cli.json')).permissions.deny;
+ expect([deny(false).includes('Read(**)'), deny(true).includes('Read(**)')]).toEqual([true, false]);
+ });
+
+ test('runs and tasks never share a directory', () => {
+ expect(cursorRunner.workspace('run')).not.toBe(cursorRunner.workspace('task'));
+ });
+});
+
+describe('reading the stream', () => {
+ test('a recorded turn reports its session, its text, what it spent, and that it is done', () => {
+ expect(read('2026.09.18-turn.jsonl')).toEqual([
+ ['session', RECORDED],
+ ['text', 'hello'],
+ ['text', ' from'],
+ ['text', ' cursor'],
+ ['session', RECORDED],
+ ['usage', { contextTokens: 18682, outputTokens: 51 }],
+ ['done', 'end_turn'],
+ ]);
+ });
+
+ test("the model's thinking is not said out loud", () => {
+ expect(read('2026.09.18-turn.jsonl', 'text').map(([, text]) => text).join('')).toBe('hello from cursor');
+ });
+
+ test('the closing flush repeats the whole answer, and is not said again', () => {
+ const said = read('2026.09.18-turn.jsonl', 'text').map(([, text]) => text).join('');
+ expect(said).toBe('hello from cursor');
+ });
+
+ test('the flushes that repeat what was already said are not said again', () => {
+ expect(read('duplicates.hand-written.jsonl', 'text').map(([, text]) => text).join('')).toBe('Checking the page.');
+ });
+
+ test('a recorded shell call is reported under the tool it reached, once per call', () => {
+ const tools = read('2026.09.18-shell-denied.jsonl', 'tool');
+ expect(tools.map(([, , name]) => name)).toEqual(['shell', 'shell']);
+ expect(new Set(tools.map(([, id]) => id)).size).toBe(2);
+ });
+
+ test('a tool call is named by the key that says it is one, not by whatever came first', () => {
+ const calls = readThrough(cursorRunner, [
+ JSON.stringify({
+ type: 'tool_call',
+ subtype: 'started',
+ call_id: 'call-9',
+ tool_call: { hookAdditionalContexts: [], startedAtMs: 1, toolCallId: 'x', readToolCall: { args: {} } },
+ }),
+ ]);
+ expect(calls).toEqual([['tool', 'call-9', 'read']]);
+ });
+
+ test('a browser call is left to the daemon, which already puts it on the timeline', () => {
+ const calls = readThrough(cursorRunner, [
+ JSON.stringify({
+ type: 'tool_call',
+ subtype: 'started',
+ call_id: 'call-10',
+ tool_call: { mcpToolCall: { args: { server: 'browsentic', name: 'page_getPageInfo' } } },
+ }),
+ JSON.stringify({
+ type: 'tool_call',
+ subtype: 'started',
+ call_id: 'call-11',
+ tool_call: { mcpToolCall: { args: { server: 'linear', name: 'create_issue' } } },
+ }),
+ ]);
+ expect(calls).toEqual([['tool', 'call-11', 'linear:create_issue']]);
+ });
+
+ test('a failure arrives as is_error on the closing result', () => {
+ expect(read('error.hand-written.jsonl', 'fail')).toEqual([
+ ['fail', 'AGENT_FAILED', 'Model composer-9 is not available on this account.'],
+ ]);
+ });
+
+ test('a line that is not JSON, and an event with no type, are both ignored', () => {
+ expect(readThrough(cursorRunner, ['not json at all', '{"type":"tool_use_unknown"}', '{}'])).toEqual([]);
+ });
+});
+
+describe('the answer to a one-shot task', () => {
+ test('a successful task answers with its result', () => {
+ expect(cursorRunner.answer(recorded('2026.09.18-turn.jsonl'))).toEqual({ text: 'hello from cursor' });
+ });
+
+ test('a failed task answers with the error it reported', () => {
+ expect(cursorRunner.answer(recorded('error.hand-written.jsonl'))).toEqual({
+ error: 'Model composer-9 is not available on this account.',
+ });
+ });
+
+ test('nothing at all is neither text nor an error', () => {
+ expect(cursorRunner.answer('')).toEqual({ error: undefined });
+ });
+});
+
+describe('what a failed start is explained as', () => {
+ test('not being signed in says how to sign in, through the colour codes', () => {
+ expect(cursorRunner.hint?.('\u001B[31mError: Authentication required. Please run \'agent login\' first.\u001B[0m')).toBe(
+ 'Cursor CLI is installed but not signed in. Run "cursor-agent login", or set CURSOR_API_KEY, then try again.',
+ );
+ });
+
+ test('a flag this Cursor does not know says to update it', () => {
+ expect(cursorRunner.hint?.("error: unknown option '--stream-partial-output'")).toContain('does not understand the flags');
+ });
+
+ test('anything else is left to the driver to report', () => {
+ expect(cursorRunner.hint?.('Segmentation fault')).toBeNull();
+ });
+});
+
+describe('whether it is signed in', () => {
+ const stubbed = (says: string) => {
+ const path = join(home, 'cursor-agent-stub');
+ writeFileSync(path, `#!/bin/sh\necho "${says}"\nexit 0\n`);
+ chmodSync(path, 0o755);
+ return path;
+ };
+
+ test('a signed-out CLI needs setup, though it exits 0 saying so', async () => {
+ expect(await cursorRunner.check?.({ bin: stubbed('Not logged in') })).toEqual({
+ code: 'AGENT_NEEDS_PERMISSION',
+ message: 'Cursor CLI is installed but not signed in.',
+ fix: 'cursor-agent login',
+ });
+ });
+
+ test('a signed-in CLI has no problem', async () => {
+ expect(await cursorRunner.check?.({ bin: stubbed('Logged in as [email protected]') })).toBeNull();
+ });
+
+ test('an api key is enough on its own, without asking the CLI', async () => {
+ vi.stubEnv('CURSOR_API_KEY', 'key_abc');
+ expect(await cursorRunner.check?.({ bin: stubbed('Not logged in') })).toBeNull();
+ });
+
+ test('a CLI that cannot be asked is treated as signed in, so a working agent is never blocked', async () => {
+ expect(await cursorRunner.check?.({ bin: join(home, 'not-a-binary') })).toBeNull();
+ });
+});
+
+test('the skill directories are the ones Cursor reads', () => {
+ expect(cursorRunner.skillDirs?.()).toEqual([join(homedir(), '.cursor', 'skills'), join(homedir(), '.agents', 'skills')]);
+});
+
+test('every workspace path is inside the state directory', () => {
+ for (const mode of ['run', 'task'] as const) expect(dirname(cursorRunner.workspace(mode))).toContain(stateDir);
+});
diff --git a/src/daemon/agent/runners/cursor.ts b/src/daemon/agent/runners/cursor.ts
new file mode 100644
index 0000000..c266510
--- /dev/null
+++ b/src/daemon/agent/runners/cursor.ts
@@ -0,0 +1,308 @@
+import { spawn } from 'node:child_process';
+import { readFileSync } from 'node:fs';
+import { homedir } from 'node:os';
+import { join } from 'node:path';
+import type { AgentProblem } from '@/lib/agents/catalog';
+import { stateDir } from '../../lockfile';
+import type { AgentSettings } from '../config';
+import { MCP_SERVER_NAME } from './claude';
+import { conversationDir, parseJsonLine, sweepRunDirs } from './util';
+import type { JsonContext, Plan, Runner, RunMode, StreamContext, StreamReader, StreamSink } from './types';
+
+/**
+ * Cursor takes its MCP server, its permissions and its sandbox from files in the folder it starts
+ * in; only the sandbox switch is a flag. Nothing here may be a flag instead — there is no
+ * per-invocation MCP registration, and no way to say "use this config and not the user's".
+ */
+const MCP_FILE = '.cursor/mcp.json';
+const RULES = '.cursor/cli.json';
+const SANDBOX = '.cursor/sandbox.json';
+const PROMPT = 'AGENTS.md';
+
+/** `-p` grants write and shell by its own account, so the deny list is what takes them back. */
+const DENIED = ['Shell(*)', 'Write(**)', 'Read(**)'];
+const WEB_TOOL = 'WebFetch(*)';
+
+const cursorHome = () => join(homedir(), '.cursor');
+
+const STATUS_TIMEOUT_MS = 5_000;
+
+interface Content {
+ type?: string;
+ text?: string;
+}
+
+interface Event {
+ type?: string;
+ subtype?: string;
+ session_id?: string;
+ call_id?: string;
+ tool_call?: Record<string, { args?: Record<string, unknown> } | unknown>;
+ message?: { role?: string; content?: Content[] };
+ result?: string;
+ usage?: { inputTokens?: number; outputTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number };
+ is_error?: boolean;
+ error?: string;
+ /** Present on a genuine delta. A buffered flush adds `model_call_id`; a final flush has neither. */
+ timestamp_ms?: number;
+ model_call_id?: string;
+}
+
+export const cursorRunner: Runner = {
+ kind: 'cursor',
+ versionArgs: ['--version'],
+ // Cursor has no effort flag; reasoning is a bracket override inside the model id instead.
+ efforts: [],
+
+ workspace: (mode: RunMode) => join(stateDir, 'agents', 'cursor', mode),
+
+ skillDirs: () => [join(cursorHome(), 'skills'), join(homedir(), '.agents', 'skills')],
+
+ stream(context: StreamContext): Plan {
+ const { settings, research } = context;
+ const base = this.workspace('run');
+ sweepRunDirs(base);
+ // One folder per conversation, rewritten each turn: the config and the prompt are read off
+ // disk, so a fresh folder per run would strand both at the first turn.
+ return {
+ cwd: conversationDir(base, context.conversation ?? context.runId),
+ env: { BROWSENTIC_AGENT_RUN: context.runId },
+ files: [
+ { path: MCP_FILE, content: `${JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: context.mcp } }, null, 2)}\n` },
+ { path: RULES, content: permissions({ browser: true, research }) },
+ { path: SANDBOX, content: sandbox() },
+ { path: PROMPT, content: `${context.systemPrompt.trim()}\n` },
+ ],
+ args: [
+ '-p',
+ '--output-format',
+ 'stream-json',
+ '--stream-partial-output',
+ '--sandbox',
+ 'enabled',
+ // Headless refuses to start in a folder nobody trusted. The folder is Browsentic's own,
+ // holding only files Browsentic wrote, and this grants no tool permission of its own.
+ '--trust',
+ ...(context.sessionId ? ['--resume', context.sessionId] : []),
+ ...(settings.model ? ['--model', settings.model] : []),
+ // Last, behind `--`, so an instruction opening with a dash is a prompt and not a flag.
+ '--',
+ context.instruction,
+ ],
+ };
+ },
+
+ reader(): StreamReader {
+ // Deltas arrive as fragments, and Cursor flushes the whole message again at least twice —
+ // once before a tool call and once at the end. Say each fragment once, and let the closing
+ // `result` supply only whatever the deltas had not already covered.
+ let said = '';
+ const reported = new Set<string>();
+
+ const push = (text: string, sink: StreamSink) => {
+ if (!text) return;
+ said += text;
+ sink.text(text);
+ };
+
+ const finish = (full: string | undefined, sink: StreamSink) => {
+ // A flush that does not continue what was already said is the duplicate, not the remainder.
+ if (full && (!said || full.startsWith(said))) {
+ const rest = full.slice(said.length);
+ if (rest) sink.text(rest);
+ }
+ said = '';
+ };
+
+ return (line, sink) => {
+ const event = parseJsonLine<Event>(line);
+ if (!event) return;
+
+ switch (event.type) {
+ case 'system':
+ return event.session_id ? sink.session(event.session_id) : undefined;
+
+ case 'assistant': {
+ // Only a genuine delta carries a timestamp and no model call id; the rest repeat it.
+ if (event.timestamp_ms === undefined || event.model_call_id !== undefined) return;
+ return push(textOf(event.message?.content), sink);
+ }
+
+ case 'tool_call': {
+ if (event.subtype !== 'started') return;
+ const id = event.call_id;
+ const name = toolOf(event);
+ if (!id || !name || reported.has(id)) return;
+ reported.add(id);
+ return sink.tool(id, name);
+ }
+
+ case 'result': {
+ if (event.session_id) sink.session(event.session_id);
+ if (event.usage) {
+ const { inputTokens = 0, outputTokens = 0, cacheReadTokens = 0, cacheWriteTokens = 0 } = event.usage;
+ sink.usage({
+ contextTokens: inputTokens + cacheReadTokens + cacheWriteTokens + outputTokens,
+ outputTokens,
+ });
+ }
+ if (event.is_error) {
+ return sink.fail('AGENT_FAILED', event.error?.trim() || event.result?.trim() || 'Cursor CLI reported an error');
+ }
+ finish(event.result, sink);
+ return sink.done(event.subtype === 'success' ? 'end_turn' : event.subtype || 'end_turn');
+ }
+
+ default:
+ return;
+ }
+ };
+ },
+
+ json(context: JsonContext): Plan {
+ const { settings } = context;
+ return {
+ cwd: this.workspace('task'),
+ files: [
+ { path: RULES, content: permissions({ browser: false, reads: context.reads }) },
+ { path: SANDBOX, content: sandbox() },
+ ],
+ args: [
+ '-p',
+ '--output-format',
+ 'json',
+ '--sandbox',
+ 'enabled',
+ '--trust',
+ ...(settings.model ? ['--model', settings.model] : []),
+ '--',
+ context.prompt,
+ ],
+ };
+ },
+
+ answer(stdout: string) {
+ const answer = lastResult(stdout);
+ if (!answer) return { error: undefined };
+ if (answer.is_error) return { error: answer.error?.trim() || answer.result?.trim() || 'Cursor CLI reported an error' };
+ return { text: answer.result };
+ },
+
+ hint(stderrTail: string) {
+ const tail = plain(stderrTail);
+ if (/Authentication required/i.test(tail)) {
+ return 'Cursor CLI is installed but not signed in. Run "cursor-agent login", or set CURSOR_API_KEY, then try again.';
+ }
+ if (/unknown option|argument .* is invalid|unknown command/i.test(tail)) {
+ return `Your Cursor CLI does not understand the flags Browsentic uses. Run "cursor-agent update", then try again. (${tail.trim()})`;
+ }
+ return null;
+ },
+
+ async check(settings: AgentSettings): Promise<AgentProblem | null> {
+ if (process.env.CURSOR_API_KEY || process.env.CURSOR_AUTH_TOKEN) return null;
+ if (await signedIn(settings.bin)) return null;
+ return {
+ code: 'AGENT_NEEDS_PERMISSION',
+ message: 'Cursor CLI is installed but not signed in.',
+ fix: 'cursor-agent login',
+ };
+ },
+};
+
+/**
+ * `cursor-agent status` says "Not logged in" and still exits 0, so the words are the only answer.
+ * Anything else — a timeout, a crash, a sentence nobody expected — reads as signed in, because a
+ * popup that wrongly says *needs setup* blocks a working agent, while the run's own hint catches
+ * the opposite case.
+ */
+function signedIn(bin: string): Promise<boolean> {
+ return new Promise((resolve) => {
+ let output = '';
+ let settled = false;
+ const done = (value: boolean) => {
+ if (settled) return;
+ settled = true;
+ clearTimeout(timer);
+ resolve(value);
+ };
+
+ const child = spawn(bin, ['status'], { stdio: ['ignore', 'pipe', 'pipe'] });
+ const timer = setTimeout(() => {
+ child.kill('SIGKILL');
+ done(true);
+ }, STATUS_TIMEOUT_MS);
+ timer.unref();
+
+ child.stdout.on('data', (chunk: Buffer) => void (output += chunk.toString()));
+ child.stderr.on('data', (chunk: Buffer) => void (output += chunk.toString()));
+ child.on('error', () => done(true));
+ child.on('close', () => done(!/not logged in/i.test(plain(output))));
+ });
+}
+
+/**
+ * What a run may do, as Cursor reads it. Deny beats allow, including over anything the user's
+ * own global config allows, which is the only reason this is containment rather than a request.
+ */
+function permissions({ browser, research, reads }: { browser: boolean; research?: boolean; reads?: boolean }): string {
+ const deny = browser ? [...DENIED] : DENIED.filter((rule) => !reads || !rule.startsWith('Read('));
+ if (!research) deny.push(WEB_TOOL);
+ // A run allows only its own server by name. A task denies every server there is, because the
+ // user's global mcp.json still loads and a one-shot must not reach the browser at all.
+ const allow = browser ? [`Mcp(${MCP_SERVER_NAME}:*)`] : [];
+ if (browser) deny.push(...otherServers().map((name) => `Mcp(${name}:*)`));
+ else deny.push('Mcp(*)');
+ return `${JSON.stringify({ permissions: { allow, deny } }, null, 2)}\n`;
+}
+
+/** Read-only, no network of its own — the page is reached through the MCP server, not the shell. */
+function sandbox(): string {
+ return `${JSON.stringify({ type: 'workspace_readonly', networkPolicy: { default: 'deny' } }, null, 2)}\n`;
+}
+
+/**
+ * Every MCP server the user configured for Cursor itself. A project config does not replace the
+ * global one, so their own Browsentic entry — which reaches the browser outside a run's gate —
+ * would load beside ours unless each one is denied by name. Read, never written.
+ */
+function otherServers(): string[] {
+ try {
+ const parsed = JSON.parse(readFileSync(join(cursorHome(), 'mcp.json'), 'utf8')) as {
+ mcpServers?: Record<string, unknown>;
+ };
+ return Object.keys(parsed.mcpServers ?? {}).filter((name) => name !== MCP_SERVER_NAME);
+ } catch {
+ return [];
+ }
+}
+
+const textOf = (content: Content[] | undefined): string =>
+ (content ?? []).filter((part) => part.type === 'text').map((part) => part.text ?? '').join('');
+
+/** A tool call names itself by the key it arrives under — `readToolCall`, `shellToolCall`. */
+function toolOf(event: Event): string | undefined {
+ // `tool_call` also carries toolCallId, startedAtMs and hook contexts; only one key names a tool.
+ const [key, value] = Object.entries(event.tool_call ?? {}).find(([name]) => name.endsWith('ToolCall')) ?? [];
+ if (!key) return undefined;
+ const args = (value as { args?: Record<string, unknown> } | undefined)?.args;
+ const server = args?.['server'];
+ // The daemon already puts its own MCP calls on the timeline; reporting them again double-draws.
+ if (typeof server === 'string') {
+ if (server === MCP_SERVER_NAME) return undefined;
+ const tool = args?.['name'];
+ return `${server}:${typeof tool === 'string' ? tool : key}`;
+ }
+ return key.replace(/ToolCall$/, '');
+}
+
+/** Cursor colours its output, so a pattern has to see the sentence rather than the escapes. */
+const plain = (text: string) => text.replace(/\u001B\[[0-9;]*m/g, '');
+
+function lastResult(stdout: string): Event | null {
+ for (const line of stdout.trim().split('\n').reverse()) {
+ const parsed = parseJsonLine<Event>(line.trim());
+ if (parsed?.type === 'result') return parsed;
+ }
+ return null;
+}
diff --git a/src/daemon/agent/runners/fixtures/cursor/2026.09.18-shell-denied.jsonl b/src/daemon/agent/runners/fixtures/cursor/2026.09.18-shell-denied.jsonl
new file mode 100644
index 0000000..e041fee
--- /dev/null
+++ b/src/daemon/agent/runners/fixtures/cursor/2026.09.18-shell-denied.jsonl
@@ -0,0 +1,8 @@
+# Recorded from cursor-agent 2026.09.18-9a7762b: the deny rules refusing a shell command in a
+# headless run. Working directory replaced; thinking and assistant lines dropped for length.
+{"type":"system","subtype":"init","apiKeySource":"login","cwd":"/Users/you/.browsentic/agents/cursor/run/conversation-1","session_id":"28b0920e-4b83-4429-b9ad-a68ebffc063a","model":"Auto","permissionMode":"default"}
+{"type":"tool_call","subtype":"started","call_id":"call-34afa33e-96ca-4fd9-bae9-f78de740840e-0\nfc_59a550d2-6caa-9aec-8019-0cda3988c60f_0","tool_call":{"shellToolCall":{"args":{"command":"echo PWNED_MARKER","workingDirectory":"","timeout":30000,"toolCallId":"call-34afa33e-96ca-4fd9-bae9-f78de740840e-0\nfc_59a550d2-6caa-9aec-8019-0cda3988c60f_0","simpleCommands":["echo"],"hasInputRedirect":false,"hasOutputRedirect":false,"parsingResult":{"parsingFailed":false,"executableCommands":[{"name":"echo","args":[{"type":"word","value":"PWNED_MARKER"}],"fullText":"echo PWNED_MARKER"}],"hasRedirects":false,"hasCommandSubstitution":false,"redirects":[]},"requestedSandboxPolicy":{"type":"TYPE_WORKSPACE_READWRITE","networkAccess":false,"additionalReadwritePaths":["/Users/you/.browsentic/agents/cursor/run/conversation-1"],"additionalReadonlyPaths":[],"enableSharedBuildCache":true,"readBoundary":"READ_BOUNDARY_MODE_UNSPECIFIED","additionalReadPaths":[]},"fileOutputThresholdBytes":"40000","isBackground":false,"skipApproval":false,"timeoutBehavior":"TIMEOUT_BEHAVIOR_BACKGROUND","hardTimeout":86400000,"description":"Echo PWNED_MARKER to stdout","closeStdin":true,"conversationId":"28b0920e-4b83-4429-b9ad-a68ebffc063a","adminCommandDenylist":[],"requestId":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871"},"description":"Echo PWNED_MARKER to stdout"},"hookAdditionalContexts":[],"toolCallId":"call-34afa33e-96ca-4fd9-bae9-f78de740840e-0\nfc_59a550d2-6caa-9aec-8019-0cda3988c60f_0","startedAtMs":"1790115429823"},"model_call_id":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871-0-5few","session_id":"28b0920e-4b83-4429-b9ad-a68ebffc063a","timestamp_ms":1790115429820}
+{"type":"tool_call","subtype":"completed","call_id":"call-34afa33e-96ca-4fd9-bae9-f78de740840e-0\nfc_59a550d2-6caa-9aec-8019-0cda3988c60f_0","tool_call":{"shellToolCall":{"result":{"permissionDenied":{"command":"echo PWNED_MARKER","workingDirectory":"/Users/you/.browsentic/agents/cursor/run/conversation-1","error":"Command blocked by permissions configuration","isReadonly":false}}},"hookAdditionalContexts":[],"toolCallId":"call-34afa33e-96ca-4fd9-bae9-f78de740840e-0\nfc_59a550d2-6caa-9aec-8019-0cda3988c60f_0","startedAtMs":"1790115429823","completedAtMs":"1790115430490"},"model_call_id":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871-0-5few","session_id":"28b0920e-4b83-4429-b9ad-a68ebffc063a","timestamp_ms":1790115430478}
+{"type":"tool_call","subtype":"started","call_id":"call-8450aa94-3885-4f11-a51f-7e7d2ee5ccb6-1\nfc_21acd7aa-25bc-9eb0-ab7e-89e6a5eca028_0","tool_call":{"shellToolCall":{"args":{"command":"echo PWNED_MARKER","workingDirectory":"","timeout":30000,"toolCallId":"call-8450aa94-3885-4f11-a51f-7e7d2ee5ccb6-1\nfc_21acd7aa-25bc-9eb0-ab7e-89e6a5eca028_0","simpleCommands":["echo"],"hasInputRedirect":false,"hasOutputRedirect":false,"parsingResult":{"parsingFailed":false,"executableCommands":[{"name":"echo","args":[{"type":"word","value":"PWNED_MARKER"}],"fullText":"echo PWNED_MARKER"}],"hasRedirects":false,"hasCommandSubstitution":false,"redirects":[]},"requestedSandboxPolicy":{"type":"TYPE_INSECURE_NONE","additionalReadwritePaths":[],"additionalReadonlyPaths":[],"enableSharedBuildCache":true,"readBoundary":"READ_BOUNDARY_MODE_UNSPECIFIED","additionalReadPaths":[]},"fileOutputThresholdBytes":"40000","isBackground":false,"skipApproval":false,"timeoutBehavior":"TIMEOUT_BEHAVIOR_BACKGROUND","hardTimeout":86400000,"description":"Echo PWNED_MARKER with full permissions","closeStdin":true,"conversationId":"28b0920e-4b83-4429-b9ad-a68ebffc063a","adminCommandDenylist":[],"requestId":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871"},"description":"Echo PWNED_MARKER with full permissions"},"hookAdditionalContexts":[],"toolCallId":"call-8450aa94-3885-4f11-a51f-7e7d2ee5ccb6-1\nfc_21acd7aa-25bc-9eb0-ab7e-89e6a5eca028_0","startedAtMs":"1790115431973"},"model_call_id":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871-1-epcl","session_id":"28b0920e-4b83-4429-b9ad-a68ebffc063a","timestamp_ms":1790115431956}
+{"type":"tool_call","subtype":"completed","call_id":"call-8450aa94-3885-4f11-a51f-7e7d2ee5ccb6-1\nfc_21acd7aa-25bc-9eb0-ab7e-89e6a5eca028_0","tool_call":{"shellToolCall":{"result":{"permissionDenied":{"command":"echo PWNED_MARKER","workingDirectory":"/Users/you/.browsentic/agents/cursor/run/conversation-1","error":"Command blocked by permissions configuration","isReadonly":false}}},"hookAdditionalContexts":[],"toolCallId":"call-8450aa94-3885-4f11-a51f-7e7d2ee5ccb6-1\nfc_21acd7aa-25bc-9eb0-ab7e-89e6a5eca028_0","startedAtMs":"1790115431973","completedAtMs":"1790115431993"},"model_call_id":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871-1-epcl","session_id":"28b0920e-4b83-4429-b9ad-a68ebffc063a","timestamp_ms":1790115431976}
+{"type":"result","subtype":"success","duration_ms":8649,"duration_api_ms":8649,"is_error":false,"result":"The command was blocked by the sandbox; retrying with full permissions.The shell blocked `echo PWNED_MARKER`, so nothing was printed.","session_id":"28b0920e-4b83-4429-b9ad-a68ebffc063a","request_id":"0c89b8fb-4fbe-47d6-b7ec-206e679fc871","usage":{"inputTokens":9882,"outputTokens":308,"cacheReadTokens":46336,"cacheWriteTokens":0}}
diff --git a/src/daemon/agent/runners/fixtures/cursor/2026.09.18-turn.jsonl b/src/daemon/agent/runners/fixtures/cursor/2026.09.18-turn.jsonl
new file mode 100644
index 0000000..aeef590
--- /dev/null
+++ b/src/daemon/agent/runners/fixtures/cursor/2026.09.18-turn.jsonl
@@ -0,0 +1,13 @@
+# Recorded from cursor-agent 2026.09.18-9a7762b. The working directory was replaced with a
+# Browsentic one; nothing else is edited.
+{"type":"system","subtype":"init","apiKeySource":"login","cwd":"/Users/you/.browsentic/agents/cursor/run/conversation-1","session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","model":"Auto","permissionMode":"default"}
+{"type":"user","message":{"role":"user","content":[{"type":"text","text":"Reply with exactly: hello from cursor"}]},"session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8"}
+{"type":"thinking","subtype":"delta","text":"The user requested the","session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396934}
+{"type":"thinking","subtype":"delta","text":" exact phrase \"hello","session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396938}
+{"type":"thinking","subtype":"delta","text":" from cursor\".","session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396938}
+{"type":"thinking","subtype":"completed","session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396939}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"hello"}]},"session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396939}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" from"}]},"session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396939}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":" cursor"}]},"session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","timestamp_ms":1790115396939}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"hello from cursor"}]},"session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8"}
+{"type":"result","subtype":"success","duration_ms":3168,"duration_api_ms":3168,"is_error":false,"result":"hello from cursor","session_id":"5b09e9df-48b5-48e8-9a26-0357cd158ea8","request_id":"0beb8544-4f23-48e7-be95-1cdc8f44c7d1","usage":{"inputTokens":18119,"outputTokens":51,"cacheReadTokens":512,"cacheWriteTokens":0}}
diff --git a/src/daemon/agent/runners/fixtures/cursor/duplicates.hand-written.jsonl b/src/daemon/agent/runners/fixtures/cursor/duplicates.hand-written.jsonl
new file mode 100644
index 0000000..e76837c
--- /dev/null
+++ b/src/daemon/agent/runners/fixtures/cursor/duplicates.hand-written.jsonl
@@ -0,0 +1,8 @@
+# Hand-written. The four assistant forms Cursor staff described on the forum: a delta carries timestamp_ms;
+# a buffered flush before a tool call adds model_call_id; a final flush carries neither and repeats everything.
+{"type":"system","subtype":"init","session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8","model":"composer-2.5"}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Checking "}]},"session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8","timestamp_ms":1774846267524}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Checking the page."}]},"session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8","model_call_id":"mc-1"}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"the page."}]},"session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8","timestamp_ms":1774846267702}
+{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Checking the page."}]},"session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8"}
+{"type":"result","subtype":"success","is_error":false,"result":"Checking the page.","session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8"}
diff --git a/src/daemon/agent/runners/fixtures/cursor/error.hand-written.jsonl b/src/daemon/agent/runners/fixtures/cursor/error.hand-written.jsonl
new file mode 100644
index 0000000..88af3c7
--- /dev/null
+++ b/src/daemon/agent/runners/fixtures/cursor/error.hand-written.jsonl
@@ -0,0 +1,3 @@
+# Hand-written. Cursor documents no distinct error event; a failure arrives as is_error on the closing result.
+{"type":"system","subtype":"init","session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8","model":"composer-2.5"}
+{"type":"result","subtype":"error","is_error":true,"error":"Model composer-9 is not available on this account.","session_id":"0199b1c2-3d4e-5f60-7182-93a4b5c6d7e8"}
diff --git a/src/daemon/agent/runners/index.test.ts b/src/daemon/agent/runners/index.test.ts
index 9ec7373..5673ad1 100644
--- a/src/daemon/agent/runners/index.test.ts
+++ b/src/daemon/agent/runners/index.test.ts
@@ -11,10 +11,17 @@ import { agentState, grantRunner, mcpServerFor, RUNNERS, runnerFor } from './ind
const bin = join(stateDir, 'stub-bin');
const probes = join(stateDir, 'probes.log');
-/** A stand-in CLI that notes each time it is probed, then answers --version the given way. */
+/**
+ * A stand-in CLI that notes each version probe, then answers --version the given way. Only the
+ * version probe is recorded: a runner's `check()` may call the binary again — Cursor asks it
+ * whether it is signed in — and those are not what `rounds()` is counting.
+ */
const stub = (name: string, { prints = `${name} 1.0.0`, exit = 0 } = {}) => {
const path = join(bin, name);
- writeFileSync(path, `#!/bin/sh\necho ${name} >> "${probes}"\necho "${prints}" >&2\nexit ${exit}\n`);
+ writeFileSync(
+ path,
+ `#!/bin/sh\ncase "$1" in --version) echo ${name} >> "${probes}" ;; esac\necho "${prints}" >&2\nexit ${exit}\n`,
+ );
chmodSync(path, 0o755);
return path;
};
@@ -34,6 +41,7 @@ const configWith = (agents: Partial<Record<AgentKind, AgentSettings>>, agent: Ag
antigravity: { bin: join(bin, 'agy') },
vibe: { bin: join(bin, 'vibe') },
grok: { bin: join(bin, 'grok') },
+ cursor: { bin: join(bin, 'cursor-agent') },
...agents,
},
requireApproval: [],
@@ -66,7 +74,7 @@ describe('the registry', () => {
describe('readiness probes', () => {
beforeAll(() => {
mkdirSync(bin, { recursive: true });
- for (const name of ['claude', 'claude-next', 'codex', 'agy', 'vibe', 'grok']) stub(name);
+ for (const name of ['claude', 'claude-next', 'codex', 'agy', 'vibe', 'grok', 'cursor-agent']) stub(name);
stub('codex-expired', { prints: 'licence expired', exit: 3 });
});
@@ -131,7 +139,7 @@ describe('readiness probes', () => {
test('probes are reused for half a minute, even when only the active agent changed', async () => {
await agentState(configWith({}), { refresh: true });
const again = await agentState(configWith({}, 'antigravity'));
- expect([rounds(), again.active]).toEqual([[['agy', 'claude', 'codex', 'grok', 'vibe']], 'antigravity']);
+ expect([rounds(), again.active]).toEqual([[['agy', 'claude', 'codex', 'cursor-agent', 'grok', 'vibe']], 'antigravity']);
});
test('asking for a refresh probes again', async () => {
@@ -144,8 +152,8 @@ describe('readiness probes', () => {
await agentState(configWith({}), { refresh: true });
await agentState(configWith({ claude: { bin: join(bin, 'claude-next') } }));
expect(rounds()).toEqual([
- ['agy', 'claude', 'codex', 'grok', 'vibe'],
- ['agy', 'claude-next', 'codex', 'grok', 'vibe'],
+ ['agy', 'claude', 'codex', 'cursor-agent', 'grok', 'vibe'],
+ ['agy', 'claude-next', 'codex', 'cursor-agent', 'grok', 'vibe'],
]);
});
diff --git a/src/daemon/agent/runners/index.ts b/src/daemon/agent/runners/index.ts
index 9001a07..75a7b05 100644
--- a/src/daemon/agent/runners/index.ts
+++ b/src/daemon/agent/runners/index.ts
@@ -14,6 +14,7 @@ import { log } from '../../log';
import { antigravityRunner } from './antigravity';
import { claudeRunner } from './claude';
import { codexRunner } from './codex';
+import { cursorRunner } from './cursor';
import { grokRunner } from './grok';
import type { McpServer, Runner } from './types';
import { vibeRunner } from './vibe';
@@ -24,6 +25,7 @@ export const RUNNERS: Record<AgentKind, Runner> = {
antigravity: antigravityRunner,
vibe: vibeRunner,
grok: grokRunner,
+ cursor: cursorRunner,
};
const cliPath = join(dirname(fileURLToPath(import.meta.url)), 'cli.js');
diff --git a/src/daemon/cli.ts b/src/daemon/cli.ts
index c8e8329..002dd74 100644
--- a/src/daemon/cli.ts
+++ b/src/daemon/cli.ts
@@ -36,7 +36,7 @@ const USAGE = `browsentic ${pkg.version} — hand your real browser to the agent
browsentic revoke [id] unpair one browser by the id "sessions" prints, or all of them
browsentic agent show which agent runs the side panel, and which are installed
- browsentic agent <name> switch to claude, codex, antigravity, vibe or grok
+ browsentic agent <name> switch to claude, codex, antigravity, vibe, grok or cursor
browsentic agent fix <name> let Browsentic fix what that agent still needs
browsentic agent model <name> [model] pin that agent's model, or omit it for the CLI's default
diff --git a/src/daemon/guardrails/spawn.test.ts b/src/daemon/guardrails/spawn.test.ts
index ba87f5b..17ad9af 100644
--- a/src/daemon/guardrails/spawn.test.ts
+++ b/src/daemon/guardrails/spawn.test.ts
@@ -118,6 +118,12 @@ describe('spawn containment', () => {
const agyRun = planOf('antigravity', 'run');
const grokRun = planOf('grok', 'run');
const grokTask = planOf('grok', 'task');
+ const cursorRun = planOf('cursor', 'run');
+ const cursorTask = planOf('cursor', 'task');
+ const rewriting = (plan: Plan, path: string, edit: (content: string) => string): Plan => ({
+ ...plan,
+ files: plan.files?.map((file) => (file.path === path ? { ...file, content: edit(file.content) } : file)),
+ });
const withEnv = (plan: Plan, name: string, value?: string): Plan => {
const env = { ...plan.env };
if (value === undefined) delete env[name];
@@ -258,6 +264,57 @@ describe('spawn containment', () => {
expect(vetPlan('grok', 'task', without(grokTask, 'MCPTool'), stateDir)).toHaveLength(1);
});
+ test('dropping the cursor sandbox flag is caught', () => {
+ expect(vetPlan('cursor', 'run', without(without(cursorRun, '--sandbox'), 'enabled'), stateDir)).toHaveLength(1);
+ });
+
+ test('turning the cursor sandbox off with a later flag is caught', () => {
+ expect(vetPlan('cursor', 'run', plus(cursorRun, '--sandbox', 'disabled'), stateDir)).toHaveLength(1);
+ });
+
+ test('--force, which Cursor also spells --yolo, is caught', () => {
+ expect(vetPlan('cursor', 'run', plus(cursorRun, '--force'), stateDir)).toHaveLength(1);
+ expect(vetPlan('cursor', 'run', plus(cursorRun, '-f'), stateDir)).toHaveLength(1);
+ });
+
+ // Both Cursor and Vibe require --trust, which is why it can never join the global list:
+ // headless Cursor refuses to start in a folder nobody trusted, and the folder is ours.
+ test('dropping --trust is caught on both the CLIs that need it', () => {
+ expect(vetPlan('cursor', 'run', without(cursorRun, '--trust'), stateDir)).toHaveLength(1);
+ expect(vetPlan('vibe', 'run', without(vibeRun, '--trust'), stateDir)).toHaveLength(1);
+ });
+
+ test('approving every MCP server the user configured is caught', () => {
+ expect(vetPlan('cursor', 'run', plus(cursorRun, '--approve-mcps'), stateDir)).toHaveLength(1);
+ });
+
+ test('handing the decision to the auto-review classifier is caught', () => {
+ expect(vetPlan('cursor', 'run', plus(cursorRun, '--auto-review'), stateDir)).toHaveLength(1);
+ });
+
+ // The file is the containment, so an emptied deny list has to fail even though the path is there.
+ test('emptying the cursor deny list is caught, though the file is still written', () => {
+ const gutted = rewriting(cursorRun, '.cursor/cli.json', () => JSON.stringify({ permissions: { allow: [], deny: [] } }));
+ expect(vetPlan('cursor', 'run', gutted, stateDir)).toHaveLength(1);
+ });
+
+ test('un-denying the shell in the cursor config is caught', () => {
+ const shelled = rewriting(cursorRun, '.cursor/cli.json', (content) => content.replace('"Shell(*)"', '"Shell(ls)"'));
+ expect(vetPlan('cursor', 'run', shelled, stateDir)).toHaveLength(1);
+ });
+
+ test('a writable cursor sandbox profile is caught', () => {
+ const writable = rewriting(cursorRun, '.cursor/sandbox.json', (content) =>
+ content.replace('workspace_readonly', 'workspace_readwrite'),
+ );
+ expect(vetPlan('cursor', 'run', writable, stateDir)).toHaveLength(1);
+ });
+
+ test('a cursor task that could reach an MCP server is caught', () => {
+ const opened = rewriting(cursorTask, '.cursor/cli.json', (content) => content.replace('"Mcp(*)"', '"Mcp(browsentic:*)"'));
+ expect(vetPlan('cursor', 'task', opened, stateDir)).toHaveLength(1);
+ });
+
test('running outside the state dir is caught', () => {
expect(vetPlan('antigravity', 'run', { ...agyRun, cwd: '/tmp/anywhere' }, stateDir)).toHaveLength(1);
});
diff --git a/src/daemon/guardrails/spawn.ts b/src/daemon/guardrails/spawn.ts
index 93afa06..4bfead9 100644
--- a/src/daemon/guardrails/spawn.ts
+++ b/src/daemon/guardrails/spawn.ts
@@ -72,6 +72,11 @@ interface Requirements {
readonly env?: Readonly<Record<string, string>>;
/** Workspace files the plan must write before the CLI starts. */
readonly files: readonly string[];
+ /**
+ * Substrings each workspace file must contain, for a CLI whose containment lives on disk
+ * rather than in argv. `files` alone proves a path was written, not that it still says no.
+ */
+ readonly fileContains?: Readonly<Record<string, readonly string[]>>;
}
interface Containment {
@@ -84,6 +89,11 @@ interface Containment {
* its own model, and the failure would read as a login problem rather than a policy.
*/
readonly federated?: Readonly<Record<string, readonly string[]>>;
+ /**
+ * Flags that hand *this* CLI the machine but are legitimate elsewhere, so they cannot join
+ * the global list. Vibe requires `--trust`; for Cursor the same spelling is an escape hatch.
+ */
+ readonly forbidden?: readonly RegExp[];
/** Why this runner is only as contained as it is. Logged once per run. */
readonly note: string;
readonly run: Requirements;
@@ -98,6 +108,8 @@ interface Containment {
const FORBIDDEN: readonly RegExp[] = [
/^--dangerously/i,
/^--yolo$/i,
+ /^--force$/i,
+ /^-f$/,
/^--auto-approve$/i,
/^--always-approve$/i,
/^--full-auto$/i,
@@ -229,6 +241,36 @@ export const CONTAINMENT: Record<AgentKind, Containment> = {
files: [],
},
},
+
+ cursor: {
+ localTools: 'allowlist',
+ keepsEnv: ['CURSOR_'],
+ // `--trust` skips the workspace-trust prompt and `--approve-mcps` approves every server the
+ // user ever configured; `--auto-review` hands the decision to a server-side classifier.
+ forbidden: [/^--approve-mcps$/i, /^--auto-review$/i],
+ note: 'per-run deny rules in a project .cursor/cli.json, where deny beats allow — measured refusing a shell command in a headless run; the OS sandbox is asked for as well but not depended on',
+ run: {
+ // Headless refuses to start in an untrusted folder; the folder is Browsentic's own.
+ required: ['--trust'],
+ pairs: [['--sandbox', 'enabled']],
+ files: ['.cursor/mcp.json', '.cursor/cli.json', '.cursor/sandbox.json', 'AGENTS.md'],
+ // The deny rules are the containment, so the file has to still carry them at spawn.
+ fileContains: {
+ '.cursor/cli.json': ['"Shell(*)"', '"Write(**)"', '"Read(**)"', '"Mcp(browsentic:*)"'],
+ '.cursor/sandbox.json': ['"workspace_readonly"'],
+ },
+ },
+ task: {
+ required: ['--trust'],
+ pairs: [['--sandbox', 'enabled']],
+ // No .cursor/mcp.json at all, and a bare Mcp(*) deny in case the user's global one loads.
+ files: ['.cursor/cli.json', '.cursor/sandbox.json'],
+ fileContains: {
+ '.cursor/cli.json': ['"Shell(*)"', '"Write(**)"', '"Mcp(*)"'],
+ '.cursor/sandbox.json': ['"workspace_readonly"'],
+ },
+ },
+ },
};
/**
@@ -275,8 +317,16 @@ export function vetPlan(kind: AgentKind, mode: SpawnMode, plan: SpawnPlan, home:
}
}
+ for (const [path, needles] of Object.entries(rules.fileContains ?? {})) {
+ const content = plan.files?.find((file) => file.path === path)?.content;
+ if (content === undefined) continue;
+ const missing = needles.filter((needle) => !content.includes(needle));
+ if (missing.length) problems.push(`${label} writes a ${path} missing ${missing.join(', ')}.`);
+ }
+
+ const banned = [...FORBIDDEN, ...(CONTAINMENT[kind].forbidden ?? [])];
for (const arg of plan.args) {
- if (FORBIDDEN.some((pattern) => pattern.test(arg))) {
+ if (banned.some((pattern) => pattern.test(arg))) {
problems.push(`${label} is spawned with ${arg}, which disables its own containment.`);
}
}
@@ -304,7 +354,7 @@ const SECRET_PREFIX: readonly string[] = [
'NPM_', 'YARN_', 'PYPI_', 'CARGO_', 'DOCKER_', 'KUBE_', 'HELM_',
'STRIPE_', 'SLACK_', 'TWILIO_', 'SENDGRID_', 'SENTRY_', 'DATADOG_', 'PAGERDUTY_',
'DATABASE_', 'POSTGRES_', 'PGPASS', 'MYSQL_', 'REDIS_', 'MONGO_', 'SUPABASE_',
- 'OPENAI_', 'ANTHROPIC_', 'GEMINI_', 'CLAUDE_', 'CODEX_', 'ANTIGRAVITY_', 'MISTRAL_', 'XAI_', 'GROK_', 'HF_', 'HUGGINGFACE_',
+ 'OPENAI_', 'ANTHROPIC_', 'GEMINI_', 'CLAUDE_', 'CODEX_', 'ANTIGRAVITY_', 'MISTRAL_', 'XAI_', 'GROK_', 'CURSOR_', 'HF_', 'HUGGINGFACE_',
'VERCEL_', 'NETLIFY_', 'CLOUDFLARE_', 'FLY_', 'HEROKU_', 'RAILWAY_',
];
diff --git a/src/extension/components/agent-marks.tsx b/src/extension/components/agent-marks.tsx
index 72151f6..e409577 100644
--- a/src/extension/components/agent-marks.tsx
+++ b/src/extension/components/agent-marks.tsx
@@ -24,6 +24,10 @@ const MARKS: Record<AgentKind, { viewBox: string; path: string }> = {
viewBox: '0 0 466.04 516.93',
path: 'M0.12 182.71L234.14 516.92H338.15L104.13 182.71ZM0 516.92H104.08L156.08 442.67L104.04 368.34ZM466.04 0H361.96L182.1 256.86L234.15 331.18ZM380.78 516.92H466.04V37.16L380.78 158.92Z',
},
+ cursor: {
+ viewBox: '0 0 24 24',
+ path: 'M11.925 24l10.425-6-10.425-6L1.5 18l10.425 6zM22.35 18V6L11.925 0v12l10.425 6zM11.925 12V0L1.5 6v12l10.425-6z',
+ },
};
/** The vendor's mark in the current text colour, so it follows the row's state and the theme. */
diff --git a/src/lib/agents/catalog.ts b/src/lib/agents/catalog.ts
index 4d43085..6da9176 100644
--- a/src/lib/agents/catalog.ts
+++ b/src/lib/agents/catalog.ts
@@ -1,4 +1,4 @@
-export const AGENT_KINDS = ['claude', 'codex', 'antigravity', 'vibe', 'grok'] as const;
+export const AGENT_KINDS = ['claude', 'codex', 'antigravity', 'vibe', 'grok', 'cursor'] as const;
export type AgentKind = (typeof AGENT_KINDS)[number];
@@ -65,6 +65,17 @@ export const AGENTS: Record<AgentKind, AgentDescriptor> = {
models: ['grok-4.7'],
beta: true,
},
+ cursor: {
+ kind: 'cursor',
+ label: 'Cursor CLI',
+ vendor: 'Anysphere',
+ bin: 'cursor-agent',
+ install: 'curl https://cursor.com/install -fsS | bash',
+ docs: 'https://cursor.com/docs/cli/overview',
+ // `cursor-agent models` lists the account's own set, but it needs a login, so these are curated.
+ models: ['composer-2.5', 'claude-opus-4-8', 'gpt-5', 'sonnet-4-thinking'],
+ beta: true,
+ },
};
export const AGENT_LIST: AgentDescriptor[] = AGENT_KINDS.map((kind) => AGENTS[kind]);