Commit Graph
663 Commits
Author SHA1 Message Date
vincent e50d73aa36 agent: disconnect previews sweep sandboxes a killed magpie left (#3136)
DisconnectPreview builds its dry-run sandbox with os.MkdirTemp and
cleans it with a bare `defer os.RemoveAll(tmp)` (internal/agent/preview.go).
Two consequences reported by OldSuns: when the removal fails (on Windows
the dry run's bun host still holds magpie-bun.exe after cmd.Run returns)
the error is dropped and the sandbox - each with an 86 MB bun re-downloaded
into it - stays in the temporary directory for good; 12 dirs / 985 MB in
the report, 99 dirs in ggggggggggz's. And nothing ever reclaims sandboxes
left by a killed magpie, unlike the cursor snapshots, whose
sweepCursorSnaps removes stale magpie-cursor-* copies.

The change: DisconnectPreview sweeps magpie-preview-* folders older than
an hour (a live preview lasts seconds; the dry run is bounded at 20 s)
before creating its own, the way the cursor snapshots do; cleanup goes
through removePreview, which retries while processes are still letting go
of files (5 tries, 0.1 s-0.5 s apart) and logs the error instead of
dropping it when it still cannot remove the folder. Only the reported
prefix is swept; the other magpie-* temp prefixes have their own
lifecycles (#2321, cursor_snapshot.go).

Each sandbox also holds a copy of magpie's config folder's files
(logins.json, providers.json and the rest, copyTop), so a sandbox the
removal left behind kept the user's sign-ins in the temporary folder for
good. The sweep takes those too.

Reported by OldSuns, ggggggggggz and track23; the fix is skygunner's
branch fix/3136-agent-magpie-preview-86-mb (98e5e7bc7), ported as it is
apart from the test: it now sweeps a temp dir of its own (TMPDIR, TMP and
TEMP set to t.TempDir()) instead of the machine's, where it could take
another magpie's stale sandboxes.

What was run (on the ported tree):

- TestDisconnectPreviewSweepsStaleSandboxes with sweepPreviews() taken
  out by hand: red ("a stale sandbox is still there after a preview").
- go vet ./internal/agent/ for linux, windows and darwin: ok.
- go test ./internal/agent/ on mote: ok 170.4s.
- Windows (xiaomi-gpu, win-run): go test -run
  'TestDisconnectPreview|TestRemovePreview|TestPreview' ./internal/agent/:
  ok 7.8s.
- On mote, the built binary's agent-disconnect-dry-run for opencode,
  claude and codex under an empty sandbox HOME, then with a plugins.json
  naming an OpenCode plugin: nothing downloaded, the sandbox stayed at
  8-12K.

Not reproduced: the 86 MB bun and the pnpm install inside a sandbox. The
reports are from v0.1.1223; on main the dry run started no plugin host in
the cases above, so nothing here changes where bun comes from. The
sandboxes it left are what this removes.

Refs #3136
2026-10-28 18:21:38 +08:00
yetone 67c8f562cd codex: a subagent named a model goes on it with "Same as the lead" (mengxiao on Discord)
mengxiao left Codex's subagent model at "Same as the lead" in magpie,
asked the lead for a subagent on GPT-6.1 Terra, and magpie put the
subagent on the lead's model anyway. The cause was codexFollowTo
(internal/gateway/codex_follow.go): on the ChatGPT-sign-in path, a
collab_spawn request asking for one of Codex's bare models, with nothing
set in magpie or [agents] default_subagent_model, was moved onto the
model the conversation's own turns go on (a1174674d, cybercaius).

Codex starts a spawn that names no model on its lead's model (codex-rs
core/src/agent/child_config.rs: build_agent_spawn_config sets the
child's model to the step's slug; apply_requested_spawn_agent_model_
overrides takes spawn_agent's model, else default_subagent_model; a
role's config can set one too). So under a lead on a magpie model, a
bare model in a subagent's request was always named by the lead, the
config or a role: the user's or the lead's pick. The GUI already says
"Same as the lead" means "the lead's model, or another the lead picks".

- codexFollowTo now handles memory calls only; a subagent is moved only
  by the model set for Codex's subagents in magpie (codexSubagentPick,
  unchanged). codex_backend.go no longer builds a pick from it.
- Dead code out: codexSessionOf, codexLeads.of, and CodexSideSet's
  "subagent" case (its doc moved onto servedSession).
- docs/subsystems/gateway-routing.md says a subagent never follows.
- Sibling checked: Claude Code writes no CLAUDE_CODE_SUBAGENT_MODEL
  while following the main model, and Claude Code takes the Agent call's
  model first; Claude Desktop's pick acts only when a model is set.
  Neither overrides a named model under "same as lead".
- Who relied on a1174674d (a lead's own pick of a Codex model following
  the session): pick the session's model as Codex's subagent model in
  magpie, which puts every subagent on it.

Ran (mote, -tags nogui -count=1, this change on 7fd77a944; rebased after onto a57c95513, which adds only docs, LESSONS and GUI test files):
- TestCodexSubagentKeepsTheModelItWasNamed on the old code (b01193ef9
  with only the new test): FAIL, "ChatGPT was asked for []".
- go test -run 'TestCodex(Subagent|Side|Memor|AppSide|Title|Prediction)'
  ./internal/gateway ./internal/agent: ok.
- go vet (darwin nogui, GOOS=linux, GOOS=windows) on internal/gateway
  and internal/agent: ok. gofmt -l: clean.
Not run: the full go test ./... suite (started on mote, not waited on);
staticcheck (not installed on mote); a real Codex spawn_agent with a
ChatGPT sign-in and a lead on a magpie model.
2026-10-28 16:16:02 +08:00
yetone f25871cddc agent: the Codex app's route is read from one look at Codex's config (#1665)
KeepCodexAppOnItsProvider asks codexAppRoute every 3s for as long as
magpie runs, and it read config.toml's keys one getter at a time, each a
look at the disk: 42 looks in 25s on Windows, where an antivirus works on
each. It now holds what it read (filememo.Hold) for the call, so each
tick looks once, and its keys come from one version of the file.

Measured on xiaomi-gpu (Windows 11), an empty sandbox HOME, magpie web
--gateway, second start, 27s, counting looks with an uncommitted build,
with the warm-up's hold (fcbbb8e47) in both: codexAppRoute's looks 42 to
8, all looks 483 to 448.

Run (mote): gofmt -l internal/agent clean; go vet ./internal/agent for
darwin, windows and linux (-tags nogui) clean; go test -count=1
./internal/agent ./internal/provider ok. Not tested by its own test:
nothing in codexAppRoute lets a test write between its getters.
2026-10-28 13:57:48 +08:00
yetone f201183047 tune: the compact window is Long conversations, one value for both agents
7eleven (Discord #help): the Usage page's "Tuned for you" compaction
value and the agents' sheet "Long conversations" window were two values
that could disagree. Codex's tune wrote model_auto_compact_token_limit
into config.toml beside the catalog's context_window that Long
conversations writes; Claude's read its own env.

One source of truth: settings.CompactAt / FullContext. Tune's compact
row for Codex and Claude Code now has source "long": its Current is
settings.Compact(), Use calls provider.SetCompactAt (Sync writes Codex's
catalog and Claude's CLAUDE_CODE_AUTO_COMPACT_WINDOW as before), Undo
puts back the CompactAt/Full it stashed under tune.long.compact. So a
value set on either page shows on the other and writes the same config.
writeCompact marks claude.compact_long when the env value came from
settings, so Claude's row reads it as ours, not as the user's.

Migration (Codex Sync, local place): an old tune.codex.compact stash
whose limit is still the one tune wrote moves into Long conversations.
At default or Full it takes tune's value; with a value the user set it
takes tune's only when smaller. config.toml gets the user's earlier
limit back or loses the key; the stash is forgotten. A limit the user
changed after tune wrote it, or wrote themselves, stays and reads
Locked. A provider's Compact at or the user's own Claude env stays
Locked too.

Run (mote, at this tree):
- go vet on agent, provider, gui, tune; GOOS=linux go vet -tags nogui
  ./...; GOOS=windows go vet ./...; go build ./... and -tags nogui: ok
- go test -tags nogui ./internal/agent ./internal/provider
  ./internal/tune ./internal/gui: ok (TestCoreScriptBudget within the
  budget, not raised; context.js is 33 bytes smaller)
- GUI: compact-one-value.test.cjs (new; Chromium and WebKit, en zh
  zh-TW ja de) and context-tune: 104/104 at the rebased head
Broken by hand: the Codex long branch, the Claude long env check and
the Sync migration call each turned red TestClaudeCompactAt,
TestCodexHomeEnvTakesThePick, TestTuneCodexCompact,
TestTuneCodexOwnLimit, TestTuneCodexMigrate (4 subtests),
TestTuneClaudeLong and TestTuneCodexMigrateOnSync. Old context.js and
i18n.js turn compact-one-value red ("You set 272K").
Not run: full suite, Go or GUI (shipped at once per owner; the GUI suite
is still running on mote, reds get their own issues).
Not tried: a real Codex or Claude Code session reading the written
config; the migration on Windows/WSL places (it runs for the local
place only).
2026-10-28 13:52:08 +08:00
yetone 5160809d2e agent: a catalog sync's round looks at each file once; a write reads the disk (#1665)
A catalog sync asked about each agent's files many times a round
(GetJSON, GetTOMLTop, settings.load from each agent's Sync): on Windows
an empty sandbox's start stat'ed settings.json 1065 times and
config.toml 569 in 25s, almost all from SyncCatalog. Each round now
holds what was read (filememo.Hold), as the GUI's read-only requests and
the gateway already do.

What a hold serves may be up to a second old, so nothing is written from
it any more:
- edit.Read, which every Set*/Del* helper and the agents' own
  read-modify-write code start from, looks at the disk even under a
  hold (filememo.ReadNow). The getters (GetJSON, GetJSONRaw,
  GetJSONItem, GetEnvFile, GetYAMLTop, the YAML getters, GetTOMLTop's
  line reader) read through the hold.
- settings: a write's load under fileMu (lockFile) reads the disk too.
Before this, a GUI request's hold could already hand a Set* stale
bytes; that is closed as well.

WriteAtomic forgot every held file even when it left the file as it
was, and a sync writes each agent's files each round, almost always
unchanged: it now forgets only after a real write.

Measured on xiaomi-gpu (Windows 11), as in the steady commit before
this one (second start, 27s, stats counted by an uncommitted build):
  before          2307 stats, sync 1318 of them, round 1308ms
  this alone      1787 stats, sync  864,          round 1273ms
  with steady's    988 stats, sync   96,          round   96ms
First start of an empty sandbox: 2448 stats before, 1041 after.

Run:
- TestHeldReadIsNotWhatAWriteIsMadeFrom (json, toml, yaml),
  TestUnchangedWriteKeepsWhatIsHeld, TestHeldSettingsAreNotWhatAWriteIsMadeFrom:
  with edit.Read and the settings write load put back on the held read
  and WriteAtomic's Forget removed by hand, json and yaml lost the other
  app's key, the settings case wrote "light" over "dark", and the
  forget case went red; green with the change, on mote.
- mote, at the pushed head: gofmt -l internal clean; GOOS=linux/windows/
  darwin go vet of steady, edit, filememo, settings and agent clean;
  go test -count=1 of steady, edit, filememo, settings, agent, provider,
  catalog and library ok; internal/gui red only on TestMainWindowCorners
  (#3949, macOS 27, red on main before this).
- xiaomi-gpu: go test of edit, filememo and settings ok.
2026-10-28 13:43:37 +08:00
yetone e29ddc407f library: a Pi in WSL is given MCP servers, and so are seven more WSL agents
leokon on Discord (#help): the Library's MCP section listed only the
Windows Pi, never a Pi installed in WSL. wslTargetOf left pi@wsl's MCP
out because its version wasn't known, and Pi's MCP file depends on the
version: 0.99+ reads mcp.json itself; before that, pi-mcp-adapter 3 reads
mcp-adapter.json and 2 reads mcp.json.

- The WSL probe now asks the distro's pi for --version (wslKind
  version: true). The answer is stored as the agent's wslVersion, and
  InstalledVersion returns it for an agent in WSL.
- pi@wsl:<distro> gets piMCP. The file is chosen as on this computer,
  with the distro's npm roots for the adapter (~/.npm-global,
  /usr/local/lib and /usr/lib node_modules): wslPiRoots, piDetectIn.
- Siblings: every agent with a local MCP target and no WSL one now
  has one, in its own file under the distro's home. These are Gemini
  CLI, Antigravity CLI, Crush, Cline, CodeBuddy Code, Kimi Code and
  Goose.
- Every WSL MCP file is marked WSL with its distro, so a Windows
  program (C:\...\npx.cmd) is refused, as for claude/codex@wsl.
- Not fixed: Kimi Code's and Goose's skills in WSL. On this computer
  they get the shared ~/.agents/skills, but the distro's needs that
  folder's sharing rule (#3966).

Run (at d8c70504d + this commit; rebased on d50f84c9f, two mover mins):
- go test -tags nogui ./internal/agent ./internal/library on mote: ok.
- GOOS=windows and GOOS=linux go vet ./internal/agent ./internal/library:
  ok.
- gofmt -l: clean.
- New tests:
  - TestWSLPiMCP covers three fake distros: Pi 1.2 gets mcp.json
    (native); Pi 0.98 with no extension gets mcp-adapter.json; Pi 0.98
    with adapter 2 in ~/.npm-global gets mcp.json (fmtPi). Each is in
    the page's view, and is written to its distro and not this
    computer's Pi. A Windows program is refused.
  - TestWSLMCPSiblings covers the 7 siblings: path, WSL mark, writes,
    and refusal. The OS switch is forced with agent.FakeWSL.
- GUI, on mote: library-*.test.cjs, wsl-agents-setting and i18n-keys
  (Chromium and WebKit, every language): 769 of 770 pass. The red is
  i18n-keys "a plugin's words are its own" ("Runs as" in
  claude_code_cli.go), red on main since 7f827b3b0, #3897.
- Full suite on mote (go test -tags nogui -timeout 45m ./...) at
  d8c70504d + this change: 76 packages ok, no FAIL, exit 0.
- Real run, on the Windows box: magpie built on Windows, run in a
  sandbox USERPROFILE. `magpie library mcp add wslfetch uvx
  mcp-server-fetch agents=pi@wsl:magpie-desktop` wrote the server into
  magpie-desktop's ~/.pi/agent/mcp-adapter.json. The distro has pi
  0.73.0 from npm, which the probe asked; it is before 0.99 and has no
  extension. A C:\Program Files\nodejs\npx.cmd server was refused for
  pi@wsl. Both files were then removed.

Broken by hand, each turned the new tests red:
1. pi@wsl with no MCP: TestWSLPiMCP.
2. The version not passed: Debian got mcp.json.
3. No distro roots: Arch got mcp-adapter.json.
4. No WSL mark on the file: the Windows program was written.
5. The gemini case removed: TestWSLMCPSiblings.

Not tried:
- A real Pi 1.x in WSL. magpie-desktop's own pi is 0.73 and was left
  as it is. The 1.x choice (mcp.json) is covered by the test only.
  @earendil-works/pi-coding-agent 1.4.0 answered `--version` with "1.4.0"
  on the box.
- The seven siblings with real installs in WSL.
- A distro that is stopped. Its saved probe from before this release
  has no pi version, so the file is chosen as for an unknown version
  (mcp.json), until the distro is probed while it runs.
- The GUI on Windows. Its MCP list shows any agent whose view has an MCP
  file, unchanged.
2026-10-28 10:37:13 +08:00
yetone 9ba3f049e2 workbuddy: a model over 200K offers WorkBuddy's context choice, set to its whole window
xiao9could on X: WorkBuddy shows no context button for magpie's models,
Opus included. WorkBuddy 5.5.6's CLI builds its "Context" session option
(and the renderer its 200K/1M submenu) only from a model's
contextWindow.supportedLengths with two sizes or more, each no larger
than maxInputTokens; magpie wrote maxInputTokens alone. Each entry over
200K now has supportedLengths [200000, window] and defaultLength set to
the window. defaultLength matters: without it resolveEffectiveContextBudget
takes the smallest size, which would have cut every session to 200K.
Read from /Applications/WorkBuddy.app's app.asar (cli/dist/codebuddy.js:
resolveEffectiveContextBudget, the context_window config option;
renderer lib-chat-ui: getSupportedContextWindows). The models.json loader
spreads each entry whole, so the field reaches the model config.

Run (mote): go test ./internal/agent -count=1 ok (157s); go vet
./internal/agent for darwin, linux, windows ok; gofmt clean.
Broken by hand: without the workbuddy.go change TestWorkBuddyContextChoice
fails.
Not tried: the menu in the running WorkBuddy app.
2026-10-28 09:30:24 +08:00
JoeyWu-tech 41427e016b agent: a stopped distro's Hermes profiles are never listed (#3924)
TestWSLColdPlaceOpensNothing is red on main since 34d38ed6 ("hermes:
each profile picks its own model on the Agents page"), on ubuntu and
macOS CI too (run 40543233193, at 5a9fb36a). The Hermes builder now
adds a field for each profile but the connected one
(hermesProfileFields), found through hermesOthers and hermesProfiles,
which list <root>/profiles and stat each profile's tombstone and
config.yaml. The builder runs at a stopped distro's place too, so every
/api/state opened that distro's folder, which starts it again (#3896's
class): the test saw the profiles folder opened and work's tombstone
and config.yaml looked at, once per build, twice.

hermesProfiles now lists nothing at a cold place, as hermesActive reads
no active_profile there and dshAt lists no profiles (e54a7d50). A
stopped distro's Hermes row has no Other profiles until the distro
runs again (a value picked on that row starts it, as asleep's Set
does), and the next build lists them. Its other callers (spread,
Sync, Unwire, hermesBack and hermesFollow, through hermesOthers) never
run at a cold place, as the asleep agent has none of them, and now
couldn't list it either.

What was run (tree 43bd70cf, on origin/main 7f0f71a0, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestWSLColdPlaceOpensNothing -v at 7f0f71a0: red, eight lines: the
  profiles folder opened, profiles/.deleted/work and
  profiles/work/config.yaml (twice) looked at, all of it twice. Here it
  passes.
- go test -run 'TestWSL|Hermes|Profile' -count=3 ./internal/agent: ok,
  372 passes, none failed.
- Broken by hand: the cold check taken out of hermesProfiles:
  TestWSLColdPlaceOpensNothing red with the same eight lines as on
  main.
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
  1.4.2: 68 packages ok and 8 red, none in what this changes, and
  TestWSLColdPlaceOpensNothing passes in it. The reds: agent
  TestCodexDriftReached (#3398), TestInstalledVersion,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir (#3141),
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
  #3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649); proc TestEnvOfChild and provider TestCodexAppServersOnHome
  (#3906), then "close of synctest channel from outside bubble" from
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632); tui
  TestTUIFetchesSubscriptionModels/agent (#3919).
- gofmt -l clean. go vet -tags nogui and go build -tags nogui for
  linux, windows and darwin, and go vet and go build for windows
  without the tag: exit 0 each. go vet and go build without the tag on
  linux: exit 1 (this box has no GTK or WebKitGTK dev packages).

Not tried: Windows with a real stopped distro that has Hermes and its
profiles.

Merged from JoeyWu-tech's branch, cherry-picked onto origin/main f13aafa87 together with the other of #3919/#3924. Run on mote at that tree:
- go test -run 'TestWSL|Hermes|Profile' ./internal/agent/: ok. hermes.go put back as on main: TestWSLColdPlaceOpensNothing red.
- GOOS=linux and GOOS=windows go vet ./internal/agent/ ./internal/tui/: ok.
2026-10-28 07:06:27 +08:00
yetone f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +08:00
yetone c544789047 agent, gui: the Codex takeover names browser use and offers Keep on ChatGPT
eddie.zhan on Discord (10-27): once Codex's allowance ran out, magpie
took it over and "many features stop working, browser use is blocked,
the agent says it has no permission".

Cause, from openai/codex 5a361b5: under the takeover magpie is Codex's
model provider without requires_openai_auth, so app-server's
getAuthStatus hands the app no auth token. The Codex app's Chrome
control needs that token, so browser use is off till the reset, with
cloud tasks, the usage meter and Log out. Image generation (actor
authorization header) and web search (provider default) stay. Bringing
requires_openai_auth back would bring back the greyed Send the takeover
exists to avoid, so it can't be kept by config.

The off switch existed (sign-in > Always ChatGPT, `magpie codex login
chatgpt`) but nothing under the takeover pointed to it. The default is
kept; the opened Codex row's takeover note now names browser use and has
a Keep on ChatGPT button (login=chatgpt) on its own line. In every
language.

Also fixed: Always ChatGPT picked while Codex was taken over on one of
its own models left model_provider = "magpie" for good. set now puts it
back on the sign-in as Join leaves it.

Run (on mote, at this tree):
- go test ./internal/agent ./internal/gui: ok except
  TestWSLColdPlaceOpensNothing (#3924) and TestMainWindowCorners/macOS_26
  (#2645), both red on origin/main f2b4b9894 too.
- TestCoreScriptBudget ok; app.js 1,310,432 under 1,310,460, not raised.
- GUI codex-app-out, codex-signin-always, i18n-keys in chromium and
  webkit at 980 and 440, every language: 95 pass, 1 red is #3897
  (i18n-keys plugin words, red on main).
- gofmt -l clean; go vet darwin, linux (nogui), windows on internal/agent
  and internal/gui.
Broken by hand: TestCodexOwnModelOutThenKeptOnChatGPT red on the old
set (model_provider = "magpie" left); codex-app-out red with origin's
app.js/i18n.js (no browser use in the note).
Not tried: the real Codex app, a real used-up account, the Windows box
and the Linux app.
2026-10-28 03:36:13 +08:00
ggbdpq 90258cf20a agent: a Codex in a WSL distro stands in for a model it names from its own config.toml (#2198)
StandIn("codex", …) read this machine's ~/.codex/config.toml alone, so a
Codex wired in a WSL distro (model_provider = "magpie", the only shape a
distro under NAT is wired in since #2145) naming a model magpie doesn't
serve (codex -m <unserved>) was answered 404, where this machine's Codex
goes to its config's model and a Claude Code in the same distro goes to
the stand-in its settings name (wslClaudeStandIn, #254). On Windows, when
this machine's Codex names none, StandIn now asks wslCodexStandIn: the
first distro running now whose config.toml has magpie as its provider,
read as codexStandIn reads it. The collecting of running distros the
probe found a kind in is shared with wslClaudeStandIn (wslReady); a
stopped distro is never opened. Off Windows nothing changes.

Reported with a patch by ggbdpq (gua2100 on Discord), independently
re-run by Edward4226. Taken as written except: the distro's config path
comes from the place's codexHome (where magpie writes it) rather than a
spelled-out ~/.codex; wslClaudeClassifier, which landed since with the
same loop, is left as it is (no test covers it); and TestWSLCodexStandIn
now also calls StandIn itself, so the Windows-only wiring is tested.

Run (sandbox HOME, caches pinned):
- go test -tags nogui -run 'TestWSLCodexStandIn|TestWSLClaude|TestCodexStandIn|TestClaudeStandIn' ./internal/agent: ok.
- Broken by hand: wslCodexStandIn returning "" fails TestWSLCodexStandIn
  ("stand-in: \"\""); wslReady without the running filter fails
  TestWSLCodexStandInSkipsStopped ("stand-in from a stopped distro:
  \"stopped/model\""). Restored: ok.
- On the Windows box (agent test binary built GOOS=windows): the same
  five tests pass; built with StandIn's codex branch put back,
  TestWSLCodexStandIn fails "StandIn on windows: \"\", want \"relay/main\"".
- go test -tags nogui -run 'WSL|StandIn|Wsl' ./internal/agent: one red,
  TestWSLColdPlaceOpensNothing (Hermes profiles of a stopped distro),
  red the same at origin/main 7f0f71a0e and filed as #3924.
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
  ./internal/agent: clean.

Not tried: a real Codex in a real WSL distro naming an unserved model
(the distros are fakes, on the Windows box too); a Windows Codex wired to
another model still wins over the distro's, as for Claude Code; the full
./... suite (one suite per machine, others running).
2026-10-28 00:47:44 +08:00
yetone 6d24d4f4ea agent: a hung wsl.exe no longer holds every Windows command 20s
On a Windows box whose wsl.exe hangs (`wsl -l` there never answered),
every magpie command took ~20s, `magpie version` too. A goroutine dump
taken 8s in showed start-up's moves (RenameLegacy, then the Cursor and
Antigravity effort moves) walking All(), whose WSL agents list the
distros: `wsl -l -q` waited out its 10s timeout, then `wsl -l --running
-q` waited out another. `magpie providers` waited too, through Copilot's
sign-in looked for in each distro's home.

- Start-up's moves look at this machine's agents only (local()). They
  came before WSL agents (the dial rename 09-23, the effort moves 09-28,
  the day WSL Codex came), so a distro has nothing for them.
- A listing that failed isn't followed by the running list: no distro
  was listed, so none runs. That was a second timeout under wsl's lock,
  which the GUI waits on.
- A listing that hung (failed after 5s or more) is remembered in
  wsl-hung beside magpie's settings for 10 minutes: a new process
  doesn't list again in that time, and a listing that answers removes
  it. A process that runs on (the GUI) lists again each minute as
  before.

Real run on the Windows box (10.0.0.132), wsl.exe hung, sandbox
USERPROFILE, old build (main c89284ae6) against this one:
  version    20.17s -> 0.12s
  agents     20.29s -> 0.24s
  providers  20.21s -> 10.16s the first time (it records the hang),
             0.14s after
wsl-hung was written at the first run's hang.

Tests: TestStartUpMovesAskNoWSL (start-up's moves ask wsl.exe nothing,
All() still has the distro's agents), TestWSLListFailsAsksNoRunning,
TestWSLHangRememberedAcrossProcesses. The first two are red on the old
code; the third goes red with the hang check turned off by hand.

Run at this head (base b10f43e89): gofmt; GOOS=linux/windows/darwin go vet
-tags nogui ./internal/agent ./internal/cli; go test -count=1 -tags nogui
./internal/agent ./internal/cli: cli ok (38s), agent ok but one test:
TestWSLColdPlaceOpensNothing is red on main already (#3924, from
34d38ed66's Hermes profiles), with or without this change.

Not tried: a real WSL that answers slowly but under 10s; it lists as
before.
2026-10-28 00:36:15 +08:00
yetone 791e27ec34 agent: the Codex app's Restart restarts only its app-server, its window stays
yoshi037070 (Discord, 10-27): when magpie restarted Codex, a new Codex
window opened. The switch paths (Connect, Disconnect, failover) already end
only the app's own app-server (codexAppStep, proc.End: SIGTERM on macOS,
exit 0 on Windows), and the app starts another and keeps its window. The
Agents row's Restart beside a Codex app left on the old list did not: on
macOS ReopenCodexApp ran osascript "quit" and then `open` on the bundle,
and that open is what brought up a new window.

Now ReopenCodexApp keeps its check (only a bundle the row lists as left on
the old list) and calls provider.RestartCodexApp, which ends each process
whose command line starts with <bundle>/Contents/ and is the app's own
app-server (isCodexAppOwnServer: an app-server, not --listen), waits up to
10s for them to be gone, and errs when none ran. The app, its window and
another program's --listen server are left alone. The confirm says only the
app-server restarts and the window stays; the status says "Codex app-server
restarted" (zh, zh-TW, ja, de). app.js stays under its budget, with no raise (1,310,458 of 1,310,460
after rebasing on 97332140a): the "asked first" comment went and
appReopen's shrank. The
agent-wiring page says the same.

The model picker: the app's restart recovery doesn't refetch its models
query; it refetches on the next window focus once the list is over 5
minutes old (staleTime), or when the picker is mounted again.

Run (rebased on origin/main, at this commit's tree):
- go test ./internal/agent: ok (280s).
- go test ./internal/provider -run 'Codex|Restart': ok. Before the rebase,
  the whole package with -skip TestUnreadLoginsWriteErrorsKeepCredentials
  (#3632 crashes the binary) was ok except TestFetchAsksASharedBaseOnce and
  its two siblings (#3854).
- go test ./internal/gui -run TestCoreScriptBudget: ok.
- GUI: agent-stale-copies in chromium and webkit, 5 languages, 980/440px:
  80 pass. i18n-keys: its only red is #3897 ("Runs as"). Before the
  rebase codex-app-stale passed too.
- gofmt -l clean; go vet darwin and windows for agent, provider, gui;
  linux for agent and provider (gui's linux vet needs wails' cgo here).
- Real app: a clone of ChatGPT.app 26.1021.31345 (APFS clone in a sandbox
  HOME, so the bundle is unique to it) run under that HOME. The real
  RestartCodexApp ended its app-server 32922 in 3.1s; the same main
  process (31894) started app-server 34143, and its one window (2273016)
  stayed the only window. The user's own ChatGPT was untouched.

Broken by hand:
- reopenApp back to appQuit + appOpen: TestCodexAppReopen red ("did quit
  …, open …").
- isCodexAppServer in place of isCodexAppOwnServer: TestRestartCodexApp…
  red (ended [2 3], the --listen one too).
- the bundle prefix dropped: red (ended [2 4], another bundle's).

Not tried: the picker refreshing in a signed-in app (the sandbox app isn't
signed in); Windows has no such Restart (the row's Restart for the Codex
app is macOS only; Windows switches already end codex.exe with exit 0 and
the app keeps its window, 3aead9c62).
2026-10-28 00:20:30 +08:00
yetone 34d38ed669 hermes: each profile picks its own model on the Agents page
dongshanfengdongshizhcn on Discord: "我的 hermes 有多个 profile,但现在
agent 的配置里面,似乎只能配置默认的 profile". magpie gave Hermes one model
picker, for the connected profile's config.yaml. A bot under
<root>/profiles/<name> could only follow it or keep its own model.

Hermes's layout comes from its own source (hermes-agent e5ea5fd9,
hermes_cli/profiles.py and main.py): named profiles live in
<root>/profiles/<name> (PROFILE_ID_RE, a .deleted tombstone, the identity
files), active_profile is the sticky one, "default" is the root, and a
profile's model is model.default/model.model under model.provider. magpie
already found these profiles (hermesProfiles/hermesOthers).

Now each profile other than the connected one has a field,
"profile:<name>" (hermesProfileFields). The opened Hermes row draws them as
Other profiles, one line per profile: its name, the app's model picker, and
`hermes -p <name>`. They are never a square of the row's own, and with one
profile only nothing new shows. Nothing needs setting up:
- a magpie model stashes the profile's own provider and model, then puts
  magpie's provider and the model into that profile only;
- a model of its own is written as model.default and gives back the stashed
  provider;
- Default puts back the profile's model from before magpie, or keeps the one
  it has. Disconnect sends the same empty value, so a profile never loses
  its model;
- a bot picked there is recorded (hermes:<path>:picked) and doesn't follow
  the connected config's next model (hermesFollow);
- a sync keeps magpie's provider current in a bot on magpie while the
  connected config isn't on it.
app.js stays under its budget through the previous commit; no budget was
raised. New string: "Other profiles" (zh, zh-TW, ja, de).

Run:
- go test ./internal/agent ./internal/gui ./internal/profile ./internal/tui
  ./internal/cli (-count=1). gui, profile and cli are ok. Two reds were already
  filed: TestFolderVarsAreListed (CARGO_HOME, fixed on main by 3116b8f58,
  which this is rebased on) and TestTUIFetchesSubscriptionModels/agent
  (#3919). Neither touches Hermes.
- TestHermes* ok after the rebase. gofmt -l is clean. go vet and GOOS=windows
  go vet pass on agent, gui and profile. GOOS=linux go vet passes on agent and
  profile; gui needs cgo for wails and doesn't cross-vet from macOS.
- GUI: new hermes-profiles.test.cjs (en, zh, zh-TW, ja, de; 1100px and 560px;
  chromium and webkit; 20/20) plus i18n-keys, claude-auto-mode,
  claude-subagents-pick, claude-subagent-effort-row, tier-effort,
  click-scroll, every agent-*.test.cjs, and the previous commit's Settings
  files: 899 of 900. The one red is the known #3897.

Broken by hand:
- origin/main's hermes.go fails TestHermesProfileModels ("pickers []").
- Without the picked guard in hermesFollow, coder followed main to
  deepseek/max.
- With Default deleting model.default, writer lost gpt-5.5.
- With the sync of bots on magpie turned off, writer's provider lacked a new
  model.
- origin/main's app.js fails hermes-profiles.test.cjs 10 of 10 in chromium.

Not tried: a real Hermes. By rule it isn't run under a sandbox
HERMES_HOME, since that rewrites the live ~/.hermes launcher. The layout was
read from Hermes's source, and the configs were written as its
_seed_model_config does. profile.yaml's display_name is not used; the line
shows the folder name, which is what `hermes -p` takes.
2026-10-28 00:17:40 +08:00
yetone e54a7d50b9 agent: a stopped WSL distro's files are never opened, which started it again (#3896)
The reporter stopped Ubuntu-24.04 with "Detect agents in WSL" on, and
magpie started it again within seconds. Opening any path under
\\wsl.localhost\<distro> starts a stopped distro, and every /api/state
did that:

- wslAgentsOf built every WSL kind at a stopped distro's place, found
  or not, only to ask Detected(). Two builders read files even at a cold
  place: hermesActive read ~/.hermes/active_profile and dshAt listed
  ~/.dsh/profiles. Now only the kinds the probe found are built (the
  same test: wslAgent's detect is k.found), and both builders read
  nothing when the place is cold.
- The Agents page asks every agent's pickers for options, and a stopped
  distro's agent kept the live options for fields with no asleep
  options of their own: Codex's memories and subagent effort read
  ~/.codex/config.toml (19 times a call), Grok Build's model read
  models_cache.json and config.toml, dsh's model listed its profiles.
  Each now has asleep options built from magpie alone: Codex's
  memories as its model, its subagent effort from magpie's catalog,
  Grok's from the live catalog, dsh's own models taken as 0.1.5 on
  (as its effort already was).

TestWSLColdPlaceOpensNothing builds every kind at a stopped distro over
a home with each kind's files, runs Values, Notice, Drift, Wired and
every field's Options, and fails on any path under it the os package
was asked to stat or open (-test.testlogfile). Red on the old code:
the hermes and dsh reads from building, then the 19 Codex, the Grok
and the dsh reads from the options.

Run at the pushed head:
tree a9e2aaf4ee, on origin/main d83f887a7 with 3116b8f58 (#3884,
JoeyWu-tech's patch, so TestFolderVarsAreListed is green), go1.26.8,
darwin/arm64: gofmt -l clean; go vet -tags nogui for linux, windows and
darwin of agent, gui, agentenv and library: ok; go test -count=1
-timeout 45m ./internal/agent ./internal/gui ./internal/agentenv
./internal/library: all ok (./internal/testenv
ok at the base before, 2a19245ce). Those packages ran at 2b0387574;
rebased on d83f887a7 (a gateway routing change only), vet x3 of agent
and agentenv and go test -run 'TestWSL|TestFolderVarsAreListed'
./internal/agent ran again: ok.

Real use on the Windows box (WSL 2, an Alpine distro of
mine, `magpie web` built with an os package that prints every
\\wsl.localhost path it is asked to stat or open):
- Before: terminate the distro, idle 10s (it stays Stopped), one
  /api/state, and it is Running again; the trace showed hermes and dsh.
- After: terminate, idle, then /api/state and
  /api/agent-models/claude@wsl:magpie-3896 three times each: the
  distro stays Stopped, and of the 45 traced accesses in that time
  none is under magpie-3896 (all are magpie-desktop's, which runs).

Not tried: the reporter's Ubuntu-24.04 with mirrored networking, and
a stopped distro with Codex, Grok or dsh really installed (the test
covers their files).
2026-10-27 23:52:55 +08:00
yetone 6c063ac1b2 agent: a model Codex hides joins Codex's own group in the picker
v0.1.1737 offered a model the user ticked but Codex's bundled catalog
hides (GPT-6.1 Terra) under a "Codex" section of its own, beside the
provider's group. ysm119 asked on Discord why one provider's ticked
models showed up as two groups. codexViaMagpieFor now gives such a
model the group and icon of the provider's own entries and lists it
first among them.

Run: go test -run 'Codex|WSL|Wsl|Via|Magpie' ./internal/agent ok;
go vet ./internal/agent for darwin, windows and linux (nogui) ok;
gofmt clean.
Broken by hand: with the group assignment removed,
TestCodexHiddenTickedModelOffered fails ("gpt-h in \"Codex\", gpt-a in
\"OpenAI\"").
Not tried: the GUI picker with a real Codex account.
2026-10-27 23:30:37 +08:00
yetone c80b32c936 agent: a model Codex hides but the user ticked is offered in Codex's picker
ysm119 (Discord) ticked four models on the Codex subscription and Codex's
picker offered three. GPT-6.1 Terra is "visibility": "hide" in Codex's
models_cache.json, so catalog.Codex() leaves it out of Codex's own list,
and viaMagpieFor dropped every codex/… entry as only a hop, so it was
offered nowhere. codexViaMagpieFor now drops a codex/… entry only when
Codex's own list already has its model; the rest stay, via magpie. Both
pickers (live Codex and Codex in WSL) take it; viaMagpieFor had no other
caller and is gone.

Run: TestCodexHiddenTickedModelOffered is red with the codex/… entries
dropped as before ([OpenAI:gpt-a]) and green with the fix;
go test ./internal/agent -run 'Codex|WSL|Wsl|Via|Magpie' ok; go vet
darwin and GOOS=windows; gofmt clean.
Not tried: picking gpt-6.1-terra with a real ChatGPT account.
2026-10-27 22:56:58 +08:00
yetone add927e604 codex: the Codex app beside the ChatGPT sign-in lists magpie's models too
laddieyao (Discord #general, 10-27): with Codex joined to magpie beside
its ChatGPT sign-in, the Codex desktop app's model picker showed OpenAI's
GPT models alone, while the Codex CLI listed magpie's. The /models
request does reach magpie's gateway and its answer holds magpie's
models. ChatGPT.app 26.1013's picker then narrows app-server model/list
to the models a Statsig config (107580212, use_hidden_models /
available_models) names, while Codex is on its built-in provider, unless
Codex reads its list from a file (model_catalog_json,
hasConfiguredModelCatalog) or names a provider of its own. The CLI has
no such filter.

Where the Codex app is installed (codexReaders has an "app"), and only
joined/beside the sign-in (not magpie as Codex's provider, not account
failover alone), magpie writes the list it hands Codex at
/backend-api/codex/models to ~/.codex/magpie-desktop-models.json and
names it with model_catalog_json. Codex is still on its built-in
provider. With a catalog named Codex asks for no list, so magpie asks
the backend itself, with Codex's live sign-in (provider.CodexLiveList):
its entries go in verbatim, base_instructions and all, merged as the
gateway merges them (codexMerged, factored out of codexModels: picked,
hidden, window, V1, AutoReview edits), magpie's models after them.

- A list not known (not asked yet, or the backend failing) is unknown:
  the file as it was stays, never an empty list; a key naming a file
  that is gone goes, as Codex loads no config then.
- Written via temp+rename at Join, set, settle and every Sync (so a
  change of magpie's models, picks or hidden models rewrites it, as
  SyncCatalog runs on them); the backend list is asked again hourly
  (5 min after a failure) and a change syncs again.
- A model_catalog_json of the user's own stands; none is written beside.
- magpie API, the app gone, or unwire take the key and the file out;
  unroute never restores the desk file as the user's catalog.
- connectinfo counts the file, so a running app on an old list reads
  as needing a restart.
- CLI-only machines: unchanged, the live /models path as before.

Run:
- Real account, sandbox HOME (copy of auth.json, chatgpt Pro; live
  ~/.codex untouched): Join wrote model_catalog_json and the file with
  the real backend's 10 entries (gpt-6.1-sol ... codex-auto-review, each
  with base_instructions) plus relay/claude-opus-5.5 and
  relay/claude-sonnet-4-5. Then the real app-server bundled in
  ChatGPT.app (codex 0.163.0-alpha.10.2, CODEX_HOME sandbox, base URL
  pointed at a dead port) model/list returned all 12, relay models
  visible, and config/read showed model_catalog_json set, which is what
  the app's picker checks to skip its filter.
- New tests: TestCodexDesktopListBesideSignIn, ...CLIOnly,
  ...KeepsTheirs (internal/agent), TestCodexDesktopCatalog
  (internal/gateway).
- Broken by hand, each went red: deskList a no-op (all three agent
  tests), the user's-own branch removed (KeepsTheirs), the gone-file
  branch removed (KeepsTheirs), the keep-last-good rule broken in
  codexDeskRefresh (TestCodexDesktopCatalog).
- go test -tags nogui -timeout 45m ./internal/agent ./internal/gateway
  ./internal/provider ./internal/cli at bc0a99bb6 (on 68bbcc01c):
  agent, gateway, cli ok; provider red on TestUnreadLogins...
  (synctest crash, #3632) and three TestFetch* tests (#3854), both red
  the same at origin/main 68bbcc01c / 5a3292354 run alone, both filed.
- Rebased over e7f21dba5 (Disconnect keeps a hand-set catalog): the
  conflict in unroute merged (the desk key counts as no catalog of the
  user's), and -run 'CodexDesktop|Disconnect|Unwire|Catalog'
  ./internal/agent ok. The packages' run at the final head could not
  build: the machine's disk was full (other sessions).
- gofmt -l clean; go vet ./... on darwin, GOOS=linux, GOOS=windows ok.

Not tried: clicking the real desktop app's picker (the app-server
answer and config were checked, not the GUI); the Windows Store app
(its readers get no version but count as the app; not run there); a
backend list change rewriting the file while the app runs (the app
needs reopening to read a new file, which connectinfo's restart notice
covers).
2026-10-27 18:38:27 +08:00
yetone 28f3c4d7fd codex: the Codex app's first 100 models hold the ones used, hidden ones last
@ZhenLuoTTAWDTT on X: with Codex on magpie the model list stops short,
and the models past it can't be chosen.

Cause, from the clients' own code: the Codex app (ChatGPT.app
26.1013.40934, app-initial-90eb42395b7d.js) and the VS Code extension
(openai.chatgpt 26.51021.22027, model-queries-667cf4bd657d.js) both ask
their app-server for model/list with includeHidden, cursor null and
limit 100 (e?.limit??100) and never ask for nextCursor. codex-rs's
list_models pages the list sorted by priority, hidden entries counted,
so anything past the 100th is in no picker there. The CLI's /model
(tui model_popups.rs) lists every preset in a scrolling popup and has no
cap. magpie truncated nothing; its models are numbered after the
account's own, so a user with many models lost everything past ~100 in
the app, while hidden entries (codex-auto-review and the like) took
slots at the top.

Fix: codexcat.Fit ranks the list last of all, on every route magpie
hands Codex a list (/backend-api/codex/models after the user's own
order, /v1/codex/models before its 1 MiB cut, and the
model_catalog_json file via CatalogUsed): hidden entries go after every
listed one, and with more than 100 listed, the models Codex used in the
last 30 days (usage.CodexUsed, most recent first, at most 100; on
/v1/codex/models only the asking key's, CodexUsedBy) are brought into
the first 100 in the order they stood. The rest keep their order. The
list's ETag and X-Models-Etag carry a tag of the used set
(codexcat.UsedTag), so Codex asks again when it uses a model it hadn't;
CodexUsed is read at most once a minute, or at once when Append writes a
Codex call to a model it doesn't hold. Documented in
docs/subsystems/gateway-routing.md.

Tests (each red on the old code, broken by hand: Fit a no-op, the gateway
calls and the used tag removed, Append's codexUsedNew removed):
TestFitKeepsUsedModelsWhereTheCodexAppReads, TestFitLeavesAShortListsOrder,
TestCatalogUsedFits, TestUsedTagIsTheSet (codexcat), TestCodexUsed
(usage), TestCodexModelListKeepsUsedModelsInTheAppsHundred and
TestCodexCatalogKeepsTheKeysUsedModelsFirst (gateway).

Real run: codex-cli 0.162.1's app-server in a sandbox CODEX_HOME (never
~/.codex) with a model_catalog_json of 3 hidden entries at priority 1-3
and 150 listed models, driven over stdio with the app's own request
(model/list includeHidden, limit 100). Before: page 1 held 100 of 153,
3 of them hidden, the last many/model-096, nextCursor "100". The same
catalog put through Fit with many/model-140 used: page 1 has no hidden
entry and ends with many/model-140. The TUI's /model scrolled to all
150 (tmux).

Run with this change on e4ca47b0f: gofmt -l clean; go vet
-tags nogui with GOOS=linux and GOOS=windows on codexcat, usage, gateway
and agent clean. go test -count=1 -timeout 45m: codexcat ok, usage ok;
-run 'Codex|Fit|Used|ModelList|Catalog' on gateway, usage and agent ok
(122s, 11s, 80s). The whole gateway and agent packages ran too, but the
machine's disk was full under other sessions' runs (209M to 2.5G free),
and 959 lines of that log are "no space left on device". Of the reds,
three are not that: TestFolderVarsAreListed is #3884 (CARGO_HOME, red on
main since e4552cca9); TestHistoryKeepsDaysAndDropsOld (gateway) and
TestSuffixModesReachAgentFiles (agent) failed beside half-written
settings files and pass alone 3 of 3 at this commit. Not run: the full
./... suite (no room on the disk); the Codex app and VS Code extension
themselves against a magpie with this change (their request was read
from their bundles and replayed against a real app-server).

Rebased on ca8a6f346 (agent rename and Codex app route, claude_runs in
gateway) and run again: GOOS=windows go vet on agent
and gateway clean; -run 'Codex|Fit|Used|ModelList|Catalog' ok on
codexcat, usage and gateway (75s), and with |Rename ok on agent (68s).
Then rebased on 94c2aaecb (usage rename) and usage run whole again: ok
(88s).
2026-10-27 18:37:16 +08:00
yetone ca8a6f346a agent: a renamed routing group moves its agents, and the Codex app reloads a changed catalog
lucis0116 on X: renaming a provider or a group in magpie didn't reach
every agent.

Display names already reached the agents' files: store and SaveGroup
drop the catalog, and SyncCatalog writes the new "<model> · <name>" and
"<group> · routing group" labels into Codex's model_catalog_json, Claude
Code's picker, OpenCode and Pi (checked in a sandbox HOME). Two gaps
were left:

- A routing group given another id (Routing page, `magpie groups
  rename`, TUI) left every agent on group/<old>, which magpie no longer
  has. The CLI even said "agents set to group/from need group/to now".
  agent.RenameGroup now moves each agent field on group/<old> to
  group/<new>, spelled as the agent spells it. It goes through
  renameRefs, the move RenameProvider already made, now shared by both,
  then SyncCatalog. The GUI, CLI and TUI call it in place of
  provider.RenameGroup.
- The Codex app's own app-server reads model_catalog_json only as it
  starts, and KeepCodexAppOnItsProvider restarts it only when
  codexAppRoute changes. The route named the catalog's path, not what
  the file holds, so a renamed provider or group, or a model added,
  stayed on the old list until the user quit the app. The route now
  carries a hash of the catalog's bytes (codexCatalogTag, read again
  only when the file's size or time changes). The restart goes through
  the existing idle gate: no Codex request in flight, 10s idle, no turn
  open. A write of the same bytes is no change.

Run, in a sandbox HOME only:
- TestRenameGroupMovesTheAgentsOnIt (new): Codex, Claude Code, OpenCode
  and Pi on group/smart, renamed to clever: each said moved and each
  file on group/clever, none naming group/smart.
- TestCodexAppRouteFollowsTheCatalog (new): the route changes when a
  renamed provider rewrites the catalog, and stays put when the same
  bytes are written again.
- Broken by hand: RenameGroup's match turned off makes the first test
  red (no agent moved, every file on group/smart). The catalog line
  dropped from codexAppRoute makes the second red ("a provider renamed
  left the Codex app's route as it was").
- At aded9beea (base ad3833512): go test -tags nogui -timeout 45m
  ./internal/agent ./internal/cli ./internal/gui ./internal/tui
  ./internal/provider -count=1: cli, gui and tui ok. agent red on
  TestFolderVarsAreListed (#3884, red on main since e4552cca9) and
  TestCodexDisconnectStaysWithAccountsOn/login=api, which passed 3 of 3
  alone and isn't on this path (filed #3891). provider crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" in filememo.Forget (#3632, open on main).
- Rebased on 56de2d192 (a312bf3e3 adds a switched account's app-server
  to the same stale set; no overlap): go test -tags nogui -count=1
  ./internal/agent -run 'Rename|CodexApp|Sync|Group|Codex|Hermes' ok
  at this head; ./internal/provider -run
  'CodexApp|Group' ok at a312bf3e3 + this change. The disk was full (other sessions' suites), so the
  whole of each package wasn't run again at this head.
- GUI: group-id-dots, group-morph, agent-model-groups and i18n-keys,
  32 of 32. No GUI script changed, and the GUI tests answer the API in
  memory.
- gofmt -l clean. go vet -tags nogui on agent, cli, gui and tui for
  darwin, linux and windows: ok.

Not covered:
- Claude Desktop reads the gateway's model list only as it starts. It
  still needs its Restart button (AppBehind) after a rename, as after
  any other catalog change.
- Pi, omp and StepCode enabledModels: RenameRefs renames magpie/<old>/
  provider entries only. A group's magpie/group/<old> entry goes as
  scope-gone, and the pick of group/<new> is added again. Not checked
  entry by entry.
- Codex signed in beside magpie (models_cache.json aged by the catalog
  tag) was not run again here.
- No real Codex app restart was watched. The reporter's agent isn't
  named.
2026-10-27 18:22:29 +08:00
yetone 56de2d1928 hermes: a model picked in magpie reaches the profile hermes starts in, and Off then On leaves every bot a model (tjhhhh)
tjhhhh on Discord (0.1.1673): switching the model of a Hermes profile
other than the default didn't take, and turning magpie's takeover Off and
On again lost the default model, so the hermes CLI failed at start.

Causes, read from Hermes' source (hermes_cli/main.py
_apply_profile_override, profiles.py):
- `hermes profile use X` writes <root>/active_profile, and every later
  `hermes` runs profiles/X. magpie always wrote <root>/config.yaml, the
  profile hermes no longer started in.
- At Off, hermesUnwireProfile deleted model.provider and model.default
  from every profile on magpie and put nothing back. On rewrote only the
  connected config, so the profile hermes ran had no model.

Now:
- hermesActive: the config magpie connects is the profile hermes starts
  in: HERMES_HOME when it names a profile, else active_profile's (BOM and
  whitespace trimmed) when it is a live profile (not "default", a valid
  name, no tombstone, its folder there), else the root.
- Off leaves each bot on magpie on a model it can start with: its own
  stashed model if it had one, else the connected config's own model,
  with that provider's providers.<name> entry copied in when the bot
  lacks it. What magpie put there is kept as hermes:<path>:off.
- On puts magpie back on each bot still on what Off left (hermesBack); a
  bot the user moved while Off keeps theirs; a bot with no model at all
  gets magpie's.
- Bots on the model magpie or hermes last picked follow a new pick
  (hermesFollow now also follows the connected config's current default).
- gone.go: a profile folder's Agent finds the root's hermes-agent
  checkout, so it counts as installed.

Run:
- go test -tags nogui -count=1 -run 'CLIMissingHermes|Hermes'
  ./internal/agent: ok.
- New tests red on the old code: TestHermesStickyProfile
  (hermes_test.go:811 'active_profile "coder\n": connects .../.hermes,
  want .../.hermes/profiles/coder'), TestHermesOffAndOnKeepsEveryBotsModel
  (hermes_test.go:698 'off: writer is on {Provider: Default:}, want
  {Provider:mine Default:kimi-k3}'), TestHermesBotsFollowTheModelHermesPicked
  (hermes_test.go:768 'writer stayed'); TestHermesProfiles' writer after
  disconnect now expects the root's own model, not nothing.
- Whole internal/agent (-timeout 45m, logged): the disk filled (other
  sessions' temp files, under 1 GB free) and 43 tests failed on "no space
  left on device"; each of them, and every Hermes test, passed on a rerun
  (131s). TestFolderVarsAreListed is red on main since e4552cca9 (#3884),
  not touched here.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  ./internal/agent: clean.

Broken by hand: without the hermesBack call TestHermesOffAndOn fails at
hermes_test.go:716 'on: writer is on {mine kimi-k3}, want {magpie
deepseek/pro}'; following only the recorded pick fails
TestHermesBotsFollow at 768; gone.go reverted fails TestCLIMissingHermes
at install_missing_test.go:132.

Not tried: the real hermes binary (it rewrites the live ~/.hermes launcher
under a temp HERMES_HOME); a real Off/On in the reporter's setup; the full
go test ./... (disk full).
2026-10-27 18:15:16 +08:00
yetone 5a32923542 edit: a write of the bytes a file already holds leaves it alone (#3870)
Every SyncCatalog wrote agents' config files again with the same bytes:
a new mtime that wakes every watcher of the file (filememo, the Codex
daemon loop, the agent's own reload), and a temp-and-rename that swaps
the file under an agent reading it. #3870 named Kimi Code, Grok and
AtomCode; with every agent connected in a sandbox HOME, a second sync
rewrote 15 files: .claude/settings.json, Cline's providers.json,
CodeBuddy, Copilot BYOK, Factory, Qwen, Snow (both), WorkBuddy (both),
ZCode, Kimi Code, Grok, AtomCode and magpie's stash.json.

WriteAtomic, which every TOML, JSON, YAML and dotenv writer goes through,
now reads the target after the filter and BOM are applied and returns
when its bytes are the same. A real change is written as before.

Tests:
- internal/edit TestUnchangedWriteKeepsFile: TOML table/key/top, JSON,
  YAML and .env; mtime and inode kept on the same bytes, a changed value
  written. Red in all 6 with the check turned off by hand.
- internal/agent TestSecondSyncWritesNothing: every connectable agent
  connected, second SyncCatalog + dshWiredOnce writes no file. Red with
  the old WriteAtomic (15 files), green -count=3 with this one.

Run:
- At 68bbcc01c + this change: gofmt clean; go vet -tags nogui
  internal/edit and internal/agent for linux, windows, darwin ok;
  go test -timeout 45m over every importer of internal/edit (access,
  agent, autostart, backup, cli, codexcat, daemon, davsync, edit,
  gateway, library, mcpauth, plugin, profile, provider, settings,
  update, usage): all ok but provider's TestFetchAsksASharedBaseOnce
  and two siblings (red the same on unchanged origin/main ad3833512,
  3 of 3: #3854) and update's TestRelaunchOpenTriedAgain (TempDir
  cleanup under load ~90, passes 3 of 3 alone: #3881).
- At the pushed head (rebased on ad3833512): gofmt, 3-OS vet, all of
  internal/edit, and internal/agent's new test plus Disconnect, Codex
  hand-edit, Kimi, Grok and AtomCode tests: ok. internal/gui, which
  imports internal/edit, was not run.

Not tried: the real Kimi Code / Grok / AtomCode apps watching the file.
2026-10-27 17:26:30 +08:00
yetone e7f21dba5e codex: Disconnect keeps an effort or model list the user set by hand after Connect
@yhwangl on X asked that putting an agent's config back never write
over what the user changed by hand after magpie took it over: only the
keys magpie changed go back, and a key magpie wrote that the user has
changed since keeps the user's value.

Codex's Disconnect put back the pre-connect model_reasoning_effort and
model_catalog_json whatever they were by then. An effort the user set
by hand to high after connecting went back to the low it was before,
and a model list of their own put in by hand was deleted.

Now:
- the effort goes back only while it is still one magpie set: the one
  settle moved it to (stashed as codex.effort_set), the one picked on
  the Agents page (the applied record), or none;
- dropProvider takes model_catalog_json out only when it is magpie's
  list (or empty), and unroute puts the old list back only where the
  key is empty;
- model_provider is put back only where the key is empty.
Other agents' fields already clear only a value still magpie's, and
put the pre-connect backup only into a field left empty.

Run, at this commit's tree (HEAD df8374921 plus this change), sandbox
HOME, private GOCACHE:
- gofmt -l internal/agent: clean; go vet ./internal/agent: ok
- go test -tags nogui -count=1 -run Codex ./internal/agent: ok (121.7s)
- broken by hand (the effort and catalog checks taken out of unroute):
  TestCodexDisconnectKeepsHandEdits went red, green again with them.
Not run: the full suite (runs with the uninstall change).
2026-10-27 17:02:55 +08:00
yetone df83749218 codex: Disconnect and Connect restart the Codex app's own app-server, so the app stops sending to magpie without a restart
JiangLiuer222 on X: after Disconnect the Codex app kept sending to
127.0.0.1:3425, now and then. The app's app-server reads config.toml only
as it starts, so one started while Codex was connected kept the gateway's
base URL until the user quit the app.

Now the gateway's watcher (KeepCodexAppOnItsProvider, from 8b0132b3d)
ends the app's own app-server whenever what it reads at start and magpie
writes changes: model_provider, openai_base_url, model_catalog_json, the
magpie table's base_url and the used-up takeover (codexAppRoute, through
the provider.CodexAppRoute hook, which replaces CodexAppOnMagpie). Same
guards as before: never while a Codex request is in flight or ended in
the last 10s, never with a turn open, only on magpie's Codex home, a
clean exit. At its first look only a used-up account's app-servers are
ended, as before.

Also checked: after Disconnect nothing writes the base URL back. Failover
and the stale-model rewire skip a disconnected Codex, and the takeover
paths in Sync need Codex joined or on magpie.

Run at this tree (on origin/main 32ea16c5a), private GOCACHE, sandbox HOME:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  (internal/agent, internal/provider); go build darwin, windows, linux
  nogui.
- go test -count=1 -run Codex ./internal/provider ./internal/agent: ok
  (at 47175a68f); -run CodexApp again at 32ea16c5a: ok.
- Broken by hand: comparing only the takeover flag (the old condition)
  made TestCodexAppServerRestartedOnDisconnect red ("disconnected, idle:
  ended [], want [60]").
- Real app: ChatGPT.app 26.1013 under a sandbox HOME (CFFIXED_USER_HOME),
  this build's magpie serve on 3492, Codex connected to a custom
  provider by magpie codex fakeai/fake-1. magpie codex default: the
  app's app-server 76497 ended within 5s, the app started 77343 and
  logged "Codex CLI process exited classifiedAsExpected=true code=0";
  window kept. Connect again: 77343 -> 79138. The owner's own app-server
  (1902, HOME=~) was untouched.

Not tried: Windows and Linux real apps, a turn running during the
switch (unit-tested only), a signed-in sandbox app (it was signed out,
so no turn was sent to see the new route used).
2026-10-27 16:33:29 +08:00
yetone 8b0132b3d2 codex: the Codex app sends again on every system as soon as magpie takes a used-up ChatGPT account over, and gets it back at the reset
Ethereal499 and Isdavexxx on X, MasterYi on Discord, #540. The Codex app greys
Send for every model, magpie's too, while the ChatGPT account it is signed in
to is used up. Its composer's gate (ChatGPT.app 26.1013) reads authMethod
"chatgpt" plus rate limit allowed=false, and it asks account/read only when its
app-server starts. ef37b6fb7 (v0.1.1381) could fail in practice:
- (a) The reopen was macOS-only, ran once per time out, only from the GUI
  process. A Windows or Linux user, a magpie without its window, or a second
  time out stayed greyed.
- Switch-back: the app stayed on magpie (authMethod null, no cloud tasks or
  Log out) after the reset. Nothing restarted it.
- (c) Detection lag: the account was read every 5 minutes.
- The notice sat on the Providers page, not on Codex's Agents row.

Now:
- The gateway process (`provider.KeepCodexAppOnItsProvider`, every 3s, on
  every OS) ends the Codex app's own app-server each time `Agent.AppOut`
  flips, both ways. The app starts another at once and reads account/read
  afresh. Its window, threads and drafts stay.
- It never ends an app-server while a Codex request is in flight through
  magpie or ended in the last 10s (`Server.CodexBusy`, Codex's requests only),
  or while a session under the Codex home has a turn open (`codexTurnOpen`).
- It ends only the app's own app-server. That one runs on stdio; one another
  program starts with `--listen` is left alone (Miyi Helper runs one on this
  Mac). It must also run on magpie's Codex home (`proc.EnvOf`: ps -E on macOS,
  /proc on Linux; Windows can't tell).
- The exit is clean (`proc.End`: SIGTERM, or TerminateProcess with code 0 on
  Windows). The app shows any other exit as a crash.
- A listing that fails is taken up again at the next look. One that outlives
  3 ends, or is denied, makes the row say to quit and reopen.
- The active account is read every minute while it is held or a window is at
  90% or more (`codexLookEvery`).
- Codex's Agents row says "On magpie until <reset> · ChatGPT allowance used
  up". Hovering it, or opening the row, says what is off until then (cloud
  tasks, the usage meter, Log out) and that it all comes back on its own. In
  en, zh, zh-TW, ja and de.
- Removed: gui's keepCodexAppSending/codexAppOut, provider's episode
  bookkeeping, and the Providers-page notice.

Not changed, by design:
- A Codex own model that no magpie account serves stays as it is: magpie
  can't serve that turn.
- Account discovery off and "Only switch Codex's sign-in" (login=chatgpt) are
  the user's own choices, and are left alone.

Full suite green at cff1a9686 (on origin/main 6ce0f14b9), below. At
4541b3e97 (rebased on 430e3050d, which touched gateway.go, app.js and
i18n.js beside this) ran: gofmt -l, go build ./..., go vet on darwin,
linux (-tags nogui ./...) and windows; go test -run Codex ./internal/provider
./internal/agent ok; GUI codex-app-out (22 ok) and codex-app-stale (20 ok),
chromium and webkit. Pushed rebased on b92cb2f59 (two more commits,
neither in these files), built, not rerun.

Run at this commit (cff1a9686, on origin/main 6ce0f14b9), with a private
GOCACHE (another session ran go clean -cache mid-run):
- gofmt -l: clean. go build ./...: ok.
- go vet: darwin (touched packages); GOOS=linux -tags nogui ./...;
  GOOS=windows (touched packages).
- go test -count=1 -timeout 45m: internal/proc, internal/provider,
  internal/agent, internal/gateway, internal/gui all ok, skipping four
  tests red on main without this change, each already filed:
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632, a synctest crash
  since 091153bf) and TestFetchAsksOneListOnceForTwoBasesOfIt,
  TestFetchUnionsProtocolListsWithoutChat, TestFetchAsksASharedBaseOnce
  (#3854, since 6eb510f78). All three of the latter fail the same at
  origin/main 6ce0f14b9 and at 353519f55 without this commit.
- GUI at cff1a9686, chromium and webkit, 231 cases ok: codex-app-out (5 languages, 980 and 440px),
  i18n-keys, gui-de/ja/zh-tw, codex-app-stale, codex-accounts-via,
  agent-stale-copies, agent-app-restart, agent-failover, agent-connect,
  agent-layout, agent-expand-steady, agent-connected-unfolded,
  agent-notice-lang and codex-signin-always.
- Windows box (cross-built test binaries): proc and provider's Codex app
  tests pass. TestEndExitsClean passes there and goes red with exit code 1.
- Broken by hand, each went red:
  - Codex-only busy: TestCodexBusy.
  - The 90% cadence: TestCodexLookEvery.
  - The retry after a failed listing: TestCodexAppServerUnknown.
  - The turn guard: TestCodexAppServerRestartedEachWay.
  - The --listen exclusion: TestCodexAppOwnServer.
  - Code 0 on Windows: TestEndExitsClean.
  - The row's notice: codex-app-out.test.cjs, 4 of 4.
- Real app: ChatGPT.app 26.1013 in a sandbox HOME/CODEX_HOME, with this
  build serving on 3492/3493. Codex was put on magpie as Sync does for a held
  account (model_provider = "magpie", codex.out in stash.json). OpenAI's usage
  reading to the app was never faked.
  - The first listing ran out at load ~200, so the timeout is now 30s. The
    next look ended the app-server, and the app started another 12s later.
    Its profile went from "Pro · Usage · Log out" to "magpie" with no reopen,
    and /api/state carried appOut.
  - Undoing it ended the app-server again, and the profile came back to Pro,
    Usage and Log out.
  - The owner's own ChatGPT app (its app-server on ~/.codex) was never
    touched.
- One webkit codex-app-out run at load 291 had one red subtest, name lost.
  It passed 3 of 3 alone and in two full webkit runs.

Not tried:
- The Windows Store app (not installed on the box), and a real Codex app
  on Linux.
- A real used-up account.
- A turn running in the real app while the switch happens (unit-tested
  only).
2026-10-27 15:57:41 +08:00
yetone 2f00fa6420 agent: PenguinHarness's desktop app is detected without its CLI (rankyurky_80676)
rankyurky_80676 on Discord (macOS): PenguinHarness's desktop app
installed, and magpie didn't detect it. The app runs its own server on
the CLI's root, ~/.penguin/data, and needs no penguin command: it links
/usr/local/bin/penguin only if the user lets it (cli-install.ts). So
~/.penguin with no CLI was taken for an uninstall's leftover (cliHeld),
and an app never opened had no ~/.penguin at all.

Now "penguin" is in desktopApps, read from Prism-Shadow/penguin-harness
main (packages/desktop/electron-builder.yml, desktop 0.2.17): bundle id
com.prismshadow.penguinharness, PenguinHarness.app in /Applications or
~/Applications (or a folder one level down, or where Spotlight has it);
on Windows PenguinHarness\PenguinHarness.exe under
%LOCALAPPDATA%\Programs, or the folder registered under
8bb9acb7-2bdc-596b-9669-7b014ab1c47f: electron-builder's UUID v5 of the
appId, the same derivation giving dsh's known 1bf39983-… from
com.deepseek.dsh. penguin.go's sign is HasApp, as dsh's is, so the app
alone is detected before its first start, its version shown and no CLI
install offered. Connect then writes default_project's
.project_config.toml, which the app's server adopts without overwriting
(project-service.ts provisionInitialProject; app-identity.ts: the
release profile shares the CLI's root). Linux's deb links
/usr/bin/penguin, found as the CLI; an AppImage is anywhere and is not
looked for. A WSL twin never has the app.

Tests: TestPenguinDesktopAppDetected (app only, opened, another bundle
id, ~/Applications, the Windows exe, WSL), TestPenguinDesktopAppRegistered,
TestPenguinDesktopOnlyConnects. The Agents page is unchanged (it already
shows an app's version for dsh), so no GUI test.

Run at this head (rebased on origin/main 6ce0f14b9):
- go test ./internal/agent -count=1 -timeout 45m: ok at the previous base (616s); at this head it
  started before the push, its result is in the follow-up. Targeted at this
  head: go test -run 'Penguin|Dsh|DesktopApp': ok
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok

Broken by hand: without the sign, TestPenguinDesktopAppDetected (app
only: detected false, offered true) and TestPenguinDesktopOnlyConnects
red; without the desktopApps entry all three red.

Not tried: the real PenguinHarness.app (its Info.plist fixture is built
from the electron-builder config, not read from a downloaded dmg; the
disk was too full for one); Windows; the guid isn't read from a real
installer.
2026-10-27 15:17:26 +08:00
yetone 6eb510f788 codex: a relay's own Codex entries reach Codex as it gave them (ctopsc on Discord)
ctopsc's custom provider points at a self-hosted sub2api (Responses). Its
plain /v1/models gives id, display_name, owner and created alone; asked
with Codex's client_version it answers Codex's own catalog shape per model
(window, max window, levels, base_instructions, tools, truncation, tiers).
magpie read the plain list and made Codex's entries up from models.dev, so
GPT-6.1 Terra went to Codex at 922000 where the relay said 272000.

What changed:
- catalog: a list row in Codex's shape (slug, supported_reasoning_levels,
  shell_type, base_instructions: CodexEntry) is kept whole on the Model
  (Codex), its window, max window and input modalities read off it.
- provider: for a provider the user added by its address (no preset, no
  account) whose Responses list has no such row, fetchOne asks the same
  URL once more with client_version (codexEntries). Only where the list is
  fetched (add, key change, Refresh), never per Codex poll. The answer only
  adds entries to models the plain list has. One that fails or can't be
  read keeps the last list's entries (a failed read is unknown); one that
  answers plainly says there are none. The entry's levels become the
  model's levels, and withUltra adds none to it.
- codexcat: listedEntry hands Codex the relay's entry as given,
  base_instructions included and unchanged, with magpie's slug, name,
  priority and " via magpie" description. The user's window, compaction,
  levels and image setting still win (levels keep the relay's
  descriptions). A model without one is made as before.
- agent: Codex's magpie-models.json gets the same entries.
- docs: providers-accounts.md, "A relay's Codex entries".

Run at this head (sandbox HOME, pinned caches):
- go test -tags nogui -count=1 ./internal/catalog ./internal/codexcat
  ./internal/provider ./internal/agent ./internal/gateway before the
  rebase onto 508911e43: catalog, codexcat, agent and gateway ok;
  provider crashed in TestUnreadLoginsWriteErrorsKeepCredentials with
  "close of synctest channel from outside bubble" in filememo.Forget,
  which is #3632 (open, not this change).
- After the rebase onto 508911e43 (it changed internal/agent): catalog,
  codexcat ok; agent whole, with TestWSLMoreAgentsPick, TestZooCode and
  TestZooCodeFresh red on "no space left on device" (the machine's disk
  was full), then those three and -run Codex ok; provider -run Codex ok;
  gateway -run Codex ok (its first link failed on the full disk).
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./... and GOOS=windows go vet ./... clean.
- Not run: the full go test ./...; it was started and stopped when the
  disk filled (under 1GB free), and is to be run after the push.

Broken by hand, TestCodexListedEntry red each time (restored after):
- no client_version ask: "asked with client_version 0 times on one
  fetch, want 1";
- listedEntry turned off: service_tiers, levels, model_messages,
  shell_type ("unified_exec"), base_instructions (magpie's "You are
  Codex, based on GPT-5…"), max_context_window and more differ;
- a failed read taken as none: the keeps-last subtest red (truncation
  limit 10000 vs the relay's 12000, shell_type unified_exec);
- the user's levels ignored: all four levels and default "medium".

Not tried: a real sub2api or ctopsc's literal reply (the fixture follows
codex-rs ModelInfo, with values magpie never writes); a Codex binary
reading the list; /backend-api/codex/models directly (same
codexcat.Entries as /v1/codex/models, which the test reads). Not changed:
a user-set models URL is not asked again with client_version, and a
model on a dead side loses its entry with it. A list saved before this
gets the relay's entries at its next Refresh, not by itself.
2026-10-27 14:28:01 +08:00
yetone 508911e431 agent, gui: Codex's ChatGPT models stay in its picker with a routing group on and its own models switched off (shiqi_40904 on Discord)
shiqi_40904 on Discord: "开启路由组后,agent 设置页面-codex-模型列表里不会显示
codex 模型,关闭路由组后才会显示".

Cause: the switch "Show Codex's own models" (#1642, provider.
OwnModelsHidden) has agent.Picks drop every option of the agent's own
(no catalog Ref) from a picker that offers one of magpie's models. On a
ChatGPT sign-in, Codex's picker offers its own models and leaves out
magpie's codex/... (viaMagpieFor: only a hop), so with no routing group
it has no Ref option and the switch did nothing; a group gives it one
(group/mygpt) and the switch then took out every Codex model but the one
it was set to. The picker was Default, gpt-5.5 and the group; turned
off, the group took the Ref away and they were back. The list's switch
itself shows only while a group is on (OwnModels), so with the group off
nothing on screen said why.

Fix: Option.Served marks one of the agent's own that magpie's list shows
it too, on the account it is signed in to. Codex's own models a ChatGPT
account in magpie serves (codex/<model> in CatalogFor("codex")) are
marked so (codexInMagpie, live and WSL Codex), and agent.Own leaves them
out, so the switch never takes them out; the list's tick decides them
(one taken out there is the switch's again). With all of them served,
OwnModels is false and the list has no switch for Codex. The GUI's
filter on closing the list (closeAgentModels) keeps o.served the same
way. Codex on a relay of its own (model_provider of the user's) is
unchanged: those go straight to the relay, the switch's to take out.

Sibling check: Claude Code offers magpie's models on its own account as
catalog options (Same, with Ref), so the switch leaves them; DeepSeek
Harness's own are not served by magpie; the TUI and the tray panel take
their options from agent.Picks (server); WSL Codex's options marked too.

Reproduced first in a sandbox HOME (fake ChatGPT auth.json,
models_cache.json, catalog.SaveLive codex with 5 models, group MyGPT of
codex/gpt-5.5 + codex/gpt-5.4, own models switched off): agent.Picks
gave [gpt-5.5 group/mygpt] with the group, all five without it. Then
drove the real GUI (Handler on 127.0.0.1:3719, Playwright chromium):
Codex connected, its picker with the fix lists Default, Disconnect,
gpt-5.5, MyGPT, gpt-5.4, gpt-5.4-mini, gpt-5.3-codex, gpt-5.2; the list
shows Routing groups 1/1, Codex 5/5 and no own-models switch.

Run at this head (rebased on origin/main 3a89dd53c):
- go test ./internal/gui ./internal/tui: ok (202s, 38s);
  ./internal/agent: ok (406s) on a second run, the first ran out of
  disk ("no space left on device" in TempDir, the machine at 100%)
- new TestCodexOwnModelsStayWithGroupOn: red with agent.Own back to
  ignoring Served ("group on: gpt-5.4 not in Codex's picker [gpt-5.5
  group/mygpt]", the reporter's case), green with it
- GUI: agent-models-own-served.test.cjs (new; chromium + webkit, en +
  zh, 420 and 1100) red 4/4 in chromium with o.served dropped from the
  close filter, green 8/8 with it; all agent-models*, i18n-keys,
  claude-picker*, picker-rail-current, editor-picker-clicks: 66 pass
  before the rebase; at this head agent-models-own, -own-served,
  -group-on, -picker and i18n-keys: 40 pass
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build

Not tried: a real ChatGPT account (the sign-in is faked in the sandbox),
the Windows box and WSL Codex (its options are built the same way), the
whole GUI suite (the change is the list's close filter, not the shared
picker).
2026-10-27 13:43:28 +08:00
yetone f51ab771f6 catalog, provider: a model only models.dev's lab lists is known, and a Claude account lists the gated models Anthropic told its Claude Code of (iebb on Discord)
iebb on Discord (10-27): his account has Claude Mythos 5.1, magpie
doesn't list it. models.dev took the gated Mythos 5.1 out of
anthropic's provider list (models.dev #11327) and kept only its lab
file, models/anthropic/claude-mythos-5-1.toml (#11328).

Cause. magpie read only models.dev's api.json (providers -> models).
The Claude subscription's list was exactly catalog.Provider("anthropic"),
so Mythos 5.1 left it with that PR. And a vendor list that still
returns it (an Anthropic key's /v1/models) got no window, reply limit,
name or thinking for it, since nothing read the lab catalog.

Fix.
- catalog: Sync also keeps models.dev's lab catalog (models.json) as
  labs.json beside the cache, through temp+rename; a failed fetch
  keeps the last one, and a cache without it is Stale once a process.
  A model only a lab lists votes into the same tables as a listed one
  (ContextOf, OutputOf, NameOf, Thinks, SeesImages); a model a
  provider lists keeps what providers say. A thinking lab-only model
  with no levels takes those of the newest of its family a provider
  gives (labKinEfforts: Mythos 5.1 takes Mythos 5's). catalog.Describe
  builds a Model from an id for lists that name ids alone.
- provider: the Claude account's list is models.dev's anthropic list
  plus what Anthropic told the account's Claude Code beyond it, read
  from .claude.json's additionalModelOptionsCache / modelAccessCache /
  additionalModelCostsCache (Claude Code's own sign-in and each saved
  account's directory). Account.Lists honours modelAccessCache's
  entitled per account, ListPrice falls back to Anthropic's price
  from additionalModelCostsCache, and the agent's own Claude Code
  picker (claudeOwn) offers the signed-in account's extras. WSL keeps
  the catalog list. magpie still asks Anthropic nothing with a Claude
  sign-in; nothing is sent differently, no Claude Code mimicry change.
- docs/subsystems/providers-accounts.md: two rows, the lab catalog
  and a Claude account's models.

Testdata: models.dev's api.json and models.json as served on 10-27,
cut to the anthropic and azure providers' Claude models and the
anthropic lab. Tests never reach the network.

Run:
- TestLabOnlyModelIsKnown, TestLabsLeaveListedModels, TestSyncKeepsLabs,
  TestClaudeAccountListsGatedModels, TestAnthropicKeyGatedModelDescribed:
  pass.
- go test -count=1 -timeout 45m ./internal/catalog/ ./internal/provider/
  ./internal/agent/ ./internal/gateway/ at 2e165fe9d + this change:
  catalog, agent (362s), gateway (557s) ok; provider crashed in
  TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest
  channel from outside bubble" in filememo.Forget). It crashes the
  same alone on a fresh origin/main 19dc5b925 and is #3632, open.
- rebased onto origin/main 2afacd7d1 (this commit's parent): catalog
  and provider again with -skip TestUnreadLoginsWriteErrorsKeepCredentials,
  both ok. agent and gateway were not run again after the rebase.
- gofmt -l internal/: nothing. go vet for darwin, linux and windows on
  catalog, provider, agent, gateway at the rebased head: ok.
- Real use: magpie built from this tree (linux, nogui) in a golang:1.26.8
  container with a sandbox HOME, so the Mac's Keychain and ~/.claude are
  never read. `magpie sync` fetched models.dev's real catalogs today
  (api.json's anthropic has no claude-mythos-5-1; labs.json has it).
  With a fake Claude sign-in and a .claude.json whose bootstrap caches
  name claude-mythos-5-1, `magpie models` lists claude/claude-mythos-5-1
  "Mythos 5.1" low/medium/high/xhigh; `magpie model spec` gives 1M,
  128k, vision on; `magpie model price` gives $25/$125, cache read
  $2.5, write $31.25 / $50 (1h). A custom Anthropic-protocol provider
  against a fake /v1/models returning claude-mythos-5-1 lists
  fakeanth/claude-mythos-5-1 "Claude Mythos 5.1" with 1M / 128k /
  low..xhigh.

Broken by hand, each red:
- lab reading off in loadGen: every lab assertion in the catalog tests
  and the provider tests (no window, no levels, the API-key entry's
  context 0).
- syncLabs off: TestSyncKeepsLabs.
- labKinEfforts off: the efforts assertions.
- the Claude list back to catalog.Provider("anthropic"): "Claude
  account's list has no Mythos 5.1".
- claudeLists / claudeCodePrice off: the entitlement and price
  assertions.

Not tried:
- a real account with Mythos 5.1: none here. The .claude.json keys and
  shapes were read from Claude Code 2.1.311's own binary, not a real
  account's file.
- a custom Anthropic-protocol provider without catalog=anthropic gets
  no price for a lab-only model (labs carry none).
- the plugin host's mdev() (host.js) reads api.json only; Gemini CLI's
  own picker stays catalog-only; a saved Claude account whose Claude
  Code never ran has no .claude.json, so its gated models show once it
  has run there.
2026-10-27 12:16:33 +08:00
yetone e7173958e9 agent: NewMax, magpie's models in its model picker (jwaitq on Discord)
jwaitq asked in #general (10-27) for NewMax (newmax.cc), an Electron app
built on the Claude Agent SDK. NewMax keeps its settings in
~/.newmax/newmax.db ($NEWMAX_USER_DATA_DIR wins), a SQLite table
settings(key, value) whose "app" row is JSON.stringify of every setting.
Connect adds one Anthropic-format provider, id magpie-gateway, with
magpie's gateway root (NewMax adds /v1/messages itself), its key and up to
20 models (NewMax's MAX_MODELS), appends it to providerOrder and, when
the user had kept NewMax's default, picks it. The row is edited by
splicing raw JSON in one immediate transaction, so every other byte the
user has stays as written. Disconnect removes the entry and its order id,
puts providerId/model back to "default" when they were magpie's, and
deletes the row when magpie made it. NewMax holds settings in memory and
writes the whole row on any change, so magpie refuses to write while
NewMax runs (macOS/Linux, matched on the program, not on a folder named
newmax) and says why in every language.

Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
  ./internal/agentenv ./internal/appdir ./internal/sessions at this head
  (rebased on 5e3dd1d52): ok
- gofmt -l clean; go vet darwin, linux (nogui) and windows on the touched
  packages
- GUI i18n-keys and agent-notice-lang, Chromium and WebKit: 15/15 each
Broken by hand, each red: user entry's name/off overwritten
(TestNewMaxProvider), running check removed (TestNewMaxLeavesAlone), row
kept after off (TestNewMaxMakesItsRow), pick left on magpie
(TestNewMaxProvider), no model cap (TestNewMaxModelCap), the first
process pattern that matched a shell in a newmax folder
(TestNewMaxProcess).

Real use: NewMax 1.1.22 (macOS dmg) in a sandbox HOME and
NEWMAX_USER_DATA_DIR, with this magpie on a sandbox port. Connect was
refused while NewMax ran; after quitting it wrote the row; on relaunch
NewMax's picker listed and picked magpie's models, its ClaudeProxy sent
to magpie's /v1/messages, and "Reply with exactly: pong" came back
"pong" through magpie to a fake Anthropic upstream. NewMax's own 58KB
row afterwards (47 providers) kept magpie's entry as written; disconnect
then removed only that entry, its order id and the pick
(live/deepseek/deepseek-flash -> default), every other byte the same.

Not tried: NewMax on Linux or Windows (Windows has no running check, as
pgrep isn't there); a real vendor reply through NewMax (the sandbox used
a fake upstream).
2026-10-27 11:03:41 +08:00
yetone 3ec3cb704b plugin: turning an agent plugin off or removing it puts the agent's config back first (#3810)
An agent a plugin adds is known only while the plugin is on. Turning
the plugin off or removing it (CLI `magpie plugin off/rm`, or the
Plugins page) left the agent's config on magpie, and `magpie <agent>
default` then said `unknown agent`, with nothing to put it back.

- provider.SetPluginOff (off) and provider.RemovePlugin first call
  provider.PluginAgentGoing, set by internal/agent to UnwirePlugin: the
  agent is disconnected as `magpie <agent> default` does (Disconnect),
  while the plugin still loads. A plugin off already is read from its
  module as it is; one whose module is gone puts back each file whose
  stash names its spec. If that fails, the plugin is left as it was
  and the error says why.
- The stash now records the plugin's spec and the file's format, so
  `magpie <id> default` for the agent of a plugin deleted on disk puts
  the file back from the stash alone (agent.RestoreGone; an older
  stash's format comes from its file's name, agentplug.FormatOf). A
  file that no longer holds magpie's gateway key is the user's and is
  left alone; one that can't be read is unknown: nothing is written,
  the stash is kept. With the plugin only switched off, `default` says
  the agent is off magpie already instead of "unknown agent".
- Turning the plugin back on (or installing it again) does not rewire
  the agent by itself: its config stays as the user had it. Connecting
  it (its switch on the Agents page) puts back the model it was on,
  through Disconnect's `.reconnect`. The CLI says so when it turns off
  or removes a plugin whose agent was on magpie.

Run (this change on origin/main f3c4d7b7a, then rebased onto
0fb0bfda3, which changes only an internal/gateway test; provider and
cli run again at the pushed head):
- gofmt -l: none; go vet -tags nogui on darwin, linux, windows for
  agent, agentplug, cli, provider, gui, plugin: ok.
- go test -tags nogui -timeout 45m -count=1 ./internal/agent
  ./internal/agentplug ./internal/cli ./internal/provider
  ./internal/plugin ./internal/gui: agent, agentplug, cli, plugin, gui
  ok; provider crashes in TestUnreadLoginsWriteErrorsKeepCredentials
  ("close of synctest channel from outside bubble", filememo.Forget),
  the same on origin/main 0fb0bfda3 run alone: #3632, open, not this
  change. At the pushed head: cli ok; provider with -skip
  TestUnreadLogins ok.
- Real use, sandbox HOME, magpie built from this tree, gateway on
  127.0.0.1:3491, web on 3492: `magpie plugin add agent-kilo`
  (@magpie-community/agent-kilo 0.1.0, not on npm, from the plugins
  repo's dist branch), a kilo.jsonc with comments and a provider of its
  own, `magpie kilo magpie/deepseek/deepseek-chat` (wired, provider
  block added). Then, each time from wired: `magpie plugin off` -> cmp
  byte-identical; `plugin on` -> still the user's; `plugin rm` ->
  byte-identical; POST /api/plugins/off and /api/plugins/remove (the
  Plugins page's calls) -> byte-identical; plugin dir deleted and
  plugins.json emptied by hand, then `magpie kilo default` -> put back,
  byte-identical. `magpie kilo default` with the plugin off says it is
  off magpie already.

Broken by hand, each red, then restored:
- PluginAgentGoing left nil: the four off/remove tests fail.
- the SetPluginOff call removed: Off and ModuleGone tests fail; the
  RemovePlugin call removed: Remove and RemovedWhileOff fail.
- Spec not stashed: ModuleGone fails. pluggedOff disabled:
  RemovedWhileOff fails. FormatOf fallback removed: TestRestoreGoneAgent
  fails. The gateway-key check removed: LeavesAFileOffMagpie fails.
- Unwire instead of Disconnect: the Off test fails (How "first", not
  "again"). The off-plugin check in RestoreGone skipped: the Off test
  fails. RestoreGone not called from the CLI: TestGoneAgentDefault
  fails with `unknown agent "kilo"`.

Not tried: the Windows box; a real Kilo CLI reading the restored file;
the GUI suite (no Plugins page code changed: the page's calls reach the
same provider functions, tried above through the web API). Not changed:
an inline JSON object magpie wrote into comes back reformatted (same
values) on any plugin agent's Disconnect, `default` included: #3814.
2026-10-27 10:01:46 +08:00
yetone cc9d68ffd3 agent: Antigravity CLI in a WSL distro is found and wired
mimi001234 (Discord, #general): agy installed in a WSL distro never
showed on the Agents page. wslKinds had no agy, so the distro probe never
looked for it.

agy is now a WSL kind (bin agy, dir .gemini/antigravity-cli), with the
model field offered for a stopped distro too. agy takes magpie only from
how it is started, and no magpie runs inside the distro, so a magpie pick
writes an agy shell function into the distro's own profiles: .bashrc,
plus .zshrc or fish's config.fish when the login shell in the distro's
/etc/passwd is zsh or fish. The function reads settings.json's model at
run time. It adds --model only for a magpie model the user didn't name
themselves, and sets GOOGLE_GEMINI_BASE_URL to place.gw() (the NAT
address, never 127.0.0.1) and GEMINI_API_KEY to the distro's WSL key.
Default removes the block. Check flags a function whose address has
moved, and Sync rewrites it. update.ShellFunction gained ShellFunctionAt,
DropShellFunctionAt and ShellFunctionInAt for profiles given by path
(fnProfile is now ShellProfile). This machine's own agy function is
unchanged. The restart notice is translated (de, zh, zh-TW, ja).
agent-wiring.md and reference.md are updated.

Run at c272f3799 + this change, then at this head (rebased on
65ee8c65c, which touched only gateway and plugin): the whole of
internal/agent and internal/update again, ok, and go build ok.
- go test -tags nogui -timeout 45m ./internal/agent/... ./internal/update/...
  ./internal/cli/...: update and cli ok. agent was red only on
  TestEveryNoticeIsTranslated (the new notice wasn't in i18n.js); after
  adding it, TestEveryNoticeIsTranslated and TestWSLAgy* are ok.
- go test -tags nogui ./internal/gui: ok.
- GUI, chromium and webkit: i18n-keys, agent-notice-lang and
  wsl-agents-setting all pass.
- gofmt -l on the changed files; go vet ./...; GOOS=linux go vet -tags
  nogui ./...; GOOS=windows go vet ./...; go build for darwin, linux
  (nogui) and windows: all clean.
- The bash and zsh functions are sourced in the test with a fake agy. The
  fish function was run in docker alpine:3.20 with fish.

Broken by hand, each red:
- bin "agyx" in the wsl kind: TestWSLAgyFound and TestWSLAgyStopped fail.
- 127.0.0.1 instead of at.gw(): TestWSLAgyPick and TestWSLAgyFunctionRuns
  fail.
- default not dropping the function: TestWSLAgyPick fails on .bashrc.

Not tried: real WSL. The Windows box (10.0.0.132) didn't answer ssh.
Fish wasn't tried inside a real distro.
2026-10-27 09:24:43 +08:00
yetone 9ae7912210 agent: plain agy starts Antigravity CLI on magpie in a new terminal
agy takes magpie's gateway, key (GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL)
and --model only from how it is started, so a user on magpie had to copy
the launch command at every start (bestony on Discord). Now:

- magpie agy run [args…] execs the real agy with the env and --model when
  agy's settings.json is on magpie's model (a --model/-model the user
  gives wins), and runs agy untouched otherwise. On Windows agy is a child
  through proc and its exit code is passed through. It refuses when "agy"
  on PATH resolves to magpie itself. magpie agy env prints what run adds
  (PowerShell's function reads it, since the desktop exe has no console).
- update.ShellFunction puts a function named agy in a marked block
  (# >>> magpie agy >>> … # <<< magpie agy <<<) of each shell profile
  cliShells finds: .zshrc (ZDOTDIR), the bash profile a terminal reads
  (.bash_profile, or .bash_login/.profile on macOS when that is missing),
  config.fish once its folder exists, and the PowerShell 7 / Windows
  PowerShell profiles where the execution policy runs them. Only the block
  is written, in place, temp-and-rename, CRLF and BOM kept; a profile that
  can't be read is not written; only files inside the home are. The
  function falls back to `command agy` when the magpie it names is gone.
- Set to a magpie model writes the block, stepping out takes it out (the
  file comes back byte for byte), and Sync at start writes it for users
  already wired.
- Notice, Launch tooltip and the connect panel say plain agy works in a
  new terminal, with the command for a terminal open now. Strings in
  i18n.js for zh, zh-TW, ja, de. docs/reference.md and
  docs/subsystems/agent-wiring.md updated.

Run at this head (base a3d4f8c5c, origin/main just fetched):
- go test -tags nogui -count=1 -timeout 45m ./internal/agent/...
  ./internal/cli/... ./internal/update/... ./internal/gui/...
  ./internal/proc/... : all ok.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... : clean. gofmt -l on the changed files: none.
- GUI (node --test, chromium + webkit): agy-launch, cursor-local-launch,
  agent-connect, agent-connect-no-models, agent-connect-all-hidden,
  agent-connected-unfolded, connect-address-kept, connect-snippet-shell,
  agent-notice-lang, agent-leave-magpie, agent-disconnect, copy-command,
  i18n-keys, gui-de, gui-ja, gui-zh-tw: 0 fail. Not the whole GUI suite.
- Real try, sandbox HOME under the scratchpad, nogui build, fake agy on
  PATH printing its args and the two env vars, env -i:
  magpie provider add deepseek + magpie agy deepseek/deepseek-chat wrote
  the block after the user's two .zshrc lines; `zsh -i -c 'agy -p hi'` got
  --model magpie/deepseek/deepseek-chat, GEMINI_API_KEY=magpie-agy and
  GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:38712; `agy --model x` kept x;
  wiring again left .zshrc's mtime alone and added .bash_profile once it
  existed, and `bash -l -i -c 'agy -p hi'` got the same; `magpie agy env x`
  refused; magpie agy default took both blocks out, .zshrc equal to the
  original, and plain agy ran with no env and no --model.

Broken by hand, each red, then restored:
- no fnInHome check: TestShellFunction, TestShellProfiles red.
- block appended instead of replaced in place: TestShellFunction red.
- unreadable profile treated as empty: TestShellFunction red.
- blank line before the block left on removal: TestShellFunction,
  TestWithFnBlock red.
- --model always added: TestAgyRun red.
- Sync without agyShell: TestAgyShell red. Stepping out without
  agyShell(false): TestAgyShell red.
- app.js typed row off, typed tooltip off: agy-launch 4 of 10 red each.

Not tried: PowerShell on Windows for real (vet only); WSL; a user's own
`alias agy` (an alias beats the function); a terminal already open needs
the copied command; macOS bash started non-login reads .bashrc, which
isn't written; a Documents folder redirected outside the profile isn't
written.
2026-10-27 07:30:16 +08:00
yetone 3fd7e16983 agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):

- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
  $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
  magpie writes [providers.magpie] (base_url, client_type, api_key),
  one [[models]] entry per magpie model (context_window, vision,
  max_tokens, [models.pricing] in usd_per_mtok) and default_model in
  Penguin's own inline spelling. Penguin's server reads the file again
  when its mtime changes, so no restart; a default naming no entry is
  refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
  Disconnect restores the user's own default_model (or none), drops a
  magpie vision model, and removes the file when magpie made it.
  Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
  Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
  irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
  penguin update --yes for the tarball, except on Windows where
  update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
  an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
  NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
  value (with child tables) by blocks, or removes them; blank lines
  between replaced entries go with them, and an unchanged result isn't
  written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
  and docs/subsystems/agent-wiring.md.

Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +08:00
yetone de54b4ff99 codex: threads started on OpenAI are listed while magpie is Codex's provider
notnico64 on Discord (Linux, magpie desktop): with Codex connected to
magpie, `codex resume` said "No sessions yet". Codex's resume picker
(tui/src/resume_picker.rs picker_provider_filter) lists only threads
whose model_provider is the one Codex is on now, with no opt-out, and
the filesystem scan checks each rollout's session_meta, not just the
state DB row. With no ChatGPT sign-in (also an API key, magpie API, an
account out of allowance, another machine/WSL) magpie writes
model_provider = "magpie", so every thread started on "openai" vanished
from the list. Nothing in it is Linux-only; macOS does the same.

Now, when magpie becomes Codex's provider and Codex was on OpenAI
before (not on a provider of the user's), the threads on "openai" move
to "magpie": the state DB row and the rollout's session_meta, rewritten
in place (both ids are 6 bytes), the file's mtime kept so the picker's
order holds, with no trash copy. At the Disconnect bringBack relabels
them back the same way before its usual mover. Threads Codex has
already packed (.zst, a week after the last turn) are left alone:
rewriting gigabytes of history at a switch isn't worth it (the owner's
~/.codex/sessions is 51GB, 11,591 of 12,255 rollouts packed). Files
written within ActiveWindow, outside this Codex home, or without their
id in the name are skipped too.

Run:
- Real Codex 0.162.1 in a sandbox HOME/CODEX_HOME (never ~/.codex):
  without model_provider the picker listed only the openai thread;
  with model_provider = "magpie" only the magpie one (the report).
  After RelabelCodexThreads(home, "openai", "magpie") the same picker
  listed both threads.
- TestCodexThreadsFollowMagpieIn (new) is red on the old code:
  "connected: thread ...c1 on "openai", want "magpie"".
- go test -tags nogui -timeout 45m ./internal/agent ./internal/sessions
  at this head: ok agent 480s, ok sessions 41s (rebased on 9298d2a7c)
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  both packages clean.

Broken by hand: dropping the prior-provider guard turns the
"provider of the user's" subtest red; dropping the Chtimes turns the
mtime check red.

Not tried: the reporter's own machine and why magpie became their
provider; Linux itself; the Codex desktop app's thread list; a full
`go test ./...`. Packed threads stay out of the list while magpie is
the provider.
2026-10-26 22:38:57 +08:00
yetone 4e3078ee47 agents: a Codex thread started on any provider table goes through magpie when reopened, not only CC Switch's
A report the owner relayed from WeChat (10-26): in Codex, with apikeyfan's
gpt-6.1-sol on, an old thread failed every turn with "unexpected status 404
Not Found: Model "apikeyfan/gpt-6.1-sol" is not supported by any configured
account in this group, url: https://slb.apikey.fan/responses". A new thread
worked, and updating magpie didn't help. The url is Codex's own call: Codex
reopens a thread on the provider it was started on, and that thread's table
pointed straight at the relay (no /v1, so not a table magpie wrote), so the
magpie model id went to the relay. 6c5ed2acf pointed only CC Switch's
"custom"/"cc-switch-N" tables at magpie; a table of the user's own, or one
named after a CC Switch card, kept going to the relay.

Now any [model_providers.<id>] table a Codex thread was started on (the
state database's threads) goes through magpie while a magpie model is on,
the same way: base_url to magpie's /v1, the old URL kept in the stash and
given back with Codex's own model or a reset, the table's other keys as they
were. Left alone: tables no thread names, tables a profile names, magpie's,
Codex's built-ins and CC Switch's OpenAI mirror. The state database is read
only when a table outside CC Switch's ids has a base_url, once per check.

Run at this head (4a33cf0a9 + this):
- TestCodexTakesThreadTables (new) is red on the old codex.go: "thread's
  table not through magpie". TestCodexWritesTablesThreadsName, changed to
  expect the user's thread table through magpie, is red on the old code too.
- go test -tags nogui ./internal/agent -run Codex: ok.
- gofmt -l, go vet (darwin, GOOS=windows), go build (darwin, GOOS=linux): ok.

Not tried: the reporter's own config.toml (its table's id isn't known, so a
quoted header or a profile-named table would still be left alone), the full
suite, and a real Codex app reopening a thread.
2026-10-26 22:02:03 +08:00
yetone a6c808b688 hermes: every bot still on magpie's model follows the model magpie sets (tjhhhh_84378)
Hermes copies the launch profile's model block into a new profile
(hermes_cli/profiles.py _seed_model_config, or --clone's config.yaml) and
never reads the main config again. magpie put its provider into each
profile but left each profile's model alone, so after a model change in
magpie every other bot (profile) still opened on the model magpie had set
when it was made (tjhhhh_84378 on Discord, with the Hermes gateway closed).

Now picking a magpie model for Hermes also moves each other profile whose
model.provider is magpie and whose model.default (or model.model, which
Hermes reads with default unset) is the model magpie had set onto the new
one (hermesFollow). "The model magpie had set" is recorded in stash.json
(hermes:<path>:magpie.default); for a config connected before the record,
it is the connected config's own magpie model. A profile on any other
model, magpie's or its own, was set by its user and is left alone, also
when it is on a model magpie used before. Disconnect forgets the record.
A profile made after the change is seeded from the current config, so it
starts on the new model already. RenameProvider goes through the same
field Set, so a renamed provider moves the following bots too.

Test: TestHermesProfilesFollowMagpieModel (internal/agent): a seeded bot
and a model.model bot follow pro -> flash (no record yet) and, through an
own model on the main config in between, -> max; a bot on magpie's
deepseek/lite and a bot on its own provider stay; a bot its user moved
back to the previous magpie model stays. On the old hermes.go it fails:
  hermes_test.go:613: flash: writer is on magpie/deepseek/pro, want magpie/deepseek/flash

Run:
- gofmt -l internal/agent: clean. go vet ./internal/agent on darwin,
  GOOS=linux -tags nogui and GOOS=windows: ok, at this commit (rebased
  onto origin/main 689cf4142; nothing under internal/agent changed in the
  rebase).
- go test -tags nogui -count=1 -run Hermes ./internal/agent at this
  commit: ok (33.6s). Whole ./internal/agent before the rebase: ok (307s).
- Full suite, go test -tags nogui ./... -timeout 45m -count=1, sandbox
  HOME, at a57d2460b (this change on 88ac42843): every package ok except
  two reds already filed on main, in packages this doesn't touch:
  internal/gui TestRestartHandsTheGatewayOver ("11 of 12 requests during
  the restart answered", #3451) and internal/provider's synctest crash in
  filememo.Forget from TestUnreadLoginsWriteErrorsKeepCredentials (#3632).
- Broken by hand: hermesFollow's call removed, the test goes red at
  hermes_test.go:613 as above.

Not tried: the real hermes binary (under a temp HERMES_HOME it rewrites
the live launcher); its seeding was read in hermes_cli/profiles.py.
2026-10-26 17:48:30 +08:00
yetone 634cbf587b agent: Claude Desktop on an imported profile for magpie's gateway is connected, and Reconnect keeps it
aa86222 on Discord: Claude Desktop's configuration (magpie's profile, with
the connectors added in it) exported on one computer and imported on
another becomes a new configLibrary entry under a random id Desktop makes
(createConfig in Desktop 2.7032's main process), applied beside magpie's
own. It points at this magpie's gateway, yet the Agents row said
"已不经过 magpie:配置已变更", since desktopCheck took any appliedId but
magpie's own as another gateway. Reconnect then applied magpie's own
profile, dropping the imported one with its managedMcpServers, and on the
old code a later switch-off applied the first entry left (CC Switch's).

Now an applied gateway profile whose inferenceGatewayBaseUrl is this
gateway (desktopIsOurGateway) counts as on magpie (desktopAppliedGateway).
Check reads its URL and key; Reconnect (desktopOn, when magpie's entry is
already listed) keeps it applied and leaves every setting in it as it is;
only a key this gateway would refuse (another magpie's named key) is set
to magpie's Desktop key, by Reconnect or by Sync at magpie's start
(desktopKeyApplied). magpie's own keys (gateway.Token, magpie-<agent>)
count as taken. A profile for another gateway (CC Switch) is still drift
and Reconnect still applies magpie's. The first switch-on still seeds
magpie's profile from an applied one (#2035, unchanged). appReads includes
the applied profile, so a key fix asks for Desktop's restart.

Run (macOS, sandbox HOME only, at 27ca0bef5 + this change):
- go test ./internal/agent -timeout 45m -count=1: ok (205s)
- gofmt -l internal/agent: clean; GOOS=linux and GOOS=windows go vet
  ./internal/agent: ok
- TestClaudeDesktopImportedProfileIsOnMagpie: fixture is _meta.json with
  CC Switch's entry (127.0.0.1:15721), magpie's, and the imported one
  applied, the imported profile carrying managedMcpServers.

Broken by hand: with claudedesktop.go put back to origin/main (and a stub
desktopAppliedGateway returning ""), the new test fails in 3 of 4
subtests: check says "uses another gateway configuration now", Reconnect
applies 00000000-…-6d6167706965, off applies CC Switch's entry, and the
other-magpie key is never fixed.

Not tried: a real Desktop export/import across two computers (the format
is from Desktop 2.7032's app.asar: configLibrary createConfig + writeConfig,
exportConfig); the GUI (no GUI file changed). Not changed: a machine
where magpie never connected Desktop and an imported profile is applied
still reads as not connected; connecting there seeds magpie's profile
from it (#2035).
2026-10-26 17:00:46 +08:00
yetone a7072926d6 agent: connecting Kiro Crew connects the harness it is set to (wuping9525)
wuping9525 (Discord, Windows): Kiro Crew's Agent Harness was Claude Code,
Claude Code was installed but not connected to magpie, and turning Kiro
Crew on refused with "connect Codex, Claude Code, ... first". On a Mac it
worked only because a harness (Codex/Claude Code) was already connected;
Crew's home is found the same way on Windows (USERPROFILE\.kiro\crew).

Now, when agent.acp_backend names one of magpie's harnesses (codex,
claude, opencode, pi, goose) and that agent is installed but not
connected, connecting Kiro Crew connects it in the same action and runs
Crew on it; the notice says so. The stash's kirocrew.joined records it.
Kiro Crew's Disconnect disconnects that agent again only if magpie
connected it and the user hasn't disconnected it since (kiroCrewUserLeft
in Agent.Disconnect); a disconnect the user made before stays recorded as
theirs. A failed Crew write undoes the join. config.local.json pins,
kas/kiro/deepseek and harnesses not installed behave as before.

Windows: the adapter search also tries npm's .cmd/.exe/.bat shim names,
and the app is detected by ~\.kirocrew-app\.venv\Scripts\kirocrew.exe.
New notice translated in zh, zh-TW, ja, de; docs/subsystems/agent-wiring.md
and docs/reference.md updated.

Run (macOS, sandbox HOME, GOMODCACHE/GOCACHE pinned), at base 11c3fbb19;
after rebasing on 2921471de (no change under internal/agent or internal/gui
since), go vet and go test -run 'KiroCrew|Disconnect' ./internal/agent
again: ok.
- go test -tags nogui -timeout 45m ./internal/agent ./internal/gui: ok
  (252s, 62s)
- new tests: TestKiroCrewConnectsItsHarness (real Claude Code wiring in a
  sandbox), TestKiroCrewLeavesTheUsersHarness (connected before, taken
  back after, off before), TestKiroCrewHarnessNotHere, TestKiroCrewOnWindows
  (kiroCrewOS forced to windows, PATH emptied)
- gofmt -l clean; go vet nogui for darwin, linux, windows; windows build
- GUI: agent-kiro-crew-lang, i18n-keys, gui-de, gui-ja, gui-zh-tw in
  chromium and webkit: 35/35 pass

Broken by hand, each red: no join (ConnectsItsHarness, taken back after,
off before), no kiroCrewUserLeft hook (taken back after), always forgetting
the user's disconnect (off before), no .cmd names and no venv exe
(OnWindows), no leave on Disconnect (ConnectsItsHarness, off before);
notice dropped from the NOTICES list: agent-kiro-crew-lang 9 red.

Not tried: a real Kiro Crew or Windows machine (the Windows box's ssh
timed out); the disconnect preview doesn't show the joined harness's
files, since it copies only Crew's folder.
2026-10-26 16:31:14 +08:00
yetone 56900e4845 agent: Claude Desktop on magpie gets the MCP servers the user added signed in (aa86222 on Discord)
aa86222 on Discord: Claude Desktop on magpie's gateway (3p mode) didn't
sync its connectors. Two parts:

- A claude.ai account's connectors can't reach 3p mode. Desktop calls
  them through claude.ai with the signed-in account
  (/api/organizations/<org>/mcp/servers/<id>/tools/call in Desktop
  2.7032's main bundle, refused with no_active_org without an account),
  and 3p mode has none. Anthropic's 3p docs say "Made by Anthropic"
  connectors are only in standard Desktop; others reach 3p through
  managedMcpServers or plugins
  (claude.com/docs/third-party/claude-desktop/extensions). magpie doesn't
  answer or pass any of these: they never go to the inference gateway.
- What magpie can do: 3p mode reads its MCP servers from
  Claude-3p/claude_desktop_config.json, a file of its own, so the
  servers added signed in (Settings -> Developer, in
  Claude/claude_desktop_config.json) were gone from the list. Switching
  on now copies each mcpServers entry Claude-3p has none of the same
  name for (desktopCarryMCP). One already there (the user's, or the
  Library's, which writes both files) stays. Sync does it once for a
  Desktop already on magpie (stash mark claude-desktop.mcp-seen), so a
  server the user takes out in 3p isn't brought back. Off takes back
  each copy still as copied (stash claude-desktop.mcp); one the user
  changed stays. Claude's own file is never written.

Run, at this tree:
- go test -count=1 -timeout 45m ./internal/agent ./internal/library
  ./internal/desktopdir: ok
- gofmt -l internal/agent: clean; go vet ./internal/agent for darwin,
  GOOS=linux and GOOS=windows: ok
- the built binary in a sandbox HOME (macOS): `magpie claude-desktop
  provider magpie` copied a filesystem server into Claude-3p's
  claude_desktop_config.json with Claude's file byte for byte; `provider
  ""` removed Claude-3p again, Claude's file unchanged.

Broken by hand: desktopCarryMCP returning at once turns
TestClaudeDesktopCarriesTheMCPServers, TestClaudeDesktopMCPKeepsThe3pServers
and TestClaudeDesktopSyncCarriesTheMCPServersOnce red; desktopUncarryMCP
returning at once turns the first two red (off left the copies); Sync
carrying on every run turns the third red.

Not tried: a real Claude Desktop reading the carried servers in 3p mode
(it reads ~/Library, so the sandbox can't host it, and the live one is
not touched); Windows and Linux folders (same code path through
desktopSets); the reporter's own connectors, which weren't described
beyond "can't sync" and are most likely claude.ai ones, which this
cannot bring.
2026-10-26 15:46:02 +08:00
yetone a1174674da codex: subagents and memories follow the session's magpie model; auto-review can too (cybercaius on Discord)
Codex's side calls ask for one of Codex's own models by its bare name
whatever the conversation is on: a subagent goes on the model the lead
names in spawn_agent, memories on gpt-5.6-luna/terra, auto-review on
codex-auto-review. With Codex signed in to ChatGPT and the conversation
routed onto one of magpie's models, each of those went to the ChatGPT
account instead (cybercaius: "can't pick follow the main model").

- gateway (codexFollowTo, codexLeads): a collab_spawn or memory call
  that asks for a bare model, with nothing set for it (no magpie
  subagent model, no [agents] default_subagent_model, no [memories]
  extract/consolidation_model in Codex's config), goes on the model its
  conversation's own turns go on (parent thread, own thread, else the
  key's last turn), when that is a magpie model the key may use. A task
  the ChatGPT backend sealed stays on ChatGPT. The trace shows a
  subagent's pick as {asked -> to}.
- agent.CodexSideSet reads Codex's config.toml for those keys; an
  unreadable config counts as set (leave as sent).
- Auto-review gets "Same as the session" (settings value "session"):
  codexcat writes each magpie entry's own id as its
  auto_review_model_override. Not the default: codex-auto-review runs
  free on a ChatGPT sign-in (#1593).
- GUI: the option in all languages; Memories' default text says it
  follows the session. app.js stays under its budget by folding five
  identical writingPrefs then/catch chains into prefWrite.

Ran (sandbox HOME, -tags nogui -count=1 -timeout 45m):
- go test ./internal/gateway ./internal/agent ./internal/codexcat
  ./internal/settings ./internal/cli ./internal/gui: ok.
  ./internal/provider: FAIL with "close of synctest channel from outside
  bubble" in filememo.Forget (TestUnreadLoginsWriteErrorsKeepCredentials),
  which is #3632 on main; this change touches nothing there.
- TestCodexSubagentFollowsTheSession and TestCodexMemoriesFollowTheSession
  go red with codexFollowTo returning "" (broken by hand).
  TestCodexSideCallsKeepTheConfigsModel, TestCodexSideCallsStayOnChatGPT,
  TestCodexSideSet, TestCodexAutoReviewFollowsTheSession pass.
- GUI (playwright 1.62.0, chromium + webkit): codex-auto-review (en, zh,
  zh-TW, ja, de), codex-memories, codex-memories-settings, codex-titles,
  codex-predictions, codex-descriptions, settings-general, agent-prefs,
  i18n-keys: 120/120 pass. TestCoreScriptBudget passes, budget unchanged.
- gofmt -l clean; go vet -tags nogui for linux, windows and darwin ok.

Again after rebasing on origin/main 49f15d124 (25341b4ca on top touches
only internal/redact; rebuilt): nogui builds (darwin, linux,
windows), TestCoreScriptBudget, the tests above, and the GUI files 120/120.

Not tried: a real Codex with a real ChatGPT account and a relay model.
2026-10-26 15:35:12 +08:00
yetone c158b0439c agent: the Codex daemon is looked at on magpie's writes, not every 15s (#3185)
KeepCodexDaemonCurrent read Codex's config.toml (four TOML reads, a hash
and the stash) every 15s for as long as magpie ran, to see whether
magpie had changed what Codex reads at start since its daemon started.
Only a write can make the daemon behind, and every one magpie makes,
Codex's config among them (edit's file writes), closes filememo.Written.
The loop now waits on that, looks once a minute (OthersEvery) for another
process's write, and every 15s only while the daemon is behind, for the
codex sessions on it to end. codexDaemonBehind's 45s freshness still
holds, since a behind daemon is still looked at every 15s.

Run at this head (rebased on origin/main):
- go test -timeout 45m ./internal/agent ok (212s).
- TestCodexDaemonLooksOnWrites -count=3 ok; red with the loop not
  waiting on Written ("looked at 0 times in 5s").
- gofmt clean; GOOS=linux / windows go vet -tags nogui ./internal/agent ok.
- Real gateway, sandbox HOME, idle, per-second wakeups over 120s after a
  90s warm-up: v0.1.1564 1.6/s with a burst every ~15s, this 1.4/s with
  no 15s period left (the sandbox has no Codex config, so this is the
  timer alone; with Codex set up each look also read its files).
2026-10-26 11:48:48 +08:00
yetone 466cafa0cf idle: the loops that look every few seconds wake together on the clock's beat (#3185)
An idle magpie serve still woke ~6 times a second with nothing to do.
Its loops each kept a ticker of their own, started at their own instant:
awake.Keep (5s), the plugin config's KeepFresh (5s), the middleware
observer (5s), OTel's session watch (5s idle), the Codex daemon check
(15s), dsh's wiring (30s), the model lists' look (1m). Every one woke
the process apart, a few threads each time.

internal/beat's Next(every) fires at the next multiple of every on the
clock, so the 5s loops come due at one instant, the 15s and 30s ones on
every third and sixth of it, and the runtime runs timers due together
in one wakeup. Each loop now waits on beat.Next instead of its ticker.
No channel is shared between callers (a synctest bubble's channel
reached from another crashes the process, #3632).

Run at this head (05ea29ac8 + this):
- Sandbox HOME serve, idle, 90s warm-up then 120s of proc_pid_rusage
  (pkg_idle_wkups + interrupt_wkups), old (origin/main 19253f67b) and new
  taking turns: old 6.1, 5.3, 6.2 wakeups/s; new 2.7, 2.6 (an earlier
  shared-timer form of beat), 3.0 (this one). CPU 0.20-0.36 ms/s old,
  0.11-0.22 new.
- TestIntervalsMeet (5s/15s/30s/1m beats from 09:00:03.2 and on a beat),
  TestNextFires; go test ./internal/beat ./internal/awake
  ./internal/middleware ./internal/otlp -count=3, ./internal/pluginrt,
  ./internal/agent -run 'Dsh|CodexDaemon', ./internal/provider -skip
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632): ok.
  ./internal/pluginrt -count=3 fails TestKeepFreshFollowsPluginsYml
  ("two plugins fresh-test") on origin/main too; -count=1 is ok.
- gofmt; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
Not tried: a GUI build's wakeups (the tray process has AppKit's own).
2026-10-26 10:27:01 +08:00
yetone 5e0d7c058b agent: WorkBuddy's own save of models.json after it starts no longer keeps its row saying restart (Sac2333o on X)
Sac2333o on X: the WorkBuddy row kept saying "已连接 · 重启 WorkBuddy 后生效"
after every restart of WorkBuddy.

WorkBuddy rewrites ~/.workbuddy/models.json itself a few seconds after
each start. 5.5.6 (Mac app.asar): registerLocalModelIpc checks whether the
computer can run local models (only some NVIDIA RTX GPUs and Intel Core
Ultra chips), and on "no" purgeLocalModelsOnGateFail saves the file
through ModelsJsonStorage.update even when nothing was purged. The live Mac
log says "Hardware eligible: false ... Purge complete: 0 models removed".
5.6.2 (Windows app.asar) does the same through the daemon's
deleteLocalCustomModel. Both save it with JSON.stringify(x, null, 2), so
magpie's trailing newline is gone. 5.6.2 also writes a bare list, and its
models-json codec encrypts apiKey (WBEF1) when its credential policy says
so. On the Windows box, WorkBuddy 5.6.2 started at 17:17:09 and
models.json was last written at 17:17:13 with no trailing newline.

AppBehind put magpie's last change at the time of the last write it
hadn't seen, using a digest of the raw bytes. WorkBuddy's own save
changes those bytes, so every start put "magpie's change" 4s after
WorkBuddy started, and the row asked for a restart forever.

appReads now digests workbuddyPart: magpie's entries (vendor magpie),
each with its keys sorted and its apiKey left out. The same models
written by magpie and saved again by WorkBuddy read the same. A model
magpie adds or removes, or a changed URL, still asks for a restart.
Upgrading users: the stash still holds the old raw digest, so the first
look after the update may still say restart once. One restart of
WorkBuddy then clears it for good.

Run:
- TestWorkBuddyOwnSaveAfterStartIsNoChange (darwin and windows subtests):
  connect, WorkBuddy restarted, WorkBuddy's save 4s after its start
  (Windows: apiKey encrypted). Red on the old appReads ("WorkBuddy's own
  save after its start read as magpie's change"), green now. Broken by
  hand (apiKey kept in the digest): the windows subtest goes red.
  TestWorkBuddyRestart*, TestChangedAt* still pass.
- GUI: internal/gui/tests/agent-app-restart.test.cjs (every language,
  chromium and webkit, wide/narrow/panel), 40/40. app.js is unchanged.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
  internal/agent.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., one run
  on this machine, no other suite running): running at push. A red it
  finds gets a follow-up commit and an issue.

ZCode (the same report: "zcode接入通信失败") is not changed here. I could
not reproduce it. In a sandbox HOME on macOS, `magpie zcode provider
magpie` (a build of 4b3bdbe28; this commit doesn't touch ZCode), then ZCode 3.14.3's own app-server
(provider/testModelConnectivity, the call behind its settings' test
button) against the gateway: {"success":true}. The same on the Windows
box, with this tree's magpie.exe and ZCode 3.14.3 for Windows run with ELECTRON_RUN_AS_NODE in a
sandbox USERPROFILE/HOME: {"success":true}, and the request reached the
upstream.

Not tried: the reporter's own machine, upstream and ZCode model (ZCode's
probe streams with max_tokens 1 and the model's first reasoning level, so
an upstream that refuses that shows as 连接失败); WorkBuddy's real app
seeing a magpie sync in this build (its save was read from its code, its
log and file times, then replayed in the test).
2026-10-25 21:44:56 +08:00
yetone 5be7d05d28 agent: Desktop on magpie offers its own import of the signed-in sessions (lambdua on X)
lambdua on X: "claude Code桌面端支持么? 我桌面端切换账号,对话都能全都不见".
Nothing is lost. Desktop on magpie runs in 3p mode, whose userData is
Claude-3p, a folder apart from Claude/. Desktop 2.7032 keys Code and
Cowork sessions by account and org (claude-code-sessions/<acct>/<org>):
in 1p the claude.ai login's, in 3p the install id in ant-did and a fixed
org. So the sessions made signed in stay in Claude/ untouched and show
again when Desktop is switched back; claude.ai chats are on Anthropic's
servers. magpie's on/off never writes or removes a session (desktopOff
removes only what magpie made, and only when empty).

Desktop has its own importer (Settings -> Import: the signed-in userData,
other Claude* folders, ~/.claude/projects; copies under new ids, originals
left), but in 3p only when the profile's claudeAiImport.enabled is true
(3p-only policy, default off, since 1.28929.0). magpie's profile now gets
"claudeAiImport":{"enabled":true,"bannerBehavior":"detect"} once per
folder set (desktopSeedImport, stash mark claude-desktop.import): on the
switch on, and from Sync at magpie's start for a Desktop already on
magpie. A claudeAiImport already there is kept; one the user removes is
not written back (the mark is read, never unstashed).

Run (suite at origin/main 5df62c5cd, then rebased on 2f44e075a):
- go test ./internal/agent/ -run Desktop -count=1: ok.
- go test ./... -timeout 45m -count=1 at 5df62c5cd (log kept whole):
  every package ok but two reds already on main and filed:
  TestFolderVarsAreListed (#3600, fixed in 2f44e075a) and
  TestNoCommandBypassesProc (#3567, internal/tui/keep.go, open).
- after the rebase onto 2f44e075a: go test ./internal/agent/
  ./internal/proc/ -count=1: agent ok; proc red on #3567 only.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/agent/
  ok; GOOS=windows go build ./... ok; GOOS=linux go build ./internal/agent/
  ok (the CLI and GUI need Wails' cgo, not cross-built here).
Broken by hand:
- desktopSeedImport returning at once (the old code): TestClaudeDesktopFresh,
  TestClaudeDesktopOnKeepsTheUsersOwnGatewayProfile and the new
  TestClaudeDesktopOffersItsSessionImport go red.
- the mark read with unstash (consumed on read): the new test goes red
  with "seeded again over the user's choice". My first draft had this
  bug; the test found it.
Schema checked in Desktop 2.7032's asar (read-only, extracted to a
scratchpad): claudeAiImport is a flat leaf key whose value is the object
{enabled, bannerBehavior}, gated in 3p on enabled === true.
Not tried: a real Desktop in 3p mode with the key (would mean running
Desktop against the live userData); the live Claude folders were only read.
2026-10-25 20:29:08 +08:00
yetone 2f44e075a2 agent: TZ is not an agent's folder (#3600)
c888ef272 made a routing rule's hours fall back to the machine's zone,
which reads TZ in internal/provider/grouprule.go. TestFolderVarsAreListed
asks every variable those packages read to be one a sandbox clears, or to
be excused; TZ is the machine's zone, not a folder, so it is excused.

Run: go test ./internal/agent -run TestFolderVarsAreListed -count=1, ok
(red at origin/main 642d430ec per #3600, the same message).

Fixes #3600
2026-10-25 20:12:48 +08:00
yetone b30734f964 sessions: Antigravity CLI (agy) conversations are listed, with title, folder, tokens and resume (RickyWei, #1718)
agy's conversations were on no Sessions page: internal/sessions had no
lister for them, only the calls reader of #2097. Now each
~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript_full.jsonl
is a session (agy.go). Its steps give the start and last times, the first
prompt (taken out of agy's <USER_REQUEST> wrapper), prompts, replies, tool
calls, and tokens under the model "agy", since no step names one. A step
written again replaces its tokens, read on or read whole. The title and
folder come from the conversation's conversation_summaries.db row:
title, and workspace_uris through agyFolder, which turns file:///C:/... and
file:///c%3A/... into C:\... and a host into \\host\share on Windows. agy
writes the title after the transcript, so the row is the file's rev. The
database is read again only when it or its -wal changed, and a failed read
keeps the rows read before. A row with conversations/<id>.db and no
transcript (#1718's case) is listed from the row alone, with no tokens and
no conversation to open. Resume is "agy --conversation <id>". When agy is
set to use magpie, it is the agent's launch command (gateway variables and
--model, the PowerShell form on Windows) with --conversation after it,
through sessions.AgyStart, which package agent sets. The transcript (user
text, thinking, text, tool calls, tool results) can be opened and searched.

Format read from real files: agy 1.3.5 and 1.4.7 in a sandbox HOME
against a fake Gemini endpoint, with plain replies, a read_file tool call
with thinking, invalid tool calls, and a conversation picked up again with
--conversation from another folder. testdata/agy-sessions is three of
those conversations with paths rewritten to /work.

Resume tried for real in the sandbox: `agy --conversation <id> -p again`
from another folder appended steps 2-4 to the same transcript and kept the
row's folder. Interactive `agy --conversation <id>` (in tmux) showed the
earlier turns.

Run at this tree, rebased on origin/main:
- gofmt -l internal clean
- go vet: darwin; GOOS=linux -tags nogui; GOOS=windows
- GOOS=windows go build ./...; GOOS=linux go build -tags nogui ./...
- go test -count=1 ./internal/sessions ./internal/gui ./internal/agent: ok
  before the row-only change. After it, sessions ok, and gui had one red,
  TestMainWindowCorners killed at its 40s deadline at load ~300 (#1936).
  It passes alone (47s).
- GUI (playwright 1.62.0, chromium and webkit, en and zh): i18n-keys,
  gui-de, gui-ja, gui-zh-tw, session-terminal, sessions-bar-names,
  sessions-manage, sessions-talk, sessions-toolbar: 49 of 49. No GUI asset
  changed. Tab names come from the agent registry.

Fails without the change (broken by hand, each one red):
- agyFiles out of allFiles: TestAgySessions, TestAgyTitleLater, TestAgyTranscript
- agy out of refresh's DBRevision check: TestAgyTitleLater
- no dropUse of a rewritten step: TestAgyGrows (4510 input, want 3010)
- AgyStart ignored: TestAgySessions (wired resume)
- drive letter not handled: TestAgyFolder
- agy out of HasTranscript: TestAgySessions, TestAgyTranscript
- the row-only listing off: TestAgyRowOnly; readable() off: TestAgyRowOnly

Not tried: agy on Windows. The Windows box (10.0.0.132) didn't answer
ssh, so the Windows paths are covered by unit tests only (agyFolder,
the Set-Location resume form). A wired resume through magpie's real
gateway was not tried. Not done: subagents (parent_conversation_id),
which I never saw agy write. The model name, which is only in
conversations/<id>.db's protobuf (#3147). Deleting an agy session from magpie. agy in WSL: #3595.

Side effect: agy's self-updater ran in the sandbox and replaced the
live ~/.local/bin/agy, 1.3.5 -> 1.4.7.
2026-10-25 18:24:20 +08:00
yetone 4b1994ad31 agent: AionUi, added through its add-provider link
seven7032 on Discord asked how to connect AionUi to magpie. AionUi
keeps its providers in its own SQLite database
(<userData>/aionui/aionui-backend.db, WAL mode), each key encrypted, so
there is no config file for magpie to write. The one supported way in
is its deeplink. AionUi 2.2.2's main process parses it
(parseDeepLinkUrl), and its renderer opens Settings -> Model with the
add form filled in, which the user confirms:

  aionui://add-provider?api_key=magpie-aionui&base_url=<gw>/v1&name=magpie&platform=custom

The AionUi row works the way Cindy's and Lody's do:
- Add magpie opens that link. /api/open allows the aionui://add-provider?
  prefix only. `magpie aionui add` opens it from the CLI.
- The key is agentKeyAt("aionui"), so it becomes the LAN key while
  sharing is on (added to TestPinnedGatewayKeyForEveryWriter).
- "custom" is AionUi's OpenAI-compatible platform. Its base URLs end in
  /v1, as its own OpenAI preset's does.
- Added reads providers.base_url for the gateway's address without
  touching the database (sessions.OpenUntouched, from the previous
  commit). A database that can't be read is unknown, never "not added".
  The last read is kept while the database and its log keep their size
  and time, for 15s at most, so the Agents poll doesn't copy a running
  AionUi's database every time.
- It is detected by userData/aionui (os.UserConfigDir()/AionUi on every
  OS).
- As with Cindy and Lody, the TUI leaves the row out (nothing to pick).

Tests:
- TestAionUiLink: the link's exact bytes.
- TestAionUiLinkParsedAs2_2_2: runs the link through
  testdata/aionui/deeplink-2.2.2.js, which is parseDeepLinkUrl copied
  byte for byte from 2.2.2's app.asar (out/main/index.js 50995-51021)
  plus the renderer's add-provider mapping and the form prefill. The
  result is action add-provider, route /settings/model, and the form gets
  platform custom, the /v1 base URL and the key.
- TestAionUiHas: a fixture database built from 2.2.2's real providers
  schema (taken from the database 2.2.2 made at first start). It covers
  none, another gateway, a row present only in the log of a running app,
  and a closed app, and checks that AionUi's folder is unchanged each
  time.
- TestAionUiUnreadableIsUnknown, TestAionUiStatusRereadsOnChange,
  TestAionUiDetect, TestAionUiImportRow (GUI: the row, unknown status,
  and /api/open refusing other aionui:// links).
- import-row.test.cjs gains the AionUi row (icon, known status in each
  language, the click opens the exact link, and it fits at 420px), in
  chromium and webkit across en, zh, zh-TW, ja and de. The same file
  now waits for the rows to settle before its alignment check: under
  load 105 one run caught Cindy's button mid-resize at 193.4px beside
  the picker's 194.4px. The old file passed 3/3 alone, so it is a
  timing assumption, not a layout bug.

Run at 18041fc5b (this change on origin/main 714ab8e8b):
- go test ./... -timeout 45m, through the suite lock: every package ok
  except internal/proc's TestNoCommandBypassesProc, red on
  internal/tui/keep.go:102 from 75e78a5a0 on main (#3567, which has a
  fix on skygunner's fork).
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet of agent, gui, cli and sessions clean.
- import-row.test.cjs: 20/20 in chromium and webkit.
- The whole GUI suite (make test-ui, 882 files) was still running at
  push, so it is not recorded here.
Rebased onto cbbf3163c, which changes GUI assets and api.go. At the
pushed head: go vet of the four packages is clean; go test
./internal/gui ok; the AionUi, Cindy and pinned-key agent tests are ok.
import-row.test.cjs at load ~210: one run had 19/20, and that run's
output wasn't kept, so I can't name the failing case. The next three
runs were 20/20.

Tried: magpie built at this commit with -tags nogui under a sandbox
HOME. `magpie aionui` printed "magpie aionui add  to add magpie" with
AionUi's folder and no database. With a copy of the real 2.2.2 database
holding one row at the gateway's /v1, it printed "magpie added".

Broken by hand:
- Dropping the aionui prefix from /api/open: TestAionUiImportRow red
  ("AionUi's link was not handed to the desktop").
- The reader put back to a plain mode=ro open: TestAionUiHas red
  ("AionUi's folder changed: aionui-backend.db ->
  aionui-backend.db,aionui-backend.db-shm,aionui-backend.db-wal").
Both were restored and are green.

Not tried: the add form, the saved row and gateway traffic. The
released AionUi 2.2.2 desktop app asks for an aionui.com sign-in before
any page, Settings included. That sign-in was not faked, and no
aionui.com account was available, so the link has never been opened in
a signed-in AionUi end to end. Also not tried: what AionUi saves for
platform custom when it is confirmed, AionUi's User-Agent (so none is
matched), and the aionui:// handler on Linux and Windows (Electron's
setAsDefaultProtocolClient, unverified there).
2026-10-25 16:49:29 +08:00
yetone c26a418d23 agent: an import app's status magpie can't read is unknown, not "not added"
Agent.Added now returns (added, known). Cindy's reader turned any
failure (a locked, corrupt or unreadable cindy-local-v1.db) into "Not
added", which told a user who had added magpie that they hadn't. Now
an unreadable database is unknown: /api/agents leaves `added` out and
the row shows the "confirm it there" hint, as it does for Lody. A
stopped WSL distro's app is unknown too, not "not added".

Cindy's database is also read without writing beside it. A mode=ro
open of a WAL database while Cindy was closed made cindy-local-v1.db-wal
and -shm in Cindy's own folder. It now goes through
sessions.OpenUntouched, which is what the Cursor reader already did
(immutable with no log, from a copy with one), moved out of
openCursorStore so both share it.

The CLI's list still offers `magpie cindy add` when the status is
unknown; it never said magpie was missing.

Run: go test ./internal/agent ./internal/sessions ./internal/cli ok;
go test ./internal/gui -run 'Import|Lody|Cindy|Agents' ok.

Broken by hand: Cindy's reader put back on the mode=ro open made
TestCindyHasClosedWALAndUnreadable red ("Cindy's folder changed:
cindy-local-v1.db -> cindy-local-v1.db,cindy-local-v1.db-shm,
cindy-local-v1.db-wal"); api.go ignoring `known` made
TestImportStatusUnreadableIsUnknown red. Both restored, both green.

Not tried: a real Cindy install; the read is tested on fixture
databases only.
2026-10-25 16:49:29 +08:00
yetone 4dfd88206e agent: Lody on Linux is run with its import link, which xdg-open turned away (Atlas on Discord)
Atlas (Discord #help, 10-25, Linux): Lody was running, and adding it
from magpie said "failed to open uri". magpie handed the
lody://provider/import link to xdg-open, as every OS's opener.

Cause, shown with the real Lody 0.108.1 AppImage in an amd64 Ubuntu
24.04 container (Xvfb, no update-desktop-database, as on many
desktops): Lody writes ~/.local/share/applications/ai.lody.desktop.desktop
with MimeType x-scheme-handler/ai.lody.stable and x-scheme-handler/lody,
but runs `xdg-mime default` for ai.lody.stable only. lody:// then rests
on the desktop database cache, which nothing built, so
`xdg-open lody://...` answers "gio: lody://...: Operation not supported"
(rc 4) while ai.lody.stable:// opens. With update-desktop-database run,
both open. The same on GNOME and XFCE with a fake handler at that entry.

Fix: on Linux agent.OpenLody runs what xdg-open would have run, the
Exec line of Lody's own desktop entry (ai.lody.desktop, then
ai.lody.desktop.nightly, then dev.loro.lody.oss; $XDG_DATA_HOME before
$XDG_DATA_DIRS, the first file of a name decides), with %U as the link.
An entry whose program is gone, no entry, or a start that fails falls
back to the opener as before. macOS (Info.plist claims lody:) and
Windows (Lody registers lody itself) are unchanged. The GUI's
/api/open and `magpie lody add` both go through it.

Tests: TestOpenLodyRunsItsDesktopEntry and TestDesktopExec
(internal/agent), TestLodyImportRunsLodyOnLinux (internal/gui, Linux
only). The GUI test is red on the old providers.go in golang:1.26.8
docker ("the link went to xdg-open: lody://..."), green on this one.
TestLodyImportHandoff now sets XDG_DATA_HOME/XDG_DATA_DIRS to its
sandbox, and XDG_DATA_DIRS is in TestFolderVarsAreListed's notAnAgent
(the system's data folders; the first run of internal/agent was red on
it until then).

Not covered, and Lody's to change: magpie on a machine Lody Desktop
reaches as a remote (Atlas's later detail: Lody on their own computer
connected to the host magpie runs on). Lody 0.108.1 imports only into
the desktop's own machine (the renderer writes the configs with
machineId = its local machine and needs __LODY_ELECTRON__), and the
link's payload takes only kind/id/name/auth/endpoints with a loopback
gateway, so no link names another machine. Lody Desktop opened on that
host shares the agent's ~/.lody/machine-id, so the import lands on the
same machine; docs/subsystems/agent-wiring.md says so.

Run:
- real Lody 0.108.1 AppImage in docker: agent.OpenLody reached a
  running Lody (its log: "handleDeepLink accepted deep link {protocol
  'lody:', host 'provider', pathname '/import'}", "sending deep link to
  renderer") and a stopped one ("pending deep link sent to renderer
  after did-finish-load"); xdg-open on the same link: rc 4.
- golang:1.26.8 docker, -tags nogui: agent and gui Lody tests ok.
- macOS: HOME=<sandbox> go test -timeout 45m -count=1 ./internal/agent
  ./internal/gui ./internal/cli: gui ok (124.9s), cli ok (48.6s), agent
  FAIL on TestFolderVarsAreListed (XDG_DATA_DIRS, fixed here); agent
  again after the fix: ok (213.5s).
- rebased on origin/main c6768f06f (5 commits, providers.go among them): the
  Lody, DesktopExec and FolderVars tests of agent, gui and cli ok again.
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... ok;
  GOOS=windows go vet ./internal/agent ./internal/gui ./internal/cli ok.

Not tried: a real GNOME/KDE session with a signed-in user, the .deb
install (its postinst runs update-desktop-database when present),
Nightly and OSS builds, KDE's kde-open, the web-mode page (location.href
still opens it there). No GUI asset changed, so no Playwright run; no
budget raised.
2026-10-25 14:13:38 +08:00