mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 08:02:53 +00:00
OpenCode's 2026-10-14 gate rejects the gateway on every lane again (403 FreeTierError) while the official CLI keeps working. Probing byte-identical CLI v2.0.29 replays against the live endpoint isolated the deltas this changeset fixes on top of #83: - identity: derive the session from the new x-opencode-session-id signal too, and stop forwarding the legacy x-opencode-request header and canonical prj_* project ids upstream — both are instant 403s. - upstream: the x-opencode-project header keeps one conversation pinned to one upstream project but is now hashed into the bare 40-hex shape the client sends (a prj_* value 403s). - refresh: when the configured anonymous upstream has no models route (404), fall back to the legacy Zen console listing so the anonymous catalog still populates. The endpoint move, genuine tool definitions, and UA shape came in with #83; the definitions embedded there were re-verified byte-for-byte against a fresh CLI v2.0.29 capture, including the smallest passing toolset (shell + read) and per-tool definition checks. Validation: live end-to-end against opencode.ai — anonymous lane serves streaming and plain JSON chat completions on big-pickle and step-5-preview-free, tool calls pass through, all nine exposed free models probe available, go vet/build/gofmt clean.
15 lines
631 B
Go
15 lines
631 B
Go
package httpx
|
|
|
|
// clientVersion is the OpenCode release the gateway claims to be. Upstream
|
|
// accepts a range of releases (the version number itself is not validated),
|
|
// so this only needs bumping when it starts rejecting older ones.
|
|
const clientVersion = "2.0.29"
|
|
|
|
// UserAgent reports the gateway as an OpenCode client using the shape upstream
|
|
// expects: "opencode/<channel>/<version>/<name>". The previous
|
|
// "opencode/<version> (<os> <arch>; <runtime>)" form is rejected with 403
|
|
// FreeTierError even when the rest of the request is identical.
|
|
func UserAgent() string {
|
|
return "opencode/latest/" + clientVersion + "/cli"
|
|
}
|