Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

build(model-hub): cut model-hub-engine-v8.0.23-3 with an HTTP/2 health check on the standard transport and per-event Codex SSE parsing (#2532)

Call White98cc70a1cdb1
diff --git a/patches/model-hub-cpa-v8.0.23/README.md b/patches/model-hub-cpa-v8.0.23/README.md
index d330628ef..819efb85e 100644
--- a/patches/model-hub-cpa-v8.0.23/README.md
+++ b/patches/model-hub-cpa-v8.0.23/README.md
@@ -1,7 +1,7 @@
# Avibe-owned CPA v8.0.23 compatibility patches
This directory records the source patches carried by Avibe's
-`model-hub-engine-v8.0.23-2` build. Each patch applies independently to the
+`model-hub-engine-v8.0.23-3` build. Each patch applies independently to the
pinned source; the build applies them in the order the manifest's
`build.patches` records.
@@ -33,8 +33,12 @@ its module import path, outside the patched hunk.
The patch also updates the three `useMaxCompletionTokens=false` cases of
upstream's `TestNormalizeOpenAIMaxTokens`, which asserted the stock rewrite,
to assert this contract: the payload, including a `null` limit, is returned
-unchanged. With all patches applied,
-`go test ./internal/runtime/executor/helps/` passes. The test change does not
+unchanged. It updates the four `use-max-completion-tokens=false` chat cases of
+upstream's executor-level `TestOpenAICompatExecutor_MaxTokensNormalization`
+and `TestOpenAICompatExecutor_MaxTokensNormalizationStream` the same way: the
+request keeps `max_completion_tokens`, including `null`, and gains no
+`max_tokens`. With all patches applied, `go test ./internal/runtime/executor/`
+and `go test ./internal/runtime/executor/helps/` pass. The test changes do not
alter the engine binary.
## `oauth-callback-forwarder-loopback.patch`
@@ -123,6 +127,112 @@ that Avibe adopts contains that setting, drop this patch and render
`http2-health-check-seconds: 30` in `vibe/model_hub_runtime/config.py`
alongside the other fixed keys, in the layout that config uses.
+## `fallback-transport-h2-ping-health-check.patch`
+
+Patch 4 covers only the dedicated uTLS connection to `https://chatgpt.com`.
+Every other upstream request on an HTTP client from
+`internal/runtime/executor/helps` ran on `http.DefaultTransport`, or on a
+per-request proxy transport, without an HTTP/2 health check. That covers
+API-key relays and OpenAI-compatible providers. The same dead-path failure
+therefore reached Avibe through API-key relays: a turn on an HTTP/2 relay
+whose path went dead waited out the 600-second bound with no byte and no
+error.
+
+The patch gives those requests one shared clone of `http.DefaultTransport`,
+created on first use, with `HTTP2Config{SendPingTimeout: 30s, PingTimeout:
+15s}`, the same timings as patch 4, as constants. It is used:
+
+- as `NewUtlsHTTPClient`'s standard fallback for hosts other than chatgpt.com
+ and api.anthropic.com (the Codex and Claude executors);
+- by the OpenAI-compatible executor, through `WithUpstreamFallbackTransport`,
+ which sets it only when `NewProxyAwareHTTPClient` left the transport nil.
+
+`buildProxyTransport` sets the same health check on proxy transports.
+`http.DefaultTransport` itself is not modified, and `NewProxyAwareHTTPClient`
+still returns a nil transport when no proxy and no injected RoundTripper
+apply, because the Antigravity executor reads that as "direct" and installs
+its own HTTP/1.1 pool. The injected context RoundTripper is untouched, as in
+patch 4. The health check only sets HTTP/2 timings: protocol selection
+(`ForceAttemptHTTP2`, `Protocols`, `TLSNextProto`, ALPN) is unchanged, and a
+transport that did not opt into HTTP/2 still speaks HTTP/1.1.
+
+Avibe renders `proxy-url: ""` and no per-Source proxy, so its Sources take the
+shared clone. Coverage by Avibe Source kind:
+
+| Source | CPA path | Covered |
+| --- | --- | --- |
+| `openai_responses` API key (OpenAI and xAI relays) | `codex-api-key`, `NewUtlsHTTPClient` fallback | yes |
+| `anthropic` API key on a non-Anthropic host | `claude-api-key`, `NewUtlsHTTPClient` fallback | yes |
+| `openai_chat` API key | `openai-compatibility`, `WithUpstreamFallbackTransport` | yes |
+| `anthropic` API key on `api.anthropic.com` | HTTP/1.1 Claude round tripper | no: PING is HTTP/2 only |
+| ChatGPT subscription | patch 4's uTLS connection | patch 4 |
+
+An HTTP/1.1 upstream has no PING, so a silent HTTP/1.1 body is still bounded
+only by the caller. The patch adds `upstream_transport_test.go`:
+
+- a dead path fails the stream;
+- a silent healthy stream survives ten idle periods;
+- the shared transport is wired into both clients and the proxy transports;
+- protocol selection is unchanged.
+
+Upstream: the same failure mode as router-for-me/CLIProxyAPI#6535, whose
+opt-in `streaming.http2-health-check-seconds` covers only the uTLS
+connection. The follow-up proposes applying that setting to the standard and
+proxy transports too. Drop this patch once a tagged CPA release Avibe adopts
+applies the setting there, and render it in `vibe/model_hub_runtime/config.py`.
+
+## `codex-sse-per-event-parsing.patch`
+
+The Codex executor read upstream SSE line by line and took every `data:` line
+as a whole event. In SSE an event's data may span several `data:` lines,
+joined with `\n`. On such a split, lenient `gjson` read `"type":
+"response.completed"` from the first fragment, the executor took its
+terminal path, and the rest of the event was never read. The handler's
+validator then failed the stream with `invalid SSE data JSON (len=<first
+fragment>)`, the error Avibe saw from an API-key relay after a turn's full
+output had streamed.
+
+The patch reads the stream through `codexSSEScanner`, which keeps
+`bufio.Scanner`'s interface. It is used by both `ExecuteStream` and the
+non-stream `Execute`. Every event on this path is one JSON value, so:
+
+- A data line that is complete JSON, or cannot start JSON (an empty value,
+ `[DONE]`), is delivered byte-for-byte as before, with no lookahead. This
+ keeps upstreams that send no blank line between events working as stock
+ does; upstream tests cover that framing.
+- A data line that starts an object or array it does not complete collects
+ the following data lines until:
+ - their joined value closes its outermost object or array, tracked
+ incrementally so validation stays linear;
+ - a blank line ends the event;
+ - the stream ends;
+ - a data line that is a complete object of its own starts the next event;
+ - or the collected bytes would exceed the scanner's 50 MB line limit.
+- A completed multi-line event is delivered compacted onto one line.
+- One that never becomes valid JSON is delivered as the same multi-line data
+ field, so it still fails downstream as before. One warning then records its
+ framing: the data line count, each line's length and whether it is valid on
+ its own, the joined length, and the JSON error offset. It records no data
+ bytes.
+- Field and comment lines inside an event follow its data line.
+- An event left unterminated at the end of the stream is still delivered.
+
+The patch adds `codex_sse_events.go` and `codex_sse_events_test.go`. They
+cover:
+
+- the minimal two-line repro and CRLF;
+- blank-less framing, also after a split;
+- invalid fragments, and the warning's contents;
+- the 50 MB bound, and a 2,000-line event under a time bound;
+- `[DONE]` and empty data lines;
+- equivalence with `bufio.Scanner` on well-formed streams;
+- the split event through `ExecuteStream`, with and without bootstrap
+ buffering, and through `Execute`.
+
+Upstream: the line-based parsing is unchanged on CPA `main` (v8.0.27) and
+`dev`. Drop this patch once a tagged CPA release Avibe adopts parses Codex
+SSE per event.
+
## Rebuild
The repository-owned release path checks out `source_sha`, applies the
diff --git a/patches/model-hub-cpa-v8.0.23/codex-sse-per-event-parsing.patch b/patches/model-hub-cpa-v8.0.23/codex-sse-per-event-parsing.patch
new file mode 100644
index 000000000..46d6f52c1
--- /dev/null
+++ b/patches/model-hub-cpa-v8.0.23/codex-sse-per-event-parsing.patch
@@ -0,0 +1,595 @@
+diff --git a/internal/runtime/executor/codex_executor_execute.go b/internal/runtime/executor/codex_executor_execute.go
+index f5afac2f..77190003 100644
+--- a/internal/runtime/executor/codex_executor_execute.go
++++ b/internal/runtime/executor/codex_executor_execute.go
+@@ -128,11 +128,12 @@ func (e *CodexExecutor) Execute(ctx context.Context, auth *cliproxyauth.Auth, re
+ data, errRead := io.ReadAll(httpResp.Body)
+ helps.AppendAPIResponseChunk(ctx, e.cfg, data)
+
+- lines := bytes.Split(data, []byte("\n"))
++ events := newCodexSSEScanner(ctx, bytes.NewReader(data), len(data)+1)
+ outputItemsByIndex := make(map[int64][]byte)
+ var outputItemsFallback [][]byte
+ sawOutputDelta := false
+- for _, line := range lines {
++ for events.Scan() {
++ line := events.Bytes()
+ if !bytes.HasPrefix(line, dataTag) {
+ continue
+ }
+diff --git a/internal/runtime/executor/codex_executor_stream.go b/internal/runtime/executor/codex_executor_stream.go
+index 7c9fef29..4b8985d0 100644
+--- a/internal/runtime/executor/codex_executor_stream.go
++++ b/internal/runtime/executor/codex_executor_stream.go
+@@ -1,7 +1,6 @@
+ package executor
+
+ import (
+- "bufio"
+ "bytes"
+ "context"
+ "io"
+@@ -145,8 +144,7 @@ func (e *CodexExecutor) ExecuteStream(ctx context.Context, auth *cliproxyauth.Au
+ bootstrapStart = nowCodexBootstrap()
+ }
+
+- scanner := bufio.NewScanner(httpResp.Body)
+- scanner.Buffer(nil, 52_428_800) // 50MB
++ scanner := newCodexSSEScanner(ctx, httpResp.Body, 52_428_800) // 50MB
+ claudeInputTokens := helps.NewClaudeInputTokenState(from, to, responseFormat, originalPayload)
+ var param any
+ outputItemsByIndex := make(map[int64][]byte)
+diff --git a/internal/runtime/executor/codex_sse_events.go b/internal/runtime/executor/codex_sse_events.go
+new file mode 100644
+index 00000000..48bb5e49
+--- /dev/null
++++ b/internal/runtime/executor/codex_sse_events.go
+@@ -0,0 +1,212 @@
++package executor
++
++import (
++ "bufio"
++ "bytes"
++ "context"
++ "encoding/json"
++ "errors"
++ "io"
++ "strconv"
++ "strings"
++
++ "github.com/router-for-me/CLIProxyAPI/v8/internal/runtime/executor/helps"
++)
++
++// codexSSEDiagnosticLines caps how many data lines one invalid-event diagnostic describes.
++const codexSSEDiagnosticLines = 8
++
++// codexSSEScanner reads an upstream Responses SSE stream line by line, as bufio.Scanner does, but
++// delivers an event whose data an upstream split across several "data:" lines as one "data:" line.
++// In SSE an event's data may span several data lines, joined with "\n". Taking each data line as a
++// whole event instead cuts such an event: on a split response.completed the stream ends at the
++// first fragment and the rest is never read.
++//
++// Every event this path carries is one JSON value, so a data line that is complete JSON on its own,
++// or cannot start JSON at all (an empty value, [DONE]), is delivered byte-for-byte as read with no
++// lookahead; this also keeps upstreams that omit the blank line between events working as before.
++// A data line that starts a JSON object or array but is not yet complete JSON starts an event that
++// collects the following data lines until their joined value closes its outermost object or array,
++// a blank line ends the event, the stream ends, a data line that is a complete JSON object on its own starts the next
++// event, or the collected bytes would exceed the scanner's line limit. A completed event is
++// delivered compacted onto one line. One that never becomes valid JSON is delivered as the same
++// multi-line data field, so it still fails downstream, and one warning describes its framing
++// without any of its bytes. Other lines pass through in order.
++type codexSSEScanner struct {
++ ctx context.Context
++ lines *bufio.Scanner
++ maxBytes int
++ queue [][]byte
++ current []byte
++}
++
++func newCodexSSEScanner(ctx context.Context, r io.Reader, maxBytes int) *codexSSEScanner {
++ lines := bufio.NewScanner(r)
++ lines.Buffer(nil, maxBytes)
++ return &codexSSEScanner{ctx: ctx, lines: lines, maxBytes: maxBytes}
++}
++
++// Scan advances to the next line, or to the next assembled event data line.
++func (s *codexSSEScanner) Scan() bool {
++ if len(s.queue) > 0 {
++ s.current, s.queue = s.queue[0], s.queue[1:]
++ return true
++ }
++ if !s.lines.Scan() {
++ return false
++ }
++ line := s.lines.Bytes()
++ if !bytes.HasPrefix(line, dataTag) || !codexSSEIncompleteJSON(bytes.TrimSpace(line[len(dataTag):])) {
++ s.current = line
++ return true
++ }
++ // An incomplete event: collect its continuation. The underlying scanner reuses its buffer, so keep copies.
++ data := [][]byte{bytes.Clone(line)}
++ joined := bytes.Clone(codexSSEValue(line))
++ var nesting codexJSONNesting
++ closed := nesting.feed(joined)
++ var rest [][]byte
++ size := len(line)
++ for !closed && s.lines.Scan() {
++ next := s.lines.Bytes()
++ if len(next) == 0 {
++ rest = append(rest, []byte{})
++ break
++ }
++ if size+len(next) > s.maxBytes {
++ // Bounded like a single line: stop collecting and let the next line be read on its own.
++ rest = append(rest, bytes.Clone(next))
++ break
++ }
++ size += len(next)
++ if !bytes.HasPrefix(next, dataTag) {
++ rest = append(rest, bytes.Clone(next))
++ continue
++ }
++ if value := bytes.TrimSpace(next[len(dataTag):]); bytes.HasPrefix(value, []byte("{")) && json.Valid(value) {
++ // A complete object of its own is the next event of an upstream that sends no blank lines.
++ rest = append(rest, bytes.Clone(next))
++ break
++ }
++ data = append(data, bytes.Clone(next))
++ value := codexSSEValue(next)
++ joined = append(append(joined, '\n'), value...)
++ closed = nesting.feed([]byte{'\n'}) || nesting.feed(value)
++ }
++ s.current = s.assemble(data, joined)
++ s.queue = rest
++ return true
++}
++
++// codexSSEValue is one data line's value: the text after "data:" without the one leading space.
++func codexSSEValue(line []byte) []byte {
++ return bytes.TrimPrefix(line[len(dataTag):], []byte(" "))
++}
++
++// codexSSEClosed reports whether joined event data is complete JSON. Only a value that now ends
++// with a closing bracket can have become complete, so other values are not re-validated.
++func codexSSEClosed(joined []byte) bool {
++ trimmed := bytes.TrimRight(joined, " \t\r\n")
++ if len(trimmed) == 0 || (trimmed[len(trimmed)-1] != '}' && trimmed[len(trimmed)-1] != ']') {
++ return false
++ }
++ return json.Valid(joined)
++}
++
++// codexSSEIncompleteJSON reports whether one data line's value starts a JSON object or array that
++// it does not complete. Values that cannot start JSON, such as an empty value or [DONE], are not.
++func codexSSEIncompleteJSON(value []byte) bool {
++ if len(value) == 0 || (value[0] != '{' && value[0] != '[') || bytes.Equal(value, []byte("[DONE]")) {
++ return false
++ }
++ return !codexSSEClosed(value)
++}
++
++// codexJSONNesting follows the nesting of a JSON text fed in pieces, so an event split across many
++// data lines is validated once, when its outermost object or array closes, not after every piece.
++type codexJSONNesting struct {
++ depth int
++ inString bool
++ escaped bool
++}
++
++// feed consumes p and reports whether the outermost object or array closed within it.
++func (n *codexJSONNesting) feed(p []byte) bool {
++ for _, c := range p {
++ switch {
++ case n.inString:
++ switch {
++ case n.escaped:
++ n.escaped = false
++ case c == '\\':
++ n.escaped = true
++ case c == '"':
++ n.inString = false
++ }
++ case c == '"':
++ n.inString = true
++ case c == '{' || c == '[':
++ n.depth++
++ case c == '}' || c == ']':
++ n.depth--
++ if n.depth <= 0 {
++ return true
++ }
++ }
++ }
++ return false
++}
++
++// Bytes returns the current line. It stays valid until the next call to Scan.
++func (s *codexSSEScanner) Bytes() []byte { return s.current }
++
++// Err returns the error that stopped the scan, as bufio.Scanner does.
++func (s *codexSSEScanner) Err() error { return s.lines.Err() }
++
++func (s *codexSSEScanner) assemble(lines [][]byte, joined []byte) []byte {
++ if len(lines) == 1 {
++ s.diagnose(lines, bytes.TrimSpace(joined))
++ return lines[0]
++ }
++ if json.Valid(joined) {
++ var compacted bytes.Buffer
++ compacted.Grow(len(dataTag) + 1 + len(joined))
++ compacted.Write(dataTag)
++ compacted.WriteByte(' ')
++ if errCompact := json.Compact(&compacted, joined); errCompact == nil {
++ return compacted.Bytes()
++ }
++ }
++ s.diagnose(lines, joined)
++ return bytes.Join(lines, []byte("\n"))
++}
++
++// diagnose logs one bounded warning when an event's data is not valid JSON: how many data lines
++// carried it, each line's length and whether it is valid on its own, and where the joined data
++// fails to parse. It never logs data bytes.
++func (s *codexSSEScanner) diagnose(lines [][]byte, data []byte) {
++ if len(data) == 0 || bytes.Equal(data, []byte("[DONE]")) || json.Valid(data) {
++ return
++ }
++ offset := int64(-1)
++ var syntaxErr *json.SyntaxError
++ if errors.As(json.Unmarshal(data, new(json.RawMessage)), &syntaxErr) {
++ offset = syntaxErr.Offset
++ }
++ shown := min(len(lines), codexSSEDiagnosticLines)
++ lengths := make([]string, shown)
++ valid := make([]string, shown)
++ for i := range shown {
++ value := bytes.TrimSpace(lines[i][len(dataTag):])
++ lengths[i] = strconv.Itoa(len(value))
++ valid[i] = strconv.FormatBool(json.Valid(value))
++ }
++ more := ""
++ if len(lines) > shown {
++ more = ",+" + strconv.Itoa(len(lines)-shown)
++ }
++ helps.LogWithRequestID(s.ctx).Warnf(
++ "codex executor: upstream SSE event data is not valid JSON: data_lines=%d line_bytes=[%s%s] lines_valid=[%s%s] data_bytes=%d json_error_offset=%d",
++ len(lines), strings.Join(lengths, ","), more, strings.Join(valid, ","), more, len(data), offset,
++ )
++}
+diff --git a/internal/runtime/executor/codex_sse_events_test.go b/internal/runtime/executor/codex_sse_events_test.go
+new file mode 100644
+index 00000000..47711d2b
+--- /dev/null
++++ b/internal/runtime/executor/codex_sse_events_test.go
+@@ -0,0 +1,330 @@
++package executor
++
++import (
++ "bufio"
++ "context"
++ "encoding/json"
++ "fmt"
++ "strings"
++ "testing"
++ "time"
++
++ "github.com/router-for-me/CLIProxyAPI/v8/internal/config"
++ cliproxyauth "github.com/router-for-me/CLIProxyAPI/v8/sdk/cliproxy/auth"
++ cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v8/sdk/cliproxy/executor"
++ sdktranslator "github.com/router-for-me/CLIProxyAPI/v8/sdk/translator"
++ log "github.com/sirupsen/logrus"
++ logtest "github.com/sirupsen/logrus/hooks/test"
++)
++
++func captureCodexSSEWarnings(t *testing.T) *logtest.Hook {
++ t.Helper()
++ hook := new(logtest.Hook)
++ log.StandardLogger().AddHook(hook)
++ t.Cleanup(func() { log.StandardLogger().ReplaceHooks(make(log.LevelHooks)) })
++ return hook
++}
++
++func scanCodexSSE(t *testing.T, stream string) []string {
++ t.Helper()
++ scanner := newCodexSSEScanner(context.Background(), strings.NewReader(stream), 1<<20)
++ var lines []string
++ for scanner.Scan() {
++ lines = append(lines, string(scanner.Bytes()))
++ }
++ if errScan := scanner.Err(); errScan != nil {
++ t.Fatalf("scan error: %v", errScan)
++ }
++ return lines
++}
++
++func TestCodexSSEScannerAssemblesEventData(t *testing.T) {
++ const marker = "body-bytes-must-not-be-logged"
++ cases := []struct {
++ name string
++ stream string
++ want []string
++ warnings int
++ }{
++ {
++ name: "one-line events pass through as read",
++ stream: "event: response.created\ndata: {\"type\":\"response.created\"}\n\n: keep-alive\n\ndata: {\"type\":\"x\",\"v\":\"a b\"}\n\n",
++ want: []string{"event: response.created", `data: {"type":"response.created"}`, "", ": keep-alive", "", `data: {"type":"x","v":"a b"}`, ""},
++ },
++ {
++ name: "CRLF line endings",
++ stream: "event: a\r\ndata: {\"type\":\"a\"}\r\n\r\n",
++ want: []string{"event: a", `data: {"type":"a"}`, ""},
++ },
++ {
++ name: "data lines of one event are joined and compacted",
++ stream: "event: response.completed\ndata: {\"type\":\"response.completed\",\ndata: \"response\":{\"id\":\"r\",\"output\":[]}}\n\n",
++ want: []string{"event: response.completed", `data: {"type":"response.completed","response":{"id":"r","output":[]}}`, ""},
++ },
++ {
++ name: "joined CRLF event",
++ stream: "data: {\"a\":\r\ndata: [1,\r\ndata: 2]}\r\n\r\n",
++ want: []string{`data: {"a":[1,2]}`, ""},
++ },
++ {
++ name: "comment and field lines inside an event follow its data",
++ stream: "data: {\"a\":\n: keep-alive\nid: 7\ndata: 1}\n\n",
++ want: []string{`data: {"a":1}`, ": keep-alive", "id: 7", ""},
++ },
++ {
++ name: "unterminated one-line event at end of stream",
++ stream: "data: {\"type\":\"response.completed\"}",
++ want: []string{`data: {"type":"response.completed"}`},
++ },
++ {
++ name: "unterminated multi-line event at end of stream",
++ stream: "data: {\"type\":\ndata: \"response.completed\"}\n",
++ want: []string{`data: {"type":"response.completed"}`},
++ },
++ {
++ name: "complete events without blank separators stay separate",
++ stream: "data: {\"a\":1}\ndata: {\"b\":2}\n",
++ want: []string{`data: {"a":1}`, `data: {"b":2}`},
++ },
++ {
++ name: "split event followed by an event without a blank separator",
++ stream: "data: {\"a\":\ndata: 1}\ndata: {\"b\":2}\n",
++ want: []string{`data: {"a":1}`, `data: {"b":2}`},
++ },
++ {
++ name: "invalid fragment followed by a complete event without a blank separator",
++ stream: "data: {\"a\":\"" + marker + "\ndata: {\"b\":2}\n\n",
++ want: []string{`data: {"a":"` + marker, `data: {"b":2}`, ""},
++ warnings: 1,
++ },
++ {
++ name: "unterminated incomplete event at end of stream is still delivered",
++ stream: "data: {\"type\":\"response.completed\",\"t\":\"" + marker + "\",",
++ want: []string{`data: {"type":"response.completed","t":"` + marker + `",`},
++ warnings: 1,
++ },
++ {
++ name: "empty and non-JSON data lines take the stock path",
++ stream: "data:\n\ndata: \n\ndata: ping\n\n",
++ want: []string{"data:", "", "data: ", "", "data: ping", ""},
++ },
++ {
++ name: "done sentinel",
++ stream: "data: [DONE]\n\n",
++ want: []string{"data: [DONE]", ""},
++ },
++ {
++ name: "invalid one-line event passes through with one warning",
++ stream: "data: {\"type\":\"response.completed\",\"t\":\"" + marker + "\",\n\n",
++ want: []string{`data: {"type":"response.completed","t":"` + marker + `",`, ""},
++ warnings: 1,
++ },
++ {
++ name: "event split inside a string stays invalid and keeps its data lines",
++ stream: "data: {\"t\":\"" + marker + "\ndata: " + marker + "\"}\n\n",
++ want: []string{`data: {"t":"` + marker + "\ndata: " + marker + `"}`, ""},
++ warnings: 1,
++ },
++ }
++ for _, tc := range cases {
++ t.Run(tc.name, func(t *testing.T) {
++ hook := captureCodexSSEWarnings(t)
++ got := scanCodexSSE(t, tc.stream)
++ if fmt.Sprintf("%q", got) != fmt.Sprintf("%q", tc.want) {
++ t.Fatalf("lines = %q\nwant %q", got, tc.want)
++ }
++ if len(hook.AllEntries()) != tc.warnings {
++ t.Fatalf("warnings = %d, want %d", len(hook.AllEntries()), tc.warnings)
++ }
++ for _, entry := range hook.AllEntries() {
++ message, errMessage := entry.String()
++ if errMessage != nil {
++ t.Fatal(errMessage)
++ }
++ if entry.Level != log.WarnLevel || strings.Contains(message, marker) || !strings.Contains(message, "data_lines=") || !strings.Contains(message, "json_error_offset=") {
++ t.Fatalf("diagnostic = %q, want a bounded warning without data bytes", message)
++ }
++ }
++ })
++ }
++}
++
++func TestCodexSSEScannerBoundsAnEventToTheLineLimit(t *testing.T) {
++ hook := captureCodexSSEWarnings(t)
++ // Each fragment fits the 64-byte limit; together they do not.
++ stream := "data: {\"a\":\"" + strings.Repeat("x", 40) + "\ndata: " + strings.Repeat("y", 40) + "\ndata: " + strings.Repeat("z", 40) + "\"}\n\ndata: {\"b\":2}\n\n"
++ scanner := newCodexSSEScanner(context.Background(), strings.NewReader(stream), 64)
++ var got []string
++ for scanner.Scan() {
++ got = append(got, string(scanner.Bytes()))
++ }
++ if errScan := scanner.Err(); errScan != nil {
++ t.Fatalf("scan error: %v", errScan)
++ }
++ // The collected fragment is flushed as an invalid event; the lines after it are read as stock reads them.
++ want := []string{
++ "data: {\"a\":\"" + strings.Repeat("x", 40),
++ "data: " + strings.Repeat("y", 40),
++ "data: " + strings.Repeat("z", 40) + "\"}",
++ "",
++ `data: {"b":2}`,
++ "",
++ }
++ if fmt.Sprintf("%q", got) != fmt.Sprintf("%q", want) {
++ t.Fatalf("lines = %q\nwant %q", got, want)
++ }
++ if len(hook.AllEntries()) != 1 {
++ t.Fatalf("warnings = %d, want 1 for the flushed invalid event", len(hook.AllEntries()))
++ }
++}
++
++func TestCodexSSEScannerAssemblesAnEventOfThousandsOfLinesQuickly(t *testing.T) {
++ // A 2 MB response.completed whose upstream wrapped it into 2,000 data lines between array
++ // elements. Every line ends with "}", so only nesting, not the last byte, tells the event apart
++ // from a finished one.
++ item := func(i int) string {
++ return fmt.Sprintf(`{"type":"message","content":[{"type":"output_text","text":"%s"}]}`, strings.Repeat(string(rune('a'+i%26)), 960))
++ }
++ head := `{"type":"response.completed","response":{"id":"resp_big","output":[`
++ var payload, stream strings.Builder
++ payload.WriteString(head + item(0))
++ stream.WriteString("data: " + head + item(0) + "\n")
++ for i := 1; i < 2000; i++ {
++ payload.WriteString("," + item(i))
++ stream.WriteString("data: ," + item(i) + "\n")
++ }
++ payload.WriteString("]}}")
++ stream.WriteString("data: ]}}\n\n")
++ started := time.Now()
++ scanner := newCodexSSEScanner(context.Background(), strings.NewReader(stream.String()), 52_428_800)
++ var got []string
++ for scanner.Scan() {
++ got = append(got, string(scanner.Bytes()))
++ }
++ elapsed := time.Since(started)
++ if len(got) != 2 || got[0] != "data: "+payload.String() {
++ t.Fatalf("assembled %d lines, want the event on one line and its blank line", len(got))
++ }
++ if elapsed > 2*time.Second {
++ t.Fatalf("assembling 2,001 data lines took %v; validation must not grow with every line", elapsed)
++ }
++}
++
++func TestCodexSSEScannerDiagnosticDescribesFraming(t *testing.T) {
++ hook := captureCodexSSEWarnings(t)
++ // A split inside a string: each fragment is invalid on its own, and so is their SSE join.
++ scanCodexSSE(t, "data: {\"type\":\"response.completed\",\"t\":\"abc\ndata: def\"}\n\n")
++ entries := hook.AllEntries()
++ if len(entries) != 1 {
++ t.Fatalf("warnings = %d, want 1", len(entries))
++ }
++ message := entries[0].Message
++ for _, want := range []string{"data_lines=2", "line_bytes=[37,5]", "lines_valid=[false,false]", "data_bytes=43", "json_error_offset=38"} {
++ if !strings.Contains(message, want) {
++ t.Fatalf("diagnostic %q lacks %q", message, want)
++ }
++ }
++}
++
++func codexStreamChunks(t *testing.T, stream string, buffered bool) []string {
++ t.Helper()
++ cfg := &config.Config{}
++ cfg.Codex.StreamBootstrapBuffering = buffered
++ executor := NewCodexExecutor(cfg)
++ ctx := context.WithValue(t.Context(), "cliproxy.roundtripper", codexAllocationTransport{stream: stream})
++ auth := &cliproxyauth.Auth{Attributes: map[string]string{"api_key": "test"}}
++ result, err := executor.ExecuteStream(ctx, auth, cliproxyexecutor.Request{Model: "gpt-5.4", Payload: []byte(`{"model":"gpt-5.4","input":"hello"}`)},
++ cliproxyexecutor.Options{Stream: true, SourceFormat: sdktranslator.FormatOpenAIResponse})
++ if err != nil {
++ t.Fatal(err)
++ }
++ var chunks []string
++ for chunk := range result.Chunks {
++ if chunk.Err != nil {
++ t.Fatalf("stream error: %v", chunk.Err)
++ }
++ if len(chunk.Payload) > 0 {
++ chunks = append(chunks, string(chunk.Payload))
++ }
++ }
++ return chunks
++}
++
++func TestCodexExecuteStreamTreatsAnEventSplitAcrossDataLinesAsOneEvent(t *testing.T) {
++ completed := `{"type":"response.completed","response":{"id":"resp_split","model":"gpt-5.4","status":"completed","output":[{"id":"msg_1","type":"message","role":"assistant","content":[{"type":"output_text","text":"hi"}]}],"usage":{"input_tokens":5,"output_tokens":1,"total_tokens":6}}}`
++ cut := strings.Index(completed, `"output":`)
++ created := "event: response.created\ndata: {\"type\":\"response.created\",\"response\":{\"id\":\"resp_split\",\"model\":\"gpt-5.4\"}}\n\n"
++ oneLine := created + "event: response.completed\ndata: " + completed + "\n\n"
++ split := created + "event: response.completed\ndata: " + completed[:cut] + "\ndata: " + completed[cut:] + "\n\n"
++ for _, buffered := range []bool{false, true} {
++ t.Run(fmt.Sprintf("buffered=%t", buffered), func(t *testing.T) {
++ want := codexStreamChunks(t, oneLine, buffered)
++ got := codexStreamChunks(t, split, buffered)
++ if fmt.Sprintf("%q", got) != fmt.Sprintf("%q", want) {
++ t.Fatalf("split event chunks = %q\nwant the one-line chunks %q", got, want)
++ }
++ if terminal := want[len(want)-1]; !strings.Contains(terminal, `"response.completed"`) || !json.Valid([]byte(strings.TrimPrefix(terminal, "data: "))) {
++ t.Fatalf("last chunk = %q, want a valid response.completed", terminal)
++ }
++ })
++ }
++}
++
++func TestCodexSSEScannerMatchesBufioScannerOnWellFormedStreams(t *testing.T) {
++ stream := codexAllocationStream(6, 64) + "data: {\"type\":\"x\"}\ndata: {\"type\":\"y\"}\n: trailing comment\n\nevent: done\ndata: [DONE]\n\n"
++ for _, newline := range []string{"\n", "\r\n"} {
++ input := strings.ReplaceAll(stream, "\n", newline)
++ t.Run(fmt.Sprintf("newline=%q", newline), func(t *testing.T) {
++ stock := bufio.NewScanner(strings.NewReader(input))
++ var want []string
++ for stock.Scan() {
++ want = append(want, stock.Text())
++ }
++ got := scanCodexSSE(t, input)
++ if fmt.Sprintf("%q", got) != fmt.Sprintf("%q", want) {
++ t.Fatalf("lines = %q\nwant bufio.Scanner's %q", got, want)
++ }
++ })
++ }
++}
++
++func TestCodexExecuteStreamPassesADoneSentinelAfterTheCompletedEvent(t *testing.T) {
++ hook := captureCodexSSEWarnings(t)
++ stream := codexAllocationStream(2, 16) + "data: [DONE]\n\n"
++ chunks := codexStreamChunks(t, stream, false)
++ sawCompleted := false
++ for _, chunk := range chunks {
++ if strings.Contains(chunk, `"response.completed"`) {
++ sawCompleted = true
++ }
++ }
++ if !sawCompleted {
++ t.Fatalf("chunks = %q, want the completed event", chunks)
++ }
++ for _, entry := range hook.AllEntries() {
++ if strings.Contains(entry.Message, "SSE event data") {
++ t.Fatalf("unexpected framing warning: %s", entry.Message)
++ }
++ }
++}
++
++func TestCodexExecuteNonStreamReadsAnEventSplitAcrossDataLines(t *testing.T) {
++ completed := `{"type":"response.completed","response":{"id":"resp_split","object":"response","model":"gpt-5.4","status":"completed","output":[{"id":"msg_1","type":"message","role":"assistant","content":[{"type":"output_text","text":"hi"}]}],"usage":{"input_tokens":5,"output_tokens":1,"total_tokens":6}}}`
++ cut := strings.Index(completed, `"output":`)
++ stream := "event: response.completed\r\ndata: " + completed[:cut] + "\r\ndata: " + completed[cut:] + "\r\n\r\n"
++ executor := NewCodexExecutor(&config.Config{})
++ ctx := context.WithValue(t.Context(), "cliproxy.roundtripper", codexAllocationTransport{stream: stream})
++ auth := &cliproxyauth.Auth{Attributes: map[string]string{"api_key": "test"}}
++ resp, err := executor.Execute(ctx, auth, cliproxyexecutor.Request{Model: "gpt-5.4", Payload: []byte(`{"model":"gpt-5.4","input":"hello"}`)},
++ cliproxyexecutor.Options{SourceFormat: sdktranslator.FormatOpenAIResponse})
++ if err != nil {
++ t.Fatalf("Execute error: %v", err)
++ }
++ var got struct {
++ ID string `json:"id"`
++ Output []json.RawMessage `json:"output"`
++ }
++ if errDecode := json.Unmarshal(resp.Payload, &got); errDecode != nil || got.ID != "resp_split" || len(got.Output) != 1 {
++ t.Fatalf("payload = %s (decode error %v), want the completed response", resp.Payload, errDecode)
++ }
++}
diff --git a/patches/model-hub-cpa-v8.0.23/fallback-transport-h2-ping-health-check.patch b/patches/model-hub-cpa-v8.0.23/fallback-transport-h2-ping-health-check.patch
new file mode 100644
index 000000000..ee4a9e9f2
--- /dev/null
+++ b/patches/model-hub-cpa-v8.0.23/fallback-transport-h2-ping-health-check.patch
@@ -0,0 +1,365 @@
+diff --git a/internal/runtime/executor/helps/proxy_helpers.go b/internal/runtime/executor/helps/proxy_helpers.go
+index 0c5f6c95..4c15b243 100644
+--- a/internal/runtime/executor/helps/proxy_helpers.go
++++ b/internal/runtime/executor/helps/proxy_helpers.go
+@@ -153,5 +153,8 @@ func buildProxyTransport(proxyURL string) *http.Transport {
+ log.Errorf("%v", errBuild)
+ return nil
+ }
+- return transport
++ if transport == nil {
++ return nil
++ }
++ return withUpstreamHTTP2HealthCheck(transport, upstreamHTTP2SendPingTimeout, upstreamHTTP2PingTimeout)
+ }
+diff --git a/internal/runtime/executor/helps/upstream_transport.go b/internal/runtime/executor/helps/upstream_transport.go
+new file mode 100644
+index 00000000..3e2bae5b
+--- /dev/null
++++ b/internal/runtime/executor/helps/upstream_transport.go
+@@ -0,0 +1,57 @@
++package helps
++
++import (
++ "net/http"
++ "sync"
++ "time"
++)
++
++// upstreamHTTP2SendPingTimeout and upstreamHTTP2PingTimeout turn on the HTTP/2 health check for
++// upstream requests that do not use a dedicated uTLS connection: API-key relays, OpenAI-compatible
++// providers and other executor traffic on the standard transport. After SendPingTimeout without a
++// frame the connection sends a PING, and it is closed if no ACK arrives within PingTimeout. Without
++// it, a stream whose path stopped delivering packets without a FIN or RST, which a NAT or a
++// TCP-terminating proxy can leave behind and TCP keepalive cannot see past, blocks its body read
++// until the caller gives up. A silent but live upstream acknowledges the PING, so long reasoning
++// pauses are not cut. PING exists only in HTTP/2; an HTTP/1.1 upstream is not covered.
++const (
++ upstreamHTTP2SendPingTimeout = 30 * time.Second
++ upstreamHTTP2PingTimeout = 15 * time.Second
++)
++
++// upstreamFallbackTransport is the standard transport upstream executors use when neither a proxy
++// nor an injected RoundTripper applies. It is one clone of http.DefaultTransport, created on first
++// use and shared, so connection pooling and HTTP/2 multiplexing work as they do on the default
++// transport. The process-wide http.DefaultTransport is not modified.
++var upstreamFallbackTransport = sync.OnceValue(func() http.RoundTripper {
++ base, ok := http.DefaultTransport.(*http.Transport)
++ if !ok || base == nil {
++ return http.DefaultTransport
++ }
++ return withUpstreamHTTP2HealthCheck(base.Clone(), upstreamHTTP2SendPingTimeout, upstreamHTTP2PingTimeout)
++})
++
++// WithUpstreamFallbackTransport gives client the shared upstream transport when it has no transport
++// of its own, as NewProxyAwareHTTPClient leaves it when neither a proxy nor an injected RoundTripper
++// applies. NewProxyAwareHTTPClient itself keeps returning a nil Transport there, because some
++// callers read that as "direct" and install a transport of their own.
++func WithUpstreamFallbackTransport(client *http.Client) *http.Client {
++ if client != nil && client.Transport == nil {
++ client.Transport = upstreamFallbackTransport()
++ }
++ return client
++}
++
++// withUpstreamHTTP2HealthCheck sets the HTTP/2 health check on transport and returns it, keeping any
++// other HTTP/2 settings the transport already has.
++func withUpstreamHTTP2HealthCheck(transport *http.Transport, sendPingTimeout, pingTimeout time.Duration) *http.Transport {
++ config := &http.HTTP2Config{}
++ if transport.HTTP2 != nil {
++ copied := *transport.HTTP2
++ config = &copied
++ }
++ config.SendPingTimeout = sendPingTimeout
++ config.PingTimeout = pingTimeout
++ transport.HTTP2 = config
++ return transport
++}
+diff --git a/internal/runtime/executor/helps/upstream_transport_test.go b/internal/runtime/executor/helps/upstream_transport_test.go
+new file mode 100644
+index 00000000..be953d58
+--- /dev/null
++++ b/internal/runtime/executor/helps/upstream_transport_test.go
+@@ -0,0 +1,220 @@
++package helps
++
++import (
++ "bufio"
++ "context"
++ "crypto/tls"
++ "crypto/x509"
++ "errors"
++ "fmt"
++ "net"
++ "net/http"
++ "net/http/httptest"
++ "strings"
++ "testing"
++ "time"
++
++ "github.com/router-for-me/CLIProxyAPI/v8/internal/config"
++ "github.com/router-for-me/CLIProxyAPI/v8/sdk/proxyutil"
++)
++
++// newHealthCheckedTLSStream starts an HTTP/2 TLS server running handler and returns a client on a
++// fresh standard transport with the health check at the given timings, whose TCP connections are
++// passed through wrap before the TLS handshake.
++func newHealthCheckedTLSStream(t *testing.T, sendPingTimeout, pingTimeout time.Duration, handler http.Handler, wrap func(net.Conn) net.Conn) (*http.Client, string) {
++ t.Helper()
++ server := httptest.NewUnstartedServer(handler)
++ server.EnableHTTP2 = true
++ server.StartTLS()
++ t.Cleanup(server.Close)
++ base, ok := http.DefaultTransport.(*http.Transport)
++ if !ok {
++ t.Fatalf("http.DefaultTransport is %T", http.DefaultTransport)
++ }
++ transport := withUpstreamHTTP2HealthCheck(base.Clone(), sendPingTimeout, pingTimeout)
++ rootCAs := x509.NewCertPool()
++ rootCAs.AddCert(server.Certificate())
++ transport.TLSClientConfig.RootCAs = rootCAs
++ transport.DialContext = func(ctx context.Context, network, address string) (net.Conn, error) {
++ conn, errDial := (&net.Dialer{}).DialContext(ctx, network, address)
++ if errDial != nil {
++ return nil, errDial
++ }
++ return wrap(conn), nil
++ }
++ t.Cleanup(transport.CloseIdleConnections)
++ return &http.Client{Transport: transport}, server.URL
++}
++
++func openHealthCheckedStream(t *testing.T, client *http.Client, serverURL string) (*http.Response, *bufio.Reader) {
++ t.Helper()
++ req, errRequest := http.NewRequestWithContext(t.Context(), http.MethodPost, serverURL, strings.NewReader("{}"))
++ if errRequest != nil {
++ t.Fatal(errRequest)
++ }
++ resp, errDo := client.Do(req)
++ if errDo != nil {
++ t.Fatal(errDo)
++ }
++ t.Cleanup(func() { _ = resp.Body.Close() })
++ if resp.ProtoMajor != 2 {
++ t.Fatalf("protocol = %s, want HTTP/2", resp.Proto)
++ }
++ reader := bufio.NewReader(resp.Body)
++ if line, errRead := reader.ReadString('\n'); errRead != nil || !strings.Contains(line, "response.created") {
++ t.Fatalf("first line = %q, error = %v", line, errRead)
++ }
++ return resp, reader
++}
++
++func TestUpstreamTransportStreamFailsWhenThePathGoesDead(t *testing.T) {
++ release := make(chan struct{})
++ t.Cleanup(func() { close(release) })
++ var path *deadPathConn
++ client, serverURL := newHealthCheckedTLSStream(t, 100*time.Millisecond, time.Second, sseUntilReleased(t, release), func(conn net.Conn) net.Conn {
++ path = newDeadPathConn(conn)
++ return path
++ })
++ _, reader := openHealthCheckedStream(t, client, serverURL)
++ path.stall()
++ started := time.Now()
++ done := make(chan error, 1)
++ go func() {
++ _, errRead := reader.ReadString('\n')
++ for errRead == nil {
++ _, errRead = reader.ReadString('\n')
++ }
++ done <- errRead
++ }()
++ select {
++ case errRead := <-done:
++ if errRead == nil || errors.Is(errRead, http.ErrBodyReadAfterClose) {
++ t.Fatalf("read error = %v, want a lost-connection error", errRead)
++ }
++ t.Logf("dead path detected after %v: %v", time.Since(started), errRead)
++ case <-time.After(10 * time.Second):
++ t.Fatal("stream read still blocked on a dead path; the HTTP/2 health check did not close the connection")
++ }
++}
++
++func TestUpstreamTransportHealthCheckKeepsASilentHealthyStream(t *testing.T) {
++ const sendPingTimeout = 100 * time.Millisecond
++ release := make(chan struct{})
++ client, serverURL := newHealthCheckedTLSStream(t, sendPingTimeout, time.Second, sseUntilReleased(t, release), func(conn net.Conn) net.Conn { return conn })
++ _, reader := openHealthCheckedStream(t, client, serverURL)
++ // Ten health-check periods of silence: the server answers each PING, so the stream survives.
++ time.AfterFunc(10*sendPingTimeout, func() { close(release) })
++ for {
++ line, errRead := reader.ReadString('\n')
++ if errRead != nil {
++ t.Fatalf("silent healthy stream failed: %v", errRead)
++ }
++ if strings.Contains(line, "response.completed") {
++ return
++ }
++ }
++}
++
++func TestUpstreamClientsUseTheHealthCheckedStandardTransport(t *testing.T) {
++ shared, ok := upstreamFallbackTransport().(*http.Transport)
++ if !ok {
++ t.Fatalf("upstream fallback transport is %T, want a dedicated *http.Transport", upstreamFallbackTransport())
++ }
++ if shared == http.DefaultTransport {
++ t.Fatal("upstream fallback transport is http.DefaultTransport itself")
++ }
++ if defaultTransport, okDefault := http.DefaultTransport.(*http.Transport); okDefault && defaultTransport.HTTP2 != nil {
++ t.Fatalf("http.DefaultTransport was modified: HTTP2 = %+v", *defaultTransport.HTTP2)
++ }
++ // 30 s without a frame, then 15 s for the PING ACK: a dead path fails at about 45 s.
++ if shared.HTTP2 == nil || shared.HTTP2.SendPingTimeout != 30*time.Second || shared.HTTP2.PingTimeout != 15*time.Second {
++ t.Fatalf("shared transport HTTP/2 health check = %+v, want 30s/15s", shared.HTTP2)
++ }
++
++ direct := &config.Config{}
++ fallback, okFallback := NewUtlsHTTPClient(context.Background(), direct, nil, 0).Transport.(*fallbackRoundTripper)
++ if !okFallback || fallback.fallback != http.RoundTripper(shared) {
++ t.Fatalf("NewUtlsHTTPClient fallback = %#v, want the shared upstream transport", fallback)
++ }
++ // NewProxyAwareHTTPClient keeps its nil-transport contract; the OpenAI-compatible executor adds the
++ // shared transport on top of it.
++ if got := NewProxyAwareHTTPClient(context.Background(), direct, nil, 0).Transport; got != nil {
++ t.Fatalf("NewProxyAwareHTTPClient transport = %T, want nil as before", got)
++ }
++ if got := WithUpstreamFallbackTransport(NewProxyAwareHTTPClient(context.Background(), direct, nil, 0)).Transport; got != http.RoundTripper(shared) {
++ t.Fatalf("WithUpstreamFallbackTransport transport = %T, want the shared upstream transport", got)
++ }
++
++ proxied := &config.Config{}
++ proxied.ProxyURL = "http://127.0.0.1:9"
++ for name, client := range map[string]*http.Client{
++ "NewProxyAwareHTTPClient": NewProxyAwareHTTPClient(context.Background(), proxied, nil, 0),
++ "NewUtlsHTTPClient": NewUtlsHTTPClient(context.Background(), proxied, nil, 0),
++ } {
++ transport := client.Transport
++ if wrapped, okWrapped := transport.(*fallbackRoundTripper); okWrapped {
++ transport = wrapped.fallback
++ }
++ proxyTransport, okProxy := transport.(*http.Transport)
++ if !okProxy || proxyTransport.HTTP2 == nil || proxyTransport.HTTP2.SendPingTimeout != 30*time.Second || proxyTransport.HTTP2.PingTimeout != 15*time.Second {
++ t.Fatalf("%s proxy transport = %T, want the HTTP/2 health check", name, transport)
++ }
++ }
++
++ injected := roundTripperFunc(func(*http.Request) (*http.Response, error) { return nil, errors.New("unused") })
++ ctx := context.WithValue(context.Background(), "cliproxy.roundtripper", http.RoundTripper(injected))
++ if got := WithUpstreamFallbackTransport(NewProxyAwareHTTPClient(ctx, direct, nil, 0)).Transport; got == http.RoundTripper(shared) || got == nil {
++ t.Fatalf("the injected RoundTripper was replaced with %T", got)
++ }
++}
++
++func TestUpstreamHTTP2HealthCheckLeavesProtocolSelectionAlone(t *testing.T) {
++ describe := func(transport *http.Transport) string {
++ var nextProtos []string
++ if transport.TLSClientConfig != nil {
++ nextProtos = transport.TLSClientConfig.NextProtos
++ }
++ protocols := "<nil>"
++ if transport.Protocols != nil {
++ protocols = transport.Protocols.String()
++ }
++ return fmt.Sprintf("force=%t protocols=%s tlsNextProto(nil=%t,len=%d) alpn=%q", transport.ForceAttemptHTTP2, protocols, transport.TLSNextProto == nil, len(transport.TLSNextProto), nextProtos)
++ }
++ for _, proxyURL := range []string{"http://127.0.0.1:9", "https://127.0.0.1:9", "socks5://127.0.0.1:9"} {
++ stock, _, errStock := proxyutil.BuildHTTPTransport(proxyURL)
++ if errStock != nil || stock == nil {
++ t.Fatalf("%s: stock transport: %v", proxyURL, errStock)
++ }
++ patched := buildProxyTransport(proxyURL)
++ if got, want := describe(patched), describe(stock); got != want {
++ t.Fatalf("%s: protocol selection changed:\n got %s\n want %s", proxyURL, got, want)
++ }
++ if patched.HTTP2 == nil || patched.HTTP2.SendPingTimeout != 30*time.Second || patched.HTTP2.PingTimeout != 15*time.Second {
++ t.Fatalf("%s: HTTP/2 health check = %+v", proxyURL, patched.HTTP2)
++ }
++ }
++
++ // The health check does not opt a transport into HTTP/2: one that has not opted in still speaks
++ // HTTP/1.1 to an HTTP/2-capable server.
++ server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {}))
++ server.EnableHTTP2 = true
++ server.StartTLS()
++ t.Cleanup(server.Close)
++ rootCAs := x509.NewCertPool()
++ rootCAs.AddCert(server.Certificate())
++ for _, withHealthCheck := range []bool{false, true} {
++ transport := &http.Transport{TLSClientConfig: &tls.Config{RootCAs: rootCAs}, DialContext: (&net.Dialer{}).DialContext}
++ if withHealthCheck {
++ withUpstreamHTTP2HealthCheck(transport, upstreamHTTP2SendPingTimeout, upstreamHTTP2PingTimeout)
++ }
++ resp, errGet := (&http.Client{Transport: transport}).Get(server.URL)
++ if errGet != nil {
++ t.Fatal(errGet)
++ }
++ _ = resp.Body.Close()
++ transport.CloseIdleConnections()
++ if resp.ProtoMajor != 1 {
++ t.Fatalf("health check=%t: negotiated %s, want HTTP/1.1 for a transport that did not opt into HTTP/2", withHealthCheck, resp.Proto)
++ }
++ }
++}
+diff --git a/internal/runtime/executor/helps/utls_client.go b/internal/runtime/executor/helps/utls_client.go
+index f832748b..c3417e78 100644
+--- a/internal/runtime/executor/helps/utls_client.go
++++ b/internal/runtime/executor/helps/utls_client.go
+@@ -405,7 +405,7 @@ func NewUtlsHTTPClient(ctx context.Context, cfg *config.Config, auth *cliproxyau
+
+ var chromeRT http.RoundTripper = newUtlsRoundTripper(proxyURL)
+ var anthropicRT http.RoundTripper = cachedClaudeCodeRoundTripper(proxyURL)
+- var standardTransport http.RoundTripper = http.DefaultTransport
++ var standardTransport http.RoundTripper = upstreamFallbackTransport()
+ if proxyURL != "" {
+ if transport := buildProxyTransport(proxyURL); transport != nil {
+ standardTransport = transport
+diff --git a/internal/runtime/executor/openai_compat_executor.go b/internal/runtime/executor/openai_compat_executor.go
+index b63f1258..47aaa55e 100644
+--- a/internal/runtime/executor/openai_compat_executor.go
++++ b/internal/runtime/executor/openai_compat_executor.go
+@@ -81,7 +81,7 @@ func (e *OpenAICompatExecutor) HttpRequest(ctx context.Context, auth *cliproxyau
+ if err := e.PrepareRequest(httpReq, auth); err != nil {
+ return nil, err
+ }
+- httpClient := helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0)
++ httpClient := helps.WithUpstreamFallbackTransport(helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0))
+ return httpClient.Do(httpReq)
+ }
+
+@@ -181,7 +181,7 @@ func (e *OpenAICompatExecutor) Execute(ctx context.Context, auth *cliproxyauth.A
+ AuthValue: authValue,
+ })
+
+- httpClient := helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0)
++ httpClient := helps.WithUpstreamFallbackTransport(helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0))
+ httpClient = reporter.TrackHTTPClient(httpClient)
+ httpResp, err := httpClient.Do(httpReq)
+ if err != nil {
+@@ -282,7 +282,7 @@ func (e *OpenAICompatExecutor) executeImages(ctx context.Context, auth *cliproxy
+ AuthValue: authValue,
+ })
+
+- httpClient := helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0)
++ httpClient := helps.WithUpstreamFallbackTransport(helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0))
+ httpClient = reporter.TrackHTTPClient(httpClient)
+ httpResp, err := httpClient.Do(httpReq)
+ if err != nil {
+@@ -408,7 +408,7 @@ func (e *OpenAICompatExecutor) ExecuteStream(ctx context.Context, auth *cliproxy
+ AuthValue: authValue,
+ })
+
+- httpClient := helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0)
++ httpClient := helps.WithUpstreamFallbackTransport(helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0))
+ // Early role/empty frames are only first-packet fallbacks, not effective tokens.
+ httpClient = reporter.TrackHTTPClientRoundTripOnly(httpClient)
+ httpResp, err := httpClient.Do(httpReq)
+@@ -678,7 +678,7 @@ func (e *OpenAICompatExecutor) executeImagesStream(ctx context.Context, auth *cl
+ AuthValue: authValue,
+ })
+
+- httpClient := helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0)
++ httpClient := helps.WithUpstreamFallbackTransport(helps.NewProxyAwareHTTPClient(ctx, e.cfg, auth, 0))
+ httpClient = reporter.TrackHTTPClient(httpClient)
+ httpResp, err := httpClient.Do(httpReq)
+ if err != nil {
diff --git a/patches/model-hub-cpa-v8.0.23/openai-compat-native-token-field.patch b/patches/model-hub-cpa-v8.0.23/openai-compat-native-token-field.patch
index ff0773405..383b9255e 100644
--- a/patches/model-hub-cpa-v8.0.23/openai-compat-native-token-field.patch
+++ b/patches/model-hub-cpa-v8.0.23/openai-compat-native-token-field.patch
@@ -1,5 +1,5 @@
diff --git a/internal/runtime/executor/helps/openai_compat_max_tokens.go b/internal/runtime/executor/helps/openai_compat_max_tokens.go
-index 71915c5..9819da9 100644
+index 71915c5b..9819da97 100644
--- a/internal/runtime/executor/helps/openai_compat_max_tokens.go
+++ b/internal/runtime/executor/helps/openai_compat_max_tokens.go
@@ -55,6 +55,13 @@ func NormalizeOpenAIMaxTokens(payload []byte, useMaxCompletionTokens bool) []byt
@@ -17,7 +17,7 @@ index 71915c5..9819da9 100644
if hasMaxTokens && !hasMaxCompletionTokens {
val := gjson.GetBytes(payload, "max_tokens")
diff --git a/internal/runtime/executor/helps/openai_compat_max_tokens_test.go b/internal/runtime/executor/helps/openai_compat_max_tokens_test.go
-index f1bd20a..4f06037 100644
+index f1bd20aa..4f060378 100644
--- a/internal/runtime/executor/helps/openai_compat_max_tokens_test.go
+++ b/internal/runtime/executor/helps/openai_compat_max_tokens_test.go
@@ -147,27 +147,22 @@ func TestNormalizeOpenAIMaxTokens(t *testing.T) {
@@ -69,3 +69,89 @@ index f1bd20a..4f06037 100644
}
})
+diff --git a/internal/runtime/executor/openai_compat_executor_max_tokens_test.go b/internal/runtime/executor/openai_compat_executor_max_tokens_test.go
+index ff455092..9713812e 100644
+--- a/internal/runtime/executor/openai_compat_executor_max_tokens_test.go
++++ b/internal/runtime/executor/openai_compat_executor_max_tokens_test.go
+@@ -119,7 +119,7 @@ func TestOpenAICompatExecutor_MaxTokensNormalization(t *testing.T) {
+ }
+ })
+
+- t.Run("Execute chat request with max_completion_tokens and use-max-completion-tokens=false converts to max_tokens", func(t *testing.T) {
++ t.Run("Execute chat request with max_completion_tokens and use-max-completion-tokens=false preserves max_completion_tokens", func(t *testing.T) {
+ gotBody = nil
+ payload := []byte(`{"model":"alias-legacy","messages":[{"role":"user","content":"hi"}],"max_completion_tokens":512}`)
+ _, err := executor.Execute(context.Background(), auth, cliproxyexecutor.Request{
+@@ -133,11 +133,11 @@ func TestOpenAICompatExecutor_MaxTokensNormalization(t *testing.T) {
+ t.Fatalf("Execute error: %v", err)
+ }
+
+- if got := gjson.GetBytes(gotBody, "max_tokens").Int(); got != 512 {
+- t.Fatalf("max_tokens = %d, want 512; body=%s", got, string(gotBody))
++ if got := gjson.GetBytes(gotBody, "max_completion_tokens").Int(); got != 512 {
++ t.Fatalf("max_completion_tokens = %d, want 512; body=%s", got, string(gotBody))
+ }
+- if gjson.GetBytes(gotBody, "max_completion_tokens").Exists() {
+- t.Fatalf("max_completion_tokens should be absent; body=%s", string(gotBody))
++ if gjson.GetBytes(gotBody, "max_tokens").Exists() {
++ t.Fatalf("max_tokens should be absent; body=%s", string(gotBody))
+ }
+ })
+
+@@ -221,11 +221,11 @@ func TestOpenAICompatExecutor_MaxTokensNormalization(t *testing.T) {
+ t.Fatalf("Execute error: %v", err)
+ }
+
+- if got := gjson.GetBytes(gotBody, "max_tokens"); !got.Exists() || got.Type != gjson.Null {
+- t.Fatalf("max_tokens = %v, want null; body=%s", got, string(gotBody))
++ if got := gjson.GetBytes(gotBody, "max_completion_tokens"); !got.Exists() || got.Type != gjson.Null {
++ t.Fatalf("max_completion_tokens = %v, want null; body=%s", got, string(gotBody))
+ }
+- if gjson.GetBytes(gotBody, "max_completion_tokens").Exists() {
+- t.Fatalf("max_completion_tokens should be absent; body=%s", string(gotBody))
++ if gjson.GetBytes(gotBody, "max_tokens").Exists() {
++ t.Fatalf("max_tokens should be absent; body=%s", string(gotBody))
+ }
+ })
+ }
+@@ -293,7 +293,7 @@ func TestOpenAICompatExecutor_MaxTokensNormalizationStream(t *testing.T) {
+ }
+ })
+
+- t.Run("ExecuteStream with use-max-completion-tokens=false emits max_tokens", func(t *testing.T) {
++ t.Run("ExecuteStream with use-max-completion-tokens=false preserves max_completion_tokens", func(t *testing.T) {
+ gotBody = nil
+ payload := []byte(`{"model":"alias-legacy","messages":[{"role":"user","content":"hi"}],"max_completion_tokens":256}`)
+ res, err := executor.ExecuteStream(context.Background(), auth, cliproxyexecutor.Request{
+@@ -309,11 +309,11 @@ func TestOpenAICompatExecutor_MaxTokensNormalizationStream(t *testing.T) {
+ for range res.Chunks {
+ }
+
+- if got := gjson.GetBytes(gotBody, "max_tokens").Int(); got != 256 {
+- t.Fatalf("max_tokens = %d, want 256; body=%s", got, string(gotBody))
++ if got := gjson.GetBytes(gotBody, "max_completion_tokens").Int(); got != 256 {
++ t.Fatalf("max_completion_tokens = %d, want 256; body=%s", got, string(gotBody))
+ }
+- if gjson.GetBytes(gotBody, "max_completion_tokens").Exists() {
+- t.Fatalf("max_completion_tokens should be absent; body=%s", string(gotBody))
++ if gjson.GetBytes(gotBody, "max_tokens").Exists() {
++ t.Fatalf("max_tokens should be absent; body=%s", string(gotBody))
+ }
+ })
+
+@@ -405,11 +405,11 @@ func TestOpenAICompatExecutor_MaxTokensNormalizationStream(t *testing.T) {
+ for range res.Chunks {
+ }
+
+- if got := gjson.GetBytes(gotBody, "max_tokens"); !got.Exists() || got.Type != gjson.Null {
+- t.Fatalf("max_tokens = %v, want null; body=%s", got, string(gotBody))
++ if got := gjson.GetBytes(gotBody, "max_completion_tokens"); !got.Exists() || got.Type != gjson.Null {
++ t.Fatalf("max_completion_tokens = %v, want null; body=%s", got, string(gotBody))
+ }
+- if gjson.GetBytes(gotBody, "max_completion_tokens").Exists() {
+- t.Fatalf("max_completion_tokens should be absent; body=%s", string(gotBody))
++ if gjson.GetBytes(gotBody, "max_tokens").Exists() {
++ t.Fatalf("max_tokens should be absent; body=%s", string(gotBody))
+ }
+ })
+ }
diff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.py
index 4ef650eb7..2283da229 100644
--- a/tests/test_model_hub_runtime.py
+++ b/tests/test_model_hub_runtime.py
@@ -902,39 +902,39 @@ def test_packaged_manifest_matches_frozen_runtime_dependency_values(
"assets": [
{
"platform": "darwin-arm64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_darwin_aarch64.tar.gz",
- "size_bytes": 40514706,
- "sha256": "db6e2e1622a066c1f407dd2c5ce0d2676cdf81b713dbf84f2afd48768015e360",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_darwin_aarch64.tar.gz",
+ "size_bytes": 40525867,
+ "sha256": "094d9fdf61d2de655bd9206190b3688fc0c22d6ef2cda09716c9b004bc15b80d",
},
{
"platform": "darwin-x64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_darwin_amd64.tar.gz",
- "size_bytes": 42974424,
- "sha256": "defbe2074ea70f578db2f0ddaa436327cc2b434730df75e01f5f8dcfecfea6cd",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_darwin_amd64.tar.gz",
+ "size_bytes": 42988519,
+ "sha256": "4d4f5c754219cf4173254e98fc8d573fea11cb425b883daeae56d57f0a6e89e4",
},
{
"platform": "linux-amd64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_linux_amd64.tar.gz",
- "size_bytes": 40932273,
- "sha256": "254b71f4c72b6b56766fd5625b7d16356cd9cc389f5cd35ef24c0470c937fd8f",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_linux_amd64.tar.gz",
+ "size_bytes": 40946469,
+ "sha256": "3733df8472813f74530ce7a739a3ebcd091db9c16de815e016ed0de537a2e1c6",
},
{
"platform": "linux-arm64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_linux_aarch64.tar.gz",
- "size_bytes": 37547515,
- "sha256": "4d89ec9733c3953243fd852d509bb913a782eb2bedf6ba81b0347bb5e998bf39",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_linux_aarch64.tar.gz",
+ "size_bytes": 37556916,
+ "sha256": "0ee21fcb4d7316ebce4a46739df75f83bcd8369b3757e5b539d0080477d396a5",
},
{
"platform": "windows-amd64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_windows_amd64.tar.gz",
- "size_bytes": 41444643,
- "sha256": "3eab3dbb539d5c88ae78231de92ceff33988ab847c1e67f282599b98022b7d77",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_windows_amd64.tar.gz",
+ "size_bytes": 41463417,
+ "sha256": "543497b874e9370c85967fd3b5688dbf582cd454b074993af11a90ce41c9c501",
},
{
"platform": "windows-arm64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_windows_aarch64.tar.gz",
- "size_bytes": 37803292,
- "sha256": "95e31d67a229908d7ce52da2cf1e1b54fa70201a14a040945cee9a021ac2d719",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_windows_aarch64.tar.gz",
+ "size_bytes": 37817697,
+ "sha256": "cde450406bc9cbe8a19cb71e75ee959e387abee0173b97700481e0cb289018fc",
},
],
}
@@ -1437,45 +1437,45 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(
"darwin-arm64",
False,
"darwin-arm64",
- 40514706,
- "db6e2e1622a066c1f407dd2c5ce0d2676cdf81b713dbf84f2afd48768015e360",
- "6a908bde31115b913b5c71a2f149805f8a976025459950ff6e8f6f0eb05767e4",
+ 40525867,
+ "094d9fdf61d2de655bd9206190b3688fc0c22d6ef2cda09716c9b004bc15b80d",
+ "8a58f862e5a881c58f05aa8bd379418ebca442d0ec1445002c8248d4cf8460a9",
"cli-proxy-api",
),
(
"darwin-x64",
False,
"darwin-x64",
- 42974424,
- "defbe2074ea70f578db2f0ddaa436327cc2b434730df75e01f5f8dcfecfea6cd",
- "569b1bb7e4a6d698dda66337ba4ae47e4b3ec2662466b7cdceb98bebd63a5e3a",
+ 42988519,
+ "4d4f5c754219cf4173254e98fc8d573fea11cb425b883daeae56d57f0a6e89e4",
+ "86870b2e96319b421949d1933f10010a8a7c11c1ba787d9d1bcf08a5e00e0f77",
"cli-proxy-api",
),
(
"linux-x64",
False,
"linux-amd64",
- 40932273,
- "254b71f4c72b6b56766fd5625b7d16356cd9cc389f5cd35ef24c0470c937fd8f",
- "197eec804e0be5264ad5e75a8c1552e601de456d9296cb1ec2e0ac6f6f16f89b",
+ 40946469,
+ "3733df8472813f74530ce7a739a3ebcd091db9c16de815e016ed0de537a2e1c6",
+ "2cbf349b79a3026cce551c65df103cf67a0878ad1c195e5087f2c4fab189cc77",
"cli-proxy-api",
),
(
"linux-arm64",
False,
"linux-arm64",
- 37547515,
- "4d89ec9733c3953243fd852d509bb913a782eb2bedf6ba81b0347bb5e998bf39",
- "e824efc5b7dface33993fd2d2634e8c3243feafc2f56a6e220fb7aef2f24419f",
+ 37556916,
+ "0ee21fcb4d7316ebce4a46739df75f83bcd8369b3757e5b539d0080477d396a5",
+ "9c968a791a9fda4f48193fafaf5ae9dc87680225c9697e2a06ba0a94ec42e2e9",
"cli-proxy-api",
),
(
"win32-x64",
False,
"windows-amd64",
- 41444643,
- "3eab3dbb539d5c88ae78231de92ceff33988ab847c1e67f282599b98022b7d77",
- "5fc8d17e4a63e996de1de59324dcb016b994442d9efca95ad52f00aa2f32b98f",
+ 41463417,
+ "543497b874e9370c85967fd3b5688dbf582cd454b074993af11a90ce41c9c501",
+ "baea8d2f7a0ae9589552f5c98033d47b1710010bfc8ed16a039c237b7292db7e",
"cli-proxy-api.exe",
),
# x64 Python on Windows on Arm still gets the native engine.
@@ -1483,18 +1483,18 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(
"win32-x64",
True,
"windows-arm64",
- 37803292,
- "95e31d67a229908d7ce52da2cf1e1b54fa70201a14a040945cee9a021ac2d719",
- "6bb5c1dde91a272da2f517f2f987bebfa5e82e9193b0636824d4164631ec10e2",
+ 37817697,
+ "cde450406bc9cbe8a19cb71e75ee959e387abee0173b97700481e0cb289018fc",
+ "ce589b8ff37d38c1da86847977692c2a21a342ac8391d749c2cf9adb9444844e",
"cli-proxy-api.exe",
),
(
"win32-arm64",
True,
"windows-arm64",
- 37803292,
- "95e31d67a229908d7ce52da2cf1e1b54fa70201a14a040945cee9a021ac2d719",
- "6bb5c1dde91a272da2f517f2f987bebfa5e82e9193b0636824d4164631ec10e2",
+ 37817697,
+ "cde450406bc9cbe8a19cb71e75ee959e387abee0173b97700481e0cb289018fc",
+ "ce589b8ff37d38c1da86847977692c2a21a342ac8391d749c2cf9adb9444844e",
"cli-proxy-api.exe",
),
],
diff --git a/vibe/model_hub_runtime/cliproxyapi_manifest.json b/vibe/model_hub_runtime/cliproxyapi_manifest.json
index a8c02e6f4..42f51486e 100644
--- a/vibe/model_hub_runtime/cliproxyapi_manifest.json
+++ b/vibe/model_hub_runtime/cliproxyapi_manifest.json
@@ -6,55 +6,55 @@
"source_url": "https://github.com/router-for-me/CLIProxyAPI/tree/d318bcc3afb9ea8782862f5e8cdb541afdc9dfa5",
"source_sha": "d318bcc3afb9ea8782862f5e8cdb541afdc9dfa5",
"release_tag": "v8.0.23",
- "asset_release_tag": "model-hub-engine-v8.0.23-2",
+ "asset_release_tag": "model-hub-engine-v8.0.23-3",
"license": "MIT",
"assets": [
{
"platform": "darwin-arm64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_darwin_aarch64.tar.gz",
- "size_bytes": 40514706,
- "sha256": "db6e2e1622a066c1f407dd2c5ce0d2676cdf81b713dbf84f2afd48768015e360",
- "binary_sha256": "6a908bde31115b913b5c71a2f149805f8a976025459950ff6e8f6f0eb05767e4",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_darwin_aarch64.tar.gz",
+ "size_bytes": 40525867,
+ "sha256": "094d9fdf61d2de655bd9206190b3688fc0c22d6ef2cda09716c9b004bc15b80d",
+ "binary_sha256": "8a58f862e5a881c58f05aa8bd379418ebca442d0ec1445002c8248d4cf8460a9",
"bin_path": "cli-proxy-api"
},
{
"platform": "darwin-x64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_darwin_amd64.tar.gz",
- "size_bytes": 42974424,
- "sha256": "defbe2074ea70f578db2f0ddaa436327cc2b434730df75e01f5f8dcfecfea6cd",
- "binary_sha256": "569b1bb7e4a6d698dda66337ba4ae47e4b3ec2662466b7cdceb98bebd63a5e3a",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_darwin_amd64.tar.gz",
+ "size_bytes": 42988519,
+ "sha256": "4d4f5c754219cf4173254e98fc8d573fea11cb425b883daeae56d57f0a6e89e4",
+ "binary_sha256": "86870b2e96319b421949d1933f10010a8a7c11c1ba787d9d1bcf08a5e00e0f77",
"bin_path": "cli-proxy-api"
},
{
"platform": "linux-amd64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_linux_amd64.tar.gz",
- "size_bytes": 40932273,
- "sha256": "254b71f4c72b6b56766fd5625b7d16356cd9cc389f5cd35ef24c0470c937fd8f",
- "binary_sha256": "197eec804e0be5264ad5e75a8c1552e601de456d9296cb1ec2e0ac6f6f16f89b",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_linux_amd64.tar.gz",
+ "size_bytes": 40946469,
+ "sha256": "3733df8472813f74530ce7a739a3ebcd091db9c16de815e016ed0de537a2e1c6",
+ "binary_sha256": "2cbf349b79a3026cce551c65df103cf67a0878ad1c195e5087f2c4fab189cc77",
"bin_path": "cli-proxy-api"
},
{
"platform": "linux-arm64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_linux_aarch64.tar.gz",
- "size_bytes": 37547515,
- "sha256": "4d89ec9733c3953243fd852d509bb913a782eb2bedf6ba81b0347bb5e998bf39",
- "binary_sha256": "e824efc5b7dface33993fd2d2634e8c3243feafc2f56a6e220fb7aef2f24419f",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_linux_aarch64.tar.gz",
+ "size_bytes": 37556916,
+ "sha256": "0ee21fcb4d7316ebce4a46739df75f83bcd8369b3757e5b539d0080477d396a5",
+ "binary_sha256": "9c968a791a9fda4f48193fafaf5ae9dc87680225c9697e2a06ba0a94ec42e2e9",
"bin_path": "cli-proxy-api"
},
{
"platform": "windows-amd64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_windows_amd64.tar.gz",
- "size_bytes": 41444643,
- "sha256": "3eab3dbb539d5c88ae78231de92ceff33988ab847c1e67f282599b98022b7d77",
- "binary_sha256": "5fc8d17e4a63e996de1de59324dcb016b994442d9efca95ad52f00aa2f32b98f",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_windows_amd64.tar.gz",
+ "size_bytes": 41463417,
+ "sha256": "543497b874e9370c85967fd3b5688dbf582cd454b074993af11a90ce41c9c501",
+ "binary_sha256": "baea8d2f7a0ae9589552f5c98033d47b1710010bfc8ed16a039c237b7292db7e",
"bin_path": "cli-proxy-api.exe"
},
{
"platform": "windows-arm64",
- "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-2/CLIProxyAPI_8.0.23_windows_aarch64.tar.gz",
- "size_bytes": 37803292,
- "sha256": "95e31d67a229908d7ce52da2cf1e1b54fa70201a14a040945cee9a021ac2d719",
- "binary_sha256": "6bb5c1dde91a272da2f517f2f987bebfa5e82e9193b0636824d4164631ec10e2",
+ "url": "https://github.com/avibe-bot/avibe/releases/download/model-hub-engine-v8.0.23-3/CLIProxyAPI_8.0.23_windows_aarch64.tar.gz",
+ "size_bytes": 37817697,
+ "sha256": "cde450406bc9cbe8a19cb71e75ee959e387abee0173b97700481e0cb289018fc",
+ "binary_sha256": "ce589b8ff37d38c1da86847977692c2a21a342ac8391d749c2cf9adb9444844e",
"bin_path": "cli-proxy-api.exe"
}
],
@@ -67,7 +67,7 @@
"patches": [
{
"path": "patches/model-hub-cpa-v8.0.23/openai-compat-native-token-field.patch",
- "sha256": "a631a1714f5becd51a88e570799f4f2666ca7be9d5d65e15681b10ef125d4dc3"
+ "sha256": "15494e9100baad5a0f3c517ce846e59fab0152d667807df4b09c7dc17b3b033f"
},
{
"path": "patches/model-hub-cpa-v8.0.23/oauth-callback-forwarder-loopback.patch",
@@ -80,6 +80,14 @@
{
"path": "patches/model-hub-cpa-v8.0.23/codex-utls-h2-ping-health-check.patch",
"sha256": "eca61db9f3e29dadb714dc8f7a2c22bc0104216459c37356d59d12ca048c6b74"
+ },
+ {
+ "path": "patches/model-hub-cpa-v8.0.23/fallback-transport-h2-ping-health-check.patch",
+ "sha256": "fb53083be5ee9e17166c6637e414ce8c8dca5aae68bd1ffdab30c8080fca2094"
+ },
+ {
+ "path": "patches/model-hub-cpa-v8.0.23/codex-sse-per-event-parsing.patch",
+ "sha256": "4fddc8d556650e57e492b769f63600184b9908f31ef4180329e641c3d80b11eb"
}
],
"source_date_epoch": 0