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.

test(daemon): expect paths as the platform spells them, tell a stopped agent by its pid rather than a SIGTERM handler, start the Codex stand-ins through stubCli, and skip on Windows only what needs POSIX modes or signals

Shahriar081613d9b13e
diff --git a/src/daemon/agent/runners/antigravity.test.ts b/src/daemon/agent/runners/antigravity.test.ts
index c2ed1d9..7102180 100644
--- a/src/daemon/agent/runners/antigravity.test.ts
+++ b/src/daemon/agent/runners/antigravity.test.ts
@@ -75,11 +75,11 @@ describe('a streamed run', () => {
});
test('a run with no conversation keeps a folder of its own', () => {
- expect(stream({ conversation: null }).cwd).toBe(`${stateDir}/agents/antigravity/run/run-1`);
+ expect(stream({ conversation: null }).cwd).toBe(join(stateDir, 'agents', 'antigravity', 'run', 'run-1'));
});
test('a conversation id is spelled so it stays one path segment', () => {
- expect(stream({ conversation: '../../escape me' }).cwd).toBe(`${stateDir}/agents/antigravity/run/______escape_me`);
+ expect(stream({ conversation: '../../escape me' }).cwd).toBe(join(stateDir, 'agents', 'antigravity', 'run', '______escape_me'));
});
// Antigravity takes no per-run tool list, so only the prompt keeps it off the web.
@@ -340,7 +340,7 @@ describe("the user's own skills", () => {
test('are listed from each root in its skills index', () => {
mkdirSync(dirname(index), { recursive: true });
writeFileSync(index, '/work/team-skills\n\n /Users/me/antigravity \n');
- expect(antigravityRunner.skillDirs?.()).toEqual(['/work/team-skills/skills', '/Users/me/antigravity/skills']);
+ expect(antigravityRunner.skillDirs?.()).toEqual([join('/work/team-skills', 'skills'), join('/Users/me/antigravity', 'skills')]);
});
test('are none when there is no index', () => {
diff --git a/src/daemon/agent/runners/drive.test.ts b/src/daemon/agent/runners/drive.test.ts
index 4a11e38..c23e80b 100644
--- a/src/daemon/agent/runners/drive.test.ts
+++ b/src/daemon/agent/runners/drive.test.ts
@@ -1,5 +1,5 @@
import { once } from 'node:events';
-import { existsSync, readFileSync, rmSync, statSync, utimesSync, writeFileSync } from 'node:fs';
+import { existsSync, readFileSync, rmSync, statSync, utimesSync } from 'node:fs';
import { join } from 'node:path';
import type { Readable } from 'node:stream';
import { afterEach, describe, expect, test, vi } from 'vitest';
@@ -10,7 +10,7 @@ import { configPath } from '../config';
import { antigravityRunner } from './antigravity';
import { codexRunner } from './codex';
import { launch, runJson, runStream } from './drive';
-import { jsonContext, streamContext } from './fixtures/support';
+import { jsonContext, streamContext, stubCli } from './fixtures/support';
import { RunError, type Plan, type Runner, type StreamReader, type StreamSink } from './types';
import { bits, modeOf } from '../../test/modes';
@@ -153,12 +153,13 @@ describe('a streamed run', () => {
});
test('a failure the reader reports stops the agent, rather than leaving it running unwatched', async () => {
- const stopped = join(stateDir, 'stopped-after-fail');
+ const pidFile = join(stateDir, 'stopped-after-fail');
+ rmSync(pidFile, { force: true });
const script =
- `process.on('SIGTERM', () => { require('node:fs').writeFileSync(${JSON.stringify(stopped)}, 'stopped'); process.exit(0); });` +
+ `require('node:fs').writeFileSync(${JSON.stringify(pidFile)}, String(process.pid));` +
`${printing(['fail', 'AGENT_UNSAFE', 'offered the shell'])} setInterval(() => {}, 1000);`;
const refused = await failure(run(standIn(script)));
- await vi.waitFor(() => expect(existsSync(stopped)).toBe(true));
+ await vi.waitFor(() => expect(alive(Number(readFileSync(pidFile, 'utf8')))).toBe(false));
expect(refused).toEqual({ code: 'AGENT_UNSAFE', message: 'offered the shell' });
});
@@ -201,13 +202,11 @@ describe('a streamed run', () => {
* It notes each subcommand it was started with, then plays the part `behaviour` gives it.
*/
function codexStandIn(name: string, behaviour: string): { bin: string; started: () => string[] } {
- const bin = join(stateDir, `${name}.js`);
const log = join(stateDir, `${name}.log`);
rmSync(log, { force: true });
- writeFileSync(
- bin,
- `#!${process.execPath}\nconst fs = require('node:fs');\nfs.appendFileSync(${JSON.stringify(log)}, process.argv[2] + '\\n');\n${behaviour}\n`,
- { mode: 0o755 },
+ const bin = stubCli(
+ join(stateDir, name),
+ `const fs = require('node:fs');\nfs.appendFileSync(${JSON.stringify(log)}, process.argv[2] + '\\n');\n${behaviour}\n`,
);
return { bin, started: () => (existsSync(log) ? readFileSync(log, 'utf8').trim().split('\n') : []) };
}
@@ -302,7 +301,8 @@ describe('what reaches the process', () => {
expect(JSON.parse(answer)).toEqual({ present: ['GEMINI_API_KEY'], run: null });
});
- test('aborting asks the agent to stop, and only kills it once the grace period is over', async () => {
+ // Windows has no signal to ask with: a stop there ends the agent and what it started at once.
+ test.skipIf(process.platform === 'win32')('aborting asks the agent to stop, and only kills it once the grace period is over', async () => {
const controller = new AbortController();
const script = `process.on('SIGTERM', () => console.log('asked to stop')); console.log('ready'); setInterval(() => {}, 1000);`;
const plan = { ...antigravityRunner.stream(streamContext(node, { runId: 'stubborn-run' })), args: ['-e', script] };
@@ -328,8 +328,8 @@ describe('what reaches the process', () => {
test('a run whose signal already fired is stopped the moment it starts', async () => {
const plan = { ...antigravityRunner.stream(streamContext(node, { runId: 'late-run' })), args: ['-e', 'setInterval(() => {}, 1000);'] };
const { child } = launch('antigravity', 'run', node, plan, AbortSignal.abort());
- const [, signal] = await once(child, 'exit');
- expect(signal).toBe('SIGTERM');
+ const [code, signal] = await once(child, 'exit');
+ expect(signal ?? code).toBe(process.platform === 'win32' ? 1 : 'SIGTERM');
});
});
@@ -369,10 +369,10 @@ describe('a one-shot task', () => {
});
test('an answer the caller accepts ends the task there, and the agent is stopped rather than waited out', async () => {
- const marker = join(stateDir, 'stopped-after-answering');
- rmSync(marker, { force: true });
+ const pidFile = join(stateDir, 'stopped-after-answering');
+ rmSync(pidFile, { force: true });
const lingering = standIn(
- `process.on('SIGTERM', () => { require('node:fs').writeFileSync(${JSON.stringify(marker)}, 'stopped'); process.exit(0); });` +
+ `require('node:fs').writeFileSync(${JSON.stringify(pidFile)}, String(process.pid));` +
`${printing({ result: { status: 'success', response: 'A pricing page.' } })} setInterval(() => {}, 1000);`,
);
const answer = await runJson(lingering, jsonContext(node), new AbortController().signal, {
@@ -380,7 +380,7 @@ describe('a one-shot task', () => {
empty: 'The agent said nothing.',
accept: (text) => text.endsWith('.'),
});
- await vi.waitFor(() => expect(existsSync(marker)).toBe(true));
+ await vi.waitFor(() => expect(alive(Number(readFileSync(pidFile, 'utf8')))).toBe(false));
expect(answer).toBe('A pricing page.');
});
@@ -404,3 +404,12 @@ function printed(stream: Readable, word: string): Promise<void> {
stream.on('data', listen);
});
}
+
+function alive(pid: number): boolean {
+ try {
+ process.kill(pid, 0);
+ return true;
+ } catch {
+ return false;
+ }
+}
diff --git a/src/daemon/agent/runners/grok.test.ts b/src/daemon/agent/runners/grok.test.ts
index 097feef..5606e35 100644
--- a/src/daemon/agent/runners/grok.test.ts
+++ b/src/daemon/agent/runners/grok.test.ts
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
import { basename, dirname, join } from 'node:path';
import { afterEach, describe, expect, test, vi } from 'vitest';
import { stateDir } from '../../lockfile';
+import { within } from '../../guardrails/spawn';
import { grokRunner } from './grok';
import { jsonContext, readThrough, shown, streamContext, transcript, valueOf } from './fixtures/support';
@@ -327,5 +328,5 @@ test("the user's own skills are listed from Grok's home, the shared agents folde
});
test('every directory a run or task uses is inside the state directory', () => {
- expect([stream().cwd, task().cwd].every((cwd) => cwd.startsWith(`${stateDir}/`))).toBe(true);
+ expect([stream().cwd, task().cwd].every((cwd) => cwd !== stateDir && within(cwd, stateDir))).toBe(true);
});
diff --git a/src/daemon/agent/runners/vibe.test.ts b/src/daemon/agent/runners/vibe.test.ts
index 54f6cc4..f363af2 100644
--- a/src/daemon/agent/runners/vibe.test.ts
+++ b/src/daemon/agent/runners/vibe.test.ts
@@ -1,3 +1,4 @@
+import { join } from 'node:path';
import { describe, expect, test } from 'vitest';
import { stateDir } from '../../lockfile';
import { jsonContext, shown, streamContext } from './fixtures/support';
@@ -85,11 +86,11 @@ describe('a streamed run', () => {
});
test('a run with no conversation keeps a folder of its own', () => {
- expect(stream({ conversation: null }).cwd).toBe(`${stateDir}/agents/vibe/run/run-1`);
+ expect(stream({ conversation: null }).cwd).toBe(join(stateDir, 'agents', 'vibe', 'run', 'run-1'));
});
test('a conversation id is spelled so it stays one path segment', () => {
- expect(stream({ conversation: '../../escape me' }).cwd).toBe(`${stateDir}/agents/vibe/run/______escape_me`);
+ expect(stream({ conversation: '../../escape me' }).cwd).toBe(join(stateDir, 'agents', 'vibe', 'run', '______escape_me'));
});
test('research adds the web tools to the allowlist, and nothing else is switched on', () => {
@@ -102,7 +103,7 @@ describe('a streamed run', () => {
describe('a one-shot task', () => {
test('a task reaches no browser and switches no tool on', () => {
const plan = vibeRunner.json(jsonContext(settings));
- expect(plan.cwd).toBe(`${stateDir}/agents/vibe/task`);
+ expect(plan.cwd).toBe(join(stateDir, 'agents', 'vibe', 'task'));
expect(plan.args).toContain('re:^$');
expect(fileIn(plan, '.vibe/config.toml')).not.toContain('mcp_servers');
});
diff --git a/src/daemon/agent/site-map-store.test.ts b/src/daemon/agent/site-map-store.test.ts
index 8c308d8..33726c8 100644
--- a/src/daemon/agent/site-map-store.test.ts
+++ b/src/daemon/agent/site-map-store.test.ts
@@ -131,7 +131,7 @@ describe('staging a map', () => {
test('the staged map is a machine-generated site skill that records what was seen', () => {
vi.useFakeTimers({ now: new Date('2026-09-21T10:00:00Z'), toFake: ['Date'] });
const { draft } = stage({ background: 'Founded in 2019.' });
- expect(draft.markdown.replaceAll(skills(), '<skills>')).toMatchInlineSnapshot(`
+ expect(draft.markdown.replaceAll(join(skills(), 'example-com', 'screenshots'), '<skills>/example-com/screenshots')).toMatchInlineSnapshot(`
"---
name: example-com
description: Machine-generated map of example.com — 2 pages, 2026-09-21.
diff --git a/src/daemon/install.test.ts b/src/daemon/install.test.ts
index 55cbee4..22c69d6 100644
--- a/src/daemon/install.test.ts
+++ b/src/daemon/install.test.ts
@@ -1,5 +1,5 @@
import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
-import { dirname, join } from 'node:path';
+import { dirname, join, sep } from 'node:path';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { install, InstallError, readStamp } from './install';
import { stateDir } from './lockfile';
@@ -28,7 +28,7 @@ const release = (version: string, files: Record<string, string> = {}) => {
const installed = () =>
readdirSync(target, { recursive: true, withFileTypes: true })
.filter((entry) => entry.isFile())
- .map((entry) => join(entry.parentPath, entry.name).slice(target.length + 1))
+ .map((entry) => join(entry.parentPath, entry.name).slice(target.length + 1).replaceAll(sep, '/'))
.sort();
beforeEach(() => {
@@ -82,7 +82,8 @@ describe('installing the extension', () => {
expect(installed()).not.toContain('background.js.tmp-4242');
});
- test('a file the browser will not let go of is explained, with what to do', () => {
+ // A read-only folder stands in for a file the browser holds open; Windows folders have no such mode.
+ test.skipIf(process.platform === 'win32')('a file the browser will not let go of is explained, with what to do', () => {
install(target);
release('1.3.0', { 'background.js': 'bg v2' });
chmodSync(target, 0o555);
diff --git a/src/daemon/uninstall.test.ts b/src/daemon/uninstall.test.ts
index 285b830..5bc387d 100644
--- a/src/daemon/uninstall.test.ts
+++ b/src/daemon/uninstall.test.ts
@@ -121,7 +121,8 @@ describe('purging npx caches', () => {
expect([purged.removed, existsSync(dir)]).toEqual([true, false]);
});
- test('a cache that cannot be deleted is reported rather than stopping the uninstall', () => {
+ // A read-only folder stands in for a cache that cannot be deleted; Windows folders have no such mode.
+ test.skipIf(process.platform === 'win32')('a cache that cannot be deleted is reported rather than stopping the uninstall', () => {
const root = join(homedir(), '.npm', '_npx');
const dir = npxEntry(root, 'h8', '0.6.0');
chmodSync(root, 0o555);