Skip to content

Feat/opencode zen provider#4467

Open
snail-vs wants to merge 7 commits into
Hmbown:mainfrom
snail-vs:feat/opencode-zen-provider
Open

Feat/opencode zen provider#4467
snail-vs wants to merge 7 commits into
Hmbown:mainfrom
snail-vs:feat/opencode-zen-provider

Conversation

@snail-vs

Copy link
Copy Markdown

Summary

  • Added OpenCode Zen as a model-aware provider.
  • Routes Zen models across Responses, Anthropic Messages, and Chat Completions.
  • Added Zen-specific missing-API-key messaging.
  • Fixed Zen Claude authentication to use x-api-key.
  • Kept OpenCode Go out of this PR.

Testing

  • [ x ] cargo fmt --all -- --check
  • [ x ] cargo clippy --workspace --all-targets --all-features
  • cargo test --workspace --all-features
    Full workspace tests were run serially. One unrelated TUI test failed in the full suite but passed when rerun in isolation:
    non_recoverable_engine_error_enters_offline_mode

Checklist

  • [ x ] Updated docs or comments as needed
  • [ x ] Added or updated tests where relevant
  • [ x ] Verified TUI behavior manually if UI changes
  • [ x ] Harvested/co-authored credit uses a GitHub numeric noreply address

snailoniu added 7 commits July 17, 2026 10:43
Represent provider wire selection as either fixed or model-aware. Resolve model-aware protocols from catalog endpoint keys and fail closed when an endpoint does not prove a supported request shape.\n\nExisting providers remain fixed-policy routes, so this creates the Zen routing seam without changing current provider behavior.

Signed-off-by: snailoniu <snailoniu@gmail.com>
Register OpenCode Zen across config, CLI, secrets, and TUI surfaces with provider-scoped API key guidance. Keep its wire policy model-aware and fail closed until a catalog offering proves the selected model protocol.

Signed-off-by: snailoniu <snailoniu@gmail.com>
Route the documented Zen catalog across Responses, Anthropic Messages, and Chat Completions by model. Normalize the official opencode/model selector and reject Gemini or unknown models until their request protocol is supported and proven.

Signed-off-by: snailoniu <snailoniu@gmail.com>
Bind clients to the resolver-proven request protocol and send Zen models through Responses, Anthropic Messages, or Chat Completions as appropriate. Keep Zen on bearer authentication, exclude Codex OAuth headers, and fail closed when a request changes protocol or uses an unproven FIM route.

Signed-off-by: snailoniu <snailoniu@gmail.com>
Document Zen as a separate API-key provider with model-scoped Responses, Messages, and Chat Completions groups. Record the unsupported Gemini boundary and teach the provider registry drift check about the manual model-aware provider implementation.

Signed-off-by: snailoniu <snailoniu@gmail.com>
OpenCode Zen routes Anthropic models through the Messages API, which expects the native x-api-key header. Sending Zen keys as Authorization bearer tokens produced upstream 401 Missing API key errors for Claude models. Refresh the request-shape test to lock the Zen Messages auth dialect while keeping bearer auth for Zen Responses and Chat Completions routes.

Signed-off-by: snailoniu <snailoniu@gmail.com>
The model-aware route guard now reports that the Anthropic-compatible route has no proven FIM wire contract. Keep the local-failure test aligned with that fail-closed behavior and continue asserting that no HTTP request is made.

Signed-off-by: snailoniu <snailoniu@gmail.com>
@snail-vs
snail-vs requested a review from Hmbown as a code owner July 17, 2026 06:22
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @snail-vs for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

@Hmbown Hmbown added this to the v0.9.3 milestone Jul 17, 2026
@Hmbown

Hmbown commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Intake note: this covers the OpenCode Zen half of #1481, which is milestone-assigned to v0.9.3 (the OpenCode Go half shipped in #4420; Zen + the Messages-protocol route follow in the v0.9.3 window). Setting the milestone accordingly — no action needed from you; we'll do the full review pass when v0.9.3 opens. Thanks for taking this on!

Hmbown commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Thanks — this is what a complete provider addition looks like: WirePolicy::ModelAware with per-model wire selection across Responses, Anthropic Messages, and Chat Completions, fail-closed handling for unknown and Gemini models, the Zen x-api-key fix with request-shape tests, secrets env-alias tests, and the parity pieces (docs/PROVIDERS.md, config.example.toml, CHANGELOG, check-provider-registry.py) all in one branch.

Where it stands: per the intake note, this is the Zen half of #1481 (Go shipped in #4420) and sits on the v0.9.3 milestone; v0.9.1 is freezing and v0.9.2 is the active lane, so the full review pass comes when v0.9.3 opens. The full CI matrix has not run on this head yet — fork PRs only get the intake gate and GitGuardian until review.

To keep the branch landable in the meantime:

  1. Rebase onto current main. The July 17-18 credential-help centralization (eb20e81, ca026e3, f6a882c) moved provider credential-page logic out of crates/tui/src/config.rs into CredentialHelp in crates/config/src/provider.rs; your hunk pointing Zen/Go at https://opencode.ai/zen/ needs to land on that new surface.
  2. Expect one more mechanical registry shift when the TelecomJS preset (feat: add TelecomJS provider support with configuration and catalog i… #4370 / Custom provider live catalog is never refreshed in production (scoped catalog state rewrite) #4462) lands in the v0.9.2 window ahead of this — re-derive the array counts rather than merging blindly.
  3. The full-suite flake you hit (non_recoverable_engine_error_enters_offline_mode) is not on the known-papercuts list; if you still have the output, filing it as an issue would be independently useful.

Related demand your work serves: #1481 and #4526.


Generated by Claude Code

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