Commit Graph
13 Commits
Author SHA1 Message Date
FLYF f8e996dc66 fix: mirror the OpenCode client fingerprint so upstream stops rejecting requests
Upstream now fingerprints the client on every tier. The gateway's request shape
no longer passes, so both the keyless free tier and the keyed lanes come back as

    403 {"type":"error","error":{"type":"FreeTierError","message":"OpenCode's
    free tier can only be used from within OpenCode..."}}

Reproduced by replaying the gateway's exact request against the live endpoint,
and cross-checked by capturing what the official client (@opencode/cli@2.0.29)
puts on the wire.

Three things are checked, and each one alone is enough to fail the request:

1. Endpoint. Keyless traffic moved off /zen onto https://opencode.ai/inference.
   Keyed traffic still uses /zen (or /inference/openai), so the anonymous lane
   gets its own `upstream.anonymous` base instead of sharing `upstream.zen`.

2. Header shape. Upstream wants the client's own headers: a
   "opencode/<channel>/<version>/cli" User-Agent, x-opencode-session-id, a bare
   40-character hex x-opencode-project, and no x-opencode-request. The previous
   legacy set — "opencode/1.18.31 (<os> <arch>; <runtime>)" User-Agent, a
   "prj_" prefixed project, and the gateway's x-opencode-request — is rejected
   on both the keyless and the keyed lanes.

3. Tool definitions. Every tool whose name upstream recognises must carry the
   genuine OpenCode definition; a synthesised stub that only reuses the name is
   rejected. The gateway now embeds the real definitions captured from the
   official client and uses them for the tools it injects, and rewrites any
   downstream tool that happens to reuse a recognised name. Unrecognised tool
   names still pass through untouched, so downstream function calling keeps
   working. `anonymousCoreTools` also drops "bash" in favour of "shell", since
   "bash" is a recognised name whose genuine definition the gateway does not
   have.

Verified against the live endpoint on both lanes: non-streaming, streaming,
function calling with a downstream tool, /v1/messages and /v1/responses all
return 200. Unit tests cover the request headers, the genuine tool definitions
and the tool rewrite.
2026-10-14 23:38:14 +08:00
Jason Xu df119c48e4 发布准备:合入 #36、#46、#48、#49、#50、#53;修复 #42、#44、#51、#52,并添加 GPL-3.0-or-later。
保留 reasoning 配置,新增免费模型可用性探测 / 手动恢复、首 SSE 事件超时,元数据改用官方地址。按维护者要求,最终文件树排除测试文件。

验证:本地 Go 回归、go vet / build、Prettier、JS / shell 语法及独立实例管理端验收通过。
2026-10-07 19:55:34 +08:00
Jason Xu 31c35704be Merge pull request #36: model rotation, quotas and API key management 2026-10-07 19:37:30 +08:00
Jason Xu 3fb18e1950 fix: set example reasoning defaults 2026-09-21 14:50:33 +08:00
Jason Xu 8e776c43b5 style: format webui and documentation 2026-09-21 14:38:30 +08:00
Jason Xu 683b7e9af0 feat: expose configurable reasoning effort 2026-09-21 14:34:00 +08:00
haverainlilili 3440273f43 feat: 新增模型轮转、额度看板和密钥管理 2026-09-21 10:18:21 +08:00
Jason Xu ea29a62eca fix: harden gateway routing and protocol fidelity
Preserve request parameters, tool-call completion reasons and retry session
affinity. Bound upstream header waits, stop expired-context scans and add
opt-in redacted request-body diagnostics.

Isolate Playground diagnostics from production pools, report stream failures
accurately, align readiness with discoverable models and honor Docker listen
configuration.

Split Go and WebUI modules by responsibility, add regression tests and CI,
standardize formatting and rewrite the English and Chinese READMEs.

Refs: #6, #18, #19, #20, #21, #22, #23, #24, #25
2026-09-15 00:43:35 +08:00
Jason Xu 8e131dcf3b feat: add anonymous Zen support 2026-08-17 12:40:24 +08:00
Jason Xu fdae1902a0 feat: add authenticated web management console 2026-08-16 04:29:43 +08:00
Jason Xu 40024ea5e8 feat: load proxy pool from file 2026-08-16 03:37:36 +08:00
Jason Xu adb0edb64a config: make zen/go preference configurable via prefer field
Add a top-level "prefer" config field ("zen" or "go", default "go") that
controls which upstream is used when a model is available in both pools,
including during the temporary model-discovery fallback. Previously Zen
was always preferred.
2026-08-14 10:34:08 +08:00
Jason Xu f32c4a0e61 feat: add OpenCode Zen API compatibility proxy 2026-08-14 08:33:22 +08:00