Skip to content

Add OpenCode Go as a model provider - #25

Closed
zoot334 wants to merge 1 commit into
owngoal-dev:mainfrom
zoot334:feat/opencode-go-burc
Closed

zoot334 wants to merge 1 commit into
owngoal-dev:mainfrom
zoot334:feat/opencode-go-burc

Conversation

@zoot334

@zoot334 zoot334 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Why

Refs #23. OpenCode Go cannot be reached through the existing OpenAI-Compatible API provider: every Go request needs an x-opencode-session header, and kwwk v0.1.100 neither sends it nor registers opencode-go as a provider.

Probed against the live gateway on 2026-10-30:

  • POST https://opencode.ai/inference/go/v1/chat/completions without x-opencode-session → 400 MissingSessionID, before auth.
  • The same for /go/openai/v1/responses, /go/anthropic/v1/messages and /go/google/....
  • With x-opencode-session: test-session, routing passes and the request reaches auth/model errors.
  • GET https://opencode.ai/inference/go/v1/models → 200, 28 models with an api family per model.

kwwk carries the opencode-go catalog and display name, but has no providerDirectory entry, no registerStored case, and no occurrence of x-opencode-session (checked the pinned revision and origin/main). This PR adds the provider the same way DeepSeek was added.

What

  • New AgentProvider.openCodeGo (opencode-go), API-key sign-in only, oc_sk_… placeholder, in the API Keys group after DeepSeek.
  • OpenCodeGoProvider registers each model on the wire its catalog entry names:
    • Chat Completions and Responses → https://opencode.ai/inference/go/openai/v1
    • Anthropic Messages → https://opencode.ai/inference/go/anthropic
    • Gemini → https://opencode.ai/inference/go/google
  • OpenCodeGoSessionProvider stamps x-opencode-session from the conversation's session id (a process id for verification and other requests with no conversation), following CopilotRequestHeadersProvider; it forwards session cleanup and native compaction.
  • Model discovery uses https://opencode.ai/inference/go/v1/models; known catalog ids keep their compat, reasoning levels, image input and context. Unknown ids fall back to Chat Completions, which Console translates, with a conservative text-only, non-reasoning model.
  • Display name, official favicon mark, 12 translations, AGENTS.md decision text and README provider list.
  • Tests: per-model wire/base mapping, fallback, auth resolver, header stamping and caller precedence, catalog list/reasoning, key-only sign-in, verification through the existing local-server test, and a live test for GLM-5.2 (Chat) and Claude Haiku 5.5 (Anthropic).

Testing

  • make check — passed locally.
  • swift build in Packages/ApelinAgent — passed.
  • swift test in Packages/ApelinAgent — 528 tests passed, including the new OpenCodeGoProviderTests, ProviderModelsTests, AccountDeskTests and ProviderKeyVerificationTests additions.
  • swift test --filter OpenCodeGoLiveTests — compiles and skips without APELIN_LIVE_OAUTH_PATH; not run against a real key here.
  • No installable .deb was built locally: this machine has Xcode 26.3 / iOS 26.2, while the repo builds with Xcode 27.1 / iOS 27.1. CI's build job produces apelin-<sha> for device testing.

To run the live test, add an opencode-go entry to a kwwk-format credential file and run:

cd Packages/ApelinAgent
APELIN_LIVE_OAUTH_PATH=~/.kwwk/auth.json swift test --filter OpenCodeGoLiveTests

Not included

  • OpenCode Zen (pay-as-you-go): it does not require x-opencode-session and is already reachable through OpenAI-Compatible at https://opencode.ai/inference/v1. A named .openCodeZen can follow separately.
  • OAuth: Go is API-key only.
  • A kwwk bump: the pinned catalog lacks four live ids and carries a few stale ones. Known ids work; live discovery offers the rest; unknown ids use the fallback. The adapter is deliberately local and can be removed when kwwk registers opencode-go itself.

Follow-ups

  • File an upstream kwwk issue/PR for opencode-go registration and the session header.
  • Refresh the bundled model catalog with a deliberate kwwk bump.
  • Device test the CI .deb: sign in, enable one Chat model and one Anthropic model, run a tool-call round trip on each.

OpenCode Go's gateway requires x-opencode-session on every request and serves each model over its own wire; the generic OpenAI-compatible provider sends neither. Register a first-class provider under opencode-go, select each model's transport from kwwk's catalog, and stamp the conversation's session id. The key-only sign-in, display name, mark and translations follow the existing provider table.
Lakr233 added a commit that referenced this pull request Oct 31, 2026
kwwk now registers OpenCode's two plans (the key bound to each
resolution, every request naming its conversation in
x-opencode-session), sends native compaction no empty metadata (issue
#26) and asks Gemini 4 by thinking level. Model Providers gains OpenCode
Go and OpenCode Zen, API keys with an optional default model and their
models listed from the plan, and kwwk 0.1.108's Kimi For Coding Global.
PR #25's own OpenCode adapter is not needed; its mark and wording are.
Pinned to EYHN/kwwk#226's head until v0.1.109 is tagged.

Co-authored-by: Burç <21700838+burcb330134@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Lakr233

Lakr233 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thank you, Burç! Your design for OpenCode Go went into kwwk itself (EYHN/kwwk#226), so Apelin 0.3.3 offers OpenCode Go and OpenCode Zen in Model Providers without a provider of its own. Closing this in favour of that: https://github.com/owngoal-dev/Apelin/releases/tag/v0.3.3

@Lakr233 Lakr233 closed this Oct 31, 2026
@zoot334

zoot334 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Thank you, Burç! Your design for OpenCode Go went into kwwk itself (EYHN/kwwk#226), so Apelin 0.3.3 offers OpenCode Go and OpenCode Zen in Model Providers without a provider of its own. Closing this in favour of that: https://github.com/owngoal-dev/Apelin/releases/tag/v0.3.3

Thanks for getting back to me so fast, I just tested it and opencode integration works flawlessly! Apelin is exactly what I needed for AI-assisted on-device tweak development. Really grateful you built it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants