Commit Graph
221 Commits
Author SHA1 Message Date
yetone ce1ecaa414 gateway: MaxRPM keeps a second's slack, so a first request's dial doesn't let the vendor see one over its minute
TestMaxRPMWaitsForRoomInTheMinute went red under CI load and b1396d23
reran it without a cause. The cause is real, not only in the test: a
request is counted when it starts to go, the vendor counts it when it
arrives, and the first on a new connection arrives later by its dial
and TLS handshake. With the bare 60s window, the limit+1-th request
could reach the vendor less than 60s after the first did.

- rpm.go: a counted request stays counted for rpmWindow + rpmSlack (1s),
  in prune and in reserve.
- rpm_test.go: minuteVendor can hold the first arrival (late); the two
  vendor-timing tests hold it 150ms with a window/6 slack and now ask
  that the vendor saw the gap of a whole window, not window-50ms.
  TestRPMReserveKeepsTheSlack checks the arithmetic. shortMinute zeroes
  the slack so the exact-minute tests are unchanged.
- docs/subsystems/gateway-routing.md: the Limits row says so.

Ran:
- With rpmSpan() returning the bare window: TestMaxRPMWaitsForRoomInTheMinute
  ("the vendor saw the third 1.346s after the first, inside the 1.5s window"),
  TestMaxRPMCountsRetriesAndCounts and TestRPMReserveKeepsTheSlack fail.
  With the slack all pass.
- go test -count=5 -run RPM ./internal/gateway; -race -count=3 -run RPM.
- go test -count=1 ./internal/gateway (581s, ok).
- gofmt -l clean; go vet on darwin, GOOS=linux, GOOS=windows for the package.
2026-10-11 02:25:05 +08:00
yetone 2305ab1fc6 gateway, netproxy: a web search goes through its searcher's proxy, not the direct line of the provider serving the turn (#1522, xixijay1988)
Claude Code on opencode-go (set to "direct"), with Codex as the search
delegate and the proxy on Auto (system proxy 127.0.0.1:7890): every
WebSearch dialed chatgpt.com directly, to the addresses a poisoned DNS
gave, and failed with "no answer in 2m0s". Codex's own requests through
the same gateway went through the proxy.

Cause: attempt() puts the turn provider's proxy choice on the request
context (Provider.Via -> netproxy.With). The search runs inside that
context, and its sub-request to Codex calls Provider.Via again, but
netproxy.With(ctx, "") returned ctx unchanged, so a provider that
follows the global proxy inherited the outer provider's "direct".

- netproxy.With: "" now replaces a choice ctx already names, so any
  request made for one provider while serving another (search delegate,
  vision describer, classifier, Codex titles, all through attempt's
  p.Via) takes its own provider's proxy or the global one.
- webSearch clears the turn's choice up front: the search APIs, which
  have no proxy of their own, follow the global one.
- kimiSearch now applies the Kimi Code plan's own proxy (p.Via); it
  had none and went the turn's way.

Verified:
- New TestSearchFollowsTheSearchersProxy: a fake CONNECT proxy on a free
  port; the turn's provider is reachable only directly, the searcher, a
  Kimi Code search service and a search API only through the proxy.
  Cases: Settings' proxy, Auto (from the environment), a searcher's own
  proxy with the global direct, a search API. On the old code it fails
  with "dial tcp search.test:443: ... (dialed directly)", CONNECTs [];
  with only the With fix the search API case fails; with the kimiSearch
  change reverted the Kimi case fails. -race -count=5 passes.
- TestWith in netproxy gains With(With(ctx, outer), "") follows the
  global proxy; fails on the old With.
- go test -tags nogui: gateway, netproxy, provider, plugin, update pass;
  the full ./... suite under load ~180 passed except
  internal/agent TestDshHomePickSurvivesSyncAndEffort, which passes alone
  (-count=3) and touches no proxy code (not this change; not yet filed).
  After rebasing onto 552c2244d (search MCP, also through webSearch) the
  search, Kimi and proxy tests pass again. gofmt -l clean; go build;
  GOOS=linux and GOOS=windows go vet -tags nogui on gateway and netproxy.
- docs/subsystems/gateway-routing.md: the one-try row says how a
  sub-request picks its proxy; the test is in its run list.
- Not tried against the reporter's real proxy and DNS.
2026-10-11 02:01:32 +08:00
yetone 552c2244dd gateway, gui: magpie's web search is an MCP server too (Kayphoon on Discord)
What: /mcp/magpie/web-search serves the gateway's existing web search
(webSearch: the searcher's model, a Kimi Code plan's service, the search
APIs, in the order Settings sets) as an MCP server with one web_search
tool, so Cursor, Claude Desktop (through mcp-remote) or any agent can
mount it. Streamable HTTP only: POSTed JSON-RPC messages and batches are
answered with JSON (initialize with version negotiation, ping, tools/list,
tools/call), notifications get 202, GET/DELETE 405. Legacy SSE isn't
served. Two segments under /mcp/, so it can't hide a signed-in server's
/mcp/{name}.

Guards: lanGuard as on every route (a gateway key from another machine,
only while shared; rebound browser hosts refused), plus a local/shared
backstop in the handler. Any web page Origin (localhost too) is refused
unless listed in Settings, as the MCP spec asks of a server. keyLimited
passes /mcp/ by, so each tools/call reserves the calling key's limit
(budget.Reserve) and a spent key gets a tool error with no search. The
search is marked CallFor{MCP: true}, and Routing says the agent called
magpie's web_search MCP tool. With nothing that can search, the tool error
says where to add a search API.

GUI: Settings > Models > Web search has an "MCP server" row with the
address (from the Settings page's gateway URL) and Copy, in en, zh, zh-TW,
ja, de. docs/subsystems/gateway-routing.md has a section on it.

Run:
- go test -tags nogui -timeout 40m ./... (all ok, at the first rebase),
  then gateway/gui package tests again after rebasing onto b1396d23.
- TestSearchMCP* (protocol, guards, key limit, Routing mark, no
  searcher). Break checks: dropping Reserve, the Origin check or MCP:true
  each turns its test red; dropping the handler's local/shared check does
  not, because lanGuard already refuses (it is a backstop).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...
- GUI, Chromium + WebKit: search-mcp (new, 5 languages, 520px), i18n-keys,
  gui-ja, gui-de, gui-zh-tw, search-first, search-api, searcher-pick,
  routing-side-calls. search-mcp caught the address falling back to 3425.
  search-mcp first held its row across Settings' redraws ("not attached
  to the DOM" 3 times in ~60 WebKit runs under load ~150); it now reads
  the row in one evaluate, and 3 full runs in both engines passed 60/60.
- Sandbox magpie (temp HOME, MAGPIE_ADDR 127.0.0.1:3512) with a fake
  SearXNG on 3513: the official MCP TypeScript SDK client 1.32.1 did
  initialize (2025-06-18), tools/list, tools/call and got the hit, as did
  mcp-remote 0.14.3 over stdio; curl: GET 405, localhost/foreign Origin
  403, rebound host 403, notification 202.
2026-10-11 01:55:34 +08:00
yetone 177fbdfe28 library, gui: the agents a skill is installed for have an All chip, one click takes them all off (#1531, liuweifeng)
Installing a skill from a repository starts with every agent lit, so
installing it for one agent alone meant unticking each of the others.
The picker now has the All chip the library's skill and server rows
already have (allChip): lit while every agent that can take it is lit,
a click takes them all off, another puts them all back. Only this one
is then All + that agent's chip, two clicks, with the same control as
the rows rather than a new idiom.

The same fix reaches every sibling picker that chooses agents before an
item is added: the market's skill install, the MCP server editor (add
and edit), pasting several servers, and the market's server install.
No new strings: All and its tooltips are already in every language.
The CSS sets All a little apart from the icons outside a row.
docs/subsystems/library.md says so.

Run:
- new internal/gui/tests/skill-install-agents-all.test.cjs: Chromium and
  WebKit, en/zh/zh-TW/ja/de at 1100px and 420px, with the reporter's
  repository: All lit at first, All -> none, Codex -> install posts
  agents ["codex"]; All puts every agent back; the server editor's All
  too. 28/28 pass; on the old library.js/css 0/28.
- the library's sibling GUI tests (by-agent, every-skill,
  group-skill-chips, library-*, market-have, market-featured-skill,
  pick-skills, project-servers, skill-install-skip,
  skill-name-many-agents, mcp-signin, import-all-skills) in both
  engines: all pass, except library-servers-bulk's known 2px flake
  (#1322), which fails the same way with this change reverted.
- screenshots of the picker in zh at 1100px and de at 420px.
No Go changed.
2026-10-11 01:45:47 +08:00
yetone b1396d2360 gateway, provider, gui: a routing group of decision models answers /v1/systemone, failing over between them (ARNO on Discord)
ARNO asked for decision models to get the group feature too: /v1/systemone
took only "<provider>/<model>" (xxx/jev-latest), so one refusing key or
vendor failed the call with nothing to fall back on.

A routing group may now be of decision models alone (provider.Group.Decides,
provider/decide_group.go). SaveGroup refuses one mixed with models that hold
a conversation, a decision group inside a chat group, and patterns, rules,
classifier, effort, levels, fast mode or a member effort on it. It is kept
out of the agents' catalog (groupEntries), and a chat request to it gets a
400 pointing at /v1/systemone.

POST /v1/systemone with "model":"group/<id>" (or the group's id or name, as
GroupFor reads them) goes to serveDecisionGroup (gateway/decide_group.go):
- the members' keys and accounts are planned with planGroup in the group's
  routing order, resting ones last; perKeyBarred no longer drops a
  decision-only provider's keys (it speaks no chat protocol), so each key
  is a try of its own;
- a gateway key's model and account limits and pause rules hold as for chat;
- a retryable failure that isn't the request's own (shape/prompt/protection)
  rests the candidate via restAfter and the next is asked; a transport error
  rests it as a 502; the last one's answer and Retry-After are passed on;
- every try is a Try of one route in the routing log; one usage row for the
  answer.
A group classifier naming a decision group fails over the same way
(askDecisionGroup; systemOne now returns decideRefused with the vendor's
status, headers and body, and postDecide returns the headers).

The GUI group editor offers a group of decision models only decision models
(groups.deciders), a chat group no decision model or decision group, a new
one both, and a decision model's row has no reasoning picker (groupJSON
.decides). The TUI member picker and `magpie group add` follow the same rule.
#1514's plugin_decide_test and TestMixedDecisionProvider now assert a mixed group is refused and a group
of decision models saves. Docs: reference.md (routing groups),
gateway-routing.md, provider-plugins.md.

Run:
- go test -tags nogui -timeout 40m . ./internal/provider ./internal/gateway
  ./internal/gui ./internal/tui: ok
- new: TestSystemOneDecisionGroupFailsOver (httptest System One fakes: a
  provider with two keys answering 429 and 503, then a second provider
  answering 200: tries ka1,ka2,kb, both failures rested and ask by name
  goes to kb first; all failing passes the last answer on; chat to the
  group is 400), TestDecisionGroupClassifierFailsOver, TestDecisionGroup,
  TestGroupAddDecisionModels, TestMemberOptionsDecisionGroup,
  group-decide-members.test.cjs (Chromium and WebKit, en and zh; no new
  strings)
- each broken by hand and seen red: no dispatch (404), no perKeyBarred
  change (ka2 skipped), no classifier failover, no rest, decision group in
  the catalog, CLI resolver, TUI and GUI picker filters
- GUI: group-*, routing-effort*, routing-levels, routing-save*,
  routing-intent-entry, routing-manual, i18n-keys in both engines: 169 pass
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on the
  touched packages
- after rebasing on bc2496dca, the five packages again: ok. The first run
  had TestMaxRPMWaitsForRoomInTheMinute red once under load; it passed
  -count=3 alone and in the rerun, and nothing here touches rpm.go.
Not tried against a real TypeSafe or Bailian account.
2026-10-11 01:37:18 +08:00
yetone bc2496dca8 gui, provider: the menu bar's "Account in use" moves as soon as another account answers, and a plugin's shows the one that answered last (#1516, ikxlpz)
f5c062677 made the menu bar's account-in-use card ("codex|*") follow the
account that answered through the gateway within the last hour. Two gaps
were left:

- The tray read its cards again only every few minutes, so after the
  gateway moved to another account, or the user switched, the menu bar
  kept the old account's numbers until the next tick. NoteServed now calls
  OnServedMoved when a provider's answers move to another account or key
  (and on the first one this process sees), and SwitchLogin calls it after
  a switch; the tray loop is woken by it, as by OnSubscriptionUsage.
- A plugin's accounts (moved Kiro, Devin, ...) are no sign-in InUseLogin
  knows, so with nothing served in the last hour the first card was shown
  even when the gateway had last gone to another. trayInUseCard now takes,
  after InUseLogin, the one that answered last at any age, before the first.

Run: TestTrayInUsePluginFollowsLastServed fails without the fallback
("plugin: ... User:k1@x.y"); TestServedMovedWakesTheMenuBar fails with
the hook's firing removed ("the first answer told nobody", "b@ answering
after a@ told nobody"); both pass now, with TestTrayInUse and
TestTrayInUseFollowsWhoAnswered. go test -tags nogui ./... (-timeout 40m)
passes; gofmt -l, go vet (gui with and without nogui), GOOS=linux and
GOOS=windows go vet -tags nogui on gui, provider, autostart pass. No GUI asset changed.
Not tried with the real menu bar and two real accounts.
2026-10-11 01:20:18 +08:00
yetone f0834b6f0d gui, sessions: a session magpie's gateway recorded downloads as Markdown instead of a 400 (akic404 on Discord)
akic404's public magpie serves other magpies as a remote magpie and records
their agents' conversations. The Sessions page showed them, but Download as
Markdown in magpie web answered 400 {"error":"no such session"}: the export
(GET /api/sessions/markdown, and the app's POST /api/sessions/export) only
looked for the agent's own session file, and an agent that ran on another
machine has none here. The transcript endpoint already fell back to the
gateway's record; the export didn't.

sessionMarkdown now takes the same fallback: no native session, but a known
gateway session for that agent and id, is written from GatewayTranscript by
the new sessions.WriteGatewayMarkdown. It shares WriteMarkdown's layout
(writeMarkdown), says "Recorded by: magpie's gateway" in place of the file,
and notes when older turns or the end of a long part weren't kept. It is not
the Host check or CSRF: the GET with the web cookie reached the handler.

Run:
- Sandbox upstream (magpie web --gateway, MAGPIE_WEB_KEY) with recorded pi
  and omp sessions reached through a downstream remote magpie: the old
  binary's /api/sessions/markdown gave 400 "no such session"; the new one
  gives 200 with the text, Content-Disposition
  magpie-session-pi-01a126b7-2a4.md; without the cookie still 401.
- TestGatewaySessionExportsMarkdown fails on the old sessionMarkdown with
  that 400 and passes now; TestSessionExportMarkdown, TestGatewayConversationAPI.
- go test ./internal/gui ./internal/sessions, gofmt -l, go vet for darwin,
  GOOS=linux and GOOS=windows on internal/gui and internal/sessions.
2026-10-11 01:13:52 +08:00
yetone 7a5536793e agent: Pi's and omp's turns are recorded by "Record gateway conversations", as OpenCode's are (akic404 on Discord)
akic404 runs a public magpie as the upstream and a local magpie that reaches
it as a remote magpie; with recording on, only OpenCode's conversations were
kept, on either side. The gateway records a turn only under the session the
client names (it never makes one up), and the configs magpie wrote for Pi and
omp didn't have them name one:

- Pi (1.1.0) sends x-session-affinity on Chat and Anthropic Messages only when
  the provider's compat says sendSessionAffinityHeaders (Responses sends
  session_id anyway). magpie's Pi provider block now sets it. A value the
  user set in that block is kept through a sync and a pick (piBlockKept, for
  pi, OmO and the aside's native Pi path).
- omp (18.6.1) sends its session header on Chat/Responses only to OpenAI
  itself, unless the provider's compat.promptCacheSessionHeader names one
  (pi-catalog 16.0.6+). magpie's omp provider entry now names
  x-session-affinity for omp 16.0.6 and later; an older or unknown version
  is left as it was.

withCaller already passes the session on to a remote magpie, so naming it
once is enough for both sides to record.

Run:
- Header dump (fake upstream LLM): real pi and omp with these provider
  blocks send x-session-affinity / session_id on every API; without them,
  nothing on Chat/Messages.
- End to end in sandbox HOMEs: an upstream (magpie web --gateway) and a
  downstream (serve, remote magpie to the upstream), both recording; the new
  binary wrote ~/.pi/agent/models.json and ~/.omp/agent/models.yml through
  `magpie pi …` / `magpie omp …`; real pi (Chat and Messages models) and real
  omp turns were recorded under gateway-conversations on both sides.
- TestPiNamesItsSessionToTheGateway and TestOmpNamesItsSessionToTheGateway
  fail on the old code (no compat; Compat field missing) and pass now.
- go test ./internal/agent (-timeout 40m), gofmt -l, go vet for darwin,
  GOOS=linux and GOOS=windows on internal/agent.
2026-10-11 01:13:52 +08:00
yetone 78b3f1f21a agent: an agent pointed at magpie on another machine keeps that address and key through a start's sync (coeo91 on Discord)
coeo91: after an update or a restart, the base URL in an agent's config
sometimes went from the LAN address back to 127.0.0.1.

Every start of magpie (and a provider added, a catalog fetched) runs
SyncCatalog, which runs each agent's Sync to bring magpie's models in
its files up to date. Each Sync writes magpie's whole provider block,
base URL and key included, from gateway.URL(), so a block the user had
pointed at a magpie on another machine (a NAS's, or this machine's LAN
address) went back to 127.0.0.1 with magpie's own key. Only ZCode
(zcodeAddress), WorkBuddy (buddyWriteAt) and Codex (#816) kept such an
address; in a sandbox HOME, 27 files of the other agents went back
(Qoder, OpenCode, Pi, Crush, Cline, Qwen Code, Kimi, Grok, Hermes, omp,
MiniMax, Snow, Hanako, VS Code, Copilot JetBrains, Goose, dsh, ...).

The fix is one place for all of them: SyncCatalog runs each Sync
through synced, which passes every file written through keptAway
(edit.Filtered, a filter on edit.WriteAtomic while it runs). In a file
without the gateway's own address, with an address on another machine
and none a WSL distro was seen at, a write that brings gateway.URL() in
place of that address keeps the address, and one that brings magpie's
own key (gateway.Token, TokenFor, the LAN key, "Bearer " too) in place
of another key keeps that key. An address on this machine's loopback
(another port, localhost) still follows the gateway, a WSL distro's
way to Windows is still magpie's to move, magpie's own files are never
filtered, and with two addresses or keys gone the write is left as it
is. A pick made in magpie still points the agent at this magpie.

Tests:
- TestSyncKeepsAnAddressOnAnotherMachine wires every agent in a sandbox
  HOME, points each file at 192.168.50.10 with a key of its own, adds a
  provider and runs SyncCatalog: no file is back on 127.0.0.1, the
  address and key are kept, and the new model is written. With
  SyncCatalog calling a.Sync() directly it fails on 27 files.
- TestKeptAwayOnlyWhatIsSure: old port, localhost, WSL and two-gone
  cases follow the gateway; a NAS beside a local Ollama is kept; Qwen
  Code's key written on its own is kept.
- TestKeyValuesFormats, TestFilteredWrites.

Run: gofmt -l (clean); GOOS=linux and GOOS=windows go vet -tags nogui
./internal/agent ./internal/edit; go test -tags nogui ./... in a temp HOME.
2026-10-11 00:59:45 +08:00
yetone a98ab77fde gui, gateway: a context window's part, cell or item clicked opens the text the request sent there (masaka)
masaka on Discord asked to see the whole context behind the context window
card: click the agent's prompt, or any other part, and read it.

What changed:
- gateway: the trace keeps the last 10 request bodies in memory only
  (promptBodies; at most 32 MiB each and 64 MiB together, oldest dropped
  first), masked as the vendor got them. For a model the user let have
  the request unmasked, the masked copy is kept all the same. Never
  written to disk, never in telemetry. Route.Prompt and the routing
  history keep names and sizes only, as before.
- gateway: Server.PromptText re-reads a part's items and their text from
  that body (prompt_text.go). promptBuilder gains a keep mode that records
  each item's pieces: system text, tool definitions laid out as JSON, each
  turn's user/thinking/assistant/call pieces, tool results, and images
  or sealed reasoning named with their size. Sizes are unchanged.
- gui: GET /api/context/text?id=&kind=[&item=] (no-store; 404 "not kept"
  when the body is gone or another process serves the gateway).
- gui: in the card, a legend part, a waffle cell or a content row
  (click, Enter or Space) opens a wide modal: one item alone with "All of
  {part}", or the part's list 100 rows at a time, each item's text
  fetched when it is opened and shown 20000 characters at a time, with
  copy buttons. Strings in zh, zh-TW, ja and de.
- docs: gateway-routing and gui-shell subsystem pages; the site's start
  page (en, zh, ja) says the text is kept for the last 10 requests in
  memory and sent nowhere. The README Privacy is unchanged, since nothing
  more is sent.

What was run:
- go test -tags nogui ./... (temp HOME). internal/gateway hit the 10m
  default under the full parallel run, in TestRequestTailAfterOldLimit,
  which takes 57s alone on the base commit too; the package run alone
  with -timeout 30m: ok (700s, the machine shared with other runs). Every other package: ok.
- New tests TestPromptTextIsWhatWasSent, ...KeepsOnlyTheLastBodies,
  ...ChatPieces, TestContextTextAPI. Broken by hand: keeping the unmasked
  body fails (the key shows), and dropping keepBody fails ("not kept").
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet on internal/gateway
  and internal/gui.
- GUI: tests/context-text.test.cjs in Chromium and WebKit, en/zh/zh-TW/
  ja/de, at 1100 and 420px: legend, row, cell and keyboard open the text,
  long text grows on demand, the page never scrolls, and a gone body is
  named. It fails with the click wiring removed. Under a load average of
  ~140 one case failed once: the test read the list while the dialog
  still said "Reading…". Reproduced with a 400ms reply, fixed by waiting
  for the list; the mock now always answers after 200ms. A second case
  ("a click doesn't move the page", 662 vs 605 on the contents row) came
  from taking the page's top while a wheel scroll was still easing: the
  test now wheels to the row like the other cases, and wheelTo waits for
  three equal looks. Four full runs at load ~150 then passed (80 cases). context-window,
  i18n-keys, held-animations and the modal tests (dialog-backdrop-drag,
  editor-short-window, readable-focus, ux-safety, whats-new, add-sheet,
  api-key-theme) pass in both engines.
- Real use: a sandbox magpie (own HOME, ports 3486/3487, the Codex login)
  served a real `claude -p` (Claude Code) request on codex/gpt-6-luna
  that read a file. In its web UI, Usage > Context: each of System
  prompt, Tools, Memory, Files and Conversation, a waffle cell and a
  contents row opened the request's real text (Claude Code's system
  prompt, 21 tool definitions, the CLAUDE.md reminder, main.go's Read
  result, the turn with its thinking and call). No page errors.
2026-10-11 00:49:01 +08:00
yetone 2c75d89827 agent: AstrBot is an agent magpie connects: its default chat model one of magpie's, its own providers kept (orange27 on Discord)
orange27 asked on Discord for AstrBot (AstrBotDevs/AstrBot) as an agent.

What changed:
- internal/agent/astrbot.go: a new agent for AstrBot's data/cmd_config.json
  under its root ($ASTRBOT_ROOT, else ~/.astrbot, the desktop app's, else
  ~/astrbot / ~/AstrBot when it holds an install).
  - Connecting adds one "magpie" entry to provider_sources
    (openai_chat_completion at the gateway, key magpie-astrbot) and one
    "magpie/<model>" entry per model of magpie's to provider.
  - It sets the default chat model:
    agent_runner.config.model.provider_id on 4.28+, or
    provider_settings.default_provider_id on older layouts.
  - Field types are taken from AstrBot's own defaults and validator: key is
    a list, timeout and max_context_tokens are ints, modalities lists
    text/image/tool_use, and custom_headers / custom_extra_body are objects.
  - The user's own sources and models are kept byte for byte. What they
    change in magpie's entries (timeout, proxy, enable) stays through a
    sync, and a sync with nothing new doesn't rewrite the file.
  - The UTF-8 BOM AstrBot writes is kept.
  - The first connect copies the file to cmd_config.json.before-magpie.
  - Disconnect takes magpie's entries out and puts back the pick it found,
    so the file comes back byte for byte.
  - A pick the user makes while connected is theirs and stands.
  - Without the file it says to start AstrBot once (or set ASTRBOT_ROOT).
    Without provider_sources (before 4.10) it says to update.
  - The notice says to restart AstrBot, before saving in its WebUI: it
    reads the file only at start-up and its WebUI writes the whole file
    back on save.
  - Docker installs aren't reached: their root is inside the container.
- agents.go, agentenv.go: registers it; ASTRBOT_ROOT joins the agent env.
- icons/astrbot.svg: AstrBot's logo, as a mask icon.
- applied_test.go, rewire_test.go: the every-agent tests seed AstrBot's
  settings, as they do Hanako's.
- docs/subsystems/agent-wiring.md, docs/reference.md: AstrBot's row.

What was run:
- go test -tags nogui ./internal/agent -run '^TestAstrBot'. The tests went
  red when, by hand, I dropped the BOM, rewrote the user's entries, left
  the pick unrestored, overwrote the user's own pick, made a no-op sync
  write, rewrote the backup on a switch, or broke the legacy layout.
- Real use:
  - AstrBot 4.28.2 installed with uv into a scratch venv (Python 3.12),
    run from an isolated root under a sandbox HOME.
  - A sandbox magpie (MAGPIE_ADDR 127.0.0.1:3617, ASTRBOT_ROOT set) with a
    fake OpenAI upstream on 3618 ran `magpie astrbot magpie/fake/echo-1`.
  - AstrBot restarted, logged "Selected openai_chat_completion(magpie/
    fake/echo-1) as default chat model provider", and answered a WebUI
    chat (/api/chat/send) with the upstream's reply.
  - usage.jsonl recorded the turn under agent "astrbot".
  - `magpie astrbot default` gave back the file AstrBot wrote,
    byte-identical, and AstrBot started clean on it.
- The icon rendered as a mask in Chromium and WebKit. No GUI strings were
  added: the notice is the agent's own English line, like the others'.
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent and
  internal/agentenv; go test -tags nogui ./... under a temp HOME (load
  ~170-240): every package passed but internal/gateway. That package
  doesn't import internal/agent. It timed out at 10m, then with -timeout
  30m failed TestQueuedStreamWaitedOutIsTheStreamsError (its 400ms idle
  read and the 100ms "the first has the slot" sleep; a delay injected
  before the first request reproduces it). internal/agent and
  internal/agentenv were rerun green after rebasing on origin/main.
2026-10-11 00:41:09 +08:00
yetone 9e823ad4cc provider, gui: a custom provider's model can be asked on Gemini alone, beside chat, Responses and Anthropic (Kayphoon on Discord)
Kayphoon: "供应商为自定义的时候 现在已经兼容 gemini 格式了 但是在下方 模型的详细
配比里面还是只能限定 chat 和 anthropic". A custom provider with a Gemini URL
(#1346) offered a model only the APIs among chat, responses and anthropic
it had a URL for, in the chip's "Asked on" menu and in Names & levels' API
row (modelAPIs). The server side refused it too: SetModelAPI and ModelAPI
took only provider.Protocols (chat, responses, anthropic), so Detect APIs →
Each picked model, which can stage gemini for a model that answered only
there, failed the Save with "a model's API is chat, responses or anthropic,
not "gemini"".

- provider: SetModelAPI and ModelAPI take gemini where the provider has a
  Gemini URL (modelAPI); the gateway's usable/APIs then send every client's
  request for that model to models/{model}:streamGenerateContent under the
  Gemini URL, translated from chat or Messages, a Gemini client's relayed.
  Native stays "" for such a model, so Pi/omp/droid ask on their own API
  and it is translated.
- gui: modelAPIs counts the Gemini URL, so both pickers offer Gemini.
  Responses was already offered when its URL is set; decide is never a
  model's API. The key protocol picker (per-key, not per-model) is unchanged.
- css: .mname .mapi has min-height, not a fixed 24px: on a phone the web
  GUI's 44px options hung out of the box over the reasoning levels (seen
  with three options on main too), and four wrap to a second row.
- docs/subsystems/gateway-routing.md says a model set to Gemini is
  translated to it. CLI and TUI have no per-model API setting; no new
  strings (Gemini and its hint were already translated).

Run:
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok.
- TestModelAPIGemini (new, httptest upstream with chat, Anthropic and
  Gemini routes): chat stream, chat JSON, Messages and a Gemini client's
  request for the gemini-picked model each hit only
  /v1beta/models/gm:streamGenerateContent?alt=sse with x-goog-api-key and
  the prompt in contents; the other model stays on chat. With modelAPI put
  back to Protocols it FAILs "Gemini picked for a model: a model's API is
  ... not "gemini""; with Save allowed but ModelAPI still refusing it,
  FAILs with chat/messages asked and 503 "no available channel".
- TestModelAPI also checks gemini without a Gemini URL and "decide" are
  refused.
- gofmt -l: nothing. go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  on internal/provider, internal/gateway, internal/gui: clean.
- GUI: model-api-gemini.test.cjs (new), Chromium and WebKit, en, zh,
  zh-TW, ja, de, at 900px and 360px: 20/20. With modelAPIs put back, 20/20
  fail; with the fixed 24px height, the ten 360px runs fail. Whole GUI
  suite, both engines, concurrency 6: 5150/5196. Every failing file rerun
  alone: model-copy-id, agent-models-redraw, library-servers-bulk,
  number-units, sessions-*, usage-* pass alone (load). mobile-web,
  old-webkit (Safari 15.0), plugin-moved-signin and routing-context-fold,
  routing-group-fold, routing-keys-fold (WebKit) fail alone on origin/main
  1b8cb53e as well, with the same counts or more; none touches the model
  API row.
- Not tried against a real Gemini relay; the upstream path is the one
  TestCustomGeminiUpstream already covers.
2026-10-11 00:33:18 +08:00
yetone 472b36cec5 gui: the Usage page's short cards stack beside a tall one, packed into columns in the user's order (#860, huoranxuanyuan)
huoranxuanyuan's screenshots (1569px window at 175%, about 897px CSS):
a tall Codex card shared a grid row with Antigravity and a DeepSeek
balance, and both short cards stretched to Codex's height, mostly empty.
They asked for Antigravity and DeepSeek to stack beside Codex.

What changed
- packUsage (app.js) packs #subscriptionUsage into columns on 1px grid
  rows. Each card takes the leftmost column that ends highest and is as
  tall as itself; the cards' 7px gap stays.
  - The DOM order is unchanged and is still settings.usageOrder, so
    dragging, Alt+arrows and screen readers work as before.
  - Column count: the most 260px columns that fit, or one fewer when
    that leaves much less empty room (<0.6x) for a page at most 1.3x
    taller. It is chosen again only when the cards change or the width
    fits another number of columns. A card that grows or shrinks (a fold,
    "Every model") is only re-packed, so the card clicked stays where it
    was, even when the view's scrollbar appears and takes 10px of width.
    Keying the choice on the pixel width moved a card turned to every
    model in WebKit, which quota-families caught.
  - A ResizeObserver on the list and each card re-packs on the next
    frame. A hidden view falls back to the plain grid.
- fitQuotas is split into fitQuota(g), so heights are measured with each
  meter box laid out for the width being tried.
- The tray panel's Allowances list is a single column with no row
  stretching, so it needs no change.
- docs/subsystems/gui-shell.md describes the packing.

Tests
- New usage-pack.test.cjs, with fixtures of the reporter's cards:
  - Codex with a 7-day window, credit resets and a curve; Antigravity by
    family; a DeepSeek balance with its trend.
  - At 897, 1018 and 1400px: Antigravity beside Codex at its top,
    DeepSeek under it with the 7px gap, order kept, no overlap, no card
    taller than its content.
  - Equal cards: one row in order at 1300px, one column at 480px.
  - Opening a brief Codex account grows that card in place, with no
    scroll.
  - Runs in Chromium and WebKit, in en/zh/ja/de. It goes red when
    packUsage returns early (checked by hand).
- usage-accounts-fold: "Show fewer" now holds the card's head where it
  was, as usage-keys-fold already does for keys. Its old assertions
  expected the page to shrink to its end, which packing no longer does.
- usage-fold: scrolls to each fold button before clicking it, since
  Codex is now packed under ZCode, past the 300px-tall window.

Run
- usage-*.test.cjs, quota-families and click-scroll in both engines:
  all pass except usage-heatmap, which fails the same way alone on
  origin/main 497656174.
- Full GUI suite at concurrency 6, under machine load ~170: 5125 pass,
  56 subtests fail.
  - Run alone, these pass in this tree and on origin/main:
    account-arrange, agent-models-redraw, agent-stale-copies,
    agent-update-all, factory-key, group-from-model-add,
    library-servers-bulk, proto-menu-overflow, routing-mode-goes,
    routing-served, sessions-overview, tray-cell-click, update-wait,
    usage-ledger, usage-refresh.
  - These fail the same alone on origin/main: mobile-web, old-webkit,
    plugin-moved-signin, routing-context-fold, routing-group-fold,
    usage-heatmap.
  - quota-families was red only in this tree. That was the width-keyed
    choice above, now fixed and green in both engines.
- No Go change.
2026-10-11 00:30:14 +08:00
yetoneandFourLeafTec 4b2f2ec31e provider, plugin: a plugin can serve System One for its provider, and the models it marks are a routing group's classifier (#1514, FourLeafTec)
A plugin had no way to say its provider answers TypeSafe's System One,
so a free decision model a plugin reaches (mu-zi-lee/magpie-our-free-model)
could only be listed as a chat model.

Now the plugin's config hook sets `decide: true` on the provider, and
`decides: true` on a model, in the config hook or on the models hook's
list. host.js passes both through (plugin.Provider.Decide,
plugin.Model.Decides). pluginProvider sets the provider's Decide to its
own base, plugin://<id>/v1, so System One is asked at {baseURL}/systemone
through the loader's fetch with the account's sign-in: pluginFetch sends
nowhere but the loader's host, so an address the plugin named itself
couldn't be reached. AskSystemOne now sends with Provider.Do, as the
gateway's classifier already did, so the editor's test goes through the
fetch too (Do is client.Do for every provider without an account).

decide.go treats a plugin provider's decision models as the ones it marks
plus Jev's by name (jev-*): kept from agents, refused for chat ("only
decides"), refused as a group member, offered as a group's classifier
(Deciders, DecisionModels, Jev). A mark without `decide` on the provider
changes nothing. Docs: site plugins page (en, zh, ja) and
docs/subsystems/provider-plugins.md.

Thanks to FourLeafTec, whose reference commit (bc0b3fee in their fork)
proposed the two fields and the plugin base; this is written afresh.

Run:
- internal/gateway TestPluginServesSystemOne and
  TestPluginMarksWithoutDecide, through the real bun plugin host with the
  fake plugin (FAKE_DECIDE). Red with host.js, plugins.go and decide.go
  reverted ("Decide = \"\""), with only host.js reverted, and with only
  decide.go reverted (no classifiers, offered to agents, chat to one 200).
- go test -tags nogui ./... (temp HOME): every package ok; internal/gateway
  hit the 10m default at load ~140 in TestLargeRequestEndpoints, then
  passed alone with -timeout 40m (548s).
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on
  internal/plugin, internal/provider, internal/gateway.
- Real use: a nogui build in a sandbox HOME on 127.0.0.1:3612, a local
  plugin declaring decide with judge-x marked, a fake vendor on 3613.
  `magpie group rule add ... classifier=dec1514/judge-x` saved; judge-x
  was not in /v1/models and not accepted as a member; a turn to the group
  asked /v1/systemone judge-x (levels, then intent) with the plugin's key
  and its fetch's own header, then went to chat-b; chat to judge-x
  answered 400 "only decides".
- No GUI change: a plugin's editor is the account editor, which has no
  address fields.

Co-authored-by: FourLeafTec <5875432+FourLeafTec@users.noreply.github.com>
2026-10-11 00:24:08 +08:00
yetone e9221e96dd provider, netproxy, gui: allowances can be read only when asked, and a system proxy set after start is taken within seconds (#1518, RooobinYe)
The reporter starts magpie at login with the proxy on "follow system
proxy". magpie comes up before the proxy app. With no system proxy set
yet, netproxy.For gives none, so magpie's own allowance reads went out
direct, from the user's real IP. That reading was then kept for up to
15s. A system proxy that is set but not listening fails the request
("proxyconnect ... connection refused"); it never falls back to direct.

Proxy freshness:
- netproxy.System re-reads a "none" reading after 2s (noneKeep) instead
  of 15s (systemKeep, unchanged for a set proxy).
- The plugin host looks again every 2s while it has no proxy
  (proxyLookNone), so a host started before the proxy app takes it soon.
- Catalog sync, the update check, plugin updates and token refresh all go
  through netproxy.Func / Dispatch, so they use the current proxy too.

Settings -> Allowances -> "Allowance reads": Automatic (default, as
before) or When I ask (settings.QuotaReads = "asked",
POST /api/settings/quota-reads):
- These count as asking (provider.Asked): the Usage page opened or
  refreshed (?asked=1), a card's refresh (RefreshUsage), magpie quota,
  magpie accounts, magpie quota wait and the TUI's quotas.
- Every other read (quotaReading -> holdUnasked) carries netproxy.Hold.
  netproxy.Func, Dispatch's choice proxies and the plugin host's calls
  refuse a held request before it leaves.
- The readers return the last reading, dated (AsOf), or "not read yet".
  That covers routing's Allowances / AwaitAllowance, the used-up switch,
  the menu bar, alerts, Quotas/KeyBalances/PlanQuotas, Codex/Claude/
  Cursor/Grok/Kiro usage and KeyAllowance.
- An account refused for its quota (StaleAllowance) or a key refused
  (StaleKeyAllowance) is still read, once.
- Warm-up and check-in are unchanged.
- Strings are added in zh, zh-TW, ja and de. The docs are updated:
  providers-accounts (Allowance row), provider-plugins (host proxy).

Run:
- go test -tags nogui ./... (sandbox HOME), gofmt -l, and go vet -tags
  nogui on GOOS=linux/windows/darwin for ., netproxy, plugin, settings,
  provider, gui and tui.
- New tests, each seen red by breaking the change by hand:
  - TestSystemProxySetAfterStartIsTakenSoon and TestHeldRequestNeverLeaves
    (netproxy).
  - TestHostWithNoProxyLooksAgainSoon (plugin; red with 15s).
  - TestAllowancesReadOnlyWhenAsked (red without the hold and without
    markStaleRead), TestAllowancesReadByThemselvesByDefault and
    TestKeyReadsOnlyWhenAsked (red without holdUnasked and without
    unheld for a refused key).
- GUI quota-reads.test.cjs in Chromium and WebKit, at 900 and 360px, in
  en/zh/zh-TW/ja/de.
- i18n-keys, gui-ja, gui-de, settings-sections, settings-groups,
  currency, number-units and tray-bird.
2026-10-11 00:20:25 +08:00
yetone 0a11b18301 gui: the tray panel's Allowances tab lists a balance where the Usage page's order puts it, not after every plan (#1510, JokerQyou)
The panel sorted its subscriptions by settings.UsageOrder like the Usage
page, then pulled every balance-only card (DeepSeek and the like) into one
"Balances" group appended after all the plan groups. With the reporter's
order Codex, DeepSeek, Copilot the panel showed Codex, Copilot, then
DeepSeek, while the Usage page and the panel's own Arrange list showed the
set order.

renderPanelQuota now builds its sections in order: a vendor's accounts at
its first card, and a run of balances where it falls. Balances next to
each other still share one Balances grid (panelBalances, the old block
moved into a function unchanged). The TUI lists in magpie's own order and
never read usageOrder; it is unchanged. The menu bar cells keep their own
picked order (TrayUsages).

Run:
- panel-balance-order.test.cjs (new): the reporter's quotas and order
  (Gemini CLI, Kimi hidden), and a balance first plus two balances side by
  side; checks the panel's groups in order, the Usage page's order, a
  Balances group holds only balances, nothing runs off at 380px. Red on
  the old app.js (Codex, Copilot, DeepSeek), 16/16 green now in Chromium
  and WebKit, en/zh/ja/de. No new strings.
- every panel-*, quota-*, tray-*, usage-*, account-arrange and
  routing-quota GUI test, both engines.
- HOME=<tmp> go test -tags nogui ./...
- screenshot of the reporter's case in zh at 440px: Codex, 余额 DeepSeek,
  Copilot.
2026-10-10 23:08:49 +08:00
yetoneandggbdpq 89271cd4e8 provider, plugin, settings: accounts left all zero by a crash are read from their last good copy, and every state file is flushed before it is renamed in (#1505, Zhangwier)
Zhangwier's Windows machine went down hard, and logins.json (10783 bytes)
and plugin-auth.json (29926 bytes) came back at full length with every byte
0x00. Every account was gone. The rename had reached the disk before the
data. magpie then read "no accounts", and its next write would have made
that final.

What changed:
- Flushed before rename: steady.WriteFile writes a temp file, fsyncs it,
  then renames it in. A failed write or flush removes the temp file and
  leaves the old file as it was. edit.WriteAtomic, Kiro's writer, the
  Codex session rewrite and the plugin host's writeDurable (host.js)
  flush the same way. So do writePrivate (providers, logins, migrations),
  settings, profiles, plugins.json, plugin-auth.json and mcp-signins.json.
- A last good generation: before each write, lastgood.Keep keeps the
  valid file there as <file>.bak. A file that isn't valid is copied aside
  as <file>.bad-<time>, with -2, -3 when two land in one second (O_EXCL),
  and is never overwritten before that copy exists. The .bak lags one
  write behind on purpose, since a crash zeroes the latest write.
- A failed read is unknown, never empty. On a cold start, logins.json,
  providers.json, migrations.json, settings.json, profiles.json,
  plugins.json, plugin-auth.json (Go and the host) and mcp-signins.json
  are read from their .bak when they don't read. The recovery is logged
  and listed in /api/state's recovered, and the window says it once in
  every language. With no good .bak, a sign-out leaves plugin-auth.json
  and mcp-signins.json as they are (the host's changeAuth no longer
  writes {} over them). magpie's own sign-out returns the error, and a
  sign-in copies the bad file aside before writing.
- caller-keys.json is flushed but never read from a .bak. A key revoked
  in the last write would come back, so a store that doesn't read still
  refuses every key, as its tests require.

ggbdpq's patch (f230bcae) is where the fsync-before-rename in
writePrivate, writeWhole and writeAuth came from. This change puts it in
one shared helper and reaches every other writer of magpie's state. The
JS write cleans up its temp file. The .bak recovery, the .bad copies and
the GUI notice are added here.

What was run:
- New tests, built from the literal case (10783 and 29926 zero bytes):
  - internal/lastgood
  - provider: TestZeroedLogins*, TestZeroedMigrations*,
    TestZeroedProviders*, TestWritePrivateSyncsBeforeRename
  - plugin: TestZeroedPluginAuth* against the real bun host,
    TestPluginAuthSyncedBeforeRename with a plugin that makes fsync fail,
    TestZeroedPluginList*
  - TestZeroedSettings*, TestZeroedProfiles*, TestZeroedMCPSignIns*
  - steady TestWriteFileSyncsBeforeRename, edit
    TestWriteAtomicSyncsBeforeRename
  - gui recovered-file.test.cjs (en/zh/zh-TW/ja/de, Chromium and WebKit)
- Broken by hand, each going red:
  - Without the sync: the steady, edit, writePrivate and host fsync tests.
  - Without the .bak fallback: every TestZeroed* test.
  - The old changeAuth writes "{}\n" over the zeros.
  - The old readLogins default.
  - KeepBad without suffixes fails the one-second test.
  - Without recoveredOnce, the GUI test fails 5/5.
- macOS: go test -tags nogui ./... in a sandbox HOME. The only failures
  were the two access tests (then fixed by not recovering caller keys) and
  TestProvidersCmdSaysUnreadable, which now removes the .bak to test the
  no-backup case. Both packages were rerun and pass. gofmt -l prints
  nothing. go vet, and GOOS=linux and GOOS=windows go vet -tags nogui, are
  clean on the touched packages.
- GUI: recovered-file, whats-new, click-scroll, gui-de, gui-ja,
  gui-zh-tw and i18n-keys pass.
- Windows box (cross-compiled test exes, sandboxed USERPROFILE/APPDATA):
  lastgood, steady, provider, plugin (real bun host), settings, mcpauth,
  edit and access pass. In profile, TestProfileSwitchesModelList and
  TestOldProfileKeepsModelList fail the same on origin/main (filed as
  #1517).

Reported-by: Zhangwier
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-10 22:54:09 +08:00
yetone f5c0626770 tray, usage: the menu bar's account in use is the one that answered last, and the Usage page's cards are told when each did (okingkee on X)
okingkee on X: three Codex accounts, the menu bar set to follow the account
in use. A used its allowance up and the gateway went on to B, but the menu
bar stayed on A; changing the first account moved it, the gateway moving
on did not. trayInUseCard asked InUseLogin, which reckons from the account
the agent is signed in to, and that lags the gateway (and under Smart it
picks any account).

- provider: SubscriptionQuota gains lastServedAt, set by Quotas
  (cardsServed) from served.json the way /v1/magpie/quotas already was,
  on this computer's own cards only and on copies, the caches untouched.
  withServed's matching moved into servedBy.at, shared by both.
  This also makes the Usage page and tray panel's "show the account that
  answered last in full" (ae6b4c93) work: it read q.lastServedAt, which the
  window's API never sent, so it always showed the first.
- tray: a "<provider>|*" card takes the provider's account that answered
  within the last hour (trayServedFresh), else InUseLogin's as before.

Run:
- TestTrayInUseFollowsWhoAnswered (A at 100% answered 40 min ago, B 1 min
  ago → B; both stale → InUseLogin's A; one account → it) fails with the
  served pick disabled and passes; TestCardsLastServed (subscription by
  user, balance with no user, a remote card left alone, inputs unwritten)
  passes; TestTrayInUse and TestQuotasLastServed unchanged and pass.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... pass.
- go test ./... passes except internal/gateway, which hit the 10m default
  timeout under this machine's load; run alone with -timeout 20m it passes
  (726s). No JS changed, so no GUI test run.
2026-10-10 22:45:01 +08:00
yetone f1fc8c65d3 gateway: Codex's auto-review reaches a model when its config names a group bare or Codex is on magpie through another provider table, instead of 404 "magpie knows no model codex-auto-review" (Adam on Discord)
Codex asks for its approval review on codex-auto-review whenever its model
list has that name or a model's entry names it as auto_review_model_override
(as a ChatGPT account's entries do). magpie stood that in with
config.toml's `model` (agent.StandIn, e31384b1), but only:
- when the top-level model_provider is "magpie": a Codex reaching magpie
  through another table pointed at it (CC Switch's "custom", the thread
  tables magpie writes), a profile, its own CODEX_HOME or another computer
  got no stand-in at all;
- and the stand-in went straight to provider.Resolve, so a config naming a
  routing group bare (its id or name, or Codex's spelling of a group's
  model, #750), which the conversation's own turns reach through GroupFor,
  was a 404 for the review.
Nothing in v0.1.1158..1163 changed this path; these cases were never
covered.

What changed:
- serve: the stand-in is taken through GroupFor and AutoStandIn, as a name
  asked for is (also for Claude Code's tier stand-ins, the same shape).
- codexMemoryStandIn also takes Codex's auto-review (x-openai-subagent
  guardian, or the name codex-auto-review): one that still names no served
  model goes to the model Codex's last turn was answered on (per agent and
  gateway key, else the ledger), as Codex itself reviews on the
  conversation's model. Before any turn it is still a 404; any other
  unknown name still is.
- docs/subsystems/gateway-routing.md says so.
Every Codex route (/v1/responses, /v1/chat/completions, compaction on
/v1/responses) resolves in serve, the one place this runs.

What was run:
- Real Codex CLI 0.162.0 (codex exec, approvals_reviewer=auto_review,
  approval_policy=on-request, a catalog entry with
  auto_review_model_override=codex-auto-review) against a sandbox
  `magpie serve` (temp HOME, port 3591) with a fake chat upstream that asks
  for an escalated exec_command:
  - origin/main: model_provider=magpie + model="my-group" or "Mine" (a
    group), and model_provider="custom" pointed at magpie: Codex printed
    "Automatic approval review failed: unexpected status 404 Not Found:
    magpie knows no model \"codex-auto-review\"", Adam's text; the ledger
    has the guardian calls 404.
  - this build: all three, and model_provider=magpie + fake/m1: guardian
    calls 200 on fake/m1, the command ran.
- TestCodexAutoReviewReachesItsTurnsModel: with gateway.go reverted it
  fails ("my-group: the review 200 ... upstream m1", went to the last turn,
  not the group's m2); with codex_memory.go reverted it fails ("the review
  after a turn: 404 magpie knows no model \"codex-auto-review\"").
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/gateway; go test -tags nogui ./... under a temp HOME with the
  Go caches pinned.
2026-10-10 21:38:51 +08:00
yetone 8211ac0113 provider: a WorkBuddy check-in answered 401 says why, the WorkBuddy app's or sign in again, not "Unauthorized, magpie tries again later" (モモコ on Discord)
モモコ (v0.1.1159, a WorkBuddy Free account, 积分 0 / 1,500 reading
fine) saw 「签到失败,magpie 稍后重试 · Unauthorized」 all day; signing in
again didn't help. "Unauthorized" is Go's text for a bare 401:
copilot.tencent.com's gateway (APISIX) answers a token it refuses with an
HTML page, no {code,msg}, so wbCallVia gave accountStatusError{401}, and
the check-in was "failed", tried again every 30 minutes.

What changed: on a 401 from checkin-activity-status or daily-checkin,
wbCheckin reads the account's credits (/billing/meter/get-user-resource-
summary) with the same headers, through the same fetch (the built-in's,
or the plugin's for a moved account).
- They read: the sign-in is good and the check-in alone refuses magpie.
  WorkBuddy 5.5.6 sends its check-in calls, and only those, with
  X-Device-Token from its TuringShield SDK (buildHeadersWithTuringToken),
  which magpie can't make. Saved as own-app, settled for the Beijing day;
  the card says "WorkBuddy only gives check-in credits to its own app;
  check in in the WorkBuddy app", WorkBuddy's 401 in the tooltip.
- They don't: the sign-in itself is refused; failed with "WorkBuddy
  refused this account's sign-in (401 Unauthorized); sign in to it again".
The CLI and TUI named no vendor on an own-app line for WorkBuddy
(By ""); they say WorkBuddy now.

What was checked against the real service (the owner's WorkBuddy China
account, a sandbox HOME, nothing live written): the status and claim
answer 200 to both the built-in's and the plugin's headers (the claim
went through, +100), with or without User-Agent, X-User-Id, X-Domain or
a wrong X-Domain; only a refused token gave 401, and its bytes are the
test fixture. So モモコ's 401 isn't wrong headers, host or User-Agent.
With her credits reading on the same token, the check-in's device token
is the one difference left; that part is inferred, not reproduced: the
owner's account claims without it. magpie accounts checkin in a sandbox
HOME with the plugin's desktop sign-in given a bogus token printed
"WorkBuddy refused this account's sign-in (401 Unauthorized); sign in to
it again" from the real gateway.

Run: TestWorkBuddyCheckinUnauthorized (status 401 and claim 401 with
credits reading → own-app, not asked again past wbCheckinRetry; all 401
→ failed, sign in again, asked again) and
TestWorkBuddyCheckinUnauthorizedThroughPlugin fail on the old code
(Outcome failed, Msg Unauthorized) and pass; -race passes.
TestCheckinOnTheUsageLine covers the TUI's WorkBuddy own-app line.
go test -tags nogui ./internal/provider ./internal/tui . pass; gofmt -l,
GOOS=linux and GOOS=windows go vet -tags nogui pass. The plugin has no
check-in code (magpie's runs through its fetch), so no plugin release.
docs/subsystems/provider-plugins.md says it.
2026-10-10 20:51:30 +08:00
yetone b6a263b9fd gateway, usage: the Usage page's numbers are read over the gateway, and a Claude Code subagent's call says which subagent and which started it (HoGee_xxl on X)
HoGee_xxl wants their own usage app to read magpie over the gateway,
which had no /api/usage counterpart, and asked for subagents' parent ids.

- GET /v1/magpie/usage (the /api/usage summary, ?period=) and
  GET /v1/magpie/usage/requests (the /api/usage/requests ledger page, same
  filters, offset/limit) on the gateway. The builders moved out of gui into
  internal/usageapi so both serve the same JSON; gui keeps aliases and sets
  usageapi.Clients for agent names (gateway can't import agent). Guard as
  /v1/magpie/quotas: this machine, or another with an enabled gateway key,
  behind the same Host check. A key held to a budget, models or accounts is
  refused the summary (403) and gets the ledger filtered to its own
  CallerKey, with callerKeys/agents/providers/accounts cut to its own rows
  (usageapi.OwnPage): those facets are drawn from every call in the period.
  `path` is left out for another machine.
- usage.Record gains subagent and parent_agent; session stays the parent
  conversation. Gateway rows take them from x-claude-code-agent-id and
  x-claude-code-parent-agent-id; session-file rows from the file name
  (<session>/subagents[/workflows/<run>]/agent-<id>.jsonl, no cache version
  bump) and the parentAgentId of the agent-<id>.meta.json beside it. Both
  packed into the request page's text columns (now 29, msg at 29).
  Codex sub-threads: only kind, as before; no spawned thread on disk to
  take a parent shape from.

Run: real Claude Code 2.1.296 under a sandbox CLAUDE_CONFIG_DIR against a
local fake Anthropic endpoint that made it spawn a subagent from a
subagent: the nested request carried X-Claude-Code-Agent-Id=a143287ac46b82a96
and X-Claude-Code-Parent-Agent-Id=a99ca20c03d1813d8, the first-level one
the agent id only, Session-Id the parent's throughout; the nested meta.json
had parentAgentId. Tests use those bytes. TestUsageOverGateway goes red
with OwnPage, the CallerKey pin, or the header read removed (each tried).
gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; set -o pipefail; go test ./... green.
2026-10-10 20:47:00 +08:00
yetone 5fb75d26cf agents: WorkBuddy AI, the international build, gets magpie's models in its own ~/.workbuddy-ai/models.json (#1494, ysicing)
WorkBuddy AI (www.workbuddy.ai, bundle com.workbuddy.workbuddy-ai) keeps
its data in ~/.workbuddy-ai: its cli/product.json sets dataFolderName
".workbuddy-ai", and the custom-models reader (getUserConfigPath in
5.6.2's app.asar) takes ~/<dataFolderName>/models.json when
WORKBUDDY_CONFIG_DIR isn't set. magpie only wrote ~/.workbuddy/models.json,
the China build's, so the reporter's WorkBuddy AI never listed magpie's
models although magpie said it was wired.

WorkBuddy AI is now its own agent, workbuddy-ai, built from the same code
as WorkBuddy (workbuddyBuild): its models.json in ~/.workbuddy-ai, a bare
list as WorkBuddy writes one, under its own key (magpie-workbuddy-ai).
WORKBUDDY_CONFIG_DIR stays WorkBuddy's, so the two rows never write one
file. Its MCP servers and skills go to its own folder too (library target),
and the library's "trust it in WorkBuddy" note names WorkBuddy AI when a
server is given to it. README agent lists and docs/reference.md list it.

Run: go test -tags nogui ./internal/agent ./internal/library
./internal/usage ./internal/gateway (sandbox HOME); new
TestWorkBuddyAIWritesItsOwnFolder (writes ~/.workbuddy-ai only, China
file untouched, env var ignored); GUI library-workbuddy-trust in Chromium
and WebKit, en/zh/zh-TW/ja/de, red on the old library.js for the
WorkBuddy AI case. A built magpie in a sandbox HOME lists "WorkBuddy AI
~/.workbuddy-ai/models.json", and `magpie workbuddy-ai provider magpie`
wrote deepseek/deepseek-chat there with key magpie-workbuddy-ai and no
~/.workbuddy. Not tried in the WorkBuddy AI app itself (needs a signed-in
account); the path is read from the installed 5.6.2's own code. gofmt -l,
GOOS=linux/windows go vet clean.
2026-10-10 19:55:29 +08:00
yetone 69c47c9e57 library, gui: the Library page is drawn at once from a glance, and the agents' own skills and out-of-date copies come in after it (#541)
Even with the memo, the first read after skills change still reads
them through, and before this the page showed only its outline until
the whole read was done (0day404, #541: minutes on Windows).

library.Glance (GET /api/library?glance=1) is the view without
FoundSkills and the skills' Behind, marked partial. The page asks for it
first, draws it, then asks for the whole read. The Skills tab shows "In
your agents · Looking through the agents' skill folders…" (aria-busy)
until the whole read comes. The other tabs aren't drawn again for it. A
whole read that a change answered first is dropped (take() counts the
answers), so it never draws an older library over a newer one.

Read now runs behind and foundSkills after letting go of the library
lock, so a change doesn't wait on them either.

New strings in zh, zh-TW, ja and de. docs/subsystems/library.md
describes the memo and the glance.

Tests:
- TestGlanceLeavesOutTheAgentsSkills (Go).
- library-loading.test.cjs: drawn from the glance, the wait row, then
  the found skill, with reads glance then read. Chromium and WebKit, 980
  and 420px. Red on the old library.js.

Run: go test -tags nogui ./internal/library ./internal/gui; node --test
for library-*.test.cjs, skill*.test.cjs, gui-ja, gui-de and i18n-keys in
both engines; gofmt; vet on darwin, linux and windows.
2026-10-10 19:53:02 +08:00
yetone d67a482908 provider: a Trae CN claim answered 9074 is final for the day and says to check in in the Trae CN app (#808)
When /status says the check-in is on and today's isn't in, and /claim
answers 9074 「当前参与用户太多,请稍后再试」, the check-in is now saved
with a new outcome, own-app, instead of failed. Like every answer other
than failed it settles the Beijing day: the loop doesn't claim again
after the 30-minute retry, and Check in now isn't offered (a press
wouldn't claim either). The next day is asked as before.

Why: Trae CN pays check-in credits only to a device registered through
its own device-register service and security SDK. The plugin's device id
isn't, so 9074 is permanent for it; across ~5 days on #808 no retry ever
succeeded, and repeated claims from an unknown device may read as abuse.

What the user sees, in en/zh/zh-TW/ja/de: the Usage card's check-in row
and the Settings "Daily check-in" line say "Trae CN only gives check-in
credits to its own app; check in in the Trae CN app" (zh: Trae CN 只给自己的
客户端发签到积分,请在 Trae CN App 里签到), with Trae's own message in the
tooltip. The TUI and `magpie accounts checkin` say the same.

Unchanged: 9074 on /status (before any claim) and every other code keep
their handling; WorkBuddy, MiniMax, Qoder and plugin check-ins untouched.
docs/subsystems/provider-plugins.md describes it.

Run:
- TestTraeCheckin9074IsOwnAppOnly with trae_checkin.go at HEAD fails:
  "same day, soon=false, asked again after 9074: [POST /status POST
  /claim]"; with the change it passes.
- usage-checkin.test.cjs new case on old app.js fails (row said "Check-in
  failed; magpie tries again later · 当前参与用户太多…"); with the change all
  28 pass in Chromium and WebKit, en and zh. plugin-checkin 16/16,
  i18n-keys, gui-ja, gui-de, gui-zh-tw pass.
- go test -tags nogui ./internal/provider ./internal/gui ./internal/tui .
  under a sandbox HOME: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on the
  touched packages: clean.
- Not tried against a real Trae CN account (none here); the 9074 bytes
  are the reporter's from #808.
2026-10-10 19:50:16 +08:00
yetone 3d7acfb40f routing: the mode chip leads to where the routing is set, and a lone key names none
xczzhh on X: "这个路由策略能自己选吗,我的一直是smart,也改不了好像". The
Routing page's hub chip and the Accounts and keys heading said Smart for
every provider, even one with a single key on, where there is nothing to
route, and nothing on the page said where it changes.

Now, where routing can be changed (a group, or a provider listed in
/api/groups' pools: two or more accounts or keys on), the chip and the
heading are .rt-go controls (goTo/goRouting): a click or Enter brings the
group's card or the provider's row under Several accounts or keys into
view via scrollOnPurpose, marks it (rt-found, off under reduced motion)
and focuses its routing picker. A provider with one on names no routing,
and the mode paragraph says to turn on a second in the provider's editor
(LONE, in zh, zh-TW, ja and de). The header is drawn again when the
groups arrive (headOf).

routing-weight-chip's fixture now lists its two-key relay in pools, as
/api/groups does.

Run: routing-mode-goes.test.cjs 40/40 (chromium+webkit, en/zh/zh-TW/ja/de,
1100px and 420px); all 20 chromium cases fail on the old routing.js. All
routing-*, quota-pool*, rate-limited-sink, panel-routing, click-scroll,
view-scrollbar-drag and i18n-keys tests pass (group-fold, keys-fold,
flood and context-fold failed only under a 6-way parallel full run and
pass alone, as on main). go test -tags nogui ./internal/gui ok.
2026-10-10 19:49:14 +08:00
yetone e70e7ed46a routing: a routing group is made from a template in one click, of the user's own models: hard turns to the strongest and easy ones to a cheap one, cheap first, or never stuck
Making a group took the whole editor (owner, 10-10). Three templates are
made from the models the user has (provider.Templates, grouptemplate.go):

- smart (smart-split): an ordered group of the strongest model and a cheap
  one; a classifier sends a hard turn to the strong one and an easy turn or
  a compaction to the cheap one, images to a model that sees them. The
  classifier is the decision API when there is one, else the cheapest
  priced model that doesn't reason.
- thrifty (cheap-first): two cheap models of different providers, then the
  strongest, which also takes high reasoning.
- steady (never-stuck): the strongest model of up to three providers, each
  failing over to the next.

A model weighs by its maker's list price, else its provider's, else by its
id's size words; one over $100 a million output tokens is never picked. A
template that can't be made says what is missing. AddTemplate saves it
under a name and id no group has (freeGroupName, now shared with
CopyGroup), never over one.

GUI: before the user has a group of their own, the Routing page shows the
templates as cards (models, Add, Edit first); after, a Templates menu by
New group. CLI: `magpie group template [kind] [name]`, no args to list.
Pricing goes through priceOf with the served entry's provider, so
/api/groups pays ~75ms for templates on 203 models, not ~600ms.

Run, at this head rebased on origin/main 4e584faa: go test ./... green;
gofmt -l clean; go vet on darwin, GOOS=linux -tags nogui and GOOS=windows.
GUI: group-template.test.cjs and group-duplicate.test.cjs (Chromium and
WebKit, 5 languages, 420px) 30/30, the template test 3 runs in a row; it
skips WebKit's "ResizeObserver loop" notice as two other tests do. The
group-*/routing-* GUI tests ran before the rebase: 628/635, the 7 being
WebKit flights in routing-group-fold and routing-keys-fold, one Chromium
routing-proxy, and the ResizeObserver notice above; run alone at this head,
routing-proxy passes and the two fold files pass twice on WebKit, as on
origin/main. Real data in a sandbox HOME: `magpie web` on 3561, the
Templates menu added smart-split as GPT-6.1 Sol → GPT-6 Luna with 3 rules.
No real request was routed through the new group.
2026-10-10 19:46:58 +08:00
yetone ac79966a6d agent, gateway: Claude Code knows a relay's claude-opus-4.6 as Opus 4.6, not the retired Opus 4 (misteer_ti.)
Claude Code 2.1.296 parses a Claude model id whose version has a dot
(relay/claude-opus-4.6-us[1m], as many relays name them) as Claude Opus
4: it warns the model is retired, asks with max_tokens 32000 and offers
no effort. The same id with dashes (relay/claude-opus-4-6-us) is Opus
4.6 to it: max_tokens 64000, adaptive thinking, effort.

What changed:
- provider/claudedash.go: ClaudeDashed (a Claude-family version's dots
  to dashes; other vendors' ids untouched), ClaudeSpelled (dashed only
  when that spelling comes back to exactly this served id), and
  ClaudeUndashed/ClaudeRead (a dashed spelling back to the one served
  id; an id served as spelled always wins, two ids dashing alike are
  neither; :level and [1m] kept). ClaudeRead also knows a switched-off
  provider's models, so Reseat still moves Claude Code off one
  (TestReseatOff went red without it: opus read "", not
  cop/claude-sonnet-4.5).
- agent/claude.go: every model magpie writes into Claude Code's
  settings is spelled so: model, the ANTHROPIC_DEFAULT_*_MODEL tiers,
  ANTHROPIC_SMALL_FAST_MODEL, CLAUDE_CODE_SUBAGENT_MODEL, modelPicker.
  Every read of them (env, claudeMain, claudeStandInAt) takes the
  spelling back, so fields, applied state and Drift keep the dotted id.
  The user's own values are stashed and given back raw. A Sync rewrites
  what an older magpie wrote dotted. claudeName, the capabilities env
  and the compact-window lookup see the dashed spelling.
- agent/t3code.go and gateway/desktop.go (claudeLooking): T3 Code's
  Claude slugs and Claude Desktop's Code-tab ids without efforts are
  spelled dashed too. Desktop entries with efforts still use the mythos
  alias, which Claude Code doesn't misparse.
- gateway.go: validateModel and unprefixed take the dashed spelling
  back to the served dotted id, before key limits, middleware and
  usage see it.
- docs/subsystems agent-wiring and gateway-routing say so.

What was run:
- New tests: TestClaudeDashedIDsReachTheDottedModel (gateway),
  TestClaudeDottedVersionsGoInDashed, TestClaudeDottedServedDashedToo
  (agent), TestClaudeDashedOnlyClaudeVersions, TestUndashInExactWins,
  TestClaudeSplitKeepsEffortAndMark (provider).
- Break-it checks:
  - With ClaudeSpelled/ClaudeUndashed made identity:
    TestClaudeDottedVersionsGoInDashed fails ("the main model and its
    followers": model relay/claude-opus-4.6-us).
    TestClaudeDashedIDsReachTheDottedModel fails (sent
    "claude-opus-4-6-us", want "claude-opus-4.6-us").
  - With ClaudeRead alone made identity, the agent test fails at
    "read back" (model:relay/claude-opus-4-6-us).
- Real use: the installed claude 2.1.296 in a sandbox HOME and
  CLAUDE_CONFIG_DIR, against an in-process gateway on a free port and
  a fake Anthropic upstream. The settings.json was written by
  agent.Find("claude").Apply("model", "relay/claude-opus-4.6-us").
  - Dashed (magpie's write): the upstream got model claude-opus-4.6-us,
    max_tokens 64000, thinking adaptive, effort high. Claude Code
    reported canonicalModel claude-opus-4-6, maxOutputTokens 64000.
  - The same config with the dotted id by hand: max_tokens 32000,
    canonicalModel claude-opus-4-0.
- Full go test -tags nogui ./... (TestReseatOff red on the first
  run, fixed as above; agent, provider, gateway and main rerun green),
  gofmt -l, go vet, and GOOS=linux and
  GOOS=windows go vet -tags nogui on the touched packages.
2026-10-10 19:44:26 +08:00
yetone c112d2a448 gateway: the Claude subscription answers when magpie runs as root (FrierenF)
Run as root (a server, a Docker container), every Claude subscription
request failed with "Claude Code: exited before it answered magpie's
initialize request (exit status 1): --dangerously-skip-permissions cannot
be used with root/sudo privileges for security reasons".

Claude Code 2.1.296's setup refuses bypassPermissions/
--dangerously-skip-permissions when process.getuid() === 0, IS_SANDBOX is
not "1" and CLAUDE_CODE_BUBBLEWRAP is unset (read from the installed
binary; --permission-mode bypassPermissions is refused the same way). The
bridge's run has no tool of Claude Code's own that touches the machine,
only magpie's MCP tools, answered by the client, and Anthropic's web
search, so the bridge run as root is now given IS_SANDBOX=1
(claudeCLI.asRoot). Its args are unchanged, and a run as anyone else has
its env exactly as before. A WSL distro whose default user is root is the
same case: the WSL probe now prints `id -u` (wslrun.Tool.Root), and
IS_SANDBOX goes into the distro (WSLENV) only then. The warm-up and /usage
runs don't pass the flag and are untouched.

Run:
- Docker node:22-bookworm-slim as root, @anthropic-ai/claude-code@2.1.296,
  fake API: the bridge's exact argv refuses with the message above without
  IS_SANDBOX, and with IS_SANDBOX=1 answers from the fake API
  (permissionMode bypassPermissions).
- The gateway's serveClaudeSubscription as root in that container (linux
  test binary, real claude, no credentials): before, 502 "Claude Code
  ended without an answer"; after, it gets past the check to Claude
  Code's own "Not logged in".
- TestClaudeRunsAsRoot (a fake that refuses as root does) goes red with
  asRoot removed from the launch; TestClaudeAsRootEnv; TestParseProbe.
- go test -tags nogui ./internal/gateway ./internal/wslrun ./internal/agent,
  gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows). WSL root path is
  unit-tested only, not tried on the Windows box.
2026-10-10 19:39:19 +08:00
wei 8f7d6ecd41 gateway: Vertex AI's minimal refused is read by geminiRefusedLevel, the same pattern #1062 added for Gemini's OpenAI-compatible API, rather than a copy of it
Rebased onto main by yetone: #1117 replaced geminiMinimalRefused with
geminiRefusedLevel(body), so the check is geminiRefusedLevel(b) != "",
as the PR description proposed.
2026-10-10 19:21:57 +08:00
wei 0a706873fa cli, tui: magpie provider add google-vertex project=… adds Google Vertex AI, its location, credentials file and service account set as pairs
* magpie provider add google-vertex project=<id> adds it. location=,
    credentials= and impersonate= set the rest, on add or on set, and an
    empty value clears one (location= is global again). A relative
    credentials path is made full from where the command runs, since
    the gateway reads it from nowhere in particular.
  * A key is refused, given on add or with provider key, with the pairs
    to use instead. So is an address (url=, chat=, openai=, responses=,
    anthropic=, decide=), which would be dropped without a word, and
    region= or plan=, which point to location=. A pair of Vertex AI's on
    another provider is refused.
  * magpie providers and the TUI's list say "● Google credentials", with
    "as <service account>", where a key would be, and "○ needs a
    project" for one without (providers.json edited by hand). magpie
    provider <id> lists project, location, signs with and as, and how to
    set a missing project. magpie presets gives the add command with
    project=.
  * The TUI's a asks for the project and adds it there; e and w say which
    pairs change its credentials, and its project and location.

Verified: the CLI's and the TUI's Vertex tests (add, set, clear, the
refusals, a provider with no project); live, in a sandboxed HOME, add,
set location= and its clearing, credentials= and impersonate=, and
provider test at each location.
2026-10-10 19:21:56 +08:00
wei 5a27b924e2 providers, gateway: Google Vertex AI is a preset, Gemini in the user's own Google Cloud project, signed with their Google credentials rather than a key
Gemini on Vertex AI was reachable only through a proxy of the user's own
in front of Vertex AI's OpenAI-compatible endpoint, added as a custom
provider. The Google Vertex AI preset (google-vertex) asks Vertex AI
itself.

  * The provider holds a project, a location (global when none is given;
    us, eu or a region), an optional credentials file and an optional
    service account to go as (provider.Vertex). It has no key and no
    URL: Save refuses a key, normalize clears a key and the four URLs
    kept by hand, and its one address is
    https://<host>/v1/projects/<project>/locations/<location>, the host
    following the location (vertexHost). It is ready when it has a
    project, never for a key or an account, and an import link can't add
    it.
  * Each request is signed with a Google token (Sign), and the token goes
    to no other address. The credentials are found as Google's libraries
    find Application Default Credentials: the provider's file, else
    GOOGLE_APPLICATION_CREDENTIALS's, else gcloud's
    application_default_credentials.json. A GOOGLE_APPLICATION_CREDENTIALS
    that isn't a full path is an error, not unset, since gcloud's file
    read in its place may be another account's. authorized_user,
    service_account and gcloud's impersonated_service_account are read;
    external_account and another universe are refused by name. With a
    service account set, the token is traded at IAM Credentials'
    generateAccessToken for one of that account's, as gcloud's
    --impersonate-service-account does. Tokens are kept in memory per
    file and account, minted once for requests made together, again 5
    minutes before they expire or when the file changes (gcloud signed
    in again). A mint is given 30 seconds; one that fails fails the
    requests that waited through it too, and a request given up on
    stops waiting. A sign-in Google refuses says the command that makes
    that file again: gcloud's for its own files, impersonating as it
    did.
  * The gateway speaks Gemini to it alone. A Gemini client's request is
    relayed as it came, its thinkingConfig, safetySettings and schema
    with it: streamed to
    publishers/google/models/<model>:streamGenerateContent?alt=sse, or
    asked whole to :generateContent. Every other API's is translated
    (buildVertex), streamed, and read back with thoughts as reasoning,
    never as the answer. The path names a model by its upstream name
    when one is set, as the usage log's endpoint does. Gemini 3 is sent a thinkingLevel fitted to the
    model's levels, 2.5 a thinkingBudget in the model's range, off
    included (Pro's least, as Pro can't stop). A call's thought
    signature goes to the client in its id and comes back on the call;
    a 400 "Invalid thought signature." is asked again with every call
    waved through, for that request, and a 400 refusing minimal is asked
    again at the model's lowest level, kept until restart. Neither is
    tried for another provider.
  * Vertex AI has no list of the models a location serves, so each
    location has the ones it answered with on 2026-10-06: 12 at global,
    6 Flash at us and eu, the 2.5 trio at a region.
  * The preset offers Priority PayGo's and Flex PayGo's request headers
    (HeaderHints). GOOGLE_APPLICATION_CREDENTIALS and CLOUDSDK_CONFIG are
    in agentenv.Vars, so the desktop app takes them from the login shell
    and the tests clear them.

Not read: the metadata server of Compute Engine, Cloud Run and GKE;
workload identity federation; Vertex AI's express-mode API keys. No
quota project is sent.

Reference: docs/subsystems/providers-accounts.md (Google Vertex AI,
Vertex AI tokens, four constraints) and gateway-routing.md (Vertex AI).

Verified: go test ./... (nogui), -race -count=5 on the Vertex tests,
gofmt and vet. A fake Google (token endpoint, IAM Credentials, Vertex
AI) checks each credentials type, the mint shared, bounded and
re-minted, every refusal's advice and that no token reaches another
host. Each of 24 mutations made after review, of the mint, the key
rules, the advice, the upstream path and the retries, fails a test.
Live, against a real project through an impersonated service account,
with magpie in a sandboxed HOME: Chat, Anthropic Messages, Responses and
Gemini clients, streamed and whole, with thinking and with tool calls, a
whole Gemini call and its signature sent back streamed, at global, us
and us-central1, and with Flex PayGo's header. No token was found in its
files or logs afterwards.
2026-10-10 19:21:56 +08:00
yetone 4e584faa51 agent: a Codex the user disconnected stays disconnected through restarts and updates (paynezhuang)
paynezhuang on Discord: magpie's first start pointed Codex at the gateway
by itself; they switched Codex on, chose "Disconnect from magpie", and after
each update and restart config.toml had openai_base_url again.

Cause: Codex's Sync runs at every start (SyncCatalog) and calls failover(),
which writes openai_base_url whenever Codex is signed in to ChatGPT and
another of the user's ChatGPT accounts is on in magpie. Nothing told it the
user had taken magpie out. The same Sync's #701 branch (sign-in "magpie
API" on one of Codex's own models) wired a disconnected Codex again too, and
with magpie API Disconnect itself left failover's base URL behind (its own
model Set ran failover).

Fix: Disconnect marks the agent disconnected in the stash
(<id>.disconnected) before it writes anything; connect() and an Apply that
leaves the agent wired take the mark out. Codex's failover treats a marked
Codex as having no other account on (and takes out a base URL it owns), and
the #701 re-wire skips it. Failover for a Codex never disconnected, and a
base URL written by hand (#856), are as before.

Siblings: TestDisconnectStaysThroughSync connects and disconnects every
non-WSL agent with fields, then runs SyncCatalog and dsh's KeepDshWired
round twice: none is wired again and no file outside magpie's own changes.
It passes on the old code too (only Codex had the problem); it guards the
class. Cursor, Copilot CLI and Devin can't be connected in the sandbox and
skip; Native (Aside) and Launch agents don't Sync wiring.

Run:
- TestCodexDisconnectStaysWithAccountsOn (ChatGPT and magpie API) and
  TestCodexAPIDisconnectStays fail on the old code ("start 0 after
  Disconnect wired Codex again", "disconnect left magpie in") and pass now.
- go test -tags nogui ./internal/agent ./internal/gui . (sandbox HOME): ok
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/agent: clean
- Real magpie (nogui build, `magpie web --gateway`) under a scratchpad
  HOME, gateway 127.0.0.1:3481, web 3482, fake ChatGPT auth.json plus a
  second ChatGPT login on: old build re-wrote openai_base_url 2s after a
  restart following Disconnect. New build: first run wires (failover),
  connect, disconnect, restart as 0.1.99998, then start as 0.1.99999
  (last-version moved): config.toml byte-identical to after Disconnect,
  no failover; connecting again wires it and a restart keeps it.
2026-10-10 19:17:53 +08:00
yetone a5114d931f agent: Claude Desktop from its MSIX isn't said to be off magpie when the package's copy is emptied, and Reconnect puts its gateway back (dumplings)
dumplings (Windows, Desktop 2.31226.0 from the MSIX) saw "Claude Desktop
已不经过 magpie:配置已变更" while Desktop ran on magpie, and Reconnect
didn't clear it; switching Desktop's provider off magpie and back did.
Two causes:

- Check went over both sets of folders magpie writes for a packaged
  Desktop (the package's LocalCache and the real ones, as which build
  is installed can't be told) and failed when either was off magpie.
  2.31226 reads the real %LOCALAPPDATA%\Claude-3p (bg5eau, already in
  desktopdir), so the package's copy, emptied, isn't Desktop off
  magpie. desktopRead now judges only the set whose Claude-3p Desktop
  ran in last ("Local State", desktopdir.LastRun), every set when it
  ran in none, as before.
- Reapply on an unwired drift re-set the field drift shows on and
  fields on magpie's models. Desktop's drift shows on a tier (sonnet,
  on a magpie model), and its provider field ("magpie") isn't a model,
  so the gateway was never written back. Reapply now also re-sets a
  field whose value is magpie itself, as Wired already counts it.

The reporter's analysis said 2.31226's AppxManifest excludes
Claude-3p from virtualization; that manifest wasn't seen here (the
Windows box has no MSIX Desktop), the fix rests on Desktop reading the
real Claude-3p, which bg5eau's case showed.

Run: TestClaudeDesktopMSIXChecksTheFoldersDesktopRuns (MSIX layout:
package Roaming\Claude and Local\Claude-3p with an older Local State,
the real Claude-3p newer); red with Check over every set, and red
with Reapply without the magpie-valued field. go test -tags nogui for
internal/agent, internal/desktopdir, internal/gui, internal/library;
the agent package's TestClaudeDesktop* built for windows/amd64 and run
on the Windows box, all pass; gofmt -l; go vet -tags nogui on darwin,
GOOS=linux and GOOS=windows for internal/agent, internal/desktopdir.
2026-10-10 19:01:11 +08:00
yetone 66f920e3a3 provider: a Claude account whose user picked every model is served Haiku 5.5 once models.dev lists it, beside the picks (wakaka)
9b51428e put Haiku 5.5 in the Claude account's list (Available), but
agents are served the user's picks (Exposed) when there are any. A user
who had picked every model (Select all, or the TUI's toggles) kept the
list as it was then. The owner's providers.json holds exactly that: all
16 Claude models up to Sonnet 5.5, not Haiku 5.5, which never reached
an agent; wakaka's file wasn't seen, so this is the likely cause there.

Save now keeps, beside new picks, the models listed when they were made
(PickedFrom); the same picks saved again keep it. withNewlyListed serves
a model listed since first beside picks that held every model listed
then; one listed then and left unpicked stays out, and picks that left
any out take nothing new. Picks saved before PickedFrom existed count as
"every model" when they hold every one released up to the newest of
them (models.dev's release_date), which is the owner's saved state. The
editor (providerJSON.Chosen) and the TUI start from Picks, so a later
Save keeps the new model picked rather than dropping it.

Run: TestClaudePicksOfEveryModelTakeOnesListedSince with the reporter's
16 picks and models.dev's Haiku 5.5 row (red with Exposed using the
picks alone); go test -tags nogui ./... under a temp HOME, all ok;
gofmt -l; go vet -tags nogui on darwin, GOOS=linux and GOOS=windows for
internal/provider, internal/gui, internal/tui.
2026-10-10 19:01:10 +08:00
yetone 53cce81664 gateway: Codex hears an event of its reply within its idle timeout while magpie holds its tries, instead of reconnecting on "idle timeout waiting for SSE" (fadenoob on Discord)
Codex counts only SSE events toward its stream idle timeout (300s by
default), not the ": keepalive" comments magpie sends while it holds a
try. Each try was bounded by itself (holdLead, 4 minutes since
1a5d7908), and a group's replan pauses (c43681d6) come between tries,
so held tries and pauses could add up past 300s with no event, and
Codex dropped the stream and reconnected. Reproduced against Codex's
own behaviour with a fake that sends only comments: the same error.

keptAlive now keeps the time of the request's start or its last event
(told) and whether the agent streams. For a streaming Responses agent,
once agentQuietMost (4 minutes) has passed with no event, the try in
hand is let through (scan, keepQuiet), and a replan or same-one retry
whose pause would end past the bound isn't taken, so the agent gets
the reply or the error in time.

Run: TestCodexHeardWithinItsIdleTimeout (agentQuietMost scaled to 1s;
a slow second member after a failed first: first event in ~1.0s,
bound 1.6s, old code 2.2s, red; every member overloaded with a 2s
replan pause: error reaches the agent in ~1.2s). Passed 3 times.
go test -tags nogui ./internal/gateway ./internal/provider ok; gofmt
-l clean; GOOS=linux and GOOS=windows go vet -tags nogui on both.
docs/subsystems/gateway-routing.md says the bound.
2026-10-10 18:54:16 +08:00
yetone cb406c8425 plugins: a plugin can add an agent magpie has no setup of its own for
Plugins could be subscription providers or gateway middleware. Now a third
kind: an agent plugin, so a user whose agent magpie doesn't ship can still
put it on magpie.

- internal/agentplug: a plugin's magpie.agent module (or a *.agent.js file)
  exports agent = {id, name, config, format?, model, prefix?, bin?, dir?,
  ua?, icon?, notice?} and an optional connect({gateway, model, models,
  agent}) returning the other keys to write. Compiled in moejs, reloaded
  when plugins.json or the file changes; why one didn't load is kept.
- internal/jsmod: module compiling (imports kept inside the plugin), moved
  out of middleware so both share it.
- internal/agent/plugged.go: each becomes an Agent (Plugin set) after
  magpie's own. JSON, YAML and env files are edited key by key, comments
  kept; what each key held is stashed typed under plugin:<id>:<path>, and
  its own model or Disconnect puts every key back. A built-in id is
  refused; a connect that throws writes nothing. Key magpie-<id>; usage
  names it by key or ua (usage.PluginAgents).
- GUI Plugins page: an Agent kind chip and glyph, a Discover "Agents"
  section (market kind "agent"), and an installed row line "Adds X to
  Agents" or why it didn't load. zh, zh-TW, ja, de strings.
- Docs: site Plugins page (en, zh, ja) "Agent plugins", reference.md,
  agent-wiring.md, gateway-middleware.md.

Run:
- go test ./... (all ok); gofmt -l clean; GOOS=linux go vet -tags nogui
  ./... and GOOS=windows go vet ./... clean.
- TestPluggedYAML, TestPluggedJSONUnwire, TestPluggedRefused.
- GUI: plugin-agent.test.cjs 22/22 (en, zh, zh-TW, ja, de; 980 and 420;
  chromium and webkit); all plugin-*.test.cjs, i18n-keys,
  deprecated-subscriptions, filter-ime: 315 pass, 0 fail.
- Real use, in a sandbox HOME: an Aider plugin (~/.aider.conf.yml, prefix
  openai/, connect writes openai-api-base/key) installed in a dev build;
  picking DeepSeek V4.1 Flash on the Agents page wired the file keeping the
  user's comment and keys; real aider 0.86.2 `--message` answered through
  magpie from the real DeepSeek account; usage.jsonl recorded agent aider,
  provider deepseek, 200; Disconnect restored the file byte for byte.
2026-10-10 18:39:47 +08:00
yetone 61aa681e60 library: an MCP server, or the servers picked, are copied as an agent's project file has them, to paste into a project magpie doesn't keep (#1478, xiaozhu1337)
A project's MCP servers could only be given by adding the project to
magpie first. For a one-off (add them, then let the project keep them),
that is a detour. Now the servers page's Select bar, and a server's
editor, have Copy config…: a menu of the agents that read a project's
servers from a file (Claude Code .mcp.json, Codex .codex/config.toml,
Gemini, Cursor, OpenCode, ZCode, Pi), each with its file. A pick puts
that file's text on the clipboard and the status says where to paste it.

What changed:
- library.ConfigOfServers(agent, names): the servers written by the same
  code a project of magpie's is written with (mcpFile.put, through() for
  one magpie is signed in to, the agent's own variable syntax) into a
  fresh file in a temp folder, read back and removed. Nothing in the
  user's files is written. A server the agent can't take there (SSE for
  Codex or Pi, a ${VAR} it can't read) is left out and named, as a
  project's sync leaves it out.
- POST /api/library/mcp/config answers {file, text, skipped}.
- library.js: copyConfigButton in the pick bar and the editor's bar;
  strings in zh, zh-TW, ja, de.
- docs/subsystems/library.md says so.

Run:
- TestConfigOfServersIsTheProjectFile: for every agent in
  projectMCPFiles, the copied text equals byte for byte the file magpie
  writes into a fresh project with the same servers, the servers left out
  are those supports() refuses, a signed-in server is the gateway's
  /mcp/<name>; with through() taken out it fails.
- library-mcp-copy-config.test.cjs in Chromium and WebKit, en/zh/ja/de at
  440px: the menu's agents and files, the post, the clipboard text, the
  left-out status, nothing copied when nothing fits, the editor's button;
  no sideways scroll. The library and project GUI tests that draw the
  pick bar or the editor (18 files) pass in both engines.
- go test -tags nogui ./internal/library/ ./internal/gui/ under a temp
  HOME; gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui.
- Not clicked in a running magpie window; the page against a faked API
  and the library code under a sandbox HOME only.
2026-10-10 18:35:17 +08:00
NorethSea 9ca4b9ec28 gateway: provider search can be Off in Settings, so a model's web search goes to the Search APIs alone (#1483, NorethSea)
Settings › Search gets an Off choice beside Automatic and the providers.
With it, no provider is asked to search for another model (no ChatGPT or
Claude account's allowance spent, no Kimi Code search service, no Google
sign-in's separate search), and the saved Search APIs are asked in their
order; one failing never falls back to a provider. With Off and no ready
Search API, magpie offers no search tool of its own. A provider's native
search on the client's own protocol is unchanged.

NorethSea's change (from their fork, feature/search-provider-off,
68fe54ff), cherry-picked onto main. On review one sibling was missing:
ownSearcher and webSearchOf (what this magpie's model list tells another
magpie about searching) still treated a Kimi Code plan or Google sign-in
as searching for its models with Off. Both now go through searchesOwn,
the one check canSearchFor uses, so with Off a remote magpie is told
there is no search instead of adding a tool that has nothing behind it.

Run: go test -tags nogui ./internal/gateway ./internal/gui
./internal/settings (sandbox HOME); TestSearchProviderOffTellsRemoteMagpie
goes red with webSearchOf's old check put back; searcher-pick, gui-ja,
gui-de, gui-zh-tw .test.cjs pass in Chromium and WebKit.

Co-authored-by: NorethSea <963979204@qq.com>
2026-10-10 18:31:32 +08:00
yetone 0fb4ff17ba agent: Snow CLI's thinking level is set from the Agents page, from the levels magpie's model has (#1457)
zRain (#1457) asked for thinking.effort, responsesReasoning and
responsesVerbosity. magpie's profile asks the gateway on Chat
Completions (requestMethod "chat"), and on that protocol Snow 0.9.2
reads chatThinking only (api/chat.ts: enabled sends reasoning_effort;
unset or disabled sends thinking {type: "disabled"}). thinking.effort is
the Anthropic method's, responsesReasoning and responsesVerbosity the
Responses method's, so none of them would change a request of magpie's
profile, and they aren't written.

A "thinking" field, as Pi's and dsh's, writes chatThinking {enabled:
true, reasoning_effort: <level>} the way Snow's own settings screen does
(ui/pages/configScreen/useConfigState.ts), on magpie's profile only, and
copies it to config.json. Its levels are the catalog's for the model
picked through magpie, after a default that says Snow takes off then;
a model that lists none offers none. Clearing it deletes chatThinking.
A chatThinking the user had on the profile magpie's was made from comes
along and is shown as theirs; it is only changed when picked here.
Enabled with no level reads as "on". On a profile of the user's own the
field is empty, offers nothing and refuses a pick.

Tests: TestSnowThinking, with a user profile in Snow's own format
carrying chatThinking: shown as theirs, levels offered, a pick written
and mirrored, kept through Sync, none offered for a model without
levels, cleared to Snow's default, the user's profile untouched. Writing
a fixed level instead of the pick fails it ("chatThinking: map[enabled:
true reasoning_effort:high]"). TestSnow* and TestSync* pass under a temp
HOME with pinned caches.

GUI: snow-fields.test.cjs (Chromium and WebKit, en/zh/zh-TW/ja/de,
window at 1240 and 720, tray panel at 440): on magpie's profile the row
draws the small and thinking pills, the thinking default reads "default
(off)" in each language and no pill runs past the row; on a profile of
the user's own neither is drawn. With the small key taken out of app.js
none() it fails 5 cases. The agent field, layout, effort and subagent
GUI tests pass beside it (156 tests), and go test ./... passes under a
temp HOME.

Real Snow CLI 0.9.2 (sandbox HOME made by Snow itself): with magpie's
profile written by this code (model relay/glm-4.6, small relay/glm-4.5v,
thinking high) and its baseUrl pointed at a fake server, `snow --ask`
sent its turn as relay/glm-4.6 with max_tokens 131072 and
reasoning_effort high, and its light request as relay/glm-4.5v.
2026-10-10 18:20:56 +08:00
yetone e949c0ca8f agent: Snow CLI's light model (basicModel) can be picked apart from its main model on the Agents page (#1457)
zRain (#1457) asked for Snow's advancedModel and basicModel to be chosen
separately; magpie wrote the picked model to both. Snow 0.9.2 asks
basicModel for its summaries, compaction and file search
(utils/config/apiConfig.ts; agents/compactAgent, summaryAgent).

A "small" field, as OpenCode's and Crush's, sets basicModel on magpie's
profile (profiles/magpie.json, copied to config.json): a model through
magpie only, since both models go to the profile's one baseUrl, the
gateway. Empty, it follows the main model. A small model of its own stays
through a new main model and a catalog sync (snowProfileFor keeps a
basicModel that differed from the advancedModel it replaces), and one
the gateway no longer resolves goes back to following.

On a profile of the user's own the field reads empty, offers nothing and
refuses a pick: that profile's models are theirs to set in Snow. The
Agents row leaves a small field with nothing to offer and no value out,
as it does an effort with none (app.js none()).

Tests: TestSnowSmallModel (pick, read back, refuse a non-magpie model,
kept through a new model and Sync, follows again when cleared,
Disconnect). With the keep in snowProfileFor removed it fails "small
after a new model and sync". TestSnow* and TestSync* pass under a temp
HOME with pinned caches.
2026-10-10 18:20:56 +08:00
yetone 6ad5dc5855 agent: Snow CLI's window, output and image support follow magpie's model until the user sets them in Snow, and a vision model of theirs that would reach the gateway is left out (#1457)
zRain (#1457, Discord #feedback) asked that maxContextTokens / maxTokens
be synced when the model changes, and for Snow's vision settings.

magpie's profile (profiles/magpie.json) already took maxContextTokens and
maxTokens from the catalog on every pick and catalog sync, which also
wrote over a value the user had set on that profile in Snow's own
settings. Now what magpie last wrote of maxContextTokens, maxTokens and
supportsVision is stashed (snow:<dir>:wrote), and a value that differs
from it is the user's and is kept through later picks and syncs; the
others follow the new model. Leaving magpie's profile forgets the stash,
so connecting again starts from the user's profile.

supportsVision is now set as every agent is told a model sees (fx,
Copilot): true while magpie's Vision describes images at the gateway,
else the catalog's word; it used to be copied from the user's profile,
where it described their own model. Snow 0.9.2 sends images to the main
model only when supportsVision !== false (agents/visionAgent.ts).

The user's profile is copied into magpie's, vision settings included.
Snow's vision model takes visionBaseUrl || baseUrl and visionApiKey ||
apiKey (buildVisionConfigOverride), so one with no endpoint of its own
went to the gateway, which doesn't know it, and one with its own endpoint
but no key sent magpie's key there. snowOwnVision keeps only a vision
model with both, on the requestMethod and baseUrlMode it was asked with.

Checked against Snow CLI 0.9.2's source (6ef56454: utils/config/
apiConfig.ts ApiConfig, agents/visionAgent.ts, api/chat.ts).

Tests (temp HOME, pinned caches): TestSnowSyncedKeepsTheUsers,
TestSnowVisionThroughMagpie, TestSnowUsersVisionModel, with Snow's own
profile layout. With the stash check disabled TestSnowSyncedKeepsTheUsers
fails "the user's window was written over: 65536"; without
supportsVision TestSnowVisionThroughMagpie fails "supportsVision <nil>";
without snowOwnVision TestSnowUsersVisionModel fails "visionModel kept:
glm-4.5v". go vet (darwin, linux, windows) clean, gofmt clean.
2026-10-10 18:20:56 +08:00
yetoneandggbdpq 91581fca27 library: a WSL agent under NAT is given a signed-in MCP server with the LAN key, so the gateway no longer answers its every call 401 (#1488, ggbdpq)
A server magpie signed in to (#615) is given to the agents at the
gateway's /mcp/<name>, at the address each reaches the gateway at. A WSL
distro under NAT reaches it at Windows' address, so its requests come
from another machine, and lanGuard refuses such a request without an
enabled gateway key with a 401, which an MCP client takes for the server
asking it to sign in. through() gave it no key. Its models already carry
the LAN sharing key there (keyAt, whqtian on Discord); the relay didn't.
The gateway's checks are unchanged: a request from another machine still
needs the key, and mcpProxy still lends a sign-in beyond loopback only
to a request that carried it (sharedWith).

What changed:
- agent.KeyAt exports keyAt: the LAN sharing key for an agent that
  reaches the gateway from another machine while sharing is on, else
  gateway.Token.
- through() gives such an agent Authorization: Bearer <that key>. The
  gateway takes it in lanGuard, and mcpProxy drops Authorization for
  magpie's token, so the server never sees it. An agent on loopback, and
  one in WSL while nothing is shared, stay keyless.
- access.LANChanged runs after sharing is turned on or off or its key is
  made anew; the library syncs again then when it relays any server, so
  the entry carries the key there is now without a visit to the Library.
- docs/subsystems/library.md says so.

Run:
- TestSignedInServerCarriesKeyBeyondLoopback (library: a FakeWSL distro
  routed via 172.20.0.1, LAN on) fails on the old through() ("claude@wsl:
  Ubuntu under NAT is given headers map[X-Team:acme], want the LAN key as
  its Authorization") and passes now; with the LANChanged call commented
  out it fails at "after a new key ... is given" the old key.
- TestMCPProxyFromWSLWithLANKey (gateway, through lanGuard as the server
  runs it): 401 without the key and the server not called, 200 with it,
  the server gets magpie's token and never the key.
- go test -tags nogui ./... under a temp HOME; gofmt -l; GOOS=linux and
  GOOS=windows go vet -tags nogui on the touched packages.
- Not tried on a real Windows + WSL NAT machine with a real OAuth MCP
  server; FakeWSL and httptest only.

Patch by ggbdpq in #1488; the LANChanged resync added on top.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-10 18:09:59 +08:00
yetone bfd5c82d1f gateway: a thinking budget turned adaptive for Claude Opus 4.7 and later still shows the thinking, so an Anthropic client's budget or a Chat client's effort on a model named by an alias is no longer answered with empty thinking (#1485)
forwardOnce turns thinking {type: enabled, budget_tokens} into adaptive
for a model that thinks only adaptively (adaptiveThinking): an Anthropic
client's own budget, or one buildAnthropic made for a model magpie knows
by another name than the vendor's (relay/opus mapped to
claude-opus-4-7: a Chat client's reasoning_effort, which the previous
commit's display didn't reach). Enabled thinking shows its text
(display "summarized" by default); adaptive thinking on Opus 4.7 and
later leaves it out unless asked, so magpie's rewrite hid the thinking
the client asked for. It now asks display "summarized" unless the
request names its own display.

adaptiveThinking now runs before withoutRefusedShapes, so a provider
that refused display isn't sent one again, and refuseShapes reads the
display as forwardOnce sends it, so a strict relay's 400 for it is
learned when the client's body had none.

Run: TestBudgetTurnedAdaptiveIsShown fails without the display (relayed
budget, plain and streamed, and a Chat effort on an alias: thinking
empty) and with the old order (a strict relay's 400 passed to the
client); passes with the change. TestAdaptiveOnlyModelsNeverGetABudget
and TestFableAndMythosNeverGetABudget expect display on a relayed
budget, and a client's own display ("omitted") is kept. go test -tags
nogui ./internal/gateway ./internal/usage under a temp HOME, gofmt -l,
GOOS=linux and GOOS=windows go vet -tags nogui. Not tried against a
real Anthropic key or a real strict relay.
2026-10-10 17:58:36 +08:00
yetoneandggbdpq 6934853b42 gateway: a Chat or Responses client that asks Claude Opus 4.7 or later to reason sees the reasoning, asked as thinking.display "summarized", not left out (#1485, ggbdpq)
Claude Opus 4.7, 4.8, 5 and 5.5, Sonnet 5 and 5.5, Haiku 5.5, Fable and
Mythos default thinking.display to "omitted": a thinking block comes
back with an empty thinking field unless "summarized" is asked for
(Anthropic's thinking docs, Controlling thinking display). buildAnthropic
asked them {"type":"adaptive"} alone, so a Chat client's
reasoning_effort or a Responses client's reasoning (Codex) got a reply
with no reasoning_content and no reasoning summary, while OpenAI's
(summary "auto" in buildResponses) and the Claude subscription's
(--thinking-display summarized) show it, as 4.6 did by default.

buildAnthropic now asks {"type":"adaptive","display":"summarized"}. A
relay that refuses display is asked again without it and from then on
sent none (refuseShapes, as for Claude Code's display). Thinking turned
off later (disabled, between_tools, none) replaces the whole thinking
object, so display never goes with it.

Run: TestTranslatedClaudeReasoningIsShown (a fake Anthropic API that
writes thinking text only for display summarized, and for 4.6 by
default) fails on the old code for Opus 5.5, Opus 4.7 and Fable 5.1 over
Chat and Opus 5.5 over Responses (no display, no reasoning in the
reply); TestTranslatedDisplayLeftOutWhereRefused fails on the old code
and passes with it (a strict relay still answers, then is sent none).
TestAdaptiveThinking and TestFableAndMythosNeverGetABudget expect the
new shape for a built request. The shapes tests
(TestRelayRefusingClaudeCodesNewShapes, TestClaudeCodesNewShapesKeptWhereTaken)
pass. Not tried with a real Anthropic key, Bedrock or Vertex, nor in
the real Codex UI.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-10 17:58:27 +08:00
yetone fcae505ff7 gateway, codexcat: Codex is offered Fast on a remote magpie's model where that magpie offers its own Codex Fast, and the tier asked reaches it (#1234, PennyVibe)
remote-magpie/codex/gpt-6.1-sol had service_tiers [] in the local
/v1/codex/models while the remote's own codex/gpt-6.1-sol had Fast: the
local catalog only gave tiers to a provider added by its address
(OwnTier, Preset == ""), and the gateway sent service_tier only to one.

Now a remote magpie's /v1/models (asked with X-Magpie-Drawers) tells each
model's service_tiers as its own Codex catalog offers them
(codexcat.ServiceTiers over the same CodexCatalog/Entries as its
/v1/codex/models). The local keeps the ids (catalog.Model.Tiers ->
Entry.Tiers), codexListed hands them on for the remote's models, and
codexcat.Entries offers them with Codex's own names. The gateway sends the
tier Codex asked for to a remote magpie as it was asked (OwnTier, still
dropped and remembered if refused); the remote serves it as its own
Codex's turn. A remote from before this sends no tiers: unchanged.

Run:
- TestRemoteMagpieOffersItsTiers (gateway, the gateway as both computers
  over HTTP): fails without the codexListed change with
  `office/relay/gpt-6.1-sol offered "" ..., want "priority:Fast "`, and
  without the gateway change with `tier sent to the remote magpie [(none)],
  by it to its vendor [(none)]; want priority, priority`.
- TestServiceTiersGoOnToAnotherMagpie (codexcat): a ChatGPT account's
  model with Codex's own entry tells priority+ultrafast, a relay's GPT
  Fast, glm none; fails when either the own-entry branch of ServiceTiers
  or the namedTiers branch of Entries is taken out.
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows on
  gateway, provider, codexcat, catalog, agent; go test -tags nogui of those
  five packages under a temp HOME: ok.
Not tried with a real ChatGPT account behind a real remote magpie.
2026-10-10 17:55:14 +08:00
wei 59c0added8 gateway: a refusal naming the levels is tested to mark reasoning off whole, the other off level counts only quoted, and the error fixtures say which bytes are captured
Review on #1117 (yetone):
- TestPassthroughEffortNoneRefused goes on: after Command Code turns none
  away with the levels named, minimal goes at low in one call. With every
  passthrough refusal marked per level, it fails.
- otherOffNamed matches the level quoted ('none', or "none" with JSON's
  escaped quote), so an English "None" in an error isn't taken for it.
  TestOtherOffNamed fails with \bnone\b, and with the escaped quote
  dropped for either level.
- aiStudioRefusal's status and message are AI Studio's literal bytes for
  minimal on gemini-3.8-flash, captured 2026-10-06 before the project's
  credits ran out; the capture kept only those two, so the envelope is
  Vertex AI's. The generateContent case is now Vertex AI's captured
  message for gemini-3.1-pro-preview, up to its "Learn more" link. The
  gpt-5.1 text in TestPassthroughMinimalRefusedNoneTaken is marked as
  reconstructed.
2026-10-10 17:54:54 +08:00
wei 67c6df418f gateway: Gemini turning away any thinking level, at once or passed through, is remembered for that model and level, and no longer stops a provider's thoughts
The commit before last tells Google's 400 for minimal apart from
thinking_config turned away. It left three ways for a level refusal to
still mark the provider unfit for thinking_config, or to reach the client:

  * Only minimal was told apart. Gemini 3 turns away any level a model
    hasn't, in the same words (AI Studio's "Thinking level MINIMAL is not
    supported for this model. Please retry with other thinking level."
    for gemini-3.8-flash). Any other level's 400 names thinking, matched
    refusesThinkingConfig, and the provider was marked unfit for
    thinking_config: no model on it was asked for its thoughts again
    until magpie restarted.
  * The check ran only while the model wasn't yet marked as refusing
    reasoning off. Claude Code sends its turn, a title and the auto mode
    classifier at once. A second 400 for minimal that arrived after the
    first had marked the model matched refusesThinkingConfig, and the
    provider lost its thoughts the same way.
  * Passed through, a Chat client's own reasoning_effort minimal went to
    gemini-3.8-flash as sent, and AI Studio's 400 went back to the client
    every time. The passthrough asked again only when the error listed the
    levels (effortLevelsNamed, Command Code's), and didn't remember that
    either.

Now:

  * geminiRefusedLevel reads the level from Google's 400, in AI Studio's
    words, Vertex AI's ("Thinking level is unsupported:
    THINKING_LEVEL_MINIMAL") and generateContent's ("thinking_level
    MINIMAL is not supported by this model"). forwardTranslated marks that
    level refused for the model (levelRefused) and asks again at the
    nearest level the model has left, still for its thoughts, and at that
    level from then on. geminiLevels gives the levels left: the model's
    own, or Gemini 3's where they aren't known or none of its own is left.
    A level turned away a second time in one request, with none left,
    goes back to the client as it came. Such a 400 never reaches
    refusesThinkingConfig.
  * The passthrough asks a none or minimal that Gemini turns away again at
    the model's lowest level (onEffort), and from then on sends that level
    at the lowest up front (turnedAway). The mark is per level. AI Studio
    takes none from gemini-3.8-flash, so none still goes as sent after
    minimal was refused. A refusal that lists the levels marks reasoning
    off as a whole (offRefused), as the translated route already did,
    unless it lists the other off level among those taken
    (otherOffNamed: OpenAI's "'minimal' is not supported with the
    'gpt-5.1' model. Supported values are: 'none', 'low', 'medium', and
    'high'."), which marks only the level refused. It is asked again at
    onEffort rather than a fixed low.
  * Both routes read and write the same marks. A refusal on one holds for
    the other.

Tests, with what the commit before this one (b9fe82b9) gives:

  * TestGeminiRefusedLevel: each of the three wordings gives its level.
    Gemini's fields turned away, a level named but not turned away
    (made up), Command Code's list of levels and an OpenAI unsupported
    value give none. (The function is new.)
  * TestGeminiThinkingLevelRefused/medium: gemini-3-pro-image-preview
    turning away medium is asked again at high with its thoughts, and at
    high at once the next turn. gemini-3.8-flash on the same provider still
    goes at medium. There: "gemini-3-pro-image-preview: the thoughts
    weren't asked for".
  * TestGeminiThinkingLevelRefused/no_level_left: a model turning away
    every level is asked at each once (minimal twice), and the client gets
    Google's 400. The provider's other model still gets its thoughts.
    There: "200 at [low ]", the turn asked again without the field.
  * TestGeminiMinimalRefusedTwiceAtOnce: two reasoning-off turns at once
    are both turned away at minimal. Each is asked again at low, and the
    next thinking turn still asks for the thoughts. There: "reasoning off
    went at [ low minimal minimal]".
  * TestPassthroughGeminiMinimalRefused: a Chat client's minimal to
    gemini-3.8-flash goes [minimal low], then [low], and none [none]. Claude
    Code's reasoning off then goes at [low]. gemini-3.7-flash, turned away
    at minimal by Claude Code's reasoning off, has a Chat client's minimal
    go at [low]. gemini-3.5-flash, which takes minimal, has it go as sent.
    There: "gemini-3.8-flash at "minimal": 400 at [minimal]".
  * TestPassthroughEffortNoneRefused: when Command Code refuses none, the
    second turn goes at low in one request. There: "turn 2: ... after 2
    calls".
  * TestPassthroughMinimalRefusedNoneTaken: on Chat and Responses,
    OpenAI's refusal of minimal has minimal go at low, in one request from
    the second turn, and none still go as sent. There: "chat turn 2 at
    minimal: ... after 2 calls". Marking reasoning off as a whole for it
    fails with "chat turn 3 at none: ... last sent ... low".
  * TestGeminiThinkingOffAtItsLowest also runs AI Studio's wording. It
    shares geminiUpstream with the tests above.

Mutations of the change were each caught by these tests:

  * dropping the second-refusal guard, or the fallback to Gemini 3's
    levels;
  * dropping the refit of an effort;
  * dropping the passthrough's up-front step, its mark, or its Gemini
    match;
  * marking reasoning off as a whole for a Gemini refusal, on either
    route;
  * narrowing the pattern to one vendor's wording, or loosening it to
    any level after "thinking level", lazily or not;
  * checking refusesThinkingConfig first;
  * turnedAway ignoring offRefused.

Verified on b9fe82b9 with a temporary HOME. gofmt -l, go vet ./...,
go build, GOOS=linux go build -tags nogui and GOOS=windows go build pass.
go test -tags nogui ./... passes, and so does -race -count=20 on the tests
above.

Not tried live. The AI Studio project's prepayment credits were depleted
(402), so the calls never reached the model. The wording for minimal is
AI Studio's, as observed on gemini-3.8-flash. Other levels are taken to be
refused in the same words.
2026-10-10 17:54:54 +08:00
yetone 7f66a0cce2 gui: on Linux the quick panel is dragged by its header, as the window is (#1430, olivezane)
On KDE Wayland the panel can't be put by the tray icon (a Wayland window
can't place itself, so KWin places it), and since ownFrame took KWin's
title bar off it (#1283) it had no handle at all: only Meta+drag moved
it. The panel's header set --wails-draggable: no-drag on every platform
(ebcd5281, when the panel began loading the Wails runtime); it now does so
on the Mac and Windows only, where the panel stays by the icon. On Linux
the header drags it as the main window's does (gtk_window_begin_move_drag,
which Wayland takes), and the tabs and buttons in it stay clicks.

Run: panel-drag-linux.test.cjs (Linux, Mac and Windows platforms; panel
and window; every visible control in the header no-drag) passes in
Chromium and WebKit, en and zh, and fails without the app.js change
("Linux: the panel's header is its handle"). tray-cell-click (which
asserts the Mac's panel stays no-drag) passes in both engines. No new
strings. Not tried on a real KDE Plasma 6 Wayland session.
2026-10-10 17:54:19 +08:00
yetone 884dbdb201 gui: on KDE a right-click on the tray icon opens its menu and leaves the quick panel shut (#1430, olivezane)
Wails (v3 beta.24, systemtray_linux.go) calls the tray's click handler
both for the icon's click (Activate) and from the dbusmenu "opened" event,
when the tray host opens the icon's menu. KDE Plasma opens the menu on a
right-click, so the right-click also opened the quick panel, which took
the focus, and on Wayland the menu shut at once (it stayed under
GDK_BACKEND=x11, as the reporter saw). On Linux the click handler now
ignores a call whose callers include Wails' (*linuxSystemTray).Event
(menuOpening, trayclick.go); a left-click (Activate) opens the panel as
before. Wails has no public hook for the menu opening.

Run: TestTrayMenuOpeningIsNoClick fails with openedBy broken ("a click
from the menu's opened event was counted a click") and passes;
TestTrayMenuOpenFrameIsWails reads the Wails module's source and fails if
Event stops calling the click handler on "opened" or is renamed.
go test -tags nogui ./internal/gui/ under a temp HOME passes; gofmt -l
clean; go vet (darwin, with the GUI) and GOOS=linux/windows go vet -tags
nogui ./internal/gui/ pass; GOOS=linux go build -tags nogui passes.
Not tried on a real KDE Plasma 6 Wayland session: no KDE machine here.
2026-10-10 17:54:19 +08:00
yetone 8a00d0bfa9 agent: Cursor Private Inference is listed on the Agents page when it is installed in a folder of the user's choosing on Windows, or kept as its AppImage on Linux (#1254, whiteS18, laacmilan)
It was found only by a product.json naming it in one of the apps
folders (on Windows %LOCALAPPDATA%\Programs, %LOCALAPPDATA%, Program
Files). Its 3.24.9 Windows user setup (CursorUserSetup-x64-3.24.9.exe,
from the cursor-local download) installs flat - resources\app\
product.json beside "Cursor Private Inference.exe" - into whatever
folder the installer is given, so one put on another drive or folder
was never found, and Routing still showed requests from it while the
Agents page had only Cursor. On Linux the build is only an AppImage
(Cursor_Private_Inference-3.24.9-x86_64.AppImage), a single file that
no product.json lookup could find.

findCursorLocal now also takes the folders Windows' uninstall entries
name for "Cursor Private Inference (User)" (cursorLocalInstalls: HKCU
and HKLM, InstallLocation, else DisplayIcon's folder), and an AppImage
named for the build in the Linux apps folders plus ~/.local/bin, ~/bin,
~/Downloads and ~ (regular Cursor's Cursor-<v>-x86_64.AppImage isn't
taken).

Run:
- TestCursorLocalFoundWhereInstalled fails with each half removed by
  hand ("installed in a folder of the user's: found \"\"", "its
  AppImage: found \"\"") and passes with the change.
- On the Windows 11 box: the real 3.24.9 user setup installed silently
  into C:\Users\yeton\cpi-1254\app; a probe test in the cross-built
  agent.test.exe found nothing with the old lookup and found
  "...\app\Cursor Private Inference.exe" (detected: true) with the
  new; TestCursorLocal* pass there. The copy was uninstalled after.
- go test -tags nogui ./internal/agent under a temp HOME; go vet
  (darwin, GOOS=linux and GOOS=windows, nogui); gofmt -l clean.
Not run: the AppImage on a real Linux desktop.
2026-10-10 17:52:30 +08:00