Commit Graph
14 Commits
Author SHA1 Message Date
sk-dev-ai 51639af3ef chore: remove orphaned stream helpers
transcodeStream, transcodeStreamWithUsage, forwardSSEWithUsage and
forceStreamBody have no callers since the package refactor; the live
paths use the request-aware TranscodeStream/ForwardStream and
prepareAnonymousBody directly. Also fix the stale comment reference.
2026-10-04 19:56:41 +05:30
asas6661 a65ff83d71 feat: accept decision payloads on message endpoints too
The dedicated /v1/systemone route is the correct surface, but many
deployments only reach the gateway through an OpenAI-shaped proxy that
pins every request to /v1/responses (sub2api forwards OpenAI-platform
accounts to Responses only). Such a proxy can never address
/v1/systemone, so a System One model stays unreachable even though the
gateway supports it.

Route System One models through the same verbatim relay when they are
requested on /v1/chat/completions or /v1/responses. The payload still
carries state and typed questions; nothing is converted, and models on
another protocol keep their normal bridge path.

Verified through a sub2api group pointed at this gateway:
  POST /v1/responses {"model":"jev-1.13-free","state":"...",
                      "questions":{"is_urgent":{"type":"noul",...}}}
  -> 200 {"answers":{"is_urgent":{"noul":0.94}},"cost":"0"}
Sending the decision fields alongside OpenAI message fields does not
work: the proxy rewrites the body and the decision fields are lost, so
the relayed request is rejected upstream.
2026-09-23 13:35:30 +08:00
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
Jason Xu 683b7e9af0 feat: expose configurable reasoning effort 2026-09-21 14:34:00 +08:00
Jason Xu e5f4e3a583 fix: shape key-tier free-model bodies to agent shape
Merge pull request #33
2026-09-19 13:05:54 +08:00
Jason Xu 41b9453d42 fix: demote phantom tool_use stop when no tool block was assembled
Merge pull request #27
2026-09-19 13:05:36 +08:00
Jason Xu b689a5b3a6 fix: preserve Chat usage for shaped free requests 2026-09-19 12:46:32 +08:00
Jason Xu 82e88f2b7f fix: filter phantom non-stream tool blocks 2026-09-19 12:46:32 +08:00
sk-dev-ai 3f8763d9da feat: forward native cache-affinity knobs (prompt_cache_key et al)
Native opencode sends prompt_cache_key (session-sliced ID), plus
safety_identifier, store, and service_tier. The translator dropped
all four, so proxied turns never rode prompt-cache affinity while
native did. Decode, carry, and re-emit on both Chat and Responses
paths, omit-when-absent. Verified live: same-session turns hit 99%
cached upstream after warm-up.
2026-09-18 19:39:17 +05:30
sk-dev-ai 79378c8744 fix: shape key-tier free-model bodies to agent shape
Upstream now rejects non-agent-shaped free-tier requests on every lane
with 403 FreeTierError (#29); #31 covered the anonymous lane only, so
keyed-only configs still 403 on bare probes. Mirror the normalization
(stream + core agent tools) for catalog-free models on key tiers; paid
bodies untouched. Non-streaming clients get the same stream collapse
as the anonymous lane. Free check uses catalog pricing metadata, not
the -free name, so nameless free models are covered.
2026-09-18 19:38:29 +05:30
58 2ce1f9e44b fix: serve anonymous free tier as agent-shaped streams
Upstream now rejects anonymous free-tier requests unless they look
like real agent traffic: stream:true plus the core agent tools
(bash/edit/glob/grep/read), returning 403 FreeTierError otherwise.

Normalize the anonymous-lane wire body (force stream:true, inject
minimal definitions for any missing core tools) and collapse the
SSE stream back into the single JSON document non-streaming
clients asked for. Authenticated tiers are untouched.
2026-09-18 09:09:20 +08:00
58 8185202382 fix: use canonical OpenCode session IDs for Zen free tier
Upstream began rejecting anonymous free-tier requests whose
x-opencode-session does not match ses_[0-9a-f]{12}[0-9A-Za-z]{14}
with 403 FreeTierError. Map every downstream identity into that
shape deterministically (preserving native sessions), and bump
the impersonated client version to 1.18.31.
2026-09-17 14:07:36 +08:00
xiechen 278b0bb8e2 fix: demote phantom tool_use stop when no tool block was assembled
Upstream Chat/Responses turns sometimes end with finish_reason
tool_calls while delivering no usable tool call (empty tool_calls
array, or deltas without a name). The bridge forwarded that as
stop_reason tool_use with zero tool_use content blocks. Strict
clients then end the turn running nothing and reporting no error,
which stalls agent loops mid-task with no visible failure.

Guard both the streaming (Finish) and non-streaming
(encodeBridgeResponse) paths: a tool stop with no assembled tool is
demoted to a plain stop so the client treats it as text end-of-turn
and continues.
2026-09-15 18:06:45 +08:00
Jason Xu 46def7fedc refactor: organize Go packages and remove test files
Move the command to cmd/opencode2api and group production code into
configuration, gateway, protocol, model, admin, telemetry and helper packages.
Keep shared state private behind context, metrics and runtime interfaces.

Remove the requested test files and replace test-only CI jobs with vet/build
checks. Update Docker and release build paths, preserve version injection and
make the WebUI an explicit embedded asset package.

Add directory trees and source reading guides to both READMEs. Anchor binary
ignore rules so the command package is tracked.
2026-09-15 01:28:44 +08:00