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.

fix(agents): allow OpenCode's scratch-folder read in both spellings of a Windows path, since which one it matches there is unmeasured, and build macOS and Linux native-host folders as POSIX paths wherever they are worked out

Shahriar0c68b7b35835
diff --git a/src/daemon/agent/runners/opencode.test.ts b/src/daemon/agent/runners/opencode.test.ts
index d038aa2..556cd2f 100644
--- a/src/daemon/agent/runners/opencode.test.ts
+++ b/src/daemon/agent/runners/opencode.test.ts
@@ -1,5 +1,5 @@
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
-import { join } from 'node:path';
+import { join, parse, relative, sep } from 'node:path';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { stateDir } from '../../lockfile';
import { opencodeRunner } from './opencode';
@@ -156,7 +156,8 @@ describe('a one-shot', () => {
const read = rulesOf(task({ reads: true })).read as Record<string, string>;
const scratch = join(opencodeRunner.workspace('task'), 'tmp');
expect(read['*']).toBe('deny');
- expect(read[`${scratch.slice(1)}/*`]).toBe('allow');
+ const fromTop = relative(parse(scratch).root, scratch);
+ expect([read[`${fromTop.replaceAll(sep, '/')}/*`], read[`${fromTop}${sep}*`]]).toEqual(['allow', 'allow']);
expect(read['task/tmp/*']).toBe('allow');
});
diff --git a/src/daemon/agent/runners/opencode.ts b/src/daemon/agent/runners/opencode.ts
index 64ca0fe..d6e0976 100644
--- a/src/daemon/agent/runners/opencode.ts
+++ b/src/daemon/agent/runners/opencode.ts
@@ -1,7 +1,7 @@
import { randomUUID } from 'node:crypto';
import { readFileSync } from 'node:fs';
import { homedir } from 'node:os';
-import { dirname, join, relative } from 'node:path';
+import { dirname, join, relative, sep } from 'node:path';
import type { AgentProblem } from '@/lib/agents/catalog';
import { stateDir } from '../../lockfile';
import { MCP_SERVER_NAME } from './claude';
@@ -243,7 +243,10 @@ function scratchReads(workspace: string): Record<string, string> {
const scratch = join(workspace, 'tmp');
const rules: Record<string, string> = { '*': 'deny' };
for (let root = dirname(workspace); ; root = dirname(root)) {
- rules[`${relative(root, scratch)}/*`] = 'allow';
+ const seen = relative(root, scratch);
+ rules[`${seen.replaceAll(sep, '/')}/*`] = 'allow';
+ // Windows spells it with backslashes. Which spelling OpenCode matches there is unmeasured, and each names only the scratch folder.
+ if (sep !== '/') rules[`${seen}${sep}*`] = 'allow';
if (root === dirname(root)) return rules;
}
}
diff --git a/src/daemon/native-host.ts b/src/daemon/native-host.ts
index d33fe4f..81e1a5c 100644
--- a/src/daemon/native-host.ts
+++ b/src/daemon/native-host.ts
@@ -10,7 +10,7 @@ import { NATIVE_HOST_NAME } from '@/lib/actions/protocol';
import { createHash } from 'node:crypto';
import { chmodSync, existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
-import { join } from 'node:path';
+import { join, posix } from 'node:path';
import { listSessions } from './auth-store';
import { readAgentConfig } from './agent/config';
import { stateDir } from './lockfile';
@@ -63,12 +63,12 @@ const WINDOWS_BROWSERS: [string, Family, string][] = [
export function hostTargets(platform: NodeJS.Platform = process.platform, home = homedir()): HostTarget[] {
if (platform === 'darwin') {
- const support = join(home, 'Library', 'Application Support');
+ const support = posix.join(home, 'Library', 'Application Support');
return MAC_BROWSERS.map(([browser, family, dir]) => ({
browser,
family,
- home: join(support, dir),
- manifestDir: join(support, dir, 'NativeMessagingHosts'),
+ home: posix.join(support, dir),
+ manifestDir: posix.join(support, dir, 'NativeMessagingHosts'),
}));
}
if (platform === 'win32') {
@@ -82,8 +82,8 @@ export function hostTargets(platform: NodeJS.Platform = process.platform, home =
return LINUX_BROWSERS.map(([browser, family, dir, manifests]) => ({
browser,
family,
- home: join(home, dir),
- manifestDir: join(home, manifests),
+ home: posix.join(home, dir),
+ manifestDir: posix.join(home, manifests),
}));
}