Commit Graph
872 Commits
Author SHA1 Message Date
yetone 39569d5604 claude desktop: an optional Claude Magpie app beside your own Claude (#5671)
baranwang on X asked to keep Claude Desktop's own (1P, Anthropic) sign-in
while using magpie. Turning on "Separate app" in Claude Desktop's row on
the Agents page (or `magpie claude-desktop launcher add`) moves magpie's
3P wiring into ~/Library/Application Support/Claude-Magpie-3p and adds
~/Applications/Claude Magpie.app. That launcher opens Claude.app with
--user-data-dir on that folder, so it runs side by side with the user's
own Claude.app. Its icon is Claude's icon with a magpie badge. Off is the
default, and turning it off (`launcher remove`) moves the wiring back
and removes the app. It is macOS only: Desktop's packaged app strips
CLAUDE_USER_DATA_DIR, and on Windows it hardcodes LOCALAPPDATA\Claude-3p.
The folder ends in -3p because Desktop adds -3p to any other name.
Restarting the isolated app ends only its own process (pkill on its
--user-data-dir) and opens the launcher again.

Run at 1b25cda26 (this change on origin/main be9dbce02); rebased onto
fdabddeb4 (catalog only), then go build ./..., vet and the budget and
launcher tests again: ok. All
on mote:
- gofmt -l clean; go vet ./internal/...; GOOS=linux go vet -tags nogui
  and GOOS=windows go vet on agent, cli, desktopiso, desktopdir, gui.
- go test (whole packages) desktopiso, desktopdir, settings, settingsapi,
  proc: ok. -run Isolated|TestDesktopInstance|TestAddStartsDesktopOnTheFolder|
  TestScript|TestAddLeavesTheirs|ClaudeDesktop|Restart in agent;
  TestClaudeDesktopLauncher|TestEveryRouteHasACommandOrIsNamed|Help in cli;
  TestCoreScriptBudget|TestSettingsSaveKeepsWhatItDoesNotSend|Budget|Desktop
  in gui and gateway: ok.
- An earlier full `go test ./...` at fef23255f had four reds, all from
  this change and fixed here: the route without a command (now in
  notYet), settings_keep's DesktopIsolated, os/exec instead of proc, and
  the core script budget (paid by sharing the switch helper with the
  largest-window line and cutting comments; no raise). A second full run
  of the touched packages queued ~7h on mote's suite lock behind other
  sessions and was stopped; the targeted runs above replace it.
- GUI on mote, both engines: desktop-isolated (new; en, zh, zh-TW, ja,
  de; 1100 and 640; aria-checked, posts, status text, no scroll, no
  select, absent without `isolated`), desktop-longest, click-scroll,
  plain-names, i18n-keys: ok. page-width-steady, panel-fold and
  zero-priced-free are red, the same 33 tests at origin/main be9dbce02
  (diffed): #4541/#5013, #5796, #5262. i18n-keys' "a plugin's words are
  its own" is red on main too (#5332).
- Whole GUI suite on WSL at an older head: 400 of 22778 red across
  ~100 files of other pages, in line with #5559 (478 of 21666 on main
  there). Not rerun on mote.

Real use, on mote in a sandbox HOME with Claude.app 4.23118 linked in:
`claude-desktop magpie`, then `launcher add`, moved the wiring to
Claude-Magpie-3p (deploymentMode 3p, mcpServers and locale carried).
Opening Claude Magpie.app started Claude with
--user-data-dir=.../Claude-Magpie-3p; it wrote configLibrary and
model-catalog there (3P mode) and no -3p-3p folder. A second, 1P Claude
ran beside it on its own sandbox folder. Opening the launcher again
kept one instance; the pkill pattern matched only the isolated pid; both
quit on SIGTERM. `launcher remove` put the wiring back and removed the
app.

Broken by hand: a folder without -3p (Desktop made -3p-3p), the
CLAUDE_USER_DATA_DIR env route (ignored by the packaged app), os/exec in
the quit (TestNoCommandBypassesProc red).

Not tried: a screenshot of the running app (screencapture fails over
ssh); a model request through a gateway from the isolated app; Windows
and Linux (not offered there). Known: the Dock shows Claude's own icon
for the running isolated app, and Chrome pairing is off in a moved
userData folder.
2026-11-09 22:31:16 +08:00
yetone 88b541a25c images: every pointer names Settings › Models › Images, where the page is
The image models moved under Settings › Models, but the Library's Magpie
Image sheet, the MCP server's instructions to agents, the gateway's
"no image model" errors, the video tool's text and the docs still sent
users to "Settings › Images", a tab that no longer exists (the scattered
settings audit after netube99 on X). Every user-facing string now names
Settings › Models › Images in en, zh, zh-TW, ja and de, as do the site's
Qwen docs (en, zh, ja), llms-full.txt, the subsystem pages and comments.

Run in the tree with this change and the rest of the audit's fixes
(mote, base cd0ba05c2):
- go vet ./internal/gui ./internal/gateway ./internal/agent
  ./internal/provider ./internal/settingsapi: ok
- go test -run 'Image|Draw|Video|Hidden|Group|Settings' ./internal/gui
  ./internal/gateway ./internal/settingsapi: ok; ./internal/imagemcp,
  ./internal/library, ./internal/catalog: ok
- GUI: i18n-keys, i18n-en-no-cjk, image-models-hide,
  library-browser-setup: pass in Chromium and WebKit
- gofmt -l: nothing
Not tried: a real agent reading the new MCP instructions (text only).
2026-11-09 21:51:53 +08:00
yetone dae104bfac capre: a length check, not an unrolled repeat, holds nine patterns
Go's regexp unrolls a bounded repeat into that many copies of its
class: [A-Za-z0-9.-]{0,254} (the session terminal's bundle id) was
89kB of program, kept from start to exit, and Codex's item-id refusal
`.{0,1000}?` 88kB. Measured one by one over magpie's 540 package-level
patterns (1.5MB in all), the nine largest bounded ones were ~440kB.

capre.MustCompile(expr, max) is the pattern with * or +, matching only
a string of max characters at most (rune count, so the (?i) Kelvin
sign and invalid bytes count as the regexp counted them). The nine:
settings' bundle id, library's name and agent id (now name@wsl:distro
cut in two), Anthropic tool names, the trace page's name and find,
access's MCP server, OpenClaw's profile and Codex's provider id. The
item-id refusal is a function: the tail within 1000 characters of a
head.

Run on mote (go1.26.8):
- go test ./internal/capre ./internal/access ./internal/settings
  ./internal/library ./internal/sessions ./internal/agent ./internal/gui
  . : ok; ./internal/gateway -run 'ItemID|Undeclared|ToolName|Refus': ok
- TestCappedMatchesBounded holds each old pattern against its new one
  over 14 units x 19 lengths (0..300, at each bound +-1); with the
  length check taken out it is red (1586 mismatches).
  TestItemIDRefusalAsTheRegexp holds the function against the old
  regexp at 998..1002 characters of x, é, 日, \xff, \n; with 1001 it is
  red. TestCappedIsSmall: 1304 bytes held, 49680 bounded.
- go vet native, GOOS=linux and GOOS=windows over the touched packages
  (gui natively: its Linux build needs cgo); gofmt -l clean.
- Real build, GODEBUG=inittrace=1: magpie's own inits allocate
  11.93MB -> 10.61MB.
- Idle on the real-account copy, 180s heap: regexp programs (sampled)
  4.54MB -> 3.01MB.

Not tried: the full ./... suite; the gateway package beyond the run
above.
2026-11-09 21:47:24 +08:00
yetone fc8e98ba47 edit: Codex's thousands of [projects] tables are left out of the reads that don't want them (#2278)
Codex writes a [projects."…"] table for every project it is trusted in;
the owner's config.toml has 10,933 of them in 1.5 MB. go-toml's decoder
checks each table against its siblings one at a time, so every decode
of the file cost ~0.3s of CPU, and six readers decoded it again each
time Codex wrote it, plus a whole-file check before each write magpie
made to it.

- edit.TOMLWithout drops [projects…] tables in a single unstable.Parser
  pass. The agent's codexTopOf, sessions' readCodexConfig, provider's
  readCodexStoreSetting, library's rtk sandbox, hooks rekey and MCP
  entries read through it. None of them reads projects. A file that
  doesn't parse is passed through unchanged, so it still fails.
- validateTOML checks definitions with the rest of the file and the
  projects decoded apart, 128 projects to a decode. A bare [projects]
  table, a dotted projects.… key outside the tables, or any error
  decodes the whole file, so the error is the one it gives.

Run on mote (M5 Pro):
- BenchmarkCodexConfigDecode (10,933 projects): 283ms -> 7.6ms a decode.
- BenchmarkValidateCodexConfig: 52ms (the whole decode was 283ms).
- Startup CPU profile, first 70s, the real-account copy (the real
  1,524,099-byte config.toml): 2.76s -> 2.26s of samples; go-toml
  0.32s -> none sampled.
- go test ./internal/edit ./internal/sessions ./internal/provider
  ./internal/library ./internal/agent: all ok.
- go vet of the same five on darwin, GOOS=linux and GOOS=windows; gofmt -l clean.

Broken by hand:
- Decoding the batches into struct{} instead of a map:
  TestValidateTOMLDefinitionsInGroups went red ("a key twice", "a
  subtable then its key"), so the check keeps maps.

Not tried:
- the whole suite. Only the five packages that read the file were run.
- Now that projects is left out, a project table defined twice no longer
  fails these readers' decode. Codex itself refuses such a file.
2026-11-09 19:07:06 +08:00
yetone 2b22425b45 agent: Claude Science in a WSL distro is found and run on magpie from Windows
shuitunlulu_ (Discord) has Claude Science in WSL2, and Windows magpie
didn't find it. It is now a WSL twin (claude-science@wsl:<distro>), found
by the probe's claude-science (~/.local/bin or PATH). Its daemon is
restarted there through wsl.exe with ANTHROPIC_BASE_URL set, the same steps
as this machine's (claudescience.go is now one scienceHost for here and for
each distro), and v0.1.3334's keeper puts it back on magpie in each running
distro that has a note (claude-science-wsl-<distro>.json). With no note,
nothing runs in WSL.

The daemon takes http only to a loopback address and sends its Claude
sign-in as the key. In mirrored networking it gets the gateway's address.
Under NAT magpie starts a relay in the distro: socat on
127.0.0.1:<gateway port> to Windows' WSL address. The daemon gets
http://127.0.0.1:<port>/<WSL key>; the gateway's lanGuard takes the key
off the path (takeWSLPathKey) before fromWSL judges it. Connect says so
when the distro has no socat. Disconnect stops the relay with the
connections it forked, as one process group. When Windows' firewall keeps
WSL out, the row shows the same firewall drift and rule as other WSL
agents.

Run:
- gofmt -l clean
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows (mote)
- go test ./internal/agent ./internal/gateway on mote (macOS)
- go test ./internal/agent on xiaomi-gpu (Windows 11): 26 FAIL; 25 fail
  the same at origin/main c7ebb6f8d on that box (#4115, #5019, #3700,
  #5344, #2808, #4785, #2958, #1827, #4786). The 26th,
  TestHermesProfilesFollowMagpieModel, passed 5/5 alone on both and
  failed only in the whole-package run (#4115, #2540). Every
  ClaudeScience test passed there.
- At the pushed head (rebased on 9dd7aabca, which changes neither
  package): go vet darwin + windows and -run 'ClaudeScience|WSL' of agent
  and gateway ok on mote.
- Full suite, -timeout 45m: not finished at push. It waits on the lock
  behind other sessions' runs on mote and on magpie-desktop; the
  packages it changes (agent, gateway) were run above.
- Real run against magpie-desktop (Ubuntu 24.04, NAT, claude-science
  0.1.72 in ~/.local/bin) from a Windows test binary, with a sandbox
  XDG_CONFIG_HOME and a stand-in gateway on 127.0.0.1 and 172.17.32.1:
  - Connect took about 10s, and /proc/<daemon>/environ had
    ANTHROPIC_BASE_URL=http://127.0.0.1:<port>/wsl-...
  - The relay outlived wsl.exe (setsid, its own SID).
  - With the firewall blocking the test binary, the row's drift named the
    firewall and the New-NetFirewallRule.
  - With a temporary allow rule for the test binary (removed afterwards),
    curl in WSL through the relay reached the stand-in with the key path,
    and no drift showed.
  - Daemon and relay were killed as a WSL restart would; one keeper pass
    brought both back.
  - Disconnect left no relay and no relay forks (a held curl fork
    included), and the daemon ran without the variable.

Broken by hand:
- relay := false: the NAT test went red six ways.
- Without lanGuard's takeWSLPathKey line: TestWSLKeyInPath got 403.
- Check's firewall branch off: TestClaudeScienceInWSLFirewall red.
- A plain kill of the relay pid left a fork connecting on the real distro;
  that is what led to the process-group kill.

Not tried:
- The real magpie GUI on Windows with this build.
- A daemon's own model request through the relay; only curl was sent.
- Bridged networking.
- A distro without socat; that path was run only in the fake.

Reported-by: shuitunlulu_ (Discord)
2026-11-09 17:46:13 +08:00
yetone 608c1543e8 gateway: a bare model name goes to the asking agent's own subscription first
freefcw on X: Codex, started by Mirasim, asked for gpt-6-astra by its bare
name. Its own ChatGPT subscription serves it, but magpie sent it to Devin
through the group it found (auto-gpt-6-astra, soonest renewal first).
With found groups off it still went to another vendor: Resolve takes the
first provider in the Providers order, AutoStandIn and agent.Reseat did
the same.

Now:
- A bare model id the asking agent's own subscription in magpie serves (a
  provider whose Account.Agent is the agent: Codex's ChatGPT accounts,
  Claude's for Claude Code, Copilot's) goes there, found groups on or off
  (gateway ownFirst, provider.OwnRoute). count_tokens counts it there too.
- Kept as they were: a group the user made or changed by that name; a found
  group magpie set one of the agent's fields to (agent.SetToGroup over the
  applied record, #750's bare spelling included, wired as
  gateway.SetToGroup); a gateway key held to some models; ids with a
  provider in them and group refs; clients magpie doesn't know as an agent.
- Found groups off: a bare id several providers serve, none of them the
  agent's own, is refused for an agent that has a subscription of its own
  in magpie, with a 400 naming the provider/model ids and
  "magpie group auto on" (provider.OffSpread). Off, magpie picks no vendor.
- AutoStandInFor and Reseat's sameModel prefer the agent's own
  subscription for a found group that is gone.

Docs: gateway-routing.md's Model resolution row and the bare-ids section.

Run (mote, at this tree on c7ebb6f8d):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/provider
  ./internal/agent ./internal/cli ./internal/gateway: all ok.

Broken by hand, each red:
- ownFirst off in serve (and AutoStandIn back):
  TestBareNameGoesToTheAgentsOwnSubscription went to the relay with groups
  on, and again with groups off alone (the reporter's two cases).
- OffSpread check off: TestBareNameOnSeveralVendorsRefusedWhileGroupsOff
  answered 200 from the relay.
- SetToGroup check off: TestBareNameOfAGroupSetOnTheAgentStaysTheGroups.
- The user's-group and own-entry checks off: TestOwnRoute, TestOffSpread.

Not run at this head: the full ./... suite (mote's suite.lock had five
suites queued); it runs under the lock after the push, any red filed.
Not tried: a real Codex with a real Devin plugin account; Reseat's own
preference has no test of its own (needs a fetched Codex account in the
agent package's sandbox).

Reported-by: freefcw (X)
2026-11-09 16:28:02 +08:00
yetone 77076eef47 agent: an npm update on Windows lets go of magpie's own claude and codex first
CLJY (Discord) had %APPDATA%\npm with only the 308-byte sh shim of claude:
no claude.cmd, no claude.ps1 and no codex at all, and `npm i -g
@anthropic-ai/claude-code` ended in "npm warn cleanup ... EPERM ...
unlink ...\.claude-code-<rand>\...\claude-code-win32-x64\claude.exe".
On Windows a running program's file can't be removed. npm moves the old
package aside, takes the old shims away, and stops partway when a
claude.exe of that package is still running; the sh shim is what is left.

magpie keeps such processes running itself:
- the Claude subscription bridge keeps up to 6 Claude Code runs waiting
  for their conversations' next turns, for up to an hour;
- Codex's app-server daemon has no idle exit, and magpie restarts it.
Its Update button ran npm with both still up.

- agent.UpdateCLI, on Windows through npm, bun or pnpm, first lets go of
  them: gateway.LetGoIdleClaudeCode ends every waiting run (its session
  shelved for the next turn, as a run let go past idleMost is) and returns
  once each has exited; provider.StopIdleCodexDaemon stops the daemon when
  no codex session is on it. Runs in a turn and sessions are left.
- An update on Windows that leaves the CLI's file gone fails, saying to
  quit it and reinstall, instead of "updated".
- proc's toolIn (FindTool) and codexExecutable no longer take the bare
  extensionless file on Windows, which CreateProcess can't run. Beside
  name.exe and name.cmd, the sh shim alone stands for the .exe it runs
  (Claude Code's bin\claude.exe), read from cmd-shim's exec line and kept
  inside its folder; a node shim (codex) or any other script is skipped.
  The testdata shims are cmd-shim 7's bytes, made with cmd-shim@7 on the
  Windows box.

Run at this head (rebased on origin/main; after the rebase, vet on all
three systems and the changed tests again: ok on Windows and macOS):
- gofmt -l internal/: clean. go vet of proc, agent, provider and gateway
  on macOS (mote), Windows (win-run) and Linux (wsl-run): ok.
- Windows (win-run): internal/proc ok;
  TestToolInNPMShShimAlone, TestLetGoIdleClaudeCodeFreesTheExe and the
  TestClaudeIdle* tests pass. internal/agent, internal/provider and
  internal/gateway (-run "Claude|LetGo|Codex") have Windows reds, and
  the same run at origin/main c9d253e4a has the same ones (26 in agent,
  15 in provider, 2 in gateway), except TestUsageReadAndReadAgain, a
  clock-tick flake filed as #4796.
- macOS (mote): internal/proc, internal/agent, internal/provider and
  internal/gateway (-run "Claude|LetGo|Codex") ok.
- Linux (wsl-run): internal/proc and internal/provider ok; internal/agent
  red only in TestGrokInstalled, red the same on origin/main c9d253e4a
  (3 of 3), filed as #3548.

Broken by hand:
- toolIn taking the bare name again: TestToolInNPMShShimAlone red on
  Windows (6 cases).
- letGoIdle not waiting for the trees: TestLetGoIdleClaudeCodeFreesTheExe
  red on Windows, and with that check off the removal fails with "Access
  is denied" - the user's EPERM.
- no let-go call and no gone check: TestUpdateCLIOnWindowsLetsGoFirst red;
  StopIdleCodexDaemon ignoring sessions: TestStopIdleCodexDaemon red.

Not tried: a real npm update of Claude Code or Codex on the Windows box
with magpie running; the Windows-only path is tested with
updateGOOS = "windows" on macOS, and the process lock with a copy of the
test binary.

Reported-by: CLJY (Discord)
2026-11-09 12:56:42 +08:00
yetone 1a37cc8516 agent: Antigravity CLI's thinking effort is picked in its row, and the gateway asks it of Gemini
xyenon on Discord: agy's effort can't be set for magpie's models. agy 1.5.3
has --effort for one session only, and turns it away for a custom model
(/effort says "not adjustable"); settings.json has no key for it (--settings
rejects every name tried as an unknown setting). Its requests ask
thinkingConfig {"includeThoughts":true,"thinkingBudget":-1}, the model's own
choice. So the pick lives in magpie, as the Antigravity app's and Cursor
Private Inference's do: agy's row gets an effort field
(provider.AgentEffort("agy")), shown while agy is on magpie's models, with
the levels the model lists. Nothing picked leaves agy's requests as today.

The gateway had no Gemini case in withFixedEffort, so a pick, a fixed member,
a rule's effort or a mapped level did nothing on a Gemini-wire request.
withGeminiEffort writes the thinkingConfig as the model takes it, from
vertexBudgets: a Gemini 2.5 gets a budget in its range (it refuses a level;
none is its least, or 0 for flash), a Gemini 3 a level from low to high
(minimal kept), a Gemini before 2.5 is left alone. includeThoughts is kept as
asked. The effort block and the needs-reasoning retry call it with the
upstream model (withModelEffort).

At a stopped WSL distro the field reads nothing (#3896), as
TestWSLColdPlaceOpensNothing asks.

Run on mote (mote-run), at the pushed head (rebased on 192d2eda8):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- go test ./internal/agent ./internal/gateway, whole packages: ok
  (gateway 943s) before the rebase; internal/agent again whole after the
  cold fix: ok. At the head: -run "Agy|WSLCold|AntigravityEffort" and
  -run "Agy|Effort": ok.
- GUI: agy-effort.test.cjs (new; window and panel, chromium and webkit,
  en zh zh-TW ja de) and cursor-local-effort: 54 pass, 0 fail.
  agent-field-names, agent-layout pass; i18n-keys' "a plugin's words are
  its own" is red as on main (#5332).

Broken by hand, each red then restored:
- withModelEffort returning the body as sent: TestAgyAgentEffort red
  (thinkingBudget -1 sent at high).
- agy's effort field taken out: TestAgyEffort red ("no effort field").
- 2.5's budgets taken from vertexBudgets: TestAgyAgentEffort and
  TestWithGeminiEffort red (thinkingLevel sent to gemini-2.5-flash).
- the field's cold check taken out (its first version):
  TestWSLColdPlaceOpensNothing red, stat of agy's settings.json.

Not tried: the full ./... suite (the suite lock on mote had ~10 runs queued,
some for 9h; agent and gateway were run whole instead); the real agy binary
against a sandbox gateway (TestAgyAgentEffort sends agy 1.5.3's captured
request body); a real Gemini API with a pick; a real stopped distro.

Reported-by: xyenon
2026-11-09 04:48:46 +08:00
yetone b1e8eb15a6 agent: the function agy in a POSIX profile is agy(), which dash reads
magpie put bash's `function agy {` in ~/.bashrc and ~/.zshrc (and a WSL
distro's). On fnOS ~/.profile reads ~/.bashrc, so sh -lc, which is dash
there, read it too and stopped at a syntax error; Codync's SSH probe
failed (ljlwlcz on X, v0.1.3336). Both POSIX bodies, agyFunction's and
agyDistroFunction's, now open with `agy() {`. The keyword was there so an
alias named agy isn't expanded where the function is defined; that guard
is now an `unalias agy 2>/dev/null || true` on the line before, since a
shell expands aliases a line at a time. Blocks already in a profile are
rewritten between their markers the next time magpie writes them.

Run (mote, macOS; wsl-run, Ubuntu 24.04 where /bin/sh is dash):
- TestAgyFunctionInEveryPOSIXShell (new): each POSIX body read after an
  alias agy by dash, sh, bash, zsh (mksh/busybox when present), then agy
  run: here falls through to the agy on PATH, the distro one passes the
  key, gateway and --model. Green on mote and in WSL.
- Broken by hand: with the old `function agy {` head it is red in dash
  (exit 2, both bodies); with `agy() {` and no unalias it is red in dash,
  sh (bash posix) and zsh.
- go test -timeout 45m ./internal/agent ./internal/update ./internal/cli:
  ok on mote. gofmt -l clean; go vet for darwin, linux, windows ok.
Not run: the full suite, a real fnOS box, Codync itself.
2026-11-09 00:19:51 +08:00
yetone f1a4b57511 agent: Claude Science goes back on magpie after its app starts its own daemon
shuitunlulu_ on Discord: after magpie connected Claude Science, it went
back off magpie. The daemon reads the gateway only from its environment's
ANTHROPIC_BASE_URL. The 0.1.72 app (Electron) attaches its window to a
daemon running; with none it starts its own (`serve --stdio
--adopt-install`, launch_context app-child) in its own environment, which
has no such variable. Its "let the app run it instead", and the offer it
makes once it updated past the daemon, stop magpie's daemon to do the
same. The keeper only started a daemon when none ran, so the app's stayed.

KeepClaudeScience now puts magpie's daemon back on the port the other was
on (stop, serve --detached with the variable) in three cases: a daemon
magpie didn't start, one started for the gateway's old address, or its
own older than the program installed (`--version`, asked again only when
the file changed). It does this only when status says no session runs
(active_frames and active_conversations 0; a status without them counts
as busy). It never touches one launchd or systemd keeps, and does it at
most three times an hour. It reads operon.lock every 10s and asks status
when the lock's pid changed or a minute went by.

Run:
- go test ./internal/agent (mote): ok 261s
- gofmt -l, go vet for darwin, linux and windows (mote): clean
- Real Claude Science 0.1.72 on mote, the keeper driven through a
  throwaway test (not committed) against the real claude-science:
  - App attached to a terminal daemon: status parsed (idle, terminal),
    the daemon was replaced on port 18481 and the new one has
    ANTHROPIC_BASE_URL. shell.log says "adopted daemon restarted
    (45446 → 89598) — following the successor", so the window carried on.
  - App opened with no daemon: it started its own (app-child, port 8000,
    no ANTHROPIC_BASE_URL in ps -E). The keeper replaced it on 8000 with
    the variable, and the app showed its "stopped from the command line"
    screen. Reopening the app attached it to magpie's daemon
    (ADOPT-RUNNING).
- Broken by hand, each red: no idle check (the busy and unknown-status
  cases), no retake cap, no version skew, no lock-pid trigger.

Not tried:
- The screen's "start it again in the app" button (read in main.js:
  runInvariant adopts the daemon running; reopening the app did the
  same).
- A daemon with a session running: one would need a Claude sign-in.
  The fake covers it.
- The Windows attach shell, and Linux.

Reported-by: shuitunlulu_
2026-11-08 22:30:07 +08:00
yetone d1f8d8aae7 agent: Cherry Studio adds magpie through its providers link (plugins#865)
Cherry Studio (CherryHQ) shows on the Agents page, and with
`magpie cherrystudio`, on macOS, Windows and Linux. Its row is the link
its main process takes, cherrystudio://providers/api-keys?v=1&data=, with
the gateway at <gw>/v1 as an OpenAI-compatible provider named magpie and
the named key agentKeyAt("cherrystudio"). Cherry Studio asks the user to
confirm it. magpie writes nothing into its store. "Added" is read
untouched from its 2.x database (Data/cherrystudio.sqlite, user_provider),
in the default userData and every one boot-config.json moved it to. A
database or boot-config that can't be read, or a 1.x userData (Local
Storage, no database), is unknown. The data is standard base64, because
Cherry Studio swaps raw + and / before parsing and back after. /api/open
lets that link through. aionui's database status is generalized into
dbStatus{has} so both apps share it. Icon: Cherry Studio's own logo, not
cherryin-color (a different product).

Run (mote, at this change on origin/main c66cdbea9; then rebased on
0f04dca6e and run again: vet of agent/gui/cli, Windows vet of agent/gui,
and the Cherry, AionUi, gateway-key and import-link tests, ok):
- gofmt -l clean; go vet ./internal/agent ./internal/gui ./internal/cli;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- go test -tags nogui -count=1 ./internal/agent ./internal/gui
  ./internal/cli: agent and cli ok; gui ok but TestCoreScriptBudget, red the
  same on a clean c66cdbea9 (#4526, 1533856 > 1533802)
- node --test import-row.test.cjs i18n-keys.test.cjs: import-row 20/20,
  chromium and webkit, en/zh/zh-TW/ja/de, and 420px wide; i18n-keys red
  only on "a plugin's words are its own", the same on clean c66cdbea9
  (#5332, #5426, #5482). No new strings.
- TestCherryStudioLinkParsedAs2_1_10 runs the link through 2.1.10's own
  parser (copied into testdata) and the renderer's zod checks, with
  gateways whose base64 spells + and /.
- Real try on mote (macOS 27.2, arm64): released Cherry Studio 2.1.10 in a
  sandbox HOME and --user-data-dir, with a sandbox magpie of this tree on
  127.0.0.1:3561 and a fake upstream. `magpie cherrystudio add` opened the
  dialog with base URL http://127.0.0.1:3561/v1 and the key
  magpie-cherrystudio. Add saved it, turned off as every Cherry provider
  is. `magpie cherrystudio` then said added, read while the app ran (WAL).
  Sync models listed fake/fake-1 from the gateway, and adding it turned
  the provider on. A chat got the fake upstream's reply, and magpie usage
  counted it as Cherry Studio's. A link sent while the first-run welcome
  page was up showed no dialog; after "set up later" it did.

Broken by hand, each red, then restored:
- URL-safe base64: TestCherryStudioLinkParsedAs2_1_10 (baseUrl decoded as
  /x~>/v1 and /xy\x7f?/v1)
- no closing quote/slash on the address match: TestCherryStudioHas
  (another port's provider counted)
- the /api/open prefix dropped: TestCherryStudioImportRow
- Cherry Studio dropped from /api/open's app case:
  TestImportLinkNothingOpens

Not tried: a real run on Windows or Linux (detection is unit tests
only); Cherry Studio 1.x, which reads as unknown; a real vendor upstream
(the try used a fake). Full suite not run at push.

Reported-by: mysterysqwq
2026-11-08 19:09:21 +08:00
yetone a210b3bd5f agents: a reply limit typed by hand into Pi or OpenCode is kept
sayagoodbyeplz on Discord set Pi's maxTokens for WorkBuddy's
deepseek-v4.1-flash to 128000 in models.json, and magpie's next sync
wrote models.dev's 384000 back. magpie writes its models block whole,
so a hand edit inside it was never kept.

output_kept.go records, in the stash, per file and model, every reply
limit magpie has wanted there (the last 8). A value in the file that is
none of them is the user's, and the next sync keeps it. Pi's
providers.magpie.models[].maxTokens and OpenCode's
provider.magpie.models.<id>.limit.output go through it. A Max output the
user sets in magpie (Model settings, Advanced, or `magpie model output`)
is still written over the hand edit, since that is their word in magpie.
With no record (a model new to the file, an unreadable stash) the value
is magpie's, as before. The record keeps every wanted value, not only
the last one written, because the same block is also built for Drift
and never written.

Other agents that write a reply limit are not covered yet: #5693.

Run (mote, at this tree):
- go test ./internal/agent/ (whole package): ok, again at the rebased
  head on a5c97cd83 (333s); on WSL, -tags nogui, the same run is ok but
  for TestGrokInstalled, red there from Windows binfmt interop (#3548)
- TestPiKeepsAMaxTokensTypedByHand, TestOpenCodeKeepsALimitOutputTypedByHand
  (new): models.dev's value is followed while nothing is typed, a hand
  128000 stays through syncs and a models.dev change, the user's magpie
  Max output wins, and taking it away gives models.dev's again
- go vet on darwin (mote), linux (-tags nogui) and windows (WSL)
- WSL magpie-desktop, -tags nogui: go test -run 'Output|Kept|Pi|OpenCode'
  ./internal/agent/: ok
Broken by hand: with the piOutputsKept and openCodeOutputsKept calls
taken out, both tests fail ("written over: 300000" / "384000").
Not tried: a real Pi or OpenCode session reading the kept value.
Full suite not run at push.

Reported-by: sayagoodbyeplz (Discord)
2026-11-08 19:05:37 +08:00
yetone cdf734757a agent: OpenMausBot gets magpie's models back, and a Restart for a list it hasn't read
maxleebeta (Discord #feedback, 11-08) picked Antigravity's models in
magpie, and OpenMausBot's model search didn't find them. magpie wrote them
correctly: a sandbox with an Antigravity sign-in lists
antigravity/gemini-3.8-flash[1m] and the others in config.json. OpenMausBot
loses them in three ways, each reproduced on the real app:

- it reads config.json once, at start, so a list magpie writes while it
  runs never reaches its picker;
- a change to any engine in its Settings writes back every engine as it
  held them since it started, so magpie's newer list is replaced by the
  old one;
- an edit of magpie's engine there (updateClaudeEndpoint) keeps only the
  model picked.

Nothing in magpie wrote the list again: a sync runs on a catalog change,
or when magpie starts.

- KeepOpenMausBotListed (gateway.WhileServing, every 30s) writes magpie's
  list again when the file lists other models (ombListStale). The model
  picked in OpenMausBot (ANTHROPIC_MODEL) and its other engines stay. It
  isn't a Check drift: that reads as unwired, and a port change rewires
  only agents without one.
- OpenMausBot gets a Restart on its Agents row (restartApps: OpenMausBot.app,
  OpenMausBot.exe; appReads: ombPart = gateway, first model, list, not the
  key), so one running on an older list is offered a reopen. Its own save
  of the same engine after it starts doesn't count.

The same gap in NewMax, LiveAgent, OpenPencil, OpenBot, Pencil and ZCode
is #5662.

Run (mote, at this tree rebased on origin/main 00198b26e; 06324e99e,
rebased onto since, changes comments and docs only):
- go test ./internal/agent ./internal/cli ./internal/claudecode . : ok
- go vet ./internal/agent ./internal/cli on darwin, GOOS=linux -tags
  nogui and GOOS=windows: ok; gofmt -l: clean
- TestOpenMausBotListWrittenAgain and TestOpenMausBotRestartOnMac, new
- Broken by hand: ombListStale always false turns
  TestOpenMausBotListWrittenAgain red (written back, edited there, the
  loop); dropping restartApps' entry turns TestOpenMausBotRestartOnMac
  and TestRestartAppsOnWindows red.
- Real OpenMausBot 0.1.145 on mote (the app's server under
  ELECTRON_RUN_AS_NODE, sandbox HOME and OMB_DATA_DIR, own port):
  /api/instances kept the start list after a model was added to the
  file; an icon PATCH on its other engine wrote the old list back over
  it; PATCH /api/instances/magpie/claude-endpoint left ["relay/gpt-5.5"].

Not tried: the full go test ./... (mote's suite.lock had six full runs
queued); the Restart on a real Windows OpenMausBot (OpenMausBot.exe is
electron-builder's default name, not seen on the box); magpie's own
keep loop against the real app (the tests cover the file it writes).

Reported-by: maxleebeta (Discord)
2026-11-08 10:55:49 +08:00
yetone 06324e99e8 automode: say that Claude Code may have no local check behind a gateway
chenxiang0010 saw "Auto mode can't check actions in this session ...
your requests go through 127.0.0.1:3425, which doesn't pass it
through". magpie's comments and the gateway-routing and agent-wiring
pages said that Claude Code, finding no safeguard_results, classifies
locally. Claude Code 2.1.312 to 2.1.316 (read from their bundles) turn
that local classifier off behind a non-Anthropic base URL when
Anthropic's per-account flag tengu_bright_dragonfly is "all"
(PA(), bbt(): auto_mode_side_calls_retired, localClassifierSwitchedOff).
A call with no server verdict then gets "No classifier runs for this
session", and each action the check would judge asks for approval.
2.1.314 adds the text for CLAUDE_CODE_AUTO_MODE_SERVER=0: "Claude Code
no longer has a check of its own to use instead".

So on a route only Anthropic doesn't answer (another vendor's model,
another subscription's Claude, a translated route, a relay that drops
the fields), auto mode has no check at all for such an account. magpie
can't answer one on Anthropic's behalf. The reviewed routes (Anthropic's
API, a relay passing the fields, the Claude subscription bridge) still
carry the beta, safeguards and safeguard_results as before. Comments and
docs only, no change in behaviour.

Not changed: answering 400 naming safeguards on an unreviewed route, as
Claude Code's gateway spec allows. It sets a refused latch for the
session, so a later /model to a reviewed Claude stays unchecked, while
the strip loses nothing.

Run: gofmt -l internal (clean); go vet -tags nogui ./internal/gateway
./internal/agent on mote (ok).
Not tried: a real Claude Code run, since the flag is Anthropic's per
account and the reporter's route is unknown.

Reported-by: chenxiang0010 (Discord)
2026-11-08 10:55:10 +08:00
yetone 30b7a17326 codex: a relay's dated or renamed GPT id keeps its xhigh, max and Ultra levels
Found while looking into maomao_00001's report on Discord: the Windows
Codex app offered no xhigh or Ultra for a relay's model. Their relay
(vip.aipro.love, ids from its public /api/pricing) names its 31 models
plainly, and every one already got its full levels in
magpie-models.json before this change and gets the same after it, so
this is not their fix. Exact ids (gpt-6.1-sol, openai/gpt-6.1-sol)
were fine; two spellings other relays use were not:

- OpenAI's dated snapshot id (gpt-6.1-sol-2026-09-29) was unknown to
  the catalog, so it got the low/medium/high fallback. borrowedEfforts
  now drops a dated suffix and takes the base model's levels.
- A relay's rename (codex-gpt-6.1-sol, "[A] gpt-6.1-sol", an id the
  user marked the same as gpt-6.1-sol) got the levels up to max but no
  Ultra, because OffersUltra matched exact ids only. It now matches
  through catalog.IsOneOf, the lookup ContextOf and EffortsOf use.

Only known models change: a dated id whose base is unknown
(model-x-2026-01-01) keeps low/medium/high, a dated Luna gets its own
levels without Ultra, and glm-5.3-flash keeps [low high max].

Not changed: a dashed-date id's window and price are still unknown,
because catalog.SameModel doesn't strip that date form (#5643).

Run:
- TestCodexCatalogRelaysKnownModelsLevels red on the old code (the
  dated Sol and Luna at [low medium high], three renames without
  ultra), green with the fix.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and builds on mote.
- go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/agent ./internal/codexcat on mote: all ok.
- The relay's 31 ids put through codex's Set with the real
  models.dev file (a probe, not committed): the same levels on
  origin/main and with this change.
- Full suite: not finished. My probe runs reused the suite's copy
  on mote, so it was stopped; it runs again after the push.

Refs: maomao_00001 (Discord)
2026-11-08 02:37:42 +08:00
yetoneandggbdpq 498d23b1d1 commandcode: providers.json entries carry a model's window and reply limit (#5567)
Command Code reads a model's context window and output limit from
providers.json alone: its parseModel2 takes raw.contextWindow (or
limit.context) and raw.maxOutput (or limit.output), its getContextLimit
falls through to its own 200K default when both miss, and its catalog
lookup keys on the bare vendor id, so "magpie/deepseek-v4.1-flash"
never matches the embedded "deepseek/deepseek-v4.1-flash" — and it
never interrogates the gateway's /v1/models. magpie's entry carried
only name, reasoning and reasoningEfforts, so a 1M-window model was
served to Command Code as a 200K one and compacted long before it had
to; the same model's dsh entry carried both numbers, per model.

ccProviderJSONAt now writes the pair the way piModelJSON does: the
window as m.Context when it is known, the reply limit as maxTokens(m)
when the model declares an output, under Command Code's own names,
contextWindow and maxOutput. A model with no output declared carries
no maxOutput.

Checked against Command Code's own bundle (command-code 1.74.1,
dist/cli.mjs): it reads contextWindow ?? limit.context and
maxOutput ?? limit.output for a providers.json model.

Run on mote at this tree: go test -tags nogui -run TestCommandCode
./internal/agent ok. TestCommandCodeModelLimits is red with main's
commandcode.go put back ("pro contextWindow <nil>, want 1048576"), and
red with the Output > 0 guard dropped ("flash carries maxOutput 0 with
no output declared"); green restored. gofmt -l clean.
Not tried: a real Command Code session against the gateway.

Reported-by: becausemadoka
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-07 21:21:27 +08:00
yetone 56f0956044 codex: switching Codex off gives a relay's table its own base_url back
Switching Codex off on the Agents page left a provider table of the
user's own (a relay, not CC Switch's) pointed at magpie's gateway, and
forgot the relay's URL for good. takeTables points such a table at
magpie while a Codex thread names it, and keeps its base_url in the
stash (codex.tables). bringOver then moves that thread onto magpie, so
by the Disconnect no thread names the table any more: giveTables asked
ccSwitchTables for the tables on magpie, which skips a table no thread
names, put nothing back, and dropped the stash. Codex was left on the
user's provider again, with that provider sending to 127.0.0.1:3425.
giveTables now reads each stashed table as it is and puts the URL back
where it still says magpie's; one the user changed since stays.

The report ("all of Codex's configuration was reset to defaults" after
the switch and a Codex restart) is not reproduced as such: every other
line of a full config.toml survives the Disconnect, an edit made while
connected too, in each auth and provider case. The new test is the
guard for all of it. TestCodexOffKeepsAppsOwnConfig guards the other
writer the switch sets off (agent.Rewired starts the library's Sync,
which gives Codex its MCP servers one way on magpie and another off it):
what the Codex app writes for its browser, Chrome and computer use
(plugins, marketplaces, node_repl with its env table and env_vars, a
server kept off, shell_environment_policy.set, [desktop]) stays through
on and off, node_repl imported into the library or not. It passed on the
old code too.

Run (mote, then the Linux box once mote's disk filled up): go test -run TestCodexOffKeepsUsersConfig ./internal/agent
(10 subtests: ChatGPT, API key, no auth, relay, relay + ChatGPT, each
with and without an edit while connected), go test -run Codex
./internal/agent ok 37s, go vet for darwin, linux and windows; on Linux (wsl-run) go test -run
'TestCodexOffKeepsAppsOwnConfig|TestRunCodexEntry|TestRunDirectServerIsCodexsCommand'
./internal/library and TestCodexOffKeepsUsersConfig ok, go vet for all
three systems of internal/agent and internal/library. The
config.toml each subtest leaves was loaded by the real Codex CLI
0.164.0-alpha.11.1 (codex mcp list, sandbox CODEX_HOME): all ten load
and list the user's MCP servers.
Broken by hand: the old giveTables back, the four relay subtests go red
with "lost base_url = https://relay.example.com/v1".
Not tried: the Codex app (ChatGPT.app) itself switched off and
restarted; the reporter's own config, version and OS (not known).

Reported-by: darwish4021 (Discord)
2026-11-07 20:57:30 +08:00
yetone 21a89fa4e8 liveagent: a model or provider of magpie's deleted in LiveAgent stays out
zero2sin on Discord: every LiveAgent restart brought back magpie's three
providers as magpie wrote them (one Anthropic model, two OpenAI providers
of twenty or thirty models each) over what they had edited in LiveAgent.
LiveAgent's developer pointed at magpie, rightly: SyncCatalog runs at
magpie's start and on every catalog change, and LiveAgent's Sync wrote
every model of magpie's into magpie, magpie-responses and
magpie-anthropic each time. A model the user deleted, or a whole provider
of magpie's, came back on the next sync, and LiveAgent read it at its
next start. TestLiveAgentProvider even asserted that a model missing from
the file is put back.

magpie now remembers, per config.json, which of its models and providers
LiveAgent has had (liveAgentKept, in the stash). One gone from the file
since is the user's: it stays out until they put it back in LiveAgent, or
turn magpie off and on for LiveAgent. A model new to magpie's list is still
added, once. A provider of magpie's whose models the user all deleted is
left as they have it. The user's own providers were never touched and
still aren't.

LiveAgent's backend writes back what it holds on any settings change, so a
model magpie adds while LiveAgent runs is dropped by its next save without
the user doing anything. Such a model is held as pending under the
LiveAgent/k-brain pids then (liveAgentPIDs, pgrep): missing under the same
pids, or after LiveAgent quit, it is written again; once other pids run
(LiveAgent restarted and read it), it counts as had. Windows can't be asked
what runs, so there each counts as had at once.

Run (wsl-run, magpie-desktop; mote's disk is full, 553MB free): gofmt,
go vet ./internal/agent for linux, windows and darwin, go test
./internal/agent: every test passes but TestGrokInstalled, red on WSL2 at
main too (#3548, Windows binfmt interop takes the fake grok). On mote
before its disk filled: go test -run TestLiveAgent -v ./internal/agent,
all 10 pass.

New tests: TestLiveAgentKeepsWhatTheUserTookOut (the reporter's case:
magpie-anthropic and a Chat model deleted, a provider of their own added;
two syncs leave the file byte for byte; a new magpie model is added once;
a model put back stays; off then on gives everything back),
TestLiveAgentAddedWhileRunning, TestLiveAgentAddedThenQuit.
TestLiveAgentProvider now expects a deleted model to stay out and a model
new to magpie to be added on and last.

Broken by hand: take() returning want unchanged (the old behaviour) turns
TestLiveAgentProvider, TestLiveAgentKeepsWhatTheUserTookOut and
TestLiveAgentAddedWhileRunning red ("sync 0 undid the user's edits");
wrote() marking every added model as had turns
TestLiveAgentAddedWhileRunning and TestLiveAgentAddedThenQuit red.

Not tried: a real LiveAgent; the reporter's own config.json; a LiveAgent
that saves over a pending model and is restarted before any sync (reads
as the user deleting it, documented); baseUrl/apiKey/type edits on
magpie's providers are still magpie's and are written back.

Reported-by: zero2sin
2026-11-07 20:43:28 +08:00
yetone 4912e760da agent: TestDshLinuxDesktopEntry is skipped on a Windows host (#5617)
61394481c's entry test went red in Windows CI's "Windows dsh
configuration" step ("the AUR's entry, its program on PATH, not
found"). An entry's program is found the way the host finds one:
proc.LookPath (Windows wants a PATHEXT extension) or an absolute file
with an exec bit (Windows has none, and /home/... isn't absolute
there). The check runs only when linuxAppOS, runtime.GOOS, is linux,
so on Windows it never runs and there is nothing to test. The test
is skipped there with that reason. TestDshLinuxDesktopApp (the
folders) and TestDshLinuxDesktopAppProfile still run on Windows.

Run:
- win-run (xiaomi-gpu): go test -count=1 -run Dsh -v ./internal/agent/
  (covers CI's '^Test(Dsh|KeepDsh)'): ok; red at 61394481c before.
- mote: gofmt, go vet ./internal/agent/ and GOOS=windows, go test
  -count=1 ./internal/agent/.
- wsl-run: TestDshLinux -v: all three pass (the entry test not skipped).

Not tried: the CI run itself before pushing.

Fixes #5617
2026-11-07 20:38:57 +08:00
yetone 61394481c7 agent: DeepSeek Harness Desktop is found on Linux (AUR, .deb, AppImage entry)
xianhongtao (magpie 0.1.3232, Arch Linux) has DeepSeek Harness Desktop
from the AUR (deepseek-harness-desktop 0.2.2rc.1-1) and no dsh CLI.
magpie knew the app on macOS and Windows only, so it said "DeepSeek
Harness CLI not found ~/.dsh/profiles/web/cordis.patch.yml".

HasApp for dsh now also finds the Linux app (linuxApp, desktopapp_xdg.go):
- a folder holding the Electron executable deepseek-harness with
  resources/app.asar beside it: /usr/lib/deepseek-harness-desktop (the
  AUR's) or /opt/DeepSeek Harness (electron-builder's .deb/.rpm);
- or the app's desktop entry in the XDG data dirs (XDG_DATA_HOME first,
  then XDG_DATA_DIRS, the first file of a name wins, Hidden=true hides
  it): Name=DeepSeek Harness, Type Application, MimeType holding
  x-scheme-handler/dsh, and its Exec program there (on PATH, or an
  absolute executable file: an AppImage anywhere). Scans of a folder are
  kept by its mtime, trusted only when read over a second after it
  changed and for a minute at most.
Linux only; macOS and Windows keep their own checks.

Siblings: everything reading HasApp for dsh follows: the profile a fresh
~/.dsh gets (profiles/desktop), the desktop lead and notices, cliHeld and
CLIMissing (so the GUI's and the CLI's "CLI not found" go away). The
"running" check for noticeDsh2 also knows deepseek-harness, the app's
Linux executable. With both profiles present (the reporter's case) Path
stays profiles/web as on macOS; the desktop lead picks the model shown.

Run (mote, through mote-run):
- go test -count=1 -race -run 'TestDshLinux|TestDshDesktop|TestCodexLinux|Lody' ./internal/agent/: ok
- go test -count=1 ./internal/agent/ ./internal/gui/ ./internal/cli/: ok
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux/windows go build: ok
Run (wsl-run, magpie-desktop, Ubuntu 24.04): the TestDshLinux tests
-count=3: ok. The first WSL run caught a stale scan of a folder made
again within the same mtime tick; the 1s rule fixes it.

Broken by hand (mote), each red, then restored:
- installed() without onLinux: all three new tests red ("the AUR's app:
  app false, CLI missing true", "the AUR's entry, its program on PATH,
  not found", the profile = profiles/web, want profiles/desktop);
- no scheme check: "another app's entry taken for DeepSeek Harness's";
- no Hidden check: "an entry the user hid still counts".

Not tried: a real AUR, .deb or AppImage install of DeepSeek Harness
Desktop (the fixtures are the AUR PKGBUILD's entry and layout as the
reporter gave them, and AppImageLauncher's entry shape); the GUI suite
(no GUI file changed). The full suite runs after the push.

Reported-by: xianhongtao (Discord)
2026-11-07 19:48:49 +08:00
yetone e9bde2520d codex: OpenAI's threads follow Codex onto magpie from a provider of the user's, and a move the budget stopped asks for the next sync (Lice9735 on X)
Lice9735 on X, Windows, magpie 0.1.3233, Codex app 26.1104: an old chat
(10-13) answered "模型提供商不匹配 — 此聊天使用的是 OpenAI,但你当前
的提供商是 magpie。请切换至 OpenAI 以继续", only a new chat worked,
after d620ff6b5 and d2c29abe7. Their config.toml has a provider table
of their own, openai-http.

Cause. The banner is the app-server's modelProviderMismatch on
thread/resume (app 26.1103: providerBlock is set only from that error;
codex 0.167 load_for_resume compares the stored thread's provider, the
row for a paginated thread, the rollout's session_meta for a legacy
one, with config.toml's). With Codex on a provider of the user's at the
takeover, the stash's codex.provider is that provider, and bringOver
moved only its threads: OpenAI's stayed on openai by design ("whose
threads bringBack would hand them to"). The Codex app lists them and
refuses each one on magpie. A second gap on the same path: the
rewriting moves (MovePackedCodexThreads, MoveRecentCodexThreads) go
128 MB a sync, newest first, and the rest waited for a sync nothing
asked for, which can be hours away.

- bringOver, with Codex on a provider of the user's before magpie (not
  OpenAI, magpie or cc-switch-official, and no profile naming OpenAI),
  moves OpenAI's threads to magpie too: in place, a paginated one by its
  row, the last 30 days rewritten. They are recorded in codex.lent with
  that provider as To, as lendOwn records its own: the Disconnect gives
  every magpie thread to that provider (bringBack), where Codex resumes
  them, and giveLent gives these back to OpenAI once Codex is on OpenAI
  again. One the app holds open waits (codexThreadsLater on openai).
- MovePackedCodexThreads and MoveRecentCodexThreads say more when the
  budget stopped them with a thread left, and bringOver, bringBeside and
  lendOwn ask for the next sync at once (codexThreadsAgain). The three
  share one mover now (codexOnto); bringBeside also waits on a held
  thread as the other two do. packedBudget is a var, for the test.
- Tests: TestCodexOpenAIThreadsFollowMagpieFromOwnProvider (new: an
  openai-http table named "OpenAI", a plain and a packed OpenAI thread,
  moved, lent, to openai-http at the Disconnect, back to OpenAI after;
  none while a profile names openai), TestCodexThreadsLeftByTheBudgetAskAgain
  (new), TestMovePackedCodexThreads checks more. TestCodexThreadsFollowMagpieIn's
  two user-provider subtests now expect OpenAI's thread on magpie, then
  on that provider after the Disconnect.
- docs/subsystems/agent-wiring.md says so.

Run:
- Real codex-cli 0.166.0 on mote, sandbox HOME and CODEX_HOME, a fake
  Responses server: a thread started on the built-in openai (API key,
  openai_base_url), a second after switching to model_provider
  openai-http (name "OpenAI"); both paginated. On openai-http the first
  was refused ("This chat uses openai, but your current provider is
  openai-http"). A throwaway test (not committed) ran magpie's takeover
  (Set fake/m1, Sync) on a copy of that home: with origin/main's code
  the openai row stayed and `codex exec resume` on magpie (the copy's
  base URLs pointed at the fake) failed with exactly "This chat uses
  openai, but your current provider is magpie"
  (modelProviderMismatch); with this change the row was magpie,
  codex.lent {"to":"openai-http",...}, and the resume answered.
- New and changed tests red on origin/main 191f3c0af (the openai thread
  on "openai", want "magpie"; after the Disconnect "openai", want the
  user's provider).
- Broken by hand: bringOver's `if more` dropped ->
  TestCodexThreadsLeftByTheBudgetAskAgain red ("0 sync(s) asked for");
  `more = true` turned false -> TestMovePackedCodexThreads red.
- mote: gofmt -l clean; GOOS=windows go vet and GOOS=linux go vet
  -tags nogui of internal/agent and internal/sessions ok;
  go test ./internal/sessions ./internal/agent ok at this head
  (this change on e6cdeac9c; rebased after onto 5dbdfc1bd, which
  changes internal/provider only), agent 292.2s, sessions 47.4s. Pushed and tagged
  without waiting for the full `go test -timeout 45m ./...`, per the
  owner's rule to ship each verified fix at once; it runs on mote after
  another session's suite, and a red it shows is filed or fixed in a
  follow-up.
- win-run (xiaomi-gpu), go test ./internal/sessions ./internal/agent
  (at the commit's parent before a rebase onto abe7b0063, which touches
  neither package): every test this change adds or touches passes; 29
  reds, 28 of them red the same at origin/main 191f3c0af run alone
  there. The 29th, TestHermesProfilesFollowMagpieModel, passes alone
  3/3 on this tree and is in #4115.

Not tried: the Codex app itself (the CLI's app-server gives the same
error the app shows); Windows with a real Codex; a legacy (non-paginated)
thread with a real Codex, covered by the unit tests only; a history
over 128 MB with real files. The chat the app has loaded at the switch
goes on once the app lets it go: fully quit the Codex app and reopen it
after magpie updates.
2026-11-07 18:08:39 +08:00
yetone e6cdeac9c6 proc: with no WSL distro registered, or after wsl.exe asks to be updated, magpie starts no wsl.exe (TraderX219 on X)
TraderX219 on Windows: while magpie ran, a console window "WSL 必须更新到
最新版本……按任意键安装" came up every 20 to 30 seconds. magpie asked
wsl.exe for its distros (the running list retries every 30s after a
failure), and Windows' inbox wsl.exe answers each run on a computer
without a current WSL package by starting `wsl.exe --update --confirm
--prompt-before-exit` in a console of its own.

proc.Command, CommandContext and ProbeContext are where every wsl.exe
magpie runs is made (agent's wslRun/wslExec, wslrun, claudetui, the
library's rtk and MCP checks, the gateway's TUI helper), so both gates
sit in wslOff beside #1264's ErrWSLOff:

- The registry is read first (HKCU\...\CurrentVersion\Lxss, one subkey
  with a DistributionName per distro). With the key there or gone and no
  distro in it, wsl.exe isn't started: ErrNoWSLDistro. agent's wslList
  and wslrun's running list read that as "no distros", not as a failure
  or a hang, so nothing is retried every 30s. It is read at every start,
  so a distro installed later is seen at once. A read that fails is
  unknown: wsl.exe is asked as before.
- When a run's output (UTF-16LE or UTF-8, stdout and stderr) says WSL
  must be updated or installed, proc.WSLSaid writes settings' wsl-update
  mark (atomic, like wsl-hung) and no magpie process starts wsl.exe for
  6h: ErrWSLNeedsUpdate. The mark holds the WSL package version (HKLM
  Lxss\MSI Version) and the registered distros; a change to either
  clears it. A refused listing is unknown, so wsl.seen, WSLKept values
  and links are kept, never removed.

docs/subsystems/agent-wiring.md describes both.

Run:
- mote: gofmt -l (clean); go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...; go build for darwin, linux (nogui),
  windows: all ok.
- mote: go test -count=1 of internal/proc, agent, wslrun, library,
  sessions, claudetui at base 191f3c0af: all ok.
- mote, full suite through suite.lock (go test -count=1 -timeout 45m
  ./...) at base 191f3c0af: 88 packages ok, none failed.
- xiaomi-gpu (Windows 11, win-run): go test -count=1 ./internal/agent/...
  ./internal/proc/... ./internal/wslrun/...: proc and wslrun ok;
  agent has 25 reds, the same 25 by name on untouched origin/main
  191f3c0af. 24 were filed (#4115, #4786, #5068 and others);
  TestCodexOwnModelsFollowPicks wasn't, now #5605.
- xiaomi-gpu, read-only: TestWSLRegistryLive (MAGPIE_WSL_REGISTRY_LIVE=1)
  read the real Lxss key (magpie-fedora, Ubuntu, docker-desktop,
  magpie-3896, magpie-desktop; package 2.6.1.0) and ran `wsl.exe -l -q`
  (docker-desktop, magpie-fedora, Ubuntu, magpie-desktop): every listed
  distro is registered, so the gate never reads none while wsl.exe has
  some. magpie-3896 is registered in State 4 (uninstalling) and not
  listed, which only keeps wsl.exe being asked. No distro was stopped or
  changed.
- At the pushed head (rebased on f13d5f16f, which touches gateway and
  provider only), mote: go test of proc, wslrun, provider ok. agent's
  TestWSLMoreAgentsPick failed with "no space left on device" (mote's
  data volume was at 100%). Rerun: -count=3 -run 'TestWSLMoreAgents|WSL'
  ./internal/agent/ ok, and -run History ./internal/gateway/ ok. abe7b0063 (gateway) and
  e4fdf9ed3 (gui) landed after that run and were rebased onto unrun; they
  touch no file this change does.

Broken by hand, each red:
- registry check off: TestNoWSLDistroStartsNoWSL ("wsl.exe wasn't
  refused") and TestNoWSLDistroRunsNoWSL ("no distro registered read as
  wsl.exe failing").
- WSLSaid left out of agent's wslRun: TestWSLUpdateKeepsDistros ("wsl.exe
  -l -q was started: exit status 1").
- wslList's ErrNoWSLDistro as listed: TestNoWSLDistroRunsNoWSL.
- wslUpdateLately always false: TestWSLUpdateBacksOff ("wsl.exe run again
  after it asked for an update").

Not tried:
- The stub's window itself: xiaomi-gpu has a current WSL and distros, so
  it doesn't pop there. The fix wasn't run on the reporter's machine.
- The registry key missing (ErrNotExist) on a real Windows without WSL.
- The stub's real exit code and stdout: the update text is matched from
  the inbox wsl.exe's .mui strings (en, zh-CN) and the reporter's words.
- A wsl.exe that times out is not taken as asking for an update; the
  existing wsl-hung back-off still covers it.
2026-11-07 17:51:51 +08:00
yetone 32fc5809e1 agents: OpenMausBot gets magpie as an engine of its own, written as its own Claude endpoints are (a user on X)
A user on X asked for OpenMausBot (github.com/milind-soni/OpenMausBot,
read at 516ca75; released 0.1.145). Its bots run on engines from
`instances` in ~/.openmausbot/config.json ($OMB_DATA_DIR,
server/config.ts:713). Without this, a Claude bot reached magpie only
through ~/.claude/settings.json, and its picker listed Claude's static
models alone: OpenMausBot doesn't read the model from env
(readClaudeModelCatalog, claude.ts:296-316).

- openmausbot.go writes `instances.magpie` in the shape of OpenMausBot's
  own "Claude endpoint" (newClaudeEndpoint, claude-endpoints.ts:91-139):
  - driver claudeAgent, access custom
  - config.configDir is <data>/providers/magpie. Given that,
    OpenMausBot starts Claude Code with that CLAUDE_CONFIG_DIR and
    strips account keys the engine doesn't set (claudeEnvironment,
    claude.ts:111-136, 158-179), so the engine owns its routing.
  - requireApiKey
  - ANTHROPIC_BASE_URL, AUTH_TOKEN, API_KEY and MODEL point at the
    gateway
  - endpointModels holds magpie's models, kept to the ids
    CLAUDE_MODEL_ID accepts. One bad id makes OpenMausBot refuse the
    whole engine (claude.ts:636).
- A non-empty `instances` is the whole fleet (config.ts:1173). With
  none saved, magpie writes DEFAULT_FLEET (instance-fleets.ts) beside
  magpie, stashed as openmausbot.fleet. Off takes the fleet out again
  if the user hasn't changed it.
- What stays the user's: the engine's name, a model they picked from
  the list, their other env and an inherited `cli`.
- Check reports the base URL drifting away from the gateway.
- OpenMausBot reads config.json once at start (index.ts:780), and an
  engine edited in it writes back the fleet it holds
  (routes/instances.ts:132, config.ts:997-1012). So Set is refused
  while it runs (errOMBRunning), and the notice asks to quit it first,
  since Windows can't tell.
- ListOnly, ListsModels, OMB_DATA_DIR in agentenv. The icon is
  OpenMausBot's build/icon.svg (Apache-2.0).
- i18n in zh, zh-TW, ja and de. Docs: reference, agent-wiring, both
  READMEs.
- Codex bots use ~/.codex (codex.ts:373-386), which the Codex wiring
  already covers.
- The agent package's TestMain holds ombRunning false. An OpenMausBot
  open on the test machine refused every test that turns magpie on for
  each agent: my own sandbox OpenMausBot on mote turned
  TestSyncKeepsAnAddressOnAnotherMachine, TestListOnlyAgentsReadConnected
  and TestReverseProxyIsStillMagpie red. With a process named
  openmausbot running, they now pass. LiveAgent's, OpenPencil's and
  NewMax's running checks have the same hole and are left to #5587.

Run (all on mote):
- gofmt -l: clean
- go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows: ok
- go build for the same three targets: ok
- go test -tags nogui ./... -timeout 45m at e1453a168 (this change on
  origin/main 30ae0e3f9): 88 packages ok, none failed. Rebased after
  it onto e932cd258, which changes internal/library and adds one GUI
  test only. At the pushed head: go vet of internal/agent and
  internal/library, and go test of internal/agent, agentenv and
  appdir, all ok.
- GUI: the 71 files this change reaches, in chromium and webkit, every
  language they cover: agent-*, agents-*, i18n-*, icon-*, gui-de,
  gui-ja, gui-zh-tw, about-notices, deprecation-notice, header-relang,
  market-icon-corners. 1145 of 1146 pass. The one red is i18n-keys'
  "a plugin's words are its own" for plugins' "Use the library's",
  "No session ID" and "View routing", the same on main and filed
  (#5332, #5426, #5482). The whole GUI suite was started too and
  stopped at 369 ok, 0 failed: at ~5h on mote it runs after this push.

Real OpenMausBot: 0.1.145's arm64 app was run on mote, its own server
(ELECTRON_RUN_AS_NODE, Resources/server/index.js) with HOME and
OMB_DATA_DIR in a sandbox, on a free port, against a config.json
magpie's Set wrote. /api/instances listed 28 engines, among them
`magpie`: access custom, claudeEndpoint at http://127.0.0.1:3425, and
models relay/glm-4.6 and relay/gpt-5.5 in its picker, with the first as
default. It read "unavailable: `claude` CLI not found" only because the
sandbox PATH had no claude. The file was left as magpie wrote it.

Broken by hand:
- The fleet not written: TestOpenMausBotEngine red.
- The model-id filter taken out: TestOpenMausBotEngine and
  TestOpenMausBotKeepsTheUsers red ("relay/glm 4.6 (beta)"). Green
  before a bad id was added to the fixture, so one was added.

Not tried:
- A bot turn through Claude Code to a gateway. No claude CLI or
  account on mote.
- The desktop app's window, Linux and Windows builds.
- An OpenMausBot running while magpie writes. The refusal is
  unit-tested only.
2026-11-07 13:13:36 +08:00
yetone 5f01b9d052 agent tests: the WSL probe test has a timeout(1) where macOS has none (#5570)
TestWSLProbeLooksPastWindowsCommand runs the distro probe in the host's
/bin/sh, and the probe asks a command's version under `timeout 10`.
A distro has timeout (coreutils); macOS 26.2 has none (mote's macOS
27.2 has one), so the ver: line was "sh: timeout: command not found", no version,
and the test was red on every macos-latest run since it landed in
f9a88c4fb (42279775186, 42285312651, 42292490462, 42295916081), not
intermittently. The probe itself is right. The test now puts a stand-in
timeout on PATH when /usr/bin/timeout is missing, and its failure prints
the probe's output.

Run (mote, macOS 27): go test -count=3 -run TestWSLProbe ./internal/agent,
ok, with the injection below and the stand-in renamed to match.
Broken by hand: mote has /usr/bin/timeout, so the probe's `timeout 10`
was renamed `timeoutx 10` in the test: with no stand-in it is red as on
CI (Has bin:pi, Versions empty; out shows "timeoutx: command not
found"), green with the stand-in.
Not tried: a macos-latest (macOS 26) runner itself; this Mac is 26.2 and
has no /usr/bin/timeout, which is the cause.

Fixes #5570
2026-11-07 06:13:32 +08:00
yetone 49f207c784 agents: DS Bot, wired in the DSH home it runs on
DS Bot (github.com/Fei2411/DS-Bot, Apache-2.0, dsbot.app) is a DSH plugin
and an Electron app built on it. The app ships its own DSH (0.2.2-rc.1 in
0.3.0) and runs it with DSH_HOME at a data folder of its own, booting the
profile ds-bot, and never reads ~/.dsh: magpie's dsh row didn't reach it.

It is a row of its own now, ds-bot (dsbot.go), wired by dsh's code on its
folder (dshOn, split out of dshAt): magpie's routes and start in
profiles/ds-bot/cordis.patch.yml, the key in that folder's .env and
.credentials.yaml. The folder is $DS_BOT_HOME, else locations.json's
dataDir in the app's userData ($DS_BOT_SHELL_DATA, else <config>/DS Bot,
or the legacy DeepSeek Bot), else ~/.ds-bot, as the app's first-run.mjs and
legacy.mjs choose it. A locations.json that can't be read or names no
folder is unknown: nothing is read or written. The routes there list the
models shown for DS Bot on the Agents page (dshListFor), and the serving
round fills a profile the app makes there as it does ~/.dsh's
(dshHomesRounds). Found by DS Bot.app (io.github.fei2411.dsbot) or its
Windows per-user install (guid from its electron-builder.yml). Three
notices, translated into zh, zh-TW, ja and de. DS_BOT_HOME and
DS_BOT_SHELL_DATA are in agentenv's sandbox list.

Run:
- go test ./internal/agent/ ./internal/agentenv/ ./internal/gui/
  ./internal/cli/ ./internal/appdir/ on mote: ok but
  internal/gui TestMainWindowCorners/macOS_26_SDK, red on mote's macOS 27
  whatever the change (#3949).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... on mote: ok. gofmt -l: clean.
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang (chromium), and
  agent-notice-lang in webkit: all pass but i18n-keys "a plugin's words
  are its own", red on main for three plugin words (#5332, #5426, #5482).
- Real DS Bot 0.3.0 (DS-Bot-0.3.0-mac-arm64.zip) on mote, all in a sandbox
  HOME with DS_BOT_HOME, DS_BOT_SHELL_DATA and DS_BOT_WORKSPACE under it:
  a magpie built from this tree (nogui), MAGPIE_ADDR 127.0.0.1:3572, a
  fake OpenAI upstream on 3571 added as a provider. `magpie ds-bot
  magpie/fake/m1` before the app was ever opened wrote the profile; the
  app's first start kept it (agent-default-model still magpie's) and added
  its own files beside it. Its Chief Bot offered "Magpie: m1 · fake, m2 ·
  fake"; picking m1 and sending "ping" over CDP went through magpie to the
  fake (POST /v1/chat/completions model m1, stream) and "pong from fake"
  showed. `magpie ds-bot default` then took every magpie entry out and the
  .env with it. Only my own pids (app, serve, fake) were stopped.

Broken by hand, each red, then put back:
- dsbot's desktopApps entry out: TestDsBotWired (not detected).
- dshListFor always "dsh": TestDsBotOwnModels.
- dshHomesRounds without DS Bot's home: TestDsBotProfileMadeWhileServing.
- a bad locations.json taken for ~/.ds-bot: TestDsBotDataFolder.
On the old code the tests don't build (no ds-bot row at all).

Not tried: the Windows app (install path and registry guid read from its
electron-builder.yml, not from an installed copy); Linux (its AppImage and
deb aren't looked for; the data folder its first start makes finds it);
a real vendor behind magpie; a default Bot model set in DS Bot (the notice
says it wins, per its models.js). Not done: usage gives DS Bot no
User-Agent of its own (its DSH's requests likely count as dsh's), and the
Sessions page doesn't read its data folder's sessions.

Reported-by: rnhung
2026-11-07 05:43:04 +08:00
yetone 9ed0f1fa49 agents: Claude Code's prompt cache lifetime is picked in its settings
Linka (Discord) asked to set Claude Code's prompt cache TTL from magpie.
Until now only Usage › Context's "Tuned for you" card wrote it, and that
card offers nothing when the value is already the cheapest it found.

Claude Code's opened row and settings sheet now have two rows under its
own Long conversations: "Prompt cache · main conversation" and "Prompt
cache · subagents". Each opens the app menu with Claude Code's default,
5 min and 1 hour. They write the keys the card writes, promptCacheTtl and
subagentPromptCacheTtl in Claude Code's settings.json
(agent.ClaudeCacheSet, POST /api/settings/claude-cache). Default takes
the key out. A pick is the user's own: it forgets the card's stash, so
the card's Undo leaves it. A variable that comes before the setting
(FORCE_PROMPT_CACHING_5M, CLAUDE_CODE_PROMPT_CACHE_TTL,
CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL, in settings.json's env or
magpie's own) disables the row and names the variable, and the route
refuses it, so a value the user set by hand is never written over.

The names were checked in Claude Code 2.1.316's binary. Its resolver
checks FORCE_PROMPT_CACHING_5M, then the env var, then the setting
(enum "5m"/"1h"), then an agent's experimental.cacheTtl, then
ENABLE_PROMPT_CACHING_1H. With nothing set, the main conversation gets
1h on a subscription within its limits and subagents get 5m.

Run (mote, at this tree on 2ce44dc28):
- go test -count=1 -run 'TestClaudeCache|TestTune' ./internal/agent
  ./internal/gui: ok; go test ./internal/cli: ok (route parity).
- node --test claude-cache.test.cjs: 8/8 (Chromium and WebKit, en and
  zh, 900 and 420px), with agent-compact, i18n-*, gui-ja/zh-tw/de,
  old-webkit, agent-details-ready and context-tune: ok.
- Whole GUI suite on the Linux VM (wsl-run, concurrency 4), still
  running at commit: 74 files red there, mostly WebKitGTK. Of those
  only codex-memories-settings reaches Claude Code's settings: it
  counted Claude Code's rows as Long conversations alone, and now
  leaves out the two cache rows and checks they are there (18/18 on
  mote). desktop-subagent-model, account-eye, allow-ips and builtins
  pass alone on mote. codex-auto-reset (webkit de, #4790) and
  i18n-keys (#5327, #5332, #5426, #5482) fail the same way at
  origin/main f0620db63 on mote.
- go test ./internal/gui ./internal/agent ./internal/tune: agent and
  tune ok; gui red only in TestMainWindowCorners/macOS_26_SDK (#3949).
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ./...: ok.

Broken by hand:
- Without forget, TestClaudeCacheSet fails ("the pick is the user's,
  not the card's").
- Without the lock check, it fails ("set under
  CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL").
- With default leaving the key, TestClaudeCacheSet and
  TestClaudeCacheRoute fail.
- Without the rows in agentcompact.js, claude-cache.test.cjs fails 8/8.
  Without the same-pick check, it fails on the extra post.
- The first GUI run was red in WebKit at 420px: Playwright's own
  scroll to an off-screen button was taken as the page scrolling. The
  test now wheels the rows into sight as a reader does, and checks they
  came into view.

Not tried: a real Claude Code session reading the picked value (only
the settings.json it reads was checked); the live ~/.claude was never
touched.

Reported-by: Linka
2026-11-07 05:16:53 +08:00
yetone 0d70f335ec agent: the disconnect preview of a plugin's agent shows what it puts back, not nothing (plugins#799)
Purfeather found that disconnecting MiniMax Design (an agent a plugin adds)
showed the dialog's generic sentence: /api/agents/.../disconnect-preview
returned changes: []. The preview runs Disconnect in a process whose HOME
(and APPDATA, LOCALAPPDATA, XDG_*) is a temporary copy, but a plugin agent's
stash key is "plugin:<id>:" + the file's whole path, so the copied
stash.json named the file under the real home. The dry run found no stash,
read the agent as not on magpie, and changed nothing.

The same holds for every built-in whose stash key carries its file's path
(Droid, AtomCode, Cline, Qwen, Kimi, Zed, Hermes, Muse, Snow, ...): their
previews found the file wired but not what to put back, and showed magpie's
lines taken out instead of the user's model going back.

The fix is in one place, DisconnectPreview: after copying magpie's files it
rewrites the copy's stash so each key naming a path under home names it
under the copy's home (moveStashKeys/movedKey; a separator must follow
home, and Windows compares without case, since %APPDATA% can spell the
home folder otherwise). The real stash, its key format and the real
connect/disconnect are unchanged, so stashes users already have keep
working and nothing is migrated. A stash that is missing or doesn't parse
is left as it is.

Run at this head (30a0bfe88 + this commit; origin/main had not moved):
- mote: go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./...: clean. gofmt -l: nothing.
- mote: go test -tags nogui -timeout 45m ./...: 87 packages ok, exit 0
  (internal/agent 381s).
- xiaomi-gpu (Windows): go test -tags nogui -run
  'TestDisconnectPreview|TestMovedKey' ./internal/agent: ok, the four new
  tests PASS (the case-insensitive branch runs there only).
- mote GUI files that show the preview (agent-changes-before-now,
  agent-disconnect-preview, agent-leave-magpie, agent-own-direct,
  aside-native, mask-actions): Chromium 60/60, WebKit 34/34.

Broken by hand: with the key rewrite skipped, TestDisconnectPreviewOfAPluginAgent
fails with "the preview doesn't take magpie's entry out: []" (the
reporter's exact empty list), TestDisconnectPreviewOfAPluginAgentsModel
and TestDisconnectPreviewOfDroidPutsItsModelBack fail with no "~" line
putting the user's model back. Restored: all pass.

Not tried: a real MiniMax Design on Windows, or the GUI dialog against a
real magpie; the tests run the real preview path (this test binary as the
dry run's process) with the plugin's agent module as plugins#799 has it.
Paths stored in stash values (not keys) are not rewritten; none of the
values read in a disconnect hold a whole path.

Reported-by: Purfeather
2026-11-07 04:55:56 +08:00
yetone a9667daad5 codex: CC Switch's OpenAI mirror's threads follow OpenAI, and OpenAI's follow the mirror
Chris on Discord (the Codex app on a Mac): "Model provider mismatch.
This chat uses OpenAI, but your current provider is OpenAI. Switch to
OpenAI to continue." The Codex app names a provider by its table's
name. CC Switch's OpenAI mirror ([model_providers.custom], name
"OpenAI", requires_openai_auth, no base_url) is named OpenAI as the
built-in openai is, and Codex up to 0.167 resumes a thread only on the
provider id it is on now (app-server config_manager.rs load_for_resume
and check_thread_model_provider_for_input: ModelProviderMismatch;
0.168.0-alpha drops that check). magpie left the mirror out of every
thread move: bringBeside skipped it as the provider it took down,
lendOwn skipped it at the top, and bringOfficial took only
cc-switch-official. So a thread on the mirror stayed refused with Codex
on OpenAI beside magpie, and OpenAI's threads with Codex on the mirror.

Both are the ChatGPT account's threads, so they follow whichever of the
two Codex is on:
- bringOfficial moves every mirror table's threads to the provider
  Codex is on with magpie (openai or magpie), unless the mirror is at
  the top, a profile names it, or it is the provider magpie took down
  (stash codex.provider);
- bringBeside takes that one, recorded, and giveBeside gives its
  threads back at the Disconnect that puts the mirror back on top;
- lendOwn moves OpenAI's threads to a mirror at the top, and giveLent
  back once Codex is on OpenAI.
Existing threads: each sync moves them, "custom" in place (OpenAI's
length), a paginated one by its row, any age; others' ids the last 30
days with a copy kept, as before. Config.toml and the provider ids
magpie writes are unchanged.

Run: real codex 0.167.0 in a sandbox CODEX_HOME, `codex exec resume`
of a thread on custom with Codex on openai: "This chat uses custom, but
your current provider is openai" (modelProviderMismatch), resumed past
the check after the relabel to openai; the reverse (custom at the top,
thread on openai) refused the same way.
mote (go 1.26.8): go test -count=1 ./internal/agent/ ./internal/sessions/
ok (408s, 58s); go vet ./internal/agent/ native, GOOS=windows, GOOS=linux
ok; gofmt -l clean.
Broken by hand: the three old exclusions back, all three new tests red
(thread left on custom / on openai); bringOfficial without the stash
skip, TestCodexMirrorAtTopJoinsWithItsThreads red (the mirror's thread
left on openai after the Disconnect).
Not tried: the Codex desktop app itself (not on any test box), and
Chris's config.toml wasn't seen, so which way round his threads were is
inferred from the two ids that name "OpenAI". A thread on a mirror with
a profile naming it stays; after the Disconnect, OpenAI's own threads
stay on OpenAI as before.

Reported-by: Chris (Discord)
2026-11-07 03:00:10 +08:00
yetone f7cf17290c codex: the app's logs and sessions are read at each file's own time, not the Windows folder listing's
bitssly on X (tweet 2118722838249234609, v0.1.3177, Store Codex
26.1029.7803.0, app-server 0.166.0-alpha.6): when Codex's usage ran out
the Codex app flickered, showed "Hosted AppServerManager identity is not
ready" (fatal_error_broadcasted) and had to be quit and opened again,
four times in a day.

The page is the app's own bug after its app-server is ended (#4550), and
magpie ends it on purpose when it becomes Codex's provider for the
used-up account. 4f624241f reads the app's log for the page and reopens
the app, but on Windows it never saw it: codexLogFiles kept only files
whose fs.DirEntry Info() time was after the end, and on Windows that is
the folder listing's time, which NTFS brings up to date only as a handle
on the file is closed. The app keeps its day's log open, so the file the
page went to listed hours old and was skipped. On the Windows box the
Store app's own log listed 10:27Z (os.ReadDir and Get-ChildItem) while
the app wrote to it at 15:22Z (os.Lstat, File.GetLastWriteTimeUtc).

The same listing time judged Codex's session files, which the
app-server holds open: codexTurnOpen skipped a turn running in a thread
opened over 30 minutes before, and codexSessionsQuietFor counted such a
session quiet, so on Windows the app-server could be ended under a
running turn.

- agent/codex_app_crash.go: codexLogFiles reads os.Lstat per file.
- provider/codex_app_server.go: sessionFileInfo (os.Lstat) for
  codexTurnOpen and codexSessionsQuietFor; a file gone between the
  listing and the stat is skipped.
- The other readers that judge a file another program may hold open by
  its listing time (sessions, claude_out_soon, subscription_usage,
  claude_subscription's idle sweep) are #5549. magpie's first look after
  its own restart ending an app-server that already started under the
  takeover (one of bitssly's four pages came a minute after an
  auto-update) is #5550.

Run:
- Windows box (win-run), Store Codex 26.1029.7803.0 installed there:
  the two new tests red on the old code
  (TestCodexAppCrashedReadsAFileTheAppHoldsOpen: crashed false;
  TestCodexSessionHeldOpenReadAtItsOwnTime: "not open"), green with the
  change; go test -run 'TestCodexApp|TestCodexSession|TestCodexTurn'
  ./internal/agent ./internal/provider ok. A Go probe on the box read
  the live Store log at listing 15:22:00Z, own 15:32:02Z.
- Broken by hand on Windows: codexSessionsQuietFor back on e.Info()
  makes TestCodexSessionHeldOpenReadAtItsOwnTime red ("quiet"); the
  test checks quiet before the turn, since reading the file closes a
  handle and Windows then brings the listing up to date.
- mote at this head on origin/main 80ae904c2: go test ./... -count=1
  -timeout 45m: 86 packages ok, red only in internal/gui
  TestMainWindowCorners (#3949, open, AppKit on mote's macOS 27).
- Rebased onto origin/main f9a88c4fb (1fd0bb967 update, f9a88c4fb wsl
  touched agent and provider): at this head go test ./internal/agent
  ./internal/provider ./internal/netproxy ./internal/update
  ./internal/plugin ./internal/pii ok on mote, GOOS=windows go vet of
  agent and provider ok.
- go vet ./... (darwin), GOOS=windows go vet ./... ok; GOOS=linux go
  vet ./internal/agent ./internal/provider ok; gofmt -l clean.
- On macOS and Linux the listing already carries the file's own time,
  so the tests pass there on old and new code alike.

Not tried: a real used-up ChatGPT account reaching the page and magpie
reopening the Store app (the reopen itself is #4550's, unchanged).
2026-11-07 00:07:00 +08:00
yetone f9a88c4fbe wsl: a distro's Pi from fnm, mise or an npmrc prefix is found, past a Windows one on PATH
千里不再 on Discord: Pi installed in WSL wasn't detected. The WSL probe
runs `sh -lc`, which reads ~/.profile but not ~/.bashrc, where fnm's
installer puts its PATH, so `command -v pi` missed it and wslbin had no
fnm folder. A Pi not run yet has no ~/.pi either, so nothing found it
(and for fnm users who had run it, its version was lost). Also, WSL
appends Windows' PATH, so a Pi npm installed on Windows answered
`command -v pi` with a /mnt/c path; that stopped the `|| wslbin`
fallback and parseProbe then dropped it as a Windows command (#406), so
the distro's own Pi was hidden.

Now wslcmd takes `command -v` only when it isn't on a Windows drive
(/mnt/X or any drive /proc/mounts lists), else walks PATH past Windows
drives, else wslbin. wslbin gains the folders proc.UserBinDirs has here:
fnm (aliases/default, then the highest version; FNM_DIR,
~/.local/share/fnm, ~/.fnm), mise's installs (highest), ~/.npmrc's
prefix, ~/.npm/bin, cargo, deno, Homebrew. Every WSL kind goes through
it, not only Pi.

Run:
- mote: GOOS=windows/linux/darwin go vet ./internal/agent; go test
  -run "TestWSL|TestOmo|TestPi" ./internal/agent ok. gofmt -l clean.
- wsl-run (magpie-desktop, Ubuntu 24.04): same tests ok.
- Real WSL: in magpie-desktop, a scratch HOME with the real fnm
  installer, `fnm install 22`, `npm i -g @mariozechner/pi-coding-agent`
  (pi 0.73.1), never run. Old probe: no bin:pi. New probe:
  `bin:pi .../fnm/aliases/default/bin/pi`, `ver:pi 0.73.1`, pi@wsl
  listed; a fnm codex was found past a /mnt/c one. Real home still finds
  codex, pi and claude (3.9s). Through proc.CommandContext on Windows
  (win-run) with Detect agents in WSL on, the probe runs (#4872 gates
  only when it is off).

Broken by hand: origin/main's wsl.go with the new tests: all four
subtests of TestWSLProbeFindsNodeManagersBins and
TestWSLProbeLooksPastWindowsCommand red.

Not tried: the reporter's own install (method unknown; fnm with a
never-run Pi is the case reproduced). Asking bash -i for ~/.bashrc's
PATH was tried and dropped: under timeout(1) an interactive bash stops
itself (state T) on WSL and outlived its timeout.

Reported-by: 千里不再 (Discord)
2026-11-06 23:47:29 +08:00
yetoneandmdwsk88 dbaeaec124 claude-desktop: a model picked for two tiers is listed for the second too, so that tier isn't left empty (#5534)
Claude Desktop keys a profile's inferenceModels by name and reads one tier
off an entry: for each tier, the entry tagged with it (isFamilyDefault
first) names ANTHROPIC_DEFAULT_<TIER>_MODEL for the Code tab's Claude
Code (JNn/WNn in 4.16336's app.asar, FPn in 4.23118's). desktopTierOf
tags a model picked for two tiers with the first only, so the second had
no model. dawei picked copilot/claude-sonnet-5.5 for sonnet and haiku
(Copilot has no Haiku 5.5); Desktop spawned Claude Code with
ANTHROPIC_DEFAULT_HAIKU_MODEL empty, and its small tasks (WebFetch page
summaries) ran on the session's copilot/claude-opus-5.5 at 94-244 s each.

Now:
- desktopSharedTiers: each tier whose pick an earlier tier already has.
- DesktopInferenceModels lists such a model once more per later tier,
  after the rows (the first row, which a new session starts on, stays
  first), tagged with the tier and isFamilyDefault, with the row's 1M
  fields and its label plus " · <tier>".
- desktopTierAlias names it in the form claudeLooking gives the model
  under a number made of its id and the tier (magpie-<n>.anthropic.<model>,
  mythos-magpie-<n>, or anthropic/magpie-<n> for a model listed by its own
  id). aliased reads that number back to the model, so the gateway serves
  it as the pick (desktopTierAsked), and a session saved on it is still
  served after the picks change.
- desktopRunsAs (previous commit) gives it behavesAs where Claude Code
  doesn't know the id.
- agent: CLAUDE_CODE_MODEL_CAPABILITIES and the modelSettings budgets
  carry the extra ids too (gateway.DesktopTierAliases).
- docs/subsystems/gateway-routing.md and agent-wiring.md say so.

Not changed: /v1/models still tags one row per model (Desktop reads no
/v1/models while the list is written); the Providers page's Desktop
number is the first id's. Desktop's menu shows the extra entry
("Claude Sonnet 5.5 · Copilot · haiku"); the list has no hidden entries.

Ported from mdwsk88's desktop-tier-shared-pick (817edde09), reviewed line
by line. Added here: TestDesktopTierSharedPick's "every tier" (one model
for opus, sonnet, haiku and fable: three extra entries, every name
distinct, each tier tagged once, each id read back and its tool-less
small task served on the pick while the session is on another model)
and "own id" (a Claude model with no reasoning levels, listed by its own
id: the later tier is anthropic/magpie-<n> with behavesAs that model).

Run on mote (go1.26.8):
- TestDesktopTierSharedPick (4 subtests), TestDesktopGroupPickRunsAsItsModel,
  TestClaudeDesktopModelsSharedTier, TestClaudeCapabilitiesDesktopSharedTier:
  ok. Broken by hand, each red:
  - desktopSharedTiers looping over no tier (the old behaviour): all four
    subtests ("haiku has no entry"), and both agent tests;
  - aliased not reading a tier's number back: all four subtests
    ("magpie-2213721611.anthropic.claude-sonnet-5-5 read back as ...").
- go test -run 'Desktop|Claude|Alias|Tier' ./internal/gateway
  ./internal/agent: ok. go vet darwin, linux (-tags nogui), windows,
  go build ./...: ok. gofmt -l: nothing.
- Desktop's own code: the list this commit gives for opus m1, sonnet and
  haiku claude-sonnet-5-5, fable m1, run through JNn/WNn taken verbatim
  from Desktop 4.16336's app.asar in node: HAIKU =
  magpie-2213721611.anthropic.claude-sonnet-5-5, FABLE =
  mythos-magpie-7663130977, OPUS and SONNET as before. The same list
  without the extra entries (the old one): HAIKU and FABLE "".
Not tried: a real Claude Desktop reading the list and starting Claude
Code; the Playwright suites (no GUI file changed). The full suite runs
after the push.

Reported-by: dawei (Discord)
Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
2026-11-06 22:50:26 +08:00
yetone e1eeeed734 browser: the extension's key connects Magpie Browser and nothing else; own needs this computer; a key turned off closes its browser
483b131ef wrote a full-access gateway key ("Magpie Browser") into the
extension zip in Downloads. Anyone with a copy of the zip could use every
model, MCP server and stat, and, with own = key == OwnBrowserKey(), could
connect from another machine as this computer's own browser and receive
this computer's agents' browser calls (page data out, prompt injection
in). A keyed WebSocket also stayed open after its key was turned off.

- access: Key.Browser / Identity.Browser. A browser key is also ReadOnly
  (so a magpie from before reads it as read-only) and never issues keys.
  access-key and issuer-key refuse it. ScopeBrowser(id) holds an existing
  key to the browser with the same secret; the sharing key is never
  scoped. Current(who) says whether a key Check took is still on by the
  same secret (Identity carries the secret's SHA-256, set on the legacy
  sharing-key fallback too, so a legacy caller's identity is the same
  before and after its migration).
- gateway readOnlyGuard, the one place every route passes after the key
  is known: a browser key gets 403 gateway_key_browser_only on every
  pattern except GET /v1/magpie/browser/extension.
- own: the key must be OwnBrowserKey() and the request local(r)
  (loopback peer, not proxied, not the page port).
- browserConn keeps its key's identity. call() refuses a connection whose
  key is no longer Current, and a 5s watcher closes it (1008).
- gui browserKey: a new key is made Browser; the recorded key is reused
  only once ScopeBrowser holds it.
- GUI key row: "Browser only" tag (zh, zh-TW, ja, de), no access toggle.
  CLI prints "browser" access. agent gatewayTakes skips a browser key.

Old data: an existing "Magpie Browser" key (OwnBrowserKey) is rescoped in
place, same id and secret, when the gateway starts (ScopeOwnBrowserKey)
and again on the next extension download. Installed extensions keep
connecting with no reinstall. Every copy of an old zip loses models, MCP,
stats and writes, and from another machine it is no longer this
computer's browser. A user who downgrades reads the key as read-only.
Keys a user made themselves are untouched.

Regression, filed as #5529: Magpie in Docker with the host's Chrome
reaches the container from 172.17.0.1, not loopback, so its agents no
longer get the host's browser as their own. #5529 proposes pairing in
its place. docs/reference.md and site docker pages (en, zh, ja) say so.

Docs: docs/subsystems/gateway-routing.md (browser key), library.md
(Download), docs/reference.md (Docker), site/public/docs{,/zh,/ja}/docker.html.

Run on mote at origin/main 2000ae439 + this change:
- gofmt -l internal cmd: empty.
- go vet darwin, GOOS=windows, GOOS=linux -tags nogui over access,
  gateway, gui, agent, cli: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway
  ./internal/gui ./internal/access ./internal/library ./internal/agent
  ./internal/cli: all ok except access's
  TestLegacyLANFallbackBeforeMigration, red from this change (the legacy
  fallback had no secret sum). Fixed here, then ./internal/access in full:
  ok.
- GUI, 21 files (gateway-key-*, i18n-*, library-browser-*), chromium and
  webkit, every language: 332 of 334. The 2 reds fail the same on
  origin/main 6f5d48ea0 run alone: i18n-keys "a plugin's words are its
  own" (#5332, #5426, #5482) and gateway-key-models' 560px width check
  (#4081, commented).

Rebased onto 6f5d48ea0 (remote_prove: a new POST /v1/magpie/prove route
and edits to readonly.go and gateway.go, so not a -run rerun): gofmt -l
empty, vet on all three ok, go test -count=1 ./internal/gateway
./internal/access ok, ./internal/gui -run Browser ok. A browser key gets
403 on the prove route too (TestBrowserKeyEveryRoute walks every pattern).

Broken by hand, each red on mote:
- guard off: TestBrowserKeyEveryRoute (/v1/ 200, /v1/models read_only
  not browser_only).
- no migrate: TestBrowserKeyEveryRoute (/v1/models 200).
- own without local(r): TestOwnBrowserKeyIsThisComputers.
- no watcher: TestBrowserKeyOffClosesItsBrowser (stayed connected).
- no Current check in call(): TestBrowserKeyOffClosesItsBrowser.
- Current ignoring the secret: TestCurrent.
- gui reuse without ScopeBrowser / new key without Browser:
  TestBrowserExtensionDownload (both).

Not tried: a real Chrome with the real extension, a real Docker
container, a real old key in a live HOME, the TUI. No CLI test for the
"browser" access word. Tests reach no network (httptest, loopback only).
2026-11-06 22:11:02 +08:00
yetoneandvincent f4068ccc25 proc: with Detect agents in WSL off, no wsl.exe is started on any path (#4872)
With Settings' Detect agents in WSL off (noWSLAgents), every Claude
request still reached wsl.exe: wslReady (wslClaudeStandIn,
wslCodexStandIn) and wslClaudeClassifier listed the running distros
without asking wslLooks, the gate #1264 put on wslAgents, wslHomes and
WSLRunning. wslrun's Up, In and running weren't gated either (only
Find was). On a computer without WSL, Windows' inbox wsl.exe answers
each ask with a window offering to install WSL, one per request.

The fix is at the one choke point every command magpie starts goes
through (TestNoCommandBypassesProc): proc.Command and CommandContext
(and so ProbeContext, wslrun.Tool.Command/Probe, the Claude TUI
helper's ConPTY start, which checks cmd.Err) refuse wsl.exe by any
name or path (wsl, WSL.EXE, C:\Windows\System32\wsl.exe) with
proc.ErrWSLOff while the setting is off, as a probe of an app's own
program is refused. The paths that reach it: agent's wslRun/wslExec
(lists, probes, links, chmod, reach), wslrun.Run/Find/In/Up/Stop,
library's cmdvars, mcp_wsl, mcp_check and rtk_wsl, claudetui's
wslread, the gateway's Claude Code in WSL. The settings read is
settings.Shared() and only for a wsl name. Not gated: the Sessions
page's resume line for a WSL session (a string a terminal runs on the
user's click), whose sessions aren't listed with detection off.
skygunner/vincent's stand-in fix is kept as well, so the stand-in and
classifier return before taking wsl's lock or recording a failed list.

Run:
- mote-run: go vet ./internal/proc ./internal/agent ./internal/wslrun;
  GOOS=windows go vet of proc, agent, wslrun, claudetui, library,
  gateway; GOOS=linux go vet of proc, agent, wslrun, claudetui: clean.
  go test -count=1 ./internal/proc ./internal/wslrun ./internal/claudetui:
  ok; -run 'WSL|Wsl|Dsh' ./internal/agent ./internal/library
  ./internal/sessions: ok. gofmt -l: nothing.
- win-run on xiaomi-gpu (Windows 11, real wsl.exe present): the four new
  tests plus TestWSLDetectionOff, TestWSLClaudeStandIn,
  TestWSLCodexStandIn, TestNoCommandBypassesProc: ok; -v shows each new
  test PASS; go test ./internal/proc ./internal/wslrun whole: ok.
  TestWSLRunnerRefusedWhenOff runs agent's real wslRun there.

Broken by hand (wslOff's check made `if false && …`, agent/wsl.go at
origin/main, new tests kept), on mote: TestWSLOffStartsNoWSL red for
every name and maker, TestRunRefusedWhenOff "Run ran wsl.exe: exit
status 1", TestWSLRunnerRefusedWhenOff red, TestWSLStandInAsksNothing
WhenOff red with three "-l --running -q" asks.

Not tried: the reporter's own Windows without WSL (the install window
itself); the full suite runs after the push under the suite lock.

Reported-by: 陌离 (Discord)
Co-authored-by: vincent <vincent@users.noreply.github.com>
2026-11-06 21:28:24 +08:00
yetone 2000ae4398 antigravity: each model's window reaches the app through its catalog; the notice names what a gateway turns off (YujunT46308)
YujunT46308 on X: wired through magpie, Antigravity 2.29.0 showed a
200K window for every model, and after a restart it lost /boost,
/teamwork, /plugin and /generative_ui.

The window. The app's backend (Resources/bin/language_server) resolves
models from models.list, then models.listSource (a remote catalog,
fetched with the gateway key), then <url>/v1/models, then its built-in
catalog. From /v1/models it reads the id alone; a model its catalog
doesn't know gets its family's defaults, maxTokens 200000. No field of
the OpenAI list (context_window, context_length, max_input_tokens) is
read. magpie now points models.listSource at
<gateway>/v1/models?format=antigravity, which answers {"list": [...]}
in the app's own fields (modelId, displayName, maxTokens,
maxOutputTokens, supportsImages, supportsThinking) for the models the
key may use. A field magpie doesn't know is left out. The user's own
listSource is stashed with their gateway and put back; Sync adds the
catalog to a file wired before, at the gateway's current address.
The picker now shows magpie's names, so NoNames is off for it.

The Google features. Not fixable on this route: on a gateway the app
uses no Google sign-in and its backend calls neither cloud_code_endpoint
nor api_server_url (headless run below), and Google's docs say a gateway
and a Google Account can't be used at once. The experiments and
commands Google's servers turn on for a signed-in account are off while
it is on magpie. No key in settings.json keeps both. The notice shown on
connecting (GUI toast, CLI) now names what is lost and that turning it
off gives it back, in en, zh, zh-TW, ja, de.

Run (mote, at this head unless said):
- go test -tags nogui ./internal/agent ./internal/gateway -run Antigravity:
  ok. Broken by hand: the listSource writes taken out ->
  TestAntigravityGateway, TestAntigravityCatalogSource,
  TestAntigravitySyncAddsCatalog red; the ?format branch taken out ->
  TestAntigravityCatalog red.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build: ok.
- GUI (Chromium and WebKit): i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, about-notices, gui-de, gui-ja, gui-zh-tw,
  name-suffix-no-names at the pre-rebase tree (only i18n.js differs in
  the GUI): all pass except i18n-keys "a plugin's words are its own",
  red the same on origin/main 18a9a2d88 (#5332, #5426, #5482).
- Real: the real Antigravity 2.29.0 language_server, headless, in a
  sandbox HOME, against magpie built from this tree (sandbox HOME, port
  3600) with a fake OpenAI vendor whose model has a 1048576 window.
  `magpie antigravity magpie/up/big-ctx` wrote listSource; the backend
  logged "Resolving models from Tier 2 (Remote catalog listSource)",
  GetAvailableModels gave maxTokens 1048576, maxOutputTokens 65536 and
  the label "big-ctx · up". A streamed chat with the app's key and UA
  went through magpie. Turning it off left the file as it was ({}).
- Full go test -tags nogui -timeout 45m ./...: queued behind mote's
  suite lock at push time; its result is recorded after the push.

Not tried: the Antigravity GUI app itself (only its backend, headless),
and a chat sent from the app's own composer.
2026-11-06 21:21:34 +08:00
yetone 37c1bc043b agent: a group whose members all serve Responses, one best there, is asked on Responses
zyh6036 on X: several subscriptions that all serve the Responses API were
asked on Chat once they were put in a routing group. Pi, OmO, omp, StepCode,
droid, dsh, Hermes, Grok CLI and the live agents ask each model on the one
API catalog.Model.APIs names, and a group had Responses only when every
member's Native was Responses (allResponses, #1594). A relay that serves
Chat and Responses, best on Chat (no Base URL API given, not OpenAI's own
host), counts as Chat there, so one such member put the whole group on
Chat, and the gateway then translated Chat to Responses for the ChatGPT,
Copilot GPT or Responses-relay members. Found groups (auto-<slug>) hit this
without the user doing anything: a new relay that also lists gpt-5.5 moved
auto/gpt-5.5 from openai-responses to Chat (pi_api_test shows it).

provider.GroupAPI now gives Responses when one member is best on Responses
and every other takes a Responses request as it is (Responses among the
APIs it relays), or translates every request anyway (a Claude Code
subscription). So no member is translated that Chat would have relayed,
and the ones best on Responses are relayed, not translated from Chat. The
gateway already relays a /v1/responses request to each member that serves
it (usable), so nothing changes there.

Mixed groups: a member that Responses doesn't reach (a Chat-only key, a
Messages-only Claude) keeps the group on Chat, where that member is
relayed; picking Responses there would translate it on every turn. A
Messages-only group stays on Chat as before (#1594's reason: a Claude
member's thinking is known by its own model id, not the group's).

An agent plugin's connect is told a group's native_endpoints now
(provider.GroupEndpoints: the APIs every member relays), where it had
none. /v1/models still leaves them out for a group:
TestRemoteMagpieNativeAPI holds that a remote magpie sends a group's
request on in the client's API for the other side to pick per member.

No setting added: the group's API follows from its members.

Run (mote, through mote-run):
- go test ./... -timeout 45m at 65780f04f on 49c9491b7, under the shared
  lock: every package ok except three reds, all filed and not in this
  change's path: internal/gateway TestBurstTellsNoSpeed/
  responses_from_chat_burst (passes 3 of 3 alone; #2719, commented),
  internal/gui TestMainWindowCorners/macOS_26_SDK (#3949), internal/provider
  TestRenewLoginsKeepsClaudeReading (red alone too; #5481, on main).
- After rebasing on fcc0daa23: go test ./internal/agent ./internal/catalog,
  ./internal/provider -run 'TestGroupAPI|TestNative|Group',
  ./internal/gateway -run 'Group|RemoteMagpie'; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; gofmt -l
  empty.
- Broken by hand: GroupAPI put back to "every member best on Responses":
  TestGroupAPI red (one best there plus one serving it too; the same
  second), TestPiModelsAskedOnTheirNativeAPI red (group/subs, and
  auto/gpt-5.5 once a Chat-first relay serves gpt-5.5).
- New: TestGroupAPI (provider), TestGroupOfResponsesServersRelaysOnResponses
  (gateway: the Chat-first member is asked on /responses, relayed).

Not tried: the reporter's own providers (not known: which subscriptions,
which agent); a real Pi or dsh run against a real mixed-API group; the GUI
(unchanged).
2026-11-06 19:07:15 +08:00
yetone fcc0daa23e usage: Tuned for you tells Claude Code's cache here with no calls, and an hour of the user's has Use 5 min
linkaww (Discord, #help) set Claude Code's prompt cache to 1 hour from
Usage > Context > Tuned for you and asked how to go back to 5 minutes. On
the computer that sends its requests to a Remote magpie the card was
empty, so there was nothing to see or undo.

Cause: the card's rows came only from advice, which needs 50 calls read
from this computer's session files, or from a knob tune put in itself
(TuneKept, v0.1.3120). A Remote-magpie client with too few calls read
here, or a 1 hour it didn't put in through magpie (set on the other
computer's card and copied, set by hand, or stashed by a version before
3120), had no row. The setting itself is Claude Code's settings.json on
the computer where Claude Code runs (promptCacheTtl,
subagentPromptCacheTtl); a Remote magpie's requests read B's, not A's.

Now:
- agent.TuneCacheHere reads Claude Code's two cache lifetimes on this
  computer whoever set them: the main conversation's always, the
  subagents' when something sets it, nothing when there is no ~/.claude.
  adviseOf adds them to the kept knobs, so Claude Code's card shows with no
  calls at all, each row's Now saying 1 hour, 5 minutes or Default.
- A row with too few calls at 1 hour that magpie didn't put in has
  Use 5 minutes (tooltip: Replaces your 1 hour; Undo puts it back); after
  it, Undo gives the hour back from the stash. A variable that comes first
  (CLAUDE_CODE_PROMPT_CACHE_TTL, FORCE_PROMPT_CACHING_5M) still locks it.
- A row with too few calls no longer reads "Already the leanest".
- The three Use buttons share one helper, which pays for the new one:
  context.js is 82 bytes smaller, TestCoreScriptBudget's budget untouched.
No new strings.

Run (mote, via mote-run):
- go test ./internal/agent ./internal/gui -count=1: agent ok; gui's only
  reds are TestMainWindowCorners/macOS_26_SDK (#3949, macOS 27 on mote)
  and, before the helper, TestCoreScriptBudget (fixed as above); after:
  -run 'CoreScriptBudget|Tune' ok.
- context-tune.test.cjs in Chromium and WebKit, all five languages, 360
  and 1100 wide: 24 of 24 ok. i18n-keys: every test ok but "a plugin's
  words are its own", red on main for three strings in other files
  (#5332, #5426, #5482).
- gofmt -l clean; go vet darwin (touched packages), GOOS=linux -tags
  nogui ./... and GOOS=windows ./... ok; builds for all three ok.
Broken by hand:
- old internal/gui/tune.go: TestTuneTellsTheCacheHere red ("the user's
  own 1h, no calls: rows []") and TestTuneKeepsWhatItPutIn red.
- old context.js: the new GUI test red in both engines (Now read "—"
  where Default is expected).
Not tried: a real Remote magpie pair (two computers) with linkaww's
settings, and a real Claude Code session reading the 5m after the press;
the whole GUI suite ran after the push, not before (suite lock held).

Reported-by: linkaww (Discord)
2026-11-06 18:51:39 +08:00
yetone f9e6061b85 claude: claude-magpie runs Claude Code through magpie, a plain claude left on the user's account
baranwang on X (11-06): `claude` stays on the user's own Claude account,
`claude-magpie` goes through magpie, and nothing is switched back and
forth.

`claude-magpie` runs `magpie claude run [args…]`. That writes a settings
file of magpie's own, <config>/claude-launch/settings.json, connected as
Connect connects Claude Code (the gateway, its key, the shared LAN key when
sharing is on, the model, the tiers) and starts
`claude --settings <file> args…`. Claude Code puts a --settings file's env
and model over the user's settings.json, a claude.ai sign-in and the
shell's variables (tried on 2.1.318), so ~/.claude/settings.json is never
rewritten. ANTHROPIC_API_KEY and the cloud switches (Bedrock, Vertex…) are
blanked in the file, so neither the user's file nor the shell can take a
request past magpie. The file is the agent `claude#launch`, listed nowhere:
the Agents page, Check and Notice see only the user's file. It is set again
when the gateway moved or its key changed.

- /model in a claude-magpie session saves to the user's settings.json
  (Claude Code never writes a --settings file). After the session a magpie
  model picked there moves into the launch file, for the next claude-magpie,
  and the user's file gets its model back. A Claude alias (sonnet) stays.
- Claude Code's own one-time `opus` -> `opus[1m]` rewrite of the user's
  file (migration_opus_to_opus1m), which the launch file's 1M opus tier sets
  off, is undone the same way. Found in the end-to-end run below.
- claude runs as a child so that can happen: on Unix a stopped child stops
  magpie too (^Z, fg; proc.WaitFollowingStops reaps it with WUNTRACED, as
  cmd.Wait can't see a stop), and claude's exit code is magpie's. On Windows magpie
  ignores Ctrl+C while claude has it.
- The command: a launcher beside the `magpie` command. Settings › Command
  line (AddCLI) writes it; `magpie claude launcher [add|remove]` adds it for
  a command put there before. It is a `#!/bin/sh` exec of magpie's stable
  path, or on Windows a .cmd running "%~dp0magpie". A file by that name
  without "written by magpie" is never written over.
- Docs: agent-wiring.md, and the start page in en/zh/ja.

Run at this commit (rebased on origin/main 218b38c59):
- mote: gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build for darwin, linux (nogui), windows;
  go test ./... -timeout 45m: 85 packages ok; red only
  TestMainWindowCorners (#3949) and TestRenewLoginsKeepsClaudeReading
  (#5481), both red alone on origin/main b020ae102. The run before at
  f22a9ae61 also had proc's TestEveryStartedCommandIsWaited red on this
  change's own Wait4 loop, fixed here by moving it into proc.
- Windows (xiaomi-gpu): go test ./internal/update ./internal/cli: cli ok;
  update red only in TestPackagedByDpkg, red the same on origin/main
  f47390bf3, filed as #4603.
- Real Claude Code 2.1.318 in WSL (magpie-desktop), sandbox HOME, a built
  magpie (`serve` on its own port), a fake Anthropic upstream:
  - `magpie claude run -p "say hi"`: PONG, exit 0; upstream got
    claude-opus-4-6 with the provider's key. A user settings.json with its
    own ANTHROPIC_API_KEY and "model": "opus" kept both values.
  - Interactive in tmux under bash -i: `/model fakeco/glm-4.6` then /exit:
    the user's file is back on opus, the launch file on fakeco/glm-4.6.
    ^Z stops both magpie and claude (T), fg resumes both.
  - `magpie claude launcher add` wrote ~/bin/claude-magpie, and running it
    answered PONG.
- Real Claude Code 2.1.281 on Windows: claude-magpie.cmd beside a built
  magpie.exe, `claude-magpie --version` printed the version through
  `claude --settings <launch file>`, exit 0.

Broken by hand, each red: the blanks dropped; the launch dir override; the
stale-address check; ClaudeLaunchAfter returning early; the opus[1m]
rewrite check; WaitFollowingStops answering 0 for a signal; "$@" turned into $* in the launcher; the model mark check;
AddCLI's launcher loop; --settings dropped from the args; the restore call
dropped.

Not tried: macOS with a real Claude Code (the Unix path ran in WSL only);
Windows interactive (Ctrl+C, /model restore); a real Claude subscription or
API key upstream (a fake upstream only). Known limits: a session that ends
by a crash or kill skips the restore; managed settings (policy) outrank
--settings; magpie has to be running (claude-magpie warns when it isn't);
Claude Code itself reformats the user's settings.json when it runs its
opus migration, values kept.
2026-11-06 17:31:04 +08:00
yetone be5e8f29f1 dsh: its own models are the two it ships, deepseek-flash named DeepSeek-V4.1-Flash (Kylin_Cloud on X)
Kylin_Cloud (X, 11-06, v0.1.2606): DeepSeek Harness's direct models in
magpie listed deepseek-v4-flash, which dsh doesn't have, and showed
deepseek-flash as "DeepSeek-V41-Flash"; dsh's built-ins are only
DeepSeek-V4.1-Flash and DeepSeek-V4-Pro.

Cause: dshModels is a table copied by hand from dsh 0.1.5 (4091b9dfd),
not generated from models.dev and not a label prettifier. dsh's own
table is @deepseek-ai/dsh-llm-deepseek's DEFAULT_MODELS; packed from npm:
  0.1.0-rc.8, 0.1.2-rc.1  deepseek-v4-flash, deepseek-v4-pro (+ vision-exp)
  0.1.5-rc.3              deepseek-flash "DeepSeek-V41-Flash", v4-flash, v4-pro
  0.1.6-alpha.2..0.2.0    deepseek-flash "DeepSeek-V41-Flash", deepseek-v4-pro
  0.2.1-rc.5, 0.2.2-rc.1  deepseek-flash "DeepSeek-V4.1-Flash", deepseek-v4-pro
The installed dsh here (0.2.1-rc.2) has the same two. So "V41" was dsh's
own name from 0.1.5 to 0.2.0, kept after dsh renamed it, and
deepseek-v4-flash left dsh in 0.1.6 while magpie kept offering it.
No other code makes a label from "4.1": V41 is in dsh.go alone.

Now dshModels is dsh's two, named as dsh 0.2.1 on names them. The WSL
(stopped distro) picker reads the same table.

A profile already starting on deepseek-v4-flash: magpie reads it as it is
and doesn't rewrite settings.yaml or the patch list; it is no longer
offered in the list. Since dsh 0.1.6 dsh itself refuses it
(dsh-api-session-controller requireModel: "Select an available model
before sending a message.", it checks listModels, i.e. DEFAULT_MODELS),
so that start was already broken in dsh before this change; picking
either model in magpie or in dsh fixes it.

Siblings pinning the old three: internal/gui's TestAgentOwnModelsHidden
(red under the full suite with the new table, now dsh's two) and the GUI
fixture agent-models-own.test.cjs, which also had made-up labels.

Run (mote, rebased on origin/main f47390bf3):
- TestDshOwnModelsAreDshs: red on the old table (lists deepseek-v4-flash,
  "DeepSeek-V41-Flash"), and red again with only the label fixed (still
  lists deepseek-v4-flash); green with the change.
- go test ./internal/agent: ok.
- node --test agent-models-own.test.cjs (chromium + webkit, en/zh/de/ja,
  narrow and wide): 16/16 ok. i18n-keys: "a plugin's words are its own"
  red, the same three words already filed (#5327, #5332, #5426, #5482),
  not touched by this change.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., GOOS=linux/windows go build: ok. gofmt -l: nothing.
- go test -timeout 45m ./... (shared lock): every package ok but gui and
  provider. gui: TestAgentOwnModelsHidden (fixed above), and
  TestMainWindowCorners (#3949) and TestPanelHiddenByWailsMarksPageOutOfSight
  (#5322), both filed; provider: TestRenewLoginsKeepsClaudeReading (#5481,
  filed). After the fix go test ./internal/gui: only TestMainWindowCorners
  (#3949) red.

Not tried: a real dsh session started on deepseek-v4-flash (the refusal
above is read from dsh's source); dsh before 0.1.5 (it had no
deepseek-flash; every dsh on npm since 0.1.6 has it); Windows/WSL run.

At the pushed head (rebased on b020ae102, which touches gateway, provider
and agent's Claude Desktop only): go vet ./internal/agent ./internal/gui,
go test ./internal/agent -run Dsh and ./internal/gui -run
TestAgentOwnModels: ok.
2026-11-06 16:51:15 +08:00
yetone b020ae1022 agent: Claude Desktop 4.23118.0's gateway window still has no Chinese (xwoffice)
xwoffice on Discord: "Claude Desktop 接入以后界面会变成英文 取消了又恢复成中文".
Nothing changes in behaviour; this records that the cause is still
Desktop's, in the newest release too.

On magpie, Desktop runs in its 3p mode, whose window is its bundled UI.
Read from Desktop 4.23118.0 (darwin RELEASES.json currentRelease,
published 11-05, downloaded and unpacked, not run):
- Resources/ion-dist.asar's i18n has en-US de-DE fr-FR ko-KR ja-JP es-419
  es-ES it-IT hi-IN pt-BR id-ID, no zh. Its supported list in
  assets/v1/shared-99 and shared-67 is the same 11, and the window maps
  navigator.languages onto them, else en-US, then calls
  electronIntl.requestLocaleChange with that pick on mount.
- app.asar's resources/frame/shell/i18n/frame-shell has the same 11.
- app.asar's resources/i18n has zh-Hans and zh-Hant, for the signed-in
  (claude.ai) window only. So disconnecting brings Chinese back.
magpie carries the signed-in "locale" into Claude-3p/config.json
(desktopCarryLocale), but Desktop writes its own pick over it at every
start. Nothing magpie can write keeps Chinese there, and magpie doesn't
patch Anthropic's signed app. Chinese readers are told so on the
Agents row and in the switch-on notice since v0.1.2123 (4b4c4a806).

Changed: desktopCarryLocale's comment and docs/subsystems/agent-wiring.md
name 4.23118.0 among the versions read.

Run: gofmt -l internal/agent/claudedesktop.go clean. Comment and doc
only, so no build, test or tag.
Not tried: starting a real Desktop 4.23118.0 in 3p mode; the mechanism
is from its shipped code. Windows' 4.23118.0 bundle not read.

Reported-by: xwoffice (Discord)
2026-11-06 16:35:54 +08:00
yetone 6bc5702cd4 agent: magpie's OpenCode provider sets setCacheKey, so OpenCode sends its session's prompt_cache_key (#5468)
mariamatrix (#5468) and mahiro233 on Discord: magpie writes OpenCode's
magpie provider with @ai-sdk/openai-compatible and only baseURL/apiKey, so
OpenCode sends no prompt_cache_key and an upstream that caches by it misses.
Checked against OpenCode's source and real runs (sandbox HOME on mote, a
recording Chat server):
- 2.2.5: v1/config/migrate.ts maps options.setCacheKey to
  compatibility.supportsPromptCacheKey, and openai-chat.ts sends
  prompt_cache_key only then. Without it: no key; with it:
  "prompt_cache_key":"ses_…" on the turn and the title request. A config
  with magpie's provider under providers, compatibility.supportsPromptCacheKey
  true, sends it too; without, none.
- 1.19.5: setCacheKey true sends camelCase promptCacheKey (the previous
  commit sends it on as prompt_cache_key).
- 2.0.25: ignores the option; the run answers as before, no error.

Now:
- the "opencode" shape's options have setCacheKey: true. Every writer of
  provider.magpie goes through it and openCodeKept: OpenCode, its
  OPENCODE_CONFIG_DIR copies, MiMo Code, DevEco, Air's OpenCode and
  OpenChamber's.
- openCodeNative writes it as OpenCode 2 does: compatibility
  .supportsPromptCacheKey, not a setting.
- a setCacheKey the file has already under provider.magpie.options, or a
  supportsPromptCacheKey under providers.magpie.compatibility, is the
  user's (false too) and stays, through a sync and a pick.
Kilo has no wiring in magpie; no other agent's config has this option.
TestAirProviderWritesKeepCustomFields compared every option as a string;
it now compares a bool as its JSON.

Run on mote: go test ./internal/agent (full package) ok; go test -run
'OpenCode|CacheKey|Air|OpenChamber|Deveco|Mimo|KeepTheir' ./internal/agent
./internal/gateway ok; go vet on darwin, GOOS=linux, GOOS=windows; go
build ./... (darwin, windows); gofmt clean.
Broken by hand, each failing TestOpenCodeSetsCacheKey: no setCacheKey in
the shape ("no setCacheKey"); no keep under provider ("the user's false not
kept"); no keep under providers (same); no move out of settings
("setCacheKey in OpenCode 2's settings").
Not tried: a config written by a running magpie fed to a real OpenCode
(the real runs used configs of the same shape, written by hand); a real
upstream's cache hit rate before and after.

Reported-by: mariamatrix
Reported-by: mahiro233
2026-11-06 15:02:53 +08:00
yetone 6b91c2ea5b usage: a cache or window Tuned for you put in keeps its Undo with too few calls
linkaww on Discord (11-06): "之前在用量 - 上下文把Claude Code缓存改成了1h
请问在哪里改回5m". Usage › Context › Tuned for you is the one place in
the GUI that sets Claude Code's promptCacheTtl, subagentPromptCacheTtl and
a model's autoCompactWindow, and its row (with Undo) came only from advice,
which needs 50 calls in the range. On Today, or a quiet week, the row and
the way back were gone, and an agent with no calls had no card at all.

agent.TuneKept lists the knobs tune put in (its stash, read back as ours,
not under Long conversations). /api/tune adds each one that has no advice
row as a few row, and keeps an agent with none of its own calls when it
has one. The card draws a few row as In use with Undo and "Not enough
calls in this range to tune on", and no curve; the card's totals skip it.
A value the user wrote themselves is not listed. Codex's compact is left
out: Settings changes it.

Run (mote, at this tree):
- go test ./internal/agent ./internal/gui -count=1: agent ok. gui is red only
  in TestMainWindowCorners, which is red the same way on a fresh origin/main
  92f5fc8fe (#3949). TestTuneKeepsWhatItPutIn and TestCoreScriptBudget pass
  (core 1,533,750 at this commit, budget 1,533,802, not raised).
- node --test of context-tune, images-codex-one, chatgpt-image-chip and
  settings-lines-wrap, in Chromium and WebKit, in en, zh, zh-TW, ja and de,
  at 360 and 1100 wide: 322 pass, 0 fail. i18n-keys is red only in "a
  plugin's words are its own", the same on origin/main 8ee85c59f (#5332,
  #5426).
- GOOS=linux go vet -tags nogui, GOOS=windows go vet, go vet (agent, gui),
  go build ./..., gofmt -l: clean.

Broken by hand:
- TuneKept's result dropped in gui/tune.go: TestTuneKeepsWhatItPutIn fails
  ("no calls: kept []").
- Without the tuneCard guard, the new context-tune case is red in both
  engines: the card throws on a few row and draws nothing.

Not tried: a real Claude Code run reading the put-back value, or the real
app (the live ~/.claude is off limits).

Reported-by: linkaww
2026-11-06 13:36:23 +08:00
yetone 773902a77b provider: Find copies the provider it gives; a list asks each group once
In the same live profile (v0.1.2906, two idle minutes, 269 MB):
- provider.Find copied every provider through All, each account's keys
  and headers, to give one (9.3 MB); All's copies were 4.6 MB of their
  own. sharedAll is the providers held, for reading; Find and resolveIn
  copy only the one they give, and the pricers read sharedAll.
- buildModels asked a group's members up to five times (its compaction,
  its price twice, its protocols, its tiers), each walking the members
  and resolving each (GroupFinder 7.9 MB, membersFound 6.3 MB).
  provider.FoundOnce answers each group once per build; every caller
  only reads the members.

Run (mote, at this tree):
- gofmt -l internal, go vet ./..., GOOS=windows and GOOS=linux go vet
  ./internal/agent/ ./internal/provider/: clean
- go test -count=1 -timeout 45m ./... (all three commits' tree): 85
  packages ok, internal/gateway 748s, internal/provider 193s. Two red:
  internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's macOS 27
  (#3949, filed before, untouched here), and internal/agent's
  TestCodexEffortOptionsReadTheKeptList, whose bar counted the
  environment's copy (see the effort test's comment), fixed in its test.
- then go test -count=1 -timeout 45m ./internal/agent/ with that fix:
  ok (200.1s)

Broken by hand (mote, -run):
- Find through All again: 167 allocations against a bar of 60, red;
  green it is 6 (TestFindCopiesTheOneItGives, which also checks that a
  change to what Find gives reaches neither the next Find nor All).
- FoundOnce forgetting what it found: group:a walked 5 times, red
  (TestFoundOnceAsksEachGroupOnce).

Not tried: the numbers on the live app after this build.
2026-11-06 12:48:51 +08:00
yetone fb4632ee0c agent, provider: Codex's polls and the usage quotas read what is kept
Heap profile diff of the live magpie (v0.1.2906, /v1/magpie/heap, two
idle minutes with the window open: 269 MB allocated):
- ownCodex found the codex provider through provider.All, a copy of every
  provider, on each look (~9 MB). Its picks are now kept per stamp
  (codexPicks, stampedLists), read only.
- Codex's model and effort fields copied magpie's whole model list on
  each Options call, every poll of the effort field (~11 MB). They read
  sharedModels, the list kept, which they only read.
- visibleQuotas built every provider's offered models to narrow Gemini's
  and Antigravity's quotas (~20 MB). exposedIDs builds the providers
  asked only.

Run (mote, at this tree):
- gofmt -l internal, go vet ./..., GOOS=windows and GOOS=linux go vet
  ./internal/agent/ ./internal/provider/: clean
- go test -count=1 -timeout 45m ./... (all three commits' tree): 85
  packages ok, internal/gateway 748s, internal/provider 193s. Two red:
  internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's macOS 27
  (#3949, filed before, untouched here), and internal/agent's
  TestCodexEffortOptionsReadTheKeptList, whose bar counted the
  environment's copy (see the effort test's comment), fixed in its test.
- then go test -count=1 -timeout 45m ./internal/agent/ with that fix:
  ok (200.1s)

Broken by hand:
- codexPicks through provider.Find again: 285 allocations, red
  (TestCodexOwnModelsFollowPicks, bar 20).
- the effort field on magpieModels again: 199896 bytes a look past
  its StampNow's 1712, red (TestCodexEffortOptionsReadTheKeptList, bar
  20000). The test takes the look's StampNow off: os.Environ copies the
  environment, and each t.Setenv before it in the package made that
  longer (an Unsetenv leaves its slot), ~56 KB a look in the whole
  package; run alone it is 1.7 KB.
- exposedIDs without the ids check: "other" built, red
  (TestExposedIDsBuildsOnlyTheProvidersAsked).

Not tried: the numbers on the live app after this build; that profile
is taken once it is released.
2026-11-06 12:48:51 +08:00
yetone dfa42c07cd agent tests: an allocation count is the fewest of five rounds
TestAlmaProvidersSeenDecodeOnce (v0.1.3114) went red in the whole
internal/agent package on mote: 401 allocations against its bar of 400,
green alone. testing.AllocsPerRun counts every goroutine's allocations,
and another test's watcher or poll left running lands in a round now and
then. leastAllocs takes the fewest of five rounds, which such a stray
reaches in one round, not in all five; leastBytes does the same for
bytes (runtime.MemStats TotalAlloc).

Run (mote, at this tree):
- gofmt -l internal, go vet ./..., GOOS=windows and GOOS=linux go vet
  ./internal/agent/ ./internal/provider/: clean
- go test -count=1 -timeout 45m ./... (all three commits' tree): 85
  packages ok, internal/gateway 748s, internal/provider 193s. Two red:
  internal/gui's TestMainWindowCorners/macOS_26_SDK, mote's macOS 27
  (#3949, filed before, untouched here), and internal/agent's
  TestCodexEffortOptionsReadTheKeptList, whose bar counted the
  environment's copy (see the effort test's comment), fixed in its test.
- then go test -count=1 -timeout 45m ./internal/agent/ with that fix:
  ok (200.1s)

Broken by hand: with the bytes.Equal check in almaProvidersSeen removed
the look measures 7232 allocations and goes red, as before.
2026-11-06 12:48:50 +08:00
yetone 6a78060c6d agent: Alma's providers are not decoded again from the same answer
almaProvidersSeen decoded Alma's providers list each time it was asked
past almaReadFor, on each poll of the Agents page. On the live magpie
(v0.1.2906) Alma's answer is 227 KB, and its json.Unmarshal was ~13 MB of
what an idle two minutes allocated (heap profile diff from
/v1/magpie/heap). The same bytes are now answered with the providers they
gave last time, by pointer or by bytes.Equal; changed bytes are decoded
as before.

Run (mote, at this tree):
- go vet ./internal/agent/, gofmt -l: clean
- go test -count=1 -timeout 45m ./internal/agent/: ok (216.6s)
- TestAlmaProvidersSeenDecodeOnce's new part (almaReadFor 0, AllocsPerRun of a
  look) is green at most 400 allocs; with the bytes.Equal check removed
  by hand it measures 7232 and goes red.

Not tried: a live Alma app against this build; the bytes compared are
what almaGet already returned.
2026-11-06 12:10:43 +08:00
yetone d2c29abe73 codex: a chat the Codex app had open as magpie became its provider moves once the app lets it go (crypto0xfish on Discord)
crypto0xfish on Discord, the Codex app: "Model provider mismatch. This
chat uses OpenAI, but your current provider is magpie. Switch to OpenAI
to continue."

magpie makes itself Codex's provider (model_provider = "magpie") when
Codex has no ChatGPT sign-in, is signed in with an API key, the user
picks magpie API, or the ChatGPT account is used up (the takeover).
bringOver then moves OpenAI's threads to magpie, a paginated one by its
row (RetagPagedCodexThreads), skipping any a Codex holds open (its
writer lock) or wrote to in the last minute, "for the next sync". The
Codex app holds the lock of every thread it has loaded, the chat on
screen among them, however long ago it was written (tried below), and
nothing asked for that next sync: Sync runs on catalog changes, which
can be hours away. So the chat open at the switch stayed on OpenAI;
the app refuses it while loaded (app-server
check_thread_model_provider_for_input compares the loaded thread's
provider with config.toml at each turn), and after the app let it go it
was refused again on resume by its row, until something else synced.
681a472ca fixed the same gap for bringBack by time alone and named the
held-lock case as not tried.

- sessions.CodexThreadsBusyOn also counts a thread on the provider
  whose writer lock a Codex holds (codexLockedIDs: the lock files in
  thread-writer-locks, each tried and let go under Codex's coordination
  lock, none made or removed).
- codexThreadsLater(dir, p) now looks every 15s, for up to 12h, and asks
  for the Sync once nothing on p is busy or held; one wait per home and
  provider. bringBack keeps calling it for magpie; bringOver calls it
  for the provider it moved from, and lendOwn for openai (the same skip,
  OpenAI's threads onto a provider of the user's).
- Tests: TestCodexOpenThreadFollowsMagpieOnceLetGo (new: a paginated
  OpenAI thread held open stays at the takeover, no Sync is asked while
  held, one is once let go, and that Sync moves it to magpie);
  TestCodexTakeoverThreadComesBackOnceQuiet now expects the Sync only
  after the thread is quiet. TestMain turns the wait off so no goroutine
  outlives a test; the two tests end theirs in Cleanup.
- docs/subsystems/agent-wiring.md says so.

The chat loaded at the moment of the switch can't be helped from
outside: the app goes on with it once it reloads it (quit and reopen).
Codex's identity line, base_instructions and every value of the user's
are untouched.

Run on mote at this tree (base cff530079):
- gofmt -l: clean; go build ./...: ok;
- go vet ./internal/agent ./internal/sessions for darwin, linux -tags
  nogui and windows: clean;
- the two tests with -race -count=3: ok;
- go test ./internal/agent ./internal/sessions: ok.
On Windows (win-run): the two tests and TestCodexPagedThreadsFollowByRow: ok.

Broken by hand: bringOver's call turned off (`if false &&`), the new test
fails "no later Sync asked for"; the lock check in CodexThreadsBusyOn
turned off, it fails the same way. Restored, both pass.

Real Codex: codex-cli 0.165.0's app-server in a sandbox CODEX_HOME, a
thread started and a turn sent (to a dead fake provider). With the thread
loaded and its rollout quiet 73s, its lock was held, a probe built from
this tree said CodexThreadsBusyOn true and RetagPagedCodexThreads moved
nothing; after the app-server exited and a quiet minute, busy was false
and the retag moved the row.

Not tried: the real Codex desktop app (whether leaving a chat for another
lets its lock go within a minute, or only quitting does), and a live
switch with a real used-up or API-key account. The reporter's own setup
(why Codex was on magpie for them) is not known.

Reported-by: crypto0xfish
2026-11-06 11:26:41 +08:00
yetone cff530079f wsl: a bridged distro reaches Windows on the bridge's adapter, not the LAN router
ecalpal_ on Discord (magpie 0.1.2689, Windows 11, WSL 3.0.3.0, Ubuntu
22.04.5; .wslconfig vmSwitch=WSL_Bridge_Switch, networkingMode=Bridged,
dhcp=false). In bridged networking the distro is a peer on the LAN and its
default route is the router, 192.168.9.1. magpie took that next hop for
Windows: wsl.json got {"net":"bridged","gateway":"192.168.9.1"} and Pi's
models.json a baseUrl on 192.168.9.1:3425, where nothing listens, with the
gateway token rather than the WSL key. serveWSL already listened on
192.168.9.147, Windows' address on vEthernet (WSL_Bridge_Switch).

wslrun.HostAt now picks the address: "" where the distro's 127.0.0.1 is
Windows' (mirrored, consomme, virtioproxy, as before); the next hop as it
is when it is Windows' own address on a WSL adapter (NAT, unchanged);
otherwise Windows' address on the one WSL adapter whose network holds
that next hop (bridged: 192.168.9.1 in 192.168.9.147/24 -> .147). A next
hop on no WSL network is kept as it was. The adapter list moved from
gateway.wslNets to wslrun.Nets (gateway.WSLNets still wraps it), so both
probes use it: agent's parseProbe (distro.Gateway, what place writes into
agents) and wslrun's (Tool.Host, a 127.0.0.1 proxy handed to a WSL CLI),
which had the same bug.

The key follows the address: keyAt(http://192.168.9.147:3425) is on a WSL
net (OnWSLNet), so agents there get the WSL key.

Existing users: on the next start, the first probe of the running distro
writes the new gateway into wsl.json and keeps 192.168.9.1 in Was. The
startup SyncCatalog then rewrites Pi's provider block (baseUrl and apiKey)
at the new address; keptaway treats the old router address as magpie's
because it is in Was. A distro that isn't running at start is fixed at its
first probe after it runs, and its agents' files at the next sync after
that. Codex in WSL, which keeps its own base_url, gets the existing
"unreachable" drift with "Use 192.168.9.147:3425" (wslMovedFrom), not an
automatic rewrite.

Tests (fixtures are the reporter's values):
- wslrun TestHostAt: bridged/nat/mirrored/consomme each with its own route
  and adapters; TestParseProbeBridged (Tool.Host and proxy).
- agent TestWSLBridgedReachesWindowsOnTheBridge (bridged .147, nat
  172.20.0.1 unchanged, mirrored 127.0.0.1) and
  TestWSLBridgedOldRouterWrittenOver: wsl.json and Pi's models.json as
  0.1.2689 wrote them, then a probe and a sync: baseUrl .147, apiKey the
  WSL key, wsl.json rewritten.

Run:
- Broken by hand: probe code put back to HostLoopback only. Both new agent
  tests and TestParseProbeBridged FAIL (Gateway/Host 192.168.9.1).
- mote: gofmt -l empty; go vet, GOOS=windows go vet, GOOS=linux go vet
  -tags nogui for wslrun, gateway, agent; GOOS=windows go build: ok.
- mote: go test -timeout 45m ./internal/wslrun ./internal/agent
  ./internal/gateway: ok (wslrun 1.3s, agent 231s, gateway 855s)
- xiaomi-gpu (win-run): go test ./internal/wslrun ./internal/gateway
  -run 'HostAt|ParseProbe|WSL' ok; ./internal/agent -run
  'WSL|ParseProbe|Omp' ok. A first try with a fallback (bridged + one WSL
  adapter -> that adapter) went red there on TestParseProbe and
  TestWSLNetworkingFromWslinfo, because the box's real NAT adapter
  (vEthernet (WSL (Hyper-V firewall)) 172.17.32.1/20) was taken for the
  bridge; the fallback was dropped.
- xiaomi-gpu, real adapters: HostAt("nat", "172.17.32.1", Nets()) =
  172.17.32.1; magpie-desktop is NAT (wslinfo nat, default via
  172.17.32.1), so its value is unchanged.

Not tried: a real bridged WSL (none on the LAN; magpie-desktop's
networking was not changed), a real magpie start against an existing
wrong config, and the full go test ./... before the push (run after).
2026-11-06 10:49:35 +08:00
yetoneandggbdpq 429f9317d2 uninstall: Codex's base URL at magpie's gateway goes even with magpie's notes gone (#3866)
Uninstalling disconnected only the agents that read as connected. A
Codex whose config still had openai_base_url at magpie's gateway (or
model_provider = "magpie") but whose notes in magpie's folder were gone
(the folder deleted by hand, a fresh install beside an old config, a
magpie older than the notes) read as not connected, so the uninstall
left it pointing at a port nothing answers: every Codex turn then failed
with a connection error that never names magpie.

Uninstall's Agents step now ends with Codex's leftovers pass
(agent.TakeCodexLeftovers, the Agent's TakeLeftovers): the base URL goes
by viaBase()/dropBase and magpie as provider by asProvider()/dropProvider,
the same gates and drops a Disconnect uses, notes or not. Codex's own
model, its own provider and keys stay, and so does
[model_providers.magpie], which threads started on magpie name. Taking
anything shows "Codex's leftover settings" in the report and restarts
the Codex app's app-server. docs/subsystems/agent-wiring.md says so.

Not changed: deleting magpie.exe by hand runs no code, so the reporter's
Windows case is covered only through Settings > About > Uninstall magpie
or `magpie uninstall`. The pass is this machine's Codex only, like
EndCodexFailover; a WSL distro's config is left as it was. viaBase
matches any loopback port with /backend-api/codex, as Disconnect does.

Run on mote, base origin/main 4e7661adc:
- gofmt -l on the touched files: nothing
- go vet -tags nogui ./internal/agent/ ./internal/uninstall/,
  GOOS=linux go vet -tags nogui, GOOS=windows go vet: clean
- go test -tags nogui -count=1 ./internal/uninstall/: ok
- go test -tags nogui -run 'Uninstall|Run|Keep|Data' ./internal/cli/: ok
- go test -tags nogui -run Codex ./internal/agent/: ok (44s)

Broken by hand: TakeLeftovers returning false at once and Agents not
calling endLeftovers: TestCodexLeftoversGoAtUninstallWithoutTheMarks and
TestCodexProviderLeftovers... FAIL "took false, err <nil>"; TestRunOrder,
TestKeepData and TestRunTakesCodexLeftovers FAIL (no "leftovers" step,
the Codex app not restarted, a failed pass not reported).

Not tried: a real `magpie uninstall` (it removes the login service, which
a sandbox HOME doesn't isolate), the Codex app, Windows.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 10:44:24 +08:00
yetone 1493acb468 gui: Codex's memories default reads right on Codex 0.167.0 and before
Codex 0.167.0 (openai/codex#58091) moved its default memory models:
extraction from gpt-5.6-luna to gpt-6-luna, consolidation from
gpt-5.6-terra to gpt-6.1-terra. The memories square's unset text and the
Settings row's tooltip named the old pair. They now say "Codex's own
memory models", true on either version, in en, zh, zh-TW, ja and de.
The code comments (agent/codex.go, gateway/codex_memory.go,
gateway/codex_follow.go, the tests' headers) name both pairs with the
Codex version that uses them. No behaviour changes: magpie routes these
calls by kind (memgen, memory_consolidation), not by the model name.

Run on mote at the pre-rebase base 4e7661adc, both engines:
node --test codex-memories, codex-memories-settings, agent-prefs,
codex-sheet-providers, settings-general, i18n-keys, i18n-en-no-cjk:
127 of 128 ok. The one red is i18n-keys "a plugin's words are its own"
("No session ID", "View routing"), red on main before this change and
filed as #5327, #5332 and #5426. go vet of internal/agent and
internal/gateway for darwin, linux and windows, and gofmt -l: clean.
Not broken by hand: text-only change; codex-memories.test.cjs asserts
the new en and zh strings, so the old text fails it.
Not tried: a real Codex 0.167.0 writing memories through magpie.
2026-11-06 09:59:56 +08:00
ggbdpq faa69b8319 dsh: a dsh test's temp home is given up only once it is really gone
TestDshSetEffortWritesALegacyEntryWithTheCatalog died once at cleanup,
not in its body: on Windows, t.TempDir's RemoveAll found .config/magpie
not empty (LoKi's box, reported by yetone, #2982). Save replaces
providers.json by renaming a file over it, and a scanner holding the
file that was just renamed over keeps its entry listed while the entry
is pending deletion, so the folder reads as not empty for a moment;
t.TempDir's own cleanup retries a sharing violation but not a
"not empty" one, so it gave up on the first try. The seven dsh tests
that set up such a home now share dshTempHome, which tries the removal
until the folder is really gone, for a short while, before t.TempDir's
cleanup gets its turn.

Not verified on Windows: the failure is one-off under a scanner there,
and on macOS removing a folder whose file is still open succeeds, so
the race cannot be reproduced on this machine. With the retry taken
out the suite is green on macOS as before, so the only change in
behavior is the retry itself.

Generated-by: GLM-5.3-Flash (ZCode)

Review: go test -tags nogui -count=20 -run TestDsh ./internal/agent/ ok on
Windows 11 (xiaomi-gpu, win-run, 232s) and -count=3 on mote. The cleanup
is registered after t.TempDir, so it runs first (LIFO) and TempDir's own
RemoveAll finds the folder gone.
Not tried: a Windows box under the load that made the original red.
2026-11-06 05:53:50 +08:00