Commit Graph
6028 Commits
Author SHA1 Message Date
yetone ff65ebd142 provider: Zed's plugin is 0.1.14 at least: a Gemini model's efforts are keyed lowercase and its thinking level goes to Zed uppercase (plugins#215)
Zed's /models now lists a Gemini model's supported_effort_levels
uppercase (LOW/MEDIUM/HIGH), so the plugin keyed its variants LOW and
magpie's pi profile, which maps efforts by key, marked every thinking
level unsupported for zed/gemini-* (Yezike-yyy on plugins#215). And a
thinking level reached Zed lowercase, which its serde enum refuses:
400 "unknown variant `low`, expected one of `MINIMAL`, `LOW`,
`MEDIUM`, `HIGH`" (iron-water, plugins#215). zed 0.1.14
(magpie-community/plugins 3618bf9, from ump45nose's #587) keys the
variants lowercase whatever case /models uses and uppercases the level
only on the wire. The mover's min is raised to it, so keepMovedCurrent
updates every moved user.

npm view @magpie-community/opencode-zed-auth version --prefer-online:
0.1.14 at landing.

Run on mote at 59fdab0af (origin/main after rebase) plus this change: go test ./internal/provider/
-timeout 45m ok (104s); go vet ./... on darwin and GOOS=windows ok;
GOOS=linux go vet -tags nogui ./... ok (without nogui, Wails' cgo
Linux files don't build from macOS); gofmt -l clean.
Broken by hand: nothing here (a one-value change); the plugin's own
tests were broken by hand in 3618bf9.
Not tried: a real Zed account (none here) and a real move to 0.1.14.
2026-11-01 23:55:43 +08:00
yetone 59fdab0af7 gateway: a caller's folder the user hasn't trusted runs in magpie's, not a 502 (lwjef on X)
lwjef (X, 2116867007799030000): a cwd Claude Code hasn't trusted hangs
the interactive-mode bridge (paseo chat).

Cause: in the user's own account the helper leaves the trust question
to the user (no MAGPIE_CLAUDE_TUI_TRUST) and ends at once saying so. Up
to 11-01 that run became -p; since e5f66f8a6 nothing runs as -p, so the
turn got a 502 (endedBefore, "Claude Code asks whether to trust the
folder"). A Claude Code client such as paseo's asks again with backoff
on a 5xx, so the chat looked hung. The real Claude Code 2.1.309 in an
untrusted folder (sandbox HOME, copied account) ends the helper in 1.3s
with that line.

Fix: startTrusted runs startRun, and when the helper ended over the
trust question (its stderr read to the end, saidOnEnd) in the caller's
folder under the user's own account, remembers that folder for 10
minutes (passedOver) and starts the run once more in magpie's own folder,
told the caller's (envElsewhere), as a caller on another computer is.
Only one retry: a second refusal is returned as before. The saved-session
retry in start goes through startTrusted too.

Run (mote, at this tree):
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- TestClaudeTUIUntrustedFolderAnswered: ok

Broken by hand: saidOnEnd returning false made the new test red (502
"exited before it answered magpie's initialize request ... trust the
folder"); passedOver turned off made it red with the same 502 after one
retry. An earlier draft that retried through start itself looped forever
with passedOver off; the retry is bounded to one since.

Not tried: a real gateway turn from paseo; the real helper and Claude
Code were run on each side of the retry (untrusted folder ends at once;
a trusted magpie folder answers), not through a live gateway. A user who
trusts the folder within 10 minutes still runs in magpie's folder until
then.

At the pushed head's tree, on origin/main 79f83798f (which has 2b52302dc,
crosscn's 400KB fix), on mote: gofmt -l is clean, and go vet
./internal/... is ok for darwin, windows and linux. go test -timeout 45m
./internal/claudetui ./internal/claudebridge is ok. ./internal/gateway is
ok except TestCodexPoolSaysTheClientsVersion, which fails the same way in
a gateway run at origin/main 79f83798f itself and passes alone at both
(#4807, filed here). The conflict with main's tuiRefusal and replay change
in start() was resolved by keeping main's req.told and calling
startTrusted. Before the rebase, the three packages were ok on
magpie-desktop (Linux) too.
2026-11-01 23:47:47 +08:00
yetone bee3ea6753 claudetui: the first message waits for Claude Code to list magpie's tools (MinhuWang on X)
MinhuWang (X, 2116836405548916907): in the interactive mode the first
message can go before MCP has loaded, and then has none of pi's tools.

Cause: the helper's ready() took the drawn "❯ " prompt as ready. Claude
Code connects its MCP servers beside the prompt, so a message pasted at
once was answered with no mcp__magpie__ tools. Reproduced with the real
Claude Code 2.1.309 (sandbox HOME, a copy of the owner's account): an MCP
server held 8s before answering initialize got "NOTOOL" for "what is the
secret word, use your tool".

Fix: startRun gives claude-mcp-helper a third argument, a `listed` file in
the run's temp folder, which RunMCP writes after it has answered
tools/list. The helper finds that path in the run's --mcp-config
(mcpListed) and ready() waits for it as well as the prompt, inside the
same ReadyWait (45s); past it the run ends saying the tools weren't
listed. Runs without that server (warm-up, model test) don't wait.

Run (mote, at this tree):
- go test ./internal/claudetui ./internal/claudebridge: ok
- go test -run 'Claude|MCP|Bridge' ./internal/gateway: ok
- real Claude Code 2.1.309 here, a sandbox HOME with a copy of the
  account's credentials, the new helper and the real claude-mcp-helper
  behind an 8s sleep: initialize answered at 12.7s, the first turn called
  mcp__magpie__pi_secret and answered "The secret word is PELICAN".
  Without the sleep: answered at 2.1s, same answer. 2.1.309 sends
  server/discover before initialize; the helper's method-not-found answer
  is taken and initialize follows.

Broken by hand: toolsListed returning true made
TestShimFirstMessageWaitsForTools red ("echo: hello (without magpie's
tools)"); RunMCP not writing the file made TestToolsListedFileWritten
red.

Not tried: Claude Code in WSL (the path is the gateway's Windows temp
path, handed to magpie.exe as the callback path is); a Claude Code that
lists tools only on its first request (2.1.309 lists them at start),
which would now wait 45s and fail saying so instead of answering
without tools; the full gateway suite (run after the next commits).
2026-11-01 23:26:57 +08:00
yetone 79f83798fd kiro: the mover installs 0.1.25, which shows bonus credits on the Usage card (plugins#602)
kiro 0.1.25 is on registry.npmjs.org (npm view --registry
https://registry.npmjs.org: 0.1.25, shasum
00882472feb467e0ecb59da3c364bda423c5f12f). It is plugins#602
(GiantGKL), squash-merged as 6053811 in magpie-community/plugins:
bonus credits (a first upgrade's 500 trial credits, a promotion's)
show as aside windows of their own, with when they lapse, and a month
used up while a bonus has credits left is shown only too, since Kiro
spends the plan's credits first. keepMovedCurrent brings every moved
Kiro user to it.

Run on mote:
- at 276c806db + this change: gofmt -l, go vet ./..., GOOS=linux go
  vet -tags nogui ./..., GOOS=windows go vet ./..., go build ok;
  go test -tags nogui -timeout 45m ./...: 85 packages ok, and 3 reds,
  all on main already and filed: TestKeysAreWhatTheSaveWrites and
  TestSettingsCLISetsWhatTheWindowSaves (#4793, since da275848b's
  trayNoNumber), TestEveryRouteHasACommandOrIsNamed (#4794, since
  8826a15ea's /api/quit).
- rebased on 8569f39f6 (internal/provider changed: Zed's min), at
  this head: gofmt ok, go vet of internal/provider for darwin, linux
  and windows ok, go test -count=1 ./internal/provider ok (104s,
  TestKiroMoverHasTheTooLongFix holds with 0.1.25), internal/cli and
  internal/settingsapi the same three reds.

Not tried: a real Kiro account moved to 0.1.25 through magpie; the
plugin's own suite and its tests broken by hand are on plugins#602.
2026-11-01 23:11:28 +08:00
yetone 8569f39f6c agent: Claude Code's /model hides its own lineup while magpie's list is narrowed
yyhhyyyyyy on Discord picked only a routing group's models for Claude Code
on the Agents page, and Claude Code's /model still listed a model they had
not picked. Real Claude Code 2.1.316 in a sandbox HOME, with the settings
magpie writes, lists: Default, the group (as Custom Opus), Claude Code's
built-in "Fable 5.1" row, then the group as Sonnet and Haiku, then
magpie's modelPicker rows. The Fable row is Claude Code's own lineup.
magpie leaves ANTHROPIC_DEFAULT_FABLE_MODEL unset for a main model that
isn't a Fable (#2090), so Claude Code shows its own Fable there. The
gateway's /v1/models already follows the picks (CatalogFor), and Claude
Code's gateway discovery is off unless
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY is set. Neither of those is
where the row comes from.

Claude Code's documented modelPicker.replaceBuiltInOptions hides the
lineup and leaves Default and magpie's rows. In the same sandbox, the
same settings with the flag set list exactly those rows. magpie already
set the flag while "Show Claude Code's own models" is off (#4548). It now
also sets it while Claude Code's list leaves out some of magpie's
catalog: only the picked models, some taken out one by one, or a
visibility of families (claudeNarrowed, CatalogFor's hidden list). A
change to the picks already rewrites settings.json through
catalog.Touched and Sync.

The user's own values:
- A user's ANTHROPIC_CUSTOM_MODEL_OPTION, in the settings env or the
  shell, keeps the lineup. The flag would hide that row too.
- availableModels was not used. It also hid the Fable row in the
  sandbox, but it is the user's key, it blocks --model, and it is meant
  for enforcement.

Run at this head (rebased on origin/main 2503520f8), on mote:
- gofmt -l: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -timeout 45m ./...: internal/agent ok, along with
  84 packages. Three packages are red, all on main and filed:
  - internal/settingsapi TestKeysAreWhatTheSaveWrites and
    internal/cli TestSettingsCLISetsWhatTheWindowSaves (trayNoNumber,
    #4793);
  - internal/cli TestEveryRouteHasACommandOrIsNamed (/api/quit, #4794);
  - internal/gui TestRestartHandsTheGatewayOver (#4167, #4107).

Broken by hand:
- On the old claude.go, TestClaudePickerNarrowedListReplacesLineup fails:
  "glm-5 taken out: ... replaceBuiltInOptions=false".
- With the custom-option guard forced off, it fails on the user's
  ANTHROPIC_CUSTOM_MODEL_OPTION step.

Not tried:
- A real magpie writing settings.json for the real Claude Code. The
  sandbox used hand-written settings of the same shape, with the base URL
  on an unused port and no sign-in.
- Claude Code in WSL. claude@wsl takes the same writePicker path.

No GUI file is touched, so no GUI run.
2026-11-01 23:00:10 +08:00
yetone 2f4c088dce usage: Warm up on a Codex or Claude account's card whose 5 hours haven't started
01huadalang on Discord looked for a way to start one account's 5-hour
countdown on the Usage page, not in Settings. A Codex or Claude account
card whose 5-hour window isn't running now has a Warm up (预热) button on
its account line. It sends the request Settings › Warm-up's Warm up now
sends (POST /api/warm-now {agent, user}), to that account alone: for a
ChatGPT account the scheduled warm-up's one "hi" with the account's own
sign-in, on its cheapest model at low effort (warmModel); for a Claude
account Claude Code's own run on haiku (WarmClaudeVia), so magpie sends
nothing that imitates Claude Code. No new server code.

When it shows: the account is one magpie is signed in to (codexUsers /
claudeUsers), its read has no error, and its 5-hour window is idle as the
scheduled warm-up tells it (idle in codex_warmup.go): nothing used and the
reset a whole window away (within warmSlack), or the reset gone by. A
Claude account never used has no window read and shows it too, as
claudeWindowsExpected fills in; a Codex account with no 5-hour window
doesn't. While the request is out the button is disabled (busy), so a
second press sends nothing; once it went, the account's button stays away
for warmSlack (10 minutes), the time a just-started window still reads as
idle, and the quotas are read again (the server marks the account stale).
Refused, the vendor's reason goes in the status line and the button
comes back. Words in en, zh, zh-TW, ja, de (the tooltip is new; the
button and status lines reuse Warm up now's).

Run (at the head before the last rebase onto 09d5dfb87, which changed no GUI asset or internal/gui file, unless said):
- quota-warm.test.cjs (new), on mote: 20 of 20 pass, Chromium and
  WebKit, en/zh/zh-TW/ja/de, 1100px and 390px. On origin/main with only
  the test copied in, 10 of 10 Chromium cases are red (no button.acct-warm).
- Broken by hand: the 10-minute hold taken out (now - busy < 600e3 ->
  false): red 2 of 2 (the button comes back after the warm-up).
- go test ./internal/gui/... ./internal/provider on mote (before the last
  rebase onto df03aeb35, which touched none of these files): provider ok;
  gui red only in TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27).
- 25 GUI files near the change on WSL (account-mask, privacy-hides-accounts,
  quota-*, usage-fold/-pack/-accounts/-keys/-card-refresh, warm-now,
  codex-auto-reset, tray-cell-click, panel-usage, i18n-keys, gui-de/-ja/
  -zh-tw ...): i18n-keys caught a comment saying Library's "Not running",
  fixed. The other reds are the same on origin/main 85e37162e run the
  same way: usage-fold "most on one screen", tray-cell-click and
  codex-auto-reset webkit de (filed #4790), warm-now 440px (#4322).
- The whole GUI suite was started at this head on mote (concurrency 3,
  another session's suite beside it); it was not finished at push. One
  red by then, account-eye chromium zh-TW (opacity '' read before the
  styles), which passes 15 of 15 alone on WSL; its fixture's windows are
  used, so no Warm up is drawn there.

Not tried:
- A real account's warm-up from this button. The request is Warm up
  now's, whose own commit (1801c96bf) didn't try a real account either;
  a Codex sign-in copied into a sandbox can rotate the live refresh token,
  and a Claude one lives in the Keychain.
- The tray panel's Allowances, which draws the same account line.
2026-11-01 22:50:45 +08:00
yetone 09d5dfb87b gateway: aliased and magpieAliasAsked read one alias parser (#4667)
magpieAliasAsked copied aliased's four prefixes; a fifth form added to
one would leave the other behind. Both now read aliasDigits.

Run: targeted alias/member/desktop/science tests, gofmt, vet x3 (mote).
2026-11-01 22:44:23 +08:00
ggbdpq 3d64d6c52f gateway: a reply to one of magpie's own aliases keeps the vendor's model name (#4667)
leizh007: with Claude Code Desktop served through magpie, ccusage counted
the model as "magpie-2213244526.anthropic…" from the 11-01 release on;
before it said the subscription's own "opus-5-5".

The asked-name rule (9bb1efdde) names a reply after the model the agent
asked for whenever the request went out under another name. Claude
Desktop's effort-picker aliases (fb1575730) made Desktop's Code tab ask by
such a name: magpie-<n>.anthropic.claude-opus-5-5, mythos-magpie-<n>,
anthropic/magpie-<n>, Claude Science's claude-magpie-<n>. The vendor is
asked under the model's own name, the reply came back under it, and the
rule wrote the alias over it — into Claude Code's usage records, where
ccusage counts each model by the reply's name. An alias is magpie's
deployment name, not a model id any vendor knows.

Now a request that came in under one of those aliases is served the
vendor's own name, as every reply was before the asked-name rule. The
recognition is the alias shape alone (magpieAliasAsked), not a catalog
lookup: a session saved on an old alias is served all the same, and its
reply keeps the vendor's name too. MemberModel and X-Magpie-Response-Model:
member are untouched — an explicit ask for magpie's id still says it. The
usage ledger still records the catalog id asked for and the vendor's name
as served.

Run (this head on dfe868a1e, upstream/main):
- go test -tags nogui -count=1 ./internal/gateway: ok (573s). The new
  TestReplyToMagpieAliasKeepsVendorName (10 subtests: the four alias forms
  and [1m], streamed and not) was red before the fix — every subtest had
  the reply naming the alias — and TestReplyNamesAskedModel,
  TestReplyNamesMember, TestGeminiReplyNamesAskedModel, TestMemberLine,
  TestMemberLines stay green.
- Ablation (product files back at the parent, test kept): 11 failures,
  all "the reply names <alias>, want the vendor's opus-5-5".
- go test -tags nogui -race -count=1 on the member and alias tests: ok.
- gofmt -l clean; go vet -tags nogui ./internal/gateway clean;
  GOOS=linux and GOOS=windows vet clean.
- Builds: darwin arm64 (cgo warnings in internal/gui pre-existing),
  linux and windows with -tags nogui, the Makefile's own cross-compile
  form (Makefile line 105).

Sibling faces checked: the alias constants are constructed only in
desktop.go and science.go; aliased() serves resolution (unprefixed) and
GUI display, both of which need the catalog, unchanged; the memberWriter
is the one writer of reply names and this gate covers it; the Responses
WebSocket path never carries a Desktop alias (Codex-side ids).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 567b648bd8 gateway: test #4445 on the reporter's route, Codex's ChatGPT backend path
The reporter's turn came to magpie's /backend-api/codex/responses, with
the Model Map plugin naming remote-magpie/codex/gpt-6.1-sol; the patch's
test asked on /v1/responses only. TestRemoteMagpieCodexModelKeepsLiteOnCodexPath
asks the same Lite request on CodexPath.

Run (mote, at this tree, -tags nogui):
- go test -run TestRemoteMagpie ./internal/gateway: ok
- with additional_tools.go and gateway.go put back as on origin/main, the
  new test is red with the report's 400 ("Office:
  X-OpenAI-Internal-Codex-Responses-Lite requires `reasoning.context` to
  be `all_turns`."), as is the patch's own /v1 test.
2026-11-01 22:44:23 +08:00
ggbdpq 1ff928139d gateway: a remote magpie's codex model gets Codex's Responses Lite as it was sent (#4445)
What changed: a Codex Desktop turn on one of its own Lite models (gpt-6.1-sol)
routed through Model Map to a Remote Magpie provider answered 400 "Remote
magpie: Codex: X-OpenAI-Internal-Codex-Responses-Lite requires
`reasoning.context` to be `all_turns`". liteKept treats a Remote Magpie like
any plain Responses upstream, so passthrough ran fromLite (the additional_tools
item lifted into tools, reasoning.context taken off) and forwardOnce dropped
the Lite header. The remote serves codex/<model> through its ChatGPT account,
which passes on what it got, and the ChatGPT backend refuses a request for one
of its Lite models without reasoning context "all_turns" (#534): the request
arrived stripped of exactly what that model demands. Had it gone as Codex sent
it, the remote's account path keeps the Lite shape (liteKept true there) and
its answer is 200, as the reporter's codex=as-sent workaround showed.

liteKept now also keeps the shape, with the model it is asked for: a Remote
Magpie's codex model, named codex/<model> — the ChatGPT account's namespace in
every magpie's catalog, so the remote lists one only when that account is there
to serve it. Its other models still get what Codex sends a model that isn't
Lite (#350), header and reasoning context included in the lift (#350, TangForX).

Run: go test -tags nogui -run 'TestRemoteMagpieCodexModelKeepsLite|
TestRemoteMagpieOtherModelLeavesLite' ./internal/gateway/ — the first failed
with the 400 above before the change and passes after; the second keeps the
old behavior. go test -tags nogui ./internal/gateway/ passes.

Fixes #4445

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
ggbdpq 6de04a26e2 gateway: a Codex memory call on its own bare name follows the session when a provider serves a model under that name too (#4765)
raphael-y7: with magpie as Codex's model provider, the conversation on
orbis/gpt-6.1-sol, Codex's memory consolidation — its own background
request on its own default consolidation model, asked by its bare name
gpt-5.6-terra — went to workbuddy-ai, the only provider of magpie's with
a model under that name, and the account it landed on refused it: 400
"model [gpt-5.6-terra] is not allowed for user type
[personal_free_user]", three tries, 8.5s, and the memory was never
written. The bare name resolved, so codexMemoryStandIn (#742) left the
call where it stood; a model of Codex's own asked by its bare name is
not a pick of whichever provider has one under that name.

Now a memory call whose bare name resolves still follows the
conversation's model, as it does on the ChatGPT backend's path
(codexFollowTo), when Codex's config names no model for its memories:
codexMemoryStandIn asks codexMemorySession first and only falls through
to the name's own resolution when there is none to follow. What keeps
going as the name resolves: any other call, a model Codex's config
names (the user's own pick, a full id or a bare name), a config magpie
can't read, and a conversation magpie has no model of (on Codex's own,
or nothing answered yet).

What this doesn't change: the three tries on a capability refusal, and
the model catalog's exposure of a model an account can't serve — the
reporter's other two suggestions, both a bigger cut; the auto-review's
codex-auto-review and the app's title, description and summary calls,
whose as-Codex-sent default is deliberate (codexTitlesTo, codexSideTo;
shruru counts a provider serving a luna-named model picking titles up
as a feature, #4590).

TestCodexMemoryOnACollidingBareNameFollowsTheSession: a provider with a
model under gpt-5.6-terra, the conversation on another provider's — the
memory call followed the conversation and the named provider got
nothing (red before: it got the memory); the config's pick and a plain
turn on the name still go to it. Run (darwin arm64, -tags nogui):

- go test -tags nogui -run 'TestCodexMemoryOnACollidingBareNameFollowsTheSession|TestCodexMemoryCallsGoWhereItsTurnsGo|TestCodexMemoryStandInFollowsTheSwitch|TestCodexMemoriesFollowTheSession|TestCodexSideCallsKeepTheConfigsModel|TestCodexSideCallsBeforeTheFirstTurnFollowTheSwitch|TestCodexOwnModelOnMagpieThreadGoesOnSignIn' ./internal/gateway: ok (the new test was red before the fix, with the report's routing)

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 206efc90c8 gateway: a Codex side call with no setting still goes on Codex's sign-in (#4590 review)
e99e75dab took every side call on one of Codex's own models (title,
description, summary, prediction) off Codex's ChatGPT sign-in. With no
setting naming a model, codexTitlesTo and its siblings hand back the
bare model Codex asked for, which magpie serves nothing for: a user
signed in to ChatGPT whose titles worked through the sign-in got
"magpie knows no model \"gpt-6.1-sol\"" 404 for every title,
description, summary and prediction. A thread's summary has no setting
at all, so it always went that way.

Now only a side call whose setting names where it goes (CodexTitles,
CodexDescriptions, CodexPredictions: a model or "off") stays off the
sign-in (codexSideSet); without one it goes on the sign-in as before.

Run (mote, at this tree, -tags nogui):
- TestCodexSideCallOnOwnModelUnsetGoesOnSignIn (new: signed in, no
  setting, each of the four kinds): red on e99e75dab, the 404 above for
  all four; green now.
- go test -run 'TestCodexSideCallOnOwnModel|TestCodexOwnModelOnMagpieThread|
  TestCodexTitlesSetting|TestCodexTitleOnMagpieProvider|
  TestCodexDescriptionsSetting|TestCodexDescriptionFallbackOnMagpie|
  TestCodexPrediction|TestCodexSummar' ./internal/gateway: ok
- broken by hand: codexSideSet always false turns gua's
  TestCodexSideCallOnOwnModelNotPutOnSignIn red (the reporter's 404);
  always true turns the new test red.
2026-11-01 22:44:23 +08:00
ggbdpq 50e8da4c34 gateway: Codex side calls on its own models stay with magpie, not its sign-in (#4590)
shruru: with magpie as Codex's model provider, picking any model in the
Codex titles setting never took: the thread's title stayed the first
message's truncation, and a request for gpt-5.6-luna, Codex's own title
model, to /v1/responses was answered 404 "is one of Codex's own models...
open ~/.codex/auth.json: no such file or directory".

A thread started while magpie was Codex's provider sends to magpie's /v1
(model_providers.magpie's base_url is magpie's /v1), and since
4586307de a request there on one of Codex's own models is put on Codex's
ChatGPT sign-in, or answered 404 when no sign-in can be had — before
handle ever asks codexTitlesTo where the settings send a title. Codex's
hidden side calls (a thread's title, description, summary, a composer
prediction) on its own models were swept up in that: magpie has its own
answer for each (codexTitlesTo and its siblings, further down handle),
so with no ChatGPT account anywhere the title request died at the sign-in
check and Codex fell back to naming the thread after its first message,
whatever the settings said.

Now codexOwnOffMagpie leaves side calls where they stand; a plain turn on
one of Codex's own models goes on the sign-in as 4586307de says.

Tests (internal/gateway/codex_own_v1_test.go): shruru's machine — Codex
never signed in (no auth.json), gpt-5.6-luna in its models cache, no
ChatGPT account in magpie, titles and descriptions set to a magpie model;
a thread_title and a thread_description request to /v1/responses on
gpt-5.6-luna: was 404 "one of Codex's own models...", now 200 with the
{"title"} / {"description"} the settings' model wrote.

Run (darwin arm64, -tags nogui):
- go test -tags nogui -run 'TestCodexSideCallOnOwnModelNotPutOnSignIn|TestCodexOwnModelOnMagpieThread|TestCodexTitlesSetting|TestCodexTitleOnMagpieProvider|TestCodexDescriptionsSetting|TestCodexDescriptionFallbackOnMagpie' ./internal/gateway: ok
  (the new test was red before the fix, with the reporter's 404 verbatim)

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:44:23 +08:00
yetone 37d7913c20 claude: the interactive mode is given an earlier conversation as a transcript
A conversation no run has (a run lost to an update, a client's own
history) was told to a new Claude Code in its interactive mode as one
first message, pasted. #4778's 229 messages and 3 images that way were
refused; #4780's 56 messages and 25 images were pasted one by one until
the paste timed out, and the request got a 502 or an empty reply.

Now, when the conversation has a reply that calls no tool,
replaySession writes it as Claude Code's own transcript: a session file
in the project folder Claude Code reads, a user line holding the
conversation before that reply (as renderClaudePrompt tells it, images
as image blocks, client cache marks out) and an assistant line holding
the reply's words. The run starts with --resume on it, as a saved
session's run does, and is typed only the turns after the reply. If
Claude Code can't go on from it, start tries once more told whole
(req.told). -p (interactive mode off), WSL (no session folder) and a
conversation with no such reply are told whole as before. The file goes
in the folder of the work path with its links followed: the first try
wrote it beside the unresolved /var/folders path on a Mac, and the
replay test was red on mote for it.

Real run (this Mac, sandbox HOME and CLAUDE_CONFIG_DIR, one of the
owner's real Claude accounts by CLAUDE_CODE_OAUTH_TOKEN, real Claude Code
2.1.316 through magpie claude-tui-helper, -p stream-json in, the
interactive mode under it, --model haiku): the transcript was made by
replaySession itself (a throwaway test on mote, not committed) from 6
earlier messages with 3 images (red, blue, green 64x64 PNGs) and a
455KB file whose line 004321 names a fruit, 464,798 bytes; the work
folder was reached through a symlink. Typed only "Name the colours of
images A, B and C, and the secret fruit named in line 004321 of the
file. One line." Answer in 8.4s: "A: red, B: blue, C: green; secret
fruit in line 004321: PAPAYA." Claude Code appended to the same session
file (504,788 bytes after).

Run (mote, at this tree, rebased on 85e37162e): go vet ./internal/gateway, GOOS=windows and
GOOS=linux -tags nogui go vet; go test -run
"TUI|Claude|Resume|Interactive|Refusal|Replay|Fallback|Branch"
./internal/gateway ok. gofmt -l clean.

Broken by hand: with replaySession returning nil,
TestClaudeTUIReplayGoesInATranscript is red ("the run wasn't given a
transcript to go on from"). TestClaudeTUISafeguardsInEnv now expects the
new run of changed safeguards to be given the whole conversation
through the transcript, not typed it, and
TestClaudeTUIBranchOfPrintRunIsToldWhole (049848c5e) accepts a branch of
a -p run's session given the whole conversation as a transcript of its
own, never the -p session (it was red at the rebased head before).

Not tried: the full gateway path (a real magpie serve with the
subscription) end to end; the request was driven at the helper with the
transcript replaySession wrote. Not changed: #4780's ask that an empty
200 not count as an answer and that the specific reason reach the
client; WSL still tells the conversation whole. Part of #4778 and #4780.
2026-11-01 22:43:52 +08:00
yetone 949000a36a claude: a request the interactive mode refuses is a 400 no account rests for
A request Claude Code's interactive mode can't take (a JSON schema, a
branch of a -p run's session, WSL Claude Code whose home wasn't found)
was refused with a 502. The fallback asked every account of the
subscription in turn and rested some for it: #4778 saw 15 tries across 3
accounts. The refusal is the same on every account, so it is now a 400
(tuiRefusal), which the fallback neither retries nor rests an account
for.

The message is reworded so that "Models" no longer stands just before
the error's "invalid_request_error": "Settings › Models › Replies
runs every request as -p\",\"type\":\"invalid_request_error" matched
provider.ModelUnserved, which made the 400 retryable again.

Run (mote, at this tree): go vet ./internal/gateway, GOOS=windows and
GOOS=linux -tags nogui go vet; go test -run
"TUI|Claude|Resume|Interactive|Refusal|Fallback" ./internal/gateway ok.
gofmt -l clean.

Broken by hand: with the 400 mapping taken out,
TestClaudeTUIRefusalIsNoAccountsFault is red (502); with the old wording
it was red on WSL (retryable true through ModelUnserved).

Not tried: a refusal against real accounts. Not changed: a run that
starts and fails (tuiNoStart) is still a 502, retried on the next
account. Part of #4778.
2026-11-01 22:43:52 +08:00
yetone df03aeb351 provider: Zed's plugin is 0.1.13 at least: a Gemini request's tool-calling mode goes in lowercase (#4657)
Zed's cloud refused every tool-bearing Gemini turn of the Zed plugin with
400 "unknown variant `AUTO`, expected one of `auto`, `any`, `none`"
(atticuskk). magpie-community/plugins f4e2ac3 (zed 0.1.13, co-authored
with ggbdpq, who found the cause) lowercases the mode in the plugin,
where the request is fitted to Zed's wire; the mover's min makes every
moved user's plugin that version.

Checked: npm view @magpie-community/opencode-zed-auth@0.1.13 version
--prefer-online -> 0.1.13. Plugin run (mote): bun test in packages/zed
54 pass; the lowercase line off -> 3 red. gofmt -l clean.
Not tried: a live request to cloud.zed.dev.
2026-11-01 22:32:41 +08:00
yetone 97e66bce26 library: an uninstalled Kiro CLI is listed to take back what it was given (#4769)
b4c67477f lists Kiro CLI in apps only while kiro-cli is found. held, which
lists an uninstalled agent on the rows of what magpie gave it so that can
be unticked and taken out of its folder (TestGoneAgentListedToTakeOut),
walks apps and agent.All, so once kiro-cli was uninstalled magpie's
entries stayed in ~/.kiro/settings/mcp.json, ~/.kiro/skills and the
steering file with no row to take them out.

Kiro CLI is now always in apps, with Bin the found path or "kiro-cli":
Detected (binAt) still decides whether it is a target, so ~/.kiro alone
(Kiro Crew, the Kiro IDE) makes nothing a target, as before. Takes tells
an app that isn't installed so, rather than recording it and then giving
it nothing (the #2254 shape); before, an uninstalled Kiro CLI got
"unknown agent".

Run (mote, mote-run -tags nogui):
- go test -count=1 -run 'Kiro|Gone|Takes|Held|Target' ./internal/library: ok
- go test -count=1 ./internal/library (whole package, before this
  change, with b4c67477f): ok 156s
- Broken by hand: apps() back to listing Kiro only when found ->
  TestKiroCLIUninstalledHeld red ("isn't listed as gone: <nil>", Takes
  "unknown agent"); Takes' new check off -> red (Takes returns kiro-cli
  for an uninstalled one).
- gofmt -l: clean.
Not tried: a real kiro-cli uninstall (the user's live ~/.kiro untouched).
2026-11-01 22:32:41 +08:00
ggbdpq eb469c70a9 fix(library): Kiro CLI gets the Library's skills, MCP servers and instructions (#4769)
The library's targets are agent.All plus apps, and apps held Claude
Desktop alone: Kiro CLI, which magpie wires no model into and the Agents
page rightly leaves alone, could be given none of the three, and a user
of it copied skills, servers and instructions into ~/.kiro by hand
(#4769, ump45nose).

Kiro CLI is an app now, found by the kiro-cli program alone — PATH,
~/.local/bin, Kiro CLI.app, where provider.KiroExecutable already
looked — never by ~/.kiro, which Kiro Crew and the Kiro IDE keep too. It
reads ~/.kiro/skills, ~/.kiro/settings/mcp.json and
~/.kiro/steering/AGENTS.md, its global steering's AGENTS.md being always
included (kiro.dev/docs). Its mcp.json has a format of its own: entries
of command/args/env or url/headers, no type written, the user's fields
(disabled, autoApprove, disabledTools, oauth) kept, no SSE named — a url
is streamable HTTP, the docs give no way to say SSE — and a ${NAME} in
headers or env passed through, Kiro expanding those its Mcp Approved Env
Vars approves.

What a kiro-cli in a WSL distro is given, and a project's .kiro, stays
out: apps are this machine's, and per-tool off stays the user's.

Run: go test -tags nogui ./internal/library (ok; TestKiroCLITarget,
TestKiroCLINotByItsFolder and TestKiroMCP new); go vet (darwin, linux,
windows; nogui) and gofmt -l clean on the package; builds for all three
platforms.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:32:41 +08:00
ggbdpq a97653bf3e routing: LeastUsed sends a key with no share behind subs with room, not first (#4535)
A pay-as-you-go key, a prepaid wallet, or an account whose use wasn't
read has Seat.Used read 0, and LeastUsed compared that 0 as if it were a
share of 0%: any subscription that had used more than nothing went after
every such key, so paid balance burned while subscription quota sat
idle. Smart and Pace already keep a seat whose allowance isn't known
behind those whose share was told; LeastUsed now does too: the shareless
go after subscriptions with room and before those running low or spent,
ordered among themselves by what a wallet has left and what magpie sent
a key lately. A learning account still goes first, once, as in Smart
and Pace. Pools of seats that all tell a share, or all tell none, are
ordered as before.

What changed:
- internal/routes/strategies.go: LeastUsed places seats by whether their
  share was told (Known with a use past 0 or a renewal known) before the
  Used comparison; its comment says so.
- internal/routes/routes_test.go: TestLeastUsedSeatsWithNoShare locks a
  key behind subs with room, a wallet behind a told share and before a
  key, keys past low and spent subs, a learning account first, and told
  shares ordered by use as before.

Run:
- go test ./internal/routes/ -count=1 (fails on the parent at
  TestLeastUsedSeatsWithNoShare: [key sub], passes with the fix)
- go vet ./internal/routes/, gofmt clean

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:32:41 +08:00
yetone 2503520f82 codexcat: each Codex model takes official Codex's own instructions for it (#3759, #4008, #4783)
Every magpie model in Codex's catalog (model_catalog_json) carried
gpt-5.2-codex_prompt.md ("You are Codex, based on GPT-5"), so a magpie
GPT-6 model, the auto group's included, ran on a GPT-5.2-era prompt while
official Codex sends GPT-6's own template. magpie still writes no words of
its own into the prompt and leaves the identity line alone: each entry now
takes the text official Codex sends that model, word for word.

- A model's slug (the id's last segment) is matched as Codex 0.166
  matches one (longest prefix of an official slug): first in the entries
  the user's ChatGPT account handed this Codex (models_cache.json), whose
  base_instructions and model_messages go over as sent; then in Codex
  rust-v0.166.0's bundled models.json (instructions_template only, as an
  older Codex may not read 0.166's model_messages), embedded as
  codex_instructions.json.
- Any other model, and a routing group, takes Codex's prompt for a model
  it doesn't know (models-manager/prompt.md, model_info_from_slug), which
  replaces codex_prompt.md: that is what official Codex sends it.
- ownEntry with no base_instructions, and internal/provider's
  codexInstructions fallback, take the same official text.
- testdata holds Codex's models.json and prompt.md at rust-v0.166.0;
  TestBundledIsCodexOwn fails when the embedded copies drift from them.
- GET /v1/codex/models (a remote Codex's model_catalog_url): entries are
  now ~21 KB, so Codex before 0.166's 1 MiB cap holds about 48 of them
  (was ~125). Codex 0.166 reads the catalog whole (models_endpoint.rs
  passes no body limit), and it sends ?client_version=, so the cap now
  applies only to a Codex below 0.166 or one that doesn't say
  (codexReadsWholeCatalog). docs/reference.md says so.
- docs/subsystems/agent-wiring.md: a "Codex instructions" row. The
  Antigravity cloak's comment no longer calls the GPT-5 prompt magpie's.

Run (mote's disk is full, 100% with other sessions' runs, so on WSL
magpie-desktop through wsl-run):
- go test ./internal/codexcat/: ok. go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok. gofmt -l: clean.
- go test -tags nogui -count=1 -timeout 45m codexcat, provider, agent,
  gui, gateway (every package that imports codexcat): codexcat, provider,
  gui ok. agent: TestGrokInstalled and TestOmpDetectedWithPiDir red, the
  same at origin/main 276c806db on the same box (#3548, #4033: WSL binfmt
  and install detection). gateway: TestCodexCatalogFitsCodexsLimit and
  TestCodexCatalogKeepsTheKeysUsedModelsFirst red from this change (the
  1 MiB cap, fixed above; both ok after, with every TestCodexCatalog*,
  TestCodexListed*, TestCodexApp*), and TestUnroutedHeldReportSaved, red
  only in the full run, ok alone here and at origin/main (#4300).
- Real Codex 0.166.0 (npm) in a sandbox HOME/CODEX_HOME, model_catalog_json
  from this codexcat, against a fake Responses gateway on 127.0.0.1:38611
  capturing each request: 0.166 sends the instructions as the first
  developer message (no top-level instructions). For magpie/gpt-6-astra it
  equals gpt-6-astra's instructions_template in Codex's models.json, byte
  for byte; for magpie/deepseek-v4-pro it equals prompt.md.

- After rebasing on origin/main 9da9bfabd: go vet (linux, windows) of
  codexcat, gateway, provider ok; codexcat ok; -run
  "Codex|Antigravity|Grok" in gateway and provider ok. Then rebased
  onto 546cdbde6 (7 commits in redact, gateway translation and a GUI
  test, none in codexcat or the Codex catalog) and not run again.

Broken by hand:
- The cap held for every client_version: both catalog tests FAIL (47
  listed for 0.166.0, 0.167.0-alpha.1 and 1.0.0).
- Old codex_prompt.md and Prompt everywhere: TestBundledIsCodexOwn,
  TestThirdPartyModelsTakeCodexOwnInstructions (all 7 slugs started "You
  are Codex, based on GPT-5"), TestThirdPartyModelsTakeCachedEntry,
  TestOwnEntryInstructions and TestCodexCatalogKeepsOwnEntries FAIL.
- The same real Codex run on origin/main's codexcat: both models' first
  developer message is the 7.5K GPT-5 prompt, differing from the official
  text at byte 15 (astra) and 8 (deepseek).

Not tried:
- GOOS=darwin go vet (needs mote, full).
- Reading the bundled catalog from the user's installed Codex binary;
  the snapshot is 0.166's, and a Codex release with new templates needs
  testdata and codex_instructions.json refreshed.
- An Antigravity account with Codex's unknown-model prompt ("You are a
  coding agent running in the Codex CLI"): the cloak breaks only the
  GPT-5 identity lines tried before.
- A remote Codex below 0.166 with many models through a gateway key: it
  lists fewer than before; the used ones FitOwn moves into the first 100
  can fall past the 48 that fit.
- A real ChatGPT account's models_cache.json entries (tested with a
  fixture cache).
2026-11-01 22:30:51 +08:00
yetone 546cdbde6b gui tests: claude-mode moves the pointer off the page once the editor is opened (#4638)
The "both modes on hover" tests found the hover card up before their
hover in WebKit. The click that opens the editor leaves the pointer on
the provider row, at (450,110) at 900px and (210,110) at 420px, and the
editor draws its TUI / claude -p switch there: a probe printed the
switch at [306,96,515,121] (en 900) and [171,78,378,126] (en 420), and
the card up in those runs. WebKit sends mouseenter for a pointer that
never moved once something is drawn under it. openEditor now moves the
pointer to (0,0) right after the click, before the editor is read.

Run in WSL (magpie-desktop, Playwright 1.62.0) at origin/main 276c806db:
- before (main): the webkit hover tests red in each run, 1 to 3 of 10
  (ja, de, en, at 900 and 420; which ones changes from run to run);
- after: BROWSER=webkit, the hover tests 3 times, 10/10 each; the whole
  file in chromium and webkit 44/44.

Not tried: mote (its disk is full); the rest of the GUI suite (no other
file uses this openEditor).

Fixes #4638
2026-11-01 22:27:23 +08:00
yetone b4d1c393c1 redact: a Chinese session's words before a missing module are read as cheaply (#4766)
The #4766 fix read the last 64 bytes before the quote, but fell back to
lowering the whole text before it when those bytes were not ASCII. A
session written in Chinese is not ASCII, so it kept the quadratic cost
the fix removed. Lowering is rune by rune with no context, so the last
bytes of the lowered window equal the last bytes of the lowered whole
text; the fallback is dropped. The spaces before the quote are now
trimmed before the window is taken, so more than 64 of them no longer
hide the words.

Run (mote-run, -tags nogui):
- go test ./internal/redact: ok.
- With ggbdpq's model.go: the new Chinese case is red (450560 bytes made,
  8 KiB at most). With main's: red (401408 bytes). With the window taken
  before the trim: the many-spaces case is red.
2026-11-01 22:23:51 +08:00
ggbdpq d3bf8f7394 fix(redact): an error's words for a missing module are read before the quote, not the whole body before it (#4766)
What changed

missingModuleAt said a quoted name is a module an error could not load by
lowering everything before the quote. A session's body holds a place a known
value turns up at for each turn it has been in the history, and knownSpans
asks packageAt at each of them, so every such place paid the body's whole
length again — a 555 KB turn held 1m54s in the masking, past the unrouted
budget, and was answered 504 (#4766). The words stand right before the
quote; what is read of what is before them is the last 64 bytes of it now,
as assignedSecret reads the 64 before the value it judges. A letter a lower
case folds wider than in those bytes reads the whole text before the quote,
as before. Nothing of what is masked changes.

Run

- RED (product file reverted, test kept): TestMissingModuleReadsOnlyTheWordsBeforeTheQuote
  fails with "judging the words made 401440 bytes, 8 KiB at most".
- GREEN: the test passes; go test -tags nogui ./internal/redact/ passes.
- A session that grows turn by turn, Personal on and config-dense as the
  report has it: a 925 KB turn went from 3.8s to 0.76s, a 560 KB turn
  masks in 0.2s; the rest of the cost is the rules' own linear scan.
- go vet on darwin, linux/amd64 and windows/amd64; builds on all three;
  gofmt clean; BenchmarkMaskLongSession unchanged on its shape.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
yetone 7126f7de3e gateway: only the user's "it sees" lifts the small models' shape guess, and a group's ID stays out (#4359)
Review of ggbdpq's aa378a4f6 (the commit before). Its comment says a
group's, auto's or a subscription's agent-written ID stays out whatever
the user said of it, but the code put those guards inside the same
"user said nothing" branch, so a group/ or auto/ ID with a modelImages
entry entered the pool. And any answer lifted the guess, a "takes no
images" too: that says nothing of whether the ID is a vendor's model,
yet let a colon or *-embed/-tts/-free ID into the searcher's small
model pool, which has no image keep to hold it back.

Now the structural guards stand for every model, and only a modelImages
true lifts the colon/word guess.

Run (mote, -tags nogui):
- TestSmallCandsLiftOnlyWhatTheUserSaidSees, new: red on aa378a4f6
  ("pool [cn:text-only cn:sees group/g auto/a], want only cn:sees"),
  green here.
- TestAutoVisionPicksANamespacedIDTheUserSaidSees (ggbdpq's): red with
  search.go at origin/main 85e37162e (AutoVision = ""), green here.
- -run 'TestAutoVision|TestRankSmall|Small|Searcher' ./internal/gateway: ok.
2026-11-01 22:23:51 +08:00
ggbdpq 4932a8bd1c fix(gateway): a model the user said sees is picked though its ID carries a namespace colon (#4359)
What changed

AutoVision never picked a model of a relay whose IDs carry a vendor
namespace (cn:deepseek-v4.1-flash, gateway key 21/cn:…), though the user
had marked every one as taking images in settings.json's modelImages:
smallCands dropped every model whose lowercased ID holds a colon or a
tilde, and the drop came after keep (seesAt) had read the user's answer,
so their word never reached the pick — the pool came out empty and seer()
said no model sees, while naming the model in vision worked.

smallCands now reads the pool's settings once and leaves a model the
user gave an answer about (ImageOverride) in the pool whatever characters
its ID carries: their answer names one of the vendor's models in full,
which is exactly what the colon, the tilde and the nano/lite/image/…
words were guessing at. The shape filters stand for every model they
said nothing of, and the structural ones — a group's, a found group's,
and, on a subscription, what magpie wrote into its agent — stand even
for a model they did name. The searcher's pool reads the same answer:
the filters are one judgment, and a model the user proved real can be
searched with too; a relay is asked to search only where it was before.

Run

- TestAutoVisionPicksANamespacedIDTheUserSaidSees (new) fails on the old
  smallCands with "AutoVision = \"\", want
  relay/cn:deepseek-v4.1-flash, the model the user said sees" and passes
  now; it also holds that with no answer of the user's the model stays
  out, and that their "takes no images" keeps it out.
- go test -tags nogui -count=1 ./internal/gateway/ (whole package).

Fixes #4359

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
ggbdpq 8d7439a1a0 gateway: a translated system turn is folded for a Responses upstream, and a relay's "Upstream request failed" 400 fails a group over (#4632)
Two faults, one turn. Claude Code 2.1.296 and later send their
environment as a message with role "system" inside messages
(Request.envInTurns). The Chat and Anthropic builds fold such a message
into the system prompt (responseInstructions); buildResponses wrote the
role as it came, and a relay whose Responses endpoint fronts the ChatGPT
backend — which takes user, assistant and developer alone — answered
every translated turn 400 "Upstream request failed". That 400 matched
none of the wordings that make a 4xx retryable, so the holdWriter held
it as final and the group's second member never ran: the relay's answer
went to the agent, every turn.

What changed: buildResponses folds a translated request's system and
developer messages the way the Chat and Anthropic builds do, keyed on
the read. A Responses client's own instruction items are kept by the
read (#2532) and go where they stood; so do a codex account's, which
its send says as developer ones in place (codexBody — the fold would
move them out of conversation order, so buildFor marks the account's
requests kept). A translated request's system message is the harness's,
so it is said in the instructions, and one after a reply is told as a
user <system-reminder>, as on every other target. A relay's own word
that the provider behind it turned the request away ("sub2api: Upstream
request failed", type upstream_error — the words the Codex compaction
already reads, #866, #1511) joins the wordings that make a 400 or 422
retryable (retryable) and fail a group over (shapeRefused): the next
member is asked, and nobody rests. A 400 that says nothing of the kind
still ends the route, as a bad request would fail on every member
alike.

Run: TestClaudeSystemTurnSaidInTheInstructionsOnResponses and
TestGroupFailsOverARelaysUpstreamFailed, red at upstream/main 77e853588
and green here; TestUpstreamFailedWordsFailARelayOver's guards (a 401,
403 or 429 with the words, a plain bad request, and an
insufficient_quota beside them keep their reading); the codex account's
own shape (TestCodexAccountUpstream, both clients), the instruction
roles contract (TestResponsesInstructionRolesThroughSearch,
TestResponsesInstructionsOtherAPIsUnchanged), the compaction, group and
retry families, the full gateway package, gofmt, vet on darwin, linux
and windows, and builds of all three (-tags nogui).

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
ggbdpq 65fc2efa44 gateway: a Chat legacy function_call carrying nothing is left out (#4659)
jinccc-ctrl on #4659: with tools declared and the model answering in text
alone, WorkBuddy's stream ended on a frame whose function_call was an
empty object where the contract has null, and OpenMausBot, which checks
every frame's shape, read the empty object for a legacy call and refused
the whole turn ("legacy function_call is unsupported; use structured
tool_calls") — so every text reply a tools-carrying request got was a
turn lost, while clients that merge silently never noticed.

An empty function_call — a name and arguments both empty — says nothing
and runs nowhere, so chatTidy leaves it out, as it leaves out an empty
reasoning_content, an empty tool_calls and a nameless call (#1475). A
null goes as it came, and a call whose name or arguments hold something
is one a client may still be reading: both untouched, as is a name or
arguments of another kind than a string.

Run (darwin/arm64, go test ./internal/gateway/ -tags nogui):

  internal/gateway/function_call_null_test.go:32: an empty function_call
  object went out where the contract has null (#4659) — before the fix;
  after, TestStreamedEmptyFunctionCallLeftOut and
  TestStreamedNamedFunctionCallKept pass, the full gateway package
  passes, and gofmt, go vet, -race on the targeted tests and
  linux/windows/darwin builds are clean.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 22:23:51 +08:00
yetone 9da9bfabdc gateway: Grok's reasoning goes back to it through a Claude, Chat or Gemini client (jenryai on X)
jenryai uses Grok through Claude Desktop and sees repeats and broken tool
calls that Grok Build doesn't make. Diffing Grok Build 1.0.67's captured
requests against magpie's: Grok Build asks for
include ["reasoning.encrypted_content"] and sends every reasoning item,
encrypted_content and all, before the function_call it led to. Through a
Messages (or Chat, Gemini) client magpie never asked for that reasoning,
and those clients have no place to keep a Responses item. So every step
of a tool loop reached Grok without the reasoning behind its earlier
calls.

Now, for a Grok plugin request from a client that isn't Responses:
- the request asks for reasoning.encrypted_content (askSealedReasoning);
- the sealed reasoning items before a call are kept on disk by hash, the
  same store as Gemini's thought signatures, and the call's id carries
  the key: <id>__rk16__<key> (carryReasoning, on both the whole and the
  streamed paths);
- on the way back afterParse strips the key from the call and its result
  and puts the items in front of that assistant turn (unreasonCalls).
  buildResponses already sends such sealed parts back.
A key magpie no longer has, or an id cut short, goes as before. A
Responses client keeps its own items and is unchanged.

The test fixture testdata/grok_reasoning_then_call.sse is a real Grok
stream (reasoning, then message, then function_call, interleaved).

Run (mote):
- at the base 85e37162e: go vet ./internal/gateway on darwin,
  GOOS=windows and GOOS=linux; go test ./internal/gateway -count=1
  -timeout 45m: ok (969.6s)
- at the pushed head, rebased on 276c806db (which changes host.js, no
  internal/gateway file): go vet ./internal/gateway and go test
  ./internal/gateway -run 'Reasoning|Sealed|Grok|Plugin|Signature'
  -count=1: ok (108.9s). The whole package was not run again there.
- real Grok account (opencode-grok-auth 0.2.3, grok-4.7, effort high)
  through a sandbox magpie built from this tree, Messages client, a
  three-call tool loop (read, read, write the sum), streamed and whole:
  both wrote 462. A mitm capture of each of the 8 upstream requests
  shows the include, and turn N carries N reasoning items
  (encrypted_content 383/179/891 bytes) before their function_calls
  under the plain call ids; every reply was 200.
Broken by hand:
- carryReasoning returning dec unchanged:
  TestGrokReasoningGoesBackThroughOtherAPIs red ("carries 0 items").
- asksSealedReasoning false: TestSealedReasoningAskedOfGrokAlone red
  ("include []" for anthropic, chat, gemini).
Not tried:
- the reporter's broken calls themselves were never reproduced (a real
  10-turn Claude Code run through the live gateway had none); the cause
  is from the diff with Grok Build.
- Claude Desktop itself; a Gemini client end to end (unit-tested only).
- reasoning before a text-only turn is not carried (no call id to ride).
- magpie's own search rounds (search.go) don't know the client's API and
  are left as they were.
No plugin change; the mover's min stays.
2026-11-01 22:21:00 +08:00
yetone 276c806db2 plugins: a plugin's own requests are counted; a provider plugin's options get the editor (plugins#592)
zelong77 asked for two things once Devin 0.1.30's cache keep-alive
worked: its pings were invisible in magpie, and the interval and ping
count could only be edited in plugins.json. The owner decided pings are
shown as counted usage and the two numbers are edited in the GUI.

- host.js gives plugins input.magpie.usage(provider, call) and
  input.magpie.account(provider). usage validates the call (kind
  [a-z0-9_-]{1,40}, a model id, whole-number tokens from 0, status at
  most 999, error clipped to 500) and sends an unasked "usage" event;
  host.go hands it to plugin.OnUsage in the background.
- internal/usage/plugin_calls.go writes each one as a row of agent
  magpie on the plugin's provider (provider.PluginID) and account
  (provider.PluginAccountUser), with its kind. It is counted, priced
  and in every total, not a probe. Kind cache_keepalive is in the
  purpose catalog as "Cache keep-alive" (five languages), so the
  request log names and filters it. The ping itself still goes straight
  to Devin, never through the gateway, which would break the cache.
- /api/plugins reads every plugin's package options example, not only a
  middleware's or request hook's, and the Installed row offers the same
  Options JSON editor for a provider or agent plugin that suggests or
  has options (not while it is off). Clear's confirm no longer calls
  them a middleware's options.
- The Devin mover's min is 0.1.31, which reports each ping and gives
  its two settings' defaults (285 s, 6) to the editor. npm has 0.1.31
  (published 10:03Z); the plugins publish run is red only for
  think-tags' known E404 (plugins#180).
- docs: provider-plugins.md (the API, the options editor),
  gateway-sessions.md (the counted row beside probes).

Run at this tree (rebased on origin/main 85e37162e):
- mote (mote-run): go test -count=1 -timeout 45m ./internal/plugin
  ./internal/usage ./internal/gui ./internal/provider: plugin, usage,
  provider ok; gui red only in TestMainWindowCorners/macOS_26_SDK, the
  macOS 27 red already filed as #3949 (not this change's code).
- mote: GOOS=linux and GOOS=windows go vet of plugin, usage, provider ok;
  gofmt -l clean.
- mote: plugin-provider-options.test.cjs (new, 5 languages, 980/420px,
  Chromium + WebKit), plugin-gateway.test.cjs and i18n-keys.test.cjs:
  28 of 28 pass.
- The whole GUI suite (make test-ui) on WSL magpie-desktop (mote was at
  load ~100 with other sessions' suites, #4125), at the 8f804396f base:
  cut off after 498 test entries, when the session's background jobs
  were killed; 495 ok, 3 red, none on a page this change touches. Run
  again alone at origin/main 85e37162e, the same files are red there
  too: account-eye webkit (#4244), agent-expand-steady webkit 980px
  (#2935), add-button zh's 3000ms waitForFunction (filed #4792). The
  rest of the suite was not run.
Broken by hand (each red, then put back):
- host.go dropping the "usage" event: TestPluginReportsOwnUsage fails.
- plugins.go reading optionsExample for middleware/hooks only:
  TestProviderPluginOptionsExample fails.
- purpose.go without the Cache keep-alive kind:
  TestPluginKeepaliveIsCounted fails (purpose {}).
- plugins.js without ownOpts: plugin-provider-options.test.cjs times
  out waiting for the Options button in every language.
Not tried: a real Devin account's keep-alive ping reported into a real
magpie (needs a live Devin conversation idle for 285 s); a plugin can
report a row for any provider id, as magpie.load can.
2026-11-01 22:14:19 +08:00
yetone a63766b071 context: Use on Codex's window reads "In use" over 7 and 30 days too (hoobnn)
hoobnn on Discord (#general, after v0.1.2572): on Usage > Context, Use
on Codex's Compact at showed "In use" with Undo over Today, but over 7
or 30 days the card never said "In use".

Cause: adviceRow checked `same` (Now equals the advice) before
`applied` (magpie put the advice in). Over 7 and 30 days the moved
models' Now reads the advice after Use, so the chip said "Already the
leanest for how you work". Today's calls were Codex's own models, so
Now stayed and `applied` won. Now `applied` is read first, in every
range; adviceRow is the only place the verdict is drawn (Claude rows
and TTL rows go through it too).

Test: context-tune's new "Use on Codex's window is In use with Undo
over Today, 7 and 30 days" (every language, 360 and 1100 wide), and
three existing assertions that wanted "Already the leanest" after Use
now want "In use".

Run:
- Red on the old code (mote, base 9621168c4, old context.js + new
  test): 20 of 30 subtests per engine red, all of 7 and 30 days,
  "Expected 'In use', actual 'Already the leanest for how you work'";
  the three updated tests red too. Today passed.
- Green at da275848b (wsl-run; mote is out of disk, ENOSPC on Go
  builds and browser launch): go test -tags nogui -run
  'TestCoreScriptBudget|TestTune' ./internal/gui/ ok; node --test
  context-tune.test.cjs i18n-keys.test.cjs 244/244 in Chromium and
  WebKit, en/zh/zh-TW/ja/de.
- origin/main moved 3 commits since (85e37162e), none touching
  context.js, its test, tune.go, i18n.js or internal/tune.

Broken by hand: putting the old order back turns the new test red
(above).

Not tried: the whole GUI suite (a broad WSL run of the context files,
i18n and the zh-TW/ja/de files was killed from outside at ~91 tests,
none failed by then). hoobnn also said Undo was missing over 7 and 30
days; on the old code Undo showed there (the test's wait for Undo
passed), so that part was not reproduced. hoobnn's real Codex config
was not tried.

Reported-by: hoobnn (Discord)
2026-11-01 22:09:06 +08:00
yetone 85e37162e9 routing: a route group can be held to chosen accounts (duanckham on X)
duanckham has a personal and a company GPT account, one tool and one
gateway, and wants a group's GPT models to spend only the company
account (or only his own). A second gateway key doesn't fit: his tool
talks to one gateway, and a local agent needs no key at all.

Group.Accounts holds a group to some accounts or keys of the providers
it names, in a gateway key's form and by the key's rule (#905,
Identity.AllowsAccount). The asked group narrows the request's
identity (access.Identity.HeldToGroup: the strict intersection with
the key's own list; "<provider>/\x00" when they share none), so every
gate a key's accounts go through holds the group's too: chat,
responses, messages, count_tokens, embeddings, images and video,
streamed or not. A group reached inside another, as a member or a
fallback, is held in planLevel (hold, Member.Via): its candidates on
an excluded account are Held rows with Weighed.HeldBy, which the
Routing trace tells. Fallback stays within the group's entries; with
every allowed account resting or out the group's usual error comes
back, and a key and a group that share no account get a 403 naming
the group, nothing asked upstream. SaveGroup resolves each entry
(ResolveAccount, shared with the key's CleanAccounts); share and
import drop them. A group without accounts is as before.

GUI: the group editor's Accounts section, a row per member provider
with two or more accounts, "Any of its accounts" until some are ticked
in the app menu (openPicker multi). Every save sends accounts, since a
save replaces the group. Strings in all five languages.

Gateway keys stay as they are: Gateway › "Gateway keys are for other
computers … added here once Share on local network is on" already says
where, and this case needs none.

Run (mote, through mote-run), at cafed0067 on origin/main 9d08993c8:
- gofmt -l internal/: clean. go vet of access, gateway, provider,
  gui; GOOS=linux -tags nogui and GOOS=windows go vet ./internal/...:
  ok.
- go test -count=1 ./internal/access ./internal/provider
  ./internal/gateway ./internal/gui: access, provider, gateway ok; gui
  red only on TestMainWindowCorners/macOS_26_SDK, red on main too
  (#3949, mote's macOS 27).
- node --test group-*.test.cjs routing-group-*.test.cjs
  routing-save*.test.cjs i18n-keys.test.cjs: 433/434. The one red is
  group-found-skip "webkit de 390px: a provider left out of found
  groups" (the clicks moved the page), filed as #4617 from main; the
  file alone passes 20/20 here and on main 94f6f6092.
  group-accounts.test.cjs is 30/30 (Chromium and WebKit; en, zh,
  zh-TW, ja, de; 1100 and 420px; no scroll on the clicks, no sideways
  scroll, the save carries accounts).
- Earlier, at base 5a0c79ed9: go test -timeout 45m ./... all ok but
  TestVisionBridgePassesLines and TestSettingsSaveKeepsWhatItDoesNot-
  Send (fixed on main by 0b783b1dd and b646a9127; both pass after the
  rebase) and TestMainWindowCorners (#3949).
- The whole GUI suite was cut short twice (a wiped scratchpad, then a
  mote reboot). Its runs at load ~140-220 had about 35 reds, none in a
  file this change touches (account-mask, balance-fix, lan-*, the
  #4617 test among them); not chased here.
- Sandbox HOME on mote, the built binary (`magpie serve`, MAGPIE_ADDR
  on a free port) with a fake upstream answering with the key it got:
  group/work and Work -> sk-work (3 of 3), group/mine and relay/m ->
  sk-mine.

- Rebased again onto 8826a15ea (no file in common): go vet of gui,
  provider, gateway; go test -run 'TestGroupAccounts|TestHeldToGroup|
  TestCleanAccounts|Budget|TestGroup' of gateway, access, provider,
  gui: ok; group-accounts and i18n-keys GUI files: 34/34.

- Rebased onto ec104b862 (trace.go and gateway-routing.md in common,
  merged clean): gofmt clean; go vet of gateway for darwin, windows,
  linux nogui; go test -count=1 ./internal/gateway: ok (640s).

- Rebased onto 2b52302dc, then da275848b (no file in common): go vet ./internal/...,
  the TestGroupAccounts/TestHeldToGroup/Budget tests, group-accounts
  and i18n-keys GUI files: ok, 34/34.

Broken by hand, each red, then restored:
- serve's heldByGroup: three TestGroupAccounts* tests red (sk-mine spent).
- count_tokens' heldByGroupAt: the count_tokens route red.
- planLevel's hold: the nested "outer" group red.
- the editor save without accounts: group-accounts.test.cjs red.

Not tried: a real Codex or OpenAI account (the fake upstream stands
in); a CLI `magpie group set accounts=` (no CLI for it yet); a
provider's own fallback naming a held group has no test of its own
(planFallbackGroup passes the group as hold, the same path as nested).
2026-11-01 21:36:32 +08:00
yetone 049848c5ed claude: a branch of a -p run's session goes to the interactive mode, told whole
With the interactive mode on, tool results another request answered
first for a run made as claude -p (before the mode was turned on) were
refused with a 502 (claudePrint's "branch"): the branch would have gone
on as -p. It now starts a new interactive Claude Code told the whole
conversation (startRun): -p's prompt isn't the interactive mode's, so
the cache has nothing of the -p session to read either way, and nothing
runs as -p while the mode is on. This is the second refusal behind
@crosscn's 502 on an old conversation (X, 11-01); the first, words over
400KB, went in v0.1.2614.

- startRun drops such a branch (from and req.branch nil) and logs it;
- the "branch" entry in claudePrint is gone;
- docs/subsystems/claude-subscription-bridge.md says so.

Test: TestClaudeTUIBranchOfPrintRunIsToldWhole (a -p run's saved
session given as the branch: the run is interactive, has no --resume,
and is told the first words too; req.branch is cleared).

Run on mote (go1.26.8), at origin/main da275848b plus this change:
gofmt, vet (darwin, windows, linux -tags nogui) ./internal/gateway ok;
go test -run Claude ./internal/gateway ok (61s); the fork, branch and
cut tests (-run 'Fork|Branch|Cut') ok before the rebase.

Broken by hand: the new block turned off: the test red, the run resumed
the -p session with -p's arguments.

Not tried: a real -p branch with real Claude Code (it needs a -p run's
lead parked on calls when the mode is switched); whether @crosscn's
conversation reached this path rather than the 400KB one; the full go
test ./... (the gateway's Claude tests ran).
2026-11-01 21:36:20 +08:00
yetone 900852e1c9 gui: an editor's Advanced fold reads as a control (sylvenPR on X)
sylvenPR on X: the 高级 fold at the foot of Codex's editor didn't look
like something to click. It was a 5px "▸" text glyph in the muted grey,
with a default cursor and nothing on hover, so it read as a disabled hint.

An editor's fold (.editor .more: Advanced on every provider, and a custom
provider's More endpoints) is now a macOS disclosure: a 10px chevron drawn
with a mask (turned down when open, as before), the label in the form
labels' colour (--fg-2), a pointer, the label and chevron brighter under
it, and a focus ring. The chevron still starts where the fields do
(--ed-at); no gradient, accent or layout change beyond the control.
The reporter's misalignment is not on main: editor-advanced-align already
holds it to the field column (their build predates that).

New test: editor-fold-clickable.test.cjs, Chromium and WebKit, dark and
light, en/zh/zh-TW/ja/de, Codex's Advanced and a custom provider's More
endpoints: pointer cursor, chevron >= ~10px and not a text glyph, label
colour equal to the form labels', a hover change, and it still opens.

Run (mote, through mote-run / ssh, playwright 1.62.0):
- At the pushed head, rebased on origin/main da275848b: editor-fold-clickable
  and editor-advanced-align ok in both engines; nav-timeout red from
  window-visibility.test.cjs (dfe868a1e), filed #4787.
- At the previous rebase (origin/main ec104b862): the 36 GUI files
  that reach an editor fold (editor-fold-clickable, editor-advanced-align,
  balance-*, provider-*, vertex-editor, zhipu-team, ...): 910 tests, 864
  pass. The 46 reds are balance-fix (#4682, #4683), vertex-editor (#4720,
  #4721) and zhipu-team (#4728); each red alone the same count at
  origin/main as at this head.
- Whole GUI suite (both engines) at base 1d8ded3ec with this change: mote
  rebooted after 243 of 1099 files; files 244-1099 rerun from there. Reds
  named, each run alone at origin/main and at this change:
  account-arrange webkit (#2200, passes alone), agent-panel-name-width
  (#4203), allow-ips (#4357, #3699), balance-fix (#4682, #4683),
  editor-advanced-align chromium under load (#4615, passes alone),
  cors-origins, context-map and gateway-key-models webkit (red the same
  at base). Second half: 39 red files, none reaching the fold; alone,
  main vs this change: model-chip-steady, model-copy-id,
  models-works-only, provider-fetch-again, provider-models-rest,
  provider-picks-stay, provider-typed, provider-levels-scroll,
  models-select-all-api equal; key-replace 5 vs 4, rest-try-now 5 vs 6,
  models-fold 1 vs 0 fails (timing, mote's main reds #4304, #4471,
  #3393); nav-timeout's red is balance-quota-left. The resumed second
  half was still running at push (184 not-ok lines so far).

Broken by hand: the old CSS fails the new test (cursor default); a 6px
chevron fails it ("the chevron is 6x6"); a hover rule with no change
fails it ("doesn't change under the pointer").

Before/after screenshots (Codex editor, zh and en, dark and light, both
engines, plus hover) were compared by eye.

Not tried: the real app's WebKitGTK on Linux and WebView2 on Windows; the
other <details> disclosure (Context's cx-part, a different component,
already a pointer) is left as it was.
2026-11-01 21:36:01 +08:00
yetone da275848b6 tray: Windows shows a card's number in its icon (Benjaminliang_1 on X)
Windows' notification area shows no text beside an icon, so with a card
in the tray the icon itself is now the first card's figure: the first
row of the first card whose first row is a percentage, used or left as
Allowance display has it, its digits alone (trayIconFigure). It is drawn
in Segoe UI Semibold (Go's bold if the font can't be read) at
SM_CXSMICON, white on a dark taskbar, near black on a light one, as tall
as fits, centred by its ink, three digits narrowed into the square
(trayNumberIcon). It is drawn again when the figure, the icon size or
the taskbar theme changes (SystemThemeChanged wakes the loop); the
tooltip still lists every card. A balance or magpie's totals are
skipped; with no such card, or no cards at all, the icon is the bird as
before. Settings > Usage > Tray icon number (settings.TrayNoNumber,
Windows only, on by default, kept per computer) keeps the bird when off;
Menu bar windows is now shown on Windows too, since it picks the row
the number comes from. The number row sits after Menu bar cost, so the
bird > pace > cost order the other tests pin holds. Linux and the Mac
are unchanged. New words in zh, zh-TW, ja and de. app.js stays in the
core budget with one comment shortened, no raise.

Run at this commit on origin/main ec104b862 (traywindows.js merged with
94f6f6092's trayExtra pills; its "not on Windows" note dropped), mote:
gofmt -l empty; go vet and GOOS=windows go vet of gui and settings ok;
go test -count=1 -timeout 45m ./internal/settings ./internal/davsync
ok; ./internal/gui red only on TestMainWindowCorners (#3949),
TestCoreScriptBudget ok. GUI tray-windows, tray-cost, quota-pace,
i18n-keys, tray-bird, tray-logos, tray-usages, quit-ask: 140 pass,
0 fail. win-run on xiaomi-gpu: TestTrayNumberIcon and
TestTrayIconFigure ok. At c0477aa72 the same GUI set once had
quota-pace webkit "On moved the page" (439 !== 120), a late wheel
(#4784); green twice after, and quota-pace alone 3 of 3 green there
and on c0477aa72 itself.

Run before on the same change over origin/main 9d08993c8, mote:
- gofmt -l on gui/settings/davsync: empty; go vet ./internal/gui
  ./internal/settings and GOOS=windows go vet: ok.
- go test -count=1 -timeout 45m ./internal/gui ./internal/settings
  ./internal/davsync: settings ok, davsync ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949) and TestCoreScriptBudget
  (5 bytes over after the rebase), which is green after the comment
  trim, rerun with TestTrayNumberIcon and TestTrayIconFigure: ok.
- GUI (both engines): tray-windows, tray-cost, quota-pace: 56 pass,
  0 fail. Earlier at this tree: tray-bird, tray-logos, tray-usages,
  i18n-keys green; quota-pace webkit de 420 red once, from a late wheel
  scroll (#4784), green on the rerun; segs-press-redraw red on
  searchAllRow, the same on a clean origin/main 9d08993c8 copy (#4566).
- A 184-file GUI run (the files touching Settings, the tray or i18n,
  before the rebase) under mote load 40-90: 3095 pass, 224 fail. My
  files' reds there (tray-cost: the number row was between pace and
  cost) are fixed above. The rest are in files this change doesn't
  reach (account-alias, model chips, menu-input-scroll, mobile-web,
  omarchy, plugin-github, key-replace, context-map and others; #4600
  lists several). Each was not compared on main one by one.
Windows (win-run on xiaomi-gpu, real Segoe UI): TestTrayNumberIcon and
TestTrayIconFigure ok.
Real Windows 11 run: a production build in a portable sandbox (own
data\, USERPROFILE/APPDATA/LOCALAPPDATA redirected, gateway on a free
port, a fake remote magpie serving one Claude card). The dark taskbar
showed a white "42", then a narrowed "100" when the card read 100%,
and the bird with trayNoNumber set. Only my processes, tasks and
NotifyIconSettings entry were removed afterwards.

Broken by hand: trayIconFigure always "" turns TestTrayIconFigure red
(6 cases); the dark and light colours swapped turn TestTrayNumberIcon
red; the old advance-width centring turns it red too.

Not tried: a light taskbar on the real box (it would change the user's
theme; covered by the test only), hovering the tooltip (screen locked),
other DPIs on real hardware, Windows on ARM64. Linux's code is
unchanged and was not run.
2026-11-01 21:31:55 +08:00
yetone 2b52302dcb claude: the interactive mode takes a first message of any length
@crosscn on X (11-01): after the upgrade made the interactive mode the
default, a week-old conversation (a DeepSeek harness on a Claude model)
got a 502, and worked again only with -p turned back on. A conversation
told whole to a new interactive Claude Code is its first message, and
words over 400KB were refused (claudePrint's "big", tuiPromptMost). The
bound was never tried: the commit that set it lists "a ~400KB paste"
under Not tried.

Tried on real Claude Code 2.1.316 in a sandbox HOME, haiku: a 3MB
bracketed paste showed "[Pasted text #1 +46154 lines]" after 35s; a
500KB one was sent, its transcript holds every line and the question,
and the model answered it (184,168 tokens written to the cache).

- tuiPromptMost and the "big" refusal are gone; claudeTUI, claudePrint,
  claudePrintWhy and claudeNotTUIWhy no longer take the prompt, which
  only that bound read.
- the helper waits for a paste to show a second per 64KB longer than
  pasteWait (shownWait): 10s alone would press Enter while a 3MB paste
  was still being taken in.
- the editor's tooltip says -p takes what the interactive mode can't
  "yet": a JSON schema (en, zh, zh-TW, ja, de).
- docs/subsystems/claude-subscription-bridge.md says so.

Tests: TestClaudeTUIBigFirstMessage (a ~1.1MB first message runs through
the helper, 200), TestShownWaitGrowsWithThePaste; TestClaudeTUIOnRefusesPrint
refuses a JSON schema now; TestClaudeTUIChosen's long-message row runs
interactively.

Run on mote (go1.26.8):
- full go test ./internal/gateway ./internal/claudetui (-timeout 45m) at
  15b035eef plus this change: claudetui ok, gateway red only on
  TestClaudeTUIOnRefusesPrint's -p half (the fake's "ok" fits no schema,
  502); that half now checks that -p ran it, not a 200. gofmt, vet
  (darwin, windows) ok; claude-mode and i18n-keys GUI files 44/44 and
  4/4 in chromium and webkit.
- rebased on origin/main ec104b862, at the pushed tree: gofmt, vet (darwin,
  windows, linux -tags nogui) ok; go test -run 'Claude|Budget'
  ./internal/gateway ./internal/gui ok; ./internal/claudetui ok;
  claude-mode 44/44, i18n-keys 4/4 in both engines.
- a real run through the helper (magpie built from this tree, real
  Claude Code 2.1.316, sandbox HOME, haiku): a 600KB first message as
  stream-json, answered "MANGO" in 12.5s, its transcript holding all of
  it.

Broken by hand: the 400KB refusal put back: TestClaudeTUIBigFirstMessage
red with the reporter's 502; shownWait returning pasteWait alone:
TestShownWaitGrowsWithThePaste red.

Not tried: the reporter's own conversation or a DeepSeek harness; a
first message past the model's context (Claude Code's own error then,
as with -p); a paste over 3MB; Windows or WSL with a large paste; the
whole go test ./... (the gateway and claudetui packages ran whole
before the rebase).
2026-11-01 21:30:04 +08:00
yetone 93b9d385f1 gui: the allowance alert's Chinese and Japanese say a share used, not reached (fRoAme)
fRoAme (Discord #feedback): 「用到此比例」 reads as either 80% left or
80% used, and magpie shows windows either way. The alert counts the
share used, so zh and zh-TW now say 已用掉的比例达到此值 and the
session line says 已用掉窗口额度的 {pct}; ja says 使用率 / を使用した.
en and de already say "share used".

Run on mote: node --test usage-alert.test.cjs i18n-keys.test.cjs,
Chromium and WebKit, 14 of 14 ok. usage-alert pins the zh line and
fails on the old one. Not tried: the real app.
2026-11-01 21:29:10 +08:00
yetone 8f804396fd mcp router: the hub says what its servers are for, and Pi's first prompt hears it
Asked "can you drive a browser?", Pi said no until nudged. Two causes:

- The hub's initialize instructions were one generic sentence ("The tools
  of the MCP servers ticked for this agent…"), so nothing said that
  playwright drives a browser or deepwiki answers about GitHub repos.
  They now start with one line, "Tools of context7 (…), deepwiki (…),
  playwright (Drive a real browser), …", at most 250 characters (names
  first, "and N more" past room, abouts shared out short-first), then a
  "- name: about" line per server. An about comes from the market entry
  the server was added from (by key, then by name), else none.
- Pi 1.4.0 lists a codemode server in its system prompt by its config
  description, else its instructions' first line, but writes the first
  prompt without waiting for codemode servers. In -p runs the first
  prompt had "- mcp__magpie (codemode)" and nothing after it. The hub
  entry in Pi's mcp.json now carries that line as its description,
  kept in step with the servers ticked; a description on another entry
  is the user's and is left alone. Pi only: other formats are unchanged.

Sync runs under the library lock, so the hub's servers are read from the
library already loaded ((*Library).hubServers), not through hubServers().

Run (mote, at origin/main ee7b8b072 + this change):
- go test ./internal/library ./internal/gateway -run 'TestHub|TestPi'
- TestHubMCPNamesItsServers: 10 failures without the change, green with it.
- TestHubPiDescription: red with the description assignment removed by
  hand ("the hub entry's description \"\""), green with it.
- gofmt -l, go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet,
  the three builds, go test -tags nogui -timeout 45m ./...: all ok (87 packages).

Real use: a sandbox HOME with context7, deepwiki, fetch, playwright and
time ticked for Pi 1.4.0 (deepseek through the sandbox gateway). After
`magpie library sync`, Pi's mcp.json hub entry carries the line. Five
everyday questions, none naming MCP, two runs without the description
and three with it:
- "can you drive a browser": playwright used every time.
- the H1 of usemagpie.ai: fetch + playwright every time.
- "is it OK to call a colleague in San Francisco now": bash `date`
  without the description (2 of 2), the time server with it (3 of 3).
- Hono timing middleware docs: context7 in 1 of 2 without, 2 of 3 with.
- how the Next.js App Router client cache works: deepwiki in 1 of 2
  without, 1 of 3 with; Pi mostly clones the repo instead. Not fixed here.

Not tried: other agents' first prompts (they get the new instructions
text, not a description), Pi versions other than 1.4.0.
2026-11-01 21:22:58 +08:00
yetone ec104b8625 gateway: a Codex account can spend its credits before magpie moves to another account (jojonas_xyz on X)
jojonas_xyz on X: "我账号额度用完了自动给我切了别的号…找不到怎么关掉设置…你怎么知道
我不是想用 credits 呢". (Roughly: "my account ran out of quota and magpie
switched me to another account by itself; I can't find a setting to turn
that off; how do you know I didn't want to use the credits?")

Cause. At 90% or 98% of a window, smart routing's tier put the account
behind every account that still had room, whether or not it had ChatGPT
credits. Codex's own sign-in (NextLogin / SwitchWhenSpent) moved at the
spent share in the same way. The account's credits were spent only once
every other account was used up, and the switch was a log line. The Use
credits switches that existed (on, and "Only after other accounts" from
699ddf152) were only on the Usage page and the panel. None of them meant
"stay on this account and spend its credits".

Change.
- A fourth credits mode, first: settings.CodexCreditsFirst. on, first,
  last and off are exclusive; one mode replaces another.
- routes.Seat.First: a first seat's tier is 0, so routing keeps it in
  front past its windows while it has credits. The trace records
  Weighed.CreditsFirst.
- NextLogin keeps Codex's own sign-in on such an account (spendsFirst).
- The POST /api/codex-credits handler takes "first". The general
  settings save keeps the stored value.
- The CLI: `magpie quota credits <account> first`.
- GUI. No new page and no new component, only the Use credits row that
  already exists:
  - 供应商 → Codex → 账号 ⋯ → 使用积分 → 「先用完积分再换账号」. The
    Providers ⋯ tools now carry the credits row too, which is where the
    reporter looked.
  - 用量 → Codex 账号卡 → 使用积分 → 「先用完积分再换账号」.
  - The menu-bar panel's folded line reads 「开,先于其他账号」.
  - The "First again once it has room" tag on a moved-off account now
    points to the switch in its title.
  - Strings are in en, zh, zh-TW, ja and de.
- "Only after other accounts" (gokoshiki, 699ddf152) is unchanged.
  Its off title now says what off means.
- Docs: docs/reference.md and docs/subsystems/gateway-routing.md.

Budgets: at this head app.js is 1,312,105 of 1,316,874 bytes, and
TestCoreScriptBudget passes (231 bytes under before the rebase). Comments
were condensed; no budget was raised.

Run on mote, at this tree (rebased on origin/main 9d08993c8; the rebase
moved the settings save into internal/settingsapi, which now carries
CodexCreditsFirst beside CodexCreditsLast):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
  ./internal/routes ./internal/settings ./internal/settingsapi
  ./internal/gui ./internal/cli at 9d08993c8+1: gateway, provider,
  routes, settings and settingsapi ok. Two reds, both filed:
  - internal/gui TestMainWindowCorners/macOS_26_SDK: #3949.
  - internal/cli TestLibraryMCPHub, TempDir cleanup not empty: #4140.
  At the pre-rebase tree (da0005df8+1) internal/gui also had
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken
  (#4510), red the same at da0005df8; both pass at this head.
- New tests:
  - internal/provider/codex_credits_first_test.go
  - internal/gateway/codex_credits_first_test.go (routing and the trace)
  - internal/gui/codex_credits_first_test.go (POST sequence, sandbox HOME)
  - internal/gui/tests/codex-credits-first.test.cjs: the Usage page and
    Providers ⋯ at 900 and 440px, and the panel at 360px; chromium and
    webkit, en zh zh-TW ja de. It also checks for no select, no stripe,
    the i18n keys, and that a click does not move the page.
- The whole GUI suite (make test-ui), at da0005df8+1 on mote at load
  66 to 213, in two parts (a wiped scratchpad cut the first log; its red
  titles were kept): 59 files with a red. 45 of them are red at
  origin/main da0005df8 too, each under an open issue: #4304 (mote
  umbrella), #4600, #4471, #4120, #4119, #4621, and per file balance-fix
  #4682/#4683, gui-ja #4580, page-width-steady #4541, phone-connect-menu
  #4706/#4707, quota-curve #4768, segs-press-redraw #4566, signin-proxy
  #4643/#1814, zhipu-team #4728, model-copy-id #4621 (red 4 of 4 on main).
- The 14 green at da0005df8 were run again at this tree. One was this
  change's: usage-curve-zoom-back. The Codex card's fourth credits line
  (366px, was 344) held the DeepSeek card beside it to 261px, so the
  "card grows" check at 1100px had no room. Its fixture now turns the
  Codex account's credits off, since the count of credits lines isn't
  what it tests; 20 of 20 pass.
- At this head (9d08993c8+1), on mote at load 75 to 84: codex-credits-first,
  codex-credits-last, codex-credits, routing-codex-credits-again,
  panel-options-fold, usage-curve-zoom-back, i18n-keys and the 13 files
  above: 232 tests, 227 pass. Each red has an open issue:
  - models-fold webkit en/zh, "ebody holds" after the click: #4071; red
    the same at 9d08993c8 (run there).
  - account-weight webkit, same "ebody holds": #4644 (red at
    da0005df8+1, green in this run).
  - routing-many-keys chromium de "2 keys in sight at the foot": #4082
    (under load; red again alone here, green at 9d08993c8 in one run).
  - signin-closes-sheet chromium en/zh: #2628 (green alone at this head
    in a second run).
  - signin-again and signin-port-blocked, red once at da0005df8+1 under
    load, pass at this head and at 9d08993c8.

- Rebased last onto 94f6f6092 (three commits; c0477aa72 changes the
  Codex Providers row): go test -run 'Budget|CodexCredits|SettingsSave'
  ./internal/gui ok, and codex-credits-first, codex-credits,
  codex-credits-last, providers-reset-use, i18n-keys and
  usage-curve-zoom-back: 92 of 92 pass.

Broken by hand, each red, then restored:
- spendsFirst forced false: the provider test is red.
- The gateway's l.first forced false: both gateway tests are red.
- codex-credits-first.test.cjs against origin/main's assets: red
  (TimeoutError on the switch).

Not tried:
- No real ChatGPT account with credits went past its window. The routing
  order and NextLogin are tested on fakes only.
- The Linux and Windows apps were not run.

go vet -tags nogui ./... with GOOS darwin, linux and windows on mote:
clean (cgo enum warnings only). gofmt -l on the changed Go files: clean.

Claude has no equivalent: magpie reads no extra_usage and has no Use
credits modes for Claude. Filed as #4662 (see #4241).
2026-11-01 21:19:22 +08:00
yetone 8826a15ea4 gui: a Quit while agents go through magpie asks first, naming them (Aisiverto on X)
Aisiverto on X (Windows, v0.1.2519) wired Codex to magpie and quit magpie.
Codex then retried "unexpected status 502 Bad Gateway ... url:
http://127.0.0.1:3425/backend-api/codex/responses" five times and gave up,
and it took a long search to find magpie's openai_base_url in config.toml.

A Quit the user chooses (the tray's Quit, the panel's and window's Quit,
Command-Q on the Mac) now asks first when this process serves the gateway
and agents are wired to it. The window comes up on a sheet
(quitask.js, lazy-loaded) that names each agent cut off, says closing the
window keeps magpie running (menu bar on a Mac, system tray elsewhere),
and offers Quit (focused), Disconnect and quit, and Cancel. Disconnect and
quit puts each agent back as its row's Disconnect does, then quits; a
disconnect that fails keeps magpie open, named in the status line. A
second Quit within a minute of the question quits, so a window that
can't show it traps nobody. With nothing wired, or another magpie serving
the gateway, Quit quits at once.

Not asked: a restart to update, Uninstall, a browser's page (magpie web),
logging out or shutting down, and the Dock's Quit (AppKit terminate:).

Found while checking the report:
- Closing the window on Windows hides it; magpie stays in the tray and
  the gateway keeps serving (tried for real, below). Not a bug.
- Autostart is off by default on Windows.
- The proxy / NO_PROXY in the report isn't magpie's to fix: the 502 is
  magpie's port with nothing behind it.

Strings in en, zh, zh-TW, ja and de (existing terms: Agent, 退出). No
native dialog, no <select>. TestCoreScriptBudget met without a raise:
app.js gains two lines, the sheet is outside the core, and driftFix's
comment block is cut to six lines (453 bytes back; main's core had grown
to 258 bytes over with these lines in).

Run, at this head (on origin/main 94f6f6092), on mote unless said:
- gofmt -l internal/gui: clean.
- go vet ./..., GOOS=windows go vet ./..., GOOS=linux go vet -tags
  nogui ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows
  go build: ok.
- go test ./internal/gui -run 'Budget|Quit|CommandQ', and with -tags
  nogui -run 'Budget|Quit': ok (TestCommandQAsksFirst runs AppKit in a
  child process).
- quit-ask.test.cjs, old-webkit.test.cjs, i18n-keys.test.cjs in chromium
  and webkit, en/zh/zh-TW/ja/de: 60/60 ok.
- At the previous base (9d08993c8): go test ./internal/gui (whole
  package, GUI build): two reds. TestCoreScriptBudget (258 over, fixed
  above) and TestMainWindowCorners/macOS_26_SDK, red the same at
  9d08993c8 itself (#3949, macOS 27). The nogui run of the package was
  not reached.
- The whole GUI suite: started at 24fd4a250 on WSL (magpie-desktop),
  stopped about halfway (3,915 results) to rebase; 68 reds in 28 files.
  Those 28 files with quit-ask, old-webkit and i18n-keys at 9d08993c8+this
  on mote: 74 reds in 7 files, none in this change's files. The 7 alone
  at origin/main 9d08993c8: the same 6 files red (73), and
  gateway-caller-keys red at main when run alone (1 of 4). All filed:
  balance-fix #4682 #4683, key-replace #4126 #3476, agent-panel-name-width
  #4203 (red on macOS too, commented), context-map #3488, header-centre
  #3479, gateway-key-models #4616, gateway-caller-keys #3797.
- Not run: go test ./... in full (mote at load 140-160 with others' full
  suites, WSL with two GUI suites), and the GUI suite to its end.

Broken by hand, each red:
- api.go's ask skipped (false &&): TestWindowQuitAsksFirst "the window's
  Quit didn't ask (AskQuit never ran)".
- askingQuit without RemoveMenuItem: TestCommandQAsksFirst "the app menu
  still has the Quit role".
- quitNow as asked == 0 ||: TestQuitNow "connected, never asked: quitNow
  = true, want false".
- The return after a failed disconnect removed: quit-ask 5/25 chromium
  red (the failed-disconnect test in every language).
- app.js's ?ask=quit line removed: 20/25 webkit red.

Windows, for real (xiaomi-gpu, sandbox HOME/APPDATA under
C:\Users\yeton\quitask-sb, MAGPIE_ADDR 127.0.0.1:3471, MAGPIE_NO_ACCOUNTS,
a -H windowsgui build of this branch, launched in the desktop session):
`magpie codex fakeq/m1` wired the sandbox Codex to
http://127.0.0.1:3471/backend-api/codex; WM_CLOSE on the window left
the process alive with no visible window and the gateway listening.

Not tried:
- The tray's Quit and the sheet on real Windows: WebView2's CDP port
  never listened and UI Automation didn't find the tray icon, so the
  sheet was tried in Playwright only.
- A real Codex run against the sandbox gateway before and after a quit.
- The Dock's Quit (not covered by design).
2026-11-01 21:16:35 +08:00
yetone 94f6f60925 tray: every window a card reports can be picked alone for the menu bar, Cursor's Grok Bot too (CrazyJal on X)
CrazyJal on X (tweet 2116833523604886006): Settings > Usage > Menu bar
windows, Cursor's pill had no choice for the Grok Bot window alone.

Why: the picker offered only the windows the menu bar shows unpicked
(trayWindows), which leaves out every window set aside. The Cursor
plugin reports Grok Bot aside (so it doesn't stop Cursor's models), so
it was never offered. And kinds were only a span ("7d"): Grok Bot and a
weekly plan's Weekly are both 7 days, as are Antigravity's two pools, so
two windows shared one kind, the GUI showed one of them, and picking it
picked both. The plugin reports the window fine; nothing changes there.

Fix (the class, every provider): trayChoices lists every window of a
card that the menu bar can say as a percent (trayCounted): the usual
ones first, then the rest (money aside, one model's window, Grok Bot),
marked TrayExtra and shown only when picked. Every choice has a kind of
its own: a usual window keeps its span's kind where it is the only one
of that span (so existing picks like claude:["5h"] keep working);
another of that span, and every extra, gets its model or name after it
("7d:grok bot", "7d:gemini · 7 days"). Unpicked, every card shows what
it showed before. The Settings pill offers the extras, and drops a pick
only when it is empty or exactly the usual windows.

Run (mote, at this tree, committed then as 0750aa783, on origin/main 15b035eef):
- go test -count=1 ./internal/gui ./internal/provider ./internal/settings:
  provider ok, settings ok; gui red only on TestMainWindowCorners,
  red the same on origin/main 15b035eef on mote (filed #3949).
- GOOS=windows go vet ./internal/gui ./internal/provider: ok. gofmt -l clean.
- win-run go test ./internal/gui -run 'TestTray|TestWithTrayKinds': ok.
- GUI (Chromium + WebKit, en/zh/zh-TW/ja/de, narrow): tray-windows 20/20;
  with i18n-keys, old-webkit, tray-usages, tray-totals, tray-cost,
  tray-logos, tray-inuse: every one ok but tray-windows' new subtest
  before its names were read through t() (fixed, then 20/20).
- No size budget touched; traywindows.js is loaded only with the menu bar.

Broken by hand: trayChoices without the extras -> TestWithTrayKinds and
TestTrayWindowsPickAside red; the old save rule (v.length < ws.length)
-> tray-windows red in every language.

Not tried: a real Cursor account in the real menu bar (the fixture is the
plugin's own window shape, index.mjs botUsage: aside, 7 days); the Linux
gui package (wsl-run lacks webkitgtk-6.0 headers to build it). A user who
picked "7d" on a card with two 7-day usual windows (Antigravity's pools)
falls back to every window and picks again; that pick was ambiguous before.

Rebased on c0477aa72 (app.js, Providers reset rows; nothing in common)
and run again at the pushed head on mote: go test ./internal/gui -run
'Budget|Tray|Size' ok; tray-windows + i18n-keys (both engines, every
language) 24/24.
2026-11-01 21:10:48 +08:00
yetone c0477aa728 providers, settings: a Codex account's resets are used where they are shown, its Providers row and Settings' auto-use rows (roamlog, husky_bobo on X)
roamlog on X (使用重置卡的功能哪去了): the Providers page's Codex editor
showed "↺ 2 张重置卡" on each ChatGPT account, windows at 0% left, and no
way to use one. Nothing was removed: the use (askReset, resetask.js) was
only ever on the Usage card ("Use a reset") and the menu bar panel ("Use
one…"); the Providers row's chip (#813) was words. husky_bobo (X, Windows
10, v0.1.2597, 为什么我没有这个手动用卡按钮呢?) looked for it in Settings ›
Usage, under "Codex: auto-use resets" with both times on, where it never
was either.

- Providers editor: a Codex account's "↺ N resets" is a button (a span
  with role=button, the window meters' aq-set look and hover, no colour of
  its own; Enter and Space too) opening the same confirmation, its
  tooltip saying which reset a use spends. A GLM team's resets, counted
  by window and used on the vendor's page, stay words.
- The confirmation asked from the editor goes back to it on Cancel or
  once spent (ed.back, as Sign out's does): the editor is the modal, and
  closing would have closed it too.
- Settings › Usage › Codex: auto-use resets: each account holding resets
  says "↺ N resets · until … · auto-used before it expires" under its
  name with "Use a reset" beside it, read as the editor reads them
  (loginUsageOf, cached a minute), drawn again once spent. In
  autoresetown.js, loaded with those rows.
- No new strings. The core's scripts are 1,533,441 bytes, 305 under
  their size before, budget 1,533,802 not raised: a span-as-button helper
  (spanBtn) shared with windowCapMeter, and the reset helpers' comments
  cut down.

Run, at base 9d08993c8:
- mote (mote-run): providers-reset-use.test.cjs (new: 40 cases, Chromium
  and WebKit, en/zh/zh-TW/ja/de, 420 and 1000/1100 px; Providers row
  click and keyboard, Cancel spends nothing and keeps the editor, a use
  posts {user} alone and the row reads 1, the GLM chip inert, no page
  move; Settings as the Windows app (navigator.platform Win32, web:false)
  with husky_bobo's settings, both times on), reset-providers,
  codex-auto-reset-settings, codex-reset-lead, codex-auto-reset: 114 of
  114 pass. go test -tags nogui -run 'Budget|I18n|Asset|Script'
  ./internal/gui ok. gofmt -l clean.
- Whole GUI suite: on the Linux box (wsl-run, magpie-desktop), since
  mote had three other sessions' full GUI suites running; started before
  the push, its result follows in the report, reds filed on their own.

Broken by hand (red, then put back), on mote:
- origin/main's assets: the Providers cases red ("the resets are words
  only, nothing uses one"), the Settings cases red (no .ar-own-resets).
- origin/main's resetask.js with the rest of this change: Cancel closes
  the editor (chip gone), and Settings still says 2 resets after a use.

Not tried: a real reset was not spent (fixtures only); not run in the
real Windows app on xiaomi-gpu, only with Windows' navigator.platform.
2026-11-01 20:55:02 +08:00
yetone 15b035eef0 claude: the interactive mode takes an image known by its URL
The interactive mode is pasted files, so an image a client names by its
URL alone made the run fall to the refusal list ("image"), which with
the TUI on means a 502. Now serveSubscription downloads each such image
first (fetchURLImages): from public addresses only (publicClient, the
same fetch the other providers use), checked to be an image by its
bytes, and kept by URL (32 of them) so a conversation that hands the
same URLs over each turn downloads each once. One that can't be had
fails the request with a 400 naming the URL and why; nothing of a
non-image's content is echoed. claudePrint's "image" entry stays as a
backstop, unreachable with the mode on.

The provider editor's tooltip for claude -p no longer lists the image
among what the interactive mode can't take (en, zh, zh-TW, ja, de), and
the bridge's subsystem page says how the image is fetched.

Run (mote, at this tree on 9f17ad4c1): gofmt -l clean; go vet
./internal/gateway, also GOOS=windows; go test -count=1 -timeout 45m
./internal/gateway: ok (760s), with ./internal/claudetui ok; GUI claude-mode, claude-tui-setting and
i18n-keys in chromium and webkit: 44, 16 and 4 pass in each engine, 0 fail.

Rebased on 9d08993c8 (main touched claude_subscription.go's tool names), then
at the pushed tree: go vet ./internal/gateway; go test -run Claude
./internal/gateway ok (68s); i18n-keys and claude-mode 48 pass, 0 fail
in each engine.

Broken by hand: with the fetchURLImages call taken out,
TestClaudeTUIImageByURL is red (502 "an image known by its URL"); green
with it back.

Not tried: a real image by URL through a real interactive Claude Code
(the plan's quota is kept for the long-conversation runs that come
next); the download itself is
FetchImage's, which the other providers' image paths already use.
2026-11-01 20:54:37 +08:00
yetone 9d08993c8b routing: Cheapest first prices Ollama Cloud's DeepSeek models at double from 12:00 to 18:00 UTC on weekdays (hayden4608)
hayden4608 on Discord asked that time-of-day routing use the gap
between peak and off-peak prices, citing https://ollama.com/pricing.
That page (read live on 11-01) gives Off-Peak rows for two models
only, deepseek-v4.1-flash ($0.30/$1.20 peak, $0.15/$0.60 off-peak) and
deepseek-v4-pro ($1.32/$3.96 peak, $0.66/$1.98), and says off-peak is
"outside 12:00 and 18:00 UTC on weekdays and all day on weekends".
models.dev's ollama-cloud catalog lists the off-peak prices, so magpie
priced Ollama Cloud's peak hours at half.

- catalog: a new Peak kind, PeakOllama. Its hours are 12:00 to 18:00
  UTC, Monday to Friday, with no holidays. PeakFactor (2) matches the
  page for both models, cache reads included.
- provider: a peakBill for ollama.com (preset/catalog ollama-cloud)
  that names the two models. Dated tags (deepseek-v4-pro:1017) count
  as their model; the bare name before ':' is compared without
  allocating. Every other model there (glm-5.3, gpt-oss...) and every
  other vendor stays flat. A local Ollama, a relay that names itself
  ollama-cloud, and an ollama.com.evil host are not matched.
- GUI: a model's price tooltip names Ollama's hours for peak "ollama".
  The Cheapest first and rate-window texts no longer say that only
  DeepSeek's hours count, in en, zh, zh-TW, ja and de.
- docs/reference.md, site docs (en, zh, ja) and the gateway-routing
  and providers-accounts subsystem pages say the same.

Run (on mote through mote-run, at this tree rebased on ef3e74a07):
- go test for ./internal/catalog ./internal/provider ./internal/gateway
  for the new and changed tests, under TZ=UTC, Pacific/Kiritimati,
  Pacific/Pago_Pago and Asia/Kathmandu: ok. The tests check 11:59,
  12:00, 17:59, 18:00, 00:00 and 23:59 on weekdays, a Chinese holiday
  Monday, Saturday and Sunday, at +14, -11 and +0545 instants.
- gofmt -l internal: empty. go vet ./..., GOOS=linux go vet -tags
  nogui ./... and GOOS=windows go vet ./...: ok.
- GUI (Chromium and WebKit): model-price-edit, provider-rate-windows,
  routing-cheapest-first, i18n-keys, gui-de, gui-ja, gui-zh-tw.
- go test -count=1 -timeout 45m ./... (one suite on mote): every
  package ok except internal/gui. TestCoreScriptBudget was 7 bytes
  over, so this commit drops a comment from the app.js change rather
  than raise the budget; it passes now. TestMainWindowCorners/
  macOS_26_SDK (the window's toolbar taken off) is red on mote and
  touches nothing here: it is red
  the same way at origin/main ef3e74a07 alone, and is #3949 (macOS 27).

Broken by hand (each red, then restored):
- the peak hours ending at 17:00: TestOllamaPeakHours red.
- the Ollama bill removed: TestPeakOf, TestOllamaCloudOffPeakPrice red.
- tagged false: the dated-tag rows red.
- Ollama's hours used for every Peak kind: TestPeakHours,
  TestPriceOfPeak and TestCheapestFirstGroupFollowsPeakHours red.

Not tried: a real Ollama Cloud account or bill; a local Ollama's
":cloud" models (sent through the local server, so not priced here);
other vendors' off-peak schedules; the site is not deployed.
2026-11-01 19:02:59 +08:00
yetone 7d1f2ecba3 claudecode: magpie keeps the Claude Code it downloaded at the newest release
alextjy on Discord runs magpie in Docker with Claude Code from
`magpie claude-code install`, and asked whether a magpie update touches
it and how it updates. The download lives in <cache>/claude-code
(/config/cache, on the volume), so a new image keeps it. But nothing
ever updated it: every run magpie starts sets DISABLE_AUTOUPDATER, so it
stayed at the version first installed until the user ran install again.

claudecode.KeepCurrent now runs while magpie serves (a WhileServing
loop): a minute after start and every six hours it asks
downloads.claude.ai for the latest release and downloads a newer one,
checked against the manifest's SHA-256 and size as install does. The
version it replaced is removed on the next look rather than at once,
since a run being started may hold its path (Install, the CLI's, still
removes it at once; a folder with a .part download in it is left
alone). It does nothing when magpie downloaded none, when the machine
has its own `claude` (that one is run and updates itself), or when
DISABLE_AUTOUPDATER is set for magpie, Claude Code's own way to hold a
version. A failed look keeps the download and is logged. It never
downgrades.

The status line of `magpie claude-code`, the Docker docs (en, zh, ja)
and the bridge's subsystem page say so.

Run:
- wsl-run (Ubuntu 24.04, Go 1.26.8): go vet, then go test -race -v
  ./internal/claudecode/ -run 'Keep|Install|Find': all pass.
- Broken by hand on WSL, each red: no newer() check
  (UpdatesMagpiesDownload, LeavesWhatIsntMagpiesToUpdate), no own()
  check (the_machine's_own), pruning at install (UpdatesMagpiesDownload),
  no prune on the next look (UpdatesMagpiesDownload).
- Real use on WSL, sandbox HOME and XDG_CACHE_HOME: a throwaway program
  with a fake 2.1.1 download ran KeepCurrent against the real
  downloads.claude.ai. After 1m34s it logged "updated from 2.1.1 to
  2.1.316", the kept binary's --version said "2.1.316 (Claude Code)",
  2.1.1 was still there for the next look, and the loop ended with its
  context.
- mote, at this tree: GOOS=windows and GOOS=linux go vet -tags nogui of
  both packages, go vet ./internal/claudecode/, go build ., then
  go test -tags nogui ./internal/claudecode/ ./internal/cli/ -timeout 45m:
  VET-OK; claudecode ok 0.680s, cli ok 56.673s.
- gofmt -l clean.

Not tried: the Docker image itself (no docker on the test boxes), and a
Windows run whose replaced binary is still in use (prune leaves what it
can't remove for the next look). Full suite not run: the change is the
claudecode package, one WhileServing line and one CLI status line. A
WSL run of ./internal/cli/ at the default 10m timeout timed out while
the box ran other sessions' full suites; the 45m run above replaces it.
2026-11-01 19:00:51 +08:00
yetone ef3e74a077 gateway: the Claude bridge offers a magpie Library tool under its own name, not mcp__magpie__ twice
packinggoods (Discord, 11-01): through the Claude bridge the model saw
mcp__magpie__mcp__magpie__magpie-browser__browser_click for each tool
the client sent up front, while deferred tools named in the client's
text kept one prefix. The client (Claude Code with magpie's Library MCP)
already names those tools mcp__magpie__<server>__<tool>, and the bridge's
MCP helper is also called "magpie", so bridgeToolName put the prefix on
again. bridgeToolName, which the tool list, tool_choice, history and
the call's mapping back (bridgeNames/declaredName) all go through, now
offers such a tool under the rest of its name, so the run's model sees
the client's own name and a call comes back as declared.

Siblings: only the Claude bridge wraps a client's tools in an MCP server
(grep of mcpServers / mcp__ in internal); Codex and direct Claude Code
pass names as written. Other servers' tools (mcp__linear__x) still show
as mcp__magpie__mcp__linear__x through the bridge; that is nesting, not
a doubled prefix, and is left as it was. A client offering both
"mcp__magpie__x" and a bare "x" would have them offered alike (not
handled). A resumed bridge session's older turns name the tool with the
doubled prefix.

Run (on mote, via mote-run, at this tree before a comment-only reword):
- TestClaudeBridgeKeepsMagpieMCPNames with the old bridgeToolName put
  back: FAIL, "mcp__magpie__magpie-browser__browser_click is shown to
  the run's model as mcp__magpie__mcp__magpie__magpie-browser__browser_click",
  and the same for history and tool choice. Passes with the fix.
- go vet ./internal/gateway, GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -timeout 45m ./internal/gateway: ok (895s).
- gofmt -l internal/gateway: nothing.
Not run: the full ./... suite, Windows/Linux test runs, and a real
Claude Code bridge session with the reporter's Library servers.
2026-11-01 18:56:25 +08:00
yetone 9f17ad4c12 claude: the interactive mode takes safeguards and a client's cache marks
With the interactive mode on, nothing runs as -p any more (e5f66f8a6),
so a request carrying safeguards or a client's own cache marks was
refused. The owner (11-01) asked for every such request to work in the
interactive mode.

Safeguards: interactive Claude Code reads CLAUDE_CODE_EXTRA_BODY only
as it starts, so startRun puts them in the run's environment
(claudeEnvVars now cleans it and DISABLE_PROMPT_CACHING from what is
inherited). A turn whose safeguards changed ends the run, and the next
starts anew, told the whole conversation (setSafeguards).

Client cache marks: the helper pastes the words without their marks, so
the run keeps Claude Code's own prompt caching (no
DISABLE_PROMPT_CACHING, no client tail), and X-Magpie-Cache-Marks-Dropped
names every mark the client placed (clientCache.pasted, systemMarks).

The provider editor's tooltip, in every language, no longer lists them
as what only -p takes. The bridge doc says how each is handled.

Run:
- mote, at this tree: go test -count=1 -timeout 45m ./internal/gateway
  ./internal/claudetui: ok (gateway 897s, claudetui 10s)
- mote: node --test claude-mode, claude-tui-setting, i18n-keys: ok, all three
- New TestClaudeTUISafeguardsInEnv and TestClaudeTUIClientCacheKeepsItsOwn
  (a stand-in helper running the script Claude Code). With each change
  broken by hand, its test went red.
- Windows (GOOS=windows on mote) and Linux (wsl-run -tags nogui) go vet
  of the gateway: ok, on the tree with the image change on top.
- Real Claude Code 2.1.316, interactive, sandbox HOME: an extra body
  given in its environment reaches Anthropic (it answered 400
  "safeguards.0.dangerous_tool_use.classifier_context: Input should be
  an object" to a made-up shape).

Not tried: a real run with a valid safeguards shape (the test account
is at its 5-hour limit).
2026-11-01 18:52:44 +08:00
yetone ee7b8b0723 commandcode: a key's Credits window says GOAT/Go/Pro's month in credits, not dollars
jiezhengj on Discord (#feedback): Command Code GOAT says "$100 on
DeepSeek V4.1 Flash", but magpie's bar counts against $70. Command Code
counts Go, GOAT and Pro in usage-value credits
(docs/resources/usage-limits: "full-allowance models like GLM-5.2 get
$1 of usage per credit, and lower-allowance models draw proportionally
more credits per dollar"); GOAT's month is 70 of them, $100 of DeepSeek
V4.1 Flash or $70 of GLM-5.2 (pricing page, read 2026-11-01). The 70 is
right: command-code 1.88.2's getPlanInfo still has individual-goat 70,
and billing/credits' monthlyCredits counts down in the same units. The
signed-in subscription's card, served by the plugin, says "credits"
since 0.1.20 (plugins #556; mover min is 0.1.21). magpie's own card for
a Command Code key (cmdQuotaOf, via cmdKeyWindows) still said
"$28.80 / $70.00" and added bought dollars into the pool.

Now, as the plugin: on Go, GOAT and Pro the window is "28.80 / 70.00
credits", used of the month's credits alone, with bought and free
credits said beside it ("+ $5.00 extra"); Max, Ultra and Teams Pro keep
the CLI's dollar pool; Provider, pay as you go, has no month.

Run (mote): go test ./internal/provider -count=1 ok at this commit on
origin/main d1a94f579; at the same change on cbfbcb383, go vet ./internal/provider on darwin,
linux and windows ok; gofmt -l clean; gateway LoopGuard (reads
docs/subsystems) ok.
Broken by hand: with the units branch turned off,
TestCommandCodeQuotaShowsWindows and TestCommandCodeKeyCardHasCredits go
red ("$28.80 / $75.00", "$4.78 / $10.00").
Not changed: a key's balance line (readCommandCode) still adds credits
and dollars; it has no plan to tell the unit by. Filed as #4774.
Not tried: a real GOAT key's card in the GUI.
2026-11-01 18:48:13 +08:00
yetone d1a94f5792 provider: a Codex pick the ChatGPT list dropped is not offered (#4772)
Cause: the owner's codex provider keeps picks (providers.json "models")
made while ChatGPT listed gpt-5.5. ChatGPT has since stopped listing it:
the backend's /codex/models for the Pro account (client_version 0.165.0,
asked 11-01) and the saved Plus account's list both have gpt-6.1-sol,
gpt-6-astra, gpt-6.1-terra, gpt-6-sol, gpt-6-luna, gpt-5.6-sol/terra/luna
and no gpt-5.5, and Codex CLI 0.165.0's models_cache.json has none
either. ExposedOf offers a pick the vendor's list lacks as typed in by
hand, and an account's refetch never drops gone picks (dropGonePicks is
for key providers), so codex/gpt-5.5 stayed first in /v1/models. The
backend refuses any model its list leaves out: a real request for
gpt-5.5 on the Pro account answered 400 model_not_found "The 'gpt-5.5'
model is not supported when using Codex with a ChatGPT account", while
gpt-5.6-luna answered 200. Not plan-specific: Plus and Pro alike.

Fix: a ChatGPT account (listedOnly) is treated as Copilot's already is:
with its list fetched, a pick the list doesn't have is left out of what
agents are offered. The pick itself stays saved and comes back when the
list has it again. The list is the pool's (codexPoolModels), so a model
only a saved account has is still offered and routed to it
(Account.Lists).

Run (mote, at this tree on origin/main 1fac66c06):
- gofmt -l internal: clean; go vet ./internal/provider, GOOS=linux
  -tags nogui and GOOS=windows: ok
- go test ./internal/provider (full): ok 131s
- go test ./internal/tui ./internal/codexcat ./internal/usageapi
  ./internal/cli ./internal/catalog ./internal/agent: all ok
- go test -run 'Codex|Pick|Expos|Listed|Models' ./internal/gateway
  ./internal/gui: ok
- Real accounts, sandbox HOME (copy of ~/.codex/auth.json and the live
  providers.json and codex model lists): `magpie models` built from
  origin/main lists codex/gpt-5.5 first; built from this tree it lists
  only the six models the account serves.

Broken by hand: with ExposedOf's condition put back to unusable != nil,
TestCodexPickTheListDroppedNotOffered fails ("offered [gpt-5.5
gpt-6-astra gpt-6-sol]").

Not tried: the full ./... suite and the whole gateway package (mote was
at load ~290 with another session's suite running); the GUI suite; the
ChatGPT API provider (siwc), which keeps a fetched list too but was not
checked for refusing unlisted models, so it is left as it was.
2026-11-01 18:35:15 +08:00
yetone cbfbcb383b usage: a lead's answers are looked up in the blocks that name its conversation (#4370)
loggedAnswers, which leadFirst falls back to when affinity has lost a
Codex subagent's lead, read thirty days of the log into a Record a row
and kept the rows of one conversation. usage.VisitSessions reads only
those rows: a block whose Session and NativeSession strings don't name
the conversation is skipped, a row of another session is passed over by
its shape's string ids without becoming a Record, and a matched row's
strings are cloned out of the lent decode buffer. Each packed block's
sessions are kept once it is decoded (blockSessions, by weak pointer, so
no block the log let go is held), so a lookup decodes only the blocks the
conversation is in and the open tail. A page's copy with Codex
identities (which rewrite Session as a row is read) is read whole and
filtered on its records.

Run on mote (macOS 27.2), at load ~70:
- BenchmarkLeadLookup (40 blocks of 3000 rows, one conversation of 300):
  visit+filter 39-56ms and 2.9MB an op; VisitSessions 0.38-0.52ms and
  12KB.
- A copy of the owner's real usage.jsonl (8,853 rows, 1,270 sessions,
  18 blocks): every session looked up both ways gives the same records;
  6.9ms a lookup before, 3.4ms for the first and 0.39ms after, 14us for
  a conversation that isn't there.
- TestVisitSessionsIsVisitOfThoseSessions, red with the shape filter's
  session ids taken out; TestVisitSessionsRecordsKeepTheirStrings, red
  with the clone taken out; TestVisitSessionsSkipsBlocksOfOtherSessions,
  red with the known-sessions skip taken out.
- GOOS=windows go vet; GOOS=linux -tags nogui go vet: ok. gofmt -l: clean.
- go test -race of the new tests and the gateway tests of a lead's
  answers, in internal/usage and internal/gateway: ok (4.4s, 31.3s).
- go test ./internal/usage ./internal/gateway (whole packages) was
  still running on mote at load ~190 when this was pushed; its result
  goes on #4370.

Not tried: a real Codex subagent whose lead lost affinity; the lookup's
callers and filters are as they were, and the gateway's loggedAnswers
tests cover them.
2026-11-01 18:33:53 +08:00
yetone 9621168c46 provider: a plugin's thinking model with no variants borrows its maker's reasoning levels
laomao04_65777 on Discord: in Codex, with SenseTime Raccoon (商汤小浣熊)
picked, the reasoning effort couldn't be switched.

Cause: Raccoon's plugin lists its models as thinking with no variants.
Its sn-* ids (sn-glm-5-3, sn-kimi-k3, sn-glm-5-3-flash,
sn-deepseek-v4-1-flash, sn-deepseek-v4-pro) are ones models.dev knows
under the maker's spelling (catalog.Knows). So levelsUnknown counted
them as known and offered nothing, and pluginCatalog borrowed the
maker's levels only for moved built-ins and Cline. Codex's catalog got
supported_reasoning_levels [] and hid the picker. A custom provider's
same id already borrows them (effortsOf), and an id models.dev doesn't
know already got low/medium/high (ddb1701fe).

The class: every plugin model that says it thinks and gives no
variants now borrows its maker's levels (borrowedEfforts). OpenCode
also reads no variants as nothing said and makes its own from the SDK
(packages/core/src/variant.ts, low/medium/high for openai-compatible).
A model with variants keeps them. A model that doesn't say it thinks
gets nothing borrowed.

What the vendor takes: xiaohuanxiong.com has no public API docs. The
official 1.1.3 desktop app's code only flips enable_deep_thinking on
its web API. The gateway already sends Codex's effort (medium) to
Raccoon today, because fitEffort passes it through when there are no
levels, and no rejection has been reported. The levels borrowed are
the maker's (kimi-k3, glm-5.3, deepseek-v4 on models.dev).
magpie-community/plugins#598 asks the plugin for real per-model
reasoning and variants.

Run (mote, at 88183d15d on origin/main 1fac66c06; then rebased onto
57246b381, whose 3 commits since touch none of provider, plugin, codexcat
or catalog):
- go test -tags nogui ./internal/provider ./internal/codexcat
  ./internal/catalog: all ok (provider 154s)
- go test -run 'Effort|Reason|Level|PluginCatalog|Variant'
  ./internal/gateway ./internal/agent: both ok
- gofmt -l clean. GOOS=linux and GOOS=windows go vet ./internal/provider
  pass.
- A repro against a copy of the live models.dev cache, with the
  Raccoon plugin's 11 models: before, the five sn-* ids got []. After,
  sn-kimi-k3, sn-glm-5-3, sn-glm-5-3-flash and sn-deepseek-v4-pro get
  [low high max], and sn-deepseek-v4-1-flash gets
  [none low high max]. The raccoon-*/sensenova ids are unchanged
  ([low medium high]).

Broken by hand: with plugins.go reverted,
TestPluginThinkingModelBorrowsEfforts is red ("raccoon/sn-kimi-k3
offered [] in Codex", and so are the provider's Efforts).
TestMovedKeepsEfforts now also checks a plugin's own variants and the
non-thinking case.

Not tried: a real Raccoon account (none here), so no request with a
borrowed level went to xiaohuanxiong.com. Not tried in the real Codex
app either. Not a full ./... suite: mote was at load 270 with another
session's gateway suite running.
2026-11-01 18:28:31 +08:00