Commit Graph
2127 Commits
Author SHA1 Message Date
yetone 065ca02c28 provider: Fireworks Nexus preset, Nexus Auto on all three APIs (CNSA0422 on X)
Fireworks Nexus is an account and plan of its own (nexus.fireworks.ai,
Pro $8, Team, Enterprise) on the platform's /inference endpoints, which
speak chat completions, Responses and Anthropic messages
(docs.fireworks.ai/nexus/apis-and-sdks). Its keys are made at
nexus.fireworks.ai/settings/api-keys; a platform key carries no Nexus
plan.

The new preset fireworks-nexus (Add sheet tile "Nexus", the Fireworks
logo) sets all three endpoints and lists only `auto`: Pro and Team
refuse an open model named directly with a 403 (nexus/open-models), so
the platform's /models would offer models the plan refuses, and no list
is asked for. Enterprise users type their open models in, or set a
models URL. The editor offers x-anthropic-api-key and x-openai-api-key,
the headers Nexus Auto takes the user's own Claude and OpenAI keys in.
No usage API is documented (only the nexus.fireworks.ai/usage
dashboard), so there is no usage card. READMEs (en, zh) and
docs/reference.md list it.

Run (mote): go test -run 'TestFireworksNexus|Preset' ./internal/provider
ok at the pushed head; go test -count=1 -timeout 45m ./internal/provider
./internal/gui ./internal/catalog at the pre-rebase base: provider and
catalog ok, gui red only in the real-window AppKit tests killed at their
deadline under mote's load (TestCoveredWindowStaysUp,
TestClosingWindowMarksPageOutOfSight,
TestPanelHiddenByWailsMarksPageOutOfSight; #2645, #4924, #4125).
gofmt clean; go vet darwin, linux (nogui) and windows of internal/provider.
Broken by hand: without NoList TestFireworksNexusPreset goes red, the
fake platform list's accounts/fireworks/models/glm-5p3 listed and its
/models asked.
Not tried: a real Nexus key (none here), so neither `auto` on each API,
the header passthrough, nor what /models answers for a Nexus key; the
`auto` context window is left to the catalog (Nexus CLI writes 1M/131K).
GUI suite not run: presets reach the Add sheet as data and no GUI file
names a preset list.
2026-11-10 22:26:38 +08:00
yetone 7e1858515b remote magpie: name its models by the provider serving them there (lcc580 on X)
lcc580 asked for a pass-through on the Remote magpie provider: show the
upstream magpie's own provider beside each model, so an agent can tell the
same model from two of its providers apart. Before, the names followed
both magpies' Provider in model names: with either one Off, both relays'
DeepSeek Chat reached the agents as "DeepSeek Chat · Office" (or plain
"DeepSeek Chat").

- The list a magpie gives another magpie (X-Magpie-Drawers) now names,
  as magpie_by, the provider serving each model there (Entry.ServedBy):
  "routing group" for a group, and for a model of its own Remote magpie
  the provider at the start of that chain. The fetch keeps it as the
  model's By (catalog/live.go).
- A Remote magpie provider gets upstreamProviders: the editor's "Model
  names" tick ("With the provider serving it there"), or
  `magpie provider set <id> upstream-providers=on`. With it on, each of
  its models is labelled "DeepSeek Chat · Office › Relay A" in every
  agent's list, whatever either magpie's Provider in model names says,
  unless the user named the model themselves under Own
  (Entry.Label/upstream, LabelsFor). Model settings' "Agents' lists show"
  line follows the tick at once.
- Ids are unchanged, so a request still goes by office/relay-b/model.
  Off (the default) names everything as before. A remote older than
  magpie_by has nothing to add, so its names stay as before.
- The core's scripts stay in budget: four long comments in app.js were
  cut to pay for it, no raise.

Run:
- Tests that fail on the old code: TestRemoteMagpieUpstreamNames
  (gateway: an httptest remote with two relays' DeepSeek Chat and a
  group, every Provider in model names mode, on and off, the third
  magpie's magpie_by, ids kept), TestServedByAndUpstreamLabel (provider),
  and name-suffix-remote.test.cjs's new case (tick, hint, save body).
- Broken by hand: upstream() returning "" and the magpie_by line removed;
  both Go tests went red with the plain labels, then restored.
- Two real gateways, built -tags nogui on the Linux box (WSL) under
  sandbox HOMEs: B with Relay A and Relay B both serving deepseek-chat,
  A with B as Remote magpie "Office". A's /v1/models before:
  "DeepSeek Chat · Relay A · Office"; after
  `provider set office upstream-providers=on`:
  "DeepSeek Chat · Office › Relay A" / "› Relay B" / "› routing group".
  A request for office/relay-b/deepseek-chat reached relay-b on B.
- gofmt -l clean; go vet darwin, linux (nogui), windows on the touched
  packages; go test catalog, provider, gateway, cli, gui on mote
  (macOS) at the rebased head: ok (catalog 2.6s, provider 165s, gateway 948s, cli 56s, gui 149s).
- GUI on mote, chromium and webkit: name-suffix-remote, remote-magpie,
  remote-self, i18n-keys, i18n-en-no-cjk, gui-ja, gui-de, gui-zh-tw,
  provider-detect-draft, provider-unmasked, routing-remote-windows,
  usage-remote-cards: all green except reds that fail the same on origin/main 388ca9ad4 (run there on the Linux box): gui-ja "ja has every zh string" (#5943) and remote-magpie "asks for the other magpie's address" in both engines (#4398); name-suffix-remote's old "named alone under Off" once in chromium de (#5147, scrollends.js import under load). The new case first failed in webkit (route lost after the save, the page's host went to DNS); it now uses one route whose server is swapped, 20 of 20 on the Linux box (WSL), both engines.

Not tried: the full suite (starts after the tag); the real desktop app's
editor by hand; a chain of three real magpies (the third magpie's
magpie_by is covered by the gateway test only).
2026-11-10 22:20:17 +08:00
yetone b9a1b4aa1d copilot: each account's own models, listed together and routed only to the accounts that have them (applemacssma on X)
"支持多个ghcp账号轮换和平均负载均衡吗,每个ghcp账号有的模型不一样。"
Several Copilot accounts and the Routing strategies (In turn, by usage)
worked already. What didn't: the copilot provider's list was the first
account's /models alone, so a model only another account's plan has was
nowhere to pick, and the gateway took every account to have every model.

Now each Copilot account's /models is kept as its own (accountModels,
read by Account.Lists), and the provider's list is their union
(copilotPoolModels over poolModels, the body codexPoolModels had). A
fetch of the first account's list also asks the other accounts on: one
with no list at once, of the rest the stalest once its list is a day
old, one per fetch. Only a failed ask is remembered (retried after an
hour). A model Copilot refused one account (model_not_supported) stays
in the list while another account on lists it (copilotOthersList).

Run (WSL magpie-desktop at 425195bf3; mote refused SSH all session):
- go test ./internal/provider/ ./internal/gateway/ -timeout 45m: ok
- go vet linux, GOOS=windows, GOOS=darwin CGO_ENABLED=0 for both: ok
- gofmt -l: clean
- TestCopilotAccountsWithOtherModels: octocat lists gpt-4.1 and
  claude-opus-9, hubot gpt-4.1 and gemini-9-pro; the list is the union,
  each model goes only to its account under In turn, gpt-4.1 to both.
- TestCopilotRefusedModelGoesToTheAccountServedIt: octocat's list has
  gemini-9-pro but Copilot refuses it; it then goes to hubot alone and
  stays listed.

Broken by hand:
- copilotPoolModels call removed: the first test red ("lists [gpt-4.1
  claude-opus-9 auto], without gemini-9-pro").
- models.go's union check dropped: the second test red (gemini-9-pro
  left the list).
- A refusal check in Account.Lists made no difference (the gateway
  already keeps a refused account off that model), so it isn't in.

Not tried: real Copilot accounts on two different plans; the full
suite (runs after the tag).
2026-11-10 22:19:31 +08:00
yetone 6bac8f8a59 gui: magpie web on a phone has a tab bar with More (geraldpppppp on X)
On a phone, magpie web's pages sat in a strip under the header that
scrolled sideways, with nothing to show that more pages lay past its
edge. Agents, Library and the rest looked missing. The pages are now a
tab bar at the foot, as an iPhone app's (HIG): each tab its mark over its
word, the page open marked. Five tabs at most: with more pages than
that, the fifth is More, and its menu lists the rest with their marks
and a tick on the open one. More is marked while one of them is open,
and it carries the dot when one of them has one. phonetabs.js does
this. app.js loads it lazily only on a phone, so the core script
doesn't grow. A status line comes up over the bar. The bar is only for
the window, never the tray panel (body.panel).

Agents still isn't shown in gateway mode on a machine with no agents,
as designed (Settings > General > Gateway mode brings it back). Library
has been shown in gateway mode since f285426ac.

Tests: phone-tabs.test.cjs (new) runs at 390x844 in chromium and webkit,
in en, zh, zh-TW, ja and de, with gateway mode on and off. It checks:
- five tabs with More fifth, at the foot, 44px tall;
- nothing scrolls sideways;
- every page is reached from the bar or from More, and More's menu opens
  above the bar;
- the bar covers no page content and no status line;
- a desktop browser has no More.
reader.cjs gets openPage() (the tab, or More's menu). mobile-web,
phone-no-sideways, routing-held-dot and name-suffix-saved open pages
through it. phone-web checks the bar at the foot. old-webkit lists
phonetabs.js as lazy. market-more waits for the view's own foot, not the
window's, which is now above the bar. group-from-model-add wheels Add
wholly into the view before its press, because at 600x420 WebKit took a
press on Add's half-hidden middle as one on the header.

Run on mote:
- The whole GUI suite once (450 files, concurrency 3). 33 red files
  were then run on this change's base and on the branch. The reds only
  on the branch were the four tests that tapped tabs now under More,
  phone-web's old label check, market-more, group-from-model-add (webkit
  600x420), and the panel tests agent-menu-label, zcode-models and
  panel-fit-tabs (webkit). The panel tests are web:true at 360-380px, so
  the bar's padding reached the panel. It is now scoped :not(.panel).
- After the fixes: phone-web, market-more, group-from-model-add,
  agent-menu-label, zcode-models, panel-fit-tabs, phone-tabs,
  mobile-web, phone-no-sideways, routing-held-dot, name-suffix-saved,
  old-webkit and i18n-keys. All are green except reds already filed on
  main: #5919 (old-webkit :has), #5869 (phone-no-sideways de 375) and
  #5215 (tray-cell-click, a web:false panel test). mobile-web's 900/1280
  desktop screenshots need git, so they were run with BASE_REF set to a
  commit of the base's assets: 30/30 pass in both engines, so the
  desktop is unchanged.
- gofmt, go vet for darwin, linux (nogui) and windows, and go test
  ./internal/gui.
- Again at the pushed head, rebased on origin/main ca7a39291: the 13
  GUI files above (239 pass; reds only #5919, #5869 and mobile-web's
  git-less desktop compare), gofmt, vet on all three, and go test
  ./internal/gui ok. TestCoreScriptBudget was over at the old base
  662546e78 and passes here: app.js is ~430 bytes smaller.
- Rebased again on 388ca9ad4 (two agent commits touching app.js and
  i18n.js): the budget tests, i18n-keys, phone-tabs and phone-web
  pass (34 of 34). Then onto 0baa223ec (Kun; a one-line app.js change)
  with no further run before the push.

Broken by hand:
- Without layoutNav's import of phonetabs.js, phone-tabs is 20 of 24 red.
- Without :not(.panel), panel-fit-tabs (webkit, 5 languages) and
  agent-menu-label go red.

Not tried: a real iPhone's Safari, or the LAN share opened on a real
phone.
2026-11-10 22:10:55 +08:00
yetone 0baa223ec9 agent: Kun, magpie as a provider connection through its runtime API (zhongxingyuyes on X)
Kun (KunAgent 0.4.5, Electron, com.xingyuzhong.deepseekgui) keeps its
model providers in ~/.kun/data/model-connections.v2.json (or
$KUN_DATA_DIR) and changes them only through its runtime's admin API,
whose address and token are in runtime.json. magpie wires Kun by
calling that API while Kun runs:

  POST   /v1/model-connections/connect    the magpie connection
  PATCH  /v1/model-connections/:id        models, gateway address
  POST   /v1/model-connections/select     the default model
  DELETE /v1/model-connections/:id        off
  POST   /v1/provider-config/transactions/preview, then commit
         off when magpie's connection is the default: Kun refuses a
         plain DELETE of the connection its default names, so the
         transaction clears the default and removes it in one step,
         and the default the user had before is put back.

When Kun isn't running, wiring says "open Kun, then try again"; the
file is never written behind Kun's back. Kun joins the agent list,
desktop-app detection, the env guard, the icon set (kun.png), the
READMEs and docs/reference.md and docs/subsystems/agent-wiring.md.

Run:
- WSL (Ubuntu 24.04), at the rebased head: go test -tags nogui
  -run 'Kun|ListsModels|Picker|Spelled|HandWired|Sync|Drift|ListOnly|
  Moved|LAN|Proxy' ./internal/agent ./internal/agentenv ok;
  ./internal/library ok; ./internal/gui -run 'Icon|Budget|CSS|I18n|
  Picker' ok (agentenv: no tests match the filter).
- Windows (win-run): go test -run 'Kun|ListsModels|Picker|Spelled|
  HandWired|Drift|ListOnly' ./internal/agent ok. CGO_ENABLED=0 go vet
  for windows (agent, gui, agentenv), darwin nogui (agent, agentenv)
  and linux nogui (agent, agentenv, gui): clean. gofmt -l clean.
- GUI (WSL, chromium + webkit): i18n-keys, i18n-en-no-cjk,
  icon-one-tone, routing-client-icons, icon-tile together 63/63 at
  this head. An earlier run at the pre-rebase head was 60/63, the 3
  reds icon-one-tone's "Open Design one-tone ... Plugins page"
  (chromium), which passed 48/48 alone there and at origin/main: a
  load red (#5425).
- Real Kun 0.4.5 (Linux build, sandbox HOME, `kun serve`): connect,
  a second model, Sync, restart, off. `kun run`
  finished a turn through the gateway (POST /v1/chat/completions,
  Bearer magpie-kun, reply "hello from magpie"). Off restored the
  previous default, and with no previous default Kun was left with
  none and no magpie connection.

Broken by hand: off through the plain DELETE again. The fake Kun now
refuses it as the real one does, and TestKunFromNothing and
TestKunFollowsTheGateway went red with "Deleted connection still has
references: default.providerId"; green with the transaction.

Not tried: Kun's desktop window itself (the runtime was driven
headless); macOS (mote refused SSH all session); `kun run --model`
(run uses its own default model, not the registry's default, so a
CLI run picks magpie's model only with --model).
2026-11-10 22:07:34 +08:00
yetone 388ca9ad45 agent: Claude Desktop says how to go on with the signed-in chats on magpie (Jacky_yyyyyyyy on X)
Jacky_yyyyyyyy on X asked that connecting Claude Desktop keep the earlier
chats and let them be continued. They are kept already: in 3p mode Desktop
runs in Claude-3p (its own userData), the signed-in profile's Code and
Cowork sessions stay untouched in Claude/, claude.ai chats stay on
Anthropic's servers, and Off brings them all back (57e58595b). What was
missing was how to go on with them while on magpie.

Desktop does that itself. magpie's profile already turns on its 3p
import policy (claudeAiImport.enabled, 5be7d05d2). Read from the app
bundles (2.7032 on this Mac, 4.16336's asar from an earlier scratch, read
only): with it on, Settings → Import offers Claude.ai's chats and projects
(arm "direct": a Claude.ai sign-in inside the importer, remotePull in
getImportCapabilities; or a Claude.ai data export zip, localZip) and this
computer's earlier Code and Cowork sessions (localSessions), copied in
under new ids that run on the gateway, originals left alone.
allowedOrganizationUuids unset (as magpie leaves it) allows any org.

So the notice after On and the opened row's "Once connected" line add:
"To go on with them on magpie, open Settings → Import in Desktop: it can
copy in your Claude.ai chats and projects and this computer's earlier
sessions, and leaves the originals as they are." (noticeClaudedesktop5),
in en, zh, zh-TW, ja, de. CONNECT_COST takes a list of sentences, each
translated. agent-wiring.md says the importer covers Claude.ai chats too.
No mimicry, nothing new written to Desktop's files. The isolated
Claude Magpie app is unchanged (the user's own Claude stays signed in).
app.js paid for the sentence with comments cut, no budget raise.

Run (worktree on origin/main a1ba92ad8; mote refused SSH all session,
so Linux runs went to wsl-run magpie-desktop, Windows to win-run):
- gofmt -l internal/agent internal/gui: nothing.
- wsl-run: go test -run 'ClaudeDesktop|Notice|Desktop' ./internal/agent
  ok; TestEveryNoticeIsTranslated ok; go vet -tags nogui ./internal/agent
  ok; go test -tags nogui -run Budget ./internal/gui ok (it was 140
  bytes over before the comment cuts).
- win-run: go vet ./internal/agent ok.
- GUI, Chromium and WebKit (wsl-run): desktop-history 10+10, i18n-keys
  4+4, agent-connect 2+2, desktop-isolated 11+11, all pass.
Broken by hand:
- Notice without noticeClaudedesktop5: TestClaudeDesktopKeepsTheSignedInHistory
  red ("doesn't say how to go on with the history on magpie").
- The opened row rendering only the first sentence: desktop-history 0 of
  10 in Chromium.
Not tried: a real Desktop importing a Claude.ai account's chats in 3p
(would need a Claude.ai sign-in inside a sandbox Desktop); a darwin go
vet and the macOS run (mote unreachable); the full suite.
2026-11-10 22:01:17 +08:00
yetone 6a450c4982 agent: Shelley, magpie's models as its custom models (on X, tweet 2120109384315658393)
"Can support Shelley?" Shelley is boldsoftware/shelley (Apache-2.0, Go,
`shelley serve`). It keeps models and profiles in its SQLite database,
not in a config file, so magpie talks to a running Shelley through the
same API its own Models and Profiles pages use, on the Unix socket it
opens for its CLI ($SHELLEY_SOCKET, else shelley.sock / shelley-N.sock in
$XDG_CONFIG_HOME/shelley or ~/.config/shelley; read from its source).

- Connect: each magpie model is a custom model (POST /api/custom-models,
  provider_type openai, endpoint = the gateway's /v1, Shelley's own
  gateway key, model_name = the catalog id, reasoning/images/max_tokens
  from the catalog). Picking one makes it the default profile's model
  (PUT /api/profiles/{name} with the whole profile, as the API requires)
  and clears a thinking level the model can't take.
- The user's own values: the profile's model and thinking level are
  stashed once and put back on Disconnect (to the server's default if
  that model is gone); only the custom models magpie made (ids stashed)
  are deleted, so a model the user pointed at the gateway by hand stays.
- Sync re-points magpie's models when the gateway port moves; Check names
  a model left on an old address. Shelley not running is an error on a
  pick and nothing on Sync/Check; turned off while Shelley is uninstalled,
  the takeout is stashed and done when Shelley answers again (Alma's way).
- A notice: new conversations start on the pick, an open one keeps its
  model. i18n for zh, zh-TW, ja, de.
- Icon: Shelley's own S mark from its assets, one tone. README (en, zh),
  site index, docs/reference.md, docs/integrating.md, site integrate
  pages (en, zh), docs/subsystems/agent-wiring.md.
- Library: listed as "not looked at (#5897)" like the other new agents.
- Shelley has no Windows build, so there is no Windows or WSL wiring.

Run (mote refused SSH for the whole session, kex reset, so runs went to
the Linux VM and the Windows box):
- Real binary: shelley v0.1718.926152762 linux_amd64 (sha256 66cb5acb…
  checked) in a sandbox HOME/XDG_CONFIG_HOME/-db on the Linux VM, with a
  throwaway test driving it against a fake OpenAI upstream at
  MAGPIE_ADDR: connect made custom model glm-4-6-… and the default
  profile's model; POST /api/conversations/new sent two
  /v1/chat/completions with model=relay/glm-4.6, auth magpie-shelley,
  UA Shelley/58d5f200; disconnect left the profile as before and no
  custom models. Check "" and Drift nil while connected.
- Linux (wsl-run, nogui): go vet ./internal/agent ./internal/agentenv
  ./internal/library; go test ./internal/agent ./internal/agentenv
  ./internal/library ./internal/profile ./internal/sessions: ok except
  TestGrokInstalled (#3548, red on base too) and, before its fix here,
  TestEveryAgentInLibrary. internal/cli times out there in
  TestEveryAgentFieldNameWritesNothing (43m, the #5234 class).
- Windows (win-run): go vet ./internal/agent ./internal/agentenv;
  GOOS=darwin and GOOS=linux -tags nogui vet; the Shelley, applied,
  rewire, disconnect, mark and kept tests: red only in
  TestAppliedOfParsesAnUnchangedFileOnce (#5950),
  TestAsideOfflineDisconnectRestoresWithoutDaemon (#5951) and the #4786
  allocation tests, all red on base d4b4a188e too. internal/cli
  TestHelpOnEveryCommandDoesNothing, TestEveryAgentFieldNameWritesNothing
  and internal/library TestEvery*: ok.
- GUI (node --test, chromium + webkit) i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone, icon-tile,
  routing-client-icons, usage-agent-filter-icons, agent-connect,
  agent-models, agent-layout, on the Windows box at the rebased head:
  110 tests, 107 pass. Red: gui-ja "ja has every zh string" ({model}
  twice, #5943) and icon-one-tone webkit voyage-color (#5962), both red
  at origin/main a1ba92ad8 too.
- At the rebased head 2a9c7b715 (on origin/main a1ba92ad8), Linux:
  vet of agent, agentenv, library ok; go test agent, agentenv, library,
  profile ok except TestGrokInstalled (#3548). Pushed on ca7a39291,
  which changes only internal/gateway (MiniMax drawing); not rerun.
- gofmt -l clean.

Broken by hand: not restoring the profile's model on Disconnect turns
TestShelley and TestShelleyThinkingLevel red; not deleting magpie's
custom models turns TestShelley and TestShelleyKeepsHandWired red.

Not tried: a real model upstream (the upstream was a fake), macOS (mote
unreachable; the darwin build was vetted only), the GUI against a real
Shelley, Shelley's web UI after the switch.
2026-11-10 21:52:19 +08:00
yetone ca7a392919 gateway: MiniMax's image-01 draws on its own image_generation API (rocbomb123 on X)
minimax-cn/image-01 went to chat completions (catalog.ImagesAPI doesn't
know image-01), and MiniMax answered "invalid params, unknown model
'image-01' (2013)". MiniMax draws only on POST <host>/v1/image_generation
(platform.minimax.io and platform.minimax.cn API reference, t2i and i2i,
checked against the docs, not the report).

- draw_minimax.go: a MiniMax API key (filmsMiniMax: the minimax and
  minimax-cn presets, or any provider at api.minimax.io, api.minimaxi.com
  or api.minimax.cn) lists image-01 and image-01-live as drawers and
  draws them at its own host: size -> aspect_ratio (a listed ratio or its
  size; else image-01's width/height in 512..2048 by 8; else the nearest
  ratio; 21:9 image-01 only), n, response_format base64, edit images as
  subject_reference type character, the caller's seed, prompt_optimizer,
  aigc_watermark and style passed on; mask and markup refused before
  asking. data.image_base64 / image_urls are read; base_resp failures in
  a 200 are told by code (1004/2049 key 401, 1008 balance 402, 1026
  content 400, 1002 rate 429, 2013 400), and all images held back
  (metadata.failed_count) says so.
- draw.go: viaFor sends them to the images path, drawImages to
  drawMiniMax, DrawersOf adds them for a MiniMax key.
- A relay serving MiniMax models under another host is unchanged. The
  minimax-code plugin sign-ins are not API keys and are untouched.

Run (mote, at e6f151507 + this change; after the rebase onto
origin/main, which touched no gateway file, -run 'MiniMax|Draw'
./internal/gateway again at the pushed tree: ok):
- go test -count=1 -timeout 45m ./internal/gateway: ok (947s)
- go vet ./internal/gateway on darwin, GOOS=linux -tags nogui, and
  GOOS=windows: ok; gofmt -l clean.
Broken by hand: with the viaFor case and the drawImages hook removed,
TestMiniMaxDrawsOnImageGeneration fails for minimax and minimax-cn with
the reporter's exact "unknown model 'image-01' (2013)".
Not tried: a real MiniMax key (no account here); the fake answers with
the documented bytes. GUI suite not run (no GUI file changed; the
Providers page reads Drawers from the API). Full ./... suite runs after
the tag.
2026-11-10 21:47:45 +08:00
yetone a1ba92ad8c library: a market of Pi's packages, installed and removed by pi itself (nineruiing on X)
Library -> Pi now has a Discover list of Pi packages: npm packages with
the pi-package keyword (pi's own docs: the keyword makes a package
eligible for the pi.dev/packages gallery), sorted by monthly downloads,
with search. Like the other markets it ships a 500-entry snapshot
(market_pi.json), keeps a 6h memory and disk cache, and refreshes from
npm. Install and remove run that Pi's own `pi install npm:<name>` /
`pi remove npm:<name>` with PI_CODING_AGENT_DIR set to its folder, so
settings.json's packages list and <agentDir>/npm are written by pi, not
by magpie. Each card says which Pis have it; Install goes straight to
the only Pi without it or asks which one; the Pi's list gets a remove
button behind a confirm. New routes: GET /api/library/market/pi, POST
/api/library/pi/install and /api/library/pi/remove.

Run:
- mote: go test -count=1 -timeout 45m ./internal/library ./internal/cli
  ./internal/gui at this head: ok, ok, ok.
- mote: gofmt -l clean; go vet of library, gui, cli for darwin, linux
  (-tags nogui) and windows: ok.
- mote: library-pi-market, library-pi-extensions, i18n-keys,
  i18n-en-no-cjk in chromium and webkit: 52 of 52; the 17 market and
  library GUI files: 598 pass, 0 fail (pre-rebase tree).
- win-run: go test -tags nogui ./internal/library -run 'TestPi|TestMarket'
  ok (TestPiRunGivesAgentDir skips on Windows).
- wsl-run: library TestPi|TestMarket ok; library-pi-market 22 of 22.
- Real pi 1.5.1 in a sandbox HOME on WSL: PI_CODING_AGENT_DIR=$A pi
  install npm:pi-btw wrote packages ["npm:pi-btw"] beside the existing
  theme and installed node_modules/pi-btw; pi remove put packages back
  to []. The live ~/.pi was untouched.

Broken by hand (each red, then green restored):
- the pi-package keyword filter dropped: TestPiMarketFromNPM;
- the name check dropped in the market: TestPiMarketFromNPM;
- the name check dropped in install: TestPiInstallAndRemove;
- PI_CODING_AGENT_DIR not set: TestPiRunGivesAgentDir;
- the identity dedupe dropped: TestPiInstallAndRemove;
- the installed marking always "live": library-pi-market 11 of 11 red.

Not tried: a real magpie binary driving pi install end to end; pi on
native Windows; git: and local package sources (the market lists npm
only, and the Pi's list still shows and removes them as before).
2026-11-10 21:15:14 +08:00
yetone 10c4dc109a update: a restart by itself waits while magpie's window is in use (BESTLJP0412 on X)
With Restart automatically on, magpie restarted to update as soon as the
gateway was idle, even while the user was adding a provider or changing
settings in its own window, which closed what they were doing.

The page now tells the app it is in use: any pointerdown, keydown, input
or wheel posts /api/update/using (at most every 20s, and at once when a
dialog opens or closes, with whether #modal is open). inUseAt holds a
restart for 2 minutes after the last input (usingFor), or 15 minutes
while a dialog was open at the last input (openFor). waitFor skips the
restart while the window is in use, unless the restart was asked for
(the tray's Restart to update, Settings' Restart now), which still
restarts at once. A `magpie update` from a terminal (restartBeside) waits
the same way. The route writes nothing, so held doesn't drop caches for
it. /api/update says `using`, and Settings' Version row and the Update
pill add "waiting while you use magpie" (en, zh, zh-TW, ja, de).
docs/subsystems/gui-shell.md describes it.

Run (mote, at this head):
- go test -run 'AutoRestart|Wait|Idle|Restart|Using|EveryRoute|CoreScript|Budget'
  ./internal/gui/ ./internal/cli/: ok.
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows for internal/gui
  and internal/cli: ok. gofmt -l: clean.
- GUI, chromium and webkit: update-using (new), every update-*.test.cjs
  and i18n-keys.
- TestCoreScriptBudget: fits with no raise. Main had 40 bytes left, so
  the update code's comments next to this change were cut to one line
  each (no code, every issue and reporter kept): 1,533,641 of 1,533,802.
- One webkit run of update-wait.test.cjs had a red subtest while mote
  needed 10 ssh tries (its output was cut by my grep, so not filed);
  update-wait passed 3 of 3 in webkit at this change and 3 of 3 on
  origin/main 016763f23.

Broken by hand (a separate worktree): waitFor's in-use check made `if
false && …`, restartBeside's !inUseAt dropped, and the page's listeners
given no events: TestAutoRestartWaitsWhileTheWindowIsUsed and
TestTerminalUpdateWaitsWhileTheWindowIsUsed went red, and update-using's
"a restart by itself waits while magpie is used" went red in chromium.

Not tried: the real app on any OS (only Playwright's engines and the Go
tests), WebKitGTK, and a real update downloaded and applied. A dialog
left open with no more input holds the restart for 15 minutes, then it
goes ahead; the wait still gives up after an hour (waitMost) as before.
2026-11-10 21:09:39 +08:00
yetone 71075af726 codex: "subagents on any model" tells Codex V1 for a relay of the ChatGPT backend too (brethhbbm on X)
brethhbbm on X: lead on relay/gpt-6-astra, subagent model set to
relay/gpt-6.1-terra, "Codex subagents on any model" on. A new session's
subagents still ran on Astra, and Routing said the task was sealed and
only a ChatGPT account could read it. The model's catalog entry still
said multi_agent_version "v2".

Cause: the setting (settings.CodexAgentsV1) stamped V1 only on the
ChatGPT account's own models (codex/) and the groups one is in (Fast).
The relay lists Codex's own entry for gpt-6-astra (a sub2api asked with
Codex's client_version), "v2" included, and a relay offering Ultra is
given "v2" (AgentsV2) besides. In V2 Codex hands the lead the
collaboration namespace (spawn_agent etc.), whose arguments a relay of
the ChatGPT backend seals as the backend does (#1109), so
codexSubagentPick kept the subagent on the lead's model (sealedKept).

Fix: catalog.Model.Seals (provider.CodexSeals) marks a model whose
provider is of no sign-in on the Responses API, as the gateway's
canSeal, or a group with such a member. With the setting on, its entry
says V1 like the ChatGPT account's, listed by its relay or made by
magpie, so the task goes as text and the model set for subagents takes
it. Seals is in the list's tag, so Codex asks for the list again. A
model of an account that seals nothing (Copilot's Ultra, #656) keeps
V2, and with the setting off every entry is as before. No prompt text
or instructions change.

Real Codex (0.165.0, sandbox HOME/CODEX_HOME, fake Responses server,
model_catalog_json with the user's gpt-6-astra entry as
relay/gpt-6-astra): with "v2" the first request carries the
collaboration namespace (spawn_agent, send_message, followup_task,
wait_agent, ...); with "v1" it has none.

Run (Linux box via wsl-run; mote refused SSH for the whole session):
- go vet -tags nogui (linux), GOOS=windows go vet, GOOS=darwin
  CGO_ENABLED=0 go vet -tags nogui on codexcat, provider, agent,
  catalog, settings: ok; gofmt -l clean
- go test -tags nogui -count=1 ./internal/codexcat ./internal/catalog
  ./internal/settings ./internal/provider: ok
- ./internal/agent, and -run 'Codex|Ultra|Subagent|Sealed|Collab|AgentsV1'
  ./internal/gateway, were still running when this was pushed; their
  results go on the release's issue thread if red
- at the pushed head (rebased on c2c2c82ca), Windows box: go vet on the
  five packages, and -run 'CodexSeals|CodexAgentsV1|Ultra' codexcat and
  provider: ok
- earlier on mote: -run 'CodexSeals|CodexAgentsV1|Ultra|CodexListed|Listed'
  ./internal/codexcat ./internal/provider: ok

Broken by hand: dropping m.Seals from both V1 conditions in codexcat
makes TestCodexAgentsV1SealingRelay red ("on: map[... relay/gpt-6-astra:v2]");
CodexSeals setting false makes TestCodexSeals red ("relay/gpt-6-astra:
Seals false, want true").

Tests: TestCodexAgentsV1SealingRelay (a relay's listed v2 entry and a
made Ultra entry say v1 with the setting, Copilot's keeps v2, all as
before with it off), TestCodexSeals.

Not tried: a real relay of the ChatGPT backend end to end with a real
subagent spawn; Codex 0.165 exec showed no V1 spawn tools in its first
request (they are deferred), so the V1 side was checked by the
collaboration namespace being gone. No GUI is reachable from this
change. A thread started before keeps the version it started with; a
new session is needed.
2026-11-10 21:05:34 +08:00
yetone 10bef5fe09 codex: every account shares one list of the Codex app's projects, removals remembered (Michael25651150 on X)
The reporter wants the Codex app's projects kept however magpie switches
ChatGPT accounts. v0.1.3559 (15acba534) copied the longest list only to
an identity with no list yet, so an account with a list of its own (an
empty one too) never got the others' projects, and a project added on
one account never reached an account that had any.

Now, while the app is closed (the same moments as before: the 3s loop
once the state file or logins changed, and between a reopen's quit and
open), shareCodexProjects gives every identity the file has and every
saved Codex login one list: each identity's local-projects together,
the signed-in identity's copy first, with the ties the other
codexProjectKeys have to them (thread-project-assignments,
project-order, pins, appearances, the app-server id maps one level
down). A folder is one project: the app gives a new project a random id
per account (randomUUID in 26.1103's bundle), so a project of a folder
an identity already has maps onto that one, its threads renamed to it.

Removals: codex-projects.json (beside logins.json) keeps each
identity's project ids and folders as the last look left them. A
project a look saw on an identity that the next doesn't have was
removed there; it goes from every identity with every tie, as do other
projects of its folders, unless the user added that project or folder
again since. No record yet removes nothing. A record that can't be
read or parsed means what was removed is unknown: nothing is written.
The record is written after the state file, and not when the app's
start overtook the write, so that look is taken again. The state file
is still written through temp + rename, only when it is byte-for-byte
what was read, with the first-write backup beside it.

Checked against ChatGPT.app 26.1103.60933's own bundle (downloaded from
its appcast into a scratch dir, unpacked there): the renderer state
schema {owner, inactive:{<hash>:{atoms, globals}}}, selectRendererOwner
parking/loading Object.values of the global-state key table (the
account-scoped keys, codexProjectKeys among them), the local project
schema (id, name, rootPaths, backings, createdAt, updatedAt) and
randomUUID ids for new projects. The live ~/.codex was not touched.

Run (mote refused ssh all session, kex reset; so on xiaomi-gpu):
- wsl-run go vet -tags nogui, GOOS=darwin CGO_ENABLED=0 go vet and
  GOOS=windows go vet of ./internal/provider: ok
- wsl-run go test -tags nogui ./internal/provider: ok (281s)
- wsl-run go test -run 'TestCodexProjects|TestCodexRendererOwner|
  TestCodexApp' ./internal/provider ./internal/agent: ok
- win-run go test -run 'TestCodexProjects|TestCodexRendererOwner'
  ./internal/provider: ok
- gofmt -l: clean.

Red on the old code (origin/main's codex_projects.go with a 3-arg
shim): TestCodexProjectsShared (shared with 1, want 2),
TestCodexProjectsRemovalRemembered (0, want 3),
TestCodexProjectsRecordUnreadable (written).
Broken by hand: removals never gone -> RemovalRemembered red; no
folder dedupe -> Shared red; no graft of ties -> FollowASwitch and
Shared red; a tie not renamed to the folder's project -> Shared red;
no MkdirAll for the record -> StepWaitsForTheAppToClose red.

Not tried: the real Codex app switching real accounts (it would share
Electron's userData with the user's running app); the switch is played
by the tests' Go port of 26.1103's selectRendererOwner. No macOS run
(mote down). The first look after this release has no record, so a
project the user removed on one account before it comes back there.
2026-11-10 21:04:11 +08:00
yetone c2c2c82ca8 agent: Tuanjie Cowork, a magpie provider and model in its Custom Models (Charles24209792 on X)
Tuanjie Cowork (Unity China's coworker app, dev.codelycowork.desktop,
2.1.6-stable) keeps the user's own models in ~/.codely/settings.json:
customModelProviders {id, name, baseUrl, apiKey, authType} and
customModels {id, model, providerId, displayName, roles, wireApi,
supportsMultimodal}, read afresh on every lookup. Read from the app's own
core (tZ/oE for the file, Mwi for a session's OPENAI_BASE_URL/KEY, BOe
for the model list, rha/sha for its startup migrations).

magpie adds a provider and a model of its own, both id "magpie": the
gateway's /v1 with Cowork's own magpie key, the model picked, wireApi
chat. The user's providers and models and every other key stay as
written; a name or roles given magpie's entries in Cowork are kept when
the model changes. Off takes both out, and the file too when magpie made
it and nothing else is in it. A provider or model with id magpie that is
the user's own is left alone, with an error. Which model a chat is on is
Cowork's own per-workspace pick, which magpie doesn't write; a notice
says to pick "<model> (magpie)" in its model menu while it runs. Skills
go to the shared ~/.agents/skills, which its core scans. Icon from the
app's icon.icns. Lists, READMEs, reference, agent-wiring doc, i18n.

Run:
- go test ./internal/agent ./internal/library ./internal/gui on mote;
  TestTuanjieCowork* and TestHandWiredMagpieProviderSiblings on Windows
  (win-run).
- gofmt; go vet darwin, linux -tags nogui, windows.
- GUI, chromium and webkit: i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone,
  icon-tile, routing-client-icons, usage-agent-filter-icons,
  agent-connect, agent-models, agent-layout.
- Cowork's own code on magpie's output: its tZ, oE, rha, sha, cE, KGa,
  Mwi, kOe and BOe, extracted from the 2.1.6 core, run in node on the
  settings.json magpie wrote (with the user's own provider, and fresh).
  Its migrations leave magpie's entries; cE("magpie") finds the model,
  the picker label is "deepseek/pro (magpie)", a session gets
  OPENAI_BASE_URL http://127.0.0.1:3425/v1 and magpie's key, the list
  URL is /v1/models, and the user's glm-4.5 is still there.

Where: the packages, vets and GUI files above ran on mote at b834dc2a7
(this change on 4a9142ccd); at the pushed head (on 016763f23) internal/agent's
Cowork, HandWired, EveryAgent, Aliases and Icon tests, internal/library, and
the de, zh-TW and en-no-cjk i18n files ran on Windows. Reds not from this
change, both red on main already: gui-ja's {model} twice (#5943), and
TestEveryAgentInLibrary for obsidian and avibe (#5945).

Broken by hand, each red:
- rest() keeping magpie's entries: TestTuanjieCowork (two models) and
  TestTuanjieCoworkMadeFile (file left behind).
- no check for a provider id magpie of the user's own:
  TestTuanjieCoworkLeavesTheUsersMagpie/provider.
- unwire never removing a file magpie made: TestTuanjieCoworkMadeFile.

Not tried: the real app's GUI (picking magpie's model in its menu and a
chat through it), Windows detection (its NSIS per-user path isn't
known, so on Windows it shows once ~/.codely exists), Linux.
2026-11-10 20:50:10 +08:00
yetone e6f151507f sessions: each session's output speed, a curve of its last two minutes
The owner liked a tweet's token-speed curve and approved a mockup
(claude.ai/artifact/7mrkMKdVi6jA3HA1Z6pRr5). Each Sessions row now
shows its output speed with a small curve; clicking it opens a popover
with the current tok/s, two minutes of seconds, tool gaps, and the
round's average, fastest second and output so far. A row not live
shows "Avg {n} tok/s".

Gateway: a curveMeter (session_speed.go) on the Server counts every
reply's content bytes per agent and session, from liveRow.observe, the
same count the Live view uses, and turns them into tokens with the
learned per-model rate (tokenRates.rate). A model with no rate yet
shows the curve's shape and no number: a guess would be a wrong
number. counted() opens a session's in-flight span, so a second with
nothing in flight is a gap (a tool ran), not a zero. A pause past 2m
starts a new round; 10m of quiet forgets the session; at most 256
sessions. Codex's own sign-in (codex_backend.go) went past serve and
liveRow before; it now has a liveRow too, so its sessions are counted.

GUI: GET /api/speeds, kept out of /api/sessions* so a once-a-second
poll doesn't set off session reading. The page polls only while
Sessions is shown and visible. managedJSON gains keys, so a row
matches a session the gateway saw under another of its keys. The
curve hides below 620px.

Run (mote's sshd resets every connection today, so Linux and Windows):
- Linux (magpie-desktop, wsl-run): gofmt clean; go test -timeout 45m
  ./internal/gateway ./internal/sessions ok except
  TestGroupFailoverTimesEachTry, red once under load, 5/5 green alone
  here and on main (#5948); node --test over every sessions-*.test.cjs
  and i18n-*.test.cjs: 546/549, the reds sessions-export en in both
  engines, the same on origin/main d657e182a alone (#5947), and
  sessions-folder-paging webkit zh, green alone. sessions-speed in
  Chromium and WebKit x en, zh, zh-TW, ja, de (row, popover, live
  update, narrow width, no poll off the page).
- Windows (xiaomi-gpu, win-run), at this head: go vet ./... clean; the
  curve/live/rates/codex tests of ./internal/gateway ok; go test
  ./internal/gui ./internal/sessions ok but 12 tests, every one red the
  same on origin/main 4d95d81ea and filed (#4115, #5928, #4043, #4925,
  #5324; TestAntigravityAppFolder new as #5957). (internal/gui needs gtk4 for cgo, which
  the WSL distro lacks.)
- At the pushed head (on 6886da1ca, which changed core i18n.js and
  gateway.go), Linux: sessions-speed, i18n-keys, i18n-en-no-cjk,
  sessions-row-narrow 22/22; the gateway curve/live/rates/codex/CORS
  tests ok. The Windows run above was at 4d95d81ea.
Broken by hand: with live.go's curves.add skipped, both
TestSessionCurveFromARealStream and TestSessionCurveFromCodexOwnSignIn
went red; green once restored.

Not tried: a real agent session in the built app; macOS (mote down);
darwin vet; the full go and GUI suites (run after the push, reds
filed).
2026-11-10 20:22:17 +08:00
yetone 4a9142ccd4 agent: Obsidian, magpie's models in Copilot for Obsidian (shirotokiren on X)
shirotokiren asked for magpie to set up Obsidian's AI plugins, naming
Copilot and Smart Connections.

The new agent "obsidian" finds the vaults in Obsidian's obsidian.json:
~/Library/Application Support/obsidian on a Mac, %APPDATA%\obsidian on
Windows, and on Linux $XDG_CONFIG_HOME/obsidian or the Flatpak or Snap
folder. In each vault that has Copilot for Obsidian 4+
(.obsidian/plugins/copilot), magpie edits data.json in the shape
Copilot 4.0.19 reads:
- it adds providers.magpie, openai-compatible at /agent/obsidian/v1,
  with requiresApiKey false and no keychain id;
- it adds one configuredModels entry per magpie model, with a
  deterministic uuid v5 id, plus limits, image input and reasoning
  efforts;
- new models go into backends.chat.enabledModels;
- on the first wire it sets defaultModelKey, and stashes the old value.

A sync keeps the models the user turned off, their default, and the
name they gave the provider. It writes only the keys that change
(edit.PatchJSON, then temp and rename), and nothing when nothing
changed. A provider named magpie counts as magpie's only when its
baseUrl is magpie's Obsidian route. One the user added by hand under
that name is theirs: it doesn't read as connected, Disconnect leaves
it, and Connect says so and writes nothing. Disconnect takes magpie's entries out and puts the old default
back. Copilot 3, a data.json it can't parse, and no vault with Copilot
are each an error, and nothing is written. A notice asks the user to
reload Copilot, since Obsidian holds the settings in memory.

The gateway now answers CORS for app://obsidian.md keylessly
(appOrigin). Copilot streams through the window's fetch, and without
CORS headers it can read no reply. Only Obsidian's own window sends
that origin, so it gets no more than its calls without an Origin get.
From the network it still needs a key.

Smart Connections is not wired. Its free plugin embeds with a local
model only, and its API providers are in the closed Pro plugin, with
keys in the keychain.

Run (mote, at 401187300 + this commit, then again after rebasing on
9c39edb92):
- gofmt
- go vet for darwin, linux nogui and windows
- go test -run 'Obsidian|Notice|CORS|Craft' ./internal/agent ./internal/gateway
- GUI, chromium and webkit: i18n-keys, i18n-en-no-cjk, icon-one-tone
  (56 of 56)
At 9c39edb92 + this commit: the whole internal/agent package ok
(211s), vet for darwin, linux nogui and windows, CORS tests ok.
At 4d95d81ea + this commit: Obsidian, HandWired and Spelled tests,
vet for darwin and windows, and the three GUI files again (56 of 56).
win-run: TestObsidian* ok on Windows 11.

Broken by hand (each went red, then was restored):
- corsGuard without the appOrigin branch: TestCORSObsidian, preflight
  404.
- re-enabling every magpie model on sync: TestObsidianCopilot, "a
  model the user turned off came back on".
- dropping the user's configuredModels: TestObsidianCopilot.
- counting any provider named magpie as magpie's:
  TestObsidianCopilotHandWiredMagpieIsTheirs.

Not tried: a real Obsidian with Copilot loading the written data.json.
The fixtures follow Copilot 4.0.19's types and migrations. Not tried
over LAN either. The full suite runs after the tag.
2026-11-10 20:06:21 +08:00
yetone 18c932385e claude: a Claude model Claude Code doesn't know is run to 1M, so Codex compacts on Fable 5.2 (magicalaciw18 on X)
Codex on claude/claude-fable-5-2 (the Claude subscription bridge) never
auto-compacted. magpie tells Codex the model's 1M window and Codex
compacts at 272K, but Claude Code 2.1.316 doesn't know claude-fable-5-2,
so it assumes a 200K window. It turned every conversation past 200K away
before Anthropic was asked ("Prompt is too long", blocking_limit, 0
tokens). Codex got that refusal as a failed turn, not a compaction.

claudeRunName now asks Claude Code for such a model by its "[1m]" name.
That applies to a Claude model of generation 5 or later that Claude Code
doesn't know (claudeKnownLong) and whose window magpie doesn't know to be
under 1M. Models it knows keep their names, since a new name misses the
prompt cache once. Every generation 4 model keeps its name too:
claude-sonnet-4-6[1m] is refused even a short turn on an account without
usage credits. Only Claude Code's --model changes. The reply, the saved
session and the logs keep the model as asked.

Real runs (sandbox CLAUDE_CONFIG_DIR, real accounts, claude -p 2.1.316,
~275K-token prompt):
- claude-fable-5-2: Prompt is too long / blocking_limit.
- claude-fable-5-2 with CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000, or with
  CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT=1: still blocked.
- claude-fable-5-2[1m]: OK.
- fable-5-1, sonnet-5-5, opus-5-5, haiku-5-5 plain, and fable-5-1[1m],
  sonnet-5-5[1m]: all OK.
- Short turn: sonnet-4-6[1m] got 429 "Usage credits required for 1M
  context" on one account; opus-4-6[1m], opus-4-8[1m] and fable-5-2[1m]
  were OK.
- The live gateway gave the same refusal: 230K to claude/claude-fable-5-2
  was refused, while claude/claude-fable-5-1 took 269K.

Siblings: Copilot lists max_prompt_tokens 200000 for claude-sonnet-5.5,
while magpie says 1M. A real 265K turn on copilot/claude-sonnet-5.5 (and
on copilot/claude-fable-5.2) was served, so that limit isn't enforced and
was left alone.

Tests: TestClaudeRunName, and TestClaudeRunAsksUnknownModelLong, which
uses a fake claude that records its args.
Run on mote:
- the new tests with TestClaudeCLI* and TestClaudeRunKept*: ok;
- go test -count=1 -timeout 45m ./internal/gateway/: ok (900s);
- go vet for darwin, linux -tags nogui and windows on ./internal/gateway/;
- gofmt -l: clean.

Broken by hand:
- passing the bare model to claudeCLIArgs made
  TestClaudeRunAsksUnknownModelLong red (asked for "claude-fable-5-2");
- dropping the generation 4 floor made both tests red (sonnet-4-6[1m],
  haiku-4-5[1m], opus-4-8[1m]).

Not tried:
- a real Codex session compacting through a sandbox build end to end;
- Claude Code versions other than 2.1.316, where the list of models it
  knows differs;
- Windows (the fake claude is a shell script, so the test skips there).
The full suite runs after the tag.

Rebased on 9c39edb92 (32 commits on, incl. 401187300 catalog fallback and 543eb39b9 interactive runs): the Claude run tests in internal/gateway, go vet darwin/linux nogui/windows ok again at this head on mote. The interactive mode takes the run's args (interactiveArgs), so it asks the [1m] name too.
2026-11-10 19:55:26 +08:00
yetone 5e3f14f21f agent: Paimon, magpie's models through its litellm provider (ditangongyuan on X)
Paimon (aisk/paimon, `uv tool install paimon`) is a terminal coding agent
on pydantic-ai. Read at 7f7fa51 (config.py, llm.py): its settings are one
JSON file, $PAIMON_CONFIG_HOME/config.json, else ~/.config/paimon/config.json
on every OS. "model" is provider:name, and "providers" keeps each
provider's api_base and api_key.

magpie connects it through pydantic-ai's litellm provider, an
OpenAI-compatible proxy that profiles a vendor/model name by its vendor,
as magpie's ids are spelled, and which Paimon's login never offers:
model = litellm:<catalog id>, providers.litellm = the gateway's /v1 and
magpie's key for Paimon (0600, as Paimon writes it), and
compaction.context_window = the model's window. Paimon compacts against
that only for names genai-prices doesn't know, which magpie's ids aren't;
for a model whose window magpie doesn't know it gets the user's own back,
never the last model's. What the user had in the three keys is stashed and
put back on Disconnect (or `magpie paimon default`); the rest of the file
is untouched, and a file magpie made goes again. A model picked in Paimon
itself while magpie's provider stays is the user's from then on. Requests
are told apart by Paimon's paimon/<version> User-Agent. WSL distros, the
PAIMON_CONFIG_HOME isolation, notices in every language, icon, READMEs,
docs/reference.md, agent-wiring.md and the site's list come with it.

Run:
mote refused SSH all session (kex reset), so the Linux runs went
through wsl-run (magpie-desktop) and Windows through win-run:
- go vet: linux -tags nogui, GOOS=windows, GOOS=darwin -tags nogui on
  internal/agent, agentenv, library: ok. gofmt -l: clean.
- go test -tags nogui ./internal/agent/... agentenv library gui cli (WSL,
  base f03ec97b8): all ok except TestGrokInstalled, the known WSL binfmt
  red #3548.
- Windows: TestPaimon, TestHandWired*, TestEveryNoticeIsTranslated,
  TestPortMovesEveryAgent ok (file-mode checks skipped there).
- GUI, chromium + webkit (WSL): i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone, icon-tile,
  mono-icon-redraw, routing-client-icons, usage-agent-filter-icons,
  agent-connect(-no-models), agent-models(-own, -picker), agent-layout:
  150/151; the red is gui-ja's usage price string, untouched here, filed
  as #5943.
- Real Paimon 0.2.8 (uv pip install paimon) in a sandbox HOME on WSL,
  against a sandbox magpie gateway over a fake OpenAI upstream:
  `magpie paimon magpie/fakeup/m1` wrote litellm:fakeup/m1 and
  providers.litellm at 0600; `paimon -p ping` answered "pong from fake
  upstream", the upstream saw POST /v1/chat/completions with
  "paimon/0.2.8 (Python 3.10.19; Linux x86_64)", and magpie usage counted
  the call under Paimon; `magpie paimon default` put the file back equal
  to the user's.
- After the rebase on origin/main 9c39edb92: the three vets, the targeted
  agent tests and internal/gui ok; internal/library's
  TestEveryAgentInLibrary red for avibe from 9c39edb92 (#5945, not this
  change); i18n-keys, i18n-en-no-cjk, agent-notice-lang, gui-de, gui-zh-tw
  ok; icon-one-tone's every-logo case ok in both engines, its webkit
  Plugins-page case timed out on page.goto's 5s at WSL load 92 (#5425).

Broken by hand, each red in TestPaimon:
- the user's window not put back for a model magpie doesn't know (switch
  window: <nil>);
- stashing again while providers.litellm is magpie's (switch window: 200000);
- a file magpie made not removed (made file left: {});
- a model picked in Paimon not kept as the user's (restore after a pick).

Not tried: macOS (mote unreachable) and the GUI's own Connect click with
the real binary; Paimon's auto-compaction at a window magpie wrote (the
fake model had none, so Paimon said compaction was off, as it does for any
name it doesn't know); a model picked in Paimon's own /model while
connected beyond the unit test.
2026-11-10 19:54:37 +08:00
yetone 9c39edb92c agent: Avibe, magpie as a model source through its Model Hub (alex_metacraft on X)
Avibe (avibe-bot/avibe, avibe-os on PyPI, the `vibe` CLI) runs its own
agent, Vibey, and Claude Code, Codex and OpenCode, all on models from its
Model Hub. Its sources live in model_hub.sources of config/config.json in
$AVIBE_HOME (else ~/.avibe, else a legacy ~/.vibe_remote), but a source
can't be written there by hand: its key is sealed in the hub's credential
store and Avibe puts it into its agents' route chains as it is made.

So the Avibe row adds "magpie" the way Avibe's Models page does, through
its internal API (POST /internal/model-hub on state/dispatch.sock, or on
Windows the loopback port + bearer of runtime/control-ipc/endpoint.json):
create_source with kind api_key, vendor custom, base_url the gateway's
/v1, key agentKey("avibe"), protocol openai_chat and save_unverified.
Avibe then lists the models from /v1/models and adds the source to
Vibey's, Claude's, Codex's and OpenCode's chains itself.

- openai_chat, not openai_responses: for a Responses source Avibe's
  CLIProxyAPI runs Codex's executor, which sends codex-tui headers the
  gateway would take for Codex.
- Off is delete_source with force, sent again with the would_remove_hops
  and would_interrupt Avibe answers, as its page confirms them. Sync is
  refresh_source the same way; on a moved gateway the source is made
  again (the key goes with the address; patch_source can't change it).
- The source id is stashed; a custom source at the gateway's /v1 counts
  as magpie's too and is stashed once seen.
- Every change needs Avibe running; otherwise the switch says to run
  `vibe start` (errAvibeDown). Nothing is written to config.json.
- A sync moves the source only from the gateway's own address on an
  older port (avibeMoved). One the user pointed at a NAS's or the LAN's
  magpie, a local proxy's route, or a WSL distro's way to Windows stays,
  as kept.away keeps every file-written agent's; a Rewire after a port
  move sets it again through the field's Set.
- Every test of the package but Avibe's own finds an Avibe running for
  each home (runningAvibe, served in-process), so the tests that connect
  every agent (gateway moved, LAN and proxy addresses kept, drift,
  ListOnly) take Avibe in too.
- The logo is a tile solid to its edges, so it joins app.css's tile rule
  (icon-tile.test.cjs went red without it).
- AVIBE_HOME joins agentenv and the ~-expanding path vars (Avibe expands
  it). Icon from Avibe's assets/logo.png (MIT), 64px.

Run:
- Real Avibe 3.2.5 (uv tool install avibe-os) in a sandbox HOME in WSL
  magpie-desktop, with a fake OpenAI server as the gateway: magpie's own
  code (a throwaway test, AVIBE_HOME + MAGPIE_ADDR) connected it, Avibe
  discovered both fake models with "Authorization: Bearer magpie-avibe"
  and put the source in vibey/claude/codex/opencode chains; Sync
  refreshed; a gateway move to :3592 made the source again there and
  stashed the new id; a second run found the source by address alone
  and still followed the move; off removed it (list_sources []).
  Earlier, by hand: Anthropic /v1/messages and /v1/responses through the
  hub reached the fake as chat completions.
- wsl-run, at this head rebased on origin/main 021a6e1fd (then 401187300, where the Avibe and all-agents tests, i18n-keys, icon-tile and the gui -run set were run again: ok on Linux and Windows): go test
  -tags nogui ./internal/agent ./internal/appdir ./internal/agentenv:
  appdir, agentenv ok; agent ok but TestGrokInstalled, red on WSL2 at
  main (#3548).
- win-run: the Avibe tests and the all-agents tests (drift, port move,
  LAN, proxy, ListOnly, pickers): ok. The whole internal/agent package
  on Windows (one commit earlier) has main's known Windows reds (#4115,
  #5068, #4846, #5130, #5344, ...); its two Avibe reds (drift, ListOnly)
  are what runningAvibe fixed.
- vet (on the Windows box): windows, GOOS=darwin, GOOS=linux nogui on
  agent/appdir/agentenv: ok.
  gofmt clean.
- GUI (chromium + webkit, win-run): i18n-keys, i18n-en-no-cjk,
  icon-one-tone, routing-client-icons, icon-tile: 63 of 63 ok; go test
  ./internal/gui -run 'Icon|Budget|CSS|I18n|Picker': ok.
- mote refused SSH all session, so everything ran on wsl-run/win-run.

Broken by hand:
- a sync moving any address that isn't the gateway's: the LAN- and
  proxy-kept tests red on Avibe's config.json.
- app.css without avibe in the tile rule: icon-tile.test.cjs red.
- protocol openai_responses: TestAvibeAddsMagpieAsAModelSource red.
- confirmed() not resending the echoed hops: the add, knows-its-source
  and follows-the-gateway tests red (source_in_route_chain).

Not tried: magpie on Windows wiring an Avibe that runs inside WSL; a
real Vibey turn against the real gateway (the fake stood in for it);
macOS with a real Avibe.
2026-11-10 19:36:59 +08:00
yetone e8fbee60ea gui: pause the gateway without quitting magpie (me2seeks on X)
Disconnect and quit was the only way to stop the gateway, and it quits
magpie too. Pause does the same without the quit, from the tray's Pause
Gateway (Resume Gateway while paused), Settings › General › Gateway
(On/Paused, the app's only) and the Gateway page's Resume gateway, all
through POST /api/gateway/pause.

- Pause disconnects each connected agent as its row's Disconnect does
  (its own settings put back), keeps their ids in gateway-paused.json in
  the config folder, and stops the listener with requests in flight
  drained. An agent that can't be disconnected keeps the gateway serving,
  those before it connected again, and is named in the status line.
- While paused, serveGatewayLocked serves nothing: not the 15s watch, a
  port change nor a handover; a magpie started again stays paused. A
  pause file that can't be read counts as paused.
- Resume serves again and connects the agents the pause disconnected.
  A port held by something else keeps the pause and says what holds it.
  The Gateway page's Start/Restart, connecting an agent and picking one
  of magpie's models for it resume too.
- quitask's wired list and the pause share wiredOf.
- Strings in en, zh, zh-TW, ja, de. gui-shell.md documents it.

Run (mote was unreachable for the later runs; the Windows box instead):
- mote, before the rebase: go vet ./internal/gui; go test -run
  'TestGatewayPause|TestGatewayResumes|TestTray|TestGatewayFix|TestQuit'
  ./internal/gui: ok.
- at this tree on b46f23ffa: win-run go vet ./internal/gui ok; wsl-run
  go vet -tags nogui ./internal/gui ok; gofmt -l clean.
- win-run go test -count=1 ./internal/gui: the pause and tray tests ok;
  8 reds, each the same on origin/main d4b4a188e run alone on Windows
  and filed (#4115 %AppData% import rows, #5928 ~\ paths, #2107/#3649
  TestGatewayHeldByAContainer).
- wsl-run GUI (chromium + webkit): gateway-pause (5 languages x 1000/420),
  settings-general, gateway-takeover, i18n-keys, i18n-en-no-cjk: 51/52.
  The red is gateway-takeover webkit en's dark-mode case, red 1 of 2 on
  untouched origin/main too: #5942.
- rebased on 401187300: win-run go test -run 'Budget|TestGatewayPause|
  TestGatewayResumes|TestTray|TestQuit' ./internal/gui ok; wsl-run go vet
  -tags nogui ./internal/gui ok; gofmt clean. darwin vet not rerun after
  the rebase (mote refused SSH).

Broken by hand: serveGatewayLocked without its pausedNow check, and the
rollback's reconnect skipped: TestGatewayPauseAndResume ("served while
paused") and TestGatewayPauseRollsBack ("codex not connected again")
went red; green again restored.

Not tried: the real app's tray on a desktop, a real agent's config
round-trip (the Go tests fake the agents; Disconnect/connect are the
rows' own code), an agent wired from the CLI while the app is paused
(it doesn't resume), the whole GUI suite, the full Go suite (started after the tag).
2026-11-10 19:36:24 +08:00
yetone 4011873001 catalog: models.dev unreachable falls back to the last copy or a shipped one, retried in minutes (creeksuen on X)
Where models.dev can't be reached (a network in China), the catalog that
gives prices, context windows, reasoning levels and names degraded:

- first run: no catalog file, so every model unpriced, no windows, and a
  plugin's provider listed no models, until a fetch got through;
- a failed fetch: KeepFresh tried again only after an hour, and the app's
  backend waited up to 30s on models.dev before it asked the vendors for
  their lists;
- Sync wrote models.json in place (os.WriteFile), so a reader could catch
  it half written, and a parse failure left no catalog at all.

Now:

- Sync writes the catalog through a temp file renamed over it
  (writeWhole, shared with labs.json). A refused, hanging or wrong answer
  (HTML, cut-off JSON) keeps the last good copy byte for byte.
- The binary ships models.dev's api.json of 2026-11-10
  (internal/catalog/bundled/api.json.gz, 608KB; go:generate refreshes it).
  loadGen reads magpie's copy, then OpenCode's, then the shipped one,
  passing over one it can't parse. Seed (app backend, magpie serve, the
  plugin host) writes the shipped copy into the cache when there is none
  or it is older, dated bundledAt, so the plugin host reads it and Stale
  still has the real one fetched. A test binary has it off (bundledOn).
- The app's backend no longer waits on models.dev before the vendors'
  lists when a catalog is there; KeepFresh fetches beside them, and a
  failed fetch is tried again after 2 minutes, doubling up to the hour.
- The fetch already goes through http.DefaultClient, which
  netproxy.Install routes through the proxy in Settings, *_PROXY or the
  system proxy; there is no models.dev mirror setting to honour.

Run (mote, at the rebased head unless said):
- gofmt -l: clean. go vet darwin (catalog, plugin, cli, gui), linux -tags
  nogui and windows: ok.
- go test ./internal/catalog: ok at the rebased head; ./internal/plugin,
  ./internal/gui, ./internal/cli: ok at the pre-rebase head but for
  TestEveryRouteHasACommandOrIsNamed, red at that older base (a GUI route
  this change doesn't touch) and ok at the rebased head.
- New tests, each fake models.dev on 127.0.0.1 (cut connection, hang,
  captive-portal HTML, cut-off JSON): TestFailedSyncKeepsLastGood,
  TestFirstRunOfflineAnswersFromShippedCopy,
  TestUnreadableCacheFallsBackToShippedCopy, TestSeed,
  TestSyncWritesThroughRename, TestFailedFetchRetriedSoon.
- Windows (win-run): the catalog tests ok, 15 of 15 with -count=15;
  TestSyncWritesThroughRename skips there (it holds the file open).

Broken by hand, each red: Sync back to os.WriteFile
(TestSyncWritesThroughRename); load without the shipped copy
(TestFirstRunOffline…, TestUnreadableCache…); Seed over a newer catalog
and Seed dated now (TestSeed); first retry after the hour
(TestFailedFetchRetriedSoon).

Not tried: the real app started with models.dev blocked; the full suite
(started after the tag).
2026-11-10 19:26:13 +08:00
yetone b46f23ffa5 docs: the model list's provider ticks and a provider's billing 2026-11-10 18:58:03 +08:00
Suge8 543eb39b94 gateway, claudetui: an interactive run asked another effort goes on in its run, the conversation read from the cache
#5584 (Suge8, magpie 0.1.3216, Claude Code 2.1.318, Pi on Opus 5.5,
interactive mode): a turn asking another effort than the one before let
the run go ("its effort is set at its start, and the next turn asks
another"), and a new Claude Code was told the conversation from a
transcript: 72,416 tokens written to the cache on a 108-message
conversation, 178,309 on a 148-message one (first token after 94.4s).

-p runs take a new level by apply_flag_settings (#502). The interactive
mode can't, as measured on the real 2.1.318 (Haiku 5.5, tmux, magpie's
own arguments):
- typing `/effort high` keeps the cache (55,310 read before, 55,400
  after), but saves the level as the default for new sessions:
  modelSettings.<model>.effortLevel in the settings.json of the
  account's folder, the user's own ~/.claude for Claude Code's own
  sign-in, even with --setting-sources ''. Only `max` is session-only.
- a --settings file rewritten (effortLevel, or modelSettings.<model>)
  changes nothing: the request stays at medium, with or without
  --effort. Claude Code pins the file's content as it starts.
- after `/effort max`, the one field of its requests that changes is
  output_config.effort.

Fix:
- Every interactive run has the guard file (guard.json, {} with no
  safeguards); guardBody writes its safeguards and, once the run was
  told another level than its --effort (ownEffort), "effort" beside
  them. setSafeguards and the new setTUIEffort both write it from the
  run's state (tellGuard, under settingsMu).
- tap.js asks each main request (x-claude-code-request-class: main) at
  the file's effort in output_config.effort, and leaves Claude Code's
  other requests as they were; CLAUDE_CODE_EXTRA_BODY gets the file
  without "effort". It writes guard.json.live at the first main request
  as well as the first one carrying safeguards.
- resume: an interactive run asked another effort calls setTUIEffort.
  A run with no .live (no tap), or a turn asking Claude Code's own
  level ("") of a run started at another, is let go as before, the log
  saying which.
- A level the model refuses (real 2.1.318 on claude-haiku-4-5 through
  such a rewrite: "API Error: 400 This model does not support the
  effort parameter.") fails the turn as a run started at it would; the
  existing path (ended, !ok) lets the run go, and the turn asked again
  starts a Claude Code at that --effort.
- docs/subsystems/claude-subscription-bridge.md says so.

Run at this tree (base 9e6687e3):
- New: TestTapAsksTheGuardFilesEffort (bun and node),
  TestClaudeTUIEffortChangeGoesOnInItsRun,
  TestClaudeTUIEffortChangeWithoutTapStartsAnew,
  TestClaudeTUIEffortRefusedStartsAnew: ok; with the guard tests,
  -race -count=3: ok.
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...; go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build: ok.
- go test -tags nogui ./... (Go 1.26.8, go.mod's; sandbox HOME):
  everything ok but TestPluginSOCKSProxy (#2207, Bun 1.4.4 here) and
  TestLaneLimitRoutes (#5150, reads the running gateway; ok alone).
- The built binary, `magpie serve` on 127.0.0.1:34251 in a sandbox HOME,
  XDG dirs and TMPDIR, Claude Code 2.1.318 signed in from a copy of the
  access token (no refresh token), three turns of one conversation on
  claude-haiku-5-5 at medium, high, medium (~20K tokens of history):
  one Claude Code pid for all three, no "its effort is set at its
  start"; the requests as sent (a read-only preload under the tap) asked
  medium, high, medium; usage read/written 795/19,413, 19,869/384,
  20,228/71. ~/.claude/settings.json byte for byte unchanged.

Broken by hand:
- resume's old abortFor back: the three gateway tests red ("started 2
  runs, want one at medium"; the log's reason; the refused turn
  answered 200).
- tap.js not asking the effort: TestTapAsksTheGuardFilesEffort red
  ("request 1 was sent … medium").

Not tried: Opus and Sonnet through the interactive mode (Haiku 5.5
only); whether Anthropic thinks harder at the rewritten level (the
request asks it, the reply doesn't tell); a Claude Code in WSL.
2026-11-10 18:57:44 +08:00
yetone 99b080e2ee agents: an agent can have its own Provider in model names (KillTry27355 on X)
"希望 可以在不同的 agent中选择是否显示供应商名字,现在只能统一开关":
Provider in model names was one switch for every agent. An agent's
Details on the Agents page now has a Provider in model names row: As in
Settings · <mode> (the default, kept for everyone), On, Not on names I
set, or Off, for that agent alone. The CLI has the same thing:
`magpie model suffix <agent> [on|own|off|every]`.

- settings.AgentSuffix keeps the agent's own mode by the id its lists are
  kept by (Agent.ListsFor, lower-cased, without @wsl: or #profile). An
  agent with none follows PlainNames/PlainOwnNames as before, so nothing
  a user already set changes.
- provider.LabelsFor(agent, es) reads that agent's mode. Every place
  that named models with Labels for an agent now passes the agent: Codex's
  catalog, the agents' written lists (route.go, Pi's extension), the
  gateway's /v1/models (by agentOf(r)), Muse, Antigravity, Ollama, Claude
  Desktop's catalog and descriptions, Claude Science. Labels is
  LabelsFor("").
- POST /api/settings/agent-suffix sets it and rewrites the agents'
  configs (catalog.Touched), as Settings' switch does.
- docs/subsystems/agent-wiring.md says where the mode is kept and read.
- The picker is in agentsuffix.js, imported when an agent's Details open,
  so the core grows by the one line that loads it (1,529,335 of its
  1,533,802 budget, after the previous commit's move). An agent whose
  list takes no names of magpie's (noNames) has no row.

Tests, each red on the old code: TestAgentSuffix (provider: modes, keys
with @wsl and #profile, reset, bad input), TestAgentSuffixReachesItsFileAlone
(agent: Pi's file follows its own mode while Codex's follows Settings'),
TestModelsListFollowsAgentSuffix (gateway /v1/models per agent),
TestModelSuffixAgentCmd (cli), settings_keep (AgentSuffix survives a
Settings save), agent-suffix.test.cjs (5 languages x 1180/390 x chromium
and webkit, and a noNames agent has no row).

Broken by hand (a copy with LabelsFor ignoring the agent and the picker
reading no own mode): TestAgentSuffix, TestAgentSuffixReachesItsFileAlone,
TestModelsListFollowsAgentSuffix and every agent-suffix GUI case went red.
TestModelSuffixAgentCmd stayed green; it checks what is saved, not the
names.

Run on mote at this change on top of 720200092: gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui and GOOS=windows clean; go test -count=1 of internal/provider,
cli, gui, settings, settingsapi and agent: ok; internal/gateway in an earlier
run of this change at 3b261932e: ok (1044s), and at this head -run
'Desktop|Models|Suffix|Science|Muse|Ollama|Antigravity|Codex.*Catalog': ok.
node --test of every agent-*, i18n-* and gui-* file plus old-webkit, both
engines: 1026 of 1049. The reds are all on main or under load:
agent-switch-accounts' 20 not-connected cases (red at origin/main 7c41060c2
too, filed as #5925), old-webkit's Safari 15 styles (#5919), and one case
each of agent-compact (#5607) and agent-stale-copies (#1949), which pass
44/44 when run alone. panel-fold's 'keeps what was clicked' is red on main
too (#5796).

Rebased on 0f94acc99 and run again at this change (9d82986ea): gofmt
clean, go vet clean for darwin, linux (nogui) and windows; provider,
gui, settings, settingsapi and agent ok, the gateway's suffix and
agentOf tests ok; GUI agent-suffix, old-webkit, agent-bulk-visibility,
visibility-saving, i18n-keys and i18n-en-no-cjk in chromium and webkit,
57 of 58, the one red Safari 15's styles (#5919). internal/cli was red
only on /api/model-price having no command, from main's 40ca0c88d;
the next commit names it. Rebased again on ccc96b4a7 before the push
(proc, codex, claudetui, a remote window, routing rules, redact;
no conflict), core budget test ok there.

Not tried: a real agent with a real account picking its own mode; WSL and
Windows agents (the @wsl: key is covered by a unit test only).
2026-11-10 18:57:16 +08:00
yetone 327fb57659 redact: Never mask holds from the next text on, earlier turns stay masked (NicoleS76448271 on X)
A value let go from the request view's menu (Never mask) went as written
in the conversation's earlier turns too, so the prompt the vendor had
cached no longer matched and the whole conversation was read again at
full price. Now a text sent masked on a route keeps that value masked,
with the same placeholder, while magpie remembers the text; new texts
(the next turn, another conversation) send it as written. It holds for
values added in Settings too.

allowkept.go remembers a maphash of (route, text) and of the value,
never the value, in two generations of 2^17 like sentSpans' memo. Only a
request with a route (Options.sent and Route) keeps it; a search's query
or an embedding's input has the value as written at once. Keeping a
value masked is the safe side: a collision masks a value the user let
go, and a text no longer remembered (after a restart) sends it as
written, as before. The menu's message now says earlier messages stay
masked so the cache holds (en, zh, zh-TW, ja, de). The request view's
inline Never mask was already there (yew_fence on Discord).

Run (mote refused SSH for ~30 min at load ~125, so on the Linux box):
- wsl-run go test ./internal/redact/ ./internal/masking/ ./plugins/redact/
  ok, at the pushed head b9d1f00a5 too.
- wsl-run go test -run "Mask|Redact|Allow|Sent" ./internal/gateway/ and
  -tags nogui ./internal/gui/: ok.
- go vet: GOOS=windows (redact, gui), GOOS=darwin (redact), linux -tags
  nogui (redact, gui): ok. gofmt -l clean.
- node --test mask-value-menu, i18n-keys, i18n-en-no-cjk (chromium and
  webkit, every language): ok. masking-records: the same reds as fresh
  origin/main b35867730 (24 there, 23 here), filed as #5830, commented.
Broken by hand: apply without the maskedBefore check makes
TestAllowKeepsSentTextMasked red (the earlier turn goes as written).
Not tried: a real Anthropic request reading the cache across the
change; macOS (mote down); the full suite.
2026-11-10 18:50:45 +08:00
yetone 82962db79a routing: a rule can match the system prompt or the last user message, by words or a regex, with no model asked (SucroseMoE on X)
SucroseMoE asked for routing on plain string and regex matches instead
of an intent model: `system[0] matches /^你是对话标题命名/` → model A,
`user[-1] matches /^正在上下文压缩/` → model B, so any harness's title
and compaction calls can be routed without a classifier.

Two new rule condition fields, beside message/effort/subagent/agent:

- system: any block of the system prompt as the agent sent it (Anthropic
  system blocks, Chat system/developer messages, Responses instructions
  and system/developer items, Gemini systemInstruction). Any block, not
  only the first, because Claude Code's first block is its billing
  header.
- last: any text of the request's last user message as sent, reminders
  the agent adds included, so an anchored ^ still meets a compaction ask.

Ops for both: contains, doesn't contain, starts with, matches (regex,
case-insensitive; a value written /…/ has its slashes dropped). The
gateway reads system and last only when a rule asks (RulesRead), and
decodes raw system JSON lazily then. Like every rule, the decision is
made as a turn starts and its tool rounds keep it.

GUI: Routing → group → Rules, "+" on a rule row offers "System prompt text"
and "Last user message" pills (no modal), with tooltips, placeholders
and the bad-regex mark; zh, zh-TW, ja, de. CLI: `--when "system matches
^You are"`, with aliases system[0], user[-1], last-user. TUI hint, docs
(gateway-routing.md, site start pages) say the same.

Ran, on mote (macOS) until its sshd began refusing connections: gofmt
-l internal/ clean, go vet of provider/gateway/cli/tui, the rule tests;
the routing GUI files (routing-rule*, routing-rules-line,
routing-pause*, group-*, i18n-*, routing-compact, routing-intent-*,
routing-smart-intent) in chromium and webkit: 751 of 781, the 30 reds
being "System prompt" taken by a core word (now "System prompt text"),
routing-rules-line's + menu count (now with system and last), and
routing-intent-entry, red on main since 01a260af4 (#5392, next commit).
Then on the Linux box (wsl-run, magpie-desktop): go vet -tags nogui and
GOOS=windows go vet of the same packages; go test -tags nogui of
internal/provider, gateway, cli, tui, gui; node --check of the routing
plugin; routing-rule-ops, routing-rules-line, routing-intent-entry,
i18n-keys, i18n-en-no-cjk, routing-rule-example in chromium and webkit,
the new test 16 of 16 over four repeats.

Broken by hand: holdsIn's system/last cases returning false turns
TestCondHolds and 8 of TestRuleSystemAndLastText's cases red; dropping
the Anthropic system wiring turns its two Anthropic cases (one the real
Claude Code system fixture) red.

Not tried: a real harness's title or compaction request end to end
through a live gateway; the fixtures are Claude Code's, Codex's and pi's
recorded system prompts.
2026-11-10 18:48:13 +08:00
yetone b358677305 gui: open a server's magpie in a window of the app (xuanwo on X)
xuanwo runs magpie on a server and wants the desktop app to show that
magpie's routing and usage. Browser access in Settings › Network and
sharing goes the other way: it serves this app's page to a browser.

Settings › Network and sharing has a new section, Another magpie. It takes
an address and a key. You can paste the whole link the server printed
(`magpie daemon install --web`, `magpie web`, or another app's Browser
access), and its k= becomes the key. The app then opens that magpie's own
web page in a window of its own. The window signs in through the server's
own webGuard with ?k=, the same way a browser does, and is traded for its
cookie. Nothing new is served here: the page in the window talks to the
server alone and gets no bound calls from this app.

- remoteAddr:
  - https:// is used when no scheme is typed.
  - Plain http is allowed only to an IP, localhost, a .local name or a
    one-word name, so the key never crosses the internet in the clear.
    This is also the rule a Mac's webview applies.
  - userinfo and other schemes are refused.
- remoteProbe: before the window opens, it asks for the link without
  following redirects. Only a 303 that sets a magpie_web_* cookie counts
  as success. A 401, a 403 (allowed addresses), an untrusted certificate,
  no answer, or any other reply is reported in Settings, translated.
- remote-magpie.json:
  - It sits beside settings.json, mode 0600, and the key is never in
    settings.json.
  - GET /api/remote returns the address and hasKey, never the key.
  - POST with no key reuses the key kept for the same address.
  - POST /api/remote/forget removes the file.
- The routes are on the app's own windows' API only (!isWeb). A host that
  can't open windows refuses.

Run (on mote, at this tree):
- go test -count=1 ./internal/gui/: ok.
- Go tests:
  - TestRemoteAddr
  - TestRemoteOpensTheOtherMagpie: real webHandler; wrong or missing key
    refused, nothing kept; the pasted link opens; 0600; the key is not
    returned; a cookie-jar client following the opened link reaches the
    page behind the key; the kept key is reused; forget.
  - TestRemoteNotMagpie
  - TestRemoteNotOnBrowserPages
- GUI test, new: another-magpie.test.cjs. Covers 5 languages, 360px,
  and a browser page with no section that never asks /api/remote.
- GUI suite: every GUI file that draws Settings › Network (18, the new one included), plus
  i18n-keys, i18n-en-no-cjk and gui-de/ja/zh-tw. Chromium and WebKit:
  307/307 pass. Also remote-magpie.test.cjs (the Remote magpie
  provider's add sheet), run with the new file at the rebased head.
- gofmt -l: clean.
- go vet: darwin, GOOS=linux -tags nogui, and GOOS=windows on
  internal/gui; ok.

Broken by hand:
- A 303 without the magpie cookie taken as signed in:
  TestRemoteNotMagpie red.
- remoteRoutes outside !isWeb: TestRemoteNotOnBrowserPages red (200).
- renderRemote drawn on a browser's page, and errors not translated:
  another-magpie.test.cjs red in zh/zh-TW/ja/de and the browser case,
  in both engines.

Not tried:
- The real Wails window on macOS, Windows or Linux.
- A real server over https.
- Links on the remote page that open a new window (target=_blank,
  window.open) inside the remote window.
- Settings › Text size does not rezoom a remote window that is already
  open.
2026-11-10 18:39:20 +08:00
yetone 248268ce4c codex: a switch of the preferred account leaves the Codex app running unless asked (Michael25651150 and ykj5353 on X)
After v0.1.3562 a switch of Codex's ChatGPT account made by hand in
magpie, between accounts that both had room, still ended the Codex
app's app-server with "Restart the Codex app when magpie switches its
account back" off. The app shows that as an error, relaunches, and
signs in as the new identity. ChatGPT.app 26.1103+ keeps its sidebar
projects per ChatGPT identity (electron-account-renderer-state-v1), so
on an identity that never had them it shows "没有项目" and every thread
under Recent: ykj5353's screenshot is the Codex app's sidebar, not
magpie's Sessions page.

codexAppStep no longer counts c.switched && !c.auto as by hand. Such a
switch is left running, logged, and the account rows' "still signed in
as" notice with its Restart is the way to follow, as for magpie's own
switch back. Still restarted with the tick off: a switch off a used-up
account (needed, the app greys Send there), Connect/Disconnect, the
takeover in and the takeover turned off by hand. RestartApp on restarts
on every switch as before.

Run (mote, at base 40ca0c88d; rebased onto bc0d9e873, whose provider changes touch no codex file): gofmt -l; go vet ./internal/provider for
darwin, GOOS=linux -tags nogui, GOOS=windows; go test -count=1
./internal/provider: ok (150.6s), vet ok on all three.

Broken by hand: putting `c.switched && !c.auto ||` back into byHand
turns TestCodexAppLeftRunningForMagpiesOwnChanges red ("switched by the
user after magpie: ended [101]").

Not tried: a real ChatGPT.app switch between two real accounts. Not
changed: during the takeover the app has no account and shows no
projects by its own rule; magpie can't fix that through the state file.
A user whose projects already went missing gets them back by quitting
the app fully and reopening it after ~30s, when carryCodexProjects
copies them to the current identity, if that identity has no project
list of its own yet.
2026-11-10 18:26:39 +08:00
yetone bc0d9e8739 agent: magpie's own Claude work folder isn't Claude Code bypassing magpie (ifccod7391564 on X)
The bridge runs Claude Code in os.TempDir()'s magpie-claude-work(-<uid>),
and on the user's own home those prompts go into ~/.claude/history.jsonl
too. LastUsed read them as Claude Code used with none of its requests
reaching magpie, and the Agents page warned "Claude Code 最近绕过了
magpie". The owner's own history.jsonl has 1594 such lines, project
/private/var/folders/.../T/magpie-claude-work-501. LastUsed now passes
over lines whose project is that folder (inMagpieWork: the last path
element, either slash, so a Mac's /private/var, C:/…, C:\… and a WSL
mount all match; magpie-claude-workshop does not). lastJSONLTime takes a
skip; Codex's history.jsonl has no project and passes nil.

Run (wsl-run, magpie-desktop; mote refused SSH the whole time):
- go test -count=1 -timeout 45m ./internal/provider ./internal/agent:
  provider ok; agent ok but TestGrokInstalled, the known WSL2 binfmt
  red (#3548), unrelated
- TestClaudeBridgePromptsArentBypass, TestDriftBypassed on Windows: ok
- cross-OS go vet as in the provider commit; gofmt -l clean
Broken by hand: LastUsed with skip nil: the new test is red with the
reporter's bypassed drift.
Not tried: the GUI (no GUI change), the macOS run (mote down).
2026-11-10 18:21:32 +08:00
yetone 980a4b981f provider: an answer naming only five_hour keeps the week kept on disk (ifccod7391564 on X)
On a cold start nothing of a Claude account was in claudeUsage, so the
first rate_limit_event, which often names five_hour alone, became the
account's whole reading: withHeardClaude laid that one window over the
card read from quotas.json, and the 7-day ring, not renewed yet, was gone.
NoteClaudeLimits now merges what an answer tells into what is kept, and
with nothing in memory into the windows quotas.json kept that haven't
renewed since (keptClaudeWindows). A renewed week isn't brought back.
quotas.json is read before claudeUsage is held: lastQuotas has its own lock.

Run (wsl-run, magpie-desktop; mote refused SSH the whole time):
- go test -count=1 -timeout 45m ./internal/provider ./internal/agent:
  provider ok; agent ok but TestGrokInstalled, the known WSL2 binfmt
  red (#3548), unrelated
- TestNoteClaudeLimitsKeepsTheWeekOnDisk on Windows (win-run): ok
- GOOS=linux go vet -tags nogui ./internal/..., GOOS=windows and
  GOOS=darwin (nogui) go vet of agent/provider/gateway: ok; gofmt -l clean
Broken by hand: NoteClaudeLimits ignoring the disk (kept = onDisk[:0]):
the new test is red with the card holding only "5 hours", as reported.
Not tried: a real cold start against a real account's rate_limit_event;
the macOS run (mote down).
2026-11-10 18:21:32 +08:00
yetone 8cc4bd7e3c agent: Craft Agents, through a keyless connection at the gateway (springg1998 on X)
Craft Agents (lukilabs/craft-agents-oss, thecraftagents.com) keeps its LLM
connections in config.json under $CRAFT_CONFIG_DIR or ~/.craft-agent
(paths.ts, storage.ts, llm-connections.ts, v0.15.8). magpie adds one
connection: slug magpie, providerType pi_compat, authType none, baseUrl at
the gateway's /agent/craft-agents/v1, customEndpoint.api
openai-completions. Its models are the ones picked for it, and defaultModel
is always one of them, because Craft resets a default that isn't in the list
to the first. magpie makes it defaultLlmConnection. The user's default is
stashed (as JSON, "" for none) and put back on off when that connection still
exists. A name the user gives magpie's entry stays, and a sync with nothing
to change writes nothing. A config.json with no workspaces list is one Craft
doesn't load, so magpie never creates one: open Craft once first. Picking one
of the user's own models removes magpie's entry and sets that model on their
default connection. Sessions keep the connection they started on, so the
notice says new sessions use it (zh, zh-TW, ja, de).

Detected by ~/.craft-agent, Craft Agents.app (com.lukilabs.craft-agent), or
%LOCALAPPDATA%\Programs\@craft-agentelectron\Craft Agents.exe (per-user
NSIS; the GUID is the UUID v5 of the appId, derived the same way as dsh's
known one). Skills go to ~/.agents/skills. CRAFT_CONFIG_DIR is in
agentenv.Vars. Icon from Craft's own icon.svg (#9570BE). README, reference,
agent-wiring and site list it.

Run on mote, first on origin/main 720200092:
- go test -tags nogui ./internal/agent ./internal/library ./internal/agentenv: ok.
- go test ./internal/gui: ok.
- go test ./internal/proc: ok (at the pre-rebase head).
- GUI tests in chromium and webkit, 69/69: i18n-keys, i18n-en-no-cjk,
  icon-one-tone, icon-tile, tray-logos and usage-agent-filter-icons.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui, and
  GOOS=windows.
Then rebased on 6b92824ff and run again there: go test ./internal/gui,
the Craft, hand-wired, spelled, drift and every-agent tests in
./internal/agent and ./internal/library, and i18n-keys: all ok.
Pushed rebased on 2fbead798 (provider relay URL, Windows restart, gateway cap: no
files in common), not run again there; the full suite runs after the tag.
Broken by hand: with unwire's restore of the user's default taken out,
TestCraftAgents goes red at "restore". On the old code the tests don't
compile (no craftAgents). The first run also showed every-agent tests
(drift, LAN, proxy, port move) needing a Craft fixture, which is now added.
Not tried: a real Craft Agents app or its Pi server against the gateway, or
the Windows install path on a real install.
2026-11-10 18:09:54 +08:00
yetone 2fbead7983 provider: a relay URL typed without its /v1 (CRS's …/openai) is tested, detected and listed under it (Cyrus_4433 on X)
Cyrus_4433 added a claude-relay-service provider as OpenAI compatible at
http://<ip>:55088/openai. The list couldn't be fetched and Test models
said "gpt-6.1-sol: 404 · Not Found". From CRS's src/app.js and routes:
/openai mounts unifiedRoutes (POST /v1/chat/completions) and
openaiRoutes (/responses, /v1/responses); /api mounts GET /v1/models.
There is no /openai/chat/completions or /openai/models, and anything
unrouted is 404 {"error":"Not Found",...}. magpie asked base +
/chat/completions, i.e. /openai/chat/completions.

- probe: a Chat/Responses 404 at an unversioned base equal to the
  provider's URL is asked once more at base/v1/... (missingV1; not
  accounts, Azure, Bedrock, Vertex). Answered OK there, the saved URL
  takes /v1 (setV1) and the result carries it (Result.V1); Detect uses
  it as the base; the editor's URL field follows (draft.onV1) so Save
  doesn't undo it. A 404 at both stays the first 404.
- catalog: an unversioned …/openai base is also listed at
  <origin>/api/v1/models (RelayOpenAIList), and fixV1 adds /v1 when the
  list answered there.

Run (WSL magpie-desktop via wsl-run; mote's sshd reset every
connection this session):
- at 630b0de98 (this change on 987eac0aa): go vet -tags nogui (linux),
  CGO_ENABLED=0 GOOS=windows and GOOS=darwin go vet of the touched
  packages ok; go test -tags nogui ./internal/catalog ./internal/provider
  ./internal/gui ok; GUI chromium + webkit: provider-test-v1 (new: en/zh,
  900/420px, Test models and a chip's Test this model, then Save posts
  .../v1), model-test-one, model-test-why, model-test-stop,
  provider-detect-models, provider-base-api: 54 pass, 0 fail.
- rebased again on 6b92824ff, the core went 366 bytes over its budget;
  five provider-test comments cut in app.js pay for it, no raise
  (core 1,533,689 <= 1,533,802). At this head: internal/gui's budget
  tests, internal/catalog and internal/provider, and the
  provider-test-v1 and model-test-one GUI files: all ok, 20 pass 0 fail.
- models-works-only is red, also red on untouched origin/main
  7c41060c2: #4391 (commented there). gofmt -l clean.

Broken by hand: missingV1 returning false and RelayOpenAIList returning
"" -> TestCRSOpenAIBaseTestsUnderV1/ListsAtAPI/DetectsV1 red with
"gpt-6.1-sol: 404 Not Found"; restored.

Not tried: a real CRS instance (the fake follows its routes and 404
body); the gateway itself doesn't retry /v1 for a provider never
tested, listed or detected since this release (the user presses Test
models or types .../openai/v1); the full suite runs after the tag; no
Windows or macOS run.
2026-11-10 18:07:27 +08:00
yetone f1996e7e5d gateway: a provider named past its usage cap is not sent on to a group (Anotiaww on X)
Anotiaww on X: magpie on server B asked magpie on server A for
claude/claude-opus-5-5. A's Claude account was past its usage cap (the
trace: "a usage window at 98%, over the account's 98% cap"), and the
Claude provider had no fallback set. The request was answered by a
WorkBuddy member of the user's routing group claude-opus-5.5 (the trace
row marked Fallback), with nothing said. They expect the cap's refusal.

Cause: 44d6dd75d (adorable_piglet, v0.1.3354) made serve plan a capped
provider again with every user-built routing group that has the model
in it (provider.GroupsAfter, groupsAfter) whenever no candidate was
left, so the Codex app, which asks its own model bare and never the
group, reaches the group's APIs. That rule did not look at what the
client asked for: a request naming the provider itself got the same
implicit fallback. Not the cause: the remote/shared path, auto groups
(GroupsAfter leaves them out), or a peer magpie's model mapping; the
peer sent claude/claude-opus-5-5 as written.

Fix: namedProvider(r, call.Model) in serve's groupsAfter arm. A model
asked with its provider in it (call.Model after unprefixed, so a flat
or aliased spelling of one too) is that provider's alone: past the cap
it goes to the provider's own Fallback list (planned before, untouched)
and else gets cappedError's 429 "usage cap reached". A bare model, and
Codex's own model that codexAccounts rewrote to codex/<model> on the
backend path (marked with providerPicked), still go on to the groups as
adorable_piglet asked; so does a turn codexFallBack hands on. CapStop is
unchanged. GroupsAfter's only other caller, codexFallsBack, is the
backend path, where Codex asks bare. Images and embeddings never read
GroupsAfter.

Tests:
- TestNamedProviderCappedRefuses: codex/gpt-5.5 past its 98% cap, a
  group [codex/gpt-5.5, a/m], on /v1/chat/completions, /v1/responses
  and /v1/messages, stream and not: 429 "usage cap reached" and the
  group's API not asked; with a fallback f/m set on the provider, the
  fallback answers (the user's fallback still holds).
- TestPluginCarefulPool: the plugin's model asked bare ("fake-1") still
  goes to the group; named "factory/fake-1" it is the 429.
- TestCappedCodexOwnModelGoesToItsGroup keeps the backend path's bare
  gpt-5.5; its /v1/responses "codex/gpt-5.5" subtest is now the named
  case above, the reverse answer.

Broken by hand (mote-run): the namedProvider guard out of serve:
TestNamedProviderCappedRefuses 6 subtests red (200 "from the group")
and TestPluginCarefulPool red ("named, group, stop off: 200 ... from
kf"). Restored: green.

Run (mote-run, mote at load ~130-165):
- gofmt -l internal empty.
- At the pushed tree, rebased on origin/main 208b89422: go test -count=1 ./internal/gateway -run 'TestNamedProviderCappedRefuses|
  TestCappedCodexOwnModelGoesToItsGroup|TestCappedSubscriptionGivesWayInGroup|
  TestSubscriptionCappedMidConversationGivesWay|TestCodexOneAccount|
  TestPluginCarefulPool|Fallback|Cap|Group': ok (144.6s; 138.9s before the rebase).
- go vet ./internal/gateway ./internal/provider: darwin, GOOS=linux -tags nogui, GOOS=windows: ok.

Rebased again onto 6b92824ff before the push (26 files of usage,
sessions and provider window-hold changes, none of the files here); the
runs above were at 208b89422, the tests run again at the pushed head
after the tag.

Not tried: a real Claude account past a real cap, and a real second
magpie (fakes only). The full suite runs after the tag. No GUI change.
2026-11-10 18:04:25 +08:00
yetone 6b92824ff5 usage: a window's whole also at base rates, without long-context premiums (#5861, Norethcy on X)
A window's whole (WindowHolds) is priced at API list prices, which charge
GPT-6.1 Sol's input above 272K at a premium a subscription's own use
doesn't pay. A cycle with more long calls then reads as a larger
allowance: NorethSea's previous week came to $76.56, $53.52 without the
premium, against $56.99 for the current one.

Each priced call is now also costed at its model's base rates, the
long-context tiers left out and a peak hour's price kept (baseRates), and
the window's whole sent as BaseCost beside Cost, only when the two differ.
Past cycles get it too (HistoricalWindowHolds goes through windowHolds).
On the card the figure then says which it is ("≈ $76.56 API") and is a
button: a click switches every card, past cycles too, to the base figure
("≈ $53.52 base") and back, moves nothing, and is kept in the browser.
Its tooltip names both and says neither is an official dollar allowance
or a fixed quota. A window that paid no premium is drawn as before. The
ledger's and the API's real cost are unchanged. #4181 (auto-review calls
counted in the whole) is not part of this.

app.js and the core stay in their budgets with holdsLine's and holdsWhy's comments cut, no raise.

Run (mote's sshd reset every connection, so on the Linux box through
wsl-run; the package run at base 720200092, and the -run tests,
quota-holds and i18n-keys again at this head on 208b89422; rebased since onto 44732325e,
a gateway test only):
- go test -count=1 -tags nogui ./internal/gui ./internal/provider
  ./internal/sessions ./internal/usage ./internal/usageapi: ok (incl.
  TestCoreScriptBudget)
- go vet -tags nogui (linux), GOOS=darwin CGO_ENABLED=0 go vet, go vet on
  Windows (win-run): clean. gofmt -l: clean.
- GUI: quota-holds (new test: every language, 360 and 1000px), i18n-keys,
  i18n-en-no-cjk, quota-fit-batched, provider-fetch-holds in chromium and
  webkit: ok.

Broken by hand:
- baseRates keeping the tiers: TestWindowHoldsBaseCostLeavesOutLong-
  ContextPremiums red (base figure 0).
- the click updating only its own button: quota-holds' new test red in
  both engines ("the other card didn't switch").

Not tried: a macOS run (mote unreachable), the darwin gui package's vet,
and the reporter's own log; the test's prices are gpt-6.1-sol's shape.
2026-11-10 18:01:13 +08:00
yetoneandNorethSea 4921bf5a97 usage, sessions: one model option for a found routing group's two ids (#5892, Norethcy on X)
A found routing group is called by its public id (auto/<model>) and is
kept as group/auto-<slug>; calls recorded under either were counted as two
models, so Usage › Sessions' model filter listed the same group twice and
the ledger, summaries and session lists split its calls.

Ported from NorethSea's 30d6261cd on their fork: UsageAlias names a found
group by its public id before the user's alias (both spellings, old
session files too), sessions' lists, the ledger keyer, the summary cache's
key and Codex's model/effort read through it, and a cache keyed on the
group names (UsageNamesKey) is read again when a group is renamed. A user's
own provider named "auto" keeps auto/<model> (autoRefsOn).

Changed in review: the patch's ledger filter compared every record with
provider.SameRef, which reads the providers (customIDs, a stat of
providers.json) for each record a filter passes over. FilterOf, the one
place a Filter is made from a query, now canonicalizes the model once, and
keepsRecord asks the providers only for an auto/ record under a group/
filter (sameGroupModel).

Run (mote's sshd reset every connection all afternoon, so on the Linux box
through wsl-run; the package run at base 720200092, and the -run tests,
quota-holds and i18n-keys again at this head on 208b89422; rebased since onto 44732325e,
a gateway test only):
- go test -count=1 -tags nogui ./internal/gui ./internal/provider
  ./internal/sessions ./internal/usage ./internal/usageapi: ok
- go vet -tags nogui (linux), GOOS=darwin CGO_ENABLED=0 go vet (provider,
  usage, usageapi, sessions), and go vet on Windows (win-run, those and
  internal/gui): clean. gofmt -l: clean.
- GUI: usage-ledger-model-pick, usage-ledger, quota-fit-batched,
  i18n-keys in chromium and webkit. usage-ledger's "newest live route
  needs no return-to-live button" (and zh "request routing links") is red
  the same on origin/main 987eac0aa on that box: #3104, #4078.

Broken by hand:
- keepsRecord back to r.Model != f.Model: TestUsageFoundGroupNames and
  TestLedgerFoundGroupNames red.
- usageGroupNames returning nothing: TestUsageFoundGroupNames (provider,
  usage), TestSessionsFoundGroupNames, TestCodexEffortFoundGroupNames,
  TestLedgerFoundGroupNames red.

Not tried: a macOS run (mote unreachable), the darwin gui package's vet,
and the reporter's own usage log.

Co-authored-by: NorethSea <963979204@qq.com>
2026-11-10 18:01:13 +08:00
yetone 25c36e862a gateway: a relay's pooled refusal of one model rests that model, not the key (Jray05343207 on X)
Jray05343207 (Windows) connected Codex through magpie and got
"auth_unavailable: no auth available (providers=codex, model=gpt-6-sol;
last upstream error: model_not_found: The 'gpt-6-sol' model is not
supported when using Codex with a ChatGPT account." That text is not
magpie's: it is CLIProxyAPI's (sdk/api/handlers/handlers_errors.go,
enrichAuthSelectionError), a relay pooling ChatGPT accounts. It lists
gpt-6-sol whatever its accounts' plans serve, and once every account
refused it answers 503 with the last refusal in its words.

modelRefused read only 400/403/404/422, so the 503 was a plain outage:
the whole key rested on the backoff ladder, every model on the relay
with it, and the model stayed offered. Now a 5xx whose body is that pool
answer ("no auth available (providers=…; last upstream error: …)",
poolLastError) is judged by the last upstream error's own words, as a
404 would be: a model refusal rests only that model on that key
(restID), and the key's other models are asked straight. A last error of
quota, or none named, reads as before. plainUnavailable leaves such a
refusal to modelRefused too. docs/subsystems/gateway-routing.md says so.

Run (WSL magpie-desktop, Linux; mote's sshd reset every connection):
- TestPoolModelRefusalRestsTheModelNotTheKey (two keys on a relay
  answering the reporter's exact body as 503) and TestPoolLastErrorRead:
  pass.
- Broken by hand (the poolLastError branch removed): both red; each key
  rested whole ("Why:other Status:503 By:backoff") and gpt-6-sol didn't
  rest on its own.
- TestModelNotInPlan*, TestFallback*, TestEscapedWords*: pass.
- go vet ./internal/gateway for linux, windows and darwin; gofmt -l clean.
- go test -count=1 -timeout 45m ./internal/gateway: ok (1025s, Linux)

Not tried: a real CLIProxyAPI with a plan lacking gpt-6-sol (fixture is
the reporter's literal text in CLIProxyAPI's body shape); the user's
Codex still gets the 503 if gpt-6-sol is the model it asks for and no
other provider serves it, so the reply asks them to pick another model.
2026-11-10 17:42:14 +08:00
yetone 987eac0aae gateway: a reported call keeps the model asked for and the one that answered (req, served) (#3534, realLemonawa on X)
POST /v1/magpie/usage/requests took a usage.jsonl line's fields except
req and served, and refused a record that carried them, so a call an
app reported showed an empty Requested and Served model on the
Requests page. Both are now optional fields: req is the model the app
asked for (an alias or a group of its own), served the one its vendor's
reply said answered. Each is checked as model is (a string, at most
256 characters, no control characters) and kept only as sent; a record
without served is never filled from model, so it says nothing of what
answered. The GUI already shows Record.Requested and Record.Served.

The issue's other metadata (the rest of a gateway row's columns) is
left out: only the two models were asked for by name.

Run (mote): go test -count=1 -run 'TestUsageIngest|TestReported'
./internal/gateway/ ok. go vet darwin (gateway, usage), GOOS=linux
-tags nogui and GOOS=windows go vet ./internal/gateway/ ok. gofmt clean.

Broken by hand: req and served taken out of ingestFields again;
TestUsageIngestRequestedAndServed went red ("req: not a field a
reported record takes").

Not tried: a real app reporting its calls; the full suite runs after
the tag.
2026-11-10 17:35:15 +08:00
yetone 720200092e agent: turn off an agent's own telemetry from its settings (OipsAnthony on X)
An agent with a documented telemetry switch has a Telemetry row in its
Settings on the Agents page (opened row and settings sheet). Off writes
that switch into the agent's own config the way magpie writes it already:

- Codex: [analytics] enabled = false in config.toml (feedback left alone)
- Claude Code: env DISABLE_TELEMETRY and DISABLE_ERROR_REPORTING = "1"
- Gemini CLI, Qwen Code: privacy.usageStatisticsEnabled = false

Nothing is written until the user turns it off. Off writes only keys the
file lacks and records them in the stash; a key the user set on refuses
Off and names it; one they set off stays, and the row says so. On takes
out only the keys magpie wrote that still hold magpie's value. An
unreadable config is unknown: the row says so and can't be pressed.
Agent.Telemetry is not a Field, so profiles never carry it and Unwire
leaves it. Only agents on this computer (no WSL distro, #3896).
POST /api/agents/telemetry/{id}; strings in zh, zh-TW, ja, de.

The row is paid for in the core budget with sixteen Agents-page comments
cut in app.js (core 1,532,840 of 1,533,802 after the rebase), no raise.

Run (mote, at this head on origin/main 1ad9d157f; vet, the three packages and agent-telemetry, i18n-keys, agent-details-ready, click-scroll again there, 98 of 98):
- go test -run Telemetry ./internal/agent, then go test -count=1
  ./internal/agent ./internal/gui ./internal/cli: ok
- go vet ./..., GOOS=linux -tags nogui, GOOS=windows: ok; gofmt clean
- GUI, chromium and webkit: agent-telemetry (34 pass: every language at
  1100 and 640px, no scroll on click, no select, the user's own off,
  a refusal, the sheet), and 104 agent-*, i18n-*, click-scroll,
  settings-search, panel-agent and agent-settings files: reds only in
  page-width-steady and mobile-web (red the same at origin/main
  5a347ca8c, #5013, #4541) and agent-compact once under concurrency 6
  (passes alone, 8 of 8; #5607; its fixture has no telemetry)
- internal/cli failed once in the first run with its name lost to a
  tail of mine; it passed on a rerun at this head and at origin/main

Broken by hand: skipping the user-on check, dropping the "still ours"
check before a delete, and removing the WSL gate each turned
TestCodexTelemetryLeavesTheUsers, TestClaudeTelemetryChangedSince,
TestUsageStatsTelemetrySwitch and TestTelemetryOnlyHere red. The tests
don't compile on the old code (no Agent.Telemetry).

Not tried: real Codex, Claude Code, Gemini CLI or Qwen Code reading the
written keys (the keys come from their source); Crush (left for later),
OpenCode (no switch); WSL agents; the whole GUI suite (the agent-*,
i18n and agent-settings files only); the full go suite runs after the tag.
2026-11-10 17:28:15 +08:00
yetoneandggbdpq 1ad9d157fe gateway: a compaction a ChatGPT-account relay refuses as system asks again with the roles as sent (#5067, acui145 on X)
Codex's summary ask to a provider that isn't OpenAI's carries its
developer messages as system ones (forVendor, #2955). A plugin provider
fronting a ChatGPT account (magpie-sub2api -> sub2api -> Codex backend)
is such a provider, and the backend behind it takes developer alone:
every compaction came back "System messages are not allowed", the
sessions that got through fell to the conversation-as-text summary,
and the ones whose refusal came as an error event after a 200 skipped
every retry and were held after three (compactFails).

Now a summary refused "System messages are not allowed" (as passed
through, or as a current sub2api words it), or with a relay's bare
"Upstream request failed" (the reporter's sub2api), as a 4xx or as an
error event in the stream (roleRefused), is asked once more with the
roles as Codex sent them (askAsSent turns off the compaction marker,
whose only reader is forVendor's swap), then as text, then made by
magpie. A summary with no developer message to give back is not asked
the same twice. Every route a compaction reaches a Responses provider
by (CodexPath, Codex's own models through magpie's accounts, the mask
route, a CC Switch table) goes through codexCompact and serve's one
forVendor call, so all of them are covered. #2955's chat-only vendors
take system and are unchanged.

Ported from ggbdpq's patch (fix/5067-compaction-system-messages,
79ec15d26), which matched only the passed-through wording on a 400.
The review added the reporter's own "Upstream request failed", the
error-event shape, the developer gate, lazyre for the words, and the
subsystem page.

Run on mote at this change on 6a253f8af; rebased onto fbc1808f2 (then 15acba534, no gateway change) and the targeted
run repeated on Linux (wsl-run, mote refused ssh): ok.
- TestCodexCompactSystemRefusedAsksAgainDeveloper (5 wordings/shapes)
  and TestCodexCompactSystemRefusedEverywhereNeverHolds: ok.
- Red on origin/main's product files: all 7 subtests fail (400 to Codex,
  502 "so there is no summary", or the text downgrade).
- Red on ggbdpq's patch alone: older sub2api, both in-stream shapes and
  the in-stream never-holds case fail.
- Broken by hand: the developer gate dropped -> the existing
  TestCodexCompactUpstreamFailed400AsksAgainAsText goes red (3 asks).
- go test -tags nogui ./internal/gateway/: queued behind ~/suite.lock on mote at push time (other sessions' suites); the full suite runs after the tag
- gofmt -l clean; go vet darwin, linux -tags nogui, windows: clean.

Not tried: a real sub2api relay of a ChatGPT account; the fakes answer
sub2api's two wordings (writeOpenAIUpstreamClientError and the older
upstream_error) and the backend's {"detail":...}. After an in-stream
"Upstream request failed" serve itself asks the same account again
(15 asks in the fake), unchanged here. The reporter's other 400
(reasoning effort 'none' on gpt-6.1-sol) is a separate path, not
touched.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-10 17:13:15 +08:00
yetone 15acba5347 codex: the Codex app's projects follow an account switch, and the app isn't quit unasked (Michael25651150 on X)
"切换账号 codex 添加的项目丢了 发生过好几次了 另外额度用尽时会强制重启 codex 客户端"

Projects. The Codex app (ChatGPT.app 26.1103 and on) keeps its sidebar's
projects per ChatGPT identity in $CODEX_HOME/.codex-global-state.json,
under electron-account-renderer-state-v1 ({owner, inactive:{<sha256 of
JSON.stringify([chatgpt_user_id, chatgpt_account_id])>: {atoms, globals}}}).
On an account change it parks the old identity's account-scoped globals
and loads the new one's, so magpie's switch (auth.json, then the
app-server's restart) showed an account that never had the app open with
no projects (#5497, #5602, #5702, #5874). Read from the app's own bundle
(early-bootstrap-133 selectRendererOwner, -815's owner hash). The app reads
the file only at launch and writes its memory over it, so magpie writes
it only while the app is closed (codex_projects.go): from the 3s loop once
the file, auth.json or logins.json changed (process listing at most every
30s), and between the quit and the open of every reopen (appQuitDone in
reopenBundle and restartWin). Each identity of auth.json and the saved
Codex logins whose snapshot has no local-projects key gets the project
keys of the identity with the most; an own list (an emptied one too) is
left; g-p- ChatGPT project mirrors and their ties aren't carried, and a
backing naming another account is dropped (the app refuses those). A
file without the key or that doesn't parse is not written; the first
write keeps the file as it was beside it (.magpie-before-projects).

Restart. When quota runs out magpie restarts the app's app-server (the
takeover needs it: the app reads its account only as its app-server
starts, else Send stays grey). A ChatGPT app can then show "hit a snag",
and magpie quit and reopened the whole app (CodexAppRelaunch), and on
Windows reopened an app that started no app-server (codexAppGotNone).
Both now happen only with "Restart the Codex app when magpie switches its
account back" ticked (codexRestartsApp, off by default); otherwise the
Agents row says to quit and reopen, as it did where a relaunch failed.

Run (mote unreachable all session: ssh kex reset on every try; so on the
Linux box and Windows box instead):
- wsl-run: go vet -tags nogui, GOOS=darwin CGO_ENABLED=0 go vet and
  GOOS=windows go vet of internal/provider and internal/agent: ok.
- wsl-run go test -tags nogui ./internal/provider ./internal/agent:
  provider ok; agent red only on TestGrokInstalled (#3548, WSL binfmt).
- win-run go test -run 'TestCodexProjects|TestCodexRendererOwner|
  TestCodexApp|Restart' ./internal/provider ./internal/agent: provider ok;
  agent red on TestWorkBuddyRestartOnMac (#4115) and
  TestOpenMausBotRestartOnMac (added to #4115), neither touched.
- gofmt -l: clean.
- The owner hash checked against node's crypto (TestCodexRendererOwner).

Broken by hand: carryCodexProjects returning at once -> the four
TestCodexProjects* red; the snag gate removed -> TestCodexAppNotQuitUnasked
red (relaunched 1); the Windows gate removed -> red (reopened 1); the
backing strip removed -> TestCodexProjectsFollowASwitch red.

Not tried: the real Codex app. This Mac's ~/.codex state has no
per-identity key (read-only check), so the switch is reproduced against a
Go port of the app's selectRendererOwner on the issues' layout, not the
app itself. No macOS test run (mote down). The takeover (no account)
still shows no projects in the app, by the app's own rule; they come back
with the account. Projects added while the app runs reach other accounts
once it is closed.
2026-11-10 17:10:32 +08:00
yetone ece12b370d search: TinyFish is a built-in search API (Niapyaya on X)
Niapyaya asked on X for TinyFish (tinyfish.ai) among the search APIs.
TinyFish has a plain Search API beside its browser agents, so it is added
as vendor "tinyfish", following Yuanbao Search (0804f2d97), from its own
docs (docs.tinyfish.ai/search-api/reference, /error-codes):
- GET https://api.search.tinyfish.ai/?query=<q> with X-API-Key: <key>;
  keys at agent.tinyfish.ai/api-keys (KeysURL). Its path is the root
  ("/", SearchVendor.Paths), so a base URL of the user's own works as
  every other API's does.
- The reply's results[] (title, url, snippet, date for news and some web
  pages) is read by the shared reader; snippet is its only text. It takes
  no count and answers one page of about 10, cut to the search's count.
- Errors come with their status and {"error":{code,message}}: 401 a wrong
  key, 402 INSUFFICIENT_CREDITS (the day's 12,000 free searches spent with
  an empty wallet), 429, so the next key or API is asked and the key rests
  as any other's; the message is what the user is told, the key masked.

The GUI's picker and Get key button are built from SearchVendors, so no
GUI file changes. README (en, zh), the CLI help and gateway-routing.md
name it.

Fixtures: testdata/tinyfish/search.json is the docs' example reply;
invalid_key_401.json is the real service's reply to a made-up key on
11-10. The 402 body is the docs' Search example.

Run on mote (mote-run), at the rebased head (3b261932e):
- go test -run 'Search|TinyFish|WSA|Volcengine|DeepSeek|You'
  ./internal/gateway/ ./internal/provider/ ./internal/cli/: ok (first
  run: TestSearchAPIBaseURLWithItsPath's guard caught an empty Paths;
  fixed with "/"); ./internal/gui/ ./internal/backup/ ./internal/davsync/
  with the same -run: ok
- search-api.test.cjs and searcher-pick.test.cjs (Chromium and WebKit):
  30/30 ok
- go vet -tags nogui darwin/linux/windows: ok; gofmt -l clean
- a throwaway test (not committed) asked the real api.search.tinyfish.ai
  through askSearchAPI with a made-up key: searchRefused 401 "Invalid or
  expired API key", so the address, path and key header are the ones it
  reads (a header it didn't read answers MISSING_API_KEY).

Broken by hand, each made TestTinyFishSearchAPI red: the key sent as
Authorization: Bearer instead of X-API-Key, and the "tinyfish" case
removed from askSearchAPI.

Not tried: a search with a real key (none available), so the success
reply rests on TinyFish's docs. The full go test ./... is to follow.
2026-11-10 16:47:33 +08:00
yetone d109ec8da8 agent: miniQ, its provider on magpie's gateway (xiancrong on X)
miniQ (LeadingThink/miniQ, 0.1.213) is a desktop coworker and a `miniq`
terminal, both clients of one miniq-daemon. Its model is one provider in
<data dir>/settings.json, {baseUrl, apiKey, model, apiProtocol}: the data
dir is $MINIQ_DATA_DIR, else the folder miniq-data-dir.json names, else
%LOCALAPPDATA%\miniq or ~/.local/share/miniq (macOS too).

Picking one of magpie's models writes the provider as the gateway's /v1,
magpie's key for miniQ (it sends no User-Agent of its own), the catalog id
and apiProtocol chat_completions ("auto" guesses a protocol from the model
name). What the user had is stashed whole and put back on Disconnect; the
rest of settings.json is left alone. A settings.json magpie made is 0600
and goes again when magpie steps out. The daemon reads settings.json once
and writes its copy back on every change, so a running one is told too:
settings.update over the WebSocket daemon.json names, as miniQ's own
Settings does, which also moves open chats. Notice compares the daemon's
settings.get with the file and asks for a restart when they differ.
"On magpie" is known by magpie's key, so a moved port or a proxy in front
of the gateway is told apart by Check (baseUrl and apiKey). WSL: the
distro's ~/.local/share/miniq. Icon, i18n (zh, zh-TW, ja, de), READMEs,
reference, site, MINIQ_DATA_DIR in agentenv.Vars.

Run:
- At the pushed head, rebased on 286e3b6d5: internal/agent and
  internal/agentenv ok; i18n-keys, agent-notice-lang, icon-tile 29 of 29.
- mote: go test ./internal/agent/ ./internal/agentenv/ ok;
  ./internal/gui/ and ./internal/cli/ ok except
  TestGatewayModeStatsNameTheGatewaySessions, run in mote's first local
  hour (00:2x), which is #5690.
- GUI on mote, chromium and webkit: i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone, icon-tile,
  routing-client-icons, usage-agent-filter-icons, agent-connect,
  agent-models, agent-layout: 110 of 110.
- Windows (win-run): TestMiniq*, TestOwnProviderNamedAsMagpies/miniq,
  TestFolderVarsAreListed ok (the LOCALAPPDATA path).
- gofmt; go vet darwin, linux nogui, windows.
- Real miniQ in a sandbox on mote: the 0.1.213 aarch64 terminal tarball,
  sha256 checked against terminal.json, miniq-daemon on a sandbox
  MINIQ_DATA_DIR, a fake OpenAI upstream at MAGPIE_ADDR (uncommitted
  test). Set magpie/deepseek/pro: the running daemon's settings.get
  showed the gateway's /v1 at once; `miniq exec --no-start "say pong"`
  sent POST /v1/chat/completions with Bearer magpie-miniq and model
  deepseek/pro and printed the reply. Set "": the daemon and the file
  were back on the user's provider with their key; nothing else in
  settings.json changed. Run twice, before and after the key fix.

Broken by hand:
- push sent "settings.nothing": TestMiniq red ("the daemon was told
  nothing").
- apiProtocol dropped from the provider: TestMiniq red.
- on() by URL only (the first version): TestPortMovesEveryAgent,
  TestDriftUnwiredEveryAgent/miniq and TestReverseProxyIsStillMagpie red.

Not tried:
- miniQ's desktop app; only the terminal and daemon ran.
- Windows and WSL with a real miniQ.
- Session titles: miniQ asks a hard-coded gemini-3.8-flash on the same
  provider for them; without such a model at magpie the chat stays
  untitled (miniQ retries later). Nothing in its settings changes that.
- A project's own model in miniQ overrides the global one, as in miniQ.
- settings.update can't remove a provider, so a daemon that had none
  before magpie keeps magpie's until it restarts; the notice says so.
2026-11-10 16:46:39 +08:00
yetone f2b9ec354a gateway: Codex's auto-review goes on where its conversation does when the sign-in is out (riverleaf88 on X)
riverleaf88 on X: with Codex's ChatGPT allowance spent and magpie routing
Codex on to another model, Codex's automatic review still failed.

Codex's guardian (codex-rs guardian-v2 sync_reviewer) asks the same
provider, so magpie's /backend-api/codex/responses, on codex-auto-review
(approval_review_preferred_model) with x-openai-subagent: guardian. On a
spent sign-in codexFallsBack and serve's groupsAfter looked for fallbacks
and routing groups of codex/codex-auto-review, a model no group names, so
the review was handed ChatGPT's 429 while the conversation's turns went
on to the group.

- codexReviewAfter: an auto-review on the codex sign-in takes the model
  its conversation's own turns go on (codexLeads). A codex model brings
  that model's fallbacks and groups (fallbacksOnly on the lead too); a
  magpie model the caller may use (servedSession) is tried itself.
  codexFallsBack and groupsAfter add them.
- codexHolds: once a 429 naming a reset held the account, later turns
  (main turns too) were answered with the held refusal before any
  fallback. The held branch now hands a /responses turn with fallbacks to
  codexFallBack as the first spent turn was.
- docs/subsystems/gateway-routing.md says both.

Run (mote): go test -count=1 -run 'TestCodexReviewSpent|TestCodexHeld|
TestCodexOneAccount|TestCodexSpent|Hold|Held' ./internal/gateway/ ok
71.2s; gofmt -l clean.
New tests red on the old code: TestCodexReviewSpentFollowsTheGroup and
...FollowsMagpieModel (review got 429 usage_limit_reached); the held case
in TestCodexHeldTurnFollowsTheGroup.
Broken by hand: codexReviewAfter returning nil turns
TestCodexReviewSpentFollowsTheGroup, ...FollowsMagpieModel and
TestCodexHeldTurnFollowsTheGroup red; dropping the held-branch fallback
turns TestCodexHeldTurnFollowsTheGroup and ...FollowsTheGroup red.
Not tried: a real exhausted ChatGPT account; guardian-v2's async scorer;
the multi-account pool path past serve's candidate loop is covered only
through the one-account tests.
Also run (mote, at this tree): go vet ./internal/gateway/ for darwin,
GOOS=linux -tags nogui and GOOS=windows: clean. go test -count=1
-timeout 45m ./internal/gateway/: ok 1037.9s (base 2219fdd49).
Rebased on 662546e78 (agentpath change only): go vet ./internal/gateway/
and -run 'TestCodex|Hold|Held|Fallback|Group': ok 289.7s.
2026-11-10 16:43:25 +08:00
yetone 5a02bf8c14 agent: mu, Pi with a judgment kernel, wired in ~/.mu/agent (xteam3301 on X)
mu (github.com/qybaihe/mu, npm mu-agent, the mu command and the mu
desktop app) is Pi 1.4.0 with a judgment-kernel extension. Its
kyrn/bin/mu.mjs starts Pi on its own agent folder, so Pi's settings.json
and models.json live in ~/.mu/agent, and the desktop app runs the same
Pi on the same folder. magpie now wires it as it wires Pi.

- agent: mu (piLikeKeyed). Its folder is found as mu.mjs finds it:
  $MU_AGENT_DIR, $KYRN_AGENT_DIR, $MU_CODING_AGENT_DIR,
  $KYRN_CODING_AGENT_DIR ("~" expanded), else ~/.mu/agent, or
  ~/.kyrn/agent while ~/.kyrn is a folder and ~/.mu isn't. Its requests
  say pi/<version>, so the provider's key magpie-mu names it. The alias
  is mu-agent. Its judge (~/.mu/mu.json) is left alone.
- `mu` is also maildir-utils' command (brew, distros). A mu on PATH
  that neither is nor names mu.mjs / mu-agent is not taken for it
  (notMuAgent).
- Gemini models stay on Chat for mu, as for Pi and StepCode (piAsked).
- WSL kind at ~/.mu/agent (found by its folder, not the command); CLI
  update through npm mu-agent; the desktop app (io.github.qybaihe.mu,
  mu.app, %LOCALAPPDATA%\Programs\mu\mu.exe, /opt/mu).
- agentenv and appdir know the four variables.
- library: mu's AGENTS.md / AGENTS.override.md, its mcp.json (Pi's
  native format) and skills in its folder; it reads ~/.agents/skills.
- GUI: a one-tone icon. Default in its model picker says it clears the
  default and mu picks one itself (PICKS_ITSELF).
- docs: READMEs, reference.md, agent-wiring.md.

Run (mote, at this tree before the rebase):
- gofmt -l internal/ clean; go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows of agent, library, appdir (and agentenv on darwin): clean.
- go test -count=1 ./internal/agent ./internal/library ./internal/appdir
  ./internal/agentenv ./internal/usage: ok (agent after its maildir
  fixture stopped using testenv.Program, which refuses a non-script).
  New: TestMu, TestMuDir, TestMuNotMaildirUtils, TestMuTarget; mu added
  to the handwired, spelled, Pi scope, scope-gone and Gemini-on-Chat
  lists.
- Windows (win-run on xiaomi-gpu): go test -run 'TestMu|TestPiScope|
  TestScopeGone|TestHandwired|TestSpelled|TestPiFolderKeepsGemini'
  ./internal/agent ./internal/library ./internal/appdir: ok.
- Real mu-agent 0.3.9 (Node 22.22.0) on mote in a sandbox HOME, a
  sandbox gateway on 47822 over a fake OpenAI upstream: `magpie agents`
  found mu with the user's deepseek model; `magpie mu magpie/fakeup/m1`
  wrote defaultProvider magpie and providers.magpie with key magpie-mu,
  keeping the user's deepseek provider; `mu -p ping` answered "pong from
  fake upstream" (upstream saw POST /v1/chat/completions, model m1,
  UA pi/0.3.9); `magpie usage today` counted the call under agent mu;
  `magpie mu default` put settings.json and models.json back byte for
  byte (cmp).
- GUI, chromium and webkit: pi-default-note (with mu added),
  icon-one-tone, icon-tile, mono-icon-redraw, routing-client-icons,
  usage-agent-filter-icons, i18n-keys, i18n-en-no-cjk, agent-connect,
  agent-models, agent-layout: 88 of 88.
- Rebased onto 1b2ad557f: gofmt clean; vet darwin (agent, library,
  gui), linux nogui and windows (agent, library) clean; go test
  ./internal/library ./internal/appdir ok; ./internal/agent -run
  'TestMu|TestPi|TestHandwired|TestSpelled|TestScopeGone|TestDesktop|
  TestCLIUpdate|TestWSL' ok; ./internal/gui ok but two reds that are red
  on an origin/main 1b2ad557f copy as well: TestCoreScriptBudget
  (1,534,470 > 1,533,802 on main, #5918; this change adds 6 bytes) and
  TestGatewayModeStatsNameTheGatewaySessions (run at 00:xx local, #5690).
  The rebase onto 4c5b89489 only adds LESSONS.md.

Broken by hand, each red:
- no binNot: TestMuNotMaildirUtils (maildir-utils' mu detected as mu).
- no ~/.kyrn fallback: TestMuDir.
- mu out of piAsked: TestPiFolderKeepsGeminiOnChatForRaft.
- mu out of PICKS_ITSELF: pi-default-note, 2 of 2 red (chromium).

Not tried: the mu desktop app (its install paths are read from its
electron-builder config, not an installed copy); a real vendor behind
the gateway (fake upstream only); a Gemini model through mu; WSL with a
real distro; mu's own session files are not read for usage outside
magpie.
2026-11-10 16:27:14 +08:00
yetone 00e8242e85 library: Hermes folds its context with billion-context through its /bili/ prefix (Duckb7si on X)
Library › billion-context said no agent could use it on a machine where
Hermes was connected to magpie. Hermes was left out of the lanes on
purpose: bili's native Hermes plugin (hermes-plugin/__init__.py,
apply_env, billion-context 0.1.213) only sets HTTPS_PROXY, HERMES_CA_BUNDLE
and SSL_CERT_FILE. magpie's Hermes provider is http://127.0.0.1:3425/v1,
plain http on loopback, so that proxy never sees it: the plugin would add
its tools and fold nothing.

Hermes now takes the route Zed takes, bili's documented /bili/ prefix.
Turned on, magpie runs `bili start --port 8787` and sets base_url of the
magpie and magpie-anthropic providers to http://127.0.0.1:8787/bili/<gw>,
in config.yaml and in every profile that has magpie's provider
(agent.HermesThrough). Each later Sync or pick keeps a loopback prefix
with a path (hermesPrefix), and drops anything else back to the gateway.
Turning it off puts the gateway back. The empty-list string, docs (en, zh,
ja), llms-full.txt and docs/subsystems/library.md name Hermes.

The other agents bili supports that magpie wires (dsh, Kimi, ZCode, Codex,
Gemini, Qwen, ...) are #5915.

Run (mote, at the rebased head unless said):
- go test -tags nogui ./internal/library: ok (252s) at the rebased head
- go test -run 'TestHermes|TestZed|TestProxy|TestBili|Kept'
  ./internal/agent ./internal/library: ok before the rebase (base
  2219fdd49); the whole internal/agent at the rebased head was still
  running at push (mote load ~60), result goes on #5915
- GUI library-bili, library-all, i18n-keys, i18n-en-no-cjk (chromium and
  webkit, every language): 84, 26, 4, 4 pass, 0 fail (before the rebase)
- site node --test: 107 pass (llms-full.txt regenerated with llms-full.mjs)
- go vet darwin, GOOS=linux -tags nogui, GOOS=windows on agent and
  library: clean; gofmt -l clean
Broken by hand:
- hermesEntries without the prefix: TestHermesThroughBili red (a pick
  drops the prefix)
- no "hermes" URL lane: TestBiliHermesThroughPrefix red (Hermes not
  offered)
Not tried:
- a real Hermes and a real `bili start`; tests fake bili and the probe
- a profile created after turning it on goes to the gateway until Hermes
  is turned on again
- bili's native Hermes plugin installed at the same time
- Windows run (vet only)
2026-11-10 16:16:11 +08:00
yetone 6a253f8af7 memory: pick several memories and keep, archive or delete them at once (RealZeroP27 on X)
Library -> Memory reviewed one memory at a time: To review held
candidates that had to be opened and kept or deleted one by one.

- Select (beside the filters, shown when two or more are listed) puts a
  box on each memory. A click picks one, Shift-click the range from the
  last one clicked, up/down move between the boxes (Shift picks as it
  goes), Cmd/Ctrl+A picks all shown, Escape ends it. A search or filter
  unpicks what it hides.
- The bar under the list (the library's lib-pickbar, as Skills' Select)
  keeps (To review), archives (In use) or restores (Archived) the picked
  ones, and deletes them on a second click.
- POST /api/memory/status {ids, status}: memory.SetStatus changes them in
  one write, each as Edit by the user (an archived inferred memory is
  dismissed, so it isn't proposed again). Unknown ids are skipped; none
  found, or a bad status, is a 400 and changes nothing.
  Delete reuses POST /api/memory/remove {ids}.

Run (mote, at this head):
- go test ./internal/memory ./internal/memdistill ./internal/library: ok
- go test -run 'Memory|Distill|Dream' ./internal/gui: ok
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., and the three builds: ok. gofmt -l: clean.
- library-memory-select.test.cjs (new): 22/22, chromium and webkit,
  en/zh/zh-TW/ja/de at 980 and 420 wide (no native select, no sideways
  overflow).
- Every library-*, i18n-* and gui-* GUI file (67), both engines: 1309 of 1309 pass.
- Rebased on 2219fdd49: i18n-keys, library-memory, library-memory-select
  and library-bili 132/132; go test ./internal/memory and -run Memory
  ./internal/gui ok (at d374168d0; only a
  client_icons test changed in those packages since).

Broken by hand:
- SetStatus without editIn: TestSetStatusOfSome red ("after keeping two:
  candidate candidate candidate candidate"), and
  TestMemoryStatusRouteActsOnSome red.
- memPick with no Shift range: the GUI test red (got [c1, c4], wanted
  c1..c4).

Not tried: the real app with a real memory.json, the WebKitGTK Linux app,
Windows' WebView2.
2026-11-10 16:00:30 +08:00
yetone 93a33d8174 agent: OpenBot's icon, its requests named its own, its skills in the Library (SSNQT on X)
SSNQT on X, magpie 0.1.3503 on macOS, OpenBot (611ce90d1): no icon in
the Agents list, its requests listed as OpenCode's, and no way to pick
it for skills or MCP servers in the Library.

- Icon: OpenBot's production icon (build/icon-production.png in
  nightly-labs/openbot, 128px) as icons/openbot.png, in pngIcons and in
  app.css's tile rule (a solid tile, icon-tile.test.cjs); openbot is off
  client_icons_test's generic list.
- Requests: OpenBot seals an endpoint's key and headers in safeStorage,
  which magpie can't write, and hands the endpoint to the OpenCode it
  runs, so every request came with OpenCode's User-Agent and nothing of
  OpenBot's. magpie's entry is now at <gateway>/agent/openbot/v1
  (gateway.AgentURL). lanGuard takes /agent/<id> off the path when <id>
  is an agent magpie knows (takeAgentPath), agentOf names that agent
  first, and startedByAgent never takes such a request for a script. An
  unknown id is left in the path (404 as before). An entry written at
  /v1 is rewritten at the next sync; OpenBot reads it after a restart,
  which its notice already says. Requests recorded before stay
  OpenCode's.
- Library: an openbot target with skills in ~/.agents/skills, the only
  folder OpenBot reads (home-skills.ts, HOME_SKILL_FOLDER). Its MCP
  servers are rows in its SQLite database (openbot.db,
  projection_mcp_servers), which magpie doesn't write, so it stays out
  of the MCP picker: #5896.
- Guard: TestEveryAgentInLibrary fails for a built-in agent that has no
  Library target and isn't in noLibrary with a reason. 34 agents had
  none when it landed; they are listed as "not looked at (#5897)". The
  icon guard (TestEveryClientHasNameAndIcon) and the agent-name guard
  (TestIsAgentByUserAgent) were there already.

Run (mote unless said): gofmt -l internal (clean); go vet darwin, GOOS=linux
-tags nogui, GOOS=windows on agent, gateway, library, gui: ok;
go test -count=1 ./internal/agent ./internal/gateway ./internal/library
./internal/gui ./internal/usage: all ok but internal/gui's
TestUpdateSlowDownloadOutlastsTheCheckBound (its check request hit its
deadline with four other suites on the box; passes 3 of 3 alone; the
updater isn't touched here; #5905); TestAgentInPath and
TestEveryAgentInLibrary on Windows (win-run): ok; GUI i18n-keys,
icon-tile, icon-one-tone, icon-builtin-over-address,
routing-client-icons, library-pick-remove: chromium 101/101, webkit
54/54. Real gateway (nogui build, sandbox HOME, port 3591): a POST to
/agent/openbot/v1/chat/completions with OpenCode's User-Agent was
recorded as agent openbot, the same at /v1 as opencode, and
/agent/openbot/v1/models answered the list.

Broken by hand, each red: the takeAgentPath call in lanGuard taken out
(TestAgentInPath: path kept, agent opencode); the pathAgent check in
agentOf taken out (agent opencode); the openbot case in targetOf renamed
(TestEveryAgentInLibrary: openbot has no place); Icon back to generic
(TestEveryClientHasNameAndIcon).

Not tried: real OpenBot or a real OpenCode sending to the new address
(the URL is built as `${baseURL}/chat/completions` by
@ai-sdk/openai-compatible, read in its source); the full suite (runs
after the tag).
2026-11-10 15:56:21 +08:00
yetone 97fcbe3540 library: billion-context's card shows the tokens it saved (Scott__D on X)
The RTK tab says what RTK saved (rtk gain); the billion-context tab said
nothing of its effect. bili 0.1.213 has no command that prints its
savings. Its running proxy serves its dashboard's numbers at
GET /__bili/overview, summed over every session in its one store, and
each bili that runs registers in <state>/instances/<id>.json
($XDG_STATE_HOME or ~/.local/state, then billion-context, on every
system; read from bili's dist and its Hermes plugin's twin reader).

readBiliSaved (internal/library/bili_saved.go) asks the registered
bilis newest first, loopback http origins only, 3s in all, and puts the
first answer on BiliView.Saved: netSavedTotal (bili's headline "net
savings", after post-fold rebuilds and the summaries' cost, only with
hasFoldData), grossSavedTotal (which bili calls an upper bound),
foldsTotal, sessions, requests. The answer is kept in bili-saved.json
in magpie's config folder and shown "as of" its time when no bili runs;
a kept file that doesn't parse is no answer. magpie never starts a bili
to ask (it would auto-update and start watchers). The card says
"166.3k tokens saved over 7 folds in 1 session", bili's own count over
every session on this computer, the gross before costs; "Nothing folded
yet over N requests" before a fold; and that it shows once bili has run
when no bili ever answered. zh, zh-TW, ja and de; site docs (en, zh,
ja) and docs/subsystems/library.md.

Run:
- Real bili 0.1.213 on mote in a sandbox HOME (ACP_AUTO_UPDATE=0, 20000
  token window, bili start on 18799, a fake OpenAI upstream answering
  usage = bytes/4): ten turns of a growing conversation through
  /bili/<upstream>/ gave overview net 166285, gross 166390, 7 folds,
  1 session, 10 requests. That literal answer is the Go fixture
  (testdata/bili/overview-0.1.213.json) and the GUI test's numbers.
  readBiliSaved/ReadBili run on mote against that live bili with that
  HOME read the same numbers (Live true, Version 0.1.213).
- go test -tags nogui ./internal/library ./internal/gui on mote: ok.
- win-run go test -run 'TestBiliSaved|TestBiliLoopback'
  ./internal/library on xiaomi-gpu: ok.
- library-bili, i18n-keys and i18n-en-no-cjk in chromium and webkit
  (every language, 1100 and 420 wide): 92 pass, 0 fail.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows for internal/library and internal/gui: ok.
- site/public/llms-full.txt regenerated (node llms-full.mjs); site
  worker.test.mjs: 38 of 38 ok.

Broken by hand:
- the loopback filter taken out: TestBiliSavedFromRunningBili red
  (192.0.2.7 asked first, the 3s budget gone, nothing read).
- net read from tokensSaved, and a kept answer marked live:
  TestBiliSavedFromRunningBili and TestBiliSavedOnThePage red.
- the card's line taken out: library-bili 40 of 42 red (chromium).

Not tried: a real agent session with a real model through bili (the
upstream was a fake with made-up usage, so only the plumbing of bili's
numbers is checked, not how much a real session saves); a bili with
money data (hasMoneyData; its dollars are passed as usd but not shown);
the card on Linux WebKitGTK.
2026-11-10 15:47:32 +08:00
yetone eff7f9f62a library: a market server starts the way its registry entry says (fwxkogaia on X)
Serena from Library → MCP's market showed "已退出 (2)": magpie ran
`uvx serena-agent`, which prints its help and exits 2. The registry has
uvx run it as `uvx -p 3.13 serena-agent start-mcp-server
--project-from-cwd --context desktop-app`: its runtimeArguments, which
the shipped crawl (market_servers.json) had dropped and magpie never
read.

The class, fixed in launchLine (market_launch.go):
- runtimeArguments are read: the runner's own options (uvx -p/--from/
  --with/--prerelease, npx --package, docker's mounts, -e and
  --entrypoint) go before the package, the program's words after it,
  then packageArguments. A required option with no value magpie can
  fill keeps the package from being offered.
- An executable not named after its package is reached with
  `uvx --from <pkg> <bin>` / `npx -y --package <pkg> <bin>`. The crawl
  now keeps each package's executables (`bins`: npm's `bin`, the
  wheel's console scripts); a package with none, or several with none
  standing out (pickBin), isn't offered. `python -m mod` among
  runtimeArguments runs that module from the package.
- One package that can't be started no longer hides another of the
  same server (npm, then pypi, then oci).
- serverKey/packageOf skip uvx's option values, so Serena's key stays
  "uvx serena-agent" and an installed one is still found.

Audit of the 500 shipped entries (old line → new): 101 change. Among
them firebase (`npx -y firebase-tools mcp`), basic-memory, docling,
ouroboros, pm-claude-skills, llm-sandbox, polymarket-paper-trader,
visualtorch, canvas-mcp, alfanous (python -m), uniswap, pyscrappy,
llmtrim, reddit-research-mcp, word-mcp-live, omega, tinysearch,
haiku-rag, orcareplay, terravision, watch-skill, PyMemoryEditor,
edgartools/mirobody/new-term-radar/backlot (--with/--python), docker
robin/funasr/MARM (mounts). No longer offered (no line that starts):
aihawk and mcp-sap-docs (not on PyPI/npm), mcp-video, unifi-mcp-server,
antigravity-link-extension (no executable), token-savior, flyto-core
(several, none for MCP), maintenant and apollo (a docker mount to fill
in).

Users who installed one already: heal() gives a uvx/npx server whose
command and arguments are exactly the line magpie offered before the
line the registry says (healMarketLines), so the next start of magpie
rewrites library.json and every agent given it. A line the user edited
is left as it is.

Run (mote, via mote-run): go test ./internal/library ./internal/gui;
go vet darwin, GOOS=linux -tags nogui, GOOS=windows; gofmt.
TestRegistryLaunchLines uses the registry's own entries (Serena,
docling, olcli, alfanous, visualtorch, basic-memory, firebase, MARM,
...); TestPopularSerenaStarts reads the shipped crawl;
TestInstalledMarketLineHealed seeds `uvx serena-agent` given to Codex,
syncs, and checks config.toml and library.json. No network in tests.
Real starts on mote in a sandbox HOME (MCP initialize): `uvx
serena-agent` exits 2 with usage; the new Serena line answers
initialize (serverInfo Serena). Also answer: polymarket pm-trader-mcp,
basic-memory, llmtrim, pm-claude-skills, visualtorch-mcp. canvas and
reddit start but need their keys.

Broken by hand: ignoring runtimeArguments and the bins check turns 14
of TestRegistryLaunchLines' cases and TestPopularSerenaStarts red;
dropping healMarketLines from heal turns
TestInstalledMarketLineHealed red.

Not tried / still wrong upstream: omega and tinysearch now run their
real executable but their registry entries omit the `[server]` extra
(omega also needs `serve`), so they still don't serve MCP; that is
their registry entries. Docker lines weren't started. No GUI asset
changed, so no GUI files were run. The full suite runs after the tag.
2026-11-10 15:47:14 +08:00
yetone d374168d04 gui: Settings stays where it was clicked in the sidebar (jen_celeus on X)
In the sidebar layout Settings sits at the sidebar's foot, and opening it
listed its eight tabs under the button. The foot is anchored at the
window's bottom, so it grew upward and the button rose about 223 points,
out from under the pointer, and dropped back when another page folded the
list.

Settings' tabs now open above its button and grow up from it, so the button
and the gateway's line stay where they were. The foot is laid from its end
(`.side-foot` is `column-reverse`, its rows ordered tabs, Settings, gateway
and kept whole). A window too short for the list scrolls the foot from its
end, so the button stays in sight, and the foot may take 80% of the sidebar
while the list shows instead of 55%. The list's DOM order is the order
shown, so Tab reads tabs, Settings, gateway. The rows rise from the button,
nearest first. The overlay bar's thumb math takes the reversed scroll
origin. Nothing else in the layout changes: pages' own tabs still open
under their rows. The core-script budget is paid by cutting two sidebar
comments, with no raise.

Run (mote, at this head after rebasing on 86825005e unless said):
- sidebar-settings-steady.test.cjs (new), chromium and webkit, wide 1200,
  narrow 760 (sidebar picked), short 460 and tiny 340 high, all five
  languages: 42 of 42 pass. It samples the button every frame while the
  list opens, after a tab is picked and while it folds.
- Broken by hand: the old code is red in all 20 cases per engine ("the
  button moved 223px", 185.8px in the short window). With the foot back to
  `column`, red (223px). With the list put under the button in the DOM,
  red on the reading order. Before the rows were kept whole, the tiny
  window was red at 21.7px.
- sidebar, sidebar-glide, sidebar-tab-top, sidebar-overlay-scrollbar,
  nav-lamp, nav-sub-unroll, side-toggle, side-width, side-gateway-lan,
  settings-tabs-stick, text-size, click-scroll, readable-focus,
  page-width, i18n-keys at 3f27eab03 (this change before the rebase, no
  GUI files changed under it except the one new test): 322 pass, 1 red,
  sidebar-overlay-scrollbar chromium en "dragged to the end: 224 of 253",
  the known #1863. Alone it passed 3 of 3. Commented on #1863.
- go test ./internal/gui/... at 3f27eab03: ok.
- At this head: sidebar-settings-steady, sidebar, side-toggle and
  i18n-keys, chromium and webkit, 90 of 90 pass; TestCoreScriptBudget ok
  (220 bytes under the core budget).

Not run: the whole GUI suite, the full Go suite (started after the tag),
Windows and WebKitGTK by hand. No Go code changed, so no gofmt or vet.
2026-11-10 15:45:35 +08:00
yetone 281a7e024f sync: a computer can follow the server, taking its setup and sending none (Ramon317317 on X)
Ramon317317 asked for a main profile: one computer the others take their
setup from, so they never drift apart. Sync merged both ways only;
Restore is a one-time pull and an agent's own fields cover agents only.

A computer can now be set to follow the server (Settings -> Sync -> This
computer: Both ways / Follows the server; /api/davsync/follow-server;
`magpie webdav|s3|github follow on|off`). It is chosen per computer and
kept in sync.json (Config.FollowServer, kept by Configure like AutoEvery).
A following computer:
- takes every changed part from the file, whichever side is newer;
- never writes the file: no push, no merged sign-in, no rebuild of a
  damaged file;
- keeps a change made on it in the sync folder, as a join does, and the
  notice says it was replaced because this computer follows the server
  (Notice.Followed; GUI and CLI);
- still keeps an unset part on the server from emptying its own, and own
  agent fields and agents only here;
- refuses to follow a server with no file yet, sending nothing.
The computer followed stays two-way; nothing changes for anyone who
doesn't pick it. Usage sharing is unchanged. docs/subsystems/sync-backup.md
says so.

app.js stays inside the core script budget (TestCoreScriptBudget) with
no raise: renderSync's comments are cut down to pay for the row.

Run (mote, at this head):
- go build ./...; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...; gofmt -l clean.
- go test ./internal/davsync ./internal/cli ./internal/gui: ok (cli
  with the route guard fix committed beside this one).
  TestFollowServer (empty server, join, own change replaced and kept,
  both changed, unchanged sync, Configure keeps it, back to both ways)
  and TestFollowServerSendsNoSignIn are new.
- GUI (node --test, Chromium and WebKit): sync-follow-server (new; en and
  zh, 900px and 400px: name, sub, picked segment, the post, the notice,
  no scroll, no overflow, no select, re-pick posts nothing), plus
  sync-auto-restore, sync-note-show, sync-own-fields, sync-not-backup,
  sync-other-kind, sync-signins, sync-spin, i18n-keys, i18n-en-no-cjk,
  gui-zh-tw, gui-ja, gui-de: all pass.

Broken by hand:
- push guard removed: TestFollowServerSendsNoSignIn red ("sent its
  sign-in: 1 puts").
- follow branch off: TestFollowServer red ("b's own change stayed:
  [deepseek=k1 kimi=kb2]").
- the row's click not posting: sync-follow-server red, 8 of 8.

Not tried: a real WebDAV, S3 or GitHub server (fake servers only); two
real computers; Windows run of the tests (vet only). The full suite starts
after the tag.
2026-11-10 15:43:41 +08:00