Commit Graph
1646 Commits
Author SHA1 Message Date
yetone 12599e9cd0 signin: ChatGPT signs in by device code, the first way from another computer
curtinp118 on Discord runs magpie on a VPS and opens its web UI from home.
ChatGPT's browser sign-in comes back to localhost:1455, which is the
viewer's own computer. The page there won't load, and the box's main line
said "The account shows up here as soon as you're done", so the sign-in
looked broken. The fix until now was to copy the dead page's address back
by hand.

ChatGPT now also signs in by device code, as `codex login --device-auth`
does (codex-rs login/src/device_code_auth.rs). This is
startCodexDeviceSignIn, with StartSignInWith site "device":
- magpie asks auth.openai.com/api/accounts/deviceauth/usercode for a code
  with Codex's client id and headers;
- the box shows the code and https://auth.openai.com/codex/device;
- magpie polls deviceauth/token, where 403/404 means not entered yet, for
  up to 15 minutes;
- it then trades the authorization code at the token endpoint with the
  returned verifier and the /deviceauth/callback redirect.
Nothing listens on this computer.

The window starts this way when magpie web is opened from a host other
than localhost or loopback (remotePage in app.js). Either way, the box has
a link to the other way: "Sign in with a code instead" or "Sign in in the
browser instead". A device code that ChatGPT turns away (404) fails, and
that box links to the browser's way. Strings are in zh, zh-TW, ja and de.
providers-accounts.md describes the flow.

This went over TestCoreScriptBudget. It now fits with no raise
(1,533,700 of 1,533,802, on main's 1,533,789). The two way-switch
buttons share one helper (codexWay), and eight comments on the sign-in
code are cut down: openSignInPage, signingKept, startPluginSignIn, the
sign-in proxy, signInProxyChoices, Copilot's GHE.com, dropSigningIn and
renderStepPlan.

Run on mote (the pushed head is rebased on ae060550b):
- go test ./internal/provider: the new TestCodexSignInByDeviceCode,
  TestCodexDeviceSignInCanceled and TestCodexDeviceSignInOff, against a
  fake auth server that answers with the bytes auth.openai.com gave on
  11-03;
- go test -tags nogui ./internal/provider ./internal/backup (before the
  comment trim, which touched app.js only): ok; ./internal/gui
  ./internal/cli after it: ok;
- GUI at this head: signin-codex-device.test.cjs (new; Chromium and
  WebKit, en and zh, 420px wide), signin-paste-codex, signin-callback,
  signin-port-blocked, signin-paste-plugin, signin-paste-import, the
  sign-in proxy files and i18n-keys, 40 files: 591 pass, 0 fail;
- the whole GUI suite one commit earlier (base c86fa2a34; the rebase onto
  6a6e4fefa only brought in internal/sessions): two runs, each cut short
  when mote rebooted or by the owner's call not to wait. They got through
  1075 and 1395 cases, with 0 not ok;
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., the Linux nogui and Windows builds, and gofmt -l (base
  c86fa2a34).
Rebased on 4cd01c964 at last: go test -tags nogui ./internal/gui ok and
signin-codex-device, signin-paste-codex, signin-callback and i18n-keys
21 of 21. Before that, rebased on ae060550b with the comments cut: go test
-tags nogui ./internal/gui ok, ./internal/provider ok, and 40 sign-in,
proxy, i18n-keys and desktop-tiers GUI files: 594 pass, 1 fail. The red
was signin-proxy's chromium ja 380 proxy test. That file alone then
passed 3 runs, 120 of 120. It is #1814, open since 10-12 for this test
under load, and noted there. The step that failed wasn't kept.
The full go test ./... was not run, by the owner's rule.

On Linux (WSL magpie-desktop, sandbox HOME), magpie web listened on
0.0.0.0:3561 and was reached at the WSL IP. POST /api/signin
{"agent":"codex","site":"device"} got a real code from auth.openai.com
with url https://auth.openai.com/codex/device. The sign-in stayed waiting
across real polls for 12s, nothing listened on 1455, and cancel ended it.

Broken by hand:
- Taking the device branch out of begin() turned
  TestCodexSignInByDeviceCode and TestCodexDeviceSignInOff red.
- Taking the remotePage default out of startSignIn turned 8 of the 12
  signin-codex-device cases red.

Not tried:
- Entering the code with a real ChatGPT account, so a real token trade
  through the device callback hasn't been seen.
- Business/Enterprise workspaces that turn device codes off.

Also not changed: WorkBuddy's plugin sign-in already finishes by itself
from a remote browser (server-side poll; checked on the same WSL setup).
A backup still carries no sign-ins.

Reported by curtinp118 on Discord.
2026-11-03 09:54:05 +08:00
yetone ae060550b9 claude-desktop: a tier's pick runs with its tier's Claude prompt (behavesAs)
moer2831 on Discord: a model picked for one of Claude Desktop's tiers ran
in the Code tab on Claude Code's generic prompt, not the one of the
Claude model of that tier ("通用提示词和对应模型提示词差距挺大的,感觉直接
蠢了一个度"). Desktop 4.29 and later hand Claude Code behavesAs only from
a profile's inferenceModels (z3t in 4.4212's app.asar: modelPicker
options with each entry's behavesAs).

What changed:
- gateway.DesktopInferenceModels: while a model is picked for a tier,
  the list is every row /v1/models gives Desktop, by its id and in its
  order (a non-empty list replaces discovery, pzn), with supports1m,
  prefer1m and labelOverride as Desktop read them off the row, and a
  pick's anthropicFamilyTier/isFamilyDefault. A pick that isn't a Claude
  model gets behavesAs = its tier's newest Claude id (claude-opus-5-5,
  claude-sonnet-5-5, claude-haiku-5-5, claude-fable-5-1). Nothing picked
  (or a pick no longer listed): no list. Unreadable picks are unknown.
- agent: desktopSyncModels writes it into magpie's Desktop profile on a
  tier's Set, as Desktop comes on magpie and on Sync; temp+rename, only
  when it changed; taken away when nothing is picked. The list is
  magpie's only while its hash is one magpie recorded (stash mark
  claude-desktop.models); any other list (the user's) is never written
  over or removed.
- Claude Code's modelSettings gets the pick's own window even when it
  matches the default (claudeBudget.behaves), since behavesAs would
  otherwise give it the Claude model's.
- GUI: the tiers menu ends with one line, "Claude Desktop reads the
  tiers as it starts: restart it after a change." (en, zh, zh-TW, ja,
  de). The Agents row's Restart already lights from the profile hash.
- docs/subsystems/agent-wiring.md and gateway-routing.md.

Run on mote at this tree (base c86fa2a34): gofmt -l clean; GOOS=linux
(-tags nogui) and GOOS=windows go vet ./internal/agent ./internal/gateway;
go test -count=1 -timeout 45m ./internal/agent ./internal/gateway
./internal/gui ./internal/cli ./internal/tui ./internal/backup
./internal/davsync ./internal/library ./internal/profile ./internal/stats
./internal/uninstall: ok but internal/gateway's
TestCodexPoolSaysTheClientsVersion (passes alone here and at main; #4807)
and internal/gui's TestMainWindowCorners (red the same at origin/main
6a6e4fefa; #3949). GUI (chromium + webkit, every
language they cover): desktop-tiers, i18n-keys, and every file named for
tiers, picks, roles, Desktop, i18n or a language (887 tests,
871 pass; the 16 reds are 4 files red the same at origin/main 6a6e4fefa:
found-skill-pick-remove #4097, menu-input-scroll #3402,
phone-connect-menu #4706/#4707, provider-picks-stay #4397). Not the
whole GUI suite.

Rebased on origin/main a5c1fa4b4 (nothing there touches agent, gateway or
GUI assets but routing.css), then again at the pushed head: go vet
./internal/agent ./internal/gateway; the size budgets,
TestDesktopInferenceModels, TestClaudeDesktop*, TestClaudePlan;
desktop-tiers and i18n-keys in both engines: ok.

Broken by hand, each red: behavesAs left out (TestDesktopInferenceModels);
the window write's behaves check dropped (TestClaudePlan); the sync on a
tier's Set dropped (TestClaudeDesktopModelsList); the user-list guard
off (TestClaudeDesktopModelsList); the menu's line not shown
(desktop-tiers 0 of 4).

Not tried: a real Claude Desktop 4.29 or later (none on mote; this
Mac's is 2.7032 and live). Builds before 4.29 ignore behavesAs and take
the names. Desktop 1.x gets the mythos ids. A user's own gateway profile
applied in Desktop makes magpie's list do nothing.

Thanks moer2831 for the report.
2026-11-03 09:33:25 +08:00
yetone 7c115f6f5b provider: picks gone from a list for over an hour serve the list (maxleebeta)
maxleebeta on Discord: with WorkBuddy and WorkBuddy AI both signed in,
the Agents page's model picker had no WorkBuddy AI model, and its
Providers row read "已登录 · 1 个图像模型 · Free plan" where WorkBuddy's
read "1 个模型".

WorkBuddy AI's /v3/config (read 2026-11-03 with the owner's account) no
longer lists deepseek-v4.1-flash, its free model until now; hy3 is at
x0.00 instead. The China build still lists deepseek-v4.1-flash. A pick a
plugin's list stops listing goes to Delisted (8febe3a50), and a provider
whose every pick is there serves none of its models (waitsForPicks), for
as long as the list leaves them out. A Free plan account whose one pick
was deepseek-v4.1-flash was served nothing, for good. The row counts
chat models on, and with none it shows the plan's drawers from
/v3/config: "1 image model". The owner's own providers.json has the
same state: workbuddy-ai picks [gpt-6-astra], delisted
[deepseek-v4.1-flash].

Now Provider.DelistedAt keeps when the last pick still in Models left
(dropGonePicks sets it, a pick listed again clears it, Save keeps it
across other settings: delistedAtWith, accountSettings). waitsForPicks
holds only for pickWait (an hour) after it. Past that, or for picks set
aside before DelistedAt was kept (DelistedAt is zero), the list is
served as if none were picked. The picks still come back with a list
that has them. Our Free Model's restart, which the wait was for, lists
its channels again within minutes, and relistSoon asks again in 5.

The plugin is unchanged: its list is what WorkBuddy AI serves today.

New test: TestPicksGoneForGoodServeTheList (the real ids: before
deepseek-v4.1-flash, -sg, glm-5.3-flash; after hy3, -sg, glm-5.3-flash).
It checks: none is served at once; the list is served past pickWait,
with another setting saved on the way; the list is served for picks set
aside with no time kept; and the pick and nothing else is served once it
is listed again. Broken by hand:
- waitsForPicks back to its old body: the new test is red ("served []
  after pickWait").
- Save dropping DelistedAt: TestEveryPickDelistedServesNone is red
  ("served after another setting was saved: [pool-a]").

Run on mote on origin/main 6a6e4fefa plus this change: gofmt -l clean; go vet for GOOS=linux (nogui)
and windows of internal/provider and internal/gui; go test -timeout 45m
of internal/provider, internal/gui, internal/routes and
internal/gateway: provider and routes ok; gui red only in TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote); gateway red only in TestCodexPoolSaysTheClientsVersion (#4807).

Not tried: a real WorkBuddy AI Free plan account (we have none); the
owner's account's config was read, not changed. The full ./... suite
wasn't run: one was already running on mote.
2026-11-03 09:26:51 +08:00
yetone 6a6e4fefac sessions: WorkBuddy AI's own sessions are listed under its name (maxleebeta)
maxleebeta (Discord #general) is signed in to both WorkBuddy builds, the
China one and the international one, and the international one was
missing from an agent list. The provider side lists both: provider.All()
and CatalogFor have workbuddy/* and workbuddy-ai/* models under "WorkBuddy"
and "WorkBuddy AI". The sessions package, though, read only ~/.workbuddy.
WorkBuddy AI keeps the same files in ~/.workbuddy-ai (its product.json
dataFolderName, as internal/agent wires it), and nothing read them. So
WorkBuddy AI was missing from the Sessions page's agent picker, from
Usage > Sessions' agent strip, from the reading consent's folders and
from the usage ledger.

Changed:
- WorkBuddyAIDir and workbuddyAIFiles read ~/.workbuddy-ai/projects as
  agent workbuddy-ai with WorkBuddy's parser, in allFiles, Dirs,
  callSources (wholeCallReaders), Deletable and Found.
- buddyDir picks WorkBuddy AI's own models.json for the
  call-through-magpie skip.
- A ~/.workbuddy-ai that is a link to ~/.workbuddy is read once, as
  WorkBuddy's.
- skillsCounted names workbuddy-ai (WorkBuddy's parser counts no skills).
- docs/subsystems/gateway-sessions.md has a line for it.

Tests:
- TestWorkBuddyAI checks sessions, cwd, title, tokens, Deletable, Found,
  calls, the skip of magpie's gateway, and the link.
- TestWorkBuddyAIGatewayIsItsOwn: one model id that WorkBuddy's
  models.json gives to magpie and WorkBuddy AI's gives to the user's own
  provider.
- TestWorkBuddyAISessionsListedUnderTheirName checks /api/sessions,
  /api/sessions/manage and /api/sessions/stats: name "WorkBuddy AI",
  icon workbuddy-color, deletable.

Broken by hand (each went red): allFiles, parserFor, Deletable, Found,
the call sources, the wholeCallReaders entry, buddyDir.

Run on mote at this head (base origin/main c86fa2a34):
- gofmt -l and go vet for darwin, GOOS=linux and GOOS=windows -tags nogui
  (internal/sessions, internal/gui): clean.
- go test -tags nogui -timeout 45m over sessions and every package that
  imports it: ok for sessions (after the skillsCounted line), agent, cli,
  davsync, gui, otlp, tui, tune and usage.
- internal/gateway failed only TestCodexPoolSaysTheClientsVersion, which
  is #4807 (red in a full package run on mote, another test's Codex
  identity reaches it). Nothing here touches it.

Not tried:
- The reporter's screenshots, which we couldn't download, so their list
  may be another one.
- A real WorkBuddy AI install.
- The Agents page's detection of a newer, renamed WorkBuddy AI bundle
  (5.9.3).
- Windows.
- WORKBUDDY_CONFIG_DIR set: both apps then use that folder, and its
  sessions are listed as WorkBuddy's.
- No GUI JS changed (the page reads the agents from the API), so no
  Playwright files were run.
2026-11-03 08:54:40 +08:00
vincent c86fa2a341 gateway: a relayed citation without the offsets OpenAI's schema wants is dropped, the thread healed (#4921)
A thread a routing group served once on Volcengine Ark (or another
vendor whose Responses endpoint writes its url_citations with no
start_index/end_index) never worked on a codex member again: magpie
relayed the reply's annotations as they came, Codex stored them, and
the ChatGPT backend refused every later replay of the history whole —
"Missing required parameter: 'input[221].content[0].annotations[0].
start_index'" — five retries a turn, on any codex member, through any
upgrade (#4921, the reporter's routing log and rollout). This is
#2855's defect with a different field: what magpie hands a client must
be something magpie could send again.

Such an annotation goes, at both seams, as the reasoning-item fix did:

- a whole reply streamed as the vendor's own events (responsesWholeEvents)
  drops it in every place a client reads a citation: its annotation
  events, the content part, the item and the reply the client keeps
  (dropOffsetlessCitations);
- the history Codex replays loses it on its way to the ChatGPT backend
  (withoutOffsetlessCitations, the same leaving-out as a reasoning
  item's text, #1411): to the backend by its own sign-in and compaction
  relay (codexUpstreamOn), to it as a group member or an openai.com or
  Azure upstream (the provider loop, beside withoutReasoningText), and
  asked again without it where a relay in front of it names the
  parameter (refusesCitationOffsets), marked so it is never sent one
  again — a thread already poisoned heals on its next turn, no new
  thread needed.

The text, and a citation that carries its offsets, go as the vendor
wrote them; a turn with no "annotations" in it is not decoded
(anyInputItem scan, itemCitesWithoutOffsets; the undecoded-turn test
holds, allocations and all).

Run: the three new tests fail on the base with the reporter's exact
400 and pass here (ablation: the tidy call and the rewrite's body
neutralized, tests kept); TestCodexRewritesAsBefore,
TestCodexRewritesLeaveTurnUndecoded and the fuzz hold the rewrite to
its scan; the citation/whole/reasoning neighborhood ok (23s); gofmt,
go vet (linux, windows) and go build -tags nogui clean.

Review: this is skygunner's version of the fix (fcea11649), not
ggbdpq's 57dc7b420. ggbdpq's stripped citations only for a request
that wasn't for a magpie model, so the reporter's own path (a routing
group's codex member, the history passed through) kept the bad
annotation. ggbdpq's parity table and verification of the report
were used to check this one.

Changed in review: annotationLacksOffsets looks only at url_citation
and container_file_citation, the two types OpenAI's schema gives
start_index and end_index. file_citation and file_path carry a single
index, so the patch dropped every one of them as "offsetless".
TestCitationsWithOneIndexKept (added in review) holds both kinds and
checks that a history with only file_citations is sent byte for byte.

Broken by hand at the reviewed head: annotationLacksOffsets made to
return false, all four citation tests red; the type check removed,
TestCitationsWithOneIndexKept red. Restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.
2026-11-03 07:43:18 +08:00
ggbdpq 0561d53521 gateway: spawned Claude Code registers no claude-cli:// URL handler (#4928)
--setting-sources "" keeps the user's own disableDeepLinkRegistration
from loading, so every spawned claude registered the claude-cli:// OS
URL handler again and "Claude Code URL Handler.app" came back after the
user had deleted it. A headless run has no use for an OS URL handler:
the setting is now passed as flag settings (--settings is not one of
the sources --setting-sources controls) on the bridge run and the
warm-up and usage runs beside it, whatever the user's settings read.

Review: applied as ggbdpq posted it (patch sha256 checked against the
issue's). Checked in the Claude Code binary that flag settings read
disableDeepLinkRegistration === "disable" and that --setting-sources
"" doesn't filter --settings. `claude auth login` and `auth status`
take no --setting-sources, so the user's own settings already apply
there; they are not changed.

Broken by hand at the reviewed head: claude_warmup.go and
claude_subscription.go reverted to their parent,
TestClaudeSubscriptionPromptKeepsForeignHarnessOutOfSystem,
TestWarmClaudeAsksClaudeCodeOnce, TestClaudeUsageRunsClaudeCode,
TestAskClaudeTUIOn and TestClaudeUsageTUIOn red. Restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-03 07:43:18 +08:00
ggbdpq a8d36b0faa fix(claude): a run let go after answering a prompt suggestion leaves its session for the conversation's next turn (#4914)
Claude Code asks its prompt suggestion after each turn as the
conversation and one message more, and its run goes on with it (#1638):
the run waits on from the suggestion's exchange, under a key the
conversation's own next turn never comes by, since the client leaves the
exchange out of its messages. While the run is kept, that turn finds it
by where it stood before and takes it back to there (resume). But a run
let go past idleMost was lost to its conversation: shelve kept its
session where the suggestion's exchange had left it, or, when the
conversation's own turn had already taken the run back from a suggestion
(-p), not at all — its session was marked taken back, which the file may
not say, and no session was kept. The next turn found no run and no
saved session, and a new Claude Code was told the whole conversation in
one message, a prefix the cache had never seen, written to the cache
again (a 50k conversation: 19k read and 29k written where 49k read and
50 written; the log said no run here had had a conversation one had).

The shelf now keeps a session where the conversation's next turn comes
by, too (savedSession.behind, run.behindKey), and unshelve takes it from
there when no session waits at the turn's own key. A session taken back
is kept once the run has answered a whole turn since (run.replied, set
as a turn ends, cleared at each take-back): the file's lines since are
that turn and what came after, and Claude Code's resume goes on from
them. And a run's end is kept under the boundary before its own
(run.convPrev), so the log of a turn that finds it gone says what became
of it when its last exchange was a side question.

Run: TestClaudeLetGoConversationAfterSuggestionResumesItsSession fails
on the parent a3768cdd1 with the product file alone reverted to it,
tests kept (the ablation: the shelf keeps no session for the
conversation's next turn), and passes on the fixed tree with
TestClaudeLetGoConversationResumesItsSession, whose fake now answers a
rewind; go test -tags nogui -count=1 ./internal/gateway/ (559s, only
the known TestCodexPoolSaysTheClientsVersion flake red); gofmt -l
clean on both files; go vet -tags nogui on internal/gateway for
darwin, linux and windows; go build -tags nogui ./... on all three.

Review, changed from ggbdpq's patch: the session kept under the
conversation's next key is cut before the side question when it is
resumed. ggbdpq's patch resumed the shelved session whole, so the
suggestion's question and answer stayed in the history the model
reads on the conversation's next turn. A shelved session found by
behindKey is now copied up to the line before the side question
(cutBehind: cutSessionBefore at behindTurn for a -p run, cutSession
at behindLine for a TUI run, the branch point both already use), the
copy is resumed and the shelved file removed. If the cut fails, the
session is dropped and a new Claude Code is told the conversation, as
before the patch.

The test now checks the resumed session id is a new copy, that the
copy ends at a2 then a3 with one SUGGESTION left (the first one,
already taken back above a2), and that the resumed run is told a3
alone. Its fake Claude writes stdin lines with printf: sh's echo
turned the JSON's \n escapes into newlines, which split every line
and hid its uuid.

Broken by hand at the reviewed head: claude_subscription.go reverted
to its parent, the test red (no session kept); ggbdpq's own
claude_subscription.go put back, red at the cut check (the shelved
session resumed whole). Restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-03 07:43:18 +08:00
ggbdpq 8f6dacbf7f gateway: a browser's CORS preflight from another machine is answered, not asked for a key (#4931)
From the report (magpie 0.1.2698, macOS 27.0.1, LAN sharing on, gateway
port 3425): a page at https://learn.trancy.org, listed in Settings ->
Network and sharing -> Web pages, failed to add itself as a custom
engine ("Failed to fetch"). The same OPTIONS preflight for /v1/models,
declaring GET and the authorization header with no key on it, was
answered 204 with the CORS headers at http://127.0.0.1:3425 and refused
401 with no CORS headers at the machine's LAN address and behind an
HTTPS reverse proxy (Nginx Proxy Manager, no CORS handling of its own);
the browser logged net::ERR_FAILED,
corsError: PreflightMissingAllowOriginHeader, and gave up before the
keyed POST. The 401 body was the gateway's own "no API key was sent:
send a magpie gateway key as Authorization: Bearer <key> (or
x-api-key)".

lanGuard sits in front of Handler (Front, oneport.go), and corsGuard is
inside Handler, so a request from another machine met the key check
first: with the gateway shared (or listening on the network),
identifyCaller refused the keyless preflight 401 before corsGuard could
see it. On loopback lanGuard asks no key, which is why the same
preflight was answered there. A preflight is an OPTIONS that declares
the call to come, and per what CORS asks of it carries no key and no
body: the browser cannot send one.

lanGuard now hands a preflight (corsPreflight: an OPTIONS with an
Origin and an Access-Control-Request-Method) to corsGuard instead,
after the allow list and the shared/on-network rules have judged it as
they judge every request. corsGuard answers a listed origin's with its
204 and headers and refuses any other page's as on loopback; the call
the preflight asks after still needs an enabled gateway key, and an
OPTIONS that declares no call is no preflight. `magpie web`'s page
port, which hands client routes to the same Front, is covered by the
same change.

Tests (internal/gateway/cors_test.go), from the report's three-row
table:
- TestCORSPreflightFromLAN: the loopback preflight answered 204 (the
  row that already worked), the LAN-direct one and the reverse-proxy
  one (X-Forwarded-For, loopback peer) answered 204 with Allow-Origin
  and Allow-Headers; an unlisted origin's preflight refused with no
  CORS headers; a keyless GET and a plain OPTIONS from the LAN still
  401; a preflight while magpie isn't shared still refused.

Broken by hand (the preflight handoff taken back out of lanGuard): the
LAN-direct and reverse-proxy rows go red, 401 with the report's own
error body, while the loopback row stays green; restored, ok.

Run (macOS arm64, this tree, -tags nogui):
- go test -run 'TestCORS|TestLAN|TestForeignPages|TestOpaqueOrigin|
  TestLocalhostSubdomain|TestRebound|TestOnePort|TestFront'
  ./internal/gateway: ok.
- the same with -race: ok.
- go vet ./internal/gateway, and with GOOS=linux and GOOS=windows: ok.
- go build . with GOOS=darwin, GOOS=linux and GOOS=windows: ok (the
  darwin cgo enum-conversion warnings in internal/gui are pre-existing).
- gofmt -l on the three touched files: clean.
- go test -count=1 -timeout 50m -tags nogui ./internal/gateway: every
  test ok except TestCodexPoolSaysTheClientsVersion, the known #4807
  (another test's Codex identity reaches it in a full package run); it
  passes run alone at this head.
- go test -tags nogui -count=1 ./internal/access ./internal/settings .:
  ok. ./internal/gui: TestProxyCheckSaysAProxyPassedBy fails, and fails
  the same way run alone on the untouched base a3768cdd1 — this
  machine's environment, not this change (the test drives checkProxy's
  ALL_PROXY walk, nothing of the gateway).

Not tried: a real Trancy page against a real LAN address and a real
Nginx Proxy Manager install; the report's LAN and proxy rows are taken
from its measured curl and browser evidence, and reproduced here at the
lanGuard/corsGuard seam with httptest instead. A preflight arriving
while magpie isn't shared is still refused, so the browser reports the
preflight, not the later call, as the failure — the network's rules
come first, as the report asks.

Review, changed from ggbdpq's patch (security): the patch let every
keyless preflight from another computer past lanGuard's key check.
corsGuard passes some unlisted origins on with no key (a page on this
computer by name or address, *.localhost, the request's own origin,
an app's or extension's scheme), and a route that takes OPTIONS
(Codex's backend relay, the MCP paths) would then serve such a
"preflight" with the user's sign-in. lanGuard now hands on only a
preflight whose origin is listed (corsAllowed); every other one meets
the key check as before, Origin null included. No request other than
an OPTIONS with Origin and Access-Control-Request-Method skips the
key: a POST, GET or DELETE carrying a preflight's headers is 401.

TestCORSPreflightFromLANReachesNothing (added in review) sends a
keyless preflight from the LAN for Codex's relay, an MCP path and
/v1/models from localhost, 127.0.0.1, foo.localhost, the request's own
origin, an extension, app://, null and a foreign site: none reaches
the handler or gets CORS headers. The listed origin's is answered by
corsGuard alone, and other methods with its headers are 401. A
rebound page never gets here: lanGuard's rebound check runs on
loopback first, and from the LAN the key check stands. Broken by
hand at the reviewed head: the corsAllowed condition removed, this
test red (TestCORSPreflightFromLAN stays green); the whole handoff
reverted, both red. Restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-03 07:43:18 +08:00
yetone 3c2dceb340 gateway: "member" in Model name in replies names the member to Claude Code and Codex too (ZoeCats)
ZoeCats (Discord #feedback, after v0.1.2760): with Settings › Models ›
Replies › Model name in replies on "vendor" the name is no longer written
over, but on "member" (作答的成员) a reply still didn't name the routing
group's member that answered.

Cause: replyNamingOf turned the "member" setting into the model asked for
whenever the agent was Claude Code, Claude Desktop or Codex (vendorNamed,
kept from #822's memberModel). ZoeCats's agent is Claude Code, so the
setting did nothing for them, while "vendor" was already for every agent.
The setting was saved and read as it should be (the vendor choice worked
through the same path), and an absent X-Magpie-Response-Model falls
through to the setting.

Fix: the user's pick is for every agent. Those three already take a
provider/model id back under the default (the group or provider/model
they asked for), so the member's provider/model id is no new shape for
them. vendorNamed, replyNamingOf's unused agent argument and the dead
namesMember are gone. The menu's note for "member" says "for every agent,
groups included" in en, zh, zh-TW, ja and de; settings.go's comment and
gateway-routing.md say the same.

Tests (fake upstreams, no network):
- TestReplyNamesMember: "on, codex", "on, claude code", "old file on,
  codex" now want the member, plus "on, claude desktop" and "on, codex,
  name asked" (the header still wins), on 6 paths x streamed or not, each
  after a failover in a group.
- TestPluginReplyNamesMember (new): a group served by the fake plugin,
  Chat and Messages, streamed and whole, with no token and Claude Code's,
  member and default.
- TestGeminiReplyNamesAskedModel: also with replyModel member and vendor.
- reply-model-setting.test.cjs: the member note says every agent and
  names no Claude Code.
Red on origin/main db7c57670 with only the tests changed: every
codex/claude code/claude desktop member case of TestReplyNamesMember
and the four Claude Code member cases of TestPluginReplyNamesMember
(the reply named group/chat, group/claude). Gemini and plugin member
cases without a vendorNamed token were already green.

Run on mote at this tree (on origin/main db7c57670, the pushed base):
- gofmt -l internal/ clean; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of ./internal/gateway ./internal/settings clean.
- go test -tags nogui -count=1 -timeout 45m ./internal/settings
  ./internal/settingsapi ./internal/gui ./internal/cli ./internal/gateway:
  settings, settingsapi, gui, cli ok; gateway ok except
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity; red in the full package, green alone), untouched here.
  TestReplyNamesMember, TestPluginReplyNamesMember and
  TestGeminiReplyNamesAskedModel pass.
- node --test reply-model-setting + i18n-keys (chromium + webkit, 5
  languages, 1100 and 420 wide): 26 pass, 0 fail.
Broken by hand: the tests alone on the old member.go (above) were red.

Not tried: a real Claude Code or Codex session reading the member's id
back (the default already gives them a provider/model or group id); a
real vendor account through a real group.
2026-11-03 07:15:52 +08:00
yetone 1851ead1a7 library: Pi and omp lock ~/.agents/skills from their versions; Put skills in links every skill there
usrname1833 on Discord asked for two things.

Pi reads ~/.agents/skills itself, so a skill kept there is Pi's whatever
is ticked, with the lock as Codex and OpenCode have. Pi started to in
0.54.0, not 0.19 (its CHANGELOG; userAgentsSkillsDir in
package-manager.js), and omp in 11.0.0 (src/discovery/agents.ts; 10.6.2
doesn't). Target.SharedToo says so from the version, and every reader of
readsShared goes through Target.readsSharedDir: Always (the lock),
syncSkills' inShared (no second link) and a handover's readsSharedHere.
OmO's senpi reads it in every npm version (0.74.0 up), so omo joins
readsShared. A Pi or omp of no known version is taken as older, as
before.

The second ask is a switch: Library > Skills > "Put skills in": each
agent's own folder (the default, today's behaviour) or ~/.agents/skills
(Library.SharedSkills; POST /api/library/skills/where {how};
magpie library skill where agents|shared). On, every library skill on
here gets magpie's link in ~/.agents/skills (syncShared, after
sweepShared), so every agent and tool reading that folder has it and
shows it locked. The files stay in the library rather than moving, so
updates, edit tracking and Off here keep working; existing skills just
get links when it is turned on, nothing is moved. A user's own entry by
the same name is never written over. Off takes out magpie's links there
and nothing else, and agents' own links come back. Per computer:
Collect doesn't carry it. docs/subsystems/library.md says all this.

Not covered, filed: on Windows without link rights the shared entry is
a marked copy, and takeEdits doesn't take edits made in it (#4958).

Run on mote rebased on d76c4b23a (which has 8abdf53a8):
gofmt -l clean; go vet GOOS=linux and GOOS=windows on internal/library,
internal/gui, internal/cli ok; go test internal/library, internal/gui,
internal/cli ok. GUI, every skill-*, library-* and i18n-keys file in
chromium and webkit: 1302 pass, 4 fail, all in library-all (webkit) and
library-null-agents (chromium). Both pass alone at this tree (52/52), so
they are load reds, filed as #4967. skill-where.test.cjs (new) covers en,
zh, zh-TW, ja, de at 900px and 400px. Before the rebase, cli's
TestEveryRouteHasACommandOrIsNamed was red on /api/usage/checkin-account
(not this change); it is green at this base.

Rebased twice more on origin/main (cli's settings_parity_test, app.js,
i18n.js, settings): internal/cli and internal/gui go test ok, i18n-keys
and skill-where green at the pushed tree.

Broken by hand, each red, then restored: since() always false
(TestPiReadsSharedSkillsFromItsVersion, TestSkillsWhereShared red);
syncShared step dropped (red); sweepShared's keepsShared keep dropped
(red on the SameFile no-relink check); the holder line in wanted
(TestSkillsWhereSharedWithKimi red); skillWhereBar not appended
(skill-where 0/11 per engine).

Not tried: a real Pi, omp or OmO run (versions read from their npm
source); the setting on the Windows box or in WSL; the whole GUI suite.
2026-11-03 05:43:12 +08:00
yetone 91379b9339 settings: a reply's model can be the vendor's own name again, the member, or the model asked for (ZoeCats)
ZoeCats (Discord #general): since v0.1.2473 a reply's model says the name
the client asked for (a group or provider/model id), groups that aren't
aggregates included, and the only way back to the vendor's own text was the
X-Magpie-Response-Model header, which their client can't send.

Settings › Models › Replies › Model name in replies (replyModel), picked
from the app's menu, in en, zh, zh-TW, ja and de:
- "" the model asked for (the default, as now);
- member: magpie's provider/model that answered (what memberModel did;
  Claude Code, Claude Desktop and Codex still get the name asked for);
- vendor: the vendor's own text, for every agent, the vendorNamed three
  included, as every agent got before v0.1.2473 and as the header's
  "vendor" already gave them.
X-Magpie-Response-Model (asked, member or vendor) still picks for its
request; an unknown value falls through to the setting, as before.

memberModel is folded in without changing anyone's choice: a file with
memberModel on reads as replyModel member, an explicit replyModel wins, and
memberModel is written beside it as a mirror so an older magpie reads the
same. An older page sending only memberModel changes the setting only when
its switch moved (a vendor choice survives its saves). The CLI's set/reset
goes through Keys/Choices (replyModel in place of memberModel).

app.js's row is paid for by five comments in Settings' code cut down:
app.js is 145 bytes under its base, no budget raise.

Run on mote at this head (rebased on origin/main b328a7790):
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet ./... clean.
- go test -tags nogui -count=1 -timeout 45m ./internal/settings
  ./internal/settingsapi ./internal/gui ./internal/cli ./internal/gateway:
  settings, settingsapi, gui, cli ok; gateway ok but
  TestCodexPoolSaysTheClientsVersion, red in the full package and green
  alone (#4807, another test's Codex identity; passed alone at the
  previous head).
- GUI (node --test, chromium + webkit): reply-model-setting (5 languages x
  1100/420, plus default-to-member), loop-guard-setting, i18n-keys,
  account-discovery, disabled-models, masking-records,
  refusal-retries-setting: 222 pass, 0 fail.
- Whole GUI suite earlier at d73b208ac's tree: reds in account-eye (#4244)
  and segs-press-redraw's "every Settings option" (#4566, searchAllRow;
  red the same at origin/main b328a7790, run alone), plus load reds in
  unrelated pages; none in Settings' Replies.

Rebased again onto f3681b90c (Agents page, usage, claude /usage) and
run there: internal/gui and settingsapi -run Budget|SettingsSave|Keys ok,
settings TestReplyModel ok, i18n-keys + reply-model-setting 26/26.

Broken by hand (each red, then put back):
- replyNamingOf ignoring the vendor setting: TestReplyNamesMember's
  vendor, vendor+codex, vendor+claude code cases red on every protocol.
- normal() without the memberModel fold: TestReplyModelFoldsMemberModel
  and TestReplyNamesMember's "old file on" red.
- Merge without the old page's memberModel rule: TestReplyModelSaves'
  old page turns it on / off red.
- settings_keep_test.go went red at the earlier head (MemberModel not sent),
  fixed by setting replyModel member there.

Not tried: a real vendor account through a real group; the GUI test was not
run against the old app.js (the row doesn't exist there).
2026-11-03 05:38:18 +08:00
yetone 3a74cd92e8 claude: /usage waits for its figures, and a read without them is unknown
Seagull fries (haioushutiao, Discord #help; magpie 0.1.2704, Claude Code
2.1.316, Windows 11, Claude Pro): the Claude card said 暂时无法获取额度,
"Claude Code's /usage told no allowance: ❯ /usage ─── Settin s Status
Config Usage …". Reproduced with a real Claude Code 2.1.316 under
Windows' pseudo console in a sandbox: /usage's panel is drawn first with
"Loading usage data…" while Claude Code asks Anthropic for the figures
(5s timeout, retried only on a 401), and the helper took 3s of a still
screen as the panel drawn whole. On a slow answer it told the panel's
frame as the result, and parseClaudeUsage called any text with no window
"told no allowance". A failed load ("Error: Failed to load usage data",
"r to retry") went the same way.

claudetui:
- screen.go: a small terminal grid (CUP/CUU..CHA/VPA, EL, ED, ECH, CR/LF
  with scrolling, OSC/DCS skipped, an escape or UTF-8 character cut
  between reads kept), 200x50 on Windows as the pseudo console is made,
  80x24 elsewhere. The pseudo console sends only the cells that changed,
  skipping a cell that holds the same letter ("Settin\x1b[1Cs"), so the
  stream read split words and kept a redrawn digit beside the old one.
  While /usage is read, each look of the screen with a window is kept
  (panel), and usageText reads that before the stream.
- command(), built on b4073c06a's wait for the panel (ikunbots; its
  usageDrawn and "hadn't drawn" error kept, now also judged on the grid,
  since the pseudo console's split "Settin s" never matched its tabs):
  "Loading usage data" on screen is waited out (to
  commandWait, s.doing "was still loading /usage's figures" for the
  deadline message); "Failed to load usage data" gets one "r"; a panel
  still with no figure and loading or failed on screen is an
  error_during_execution result, "/usage couldn't load the plan's usage:
  <screen>".
- the fake draws the panel a frame at a time (fakeFrames), as Claude Code
  does: with one write, the pseudo console passed on only the last
  frame, which no longer shows the windows. TestShimReadsUsage now passes
  on Windows (#4820, the fake's side; a real panel with figures was not
  seen on Windows, see below).

provider:
- parseClaudeUsage: a panel with no figure is "Claude Code's /usage
  showed no usage figures: …", not "told no allowance" (kept for
  claudeUsageDenied's refusals).
- claudeUsageUnknown: Claude Code's "temporarily unavailable" and the
  helper's "couldn't load the plan's usage" keep the account's reported
  reading (quota_last), as the first did alone before. Other no-figure
  text is still shown as an error (TestClaudeHeaderSurvivesUnclassified-
  UsageFailure, TestClaudeUsageReadingAloneDoesNotHideUnclassifiedFailure
  hold that).

Fixtures are the reporter's case as the pseudo console passed it on for
the real 2.1.316 (a temporary dump of the helper's screen bytes, sandbox config,
proxy that never answers / refuses): testdata/usage-loading-win-2.1.316.bin
and usage-failed-win-2.1.316.bin.

Run at the pushed head:
- mote: go test ./internal/claudetui ./internal/provider ok; go test
  -run 'Claude|Usage|TUI' ./internal/gateway ok; GOOS=darwin/linux/
  windows go vet ./internal/claudetui ./internal/provider ok; gofmt -l
  clean.
- xiaomi-gpu (win-run): go test ./internal/claudetui: all pass except
  TestShimFirstMessageWaitsForTools, red on Windows at main (#4810).
- xiaomi-gpu, real Claude Code 2.1.316 (npm), sandbox CLAUDE_CONFIG_DIR
  with a fake token, magpie.exe built from this tree, helper run as the
  gateway runs it: a proxy that never answers gives is_error "/usage
  couldn't load the plan's usage: … Settings Status … Loading usage data…"
  after the 20s wait (was a success with the chrome); a refused proxy
  shows "Failed to load usage data", "r" is pressed, and the same error
  comes back in 6.6s. "Settings" is whole now.

Broken by hand (before the rebase onto b4073c06a; the merged loop is
re-checked below):
- old tui.go: TestShimWaitsForUsageFigures slow, retried and failed again
  all red, each telling the reporter's chrome as success.
- the "r" not written: TestShimWaitsForUsageFigures/retried red.
- old parse message: TestClaudeUsageWithoutFiguresIsUnknown red ("told
  no allowance"); old quota_last check: its couldn't-load cases red.
- after the rebase, on the merged loop: the "r" not written,
  TestShimWaitsForUsageFigures/retried red; the old "anything still 3s"
  in place of usageDrawn on the grid, TestShimWaitsPastTheBanner red.

Not tried: a real account (the box has none of the owner's), so a real
2.1.316 panel with figures was never seen through the pseudo console;
whether Claude Code's frames that show the windows reach the pseudo
console's output before it renders the next one is shown only by the
fake. Not taken: asking Anthropic's /api/oauth/usage, which the owner
ruled out (9bf6d4352).
2026-11-03 05:16:40 +08:00
yetone 6c08ee13b0 gateway: a model asking for earlier reasoning back goes on to the group's next member
EDwinpzy (Discord #feedback, magpie 0.1.2717): Command Code's
reflection/beam:free answered a second turn with 400 "Missing required
parameter: 'messages[N].reasoning_content'". The 400 wasn't retryable,
so a routing group of Beam then Glyph ended at Beam and never asked
Glyph. The client's request is whole; it is that model's demand for
history it doesn't have, and another member's model may not make it.

reasoningBackRefused (thinking_back.go) reads the demand: DeepSeek's
"must be passed back" (thinkingBackRefusal) and words that name
reasoning_content as missing or required. shapeRefused and retryable
take it, so the member fails as a shape refusal (failShape): no rest,
the next member is asked once. refuseThinkingBack's refill still runs
first, inside forwardOnce. A 400 for a missing 'messages' or 'model'
still stops at the first member. The plugin side (commandcode 0.1.22
fills Beam's earlier replies with reasoning_content) ships separately.

Tests: TestGroupFailsOverAMissingReasoning (chat and responses routes,
the reporter's two-turn shape, his words in the Provider API's error
JSON) and TestMissingReasoningIsNotABadRequest.

Run on mote: go test -count=1 -timeout 45m ./internal/gateway: every
test passes except TestCodexPoolSaysTheClientsVersion, red in a full
package run and green alone, already filed as #4807 (another test's
Codex identity reaches it); go test ./internal/provider ok;
GOOS=linux and GOOS=windows go vet ./internal/gateway ok; gofmt -l clean.
After a rebase on 253aee08b (conflict with #4732's zhipuImageRefusal in
shapeRefused, both kept): the same packages and vets again, provider ok,
gateway red only for #4807 and TestCompactionOverByteCapEveryTime, which
is #4862 (red in a full run, green alone). At the pushed head, rebased on
d76c4b23a: TestGroupFailsOver*, the two new tests, ThinkingBack, Zhipu,
Webp, #4807's and #4862's tests ok in gateway; Mover/Moved/CommandCode ok
in provider.

Broken by hand: with reasoningBackRefused returning false (the old
classification), both new tests are red (400 from Beam, Glyph never
asked; shapeRefused and retryable false for every demand).

Not tried: a real Beam request (the Command Code key here answers 401),
so the error JSON around the reporter's words is constructed, not saved.
2026-11-03 05:10:38 +08:00
yetone b4073c06a0 claude-tui: /usage waits for its panel, never takes Claude Code's banner as it (ikunbots on X)
ikunbots (v0.1.2738) showed a Claude card saying "Claude Code's /usage
told no allowance: ▘▘ ▝▝ /private/var/folders/…/magpie-claude-work-501
────". After /usage is typed, Claude Code draws itself again (banner,
folder, the prompt's rules) before the panel. A slow /usage leaves that
still, and the helper took any screen still for 3s as the panel, so the
banner was told as /usage's answer and parsed as an error.

Now a screen without "NN% used" counts as drawn only when the panel's
Settings tabs show and nothing says loading (usageDrawn). With no panel by
commandWait (or the caller's deadline), the result is an error naming what
was last drawn, never a success carrying the banner.

Run (on mote):
- go test ./internal/claudetui/: ok (new TestShimWaitsPastTheBanner: the
  fake draws the reporter's banner, then the 2.1.316 panel 4.5s later;
  TestUsageDrawn; a "banner, no /usage panel" case in
  TestShimEndsAtItsCallersDeadline).
- Broken by hand (old "anything still 3s" condition back):
  TestShimWaitsPastTheBanner red, told the banner as the result, as in the
  report.
- go test -run 'Usage|TUI' ./internal/gateway/ ./internal/provider/: ok.
- GOOS=darwin/linux/windows go vet ./internal/claudetui/ ./internal/gateway/: clean; gofmt clean.

Not tried: a real slow /usage on a real account; the "loading" word is
a guess at the panel's loading text, which only keeps waiting longer.
2026-11-03 02:41:17 +08:00
yetone dfd3b720bd docs: the gateway's OpenAI images and videos routes, and what each vendor is sent
A table of POST /v1/images/generations, /v1/images/edits, POST /v1/videos, GET /v1/videos/{id} and /content, what each takes and answers, and each vendor's translation, checked against draw.go, draw_volcengine.go and video.go. Asked for by axelburks on Discord. Docs only; nothing run.
2026-11-03 02:40:27 +08:00
yetone 5bd1aee637 video: Seedance takes a last frame and Ark's own fields through /v1/videos
/v1/videos read OpenAI's request into Ark's content-generation body
but left out the last frame (last_frame, which magpie reads for
MiniMax), and dropped every field OpenAI's API doesn't have, so a
caller in OpenAI's shape couldn't turn off Seedance's audio, fix a
seed or ask for an adaptive ratio (axelburks on Discord asked that the
OpenAI shape be converted to the vendor's).

volcengineVideoBody now sends last_frame as an image_url item with
role last_frame, and passes the request's other fields on as sent
(masked as the prompt is, as for a provider's own videos API). A
multipart form's "false" or "42" goes as false or 42, as Ark takes
them.

Run (mote): at a7f31ef46 (this stack on 2c90922b0), gofmt -l internal clean,
GOOS=linux and GOOS=windows go vet ./... ok; go test -timeout 45m of
internal/gateway, imagemcp, browsermcp, cli, davsync, gui, library,
settingsapi, tui, agent: all ok but two reds already filed and untouched
here: gateway TestCodexPoolSaysTheClientsVersion (#4807) and cli
TestEveryRouteHasACommandOrIsNamed (#4826). After rebasing on 1490045f5, gateway re-run there (pushed onto 253aee08b, whose later commits change only provider/gui Gemini URL defaults; not re-run):
gofmt, both vets, and gateway -run Ark|Volcengine|Video|Videomaker|
ImageMCP|Draw|Image|Film|MiniMax|Grok plus imagemcp, ok.

Broken by hand: arkFilms false for a non-preset Ark key turns
TestArkKeyMakesSeedanceVideos red (create 404 at /api/v3/videos, the
reported gap); leaving out the last_frame item, or sending multipart
strings untyped ("false", "42"), turns
TestArkVideoTakesLastFrameAndItsOwnFields red.

Not tried: a real Ark account (the fake answers with Ark's captured
replies from volcengine_fixtures_test.go); multipart extras against real
Ark; the MCP's generate_video has no last_frame argument yet. Siblings
filed: #4954 (an OpenAI key's Sora can't make videos), #4955 (Seedance
listed as chat models).
2026-11-03 02:40:27 +08:00
yetone 93060c98d0 video: an Ark key's Seedance models make videos at Ark's tasks (axelburks on Discord)
axelburks asked for image and video APIs on the gateway that convert
OpenAI's request shape into the real vendor's, Volcengine's in
particular. /v1/videos already did that for the Volcengine preset's
Agent Plan, but any other Ark key (pay-as-you-go /api/v3, or an Ark
endpoint added by hand) had no video models, and one marked a Video
model was sent to an OpenAI-shaped <base>/videos that Ark doesn't
have (404).

Now an Ark key's Seedance models (listed or picked, named seedance) are
its video makers, started at <base>/contents/generations/tasks with
volcengineVideoBody, polled at .../tasks/<id> and downloaded from
content.video_url, as the Agent Plan's are. The id names the key that
started the video, and its poll and download go on that key.

Docs: docs/subsystems/gateway-routing.md.

Run (mote): at a7f31ef46 (this stack on 2c90922b0), gofmt -l internal clean,
GOOS=linux and GOOS=windows go vet ./... ok; go test -timeout 45m of
internal/gateway, imagemcp, browsermcp, cli, davsync, gui, library,
settingsapi, tui, agent: all ok but two reds already filed and untouched
here: gateway TestCodexPoolSaysTheClientsVersion (#4807) and cli
TestEveryRouteHasACommandOrIsNamed (#4826). After rebasing on 1490045f5, gateway re-run there (pushed onto 253aee08b, whose later commits change only provider/gui Gemini URL defaults; not re-run):
gofmt, both vets, and gateway -run Ark|Volcengine|Video|Videomaker|
ImageMCP|Draw|Image|Film|MiniMax|Grok plus imagemcp, ok.

Broken by hand: arkFilms false for a non-preset Ark key turns
TestArkKeyMakesSeedanceVideos red (create 404 at /api/v3/videos, the
reported gap); leaving out the last_frame item, or sending multipart
strings untyped ("false", "42"), turns
TestArkVideoTakesLastFrameAndItsOwnFields red.

Not tried: a real Ark account (the fake answers with Ark's captured
replies from volcengine_fixtures_test.go); multipart extras against real
Ark; the MCP's generate_video has no last_frame argument yet. Siblings
filed: #4954 (an OpenAI key's Sora can't make videos), #4955 (Seedance
listed as chat models).
2026-11-03 02:40:27 +08:00
yetone 1490045f59 claude bridge: an unloaded deferred magpie MCP tool is handed over by its full name
packinggoods (#feedback, 11-02): every first MCP call in Claude Code
failed with "Error: No such tool available: magpie-web-search__web_search"
and the retry worked.

Claude Code with tool search on names a deferred MCP tool in a reminder
and leaves it out of tools until ToolSearch loads it. Through the Claude
subscription bridge the run's model reads that name and calls it,
mcp__magpie__magpie-web-search__web_search; toolStart cut mcp__magpie__
and, the tool not being one the client sent, handed the client the bare
magpie-web-search__web_search, which it has no tool of. After a
ToolSearch the tool is in tools, the cut name maps back, and the call
works: the retry. a3768cdd1 (the router sending a name it no longer
lists to its server) doesn't reach this; nothing gets to the router.

toolStart now hands such a call over under the name the model called,
the client's own, when the cut name maps to nothing and isn't among the
run's tools. A declared tool maps as before; with the run's tools not
yet set the old behaviour stays.

Reproduced in a sandbox HOME with Claude Code 2.1.316 against a fake
Anthropic API and a stdio MCP server: a call of the bare name gives
the reporter's exact error, and a call of the full name of an unloaded
deferred tool runs.

Run at this head (mote): go test -tags nogui ./internal/gateway -run
'TestClaudeBridgeHandsOverAnUnloadedMagpieTool|TestClaudeBridgeKeepsMagpieMCPNames|TestClaudeRunEndsAfterStructuredOutput|ToolChoice|ToolName'
ok; then rebased on fb872a68e (a2837c1f5 and 2ff93ffd6 on top change
only two provider movers' mins): gofmt -l internal/gateway clean,
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gateway ok,
go test -tags nogui ./internal/gateway -run 'Claude|MCP|Hub|ToolName|ToolChoice'
ok (88s).
Broken by hand: with the name = called line out,
TestClaudeBridgeHandsOverAnUnloadedMagpieTool is red: handed
"magpie-web-search__web_search", want
"mcp__magpie__magpie-web-search__web_search".
Not tried: a real bridge run on a real Claude account, and the
reporter's own setup (agent, account) is inferred from the screenshot.
Not changed: a deferred tool of another client MCP server
(mcp__linear__…) is still answered by the run (#4956, related #4854).
2026-11-03 02:36:06 +08:00
yetone 2ab9235711 agents: an agent's picks can be kept to this computer, as an MCP server can
chenxiang0010 on Discord: 「agent当前选择的模型可不可以像mcp那样 只对当前设备生效」.
Sync carries every agent's picks (model, effort...) between computers;
an MCP server has an opt-in "This computer only" that sync and backup
files never carry. Agents now have the same: the row's menu (right-click
or ...) has This computer only, off by default, so an upgrade changes no
pick on any computer.

- settings: AgentsHere, this computer's own (KeepOwn), and kept by a save
  of the Settings page (settingsapi.Apply), which doesn't send it.
- davsync: each kept agent adds "<id>.*" to the own set (withHere, isOwn),
  so a sync neither pushes its fields nor brings the server's; a Restore
  from the server leaves them. sync-state.json records the list as of the
  last sync (Here): hashes before a sync use it and after use the current
  list, so turning it on or off is no change on either side, and a changed
  list forces the sync past its early returns. Turned off, the next pick
  goes up again. Other agents still sync both ways; the implicit own
  fields (hayden4608) are unchanged.
- backup.Restore skips a kept agent in a backup file.
- gui: POST /api/agents/here; the row says "This computer only" beside
  the version (hidden in the tray panel and in a narrow row), menu ticks.
  Core words moved from the library plugin's i18n into core i18n
  (zh/zh-TW/ja/de). Comments in renderAgents cut to pay for it under the
  core budget (no raise).
- cli: the route is named under stage 3 (no command yet).
- docs/subsystems/sync-backup.md describes it.

Run on mote, at the base eb8b840dd (Go and the GUI files below) and again
at this head's base for internal/gui (core budget) and agent-here,
i18n-keys, agent-menu-label:
- go test -tags nogui ./internal/davsync ./internal/settings
  ./internal/backup ./internal/gui ./internal/settingsapi: ok
- go test ./internal/cli: ok but TestEveryRouteHasACommandOrIsNamed,
  red on main for POST /api/usage/checkin-account alone (#4826)
- GOOS=linux and GOOS=windows go vet ./...: ok; gofmt -l: clean
- GUI, chromium + webkit: agent-here (en/zh/zh-TW/ja/de x 1100/640/360),
  i18n-keys, sync-own-fields, mcp-local-server, agent-menu-label:
  90/90 ok
- the whole GUI suite: cut off at test 3783 by a session restart; the
  rest (key-* on) is still running at push. Reds seen so far, under
  three GUI suites at once on mote, none in an agent file: account-eye,
  balance-fix (Sub2API, /api/user/self), codex-auto-reset, context-map,
  editor-advanced-align; being checked at main and filed there.

Broken by hand, each red then restored:
- hereOf returns nil: TestAgentHereThroughSync "B's kept picks went up"
- backup.Restore's kept skip off: "B after a backup file"
- KeepOwn line dropped: TestAgentsHereIsThisComputers "another
  computer's kept agents came in"
- TestSettingsSaveKeepsWhatItDoesNotSend went red on this change before
  settingsapi kept AgentsHere (a Settings save would have dropped it).

Not tried: a real two-computer sync with real accounts; no CLI/TUI
command for the flag; Settings -> Sync doesn't list kept agents; WSL
agent ids (codex@wsl:...) only through the key format.
2026-11-03 02:27:20 +08:00
yetone 5ec2375688 gateway: a call's HTTP headers both ways, masked, folded under its bodies
usrname1833 on Discord asked to see the raw request and response HTTP
headers (查看原始请求和原始响应的http头), to debug as with a capture.
magpie kept the client's request headers and its own response headers
only in the request archive, and nothing of what went upstream.

Now a call keeps its headers both ways (internal/gateway/wire_headers.go):
- the client's, as they reached magpie: headerLogged in Handler() clones
  them for every request that isn't a GET, HEAD or OPTIONS;
- each request magpie sent upstream for the call: method, address,
  headers, and the answer's status, protocol, headers and time, or the
  error. rpmTransport (under s.client) records it as it is sent;
  provider.SendsThroughPlugin records a plugin account's hand-off, shown
  as handed to the plugin, since the plugin's own request to its vendor
  is made in Bun and magpie doesn't see it (the view says so). The first
  8 tries are kept, the rest counted.
Recording copies each header map; nothing is masked or sorted as a
request goes. Secrets are taken out when the headers are read
(Call.Headers): by what each header is (new redact.SecretHeader, now
behind redact.ScrubHeader: Authorization, cookies, x-api-key, api-key,
any *-Key, *-Token, *-Secret, *-Auth, *-Signature, but Idempotency-Key
and a count of tokens such as anthropic-ratelimit-tokens-remaining),
any Bearer or Basic value, and redact.Scrub on the rest; an address
loses its password, a secret-named query value (?key=) and its fragment.
They live with the call in the 40-call ring; /api/gateway/call gives
them as "headers". The request archive keeps the upstream ones as
"upstream" beside the request's and response's headers, masked the same
way. No body is stored that wasn't before.

GUI: under a recent call's bodies on Gateway and a request's on Routing,
"HTTP headers" folds open the client's headers, then each upstream
request beside its answer (wireHeadersView, plugins/usage/page.js); the
archive's copy shows its upstream requests too. Strings in all four
languages. docs/subsystems/gui-shell.md describes it.

Also changed by SecretHeader: the request archive no longer masks a
rate-limit count header (…-tokens-remaining), which the old name rule
took for a token. (provider.SecretHeader, which backups use, is another
function and unchanged.)

Tests: TestRecentCallHeadersBothWays (a fake vendor; the client's key and
cookie, magpie's upstream key and the vendor's Set-Cookie all masked;
status, protocol and response headers kept), TestRecentCallHeadersEachTry
(a 429 then the next key, both kept in order), TestPluginHandOffHeaders,
TestScrubURL, TestSecretHeaderRealNames (real header names both ways),
TestArchiveOnThisComputer and TestRecentCallBodiesOnDemand extended,
call-headers.test.cjs (Gateway, Routing and the archive's copy; chromium
and webkit; en at 1100px, zh, zh-TW, ja, de at 380px and Routing at 440;
nothing out of the box, no left-border accent).

Run (on mote, macOS 27.2, through mote-run, unless named):
- Full suite at ebd22b1b4 (the same change on 5daba8337): gofmt -l
  empty, GOOS=windows go vet ./... ok, GOOS=linux go vet -tags nogui
  ./... ok, go test -count=1 -timeout 45m ./...: every package ok but
  four tests, none in this change's code, each filed:
  TestEveryRouteHasACommandOrIsNamed (internal/cli,
  /api/usage/checkin-account from e87140242, #4826),
  TestCodexPoolSaysTheClientsVersion (#4807: another test's Codex
  identity, passes alone, 3 of 3 here), TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27), TestClosingWindowMarksPageOutOfSight (passes
  alone; filed #4924).
- Rebased on a3768cdd1 (it changed internal/gateway, routing/client.js
  and i18n.js): gofmt, go vet, Linux (nogui) and Windows vet of
  internal/... ok; go test of internal/gateway, gui, redact, provider:
  ok but TestCodexPoolSaysTheClientsVersion (#4807, ok 3 of 3 alone
  with this change's gateway tests) and TestMainWindowCorners (#3949);
  TestCoreScriptBudget ok. GUI: call-headers, routing-bodies,
  recent-call-bodies, request-archive and i18n-keys, 58 of 58.
- Rebased again on 2c90922b0 (app.js and internal/provider, no file of
  this change): TestCoreScriptBudget and TestRecentCall* ok;
  i18n-keys plus call-headers 24 of 24 three times out of four at load
  ~130 on mote. The first try had 1 red of 24 whose name was lost
  (its output was grepped, not kept); it did not come back in 3 runs.
- At the pushed head, rebased on 898c314b7, then 3e61d814e and 8d4d8b2d5 (gateway search, redact; vet, internal/redact and the header tests again ok) (app.css, app.js, i18n.js,
  gui-shell.md and internal/gateway changed): gofmt, vet of gateway and
  gui ok; TestCoreScriptBudget, TestRecentCall*, TestRouteCall,
  TestPluginHandOffHeaders, TestArchiveOnThisComputer, TestScrubURL ok;
  i18n-keys, call-headers, routing-bodies, recent-call-bodies 54 of 54.
- call-headers.test.cjs 20 of 20 (chromium and webkit; en at 1100, zh,
  zh-TW, ja, de at 380; Routing at 440), screenshots looked over.
- GUI: not the whole suite. mote had three other sessions' full GUI
  suites running and the Linux box one, so 131 files the change can
  reach (gateway*, routing bodies/log/steady/story/time, recent*,
  call-*, request-archive, masking*, usage*, i18n*, gui-*, account-eye)
  ran on the Windows box: 1739 of 1862. Every red file was run again at
  5daba8337 on the same box: routing-bodies, gateway-card,
  gateway-systemone, masking-demo, usage-ledger's Requests and the rest
  are red there too (Windows WebKit and Windows-only), and account-eye,
  routing-log-icons, usage-ledger-leave and -probe pass alone at this
  change. call-headers' 4 webkit Routing reds on Windows are
  routing-bodies' own (".rt-day" never visible in Windows WebKit).

Broken by hand, each then put back:
- ScrubHeader back on the name rule: TestSecretHeaderRealNames red
  ("a count of tokens: [REDACTED]").
- rpm.go's upstreamBegins taken out: TestRecentCallHeadersBothWays,
  TestRecentCallHeadersEachTry, TestArchiveOnThisComputer and
  TestRecentCallBodiesOnDemand red.
- scrubHeaders off the sent headers: TestPluginHandOffHeaders red with
  the plugin's key shown.
- Gateway client.js's toggle taken out: the 5 chromium recent-call GUI
  tests red.

Not tried:
- The whole GUI suite (above), and the GUI on Linux.
- A real account or the real app: only fakes.
- What a plugin sends its vendor (made in Bun, not seen by magpie; the
  view says so), and headers Go's transport adds itself
  (Accept-Encoding, Content-Length).
- magpie's own requests (System One's decision, titles, search) keep no
  headers; a gateway served by another magpie shows none.

Asked by usrname1833 on Discord.
2026-11-03 02:25:23 +08:00
yetone 8d4d8b2d5f redact: a field set to nothing takes nothing from the next one (mx_albert)
mx_albert on Discord (#feedback): with Secrets masking on, this command
line went to the vendor with 127.0.0.1 replaced:

  env -i PATH HOME UI_USER= UI_PASSWORD= UI_ADDR=127.0.0.1:39117 DATA_DIR=/tmp/x ./syncer serve

The SECRET rule (a name with password/secret/token/api_key, then = or :)
lets a space stand after the separator, for `password = hunter2` in a
config. UI_PASSWORD is set to nothing, so the rule took the next word,
UI_ADDR=127.0.0.1, as its value and masked it as {{SECRET_…}}:39117;
once masked it was a known value and went masked wherever it came again.
The other field rules (*_KEY / *_PASS, key, 密码, 密钥, "token 是") had the
same shape.

Now a value that is an assignment of its own after a space (UI_ADDR=,
addr=, --listen=; an = with something other than = after it, so a
base64 value's padding is never one) is the next field: the match is
dropped and the search goes on from that value, which is read with its
own name (fieldMatches, nextField). UI_ADDR's address goes as written;
UI_PASSWORD= UI_TOKEN=t0k3nValue2 still masks the token, as UI_TOKEN's.

Old data: what was masked before is known only in memory, so after the
update's restart 127.0.0.1 in that line goes as written for every user;
a conversation carrying it sends it as written from then on (one prompt
cache miss).

Tests: TestEmptyFieldTakesNotTheNext (the reporter's literal line, plus
0.0.0.0, [::1], localhost:port, logfmt, --flag=, and the CJK and
"token 是" rules, every category on) and TestSecretBesideEmptyFieldMasks
(hunter2pass9, a token after the empty field, a *_KEY, a base64 value,
password = with spaces).

Run at this head on mote: go test ./internal/redact ./internal/masking
./internal/otlp ./internal/pii ./internal/sessions ./internal/settings
./plugins/redact all ok; ./internal/gateway and ./internal/gui (nogui)
-run 'Redact|Mask|Privacy|Secret' ok, gateway
TestLoopGuardLeavesOrdinaryRepliesAlone ok (it reads the doc page);
GOOS=linux and GOOS=windows go vet ./internal/redact ok; gofmt -l clean.

Broken by hand: findAll with the field check turned off. Both new tests
go red: the reporter's line masks {{SECRET_…}}:39117, and 17 of the
other cases fail (UI_TOKEN= after an empty field masked with its name,
UI_ADDR=127.0.0.1 then masked as known in the next case).

Not tried: the full gateway and gui packages (another session's suite
was on mote), the GUI, a real request through a running gateway.
UI_PASSWORD=hunter2 itself is not masked by a rule, before or after
this: the rule asks 8 characters of a value, hunter2 has 7.
2026-11-03 02:22:05 +08:00
yetone d5dc8eeccc gui: Scroll to top and Scroll to bottom on a long page (emo172)
#1090 (emo172) asked for back-to-top and back-to-bottom buttons on the
main pages. Once a page is scrolled more than one window down, a small
capsule with two buttons, Scroll to top and Scroll to bottom, fades in.
It sits in the page's right margin when a wide window leaves one, and
otherwise over the page's corner, above Providers' sticky Add buttons.
It stays hidden near the top of the page, while a dialog is open, and
(over the corner) at the page's foot, where the last row can't scroll
out from under it, unless it has the pointer or keyboard focus. The
page's own height never changes for it, because app.js's scroll guard
measures that height.

A press goes through scrollOnPurpose, so the window's scroll guard
takes it as the reader's own scroll. It scrolls smoothly, or at once
under reduced motion, and the button at the end it already reached is
aria-disabled. Both buttons are real buttons, reachable by Tab, with a
label and tooltip in en, zh, zh-TW, ja and de. They are drawn from the
window's tokens in both themes, with no gradient and no coloured edge.

scrollends.js is imported on the window's first scroll, so the core
scripts carry one line in app.js, paid for by two comments cut from
the scroll guard's. No budget was raised. old-webkit lists scrollends.js among the lazy scripts.
docs/subsystems/gui-shell.md says where the capsule sits and when it
shows.

Run on mote at this head (on 2c90922b0, with the next commit):
- view-ends.test.cjs, 32 of 32: Chromium and WebKit, light and dark,
  420 and 1180 wide, every language. It checks that the capsule shows
  only past one window, that Scroll to bottom reaches the foot and stays
  there, and that the page is never taller under the capsule. It checks
  that the capsule is beside every row, or steps aside at the foot, and
  that Tab plus Enter on Scroll to top reaches 0 and stays.
- click-scroll, i18n-keys and old-webkit: ok.
- go test -run Budget ./internal/gui, gofmt -l, and go vet with
  GOOS=linux -tags nogui and with GOOS=windows: ok.
- The whole GUI suite at the pre-rebase head (5f0a84a00 + this):
  18,675 tests, 18,370 pass, 305 fail in 51 files. All 51 files were run
  again at 5f0a84a00 without this change, and 48 were red there too
  (297 fails).
  - The other three, import-row, provider-detect-models and
    routing-many-keys, and every test red at the head but not at the
    base, were run again alone at the head. They passed, or failed in a
    different engine or language than the first run, in the same tests
    that were red at the base. These are known load reds: #4389, #3488,
    #4585, #3415, #4127, #4126, #4244, #4082, #4619, #4431 and #4035.
  - old-webkit's red ("profilerename.js is not loaded by index.html")
    is on main since 1cb4d4301 and is fixed in the next commit.
- go test ./internal/gui: red only at TestMainWindowCorners on mote's
  macOS 27 (#3949), the same as on main.

Broken by hand:
- At the old code, view-ends is red: the capsule's ::after room made the
  page taller ("the page grew under the capsule"). That room had also
  turned add-button, library-discover-jump and account-eye red in the
  whole suite, which is why the capsule steps aside instead.
- Without the step-aside at the foot, view-ends is red.
- Without the import hook in app.js, every case is red.
- Without scrollOnPurpose, "the page stays at its foot" is red, because
  the guard puts the scroll back.

Not tried: the real Wails app on macOS, Windows and Linux (WebKitGTK),
and the tray panel, which has no long page to show it on.
2026-11-03 02:14:32 +08:00
yetone eb8b840dd4 claude: a one-off ask's instructions go after Claude Code's system prompt in the interactive mode (#2432)
The interactive mode's helper pastes a run's first message as one text,
without the cache marks renderClaudePrompt puts on it. A one-off ask's
caller instructions were in that message, so Claude Code's auto mode
classifier wrote them to the cache on every check of one conversation:
laozhang713's six checks on one account, no 429, read 1,197 and wrote
83-85k each (#2432; j1374615791-lab saw the same at 125k).

A new interactive run for a one-off ask (no tools, no reply before it,
not lean, no client marks: appendsPrompt) now gets the instructions by
--append-system-prompt-file (append.md, the leanSystem text, the
environment note worded as a lean run's), and its first message holds
the ask alone. Such a run is let go after its reply (ended); it is never
shelved or branched (run.appended), since a session resumed without the
file would have no instructions. Every other run is unchanged.

Run:
- TestClaudeTUIOneOffAskAppendsInstructions and
  TestClaudeAppendOnlyForInteractiveOneOffs (tools, reply, -p) on mote.
  Broken by hand (appendsPrompt returning false): the first goes red.
- mote: gofmt; go vet ./internal/gateway for darwin, linux and windows;
  go test ./internal/gateway -run 'Claude|Lean|TUI|Subscription|Replay|Branch'
  ok (65s), at base a3768cdd1.
- Real Claude Code 2.1.316, interactive, in a sandbox HOME against a
  recording server, two runs with the same appended rules and different
  asks: the two marked system blocks are byte for byte the same, the
  rules at the end of the 110k one; only the unmarked billing line differs.

Not tried: a real account's cache_read on the second classifier ask;
the full internal/gateway package and the full suite (running after the
push); Windows/WSL runs of the bridge.
2026-11-03 02:08:41 +08:00
yetone 95d0c97bf9 routing: "Use before expiry" counts credits that expire before the reset (lcyksp)
lcyksp on Discord: the 「重置前用完」 strategy (pace) ranked a WorkBuddy
account by its monthly 500 credits ("积分 0 / 500 · 已用 0% · 28 天后重置").
WorkBuddy spends check-in credits first because they expire sooner
("70.85 积分 将于 2026/11/3 09:28:52 过期"), and the account was ranked as
if nothing would be lost for 28 days.

What changed:
- provider.Allowance.Pace takes a budget window's soonest expiry into
  account (Limit.RunsOut, from QuotaWindow.RunsOutAt, which the
  WorkBuddy plugin and others set on the credits window). When that
  expiry comes before the window's reset, the window's pace is the
  higher of:
  - what is left per hour until the reset;
  - the share that expires (QuotaWindow.RunsOut, now carried as
    Limit.RunsOutLeft) per hour until it expires. When the amount isn't
    told, all that is left counts. A share is capped at 100%, and the
    hours at no less than one.
  The account whose credits are lost soonest per hour goes first.
  Expiry at or after the reset, or already past, changes nothing.
  Zero-config: nothing new to set.
- The trace says DueBy "expiry" when the expiry set the deadline. The
  Routing page's reason then reads "Use before expiry: {who} has the most
  credits expiring per hour until they expire — {n} of its allowance
  expires in {d}."
- Label: "Weekly pace" / 重置前用完 / 週ペース / Wochentempo becomes
  "Use before expiry" / 到期前用完 (zh, zh-TW) / 期限前に使い切る /
  Vor Ablauf aufbrauchen. Product call: the strategy's goal was always
  "lose nothing at the deadline". A reset and an expiry are both such a
  deadline, and "到期" covers both, where 「重置」 names only one. The id
  stays pace, so saved groups are unchanged.
- The descriptions (Routing, Settings, group editor), docs/reference.md,
  docs/subsystems/gateway-routing.md and the site's start page (en, zh,
  ja) say the same.

Go, run on mote at base f95bacdfb:
- gofmt -l internal plugins: clean.
- go test -count=1 -timeout 45m on ./internal/provider,
  ./internal/gateway/..., ./internal/routes, ./plugins/..., ./internal/gui,
  ./internal/tui and ./internal/cli: all ok except three reds that are
  filed and don't touch routing or pace:
  - TestCodexPoolSaysTheClientsVersion (#4807)
  - TestMainWindowCorners (#3949)
  - TestEveryRouteHasACommandOrIsNamed (#4826)
- GOOS=linux and GOOS=windows go vet on the same packages: ok.
- GUI: the touched files (routing-pace-expiry, routing-save,
  routing-group-strategy, routing-reset-deadline,
  routing-wallet-balance, builtins), chromium and webkit: 90 pass, 0
  fail.
- GUI on WSL magpie-desktop (Linux), after the rebase onto 9c58c87e8:
  the 387 files that name routing, i18n, strategy or reason text,
  chromium and webkit: 6211 tests, 6012 pass, 199 fail in 54 files.
  Another session's full suite was running beside it.
- Those 54 files again on mote, with this change and at 9c58c87e8
  without it: 100 and 99 reds. They are the same tests, differing only in
  which language went red. Filed as #4932. routing-group-strategy, whose
  one WSL red was a 9px webkit position, passed both times.
- After the last rebase, onto d29f02d65 (it changed gateway/routing.go,
  i18n.js and app.js), on mote: gofmt clean.
  - go test ./internal/provider ./internal/routes ./plugins/rotation/...:
    ok.
  - go test -run "Pace|Reset|Deadline|Expir|Routing|Weekly|Strategy|Order|Allowance"
    ./internal/gateway: ok.
  - linux and windows vet: ok.
  - GUI routing-pace-expiry, routing-save, routing-group-strategy,
    routing-reset-deadline, routing-wallet-balance, builtins and
    i18n-keys: 94 pass, 0 fail.
- c47fc516a (Tencent Cloud's Token Plan) landed after that run and was
  not run again with this change.

Broken by hand, each red:
- The expiry branch in Pace taken out: TestPaceCreditsExpiring and
  TestPaceGoesByCreditsExpiring.
- dueExpiry left unset: TestPaceGoesByCreditsExpiring's trace check.
- RunsOutLeft not carried: TestAllowanceCarriesRunsOutLeft.
- client.js's expiry reason line taken out: routing-pace-expiry, 0 of 10
  pass in chromium.

Not tried:
- A live WorkBuddy account with check-in credits about to expire. The
  fixtures use lcyksp's numbers (500 monthly, 70.85 expiring).
- The site pages are not deployed by this commit.
2026-11-02 21:52:57 +08:00
yetone c47fc516a4 provider: Tencent Cloud's Token Plan is at tokenhub.tencentmaas.com/plan (ysm119)
ysm119 (Discord) showed Tencent's docs: Token Plan's OpenAI base is now
https://tokenhub.tencentmaas.com/plan/v3 and the Anthropic one on
tokenhub.tencentmaas.com is the recommended one, with
api.lkeap.cloud.tencent.com marked as going away.

Tencent's current pages (product/1823/130060 个人版 overview, 130070
Claude Code, 130071 Codex, 130119 quickstart, 136601 CC Switch, all
updated 10-15 to 10-22) give 个人版 the same endpoints as 企业版 China
(130659): chat/responses at https://tokenhub.tencentmaas.com/plan/v3,
messages at https://tokenhub.tencentmaas.com/plan/anthropic, one sk-tp-
key for 通用 and Hy plans.

- The tencent-cloud preset's plan region (and the preset default) are
  at those endpoints, with Responses added (Codex's page uses
  wire_api "responses"). magpie tells regions apart by endpoint, so the
  personal and China enterprise regions, now one address, are one:
  "plan", models the union of both lists. "enterprise" stays an alias
  (regionAliases, RegionID): a key saved on it, an import link with
  region=enterprise and `region=enterprise` on the CLI land on plan.
  Singapore 企业版 (enterprise-intl) is unchanged.
- A Tencent Cloud provider saved at the old lkeap /plan/v3 or
  /plan/anthropic is moved to TokenHub at load (moveEndpoints in
  normalize), and gains the Responses endpoint when it had chat. A
  Responses address the user set stays. A provider of no preset (a
  custom one the user typed lkeap into) keeps its address: that is the
  user's value, and lkeap still answers today.
- An app config still at lkeap (Tencent's OpenClaw page, 130062, still
  gives it) imports as tencent-cloud at the new endpoints.
- Usage: DescribeTokenPlan is 企业版's API (api/1823/132270 lists
  enterprise products only), and Guangzhou's endpoint now serves
  个人版 too, so a Guangzhou provider with no SecretId no longer gets the
  card asking for one (tcSharedRegion); Singapore's still does. The
  editor shows the optional SecretId/SecretKey at the plan region, so a
  personal user sees them too.
- docs/subsystems/providers-accounts.md says all of this.

Run at the pushed head's base f3551387c on mote (rebased onto
d29f02d65, which only touches internal/agent's omp; provider and cli
re-run after the rebase):
- go test -timeout 45m ./...: every package ok except three filed reds
  that touch nothing here: cli TestEveryRouteHasACommandOrIsNamed
  (#4826), gateway TestCodexPoolSaysTheClientsVersion (#4807), gui
  TestMainWindowCorners/macOS_26_SDK on macOS 27 (#3949).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: clean. gofmt -l: nothing.
- GUI tencent-cloud, tencent-access-key, i18n-keys (chromium+webkit,
  en/zh): 24 pass, 4 fail, all "a region clicked right after the strip
  scrolled" (#4321/#4399/#4625; app.js is unchanged here).

Broken by hand, each red then green again:
- normalize without moveEndpoints: TestTencentCloudOldPresetsKeepWorking
  and TestTencentPlanMovedFromLkeap fail.
- the import's movedEndpoints lookup: TestTencentPlanMovedFromLkeap.
- the Guangzhou card skip: TestPlanCardWithoutAccessKey.
- RegionID in ParseImport: TestTencentPlanMovedFromLkeap; in the CLI:
  TestTencentOldRegionAtCLI.

Not tried: no real Tencent key here, so no request reached either host
and no real usage read. Tencent's international personal plan (CodeBuddy
page tencentcloud.com/document/product/1300/81035) is at
tokenhub-intl.tencentcloudmaas.com, a host magpie has no region for; not
added. The 即将下线 label in ysm119's screenshot is not on the pages
fetched, and no retirement date was found (FAQ 130076). The site's
import-link builder still offers "Enterprise plan · China", which now
adds the plan through the alias.
2026-11-02 21:41:56 +08:00
yetone f3551387c6 gateway: a vendor's overload rests no account and climbs no backoff (celestial_eagle_99230)
celestial_eagle_99230 on Discord (v0.1.2670, Codex on auto/gpt-6-sol,
eight ChatGPT Plus accounts, reported several times): every account
showed "休息中 · 529 · 失败 · 10 分钟后恢复", with "它已连续失败 5 次:
休息 10 分钟,每次更久". The request log had the ChatGPT backend's
{"type":"service_unavailable_error","code":"server_is_overloaded",
"message":"Our servers are currently overloaded. Please try again
later."} on /backend-api/codex/responses.

restAfterMarked read the 529 as failOther: the account's own failure,
counted on the backoff ladder (1m, 2m, 4m, 8m, 10m cap). An overload is
the vendor's servers, which every account meets alike, so one spell of
it benched all eight accounts for growing periods and left nothing to
answer. b58669eb0 (v0.1.2721) changed only how the overload is told to
Codex; origin/main still rested and climbed this way.

Now an overload (vendorOverloaded: a 529, or a 5xx whose words say
overloaded, the existing saidOverloaded rule: ChatGPT's
server_is_overloaded, Anthropic's overloaded_error, Gemini's 503 "The
model is overloaded") rests only the model on that account
(restID), 30s (overloadRest), or as long as Retry-After asks up to a
minute (overloadRestMost), every time alike, and counts no failure. The
next account is still asked, the serve loop's patience still waits out
an overload on every member as before, and when all stay busy the
client is told the overload as b58669eb0 tells it (unchanged here). Quota,
credit, rate limits, 401/403 and a plain 5xx rest and climb as before.
The one choke point covers every route that rests (serve loop, group
decider, plugin calls). A provider set never to rest (RestCapOff) still
doesn't.

docs/subsystems/gateway-routing.md says it beside fallbackCooldown.

Tests (internal/gateway/overload_rest_test.go), from the reporter's
literal error body:
- TestOverloadRestsNoAccount: three Codex accounts, two answering 529
  server_is_overloaded with Retry-After 7, six requests: no account rests
  whole, the model rests <=7s by retry-after with 0 failures.
- TestOverloadRestIsShortAndFlat: six overloads in a row for each of
  ChatGPT 529, ChatGPT stream error, Anthropic 529 overloaded_error,
  Gemini 503: model rest <=30s, 0 failures each time; Retry-After 600
  is held to a minute; then a 500 is the first ladder step (1 failure),
  a 401 rests the account (2), a usage_limit_reached is quota.

Broken by hand: with origin/main's routing.go both tests go red, the
rests climbing 1m, 2m, 4m, 8m, 10m by backoff for the same overloads.

Run on mote at this head: gofmt -l clean; GOOS=linux and GOOS=windows
go vet ./internal/gateway ok; go test -count=1 -timeout 45m
./internal/gateway: every test ok except
TestCodexPoolSaysTheClientsVersion, the known #4807 (another test's Codex
identity reaches it in a full package run); it and the new tests pass
run alone at this head.

Not tried: a real ChatGPT overload (can't be caused on demand); the
full ./... suite (another session's full suite was running on mote);
GUI suite (no GUI change: the rest shows with the existing "retry-after"
and "cooldown" wording). A real 5xx met during an overload's 30s rest
isn't counted (backingOff sees a failOther rest), so it rests at the
current step rather than climbing one; that errs toward resting less.
2026-11-02 20:50:46 +08:00
yetone b0174e7615 usage: a ChatGPT card says why its allowance can't be read, and a ChatGPT API account says where it shows
hmy on Discord: five ChatGPT accounts each said only "暂时无法获取额度"
(Allowance unavailable). danzi002 on Discord: accounts added through the
API never show usage, ones added as ChatGPT do.

What changed:
- Codex's usage read (codexWindows) now words its failure
  (codex_usage_words.go): a Cloudflare challenge names the proxy/VPN
  address as the usual cause; any other HTTP answer names its status and
  what ChatGPT said; a network error says chatgpt.com couldn't be
  reached; a reply magpie can't decode says so. The error still unwraps
  to accountStatusError, so expiry and passing logic is unchanged.
- A ChatGPT API account (chatgpt-api) was read as a Codex account: a
  saved one said "chatgpt-api accounts can't be used side by side", the
  one in use read Codex's own sign-in ("Codex is signed out", or another
  account's allowance under its name). OpenAI's API tells no plan usage,
  so its row now says so, names chatgpt.com/settings/usage (SeeAt) and
  says the same account added as ChatGPT shows it here.
- GUI quotaError translates each of these (en, zh, zh-TW, ja, de), and
  "not read yet" (errNotAsked) gets its own words. The generic fallback
  now reads "Allowance unavailable — hover for why"; the row's tooltip
  has always been the raw error. Comments in app.js were shortened to
  stay under TestCoreScriptBudget, which is not raised.
- docs/subsystems/providers-accounts.md describes the words.

Endpoint: the real wham/usage read of the owner's accounts in a sandbox
HOME copy (read-only, ~/.codex untouched) answered 200 and parsed, so
the endpoint itself is not broken; the "error decoding response body"
work is another session's and is not touched here.

Run (on mote; provider and gui again at the pushed head, rebased on
18c69aa46; 2251ca1ce, new under it, changed app.js and the budget):
- gofmt -l clean; GOOS=linux -tags nogui and GOOS=windows go vet of
  provider and gui clean.
- go test -timeout 45m ./...: ok except TestEveryRouteHasACommandOrIsNamed
  (#4826, red on origin/main 2251ca1ce too), TestMainWindowCorners (#3949,
  red on main too) and TestCodexPoolSaysTheClientsVersion (#4807, red in
  the full run, ok alone here and on main). At the pushed head:
  provider ok, gui ok but TestMainWindowCorners (#3949), core budget ok.
- GUI: chatgpt-usage-why.test.cjs (new; chromium and webkit, 560 and
  390, en/zh/zh-TW/ja/de, each row's words, its status code, the raw
  tooltip, no overflow) and the six tests whose generic line changed.
  The whole GUI suite was not run before this push: another session's
  full suite held mote. The change adds no API call and no layout, only
  words; the whole suite runs after the push and its reds get issues.

Broken by hand:
- codexWindows returning the bare err: TestCodexUsageSaysWhy and
  TestCodexLoginUsageSaysCloudflare red.
- the GUI ChatGPT patterns removed: chatgpt-usage-why 0/2.
- the chatgpt-api branch off: TestChatGPTAPIUsageSaysWhere red, the
  row read "Codex is signed out; run codex login".

Not tried: a real Cloudflare challenge (the fixture is the start of its
page as Cloudflare serves it, not hmy's bytes, which magpie hasn't got); a real ChatGPT API account (none signed in here); making a
ChatGPT API account's usage readable, since its token is for
api.openai.com and OpenAI shows plan usage only on chatgpt.com.
2026-11-02 20:04:32 +08:00
yetone 18c69aa467 gui: Windows reads the screens with one callback, not one per display change (1111_13879)
1111_13879 on Discord: on Windows the app died after a few hours with
"fatal error: too many callback functions", taking the gateway with it
(clients got connection refused). Five dumps all ended in
w32.GetAllScreens -> syscall.NewCallback -> runtime.compileCallback,
from Wails' WM_DISPLAYCHANGE handling.

Wails (v3.0.0-beta.24 here; v3.1.0 and v3.2.0-nightly.20261101 are the
same) reads the screens again on every WM_DISPLAYCHANGE, and on
WM_SETTINGCHANGE for SPI_SETWORKAREA, through w32.GetAllScreens, which
passes a fresh closure to syscall.NewCallback each call. Go never frees
a callback and throws past about 2000, unrecoverably.

magpie now sets WndProcInterceptor (screensWndProc): on Wails' hidden
main-thread window ("__wails_hidden_mainthread") it takes those two
messages before Wails does, enumerates the monitors with one callback
made once at package level (allScreens), builds the screens exactly as
Wails' processAndCacheScreens does (wailsScreen) and hands them to
Screen.LayoutScreens, then answers as Wails would (DefWindowProc for
WM_DISPLAYCHANGE, 0 for WM_SETTINGCHANGE). Other windows and messages go
on to Wails. Wails' one read at start-up is the only per-call callback
left. No go.mod change: no newer Wails fixes it, and magpie has no fork.

Other per-call NewCallbacks in Wails' Windows code: w32.EnumChildWindows
and w32.SetWindowsHookEx, neither called by Wails or magpie. WndProc
classes are registered once; the WebView2 COM vtables are package-level.
magpie's own (internal/agent apprestart) is already made once.

Run at this tree (base e156fdd03; origin/main since adds only
2251ca1ce, providers, no shared file):
- Windows (win-run, xiaomi-gpu): the three new tests pass;
  TestScreensReadFarPastTheCallbackLimit reads 5000 times and matches
  Wails' own read field for field. go test ./internal/gui: 5 reds,
  TestGatewayHeldByAContainer, TestLodyImportHandoff,
  TestImportStatusUnreadableIsUnknown, TestAionUiImportRow,
  TestUpdateThatWontStart, the same 5 at e156fdd03 without this change
  (#4115, #2107). internal/proc, agentenv, pluginrt ok; sqlitedb's
  TestSQLiteSurvivesMalformedEnv red, the same at the base (#4115).
- mote: gofmt -l clean; go vet ./internal/gui ./internal/cli .;
  GOOS=windows go vet ./...; GOOS=linux go vet -tags nogui ./...;
  go build, GOOS=windows go build, GOOS=linux go build -tags nogui;
  go test ./internal/gui: ok but TestMainWindowCorners (#3949, macOS 27).
- Linux (wsl-run): go test -tags nogui ./... was still running at push (the nogui build leaves these files out), so it had no result to record here.

Broken by hand:
- allScreens with a NewCallback per call (as Wails does):
  TestScreensReadFarPastTheCallbackLimit dies with the reporter's
  "fatal error: too many callback functions" from
  syscall.compileCallback.
- A throwaway test calling Wails' w32.GetAllScreens 5000 times dies the
  same way at w32/screen.go:145.
- WndProcInterceptor left out of windowsOptions:
  TestAppReadsDisplayChangesItself fails.
- wailsMainThread misspelt: TestWailsScreensAreReadOnTheMainThreadWindow
  fails.

Not tried: the real app through real display changes on a desktop
session (win-run has no interactive desktop; the test creates a window
titled as Wails' own and sends it the messages); a multi-monitor or
rotated-display layout (the box has one screen). No upstream Wails issue
filed yet; text drafted.
2026-11-02 20:00:54 +08:00
yetone 2251ca1ce9 providers: a ChatGPT account's row says when its paid plan ends (danzi002)
danzi002 on Discord (#general, 11-02): 「codex 账号什么是可以加一个 plus
账号到期时间」. The Usage page, the tray panel, the TUI and `magpie
quota` have shown "Until …" for the signed-in Codex account since
d8200dfe5. The Providers → Codex editor's account rows showed only
"ChatGPT Plus", for every account, saved ones included.

Now each Codex and ChatGPT API account in /api/providers carries
`until`, from its own sign-in's id token claim
https://api.openai.com/auth → chatgpt_subscription_active_until (no new
network call). The row puts "Until Nov 19" on the line under its name,
beside its allowance, the whole date and time in its tooltip.
- Codex: the sign-in Codex holds when it holds that account (through
  readCodexLogin, which it refreshes), else logins.json's copy.
- ChatGPT API: its saved id token, then its access token.
- No claim, an unparsable one, or a date gone by: nothing shown, never
  a guess. A real Pro token issued today carried an until weeks in the
  past (its last_checked was older still): OpenAI updates the claim now
  and then, so a past date says nothing true about the plan.
- chatgptUntil is the one reader; codexUntil (the usage card) uses it.

The core scripts' budget is not raised: two account-row comments in
app.js were cut to pay for the line (1,533,739 of 1,533,802).

Checked on real tokens (key names only, read-only from
~/.config/magpie/logins.json): the auth claim's keys are
chatgpt_account_id, chatgpt_plan_type, chatgpt_subscription_active_start,
chatgpt_subscription_active_until, chatgpt_subscription_last_checked,
chatgpt_user_id, groups, localhost, organizations, user_id; the until is
RFC3339 with +00:00. The tests' claims are written in that shape.

Run at this tree on mote (macOS 27):
- gofmt -l internal: nothing.
- go test -count=1 -timeout 45m ./internal/provider ./internal/gui
  ./internal/tui .: provider, tui and root ok; gui red only on
  TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 only, the same
  on main). TestCoreScriptBudget ok.
- go vet ./internal/provider ./internal/gui; GOOS=linux go vet -tags
  nogui; GOOS=windows go vet: ok.
- New TestCodexLoginUntil (signed-in and saved accounts, a past date, no
  claim, the JSON the GUI reads) and TestSIWCLoginUntil: ok.
- New account-plan-until.test.cjs: Chromium and WebKit, 1000, 560 and a
  390 phone browser, en zh zh-TW ja de; the date is whole, inside its
  row, translated, the first line stays one line, no sideways scroll.
- GUI files account-*, codex-*, i18n-keys, lane-limit, login-*,
  providers-*: 892 of 894 ok. The two reds are codex-auto-reset webkit
  de 1100 and 420 ("the click moved the page", Usage page), red the same
  way run alone at origin/main e156fdd03 on mote (#4790).

Rebased on origin/main e156fdd03 (three mover-min commits since the
base): ./internal/provider and TestCoreScriptBudget run again there, ok.

Broken by hand: dropping lg.Until's assignment in loginsNow turns
TestCodexLoginUntil red; dropping the line in siwcLoginList turns
TestSIWCLoginUntil red; dropping the aq.append in renderAccounts turns
account-plan-until red in both engines.

Not tried: a Codex account held in another home (codexHeldIn) has no
test; no real ChatGPT API account's token was read, so its claim is
assumed from the Codex one; no Team plan token was seen; the real app
was not opened, only Playwright's Chromium and WebKit.
2026-11-02 19:41:05 +08:00
yetone 5f0a84a003 agent: Air in JetBrains IDEs gets magpie's Magpie agent in ~/.jetbrains/acp.json (Jumy on Discord)
Jumy asked for the "air-plugin" new in IntelliJ IDEA 2026.3 (Settings ›
AI › Air). magpie's air agent wrote the Air app's acp.json, in
~/Library/Application Support/JetBrains/Air, which the IDE plugin never
reads: the plugin (com.intellij.air, air-plugin-262.8665.521-mac-arm64
from JetBrains Marketplace) loads its custom ACP agents in
AcpConfigurationLoader (intellij.air.backend.acp.runtime) from
user.home/.jetbrains/acp.json on every system, the file AI Assistant's
custom agents use too; AgentServerConfig takes command, args, env,
use_idea_mcp and use_custom_mcp. The standalone app (Air-262.1037.14,
Fleet-based) reads acp.json from its own configs folder
(genericAcpConfigPath), so the two are separate files.

Air's own agents have no base URL: JetBrains AI, the agent's own login,
or an Anthropic, OpenAI, Gemini or OpenRouter key under AI › Air ›
Accounts. So the IDE gets the same route as the app: a new air-ide agent
("Air (JetBrains IDEs)", aliases air-plugin, air-in-ides) writes a
Magpie entry (opencode acp, OPENCODE_CONFIG naming magpie-opencode.json
beside acp.json) and nothing else; the user's agents and
default_mcp_settings stay, and disconnecting takes out that entry and
that file. air and air-ide share airAt. air-ide shows for an IDE config
folder of 2026.2 or later (the plugin is bundled from 2026.3), or with
its entry already in acp.json. Notice in en, zh, zh-TW, ja, de; README,
reference and agent-wiring rows.

Run at this head (rebased on ed978e560), on mote:
- go test -tags nogui ./internal/agent ./internal/gui: ok.
  ./internal/cli: TestEveryRouteHasACommandOrIsNamed red, the
  checkin-account route, #4826, not this change.
- go vet darwin, GOOS=linux, GOOS=windows (agent, gui); gofmt -l clean.
- -run Air on Windows (win-run) and Linux (wsl-run): ok.
- GUI i18n-keys, agent-notice-lang, about-notices, agents-last-known in
  chromium and webkit: all pass.
Broken by hand: air-ide on the app's folder fails
TestAirIDEAddsMagpieAgent; a version check of > in place of >= fails
TestAirIDEDetectedByIDEVersion on GoLand2026.2.
Not tried: a real IntelliJ IDEA 2026.3 with the plugin listing Magpie
(the plugin's watcher should pick up acp.json; JetBrains' docs say to
restart the IDE, which the notice says); opencode acp itself was checked
under the app's entry in 5a0559d37, the entry is the same here.
2026-11-02 19:00:29 +08:00
yetone ed978e560f gui: the Quit question's Don't ask again, and Settings › General › Ask before quitting (zhujiu on Discord)
zhujiu (Discord #feedback) asked for a 不再提示 on the question a tray
Quit asks while agents go through magpie (8826a15ea), and a switch in
Settings to turn it on and off again.

- The question (quitask.js, an in-app sheet) has a "Don't ask again"
  checkbox above its buttons, unticked each time. It goes with the Quit
  chosen: Quit and Disconnect and quit post window/quit?now=1&noAsk=1,
  which saves settings.quitNoAsk (settings.SetQuitNoAsk, under the file
  lock) before quitting; a failed save keeps magpie open. Cancel saves
  nothing.
- AskQuit quits at once when quitNoAsk is set (quitAtOnce); otherwise as
  before. The default is unchanged: it asks.
- Settings › General has "Ask before quitting" On/Off (segs, app-only),
  after Open at login. settingsapi.Keys lists quitNoAsk, and Merge carries
  it when a save doesn't send it, so the tray panel or an older page
  can't turn the question back on.
- zh, zh-TW, ja, de strings. Five app.js comments shortened to stay in
  the core script budget (no raise).

Run at the pushed head (on origin/main f95bacdfb), on mote:
- gofmt clean; go vet darwin, linux, windows (nogui too).
- go test internal/settings, internal/settingsapi ok; internal/gui
  -run "Budget|Quit" ok.
- internal/cli: TestEveryRouteHasACommandOrIsNamed red for
  POST /api/usage/checkin-account, from e87140242, filed as #4826; this
  change adds no route.
- GUI, chromium and webkit: quit-ask-setting (25: en, zh, zh-TW, ja, de
  at 1100 and 420), quit-ask (35), settings-general, settings-sections,
  settings-search, settings-tabs-stick, wsl-agents-setting, agent-prefs,
  i18n-keys, old-webkit, auto-backup, all pass.

Broken by hand, each red:
- api.go's noAsk ignored: TestQuitDontAskAgain "wasn't saved".
- quitAtOnce not reading the setting: TestQuitDontAskAgain "still asks".
- Merge carry dropped: TestQuitNoAskKeptUnlessSent.
- SetQuitNoAsk saving false: TestSetQuitNoAsk.
- quitask.js without &noAsk=1: quit-ask's two Don't ask again tests.

Not tried: a real tray Quit with the box ticked in the built app on
macOS, Windows or Linux; only the sheet in Playwright and the handler
in Go. Not the whole GUI suite.
2026-11-02 18:53:07 +08:00
yetone b58669eb09 gateway: an overload told in Codex's stream says server_is_overloaded (wjh66)
wjh66 on Discord (Windows, v0.1.2710, Codex on the ChatGPT sign-in,
gpt-6.1-sol): every turn showed "reconnecting 5/5", and app.log had the
backend's "Our servers are currently overloaded" again and again.

With one ChatGPT account, magpie asks an overloaded turn again
(lastRetries) and keeps Codex alive past keepHeldAfter with the stream's
200 and comments. When the retries ran out, the backend's busy status
(529, or a 503 saying overloaded) went to Codex in that stream as
response.failed with code server_error. Codex reads server_error as
Retryable (codex-rs codex-api sse/responses_error.rs) and sent the turn
five more times, each one asked three times by magpie: 18 asks of an
overloaded model, then the last error alone. The backend itself says
an overload in a stream as server_is_overloaded (#1418), which Codex
reads as ServerOverloaded: "Selected model is at capacity. Please try a
different model.", without the reconnects.

streamError now gives a Responses client server_is_overloaded when the
status is 529, or a 5xx whose words say overloaded (saidOverloaded).
Other failures keep server_error, which Codex retries. A routing group
or the codex subscription's fallbacks still take an overload before any
of this, as before.

This does not explain the earlier "error decoding response body".
Codex says that only when the body of a 2xx fails to read. magpie's
streams read clean over real TCP in every overload shape tried (see
07f4d46c5, which logs a reply cut early).

Ran on mote at this change rebased on 1cb4d4301: gofmt; go vet
darwin, GOOS=linux -tags nogui, GOOS=windows; go test -count=1
-timeout 45m ./internal/gateway: ok but for TestCodexPoolSaysTheClientsVersion,
the known #4807 (the machine's own Codex 0.165.0 identity reaches it).
At the pushed head (rebased on f95bacdfb, whose new commits add
hub_mcp.go to the gateway, nothing of streamError): go vet darwin,
linux, windows, and the overload, StreamError and Hub tests: ok. On Windows (win-run):
TestCodexKeptAliveOverload*, TestStreamErrorOverloadOnly,
TestCodexOneAccount*, TestCodexOwnModel*, *Overload*, *StreamError*,
TestCodexReplyBrokenOffLogged, TestCodexClientGoneLogged: ok, 50 tests.

Broken by hand: with the else-if turned off,
TestCodexKeptAliveOverloadSaysServerIsOverloaded is red in both
subtests (503 message, 529): code "server_error".

Not tried: a real ChatGPT account or the real Codex client against
this build. Whether gpt-6.1-sol is busy for this account only, or the
same request without magpie. The Windows system proxy between Codex
and 127.0.0.1 as the cause of the decode error.
2026-11-02 18:50:12 +08:00
yetone 58a833f254 mcp router: initialize says what each server behind it is and does
packinggoodsllc_07668 (Discord) runs magpies that only share MCP servers,
and an agent given several routers knew each by its name alone. A
router's initialize instructions now describe what it holds, built from
what the servers themselves say; no model writes any of it.

- After the "Tools of …" first line (and the router's name sentence when
  it has one), a line per server: "- name (its serverInfo.title): what it
  is for. Tools: tool (first clause of its description), …". The tools
  the Library turned off are left out; another router's "[name] " prefix
  is dropped. A line too long for its share says tools by name, then as
  many as fit and "and N more". The whole is at most 2000 characters
  (hubSayMax), the closing text kept whole.
- What a server is for: the market's words as before, else its
  serverInfo.description, else its instructions' first line (saysOf).
  Another magpie's "Tools of a (…), b." is said with "Tools of" once.
- What a server said and listed is kept in settings.Dir()/
  mcp-hub-servers.json (not the synced library folder), keyed by name and
  a hash of hubKey, written via temp+rename only on change, pruned of
  servers gone. A router started again describes its servers without
  starting any; one added or edited since is listed by initialize, which
  waits up to 5s for it.
- Pi's hub description (hubAbouts) uses the server's own words too.

Agents, from their installed source (research, not run): Claude Code
shows instructions (4096 chars), Codex as the namespace description,
OpenCode, Gemini CLI (trusted folders only), Qwen Code, Pi (first line in
the prompt); Kimi CLI ignores them. None shows serverInfo.title.

Run at this tree (mote):
- go test -tags nogui ./internal/library: ok (116s)
- go test ./internal/gateway -run 'Hub|MCP|Roots|OversizedBody|
  ReadOnlyKeyEveryRoute|FileURI|ImageModel': ok
- GOOS=linux and GOOS=windows go vet internal/gateway internal/library;
  go vet internal/gui internal/cli; go build ./...; gofmt -l: clean
- New: TestHubInstructionsDescribeServers, TestHubDescriptionsOutlive
  ARestart (library); TestHubAboutBounded, TestHubServerLine,
  TestHubClauseBrackets, TestHubLineOfARouter (gateway).
- Red on the old code: TestHubInstructionsDescribeServers at c9af34446
  fails ("Tools of la, notes." and nothing more).
- Broken by hand, each red: noteCard not writing the file (restart test),
  the DisabledTools filter removed, saysOf returning nothing.
- Real use: two magpie serve builds of this tree in sandbox HOMEs on
  mote (127.0.0.1:3561, :3562), A serving a stdio notes server, B with A's
  /mcp/magpie/hub as server "la". B's initialize said
  "- la (Magpie MCP hub): Tools of notes (…). Tools: notes__add_note (Add
  a note to the notebook), notes__search_notes (…)."; B restarted with A
  down said the same from the file.

Not tried: a real agent reading the new text (Claude Code, Codex,
OpenCode etc. were read in source only); a router with dozens of real
servers; Windows and Linux runs (the change has no OS-specific code).
2026-11-02 18:37:57 +08:00
yetone a00b53f7b1 gateway: a plugin's fetch is told the session the agent named and its Claude Code subagent (plugins#620)
magpie builds each plugin's request itself, so the agent's own headers
(x-claude-code-session-id, x-claude-code-agent-id, x-opencode-session)
never reached a plugin. Devin's cache keepalive therefore keyed Claude
Code Auto's permission check by its text alone, and on the translated
path magpie merges consecutive same-role messages, so a check whose
history grew changed its first message in the middle and got a new key:
its older pings kept running beside the new ones (zelong77, plugins#620,
still seen on devin 0.1.33).

forwardOnce now sets X-Magpie-Session (sessionOf: the caller's own
X-Magpie-Session, else the agent's session header) and
X-Magpie-Subagent (Claude Code's agent id) on a plugin's request, after
deleting any the caller sent, and host.js's MAGPIE_ONLY list strips both
from what the plugin sends on, so the vendor never gets them. A request
naming no session has neither. devin 0.1.34 keys its pings by them.
docs/subsystems/provider-plugins.md says so.

Run at origin/main 1829cd52f plus these three commits (mote, macOS):
- gofmt -l internal/gateway internal/provider internal/plugin: clean.
- GOOS=linux and GOOS=windows go vet of the three: ok.
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway: plugin ok, provider ok; gateway one red,
  TestCodexPoolSaysTheClientsVersion, which passes alone (-count=3)
  and is another test's Codex identity leaking into it, filed as #4807,
  untouched by this change.
- -v: TestPluginToldTheSession and TestMovedBuiltinsSayTheirPlugin pass.
- Rebased onto origin/main 52195b6b0 (it brings #3388's provider
  change): gofmt clean, linux and windows vet ok,
  internal/provider and internal/plugin ok, internal/gateway -run
  'TestPlugin|TestMoved|Devin|WorkBuddy' ok. Pushed on 9f641daea,
  whose Codex app-server change (codex_app_server.go, codex_daemon.go,
  login_usage.go) touches none of these files; not run again on it.

Broken by hand:
- without the two Set lines in forwardOnce: TestPluginToldTheSession red
  (the plugin told nothing), on relayed Anthropic and translated Chat.
- without the MAGPIE_ONLY entries in host.js: red, the vendor got
  X-Magpie-Session.

Not tried: a real Devin account and a real Claude Code Auto session.
2026-11-02 18:32:47 +08:00
yetone 9f641daeab codex: a turn stuck on a used-up account no longer holds the Codex app's Send grey after a switch by hand or magpie's takeover (xiaoq6285)
xiaoq6285 on Discord (v0.1.2700): Codex on an official ChatGPT account
ran out of quota, and after switching to another account or provider in
magpie, the Codex app's Send button stayed grey. magpie has no chat
composer of its own; the button is the Codex app's, which greys Send for
every model while the app-server it runs is on a ChatGPT account the app
holds. magpie lifts that by restarting the app's app-server
(codexAppStep), but never while a Codex turn is open in its sessions, for
up to codexTurnWindow (30m). When quota runs out mid-turn the turn is
left open, so the restart, and the grey, waited.

cc81ad4ea let a quiet stuck turn be restarted past (codexTurnStuckAfter,
2m) only after SwitchWhenSpent's own switch. Two siblings that leave the
app-server on the same used-up account still waited the 30 minutes:
- a switch by hand (Accounts, CLI) off an account last read held:
  noteCodexSwitch now marks it spent when the account's reading in hand
  says Held (codexHeldKnown: cache only, no I/O; a failed read or none
  is not held);
- magpie becoming Codex's provider for the used-up account (codex.out):
  codexAppStep marks the change into out spent. The way back at the
  reset still waits for any open turn, as a real one may run there.
A turn still writing its session or sending through magpie in the last
2 minutes holds the restart as before.

Tests, both red on the old code:
- TestCodexAppServerRestartedPastATurnStuckWhenMagpieTakesOver
- TestCodexHandSwitchOffAHeldAccountIsSpent
docs/subsystems/agent-wiring.md says so.

Run at this head on mote:
- go test -tags nogui ./internal/provider: ok (151s), at this head
  after the rebase on 52195b6b0 (it changed provider_test.go and two
  more provider files, so provider was run again).
- Before the rebase (on 07f4d46c5): provider ok, agent ok, gui ok;
  gateway red on TestCodexPoolSaysTheClientsVersion alone (#4807, red in
  a full package run, passes alone; -count=5 alone ok at this change);
  cli red on TestEveryRouteHasACommandOrIsNamed (#4826), red the same
  on origin/main 52195b6b0 just fetched.
- gofmt -l clean; GOOS=linux go vet -tags nogui, GOOS=windows go vet
  and go vet of ./internal/provider ./internal/agent ok at this head.
- Not run: the full go test ./... (agent, gateway, gui, cli and provider
  are what reach this code). No GUI change, so no GUI suite.

Broken by hand, each red, then restored:
- spent not set on the takeover (c.spent && into): the takeover test
  failed "a turn stuck on the used-up account as magpie took over:
  ended [], want [60]".
- noteCodexSwitch never marking spent: the hand-switch test failed
  "switched off out@x: switched true, spent false, want true, true".

Not tried: the real Codex app with an account actually out of quota
(no such account to hand), and Windows/Linux runs of the package (the
change is OS-independent logic; GOOS vet run). Not confirmed with the
reporter that their case is a turn left open; their screenshot wasn't
seen here.
2026-11-02 18:31:11 +08:00
yetone 52195b6b07 backup: the setup is backed up into a folder by itself, and any version put back (jwaitq)
jwaitq (Discord) nearly lost their setup on Windows and got it back only
from a Downloads\data folder they happened to have. They asked for
backups made on a schedule into a folder, with a version to go back to.

What changed

- internal/backup/auto.go: Settings › Sync › "Back up by itself". On by
  default: once every 24 hours, the last 7 kept, into
  <config dir>/auto-backups. Interval (1 hour, 6 hours, 1 day, 1 week, or Off), keep (3,
  7, 14, 30) and the folder are the user's to change. autobackup.json holds
  only what the user set; a field they never touched follows the default,
  so a later default never overrides their own value. An unreadable
  autobackup.json makes no backup and says so, never "off" or a default.
- What goes in is the export without API keys (backup.Collect(false)),
  the same bundle and the same handling of secrets as the manual no-keys
  export, with the proxy URL blanked as well (it can carry a password).
  Not sealed, so it opens without a passphrase. Files are 0600 in a 0700
  folder, written to a temp file, fsynced and renamed, and listed only
  when they parse and their sha256 matches, so a half-written file is
  never a version. A temp file over an hour old is removed.
- A backup is made only when the setup changed since the newest one, so
  a quiet week keeps a week of versions, not seven copies of one day.
  The loop runs inside the gateway (WhileServing), first 2 minutes after
  launch, then every 10 minutes it checks whether one is due by the
  newest file's time, so a restart doesn't make an extra one.
- Restore puts a version back the way Import does (additive), after
  first writing the current setup as a "-restore" backup. If that
  backup can't be written, nothing is put back. The row says when the
  undo copy was made, and restoring it undoes the restore. "-restore"
  backups are pruned past Keep like the rest.
- internal/gui/backup.go: GET /api/autobackup and POST
  /api/autobackup/{set,choose,now,reveal,restore}. internal/cli
  settings_parity_test names the two routes in notYet (S2).
- GUI: autobackup.js, imported lazily when Sync is drawn, so app.js and
  the core budget are not raised. The app's own segmented controls and
  menus (no <select>), the folder row with Change…/Show/Default, Back up
  now, and the versions list with Restore behind a confirm. Strings in
  en, zh, zh-TW, ja, de (22 keys each).
- docs/subsystems/sync-backup.md: "Backups by themselves".
- Tests touched beside it: sync-sign-in's "last row" is now the last of
  Sync's own rows (the new rows come after Import); usage-computers
  scrolls its tick to the middle, since in WebKit the sticky Settings
  tabs covered it at the page's end; agent-prefs waits for Settings'
  first draw instead of reading the static index.html's rows.

Tests

- internal/backup/auto_test.go: TestAutoBackupOnSchedule (injected
  clock, no sleeps), TestAutoBackupAfterRestartWaits,
  TestAutoBackupOffOrUnreadable, TestAutoBackupPrunes,
  TestAutoBackupHoldsNoSecrets, TestAutoRestoreRoundTripAndUndo,
  TestAutoRestoreNeedsTheBackupFirst, TestAutoHalfWrittenNeverListed.
- internal/gui/backup_test.go: TestAutoBackupRoutes.
- internal/gui/tests/auto-backup.test.cjs: chromium and webkit, 1100px
  and 420px, en/zh/zh-TW/ja/de; plus "Sync redrawn while the backups are
  being read still shows them", which found a real bug (the rows were
  dropped when Sync redrew during the first read) and is red on the old
  code.

Broken by hand, each test red, then put back: dedup off (OnSchedule),
interval check off (OnSchedule, AfterRestartWaits), keep+1
(Prunes), proxy left in (HoldsNoSecrets), no backup before a restore
(RoundTripAndUndo), restore going on after a failed backup
(NeedsTheBackupFirst), unreadable config read as default
(OffOrUnreadable), checksum not checked (HalfWrittenNeverListed),
os.Rename without the temp step (HalfWrittenNeverListed). And the
redraw fix, reverted: the redraw GUI test red in both engines.

Run on mote (macOS 27) at this change on c9af34446; rebased then onto
019b308f1 (internal/provider only) and built and vetted again, then onto
70b96126e (app.js/app.css editor sizing): TestCoreScriptBudget and
TestAutoBackupRoutes ok on mote; auto-backup, old-webkit, i18n-keys,
sync-sign-in and editor-roomy 152/152 on WSL. The earlier runs:
gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
of backup, gui, cli ok; go build ./... ok; go test -timeout 45m
./internal/backup ./internal/davsync ok, ./internal/cli and
./internal/gui red only on known reds: TestEveryRouteHasACommandOrIsNamed
for POST /api/usage/checkin-account (#4826) and
TestMainWindowCorners/macOS_26_SDK (#3949).
GUI on Linux (WSL magpie-desktop, Playwright 1.62.0, chromium and
webkit) at 0dd8901a7, whose only difference from this head is Go files
outside this change: auto-backup, gui-de, gui-ja, gui-zh-tw, i18n-keys,
old-webkit, settings-general, settings-lines-wrap, settings-search,
settings-sections, settings-tabs-stick, sync-auto-restore,
sync-not-backup, sync-note-show, sync-other-kind, sync-own-fields,
sync-sign-in, sync-spin, sync-usage-error, webdav-settings-refresh,
github-sync, s3-sync, import-row, menu-scroll, agent-prefs,
usage-computers, account-eye: green. Red the same at origin/main
1aca55909 in the same run: segs-press-redraw searchAllRow (#4566),
balance-fix Sub2API (#4683), agent-panel-name-width (#4203), click-scroll
webkit wheel (#4385), codex-auto-reset webkit de (#4790),
codex-predictions webkit (#2624), codex-credits-first webkit (#4908,
filed now).

Not tried: the whole GUI suite (on WSL at concurrency 4 it ran past 5
hours beside other sessions' runs; I stopped my own run and ran the
files a Settings/Sync change can reach, plus the ones it had shown red);
a real Windows install (jwaitq's system) or the real app with a real
HOME; a restore of a real user's backup.

Asked for by jwaitq on Discord.
2026-11-02 18:24:38 +08:00
yetone 70b96126ef gui: a provider's editor grows with a large window (5046312 on Discord)
5046312 on Discord: in a large, wide window the provider editor (Codex's,
with its accounts, meters, cap pill, switches and many option rows) stayed
a 600px box in the middle, cramped, and asked for a better layout or a
resizable sheet.

drawEditor's editor now carries `roomy`, and openModal copies it onto
#modal's dialog as it already did `wide`. `.modal .dialog.roomy` is
min(max(600px, 56vw), 880px, 100%): 600 up to a 1071px window, then 56%
of it, at most 880, as a Mac sheet takes the room its content needs. Its
height already follows the content up to the window, so no new height
rule. A question that takes the editor's place in the same dialog (Sign
out's forget-ask, Disconnect, ...) drops the class and stays 600. No
drag handle. The rows themselves are unchanged. Every provider editor
(subscriptions, keys, new providers, presets) goes through drawEditor.
The core-script budget is not raised (7 bytes under).

Sizes (chromium, en; width x height of the dialog):
  window       before        after
  2560x1440    600 x 1228    880 x 1038.5
  1440x900     600 x 810     806.4 x 810
  1100x800     600           616
  1024x768     600           600
  560x420      512           512
  390 web      374           374

Run at the pushed tree (this commit on 019b308f1; the whole-suite runs below at earlier bases, editor-roomy, i18n-keys and the budget tests again at 019b308f1):
- editor-roomy.test.cjs (new), chromium and webkit, en zh zh-TW ja de, at
  2560, 1440, 1100, 1024, 800, 560 and 390 (magpie web): the width, the
  dialog in the window, head and buttons in sight, no sideways scroll,
  nothing past its sides; and at 2560 Sign out's question is 600 and the
  editor is 880 again after Cancel. 80/80 on mote and on WSL.
- go test -tags nogui ./internal/gui on mote (TestCoreScriptBudget): ok.
- The whole GUI suite on WSL magpie-desktop (Linux, both engines) at
  ed852df10 (the same change on 838d12d6f): 18363 tests, 17874 pass, 489
  red in 100 files. The 100 files again alone at head and at origin/main
  b2f7818d2: 472 and 452 red, the same tests save flakes that change
  language between runs. editor-advanced-align, gateway-key-models,
  codex-predictions and codex-credits-first, one at a time: identical
  reds on both. Named issues: #4471 (WSL whole-suite reds, the class),
  #4203 agent-panel-name-width, #4683 balance-fix, #4908
  codex-credits-first, #2624 codex-predictions, #4616 gateway-key-models,
  #4541 page-width-steady, #3699 allow-ips.

Broken by hand: the test on origin/main's assets fails 40 of 80 (every
size from 1100 up, "dialog is 880px wide...: 600"), the narrow ones pass;
with openModal's toggle made add-only, the Sign out case fails 10/10
("the question is 600px wide").

Not tried: the real Wails app on macOS, Windows and Linux (WebKitGTK);
the whole GUI suite on mote (another session's full suite held it);
other dialogs, left at 600 on purpose.
2026-11-02 18:21:14 +08:00
yetone 1829cd52ff sessions: a poll while a session grows makes only the rows it shows
VeryBTC on X (tweet 2117104179454091396) reported RSS that rises and
stays up while the window is open and a long-context session is active.
In that case every Sessions poll sees a changed file and rebuilds the
list. That rebuild copied every gateway-only session three times
(GatewaySessions, listedGateway, gatewayListed) and made each one a
Session row before EachMerged stopped at its 5000-row limit. It also
made every Claude Code file's path and key again.

- usage.EachGatewaySession walks the projection without copying it.
  gui's listedExternal stops at the list's limit and skips hidden
  sessions and sessions without an agent or id, as listedGateway did.
- sessions.EachMerged sorts indexes and makes a row only when the merge
  reaches it. The order is unchanged: newest first, stable on ties.
- listCCFiles reuses the last listing's path and key strings while a
  folder lists the same names. One file new or gone is stepped over.
  This holds ~32 B per file (~480 KB at 15k files), and the strings are
  shared with the listing it already held.
- page_memory.go's ~330 MB comment now has current numbers.
  gateway-sessions.md describes the lazy rows.

Per poll, on mote (go test probe through the real /api/sessions
handler, TotalAlloc):
  15k sessions x 10 turns, 400k ledger rows
    after a session file grows  150.6 MB, 201 ms -> 109.9 MB, 170 ms
    unchanged (warm)             17.2 MB         ->  12.0 MB
  3k sessions x 40 turns, 150k rows (no gateway-only rows past the cap)
    after a session file grows   31.3 MB         ->  29.6 MB
    unchanged (warm)              4.5 MB         ->   3.4 MB
  /api/usage is unchanged at 0.4 MB.

Tests:
- TestSessionsListMakesOnlyTheGatewayRowsItShows (gui) uses 3 natives,
  6000 gateway sessions in tied pairs, one hidden and one carrying a
  native's id. At limits 5, 40 and 6010, and with no limit, the rows
  equal the old pipeline's (listedGateway + gatewayListed +
  MergeExternal) after the JSON round trip. A grown native comes first
  with its new Last. The poll's allocation stays under 6000 rows' size.
- TestEachMergedMakesOnlyTheRowsItReaches (sessions): 15000 externals
  and 20 rows give MergeExternal's first 20, with allocation under a
  tenth of the rows.
- TestCCListingKeepsItsNames (sessions): a second listing of 3000 files
  is equal to the first, in at most 3n mallocs. A file added, files
  removed, and a folder gone with another new each list as a fresh
  listing does. Another agent's keys keep their own prefix.

Broken by hand, each red:
- EachMerged building every row first: 8.8 MB, the sessions test fails.
- The GUI handler back on the listedGateway(GatewaySessions) loop, with
  the lazy merge kept: 13.7 MB, the gui test fails.
- The gui test on origin/main's code: 23 MB, fails.
- The ccNames reuse turned off: 12197 mallocs, the listing test fails.

Run on mote (mote-run) at 73a1b8769, rebased on origin/main 07f4d46c5:
gofmt -l internal (empty), go vet ./..., GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./... all clean. go test -count=1 -timeout
45m ./internal/sessions ./internal/usage ./internal/gui: sessions ok,
usage ok. gui is ok except TestMainWindowCorners/macOS_26_SDK, which is
#3949 (red on mote's macOS 27, an AppKit title bar test this change
doesn't reach). It was red the same way in the run before the rebase.

Not tried:
- A real app window with RSS measured over time. The numbers are
  allocation per poll from a probe.
- The rest of a changed poll: statsKept re-sums every session (~26 MB at
  15k), listing (~24 MB) and byKey (~9 MB). None was a cheap, safe
  change.
- Windows and Linux test runs (vet only).
- A gateway title store in the fixture. GatewayTitler's ReadDirs now run
  only for the rows shown.
2026-11-02 17:19:23 +08:00
yetone 07f4d46c52 gateway: a Codex reply that ends early, and any failed call, is written to app.log
wjh66 (Discord, Windows, v0.1.2696) saw Codex on a ChatGPT sign-in with
gpt-6.1-sol show "reconnecting 5/5" and then `error decoding response
body`, and app.log around 15:27 held nothing about it. That text is
reqwest's for any read error in a body (a reset, a chunk cut short, a
timeout), so it says the connection broke mid-reply, not which side broke
it. The cause is not found; this change only makes the next report carry
evidence.

- record logs a failed call (status >= 400 or an error) when debug is off,
  once a minute per agent/provider/model/status/error, counting repeats.
- codexUpstream logs a reply that ended before its last event (or a
  non-SSE body cut by a read or write error): bytes passed on, whether
  OpenAI's stream failed or ended, and whether Codex went away, a write
  to it failed, or it was told response.failed.
- Shutdown with requests in flight says they are cut (Windows has no
  handover, so a quit or update cuts streams after shortDrain).

Run at this head (rebased on 4bd0d6f38; the new and stream-cut tests and vet run again after the rebase on mote and Windows, the full gateway run on Linux was at 4e764fc39):
- win-run: TestCodexReplyBrokenOffLogged, TestCodexClientGoneLogged,
  TestFailedCallLineOncePerMinute, TestCodexStreamCut* - ok.
- wsl-run: go test -tags nogui ./internal/gateway -timeout 45m - one red,
  TestCodexPoolSaysTheClientsVersion, which is #4807 (red on main too; the
  identity it sees is the machine's own Codex 0.165.0).
- mote-run: gofmt -l clean; go vet -tags nogui ./internal/gateway for
  darwin, GOOS=linux and GOOS=windows - ok.

Broken by hand: both new log.Print calls replaced with `_ = line`; the
two Codex tests went red ("no log line holds ...").

Not tried: a real Codex on Windows, a real cut from chatgpt.com, the
serveAgent (magpie's Codex accounts) path specifically, the full suite
on macOS or Windows.

Reported by wjh66.
2026-11-02 17:10:02 +08:00
yetone 02727188a4 gateway: a Zen free model asked on OpenCode Go is asked at Zen's free tier, else the refusal says where it is served (51bit.eth)
51bit.eth (Discord #general) ran Claude Code through magpie with
OpenCode's free models on a provider named OpenCode Go
(opencode.ai/zen/go). Every request failed "400 OpenCode Go: Upstream
request failed: Model is unavailable.", and a header of their own
(x-opencode-session) didn't help. The same models worked in OpenCode.

Cause: OpenCode's two gateways serve different free models. Zen's free
tier (/zen, the public key) serves the -free models and big-pickle; Go
(/zen/go, a Go key) serves only beam-free and iceman-contributor-free
(its /models on 2026-11-02). Go answers any model it doesn't serve 400
"Model is unavailable." before it reads the key. A user ends up with a
Zen free model under Go by typing it, or because a Go key /models
refuses makes the provider list models.dev's opencode-go catalog,
which names free models Go doesn't serve (#4900, not changed here).

What changed:
- provider.RetryOpenCodeFreeOnZen, called in forwardOnce for OpenCode
  URLs beside RetryZhipuCoding: a 400 "Model is unavailable" from Go
  for a model OpenCodeFree calls free is asked once more at Zen's free
  tier on the same API (openCodeGoToZenFree: /zen/go/v1/... and
  /inference/go/... to OpenCodeFreeURL's /inference/openai|anthropic),
  with the public key in Authorization (and x-api-key on Anthropic),
  never the user's Go key. Zen's 2xx is returned as is.
- Refused at Zen too, Go's 400 keeps its words and adds what Zen said
  and where the model is served: under the OpenCode Zen provider,
  which needs no key. A model that isn't free isn't asked at Zen; its
  400 says to pick one the OpenCode Go provider lists.
- docs/subsystems/providers-accounts.md: a row beside the GLM Coding
  Plan one.

Run (mote, through mote-run):
- go test ./internal/provider -run 'OpenCode|Zen' and
  ./internal/gateway -run 'OpenCodeGo|ZenFree': ok, at the pushed head
  after the rebase too.
- gofmt -l: clean. GOOS=linux and GOOS=windows go vet ./internal/provider
  ./internal/gateway: ok.
- go test ./internal/provider -count=1 -timeout 45m: ok (113.9s).
  go test ./internal/gateway -count=1 -timeout 45m: one red,
  TestCodexPoolSaysTheClientsVersion, which is #4807 (open, red in full
  runs on mote; this change touches no Codex path). Output added there.
- Real: a built magpie serve on mote, sandbox HOME, port 3591, an
  opencode-go provider with a made-up key, Claude Code-shaped
  /v1/messages:
  - deepseek-v4.1-flash-free (Zen's): Go 400, then asked at
    /inference/openai/v1/chat/completions with the public key; Zen
    answered 429 FreeUsageLimitError (#3491), and the message names
    both and the OpenCode Zen provider.
  - cat-jam-free (in the catalog, served by neither): Go 400, Zen 400,
    message says where.
  - glm-5.3 (Go's, paid): "Invalid credential" as before, Zen not asked.

Broken by hand:
- Retry call removed from forwardOnce: TestOpenCodeGoFreeModelAskedAtZen
  and TestOpenCodeGoUnavailableSaysWhere red (old message, one request).
- Key swap removed: TestOpenCodeGoFreeModelAskedAtZen red, Zen asked
  with "Bearer sk-go-users-own".

Not tried:
- A working Go key (the owner's is expired), so beam-free on Go
  end to end is only the fake.
- A Zen free reply end to end: from mote Zen's free tier answers 429
  FreeUsageLimitError to magpie with the built-in OpenCode Zen
  provider too (#3491).
- Gemini protocol: not asked at Zen (OpenCode has no Gemini free URL).
2026-11-02 17:08:45 +08:00
yetone 4bd0d6f389 gateway: a provider whose model asks for a tool turn's thinking back, under a name that doesn't say DeepSeek, is asked again with it and sent it from then on (qisishiqi)
qisishiqi (Discord #help): a routing group fell from a rate-limited Codex
subscription to "My Claude", an Anthropic-format endpoint, and the request
failed 400 "My Claude: The `content[].thinking` in the thinking mode must
be passed back to the API."

That is DeepSeek's model refusing a tool loop continued without the
thinking of its tool turn. magpie fills those turns (a space, or the
turn's readable reasoning) only when the host or the model names
DeepSeek (anthropicReplaysThinking, chatReplaysReasoning, #1462/#1611).
A relay serving DeepSeek under another name, or a model the user named
otherwise, got nothing, and Codex's sealed reasoning has no text to give.

Now forward reads a 400 on Messages or Chat whose words are DeepSeek's
(thinkingBackRefusal: `content[].thinking` / `reasoning_content` ... in
the thinking mode must be passed back), and when filling the tool turns
(withThinkingOnToolTurns / withReasoningOnToolTurns) changes the body,
remembers the provider's model (unfit, thinkingBackNeeded) and asks once
more; forwardOnce fills them for it from then on, every route alike. A
provider that never asked is sent the conversation as before. Scoped to
the vendor's refusal, not to every Anthropic endpoint.

Checked against api.deepseek.com with the owner's key, 2026-11-02
(deepseek-flash, Messages and Chat): a tool turn of the loop being
continued with no thinking is refused with exactly these words (the
test fixtures are those bytes); a space thinking block or
reasoning_content " " is taken; readable unsigned thinking is taken;
finished tool turns and plain replies without thinking are taken, with
or without tools; thinking disabled takes it all. So DeepSeek's docs'
"even for turns without a tool call" is not enforced today, and the
existing tool-turn rule stands.

Sibling: the Chat side had the same name-only gate, and gets the same
learned fill (TestReasoningBackLearnedBehindAnotherName). Responses
(reasoning_text) is filled by model name on any host already.

Run at this head on mote:
- go test ./internal/gateway -count=1 -timeout 45m: every test ok but
  TestCodexPoolSaysTheClientsVersion, #4807 (red in a full run, passes
  alone; passed 5 of 5 alone here). Not touched by this change.
- GOOS=linux and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
- New: TestThinkingBackRefusalRead (the live bytes and qisishiqi's
  literal error read; Responses' reasoning_text and a bound-signature
  refusal not), TestThinkingBackLearnedBehindAnotherName (Codex request
  mid loop, group: 429 on the Responses member, then "My Claude" with
  claude-sonnet-4-6 and relay-model: 200 on the second ask with a space
  thinking block first, next turn 200 on the first ask, another provider
  sent no thinking), TestReasoningBackLearnedBehindAnotherName.

Broken by hand: with the retry in forward off, all three cases go red
with qisishiqi's error ("400 after 1 calls ... My Claude: The
`content[].thinking` ..."); with the learned fill in forwardOnce off,
the second turn is refused again ("400 after 2 calls").

Not tried: qisishiqi's own provider (its host and model are unknown); a
real relay in front of DeepSeek; a plugin provider's fetch path.
2026-11-02 17:03:34 +08:00
yetone f9595e7684 gateway: System One requests are kept in the request archive, and Routing says when the archive is on (wangb on Discord)
wangb on Discord: 「请求存档开启, 但是 systemone 的请求没有记录下来」. The
Routing page then said "magpie 只保留最近 40 个请求的请求体和响应体… 要保留
每个请求的,请在「用量 › 请求」顶部打开「请求存档」", as if the archive
were off.

Why: only serve() made an archive wire (archiving). The two System One
paths never reached it:
- /v1/systemone, which an app sends (serveDecideTries, also used for a
  decision group), opened a Route but recorded no Call. It was in
  neither Recent calls nor the archive, so the Routing page could never
  open its bodies.
- the question a routing group's Jev classifier asks for a turn
  (askJev / jevLevelled -> systemOne -> postDecide) only appended a
  usage row.

What changed:
- serveDecideTries captures its reply, makes the wire as serve does,
  names it on the Route from the start (Route.Archive), and records a
  Call (Route, status, error, fallbacks, usage, bodies) when it ends.
  So the call is in Recent calls and, with the archive on, in the
  archive. Its usage row carries Archive.
- systemOne keeps the call magpie made itself through a new
  archiveOwn. It keeps the request as it went (method, path, the headers
  magpie signed it with, the body in the provider's shape) and the
  answer, with secrets scrubbed as for any call. Its "routing" usage
  row names the archive entry. postDecide became postDecideSent, which
  also returns the request it sent. archive's queueing moved into
  queueArchive, which both share. archiveID makes the name.
- Routing's "Request and response" for a request in neither the ring
  nor the archive: with the archive on (gateway.archive.on in
  /api/providers) it says the archive is on and this request isn't in
  it (made while it was off, or not saved). It no longer says to turn
  the archive on. New string in zh, zh-TW, ja and de.
- docs/subsystems/gui-shell.md says which calls are archived and which
  still aren't.

Still not archived (unchanged): Codex's own backend (codexUpstreamOn),
draw, embeddings and video side routes, and replies magpie writes
itself (answeredHere). Masking makes no outgoing call. Chat classifiers
and Codex titles to a model already go through serve and are archived.

Run on mote at base 4b407bb79, then rebased onto 0285f572f, whose one
commit changes only internal/gui/whatsnew*.go (nothing here reads it):
- TestArchiveKeepsSystemOne and TestArchiveKeepsJevClassifier (new)
  pass. Broken by hand: with archiving(...) taken out of
  serveDecideTries, the first is red ("uploaded []"). With archiveOwn
  returning at once, the second is red (only the chat turn uploaded).
- routing-bodies.test.cjs, chromium and webkit, every language, 440px:
  the new "archive on" case passes, and the archive-off case asserts
  the old text. Against the old client.js the new case is red in all 5
  languages (chromium). i18n-keys passes.
- gofmt -l clean. go vet ./... (darwin) and GOOS=windows go vet
  ./internal/gateway ./internal/gui are clean. GOOS=linux go vet
  -tags nogui is also clean for both (without nogui, wails' linux cgo
  doesn't build in a cross vet).
- go test ./internal/gateway: ok except TestCodexPoolSaysTheClientsVersion
  (#4807: red in a whole package run on mote, passes alone).
- go test ./internal/gui (an earlier base, 834c6c7df): ok except
  TestMainWindowCorners (#3949, macOS 27).
- The other routing-* GUI files (an earlier base, 834c6c7df): the whole
  set was cut short when mote rebooted. Six files went red:
  routing-many-keys, order-unknown, row-swap, rule-drag, rule-remove
  and rules-line. Run alone they are red the same way at base
  834c6c7df without this change (filed: #4082, #4627, #3799, #3789,
  #3096, #4585).

Not tried: a real Jev or System One account. The tests use fake
System One servers. Not tried either: an S3 bucket (memBucket), the
local disk archive, or the GUI's whole suite.
2026-11-02 16:21:58 +08:00
yetone a8d6a861a4 agent: Pi's codemode gets magpie's decision and image models (extensions/magpie.ts)
wangbinyq on Discord (#feedback) asked for magpie's System One and image
models in Pi's config, since Pi's codemode can call classifier and image
models (models.classify, models.generateImages; Pi docs/models.md "Use
classifier models").

Pi's models.json can't hold them: its model entries have no type, so
every one is a chat model (ModelDefinitionSchema, modelFromJson in
provider-composer.ts, Pi 1.4.0 / c9f4c7b9f). A custom provider's
classifier and image models come from an extension alone
(docs/custom-provider.md, "Register mixed-operation models"). So while
models.json has providers.magpie, magpie now writes
extensions/magpie.ts in Pi's agent folder, which Pi loads by itself:

- provider magpie-systemone: provider.OfferedDeciders, labelled as
  /v1/models labels them, on Pi's own typesafe-system-one client
  (builtinProviders' typesafe .classify), which posts the TypeSafe
  System One body to the gateway's /v1/systemone. Text input only.
- provider magpie-images: gateway.ImageModels (new; mediaModels with
  labels, the Settings > Images default first, none while it is off),
  drawn by POST /v1/images/generations with the input's images as data
  URLs, b64_json back as image blocks.

Separate ids because an extension's models replace those models.json
gives the same provider id: registered as "magpie", Pi 1.4.0 listed no
chat models at all ("No models available").

The file is rewritten at each Sync and on a pick, and removed with
providers.magpie (pick of none, Disconnect, a Sync that finds it gone).
A magpie.ts whose first line isn't magpie's mark is the user's and is
never written over or removed. Pi only, not OmO or Prime Agent. On a Pi
older than its classifier models the extension returns without
registering anything. Codemode itself is not turned on: that is the
user's defaultTools.

Run at the pushed head (on mote):
- At e7185daeb plus this change: go build ./..., go vet (darwin, GOOS=linux,
  GOOS=windows) of agent and gateway, gofmt -l clean; go test -timeout 45m
  of agent, backup, cli, davsync, gateway, gui, library, profile, stats,
  tui, uninstall. All ok but three reds that are the same on origin/main
  1747559d0 and filed: cli TestEveryRouteHasACommandOrIsNamed (#4826), gui
  TestMainWindowCorners/macOS_26_SDK (#3949), gateway
  TestCodexPoolSaysTheClientsVersion (full-run only, passes alone, #4807).
- Rebased on 1aca55909: go build ./..., go vet linux/windows of agent and
  gateway, go test ./internal/agent/ ok (181s), gateway -run
  'Image|Media|Draw|Decide|SystemOne' ok.

Real Pi in a sandbox HOME on mote (npm @earendil-works/pi-coding-agent),
against a fake gateway, with the extension magpie generated
(piExtensionFor from the test fixture):
- 1.4.0: `pi -p --tools +codemode`, the script listed
  magpie-systemone/mixed/typesafe/jev and magpie-images/art/gpt-image-2
  (in=text,image); classify answered {approved: bool 0.93}; a drawing
  with an image input came back as image/png. The fake logged
  /v1/systemone {model: mixed/typesafe/jev, noul question} and
  /v1/images/generations {model: art/gpt-image-2, images: [data URL]},
  both with Bearer magpie; the chat model from models.json still ran.
- 0.87.1 and 1.0.0: start and chat with the file in place, no error.

Broken by hand: the user's-own check removed -> LeavesTheUsersOwn red
(file written over, then removed); the Pi-only gate removed ->
PiOnly red; the extension write made a no-op -> ListsDecisionAndImage
Models and FollowsSync red.

Not tried: a real magpie gateway with real decision or image vendors
behind it (the fake answers in TypeSafe's wire shape, as magpie's
/v1/systemone does); classifier image input (left off); a WSL Pi. A
change of decision or image models reaches the file at the agent's next
Sync (a catalog change) or pick; whether a Settings > Images change
alone starts a Sync was not checked.
2026-11-02 15:43:43 +08:00
yetone 1aca55909f gateway keys: a key given a model is not given a routing group of it the user never handed out (kautism)
kautism on Discord: a gateway key held to gemini 3.8 alone was shown,
and could use, a routing group the user made of gemini 3.8 alone, though
the user never gave the key that group. groupAllowed let a key use any
group whose every member it may use (the #882 rule), so the group leaked
into /v1/models and every route that asks it.

- key_models.go groupAllowed, the one check every route asks (the model
  lists' entryAllowed, serve on every API, countHeld, embeddings, images,
  videos, decision groups, a subagent's and masking's route): a group of
  the user's own is a key's only when the key names it (group/<id> or
  group/*). A group magpie found (auto/<model>, one model several
  providers serve; foundGroup) still passes when the key may use every
  member, as it is that model. A key that names accounts and no model
  (Linka, access.HeldModels gives it "<provider>/*") still may use a
  group of those providers' models alone, as it may every such model:
  access.Identity.AccountModels says so, for an issued key too.
- keyGroupFor: a bare name that is both a group of the user's the key may
  not use and a model it may use is that model for the key (a group the
  user called "Gemini 3.8", id gemini-3-8, would otherwise have turned
  the key's bare gemini-3.8 into a 403). serve's grouped and countHeld
  use it.
- Decision models (v0.1.2681) unchanged: a group the key names still
  asks its own Jev; TestGatewayKeyHeldToAGroupKeepsItsDecider passes.
- A group named inside one the key doesn't name no longer makes the outer
  one the key's (TestGatewayKeyModelsNameAGroup updated); the key names
  the outer group to use it.
- docs/reference.md and gateway-routing.md say so.

TestGatewayKeyGivenAModelIsNotGivenItsGroup is the reporter's case: a key
given google/gemini-3.8 alone, a group "Only 3.8" and one "Gemini 3.8" of
that model alone. Neither is listed in /v1/models nor found at
/v1/models/{id}; each is refused on chat completions, messages and
count_tokens, by id and by name; the model is served by id and bare;
a found group of two providers' gemini-3.8 is still listed and served to
a key given both; a key naming group/only-38 is given it.
TestGatewayKeyModelsHoldAKey, TestKeyListSeesChangesNextRequest updated
from the old rule.

Broken by hand: groupAllowed back to the old rule: the new test,
TestGatewayKeyModelsHoldAKey and TestGatewayKeyModelsNameAGroup red. The
bare-name fallback off: the new test red (chat gemini-3.8 403). The
accounts-only exception off: TestGatewayKeyAccountsOnlyHoldTheModels red.

Run on mote at this commit (rebased on origin/main 1747559d0): go build
./... ok; go vet of internal/gateway and internal/access for darwin,
linux and windows ok; gofmt -l clean; go test ./internal/access ok;
go test -run 'Key|Count|Group|Model|Identity|Issue' ./internal/gateway
ok; go test -run 'CallerKey|Key' ./internal/gui ok. Before the rebase
(at e7185daeb) the whole internal/gateway package and internal/cli ran:
red only in TestCodexPoolSaysTheClientsVersion (#4807, red in a full
package run on mote, passes alone) and TestEveryRouteHasACommandOrIsNamed
(#4826, red on main since e87140242), neither touched here.

Not tried: a real magpie with the reporter's own key and group; an issued
key under an accounts-only issuer (set in identityOf, no test of its own).
2026-11-02 15:34:08 +08:00
yetone 1747559d02 plugin pages: name the scheme in a browser's policy, and the service's 'self' (#4198)
In `magpie web`, iOS Safari (18.7) loaded none of a plugin page's
scripts: pagePolicy named the page's folder as a scheme-less host-source
(host/_magpie/plugin/<tok>/), a sandboxed frame's origin is opaque, and
that WebKit took the missing scheme from it, so the bridge never said
hello and the page was broken at 10s (orinsid; YangHonghang on v0.1.2681,
young02036 on Discord).

- pagePolicy: a browser's policy now names the folder under both
  https:// and http:// (ownSources). Behind nginx or Cloudflare TLS ends
  before magpie and nothing magpie trusts says which scheme the page came
  over, so X-Forwarded-Proto is not read; both name the same host, port
  and folder, and an https page can't load http:// files anyway. The
  desktop window keeps its own transport alone (wails://, http:// on
  Windows, #2501).
- The second layer (YangHonghang): a page's local service sends its own
  policy, `connect-src 'self'`, and what it sends runs under magpie's
  `sandbox allow-scripts`. In WebKit, 'self' there didn't match the
  service page's own fetch of api/x. servePageService now names the
  service's root (/_magpie/plugin/<tok>/_magpie/service/) under both
  schemes after each 'self' in a CSP header the service sends, plus ws://
  and wss:// in connect-src and default-src (serviceSelf). 'self' stays,
  so nothing allowed before is taken away. A <meta> policy isn't
  rewritten; the plugin docs (en, zh, ja) say to write whole sources.

Run at f0a723d4c's tree (rebased on c74b932c8), on mote:
- go test ./internal/gui/: every test ok but TestMainWindowCorners, red
  the same at an origin/main e7185daeb copy (#3949, macOS 27). The real
  WKWebView test TestPluginPageLoadsItsFilesInTheWindow (desktop
  wails:// path) passes.
- gofmt -l, go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet:
  clean.
- node --test plugin-page, plugin-panels, plugin-page-idle (chromium and
  webkit): 14/14.
- win-run: TestPluginPage*, TestServiceSelf, TestPluginPanel* ok on
  Windows 11 (the window's http:// scheme).
- A scratch test (not committed) served the real pluginPageRoutes(web)
  and a fake service with "default-src 'self'; connect-src 'self'" over
  http and https (httptest TLS), framed sandbox=allow-scripts, in
  Playwright Chromium 151 and WebKit 26.5. At origin/main WebKit refused
  the service's fetch ("Refused to connect to .../_magpie/service/api/x
  because it does not appear in the connect-src directive", the
  reporter's words); with this change it fetched, and Chromium did both
  times. The page's bridge said hello in both engines both times.

Broken by hand: ownSources back to the scheme-less source and
serviceSelf skipped: TestPluginPageWebPolicyNamesItsScheme,
TestPluginPageServedShutIn, TestPluginPanelsServedShutIn,
TestPluginPageWindowPolicy and TestPluginPageServiceProxied go red.

Not tried: a real iPhone. Playwright's WebKit is not iOS Safari, and it
loads the scheme-less source fine, so the first layer is fixed on the
reporters' evidence and the CSP rule, not seen fail and pass here. Not
tried behind a real nginx or Cloudflare, nor a service WebSocket.
2026-11-02 15:27:15 +08:00
yetone b4a9cd8db5 codex: a tool name the ChatGPT backend refuses goes as one it takes, and comes back as the agent's
wing3556 on Discord (11-02): a compaction through a Codex account failed
400 "Codex: Invalid response.create payload: Invalid 'input[83].name':
string does not match pattern. Expected a string that matches the
pattern '^[a-zA-Z0-9_.-]+\z'." The ChatGPT backend checks every tool
name in a request, a call's in input as well as a tool's in tools, and
refuses the whole request when one fails. A conversation can hold a call
by such a name: a model another provider served wrote one with a space,
a colon or non-ASCII in it, and the agent kept it beside its "no such
tool" answer. Every request that replayed it, the compaction above all,
then failed on Codex. Nothing on the way checked: buildResponses copies a
call's name as it is, and redaction keeps names as written.

What changed:
- provider.CodexToolName: a valid name stays as it is. Otherwise each
  refused byte becomes "_", the result is cut to 55 and gets "_" plus 8
  hex of its sha256, so it is the same on every request and two names
  never meet. CodexToolNames applies it to tools (namespace children
  too), function_call/custom_tool_call items, additional_tools and
  tool_search_output items, and tool_choice. A body with no bad name goes
  byte for byte.
- It runs where every request to the ChatGPT backend passes: codexBody
  (an account's, translated or relayed) and codexUpstreamOn (Codex's
  own sign-in, /responses and /responses/compact), beside DeclareSearch.
- A tool the agent declared under such a name is called back by its own
  name: translated replies through decoderFor (now given the request's
  tools; codexNamesBack), relayed Responses replies through nsTidy's new
  back map (codexRenamedIn).
- docs/subsystems/gateway-routing.md says so beside #1270's paragraph.

Not covered: namespaces, the OpenAI API (whose pattern has no "." and a
64 limit), Azure and Copilot Responses, filed as #4875.

Run on mote at this head:
- TestCodexToolNamesTheBackendTakes and TestCodexToolNamesKeepValid
  pass. The fake backend refuses a bad name with the reporter's 400 word
  for word; the test covers Claude Code's compaction on /v1/messages with
  four bad history names (sent twice, byte-equal), Chat with a declared
  "search:web" called back by that name, Responses relayed the same, and
  Codex's own /backend-api/codex/responses.
- go test ./internal/provider ./internal/gateway (-timeout 45m): provider ok;
  gateway ok but TestCodexPoolSaysTheClientsVersion, the red already
  filed as #4807 (full package run only, another test's Codex identity
  reaches it); it passes alone at this head.
- go vet ./... (darwin) and GOOS=linux/windows CGO_ENABLED=0 go vet
  -tags nogui ./...: ok. gofmt -l: clean.

Broken by hand:
- codexBody hook off: compaction red with the reporter's 400.
- codexUpstreamOn hook off, decoder restore off, passthrough restore off
  (together): the codex, chat and responses cases each red.

Not tried: wing3556's real conversation (we don't have its bytes, and
the agent is unknown; Claude Code is likely). No real ChatGPT account
was asked with a bad name, so whether the real backend also limits
length is unknown.
2026-11-02 15:15:21 +08:00
yetone e7185daebe claude: a failed interactive read says why in app.log, and names the trust question (#4830)
mydosu (#4830) found nothing in app.log to say why every /usage read and
test of a saved account failed, and the card's reason, "showed no
prompt", said nothing of the trust question Claude Code was waiting on.

- claudetui: when the helper's deadline comes while Claude Code shows
  "trust this folder", the reason is "Claude Code asked whether to trust
  <folder>, not answered in the 16.8s its caller waits for it: <screen>".
  Any other screen keeps "showed no prompt".
- gateway: askClaudeTUI and claudeUsageTUI log a failure to app.log
  (logOneOff): "claude: a /usage read of saved account <dir> failed: ...",
  with the helper's whole reason on one line, which the card clips to 300
  bytes. The home folder and any /Users/<name>, /home/<name> or
  C:\Users\<name> become ~, secrets go through redact.Scrub, and past
  800 bytes the line keeps the first 300 and the last 500, so the end of
  the last screen stays.
- docs/subsystems/claude-subscription-bridge.md says both.

Run at this head (mote, rebased on origin/main; the gateway set re-run
with Upstream|Unsent|Routing added after the rebase): gofmt -l clean; go vet for claudetui and
gateway, and GOOS=linux and GOOS=windows go vet for claudetui, gateway
and provider: ok. go test -count=1 -timeout 45m ./internal/claudetui
./internal/provider: ok. ./internal/gateway -run
'Claude|TUI|Usage|Warm|Ask|Trust|Subscription|Bridge|OneOff': ok.
Windows (win-run): ./internal/claudetui ran with the new trust_unanswered
case passing through ConPTY; TestShimFirstMessageWaitsForTools and
TestShimReadsUsage are red there, the same at origin/main f849ccced
(#4810, #4820). TestClaudeOneOffFailureLogged skips on Windows (a shell
script helper).

Broken by hand, each red: no logOneOff call (app.log says nothing); no
home and path masking (the line has the home folder and "mydosu"); no
redact.Scrub (the token's body is in the line); no head/tail cut (1530
bytes); no trust wording in ready() (trust_unanswered says "showed no
prompt").

Not tried: a real failing read on mydosu's Windows machine; the full
internal/gateway package (another session's full suite was queued on
mote). Not changed: oneOffErr's clip() can cut a rune in two for the
card's 300 bytes; logOneOff cuts on rune starts (#4878).
2026-11-02 15:06:47 +08:00
yetone aab48dea94 claude: a saved account's .claude.json says magpie's work folder is trusted (#4830)
mydosu (#4830, Windows, v0.1.2679, Claude Code 2.1.316): since
d39358f1b the /usage reads and the "hi" test of a saved account run in
<tmp>/magpie-claude-work, and the account's config directory never got
a trusted entry for it. Every read waited out its 16.8s on the trust
question.

magpie now writes the entry itself, before each run there, into a saved
account's .claude.json (provider.ClaudeTrustFolder, gateway trustWork).
This covers every place Claude Code runs in that folder with a
non-default config dir: askClaudeTUI, claudeUsageTUI, and the bridge's
startRun when the caller's folder isn't used. The key is the one Claude
Code 2.1.316 looks a folder up by (its trust check, read from the
binary): the path in NFC, with forward slashes on Windows
("C:/Users/<me>/AppData/Local/Temp/magpie-claude-work"), and also with
its links resolved (/private/var/... on a Mac). For a Claude Code in WSL
it is the mount path. Only a direct child of claude-accounts is written,
never ~/.claude.json or the account Claude Code is signed in to. Other
keys and the project's own fields are kept, numbers go back as written
(UseNumber), a file that can't be parsed is left alone, and nothing is
written once the entry is there. A run's own fallback temp folder isn't
recorded. The helper's yes answer stays as it was.

I could not reproduce the missing entry itself. On xiaomi-gpu, Claude
Code 2.1.316 with a fake sign-in and the helper's yes recorded the key.
This fix does not depend on why it wasn't recorded on mydosu's machine.

Run at this head:
- mote: gofmt -l internal (empty); GOOS=linux and GOOS=windows go vet
  ./internal/gateway ./internal/provider; go test ./internal/provider
  ./internal/claudetui ok; go test -run
  'Claude|TUI|Usage|Warm|Ask|Trust|Subscription|Bridge'
  ./internal/gateway ok. The full gateway package was not run: two
  other sessions' full gateway suites were running on mote.
- xiaomi-gpu (win-run): go test -run
  'TestClaudeTrust|TestClaudeOneOffTrusts|TestClaudeBridgeTrusts'
  ./internal/provider ./internal/gateway ok (the shell-script ones
  skip there).
- xiaomi-gpu, real Claude Code 2.1.316 in a sandbox HOME/TEMP, helper
  told not to answer the question (MAGPIE_CLAUDE_TUI_TRUST=0). A saved
  account dir under a sandbox claude-accounts, with the entry written by
  trustWork (key "C:/Users/yeton/trust4830-sb/tmp/magpie-claude-work"):
  /usage drew its panel in 5.6s, exit 0. The same dir without the entry:
  "Claude Code asks whether to trust the folder" in 0.9s.

Broken by hand, each red:
- trustWork returning at once: TestClaudeOneOffTrustsMagpiesFolder,
  TestClaudeTrustWorkOnlyMagpiesFolderInSavedAccounts,
  TestClaudeBridgeTrustsMagpiesFolderForSavedAccount.
- the bridge's call dropped: TestClaudeBridgeTrustsMagpiesFolderForSavedAccount.
- no "/" for "\" on Windows: TestClaudeTrustKeysAsClaudeCodeKeys on
  mote, plus TestClaudeTrustWorkOnlyMagpiesFolderInSavedAccounts on
  Windows.
- no claude-accounts guard: TestClaudeTrustFolderOnlyMagpiesAccounts.

Not tried: a real signed-in saved account (the reporter's), and Claude
Code in WSL (the key is the mount path, by unit test only).
2026-11-02 14:51:16 +08:00
yetone 4dfdd0cd63 provider: a provider switched off is asked for nothing, its plugin's model list included
ChangQiu on Discord switched a provider off long ago, and magpie still
reached it. Routing, fallback, usage and balance reads, warmups,
check-ins and keepalive were already held back (On(), leftAlone,
KeepListsFresh). These were not:

- The plugin host's providers listing ran every plugin's models hook,
  which asks the vendor, and its sign-in renewal (fresh), for every
  plugin provider, on or off. Go now passes the ids switched off
  (plugin.ListingOff, provider.pluginsOff: the provider's id and the
  plugin's own id, read from providers.json alone). host.js lists such
  an id without running a hook (info(..., quiet)), so its row stays and
  keepListed keeps the last list.
- Sync (POST /api/sync, `magpie sync`) fetched every ready provider's
  list. Both now go through provider.RefreshLists, which skips one
  switched off.
- Saving or switching on in the GUI fetched the list even for one left
  off; PrefillNewKeys asked one switched off too.

What still asks one switched off, by the user's own click: the TUI's
refetch, the provider Test button and `magpie provider models <id>`
refetch.

Tests: TestOffPluginProviderAskedNoModels (the fake plugin's models
endpoint counts its hits: 0 while off, the list kept, asked again once
switched on), TestPrefillAsksNoProviderSwitchedOff,
TestPluginsOffNamesThePluginsOwnIDs and
TestRefreshListsAsksNoProviderSwitchedOff.

Run on mote at this head (first at a4916aec1):
- go test -timeout 45m ./internal/provider ./internal/plugin
  ./internal/gui ./internal/cli ./internal/tui ./internal/gateway:
  provider, plugin and tui ok. Three reds, each also red on origin/main
  and filed: gui TestMainWindowCorners/macOS_26_SDK (#3949), cli
  TestEveryRouteHasACommandOrIsNamed (#4826), gateway
  TestCodexPoolSaysTheClientsVersion (#4807).
- After rebasing on ce2e81da1: provider and plugin again, plus darwin
  vet of the four packages. One provider run went red on
  TestClaudeAccountServesModelsListedSinceItsFetch (#3174, full-run
  only). It is green alone 3/3 on this head and on origin/main, and the
  next full provider run was ok on both.
- GOOS=windows go vet of plugin, provider, cli and gui: clean.
  gofmt -l: clean. Linux go vet (WSL magpie-desktop) of plugin and
  provider: clean. cli and gui can't be vetted there: the distro has no
  gtk4/webkitgtk-6.0 headers for wails' cgo.
Broken by hand: with each guard taken out, its test went red ("switched
off, the vendor was asked 2 times", "the vendor asked 2 times",
"pluginsOff = [fakeco onco openai openai-plugin]", "the provider
switched off was asked 1 times").
Not tried: a real plugin provider switched off in the app. Which
provider ChangQiu had switched off isn't known, so his exact case is
not reproduced.
2026-11-02 14:30:45 +08:00
yetone ce2e81da11 routing: a group's member its provider counts free says free on its card and in its editor (jiabubu)
jiabubu on Discord: v0.1.2274's Free for me and a group's Free first,
but a routing group never showed which of its members are free.

groupsState's memberInfo now carries free (provider.FreeModel: the
provider is Free for me, or its vendor serves the model free). The
Routing page says a muted "free" for such a member, whatever the
group's routing, so it shows before Free first is picked (and Cheapest
first reads the same word): on the group's card line, beside the
provider in the group editor (a small like "by pattern", with a hover
saying what Free first and Cheapest first do with it), and in a manual
group's pick row and menu. A paid member says nothing. Routing plugin
files only; the core's scripts are unchanged. No new colours.

Run at 67dedea38 (rebased on origin/main a4916aec1), on mote:
- group-member-free.test.cjs: 20/20 (Chromium, WebKit; 1100, 420px;
  en, zh, zh-TW, ja, de); i18n-keys 4/4
- go test ./internal/gui -run TestGroupMemberSaysFree|
  TestGroupModelsCarryWhatTheyTake|TestCoreScriptBudget: ok
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/gui: ok; gofmt clean
- earlier at fb23a3279 (pre-rebase): go test ./internal/gui all but
  TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote);
  the whole GUI suite (make test-ui) still running at push, reds named
  so far are filed: balance-fix (#4683), agent-panel-name-width (#4600),
  codex-auto-reset (#4790, #2360); none in a Routing or group file.

Broken by hand: freeIn always false and the editor tag off: the card
and editor assertions go red; the editor tag alone: "the free member
has no free tag"; memberJSON.Free always false: TestGroupMemberSaysFree
red.

Not tried: a real ModelScope provider in the real app; the whole GUI
suite to its end at the pushed head.
2026-11-02 14:13:52 +08:00