harness-providers + app: dedicated opencode (Zen) provider

OpenAiProvider gains a custom id and a chat-only mode; `OpenAiProvider::opencode`
builds an OpenCode Zen provider (id `opencode`, defaults to Zen's gateway, always
chat-completions so even gpt-*/o* model ids route correctly). Registered from a
`providers.opencode` config block / OPENCODE_API_KEY env, so it coexists with a
real `openai` provider. Models are referenced as `opencode/<model>`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-09 06:59:46 +02:00
co-authored by Claude Opus 4.8
parent 7738ed55b9
commit 230e828b81
3 changed files with 64 additions and 3 deletions
+13
View File
@@ -147,6 +147,19 @@ impl EngineHandle {
};
providers.register(Arc::new(provider));
}
// OpenCode Zen: OpenAI-compatible chat gateway under its own `opencode` provider id,
// so it coexists with a real `openai` provider. `base_url` defaults to Zen's endpoint.
if let Some(key) = config
.providers
.get("opencode")
.and_then(|p| p.api_key.clone())
{
let base_url = config
.providers
.get("opencode")
.and_then(|p| p.base_url.clone());
providers.register(Arc::new(OpenAiProvider::opencode(key, base_url)));
}
Self::build(cwd, store, config, providers)
}