Files
opencode2api/internal/protocol/protocol.go
T
asas6661 4fed6e4d31 feat: serve System One decision models on /v1/systemone
OpenCode Zen publishes System One models (jev-1.13, jev-1.13-free) on a
/v1/systemone endpoint. A request pairs a free-form state with typed
questions and the reply carries typed answers, so the payload shares no
shape with the chat/responses bridge and cannot be translated.

- protocol: add SystemOne with its endpoint path.
- discovery: read "systemone" rows from the upstream endpoint tables so
  those models stop being bucketed as unsupported.
- gateway: add POST /v1/systemone, which relays the body verbatim
  through the existing tier and anonymous machinery and returns the
  answer document unchanged. Models on another protocol are rejected
  with a clear error instead of being forwarded to a message API.
- anonymous lane: keep System One bodies verbatim. Forcing streaming or
  injecting the core agent tools, which the free tier requires for chat
  traffic, would invalidate a decision request.

Verified end-to-end against the live upstream: jev-1.13-free answers
through the gateway with cost 0, chat and responses models keep working,
and the endpoint rejects mismatched payloads.
2026-09-23 12:11:45 +08:00

34 lines
908 B
Go

// Package protocol translates Chat, Responses, and Anthropic payloads and
// streams, and carries the opaque System One decision payloads.
package protocol
type Protocol string
const (
Chat Protocol = "chat"
Responses Protocol = "responses"
Anthropic Protocol = "anthropic"
// SystemOne is OpenCode Zen's structured decision endpoint. A request pairs
// a free-form state with typed questions and the reply carries typed
// answers, so the payload shares no shape with the chat/responses bridge and
// is forwarded as-is.
SystemOne Protocol = "systemone"
)
func Valid(p Protocol) bool {
return p == Chat || p == Responses || p == Anthropic || p == SystemOne
}
func Path(protocol Protocol) string {
switch protocol {
case Responses:
return "/v1/responses"
case Anthropic:
return "/v1/messages"
case SystemOne:
return "/v1/systemone"
default:
return "/v1/chat/completions"
}
}