Commit Graph
7339 Commits
Author SHA1 Message Date
yetone 47128ffa59 gateway: a remote client's effort reaches Claude Code from every route (amhcwushuang on X)
amhcwushuang on X runs Claude Code -> new-api -> magpie on a server ->
the Claude subscription, and says the thinking level is lost.

Read from new-api (QuantumNous/new-api main): a Claude channel keeps
thinking and output_config as written (relayconvert shared/claude
ApplyReasoning passes a native request through), including the
{role: system} turn's output_config; an OpenAI channel turns the request
into Chat with reasoning_effort (reasoning.ApplyToOpenAIChat), and an
OpenRouter-dialect channel into a `reasoning` object. Claude Code's own
fixture (claude-code-2.1.296.json) carries top-level output_config.effort,
thinking adaptive, and the same effort on a system turn.

magpie already passed, to the spawned Claude Code's --effort: Messages with
a thinking budget or a top-level output_config, Chat reasoning_effort,
Responses reasoning.effort (checked by the new test on the old code).
It did not take the level from:
- a Messages request whose only effort is the last turn's output_config;
- a Chat request with reasoning.effort (an object), output_config.effort
  or a thinking budget in place of reasoning_effort.
Those now set the request's effort. reasoning_effort, when present, stays
the client's word; no setting of the user is read or overridden.

Run: TestClaudeBridgeTakesTheEffortOfEveryRoute red on the old chat.go and
decide.go (4 of 9 cases), green now; gofmt; go vet darwin, linux nogui,
windows on internal/gateway; internal/gateway full package on mote.
Not tried: a real Claude subscription behind new-api; Claude Code's
interactive mode with a message-only effort (the -p stand-in was used).
2026-11-12 08:30:48 +08:00
yetone 3af8fe9cf7 gateway: a Claude account's Fable week used up rests Fable on it, not the account (kaitokiku on X)
Claude Code's refusal for a used-up window is "You've hit your limit" and
names no window, and its rate_limit_info may carry no rateLimitType (the
transcript's rejected row). restAfter read the account's windows as they
were cached before the Fable week filled (Fable 60%, nothing full), so
Pooled said no and the whole account rested for the refusal's time:
Opus, Sonnet and Haiku with it, though the other weekly quota was left.

A quota refusal on an account whose reading holds a window of some models
only that counts the model, none known full, now asks for the reading
again and narrows the rest to the model when it shows that pool full
(narrowWhenRead, as for an unread account, #2036). Every route rests
through restAfter, so Messages, Chat Completions, Responses and the group
fallback share it; Claude is not a plugin.

Run at this tree (mote): TestClaudeFableWeekRestsFableOnly red on the old
routing.go (rests the account), green with the fix; internal/provider,
gofmt, vet on darwin, linux and windows. Full internal/gateway follows.
Not tried: a real Fable-limited account; a usage reading that keeps
failing leaves the account resting whole, as before.
2026-11-12 08:27:46 +08:00
yetone 96c65e3e7d provider: WorkBuddy's mover min is 0.2.29 (plugins #1022, #1015)
0.2.29 pins WorkBuddy AI's free window at the reset a routed-past refusal names (yetihan, plugins #910, #1022). 0.2.28 lists an enterprise's custom: models (plugins #1015). Both are on npm (npm view --prefer-online: latest 0.2.29).

Ran: go test -count=1 ./internal/provider/ on mica, ok.
2026-11-12 08:12:42 +08:00
yetone 7b5c069c3a gateway: Vertex AI gets a tool's image in a user turn of its own, no "Requests ending with a model turn" after view_image (Voo_Ler on X)
What the user saw: Codex on Google Vertex AI stopped right after "Viewed an
image" with "Requests ending with a model turn are not supported".

Why: Codex's view_image answers with a function_call_output whose output is
[input_text, input_image] (as ~/.codex/sessions rollouts record it). The
Gemini build kept a tool's images in the same user turn as its
functionResponse. Vertex AI answers a response turn mixing in anything else
with that 400 although the last role is user (#1533 showed it for text, and
ce11b1801 split the text out but left images with the response).

What changed: buildCodeAssistSent, for Vertex AI, puts a tool's images in a
user turn after the responses (with what the user said, if anything). The
image and the words are kept. AI Studio, Code Assist (Gemini CLI,
Antigravity) are unchanged: Gemini CLI itself sends a read image beside the
response, and no refusal is known there. Chat and Messages clients reach the
same builder, so they are covered; the image-under-assistant and trailing
model turn cases already end with a user turn (continueText).

Tests: gemini_view_image_test.go posts Codex's real view_image shape (array
output, image-only output, image in a following user message, image in a
model-role message) to /v1/responses against a fake Vertex that refuses as
the real one does; vertexTurnsAway now also refuses an image beside a
response. Reverting codeassist.go makes it fail with the reporter's exact
message, and TestGeminiToolResponseTurnHoldsNoText fails too.

Run: go test ./internal/gateway ./internal/provider on mote, gofmt -l, go vet
-tags nogui for darwin, linux and windows.
Not tried against real Vertex AI: no Vertex credentials on this machine.
2026-11-12 07:50:22 +08:00
yetone 040debfb1e sessions: the kept parses' file is mapped, not read onto the heap (#2278)
A start read sessions.json whole onto the heap (24.6 MB on a real
history) and decoded it; then each `named` object was copied again by
gjson.ParseBytes before being read. Nothing decoded keeps a byte of
the file: json.Unmarshal, ccStr and unique.Make all copy, and the keys
are cloned.

On unix the file is now mapped read-only and unmapped once decoded (it
is only replaced by a rename, never written in place); elsewhere it is
read as before. `named` parses its bytes in place.

Run:
- go test ./internal/sessions (mica): ok 63s.
- GOOS=darwin/linux/windows go vet ./internal/sessions: ok.
- Broken by hand: read onto the heap again, TestCacheFileReadWithoutACopy
  is red ("allocates 688976 bytes; want it mapped"); a key left
  pointing into the file (no Clone) faults it with SIGSEGV after the
  unmap. The fixture has plain and escaped names, since an escaped one
  is unescaped into a copy anyway.
- Every custom UnmarshalJSON in internal/sessions read for bytes it
  keeps: none.
- Real account, mote sandbox HOME, start to 50s (pprof alloc_space):
  sessions.loadCache 29.5 MB -> 4.4 MB, os.readFileContents 46.7 MB ->
  22.0 MB. Footprint peak unchanged (163 to 164 MB); it is set later.

Not tried: a real Linux start; Windows reads the file as before.
2026-11-12 07:40:42 +08:00
yetone 972f69fdc7 dsh: a start's first round goes by the last magpie's record (#2278)
A start's first dsh round read every profile through the yaml emitter to
find what the last magpie's round had found: nothing to write. On a real
account that was ~60 MB of the first minute's 523 MB.

The round's key (dsh's files, the gateway, the models) is now summed with
sha256, the same in every process, and a round that ends with nothing to
write records it in the cache folder (dsh-rounds.json, temp + rename).
A start's first round goes by that record when it is this magpie
version's; a dev build never does. A file, the models or the version
changed has the round run as before.

Run:
- go test ./internal/agent (mica): ok 188s.
- GOOS=darwin/linux/windows go vet ./internal/agent ./internal/gateway
  ./internal/appdir: ok.
- Broken by hand: with the record not read, TestDshFirstRoundGoesByTheLastMagpies
  is red ("read and wrote dsh's files 1 times").
- Real account, mote sandbox HOME, a start after one start (pprof
  alloc_space at 50s): dshRounds.once 101 MB -> 38 MB (the catalog
  only), yaml emitter 43 MB -> none, total 522 MB -> 463 MB. Footprint
  peak 168 MB (w11) -> 165 MB.

Not tried: Windows and Linux real starts; the record is plain JSON in
appdir.Cache() there too.
2026-11-12 07:03:00 +08:00
yetone a535bbf3cf gateway: a Claude TUI test's unanswered call ends with its test
tuiCalls.call made Claude Code's MCP call with httptest.NewRequest, whose
context is never done, so a call a test didn't answer waited in mcpCall
until the package ended. macOS CI's 30m alarm at e787e7b5c (run
43102520567) showed one such goroutine blocked 24 minutes in mcpCall from
claude_tui_call_test.go:76. The request now carries a context the test's
cleanup cancels, and the cleanup waits for the call to return.

Run (mote, at origin/main 152734cd1 plus this change): a throwaway probe
test, run after the TUI tests, counting (*tuiCalls).call goroutines still
alive: old helper "1 tuiCalls calls still running after their tests",
fixed helper ok. go test -race -count=5 -run TestClaudeTUI ./internal/gateway
ok (240s); that pattern covers every user of newTUICalls and schemaTUI.
Not the cause of that run's timeout: the package took 1801s where the
last green macOS run took 888s, with the alarm landing on a 5s-old
ZCode test (#2191).
2026-11-12 06:43:10 +08:00
yetone 152734cd12 dirent: one probe vouches for every folder a poll watches (#2278)
A Sessions poll watched each Codex day folder and each Claude Code
project folder through dirent.Watch, and every call ran its own sync1
probe (a mkdir, an unlink and a wait for the write to be heard). On a
real history that was ~130ms of 1.47s CPU per 40 polls, and the
syscalls around it more. WatchSince(dir, mark) skips the probe when a
probe begun after mark was heard; sessions takes the mark when a hold
begins, so one poll makes one probe. A folder watched for the first
time still probes, since its watch hears only what comes after.

Run, real account (mote, the owner's Claude Code and Codex history,
40 back-to-back /api/sessions polls, sandbox HOME):
- CPU: w10 1.47s -> w11 0.54s; under sync1: 130ms -> 10ms.
- Allocated: 25.98 MB -> 25.08 MB.
Tests (mica): go test ./internal/dirent ./internal/sessions ok at the
pushed head. TestWatchesFromOneMarkProbeOnce is red with covered
forced false ("round 0: 3 probes from one mark") and green on this.
./internal/gui: TestPanelHiddenByWailsMarksPageOutOfSight fails under
-count=3 on an origin/main copy (4ae833f84) too and passes -count=1;
recorded on #6203.
2026-11-12 06:29:11 +08:00
yetone 390341f9ed appdir: the homes look tells folders apart by inode, not EvalSymlinks (#2278)
ClaudeHomesIn and CodexHomesIn run on every Sessions poll, and keyed
each folder they found by filepath.EvalSymlinks, which Lstats every part
of the name: ~3 MB of garbage per 40 polls on a real home. On unix a
folder is now keyed by its device and inode, which a link to it shares;
a folder that can't be looked at is keyed by its name, and other systems
keep EvalSymlinks. The folder checks use DirStat, moved here from
internal/sessions so both share one.

Run (mica, at this tree): go vet for darwin and windows of appdir,
sessions, provider and gui, for linux of the first three (gui needs cgo
there); GOOS=freebsd go build; go test ./internal/appdir ./internal/sessions
./internal/provider ok. TestHomesLookAllocatesLittle: 55 and 68
allocations a look now, 387 and 400 on the old code, which fails it.

Real account (mote, 40 polls of /api/sessions): w9 31.28 MB allocated
with os.lstatNolog 3 MB; w10 25.98 MB, lstat gone from the top list.
CPU over 30s 1.47s, within noise of w8's 1.29s at mote's load.
2026-11-12 05:44:12 +08:00
yetone f8248ccd70 sessions: an unchanged folder's look allocates nothing (#2278)
readDirectory looked at each folder with os.Stat on every Sessions poll
to see whether its cached listing still held. os.Stat builds a FileInfo
and a name each time, ~6 MB per 40 polls on a real history. dirStat reads
the same mod time, size and kind with unix.Stat into a stack Stat_t;
other systems keep os.Stat.

Run (mica, at this tree): go vet ./internal/sessions for darwin, linux,
windows; GOOS=freebsd go build ./internal/sessions; go test ./internal/sessions
ok (61.8s). TestDirStatAsOSStat passes; with the old discovery.go it fails
("an unchanged folder's look allocated 2 times").

Real account (mote, 40 polls of /api/sessions): w8 34.16 MB allocated,
os.statNolog 6 MB; w9 31.28 MB, os.statNolog not in the top list.
2026-11-12 05:36:00 +08:00
yetone 57855191f0 provider: a price looks its provider up without copying them all (#2278)
byIDOrWas, which every model's price (BasePriceIn, UserBasePriceIn)
and a few model preferences go through, read All(): a copy of every
provider, its keys, headers, models and account maps, to find one. A
Sessions poll prices every model of every call, so that was the next
largest allocator of a poll. It now looks among the shared providers
(sharedAll, as Find does) and clones only the one it found, which stays
the caller's to change.

Measured on mote with the owner's real account, 40 /api/sessions
polls, `magpie heap` alloc_space diff:
  before (w7): byIDOrWas 9.74 MB (All 9.74: its copies 5.7, sharedAll
  4.0)
  after  (w8): byIDOrWas 3.52 MB, all of it sharedAll's rebuild when
  the hold expires; All gone from the poll
CPU over 30 s of polling: 1.37 s (w7) -> 1.29 s.

Test: TestByIDOrWasCopiesOnlyItsOwn (new), 40 providers of 5 keys each
under Hold: a change to the returned provider doesn't reach the shared
ones, and the lookup allocates under a tenth of All. With the old
models.go it fails (1560 allocations, against 1560 for All).
Run on mica at 10c331531 plus this change: go vet ./internal/provider
for darwin, linux and windows clean; go test ./internal/provider ok
(130 s).
Not tried: Windows or Linux runs; the change is which list is read.
2026-11-12 05:30:42 +08:00
yetone 10c3315312 sessions: an unchanged listing is the last one, not a new list (#2278)
Every 15 s Sessions poll built every Claude Code file's and Codex
rollout's list again, and merged and filtered them into more new
lists, while nothing on disk had changed. On the owner's real history
that was ~120 MB of garbage per 40 polls in listedRollouts,
claudeFiles, listCCFiles and filesKept.

Each lister now keeps its last list (listsKept). A listing walks the
folders as before and compares each file with the kept list's file at
the same place; while they match nothing is allocated, and the kept
list itself is returned. On the first difference it copies the matched
part and goes on, so a grown, new or gone file is listed as a fresh
listing has it, and the kept list is never written. listCCFiles reuses
its walk's scratch slice per lister. distinctPaths and
distinctCodexFiles return their input when nothing is dropped and never
filter in place; codexFilesIn's twin filter clones before deleting.
rolloutsSeen's day entry is its part of the kept list (clipped), not a
clone. The idle cache drop forgets all of it.

Measured on mote with the owner's real account (75 GB history),
40 /api/sessions polls, `magpie heap` before and after, alloc_space
diff:
  before (w6): 155.7 MB; listedRollouts 42.8, claudeFiles 32.2 (71.1
  cum), listCCFiles 31.0, filesKept.distinct 18.0
  after  (w7):  34.8 MB; none of the listers in the top; distinct 4.5,
  provider.All 9.7 (next)
CPU over 30 s of polling: 1.79 s -> 1.37 s.

Tests: lists_kept_test.go, red on the old code (an unchanged listing
made a list of its own; distinctPaths wrote its input), green now.
TestClaudeFilesMadeAtTheirSize expects the clipped kept list.
Run on mica at this tree (rebased on 0cff3429f, sessions vet + test again ok): go vet ./internal/sessions for darwin, linux
and windows, ./internal/gui for darwin; go test ./internal/sessions ok
(64 s); go test ./internal/gui ok but TestPanelHiddenByWailsMarksPageOutOfSight
(#6203, flaky on mica, passes alone). -race of sessions: #4360 and
#6213, both red on the old code too, no stack in the changed code.
Not tried: Windows and Linux runs of the new test (the codex subtest is
darwin-only).
2026-11-12 04:52:19 +08:00
yetone 729664580b gateway: the Grok balance rest test waits for its narrowWhenRead
TestGrokBalanceExhaustedRestsToReset (ac6db8933) swaps awaitAllowance
and puts it back in a defer. Its "no window known" case is an unread
quota rest, so restAfter starts narrowWhenRead, which reads
awaitAllowance off the test; nothing waited for it, and the race job
went red at 0d0a1a567 (write in the test's defer, read in
narrowWhenRead at routing.go:956). The Factory pool tests that swap
awaitAllowance already defer narrowing.Wait(); this one now does too.
Those two files are the only tests that reassign awaitAllowance.

Run (wsl-run, magpie-desktop): go test -race -count=200 -run
'^TestGrokBalanceExhaustedRestsToReset$|^TestFactory' ./internal/gateway
ok. Not reproduced red here: 500 race runs of the old test, with a pause
injected in narrowWhenRead or at the test's end, stayed green, so this
rests on the CI stacks and the Factory tests' rule.
2026-11-12 04:24:58 +08:00
yetone e0a1ab0a47 agent: RenameLegacy reads no thinking level as a model
RenameLegacy looks for model fields still holding a legacy provider id.
It read every field's value, Pi's defaultThinkingLevel too, and Pi's
effort Get checks the level against the models Pi offers: the whole
catalog built for Pi at every start, though no thinking level is ever a
model id. A field whose key ends in "effort" is now skipped.

Measured on mote with a real account (its providers, Codex and dsh
homes), the profile 8s after start, two runs each:
- before (w5): RenameLegacy 67 MB allocated, piOffered/sharedModels
  46-48 MB of it
- after (w6): RenameLegacy 25 MB, piOffered gone from the profile;
  the diff of the two profiles: sharedModels -47 MB, but the dsh round
  now builds its own list (+27 MB) where it used the one Pi built, so
  ~20 MB less allocated at start. liveHeap 104.5 MB both, footprint
  134-137 MB both: this is garbage saved, not memory kept.

Run: TestRenameLegacyBuildsNoModels (new) passes; with the old
legacy.go it fails ("RenameLegacy built pi's models"). gofmt, go vet
and go test ./internal/agent on mica at 40c8d0c81 plus this change: vet clean, ok internal/agent 287s.
Not tried: Windows or Linux; the change is a string check on keys.
2026-11-12 04:15:52 +08:00
yetone 40c8d0c81a routing: an account whose windows are all set aside shows what the Usage page read, not "not known" (@apple_test_src on X)
A Cursor account signed in through its plugin (pooled plan, or on-demand
or free credit that can pay) sets every window aside, since none can stop
the account. Routing's allowance then holds no figure for it, so the
Accounts and keys row (and the stage row) said "what's left not known
yet" while the Usage page showed its percentages. This is true of any
plugin-served subscription that sets all its windows aside, not only
Cursor.

Both Routing rows now say the card's first window (as Usage read it) when
routing has no figure, the rest on hover; with no card the unknown line
stays. Display only: how accounts are weighed is unchanged.

Run: new routing-pooled-card.test.cjs (5 languages, 1100/420px, chromium
and webkit) 22 pass; red 22 of 22 with client.js put back to origin/main's
(broken by hand). Routing, i18n-keys, use-first, account-mask and
codex-credits GUI files on mote: the only reds are in routing-context-fold,
routing-pin-away, routing-row-swap, routing-story-shrinks, many-keys and
accounts-narrow; the first four fail the same on the origin/main client.js
(umbrella #4494, #5475).
Not tried: a real Cursor account; the Go suite starts after the tag.
2026-11-12 03:51:33 +08:00
yetone f590987e73 dirent: a probe's wait removes its file and folder, not RemoveAll
Each Sessions poll calls Watch twice, and each wait made a folder with
one file and then RemoveAll'd it, which looks, opens and lists the
folder first. On mote's real account profile, RemoveAll was half of
sync1's 0.16s over 40 polls. Now it removes the file, then the folder,
with RemoveAll kept only for when one of those fails.

Run (mica, darwin/cgo): gofmt -l internal/dirent (empty), go vet,
go test -count=3 ./internal/dirent ok. TestProbeLeavesNothing checks
that the probe's folder is empty after five Watch calls. A throwaway
benchmark of 1000 Watch calls, 3 runs each, user+sys: new 1.43/1.42/
1.48s, old (RemoveAll) 1.62/1.52/1.47s, about 5% less CPU per
Watch. Wall time is the FSEvents latency, ~12ms, the same on both.
Not tried: a new real-account poll profile on mote (load 77 at the
time).
2026-11-12 03:32:33 +08:00
yetone 76c7742cf3 provider: the ZCode mover's min is 0.1.60 (plugins#1020)
zcode 0.1.60 (plugins 7c44d027) keeps the last coding plan key when reading it fails for a network reason (ECONNRESET, a timeout), or answers a wall that magpie sends once and then rests the account. Before, a thrown error was retried about 8 times over six minutes. Free first also no longer replays onto a coding plan whose usage read showed a window full. Raising the min lets keepMovedCurrent update every moved user.

npm view --prefer-online: 0.1.60 at the time of the change.
Run on mica: go test -count=1 ./internal/provider/ ok (129s). gofmt -l clean.
Not run: the full suite. This change is the min string only.

Reported-by: takomitkm
2026-11-12 03:30:27 +08:00
yetone 0d0a1a5678 balance probe: kept across restarts, Auto-detect switch, Detect again, not-detected line in the editor (#3146, Niapyaya on X)
A custom provider at a New API / Sub API / One API relay with no Balance URL
has its balance query found by magpie (provider/balance_probe.go). This keeps
what was found, or not found, in balance-probes.json (keyed by origins and a
hash of the key, written through temp-and-rename, an unreadable file read as
empty), so a restart does not probe again. The editor gets an Auto-detect
switch (NoBalanceProbe), a Detect again button (ForgetBalanceProbe) and a line
saying where the balance was found, or that none was, with the Balance URL
field as the way out. A found balance is a balance card on the Usage page.

Run at the rebased head (parent 6a3f162f0 = origin/main), on mica:
- gofmt -l: clean.
- go vet ./... (darwin), GOOS=linux -tags nogui, GOOS=windows: clean (at the
  previous base e6bf4adf1; go vet ./internal/... again at this head).
- go test -count=1 internal/provider internal/gui: ok, at this head.
- GUI, both engines, five languages: balance-found, gui-de/ja/zh-tw, i18n-keys,
  i18n-en-no-cjk, provider-billing, provider-detect*: all ok except gui-de and
  gui-ja "has every zh string" ({agent} twice in sessions' "isn't installed
  here"), which are red the same at e6bf4adf1 (filed).
- At e6bf4adf1, 79 provider/gui/i18n files: 80 reds, the same 80 on the
  unmodified base (provider-fetch-again #5232/#5057, provider-picks-stay
  #4397, provider-models-rest #4396, provider-typed #4673, menu-scroll #1550,
  provider-max-output and provider-many-keys filed with the rest).
Not tried: a real New API / Sub API relay with a real key; the full Go suite
(started after the tag).
2026-11-12 03:13:50 +08:00
yetone 5a36e46d67 cli: name POST /api/library/mcp-account as not yet a command
60fde6fb1 added the MCP server accounts route and ran chosen packages,
so TestEveryRouteHasACommandOrIsNamed has been red on main since. It
joins the other library MCP routes under stage 3.

Run (wsl-run): the test is red on origin/main 5d5d57cbb and passes with
the entry; GOOS=windows and GOOS=darwin -tags nogui go vet clean.
2026-11-12 03:06:11 +08:00
yetone 8dfc75afd2 testenv: tests on WSL leave the Windows drives off PATH
On WSL the interop PATH holds a dozen /mnt/c directories, reached over 9P.
proc's look cache stats every PATH directory, and in tests it is never
fresh (lookFreshInTests is 0), so every command a test runs paid for a
dozen 9P stats. internal/cli took over 40 minutes on the magpie-desktop
distro and timed out at 45m; two of its tests alone took 34.9s each with
/mnt in PATH and 0.27s without. A test also found Windows programs
there (VS Code's `code`) instead of the fake it set up.

Isolate now drops every /mnt/<drive> entry from PATH when it runs under
WSL (WSL_DISTRO_NAME, WSL_INTEROP or binfmt_misc's WSLInterop). /mnt/wsl
and /mnt/wslg stay.

Run (wsl-run, magpie-desktop):
- go test ./internal/testenv: ok. TestIsolateDropsWindowsPath is red
  with dropWindowsPath returning early, green with the fix.
- internal/cli: 36.7s, was over 40m; its one red is
  TestEveryRouteHasACommandOrIsNamed, from 60fde6fb1, fixed in the next
  commit.
- internal/proc ok (3.5s), internal/library ok (68s), internal/agent ok
  (113s).
- GOOS=windows go vet and GOOS=darwin go vet -tags nogui of
  ./internal/testenv ./internal/cli: clean.
Not run: the full suite (mote and mica were over their load bar).
2026-11-12 03:06:10 +08:00
yetone 5d5d57cbbb library: Variables are carried in backups and sync, keys only with keys (onducoder on X)
A skill's key set once as a Library variable (ANYSEARCH_API_KEY and the
like) now goes with the library: Bundle.Env carries name, value and agents
(nil from an older magpie, and Put then keeps this computer's). It follows
how servers' tokens are carried: a backup or sync without keys keeps the
names and empties every value (whatever the name, since a variable's name
says nothing of its value), WithSecrets fills them from this computer's, and
one with keys is sealed under its passphrase. A variable with no value is
not written into an agent (syncEnv), and a value the user set in the agent's
file is still never overridden. Not built: showing the variables a skill
needs on its sheet; nothing in a SKILL.md says them reliably.

Run (mote): go test ./internal/library ./internal/backup ./internal/davsync
ok; gofmt clean; go vet darwin, windows, linux -tags nogui clean.
Broken by hand: WithoutSecrets leaving the value turns TestEnvIsCarried red.
Not tried: real Claude Code / Codex reading the carried key; a real WebDAV
or S3 round trip; the full suite; GUI tests (no GUI file touched).
2026-11-12 02:59:41 +08:00
yetone 4b29709eca gui: Standard speed is one word, in the core strings; the routing plugin's copy is gone (#6206)
a5e805f57 added the core string for Model settings while the routing plugin
already had it, so i18n-keys failed "no language has a key twice" and "a
plugin's words are its own". The plugin reads core words, as it does Fast and
Ultrafast.

Run on mica at the rebased head: i18n-keys and i18n-en-no-cjk 8 of 8 from the
repo root (red before: 2 of 8). Chromium and webkit: model-speed, group-*,
routing-group*, routing-save*, routing-js, i18n-*: 775 of 778; the red are
group-editor-selected (#5049, red on a clean main) and i18n-keys' "a plugin's
words are its own" when run with -C internal/gui, where the test's repo root
becomes mica's home and it reads another session's run copies (the same file
passes from the repo root); not a code red.
Not tried: the full GUI suite.
2026-11-12 02:45:22 +08:00
yetone facc092d00 sessions: a ZCode name poll stamps a copy, not the kept file list
v0.1.3800 (729be88e1) has allFilesForTitles give back the list it keeps
from poll to poll, and other polls read it meanwhile. Titles then
wrote each asked ZCode session's message count and time into that list
in place (zcodeTitleStamps): a data race with any poll reading it, and
the kept list no longer matched the rows, so it was made again on the
next pass. The stamps now go in a copy made at the first one that
changes a file; a poll with nothing to stamp copies nothing.

Audited the other users of allFiles/allFilesForTitles and the
in-place writes in internal/sessions (&files[i], .w(), sort.Slice):
the rest write into lists of their own (byKey copies, traceLineFiles
concatenates, callSources goes through distinctOf).

Run (mica): go test -count=1 -timeout 45m ./internal/sessions/ ok;
go test -race -count=3 -run 'TestZCode|TestFilesKept|Titles' ok; vet
ok; gofmt clean. Broken by hand: stamping in place again makes
TestZCodeTitleStampsLeaveKeptListAlone red ("the kept list was
stamped in place: size 1, mod 1790496500000").
Not run: the full ./... and GUI suites (one package touched).
2026-11-12 02:44:19 +08:00
yetone 0b4b249e54 sessions: an unchanged Sessions poll keeps the last file list
Every 15 s poll made the whole deduped file list again (~1.5 MB on a
real history, distinctOf's 58 MB over 40 polls). allFiles and
allFilesForTitles now compare each pass with the last list, held
weakly so a magpie with the page shut keeps none of it, and give the
same array back while nothing differs. A changed or gone file makes a
new list; the old one is never written into (cap == len). An empty
pass is an empty slice, never nil: refresh reads nil as "not listed"
and kept the parses of deleted files (TestGoneAgentLeavesNoSession
went red on the first try, caught before commit).

Run (mica): go test -count=1 -timeout 45m ./internal/sessions/
./internal/dirent/ ok; go vet of both ok; gofmt clean.
Broken by hand: the nil return makes TestFilesKeptWhileTheSame ("an
empty pass: nil") and TestGoneAgentLeavesNoSession ("5 parses kept")
red; a fresh slice on every pass makes TestFilesKeptWhileTheSame red.
Real account on mote, 40 unchanged /api/sessions polls, alloc_space:
179.5 MB (v0.1.3794 build) -> 147.9 MB; distinctOf gone, the kept
list's own compare 12 MB. /api/sessions body sha identical on both.
Not run: the full ./... suite (mote over its cores; this touches the
sessions package only) and the GUI suite.
2026-11-12 02:30:15 +08:00
yetone c75a1a0f83 agent: dsh's bili route asks sharedModels for the catalog, as every reader of the list does (TestModelReadersShareTheList)
The previous commit read len(magpieModels(...)) in dshThrough; the guard test
that lists readers of the shared catalog went red. Run (mica): go test -tags
nogui ./internal/agent: ok (202s); ./internal/library: ok (139s); go vet
darwin, GOOS=linux -tags nogui, GOOS=windows on agent and library: clean;
GUI library-bili, library-all, i18n-keys, i18n-en-no-cjk and site node --test:
exit 0 at the commit before.
2026-11-12 02:24:10 +08:00
yetone a1a3b6fadb library: DeepSeek Harness folds its context with billion-context through its /bili/ prefix (VantH_off on X)
VantH_off asked for DeepSeek Harness in billion-context's support.
Library's billion-context tab offered Pi, omp, OpenCode, Claude Code, Hermes
and Zed. bili's dsh route is `dsh plugin add billion-context` (billion-context
0.1.213 README), which loads in dsh's process and takes traffic by proxy
settings; magpie's dsh route is baseURL http://127.0.0.1:3425/v1, plain http
on loopback, so that never sees it and the plugin would add tools and fold
nothing (the Hermes case, 00e8242e8). dsh's route baseURL is editable, so it
takes the route Zed and Hermes take, bili's documented /bili/ prefix.

Turned on, magpie runs `bili start --port 8787` and writes magpie's route
baseURL in every dsh profile and the home layer as
http://127.0.0.1:8787/bili/<gateway>/v1 (Anthropic route: no /v1)
(agent.DshThrough: dshSyncFresh with the prefixed gateway). dshReach reads the
prefix back from the profiles' routes (loopback path before the gateway's
address) and Check, Sync, a pick and the serving round (dshWiredWith, which
read gateway.URL() directly) keep it; an address that isn't a local proxy's
goes back to the gateway. Off writes the gateway back. Empty-list string (en,
zh, zh-TW, ja, de), docs (en, zh, ja), llms-full.txt and
docs/subsystems/library.md name dsh. bili's dsh plugin installer is never run
for it. The remaining agents are #5915.

Run (mica, at the pushed head unless said):
- TestDshThroughBili, TestBiliDshThroughPrefix: ok
- see below for the packages and GUI files
Broken by hand:
- dshReach returning gw: TestDshThroughBili red (a sync drops the prefix)
- no "dsh" URL lane: TestBiliDshThroughPrefix red (dsh not offered)
Not tried:
- a real dsh and a real `bili start`; tests fake bili and the probe, so
  whether dsh's SDK sends to the prefixed address is by analogy with Hermes
- Windows run (vet only)
2026-11-12 02:24:10 +08:00
yetone 4847a087fb provider, library: two package-level regexps compile on first use
TestNoEagerPackageRegexps (root package) was red on main: fc615339f
added aliWindowField in internal/provider/alibaba_usage.go and
e174b5515 added envName in internal/library/env.go, both with
regexp.MustCompile at package level. Both now use lazyre.New; each has
one call site (FindStringSubmatch, MatchString), which lazyre has.

Run (WSL magpie-desktop, origin/main 2bb201162 + this):
- red first, unchanged main: TestNoEagerPackageRegexps named
  env.go:57:15 and alibaba_usage.go:374:22.
- after: gofmt -l clean; go vet -tags nogui ./internal/provider
  ./internal/library ok; -run TestNoEagerPackageRegexps . ok;
  ./internal/library ok; -run 'Ali|Alibaba' ./internal/provider ok.
2026-11-12 02:14:21 +08:00
yetone e7980ed955 gateway: a summary that arrives while the reply streams still branches from the run's session (recih on X, #6128)
A call got the conversation it answers only in park(), after the whole
reply ended. Claude Code's AgentSummary that arrived while the reply
still streamed (a call shown, park not yet run) found no line with that
conversation, so branch() said "no run waits on a reply to this
conversation" and a new Claude Code was told the whole transcript
(108K cache tokens written). emit now registers a call's line with the
run's conversation when the call is shown; park and noteLines keep it.

Run (mica, load on mote): TestClaudeBranchForSummaryWhileTheReplyStreams
(attach, KStart, KToolStart, no park, then the summary) is red on the old
code ("no run waits on a reply to this conversation") and green now.
go test -run 'Claude|Branch|Fork|Park|Subscription' ./internal/gateway ok;
gofmt clean; go vet darwin, windows, linux nogui ok.
Broken by hand: the fix reverted, the new test goes red.
Not tried: a real AgentSummary on a live TUI run; the full suite is
started after the tag.
2026-11-12 02:14:08 +08:00
yetone e6bf4adf1f usage: Claude Code's helper requests are labelled, the largest cache write is one click away (recih on X, #6199)
Claude Code's AgentSummary and its auto mode classifier name themselves
nowhere in the request, so there is no client marker to read. The gateway
tells them by their content (inferredKind: a claude-cli/ request on the
Messages API; the classifier by autoModeClassifierAsk, the summary by its
last user text "Describe your ... in 3-5 words") and records them as
agent_summary_inferred and auto_mode_check_inferred. The purpose catalog
names them "Progress summary (inferred)" and "Auto mode check (inferred)"
and puts each with its plain kind's purpose, so the existing Purpose filter
lists both; nothing known and nothing inferred share a name. A tool that
printed the same words, a chat, and another agent's request stay unmarked.

A requests page now also holds BigWrite, the gateway-served row that wrote
the most to the cache (cells, page-v1.json and pageFromLedger all carry it;
rows from session files have no request to open). The Requests line shows
it as "109K largest write", a button that opens that request through
openUsageRoute. settledCountVersion is raised to 3, which keys the cached
pages.

Not done: the per-request branch recovery result asked for in #6199. No
structured field holds it.

Run on mote (load 21-24 of 18 cores, mica was higher): go test ./internal/usage
./internal/usageapi, the gateway and gui purpose tests, go vet for darwin,
linux (nogui) and windows, gofmt; the GUI files usage-big-write (new),
purpose-filter, routing-kind, i18n-keys and usage-ledger in chromium and
webkit. Broken by hand: inferredKind returning "" turns
TestClaudeHelperRequestsAreLabelled red; the larger-than test of BigWrite.add
turned round turns TestRequestPageBigWrite red on both paths; the jump off
turns usage-big-write red. Not tried: a real Claude Code session against a
live subscription, Linux WebKitGTK.
2026-11-12 02:01:31 +08:00
yetone e174b55150 library: a Variables tab gives environment variables to Claude Code and Codex (paopao_baobao on X)
An environment variable is kept once in the Library and written into each
agent picked: Claude Code's settings.json "env", Codex's config.toml
[shell_environment_policy.set] (a sub-table or inline set is edited; a
dotted spelling is refused). It follows Hooks: Applied.Env records what
magpie wrote, so turning it off or removing it takes out only that, and a
value the user set or changed in the file is never overridden (a conflict
is a problem on the row). An unreadable file is an error, nothing is
written. The tab has name, value and agent chips, an edit sheet and a
row Remove with a confirm; its sidebar entry is in "Every agent". Not
carried in backups, as hooks first were. docs/subsystems/library.md updated.

Run (mica, sandbox HOME): internal/library and internal/gui go tests ok;
gofmt clean; go vet darwin, linux -tags nogui, windows clean; GUI
library-*, i18n-* in chromium and webkit (en, zh, zh-TW, ja, de, 440px):
all green except "the Library while it loads", red on the merge base too
(not from this change). Existing tab-list assertions in library-hooks,
-subagents, -groups, -loading now include Variables.
Broken by hand: syncEnv overwriting the user's value turns
TestEnvNeverOverridesTheUsers red.
Not tried: real Claude Code / Codex reading the written env; other agents
(Gemini .env, Qwen, Droid); WSL; env in backup carry.
2026-11-12 02:00:19 +08:00
yetone a5e805f574 Codex: Ultrafast beside Fast in a group member, and a Fast/Ultrafast setting per model (kdajenks on X)
kdajenks (magpie 0.1.3739, Codex on ChatGPT Pro) could set Fast only from a
routing group's member row and had no Ultrafast there, and no way to set the
speed in the model's own settings. Ultrafast exists: Codex's catalog lists
the `ultrafast` service tier, the code already sent it for agent picks and
Codex's service-tier row, and the live account's service_tiers hold it.

- Group member: the button steps Standard speed, Fast, Ultrafast (where an
  account offers it, `ultraOK`), back to Standard. `Group.Ultra` is a subset of
  `Fast`, kept through rename, fold, share, gone-filter and the CLI
  (`magpie group ... ultra=`). The gateway marks the candidate `ultra`.
- Per model: `settings.ModelTiers` ("<provider>/<model>" to priority or
  ultrafast), `provider.SetModelTier` (refused where CanFast/CanUltra say no),
  `ModelPref.Tier` in Model settings (Standard speed / Fast / Ultrafast, in
  modellimits.js), and `magpie model tier <provider/model> [fast|ultrafast|usual]`.
  The gateway sends it on a direct pick for an agent with no fast pick of its
  own, through fastPick, so an account without Ultrafast gets priority. A group
  member goes as the group says.
- Docs: gateway-routing, providers-accounts, reference.

Run (mica, at the rebased head over a6d84e13a):
- gofmt -l clean; go vet darwin, linux nogui, windows clean.
- go test internal/provider, internal/settings ok; internal/gui and
  internal/cli ran: the one red of mine (TestSettingsSaveKeepsWhatItDoesNotSend
  wanting ModelTiers) is fixed in this commit; the others are not mine and
  red on a clean origin/main: TestEveryRouteHasACommandOrIsNamed (#6202),
  TestPanelHiddenByWailsMarksPageOutOfSight (#6203, not checked on main).
- internal/gateway ok (984s).
- GUI, chromium and webkit: new model-speed.test.cjs (30, five languages, 1200
  and 420px), plus model-*, group-*, fast-*, i18n-*, text-size,
  codex-service-tier, panel-*, routing-group*, routing-save* files. Red and not
  mine, same on a clean origin/main worktree: fast-pick and fast-ultra (#6201),
  group-editor-selected (#5049).
- New tests TestModelTierSentToEveryAgent, TestGroupMemberUltrafast,
  TestCleanModelTier, TestSaveGroupUltra.

Broken by hand: removing the gateway's model-tier branch and the candidate
`ultra` copies turned both gateway tests red; turning off the Ultrafast choice
in Model settings turned 20 of 30 GUI tests red; reverting the member button to
two states turned 10 of 30 red.

Not tried: a real ChatGPT account sending Ultrafast through the new setting;
the agent picker's bolt does not show a model-level default; Windows and Linux
GUI runs.
2026-11-12 01:56:26 +08:00
yetone 6f3e76626c sessions: an unchanged session folder isn't listed again on each poll (macOS)
Every 15 s Sessions poll listed every Codex day folder and Claude Code
project again (~18k files in a few hundred folders on a real history),
and those getattrlistbulk calls were ~63% of the poll's CPU while
nothing had changed. dirent now keeps an FSEvents watch on the Codex
and Claude Code homes, and Stats of a folder under one gives its last
listing back unless the system said something in it changed since.

What makes the word trustworthy:
- FSEvents is a moment late, so each Watch (once per read) writes in a
  new folder of its own under the watch and waits for that write to be
  heard; events come in order, so every earlier change is heard by
  then. An earlier write's late word can't end a later wait: each wait
  has its own folder (an earlier version shared one, and the test went
  red 4 of 30 at load 73 on mica).
- A write to a file held open is heard only when it closes, and Codex
  holds its rollout open. So a folder with a file written in the last
  15 min is listed every time, a change in a home's own folder
  (history.jsonl, at each prompt) relists everything under it, and no
  listing is trusted past 2 min.
- Dropped events, a moved root, a mount, a wait over 1 s, another
  volume, or no Watch in the last 2 s: the folder is listed.
Linux and Windows have no watcher, so they list as before.

Run:
- mica: go test -count=30 of the dirent watch tests at load 73, green;
  with the shared probe folder put back by hand, 4 of 30 red.
- mica: go test -count=1 -timeout 45m ./internal/dirent ./internal/sessions
  ./internal/gui, ok (sessions 253s, gui 159s), one change before the
  per-wait probe folder; dirent and the real-account checks after it.
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows, CGO_ENABLED=0.
- mote, real Codex + Claude Code account (sandbox HOME copy), 40
  unchanged /api/sessions polls: 3.54 s CPU sampled on the base
  binary, 2.28 s with this; getattrlistbulk gone from the top.
  What is left is GC and os.Stat in claudeFiles.
- Same account: an event with a new timestamp appended to the newest
  rollout changes the sessions tag on the next poll, as on the base.

Not tried: Linux and Windows (no change there); a rollout held open by
a real running Codex for more than 15 min without a prompt.
2026-11-12 01:45:17 +08:00
yetone a6d84e13a9 agent: Claude Desktop can use this computer's LAN HTTPS address for SSH remote sessions (zyc-bit on X, #4546)
Desktop's built-in SSH remote sessions hand the profile's gateway address
and key to the remote host. magpie wrote 127.0.0.1 and this computer's own
key there, so the host refused it (provider_loopback; a non-loopback address
must be https), the gateway turned the key away from another machine, and
3p mode's sshHostAllowlist (empty) allowed no host.

Desktop's row gets a "gateway" picker, drawn only while LAN sharing is on
and an address of this computer is https (gateway.LANURLs: HTTPS on, or
MAGPIE_PUBLIC_URL): "This computer" (default, loopback) or that address.
The pick is settings.DesktopGateway (carried by the settings save, kept by
KeepOwn). desktopOn / desktopCheck / desktopKeyApplied write and compare
desktopGateway() and the key at it (agentKeyAt: the sharing key). On a
non-loopback address sshHostAllowlist is seeded once with ["*"]
(desktopSeedOnce; the user may narrow it, never rewritten). The pick holds
only while it is still one of the https addresses; Agent.Gateway is
desktopGateway, so Rekey (after the sharing toggle, and now after the HTTPS
toggle) sets Desktop again, back to loopback when sharing goes off.
desktopIsOurGateway takes this computer's LAN addresses; realReachProbe no
longer verifies the certificate (magpie's CA is not trusted on this
computer), which read a LAN https address as unreachable.

Run (mica, sandbox HOME): go test ./internal/agent ./internal/settings
./internal/settingsapi ok; ./internal/gui ok except
TestPanelHiddenByWailsMarksPageOutOfSight, flaky the same on origin/main
fc615339f (#5322); go vet darwin, linux (nogui) and windows on the three
packages; gofmt clean. TestDesktopPointedAtLANHTTPS is red when desktopOn
writes loopback and when the key is not the sharing key. GUI
desktop-gateway-address.test.cjs 20/20 (chromium + webkit, en zh zh-TW ja
de, 1100 and 420px), red 20/20 with the field left in the "nothing to pick"
filter's absence; i18n-keys, desktop-*, click-scroll files.

Not tried: a real Desktop SSH session to a remote host, the remote host
trusting magpie's CA (it must, or use an imported certificate), the real
Claude Desktop app. Windows and Linux runs only vetted.
2026-11-12 01:28:03 +08:00
yetone fc615339f0 provider: Alibaba Cloud Token Plan quota read with the account's AccessKey; intl Token Plan preset (pppMathew on X, #2940)
Cause: a Token Plan sk-sp- key only authorizes inference. The plan's
usage sits on the Bailian console gateway, which wants a console token
(the key gets BailianGateway.Login.NotLogined) that Alibaba's own `bl` CLI
makes from the account's AccessKey through GenerateCLIAccessToken (ACS3
signed). magpie had no such path, so the usage card showed no quota.

Change:
- alibaba_usage.go: ACS3-HMAC-SHA256 signing, the console token (kept 20
  minutes per AccessKey and region, made again once on NotLogined), the
  personal plan's usage API, and per<N><Unit>Percentage/ResetTime read as
  5 hours / Weekly / Month windows. Hooked in as AccessKeyVendor "alibaba"
  (editor asks AccessKey ID and Secret, a keyless card says so),
  accountPlanOf (routing), PlanQuotas and the key card tag.
- Hosts: token-plan.cn-beijing.maas.aliyuncs.com (bailian-token-plan) and
  the new token-plan.ap-southeast-1.maas.aliyuncs.com preset
  alibaba-token-plan (Alibaba Cloud international Token Plan, #2940), also
  an OpenCode import target.
- Editor hint in zh, zh-TW, ja, de; docs (providers-accounts, reference).

Not covered: qwen-token-plan (Qwen AI platform) and qwencloud-token-plan
have no AccessKey route (browser-session console, #5829); team plans.

Run on mica at this tree: go test ./internal/gui ./internal/provider ok;
go vet darwin, linux nogui, windows on provider/gui clean; GUI files
i18n-keys, i18n-en-no-cjk, tencent-access-key, volc-access-key,
usage-access-key-card, tencent-cloud in chromium and webkit: 60 of 64 pass,
the 4 reds are tencent-cloud's "region clicked right after the strip
scrolled", red the same at origin/main 319753d89 (filed: #4321, #4399,
#4625). Broke it by hand: dropping the *100 on the percentage turns
TestAliReadWindows and TestAliPlanQuotas red.
Tests never reach the network (httptest behind a rewriting transport).

Not tried: no real Alibaba Cloud account, so neither the mint nor the
usage reply was seen live; the field names and the envelope come from the
official client's source. The international gateway host
(bailian-singapore-cs.alibabacloud.com) and the RAM-user case are the least
certain. The full suite was not run before the tag.
2026-11-12 01:20:52 +08:00
yetone 319753d892 gateway: a key can follow, force on or force off masking (y0ngb1n on X)
A gateway key now carries Redact: "" follows the global setting, "on"
masks that key's requests even when masking is off, "off" sends them as
written. Trusted devices turn it off, external ones are forced on.

- access: Key.Redact, CleanRedact and the redact-key action; an issued key
  inherits "on" from its issuer and can't turn it off; the default key
  takes the same values.
- gateway: maskingFor(ctx) decides per request; every route that masked
  (chat, native, text hits, the Masked-As header) asks it. A local request
  with no key keeps the global setting. masking.WithForced carries "on"
  into the masker; the redact plugin's InUse counts keys set on.
- CLI: magpie gateway keys redact <key> follow|on|off.
- GUI: key-row badge and an app menu; 7 strings in zh, zh-TW, ja, de.
- docs/subsystems/gateway-routing.md: the Redact paragraph.

Note: "on" with global masking off masks secrets and personal data by the
defaults. An off key is still masked on a Remote magpie hop, which sends no
Masked-As header.

Run (mote-run): go test for access, masking, redact, cli, gui and
plugins/redact packages and the new gateway key_redact tests; gofmt -l and
go vet on darwin, windows and linux nogui, all clean; the new GUI test.
Broken by hand: maskingFor returning the global value goes red in
key_redact_test.go.
Not tried: a real remote-to-remote hop with two keys; the full suite runs
after the tag.
2026-11-12 01:01:32 +08:00
yetone db58a88a83 gateway: a request masked by another build with the same settings is not masked again (Luxzinw on X)
Cause: X-Magpie-Masked-As carried this build's version and the other
magpie skipped its pass only on an exact match, so 0.1.3771 into 0.1.3638
(or any two builds) masked twice. Now the settings fingerprint must match
and the sender's build must be >= maskerSince (3584, the last masker
change), whichever build is newer; the header is passed on as it came
(it named the passing magpie's build, which never masked). Old-format
headers (v0.1.N/fp) parse the same.

Stand-ins: a user name's made-up name, public-ip- names and {{}}
placeholders are left alone by a process that has none of them in memory
(TestSecondProcessLeavesStandInsAlone). A made-up key looks like a key and
is masked again by such a process; the header skip covers that between
magpies with the same settings, not different ones.

Run (mote): go test -run 'MaskedBefore|RemoteMagpie' ./internal/gateway ok;
internal/redact SecondProcess ok. Broken by hand: maskerSince=999999 turns
the new tests red. Not tried: a real two-machine hop; full suite after tag.
2026-11-12 01:01:32 +08:00
yetone 60fde6fb1a library: an MCP server holds several accounts, one in use, switched in place (Elorynth on X)
A remote server can hold several OAuth sign-ins or several sets of
headers (Authorization keys), one in use, which every agent given the
server follows.

- mcpauth: a server's sign-ins are kept with the one in use at m[name]
  and the others in Spare (Use, RemoveAccount, StartAccount); the gateway
  sends the one in use from its next request on.
- library: Server.Accounts and Server.Account; `live` lays the account's
  headers over the server's own in through, remoteHeaders and hubKey, so a
  switch rewrites each agent's file. A save from the editor keeps them,
  and a backup or sync carries no account's key (carry.go). Add, use and
  remove calls, POST /api/library/mcp-account, and mcp-signin takes add
  and label.
- GUI: a server with one set of headers or one sign-in looks as before,
  with a quiet "+ Add account"; with several, a list with the one in use
  marked, a click to switch, an x to remove. Four languages.
- mcp_rename tests compare mcpauth.Record with reflect.DeepEqual now, as
  Spare makes it not comparable (the windows one too).

Run (mote, at this tree): go test ./internal/library ./internal/mcpauth/...
./internal/gui; go vet darwin, linux nogui, windows; mcp-accounts.test.cjs
in chromium and webkit, five languages, plus the existing mcp-* and
library-mcp-* and i18n GUI files. Broken by hand: live() returning the
server unchanged turns TestServerAccountsSwitchEveryAgent red; the use
click removed turns mcp-accounts red.
Not tried: a real OAuth server with two real accounts; an agent's upstream
Mcp-Session-Id is not reset by a switch.
2026-11-12 00:57:23 +08:00
yetone 2bb2011621 gui: env lines pasted into the Add sheet or a key box open a provider (WJaunita45604 on X)
Pasting `export ANTHROPIC_BASE_URL=... / export ANTHROPIC_AUTH_TOKEN=...`
(also set, setx, $env:, Docker ENV, .env lines, and a JSON object of them
such as Claude Code's settings.json env) into the Add sheet's search box
opens a custom provider: name from the URL's site (api.moonshot.cn ->
Moonshot), API from the variable names (ANTHROPIC_* Anthropic, OPENAI_*
OpenAI chat, GEMINI_* Gemini), key, model, and the site's icon through the
existing /api/icons/favicon (it is sent the URL and name only; the key stays
in the draft until Save). Pasted into a custom provider's key or Base URL it
fills the form, as a curl command already did (curlOf). A key that only
stands for one (sk-xxxx, $VAR) is left out with a note. A bare host without a
scheme is https; a name with no dot (the tweet's example-xxx) is no address.

The curl and env readers moved to assets/pasteread.js, loaded when the
Providers page first draws, because the core script budget had no room and
raising it moves nothing out.

Run (mote, origin/main 8bc46b407 base, rebased clean): new
provider-env-paste.test.cjs, 18 cases (envOf on six forms plus a two-API
text, non-env text; Add sheet and key-box paste in en/zh at 900 and 440px,
chromium and webkit): all pass. provider-curl-paste, i18n-keys,
i18n-en-no-cjk, TestCoreScriptBudget pass. Broken by hand: with the search
box paste handler returning early, 8 of 18 go red. Provider/add/editor/custom
GUI files (92 files, both engines): 12 reds, all in provider-picks-stay
(#4397), provider-typed (#4673) and reset-providers (new #6196), and
all 12 fail the same in a clean origin/main worktree.

Not tried: a real vendor account with this paste, the favicon fetch against
the live site (the test stubs it), the full Go suite, Linux WebKitGTK.
2026-11-12 00:43:45 +08:00
yetone 4b1f3eca4a usage: a ZCode call magpie routed is not counted again as a local session's (nori_tsukiji on X)
With ZCode on the same computer as magpie, the Usage page's local session
calls came out equal to the calls magpie had routed: each was counted twice.

Cause: a ZCode request names its session without the sess_ prefix ZCode's
database gives it (zcodeBareID; GatewayKeys, Titles and the Sessions list
already knew). The Usage page pairs a gateway record with a session file's
call by session, tokens and end time (matchedBlocks), and the calls read
from ZCode's database kept sess_<id> / sess_subagent_agent_<id>, so they
never shared a session with the gateway's records and were never paired.
Leaving out calls whose providerID is "magpie" (ocGatewayProvider) only
helps when ZCode writes that id beside a reply; with any other id the call
was listed twice.

Fix: readZCodeCalls gives each call the bare session id; zcode's call parse
version is 3, so cached shards are read again. Claude Code, Codex, Pi,
OpenCode, Kimi, dsh, grok, minimax, agy and WorkBuddy name their sessions as
their requests do (raft.go's requestIDs has ZCode alone); not changed.

Run on mote: go test ./internal/usage ./internal/sessions (ok; the zcode
fork test's expected session ids are now the bare ones), gui and cli with
-run 'ZCode|Zcode|Usage|Session' (ok), go vet darwin/linux/windows (clean),
gofmt -l clean. TestZCodeCallsPairWithTheGatewaysRecords (a session, a
provider id of ZCode's own, a subagent) was red on the old code: 4 rows for
2 routed calls, the local ones Session sess_7c1f against the gateway's 7c1f.
Not tried: a real ZCode database (this computer has none, only the app's
tasks index) and the full suite.
2026-11-12 00:42:50 +08:00
yetone 8bc46b407a gateway: tests that an overloaded Codex account fails over to the next, by every door (Coordinate_siwu on X)
Coordinate_siwu: two ChatGPT accounts of different emails, GPT answers
529, magpie asks again and fails instead of moving to the other account.

Could not reproduce. New tests hold two Codex accounts, acct-1 refusing
every ask and acct-2 serving, and the turn must reach acct-2: 529 (json,
empty, html, rate and usage words), 503 overloaded and plain, 500, 429
rate, 200 stream ending response.failed server_is_overloaded; by Codex's
POST and its WebSocket, /v1/chat/completions (stream and whole) and
/v1/messages; routing smart, order, rotate, drain; and a conversation
kept on the account that answered its first turn. All pass on main, so
no gateway change. Broken by hand (codexAccounts always relaying as it
came): 47 subtests red.

Run: go test -run 'TestCodexOverloaded|TestCodexKept|TestCodexSocketOverloaded'
./internal/gateway on mote, ok. Not tried: a real ChatGPT 529, the
reporter's own settings (Codex "only switch sign-in", the second account
switched off), WebKit/GUI (no GUI change).
2026-11-12 00:42:05 +08:00
yetone 12610cf2ff sessions: the Usage page's list leaves out sessions taken off the list of an uninstalled agent (_SekiBetu_ on X)
v0.1.3784 hid a forgotten session only on the Sessions manage page; /api/sessions
still listed it. ForgottenOut drops those rows (only while the agent's command
is gone, so Restore and a reinstall list them again), and the hidden list's
stamp is part of the poll's tag so a Delete shows on the next poll.

Run on mote: go test -count=1 ./internal/sessions ok; ./internal/gui fails only
TestCoreScriptBudget, red on clean origin/main too (#6189); go vet darwin and
windows ok; gofmt clean.
Broken by hand: ForgottenOut never hiding turned TestUninstalledAgentSessionsAreForgotten red.
Not tried: a real uninstalled OpenCode; the Usage page in a browser.
2026-11-12 00:25:56 +08:00
yetone 7e3e0fec4f gui: put agents back as they were when magpie quits, connect them again at start (tudjam17795 on X)
New Settings > General switch, "Put agents back when quitting" (zh: 退出时还原 Agent 配置),
default off. With it on, quitting the GUI app runs the same restore Disconnect does
for every agent magpie has connected (*.before-magpie files back byte for byte), and the
next start connects those agents again. Off keeps today's behaviour: a connected agent
keeps magpie as it quits.

- agent.RestoreOnQuit disconnects each wired agent that the user did not disconnect, then
  forgets the <id>.disconnected mark, so the quit leaves no mark; it stashes the list of ids.
  agent.RewireOnStart takes that list once and connects those still unwired and not
  disconnected since. An agent the user disconnected stays disconnected.
- gui: OnShutdown restores only when the setting is on and this process served the
  gateway; start re-wires in the background (not while the gateway is paused). A restore
  on quit also quits at once without the ask.
- settings.RestoreOnQuit, settingsapi key kept unless sent, row in index.html, i18n for
  zh, zh-TW, ja, de, docs in gui-shell.md and agent-wiring.md.
- app.js: the repeated Off/On settings rows go through one helper (segsOO), 422 bytes
  smaller overall, so TestCoreScriptBudget passes without raising the budget.

Run (sandbox HOME, mica because mote was loaded):
- go test internal/agent, internal/gui, internal/settings, internal/settingsapi, internal/cli
  at the rebased head: the new tests and the budget test pass.
- GUI, chromium and webkit, five languages, widths 1100 and 420: restore-on-quit (new),
  quit-ask-setting, quit-ask, settings-general, settings-sections, settings-places,
  i18n-keys, i18n-en-no-cjk, gui-de, gui-ja, gui-zh-tw, and for the rows moved to
  segsOO: reduce-motion, skeleton-bird, lightweight, keep-login, checkin-at,
  update-auto, update-hide, update-restart, update-download, tray-bird, tray-logos,
  tray-cost, wsl-agents-setting, login-allow. All 0 fail.
- gofmt -l clean; go vet darwin, windows, linux -tags nogui clean.

Broken by hand: not forgetting the disconnected mark turns
TestRestoreOnQuitAndRewireOnStart and TestRestoreOnQuitLeavesUserDisconnected red;
dropping the Disconnected() checks turns TestRestoreOnQuitLeavesUserDisconnected red;
dropping the setting gate turns TestRestoreAgentsOnQuit red.

Known reds, not from this change (same on the base 60559ee73): 20 GUI failures in
settings-hints, settings-lines-wrap and settings-search (#6133, #6107, #6156, #6073);
internal/gui TestPanelHiddenByWailsMarksPageOutOfSight killed under load (#6063);
internal/agent TestPiGroupEntryKeepsItsMembers on mica.

Not tried: real agent configs (sandbox HOME only), a real Wails quit on a Mac with real
accounts, Windows via win-run, the Linux WebKitGTK app.
2026-11-12 00:19:34 +08:00
yetone 7e8214d60a tests: four reds on main from 85e6ec540, 5a475f90c and 0706d7a35 (#6187, #4457)
- library: TestEveryAgentInLibrary. 85e6ec540 added the Paseo agent with
  no Library target; it is listed as "not looked at (#5897)" like the
  other new agents.
- provider: TestAddSameKeyOtherFormat pinned OpenCode Go's Chat at
  /zen/go/v1. 5a475f90c moved it to /inference/go/openai/v1, the endpoint
  Go's docs name, and didn't run the package.
- provider: TestQuotaSpanCarriesEveryWindowField. 0706d7a35 (#6160) put
  Lane on QuotaSpan; the test's full window now sets it too.
- provider: TestKeptQuotaReportAsksNobody (#6187). The same commit gives a
  ChatGPT card an image row from what the gateway remembers, so the kept
  report has two windows; the test takes the image row and still asks
  that nothing is read.

0706d7a35 ran -run of its own tests only.

Run (mica): all four red at origin/main fe20e4dbd; with this change
./internal/provider ok (125s) and ./internal/library ok (113s), -tags
nogui -count=1. gofmt clean.
2026-11-12 00:17:30 +08:00
yetone 7b9ae7cf9c agent tests: Pi's group entry counts the group look-ups, not the process's bytes (#6178)
TestPiGroupEntryKeepsItsMembers (efdca11be) compared runtime.MemStats
TotalAlloc across five polls, which counts every goroutine the earlier
tests left running. Alone it passed; in a full ./internal/agent run, with
~1,000 tests before it, it was red on macOS CI and on mote. A bisect on
mote found no single test behind it: the red needs tests from both halves
of a 128-test set, so it is cumulative, not one leak.

provider.GroupsFound counts how often GroupFinder found a group's
members, and the test asks that five kept polls found none.

Run (mica): -run TestPiGroupEntryKeepsItsMembers green; with agents.go's
old provider.GroupFinder() loop put back by hand it is red ("found the
group's members 5 times"); ./internal/agent whole ok (200s);
./internal/provider's only reds were the three on main (fixed in the
next commit). gofmt clean.
2026-11-12 00:17:23 +08:00
yetone fe20e4dbd8 sessions: an uninstalled agent's sessions can be deleted and are not offered Resume (_SekiBetu_ on X)
OpenCode (and Cline, Grok, Kimi, Hermes) keep sessions in their own
database, so magpie never deletes them and they stay listed after the
agent is uninstalled, with only Resume. When the agent's command is gone
from PATH, its rows now get Delete (Forget: hidden through the gateway
hidden list, a trash note marked forgot, the agent's files untouched,
Restore unhides) and no resume command. Installed agents are unchanged.

Run on mote: go test -count=1 ./internal/sessions ./internal/gui ok;
go vet darwin, windows, linux -tags nogui ok; gofmt clean; GUI files
sessions-forget (new, 5 languages x chromium+webkit), sessions-gateway-delete,
sessions-manage, sessions-folder-delete, sessions-purge, sessions-row-narrow,
i18n-keys, i18n-en-no-cjk all pass.
Broken by hand: removing the hidden-row filter turned the gui Go test red;
the old client.js turned sessions-forget red (5 of 5 chromium).
Not tried: a real uninstalled OpenCode on a user's machine; the Usage
page's /api/sessions list still shows a forgotten row (manage page only);
the whole GUI suite and full go suite run after the tag.
2026-11-12 00:09:56 +08:00
yetone 535f0dd95f gateway tests: reservations crossing a window skip total, which has no boundary (#6165)
ab5824aee added "total" to access.Periods. TestKeyLimitReservationsStayInTheirWindow
loops over every period and moves the clock past the window's end, but a
total window runs from Since (or the epoch) for 100 years, so a reservation
made before the "boundary" is still in the same window after it, and the
test went red on total/tokens and total/cost. ab5824aee's run record covers
internal/access, budget, cli and provider, not internal/gateway.

The total window's own reservations are held by internal/budget's
total_test.go.

Run (mote): the old file is red on total/tokens and total/cost, the fixed
file passes -run TestKeyLimit, and the whole ./internal/gateway package
is ok (1001s, -tags nogui -count=1 -timeout 45m). gofmt clean.
2026-11-12 00:09:38 +08:00
yetone af3334533d catalog: a Gemini models.dev doesn't list yet takes its generation's window (stockAAAAA on X)
gemini-4-carbon read no context window while gemini-4-argon had 1M:
models.dev lists a new Gemini a day after Google's lists name it, and
magpie's bundled copy (11-10) and a fresh cache lacked it. ContextOf now
ends on geminiKinWindow: the window every listed gemini-<N>-* agrees on,
none when they differ or for a point release (gemini-3.8-flash). Google's
model page (aistudio.google.com/docs/models) gives both 4 Argon and 4
Carbon 1M. Reaches every route that asks ContextOf: Antigravity and
Gemini API lists with no limit, Code Assist, Vertex, Copilot, relays.

Run (mote): go test ./internal/catalog ok; go vet darwin/linux/windows
ok; gofmt clean. Broken by hand: with the fallback returning 0 the new
test is red (carbon and nova read 0). Full ./internal/provider has 3 reds
(TestAddSameKeyOtherFormat, TestQuotaSpanCarriesEveryWindowField,
TestKeptQuotaReportAsksNobody) that fail identically with my change
stashed, on origin/main c43314792; not mine. Not tried: a real
Antigravity account listing carbon.
2026-11-12 00:01:06 +08:00
yetone d3aecfe958 test models: a plugin model its vendor queued answers OK, saying the queue (Mr7Faith on X)
Qoder personal_standard: qmodel_latest (shown as Qwen4-Max-Preview) and
dfmodel were queued (503 "queued the request for qmodel_latest (this
plan's queue: p4, 1 ahead); try again in 60s"). The test sends
X-Magpie-Fallback so the plugin says the queue at once, and the probe
counted that 503 a failure: red all day, and Working only unpicked the
models. The id in the error is the model's own id (the listing's display
name changed), not a mapping bug. A queued model is served and an agent's
turn waits it out, so the probe now sets OK with Result.Queued, which the
chip's title shows.

Run on mote: go test -run TestPluginModelTest ./internal/provider ok
(TestPluginModelTestSaysQueued now wants OK + Queued; build-red on the old
test.go); go vet darwin/linux/windows ./internal/provider; GUI
models-queued, model-test-one, i18n-keys in chromium and webkit ok;
models-queued red without the app.js line. models-works-only is red on
origin/main c43314792 too (#4391). Not run: full suite, real Qoder account.
2026-11-11 23:54:16 +08:00
yetone b52c711142 Restore what 85e6ec540 reverted: it was committed on a stale index and took out b587eb306's and earlier work (webview2, library skills, opencode endpoints, quotas); this puts the tree at b587eb306 plus the Paseo agent only 2026-11-11 23:09:15 +08:00
yetone 85e6ec5406 agent: Paseo's Claude model picker lists magpie's models (@TheMist016 on X)
Paseo (getpaseo/paseo) starts the same Claude Code, but builds its own model
list: first-party models plus settings.json's `model` and a few
ANTHROPIC_*_MODEL variables (providers/claude/models.ts). It never reads
Claude Code's modelPicker, where magpie writes every model, so the rest were
not selectable in Paseo. Paseo's own ~/.paseo/config.json takes
agents.providers.claude.additionalModels ([{id,label,description}], checked
against protocol/src/provider-config.ts) and passes each id to Claude Code as
written.

New agent "Paseo" (detected by ~/.paseo or PASEO_HOME): its switch writes the
models Claude Code's /model lists (same ids, [1m] marks, names; only the ones
picked for it) there, marked "via magpie" in the description; the user's own
entries and keys stay, off takes out only magpie's, a sync refreshes when on.
Claude Code must be connected to magpie as well.

Run (mote-run, sandbox HOME in tests): TestPaseoAdditionalModels,
TestStateListsPaseo, internal/agentenv, internal/gui full package ok;
internal/agent full run red only on TestPiGroupEntryKeepsItsMembers, which is
red the same on origin/main 12cd456f2 (passes alone; filed). gofmt clean,
vet darwin, windows and linux nogui on internal/agent. Broken by hand: Set
writing no models goes red.
Not tried: a real Paseo daemon reading the file (checked against its schema
source only); GUI browser suites.
2026-11-11 23:08:39 +08:00