Commit Graph
2421 Commits
Author SHA1 Message Date
yetone dc507aefd3 gateway: Automatic image recognition and web search stay with the provider that served them
hxy920830 on X added a Claude account only for account switching, and
every agent's image recognition and web search moved onto it: with
Settings › Models › Image recognition and Web search on Automatic, magpie
ranked the picks again on each call, and a Claude account ranks first in
both (seersRanked tier 0, searchRank 0). Adding a provider reassigned
what another provider already served.

- auto_picks.go holds each Automatic slot (Image recognition, Web search,
  Image generation, Video generation) to the provider magpie first picked,
  in auto-picks.json beside providers.json. seersRankedHeld and
  autoSearcherReady put the held provider before every other of its
  readiness; AutoDrawer and AutoVideomaker pick among its models while it
  has one. A default fills only a slot nothing serves: nothing held, or
  the held provider removed, off, or left with no model for it.
- Allowance still comes first for the moment (#1801); the hold stays.
- A model picked in Settings is untouched. The picker already shows the
  pick as "Automatic · <model>", where it can be changed.
- A file that can't be read holds nothing and is not written over.

Users already switched: holds begin once, when the gateway first serves
(seedAutoPicks). It reads the last 30 days of the ledger's Image
description calls (kind vision) and the searcher's Web search calls
(kind web_search, not search API / native rows). A slot a later provider
took over is given back to the provider that served the call just before
the current pick's first, while it can still serve it. A switch older
than 30 days, or one whose earlier provider is gone, is not restored: the
current pick is held and the user picks in Settings › Models. Image and
video generation have no Automatic call in the ledger and are held to
the pick at the seed, nothing restored.

Docs: docs/subsystems/gateway-routing.md, "Automatic picks are held to
the provider that serves them".

Run:
- go test ./internal/gateway -run 'TestAddedProviderTakesNoAutomaticPick|TestAutoPicksSeededFromTheLedger|TestClaudeAccountAddedTakesNoImages' -v: ok (mica)
- GOOS=linux go vet ./internal/gateway, GOOS=windows go vet ./internal/gateway: ok (mica)
- go test -count=1 -timeout 45m ./... (mote, at 589e4ba6d + this change):
  every package ok (internal/gateway 1080s) except seven reds, each
  already filed and each passing alone at this tree on mica:
  capre TestCappedIsSmall (#5975); cli TestHealthcheckFindsTheRunning-
  GatewayWithoutMagpieAddr, TestUpdateRestartsTheGatewayItFindsWithout-
  MagpieAddr, TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471:
  something serves on mote's 127.0.0.1:3425); gui TestAppReplacesIts-
  OlderGatewayOnceIdle (#6297), TestLaneLimitRoutes (#5150). The four
  cli and capre tests pass on origin/main 9314999a4 too.
- After the rebase onto origin/main e08dc0fe5 (mica): go test ./internal/gateway -run 'the three|Vision|Searcher|Drawer|Videomaker' ok, GOOS=windows go vet ok.

Broken by hand: heldPick returning "" (the old ranking) turns all three
tests red: AutoVision = "anth/eye" after a provider was added, and
"claude/claude-haiku-5-5" after the Claude account was signed in.
Not tried: the real app with a real Claude account; no GUI file changed,
so the GUI suite was not run.
2026-11-18 20:27:20 +08:00
yetone e08dc0fe58 provider: OpenAI's own API sends Responses turns over the WebSocket by default, only the new input each turn (KawaiiZapic on X)
KawaiiZapic's screenshot showed 6.4 GB up for 799 MB down: every turn
went out whole. What each leg sends, checked in the code:

- Codex on a ChatGPT subscription: the kept upstream socket already
  sends previous_response_id and only the new input (codex_socket*.go).
- A Responses provider with socket=auto/on: the same, but socket was
  off unless someone ticked it, so an OpenAI API key provider sent the
  whole conversation each turn over HTTP.
- A client's own previous_response_id is kept for api.openai.com,
  Azure and Ark (prevKeeps); other relays get the expanded whole turn,
  since they can't be trusted to hold the chain.
- Claude Messages, Chat Completions and Gemini have no incremental
  protocol; those always send whole (prompt caching is what saves there).
- The ↑ counter (upbytes.go) counts each upstream write once; no double
  count found.

Change: a Responses provider at https://api.openai.com with no socket
set now goes over the WebSocket (provider.SocketByDefault, mirroring
codex-rs's create_openai_provider supports_websockets: true). socket=off
is now stored, so unticking it there sticks; elsewhere unticked is still
"". The CLI shows "auto (default)" and takes socket=off|default. The
editor's WebSocket row moved into socketrow.js (imported as the editor
draws), so app.js and the core shrink by 165 bytes and their budgets
drop with them. Caveat: an OpenAI provider saved unticked before this
(socket "") now goes over the socket until it is unticked again; the
docs say so.

Measured (fake api.openai.com over TLS, sandbox HOME, 20 turns of a 4KB
user message each): socket off 20 HTTP posts, 876,345 bytes up;
default 0 posts, 20 socket turns on one handshake, 84,928 bytes up
(Traffic().Up equal to the socket bytes, so no double count).

Run (mica). At this head, rebased on origin/main 589e4ba6d: the go
test -run line below ok (budgets included), gofmt clean,
provider-socket.test.cjs 80/80 and old-webkit's same 2 reds. The rest
ran at the tree rebased on 1bfa8d5a1 (main since touched only plugin
assets and docs outside these files):
- go test -run 'Socket|Budget|OpenAI' ./internal/gui ./internal/provider
  ./internal/cli ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  for provider, cli, gateway, gui: ok.
- GUI: provider-socket.test.cjs 80/80 (chromium + webkit, 5 languages,
  2 widths). Every provider-*, i18n-* and old-webkit file in one
  run: 1793 pass, 76 red. Each red file run alone at this tree and at
  origin/main 1bfa8d5a1 is red the same or green at both:
  provider-fetch-again (#5057, #5232), provider-many-keys and
  provider-max-output (#6209), provider-models-rest, provider-picks-stay
  and provider-typed (#6532), provider-proxy (#7100), provider-remove
  (#7101); provider-advanced-fold 50/50, provider-env-paste,
  provider-add-gemini, -gemini, -at-once, -auth-header and -mask pass
  alone (load).
- Full suite, go test -count=1 -timeout 45m ./...: 99 packages ok, 4 red.
  Alone: TestSearchQueueKeepsCodexAlive (gateway) and
  TestWSLStoppedDistroKept (sessions) pass; TestGatewayModeListsNoOwnSessions
  (gui, #7064) and the dirent watch tests (#7031) are red at
  1bfa8d5a1 too.
- old-webkit.test.cjs: 2 reds (guideback.js not in the lazy list,
  Safari 15.0 styles), the same on origin/main 1bfa8d5a1 run alone;
  noted on #6570.

Broken by hand: SocketByDefault returning false turns
TestSocketByDefaultOnOpenAI and TestOpenAIProviderTurnsGoOverWebSocketByDefault
red ("2 HTTP posts, 0 socket turns on 0 handshakes").

Not tried: a real OpenAI API key, and a real Codex binary against an
API-key provider; the fake follows the Responses WebSocket protocol the
existing socket tests use.

Reported-by: KawaiiZapic on X
2026-11-18 20:22:30 +08:00
yetone 9314999a4a ccswitchlink: a ccswitch:// link that still reaches magpie goes to CC Switch, and so does the scheme (asombrado_a on X)
@asombrado_a (X, 2122995130097713493) has CC Switch and magpie both
installed, and a ccswitch://v1/import link opened magpie. magpie claims
magpie:// only since 03314b25a (v0.1.4455), but v0.1.3981 to v0.1.4454
claimed CC Switch's scheme too, and what they registered stays:
- macOS: Launch Services keeps the old Info.plist's ccswitch claim after
  the bundle is rewritten in place (seen on mote below);
- Windows: HKCU\Software\Classes\ccswitch running magpie.exe;
- Linux: magpie-ccswitch.desktop as the x-scheme-handler/ccswitch default.

The owner's call in 03314b25a stands: magpie doesn't read CC Switch's
links. A ccswitch:// link that reaches magpie anyway is now handed on:
- cli.run, before anything is read, moved or started (Windows, Linux:
  `magpie ccswitch://…`), and the Mac's URL event in gui.Run call
  ccswitchlink.Forward;
- macOS: `open -b com.ccswitch.desktop <link>`, then `lsregister -f` on
  magpie's own bundle, which reads its current Info.plist and drops the
  claim;
- Windows: the handler's program when it isn't this magpie, else
  %LOCALAPPDATA%\Programs\CC Switch\cc-switch.exe (where CC Switch's
  per-user MSI installs it); when the handler ran this magpie the key is
  rewritten as that MSI writes it ("URL:com.ccswitch.desktop protocol",
  URL Protocol, DefaultIcon, shell\open\command "exe" "%1");
- Linux: CC Switch's .desktop entry in the XDG data dirs (its first
  start's cc-switch-handler.desktop with %u first, else the package's
  "CC Switch.desktop", whose Exec has no %u, so the link is appended) is
  run, and a default that is magpie-ccswitch.desktop moves to it; magpie's
  entry is removed while it runs this magpie or a gone binary. Any other
  default is left alone.
- No CC Switch: ErrNotInstalled, nothing opened, the claim kept, so
  magpie opens such a link as it does now (it says it reads magpie://
  links only).

Existing users: nothing changes until a ccswitch:// link reaches magpie.
The first one is opened in CC Switch and the claim goes back, so later
links go to CC Switch directly.

CC Switch's facts come from farion1231/cc-switch (tauri.conf.json's
deep-link schemes ["ccswitch"], wix per-user-main.wxs, lib.rs's
register_all) and its v4.0.35 assets: macOS.zip's Info.plist
(com.ccswitch.desktop, CFBundleURLSchemes ccswitch), the portable zip's
cc-switch.exe, the .deb's "CC Switch.desktop" and /usr/bin/cc-switch.

Run (this tree on d74754970, then again where named after a rebase on
589e4ba6d, which touches none of these files):
- mote: go test -count=1 ./internal/ccswitchlink ./internal/cli
  ./internal/gui ok; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ok; gofmt -l empty.
- wsl-run (magpie-desktop) and win-run (xiaomi-gpu): go test -count=1
  -v ./internal/ccswitchlink ok (Windows writes a test key of its own,
  Software\Classes\magpie-test-ccswitch-<pid>, removed after).
- Full suite on mica (go test -count=1 -timeout 45m ./..., on
  d74754970): 101 packages ok; reds, all filed and none in a package this
  touches: internal/dirent's watch tests (#7031; red alone on a fresh
  origin/main 589e4ba6d too), TestGatewayModeListsNoOwnSessions (#7064)
  and TestWSLStoppedDistroKept (#7071), both ok alone on mica.
- After the rebase on 589e4ba6d: go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, gofmt -l on mote ok;
  ./internal/ccswitchlink and ./internal/gui ok on mote; ./internal/cli
  ok on mica. On mote three cli tests reach the 127.0.0.1:3425 an ssh
  port forward holds there (#6223).
- Real, macOS (mote, in ~/runs, cleaned up with lsregister -u): a test
  bundle registered with the old ccswitch claim kept it 5s after its
  Info.plist was rewritten without it; the built Forward then opened
  the real CC Switch v4.0.35 app and the dump showed the claim gone.
  Without CC Switch registered it returned ErrNotInstalled.
- Real, Linux (magpie-desktop, sandbox HOME and XDG dirs): with
  magpie-ccswitch.desktop as the real xdg-mime default, Forward ran
  cc-switch-handler.desktop's Exec with the link and the default was
  cc-switch-handler.desktop after.
- Broken by hand: no lsregister call (darwin), no xdg-mime default
  (linux) and no handBack (windows) each turned their test red.
- GUI suite: not run; no page, app.js or i18n change.

Not tried: a real CC Switch install on Windows (the box's real HKCU
ccswitch key is left alone; the test uses its own key), and a real
CC Switch .deb or AppImage on Linux (its entry was faked with the
package's own bytes).
2026-11-18 20:07:09 +08:00
yetone 389169f761 gateway: a Qwen Token Plan's TTS, ASR and video models are served on OpenAI's routes
gaubeebangeel on X (tweet 2122991088017477954) asked for every kind of
model Alibaba's Token Plan sells, each on its own DashScope endpoint.
Before this, magpie served the plan's text (Anthropic and chat
completions), its realtime voice (/v1/realtime, realtime.go) and its
Qwen-Image drawing (draw_dashscope.go). The plan's text list lacked
deepseek-v4.1-flash-1017, and nothing served its TTS, ASR or video
models.

- presets: alibabaPlanModels as the four plans' overviews list them on
  11-18 (qwen4-max, qwen4-max-preview, deepseek-v4.1-flash-1017 added).
  PresetDef gains Drawers, Videos, Speakers and Transcribers, Region
  gains Speakers and Transcribers, and the four Token Plans
  (qwen-token-plan, bailian-token-plan, alibaba-token-plan,
  qwencloud-token-plan) name qwen-image-3.0-pro and wan2.7-image(-pro),
  wan3.0-video and happyhorse-1.1-t2v/-i2v/-r2v, qwen-audio-3.0-tts-plus
  and qwen-audio-3.0-asr-flash. PlanSpeakers and PlanTranscribers feed
  PlanRetrieval, so the router knows which provider speaks and
  transcribes.
- /v1/audio/speech (speech_dashscope.go): a plan key's qwen-audio TTS
  model is asked on <root>/api/v1/services/audio/tts/SpeechSynthesizer,
  every field under input as the docs have them. An OpenAI voice name
  becomes the model's own first voice (longanlingxin for -plus,
  longanhuan_v3.6 for -flash), speed goes as rate (0.5 to 2), and
  instructions as instruction. mp3, wav, pcm and opus are served; aac,
  flac and stream_format sse are 400s before DashScope is asked. The
  answer's output.audio.url is fetched (or data decoded) and served with
  the format's type.
- /v1/audio/transcriptions: a plan key's qwen-audio ASR model goes to
  multimodal-generation with the file as an input_audio data URI, its
  format from the file's name or type, and language as language_hints.
  The answer is given back as OpenAI's json, text or verbose_json; srt,
  vtt and translations are 400s. The form's file is read only on this
  path (audioForm.file), so a form passed on as sent is never copied.
- /v1/videos (video_dashscope.go): Wan 3.0 and HappyHorse start at
  video-synthesis with X-DashScope-Async: enable and are polled at
  /api/v1/tasks/<id>. The id carries the model and the key's mark, as
  MiniMax's does. vendorAsk.answer now takes the request's context, so
  the TTS answer's audio URL is fetched under it.

Hosts, paths, fields and voices were checked against Alibaba's docs
(help.aliyun.com model-studio qwen-audio-tts/asr HTTP API and Wan 3.0
video reference, docs.qwencloud.com Token Plan multimodal pages,
platform.qianwenai.com token-plan), not against the tweet. Not tried
against the real API: the owner's magpie has no Token Plan provider.
The tests use a fake DashScope serving the docs' shapes.

Run (on mote via mote-run, tree at 8634c4ad0 plus this diff):
- gofmt -l internal/: nothing.
- go test -count=1 -run 'TokenPlan|DashScope|Speech|Transcri|Video|Plan|Qwen|Qianwen|Alibaba'
  ./internal/gateway ./internal/provider ./internal/gui: ok, ok, ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go
  build: all ok.
- go test -count=1 -timeout 45m ./...: 101 packages ok; internal/cli and
  internal/gui red on TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr,
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471) and
  TestLaneLimitRoutes (#5150). mote has an ssh forward listening on
  127.0.0.1:3425, which those tests read. All four are red the same way,
  run alone on mote, at a just-fetched origin/main 589e4ba6d.
- Broken by hand: with the X-DashScope-Async header dropped,
  TestTokenPlanMakesVideos goes red (403 "does not support synchronous
  calls"); with -plus's default voice changed to alloy,
  TestTokenPlanSpeaks goes red.
- GUI: no asset changed, and the .cjs files run app.js on fixtures, so
  none can be reached. The Go GUI API that lists the plans' models ran
  in ./internal/gui above.
- Rebased on origin/main 589e4ba6d (6 commits, none touching these
  files) and run again at this head on mote: gofmt -l nothing; the
  targeted run above ok, ok, ok; vet (darwin, linux nogui, windows) of
  ./internal/gateway ./internal/provider and the three builds ok.
2026-11-18 19:59:27 +08:00
yetone 589e4ba6da agent: OpenCode finds magpie's models itself; opencode.json no longer lists them
chawyehsu on X asked for dynamic model discovery, as
yuhp/opencode-models-discovery does. magpie wrote its whole catalog into
opencode.json's magpie provider. For an OpenCode that loads plugins of
today's shape (1.4.0 and later, 2.0.5 and later; openCodeDiscovers),
the provider now has no "models". magpie writes plugins/magpie-models.js
beside the file (opencode_models.js, marked by its first line). It fills
the provider's models as OpenCode starts, from the gateway's new
/v1/models?format=opencode (opencode2 for OpenCode 2;
gateway/opencode_models.go). That endpoint gives the same entries a sync
would have listed, in magpie's order, never cached, and only the
models of OpenCode's catalog the key asking may use (keyListed).

- OpenCode 1: through its config hook, which runs before it reads
  providers. The user's entries under magpie's provider are laid over
  magpie's, and an id magpie doesn't list stays.
- OpenCode 2: through ctx.model.transform. The config's own entries are
  laid on afterwards by OpenCode. Every entry says variants ([] for
  none), so OpenCode makes up none.
- Gateway not answering (3s timeout): the plugin lists the models magpie
  had when it last wrote it.

Existing users: the first sync on such an OpenCode takes magpie's list
out of the file (modelsLeft). Of each model, only what the user said
differently stays: their own variant, or a limit.output they typed. A
limit or cost they changed stays whole, since OpenCode 1.19.6 refuses
one without its context ("Missing key ...limit.context"). An id magpie
no longer lists goes that once (stash opencode-discover:<path>), as it
did on every sync before; one added after that is the user's and stays.
The user's other keys and providers are untouched. These keep the list
in the file as before: an OpenCode older than those versions, of no
known version, and the forks (mimocode, DevEco, Air). Going back to
such an OpenCode writes the list again and removes the plugin, and so
does taking magpie out. A file at the plugin's path without magpie's
first line is the user's and is never touched.

Run:
- mote-run go vet ./internal/agent ./internal/gateway, also with
  GOOS=linux and GOOS=windows: clean. gofmt -l: clean.
- mote-run go test ./internal/agent -run
  'OpenCode|OpenChamber|Air|DevEco|Mimo': ok (TestOpenCodePluginRuns runs
  the plugin in node against a stubbed gateway, up and down, v1 and v2).
- mote-run go test ./internal/gateway -run 'TestOpenCodeModelsList|Models': ok.
- Broken by hand, each red: no key filter (TestOpenCodeModelsList),
  openCodeDiscovers always false (Finds/ListMoves/DiscoversFrom), the
  delta keeping whole models (ListMoves), and the plugin letting magpie's
  fields win over the user's (PluginRuns).
- Three opencode_v2 tests that check the listed words now pin 2.0.4 and
  1.3.9, which still list.
- Real OpenCode on mote in a sandbox HOME, opencode-ai 1.19.6 and
  @opencode/cli 2.3.2. Config and plugin written by magpie's own code, a
  fake /v1/models serving one extra model:
  - `opencode models` lists the served model with the gateway up, and
    the cached list with it down. Both versions, Bearer key sent.
  - A file moved from 1.3.9/2.0.4 with a user limit.output and a user
    model: `opencode models magpie --verbose` (1.19.6) and
    `opencode api --standalone GET /api/model` (2.3.2) resolve magpie's
    models the same as the old full-list file did. Names, limits,
    variants and the user's edits are identical; 2.3.2 orders a model
    the file names first.
- Full suite: mote-run go test ./... -timeout 45m -count=1 on this change over base 1bfa8d5a1: 103 packages ok, no FAIL.
- Rebased on 7300be4d0 (main touched agents.go and gateway.go): go vet
  darwin/linux/windows of internal/agent and internal/gateway clean;
  go test ./internal/agent ok; ./internal/gateway red only in
  TestSearchQueueKeepsCodexAlive/comments and /cancel at load ~37, the
  idle-bar class of #7090 (commented), 5/5 ok alone at this head.
- Not changed: the forks mimocode, DevEco and Air keep the list; filed as #7055.
Not tried: a WSL distro's OpenCode, and OpenChamber's own UI over the
plugin-filled provider.
2026-11-18 19:47:19 +08:00
yetone 7300be4d01 gateway: find_tools says no tool was found instead of handing over near names
sahuaja3669 on X (tweet 2122928458355319211), on the on-demand router:
it shouldn't pad its answer with tools of a near name that do something
else, and it should say plainly when nothing was found.

Before, find_tools counted any query word found as a substring of a
tool's name or description, stop words and single letters included. "a"
is in nearly every name, so "send an email" against GitHub, filesystem,
Linear, magpie-image and magpie-browser gave five tools in full
(search_code, read_file, write_file, ...) as matches, with nothing saying
they were weak; a query nothing matched did say so.

Now find_tools matches on the query's key words (stop words such as a,
the, to, my left out), each a whole word of the name or description or
the start of one at four letters or more (open/opens, issue/issues; a
non-ASCII word anywhere, as before). A tool is a match only when the
query is its name, or it has two thirds of the key words, one in its
name unless it has them all. When none clears that, the answer says no
tool was found and not to call one that only sounds close, and names
each server with its tool count and up to 8 of its tool names, as what
there is rather than as matches. call_tool's "close to it" for an
unknown name keeps a looser rule (a key word shared with the name,
hubNear), so create_isue still points to create_issue. Cheap and
deterministic: word lists, no model, no index.

The cost: a query in other words than the tool's ("draw an image of a
cat" for generate_image) now finds nothing, and the model reads
generate_image from the server list in the answer, and from find_tools'
description, which already names each server's tools.

Test: TestHubFindNothingClose, on real descriptions from
github-mcp-server, the reference filesystem server, Linear's, and
magpie-image's and magpie-browser's own. Red on the old
hub_ondemand.go: "send an email" matched eight tools or more, five in full.
docs/subsystems/mcp-router.md updated.

Run:
- full go test ./... -count=1 -timeout 45m on mote at 5c32b285d (on
  48fffb60c): every package ok, internal/gateway 1392s.
- full go test ./... -count=1 -timeout 45m on mica at 1acbfcc23 (on
  3e66d25d8), mote over its load: 100 packages ok, three red, none in
  code this touches: internal/dirent's watch tests (red on mica at
  3e66d25d8 alone too, ok on mote; #7031), internal/sessions
  TestWSLStoppedSinceNotOpened (internal/sessions doesn't import
  gateway; red 1 of 4 on mica at 3e66d25d8 alone, ok on mote; filed
  #7089), internal/gateway TestSearchQueueKeepsCodexAlive/progress (ok
  3 of 3 alone; filed #7090).
- at the pushed head 22647c27f (on e199eb9c7): go test ./internal/gateway
  -count=1 -timeout 45m on mica ok (1306s); go vet ./internal/gateway
  for darwin, linux and windows ok; gofmt -l clean.
- rebased onto d2fa7d8d7 to push (four commits: sessions, library, and
  d74754970's system-message placement in gateway, none in the hub);
  there go test ./internal/gateway -run 'Hub|MCP|Search|Message|System'
  ok on mica, go vet ok. 65c9a2e41 there addresses #7089's WSL wait.
Not tried: a real agent driving find_tools against a live router.
2026-11-18 18:58:55 +08:00
yetone d2fa7d8d79 sessions: an Antigravity app conversation shows what was said, not only its title
@yansheng1003 on X: the Sessions page showed an Antigravity 2.0
conversation's title and preview only. HasTranscript left "antigravity"
out, since conversations/<id>.db's step text is encrypted at rest, so
the row had no Show conversation and /api/sessions/transcript said
"this agent's conversations can't be shown".

The app also writes every step in plain text beside the database:
brain/<id>/.system_generated/logs/transcript_full.jsonl in the same
store, in agy CLI's format (user input, planner responses with their
tool_calls, tool results). Antigravity 2.30's language server writes it
in the stable store and in Insiders' (both checked: run in a sandbox
HOME on Windows against a fake model that called read_file).

- transcript.go: antigravity has a transcript; readTranscriptOf reads
  it through agyTranscript (antigravityTranscriptOf), so the viewer,
  TranscriptAt, search, the said index and the Markdown export all get
  it. A conversation with no transcript file is ErrNoTranscript, as
  before.
- antigravity_app.go: antigravityTranscript derives the path from the
  database's (stable, Insiders, a WSL distro's); its size and time are
  folded into the session file's with the -wal's, so a step it adds
  reads the session and the said index again.
- search.go: linesFile is false for antigravity, so the encrypted .db is
  never pre-scanned for the words.
- testdata/antigravity-2.30-tools: that real conversation (db with the
  WAL checkpointed, summary row, brain/ logs).

Tests: TestAntigravityAppTranscript (stable, Insiders, WSL: parts, search
hit and miss, Markdown), TestAntigravityAppNoTranscript,
internal/gui TestSessionAntigravityConversation (/api/sessions marks it,
/api/sessions/transcript gives the five parts).

Run: on mica (mica-run) at base de5fc6700:
- gofmt -l internal/sessions internal/gui: clean.
- go vet ./internal/sessions ./internal/gui, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet on the same, go build .: ok.
- go test -count=1 -timeout 45m ./internal/sessions: ok but for
  TestWSLAgentsGoneListingDrops (load ~48; fixed at its cause in the
  commit before this one); go test ./internal/gui: ok (299s).
- After that fix: go test -run 'WSL|Antigravity|Agy|Gone'
  ./internal/sessions ok; GUI files sessions-talk, -talk-sheet,
  -talk-model, -export, -said, -subagents, -reads, -search, -convert:
  168 of 168 in Chromium and WebKit.
- Old code (de5fc6700 with only the new tests and testdata):
  TestAntigravityAppTranscript red in stable, insiders and wsl ("the
  session isn't marked readable"), TestSessionAntigravityConversation
  red ("listed with no conversation to show ... Transcript:false").
- Windows (win-run on xiaomi-gpu): TestAntigravityAppTranscript (3
  subtests) and TestAntigravityAppNoTranscript pass.
  TestAntigravityAppFolder is red there at the base as well (#5957).
Rebased onto bfddc9cfb, on mote (mote-run) at this tree: gofmt clean,
the three vets and go build ok, go test -count=1 ./internal/sessions
./internal/gui ok (56s, 157s).
Not tried: the real GUI window opening this conversation; the API and
page are covered by the tests above.
2026-11-18 18:55:46 +08:00
yetone bfddc9cfba routing: DimCode's requests read as DimCode, with its mark, by key too
Yayoi_no_yume on X, a Docker magpie (v0.1.4350): DimCode (dimcode.dev)
on another computer, calling with a gateway key named "Magpie", drew
the Routing page's client node as the cube and "Magpie", and the
request's story said "DimAgent asked for the routing group Step 5
Preview".

Two causes:
- DimCode was no client magpie knew, so usage.AgentOf named it by its
  product name: npm's dimagent 0.5.29 sends "DimAgent/<version>" to a
  provider set to send its identity (resolveDimOAuthIdentityHeaders)
  and "DimCode/<version>" otherwise (read from the published binary).
  A client "dimcode" (DimCode, UA dimagent/dimcode) now names it,
  apart from the Dim alpha magpie starts ("dima"/"dimcode-alpha" stay
  Dim's, by name first). Its icon is dim-color: dimcode.dev's favicon
  (dimagent-favicon.svg, "Official DimAgent mark") is the same artwork.
  Routes and ledger records kept before are named again through
  AgentOf (Route.routedAgain), so old "DimAgent" rows read as DimCode.
- A keyed request's node read the key's name alone (eadc6cdb9, for a
  script's key behind "Python-urllib"). An agent magpie knows now
  reads "agent · key", as Usage's ledger rows already do; a script's
  key keeps the key's name alone. The tooltip names the agent once.
  The tray panel's stage and rows share callerName and read the same.

The icon comes from the embedded assets, which the web (Docker) build
serves the same way; the GUI test checks the image loads.

Run on mote:
- go vet ./internal/agent, GOOS=linux -tags nogui and GOOS=windows:
  ok. go test -count=1 ./internal/agent ./internal/usage: ok (agent 463s, usage 124s)
- TestDimCodeByUserAgent is red with the dimcode entry taken out
  (AgentOf("DimAgent/0.5.29") = "DimAgent").
- GUI, chromium and webkit, every language, 1100 and 420:
  routing-agent-with-key.test.cjs (new), i18n-keys, i18n-en-no-cjk:
  30 of 30 pass. Earlier, on mica, with the same client.js: the 28 other
  files that read callerKey, .rt-src, .ps-name/.ps-ag or .pr-who pass
  but api-key-usage (#7083) and usage-ledger's return-to-live case
  (#5048), both red on origin/main 2416beed6 too.
  routing-agent-with-key is red on the old client.js ('Magpie' for
  'DimCode · Magpie').

Not tried: a real DimCode against a real Docker magpie; the
User-Agents come from the published binary and the reporter's log.
2026-11-18 18:03:16 +08:00
yetone 71b8ab46c1 gateway: Codex's compaction on Open Design goes without empty tools, and its upstream_error is asked again (Mugenrikka on X)
Codex compacting on any Open Design model got 400 "[code=upstream_error]
Provider returned error" from amr-link, while other providers compacted.
Codex's compaction is its one request with "tools": [], and the summary
ask adds tool_choice and parallel_tool_calls beside them (#292). Since
plugins 0.1.13 / 48f976402 the Responses body is relayed to amr-link as
written, and an OpenAI-style validator refuses empty tools and a lone
tool_choice.

- passthrough: a Responses request to Open Design (its plugin, or a
  provider at amr-link.open-design.ai) goes without an empty tools list
  and the tool_choice/parallel_tool_calls beside it (withoutEmptyTools).
  A body that declares a tool is unchanged; every other upstream is sent
  Codex's shape as before.
- codexCompact: amr-link's "[code=upstream_error]" counts as
  upstreamFailed, so a summary still refused is asked as sent, then as
  text, then made locally, never handed to Codex as the 400.
  upstreamFailed is only used by the compaction ladder.

Run (mote; the suite at 54117164c, then rebased on 1bfa8d5a1 and
-run 'OpenDesign|Compact' ./internal/gateway run again there: ok):
- TestOpenDesignCompactionSendsNoEmptyTools and
  TestOpenDesignCompactionRefusedAsksAsText, built from Codex Desktop
  26.1007's real compaction (testdata/codex-26.1007-compaction.json)
  through the fake plugin as opendesign: both red on the old
  gateway.go/codex_backend.go with the reporter's 400, green with them.
- go test -run 'OpenDesign|Compact|LoneToolChoice|ToolsOff' ./internal/gateway ok.
- go test -timeout 45m ./...: every package ok.
- go vet (darwin), GOOS=linux -tags nogui and GOOS=windows vet of
  internal/gateway ok; gofmt -l clean.

Not tried: a real Open Design account (none here). Which of the empty
tools, the lone choices or the history's calls amr-link refuses is not
confirmed; the second change covers whichever it is.
2026-11-18 17:58:02 +08:00
yetone 54117164cd gateway: a Claude account Anthropic turned off moves on and rests as restricted
When Anthropic turns a Claude subscription account off, the request now
goes on to the routing group's next member and the provider's other
accounts, and the account rests as restricted (2h) instead of a short
failure rest. Before, a disabled organization's 400 ended the group at
that account and its next members were never asked (Ramon317317 on X),
and Claude Code's "account is on hold" came back from the bridge as a
502 that rested the account a minute and asked it again.

The words (claudeOffWords, routing.go): "This organization has been
disabled." (400 invalid_request_error or 403), "account is on hold and
can't use Claude Code" (the bridge now answers it as a 403),
"organization has disabled Claude subscription access", "OAuth
authentication is currently not allowed for this organization", and
"account can't receive replies from Claude" (either apostrophe, or
"cannot"). claudeAccountOff scopes them to a Claude subscription account
or a key on api.anthropic.com. A relay's same words are about the
relay's own account behind it, so they stay ordinary failures there, as
on Codex. The extra-usage and Usage Policy refusals are not account
faults and are unchanged. riskRefused keeps the provider's other
accounts in, as for Google's suspension.

Docs: claude-subscription-bridge.md and gateway-routing.md updated.

Run at f357a5e25 (this commit on origin/main f7e0f68ca), on mote:
- new tests (TestClaudeAccountOffMovesToNextAccount,
  TestClaudeOrgDisabledGroupMovesOn, TestClaudeAccountOffScoped):
  51 PASS lines, 0 FAIL.
- Broken by hand: routing.go, fallback.go and claude_subscription.go put
  back to the parent's, with a claudeAccountOff stub returning false so
  the test compiles: all 3 tests fail, 35 FAIL lines (32 subtests), 16
  pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test ./... -timeout 45m: every package ok (103 ok lines), rc 0.

Then rebased on origin/main a2d402afe (six commits, internal/gui, site/
and docs/ only) and run again at the pushed head, on mote: gofmt -l
nothing; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
go vet ./... ok; go test -count=1 ./internal/gateway ./internal/gui ok.
Rebased again on 1318864d1 (internal/agent, internal/provider,
internal/sessions; none touched here) and run at this head: gofmt and
the three vets as above ok; go test -count=1 ./internal/gateway
./internal/provider ok.
main moved once more (3e66d25d8, 03314b25a: internal/agent, catalog,
gui import links, provider's CC Switch import; none touched here), and
this pushed head was run with gofmt, the three vets ok and the new tests
(51 PASS, 0 FAIL); the gateway package as a whole last ran at 1318864d1.

Not counted: an earlier full run on mica at an older base was voided
because mica's disk filled mid-run (253 "no space left on device"
failures). Its three internal/dirent reds (TestWatchesFromOneMarkProbeOnce,
TestWatchedFolderReadOnlyWhenChanged, TestFileHeldOpenStillSeen) did not
come back in the mote run above. mote's 1-minute load was ~39 on 18 cores
during the run, with no other full suite there.

Not tried: a real disabled or on-hold Claude account; the bodies are
from Claude Code's errors page and users' reports.
2026-11-18 17:09:18 +08:00
yetone 3ec89c5224 codex: the takeover's end waits for the chats on magpie the Codex app has open (milianxinqi on X)
milianxinqi on X, the Codex app: "Model provider mismatch. This chat uses
magpie, but your current provider is OpenAI. Switch to magpie to
continue." ("用的好好的,codex 突然就弹这个了"), with nothing disconnected.

Cause. With the ChatGPT account Codex is signed in to held (out of its
allowance and credits), magpie is Codex's provider (the codex.out
takeover, #540) and new chats start on magpie. When the account has room
again (its window's reset, a switch to another account, or the account
the user keeps Codex on, a5e3972a7), Sync ended the takeover at once:
model_provider out of config.toml, Codex back on OpenAI. The Codex app
keeps the app-server the takeover started (codexAppStep leaves it
running unless Restart the Codex app to follow is on, off by default,
#4550), with its chats loaded and each one's writer lock held, so
bringBack could move none of them and codexRetagOpenThreads never ran
(it runs only before magpie ends the app-server). Every send in an open
chat then met the mismatch, with no step of the user's.

Fix. outStays (agent/codex.go): the takeover's end in Sync, both the
out_own way back and #540's, waits while a Codex holds a chat on magpie
open or wrote to one in the last minute (codexHeldOnMagpie:
sessions.CodexThreadsBusyOnBut, T3 Code's own threads left out, as
codexRetagOpenThreads leaves them), and codexThreadsLater asks for the
Sync that ends it once they are let go; bringBack then moves them onto
OpenAI. Meanwhile magpie serves them on the account, which has room, and
the app on the takeover's app-server shows no account either way. Nothing
waits when the app-server is restarted for the change (Restart the Codex
app to follow on, provider.CodexRestartsApp) or the user turned the
takeover off (Always ChatGPT): that restart moves the open chats first.
The [model_providers.magpie] table already stays after a Disconnect, so
an old thread still opens; a deliberate Disconnect restarts the
app-server (byHand) and retags its chats.

Other paths looked at and left: Disconnect, Unwire, Join and Codex's
account switch go through the same bringBack/retag; RestoreOnQuit (off by
default) runs at quit only; the update restart hands the gateway over on
macOS and Linux and skips it. On Windows a restart runs RestoreOnQuit
when it is on: filed separately.

Tests:
- TestCodexTakeoverWaitsForTheOpenChat (new): takeover, a chat on magpie
  quiet but its lock held, account back: still magpie's provider, the
  chat on magpie, no Sync asked; lock let go: a Sync asked, which ends
  the takeover and moves the chat to openai.
- TestCodexTakeoverEndsAtOnceWhenTheAppFollows (new): with the app
  restarted for the change, nothing waits.
- TestCodexTakeoverThreadComesBackOnceQuiet (nb5p): now the takeover
  stays while the thread is written to, and ends at the later Sync.
Broken by hand: outStays' gate taken out of Sync: the new test and nb5p's
red ("Codex was put on OpenAI under it"), green with it.

Run (mica, mote over its load, at this tree on origin/main 48fffb60c):
- go test -count=1 -timeout 45m ./internal/agent ./internal/sessions
  ./internal/provider: ok (426s, 1917s, 237s).
- go vet of those on darwin, GOOS=windows, GOOS=linux: ok. gofmt -l clean.
- Rebased onto origin/main a2d402afe (provider and sessions changes
  elsewhere): go build ./..., go vet of the three, and the takeover,
  thread-move and retag tests of internal/agent and internal/sessions
  again: ok.

Not tried: the real Codex app through a real reset (needs an account
held then given room); a full ./... run (mica had another session's full
suite and GUI suite running).
2026-11-18 16:33:04 +08:00
yetone c5cb1c0588 gui: the tray's logo is 16pt, as large as other apps' menu bar icons
qingnianxiaozhe on X: magpie's A\ in the menu bar looked a size smaller
than another app's A\ beside it. magpie fitted each logo to a 14pt box,
so the A\ (about 1.37:1) drew 14x10pt. Claude.app's menu bar template
(TrayIconTemplate@2x.png, 48x48 px) has 32x32 px of ink, a 16pt glyph,
and in the reporter's screenshot the other A\ is 32x22 px against
magpie's 28x20 px at 2x. mpLogo is now 16; the letter in a ring (a logo
that can't be read) grows with it. The two 10pt rows of percentages are
unchanged and still fit the 22pt bar.

Tests: the logo boxes in the tray tests follow the 16pt box (offsets 28
-> 32, 34 -> 38 px at 2x); TestTrayImageLogoSizes now wants 27-33 px of
a 32 px box.

Run on mote (macOS 27.2):
- go test ./internal/gui -run Tray -count=1 -v: ok.
- Broken by hand (mpLogo back to 14): TestTrayImageLogoSizes FAILs
  ("alma spans 24 px of a 32 px box", codex/zcode/workbuddy 26 px) and
  TestTrayImagePlain FAILs ("238 px with logos, 182 without").
- Rendered by the real drawing code (trayImagePNG, 22pt bar at 2x)
  next to Claude.app's own template icon: the A\ is 28 px wide before
  and 32x24 px of ink after, as wide as Claude's 32 px spark; the
  percentages are the same text at the same size. The before/after
  strips are kept outside the repo (tray-toolbar-scratch/before and
  after/strip-{light,dark}.png).
Suite and checks, on mote at aa31e737c8d271455865615fafdf512e09073663 (this commit and its pair, the
tray logo size / the toolbar menu):
- go test -count=1 -timeout 45m ./... in a sandbox HOME, caches pinned:
  exit 0, 103 packages ok, none FAIL (internal/gateway 1633s,
  internal/agent 949s, internal/provider 470s, internal/gui 295s).
- gofmt -l internal/gui: nothing. go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: all ok.
- No GUI asset changed, so the Playwright suite wasn't run.
After a rebase onto 42c43c002 (Antigravity sessions, internal/gui
sessions reads; no file in common), at the pushed head:
go vet, GOOS=windows and GOOS=linux -tags nogui go vet of ./internal/gui/...
and go test -count=1 ./internal/gui/...: ok.
Then rebased onto f7e0f68ca (Codex instructions, internal/provider
only), not run again.

Not tried: a screen screenshot of the real menu bar (no Screen
Recording permission over ssh on mote; the image is the one the app
hands NSStatusItem); the reporter's notch Mac, where the bar is 24pt.
2026-11-18 16:08:15 +08:00
yetone add1e75ee3 gui: no Icon and Text menu on a right-click by the traffic lights
AlanWang1027713 on X: a right-click on the main window's title bar, by
the lights, offered "Icon and Text / Icon Only / Text Only". It comes
from the empty NSToolbar that MacTitleBarHiddenInset puts there to
inset the lights; NSThemeFrame's menuForEvent: lists its display modes.
insetLights takes the toolbar away only in the macOS 26 design, so on
macOS 27, with an older SDK and in a right-to-left layout the toolbar,
and its menu, stayed.

quietToolbar turns the menu off where the toolbar stays:
allowsDisplayModeCustomization = NO (macOS 15+), and AppKit's own
_setWantsToolbarContextMenu: NO for macOS 12-14, each looked up with
respondsToSelector, since the SDK that builds magpie may be older than
the system it runs on. Nothing about the title bar's shape changes.

windowshape.Of now reads the menu a right-click 20pt below the top,
120pt in, gets from the window frame (TitlebarMenu), and
TestMainWindowCorners and TestMainWindowRightToLeft fail when the main
window gets one, or when the reference toolbar window doesn't (so the
probe is proven to see it).

Run on mote (macOS 27.2), real makeMain window:
- go test ./internal/gui -run 'TestMainWindowCorners|TestMainWindowRightToLeft'
  -count=1 -v: ok. Each stage logs "title bar menu []" next to the
  reference toolbar window's ["Icon and Text" "Icon Only" "Text Only" "-"]
  (macOS 26 SDK) and ["-"] (macOS 15 SDK). Lights [[26 26] [49 26] [72 26]],
  66pt title bar and 16pt corners with the 26 SDK, [[19 19] [39 19]
  [59 19]] and 38pt with the 15 SDK: the same as without the change.
- Broken by hand (quietToolbar call taken out): both FAIL, "a right-click
  on the title bar gets a menu: ["Icon and Text" "Icon Only" "Text Only"
  "-"]" (26 SDK) and ["-"] (15 SDK).
- A probe app on mote: either switch alone empties the frame's menu.
Suite and checks, on mote at aa31e737c8d271455865615fafdf512e09073663 (this commit and its pair, the
tray logo size / the toolbar menu):
- go test -count=1 -timeout 45m ./... in a sandbox HOME, caches pinned:
  exit 0, 103 packages ok, none FAIL (internal/gateway 1633s,
  internal/agent 949s, internal/provider 470s, internal/gui 295s).
- gofmt -l internal/gui: nothing. go vet ./..., GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: all ok.
- No GUI asset changed, so the Playwright suite wasn't run.
After a rebase onto 42c43c002 (Antigravity sessions, internal/gui
sessions reads; no file in common), at the pushed head:
go vet, GOOS=windows and GOOS=linux -tags nogui go vet of ./internal/gui/...
and go test -count=1 ./internal/gui/...: ok.
Then rebased onto f7e0f68ca (Codex instructions, internal/provider
only), not run again.

Not tried: a screen screenshot (screencapture over ssh has no Screen
Recording permission on mote; the menu is read from AppKit instead);
macOS 12-14, where only the private selector applies.
2026-11-18 16:08:15 +08:00
yetone 42c43c0020 sessions: an agent found after Allow selected is asked about once (Antigravity 2.0)
baysonfox on X: Antigravity 2.0 desktop sessions showed on the Sessions
page only while the app was connected to magpie; agy CLI's always showed.

Cause: not the file reader. Real Antigravity 2.30 (signed out, no model,
sandbox HOME on the Windows box) writes ~/.gemini/antigravity/
conversations/<id>.db, conversation_summaries.db and brain/, and
internal/sessions parses them. The gate is settings.SessionReads:
"Allow selected" (and the Usage readsNote's "Count …") saves all:false,
so an agent installed after that choice is never read and never asked
about again. Gateway-recorded sessions skip the gate, hence "only when
connected".

Fix: /api/sessions/reads marks a found agent `new` when the choice was
made, it isn't read, isn't named in Agents and is on disk (Found(), which
checks every OS's path). The Sessions page shows one quiet card for those
(laterCard): "Show their sessions" names each on, "Keep off" names each
off, so it isn't asked again. No new endpoint; the card posts the
existing sessions/reads.

Tests: TestSessionReadsNewAgent copies the real 2.30 files
(internal/sessions/testdata/antigravity-2.30, sandbox paths only, no
tokens) beside agy-sessions, with agy allowed by name: antigravity is
off and new, nothing listed; after the answer it is not new, settings
keep all:false/agy:true, and its one session is listed only when shown.
TestSessionReadsNewOnlyWhenNamed: not asked, allow all, all with agy off
mark nothing new. sessions-reads.test.cjs: the card, both answers, posts
and no card after reload, Chromium and WebKit, 5 languages, 900/390px.

Run at d7d62d889, on mote, then rebased onto 48fffb60c (app.js and
settings-groups only, no file in common):
- gofmt -l, node --check client.js/i18n.js: clean
- go vet ./internal/gui ./internal/sessions; GOOS=linux -tags nogui and
  GOOS=windows go vet of the same: ok; go build .: ok
- go test -count=1 ./internal/sessions: ok (282s)
- go test -run 'TestSessionReads|TestCoreScript|TestI18n|TestCSS'
  ./internal/gui: ok
- GUI: sessions*.test.cjs (45 files), usage-reads-note,
  gateway-mode-sessions, i18n-keys, window-back-once: 711/711 pass
Broken by hand: New forced false, TestSessionReadsNewAgent red in both
subtests ("want off and new"). An earlier "Allow" button label was red
in i18n-keys (core word, internal/agent/reach.go), hence the label.
Not run: the whole GUI suite and the full go test ./... (mote and mica
were overloaded, mica's disk full). Not tried: a real Antigravity 2.0
on macOS/Linux; Found() paths for those come from the existing reader.
Not changed: the Usage page's readsNote still shows only before the
choice; Found() doesn't look into WSL distros.
2026-11-18 16:04:10 +08:00
yetone 3b74aaf12c agent: Claude's auto-compact window is held to the 1000000 Claude Code takes
ZeroX2017 on X (0.1.4404): a compaction threshold of 1048576 typed for
Ollama Cloud's 1M DeepSeek went into ~/.claude/settings.json as it was.
Claude Code 2.1.316's settings schema (and Claude Desktop 2.7032's copy
of it in app.asar) takes autoCompactWindow as an int of 100000 to
1000000 and reads a larger one as none, so a new Claude App session ran
that model at the top-level 272K for every model.

Every auto-compact window magpie writes for Claude Code is now held to
1000000 (claudeCompactCap): the per-model modelSettings entries
(claudePlan), the top-level autoCompactWindow, and
CLAUDE_CODE_AUTO_COMPACT_WINDOW. An entry the hold makes equal to what
the model runs at anyway is left out. The threshold in magpie stays as
typed; Codex and Grok Build get it unheld; tune's card still reads the
top-level value back as Long conversations at the typed value
(claudeLongWindow compares against the held value). agent-wiring.md
says so.

Tests: TestClaudeCompactHeldToClaudeMax (Desktop entry, a second sync
rewrites nothing, magpie's threshold unchanged, the variable when
Claude Code is alone, Codex unheld), TestClaudePlanHeldToClaudeMax,
TestClaudeTopCompactHeldToClaudeMax (top-level + tune read-back).

Run:
- Full suite, go test ./... -timeout 45m -count=1 on mote at base
  afabb7f90: exit 0, 103 packages ok, no FAIL/panic/timeout in the
  kept log.
- Rebased on origin/main 07d19510f (11 commits, GUI and
  internal/library only, nothing in internal/agent): go test
  ./internal/agent ./internal/library -count=1 ok on mote;
  GOOS=linux and GOOS=windows go vet ./internal/agent ok; gofmt -l
  clean.
- Broken by hand: claudeCompactCap made a no-op, all three new tests
  red (entry 1048576, top-level 1048576).

Not tried: a real Claude App session with a 1048576 threshold; the
schema bounds were read from Claude Code 2.1.316 and Desktop 2.7032's
bundled source.
2026-11-18 14:32:09 +08:00
yetone 00d6c8dbfc library: the Plugins page's Give to agents and Hide from agents follow the Library's switch for the plugin's tools
PluginServers called a plugin's tools server on when any agent was
ticked for it, but the Library row's switch is !Hidden. With the server
on in the Library and no agent ticked, the two pages disagreed. The
Library's switch said on, and an app at the MCP router's address had
the tools. The Plugins page said "Tools, hidden from agents" and offered
Give to agents. Now `on` is !Hidden on both pages.

Test: TestPluginToolsHidden checks that with the server on in the
Library and no agent ticked, an app at the router's address lists it and
PluginServers says on. docs/subsystems/plugin-tools.md says what `on` is.

Run (mica, at this tree on 32a181868):
- go test ./internal/library -run 'TestPluginTools|TestPluginServer':
  ok.
- plugin-tools.test.cjs, both engines, in the same 61-pass run as the
  two commits before.

Broken by hand: `On: len(s.Agents) > 0` put back made
TestPluginToolsHidden red ("on in the Library, given to no agent: the
Plugins page says hidden"). Put back.

Not tried: the real app window with a real tools plugin.

Run again after a rebase on 888d4eba5 (mica): the go test guards and ./internal/library ok; library-plugin-parts, library-plugins, agent-disconnect, agent-bulk-visibility, agent-visibility-saving, plugin-tools, i18n-keys, gui-de, gui-ja and gui-zh-tw, both engines: 155 pass, 0 fail.

At the pushed head, on cb1fe6d5d (mica): the go test guards, ./internal/library -run TestPlugin, i18n-keys and agent-disconnect ok.
2026-11-18 13:52:12 +08:00
yetone cb1fe6d5d9 gui: Get started put away comes back from Settings › General
Once the Agents page's Get started card was hidden (POST
/api/settings/guide {hidden:true}) nothing in the app brought it back.
Hiding it now says where it comes back ("Get started hidden; Settings ›
General brings it back"), and General has a Get started row with Show,
only while the card is hidden and would otherwise show (setup not done,
not gateway mode). Show posts {hidden:false}, redraws the Agents page and
says so; the row goes. The row lives in guideback.js, imported by
navpages.js beside the sidebar's pages, so the core grows by one status
line. Settings' search finds it by its name.

Run (mote, at this tree):
- getting-started, nav-pages-hidden, nav-pages-order, settings-general,
  settings-search, i18n-keys, gui-de, Chromium and WebKit, every
  language: 117 tests, all pass after the fake server answered
  /api/settings with the guide flag as the real one does.
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.

Broken by hand, each red, then put back:
- renderNavPages not calling guideBack: getting-started 20 of 60 red
  (the row never shows).
- the hide's status line removed: getting-started 30 of 60 red.

Not tried: the real app window.
2026-11-18 13:46:51 +08:00
yetone afabb7f90f library: a skill the router lists stays a /name of Claude Code's
RoyShen on X (yuushabu_buyinn): with the skill router on, / in the agent
no longer picks a skill. A listed skill has no link of its own in the
skills folder, so Claude Code had no /name for it.

For each skill the router lists for Claude Code (any profile; not a
plugin agent or WSL), routerCommands writes <claude dir>/commands/
<name>.md: the skill's description, disable-model-invocation: true, and
a body that has the agent read the skill's SKILL.md at the router's path
and follow it, with $ARGUMENTS. The flag keeps the description out of
the model's prompt, so the router still saves what it saved. The stubs
go in the commands folder, not the skills folder, because Crush, DevEco
Code and Kimi Code read ~/.claude/skills too and ignore the flag.

Applied.RouterCommands records the files with their hash (syncOwnFiles):
one the user changed is theirs. A user's own command file by that name,
or a Library command of that name given to Claude Code, means no stub;
syncCommands takes a stub's file over when such a command is added. The
command import leaves the stubs out. Router off, or the skill kept
direct: the stub goes.

Run:
- mica-run go test -tags nogui ./internal/library -count=1 -timeout 45m: ok
  (277s); GOOS=linux and GOOS=windows go vet ./internal/library: ok;
  gofmt -l clean. Base 18fe1e2dc (fetch failed at commit time).
- Broken by hand: routerCommandsDir returning "" (the old behaviour)
  turns TestSkillRouterKeepsSlashCommands red.
- Real Claude Code 2.1.316 in a sandbox HOME, magpie built from this
  tree placing two skills (okapi, zebu) with the router on, through a
  recording proxy to the gateway (auto/claude-haiku-5-5): the / menu
  lists /okapi and /zebu with their descriptions; "/okapi" answered the
  codeword from okapi's SKILL.md; "Use my zebu skill." went through
  magpie-skills and answered zebu's; every run's first request has each
  description once, in the router's own line, none from a stub. Router
  off: both stubs gone, links back, settings.json's rules gone.

Not tried: Windows and Linux Claude Code (the path is the same
filepath.Join; Windows rules use claudePath already). The Library's
"keep direct" tooltip still says "to type it as /name", which stays
true for the other agents.
2026-11-18 13:43:49 +08:00
yetone 888d4eba52 library: the MCP market puts the most used servers first, counted from the day's report
gugediyige666 and freedomf26 on X asked for an MCP list ranked by
downloads, searchable and installable. Search and install from the list
were already there; skills were already ranked by skills.sh's install
counts. What was missing was a count of who uses each MCP server.

- internal/library/market_public.go: PublicServers names the Library's
  servers that an agent is given and that the market lists from what
  ships with magpie (featured, or the registry snapshot), by market id
  only, matched by serverKey. A bare command names no package and is
  never matched; a server of the user's own, one found only by a
  search, and its address, command or keys never go.
- internal/stats/plugins.go: the day's plugin report carries them as
  "servers" (at most 50), and goes when either list has something.
  PluginCounts returns a Board with plugins and servers.
- site/pluginstats.js: servers are kept as mcp:<id> beside the plugins,
  pruned apart (D1 binds at most 100 values a statement; the test's
  stand-in now enforces that), never liked, and /api/plugins/stats
  returns them under servers.
- GUI: with nothing searched, a server with 20 or more users comes
  first, most used first, with a person chip of its count; the rest
  keep the curated order. Counts are waited for at most a second, so a
  drawn list never reorders; a search keeps the registry's ranking; a
  failed ask is tried again after a minute, not with every search.
- Privacy text: READMEs (en, zh), site privacy and start pages (en, zh,
  ja), reference.md, the Settings privacy row (zh, zh-TW, ja, de),
  llms-full.txt and search indexes rebuilt; docs/subsystems/library.md.

Run (mote, rebased on 18fe1e2dc; budget, TestI18n*, i18n-keys, market-used and privacy-usage-stats again at b53e23ba3, ok):
- go test ./internal/library ./internal/stats ./internal/gui (TestPublicServers,
  TestPublicServerIDsAreCatalogIDs, TestSendPlugins, TestPluginCounts,
  TestCoreScriptBudget, TestI18n*): ok. gofmt -l clean; go vet darwin ok,
  GOOS=linux/windows CGO_ENABLED=0 vet of library and stats ok.
- node --test site/pluginstats.test.mjs: 8 of 8.
- GUI, chromium and webkit, en/zh/zh-TW/ja/de: market-used (new, 30 of
  30), i18n-keys, i18n-en-no-cjk, market-*, plugin-market, privacy-*,
  library-pi-market: 284 of 284.
- Broken by hand: matching a bare command made TestPublicServers name
  "bare-one"; turning byUse off made market-used red. The old single
  DELETE of 100+ bound values made the new site test red.

Not run before the push: the full Go suite and the whole GUI suite.
mote and mica were both running other sessions' full and GUI suites
(load 45 to 270); they run after, on mote. Not tried: a real day's
report reaching usemagpie.ai from a live install (the worker is
checked with curl after deploy).
2026-11-18 13:39:27 +08:00
yetone de321cc92e gui: Settings' search finds by a part's name, unfolds an Advanced around a hit, and reaches the settings sheets build
Three gaps in Settings' search (the UI/UX scan's item 12):
- every part matched its tab's id too, so "usage" brought all of
  Allowances (id usage), rows that never say it included. A part is now
  found by its name; Observability still answers to "otel".
- a hit under a folded Advanced (Network and sharing's Name) stayed
  folded, so the part showed with nothing in it to see. It is unfolded
  while the search lasts and folded again when it ends (setFolds, in the
  lazy provlinks.js, so the core grows by two calls).
- what an agent's sheet or the Claude editor draws only when opened
  wasn't in the page to be found: Claude Code's prompt cache (main and
  subagents), its commit signature (Co-Authored-By), an agent's own
  fields (permission mode) and the Claude editor's run mode (claude -p).
  Each has a link row now, in the agent's or provider's name; Open opens
  the sheet or editor and lights the row, again if the editor draws it
  anew once the provider list is in (lightWhen).

docs/subsystems/gui-shell.md says so.

Run (mote, at this tree, rebased on origin/main 98355866f):
- settings-search-reach (new), settings-search, provider-prefs,
  provider-prefs-layout, settings-groups, settings-back,
  settings-tabs-stick, settings-hints, i18n-keys, gui-de, claude-mode,
  claude-cache, claude-attribution, claude-permission-mode,
  claude-lean-prompt-setting, claude-extra-usage-setting, agent-prefs,
  sync-own-fields, update-row-steady, win-caption; Chromium and WebKit,
  every language: 349 of 355 pass. The 6 red are settings-groups' "warm-ups
  and check-in" (an extra "Spend extra usage" row), red the same on
  origin/main 98355866f and filed as #6597.
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS':
  ok, no budget raised.

Broken by hand, each red in both engines and every language (12 of 12),
then put back:
- the old code (origin/main): "usage" brings Menu bar cost.
- the tab's id put back in a part's words: the same.
- setFolds' unfold removed: "its Advanced unfolded".
- the fold-back on clear removed: "folded again after the search".
- sheetLinks not called: "Co-Authored" finds nothing.
- the run mode's link left out: "claude -p" finds nothing.
- lightWhen lighting only its first find: the editor's run-mode row is
  never lit (the editor draws it anew).

Not tried: the real app window; agents other than Claude Code with own
fields (the rows come from the same a.own list).
2026-11-18 13:16:18 +08:00
yetone 74bba1fa67 gui: Settings › Version and the tray restart magpie with no update (yansheng1003 on X)
yansheng1003 asked for a Restart beside Check: "每次改了需要重新magpie,
都要自己退出再启动麻烦". The Version row now has Restart after Check
while no update is on offer (found, downloading, downloaded, blocked, a
newer version named or a failed download each have their own buttons,
which restart through the update and fill a 420px row), and the tray's
Restart magpie is always shown:
with an update ready it installs it as before, with none it starts this
magpie again as it is.

Both go through restartSelfNow (restart.go), the updater's own way of
starting again: on macOS and Linux the gateway's socket is handed over
(beginHandover), so requests in flight carry on; otherwise the bundle or
binary is started again (update.Relaunch, relaunchBinary), and on
Windows requests in flight are cut. magpie web runs itself again in
place. POST /api/restart answers 204 and then quits, or 400 "magpie
couldn't start again: quit it and open it again", and the row says
Couldn't restart magpie with the reason and gives its buttons back.
/api/update now says its run (the time this process started), so a
browser's page reloads once another run answers.

The click, its error and the reload are in versionrow.js, imported when
Restart is pressed. The mirror's Download from GitHub click moved there
too, so app.js stays under its budget with no raise (TestCoreScriptBudget
at 1,088,248 and 1,272,581, as they were). The route is named in the
CLI's notYet list. Words in en, zh, zh-TW, ja and de.

What needed a restart before, besides an edited path plugin (the commit
before): most settings already applied live (proxies, OTel, HTTPS/mTLS,
LAN from the GUI, allow-lists, CORS, shortcuts, tray, language, name,
fonts, port, hand-edited caller-keys, oidc-rules and library.json).
Still start-only: LAN switched by hand in settings.json, environment
variables, and in-memory routing state such as a rate-limited account's
order; Restart is for those.

Run:
- Full Go suite (mote, -timeout 45m) at the head before the rebase and
  before versionrow.js: 101 packages ok; the reds were
  TestEveryRouteHasACommandOrIsNamed, TestEveryRouteIsNamedForTheCLI
  (the route unnamed) and TestCoreScriptBudget, all fixed here.
- At this head (mote): go test ./internal/gui -run
  'TestCoreScriptBudget|TestEveryRouteIsNamedForTheCLI|TestRestart|
  TestUpdateSaysItsRun|TestTrayMenu' ok; ./internal/cli -run
  TestEveryRouteHasACommandOrIsNamed ok. go build, go vet, GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./... ok; gofmt -l
  clean.
- GUI (mote, both engines, at this tree): update-*.test.cjs,
  version-restart, settings-update-source, refresh-page, old-webkit,
  i18n-keys and i18n-en-no-cjk: 628 pass, then 6 red in update-check
  (Restart not dimmed while a check runs), fixed here (Restart dims
  with Check); update-check, version-restart and old-webkit again: 90
  pass, 0 fail.
- Real restart (mote, sandbox HOME): a built magpie web with
  MAGPIE_WEB_KEY, signed in through ?k=; POST /api/restart answered 204,
  the same pid ran again with a new run, and the cookie still signed in.
- Broken by hand: restartAppFrom returning true on an error, and
  TestRestartStartsMagpieAgain is red; version-restart.test.cjs on the
  old app.js is red (21 on chromium); with Restart shown beside an
  update on offer again, "no Restart beside an update on offer" is red
  in all 5 languages and both engines (12 fails).
- The whole GUI suite is still running on mica at push time; its reds
  are compared against origin/main and fixed or filed after.

Not tried: the tray item and a restart in the real macOS, Windows and
Linux apps (only magpie web was restarted for real).
2026-11-18 12:58:38 +08:00
yetone 95a7c70a63 docs: a plugin added by its path is loaded again when its files change
The design reference for the commit before this one: seenStamp, pathsStamp, what is left
out and how often it is walked.
2026-11-18 12:58:38 +08:00
yetone b0c2b5e261 gui: a page left out of the sidebar still opens from a link, ?view= or a search hit
Settings › General › Sidebar pages (magpie.navHidden) took a page out of
the sidebar, and offView then sent every way to it (a link, ?view=, a
Settings search hit, a plugin's show()) to Agents or Providers with
nothing said, so the page was unreachable. offView now redirects only a
page gateway mode or a switched-off built-in plugin leaves out. Hiding
stays a sidebar choice: the window's own kept page (magpie.lastView)
isn't reopened when it is hidden, so a fresh window still opens on the
first page, or Providers when Agents is hidden too (keptView in
start.js).

nav-pages-hidden: with Library hidden, show("library") and ?view=library
open Library; a kept lastView of library opens Providers.

Run (mica, at this tree; mote at load 27):
- nav-pages-hidden, nav-pages-order, last-page, gateway-mode, Chromium
  and WebKit: 19 pass, 1 red, last-page WebKit, red the same on
  origin/main and filed (#7033).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.

Broken by hand, each red, then put back:
- the new test on origin/main's app.js and start.js: 2 of 2 red (line
  69, Library not opened), both engines.
- keptView without the navMine check: Chromium red at line 76 (the
  window reopened the hidden page).

Not tried: the real app window, the full GUI suite.
2026-11-18 12:31:23 +08:00
yetone e1e454398e agent, gateway: the web search path is Settings › Models › Web search
dsh's and DS Bot's "nothing to search with" notices, and the gateway's
"searcher picked in Settings" errors, sent people to Settings › Web
search. There is no such tab: Web search is a section of Settings ›
Models. The notices in every language, the gateway errors, the DS Bot
docs page (en, ja; zh says no path) and the subsystem docs now name the
real path. llms-full.txt, the search indexes and docs-index.sums are
rebuilt with `node docs-index.mjs`.

Run (mica, at this tree):
- go test ./internal/agent -run 'Dsh|Dsbot|Notice': ok
- go test ./internal/gateway -run Search: ok
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS|Search': ok
- site: node --test search.test.mjs: 6 pass
- GUI: i18n-keys.test.cjs: 4 pass

Not broken by hand: a text change, with no test that names the path.
Not tried: the real app window.
2026-11-18 12:28:47 +08:00
yetone 32a1818681 provider: an AI Studio key decides with Google's gemini-decision-1 (WangYeruo on X)
WangYeruo (v0.1.4401) has a Google AI Studio key's provider, the google
preset. magpie's System One asked for google/gemini-decision-1 fell to
OpenRouter's decision list, because the google provider had no decision
API, and the user's own attempt got Google's 400 "type parameter is
required at input[0]" for an object input.

Google's Decisions API (launched 11-11, aistudio.google.com/docs/
decisions-api, api-reference/decisions/create-decision) serves
gemini-decision-1 at POST generativelanguage.googleapis.com/v1beta/
decisions on any AI Studio key, free tier included, with the key as
x-goog-api-key. It takes System One's questions (noul, choice, score),
an input of text or content blocks, and answers by name with usage
total_input_tokens / total_output_tokens.

- normalize gives a provider asked at the Gemini Developer API (the
  google preset's OpenAI-compatible base or a native Gemini base) its
  System One at AIStudioGemini (googleDecisions). Not Vertex, not a
  signed-in account, not another magpie, and a URL the user gave is kept.
- ViaGoogle: /decisions, signed as Gemini (x-goog-api-key, never Bearer;
  DecideProtocol), in AskSystemOne, the list and key checks, and the
  gateway's postDecideSent.
- googleAsk: the state goes as input (a string as it is, an object as
  its JSON text, never an object, which Google reads as a block), images
  as image blocks after it, a choice's null description as "".
- DecideResult: the usage comes back as System One's input_tokens /
  output_tokens; prompt_feedback.block_reason with no answers is a 400
  that says why. Every other way of asking is unchanged (tested).
- gemini-decision-1: 262,144 context, takes images, so the gateway lets
  images through to it as it does for the Clef.
- docs/subsystems/providers-accounts.md says so.

Tests, from Google's documented request and answer bytes, no network:
TestGoogleDecideWire, TestGoogleKeyDecides (with OpenRouter's live list
holding google/gemini-decision-1 seeded: it now routes to google),
TestGoogleSystemOne, TestGoogleDecisionsTakesImages.

Broken by hand, each red: the normalize fill dropped (KeyDecides,
SystemOne, TakesImages red); googleAsk skipped (Wire, KeyDecides,
SystemOne, TakesImages red); signed as Chat/Bearer (KeyDecides,
SystemOne, TakesImages red).

Run at this head:
- gofmt -l internal/: clean. go vet (provider, gateway), GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./... on mote: ok.
- Full suite on mote at 6317fd789 (this change on 7707ba9ad+f4b202030):
  go test -count=1 -timeout 45m ./...: 103 packages ok, exit 0, no FAIL.
- Rebased onto bf1b2893d (GUI and docs only since: app.js, two GUI
  tests, skill-router.md; nothing this change reads), then at this head
  on mote: go test -run 'Google|Decide|Decision|SystemOne|Ark'
  ./internal/provider ./internal/gateway: ok. The whole internal/provider
  package was also ok at 6317fd789 (155s).
- No GUI file changed, so no GUI suite.

Not tried: a real call. No AI Studio key is in magpie's accounts here.
2026-11-18 12:08:46 +08:00
yetone 2c748531a6 docs: skill router, Alma keeps its own magpie-skills first (#5722)
Tried with a real Alma 0.4.738 (/Applications/Alma.app copied to mote,
started with a sandbox HOME, its userData under that HOME, port 23001
free there). magpie at origin/main f4b202030 set up the sandbox through
library.CreateSkill / SetSkillRouter / SkillRouterHow (a throwaway
driver, not committed): only-alma ticked for Alma, only-claude for
Claude Code, both-agents for both, router on. Alma's /api/skills:

- Router on for both: one magpie-skills, source personal, listing
  both-agents and only-alma. Claude Code's entry is dropped, so neither
  failure the issue guessed at happens.
- Alma's skills kept direct (no entry in its folder): both-agents and
  only-alma as their own skills, plus Claude Code's magpie-skills
  (source claude-code) listing only-claude. That is what Alma got before
  the router too, through Claude Code's links; Alma reads that folder
  by design (#824) and can turn it off.

This matches loadSkills in Alma's skillsManager.ts (personal >
claude-code > codex > agents). No code change. Not tried: a chat turn
(no model account on mote), Codex's folder, Windows and Linux Alma.
2026-11-18 11:41:58 +08:00
yetoneandSuge8 f4b2020306 claude: a client's tool call is waited for however long it takes, never moved to the background at 120s (#6034, FunnyPartMent on X)
#6034 (Suge8) and FunnyPartMent on X: interactive Claude Code moves an
MCP call still running after 120s to the background (2.1.316's
getMcpAutoBackgroundMs: 120000 by default, behind
tengu_mcp_auto_background) and tells the model "It was moved to the
background as task ... You can keep working in the meantime". Every
client tool magpie hands the bridge is such a call.
- Pi's long tool runs: the model wrote its next step without the result,
  and the turn's reply was a tool_calls finish with no calls; the run
  went on calling tools no one was shown.
- Pi's ask_user_question waiting on its user: the model wrote a bash
  call past it that no client runs. The answer reached the run at once
  but the model only when that bash call was moved to the background
  too, its own 120s later (~113s after the answer).

Change (Suge8's branch fix/claude-mcp-wait, ported): claudeRunEnv sets
CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS=0 and CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUT=0
(claudeToolWaitVars) unless magpie's environment sets them, for -p and
the interactive mode alike, and claudeEnvVars hands both to a run in WSL.
0 also turns off the move made to hand over a message that arrived
mid-call (isMcpCallMovableWithoutTimer reads the same value), and the
idle limit no longer aborts an answer that took over 30 minutes. One-off
runs (model test, warm-up, /usage) make no MCP calls and are unchanged.
The subsystem page says why, with the measurements.

Reproduced (Claude Code 2.1.316, sandbox HOME and CLAUDE_CONFIG_DIR, a
fake Anthropic API on 127.0.0.1 and a stdio MCP server whose "wait"
answers after 10s and "bash" after 100s; no real account):
- interactive mode, limit 3000: wait moved at 3s, the model called
  bash, bash moved at 3s, the result came only as a task notification.
- -p with CLAUDE_AUTO_BACKGROUND_TASKS=1, limit 8000: wait moved at
  8.0s, bash called, next model request at 16.0s, 6s after the result
  was in (the 113s, scaled).
- limit 0, both modes: the model's next request at 10.0s carried
  "late-result", no bash call made.

Run (on mica, Go 1.26.8, at this change on 53db3e389; the four tests
above again at this head, rebased on 7707ba9ad: ok):
- red on the old code: with claudeRunEnv's append taken out,
  TestClaudeRunWaitsOnToolCalls fails all four subtests (tui=false and
  tui=true, "run's environment, want \"background 0 idle 0\"");
  with the two names out of claudeEnvVars TestClaudeToolWaitVarsReachWSL
  fails ("CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS isn't in claudeEnvVars").
  Both pass with the change, beside TestClaudeRunReadsItsFlags and
  TestCleanClaudeEnvRemovesGatewayOverrides.
- gofmt -l empty; go vet, GOOS=linux go vet -tags nogui and GOOS=windows
  go vet of internal/gateway; go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build: ok.
- go vet ./... (3 OSes) and go test -tags nogui -timeout 45m ./... in a
  sandbox HOME: running on mica at push time; result goes on #6034.

Not tried: a real Claude subscription turn from Pi through a rebuilt
magpie with a tool of over 120s; the real 120s default (measured with
3s and 8s limits).

Co-authored-by: Suge8 <nnyless@foxmail.com>
2026-11-18 11:32:58 +08:00
yetone 7707ba9adb sessions: a compaction that doesn't fit its line goes as text, never as magpie's seal (hey_boyce on X)
hey_boyce on X: Codex, talking to OpenAI itself, got 400
invalid_encrypted_content "The encrypted content for item
cmp_magpie_1794916786407450000 could not be verified".

Cause: PortCodexRollouts writes magpie's compaction item (magpie1:
base64 summary) as Codex's own summary message, keeping each line's
length, since a paginated rollout keeps places by byte. A message
longer than the line (a short summary under Codex's ~400-char prefix)
was left as it was, so the magpie1: seal stayed in the rollout, Codex
replayed it to OpenAI every turn, and the thread was stuck. The
incremental pass never looked at such a rollout again.

Change:
- fitShorter: when the full message doesn't fit, the summary goes
  under a short heading, then cut to fit (rune-safe, "…"), then
  with no heading. If nothing fits, a standalone item is retired as
  {"type":"magpie_compaction"}, which Codex reads as unknown and
  never sends.
- In replacement_history an unknown item IS sent (as "other"), and
  OpenAI refuses it ("Invalid value: 'other'"; seen with real
  codex-cli 0.165.0 and 0.169.1). So a compaction or reasoning item
  retired there is left out with its metadata entry, and
  magpie_reasoning items main's PortCodexRolloutsLeft already wrote
  there are taken out (retiredInList). That was a sibling bug: those
  threads failed the same way.
- codex-portable.json gains refit: a state from before makes one
  whole pass again, so rollouts already left with the seal are fixed.
- The gateway's last line: a 400 naming an item of magpie's own
  compaction asks again with its summary message in its place
  (withoutItem), not with the summary dropped.
- codexsummary.Summary decodes the seal; Message uses it.
- docs/subsystems/gateway-routing.md says all of this.

Run (on mica, at this head rebased on a265632da):
- red on the old code, green now: TestPortCodexRolloutsLongerLine
  (short, cut), TestPortCodexRolloutsDropsRetiredFromHistory,
  TestPortCodexRolloutsRefitsOnce,
  TestPortCodexRolloutsLeftRetiresUnsealedReasoning,
  TestRefusedMagpieCompactionGoesAsText (old withoutItem: 2 items,
  the summary gone).
- broken by hand: without `&& was.Refit` RefitsOnce is red.
- real Codex, sandbox HOME with a copy of the owner's ChatGPT auth,
  codex-cli 0.169.1, gpt-6-sol, against OpenAI:
  - the reporter's item (id cmp_magpie_1794916786407450000, summary
    "ok") gave the same 400 word for word. Ported by this code, resume
    answered.
  - an id-less item plus a magpie_reasoning in replacement_history
    (as main left it) failed "Invalid value: 'other'" before. Ported,
    resume answered.
- go test -count=1 -timeout 45m ./internal/codexsummary
  ./internal/sessions ./internal/gateway ./internal/agent: all ok
  (gateway 1026s, agent 221s), log kept in enc-scratch/pkgs.log;
  TestLoopGuard* again after the doc edit: ok.
- rebased on 53db3e389 (stream keepalive; only the doc page is
  shared): the refusal, seal, compaction, LoopGuard and Quiet tests
  in internal/gateway again at this head: ok.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ./... ok.

Not tried: a summary cut to fit with real Codex (the unit test checks
it is a plain user message, the same shape as the case that was run);
a Codex in WSL; the full ./... suite: mote was over its cores and both mote and
mica were running another session's GUI suite, so only the changed
packages and internal/agent, which ports rollouts, ran (above).
2026-11-18 11:16:54 +08:00
yetone 53db3e3891 gateway: a held or relayed stream is kept alive for 30 minutes, then ended with an error (Wing8Aqua on X)
Wing8Aqua on X (magpie 0.1.4111, Ubuntu): asking Claude Fable 5.2 ended
with "pi-ai stream idle timeout after 300000ms". A stream the gateway
passes through as it is (or holds before its headers) got a comment each
keepaliveEvery of vendor silence, but only for keepaliveLongest (5
minutes) since the vendor was last heard. After that the client got no
bytes and no error, so an agent's own idle timer ended it. A translated
stream is already kept alive for translatedQuietLongest (30 minutes), and
the Claude bridge for as long as its Claude Code works (#5043).

holdWriter.keepQuiet now keeps up its comments for translatedQuietLongest.
Past that the vendor is taken as stuck (endStuck): the client gets a 504
"<provider> sent nothing for <d>; the request was ended", as its stream's
error event once the reply has passed or as a status before it, and
serve records the try and tries nothing again after so long a wait.

Note that the reporter's message is DeepSeek Harness's (dsh-llm-pi-ai). Its
watchdog re-arms only on content events, so no keepalive reaches it, and
the 300000 is the route's streamIdleTimeoutMs. magpie writes 600000 into
the dsh routes it makes (dshIdleWait, since v0.1.2464) and keeps a value
already there. This change covers byte-counting clients (pi, Claude Code,
Codex). It does not change dsh.

Tests: TestQuietClaudeStreamKeptAlivePastFiveMinutes (Messages relay,
quiet after message_start and before its headers, keepaliveLongest at
100ms, 1.5s of silence: the client never goes 500ms without a byte, the
reply is whole, and the vendor is asked once) and
TestQuietClaudeStreamStuckEndsWithAnError (silence past
translatedQuietLongest: an error event naming the provider, no reply after
it, one request). TestQuietKeptAliveOnlySoLong now expects the error.

Run at this tree (rebased on a265632da):
- gofmt -l internal/gateway: clean.
- mote-run go vet ./internal/gateway, plus GOOS=linux and GOOS=windows: ok.
- mote-run go test ./internal/gateway -run
  'TestQuiet|TestSilentHeld|TestTranslatedStream|TestKeep|Loop|Slow|Hold': ok.
- wsl-run (Ubuntu 24.04) go test ./internal/gateway -run
  'TestQuiet|TestSilentHeld|TestTranslatedStream|TestKeep|Hold': ok.
- Broken by hand: restoring keepQuiet's keepaliveLongest bound turns
  both new tests (all four subtests) and TestQuietKeptAliveOnlySoLong red.
- Real pi 1.5.2 on mote in a sandbox HOME (httpIdleTimeoutMs 2000),
  through a test gateway to a fake Claude relay quiet for 6s after
  message_start, with keepaliveLongest at 300ms. Old bound: "terminated:
  Body Timeout Error (UND_ERR_BODY_TIMEOUT)". New: "answered". With
  translatedQuietLongest at 1s and the relay quiet 20s, pi prints "Relay
  sent nothing for 1s; the request was ended (504 ...)". This was a
  temporary test, not committed.

Not run before the push: the whole internal/gateway package and the full
suite. mote was at load 20-28 and mica had another session's full suite.
They run next, and any red gets its own issue.
Not tried: real dsh, and a real Fable 5.2 account (the route the reporter
uses is unknown).
2026-11-18 11:08:46 +08:00
yetone ba3a25421b gui: /api/state sends no saved proxy password, LAN key, Bark key or GitHub token
/api/settings strips these (settingsState), but /api/state, which the
window polls after nearly every click, sent settings.Shared() whole, so
every saved proxy's password and key, the old LAN key, the Bark key and
the GitHub token went with it. /api/state?last=1 (the start's read of
the last state) put settings.Load() in whole too. Both now go through
stateSettings. The page reads none of these from the state (grep of
assets: no .lanKey, .barkKey or .githubToken, and saved proxies come
from /api/settings). The kept state file never held settings
(keptFile empties them), so nothing on disk needs rewriting.

Found while writing the saved-proxy Test: a probe of /api/state carried
a saved proxy's password.

TestLastKnownState used the GitHub token as its mark of today's
settings; the theme is that mark now, and the test asks that the token
is not sent.

Run (at this head's tree):
- mote: go test ./internal/gui -count=1 -timeout 45m: ok (182.9s).
- mote: TestStateSendsNoCredentials and TestLastKnownState -race ok.
- Broken by hand: stateSettings' strip commented out, TestStateSends
  NoCredentials red on all four secrets in /api/state and ?last=1.
- mote: Linux and Windows go vet ./... ok; gofmt -l clean.
2026-11-18 06:42:01 +08:00
yetone 97e0ecdaab settings: a saved proxy's Test says its latency and exit region, from Settings and the provider editor (IcyLiqu1d on X)
IcyLiqu1d asked for sub2api-style proxy management: test each saved
proxy's region and latency, then pick a provider's proxy from the list.

- A saved proxy's row in Settings, once tested, reads "Reachable, 42 ms ·
  Japan": the exit's country from Cloudflare's trace page (the endpoint
  the quick check already uses), named in the reader's language by
  Intl.DisplayNames; the exit IP is in the tooltip. A failure says why.
- The latency is the round trip through the proxy, from the request
  written to the answer's first byte (httptrace). The whole request's
  time counted a new connection's dial, tunnel and TLS on a first Test
  and not on a second, which reuses the pooled connection.
- The provider editor's Saved mode has a Test beside the proxy picked;
  its answer is said where the picker's hint is, red on failure, until
  another proxy or mode is chosen.
- An editor opened before Settings was read drew its picker with no
  saved proxies (Saved mode missing, or "A proxy that is gone" for one
  chosen). It now reads the settings and draws the picker again.
- Nothing is tested until Test is clicked; nothing runs in the background.

Run (at this head's tree, rebased on c687dbdc6):
- mote: go test ./internal/gui -count=1 -timeout 45m: ok (182.9s);
  -run 'TestSavedProxy|TestProxyCheck' -race ok.
- mote: GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...
  ok; gofmt -l clean; TestCoreScriptBudget room 21 bytes, no raise.
- mica: provider-proxy-pick-test (new, 20 cases: chromium and webkit, en
  zh zh-TW ja de, 900 and 420px) 20/20; saved-proxies, saved-ssh-proxy,
  provider-proxy, i18n-keys, old-webkit pass.
- mica: whole GUI suite, still running at push: 3736 tests in, 127 red,
  none in a proxy or provider file. The reds are files red on
  origin/main: agent-details-ready and data-folder were run alone at
  c687dbdc6, 14 pass 42 fail (#6369, #6373, #6876); account-refresh-holds,
  account-arrange (#6003, #5814), api-key-theme (#6444) and the rest are
  the files another session is rerunning on mote as main's reds.
- Broken by hand: the round-trip branch off, TestSavedProxyLatencyIs
  TheRoundTrip went red ("took 1601 ms", the fake's 1.5s dial counted).

Tests reach no network: a local fake proxy answers the trace page, the
trace URL is .invalid, and the dial delay is injected.

Not tried: a real proxy's exit (the region comes from Cloudflare's loc=).
Not changed: the global proxy check in Settings still shows the raw
country code (ip (JP)).
2026-11-18 06:42:01 +08:00
yetone a0993ed71d gateway keys: a key held to some models can be given a decision group (Kautism on Discord)
Kautism on Discord, after making a group of Clef and Jev models: "group
似乎不能在閘道金鑰上使用?我翻不到。" The key editor's model list comes from
GET /api/caller-keys/models, which is built from provider.Catalog, and
Catalog keeps decision groups out (no agent chats with one). The gateway
already serves a key that names one (serveDecisionGroup's groupGiven at
/v1/systemone), so a key held to some models could only reach a
decision group through All models.

Now the list puts the decision groups after the chat groups, marked
Group and Decides: only those the gateway serves (not hidden, not
switched off, found by FindGroup), and none twice.

Tests:
- TestCallerKeyModelsOfferDecisionGroups: a decision group is listed
  after the chat group; a switched-off one is not. It fails with the
  new block taken out by hand ("groups offered [group/chat], want the
  chat group and the decision group").
- TestGatewayKeyNamingADecisionGroup: a key given only the decision
  group reaches it at /v1/systemone, and a key given another model is
  refused. This is a guard on gateway behaviour that is already there;
  the gateway code is unchanged.

Run (worktree base 223b900b4, rebased onto 169446a1d, which changes
only the tray files):
- mote: go test -count=1 -timeout 45m ./internal/gui/ ./internal/gateway/
  ok (199s, 988s); go vet for darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok; gofmt clean.
- node --test internal/gui/tests/gateway-key-*.test.cjs: 363 pass,
  11 fail. 10 of the fails are gateway-key-arrange's "dragged into
  order" at 420px, both engines and every language, which are #6268.
  On mica, at load ~5, those two files fail the same 10 at this branch
  and at a fresh origin/main 169446a1d. The 11th (limit-off, chromium
  de 420) passed in the rerun of both files.

Not tried: the editor in the real app with the reporter's group.
2026-11-18 03:48:29 +08:00
yetone 169446a1d7 gui: the Mac's menu bar item takes its clicks from the start, so the first click after a restart keeps the panel open (Refeccd on Discord)
Refeccd on Discord: "每次更新后,第一次在菜单栏点击唤起主界面会出现闪退现象
(实际程序未退出,只是隐藏了)" (macOS, automatic updates).

Cause: 182803ea7 made the panel lazily, on its first open, and
trayOwnClicks (mpOwnClicks, the local monitor that sends the item's
action on mouse-down and drops the event) was installed in makePanel.
So the first click after every start went through the button's own
mouse-down tracking: the panel came up, the tracking loop took focus
back, and HideOnFocusLost hid it at once. Later clicks were fine,
because by then the monitor was in. Every update restarts magpie, so
it showed after each one.

Now trayOwnClicks runs right after the tray item is made, in app.go,
before any click can arrive; makePanel no longer installs it (the
monitor is dispatch_once, so nothing is installed twice).

Run (mica):
- go test -count=1 ./internal/gui/: ok (153.7s).
- Quick tests, go vet (darwin, GOOS=windows, GOOS=linux -tags nogui)
  on mote: ok; gofmt -l clean.
- TestTrayOwnsClicksBeforeThePanel is red with the call moved back
  into makePanel (broken by hand), green with the fix.

Not tried: a real tray click after a restart (no click can be driven
over ssh); the reporter's case is reasoned from the code path above.
2026-11-18 03:34:06 +08:00
yetone 223b900b48 library: a skill from GitHub or git syncs as its source, and what a sync leaves out is said (#5715)
JJasonsun (Discord #help, #5715): a skill over a sync's 64 MiB budget was
left out of the server's file while Settings > Sync said the sync worked,
so the other computer silently didn't have it.

A library skill from GitHub or another git repository whose folder is
still what was fetched (editState known and unedited, or Pending) now
goes as its source, as a plugin does (plugin_carry.go): CarriedSkill
gets Fetch, Hash and Commit, and the receiving computer fetches it
itself after Put lets go of the library lock (fetchSkills, through
updateSkills). Its files still go as far as the room the skills carried
as files leave, so a magpie from before this, which ignores Fetch,
writes the skill as it did.

On the receiving side (fromSourceHere): same version is kept; one
changed here is kept and, when the other computer has another version,
said as a problem ("Update replaces them"); another version or a skill
new here is fetched, unless the carried files are already the whole of
it. A skill that can't be fetched stays Pending, shows "Not fetched
yet" on its Library row, and is said as a problem until Update fetches
it (library.Unsettled drops a settled one).

A skill changed here, one from a folder, and one from a link holding a
token (whose link must not be synced) go as their files, as before.

What a sync still leaves out is said: state.LibraryLeft names skills
and plugins whose files were too big (or that this computer never got,
Skill.Missing, carried on as Left so a third computer isn't told it
has them), state.LibraryProblems what the last sync bringing the
library in couldn't put here. Status gives them as libraryLeft and
libraryProblems, and Settings > Sync shows them in red under the
status (askPreviewRows). Strings in every language.

Run at this head (rebased on origin/main 7b552eef3):
- gofmt -l: clean. go vet darwin, GOOS=linux, GOOS=windows: ok.
- mica: go test -count=1 -timeout 45m ./internal/library
  ./internal/davsync ./internal/backup ./internal/gui: ok.
- mote: node --test in Chromium and WebKit of sync-*, i18n-*, gui-zh-tw,
  gui-ja, gui-de, skill-*, library-items, library-all, library-plugins
  and the new sync-library-left (16/16 in both engines). Red, and red
  the same in a fresh origin/main 7b552eef3 worktree, each filed:
  skill-fold-all (#6667), skill-manual (#6668), skill-group-shared
  (#6687), skill-where's zh 900px under concurrency (#5859).
- The first package run at this head had TestSkillCarriedBySource and
  ...NotFetched red: InstallSkills took another test's cached probe of
  owner/repo (SKILL.md only). carrySource now forgets the probes before
  and after; ./internal/library ok again, once more with -shuffle=on.

Broken by hand, each red: bySource always false (5 library tests),
fetchSkills removed (library + davsync), changedHere removed, Missing
not carried on, Unsettled removed, Pending not set in Put, signedIn
check removed from Collect and from Put (TestSkillSignedInLinkGoesAsFiles),
leftOut returning nil, Fetch not excluded from leftOut.

Not tried: a real sync between two computers with a real >64 MiB skill
from GitHub; the tests use a local git repository as the source. A
restore (backup.Restore through the restore and plan paths) carries
skills by source too but doesn't record LibraryLeft/LibraryProblems
yet (said in sync-backup.md).
2026-11-18 03:05:47 +08:00
yetone b2b3d488c1 settings: an SSH server as a saved proxy, and a failed proxy says why
@laiuuui on X (tweet 2122704105005314155) was told to put Gemini behind
a proxy in a supported region. Their VPSes give only SSH (address, port,
password or key), and every http:// proxy they added failed with Go's
words alone.

A saved proxy can now be an SSH server. Settings > Network > Add proxy
has Proxy | SSH; SSH asks for the server, the user and the password, and
Advanced (closed) holds a private key and the trusted host key. magpie
logs in itself with golang.org/x/crypto/ssh (no ssh command) and resolves
the @id to a SOCKS5 server of its own on loopback, which takes only its
own random login and carries each CONNECT as a direct-tcpip channel, as
ssh -D does: lazy login, keepalive@openssh.com every 20s, one re-login
when a channel finds the connection dead.
- Save logs in first: a refused login is said there and nothing is kept.
- The host key is trusted on first use, kept in authorized_keys form and
  shown as its SHA256 fingerprint; another key is refused
  (HostKeyChangedError, both fingerprints said) until Trust a new key.
- The key is a secret like the password: left out of backups and
  syncs without keys, kept on a sync that has none.
- ssh:// typed as a plain address is refused: its login goes with a
  saved proxy.

A failed proxy says why (netproxy.Why: an English template the page
translates in all five languages, Go's words after it): an SSH server
typed as http:// or socks5:// ("is an SSH server, not a proxy: add it as
SSH"), a refused login, keyboard-interactive refused (OpenSSH without
PAM, "unexpected message type 51"), nothing listening, not SSH, TLS on a
plain proxy, 407, timeouts, hangups, and a server that logs in but won't
forward (AllowTcpForwarding no, or macOS 27's sshd, which hangs up on
every forward, OpenSSH's own ssh -W too). A check the user asks for
reads the server's first bytes when Go's text can't tell: Go reads a
real OpenSSH banner ("SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.20") as an
HTTP status line with a malformed code, and an SSH server's banner can
reach Go's transport before its request goes out
("readLoopPeekFailLocked", found red 1 of 20 on mica, then 40 of 40
green). Each save is tested at once.

app.js keeps one line (api() hands a proxy_why reply to proxies.js,
where proxyWhy now lives); both script budgets are raised by that line's
52/54 bytes, with the reason in core_budget_test.go.

Run (mica, at this head on origin/main 81c666e1c):
- go test -tags nogui ./internal/netproxy/... ./internal/settings/
  ./internal/davsync/ ./internal/gui/ ./internal/provider/
  ./internal/backup/...: ok
- GOOS=linux and GOOS=windows go vet of netproxy, settings, gui; gofmt -l
  internal: clean
- GUI, chromium and webkit, en/zh/zh-TW/ja/de, 1100 and 420px:
  saved-ssh-proxy, saved-proxies, i18n-keys, provider-proxy-missing:
  64/64
- Tests use netproxy/sshtest, an SSH server on loopback that answers
  channels itself; nothing reaches the network.

Broken by hand, each red: accepting any host key
(TestSSHProxyRefusesAChangedHostKey); no login check on the SOCKS end
(TestSSHProxyLocalEndNeedsItsLogin); no SSH banner case and no banner
probe (TestProxyFailureNamesAnSSHServer, its OpenSSH-banner case); no
type-51 case (TestSSHProxySaysWhyItFailed, keyboard-interactive); no
code 2 for a hangup (TestSavedSSHProxyThatWontForward, both cases);
api() not handing proxy_why to proxies.js (saved-ssh-proxy, 20 of 20
cases red: err.why is already a failed move's reason).

Real use: Ubuntu 24.04 OpenSSH_9.6p1 (WSL magpie-desktop, a user sshd
on loopback, key login): the host key was learned, a Cloudflare trace
through the tunnel came back ip=104.194.93.45 loc=US, a wrong password
said "turned the login away", a changed host key said both
fingerprints, and http:// and socks5:// pointed at the sshd both said
"is an SSH server". mote's and mica's sshd (macOS 27, OpenSSH 10.5 and
10.3) log in and refuse every forward, now said as "won't forward
connections".

Not tried: a password login against a real sshd (the user sshd had no
shadow access), a real VPS, and the full go test ./... and full GUI
suite: both mote and mica were running other sessions' GUI suites the
whole time.
2026-11-18 01:01:30 +08:00
yetone 81c666e1c2 gateway: an advisor call Anthropic's server ran is a usage row of its own (#6977)
A Claude Code turn relayed on Messages with its advisor on has the advisor
run at the vendor. The reply's top-level usage is the executor's alone;
each advisor call is an advisor_message entry of usage.iterations, billed
at the advisor model's rates (Anthropic's advisor tool page, "Usage and
billing"). magpie read only the top level, so an Opus advisor beside a
Sonnet executor was in no row and priced nowhere.

aUsage reads iterations, whole and from a stream's message_delta (whose
list is cumulative, so the latest stands for the reply). Each advisor call
becomes its own row (advisorRows, written by appendAdvised at every row of
a try that reached a provider, and on the native route): under the
advisor's model by magpie's id (advisorKeyModel of the request's advisor
tool), Served as the vendor names it, Kind "advisor" (named Advisor in
Usage's filters, already translated), the request's route, agent, account
and session, status 200, counted as its own request as magpie's own
advisor calls already are. The executor's row is unchanged. Routing prices
the calls too, before the request's own usage so the prompt is still read
from the last entry. Iterations with no advisor entry (Copilot) leave
Usage as it was.

The fixture is Anthropic's documented example word for word; no real
reply with an advisor call was captured.

The core script budget is raised by 52, the Advisor entry in the
generated purposes.js (the base had no room; 1 byte less is red). The
kinds are read wherever Usage and Routing draw a row, so there is no page
to move it to.

Run at this commit's tree on f1b0663f1, then on b1f044fc1 (which changed
core scripts only, i18n.js and syncfiles.js, so internal/gui and the GUI
files were run again there):
- mica: gofmt -l (nothing), go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet for internal/gateway, internal/usage, internal/gui: ok.
- mica: go test -timeout 45m -count=1 ./internal/gateway ./internal/usage
  ./internal/gui: ok (916s, 64s, 161s).
- mote: node --test purpose-filter, routing-purpose-state, usage-big-write,
  usage-ledger-mcp, usage-ledger-search, i18n-keys (Chromium and WebKit):
  74 of 74 pass.
- On b1f044fc1, the pushed base: mica go test -timeout 45m -count=1
  ./internal/gui ok (147s); mote the same six GUI files, 74 of 74 pass.
- Before the rebase, at ae94571d7, the same packages on mote were ok
  except TestCoreScriptBudget, which this commit's budget line answers.

Broken by hand:
- aUsage.usage never setting advised: TestAdvisorIterationsRead red
  ("stream=false: advisor calls <nil>, want one"), TestAdvisorCallHasItsOwnRow
  red in both subtests ("advisor rows: []").
- passthrough without advisedAs: TestAdvisorCallHasItsOwnRow red in both
  subtests, the row named claude-opus-5-5 and not magpie's claude-opus-5.5.

Not tried: a real Anthropic reply with an advisor call (no account with the
advisor beta at hand); Bedrock and Vertex passthrough with an advisor
(they share the sniffer, not run); the Usage page with an advisor row in a
real browser session beyond the GUI files above.

Reported by Refeccd on Discord.
2026-11-18 00:38:36 +08:00
yetone b1f044fc1e library: a Claude plugin goes to another computer whole, its hooks naming that computer's folder (#6685)
A plugin installed from Library > Claude plugins didn't reach the other
computer by sync: the bundle carried its parts as plain items, with
${CLAUDE_PLUGIN_ROOT} already resolved to the first computer's
<library>/plugins/<name>, and neither the plugin record nor its folder.
Hooks there pointed at a path that doesn't exist, Windows' too.

Now Bundle.Plugins carries each plugin's record (name, version, source,
pick, agents, Off, parts taken out by hand) and never its parts:
- A GitHub or git link goes as its source. The receiving computer
  installs it from there, as UpdatePlugin does, after the library's lock
  is let go. Re-installing from the source was chosen because the files
  stay the vendor's and an update keeps working there; a fetch that
  fails keeps the plugin Pending (shown on its row, "Update tries again")
  with a problem, and the next sync or Update tries again.
- A plugin from a local folder, or from a link holding a token (whose
  link must not be synced), goes with its files on the skills' budget,
  executables kept executable, and is installed from them.
- Either way the parts are read again there, so every hook, server and
  skill names that computer's own plugin folder. A plugin the bundle no
  longer has is removed with its folder; Off spreads.
- A bundle from an older magpie has no plugins list: this computer's
  plugins keep their parts over the same-named items it carries.
- An empty list hashes as before, so computers without plugins don't
  see a change; the preview names each plugin, its files as one digest.
- Sibling: a plugin installed from a marketplace under a name other
  than its manifest's named the manifest's folder in its parts.
- The sync settings' text says Claude plugins go with the Library (en,
  zh, zh-TW, ja, de); "Claude plugins" moved into the core i18n.js since
  the core now says it.

Run at this head (54e682dc5's tree on f1b0663f1, mote):
- go test -tags nogui -timeout 45m ./internal/library ./internal/davsync
  ./internal/backup: ok
- gofmt -l: empty; go vet GOOS=darwin (library, davsync, backup, gui),
  GOOS=linux -tags nogui ./..., GOOS=windows ./...: clean
- Windows (win-run, xiaomi-gpu): go test ./internal/library -run
  TestPlugin and ./internal/davsync -run Plugin: ok. The hook there names
  B's C:\...\plugins\kit/bin/done (TestSyncLibraryPlugins first failed
  on Windows for the test's own path form; fixed in the test).
- GUI, Chromium and WebKit, every language the files test:
  library-plugins, library-items, agent-plugin-agents, i18n-keys,
  i18n-en-no-cjk, old-webkit, every sync-*, github-sync, s3-sync,
  auto-backup: 337 pass, 1 fail: webkit en "S3 sync settings", red the
  same at origin/main f1b0663f1 (#2448, #3413, open).

Broken by hand, each red, then restored:
- parts not skipped and Plugins not set in Collect:
  TestPluginCarriedWhole, TestPluginCarriedBySource,
  TestSyncLibraryPlugins
- held.without dropped: TestPluginOldBundleKeepsPlugins
- fetchPlugins dropped: TestPluginCarriedBySource
- marketplace name fix reverted: TestPluginMarketplaceNameIsItsFolder
- empty list not hashed as none: TestNoPluginsHashAsBefore
- TestPluginFromFilesEitherOS guards that a Mac path is files on
  Windows and C:\ on a Mac; it passed without a new check (such paths
  are no git source), so none was added.

Not tried:
- a real two-computer sync through the GUI, Mac to Windows;
- a local marketplace entry's own fields (strict: false) aren't carried,
  so there it is read from its files alone;
- a private git source over ssh on the receiving computer.

Reported by JJasonsun on Discord; issue by JJasonSun (#6685).
2026-11-18 00:24:41 +08:00
yetoneandmdwsk88 0bad752415 claude-desktop: a session on a tier's pick the catalog leaves out for now stays on the pick, not on another session's model (#6748)
Claude Desktop names a Claude model with reasoning levels by magpie's own
id for it (claudeLooking: magpie-<n>.anthropic.claude-opus-5-5), and
aliased read <n> back from the catalog alone. When the model was out of
the catalog for a while, the id stayed as asked, unserved took it for a
model magpie doesn't serve, and desktopMoveTo's gone branch served it on
desktopPicked: the model of the last tool turn of any Desktop session.
Copilot's /models once answered without its three Claude models and the
list was kept for an hour; three sessions on Copilot's Opus 5.5 were
answered by another provider's model for 25 minutes, with Desktop still
saying Opus (desktop-gone in the Routing rows).

- aliased: after the catalog, the models picked for Desktop's tiers
  (DesktopTiers) are matched by <n> too, a later tier's number
  (desktopTierKey) by whichever tier. A pick so read back goes to its
  provider as asked. A routing group's id is skipped (#6719).
- desktopTierTurn: an id of magpie's that still names no model but names
  a Claude model (aliasClaude) goes to the pick for that model's tier
  (desktop-tier), as Claude Code's own id of one does.
- The routing reference states the rule.

Ported from mdwsk88's reference commit 68f39e8ae (branch
desktop-alias-tier-pick on mdwsk88/magpie, patch sha256[:16]
a7b9dee0d26cdcbc, matching the issue). Reviewed line by line; code and
tests taken as written, only the routing doc hunk re-placed onto current
main. Thanks to mdwsk88 (dawei) for the report, the logs and the fix.

Siblings checked: desktopPicked is read by desktopMoveTo (gone, title,
aside branches) and desktopChosen's probe path (served picks only);
aliased is reached through unprefixed and DesktopCatalogID
(internal/agent's Desktop settings), which now also read a pick back.
Left as they were, filed as #6983: an unresolved alias of a model that
is no tier's pick (mythos-magpie-<n>, or a Claude alias whose tier has
no pick) still goes to desktopPicked, and Claude Science's scienceTurn
has the same fallback to sciencePicked.

Run on mica, sandbox HOME with Go's caches pinned, at this head
(rebased on 50c5a52db):
- gofmt -l on the changed Go files: no output.
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  ./internal/gateway/ ./internal/masking/: ok.
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway/
  ./internal/masking/: gateway ok (932.6s), masking ok (6.5s).
  (masking reads the routing reference). Same green at the earlier base
  a922e3864 (934s) and 4a1ac8442 (943s).
Red on the old code (origin/main's desktop.go, aliasClaude stubbed to ""
so the tests compile), on mote: TestDesktopAliasOfTierPickLeftOutOfCatalog
(aliased/unprefixed keep the alias), TestDesktopClaudeAliasGoneTakesItsTier
(went to "other/some-model" by "desktop-gone") and
TestDesktopAliasLeftOutRoute (the opus session's turn sent upstream as
"some-model"); all four green with the change.
Broken by hand, each red: group skip removed
(TestDesktopAliasSkipsGroupPick: "a deleted group's alias read as
group/gone"); aliasClaude fallback removed from desktopTierTurn
(TestDesktopClaudeAliasGoneTakesItsTier); later tier's number not read
(TestDesktopAliasOfTierPickLeftOutOfCatalog).

At the pushed head (rebased onto 4b8c5948e: 6c6d3bc84 changes Codex search in
internal/gateway, 4b8c5948e GUI files only), on mica:
- at 7ba7f26e8 (parent ae94571d7): go test -timeout 45m -count=1
  ./internal/gateway/ ./internal/masking/ ok (gateway 1013.2s, masking
  6.6s); go vet ./internal/gateway/ for darwin, linux and windows ok.
- after the rebase: go test -run "Desktop|CodexSearch|WebRun"
  ./internal/gateway/ ok; vet for darwin, linux and windows ok; gofmt -l
  clean.

Not tried: a real Claude Desktop session while Copilot's list lacks its
Claude models (the route test through Server.Handler stands in);
go test ./... and the GUI suite (no GUI file changed; both machines were
running other sessions' full and GUI suites).

Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
2026-11-18 00:04:34 +08:00
yetone 6c6d3bc842 gateway: Codex's web.run goes to a relay set to search by itself (YIXIE233 on X)
YIXIE233's GPT relay serves /v1/alpha/search itself, but Codex's web.run
(<base>/alpha/search) only went upstream for ChatGPT accounts; for every
API-key provider magpie ran its own searcher. The per-provider "Searches
the web by itself" switch (search=yes, Advanced > Web search, default
off) already sent Responses' web_search tool and Claude's WebSearch
through as sent; now it covers web.run too.

- relaySearchers resolves the model's provider, or a routing group's
  members in order (the leading candidate decides, as for the request).
  A provider qualifies when it has search on, is an API-key provider
  (not a ChatGPT account, not a plugin) and has a Responses base.
- The search goes to that base's /alpha/search with the provider's key,
  Codex's headers, originator and the agent's User-Agent.
- If the relay fails, magpie searches in its place and the output says
  "X's web search failed (why); magpie searched in its place."
- Settings' "magpie searches for every model" still overrides it.
- GUI help text, every language, names web_search and web.run; the CLI
  help, docs/reference.md and docs/subsystems/gateway-routing.md say so.

Tests: TestCodexWebRunGoesToRelayThatSearches and
TestCodexWebRunInGroupFollowsLeadingMember are red on the old code
(magpie's searcher answered). TestResponsesWebSearchToolToRelayThatSearches
guards the web_search pass-through. provider-search.test.cjs covers en,
zh, zh-TW, ja, de in both engines and at 400px (no sideways scroll).

Run (mica): gofmt clean; go vet, GOOS=linux and GOOS=windows vet ok.
Full go test ./... -timeout 45m before the rebase: 102 packages ok, only
internal/gui TestCoreScriptBudget red (app.js 22 bytes over); fixed by
shortening the English help key (net -2 bytes), budget not raised.
At 64c5e1e0a (on origin/main d4af0ca4f; then rebased over ae94571d7, a Library change, and the gui budget tests rerun ok): internal/gateway,
internal/gui and internal/cli ok; provider-search, i18n-keys and
images-codex-one GUI files 72 pass, 0 fail.
Whole GUI suite (two runs on mica, under other sessions' load): reds in
30 files, none touched by this change. The 26 files run alone on
origin/main d4af0ca4f are red there too (154 tests; filed in #6975,
#6934, #6709); header-centre (#3479) and icon-tile (#6759) are red on
main too. images-codex-one was red only under load and passes alone
at the pushed head.

Not tried: a real relay serving /alpha/search (tests use a local fake);
a plugin-served provider (excluded on purpose).
2026-11-17 23:50:29 +08:00
yetone ae94571d70 library: a project's own instructions, in the file each agent reads
@VictorHong1022 on X asked to manage AGENTS.md per project beside a
project's skills, so the shared instructions keep only general rules.

A project in the Library now has instructions of its own (the
Instructions tab, expand a project; `magpie library project
instructions <dir>`). magpie writes them into the project file each
picked agent reads there, by that agent's own name for it: Claude Code
CLAUDE.md (or .claude/CLAUDE.md when that is the one there), Codex and
pi their override first, Gemini GEMINI.md (or its context.fileName),
Qwen QWEN.md, CodeBuddy CODEBUDDY.md, the rest AGENTS.md. magpie owns
only a marked part (<!-- magpie:begin … --> to <!-- magpie:end -->):
the user's own text around it is kept byte for byte, CRLF included, a
hand edit of magpie's part stays until the project's text changes, a
file magpie made is listed in the repo's .git/info/exclude and removed
when emptied, and an agent's user-wide instructions file is refused.
Worktrees of the project follow it. A first text goes to the agents
the shared instructions are on for, else every agent here that reads a
project file. Problems show as the project's "instructions" problem.

Tested:
- internal/library: 8 new tests (block kept around user text, CRLF,
  hand edit kept, made file excluded and removed, renamed files,
  global file refused, worktrees). Four broken by hand, each red.
- internal/cli: TestLibraryProjectInstructionsCmd; red with the
  default agents dropped.
- GUI: project-instructions.test.cjs, en and zh, chromium and webkit,
  6 of 6. Red when Goose (no project file) was offered, and red when
  the defaults ignored the agents the instructions are on for.
- Real use on mote: the built binary, sandbox HOME and project. add,
  text, agents; CLAUDE.md kept CRLF with the part appended; AGENTS.md
  and GEMINI.md made and excluded; the user-wide CLAUDE.md untouched;
  zed refused; an edited part survived `library sync`; `agents none`
  put CLAUDE.md back byte for byte, removed the made files and
  emptied the exclude block.
- Full Go suite (go test ./... -timeout 45m) on mote: 103 packages ok,
  gofmt clean, go vet darwin, linux (nogui) and windows rc=0, at this
  change on origin/main 873b1f7d5.
- At dbb7230ae (rebased on d4af0ca4f), on mote: gofmt clean; go vet
  darwin, linux (nogui) and windows rc=0; go test internal/library,
  internal/cli, internal/gui and internal/testenv ok; node --test
  site/*.test.mjs 133 of 133. Not the whole Go suite again: of the
  commits that came in, only backup_cmd.go and main.go in internal/cli
  touch a package this change does, and its tests pass.
- The 89 Library GUI files (library-*, lib-*, project-*, skill-proj*,
  i18n-keys) at dbb7230ae on mote, both engines: 1868 of 1876. Red:
  library-open-again's 6 at 1100px, red alone at origin/main 28f27e07b
  too (#6751); library-new-skill's chromium en 420 timed out waiting for
  "taken" under the parallel run and passed alone at this head.
- Rebased again on 28f27e07b (three commits, one internal/cli test):
  go test internal/cli and internal/library ok on mote, and
  docs-index.mjs leaves the generated site files unchanged.
- Site: node docs-index.mjs regenerated llms-full, search and
  docs-index.sums at the rebased head; node --test site/*.test.mjs
  133 of 133.
- Full GUI suite (make test-ui, both engines) on mote at 873b1f7d5's
  rebase, beside other sessions' runs at load up to ~100: 28532 tests,
  1156 red in 133 files, none of them project-instructions. 115 files
  are #6975's, red at origin/main. Run alone at this change and at
  origin/main 8e1534f5f, the other 18 give the same result at both:
  16 green, name-suffix-remote red (#5147), library-env red. Recorded
  on #6975.

Not tried: a real Cursor, Copilot or Gemini session reading the files;
the library tests on Windows or Linux (cross vet only). Cursor and
Copilot read both CLAUDE.md and AGENTS.md, so picking Claude Code and
them together can show them the text twice.
2026-11-17 23:37:54 +08:00
yetone 28f27e07b7 editor: a provider's warm-up or check-in that is on opens its Advanced (ChrisYagao on X)
ChrisYagao on X asked where his warm-up went. Nothing was lost: warm-up
moved from Settings into each provider's editor (11-09), then into that
editor's folded Advanced (11-10), so a warm-up that was on vanished from
sight with no trace of where it went.

Fix: the editor's Advanced opens on its own while that provider's
warm-up (on reset or daily times) or daily check-in is on
(provPrefsOn), unless the reader opened or closed it by hand, the same
rule as Routing's Advanced. renderWarmAtOwn moves into the lazily
loaded autoresetown.js (warmAtOwnPaint), so app.js and the core script
budget each drop by 1,529 bytes. reader.cjs's openProvPrefs waits for
the modal's animations to end before measuring (warm-at-times WebKit
900px measured mid-animation, 0.66px overhang).

Old data: no setting changes and nothing migrates; a warm-up that was
on shows again the first time its editor opens.

What was run:
- warm-advanced.test.cjs (new): red 10/10 on the old app.js
  ("codex, warm up on reset: Advanced open"), green after; chromium and
  webkit, en zh zh-TW ja de.
- At the pushed head (rebased on origin/main), on mica: warm-advanced,
  warm-at-times, warm-at-own, warm-now, quota-warm, plugin-checkin,
  editor-advanced-align, routing-advanced: 160 passed, 0 failed.
- 29 related GUI files (every openProvPrefs user, warm-*, quota-warm,
  plugin-checkin, routing-advanced, editor-advanced-align,
  codex-auto-reset*, reset-providers, search-mix, model-api-preset,
  i18n-keys, segs-press-redraw, settings-groups) alone on mica: 603
  passed, 31 failed; every red is red at origin/main 8e1534f5f too:
  codex-auto-reset-settings webkit de #4790, i18n-keys "a plugin's
  words are its own" #6877, model-api-preset chromium #5838,
  reset-providers 420px #6196, settings-groups "Spend extra usage"
  #6597, segs-press-redraw currencySegs (filed #6990).
- go test ./... -timeout 45m on mote: ok, no FAIL. After the rebase,
  go test ./internal/gui/ (budgets) on mica: ok.
- GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok,
  gofmt -l clean.

Not tried: the whole GUI suite ran once only, by accident, at an
earlier head before the reader.cjs fix, under load on mica (24,676
passed, 3,151 failed); those reds can't be attributed and are not a
record for this head. Not tried in the real app with ChrisYagao's
settings.
2026-11-17 23:27:42 +08:00
yetoneandmdwsk88 fe41216b01 claude-desktop: Claude Code's WebSearch runs on the model picked for haiku (#6348)
In Claude Desktop's gateway mode, Claude Code's WebSearch call always went
to the session's model (Opus here, 11-19s a search). Claude Code 2.1.321
sends it to its small (haiku-tier) model only when the remote flag
tengu_plum_vx3 is on, and Desktop sets DISABLE_GROWTHBOOK=1 in gateway
mode, so the flag falls back to off. WebFetch's page summaries already run
on the haiku pick (#5534); WebSearch now does too.

- desktopSearchCall knows the call by its shape only: tools is exactly one
  web_search_* server tool named web_search, and tool_choice is
  {"type":"tool","name":"web_search"}. The prompt is never read.
- desktopMoveTo, for a request Claude Code sent in Desktop, puts it on
  DesktopTiers()["haiku"] when that pick is set, served and not already
  the model asked, recorded as desktop-search. It doesn't change the
  session's recorded model (desktopPicked).
- A subagent's search taken by the haiku pick is Claude Code's helper,
  not the subagent's turn: Desktop's subagent model, effort and turn tag
  leave it (desktopSearchHelper; subagentTurnOf takes the agent, so
  terminal Claude Code is unchanged).
- No haiku pick, or one magpie doesn't serve: nothing changes.
- The Routing page says why (desktop-search, en/zh/zh-TW/ja/de), and
  gateway-routing.md has the rule.

Ported from mdwsk88's f68197aa6 (mdwsk88/magpie
desktop-websearch-haiku-tier), reviewed line by line. Changed in the port:
the gateway-routing.md conflict was merged onto main's text (main's
codex-suggestions kept), and the cheap pre-check is bodyHas on
`"tool_choice"` and `web_search_` instead of bytes.Contains, since
desktop.go no longer imports bytes on main (the patch didn't compile
there) and every Desktop request from Claude Code takes this check.
web_search_* is kept as a prefix, so a newer search tool version
(web_search_20260209) is matched as the same call.

Run on mote (go1.26.8). Whole packages last at base 659e8850a (also
fefe3f658, 05d46f42e, 4a1ac8442 before; all ok):
- go test -count=1 -timeout 45m ./internal/gateway/ ./internal/gui/: ok
  (gateway 949s, gui 218s at 659e8850a).
- After rebasing on 50c5a52db (backup, touches internal/gui):
  go test ./internal/gui/ ok, and the focused gateway run below ok.
- Focused -run '^(TestDesktop|TestClaudeDesktop|TestSubagentTurn)': ok.
- Broken by hand, each red: the search rule removed (old routing) ->
  TestDesktopWebSearchHaiku, ...KeepsSessionPick, ...Route fail; the
  Claude Code guard removed -> TestDesktopWebSearchScope fails; the
  subagent helper exemption removed -> TestDesktopSubagentWebSearchIsHelper
  and TestDesktopWebSearchRoute fail.
- node --test routing-moved-why, i18n-keys, i18n-en-no-cjk (chromium and
  webkit): 37/38; the one red is i18n-keys "a plugin's words are its
  own" on ", with an image", red on origin/main and filed as #6877.
- gofmt -l: clean. GOOS=linux go vet (-tags nogui and without) and
  GOOS=windows go vet on ./internal/gateway ./internal/gui: ok.

Not tried: a real Claude Desktop session's WebSearch; the reporter's
routing log will show it landing on the haiku pick.

Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
2026-11-17 22:56:55 +08:00
yetone 50c5a52dbd backup: a backup file carries the usage history, and a restore merges it (JasonLeeForOnly on Discord)
JasonLeeForOnly moved magpie to a new server with magpie backup / magpie
restore and lost every call's usage history: a backup file held the setup
only.

- backup.WithUsage puts usage.jsonl's whole lines (gzipped, usage.LogBackup)
  and the quota history (gzipped) in Bundle.Usage. magpie backup and
  Settings -> Sync -> Export add it unless --no-usage / the tick says no.
  Collect never does, so sync, join and automatic backups are unchanged.
- Restore (Parts.Usage, on in All; magpie restore --no-usage and the Import
  tick turn it off) merges: usage.MergeLog appends the lines the log here
  doesn't have, compared byte for byte as a multiset, so restoring the same
  file twice adds nothing and two equal calls both arrive. It reads most
  of the log before the gateway's log lock, the rest under it, and appends
  with O_APPEND in 4MB chunks, after a newline when the log ends in an
  unfinished line. Quota points merge with provider.MergeQuotaHistory.
  A file without usage (older magpie, or --no-usage) restores as before.
- Result.Usage is the calls added; the CLI and the Import form say it.
- Docs: sync-backup.md, reference.md, site sync pages (en, zh, ja) and the
  search index/llms-full.txt rebuilt with node docs-index.mjs.

Not changed: where usage is also shared by sync, the old computer's calls
are in usage-others and, after a restore, in this log too: filed #6987.

Run on mote at this head (26f69e85e rebased on origin/main 4a1ac8442):
- gofmt -l clean; go vet (darwin), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet for backup, usage, cli, gui; GOOS=linux go build
  -tags nogui and GOOS=windows go build of the app.
- go test -count=1 -timeout 45m ./internal/backup/ ./internal/usage/
  ./internal/cli/ ./internal/davsync/ ./internal/provider/ ./internal/gui/:
  all ok.
- GUI (Chromium and WebKit, 5 languages, 1100/420px): sync-*.test.cjs,
  i18n-*.test.cjs, auto-backup.test.cjs: 245 pass, 1 fail, i18n-keys'
  "a plugin's words are its own" over claude_image_budget_test.go, red on
  origin/main and filed as #6877.
- Real use: a built magpie on mote, two sandbox HOMEs, a copy of a real
  105,815-line usage.jsonl (47MB): magpie backup wrote a 9.1MB file in
  1.9s (364 bytes with --no-usage); magpie restore on a home holding the
  last 1000 of those calls added 104,815 in 0.5s, the sorted log then equal
  to the old one; a second restore added 0; the --no-usage file changed
  nothing; magpie usage read the merged log.

Broken by hand, each red: MergeLog without the multiset skip
(TestBackupCarriesUsageHistory); no newline before the
first appended line (TestUsageMergeKeepsLinesWhole); WithUsage not setting
Bundle.Usage (both tests). The Import form's tick check first sat after
the Import click and went red in WebKit; it now runs before the click.

Not tried: the GUI's export and import against a real gateway (the GUI
tests use a fixture API); the full go test ./... and the whole GUI suite,
since mote and mica were each running other sessions' full suites.
2026-11-17 22:41:26 +08:00
yetone 659e8850a2 gateway: a routing group named for a model is listed by that id when the model's own row isn't (小八 on Discord)
v0.1.4377, Settings › Network and sharing › Model ids without the
provider = Only: group/glm-5.2, group/glm-5.3, group/glm-5.3-flash,
group/deepseek-v4.1-flash-1017 and group/sensenova-6.8-flash kept their
prefix while other groups lost it (3126b0bac). Each is a group the user
made, named for a model a provider serves.

Cause: groupBare refused a group's own id whenever any provider entry
(providerEntries, not the shown list) served a model by it, on the
reasoning that the provider's glm-5.2 row would carry the bare id to
the group. That row isn't always shown: a group that lists its members
alone (Group.Unlists), a provider kept for routing groups
(Provider.Unlisted) and an agent's hidden models all keep it out of
/v1/models. Then nothing carried glm-5.2, and the group stayed
group/glm-5.2. The check is gone. bareTarget already requires that a
request for the id reaches this very group (the gateway routes a bare
id GroupFor before Resolve: groupForIn tries a group of that exact id
first), and when the model row is shown its bare id reaches the group
first (BareEntries' reached), so the id is still listed once.

The other way it could stay prefixed, a shown row whose ID is already
"glm-5.2" (ids[id]), isn't real: every provider entry's ID is
provider/model (sharedEntry) and every group's is group/<id>.

Run (mote, mote-run, waited for load under its cores; at
4a1ac8442 + this change, origin/main unchanged since):
- go test -timeout 45m -count=1 ./internal/provider ./internal/gateway:
  ok (158s, 1158s)
- GOOS=linux go vet -tags nogui ./...: ok; GOOS=windows go vet ./...: ok
- gofmt -l on the changed Go files: nothing

Broken by hand: the new TestBareIDsListGroupNamedForAModel (a group
glm-5.2 of b/glm-5.2 and a/glm-5.2, listing its members alone) at the
old bare.go fails "on: [group/glm-5.2 auto/glm-5.2 a/other-a other-a],
want glm-5.2 once". With the fix, under Only glm-5.2 is listed once in
group/glm-5.2's place, GET /v1/models/glm-5.2 answers, and a chat
request for glm-5.2 (and group/glm-5.2) reaches the group's first
member, b, not a as Resolve would.

Not tried: 小八's own providers.json (which of the three ways hides
their model rows is not known; Unlists is the one tested); a real
client against a running magpie; the full ./... suite and the GUI
suite (no GUI file changed); Windows and Linux runs beyond vet.
2026-11-17 22:34:51 +08:00
yetone 3fbade47ab gateway: a found group gone with a provider still goes to its model (canlee886)
canlee886 on X (2122660479411855365): a Codex App thread saved on
group/auto-gpt-6-1-sol failed every turn with 404 "magpie knows no
model", followed by every id magpie has, after azure-fte2-sea's
gpt-6.1-sol went away; other threads were fine, and switching the
thread's model did not help. The user patched the thread over Codex's
app-server RPC.

Cause: a group magpie finds needs two providers serving the model
(autoGroups). When one is removed, or its list no longer has the model,
the group is gone. Reseat moves an agent's config off it, but a Codex
thread keeps the model it was saved with and names it on every turn.
provider.AutoStandIn sent a gone found group's id to its model only
while found groups were off, or when a provider kept out of them took
it away; any other way of losing the group was a hard 404, even with a
provider still serving the very same model.

Fix:
- AutoStandInFor: with found groups on, a found group's id (group/auto-…
  or auto/<model>) that is no group now, and that the user neither
  changed nor removed (no providers.json record), goes to its model from
  a provider that serves it (the agent's own subscription first, then
  one not kept out, then the first). It is the same model, never
  another; a group the user removed stays a 404.
- With no provider serving the model, the request is still 404, but
  unknownModel says the model is gone and to pick another for the
  conversation (Codex: the model menu under the message box), with the
  three nearest ids, not every id (provider.GoneAutoGroup).
- Codex's compaction on the model a thread is leaving
  (model_downshift) already compacts locally when that model 404s
  (2768f04f9); TestCodexLeavingGoneGroupCompactsLocally pins it for a
  gone group.
- docs/subsystems/gateway-routing.md says when a found group can go and
  what a request for it gets.

Siblings: the stand-in is in serve's model resolution, so Claude Code
and every other agent saving the id are covered, as are key limits,
count_tokens, budget and Codex's own-v1 path, which already ask
AutoStandIn.

Run (mica/mote via mica-run/mote-run, at this tree):
- TestFoundGroupGoneGoesToItsModel: red on the old code (404 "magpie
  knows no model ... it has ..." with b still serving gpt-6.1-sol),
  green now. TestAutoGroupSkip's "group/auto-y" case (b's model alone)
  now expects the stand-in b/y; group/auto-nothing still none.
- go test ./internal/provider, ./internal/gateway -run of the
  group/stand-in/Codex compaction tests: ok.
- Full suite at 473de21fa (this change on fefe3f658's parent base) on
  mote, mote-run: gofmt -l nothing; GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go vet ./...: ok. go test -timeout 45m
  -count=1 ./...: 101 packages ok, internal/gateway (1035s), agent,
  provider, gui, cli, budget among them. Two reds, neither touched here:
  internal/plugin's TestHostOnUnstartableBunSaysWhy (62s deadline, #5878)
  and internal/redact, whose tests passed and whose TestMain then hung
  46m in testenv.RemovePrograms on stand-in warm-ups (#5267, SIGQUIT at
  47m); both commented with the output.
- After the rebase onto origin/main (fefe3f658, which changed
  internal/provider/bare.go and internal/gateway), on mica: gofmt -l
  internal nothing; go test ./internal/provider ./internal/gateway: ok
  (149s, 1004s). On mote: ./internal/plugin ./internal/redact alone: ok.
- Rebased again onto 05d46f42e (gateway advisor, agy move; no file
  shared): go vet and go test -run
  "FoundGroup|Gone|AutoGroup|StandIn|Advisor|Unknown|Compact|Group" of
  ./internal/gateway ./internal/provider on mote: ok.

Not tried: the reporter's real Codex App thread and Azure providers;
the fixture removes the model from a provider's list rather than
reproducing why azure-fte2-sea's list lost it.
2026-11-17 22:00:51 +08:00
yetone 05d46f42e5 gui: Claude's menu bar cards can show Anthropic's A\ mark (qingnianxiaozhe on X)
qingnianxiaozhe asked for Anthropic's A\ in the menu bar in place of
Claude's logo. Settings › Usage › Menu bar Claude logo (Mac only, shown
while logos are on and a ticked card is Claude's, under the magpie icon
row) picks Claude's logo
(the default, unchanged) or the A\.

- settings.TrayAnthropicMark, kept per computer through KeepOwn like the
  other menu bar choices; settingsapi.Keys saves it; a change wakes the
  menu bar (onTrayUsage).
- trayAnthropic swaps the icon of cells whose card logo is claude-color
  or a plugin's claudecode-color (trayCell.Logo) for trayAnthropicMark,
  an SVG drawn here (two paths, no other app's bytes), and marks it mono
  so mpGlyph paints it in the bar's text colour. Menu bar logos off
  wins.
- The row's code is trayClaudeRow in traywindows.js (lazy). app.js only
  adds the key to prefsKeep; to stay in TestCoreScriptBudget without a
  raise, renderTrayUsage's no-card branch moved into trayWindowsRow,
  which now hides Windows' figure row itself when no card is ticked.
- en, zh, zh-TW, ja, de strings; docs/subsystems/gui-shell.md bullet.

Tests: TestTrayAnthropicMark (which cells change, input not mutated,
plain cells stay plain), TestTrayAnthropicMarkSVG,
TestTrayAnthropicMarkSaved (POST as the page does, saved and woken once
per change), TestTrayImageAnthropicMark (darwin: renders the real
AppKit image light and dark, the logo rect differs, the rest of the
image is identical), tray-anthropic-mark.test.cjs (five languages, 900
and 400px, Chromium and WebKit: row, two logos, default Claude, A\
posts true, another setting's save keeps it, back to false, no row with
no Claude card / logos off / no card / Win32, no page errors, no
sideways scroll). The GUI test waits for the redraw after a save rather
than a fixed time: a click on a control drawn before the save lands
sends the old value back (any setting, not new here).

Broken by hand: trayAnthropicMark taken out of prefsKeep turns the GUI
test red ("a save of another setting keeps the A\") in all languages;
taken out of settingsapi.Keys turns TestTrayAnthropicMarkSaved red.

Run:
- mica, at 2fa9295ed (this tree less the doc bullet): go test -timeout
  45m -count=1 ./... : 103 ok, exit 0.
- mote, at this head's code: gofmt -l clean; go vet ./...;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./... ok;
  internal/settings, settingsapi, davsync ok; internal/gui -run
  "Tray|CoreScript|Budget|EveryRoute" ok.
- mote GUI, Chromium and WebKit, the 20 files that touch the menu bar
  rows, Settings search or prefs (tray-*, settings-search, side-effort,
  searcher-pick, quota-pace, proto-menu-overflow, classify/image-timeout,
  i18n-*): tray-bird first went red (its row must follow the logos row),
  so the Claude row sits after the magpie icon row. side-effort is 5/5
  red in both engines on origin/main a922e3864 too (#6353).
- After rebasing on a922e3864, at this head: gofmt clean; go vet
  internal/gui, settings; go test -run Tray|CoreScript|Budget|EveryRoute|
  Settings internal/gui, settings, settingsapi ok; tray-anthropic-mark,
  tray-bird, tray-logos, tray-windows, tray-usages, settings-search 51/51
  in Chromium and 51/51 in WebKit.
- i18n-keys: "a plugin's words are its own" red, the same on origin/main
  (routing's ", with an image" in claude_image_budget_test.go), #6877.
- Real AppKit renders of the menu bar image (trayImagePNG, light and
  dark) looked at: "A\ 42%/18%" reads at 14pt.

Not run: the whole GUI suite (mote and mica each had another session's
full GUI suite running); the files above are the ones this can reach. Not tried: a screenshot of the live menu bar of a built app.
2026-11-17 21:50:54 +08:00
yetone d54b7acf43 gateway: Claude Code's dashed advisor id goes upstream as the provider names it
Refeccd (Discord, v0.1.4366): Claude Code with Opus 5.5 as the model and
Fable 5.2 as the advisor, both on one provider; the advisor's turns came
from Opus and Routing showed no Fable request.

Claude Code 2.1.316 (real binary, sandbox HOME, a fake upstream) never
sends a request of its own for the advisor: it is the server tool
{"type":"advisor_20260301","model":"relay/claude-fable-5-2"} inside the
main request, with settings.json's advisorModel as written. magpie writes
a dotted Claude id dashed (ClaudeSpelled), and the gateway took the main
model back to the served id (validateModel) but not the advisor's. On a
provider listing claude-opus-5.5 and claude-fable-5.2 the request went
upstream as model claude-opus-5.5 with advisor claude-fable-5-2, a name
the relay doesn't know.

advisorID now takes the advisor's model to the served id as a request's
own model is (ClaudeUndashed, then unflat and CanonicalRef), and drops
[2m] beside [1m]. Every reader of it goes through it: advisorModel
(passthrough name), advisorKeyModel (key limits), advisorAsked
(advisedHere, advisedInBridge) and readAnthropic's Request.Advisor
(magpie-run advice).

Run (on mica):
- go test -count=1 -timeout 45m ./internal/gateway/: ok at 38babcb13
  (this change on efcf8d9c0), and before at d67ccbd3c and 8e1534f5f
- rebased since onto a922e3864, which adds only internal/library,
  internal/agent/dsh.go and internal/provider/agy_move.go: at this head,
  go test -run Advis ./internal/gateway/ ok, and GOOS=linux and
  GOOS=windows go vet ./internal/gateway/ ./internal/provider/ ok
- gofmt -l internal/gateway: clean
- GOOS=linux and GOOS=windows go vet ./internal/gateway/: ok

Broken by hand: advisorID returning the trimmed id as before makes
TestAdvisorModelAsTheUpstreamNamesIt's new "a dotted id as Claude Code
names it" case red: advisor sent as ["claude-fable-5-2"], want
"claude-fable-5.2", the reporter's shape.

Not tried: the reporter's own relay. magpie still doesn't read
usage.iterations' advisor_message entries, so a passthrough advisor run
at the vendor shows no Fable row in Routing; that is by design of the
server tool, not changed here (#6977).
2026-11-17 21:48:13 +08:00
yetone 3126b0bacd gateway: with model ids without the provider on, a routing group the user made is listed by its own id too (小八 on Discord)
"路由组的外显模型名可以选择去掉 group/ 这个前缀吗": with Settings ›
Network and sharing › Model ids without the provider on, /v1/models
listed a user's routing group only as group/<id>, though the gateway
already takes a request for its bare id (GroupFor). BareEntries skipped
every group row. Now a group the user made adds a row by its own id
(fast beside group/fast; under Only in group/fast's place, through
OnlyBare as before), and GET /v1/models/fast and Ollama's lookup answer
it (BareEntry). Only where the id is the group's alone: not when a
provider serves a model by it (the model's bare id is listed, reaching
the group as the gateway routes it), when it is listed already, when
GroupFor of it reaches another group, for a group magpie found (its
auto/<model> row is already listed under the model's bare id), or for a
group a gateway key can't use.

Agents: unchanged. magpie still writes group/<id> into an agent's
config, as it writes provider/model under Only; the gateway takes either
id, so turning the setting on or off rewrites nothing. The Settings help
text says nothing that is now false, so i18n is unchanged.

Run (mica, mica-run, mote over 18 cores):
- go test -timeout 45m -count=1 ./internal/provider ./internal/gateway:
  ok (152s, 1059s)
- GOOS=linux go vet -tags nogui ./...: ok; GOOS=windows go vet ./...: ok
- gofmt -l on the changed Go files: nothing
- After the rebase onto origin/main: TestBare in internal/gateway again.

Broken by hand: with bare.go at its old version, TestBareIDsListUserGroups
fails "on: [... glm-5.3 only-a only-b], want [...] and then fast once".
With the found-group and already-reached checks taken out of groupBare /
BareEntries, it fails listing "auto-glm-5-3".

Not tried: a real client against a running magpie; the full ./... suite
and the GUI suite (no GUI file changed); Windows and Linux runs beyond vet.
2026-11-17 21:10:26 +08:00
yetone 8e1534f5f9 sessions: read LiveAgent's sessions (#6741)
Usage › Sessions and the Sessions page now list LiveAgent's sessions
with their title, time, model, tokens and cost, and show their
conversation.

- Where: K-brain keeps each session at
  <root>/sessions/<project>/<id>/session.jsonl (older ones right under
  sessions/). sessions/.runs and sessions/.deleted-history are skipped.
- Root: $LIVEAGENT_HOME, then $K_BRAIN_HOME, then
  ~/.liveagent/data-dir.json, then ~/.liveagent. The rule now lives in
  sessions.LiveAgentDirIn, and agent.liveAgentDir calls it, so it has
  one owner.
- Reading: K-brain rewrites the file whole, so it is parsed whole. The
  first line is session_meta (id, title, cwd, running totals).
- Tokens:
  - Each reply's own usage counts on the day it came back.
  - What the totals (model_usage, else usage_in/usage_cached/usage_out)
    hold beyond those replies, such as a compaction's call or a rewound
    reply, counts on the last message's day, together with sub_usage.
  - Cache reads and writes are taken out of prompt_tokens.
- Forks: a fork's copies of its source's messages (seq <= fork_seq) are
  the source's, and count in neither the fork's messages nor its totals.
- Subagents: a subagent's own session (task-<parent>-<task>, task_id
  set) is filed under its parent with its activity, but no tokens,
  because its spend is the parent's sub_usage already.
- Not added:
  - a Calls reader: the gateway's own record of LiveAgent's calls
    carries no session id, so it would count them twice;
  - resume and delete: LiveAgent has no resume command.
- Skills: SkillsManager read (skill://<name>/SKILL.md) and Read of a
  skill path are counted.

Run (mote, mote-run, at d67ccbd3c plus this change before the rebase):
- go test -count=1 -timeout 45m ./internal/sessions ./internal/agent
  ./internal/library ./internal/agentenv ./internal/gui: all ok.
- go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean. gofmt -l: clean.
- TestEveryAgentSaysItsSkills has liveagent →
  TestLiveAgentSessions.

Again after the rebase on 3be322fe4 (mote): ./internal/sessions,
./internal/agent, ./internal/library ok; GOOS=linux -tags nogui and
GOOS=windows go vet ./... clean.

Broken by hand (mote), each red:
- Without parserFor's liveagent case: TestLiveAgentSessions (0 listed)
  and TestLiveAgentTranscript.
- Without subtracting a fork's copies: fork1 tokens 600/140/1000 for
  want 400/40.
- Without subtracting the replies already counted: abc123
  3500/550/2000 for want 2500/350/1000.

Fixtures: the issue's literal session_meta, with its placeholders
filled in (12786068 in, 12455808 cached, 103572 out →
330260/103572/12455808). The message, snapshot and compaction lines
follow K-brain's record types as its source writes them.

Not tried: no real LiveAgent install. The files were not written by
LiveAgent itself, and no real session was read. Imported sessions
(ImportHistory) are listed as they are. No GUI file changed, so no
GUI tests were run.
2026-11-17 20:56:30 +08:00
yetone 5622149331 gateway: a relayed Messages request whose tool exchange doesn't pair is mended (miwanzi on Discord)
Claude Desktop through magpie, several conversations at once: a
conversation died with "Invalid request … 400 due to tool use concurrency
issues", which Claude Code shows when the upstream answers 400 with
"messages.N: `tool_use` ids were found without `tool_result` blocks
immediately after" or "unexpected `tool_use_id` found in `tool_result`
blocks", and every later turn carried the same history, so it stayed
stuck. pairToolBlocks mended only a translated request (buildAnthropic);
an Anthropic client's own body relayed to a Messages upstream went as it
came.

toolBlocksPaired (tool_blocks_paired.go) mends it in passthrough's
Anthropic case (an API key, a relay, a plugin's fetch) and before
count_tokens, by pairToolBlocks' rule: a call the next message doesn't
answer gets the synthetic interrupted result (is_error), first in the
user message after it or in one of its own; a result answering no call of
the message before becomes the text it said; a second answer is dropped;
a result after other content of its message goes first. It works on the
raw bytes: a body whose exchange pairs comes back byte for byte (nothing
decoded into maps, nothing marshalled), and a mended body keeps every
message it didn't change, and every other member of one it did, as they
came. A Claude subscription's turn goes through the bridge, which writes
the history as text, so it was never refused for this and isn't touched.

Cause: nothing found in magpie that makes such a history. Salted call ids
(tool_use_ids.go) unsalt id and tool_use_id alike, and a stream cut
mid-reply gets an error event, not a made-up block. A reply cut or failed
after a tool_use block was told (an upstream drop or overload under
parallel load, or the user stopping it while parallel calls run) leaves
the client a call with no result; the mend is what un-sticks it.

Tests (vendor's literal refusal texts through validateExchange):
TestToolBlocksPairedLeavesAPairedBodyAsItCame (Claude Code body with
cache_control, thinking, &, key order: same bytes),
…AnswersACutCall, …OrphanResultBecomesText, …CallsWithNoUserTurnAfter,
…SecondAnswerAndOrder, TestMessagesRelayMendsABrokenToolExchange (relay
to a fake that refuses as Anthropic does: 200; a paired request reaches
it with the client's bytes), TestCountTokensMendsABrokenToolExchange.

Broken by hand:
- the two call sites taken out: the relay and count_tokens tests red with
  "messages.2: `tool_use` ids were found without `tool_result` blocks
  immediately after: toolu_01B".
- toolBlocksPaired decoding and re-marshalling every body: the byte tests
  (unit and relay) red.

largeConversation's Anthropic fixture replaced the last call's answer
with "go on", so its last call went unanswered, which Anthropic refuses;
the mend changed it and TestUpstreamBodiesUnchanged/large-anthropic(-group)
went red. Its user's words now follow the answer, as the Chat fixture's
do since 43001be86, and the two hashes were written again. They come out
the same with the call sites taken out, so that paired large body is
relayed byte for byte with and without the mend.

Run:
- mica (macOS), at 5e4bbf0ce (this change before the rebase onto
  f9492fd8e and before the fixture change): gofmt -l clean, go vet ./...
  ok, GOOS=linux go vet -tags nogui ./... ok. Its GOOS=windows vet and
  gateway tests stopped on "no space left on device" (mote and mica both
  had under 1 GB free, other sessions' files).
- xiaomi-gpu, native Windows, at the rebased head before the fixture
  change: go vet ./... ok.
- WSL magpie-desktop (Linux), rebased on f1a4de736: go vet and
  GOOS=windows go vet ./internal/gateway/ ok, go test -count=1
  -timeout 45m ./internal/gateway/ ok (1097s); the same at the
  f9492fd8e base (1135s).
- At the pushed tree (rebased on 3be322fe4, whose ff28dc6bd changed
  gateway.go away from these lines): go vet ./internal/gateway/ ok and
  -run "ToolBlocksPaired|MendsABrokenToolExchange|
  TestUpstreamBodiesUnchanged|TestMessages|ToolPair|TestAnthropic|Cap|
  Near|Round" ok; the whole package not again. The run before the
  fixture change was red only on the two large-anthropic cases (above);
  its log shows #6339/#6505/#6690's doneHold panic, no test failed for it.

Not tried: a real Claude Desktop or Claude Code conversation against a
real Messages upstream; the miwanzi history itself (not shared). The
full ./... suite was not run, only internal/gateway; the gateway
tests did not run on macOS (no disk on mote or mica).
2026-11-17 20:53:21 +08:00