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): OpenCode 2's model picker offers the models Browsentic's own sign-in reaches, asked of OpenCode itself, without Zen's free ones or any that cannot call a tool, and a turn Zen refuses names the model it ran on
Shahriarb38dc4e51e14
diff --git a/docs/guide/agents.md b/docs/guide/agents.mdindex 78dffae..d620bed 100644--- a/docs/guide/agents.md+++ b/docs/guide/agents.md@@ -29,14 +29,15 @@ Where a CLI can list the models your account has, the select offers that list:| Antigravity | `agy models` || Grok Build | `grok models` || Cursor CLI | `cursor-agent models`; there are over 200, so the select becomes a filter, with Browsentic's picks first |+| OpenCode 2 | `opencode api --standalone model.list` on Browsentic's own OpenCode database, leaving out models that cannot call a tool and OpenCode Zen's free ones ([why](#opencode-is-in-beta)) |-The other four have no such command, so the select offers a short list shipped with Browsentic. For-Claude Code that list is its aliases (`fable`, `opus`, `sonnet`, `haiku`), which it resolves to the-newest model of each family.+Claude Code, Mistral Vibe, Qwen Code and OpenCode 1 have no such command, so the select offers a+short list shipped with Browsentic. For Claude Code that list is its aliases (`fable`, `opus`,+`sonnet`, `haiku`), which it resolves to the newest model of each family.The Bridge reads each list in the background, so the agent picker never waits on one. A list is-kept for six hours and read again at once when the CLI is updated; *Recheck* reads it again-immediately. If a read fails (the CLI is signed out, times out, or prints something Browsentic+kept for six hours and read again at once when the CLI is updated, or for OpenCode 2 when its+sign-ins change; *Recheck* reads it again immediately. If a read fails (the CLI is signed out, times out, or prints something Browsenticcannot parse), the last list that read cleanly stays, or the shipped one if there is none, and theline under the select says why. A model you pinned yourself is never changed: if the CLI stopslisting it, it stays selected, marked *not listed*.@@ -282,8 +283,9 @@ What both lines share:- **Zen's free models refuse a Browsentic run.** They answer only requests that carry OpenCode'sown built-in tools. A Browsentic run carries only the browser's, so they refuse it with *free tier- can only be used from within OpenCode*. Sign in to a provider first; until then the agent picker- shows *needs setup*.+ can only be used from within OpenCode*. Sign in to a provider, or to OpenCode Zen and pick one of+ its paid models, which Zen bills to your OpenCode account. Until you are signed in, the agent+ picker shows *needs setup*.- **Models are `provider/model`**, spelled as `opencode models` lists them.- **A key in the environment does not reach a run.** Only `OPENCODE_*` does; `ANTHROPIC_API_KEY`and the like are sealed away. Sign in instead, which keeps the key in OpenCode's own store.@@ -319,6 +321,10 @@ What both lines share:On Windows the line is for PowerShell, and it puts the window's own `OPENCODE_DB` back once thesign-in ends, so OpenCode run there afterwards still opens your database. An `OPENCODE_API_KEY` inthe environment, or a provider in your config, counts too.+- **The agent picker lists the models that sign-in reaches.** It asks OpenCode itself, on+ Browsentic's database, and leaves out models that cannot call a tool and Zen's free ones. With no+ model picked, OpenCode chooses one itself, and on a sign-in to OpenCode Zen that is one of the free+ models, so pick one. A refused turn names the model it ran on.- **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.@@ -390,7 +396,9 @@ Claude runner's settings.| Qwen Code: *No auth type is selected* | Qwen has no provider configured, and its OAuth free tier has ended. Run `qwen` and use `/auth`, or export `OPENAI_API_KEY` with `OPENAI_BASE_URL`. || Qwen Code cannot find a key you have exported | Only `QWEN_*`, `DASHSCOPE_*`, `BAILIAN_*` and `OPENAI_*` reach a run; `ANTHROPIC_*` and `GEMINI_*` are sealed away. Point Qwen at one of the first four. || `AGENT_UNSAFE`: *Qwen Code registered …* or *loaded the MCP server …* | Qwen's own `init` line named a tool or a server Browsentic denied, so the run was stopped. Update Qwen Code and Browsentic, and report it if it persists. |-| OpenCode: *free models refuse a run whose tools Browsentic has narrowed to the browser* | Zen's free tier serves only requests carrying OpenCode's own tools. Sign in to a provider (`opencode auth login` on OpenCode 1, the line in the message on OpenCode 2), then pick that provider's model in the side panel's agent picker. |+| OpenCode: *free models refuse a run whose tools Browsentic has narrowed to the browser* | Zen's free tier serves only requests carrying OpenCode's own tools. On OpenCode 2, pick a paid model in the side panel's agent picker, or sign in to another provider with the line in the message. On OpenCode 1, sign in to a provider with `opencode auth login`, then pick that provider's model. |+| OpenCode 2: *OpenCode Zen refused …* | Zen turned down the model named, which OpenCode chose itself when the message says no model is picked. Its free models refuse every Browsentic run, and its paid ones need credit on your OpenCode account. Pick a paid model in the agent picker, or sign in to another provider with the line in the message. |+| OpenCode 2: *no working sign-in for …* | Browsentic's OpenCode is not signed in to that model's provider, or the sign-in has lapsed. Run the line in the message, or pick another model. || OpenCode 2: *no model "…" here* | OpenCode 2 does not offer that model. Pick one of those the message lists, `provider/model`. || OpenCode 2: *could not start Browsentic's browser tools* | The run's browser tools did not reach OpenCode within 20 seconds. Run `browsentic restart`, then send the message again. || OpenCode: *changed version since Browsentic last checked it* | OpenCode 1 and 2 refuse each other's flags, which is what a swap while Browsentic runs looks like. Send the message again. |diff --git a/docs/guide/configuration.md b/docs/guide/configuration.mdindex 40cd779..9b1a324 100644--- a/docs/guide/configuration.md+++ b/docs/guide/configuration.md@@ -61,8 +61,8 @@ None of these keys is required.| `agents.<name>.effort` | unset | That CLI's reasoning-effort flag; an unaccepted value is dropped || `agents.codex.transport` | unset (the app-server) | `"exec"` runs Codex through `codex exec` instead of its app-server; see [agents.md § Codex](agents.md#codex-gets-the-browser-tools-as-its-own) |-The models the select offers are not configurable: Codex, Antigravity, Grok Build and Cursor CLI are-asked for their own list, and the rest offer a short list shipped with Browsentic.+The models the select offers are not configurable: Codex, Antigravity, Grok Build, Cursor CLI and+OpenCode 2 are asked for their own list, and the rest offer a short list shipped with Browsentic.Full detail, including the Antigravity permission rule: [Choosing an agent](agents.md).diff --git a/docs/guide/troubleshooting.md b/docs/guide/troubleshooting.mdindex a909e0a..c3ffb1d 100644--- a/docs/guide/troubleshooting.md+++ b/docs/guide/troubleshooting.md@@ -94,7 +94,9 @@ Those three answer most questions. The Bridge's log is at `~/.browsentic/daemon.| Qwen Code fails with *No auth type is selected* | Qwen has no provider configured, and its OAuth free tier ended on 2026-04-15 | Run `qwen` and use `/auth`, or export `OPENAI_API_KEY` with `OPENAI_BASE_URL` || Qwen Code cannot see an API key you exported | Only `QWEN_*`, `DASHSCOPE_*`, `BAILIAN_*` and `OPENAI_*` reach a run; the rest are sealed away | Point Qwen at one of those four providers || `AGENT_UNSAFE`: *Qwen Code registered …* / *loaded the MCP server …* | Qwen's own startup line named a tool or a server Browsentic denied, so the run was stopped before the model saw it | Update Qwen Code and Browsentic, and report it if it persists |-| OpenCode fails with *free models refuse a run whose tools Browsentic has narrowed to the browser* | OpenCode Zen's free tier serves only requests carrying OpenCode's own built-in tools | Sign in to a provider: `opencode auth login` on OpenCode 1, the line in the message on OpenCode 2. Then pick that provider's model in the side panel's agent picker |+| OpenCode fails with *free models refuse a run whose tools Browsentic has narrowed to the browser* | OpenCode Zen's free tier serves only requests carrying OpenCode's own built-in tools | On OpenCode 2, pick a paid model in the side panel's agent picker, or sign in to another provider with the line in the message. On OpenCode 1, sign in to a provider with `opencode auth login`, then pick that provider's model |+| OpenCode 2 fails with *OpenCode Zen refused …* | Zen turned down the model named: its free models refuse every Browsentic run, and its paid ones need credit on your OpenCode account. With no model picked, OpenCode chose that model itself | Pick a paid model in the agent picker, which lists those Browsentic's sign-in reaches, or sign in to another provider with the line in the message |+| OpenCode 2 fails with *no working sign-in for …* | Browsentic's OpenCode is not signed in to that model's provider, or the sign-in has lapsed | Run the line in the message, or pick another model || OpenCode 2 needs setup though you are signed in to OpenCode | Browsentic's runs keep an OpenCode database of their own, apart from yours, and OpenCode 2 keeps sign-ins in it | Run the line the agent picker shows, which signs that database in || OpenCode 2 fails with *no model "…" here* | OpenCode 2 does not offer that model to Browsentic's sign-in | Pick one of the models the message lists, `provider/model` || OpenCode 2 fails with *could not start Browsentic's browser tools* | The run's browser tools did not reach OpenCode within 20 seconds | Run `browsentic restart`, then send the message again |diff --git a/src/daemon/agent/runners/fixtures/README.md b/src/daemon/agent/runners/fixtures/README.mdindex 2041f4f..e24310f 100644--- a/src/daemon/agent/runners/fixtures/README.md+++ b/src/daemon/agent/runners/fixtures/README.md@@ -23,4 +23,8 @@ Lines starting with `#` are comments, and the tests skip them.- `<cli version>-models.txt` and `-models-signed-out.txt` are what the CLI's model-listing commandprinted, for `../models.test.ts`: stdout, then stderr after a `# stderr` line, with the exit codein a `# exit` line. `codex/<version>-models_cache.json` is Codex's own cache, cut to the fields the- lister reads, with the account identity and etag replaced.+ lister reads, with the account identity and etag replaced. OpenCode 2.0.32's are what+ `opencode api --standalone model.list` printed, cut to the fields the lister reads, which drops+ the account's organization id: `models` on a database signed in to OpenCode Zen alone,+ `-signed-out` on an empty one, and `-provider-keys` on an empty one with stand-in keys for+ Anthropic, OpenAI and Google in the environment.diff --git a/src/daemon/agent/runners/fixtures/opencode/2.0.32-models-provider-keys.txt b/src/daemon/agent/runners/fixtures/opencode/2.0.32-models-provider-keys.txtnew file mode 100644index 0000000..3adf581--- /dev/null+++ b/src/daemon/agent/runners/fixtures/opencode/2.0.32-models-provider-keys.txt@@ -0,0 +1,3 @@+# `opencode api --standalone model.list` 2.0.32 on an empty database with stand-in ANTHROPIC_API_KEY, OPENAI_API_KEY and GEMINI_API_KEY, recorded 2026-10-19, cut to the fields the lister reads.+# exit 0+{"data":[{"providerID":"opencode","id":"ll-alpha-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"nemotron-3.5-super-vl-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"google","id":"gemini-4-argon","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10}]},{"providerID":"opencode","id":"cat-jam-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"anthropic","id":"claude-haiku-5-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.5},{"input":0.5,"output":2.5}]},{"providerID":"openai","id":"gpt-6.1-sol","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10},{"input":4,"output":15}]},{"providerID":"openai","id":"gpt-6.1-sol-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":4,"output":15}]},{"providerID":"openai","id":"gpt-6.1-sol-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10},{"input":4,"output":15}]},{"providerID":"openai","id":"gpt-6.1-sol-ultrafast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":12,"output":60},{"input":4,"output":15}]},{"providerID":"anthropic","id":"claude-sonnet-5-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10}]},{"providerID":"opencode","id":"longcat-2.5-preview-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"space-bunny-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"anthropic","id":"claude-opus-5-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20}]},{"providerID":"anthropic","id":"claude-opus-5-5-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":8,"output":40}]},{"providerID":"opencode","id":"mimo-v2.6-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"openai","id":"gpt-6-luna","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.5},{"input":0.2,"output":0.75}]},{"providerID":"openai","id":"gpt-6-luna-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.2,"output":1},{"input":0.2,"output":0.75}]},{"providerID":"openai","id":"gpt-6-luna-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.5},{"input":0.2,"output":0.75}]},{"providerID":"openai","id":"gpt-6-sol","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10},{"input":4,"output":15}]},{"providerID":"openai","id":"gpt-6-sol-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":4,"output":15}]},{"providerID":"openai","id":"gpt-6-sol-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10},{"input":4,"output":15}]},{"providerID":"opencode","id":"deepseek-v4.1-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"openai","id":"gpt-6-astra","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50},{"input":20,"output":75}]},{"providerID":"openai","id":"gpt-6-astra-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":20,"output":100},{"input":20,"output":75}]},{"providerID":"openai","id":"gpt-6-astra-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50},{"input":20,"output":75}]},{"providerID":"openai","id":"gpt-6-astra-ultrafast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":60,"output":300},{"input":20,"output":75}]},{"providerID":"google","id":"gemini-3.8-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":3.75}]},{"providerID":"opencode","id":"muse-spark-1.3-contributor-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"anthropic","id":"claude-fable-5-1","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50}]},{"providerID":"opencode","id":"glm-5.3-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"google","id":"gemini-flash-latest","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":3.75}]},{"providerID":"google","id":"gemini-3.7-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":3.75}]},{"providerID":"opencode","id":"nemotron-3.5-lightning-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"openai","id":"gpt-daybreak-blue-latest","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-daybreak-red-latest","enabled":true,"capabilities":{"tools":true},"cost":[{"input":12.5,"output":75}]},{"providerID":"anthropic","id":"claude-opus-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":25}]},{"providerID":"anthropic","id":"claude-opus-5-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50}]},{"providerID":"google","id":"gemini-flash-lite-latest","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.3,"output":2.5}]},{"providerID":"google","id":"gemini-3.6-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":3.75}]},{"providerID":"google","id":"gemini-3.5-flash-lite","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.3,"output":2.5}]},{"providerID":"openai","id":"gpt-5.6","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-5.6-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":8,"output":40},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-5.6-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-5.6-luna","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.2,"output":1.2},{"input":0.4,"output":1.8}]},{"providerID":"openai","id":"gpt-5.6-luna-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.4,"output":2.4},{"input":0.4,"output":1.8}]},{"providerID":"openai","id":"gpt-5.6-luna-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.2,"output":1.2},{"input":0.4,"output":1.8}]},{"providerID":"openai","id":"gpt-5.6-terra","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"openai","id":"gpt-5.6-terra-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":24},{"input":4,"output":18}]},{"providerID":"openai","id":"gpt-5.6-terra-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"openai","id":"gpt-5.6-sol","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-5.6-sol-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":8,"output":40},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-5.6-sol-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20},{"input":8,"output":30}]},{"providerID":"openai","id":"gpt-realtime-2.1","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":24}]},{"providerID":"google","id":"gemini-3.1-flash-lite-image","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.25,"output":30}]},{"providerID":"anthropic","id":"claude-sonnet-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10}]},{"providerID":"anthropic","id":"claude-fable-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50}]},{"providerID":"opencode","id":"nemotron-3-ultra-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"anthropic","id":"claude-opus-4-8","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":25}]},{"providerID":"anthropic","id":"claude-opus-4-8-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50}]},{"providerID":"google","id":"gemini-3.1-flash-image","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.5,"output":60}]},{"providerID":"google","id":"gemini-3-pro-image","enabled":true,"capabilities":{"tools":false},"cost":[{"input":2,"output":120}]},{"providerID":"google","id":"gemini-3.5-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.5,"output":9}]},{"providerID":"google","id":"gemini-3.1-flash-lite","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.25,"output":1.5}]},{"providerID":"openai","id":"gpt-5.5-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":30,"output":180},{"input":60,"output":270}]},{"providerID":"openai","id":"gpt-5.5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":30},{"input":10,"output":45}]},{"providerID":"openai","id":"gpt-5.5-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":12.5,"output":75},{"input":10,"output":45}]},{"providerID":"google","id":"gemini-embedding-2","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.2,"output":0}]},{"providerID":"google","id":"deep-research-preview-04-2026","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"google","id":"deep-research-max-preview-04-2026","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"anthropic","id":"claude-opus-4-7","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":25}]},{"providerID":"google","id":"gemma-4-31b-it","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"google","id":"gemma-4-26b-a4b-it","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"google","id":"gemini-3.1-flash-live-preview","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":4.5}]},{"providerID":"google","id":"lyria-3-pro-preview","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0,"output":0}]},{"providerID":"google","id":"lyria-3-clip-preview","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0,"output":0}]},{"providerID":"openai","id":"gpt-5.4-nano","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.2,"output":1.25}]},{"providerID":"openai","id":"gpt-5.4-nano-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.625}]},{"providerID":"openai","id":"gpt-5.4-mini","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":4.5}]},{"providerID":"openai","id":"gpt-5.4-mini-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.5,"output":9}]},{"providerID":"openai","id":"gpt-5.4-mini-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.375,"output":2.25}]},{"providerID":"openai","id":"gpt-5.4","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":15},{"input":5,"output":22.5}]},{"providerID":"openai","id":"gpt-5.4-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":30},{"input":5,"output":22.5}]},{"providerID":"openai","id":"gpt-5.4-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":30,"output":180},{"input":60,"output":270}]},{"providerID":"google","id":"gemini-3.1-flash-image-preview","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.5,"output":60}]},{"providerID":"google","id":"gemini-3.1-pro-preview","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"google","id":"gemini-3.1-pro-preview-customtools","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"anthropic","id":"claude-sonnet-4-6","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3,"output":15}]},{"providerID":"openai","id":"gpt-5.3-codex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.75,"output":14}]},{"providerID":"openai","id":"gpt-5.3-codex-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3.5,"output":28}]},{"providerID":"openai","id":"gpt-5.3-codex-spark","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.75,"output":14}]},{"providerID":"anthropic","id":"claude-opus-4-6","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":25}]},{"providerID":"google","id":"gemini-3-flash-preview","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.5,"output":3}]},{"providerID":"openai","id":"chatgpt-image-latest","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0,"output":0}]},{"providerID":"openai","id":"gpt-5.2-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":21,"output":168}]},{"providerID":"openai","id":"gpt-5.2","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.75,"output":14}]},{"providerID":"openai","id":"gpt-5.2-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3.5,"output":28}]},{"providerID":"openai","id":"gpt-5.2-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.875,"output":7}]},{"providerID":"openai","id":"gpt-image-1.5","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0,"output":0}]},{"providerID":"anthropic","id":"claude-opus-4-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":25}]},{"providerID":"anthropic","id":"claude-opus-4-5-20251101","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":25}]},{"providerID":"google","id":"gemini-3-pro-image-preview","enabled":true,"capabilities":{"tools":false},"cost":[{"input":2,"output":120}]},{"providerID":"openai","id":"gpt-5.1","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.25,"output":10}]},{"providerID":"openai","id":"gpt-5.1-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":20}]},{"providerID":"openai","id":"gpt-5.1-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.625,"output":5}]},{"providerID":"opencode","id":"big-pickle","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"anthropic","id":"claude-haiku-4-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1,"output":5}]},{"providerID":"anthropic","id":"claude-haiku-4-5-20251001","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1,"output":5}]},{"providerID":"google","id":"gemini-2.5-computer-use-preview-10-2025","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.25,"output":10},{"input":2.5,"output":15}]},{"providerID":"openai","id":"gpt-5-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":15,"output":120}]},{"providerID":"anthropic","id":"claude-sonnet-4-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3,"output":15}]},{"providerID":"anthropic","id":"claude-sonnet-4-5-20250929","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3,"output":15}]},{"providerID":"openai","id":"gpt-image-1-mini","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0,"output":0}]},{"providerID":"google","id":"gemini-2.5-flash-image","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.3,"output":30}]},{"providerID":"openai","id":"gpt-5-mini","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.25,"output":2}]},{"providerID":"openai","id":"gpt-5-mini-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.45,"output":3.6}]},{"providerID":"openai","id":"gpt-5-mini-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.125,"output":1}]},{"providerID":"openai","id":"gpt-5-nano","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.05,"output":0.4}]},{"providerID":"openai","id":"gpt-5-nano-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.025,"output":0.2}]},{"providerID":"openai","id":"gpt-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.25,"output":10}]},{"providerID":"openai","id":"gpt-5-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":20}]},{"providerID":"openai","id":"gpt-5-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.625,"output":5}]},{"providerID":"google","id":"gemini-2.5-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.25,"output":10},{"input":2.5,"output":15}]},{"providerID":"google","id":"gemini-2.5-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.3,"output":2.5}]},{"providerID":"google","id":"gemini-2.5-flash-lite","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.4}]},{"providerID":"openai","id":"o3-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":20,"output":80}]},{"providerID":"google","id":"gemini-embedding-001","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.15,"output":0}]},{"providerID":"openai","id":"o3","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":8}]},{"providerID":"openai","id":"o3-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3.5,"output":14}]},{"providerID":"openai","id":"o3-flex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1,"output":4}]},{"providerID":"openai","id":"gpt-4.1","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":8}]},{"providerID":"openai","id":"gpt-4.1-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3.5,"output":14}]},{"providerID":"openai","id":"gpt-4.1-mini","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.4,"output":1.6}]},{"providerID":"openai","id":"gpt-4.1-mini-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.7,"output":2.8}]},{"providerID":"openai","id":"gpt-4o-2024-11-20","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":10}]},{"providerID":"openai","id":"gpt-4o-2024-08-06","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":10}]},{"providerID":"openai","id":"gpt-4o-mini","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.15,"output":0.6}]},{"providerID":"openai","id":"gpt-4o-mini-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.25,"output":1}]},{"providerID":"openai","id":"gpt-4o","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":10}]},{"providerID":"openai","id":"gpt-4o-fast","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4.25,"output":17}]},{"providerID":"openai","id":"text-embedding-3-small","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.02,"output":0}]},{"providerID":"openai","id":"text-embedding-3-large","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.13,"output":0}]},{"providerID":"openai","id":"text-embedding-ada-002","enabled":true,"capabilities":{"tools":false},"cost":[{"input":0.1,"output":0}]}]}diff --git a/src/daemon/agent/runners/fixtures/opencode/2.0.32-models-signed-out.txt b/src/daemon/agent/runners/fixtures/opencode/2.0.32-models-signed-out.txtnew file mode 100644index 0000000..40fc35c--- /dev/null+++ b/src/daemon/agent/runners/fixtures/opencode/2.0.32-models-signed-out.txt@@ -0,0 +1,3 @@+# `opencode api --standalone model.list` 2.0.32 on an empty database, recorded 2026-10-19, cut to the fields the lister reads.+# exit 0+{"data":[{"providerID":"opencode","id":"big-pickle","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"deepseek-v4.1-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"glm-5.3-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"muse-spark-1.3-contributor-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"ll-alpha-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"nemotron-3.5-super-vl-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"cat-jam-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"longcat-2.5-preview-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"space-bunny-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"mimo-v2.6-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"nemotron-3.5-lightning-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"nemotron-3-ultra-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]}]}diff --git a/src/daemon/agent/runners/fixtures/opencode/2.0.32-models.txt b/src/daemon/agent/runners/fixtures/opencode/2.0.32-models.txtnew file mode 100644index 0000000..a90709f--- /dev/null+++ b/src/daemon/agent/runners/fixtures/opencode/2.0.32-models.txt@@ -0,0 +1,3 @@+# `opencode api --standalone model.list` 2.0.32 on Browsentic's database, signed in to OpenCode Zen and nothing else, recorded 2026-10-19, cut to the fields the lister reads.+# exit 0+{"data":[{"providerID":"opencode","id":"minimax-m3.1-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"nemotron-3.5-super-vl-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"gemini-4-argon","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10}]},{"providerID":"opencode","id":"claude-haiku-5-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.5},{"input":0.5,"output":2.5}]},{"providerID":"opencode","id":"mistral-large-4","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.68,"output":2.09}]},{"providerID":"opencode","id":"beam-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"gpt-6.1-sol","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10},{"input":4,"output":15}]},{"providerID":"opencode","id":"claude-sonnet-5-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":10}]},{"providerID":"opencode","id":"longcat-2.5-preview-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"gpt-6-luna","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.1,"output":0.5},{"input":0.2,"output":0.75}]},{"providerID":"opencode","id":"mimo-v2.6-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"claude-opus-5-5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":4,"output":20}]},{"providerID":"opencode","id":"grok-4.7","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":6},{"input":4,"output":12}]},{"providerID":"opencode","id":"deepseek-v4.1-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.3,"output":1.2}]},{"providerID":"opencode","id":"deepseek-v4.1-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"gpt-6-astra","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50},{"input":20,"output":75}]},{"providerID":"opencode","id":"muse-spark-1.3","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.25,"output":4.25}]},{"providerID":"opencode","id":"gemini-3.8-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.5,"output":7.5}]},{"providerID":"opencode","id":"claude-fable-5-1","enabled":true,"capabilities":{"tools":true},"cost":[{"input":10,"output":50}]},{"providerID":"opencode","id":"qwen3.8-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.15,"output":0.47}]},{"providerID":"opencode","id":"glm-5.3-flash-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"glm-5.3-flash","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.15,"output":0.5}]},{"providerID":"opencode","id":"glm-5.3","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.4,"output":4.4}]},{"providerID":"opencode","id":"nemotron-3.5-lightning-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"gemini-3.5-flash-lite","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.3,"output":2.5}]},{"providerID":"opencode","id":"kimi-k3","enabled":true,"capabilities":{"tools":true},"cost":[{"input":3,"output":15}]},{"providerID":"opencode","id":"gpt-5.6-terra","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2.5,"output":15},{"input":5,"output":22.5}]},{"providerID":"opencode","id":"kimi-k2.7-code","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.95,"output":4}]},{"providerID":"opencode","id":"nemotron-3-ultra-free","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]},{"providerID":"opencode","id":"minimax-m3","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.3,"output":1.2}]},{"providerID":"opencode","id":"deepseek-v4-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.74,"output":3.84}]},{"providerID":"opencode","id":"gpt-5.5-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":30,"output":180}]},{"providerID":"opencode","id":"gpt-5.5","enabled":true,"capabilities":{"tools":true},"cost":[{"input":5,"output":30},{"input":10,"output":45}]},{"providerID":"opencode","id":"grok-build-0.1","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1,"output":2}]},{"providerID":"opencode","id":"qwen3.6-plus","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.5,"output":3}]},{"providerID":"opencode","id":"gpt-5.4-nano","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.2,"output":1.25}]},{"providerID":"opencode","id":"gpt-5.4-mini","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0.75,"output":4.5}]},{"providerID":"opencode","id":"gpt-5.3-codex","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.75,"output":14}]},{"providerID":"opencode","id":"gemini-3.1-pro","enabled":true,"capabilities":{"tools":true},"cost":[{"input":2,"output":12},{"input":4,"output":18}]},{"providerID":"opencode","id":"gpt-5.3-codex-spark","enabled":true,"capabilities":{"tools":true},"cost":[{"input":1.75,"output":14}]},{"providerID":"opencode","id":"big-pickle","enabled":true,"capabilities":{"tools":true},"cost":[{"input":0,"output":0}]}]}diff --git a/src/daemon/agent/runners/models.test.ts b/src/daemon/agent/runners/models.test.tsindex e54bc63..c7e7e1e 100644--- a/src/daemon/agent/runners/models.test.ts+++ b/src/daemon/agent/runners/models.test.ts@@ -5,15 +5,18 @@ import { AGENTS, type AgentKind } from '@/lib/agents/catalog';import { stateDir } from '../../lockfile';import { listing, stubCli } from './fixtures/support';import { RUNNERS } from './index';-import { modelsFor, refreshModels } from './models';-import type { Listing, Runner } from './types';+import { listerFor, modelsFor, refreshModels } from './models';+import type { CommandLister, Listing, ModelLister, Runner } from './types';const bin = join(stateDir, 'model-bin');const calls = join(stateDir, 'model-calls.log');const store = join(stateDir, 'models.json');+/** The version each recording was made with, for a runner that lists per version. */+const RECORDED: Partial<Record<AgentKind, string>> = { opencode: 'opencode v2.0.32' };+const parsed = (kind: AgentKind, output: Listing) => {- const lister = RUNNERS[kind].models;+ const lister = listerFor(RUNNERS[kind], RECORDED[kind]);if (!lister || 'file' in lister) throw new Error(`${kind} does not list its models with a command`);return lister.parse(output);};@@ -36,14 +39,33 @@ describe("each CLI's own list, as recorded", () => {});test("Codex's cache yields the models its own picker lists, by its priority, and none of its hidden helpers", () => {- const lister = RUNNERS.codex.models;+ const lister = listerFor(RUNNERS.codex, 'codex-cli 0.155.1');expect(lister && 'file' in lister ? lister.parse(codexCache()) : null).toEqual(['gpt-5.6-terra', 'gpt-5.6-luna', 'gpt-5.5']);});+ // Zen's free models serve only requests carrying OpenCode's own tools, so a Browsentic run on one is refused.+ test("OpenCode 2 lists what Browsentic's own sign-in reaches, by provider and in order, and none of Zen's free models", () => {+ const ids = parsed('opencode', listing('opencode', '2.0.32-models.txt')) ?? [];+ expect([ids.length, ids.every((id) => id.startsWith('opencode/')), ids.includes('opencode/claude-sonnet-5-5')]).toEqual([31, true, true]);+ expect(ids.filter((id) => id.endsWith('-free') || id === 'opencode/big-pickle')).toEqual([]);+ expect(ids).toEqual([...ids].sort());+ });++ test('OpenCode 2 leaves out a model that cannot call a tool, and keeps a free one of any provider but Zen', () => {+ const ids = parsed('opencode', listing('opencode', '2.0.32-models-provider-keys.txt')) ?? [];+ expect([ids.length, ids.includes('google/gemma-4-31b-it'), ids.includes('openai/text-embedding-3-small'), ids.some((id) => id.startsWith('opencode/'))]).toEqual([+ 115,+ true,+ false,+ false,+ ]);+ });+test.each([['antigravity', '1.2.11-models-signed-out.txt'],['cursor', '2026.09.18-models-signed-out.txt'],['grok', '1.0.40-models-signed-out.txt'],+ ['opencode', '2.0.32-models-signed-out.txt'],] as const)('%s signed out is no list at all', (kind, name) => {expect(parsed(kind, listing(kind, name))).toBeNull();});@@ -53,6 +75,7 @@ describe("each CLI's own list, as recorded", () => {antigravity: parsed('antigravity', listing('antigravity', '1.2.11-models.txt')),cursor: parsed('cursor', listing('cursor', '2026.09.18-models.txt')),grok: parsed('grok', listing('grok', '1.0.40-models.txt')),+ opencode: parsed('opencode', listing('opencode', '2.0.32-models-provider-keys.txt')),};const unlisted = Object.entries(listed).flatMap(([kind, ids]) =>AGENTS[kind as AgentKind].models.filter((id) => !ids?.includes(id)).map((id) => `${kind}: ${id}`),@@ -125,6 +148,33 @@ describe('reading and keeping a list', () => {expect(spawned()).toEqual(['agy models', 'agy models', 'agy-signed-out models']);});+ test('a list that rests on more than the CLI, such as its sign-ins, is read again when that changes, and only then', async () => {+ let signIns = 'zen';+ const stamped: Runner = { ...agy, models: { ...(agy.models as CommandLister), stamp: () => signIns } };+ await refreshModels(stamped, settings(listed), '1.2.11');+ await refreshModels(stamped, settings(listed), '1.2.11');+ signIns = 'zen and anthropic';+ await refreshModels(stamped, settings(listed), '1.2.11');+ expect(spawned()).toEqual(['agy models', 'agy models']);+ });++ test("a lister's own environment reaches the listing, which runs in a folder of its own", async () => {+ const seen = join(bin, 'listed-in.json');+ const reporting = stub(+ 'agy-env',+ `require('node:fs').writeFileSync(${JSON.stringify(seen)}, JSON.stringify([process.env.LISTED_IN, process.env.NO_COLOR]));\n${out('gemini-3.8-flash-high\tFlash\n')}`,+ );+ const withEnv: Runner = { ...agy, models: { ...(agy.models as CommandLister), env: (cwd) => ({ LISTED_IN: cwd }) } };+ await refreshModels(withEnv, settings(reporting), '1.2.11');+ expect(JSON.parse(readFileSync(seen, 'utf8'))).toEqual([join(stateDir, 'agents', 'antigravity', 'models'), '1']);+ });++ test('a runner that lists per version reads nothing for a version it has no lister for', async () => {+ const versioned: Runner = { ...agy, models: (version) => (version === '2' ? (agy.models as ModelLister) : undefined) };+ expect([await refreshModels(versioned, settings(listed), '1'), await refreshModels(versioned, settings(listed), '2')]).toEqual([false, true]);+ expect(spawned()).toEqual(['agy models']);+ });+test('a failed read keeps the last good list, and says why', async () => {await refreshModels(agy, settings(listed), '1.2.11');expect(await refreshModels(agy, settings(signedOut), '1.2.11')).toBe(true);diff --git a/src/daemon/agent/runners/models.ts b/src/daemon/agent/runners/models.tsindex 3565190..c6fcc4a 100644--- a/src/daemon/agent/runners/models.ts+++ b/src/daemon/agent/runners/models.ts@@ -6,7 +6,7 @@ import { log } from '../../log';import type { AgentSettings } from '../config';import { spawnCli, stopTree, type CliProcess } from './command';import { childEnv } from './drive';-import type { Listing, ModelLister, Runner } from './types';+import type { CommandLister, Listing, ModelLister, Runner } from './types';const FRESH_MS = 6 * 60 * 60_000;const RETRY_MS = 10 * 60_000;@@ -19,6 +19,7 @@ const storePath = join(stateDir, 'models.json');interface Entry {bin: string;version?: string;+ stamp?: string;/** The last list that read cleanly. A failed read never replaces it. */ids?: string[];at?: number;@@ -26,6 +27,9 @@ interface Entry {error?: string;}+/** What a list was read from: a change to any of it reads the list again. */+type Source = Pick<Entry, 'bin' | 'version' | 'stamp'>;+type Store = Partial<Record<AgentKind, Entry>>;type Outcome = { ids: string[] } | { error: string };@@ -50,15 +54,16 @@ export function refreshModels(version: string | undefined,{ force = false } = {},): Promise<boolean> {- const lister = runner.models;+ const lister = listerFor(runner, version);if (!lister) return Promise.resolve(false);const running = inFlight.get(runner.kind);if (running) return running;- if (!force && !due(readStore()[runner.kind], settings.bin, version, lister)) return Promise.resolve(false);+ const source: Source = { bin: settings.bin, version, stamp: 'file' in lister ? undefined : lister.stamp?.() };+ if (!force && !due(readStore()[runner.kind], source, lister)) return Promise.resolve(false);const reading = read(runner.kind, settings.bin, lister).catch((error: unknown): Outcome => ({ error: String(error) }))- .then((outcome) => record(runner.kind, settings.bin, version, outcome))+ .then((outcome) => record(runner.kind, source, outcome)).catch((error: unknown) => {log(`could not keep ${AGENTS[runner.kind].label}'s model list: ${String(error)}`);return false;@@ -68,8 +73,12 @@ export function refreshModels(return reading;}-function due(entry: Entry | undefined, bin: string, version: string | undefined, lister: ModelLister): boolean {- if (!entry || entry.bin !== bin || entry.version !== version) return true;+export function listerFor(runner: Runner, version: string | undefined): ModelLister | undefined {+ return typeof runner.models === 'function' ? runner.models(version) : runner.models;+}++function due(entry: Entry | undefined, { bin, version, stamp }: Source, lister: ModelLister): boolean {+ if (!entry || entry.bin !== bin || entry.version !== version || entry.stamp !== stamp) return true;const age = Date.now() - entry.triedAt;if (entry.error) return age >= RETRY_MS;return 'file' in lister || age >= FRESH_MS;@@ -87,7 +96,7 @@ async function read(kind: AgentKind, bin: string, lister: ModelLister): Promise<return accepted(() => lister.parse(content)) ?? { error: `${basename(path)} holds no model Browsentic could read.` };}- const listing = await list(kind, bin, lister.args);+ const listing = await list(kind, bin, lister);if ('error' in listing) return listing;return accepted(() => lister.parse(listing)) ?? { error: reason(listing) };}@@ -115,7 +124,7 @@ function reason({ stdout, stderr, code }: Listing): string {return code === 0 ? 'It printed no model list Browsentic could read.' : `It exited with code ${code}.`;}-function list(kind: AgentKind, bin: string, args: string[]): Promise<Listing | { error: string }> {+function list(kind: AgentKind, bin: string, { args, env }: CommandLister): Promise<Listing | { error: string }> {const cwd = join(stateDir, 'agents', kind, 'models');mkdirSync(cwd, { recursive: true, mode: 0o700 });const command = `"${[basename(bin), ...args].join(' ')}"`;@@ -123,7 +132,7 @@ function list(kind: AgentKind, bin: string, args: string[]): Promise<Listing | {let child: CliProcess;try {- child = spawnCli(bin, args, { cwd, env: { ...childEnv(kind), NO_COLOR: '1' }, detached: group });+ child = spawnCli(bin, args, { cwd, env: { ...childEnv(kind), ...env?.(cwd), NO_COLOR: '1' }, detached: group });} catch (error) {return Promise.resolve({ error: (error as Error).message });}@@ -165,14 +174,14 @@ function list(kind: AgentKind, bin: string, args: string[]): Promise<Listing | {});}-function record(kind: AgentKind, bin: string, version: string | undefined, outcome: Outcome): boolean {+function record(kind: AgentKind, source: Source, outcome: Outcome): boolean {const store = readStore();const before = store[kind];const now = Date.now();const entry: Entry ='ids' in outcome- ? { bin, version, ids: outcome.ids, at: now, triedAt: now }- : { bin, version, ids: before?.ids, at: before?.at, triedAt: now, error: outcome.error };+ ? { ...source, ids: outcome.ids, at: now, triedAt: now }+ : { ...source, ids: before?.ids, at: before?.at, triedAt: now, error: outcome.error };if ('error' in outcome) log(`could not list ${AGENTS[kind].label}'s models: ${outcome.error}`);store[kind] = entry;writeStore(store);@@ -203,6 +212,7 @@ function entryOf(value: unknown): Entry | null {return {bin: raw.bin,version: typeof raw.version === 'string' ? raw.version : undefined,+ stamp: typeof raw.stamp === 'string' ? raw.stamp : undefined,ids: ids?.length ? ids : undefined,at: typeof raw.at === 'number' ? raw.at : undefined,triedAt: raw.triedAt,diff --git a/src/daemon/agent/runners/opencode-acp.test.ts b/src/daemon/agent/runners/opencode-acp.test.tsindex ed24d3b..e5b77d0 100644--- a/src/daemon/agent/runners/opencode-acp.test.ts+++ b/src/daemon/agent/runners/opencode-acp.test.ts@@ -192,8 +192,28 @@ describe('a turn', () => {});// Recorded against the real Zen endpoint with no sign-in: ACP passes on only "Authentication required".- test('a model with no sign-in says how to sign Browsentic in', () => {- expect(through('free-tier')).toEqual([['fail', 'AGENT_FAILED', expect.stringMatching(/narrowed to the browser.*OPENCODE_DB=.*auth login --standalone/)]]);+ test('a refused model OpenCode chose itself is named, with the paid model to pick instead', () => {+ expect(through('free-tier')).toEqual([+ [+ 'fail',+ 'AGENT_FAILED',+ expect.stringMatching(+ /^OpenCode Zen refused opencode\/big-pickle, which OpenCode chose because no model is picked in Browsentic\. .*Pick a paid model in the side panel, .*OPENCODE_DB=.*auth login --standalone\. \(Authentication required/,+ ),+ ],+ ]);+ });++ test('a refused model picked in Browsentic is named as picked, and one of another provider names the sign-in it lacks', () => {+ const refusedFor = (model: string) => {+ const turn = holding({ settings: { bin: 'opencode', model } });+ turn.feed(answerTo('free-tier', 1), answerTo('free-tier', 3), answerTo('free-tier', 6));+ return turn.failed();+ };+ expect(refusedFor('opencode/big-pickle')).toEqual([['fail', 'AGENT_FAILED', expect.stringMatching(/^OpenCode Zen refused opencode\/big-pickle\. Zen's free models/)]]);+ expect(refusedFor('mock/m1')).toEqual([+ ['fail', 'AGENT_FAILED', expect.stringMatching(/^Browsentic's OpenCode has no working sign-in for mock, so it could not run mock\/m1\. Sign it in with OPENCODE_DB=/)],+ ]);});test("another session's updates are not this turn's", () => {diff --git a/src/daemon/agent/runners/opencode-acp.ts b/src/daemon/agent/runners/opencode-acp.tsindex 643603a..fa31b19 100644--- a/src/daemon/agent/runners/opencode-acp.ts+++ b/src/daemon/agent/runners/opencode-acp.ts@@ -47,12 +47,18 @@ interface Update {used?: number;}+/** The model a turn ran on, and whether it was picked in Browsentic or left to OpenCode. */+export interface TurnModel {+ id: string;+ picked: boolean;+}+export interface AcpTurn {plan: Plan;/** The agent the config defines, which every session has to be in. */agent: string;declined: (reason: string) => void;- explain: (message: string | undefined) => string;+ explain: (message: string | undefined, model?: TurnModel) => string;stoppedFor: (tool: string) => string;}@@ -64,6 +70,7 @@ export interface AcpTurn {*/export function acpTurn(context: StreamContext, turn: AcpTurn): Conversation {let session: string | undefined;+ let model: TurnModel | undefined;let holding = false;let contextTokens = 0;const calls = new Map<string, string>();@@ -101,20 +108,27 @@ export function acpTurn(context: StreamContext, turn: AcpTurn): Conversation {return prompt(io, sink);};+ const modelOf = (options: ConfigOption[] | undefined): TurnModel | undefined => {+ const pinned = context.settings.model;+ if (pinned) return { id: pinned, picked: true };+ const current = option(options, 'model')?.currentValue;+ return current ? { id: current, picked: false } : undefined;+ };+// A model OpenCode does not know is swapped for another without a word, so a pinned one is asked for by name.const chooseModel = (options: ConfigOption[] | undefined, io: ConversationIO, sink: StreamSink) => {- const model = context.settings.model;+ const pinned = context.settings.model;const choice = option(options, 'model');- if (!model || choice?.currentValue === model) return chooseEffort(options, io, sink);- if (!offers(choice, model)) {+ if (!pinned || choice?.currentValue === pinned) return chooseEffort(options, io, sink);+ if (!offers(choice, pinned)) {const some = (choice?.options ?? []).flatMap((offered) => (offered.value ? [offered.value] : [])).slice(0, 6);return sink.fail('AGENT_FAILED',- `OpenCode offers no model "${model}" here.${some.length ? ` It offers ${some.join(', ')}, among others.` : ''} ` ++ `OpenCode offers no model "${pinned}" here.${some.length ? ` It offers ${some.join(', ')}, among others.` : ''} ` +'Pick one in the Browsentic side panel, spelled provider/model, then try again.',);}- return ask(io, ASK.model, 'session/set_config_option', { sessionId: session, configId: 'model', value: model });+ return ask(io, ASK.model, 'session/set_config_option', { sessionId: session, configId: 'model', value: pinned });};const onSession = (message: Message, io: ConversationIO, sink: StreamSink) => {@@ -126,6 +140,7 @@ export function acpTurn(context: StreamContext, turn: AcpTurn): Conversation {session = message.result?.sessionId ?? context.sessionId ?? undefined;if (!session) return sink.fail('AGENT_FAILED', 'OpenCode opened a session without naming it.');holding = true;+ model = modelOf(options);sink.session(session);chooseModel(options, io, sink);};@@ -147,14 +162,14 @@ export function acpTurn(context: StreamContext, turn: AcpTurn): Conversation {return onSession(message, io, sink);case ASK.model:- if (failed) return sink.fail('AGENT_FAILED', turn.explain(failed.message));+ if (failed) return sink.fail('AGENT_FAILED', turn.explain(failed.message, model));return chooseEffort(message.result?.configOptions, io, sink);case ASK.effort:return prompt(io, sink);case ASK.prompt: {- if (failed) return sink.fail('AGENT_FAILED', turn.explain(failed.message));+ if (failed) return sink.fail('AGENT_FAILED', turn.explain(failed.message, model));const output = message.result?.usage?.outputTokens;if (output !== undefined) sink.usage({ contextTokens, outputTokens: output });// Stopped from Browsentic, OpenCode ends the prompt itself before it exits.diff --git a/src/daemon/agent/runners/opencode.test.ts b/src/daemon/agent/runners/opencode.test.tsindex 562483f..99a5173 100644--- a/src/daemon/agent/runners/opencode.test.ts+++ b/src/daemon/agent/runners/opencode.test.ts@@ -2,9 +2,10 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'nodeimport { dirname, join, parse, relative, sep } from 'node:path';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';import { stateDir } from '../../lockfile';+import { listerFor } from './models';import { isOpenCode2, opencodeRunner, signInLine } from './opencode';import { jsonContext, readThrough, shown, streamContext, stubCli, transcript, valueOf } from './fixtures/support';-import type { Plan } from './types';+import type { CommandLister, Plan } from './types';const settings = { bin: 'opencode' };const stream = (overrides: Parameters<typeof streamContext>[1] = {}) => opencodeRunner.stream(streamContext(settings, overrides));@@ -526,10 +527,9 @@ describe('reading an OpenCode 2 stream', () => {});// Recorded against the real Zen endpoint, which still serves its free models only to OpenCode's own tools.- test("Zen's free tier refusing a contained run says to sign Browsentic in to a provider", () => {+ test("Zen's free tier refusing a contained run says to pick a paid model, or sign Browsentic in to another provider", () => {const [[, , message]] = read2('2.0.32-free-tier.jsonl', 'fail');- expect(message).toEqual(expect.stringContaining('narrowed to the browser'));- expect(message).toContain(`OPENCODE_DB=`);+ expect(message).toMatch(/narrowed to the browser\. Pick a paid model in the side panel, .* another provider with OPENCODE_DB=/);});test('a model, or an effort, OpenCode does not have says which to change', () => {@@ -546,6 +546,48 @@ describe('what an OpenCode 2 says when it cannot start', () => {});});+describe('the models an OpenCode 2 picker offers', () => {+ const lister = () => listerFor(opencodeRunner, V2) as CommandLister;+ const parsed = (data: unknown[]) => lister().parse({ stdout: JSON.stringify({ data }), stderr: '', code: 0 });++ // Without --standalone, the question would start the user's background service on Browsentic's database.+ test("are asked of OpenCode's own server, on Browsentic's database, with the user's plugins and other servers kept out", () => {+ const env = lister().env?.('/state/agents/opencode/models') ?? {};+ expect(lister().args).toEqual(['api', '--standalone', 'model.list']);+ expect(env).toMatchObject({+ OPENCODE_DB: join(stateDir, 'agents', 'opencode', 'opencode-2.db'),+ PWD: '/state/agents/opencode/models',+ OPENCODE_CONFIG_PROJECT_DISABLE: '1',+ });+ expect(JSON.parse(env.OPENCODE_CONFIG_CONTENT).policies).toEqual([+ { action: 'integration.use', resource: 'plugin:*', effect: 'deny' },+ { action: 'integration.use', resource: 'mcp:*', effect: 'deny' },+ { action: 'integration.use', resource: 'mcp:browsentic', effect: 'allow' },+ ]);+ });++ test('OpenCode 1 has no such list, so its picker keeps the curated one', () => {+ expect(listerFor(opencodeRunner, '1.19.3')).toBeUndefined();+ });++ test('a disabled model is left out, and a Zen model with no price on record is kept', () => {+ expect(+ parsed([+ { providerID: 'opencode', id: 'unpriced' },+ { providerID: 'opencode', id: 'retired', enabled: false, cost: [{ input: 1, output: 2 }] },+ { providerID: 'opencode', id: 'priced-past-a-tier', cost: [{ input: 0, output: 0 }, { input: 4, output: 15 }] },+ { providerID: 'ollama', id: 'qwen3.8', cost: [{ input: 0, output: 0 }] },+ { id: 'no-provider' },+ ]),+ ).toEqual(['ollama/qwen3.8', 'opencode/priced-past-a-tier', 'opencode/unpriced']);+ });++ test('an answer that is not the list, or a failed one, is no list', () => {+ expect(lister().parse({ stdout: '<!doctype html>', stderr: '', code: 0 })).toBeNull();+ expect(lister().parse({ stdout: JSON.stringify({ data: [{ providerID: 'opencode', id: 'm' }] }), stderr: '', code: 1 })).toBeNull();+ });+});+describe('OpenCode 2 readiness', () => {const db = join(stateDir, 'agents', 'opencode', 'opencode-2.db');const bins = join(stateDir, 'opencode-bins');@@ -590,6 +632,21 @@ describe('OpenCode 2 readiness', () => {expect((await problem(answering(JSON.stringify(stale)).bin))?.code).toBe('AGENT_NEEDS_PERMISSION');}, 20_000);+ // A run writes its sessions to the same database, which has the sign-ins asked again without changing them.+ test('the model list is read again once the sign-ins change, and not for a run that only wrote its sessions', async () => {+ created();+ const zen = [{ id: 'opencode', connections: [{ id: 'cred_zen', type: 'credential' }] }];+ const stamp = () => (listerFor(opencodeRunner, V2) as CommandLister).stamp?.();+ await problem(answering(JSON.stringify(zen)).bin);+ const signedIn = stamp();+ writeFileSync(db, 'a run wrote its session');+ await problem(answering(JSON.stringify(zen)).bin);+ const afterRun = stamp();+ writeFileSync(db, 'signed in to another provider');+ await problem(answering(JSON.stringify([...zen, { id: 'anthropic', connections: [{ id: 'cred_anthropic', type: 'credential' }] }])).bin);+ expect([signedIn, afterRun === signedIn, stamp() === signedIn]).toEqual([expect.stringMatching(/^[0-9a-f]{16}$/), true, false]);+ }, 20_000);+// A picker that wrongly says "needs setup" blocks a working agent; the run's own error catches the opposite case.test('an answer it cannot read is taken as signed in', async () => {created();diff --git a/src/daemon/agent/runners/opencode.ts b/src/daemon/agent/runners/opencode.tsindex 500907a..db11903 100644--- a/src/daemon/agent/runners/opencode.ts+++ b/src/daemon/agent/runners/opencode.ts@@ -1,4 +1,4 @@-import { randomUUID } from 'node:crypto';+import { createHash, randomUUID } from 'node:crypto';import { mkdirSync, readFileSync, statSync } from 'node:fs';import { homedir } from 'node:os';import { dirname, join, relative, sep } from 'node:path';@@ -8,9 +8,9 @@ import type { AgentSettings } from '../config';import { MCP_SERVER_NAME } from './claude';import { spawnCli, stopTree, type CliProcess } from './command';import { childEnv } from './drive';-import { acpTurn } from './opencode-acp';+import { acpTurn, type TurnModel } from './opencode-acp';import { conversationDir, effortOf, MCP_CALL_TIMEOUT_MS, parseJsonLine, sweepRunDirs } from './util';-import type { JsonContext, McpServer, Plan, Runner, RunMode, StreamContext, StreamReader, StreamSink } from './types';+import type { CommandLister, JsonContext, McpServer, Plan, Runner, RunMode, StreamContext, StreamReader, StreamSink } from './types';/*** The whole config travels in OPENCODE_CONFIG_CONTENT, and its containment is one rule: the agent@@ -67,6 +67,11 @@ const configHome = () => join(process.env.XDG_CONFIG_HOME || join(homedir(), '.cconst INSTALL = 'npm i -g opencode-ai';+/** OpenCode Zen's provider id, whose free models serve only requests carrying OpenCode's own tools. */+const ZEN = 'opencode';++const NARROWED = 'a run whose tools Browsentic has narrowed to the browser';+/** `opencode v2.0.32` from 2.x, a bare `1.19.3` from 1.x. */export const isOpenCode2 = (version?: string): boolean => Number(/^(?:opencode\s+)?v?(\d+)\./i.exec(version?.trim() ?? '')?.[1] ?? 0) >= 2;@@ -139,6 +144,8 @@ export const opencodeRunner: Runner = {join(homedir(), '.claude', 'skills'),],+ models: (version) => (isOpenCode2(version) ? models2 : undefined),+stream(context: StreamContext): Plan {if (isOpenCode2(context.version)) return standalone(context);const { settings, research } = context;@@ -183,7 +190,7 @@ export const opencodeRunner: Runner = {plan: { ...turn2(context), args: ['acp'] },agent: AGENT,declined: () => noConversation.add(bin),- explain: (message) => explain({ message }, bin),+ explain: (message, model) => explain({ message }, bin, model),stoppedFor: (tool) => stoppedFor(tool),});},@@ -446,7 +453,7 @@ export function signInLine(bin: string, platform: NodeJS.Platform = process.platreturn `OPENCODE_DB=${quote(db)} ${/^[\w./-]+$/.test(bin) ? bin : quote(bin)} auth login --standalone`;}-function explain(failure: Failure | undefined, bin = 'opencode'): string {+function explain(failure: Failure | undefined, bin = 'opencode', model?: TurnModel): string {const message = oneLine(failure?.data?.message ?? failure?.message ?? failure?.name ?? failure?.type ?? 'OpenCode reported an error');const status = failure?.data?.statusCode ?? failure?.status;const body = failure?.data?.responseBody ?? failure?.response?.body ?? '';@@ -461,17 +468,12 @@ function explain(failure: Failure | undefined, bin = 'opencode'): string {}if (!v1 && body.includes('FreeTierError')) {return (- `OpenCode Zen's free models refuse a run whose tools Browsentic has narrowed to the browser. Sign Browsentic's OpenCode in ` +- `to a provider with ${signInLine(bin)}, then pick one of its models in the side panel. (${message})`+ `OpenCode Zen's free models refuse ${NARROWED}. Pick a paid model in the side panel, which Zen bills to your OpenCode account, ` ++ `or sign Browsentic's OpenCode in to another provider with ${signInLine(bin)}. (${message})`);}// Over ACP, 2.x says only this, for a provider with no sign-in and for Zen's free tier alike.- if (!v1 && /authentication required/i.test(message)) {- return (- `OpenCode has no sign-in for this model in Browsentic, and OpenCode Zen's free models refuse a run whose tools Browsentic ` +- `has narrowed to the browser. Sign Browsentic's OpenCode in to a provider with ${signInLine(bin)}, then pick one of its models in the side panel. (${message})`- );- }+ if (!v1 && /authentication required/i.test(message)) return `${refused(model, bin)} (${message})`;if (failure?.name === 'ProviderAuthError' || failure?.type === 'provider.auth' || status === 401 || status === 403) {if (!v1) return `${message} If that is a login problem, sign Browsentic's OpenCode in with ${signInLine(bin)}.`;return (@@ -493,6 +495,26 @@ function explain(failure: Failure | undefined, bin = 'opencode'): string {return message;}+/** What a refused 2.x turn needs, told from the provider of the model it ran on. */+function refused(model: TurnModel | undefined, bin: string): string {+ const line = signInLine(bin);+ if (!model) {+ return (+ `OpenCode Zen's free models refuse ${NARROWED}, and any other model needs a sign-in Browsentic's OpenCode holds. ` ++ `Pick a paid model in the side panel, or sign Browsentic's OpenCode in to a provider with ${line}.`+ );+ }+ const chosen = model.picked ? model.id : `${model.id}, which OpenCode chose because no model is picked in Browsentic`;+ const provider = model.id.split('/')[0];+ if (provider === ZEN) {+ return (+ `OpenCode Zen refused ${chosen}. Zen's free models refuse ${NARROWED}, and its paid ones need credit on your OpenCode account. ` ++ `Pick a paid model in the side panel, or sign Browsentic's OpenCode in to another provider with ${line}.`+ );+ }+ return `Browsentic's OpenCode has no working sign-in for ${provider}, so it could not run ${chosen}. Sign it in with ${line}, or pick another model in the side panel.`;+}+const oneLine = (message: string) => message.replace(/\s+/g, ' ').trim().slice(0, 240);const dataHome = () => join(process.env.XDG_DATA_HOME || join(homedir(), '.local', 'share'), 'opencode');@@ -520,7 +542,7 @@ function declaresProvider(pattern = /"provider"\s*:/): boolean {const AUTH_TIMEOUT_MS = 5_000;/** One answer per state of the database, and one question at a time. */-let lastAnswer: { key: string; problem: AgentProblem | null } | undefined;+let lastAnswer: { key: string; problem: AgentProblem | null; signIns?: string } | undefined;let asking: Promise<AgentProblem | null> | undefined;/**@@ -540,9 +562,9 @@ async function check2(settings: AgentSettings): Promise<AgentProblem | null> {const key = `${settings.bin}|${stamped}|${stamp(`${db}-wal`)}`;if (lastAnswer?.key === key) return lastAnswer.problem;asking ??= listSignIns(settings.bin)- .then((signedIn) => {- const problem = signedIn ? null : needsSignIn(settings.bin);- lastAnswer = { key, problem };+ .then((integrations) => {+ const problem = connected(integrations) ? null : needsSignIn(settings.bin);+ lastAnswer = { key, problem, signIns: integrations ? signInsOf(integrations) : undefined };return problem;}).finally(() => (asking = undefined));@@ -561,30 +583,46 @@ const stamp = (path: string) => {const needsSignIn = (bin: string): AgentProblem => ({code: 'AGENT_NEEDS_PERMISSION',message:- "This OpenCode 2 has no sign-in of its own for Browsentic, which keeps one apart from yours, and OpenCode Zen's free models refuse a run whose tools Browsentic has narrowed to the browser.",+ "This OpenCode 2 has no sign-in of its own for Browsentic, which keeps one apart from yours. Sign it in to a model provider, or to OpenCode Zen and then pick a paid model: Zen's free models refuse a run whose tools Browsentic has narrowed to the browser.",fix: signInLine(bin),});interface Integration {- connections?: { status?: { status?: string } }[];+ id?: string;+ connections?: { id?: string; type?: string; status?: { status?: string } }[];}-function listSignIns(bin: string): Promise<boolean> {+const connected = (integrations: Integration[] | null) =>+ !integrations || integrations.some(({ connections }) => connections?.some(({ status }) => !status || status.status === 'connected'));++/** The sign-ins as they stand, which a run writing its sessions to the same database leaves alone. */+const signInsOf = (integrations: Integration[]) =>+ createHash('sha256')+ .update(JSON.stringify(integrations.map(({ id, connections }) => [id, connections?.map(({ id: credential, type, status }) => [credential ?? type, status?.status])])))+ .digest('hex')+ .slice(0, 16);++/** How Browsentic's own OpenCode 2 is asked something: on its database, with the user's plugins and other MCP servers kept out. */+const asked2 = (cwd: string) => ({+ ...SEALED_2,+ PWD: cwd,+ OPENCODE_DB: database2(),+ OPENCODE_CONFIG_CONTENT: JSON.stringify({ policies: POLICIES }),+});++function listSignIns(bin: string): Promise<Integration[] | null> {const cwd = opencodeRunner.workspace('task');mkdirSync(cwd, { recursive: true });let child: CliProcess;try {- child = spawnCli(bin, ['auth', 'list', '--standalone', '--format', 'json'], {- cwd,- env: { ...childEnv('opencode'), ...SEALED_2, PWD: cwd, OPENCODE_DB: database2(), OPENCODE_CONFIG_CONTENT: JSON.stringify({ policies: POLICIES }) },- });+ child = spawnCli(bin, ['auth', 'list', '--standalone', '--format', 'json'], { cwd, env: { ...childEnv('opencode'), ...asked2(cwd) } });} catch {- return Promise.resolve(true);+ return Promise.resolve(null);}return new Promise((resolve) => {let output = '';let settled = false;- const done = (value: boolean) => {+ const done = (value: Integration[] | null) => {if (settled) return;settled = true;clearTimeout(timer);@@ -592,16 +630,52 @@ function listSignIns(bin: string): Promise<boolean> {};const timer = setTimeout(() => {stopTree(child, 'SIGKILL');- done(true);+ done(null);}, AUTH_TIMEOUT_MS);timer.unref();child.stdout.on('data', (chunk: Buffer) => void (output += chunk.toString()));child.stderr.on('data', () => {});- child.on('error', () => done(true));+ child.on('error', () => done(null));child.on('close', (code) => {const integrations = code === 0 ? parseJsonLine<Integration[]>(output.trim()) : null;- if (!Array.isArray(integrations)) return done(true);- done(integrations.some((integration) => integration.connections?.some((connection) => !connection.status || connection.status.status === 'connected')));+ done(Array.isArray(integrations) ? integrations : null);});});}++interface ListedModel {+ providerID?: string;+ id?: string;+ enabled?: boolean;+ capabilities?: { tools?: boolean };+ cost?: { input?: number; output?: number }[];+}++interface Listed {+ data?: ListedModel[];+}++/** Zen bills nothing for its free models, and serves them only to OpenCode's own tools. */+const zenFree = ({ providerID, cost = [] }: ListedModel) => providerID === ZEN && cost.length > 0 && cost.every(({ input, output }) => !input && !output);++function runnable(listed: Listed | null): string[] | null {+ const models = listed?.data;+ if (!Array.isArray(models)) return null;+ const ids = models+ .filter((model) => model.providerID && model.id && model.enabled !== false && model.capabilities?.tools !== false && !zenFree(model))+ .map(({ providerID, id }) => `${providerID}/${id}`)+ .sort();+ return ids.length ? ids : null;+}++/**+ * The models Browsentic's own OpenCode 2 can run a turn on, as its server lists them for the sign-ins+ * that database holds: none that cannot call a tool, and none of Zen's free ones. The list is read+ * again when a sign-in changes.+ */+const models2: CommandLister = {+ args: ['api', '--standalone', 'model.list'],+ env: asked2,+ stamp: () => lastAnswer?.signIns,+ parse: ({ stdout, code }) => (code === 0 ? runnable(parseJsonLine<Listed>(stdout.trim())) : null),+};diff --git a/src/daemon/agent/runners/types.ts b/src/daemon/agent/runners/types.tsindex b980921..50f8d83 100644--- a/src/daemon/agent/runners/types.ts+++ b/src/daemon/agent/runners/types.ts@@ -117,13 +117,27 @@ export interface Listing {code: number | null;}+/** A subcommand that prints the models the account can use. */+export interface CommandLister {+ args: string[];+ /** Set for the listing alone, over the sealed environment every spawn of the agent gets. */+ env?(cwd: string): Record<string, string>;+ /** What the list depends on besides the CLI itself, such as its sign-ins: a change reads it again. */+ stamp?(): string | undefined;+ parse(listing: Listing): string[] | null;+}++/** A file the CLI keeps its model list in. */+export interface FileLister {+ file(): string;+ parse(content: string): string[] | null;+}+/**- * Where a CLI lists the models its account can use: a subcommand it prints them from, or a file- * it keeps them in. `parse` answers null for anything but a clean list — signed out included.+ * Where a CLI lists the models its account can use. `parse` answers null for anything but a clean+ * list — signed out included.*/-export type ModelLister =- | { args: string[]; parse(listing: Listing): string[] | null }- | { file(): string; parse(content: string): string[] | null };+export type ModelLister = CommandLister | FileLister;export interface Runner {kind: AgentKind;@@ -134,8 +148,8 @@ export interface Runner {workspace(mode: RunMode): string;/** Directories where this CLI keeps the user's own skills, feeding the panel's skill picker. */skillDirs?(): string[];- /** Absent: the picker offers the catalog's curated models. */- models?: ModelLister;+ /** Absent, or none for the version probed: the picker offers the catalog's curated models. */+ models?: ModelLister | ((version?: string) => ModelLister | undefined);stream(context: StreamContext): Plan;/** A conversation to hold for this turn instead, where the CLI offers one; null to use `stream`. */converse?(context: StreamContext): Conversation | null;