mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
OpenCode Browser lets AI agents use the user's real Chromium browser (Chrome, Edge, Brave, Opera, Vivaldi, Chromium, Helium, Arc). It has no chat UI: agents drive it through the `browse` MCP server (added in the next commit), which talks to it through a local relay: agent - browse MCP (stdio) - relay 127.0.0.1:19988 - WebSocket - extension The extension (src/): - background/agent-relay.ts: the WebSocket link to the relay. Runs its commands (CDP through chrome.debugger, tabs, groups, badges, tab-capture recordings) and reports tab events; reconnects with backoff; survives an extension reload or worker restart by re-attaching its tabs (debugger-hub.ts). Commands it doesn't know get an error reply instead of leaving the relay waiting. - agent-groups.ts, tab-cleanup.ts: agent tabs are grouped under the session's name at the start of the tab strip, collapsed unless the user is looking at one; agent tabs nobody uses for 10 minutes close. - background/index.ts: the toolbar button lets agents use the current tab, or stops them (badge ON / RUN / WAIT). - content/page-status.ts: the in-page banner while an agent works or waits for a handoff (login, 2FA, payment), with Continue. - status/ (welcome.html, also the options page): install command, relay connection, reconnect, close agent tabs, copy diagnostics. Permissions: debugger, tabs, tabGroups, storage, alarms, offscreen and tabCapture (recordings), <all_urls> (agents work on any site the user asks; the banner content script). The manifest key pins the unpacked ID (afeafocngkodbmaipcngoamamfmekgfo); the store build is mfnicocicmmlkpjnaffgihfjhdgjkdjg. store/ holds the Web Store listing and privacy policy; scripts/package.ts builds the store zip. Verified: typecheck, lint, build; loaded in a clean headless Chrome (status page connects, no worker errors) and in Helium, driven through the browse MCP tools.
22 lines
1.2 KiB
TypeScript
22 lines
1.2 KiB
TypeScript
// Builds the extension and zips it for the Chrome Web Store: release/opencode-browser-<version>.zip.
|
|
// The store assigns its own ID and rejects the `key` field, which only pins the ID of unpacked builds.
|
|
// The version comes from cli/package.json, the one release version for the zip and the npm helper.
|
|
import { $ } from "bun"
|
|
import { cp, mkdir, rm } from "node:fs/promises"
|
|
import path from "node:path"
|
|
|
|
const root = path.resolve(import.meta.dir, "..")
|
|
const staging = path.join(root, "release", "staging")
|
|
await $`bun run build`.cwd(root)
|
|
await rm(staging, { recursive: true, force: true })
|
|
await mkdir(staging, { recursive: true })
|
|
await cp(path.join(root, "dist"), staging, { recursive: true })
|
|
const manifest = await Bun.file(path.join(staging, "manifest.json")).json()
|
|
delete manifest.key
|
|
manifest.version = (await Bun.file(path.join(root, "cli", "package.json")).json()).version
|
|
await Bun.write(path.join(staging, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n")
|
|
const zip = path.join(root, "release", `opencode-browser-${manifest.version}.zip`)
|
|
await rm(zip, { force: true })
|
|
await $`zip -qrX ${zip} . -x "*.map" -x ".DS_Store"`.cwd(staging)
|
|
await rm(staging, { recursive: true, force: true })
|
|
console.log(zip)
|