diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md index 2f9b6b469..38b6a917b 100644 --- a/docs/subsystems/gateway-routing.md +++ b/docs/subsystems/gateway-routing.md @@ -3232,12 +3232,19 @@ serves it on `/v1/responses`, `/responses` and the Codex backend's - `Run`'s shutdown ends each socket going away (1001) once its turn is answered, through `clientSockets.drain` beside `srv.Shutdown` (a hijacked connection isn't the server's), and refuses new ones 503. -- Not covered: the leg to the vendor is the whole conversation each turn, - as before (for the ChatGPT backend, a socket per turn: see - [Providers and accounts](providers-accounts.md)); what is saved is - Codex's upload to magpie, and, when the provider is another magpie, the - leg between the two magpies (below). A socket's conversation doesn't - outlive the socket or the gateway. +- The leg to the vendor cuts its own delta where the vendor keeps a + turn for the next: the ChatGPT backend and a Responses provider that + speaks the socket (`Socket`; unset, OpenAI's own API does, as Codex's + built-in OpenAI provider does, KawaiiZapic on X) take a turn as its new + input after `previous_response_id` on a kept socket (see + [Providers and accounts](providers-accounts.md)); OpenAI's API, Azure + and Ark over HTTP take the client's own `previous_response_id` + (`prevKeeps`, below), which Codex never sends (`store: false`); another + magpie takes the delta between the two (below). Everything else + (Chat Completions, Messages, Gemini, a Responses provider over HTTP) + is sent the whole conversation each turn, since those protocols keep + nothing between requests. A socket's conversation doesn't outlive the + socket or the gateway. ## A Realtime session diff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.md index cc492799f..c7c5e5a5c 100644 --- a/docs/subsystems/providers-accounts.md +++ b/docs/subsystems/providers-accounts.md @@ -453,7 +453,7 @@ and `TestHistoricalWindowHoldsUsesEachWindowsOwnReading`. - The same providers may instead pin their server's certificate (`ServerPin`: the SHA-256 of its DER, lower-case hex; Zhangzhangi on X, a Remote magpie on a domain with a self-signed certificate macOS calls not standards compliant). Off by default, per provider. The editor's Advanced → Server certificate asks `POST /api/provider/peekcert`, which reaches the form's first `https://` address through its proxy and client certificate with the certificate unchecked (`Provider.PeekServerCert`) and shows its fingerprint, names, dates and why this computer doesn't take it (`x509.Verify` with the system roots); Trust keeps the pin, and the row then says in red that the certificate isn't verified. `Via` passes the pin to `netproxy.WithClientCert`, whose transport for those hosts skips the chain, name and date checks and refuses in `VerifyConnection` any leaf whose SHA-256 isn't the pin (`pinTLS`, `PinMismatchError`). The hosts it applies at are `PinHosts`: every endpoint of a provider that takes a client certificate, and of a preset's only the `https://` addresses at a host neither the preset nor its regions name (Zhangzhangi on X, "建议对别的自签名域名也生效": LM Studio or Ollama on another computer), never a subscription's, Vertex or a vendor's own host; a client certificate and Server CA still go only where `TakesClientCert` holds. `TakesServerPin` is in `/api/providers`, and the editor shows the row while the form has such an address (`pinAddrs` in app.js). `Save` refuses a pin that isn't 64 hex digits, or on a provider with no such address (`TestServerPinRemoteMagpie`, `TestServerPinSaveChecks`, `TestServerPinPresetAtOwnServer`, `TestServerPinNoVendorHost`, `TestPinOnlyThatCertificate`, `provider-server-pin.test.cjs`). - A provider may connect a host of its base URLs to addresses of the user's choosing, as `curl --resolve` (`Provider.Resolve`, a map of host name to places; quantum_lsfc on X, a managed network whose domains go to an internal L4 SNI gateway, where an IP in the base URL fails the certificate and `/etc/hosts` can't be edited). A place is an IP address (with `:port` if the gateway listens elsewhere) or `dns:`, looked up at each new connection so a rotating record is followed. Only the TCP target changes: the URL's name is still the TLS server name and the `Host`. The places are tried in order, each given 8s (`resolveTry`); when none connects, the name is dialled as if there were no rule. `Via` puts the rule on the context (`netproxy.WithResolve`), `Dispatch` keeps one transport clone per rule and wraps its `DialContext` (`resolveTLS`). Through a proxy (the provider's, the global one, the environment's) the rule is not used: the proxy gets `CONNECT` with the original name and connects itself; `RoundTrip` marks a request direct (`directKey`) only when `t.Proxy` says none. `TakesResolve` is where `TakesInsecureTLS`, `TakesClientCert` or `PinHosts` hold: a provider the user added, Remote magpie, a preset at a host of the user's own; never a subscription's account or a vendor's own host. Plugins are not covered: a plugin's requests are `fetch` calls in the Bun plugin host, which has no hook for the connection's address, so a plugin's provider takes no rule (`TakesResolve` is false for an account). `Save` runs `netproxy.CheckResolve` (bare host names, IP or `dns:` places, at most 32 hosts and 16 places) and refuses a rule on a provider that doesn't take one. The gateway's offline check leaves such a provider's host out of the hosts it dials to tell whether the network is up (`otherHosts`), since it dials them by name. The editor's Advanced → Connect to is a box of `host = place, place` lines (`resolveRow` in tlscerts.js; `TestResolveSaved`, `TestResolveVia`, `TestOtherHostsSkipResolved`, `TestProviderSaveResolve`, the `netproxy` `TestResolve*` tests, `provider-resolve.test.cjs`). - A provider the user added may be held to HTTP/1.1 (`HTTP1`, the editor's "HTTP version" row under Advanced, shown while an address is `https://`; kepner_53726 on Discord: a company gateway whose HTTP/2 streams broke mid-reply with "tls: bad record MAC" while a plain Go client held). It takes the same providers as `InsecureTLS` (`TakesInsecureTLS`), and `Save` refuses it on any other. `Provider.Via` adds `netproxy.WithHTTP1` with the hosts of its own base URLs, so a request made on its behalf to one of those hosts goes through the `Dispatch` transport's HTTP/1.1 copy (`route.h1`); another host, and a request made for another provider (`netproxy.With` drops it), are offered HTTP/2 as before (`TestHTTP1AskedOnlyItsHost`, `TestHTTP1OwnProviderOnly`, `TestProviderSaveHTTP1`). Without it, a TLS record error read on an HTTP/2 reply (`recordError`: "bad record MAC", "received record with version …", an oversized record) moves that host:port to HTTP/1.1 for 6 hours (`h2BrokenFor`; see [Gateway routing](gateway-routing.md)). -- A provider the user added with a Responses address may send its turns over the Responses WebSocket, as the ChatGPT leg above does (`Socket`, #5781, faithleysath; matrix0487 on Discord; `magpie provider set socket=auto|on|off`, the editor's WebSocket row under Advanced). It takes a provider with no account, an `http(s)://` Responses address and not Vertex (`TakesSocket`); the CLI refuses it on any other. `Provider.Via` puts the provider's Responses host and path in the request's context (`withSocket`), and `codexSocket` speaks the socket only to a POST to that host at `/responses` (`SocketTurn`); a provider without `Socket` hides a value an outer context carried, so it never dials a socket (`TestResponsesProviderWithoutSocketNeverDials`). Everything after is the ChatGPT leg's: the fallback to HTTP on a refused handshake or a socket that ends before the reply, the kept socket and its delta (keyed by scheme, `Authorization`, `X-Api-Key` and `Api-Key` too), and a server-sent-events reply. `auto` speaks HTTP to a host for 10 minutes once it refused the handshake; `on` tries the socket every turn and never shuns. Routing, keys, limits, usage and masking are the HTTP route's, since the socket replaces only the transport. +- A provider the user added with a Responses address may send its turns over the Responses WebSocket, as the ChatGPT leg above does (`Socket`, #5781, faithleysath; matrix0487 on Discord; `magpie provider set socket=auto|on|off`, the editor's WebSocket row under Advanced). It takes a provider with no account, an `http(s)://` Responses address and not Vertex (`TakesSocket`); the CLI refuses it on any other. `Provider.Via` puts the provider's Responses host and path in the request's context (`withSocket`), and `codexSocket` speaks the socket only to a POST to that host at `/responses` (`SocketTurn`); a provider without `Socket` hides a value an outer context carried, so it never dials a socket (`TestResponsesProviderWithoutSocketNeverDials`). Everything after is the ChatGPT leg's: the fallback to HTTP on a refused handshake or a socket that ends before the reply, the kept socket and its delta (keyed by scheme, `Authorization`, `X-Api-Key` and `Api-Key` too), and a server-sent-events reply. `auto` speaks HTTP to a host for 10 minutes once it refused the handshake; `on` tries the socket every turn and never shuns. Unset, a provider at `https://api.openai.com` (its Responses host exactly, no plugin) is `auto` (`SocketByDefault`, `SocketMode`), as Codex's built-in OpenAI provider speaks the socket there (codex-rs `create_openai_provider`, `supports_websockets: true`): Codex says `store: false`, so over HTTP every turn went up whole (KawaiiZapic on X, `TestOpenAIProviderTurnsGoOverWebSocketByDefault`); `off` is kept as set, so such a provider stays on HTTP, and the editor's tick opens ticked there, saving `off` unticked and unset ticked again. Before this an unticked tick saved unset, so a provider unticked then goes over the socket now until it is unticked again. Routing, keys, limits, usage and masking are the HTTP route's, since the socket replaces only the transport. - A provider the user added may be set never to rest for a limit (`LimitRestOff`, `limitRestOff`; the editor's Advanced fold, "Set it aside when out of quota or rate limited", ticked by default; zoecats on Discord: a local aggregator's "quota exhausted" while it switches upstreams). Off, a quota, credit or rate refusal and any 429 rest none of its keys and the next request is sent to it as usual (`restAfterMarked` in the gateway, see [gateway routing](gateway-routing.md)). The editor offers it only to a provider the user added (`custom`); a save that leaves it out keeps it (`TestProviderSaveLimitRestOff`, `provider-limit-rest.test.cjs`). - The Copilot account the editors and CLI keep is read by `copilotLogin` ([account.go](../../internal/provider/account.go)): an editor's github.com sign-in in `~/.config/github-copilot/apps.json` or `hosts.json` first, then the Copilot CLI's, then an editor's on GHE.com. When GitHub refuses the editor token's trade for a session token (401 or 403, `copilotRefusals`, retried after an hour), the CLI's sign-in of the same login on the same host takes its place, sent as the CLI sends it, from that request on and on the Usage card (`copilotStandIn`); a CLI signed in to another account is never used for it, and the error names the editors' file (#1238). A sign-in from magpie of the account whose editor token is refused is kept and stands for it (`copilotProbeEditor`, `addCopilotLogin`); while the editor token works, it is let go as the agent's own, as before. - A keychain read that may have shown the user a dialog is not asked again for ten minutes after it was refused (`keychainDeniedTTL` in [account.go](../../internal/provider/account.go)): Copilot's token read backs a denial off (`copilotCLISecret`), and the Cursor token (`cursorKeychainToken`) and Claude Code's item (`readClaudeKeychainItem`, through `claudeCredential`'s cache) do too (#2408). 44, the item not being there, is no refusal and keeps the short TTL, so a sign-in made in the agent is still seen within it; a sign-in or out in magpie reads afresh (`forgetCursorStatus`, `forgetClaudeCredential`), backoff or not. @@ -537,7 +537,7 @@ go test -tags nogui ./internal/provider ./internal/gateway ./internal/gui -run ' node --test internal/gui/tests/provider-many-keys.test.cjs internal/gui/tests/provider-many-keys-proxy.test.cjs go test -tags nogui ./internal/provider -run 'TestCapHeld|TestCapReached|TestWindowCapHeld|TestSetWindowCap' go test -tags nogui ./internal/netproxy ./internal/provider ./internal/gateway -run 'TestDispatchHTTP1|OverHTTP1|TestAccountProxy|TestUncheckedTLS|TestInsecureTLS|TestHTTP1|TestH2Record|TestRecordError' -go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli ./internal/gui -run 'TestSocket|TestResponsesProvider|TestProviderSetSocket|TestProviderSaveSocket' +go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli ./internal/gui -run 'TestSocket|TestResponsesProvider|TestOpenAIProvider|TestProviderSetSocket|TestProviderSaveSocket' node --test internal/gui/tests/provider-socket.test.cjs go test -tags nogui ./internal/provider -run 'TestSeat|TestPlanOfASignedInAccountShownOnce|TestGLMPlanMatchesZCodePlugin|TestAccountName' go test -tags nogui . -run TestAccountsAlias diff --git a/internal/cli/providers_cli.go b/internal/cli/providers_cli.go index e520c1aff..fa59005b5 100644 --- a/internal/cli/providers_cli.go +++ b/internal/cli/providers_cli.go @@ -71,7 +71,8 @@ const providerUsage = `usage: patience=default, 1m socket=auto sends its Responses turns over the Responses WebSocket, over HTTP when it can't, and over HTTP alone for 10m once the host - refuses it; socket=on tries it every turn; socket=off, the default + refuses it; socket=on tries it every turn; socket=off sends them + over HTTP alone; socket=default, auto on api.openai.com, else off errors=pass sends the agent its errors as the vendor sent them: asked once, nothing read into them, no other provider tried; errors=magpie, the default, has magpie handle them @@ -975,6 +976,8 @@ func showProviderAsking(p provider.Provider, ask bool) error { } if p.Socket != "" { kv("socket", p.Socket) + } else if p.SocketByDefault() { + kv("socket", "auto (default)") } switch { case p.Account != nil: @@ -1345,7 +1348,7 @@ func applyPairs(p *provider.Provider, pairs []string) error { // refuses it to HTTP for a while, on tries it every turn s, ok := provider.ParseSocket(v) if !ok { - return fmt.Errorf("socket=auto|on|off, not %q", v) + return fmt.Errorf("socket=auto|on|off|default, not %q", v) } p.Socket = s case "patience": @@ -1564,7 +1567,7 @@ func applyPairs(p *provider.Provider, pairs []string) error { return fmt.Errorf("unknown field %q\n\n%s", k, providerUsage) } } - if p.Socket != "" && !p.TakesSocket() { + if p.Socket != "" && p.Socket != provider.SocketOff && !p.TakesSocket() { return fmt.Errorf("socket=%s: %s has no Responses API of its own to speak a WebSocket to; only a provider with responses= and a key can", p.Socket, p.Name) } if p.NativeCompaction && !p.CarriesCompaction() { diff --git a/internal/cli/socket_cli_test.go b/internal/cli/socket_cli_test.go index e83421744..d6536c478 100644 --- a/internal/cli/socket_cli_test.go +++ b/internal/cli/socket_cli_test.go @@ -11,7 +11,7 @@ import ( // without a Responses URL, or a signed-in account, takes none. func TestProviderSetSocket(t *testing.T) { p := provider.Provider{ID: "relay", Name: "Relay", Key: "k", Responses: "https://relay.example/v1"} - for _, c := range []struct{ v, want string }{{"auto", "auto"}, {"on", "on"}, {"off", ""}, {"AUTO", "auto"}, {"default", ""}} { + for _, c := range []struct{ v, want string }{{"auto", "auto"}, {"on", "on"}, {"off", "off"}, {"AUTO", "auto"}, {"default", ""}} { if err := applyPairs(&p, []string{"socket=" + c.v}); err != nil || p.Socket != c.want { t.Fatalf("socket=%s: %v, got %q", c.v, err, p.Socket) } diff --git a/internal/gateway/responses_socket_test.go b/internal/gateway/responses_socket_test.go index 52fefbeb3..bbc743e76 100644 --- a/internal/gateway/responses_socket_test.go +++ b/internal/gateway/responses_socket_test.go @@ -209,3 +209,74 @@ func TestResponsesProviderSocketReplyIsAStream(t *testing.T) { t.Errorf("Content-Type %q", ct) } } + +// openAIAt adds "oai", a key's provider at OpenAI's own Responses URL +// with Socket sock, whose api.openai.com is connected to the fake f on +// this computer (Resolve, its test certificate let through), so nothing +// reaches the network. It returns the handshakes the fake was asked for. +func openAIAt(t *testing.T, f *fakeSocketBackend, sock string) *atomic.Int32 { + t.Helper() + noRests() + t.Cleanup(noRests) + t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + t.Setenv("XDG_CACHE_HOME", t.TempDir()) + f.path = "/v1/responses" + var asked atomic.Int32 + up := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Host != "api.openai.com" { + http.Error(w, "host "+r.Host, http.StatusMisdirectedRequest) + return + } + if strings.EqualFold(r.Header.Get("Upgrade"), "websocket") { + asked.Add(1) + } + f.ServeHTTP(w, r) + })) + t.Cleanup(up.Close) + p := provider.Provider{ID: "oai", Name: "oai", Key: "sk-oai", Models: []string{"m1"}, Responses: "https://api.openai.com/v1", Socket: sock, + InsecureTLS: true, Resolve: map[string][]string{"api.openai.com": {up.Listener.Addr().String()}}} + if err := provider.Save(p); err != nil { + t.Fatal(err) + } + return &asked +} + +// KawaiiZapic on X: Codex on an OpenAI API key sent the whole +// conversation up every turn, since Codex says store false and only the +// Responses WebSocket keeps a turn for the next one then. Codex's own +// OpenAI provider speaks that socket to api.openai.com, and so does magpie +// now with Socket unset: the second turn is the new input alone after +// previous_response_id, on the first turn's socket. +func TestOpenAIProviderTurnsGoOverWebSocketByDefault(t *testing.T) { + socketOn(t) + f := &fakeSocketBackend{keep: true, whole: true} + f.frames = keptReply(f) + asked := openAIAt(t, f, "") + + relayPost(t, keptTurn("conv-1", "oai/m1", userPing)) + relayPost(t, keptTurn("conv-1", "oai/m1", userPing, asstPong, userAgain)) + if posts, sockets := f.counts(); posts != 0 || sockets != 2 || asked.Load() != 1 { + t.Fatalf("%d HTTP posts, %d socket turns on %d handshakes; want both turns on one socket", posts, sockets, asked.Load()) + } + second := gjson.ParseBytes(f.turn(1).msg) + if got := second.Get("previous_response_id").String(); got != "resp-1" { + t.Errorf("previous_response_id %q, want resp-1: %s", got, f.turn(1).msg) + } + if in := second.Get("input").Array(); len(in) != 1 || in[0].Get("content.0.text").String() != "again" { + t.Errorf("delta input %s, want only the new user message", second.Get("input").Raw) + } +} + +// Set off, OpenAI's API is spoken HTTP alone, as before. +func TestOpenAIProviderSocketOffNeverDials(t *testing.T) { + socketOn(t) + f := &fakeSocketBackend{keep: true, whole: true} + f.frames = keptReply(f) + asked := openAIAt(t, f, provider.SocketOff) + + relayPost(t, keptTurn("conv-1", "oai/m1", userPing)) + relayPost(t, keptTurn("conv-1", "oai/m1", userPing, asstPong, userAgain)) + if posts, _ := f.counts(); posts != 2 || asked.Load() != 0 { + t.Fatalf("%d posts, %d handshakes; want HTTP alone", posts, asked.Load()) + } +} diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index cb3d1c181..cfba89f8d 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -10115,17 +10115,11 @@ function drawEditor(p, presetID) { // another editor's: no rows for it const certDraft = draft; import("./tlscerts.js").then(() => draft === certDraft && tlsCertRows({ p, pr, draft, at: certAt, certTakes, onHTTPS, addressOf, asTyped, show: (f) => { const was = showTLS; showTLS = () => { was(); f(); }; showTLS(); }, save: (f) => { pinBody = f; } }), statusErr); - // Responses over WebSocket (#5781): auto, or the CLI's on kept + // Responses over WebSocket (#5781), its row in socketrow.js const socketable = () => !p?.account && (p?.preset || pr?.id) !== "google-vertex" && /^\s*https?:\/\//i.test(addressOf("responses")); - { - const [stk, scb] = tick(t("Send Responses turns over WebSocket"), !!draft.socket); - stk.classList.add("socket-tick"); - scb.onchange = () => { draft.socket = scb.checked ? (p?.socket || "auto") : ""; }; - const srow = field(t("WebSocket"), stk); - showSocket = () => { for (const e of srow) e.style.display = socketable() ? "" : "none"; }; - showSocket(); - advIn.append(...srow); - } + const sockAt = document.createComment(""); + advIn.append(sockAt); + import("./socketrow.js").then(() => draft === certDraft && socketRow({ p, draft, at: sockAt, socketable, addressOf, show: (f) => { showSocket = f; f(); } }), statusErr); // off, a 429 or quota refusal rests none of its keys (LimitRestOff, zoecats) if (custom) { const [rtk, rcb] = tick(t("Set it aside when out of quota or rate limited"), !draft.limitRestOff); diff --git a/internal/gui/assets/socketrow.js b/internal/gui/assets/socketrow.js new file mode 100644 index 000000000..dbf66ebac --- /dev/null +++ b/internal/gui/assets/socketrow.js @@ -0,0 +1,19 @@ +// A provider editor's WebSocket row under Advanced (#5781): its tick +// sends the Responses turns over the Responses WebSocket. Ticked it saves +// auto, or keeps the CLI's on; unticked it saves "", HTTP alone. OpenAI's +// own API goes over it unset (provider.SocketByDefault, KawaiiZapic on +// X), so there it opens ticked, saves off unticked and "" ticked again. +// app.js imports this when it draws the editor, so it weighs nothing on +// the core; show is handed the row's showSocket. +window.socketRow = function ({ p, draft, at, socketable, addressOf, show }) { + const def = () => /^\s*https:\/\/api\.openai\.com(?:[:/]|\s*$)/i.test(addressOf("responses")); + const [stk, scb] = tick(t("Send Responses turns over WebSocket"), draft.socket ? draft.socket !== "off" : def()); + stk.classList.add("socket-tick"); + scb.onchange = () => { draft.socket = scb.checked ? (p?.socket === "on" ? "on" : def() ? "" : "auto") : def() ? "off" : ""; }; + const srow = field(t("WebSocket"), stk); + at.replaceWith(...srow); + show(() => { + for (const e of srow) e.style.display = socketable() ? "" : "none"; + if (!draft.socket) scb.checked = def(); + }); +}; diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 726283cae..76c4d7d30 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -17,8 +17,8 @@ import ( // never what pays for a change (#5918); the history of each number is in // `git log -L` of this file. const ( - appScriptBudget = 1_088_733 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had; +123 for a sidebar list folded from its page's row (hkwok06 on X), its chevron and fold in navicons.js, imported with the first list; +57 for each account of a provider's Usage card in a card of its own (normalcoder_ on X), past the 24 of room left; +17 for an allowance card's wallet line under its rings (apple_test_src on X), the one filter shared with its text line; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to; -1,529: each ChatGPT account's own warm-up time (renderWarmAtOwn) moved into autoresetown.js, imported when its rows first draw, paying for a provider's editor opening Advanced when its warm-up or check-in is on (ChrisYagao on X), and the room left over given back; +103 for the sidebar foot that holds Settings' tabs marked by a class, not :has(), which Safari before 15.4 can't parse (#5919): no page's code small enough to move was left (modelInfo serves two plugins); +52 for a proxy's failure said in the reader's language (laiuuui on X): proxyWhy is in proxies.js, imported when Settings draws its saved proxies, and what is left is api()'s one line handing the reply to it; api() reads every error, so there is no page to move it to; +485 for which effort a Claude Code tier runs at (lightwlh on X): an unset tier's effort reads follows session, a set one's title says the session's effort and /effort don't change it, and New sessions' effort says a tier with its own runs at that one, one ownSaid shared by both titles, packed to the shortest form; connectPanel and the effort slider draw every agent's Details, so there is no page to move it to - coreScriptBudget = 1_273_424 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to; +12 for AIGoCode's logo in pngIcons (MindfulReturn on X), the list every drawn icon is looked up in; +491 for each cost in the tray panel's and Requests' chart and ranking in its own provider's currency (onkashiko on X): ledProv and the provider passed through, packed to the shortest form; drawLedColumns and drawLedRank are shared by the panel, so there is no page to move it to; +326 for the Qwen AI platform's Token Plan sign-in (imthe99galaxy on X): its field, sign-in and wait in qianwenplan.js, imported when such a provider's editor opens, and what is left is the import and one quotaError line for its two refusals, packed to the shortest form; quotaError reads every card's error, so there is no page to move it to; +72 for Copy all keys (emilochen on X): its row in keyrates.js, imported when a provider with two or more keys opens through keyRateField, now told which of its parts to draw, and what is left is the one line that places it; +83 for the page saying it has gone from view, so what its Sessions and Usage pages keep goes in 30 s and not 7 minutes (P0 memory): folded into the visibilitychange listener every window has, packed to the shortest form, so there is no page to move it to; +270 for Providers' Select, to remove several at once (eiyuuzaki2333 on X): its rows, bar, removal and keys in pvpick.js, imported when Select is first clicked, and what is left is pvSel, the button's click and two lines in renderProviders, which draws the list, so there is no page to move it to; +81 for each account of a provider's Usage card in a card of its own (normalcoder_ on X): one line that makes the box, its brief look left to CSS, and renderQuotas, which draws every card, so there is no page to move it to; +17 for Kimi Code's booster balance under an allowance card's rings in the tray panel (apple_test_src on X): the card's text line and the wallet line share one filter, packed to the shortest form; panelQuotaCard draws every card, so there is no page to move it to; +51 for what a failed plugin install left in plugins/, listed under Installed with a Remove (CHENGJIAHEGOXIS on X): its section in plugininstalled.js as pmLeftovers, imported when Plugins first draws, and what is left is the one call after drawInstalled; draw is what draws the page, so there is no page to move it to; +123 for a sidebar list folded from its page's row (hkwok06 on X): the chevron, its click and the fold kept per page in navicons.js, imported with the first list, and what is left is the folded list read beside the hidden pages' (navList, which navMine now shares) and the two rows' clicks asking navFold first; navSubs draws every list, so there is no page to move it to; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +189 for Let magpie set it on a Codex card locked by config.toml's own compact limit or background threshold (sufeng1894 on X), and Undo for a background share taken over: the shared send posts it, packed to the shortest form; adviceRow draws every card, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to; -1,529: each ChatGPT account's own warm-up time moved into autoresetown.js, paying for Advanced opening on a warm-up or check-in that is on (ChrisYagao on X), the room left over given back; +103 for the same .with-sub foot (#5919); +52 for the Advisor kind of an advisor call's own usage row (#6977, Refeccd on Discord): its entry in the generated purposes.js; the kinds are read wherever Usage and Routing draw a row, so there is no page to move it to; +54 for a proxy's failure said in the reader's language (laiuuui on X): proxyWhy is in proxies.js, imported when Settings draws its saved proxies, and what is left is api()'s one line handing the reply to it; api() reads every error, so there is no page to move it to; +843 for which effort a Claude Code tier runs at (lightwlh on X): an unset tier's effort reads follows session, a set one's title says the session's effort and /effort don't change it, and New sessions' effort says a tier with its own runs at that one, one ownSaid shared by both titles, packed to the shortest form; connectPanel and the effort slider draw every agent's Details, so there is no page to move it to + appScriptBudget = 1_088_568 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had; +123 for a sidebar list folded from its page's row (hkwok06 on X), its chevron and fold in navicons.js, imported with the first list; +57 for each account of a provider's Usage card in a card of its own (normalcoder_ on X), past the 24 of room left; +17 for an allowance card's wallet line under its rings (apple_test_src on X), the one filter shared with its text line; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to; -1,529: each ChatGPT account's own warm-up time (renderWarmAtOwn) moved into autoresetown.js, imported when its rows first draw, paying for a provider's editor opening Advanced when its warm-up or check-in is on (ChrisYagao on X), and the room left over given back; +103 for the sidebar foot that holds Settings' tabs marked by a class, not :has(), which Safari before 15.4 can't parse (#5919): no page's code small enough to move was left (modelInfo serves two plugins); +52 for a proxy's failure said in the reader's language (laiuuui on X): proxyWhy is in proxies.js, imported when Settings draws its saved proxies, and what is left is api()'s one line handing the reply to it; api() reads every error, so there is no page to move it to; +485 for which effort a Claude Code tier runs at (lightwlh on X): an unset tier's effort reads follows session, a set one's title says the session's effort and /effort don't change it, and New sessions' effort says a tier with its own runs at that one, one ownSaid shared by both titles, packed to the shortest form; connectPanel and the effort slider draw every agent's Details, so there is no page to move it to; -165: the provider editor's WebSocket row moved into socketrow.js, imported as the editor draws, paying for its tick opening ticked on OpenAI's own API (KawaiiZapic on X), and the room left over given back + coreScriptBudget = 1_273_259 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form; +468 for a plugin's own file import (auth.import) in the import sheet, in the plugin's words (marchen_cc on X), packed to one statement; importSay is read as the Providers rows draw, so it has no lazy page to go to, and nothing else was moved out; +180 for Claude Magpie's own Claude Code folder (xMopf7RF on X, #6459): its Advanced fold in claudemagpie.js, imported when it first shows, and what is left is the import and the fold's place in the Separate app line, 216 bytes packed to the shortest form, less the 36 of room there was; +81 for the Use Claude Magpie button on Claude Desktop's row (xMopf7RF on X), drawn by claudemagpie.js too, what is left the one line that places it (#2710); +225 for the Hermes row's Other profiles lines (Norethcy on X), which 1d60b165c took out while each profile had a row and c96f33d65 left with no place at all, packed to the shortest form; the dead hermes# Default note went with it, and the Agents rows draw it, so there is no page to move it to; +397 for a key's own price rate (tnt12231 on X): its lines, check and placeholder in keyrates.js, imported when a provider with two or more keys opens, and what is left is the import, the draft's copy, Advanced opening for it, the save's one line and proxyLines drawing another kind of line; +316 for an image or video model's chip saying what it makes from its right-click (iceloon on X): the chat chip's Makes… now shared with it, and the media chip's Copy model ID left out, packed to the shortest form; the provider's editor draws it, so there is no page to move it to; +67 for the Claude Code · Claude Magpie row saying it is on magpie through Claude Magpie (xMopf7RF on X), one line in connectLine with the shortest words that say it; the Agents rows draw it, so there is no page to move it to; +12 for AIGoCode's logo in pngIcons (MindfulReturn on X), the list every drawn icon is looked up in; +491 for each cost in the tray panel's and Requests' chart and ranking in its own provider's currency (onkashiko on X): ledProv and the provider passed through, packed to the shortest form; drawLedColumns and drawLedRank are shared by the panel, so there is no page to move it to; +326 for the Qwen AI platform's Token Plan sign-in (imthe99galaxy on X): its field, sign-in and wait in qianwenplan.js, imported when such a provider's editor opens, and what is left is the import and one quotaError line for its two refusals, packed to the shortest form; quotaError reads every card's error, so there is no page to move it to; +72 for Copy all keys (emilochen on X): its row in keyrates.js, imported when a provider with two or more keys opens through keyRateField, now told which of its parts to draw, and what is left is the one line that places it; +83 for the page saying it has gone from view, so what its Sessions and Usage pages keep goes in 30 s and not 7 minutes (P0 memory): folded into the visibilitychange listener every window has, packed to the shortest form, so there is no page to move it to; +270 for Providers' Select, to remove several at once (eiyuuzaki2333 on X): its rows, bar, removal and keys in pvpick.js, imported when Select is first clicked, and what is left is pvSel, the button's click and two lines in renderProviders, which draws the list, so there is no page to move it to; +81 for each account of a provider's Usage card in a card of its own (normalcoder_ on X): one line that makes the box, its brief look left to CSS, and renderQuotas, which draws every card, so there is no page to move it to; +17 for Kimi Code's booster balance under an allowance card's rings in the tray panel (apple_test_src on X): the card's text line and the wallet line share one filter, packed to the shortest form; panelQuotaCard draws every card, so there is no page to move it to; +51 for what a failed plugin install left in plugins/, listed under Installed with a Remove (CHENGJIAHEGOXIS on X): its section in plugininstalled.js as pmLeftovers, imported when Plugins first draws, and what is left is the one call after drawInstalled; draw is what draws the page, so there is no page to move it to; +123 for a sidebar list folded from its page's row (hkwok06 on X): the chevron, its click and the fold kept per page in navicons.js, imported with the first list, and what is left is the folded list read beside the hidden pages' (navList, which navMine now shares) and the two rows' clicks asking navFold first; navSubs draws every list, so there is no page to move it to; +338 for the Daily update channel (fishmagic80 on X): its segment, its line under Update channel and the version row's two Up to date on Daily words, packed to the shortest form (one t() per choice); Settings › About and renderUpdate draw them on every window, so there is no page to move them to; +35 for Baidu Qianfan's Token Plan sign-in (yuushabu_buyinn on X, #5860): its field in qianfanplan.js, imported when such a provider's editor opens, drawn by renderStepPlan now told whose sign-in it brings, and what is left is the import and two quotaError lines, past the room there was; quotaError reads every card's error, so there is no page to move it to; +27 for Windows' title bar (258a14 on X): the caption buttons, their clicks, the bar's double click and what keeps them over a dialog in wincap.js, imported in Windows' window alone, the header's room for them in app.css, and what is left is the one line that imports it, past the 29 of room there was; that window's frame is drawn on every start, so there is no page to move it to; +107 for the pages in the reader's own order (chet030714 on X): the order, the sidebar and tab bar put in it, and the menu's drag and keys in navorder.js and navpages.js, imported once an order is kept or Settings draws, and what is left is the one line in navHides that imports it; navHides runs on every start, so there is no page to move it to; +275 for the grants Alibaba's Token Plan asks of a RAM user's AccessKey in the reader's language (MetalHqa on X): one string (ALI_RAM) shown under the editor's AccessKey ID and on the card that names them, less the 48 of the wrong "a RAM user that may use Model Studio is enough" it replaces; the editor and quotaError draw them on every window, so there is no page to move them to; +135 for a model test its vendor queued shown queued and not green (sufeng1894 on X): queuedSaid, one string shared by the chip's title, Test models' and Test this model's status, and the chip's amber dot; renderModels draws the provider editor's chips, so there is no page to move it to; +66 for AstrLink Guard's row saying an x64 magpie runs it under Windows on Arm's emulation until the next update installs the Arm build (EV_John_Liu on X), the Rosetta line's sibling, one line in pmSub; the Privacy rows draw it, so there is no page to move it to; +189 for Let magpie set it on a Codex card locked by config.toml's own compact limit or background threshold (sufeng1894 on X), and Undo for a background share taken over: the shared send posts it, packed to the shortest form; adviceRow draws every card, so there is no page to move it to; +864 for Use on a Claude setup-token account, which switches Claude Code itself to it in its settings.json, and Use back on its signed-in account (liukaybee on X): one swUse helper shared by both buttons, packed to the shortest form; renderAccounts draws every account row, so there is no page to move it to; +1 for the classifier timeout's unset default, 15 and not 8 (ESern29751 on X): its second digit in the Settings row's fallback, which renderReplies draws, so there is no page to move it to; +457 for Kimi Code's subagent pool and its effort (XiaoLing_Arisa on X): the Subagents line and its pool menu in kimisub.js, imported before a Kimi Code row's Details first slides open so it measures the line, and what is left is that import, the line's place, the three fields kept out of the row's squares and the picker's note that Kimi's subagents run on the lead's model, packed to the shortest form; renderAgents draws every row, so there is no page to move it to; +354 for Images per request (#6849, Yuu_jiang_ on X): its field and parse are in maximages.js, imported as the editor draws Max output, and what stays is the import, the two saves' lines and the check that the editor is still open when it and keyrates.js land, no page to move them to; +499 for Speed beside Model and Effort in an agent's opened row (Tengs999 on X): the line, its menu and what decides the speed in agentspeed.js, imported before a fast model's Details first slides open so it measures the line, and what is left is that import and the line's place in the panel's and the window's rows, packed to one helper; renderAgents draws every row, so there is no page to move it to; -1,529: each ChatGPT account's own warm-up time moved into autoresetown.js, paying for Advanced opening on a warm-up or check-in that is on (ChrisYagao on X), the room left over given back; +103 for the same .with-sub foot (#5919); +52 for the Advisor kind of an advisor call's own usage row (#6977, Refeccd on Discord): its entry in the generated purposes.js; the kinds are read wherever Usage and Routing draw a row, so there is no page to move it to; +54 for a proxy's failure said in the reader's language (laiuuui on X): proxyWhy is in proxies.js, imported when Settings draws its saved proxies, and what is left is api()'s one line handing the reply to it; api() reads every error, so there is no page to move it to; +843 for which effort a Claude Code tier runs at (lightwlh on X): an unset tier's effort reads follows session, a set one's title says the session's effort and /effort don't change it, and New sessions' effort says a tier with its own runs at that one, one ownSaid shared by both titles, packed to the shortest form; connectPanel and the effort slider draw every agent's Details, so there is no page to move it to; -165: the provider editor's WebSocket row moved into socketrow.js, imported as the editor draws, paying for its tick opening ticked on OpenAI's own API (KawaiiZapic on X), and the room left over given back ) // codeBytes is how many bytes of b are code: its blank lines, its lines diff --git a/internal/gui/providers.go b/internal/gui/providers.go index 8d60f0768..5bc9789b0 100644 --- a/internal/gui/providers.go +++ b/internal/gui/providers.go @@ -216,7 +216,8 @@ type providerJSON struct { // (provider.PinHosts), a preset's pointed at their own server too TakesServerPin bool `json:"takesServerPin,omitempty"` // its Responses turns over the Responses WebSocket (provider.Socket, - // #5781): auto, on or ""; TakesSocket: a provider of a key with a + // #5781): auto, on, off or "" (auto on OpenAI's own API, HTTP + // elsewhere: provider.SocketMode); TakesSocket: a provider of a key with a // Responses URL Socket string `json:"socket"` TakesSocket bool `json:"takesSocket"` @@ -1926,7 +1927,7 @@ func providerRoutes(mux *http.ServeMux, w Windows) { // save that leaves it out keeps it HTTP1 *bool `json:"http1"` // Socket is how its Responses turns go over the Responses - // WebSocket (#5781): auto, on, or "" for HTTP alone; a save + // WebSocket (#5781): auto, on, off, or "" for its default; a save // that leaves it out keeps it Socket *string `json:"socket"` // LimitRestOff is whether a quota refusal or a 429 leaves it diff --git a/internal/gui/socket_test.go b/internal/gui/socket_test.go index a498d7034..6f2c3fb82 100644 --- a/internal/gui/socket_test.go +++ b/internal/gui/socket_test.go @@ -59,6 +59,20 @@ func TestProviderSaveSocket(t *testing.T) { if info("relay").Socket != "auto" { t.Fatal("ticked in the editor, not saved auto") } + // KawaiiZapic on X: OpenAI's own API goes over the socket unset, so + // unticked there it is saved off, and ticked again unset + if err := provider.Save(provider.Provider{ID: "oai", Name: "OpenAI", Key: "sk-o", Responses: "https://api.openai.com/v1"}); err != nil { + t.Fatal(err) + } + oai := `{"id":"oai","from":"oai","name":"OpenAI","key":"","responses":"https://api.openai.com/v1","models":[],"headers":{}` + post(oai + `,"socket":"off"}`) + if info("oai").Socket != provider.SocketOff { + t.Fatal("unticked on OpenAI's API, not saved off") + } + post(oai + `,"socket":""}`) + if info("oai").Socket != "" { + t.Fatal("ticked again on OpenAI's API, not saved unset") + } post(`{"id":"chat","name":"Chat","key":"sk-c","chat":"https://chat.example/v1","icon":"generic","new":true}`) if info("chat").TakesSocket { t.Error("a provider without a Responses URL is offered the socket") diff --git a/internal/gui/tests/provider-socket.test.cjs b/internal/gui/tests/provider-socket.test.cjs index 1608d9983..afdafc896 100644 --- a/internal/gui/tests/provider-socket.test.cjs +++ b/internal/gui/tests/provider-socket.test.cjs @@ -4,7 +4,9 @@ // version", whose tick sends its Responses turns over the Responses // WebSocket. Ticked it saves auto; one set on from the CLI opens ticked // and keeps on; unticked it saves off. One without a Responses URL and a -// signed-in account show none, and their Save sends none. Every +// signed-in account show none, and their Save sends none. KawaiiZapic on +// X: OpenAI's own API goes over it unset, so its row opens ticked with +// Advanced shut, unticked saves off and ticked again saves unset. Every // language, wide and narrow. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); @@ -20,6 +22,7 @@ const base = { }; const relay = { ...base, id: "relay", name: "Relay Hub", responses: "https://relay.example/v1", takesSocket: true, socket: "" }; const kept = { ...base, id: "kept", name: "Kept Hub", responses: "https://kept.example/v1", takesSocket: true, socket: "on" }; +const oai = { ...base, id: "oai", name: "OpenAI Key", responses: "https://api.openai.com/v1", takesSocket: true, socket: "" }; const chat = { ...base, id: "chat", name: "Chat Hub", chat: "https://chat.example/v1", takesSocket: false }; const codex = { id: "codex", name: "Codex", icon: "codex-color", chat: "", responses: "", anthropic: "", catalog: "", @@ -29,7 +32,7 @@ const codex = { }; function serve(lang, posts) { - const providers = { providers: [relay, kept, chat, codex], presets: [], excluded: [], gateway: { running: true, window: true } }; + const providers = { providers: [relay, kept, oai, chat, codex], presets: [], excluded: [], gateway: { running: true, window: true } }; const state = { agents: [], profiles: [], settings: { lang, theme: "light" } }; return async (route) => { const url = new URL(route.request().url()); @@ -134,6 +137,28 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.deepEqual(errors, []); }); + test(`${engine} ${lang} ${width}: OpenAI's own API opens ticked, saves off unticked and unset ticked again`, async (t) => { + const { page, errors, posts, w } = await open(t, "OpenAI Key"); + assert.equal(await adv(page).evaluate((d) => d.open), false, "Advanced stays shut for a default"); + await unfold(page); + await box(page, w).scrollIntoViewIfNeeded(); + assert.equal(await box(page, w).isChecked(), true, "ticked by default"); + await box(page, w).uncheck(); + let saved = await save(page, posts, w); + assert.equal(saved.body.id, "oai"); + assert.equal(saved.body.socket, "off"); + await page.locator(".editor .bar").waitFor({ state: "detached" }); + await page.locator(".row.provider", { hasText: "OpenAI Key" }).click(); + await page.locator(".editor .bar").waitFor(); + await unfold(page); + await box(page, w).scrollIntoViewIfNeeded(); + await box(page, w).uncheck(); + await box(page, w).check(); + saved = await save(page, posts, w); + assert.equal(saved.body.socket, ""); + assert.deepEqual(errors, []); + }); + test(`${engine} ${lang} ${width}: a provider without a Responses URL and a sign-in have no row, nor send one`, async (t) => { { const { page, errors, posts, w } = await open(t, "Chat Hub"); diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f343795f8..475e67532 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -425,9 +425,10 @@ type Provider struct { // Discord): SocketAuto tries it and falls back to HTTP, and leaves the // host to HTTP for a while once it refuses the handshake, as // chatgpt.com is; SocketOn tries it every time and falls back without - // that. "", the default, is HTTP alone. Only a provider of a key with a - // Responses URL takes it (TakesSocket). Set with `magpie provider set - // socket=`. + // that; SocketOff is HTTP alone. "", the default, is auto on OpenAI's + // own API and HTTP alone elsewhere (SocketMode). Only a provider of a + // key with a Responses URL takes it (TakesSocket). Set with `magpie + // provider set socket=`. Socket string `json:"socket,omitempty"` // NativeCompaction has Codex's compaction_trigger go to the provider diff --git a/internal/provider/socket.go b/internal/provider/socket.go index eb0ede48c..c60f48c76 100644 --- a/internal/provider/socket.go +++ b/internal/provider/socket.go @@ -9,26 +9,61 @@ import ( // The ways a provider's Socket is set: SocketAuto tries the Responses // WebSocket and leaves a host that refuses its handshake to HTTP for a -// while; SocketOn tries it every turn. Off is "". +// while; SocketOn tries it every turn; SocketOff is HTTP alone, where +// the default would be the socket. "" is the default (SocketMode). const ( SocketAuto = "auto" SocketOn = "on" + SocketOff = "off" ) -// ParseSocket is the Socket v sets: auto, on, or "" for off (off, no, -// default or empty); ok is false for anything else. +// ParseSocket is the Socket v sets: auto, on, off (off, no or false), or +// "" for the default (default or empty); ok is false for anything else. func ParseSocket(v string) (string, bool) { switch strings.ToLower(strings.TrimSpace(v)) { case SocketAuto: return SocketAuto, true case SocketOn, "yes", "true": return SocketOn, true - case "", "off", "no", "false", "default": + case SocketOff, "no", "false": + return SocketOff, true + case "", "default": return "", true } return "", false } +// SocketMode is how p's Responses turns go: SocketAuto, SocketOn, or "" +// for HTTP alone. A Socket the user set is kept; unset, OpenAI's own API +// (an https Responses URL at api.openai.com) is auto, as Codex's built-in +// OpenAI provider speaks its WebSocket mode to it (supports_websockets in +// codex-rs's create_openai_provider). There a conversation's next turn +// goes as its new input after previous_response_id, even with store +// false, where HTTP sends the whole conversation every turn (KawaiiZapic +// on X). Any other address is HTTP alone unless set. +func (p Provider) SocketMode() string { + switch p.Socket { + case SocketOff: + return "" + case SocketAuto, SocketOn: + return p.Socket + } + if p.SocketByDefault() { + return SocketAuto + } + return "" +} + +// SocketByDefault says p's turns go over the Responses WebSocket with +// Socket unset (SocketMode). +func (p Provider) SocketByDefault() bool { + if !p.TakesSocket() || p.PluginProvider() != "" { + return false + } + u, err := url.Parse(strings.TrimSpace(p.Responses)) + return err == nil && u.Scheme == "https" && strings.EqualFold(u.Hostname(), "api.openai.com") +} + // TakesSocket says p can have its turns go over the Responses WebSocket // (Socket): a provider of a key with a Responses URL. A signed-in account // or a plugin's provider has its own way there. @@ -61,14 +96,15 @@ func withSocket(ctx context.Context, p Provider) context.Context { } func (p Provider) socketAt() (socketAt, bool) { - if p.Socket == "" || !p.TakesSocket() { + mode := p.SocketMode() + if mode == "" || !p.TakesSocket() { return socketAt{}, false } u, err := url.Parse(strings.TrimRight(strings.TrimSpace(p.Responses), "/")) if err != nil || u.Host == "" || (u.Scheme != "https" && u.Scheme != "http") { return socketAt{}, false } - return socketAt{host: u.Host, path: u.Path + "/responses", shun: p.Socket != SocketOn}, true + return socketAt{host: u.Host, path: u.Path + "/responses", shun: mode != SocketOn}, true } // SocketTurn says req is a Responses turn that may go over the Responses diff --git a/internal/provider/socket_test.go b/internal/provider/socket_test.go index 1952eae73..ef385ee74 100644 --- a/internal/provider/socket_test.go +++ b/internal/provider/socket_test.go @@ -54,9 +54,51 @@ func TestSocketTurn(t *testing.T) { } func TestSocketKeptAsSet(t *testing.T) { - for v, want := range map[string]string{"auto": "auto", " On ": "on", "off": "", "": "", "maybe": ""} { + for v, want := range map[string]string{"auto": "auto", " On ": "on", "off": "off", "no": "off", "": "", "default": "", "maybe": ""} { if got := normalize(Provider{ID: "x", Socket: v}).Socket; got != want { t.Errorf("%q kept as %q, want %q", v, got, want) } } } + +// KawaiiZapic on X: OpenAI's own API takes the Responses WebSocket, as +// Codex's built-in OpenAI provider speaks it, so with Socket unset its +// turns go there (auto); set off they don't, and any other host, a +// signed-in account or plain http stays HTTP alone unless set. +func TestSocketByDefaultOnOpenAI(t *testing.T) { + turn := func(p Provider, u string) (bool, bool) { + t.Helper() + req, err := http.NewRequestWithContext(p.Via(context.Background()), "POST", u, nil) + if err != nil { + t.Fatal(err) + } + return SocketTurn(req) + } + oai := Provider{ID: "openai", Key: "sk", Responses: "https://api.openai.com/v1"} + if got := oai.SocketMode(); got != SocketAuto { + t.Errorf("unset on api.openai.com: %q, want auto", got) + } + if ok, shun := turn(oai, "https://api.openai.com/v1/responses"); !ok || !shun { + t.Errorf("unset on api.openai.com: %v %v, want a turn that shuns", ok, shun) + } + off := oai + off.Socket = SocketOff + if ok, _ := turn(off, "https://api.openai.com/v1/responses"); ok || off.SocketMode() != "" { + t.Error("set off, OpenAI's turns went over the socket") + } + on := oai + on.Socket = SocketOn + if ok, shun := turn(on, "https://api.openai.com/v1/responses"); !ok || shun { + t.Errorf("set on: %v %v", ok, shun) + } + for _, p := range []Provider{ + {ID: "relay", Key: "k", Responses: "https://relay.example/v1"}, + {ID: "lookalike", Key: "k", Responses: "https://api.openai.com.example/v1"}, + {ID: "plain", Key: "k", Responses: "http://api.openai.com/v1"}, + {ID: "acct", Responses: "https://api.openai.com/v1", Account: &Account{}}, + } { + if p.SocketMode() != "" || p.SocketByDefault() { + t.Errorf("%s: %q by default, want HTTP alone", p.ID, p.SocketMode()) + } + } +}