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.
TypeScript agentic-browseragentic-browsingagy-cliaiai-agentai-browser-extensionai-toolsbrave-extensionbrowser-agentbrowser-automationbrowser-extensionbrowser-usebrowserskillchrome-extensionclaude-codecodexfirefox-addonmcp-servernanobrowserweb-automation
fix(agents): the OpenCode 2 sign-in line for Windows puts the PowerShell window's own OPENCODE_DB back once it ends, so OpenCode run there afterwards opens the user's database and never starts their background service on Browsentic's
Shahriarccf42b62abf8
diff --git a/docs/guide/agents.md b/docs/guide/agents.mdindex 1fbea3f..78dffae 100644--- a/docs/guide/agents.md+++ b/docs/guide/agents.md@@ -316,7 +316,9 @@ What both lines share:sessions, and Browsentic runs keep a database apart from yours, so your own sign-in does not carryover. The agent picker shows the one line to run, which signs that database in; on macOS and Linuxit is `OPENCODE_DB="$HOME/.browsentic/agents/opencode/opencode-2.db" opencode auth login --standalone`.- An `OPENCODE_API_KEY` in the environment, or a provider in your config, counts too.+ On Windows the line is for PowerShell, and it puts the window's own `OPENCODE_DB` back once the+ sign-in ends, so OpenCode run there afterwards still opens your database. An `OPENCODE_API_KEY` in+ the environment, or a provider in your config, counts too.- **Your sessions and your background service are never touched.** Every run starts its own privateOpenCode server rather than the shared one, so a run is never added to your session list and yourservice never picks one up.diff --git a/src/daemon/agent/runners/opencode.test.ts b/src/daemon/agent/runners/opencode.test.tsindex ba1d2c3..249fe9a 100644--- a/src/daemon/agent/runners/opencode.test.ts+++ b/src/daemon/agent/runners/opencode.test.ts@@ -606,9 +606,12 @@ describe('OpenCode 2 readiness', () => {expect(await problem('/nonexistent/opencode')).toBeNull();});- test('the sign-in line points OpenCode at that database, quoted for the shell it runs in', () => {+ test('the sign-in line points OpenCode at that database, quoted for the shell it runs in, and leaves a PowerShell window as it was', () => {expect(signInLine('opencode', 'darwin')).toBe(`OPENCODE_DB='${db}' opencode auth login --standalone`);expect(signInLine("/Users/o'neil/bin/opencode 2", 'darwin')).toBe(`OPENCODE_DB='${db}' '/Users/o'\\''neil/bin/opencode 2' auth login --standalone`);- expect(signInLine('C:\\Program Files\\opencode.cmd', 'win32')).toBe(`$env:OPENCODE_DB='${db}'; & 'C:\\Program Files\\opencode.cmd' auth login --standalone`);+ expect(signInLine("C:\\Users\\o'neil\\opencode.cmd", 'win32')).toBe(+ `$before = $env:OPENCODE_DB; $env:OPENCODE_DB = '${db.replaceAll("'", "''")}'; ` ++ `try { & 'C:\\Users\\o''neil\\opencode.cmd' auth login --standalone } finally { $env:OPENCODE_DB = $before }`,+ );});});diff --git a/src/daemon/agent/runners/opencode.ts b/src/daemon/agent/runners/opencode.tsindex 8a1e796..5ccb151 100644--- a/src/daemon/agent/runners/opencode.ts+++ b/src/daemon/agent/runners/opencode.ts@@ -430,10 +430,17 @@ function scratchReads(workspace: string): Record<string, string> {}}-/** The command that signs Browsentic's own OpenCode 2 database in, in the user's shell. */+/**+ * The command that signs Browsentic's own OpenCode 2 database in, in the user's shell. PowerShell has+ * no variable for one command, so its line puts back what the window had: the user's own `opencode`+ * there would otherwise open this database, and start their background service on it.+ */export function signInLine(bin: string, platform: NodeJS.Platform = process.platform): string {const db = database2();- if (platform === 'win32') return `$env:OPENCODE_DB='${db.replaceAll("'", "''")}'; & '${bin.replaceAll("'", "''")}' auth login --standalone`;+ if (platform === 'win32') {+ const literal = (value: string) => `'${value.replaceAll("'", "''")}'`;+ return `$before = $env:OPENCODE_DB; $env:OPENCODE_DB = ${literal(db)}; try { & ${literal(bin)} auth login --standalone } finally { $env:OPENCODE_DB = $before }`;+ }const quote = (value: string) => `'${value.replaceAll("'", `'\\''`)}'`;return `OPENCODE_DB=${quote(db)} ${/^[\w./-]+$/.test(bin) ? bin : quote(bin)} auth login --standalone`;}