Skip to content

Models-first provider connect and multi-protocol OpenCode Go - #323

Merged
TheGreatAxios merged 11 commits into
mainfrom
stack/opencode-models-first-connect
Aug 5, 2026
Merged

Models-first provider connect and multi-protocol OpenCode Go#323
TheGreatAxios merged 11 commits into
mainfrom
stack/opencode-models-first-connect

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Replace standalone /login with models-first Connect on /model (c / Ctrl+A) for seven first-class providers (Codex, xAI, Zen, Anthropic, OpenAI, Google, OpenCode Go).
  • Ship TUI-free packages @corbits/provider-opencode-go and @corbits/first-class-providers (catalog, auth metadata, protocol routing, usage).
  • Route OpenCode Go inference by per-model protocol (chat completions / responses / Anthropic messages), not a single provider-wide adapter.
  • Classify Go gateway errors (GoUsageLimitError, free-limit, provider rate limits) including the observed HTTP 400 rate-limit quirk, so quota aborts and short limits stay retryable.
  • Show Go subscription usage in the status bar when Go is active (clean degrade on auth/network failure).

Commits

  1. OpenCode Go provider package (catalog, protocol, auth, usage, errors)
  2. First-class provider connect catalog
  3. Inference sources + openai-responses adapter wiring
  4. Go quota/rate-limit error classification
  5. Connect UX from model picker (remove /login entry points)
  6. Status-bar Go usage
  7. Docs (PRODUCT / ARCHITECTURE / IMPLEMENTATION)

Test plan

  • bun run typecheck
  • bun run build
  • Package + inference + gateway + config unit tests green
  • Full suite: 3941 pass; 1 pre-existing flaky (permission.wait spans in src/perf/permission-subagent-spans.test.ts)
  • Manual: /model → Connect (c/Ctrl+A) → API-key providers persist and models appear without restart
  • Manual: OpenCode Go chat vs messages vs responses models stream correctly
  • Manual: Go usage appears in status bar; degrades if usage API 404s
  • Manual: simulate rate-limit/quota body (429 and 400) surfaces correct category

Ship @corbits/provider-opencode-go as a TUI-free package: pre-seeded
models with per-model protocol metadata, endpoint routing for chat
completions / responses / Anthropic messages, API-key validation,
subscription usage fetch with clean degrade, and gateway error
classification for quota and rate-limit shapes (including HTTP 400).
Ship @corbits/first-class-providers with the seven connect targets
(Codex, xAI, Zen, Anthropic, OpenAI, Google, OpenCode Go), auth mode
metadata, pre-seeded models, and adapter hints so Corbits only wires
connect and inference.
Add settings flags, catalog builders, and per-model protocol routing
so Go models resolve to the correct adapter and base URL. Register a
generic openai-responses adapter for responses-protocol models and
keep settings load from dropping optional keys including otel.
Reclassify GoUsageLimitError and provider rate-limit payloads in the
retry normalizer so long-window quota aborts cleanly and short rate
limits stay retryable, including when the gateway returns HTTP 400.
Remove the standalone login command entry points and add Ctrl+A /
c Connect on /model for first-class providers. OAuth paths reuse
existing Codex and xAI flows; API-key providers prompt, validate,
and persist so models are selectable without restart.
When the active provider is OpenCode Go, fetch and format rolling
usage for the status bar and degrade cleanly on auth or network
failure instead of blocking the session.
Update product, architecture, and implementation docs for Connect
from /model, first-class provider packages, and per-model protocol
routing on the Go gateway.
Editing a Go or Anthropic catalog entry without re-submitting connect flags
was dropping anthropic/opencodeGo and breaking multi-protocol routing. Seed
connectDraft from existing provider flags, preserve flags in
buildProviderEntry, and stop matching bare provider_rate_limit_exceeded so
non-Go proxies are not misclassified. Align remaining /login and /agent copy
with models-first Connect.
Connecting an already-saved API-key provider (e.g. OpenCode Go) failed with
name conflict. Seed Connect as edit when the catalog already has that id so
key rotation works in place while keeping operator-customized models and
protocol flags.
Accidental staging from a parallel PR review; not part of models-first
Connect or OpenCode Go work.
Bare Go 429s were stuck as quota_exhausted because reclassification
required body markers while intx defaults 429 to quota. Recognize known
Go context via requestURL, provider id, or opencodeGo so short rate
limits reclassify as retryable. Prefer clear usage-limit markers on 403
over unauthorized. Cover empty-key re-Connect apiKey preservation.
@TheGreatAxios
TheGreatAxios force-pushed the stack/opencode-models-first-connect branch from 2e85f72 to fa36256 Compare August 5, 2026 06:26
@linear-code

linear-code Bot commented Aug 5, 2026

Copy link
Copy Markdown

@TheGreatAxios
TheGreatAxios merged commit 9ec5cc5 into main Aug 5, 2026
1 check passed
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.

1 participant