Commit Graph
1958 Commits
Author SHA1 Message Date
yetone 8cc4bd7e3c agent: Craft Agents, through a keyless connection at the gateway (springg1998 on X)
Craft Agents (lukilabs/craft-agents-oss, thecraftagents.com) keeps its LLM
connections in config.json under $CRAFT_CONFIG_DIR or ~/.craft-agent
(paths.ts, storage.ts, llm-connections.ts, v0.15.8). magpie adds one
connection: slug magpie, providerType pi_compat, authType none, baseUrl at
the gateway's /agent/craft-agents/v1, customEndpoint.api
openai-completions. Its models are the ones picked for it, and defaultModel
is always one of them, because Craft resets a default that isn't in the list
to the first. magpie makes it defaultLlmConnection. The user's default is
stashed (as JSON, "" for none) and put back on off when that connection still
exists. A name the user gives magpie's entry stays, and a sync with nothing
to change writes nothing. A config.json with no workspaces list is one Craft
doesn't load, so magpie never creates one: open Craft once first. Picking one
of the user's own models removes magpie's entry and sets that model on their
default connection. Sessions keep the connection they started on, so the
notice says new sessions use it (zh, zh-TW, ja, de).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Not tried: a real WebDAV, S3 or GitHub server (fake servers only); two
real computers; Windows run of the tests (vet only). The full suite starts
after the tag.
2026-11-10 15:43:41 +08:00
yetone 86825005e2 plugin: a gateway hook given more than 10s gets up to 30s (#5890)
gatewayTimeoutMs was capped at 10000 and the Go side cut every hook RPC at
11s, so a recall hook (Nowledge Mem) asking for 15s was cut at 1s (any
value over 10000 fell back to the default) and could never finish.

- host.js: gatewayTimeoutMs takes integers 100-30000; a value outside is
  clamped to the nearer bound, a non-integer gets the 1000 default.
  gatewayBudget() is the old chain budget (sum, clamped 2-10s) or the
  longest hook's own timeout, whichever is larger. With no hook over 10s
  nothing changes.
- gateway.go mirrors both (gatewayTimeout, gatewayBudget, cached with the
  HasGateway scan). GatewayBegin's request RPC, Finish's completion RPC
  and GatewaySignIn now wait the budget plus 1s, never less than the old
  11s; host startup and the lock wait stay bounded at 11s. Caller
  cancellation still reaches the hook at once, a failing hook still
  rolls back, and the request-state limits are unchanged.
- Docs: gateway-request-hooks subsystem page, plugins docs (en, zh, ja).
  site/public/llms-full.txt regenerated with `node llms-full.mjs`; it was
  already stale on origin/main (OpenCode 2 keys, billion-context tab,
  data-folder move, vendor presets, group rule), so those docs pages'
  text lands in it too.

Run on mote at this tree (base 03a800ac6; origin/main has one newer
commit touching none of these files):
- gofmt -l internal/plugin internal/gateway: clean
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: rc 0
- go test -tags nogui -count=1 -timeout 45m ./internal/plugin/...
  ./internal/gateway/...: ok plugin 161.6s, ok gateway 897.0s
- site: node --test worker.test.mjs: 38 pass (llms-full red before the
  regeneration)
New tests (internal/plugin/gateway_budget_test.go): a 12s onRequest and
onResponse with gatewayTimeoutMs 15000 both land (24.2s); the default and
10000 are still cut with outcome "timeout"; two 8000ms hooks still share
10s; 130000 is clamped, not dropped; cancelling a 15000ms hook's request
stops its fetch at once (0.07s); the Go mirror matches host.js.

Broken by hand, each red:
- A host.js as on main: SlowRecall red at 1.10s, Clamps red
- B Go RPC kept at 11s: SlowRecall red at 11.04s, Mirror red
- C chain capped at 10s: SlowRecall red at 10.13s
- D default per-hook 30000: DefaultStillCuts/default red
- E caller signal off the begin chain: LongBudgetCallerCancellation red
- F chain budget 30s for every config: ChainStillTenSeconds red

Not tried: a real Nowledge Mem server; the full ./... suite; GUI tests
(no GUI change); a Windows or Linux runtime run (vet only).

Reported-by: aboat0625-cpu
2026-11-10 15:31:01 +08:00
yetone add0dadd4f codex: a service tier set in Codex's settings goes on every request of Codex's (JackyFill on X)
JackyFill asked for a choice in Codex's agent settings that rewrites
service_tier: follow the request, force Fast, force Ultra Fast. Codex's
settings on the Agents page now have "Codex service tier", picked from
the app menu: As Codex asks (the default, nothing changes), Standard,
Fast or Ultrafast.

The values are Codex's own request values (codex-rs protocol
config_types.rs ServiceTier, tui service_tier_resolution.rs): Fast is
"priority", Ultra Fast is "ultrafast", and Standard sends no
service_tier. Flex isn't offered: the ChatGPT backend's requests drop
it (codex_request.go).

settings.CodexServiceTier ("", "default", "priority", "ultrafast";
anything else refused) is set through POST
/api/settings/codex-service-tier. codexTiered rewrites the body where
Codex's requests come in, on both ways: codexBackend (Codex signed in,
/backend-api/codex) and the main handler's Codex-on-Responses block,
which a websocket turn goes through too. It applies only when the
request is Codex's (fromCodex or agentOf == codex). Everything after
treats it as Codex's own ask: an account whose list lacks Ultrafast is
put after a mate that has it or sent priority. A bare model (Codex's own
sign-in, whose plan magpie doesn't know) gets ultrafast only where one
of magpie's Codex accounts lists it on the model (UltraModels), else
priority. The body is edited with topMember/withoutTopMember, no full
decode. Fast picks still apply after, unchanged.

Run (mote):
- TestCodexServiceTierSet, TestWithServiceTier: ok. The test signs in a
  Plus and a Pro ChatGPT account against a fake backend whose lists offer
  gpt-6-luna's Ultrafast to Pro only, and checks the tier sent for each
  setting x what Codex asked, through /v1/responses (account:tier tried)
  and on /backend-api/codex for a model with Ultrafast and one without;
  OpenCode's own priority is left alone; "flex" is refused.
- go test -count=1 -timeout 45m ./internal/settings ./internal/provider
  ./internal/gui ./internal/gateway: ok but internal/gui, which was red
  twice: TestCoreScriptBudget (1,535,075 > 1,533,802) and
  TestSettingsSaveKeepsWhatItDoesNotSend (a save of the Settings page
  dropped the tier). Paid for by eight Codex-row comments cut in app.js
  (now 1,533,416), no raise; settingsapi.Apply keeps CodexServiceTier
  as it keeps the other Codex rows. At the pushed head: go test
  ./internal/settingsapi ./internal/settings ./internal/gui ok, the two
  gateway tier tests ok.
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (gateway,
  provider, settings, gui): clean. gofmt -l: clean.
- GUI, chromium + webkit: codex-service-tier (new, en/zh/zh-TW/ja/de at
  900 and 400px: 20/20), agent-prefs (56/56, Codex's row list updated),
  i18n-keys, i18n-en-no-cjk, settings-search, codex-titles,
  codex-subagent-model, settings-general, codex-sheet-providers,
  click-scroll: all pass; at the pushed head codex-service-tier,
  agent-prefs, i18n-keys, settings-search, codex-titles,
  codex-subagent-model, settings-general, click-scroll: 166/166.

Broken by hand:
- codexTiered returning the body as it came: TestCodexServiceTierSet red
  (17 lines).
- the Ultrafast-to-Fast downgrade for a bare model removed: red on
  gpt-6-sol (sent ultrafast, want priority).
- the GUI posting to the wrong path, and the row left out of Codex's
  AGENT_PREFS: codex-service-tier red in chromium and webkit.
- settingsapi without the CodexServiceTier keep:
  TestSettingsSaveKeepsWhatItDoesNotSend red.

Not tried: a real ChatGPT account's Ultrafast or Fast request with the
setting on (only the fake backend), a real Codex websocket session, and
Windows/Linux runs of the GUI.
2026-11-10 15:24:40 +08:00
yetone 03a800ac69 agent: OpenCode 2's config in its own words (kaising00 on X)
For an OpenCode 2 magpie wrote OpenCode 1's opencode.json: its provider
under `provider`, the small model as `small_model`, and `reasoning: true`
on models that reason. OpenCode 2 converts the first two in memory, but
it doesn't read `reasoning` and logged a WARN for each such model on
every load ("configuration normalization diagnostic ... omitted
unsupported legacy setting", reproduced with a real OpenCode 2.2.6).

Now the OpenCode that reads the file decides its words (openCodeTwo in
opencode_v2.go: the opencode on PATH, or a WSL distro's probed version,
now asked for opencode too). For 2.x magpie writes `providers.magpie` in
OpenCode 2's shape (openCodeNative), `agents.title.model`, and no
`reasoning`. A file written for OpenCode 1 moves over on the next sync:
openCodeFromV1 ports migrateStandardProvider (v2.2.6) so the user's keys
in magpie's provider (headers, timeout, setCacheKey, their own variants,
limit.output) go along; an empty `provider` is dropped; a small_model
that isn't magpie's stays. OpenCode 1, or an unknown version, gets the
same output as before. OpenChamber writes the same file and takes the
same decision, so the two syncs don't undo each other. mimocode, DevEco
Code and Air keep OpenCode 1's words.

Run:
- gofmt; go vet ./internal/agent for darwin, linux (-tags nogui) and
  windows (mote): clean.
- go test -count=1 ./internal/agent on mote: ok, at the rebased head.
- win-run go test -run 'OpenCode|OpenChamber|WSL' ./internal/agent: ok.
- Real binaries on mote, sandbox HOMEs, `opencode debug config
  --print-logs`: the file magpie now writes for OpenCode 2 loads in
  OpenCode 2.2.6 with no WARN/ERROR, and resolves (model, agents,
  providers) exactly as 2.2.6 resolves the OpenCode 1 file it replaces;
  the OpenCode 1 file loads in 1.19.5 with no WARN, small_model and
  reasoning intact. The old file in 2.2.6 still shows the reasoning WARN.

Broken by hand:
- openCodeTwo always false: TestOpenCode2WritesItsOwnWords,
  TestOpenCode2MovesAnOpenCode1File, TestOpenChamberAndOpenCode2AgreeOnWords
  and TestOpenCodeTwo red.
- moveProvider not carrying the v1 block over: the move test red on the
  user's timeout.
- moveSmall off: the move test red on agents.title.model.

Not tried: a real OpenCode 1 desktop app reading a file written for an
OpenCode 2 CLI on PATH (it would see no magpie provider; 1.19.5 logs
`providers` as not representable); Air's bundled OpenCode version; a real
WSL distro with OpenCode 2.
2026-11-10 14:52:01 +08:00
yetone e7fe52fdc3 minimax: follow the data folder MiniMax Code Desktop moved, not ~/.minimax (YujunT46308 on X)
YujunT46308 on X (magpie 0.1.3519, MiniMax Code 3.1.13 CN): with the
app's data folder moved to another parent (localRuntimeDataParentDir),
magpie went on writing ~/.minimax/config.yaml, which the app no longer
reads.

How MiniMax Code 3.1.13 finds it, read from its own app.asar
(dist/main/modules/local-runtime/data-dir.js,
resolveLocalRuntimeDataDirSelection; @mavis/config's config.js for the
runtime): MINIMAX_DATA_DIR, then MAVIS_DATA_DIR, then the desktop
setting, then ~/.minimax. Settings' data-folder move keeps the parent as
config.localRuntimeDataParentDir in its electron-store file
(storage.ipc.js: minimax-agent-cn-config.json for the China build,
minimax-agent-config.json for the global one) in Electron userData,
named by app-identity.js: "MiniMax" (CN) / "MiniMax Agent". The data
folder is <parent>/.minimax.

What changed:
- appdir.MiniMaxDirIn resolves the folder in that order, reading the
  store under ~/Library/Application Support on a Mac and %APPDATA% on
  Windows. A missing, unreadable or unparseable store, or a parent that
  isn't an absolute string, is ~/.minimax, as electron-store itself
  reads a file it can't parse as its defaults.
- internal/agent's MiniMaxDir (detection, connect, restore, Sync, Check)
  and internal/sessions' MiniMaxDir (Usage's calls) both use it; the
  Library's skills follow a.Dir. WSL's mcode still uses the distro's
  ~/.minimax (no desktop app there).
- MAVIS_DATA_DIR joins agentenv's variables, so tests sandbox it.
- agent-wiring.md and reference.md say where the folder comes from.

Run:
- On mote, the real MiniMax Code 3.1.13 CN arm64 dmg: launched with no
  setting, userData was ~/Library/Application Support/MiniMax holding
  minimax-agent-cn-config.json; with config.localRuntimeDataParentDir
  set to a folder, the next launch created <parent>/.minimax/config.yaml.
  appdir.MiniMaxDir() against that real store printed <parent>/.minimax.
  (The test data I made on mote was removed after.)
- mote-run go test -count=1 ./internal/appdir ./internal/agentenv
  ./internal/sessions ./internal/library: ok. ./internal/agent -run
  'MiniMax|Minimax|WSL|Env|Spelled|Handwired': ok.
- win-run go test -run MiniMax ./internal/appdir ./internal/agent
  ./internal/sessions: ok, TestMiniMaxDirIn and
  TestMiniMaxCodeMovedByDesktop ran (not skipped) with %APPDATA% paths.
- gofmt -l clean; go vet of the touched packages for darwin, windows
  and linux (nogui, CGO off) ok.

Broken by hand: with the desktop store read turned off,
TestMiniMaxDirIn and TestMiniMaxCodeMovedByDesktop go red (the folder
reads as ~/.minimax).

Not tried: the Windows desktop app itself (userData %APPDATA%\MiniMax
is Electron's appData plus the app name, the same rule seen on the
Mac); the global build's store with a real install; a store mid-rollback
(the app's guard writes the restored parent back to the same key on its
next launch). A user who also runs the mcode CLI without
MINIMAX_DATA_DIR has it on ~/.minimax, which magpie now leaves alone
while the desktop folder is moved.
2026-11-10 14:43:44 +08:00
yetone efb75ad1f0 gateway: client certificates (mTLS), and Remote Magpie can show one (hhdaxia on X, #5596)
hhdaxia on X asked for mTLS so a shared magpie isn't open to the internet
on a key alone; clxsh's #5596 asks Remote Magpie to send a client
certificate and key (PEM) to an Nginx doing mTLS, the server still
verified, the Gateway Key still sent, for models, the test and streaming.

Server side (magpie's own CA, internal/mtls):
- Settings -> Network and sharing -> Require a client certificate, or
  `magpie mtls on|off|issue <device>|list|revoke`. Issue saves
  client.pem, client-key.pem and ca.pem to ~/Downloads/magpie-<device>;
  the key is kept nowhere else.
- With it on, a peer that isn't this computer or a WSL distro must finish
  the TLS handshake with a certificate the CA issued and hasn't revoked
  (RequireAndVerifyClientCert + VerifyConnection -> Admits). The TLS
  config is chosen per connection, so the switch needs no relisten;
  without --tls-cert the server certificate is made by the CA in memory.
- lanGuard and ClientCertGuard (magpie web's page) refuse 403 what still
  arrives without a verified one: plain HTTP, a proxy or tunnel on
  loopback (unless MAGPIE_TRUST_PROXY=1), the page port, a connection
  from before the switch, a certificate revoked since its handshake.
- Loopback, this computer's own address and a WSL agent with its key are
  answered as before.
- A page open from another computer can't shut itself out: without a
  certificate it can't turn mTLS on, and it can't revoke or reissue the
  certificate it came with.

Client side: a provider with a base URL of the user's own (Remote
Magpie included) takes ClientCert, ClientKey and ServerCA paths (editor:
Advanced -> Client certificate). netproxy.WithClientCert shows them to
that provider's own hosts only, on a transport per identity keyed on the
files' mtimes; through an https:// proxy such a request is refused. Save
refuses half a pair, a pair that doesn't match and a CA that isn't one.

Run (on mote, at 4024df0f9, this commit before its rebase):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/mtls ./internal/netproxy ./internal/provider
  ./internal/settings ./internal/settingsapi ./internal/cli ./internal/gui
  ./internal/gateway: ok (gateway 893s). The first run had three reds of
  this change, each green at base and fixed here:
  TestEveryRouteHasACommandOrIsNamed (the mtls routes now name `magpie
  mtls`), TestSettingsSaveKeepsWhatItDoesNotSend (MTLS kept), and
  TestGoroutineDumpAnswersWhileRequestsWait (mtlsRefuses asks whether the
  peer is remote before reading settings, so a local request never waits
  on the settings lock). TestHandedOffGatewayAnswersAConnectionNotedLate
  was reset because ServeTLS now always wraps the listener: tlsListener
  hands a connection it took as Close came to the server instead of
  dropping it. -count=3 of these and every TLS/MTLS/Handover/Relisten test
  ok.
- Every route without a certificate, with a foreign one, a revoked one
  and a good one: TestMTLSOtherComputerHandshake, TestMTLSGuardEveryRoute,
  TestMTLSThisComputerAndProxies, TestMTLSToggleWithoutRelisten,
  TestMTLSRevokeMidConnection, TestClientCertGuardPage. Remote Magpie
  against an httptest server asking RequireAndVerifyClientCert: models
  and the connection test fail without the certificate and pass with it
  (TestRemoteMagpieClientCert).
- GUI: the 92 files near the change (settings-*, provider-*, editor-*,
  lan-*, i18n*, allow-ips, remote-*, mtls-settings new) in Chromium and
  WebKit: 2904 pass, 74 fail, all in nine files red the same way at base
  0791c91c5 and listed in #5872 (editor-thumbs-batched also #5886;
  provider-fetch-again #5057 #5232; provider-many-keys, -models-rest,
  -picks-stay, -typed #5475 #4396 #5233 #4673; remote-magpie #4398;
  settings-hints, settings-lines-wrap run alone at base and here: the
  same 8 reds). The whole GUI suite and the whole Go suite were not run:
  mote's suite lock had about 15 runs queued at load 31-40.

Rebased on 031938ca9 (one conflict, internal/gui/api.go's route list,
both kept) and run again there: gofmt clean, vet on three systems, go
test ./internal/{gui,cli,mtls,netproxy,provider,settings,settingsapi} ok
(cli with the next commit's line), the gateway's TLS, MTLS, Handover,
Relisten, HandedOff, GoroutineDump, ClientCert and RemoteMagpie tests ok,
TestCoreScriptBudget ok, and mtls-settings, i18n-keys, allow-ips and
provider-insecure-tls in Chromium and WebKit: 143 pass, 0 fail.

Broken by hand, each red:
- lanGuard without refuseWithoutClientCert: TestMTLSGuardEveryRoute,
  TestMTLSThisComputerAndProxies, TestMTLSRevokeMidConnection.
- VerifyClientCertIfGiven and no Admits: TestMTLSOtherComputerHandshake.
- netproxy.With keeping another provider's certificate:
  TestClientCertOnlyItsHost.
- The page-lockout and own-serial guards in internal/gui/mtls.go:
  TestSettingsMTLSPageLockout.

Not tried: a real Nginx doing mTLS; a Windows or Linux run (vet only);
installing the certificate in a browser (there is no .p12 yet); a
proxy that checks certificates itself with MAGPIE_TRUST_PROXY=1.
2026-11-10 14:27:21 +08:00
yetone 031938ca97 antigravity: 2.30 reads its gateway from ~/.gemini/config/config.json; magpie writes both (YujunT46308 on X)
Antigravity 2.30.0 moved the Enterprise Gateway settings from
~/.antigravity/settings.json to ~/.gemini/config/config.json (same
gateway/models schema, beside the app's userSettings and plugins). Each
version reads only its own file and an update copies nothing across, so
a wiring made for 2.29 left 2.30 off magpie, on every OS (the report was
Windows). The AGY_LLM_GATEWAY_* variables and admin paths are unchanged.

magpie now writes the same gateway block, listSource and defaultModelId
into both files, each with its own stash, and puts each back on
disconnect (config.json keeps userSettings/plugins; a config.json that
isn't there is not created on disconnect). Sync carries a wiring made by
an older magpie into config.json at the next start, at the level the
wired file starts on. Check judges each file.

Run:
- Windows (xiaomi-gpu, real 2.30.0 per-user install, sandbox
  USERPROFILE/APPDATA): language_server.exe headless as the hub.
  With only settings.json wired (what magpie wrote before) it lists no
  models and never resolves a gateway catalog: the report reproduced.
  With this magpie.exe (serve, provider add, `antigravity
  magpie/up/g3`): config.json gets the block beside userSettings, the LS
  logs "Resolving models from Tier 2 (Remote catalog listSource:
  http://127.0.0.1:3640/v1/models" and GetAvailableModels returns up/g3.
  `antigravity default` gives config.json back as it was and
  settings.json as {}.
- macOS (mote, real 2.30.0 language server headless): origin/main's
  magpie wires, then this tree's `magpie serve` syncs config.json, 2.30
  resolves Tier 2 from it; off restores both files.
- win-run go test -run ^TestAntigravity ./internal/agent: ok.
- mote: go test ./internal/agent; -run Antigravity ./internal/gateway
  ./internal/gui; gofmt -l; go vet ./internal/agent; GOOS=linux go vet
  -tags nogui ./...; GOOS=windows go vet ./...: all ok.

Broken by hand: config.json left out of antigravityFiles ->
TestAntigravityConfigJSON and TestAntigravitySyncWiresConfigJSON red;
Sync not connecting an unwired file -> TestAntigravitySyncWiresConfigJSON
red.

Not tried: a chat turn from the real 2.30 GUI app (only its language
server, headless); Linux's 2.30 build (same language server code path,
same home-relative file); whether the agy CLI reads config.json (it has
its own ~/.gemini/antigravity-cli/settings.json row, untouched).
2026-11-10 14:23:48 +08:00
yetone 350856f512 memory: read a backlog of conversations at once, with progress and a Stop (RealZeroP27 on X)
Every run, the hourly one and Read now alike, read at most 10
conversations (PerRun), so a backlog of 400 (All) took 40 hours.

- A run the user asks for reads every conversation due
  (memdistill.ReadAll, through distillNow): switching on, picking a
  model or a longer range, and Read now. Still one request at a time,
  at the picked model and reasoning level.
- The hourly run reads up to 30 (PerRun, was 10), more than a busy
  hour brings, so only a backlog left by a stop or a failure waits for
  it.
- The row shows how far a run has gone ("Reading conversations… 37 of
  400", Progress -> doing/of in GET /api/memory/distill), with a Stop
  (memdistill.Stop, POST /api/memory/distill/stop); switching off stops
  it too. A stop drops the request in flight, which is read next time,
  and isn't an error.
- After a run the row says how many it left unread (State.Left), and
  Read now reads them. All's menu note no longer says "10 an hour".

docs/subsystems/memory.md says all of this.

Run (mote; all at base bb4dd8679, then the Go tests again at this head
on 53280aa08, which touches sessions stats only: ok):
- go test -count=1 ./internal/memdistill ./internal/memory: ok;
  -race -count=3 ./internal/memdistill: ok
- go test -count=1 -run 'Distill|Dream|Budget' ./internal/gui: ok
- node --test library-memory.test.cjs i18n-keys.test.cjs, chromium and
  webkit, 980 and 420 wide, every language: 26 pass, 0 fail
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (memdistill,
  gui): ok. gofmt -l: clean.

A sandbox backlog: TestBacklogReadAtOnce lists 400 (Listed)
conversations under All; the hourly run reads 30 and leaves 370,
ReadAll reads all 370 with progress 1 of 370 to 370 of 370, and reads
none again.

Broken by hand:
- ReadAll capped at PerRun again: TestBacklogReadAtOnce red (read 30)
- Stop without cancelling the run: TestStopEndsTheRun times out

Not tried: a real run of a 400-conversation backlog against a real
model and account (how long it takes depends on the model; one request
each); the full suite (started after the tag).
2026-11-10 14:01:23 +08:00
yetone bb4dd86790 appdir: magpie's files and cache move to another disk, a link left where they were (CHENGJIAHEGOXIS and buhaodeshiyehao on X)
CHENGJIAHEGOXIS asked to keep magpie's data and cache on an external SSD
instead of the Mac's own disk. buhaodeshiyehao asked to keep magpie's
personal data on another disk. Settings › Sync now has a Data folder row.
It shows where magpie's files are, with Show, Move… and Move back.
`magpie data` does the same from a terminal.

- What moves: appdir.Config() and Cache() only, into <picked>/magpie/config
  and /cache. The agents' own folders and session histories stay where
  each agent reads them. A link is left at each old path, so every path
  the agents were given still works. On Windows, when symlinks need a
  privilege (#973), the link is a junction; library's junction code moved
  into appdir for this.
- Never under a running magpie. Move… explains first in the app's own
  dialog, then asks for the move (move-to.json). The app restarts itself
  through the update path's relaunch and quits, and the new process makes
  the move in cli.Main before it reads anything, once. A failed move is
  kept in move-result.json and shown under the row. When another magpie
  serves the gateway, or for magpie web, the app doesn't restart, and the
  row says the move waits, with Cancel.
- Refused before anything quits: a relative or missing folder, a
  magpie folder there with files in it, or a folder inside magpie's own.
- One disk: a rename. Across disks: a copy. The old folder is put aside
  until the link is made, and a failed copy leaves everything as it was.
- Disk unplugged: magpie stops with an error (and a native alert from the
  app, as #989) instead of starting empty and writing over the link.
- Usage history in auto backups is left for a follow-up: auto backups are
  plain JSON kept 7 times, and usage is large and synced separately.

Docs: sync-backup.md has a "Data folder on another disk" section, and
docs/start's #data-folder (en, zh, ja) describes Move….

Run (mote, at this tree on 0791c91c5):
- gofmt -l: clean
- go vet: darwin, linux -tags nogui and windows, for appdir, cli, gui and
  library: ok
- go test -count=1 ./internal/appdir ./internal/cli ./internal/library
  ./internal/gui: ok. cli was red first, on TestEveryRouteHasACommandOrIsNamed;
  the routes are now mapped to magpie data.
- Windows (xiaomi-gpu): appdir's Move tests, including TestMoveByJunction
  with symlink forced to fail with ERROR_PRIVILEGE_NOT_HELD, and
  TestDataFolderMoveRestarts: ok. TestFoldersJoinedOnce is red there,
  which is #4846 (appdir.go is untouched).
- GUI, chromium + webkit: data-folder (5 languages x 1100/420px),
  auto-backup, sync-*, settings-sections, segs-press-redraw, old-webkit,
  github-sync, s3-sync, skill-how, usage-computers,
  webdav-settings-refresh, i18n-keys and i18n-en-no-cjk: ok except
  phone-no-sideways de 375 (#5869) and s3-sync webkit en (#3413/#5872,
  red 3 of 3 on this tree too), both already red on main.
- Linux (WSL magpie-desktop): appdir -run Move and
  TestDataFolderMoveRestarts (nogui): ok.

Again after rebasing on 0a44c1c84 (mote): gofmt, the three vets, go test
./internal/appdir ./internal/cli ./internal/gui, and the GUI files
data-folder, i18n-keys, i18n-en-no-cjk, auto-backup and settings-sections
in both engines (60 of 60): ok. Pushed on 5426c43cc, which touches only
the gateway's dsh_compact and the routing plugin, none of these files.

Broken by hand (each went red):
- no removal of a half copy: TestMoveCopyFailsLeavesAll "a half copy
  is left on the disk"
- no Unreachable check for a gone disk: TestMovedDiskGoneIsUnreachable
- restarting with another magpie serving: TestDataFolderMoveRestarts
  "2 restarts"

Not tried: a real app restart making a real move on a real external disk
(the restart is the update path's relaunch, faked in the test); a real
unplug.
2026-11-10 13:46:13 +08:00
yetone 5426c43cca gateway: DSH's compaction leaves a provider out of its limit for the same model elsewhere (qtwaiter on X)
qtwaiter's DSH chat ran on WorkBuddy's deepseek-v4.1-flash until
WorkBuddy rate-limited it. A switch to Trae CN's deepseek-v4.1-flash
failed with the same 429 ("WorkBuddy: 您的使用量已超出频率限制 ...
(out of its allowance: not asked again before ...)"), while DSH's own
DeepSeek route switched fine. compaction-basic (0.2.2-rc.1, agent/request
hook) compacts on the model it switches away from before a turn on
another, whenever the history is over the new model's threshold (Trae CN
lists the model at 200000/64000, so ~84K; DSH's own routes are 1M and
never compact), and fails the switch with MODEL_SWITCH_COMPACTION_FAILED
when that compaction is refused. The compaction went to WorkBuddy, which
magpie held as out of its allowance, so every switch failed.

Now a dsh compaction whose provider has every key or account resting
(quotaHeld or timedHeld over its candidates) goes on the same model from
another provider (provider.AutoGroupOf), the widest window that is
served, allowed to the key and not resting itself
(dshCompactElsewhere in dsh_compact.go). The route records it as
Moved{Why: "dsh-compact-rested"}, which the Routing page explains in
five languages. With no such provider it stays as asked with a log
line. A compaction model set on dsh's row (#5395) is still read first.

Run (mote):
- go test -run TestDshCompact ./internal/gateway/: ok.
  TestDshCompactLeavesRestedProvider replays the screenshot's case:
  turn on workbuddy 429 (Retry-After 3600), compaction then served by
  trae-cn/deepseek-v4.1-flash with WorkBuddy not asked again, the next
  ordinary turn still held. Red on the old code with the reporter's
  exact 429 text. TestDshCompactStaysUnlessRested: not resting, no other
  provider, another agent all stay.
- go vet ./internal/gateway/ on darwin, linux (nogui) and windows; gofmt.
- go test -count=1 -timeout 45m ./internal/gateway/: ok (908.8s)
- GUI (chromium + webkit, 5 languages, 2 widths): dsh-compact-model
  20/20, routing-moved-why 20/20, i18n-keys 4/4, i18n-en-no-cjk 4/4.
At the pushed head (rebased): go vet and the TestDshCompact tests ok.
Broken by hand: skipping the stand-in (`false && m != ""`) turns
TestDshCompactLeavesRestedProvider red; removing the client.js case turns
dsh-compact-model red. Both restored.
Not tried: the real DSH app with a rate-limited WorkBuddy account. A
switch away from a model no other provider serves still fails while its
provider is out of its limit; the compaction model square covers it.
2026-11-10 13:42:14 +08:00
yetone 9e51c5c2a8 gateway keys: account groups a key may use or keep out (LeiWang_2000 on X)
LeiWang_2000 asked for account groups, so a gateway key can be limited to
a group of accounts, or keep a group out, instead of picking accounts one
by one (on top of v0.1.3504's "Keep accounts out").

An account group is a named set of accounts of any providers, kept in
account-groups.json beside caller-keys.json (access.AccountGroup). A key's
account list names one as "@<id>" (use only its accounts) or "!@<id>"
(every account but its). identityOf expands the groups of the key and of
its issuer on every request, so every route that reads the Identity
(AllowsAccount, HeldModels, the routes' model checks) holds to the group
as it is now: a membership change reaches every key naming it at once, and
an account signed out since matches nothing. Fails closed: a group gone,
or a used group with no account, holds the key to nothing
(heldToNothing); unreadable groups refuse a key naming one and leave other
keys alone. A group a key names can't be removed (the error names the
keys); ReplaceAccount moves a rotated key in the groups too. Groups are
backed up and synced (WebDAV) with the gateway keys. A magpie older than
the mark reads "@<id>" as an account of no provider and fails closed.

CLI: `magpie gateway-key groups add|set|rename|remove`, and
`gateway-key accounts <id> @Work` / `!@Work`.
GUI: an "Account groups" editor (modal, rows of name + accounts picked in
the app menu) from the keys' header; the key's account menus list the
groups as options; the badge says "Work" / "Not Work". No layout change to
the rows.

Tests:
- internal/access TestAccountGroupHoldsAKey / ...AnIssuedKey: save rules,
  name->id, used+kept-out refused, held/kept-out allows and models, a
  change reaching both keys, rotate, remove refused, empty group, groups
  gone, unreadable groups.
- internal/gateway TestGatewayKeyAccountGroupsKeyedRoutes: a held and a
  kept-out key on 7 routes, flipped by a group change, and nothing asked
  once the group is gone.
- internal/cli TestGatewayKeyAccountGroupsCLI.
- GUI gateway-key-account-groups.test.cjs: 5 languages x chromium/webkit
  x 1100/440.

Broken by hand (each red, then restored):
- identityOf not expanding groups: access test red, gateway test 403.
- a gone/empty held group not becoming heldToNothing: access test red
  ("held to an empty group"), gateway test asked kA with the group gone.

Run on mote at this tree: gofmt -l clean; go vet darwin (touched
packages), GOOS=linux -tags nogui ./..., GOOS=windows ./... clean;
go test -count=1 access, cli, gui (size budgets included), backup,
davsync, gateway: all ok;
GUI: every gateway-*.test.cjs plus i18n-keys, i18n-en-no-cjk, key-page,
plugin-kernel, readable-focus, chromium + webkit: 571 of 574 at
--test-concurrency=6. The 3 reds: gateway-caller-keys and
gateway-key-models chromium en (the 560px read, red on main too, fixed in
the next commit), and gateway-key-groups zh once, 12 of 12 alone (#1974).
Rebased on c4a542466 (regexps made lazy across 157 files): gofmt, darwin
vet, go test of the root (lazyre guard), access, gui, backup, and the
cli and gateway account-group, key and parity tests again: all ok.

Not tried: a real account's requests through a group-held key (fixture
providers only), the Windows box, the real Linux app.
2026-11-10 13:12:52 +08:00
yetone a79d16c684 routing: a rule can match on conditions: effort, subagent, message content, agent (aipha2025 on X)
A routing rule takes field/op/value conditions (Rule.Where) beside its
existing match. Fields: reasoning effort, whether the request comes from
a subagent, the user's own message that opened the turn (content), and
the agent. Ops: is, is not, contains, starts with, regex, greater/less
than. Only Claude Code and Codex say when a request is a subagent's.

- provider: rulecond.go parses and evaluates conditions; grouprule.go
  and ruleparse.go carry them in a rule.
- gateway: the request's effort, subagent flag and opening user text
  reach the rule check (ir.go, rules.go); the trace names a rule's where.
- CLI: `when="..."` on a rule; TUI shows it.
- GUI: the conditions are edited inside the existing rule row (no
  dialog), in every language (routing i18n).
- Docs: gateway-routing.md, site start pages (en, zh, ja).

Run:
- GUI: 124/124 on the touched files (routing-rule-ops, routing-rules-line,
  i18n-keys and the routing files), chromium and webkit.
- A wider 236-file GUI run is red only where the old code is red too:
  menu-input-scroll (#3402), webkit context-fold, intent-entry, row-swap.
- gofmt; go vet darwin, linux (nogui) and windows.
- go test ./internal/provider ./internal/cli ./internal/tui
  ./internal/gateway pass.
- After the rebase on origin/main c4a542466, at this head on mote:
  i18n-keys, routing-rule-ops and routing-rules-line 42/42 pass;
  go test ./internal/gui ./internal/provider ok.

Broken by hand: removing the condition loop, and forcing subagent to
false, each turn rulecond/rule_where tests red.

Not tried: a real Claude Code or Codex subagent end to end.
2026-11-10 13:10:28 +08:00
yetone c4a5424667 claude: Fetch models fetches models.dev's list first when it is old, so Fable 5.2 shows (hhdaxia on X)
hhdaxia on X (magpie 0.1.3504, Linux): the Claude subscription's Models
editor, "vendor list · just now" after Fetch models again, lists Fable
5.1 and the 5.5s but not Fable 5.2, which Claude Code's own /model has.

Cause: a Claude account's list is models.dev's anthropic list plus what
Claude Code's .claude.json says beyond it (magpie asks Anthropic
nothing). Its fetch rebuilt that list from the local models.dev cache,
which is fetched again only once it is a day old. models.dev added
claude-fable-5-2 after the user's last daily sync, so every fetch that
day answered without it. Claude Code builds /model from the catalog
baked into its binary (2.1.321 and the latest 2.1.322 both have
latest_per_family fable: claude-fable-5-2), not from its bootstrap's
additionalModelOptionsCache (here still only claude-fable-5-1[1m]),
so nothing in .claude.json would have given it either. Not
Linux-specific.

Fix: catalog.Asked, called by the Claude account's fetch, syncs
models.dev first when the cache is older than 10 minutes and wasn't
tried in that time, bounded by the fetch's context; a failure is logged
and the local catalog answers. Only in a process that keeps the catalog
fresh (the app, magpie serve), so CLI commands and tests never reach
the network. Subsystem page updated.

Run on mote at 59d9f5c7d plus this change: gofmt -l clean; go vet ./... (darwin),
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
go test -count=1 ./internal/catalog ./internal/provider ok (0.8s, 156s).
TestClaudeFetchAsksModelsDevForANewModel: a two-hour-old catalog
without Fable 5.2, a fake models.dev with it; the fetch lists it first,
a second fetch asks nothing more, and outside KeepFresh nothing is
asked.
Rebased onto 5e6fb2770 (54 files in internal/catalog and
internal/provider changed) and run again at this tree on mote:
go test -count=1 -run 'Claude|Fable|KeepFresh|Sync' ./internal/catalog
./internal/provider ok (0.6s, 30s).
Broken by hand: with the catalog.Asked call taken out of the fetch the
test is red ("Fable 5.2 not first after a fetch: [claude-haiku-5-5
claude-opus-5-5] (0 asks of models.dev)").
Real: a throwaway program on mote with a sandbox cache holding only
Fable 5.1, three hours old, called catalog.Asked against the real
https://models.dev/api.json: after it, claude-fable-5-2 is listed
(1.9s).
Not tried: the GUI click with a real Claude account; the full suite
runs after the push and a red gets an issue.
2026-11-10 13:04:57 +08:00
yetone 0791c91c5a gateway: text that isn't UTF-8 in a request body reaches the vendor as U+FFFD (laincatx on X)
A JSON body holding bytes that aren't UTF-8 (GBK, a surrogate written as
UTF-8, \xed\xa0\x80) or a lone surrogate's escape ("\ud800") was sent on
with those bytes as they came. DeepSeek and OpenAI answered 400, MiniMax
200 with nothing, so in a routing group one request worked or failed by
which member got it.

readBoundedRequestBody, which every route reading an agent's body goes
through (each API, Gemini's, count_tokens, the Codex backend path and
relay, a Codex socket's turn, served as a POST through the handler), now
makes them U+FFFD (textBody): one per bad byte, as Go's encoding/json
does. A surrogate pair's escapes, an escaped backslash before "ud800",
and multipart, audio, image or octet-stream bodies are left alone.

Why replace, not refuse (the report's option A): a tool result carries a
file's bytes as they are, and an agent resends the whole history every
turn. Anthropic answers a lone surrogate 400 ("no low surrogate in
string"), which fails every later turn of a Claude Code session; a 400
from magpie would do the same. Replacing is what Go's decoder and WHATWG
decoders do, keeps the session going, and changes only bytes that were
not text. Since nothing bad reaches the vendor, its 400 can't rest an
account or count against a key (the test checks nothing rests).

Cost: utf8.Valid plus a scan of backslashes, no copy when valid; 24 MB of
escape-dense JSON in 24.5 ms on mote (~1 GB/s).

Run (mote):
- new tests: TestBadTextReachesVendorsAsReplacement (inbound Chat,
  Responses, Messages x upstream Chat, Responses, Anthropic x six bad
  texts x stream on/off, in a user message and a tool result),
  TestBadTextOnSocketAndGemini, TestGoodTextGoesAsSent, TestTextBody:
  ok; also ok on Windows (win-run).
- broken by hand: with the textBody call removed from
  readBoundedRequestBody, TestBadTextReachesVendorsAsReplacement,
  TestGoodTextGoesAsSent and TestBadTextOnSocketAndGemini go red with the
  fake vendor's 400 (the reporter's case).
- the whole internal/gateway package: queued behind other sessions on
  mote's suite lock (2h+); the full suite runs after the tag and its
  reds are filed. Rerun at the rebased head (cdff4b726 parent e4197144a):
  the new tests and the body-reader tests (TestPayloadTooLarge*,
  TestOverLimit*) ok.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.

Not tried: a real DeepSeek/OpenAI/MiniMax request (tests never reach the
network); the strict fake answers DeepSeek's wording. Bytes in an MCP
proxy's body (/mcp/...) are not touched; that isn't a model request.
2026-11-10 12:57:48 +08:00
yetone 84a6d6a813 usage: Cursor calls made outside magpie are counted on the Usage page (WaiooT on X)
WaiooT asked for Cursor's usage to be counted. The quota card was there
already (the plugin's auth.usage); what was missing was the calls the
account made in Cursor's own editor and cursor-agent, which never pass
magpie's gateway.

The Cursor plugin (0.2.44, magpie-community/plugins f73ba656) gains
auth.calls: it reads Cursor's own usage list,
DashboardService/GetFilteredUsageEvents (the call cursor.com's Usage
page makes), keeps the signed-in user's events (owningUser = GetMe's
userId), and leaves out the conversations it sent itself for magpie.

magpie side:
- host.js: a provider says `calls` when its plugin has auth.calls; a
  `calls` RPC normalises the reply (a call without an rid or time is
  dropped, cost only when a number >= 0).
- plugin.AccountCalls / plugin.OutsideCall.
- usage.ReadOutsideCalls, run by the gateway a minute after the start
  and every 10 minutes: each account's calls since its mark go in as
  reported calls (IngestReported, request id "cursor:<usageEventId>", so
  each is written once across restarts), by agent "cursor", provider
  cursor, with Cursor's own cost. The first reading goes 30 days back,
  but never before the gateway's last call to that provider, which older
  plugin versions couldn't tell apart. A failed reading keeps its mark;
  each later one starts 30 minutes back for events listed late.
  Marks are kept in plugin-calls.json beside usage.jsonl.
- Cursor's mover min 0.2.43 -> 0.2.44 (npm view --prefer-online: 0.2.44).
- docs/subsystems/provider-plugins.md: "Calls an account made outside
  magpie".

Run (mote, at this head):
- go vet for darwin, GOOS=linux -tags nogui and GOOS=windows on
  internal/usage, internal/plugin, internal/gateway, internal/provider: ok.
- gofmt -l: clean.
- go test -count=1 -timeout 45m ./internal/usage ./internal/plugin
  ./internal/provider ./internal/gateway: all ok (usage 36s, plugin 129s, provider 152s,
  gateway 937s), at 96d9b9ccd before the rebase onto origin/main (2
  commits, none touching these files).
- Plugin: the cursor package's whole suite (410 pass) and
  scripts/check.mjs on mote; a real-account auth.calls read returned 43
  calls with models, tokens and cents.

Broken by hand:
- lastThrough's start removed: TestOutsideCallsStartAfterTheGateway red.
- RequestID left empty: TestOutsideCallsCounted red (rows written again
  after a restart).
- host.js's rid/time filter removed: TestPluginOutsideCalls red ("4
  calls, want 2").
- Plugin: owningUser and own-conversation filters removed: calls.test.mjs
  red.

Not tried:
- A full magpie gateway with the plugin installed reading a real
  account end to end (the plugin read was real; the magpie side ran
  against the fake plugin and stand-ins).
- A team account (teamId), and the Cursor editor itself (none installed
  here); the editor's and cursor-agent's calls are one list, both shown
  as the Cursor agent.
- Two computers running magpie on one Cursor account each count the
  other's gateway calls as made outside magpie.
- No GUI change: the rows use the reported-row path the Usage page has.
2026-11-10 12:22:53 +08:00
yetone 0e68455863 memory: pick how far back conversations are read, and the model's reasoning level (RealZeroP27 on X)
Learn from conversations read the last 7 days only (Back, fixed at
switch-on) and asked its model with no reasoning level. Its row now has
two more pickers, beside the model:

- How far back it reads: 7 days (default), 30, 90, 1 year or All
  (State.Days; 0 stays 7 days, so an existing distill.json keeps its own
  Since until a range is picked). A longer range reads at once. Every
  range reads from the latest 400 conversations (memdistill.Listed) at
  10 an hour (PerRun), so All is ~240 requests a day at most until the
  backlog is read; All's menu note says so.
- Thinking: Default (none sent, as before) or one of the model's own
  levels, fitted and sent with room to think the way Vision and Searcher
  do (gateway.WithSideEffort over sideEffort/replyRoom/withFixedEffort).
  The nightly tidy uses the same level, and its row shows the picker
  when distilling is off.

Fixed on the way, as the longer ranges depend on it: a conversation's
mark was dropped after 30 days while Since stayed put, so anything
older than 30 days inside Since was read again every hour. A mark is now
dropped once it is before Since, or older than 30 days and past the
oldest conversation listed.

POST /api/memory/distill takes effort and days; a bad one is a 400.
docs/subsystems/memory.md says all of this.

Run (mote; first at base 4bfac1268, then memdistill, gui Distill|Dream|Budget and both GUI files again at this head on e697e7ddf: ok, 26 pass):
- go test -count=1 ./internal/memdistill ./internal/memory ./internal/gui: ok
- go test -count=1 -run 'Distill|Dream|Effort' ./internal/gateway: ok
- node --test library-memory.test.cjs i18n-keys.test.cjs, chromium and
  webkit, 980 and 420 wide, every language: 26 pass, 0 fail
- go vet darwin; GOOS=linux -tags nogui; GOOS=windows (memdistill, gui,
  gateway): ok. gofmt -l: clean.
- win-run go test ./internal/memdistill: ok

Broken by hand:
- the old 30-day mark prune: TestOldConversationReadOnce red
- distillComplete without WithSideEffort: TestDistillCompleteThroughGateway
  red (high sent with thinking disabled, max_tokens 4096)

Not tried: a real distill run with a real account at a picked level or
over All; the full suite (started after the tag).
2026-11-10 12:16:51 +08:00
yetone 8287e24c79 usage: a card is as tall as what it holds, none stretched to the tallest (jen_celeus on X)
jen_celeus: the Usage cards didn't size to their content but filled the
whole height, leaving a large empty space. packUsage gave the last card
in each column a min-height down to where the tallest column ended
(ikunbots on X, 3deb85685, so cards in one row lined up). An OpenCode
Zen card, a plan and no windows, beside Claude Code stood as tall as
Claude's, mostly empty. Now every card is as tall as what it holds, the
last in a column too; the packing is unchanged. This reverses ikunbots'
bottom alignment on purpose: the two asks conflict, and empty space
inside a card read as broken. A head with nothing under it keeps no
margin below (.subscription-head:last-child).

usage-pack.test.cjs: each card is as tall as itself (none reaches the
tallest's end); a new case of Claude Code, OpenCode Zen with no windows
and Codex at 1400, 897 and 560 (Zen a head's height, ending at its own
content beside Claude); ikunbots' row has ragged bottoms; an opened
account makes its card taller.

Run (mote): usage-pack.test.cjs, en, zh, ja, de, chromium and webkit,
8 of 8. The 154 GUI files that load the Usage page (grep view=usage,
subscriptionUsage, subscription-card, subscription-head) plus
i18n-keys, both engines, on the previous base 0842bc517: 2692 of 2739.
The reds' 11 files run again at origin/main b596da773 and at this
change: every red at this change is red at origin/main too
(phone-no-sideways de 375, #5869; usage-fold, tray-cell-click and
codex-auto-reset webkit de, #4790); account-eye and quota-curve, red
only in the 154-file run, pass alone on both. At the pushed head (on
origin/main 4bfac1268): usage-pack, usage-card-more, usage-cards-hide,
usage-accounts-fold, usage-keys-fold, usage-shared-balance and
i18n-keys 92 of 92, go test -run Budget ./internal/gui/ ok. gofmt; go vet darwin, linux -tags
nogui, windows; go test ./internal/gui/ ok (on 0842bc517).

Broken by hand: with the last-card min-height put back, usage-pack is
red 8 of 8 (the Zen case first).

Not tried: the real app's WebKitGTK and WebView2 windows.
2026-11-10 11:50:01 +08:00
yetone add47afd82 usage: a card's ⋯ opens its menu, Hide from Overview where it is seen (jen_celeus on X)
jen_celeus asked to hide providers with no usage information, OpenCode
Zen and the like, from Usage. The hide was already there
(UsageCardsHidden, Hide from Overview, the "n hidden" line with Unhide
and Show all), but it sat behind a right-click, a long press or the drag
handle's menu, and nobody found it. Each card's head now has a ⋯ button
(quotaCardMore), the Agents row's pattern: shown on hover and keyboard
focus, always shown where nothing hovers, opening the same menu
(quotaCardMenu, now anchored on the ⋯), a second click closing it. On a
phone it keeps 22px with a 44px-high hit area that stops at the card's
edge (an even -11px inset spilled past it: usage-accounts-fold,
usage-keys-fold and usage-shared-balance said "card spills"). The long
press leaves the ⋯ alone. Its label reuses "Actions for {name}", already
in every language.

Run (mote): usage-card-more.test.cjs (new: Claude beside a Zen card with
a plan and no windows; en, zh, zh-TW, ja, de at 1200, 560 and a 390 web
phone; chromium and webkit): the ⋯ is there with its label, hidden at
rest where hover is, shown on hover, never over the head's text where
nothing hovers, menu = Hide from Overview, toggles, the hide posts
{cardsHidden:["opencode-zen-free|plan"]}, no scroll, the "1 hidden"
line's Unhide brings it back, no page errors. The 154 GUI files that
load the Usage page plus i18n-keys, both engines: see the next commit's
record. gofmt; go vet darwin, linux -tags nogui, windows;
go test ./internal/gui/ (budgets) ok.

Broken by hand: without head.append(quotaCardMore(...)) the new test is
red in every subtest (chromium 0 of 16).

Not tried: the real app's WebKitGTK and Windows WebView2 windows; the
web page on a real phone.
2026-11-10 11:47:06 +08:00
yetone 4bfac12683 plugins: downloads take a proxy of their own, apart from the vendors' (JonahFu on X)
JonahFu on X: GitHub is unreachable without a proxy, while API requests
may go direct, so plugin downloads' proxy should be set apart from the
one model requests take.

Before: plugin downloads already followed the global proxy (fetches
through http.DefaultClient and netproxy.Func, bun add and git through
netproxy.Env), so nothing ignored it; there was only no way to give
them a different one.

Now Settings › Network has a Plugin downloads row under Proxy: Same as
above (the default, unset: downloads follow the global proxy as
before), Direct, or Custom with its login, remembered as
pluginProxyCustom as Proxy's Custom is. The CLI takes it as
`magpie settings set pluginProxy <url|direct|"">`. It covers the plugins
list and Discover's lists (fetchJSONFrom), a user's own npm registry
(fetchRegistry), Bun's download (getURLFrom), bun add/update/remove and
the git commands of GitHub-installed plugins (dlEnv). The plugin host
(bun run) keeps the global proxy: its requests are the vendors'. Both
fields belong to this computer (KeepOwn) and are left out of
auto-backups, since a proxy URL may hold a password. Settings' Proxy
row and the new one are drawn by one helper (proxyRow); the core's
script budget is met by cutting the proxy rows' comments, no raise.

Run (mote, through mote-run): gofmt -l clean; go vet of the touched
packages (darwin), GOOS=linux -tags nogui ./..., GOOS=windows of the
touched packages; go test -count=1 internal/settings, settingsapi,
backup, netproxy, plugin, gui, cli all ok (gui after the comment cut;
its first run had TestCoreScriptBudget 1,352 bytes over). GUI, chromium
and webkit: settings-plugin-proxy (new, 5 languages x 2 widths),
settings-proxy-remember, settings-proxy-auth, proxy-test,
settings-sections, proxy-login-fields and the i18n files: 102 pass, 0
fail. plugin-proxy-page, proxy-own-wording, account-proxy,
provider-proxy, routing-proxy, provider-many-keys-proxy and
signin-proxy: 104 pass, 2 fail, both signin-proxy's "a subscription
with no proxy offers the global one" at 380px in Chromium, red the same
way on origin/main b596da773 (filed #5866).

Again at this commit, rebased on b596da773: gofmt, the three go vets,
the seven packages' go test (all ok, TestCoreScriptBudget included) and
settings-plugin-proxy, -remember and -auth (50 pass, 0 fail).

Broken by hand: fetchJSONFrom without netproxy.Downloads ->
TestPluginDownloadsTakeTheirOwnProxy red (the list went direct and hit
testenv's offline guard); bunCommand always taking env() -> red (bun
add's HTTPS_PROXY ""); the GUI row saving key "proxy" ->
settings-plugin-proxy 10 of 10 red in chromium.

Not tried: a real install behind a real proxy with GitHub blocked; the
Library's (skills, MCP) downloads and plugin icons (loaded by the
webview through usemagpie.ai) still follow the global proxy; Windows.
2026-11-10 11:44:17 +08:00
yetone 6ce663c0ce check-in: a time of day every daily check-in waits for (times_ang on X)
times_ang asked on X: 可以调整自动签到的时间吗. Before this, the daily
check-in had no time to choose. The loop first looks 2 minutes after start,
asks every 30 minutes, and asks as the Beijing day (UTC+8) turns. So an
account was checked in at the first look after 00:00 Beijing, on whatever
clock the computer kept.

settings.CheckinAt ("15:04", local time) is one time for every check-in:
the built-in WorkBuddy, Trae, MiniMax and Qoder ones and the plugins'
auth.checkin.
- checkinGate puts it on the Beijing day the account is checked in for:
  the first HH:MM on the computer's clock at or after that day's start.
- The loop holds each account's first ask of a Beijing day until then,
  and wakes at it.
- Within the day nothing changes: a vendor's own turn (a plugin's until),
  retries and the before-noon recheck. So a vendor day is never skipped.
- Unset keeps today's behaviour.
- A press (Check in now, `magpie accounts checkin`) is never held.

Where to set it:
- The editor's check-in groups get a Check-in time row (Off/On and a time
  box, as the warm-ups do), drawn by checkinnow.js so the core stays in
  its budget.
- The Usage card's not-yet line says "checks in from 09:00".
- From the CLI: `magpie settings set checkinAt 09:00`.

Run (on mote unless named):
- go test ./internal/provider ./internal/gui ./internal/tui; settings,
  settingsapi and cli.
- The check-in tests again with TZ=UTC and TZ=Pacific/Kiritimati.
- TestCheckinAt*/TestCheckinGate on Windows (win-run).
- TestCoreScriptBudget at the rebased head: 1,533,673 of 1,533,802.
- gofmt; go vet for darwin, linux (nogui) and windows.
- GUI: checkin-at.test.cjs (chromium and webkit, 1100 and 420 wide, en,
  zh, zh-TW, ja, de) plus 27 more files the change reaches (check-in,
  warm-at, provider-prefs, settings, i18n, gui-de/ja/zh-tw).

New tests, with the zone held in UTC+8 and in UTC-5:
- One ask per Beijing day, at the set time, with no day skipped.
- A press goes ahead of the time.
- A vendor whose day turns at 10:00 gets one ask a day at 20:00.
- Save refuses 25:00.

Broken by hand:
- The gate off: the Beijing 09:00, New York 23:30, press and vendor-day
  cases went red.
- The row not drawn: checkin-at 0 of 40.

Not tried:
- Real vendor accounts.
- The real Linux app.
- The whole GUI suite; the full Go suite runs after the tag.
2026-11-10 11:17:07 +08:00
yetone ef73a0b1ca claude bridge: a tool whose schema has a oneOf at its root reaches the model (Lee931018 on X)
Through the Claude subscription bridge, Codex desktop's browser tool
mcp__cua_repl__js never reached a Claude model; mcp__cua_repl__js_reset
did. The tools.json the run's Claude Code is handed carried each
inputSchema as the client sent it, and cua_repl__js's is a oneOf of
objects at the root, which Anthropic's API refuses, so Claude Code left
the tool out.

bridgeTools, the one place the bridge's tools are built (the first
tools.json and the tools a ToolSearch loads mid-turn), now folds each
schema with objectSchema / provider.ObjectRoot, as every Messages request
magpie builds already is (anthropic.go) and as the gateway does for
relays and xAI (object_root.go): the variants' properties merged, a field
every variant requires stays required, allOf's required all kept. A
schema with an object root goes byte for byte as it came. The checks of
a call against the original schema (answer tool) are unchanged.

Paths checked: Messages built from a translated request (objectSchema in
anthropic.go), a Messages body passed through (objectRootsBody, folded
for every upstream), Chat/Responses to relays (foldsRoots + retry on
rootUnionRefusal), Grok (grokBody). The bridge was the only one left.

Run (mote, at 48bea11dc): gofmt; go vet ./internal/gateway on darwin,
linux (nogui, CGO off) and windows; go test -run
'TestClaudeBridge|ObjectRoot|OneOf|BridgeTools|ToolNames'
./internal/gateway: ok.
Broken by hand: without the objectSchema line in bridgeTools,
TestClaudeBridgeToolsHaveObjectRoots fails (oneOf/anyOf/allOf kept at
the root, type missing).
Not tried: a real Codex desktop with the cua browser plugin and a real
Claude Code run; the whole internal/gateway package is queued behind
mote's suite lock and runs after the tag.
2026-11-10 11:13:58 +08:00
yetone 60f0433d1b dsh: a model of its own for DeepSeek Harness's compaction (Musikrv77852 on X, #5395)
DSH compacts on the session's latest model (compaction-basic with no
summarizationModel). A session on magpie/workbuddy/deepseek-v4.1-flash
switched to another model compacted on WorkBuddy first, got 429, and the
switch failed.

DeepSeek Harness's opened row on the Agents page now has a "compaction
model" square (compact_model), offered once dsh is on magpie's route. It
is magpie's own Live setting (settings.DshCompactModel), so nothing is
written into dsh's profiles and no restart is needed. The gateway moves a
dsh compaction to it (dshCompactTo, Route.Moved why "dsh-compact") when
the model is enabled, served by its exact id and allowed to the key; else
the compaction stays as asked with a log line. The Routing page says why.

On magpie's llm-pi-ai routes DSH sends no x-deepseek-harness-compact mark,
so its compaction is now known by compaction-basic's own ask
(@deepseek-ai/dsh-compaction-basic 0.0.1-rc.3, the latest) in
compactAsks. As a result DSH compactions show as Compaction in Usage and
Routing, and a group's Compact rule reaches them too.

The options are spelt magpie/<id> like the model field's, so
`magpie dsh deepseek/flash` still sets the model (fieldForValue gives a
bare value to the first field offering it). CLI: `magpie dsh
compact_model magpie/deepseek/flash`; API: /api/set. zh, zh-TW, ja and
de strings added.

Run (mote): go test -count=1 -timeout 45m on internal/gateway,
provider: ok at the base before the rebase on 0842bc517; agent, gui,
settings, settingsapi, and the gateway's TestDsh/TestCompacting/
TestRuleCompact: ok at this head. The first agent run caught the square
reading dsh's profiles at a stopped WSL distro (TestWSLColdPlaceOpensNothing,
#3896); its options now look at nothing at a cold place. go vet on darwin,
GOOS=linux -tags nogui and GOOS=windows: clean. gofmt clean. GUI in
chromium and webkit: dsh-compact-model (new, 5 languages x 2 widths),
desktop-subagent-model, codex-subagent-model, routing-moved-why,
i18n-keys, i18n-en-no-cjk, claude-subagent-effort-row,
codex-start-model-field, model-test-why and agent-connect-no-models: 140
of 140 pass; after the rebase (i18n.js changed upstream) i18n-keys,
i18n-en-no-cjk, dsh-compact-model and routing-moved-why 48 of 48.

Broken by hand, each red: dropping the compactAsks line (TestCompacting,
TestDshCompactMoved on all three protocols), skipping the move in serve
(TestDshCompactMoved), dropping the agent check (TestDshCompactLeft's
other agent), taking the square out of extra() and dropping the routing
story's case (dsh-compact-model.test.cjs).

Not tried: a real DeepSeek Harness desktop app (none on this Mac or on
mote); the compaction text was checked against the npm package's source.
DS Bot's requests can't be told from dsh's, so its compactions follow
the same setting, though it has no square of its own.
2026-11-10 11:05:59 +08:00
yetone 0842bc517e gateway keys: a key may keep some accounts out and use every other, later ones too (LeiWang_2000 on X)
A gateway key could only be held to accounts picked one by one, so an
account signed in after the key was saved was never used. An entry
"<provider>/!<account>" (access.ExcludeMark) now keeps that account out:
the key uses every other account of the provider, one added later too,
and never the one kept out.

- access: AllowsAccount refuses a kept-out account first, and counts only
  the entries naming accounts to use for "the providers it names", so a
  provider with only kept-out entries serves every other account.
  HeldModels and AccountModels ignore kept-out entries (keeping one out
  holds the key to no model). An issued key keeps out what its issuer
  does (foldAccounts). CleanAccounts resolves the ref after the mark and
  refuses an account both used and kept out. ReplaceAccount moves
  kept-out entries too. AccountsShown renders "X; every account but Z"
  for the CLI and the gateway's refusals.
- CLI: `magpie gateway-key accounts <id> relay/!Second` prints "every
  account but relay/Second"; list and models read it.
- GUI: the key row's menu has "Keep accounts out", which opens the app's
  menu (openProtoMenu, no native select); a badge names what is kept out
  and opens the same menu; an account the key was held to and is now kept
  out leaves the held ones. Strings in zh, zh-TW, ja and de.
- docs: reference.md and providers-accounts.md.

Run (mote, at this tree):
- gofmt -l internal/ clean; go vet darwin, GOOS=linux -tags nogui and
  GOOS=windows of access, cli and gateway: clean.
- go test -count=1 ./internal/access ./internal/cli ./internal/gateway: ok.
  New: TestKeptOutAccounts, TestKeptOutFolded, TestKeptOutReplaced;
  TestGatewayKeyKeptOutAccountsKeyedRoutes (chat, messages, responses,
  count_tokens, images, videos, System One and /v1/models over a key
  provider, a remote magpie and a Decide provider: the kept-out key never
  asked, every account kept out asks nothing, a key added after the
  gateway key was saved is used); TestGatewayKeyKeptOutCodexAccounts
  (Codex sign-ins, one signed in later used);
  TestGatewayKeyKeptOutQuotaCards; TestGatewayKeyAccountsCLI extended.
- GUI: gateway-key-kept-out.test.cjs, chromium and webkit, 1100 and 440
  px, en zh zh-TW ja de: 20 of 20. Every gateway-*.test.cjs and
  i18n-*.test.cjs file in both engines: 496 of 516, the 20 red all
  gateway-card's count of the row menu's items (5, now 6), updated here;
  then gateway-card, api-key-theme, gateway-connect-keys, gui-de, gui-ja
  and gui-zh-tw: 39 of 39.
- Again after rebasing onto 4869d0c96 (this commit's tree): gofmt clean,
  vet darwin/linux nogui/windows clean, go test access, cli, gateway and
  gui (TestCoreScriptBudget among them) ok; gateway-key-kept-out,
  gateway-card, gateway-key-accounts, i18n-keys, i18n-en-no-cjk, gui-zh-tw,
  gui-ja, gui-de in both engines: 61 of 61.
- Rebased onto b922e5168 (nanobot, which also adds i18n strings): go test
  gui and access ok; gateway-key-kept-out, i18n-keys, i18n-en-no-cjk,
  gui-zh-tw, gui-ja, gui-de in both engines: 37 of 37.

Broken by hand:
- AllowsAccount without its kept-out refusal: TestKeptOutAccounts,
  TestKeptOutFolded and all three TestGatewayKeyKeptOut* tests red.
- gatewayKeptOutPick keeping a held account it was told to keep out:
  gateway-key-kept-out red (the server key's accounts-key body).

Not tried: a real account kept out on a running magpie (the tests use
fake upstreams and sign-ins); Windows (no OS-specific code).
2026-11-10 10:50:26 +08:00
yetone b922e51685 agents: nanobot gets magpie as a provider of its own (Niapyaya on X)
nanobot (HKUDS/nanobot, pip install nanobot-ai) is now an agent magpie
connects. Its config is read from its own source (5c72ced, 0.4.1):
~/.nanobot/config.json, camelCase or snake_case keys, any extra key under
providers an OpenAI-compatible endpoint whose name is stripped from the
model.

magpie adds providers.magpie (apiBase at the gateway's /v1, its key, and
extraHeaders User-Agent nanobot), and sets agents.defaults provider
magpie, model magpie/<id> and contextWindowTokens when the window is
known. What the user had there, both spellings, and a modelPreset that
would go over magpie's model, is stashed and put back on disconnect,
the window as a number. A file magpie made goes again. Also in WSL
distros, with a notice in every language, the icon (a tile in app.css's
rule), READMEs, site list, docs/reference.md and agent-wiring.md.

Run:
- real nanobot 0.4.1 on mote in a sandbox HOME (~/nbsb), a sandbox
  gateway on 47812 over a fake OpenAI upstream: `magpie nanobot
  magpie/fakeup/m1` wrote the config and kept the user's relay provider
  and channels; `nanobot agent -m ping` answered "pong from fake
  upstream"; the upstream saw POST /v1/chat/completions, model m1,
  UA nanobot; `magpie nanobot default` put relay/glm-4.6 back exactly.
- go test ./internal/agent ./internal/gui ok; ./internal/gateway and
  ./internal/cli -run 'Client|UA|Agent|Empryo' ok; go vet darwin,
  linux -tags nogui, windows ok; gofmt -l clean.
- GUI, chromium 110/110 and webkit 65/65: i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone,
  icon-tile, routing-client-icons, usage-agent-filter-icons,
  agent-connect, agent-models, agent-layout.

Broken by hand, each red in TestNanobot: modelPreset not stashed
(preset left over magpie's model), the made file not removed, and the
window restored as a string.

Not tried: a real vendor behind the gateway (fake upstream only),
nanobot's long-running `nanobot gateway`/WebUI picking the change up
live, and WSL.
2026-11-10 10:27:05 +08:00
yetone 4869d0c966 library: an MCP server switches off for every agent and app, and on again as it was (swang20201 on X)
An installed server in Library could only be removed. Each server row
now has a switch after its agent chips. Per-agent chips already
existed, but in Docker gateway mode there are none, and the MCP router
gives every server to any app at its address, so nothing could turn a
server off there.

ServerOn (POST /api/library/servers/on, `magpie library mcp off|on
<name>`) reuses the Hidden/Paused pair a plugin's hidden server
already has. Off: Hidden, with its agents kept in Paused. On: those
agents get it back, or none when it had none, so the router gives it
to other apps again. Its command, env, headers, sign-in, DisabledTools
and note stay in library.json. Off, it is also left out of every
project's files (syncProjectMCP) and of subagents' mcpServers
(renderSubagent), which before had only skipped a server gone from
the library. The router's held process ends on the next prune,
because Hidden/Paused are in its hubKey. An off row is dimmed, its
chips take no click, and it is health-checked only on a click.
Strings are in zh, zh-TW, ja and de. docs/subsystems/library.md has
a row for it, and mcp-router.md names it.

Run (mote):
- go test ./internal/library ./internal/cli ./internal/gui: ok.
- go vet ./..., GOOS=linux -tags nogui, GOOS=windows: ok.
- gofmt -l: empty.
- GUI: the 145 files that touch the Library, i18n-keys and gui-*, in
  chromium and webkit. 2798 of 2881 passed.
  - i18n-keys was red because the key "{name} on" also matched core's
    "{name} on magpie". The key is now "Turn {name} on or off", and
    i18n-keys and library-mcp-on are green (26/26).
  - Nine files are red the same way on a clean origin/main 217d77848,
    with the same set failing on this branch: library-hooks,
    library-subagents, library-loading, library-items, list-sort,
    market-have, mobile-web, sidebar-tab-top and skill-where. The Library's
    tab strip shows MCP and has no RTK. Filed as #5850.
- library-mcp-on.test.cjs: en, zh, zh-TW, ja and de, in the app at
  1100px and in gateway mode at 420px, both engines, 22/22.

Broken by hand, each went red:
- project_mcp without the Hidden skip: the project's .mcp.json kept it.
- subagents without it: the subagent still named it.
- ServerOn not giving Paused back: on again, claude's file lacked it.
- the row without its switch, and the CSS without pointer-events:none
  on an off row's chips: library-mcp-on red.
- A Hidden check added to hubPrune stayed green, because hubKey
  already ends the process, so it was left out. The test still checks
  that the process ends.

Not tried: the real Docker image, and a real MCP server with a
sign-in (the test's server is a fake stdio one). The TUI has no
switch (the CLI has one).
2026-11-10 10:23:53 +08:00
yetone 0549e5301a masking: Send requests unmasked is found from Settings › Privacy and holds on every route (CrazyMouse_TT on X)
CrazyMouse_TT runs a model of their own and wanted masking off for it.
The switch already existed (the provider editor's Advanced › Send requests
unmasked, provider.Unredacted), but nothing near masking pointed to it,
and it held only on chat-shaped routes.

- Settings › Privacy has a "Sent unmasked" row: each provider set so is a
  button that opens its editor with Advanced open; with none, the row says
  where the switch is (settingsJSON.UnmaskedProviders, redact plugin's
  unmaskedRow).
- Images (draw.go), videos (video.go) and Ark's own API (native.go) go as
  written when every model they may go to is such a provider
  (unmaskedMembers); a group with one member left on stays masked, as a
  chat's route does (unredactedRoute).
- A Remote magpie may be set so too (SkipsRedaction no longer refuses
  it): it is sent the request as written with no X-Magpie-Masked-As, so
  it masks by its own Settings and switches, once, before any vendor
  (1d6d263ee's hop). Left off, it is masked here, as before. The editor
  says so for a remote magpie.
- Default stays off for every provider: nothing changes for anyone who
  hasn't ticked it.

app.js stays under TestCoreScriptBudget by a shorter unmaskRow call and
three trimmed comments (app.js -51 bytes vs base).

Run (mote, at this tree): gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows clean; go test -count=1 ./internal/gateway
./internal/provider ./internal/cli ./internal/masking ./internal/gui ok.
GUI (chromium + webkit, 5 languages, 1100/440px):
provider-unmasked, unmasked-providers, i18n-keys, i18n-en-no-cjk,
redact-route: 126 pass, 0 fail. masking-records.test.cjs is red the same
on origin/main 9430c5309 (#5830).

Broken by hand: SkipsRedaction refusing a remote magpie again made
TestUnredactedRemoteMagpieMasksOnItsOwnSide red; images/videos/Ark
ignoring the switch made TestUnredactedProviderDrawsWhole,
...MakesVideosWhole and ...ArkNativeWhole red; dropping
unmaskedProviders made unmasked-providers.test.cjs red.

Not tried: Windows (win-run), and a real two-machine magpie hop; the hop
is tested with two in-process gateways and a tap between them.
2026-11-10 10:03:49 +08:00
yetone 9309e28ced plugins: a plugin's provider in front of a vendor's API is that vendor to the gateway (songlairui on X, #5462, #5464)
A plugin whose provider's `api` is on a vendor's preset host (a Mistral
Vibe plugin's https://api.mistral.ai/v1) got none of what magpie does for
that vendor, since its Host() is the plugin's id. An earlier turn's
thinking went to the plugin's fetch as reasoning_content, and Mistral
turned the whole request away (422 extra_forbidden); the plugin had to
rewrite the body itself.

provider.VendorHost and VendorPreset now resolve a plugin's declared `api`
host to the preset that names it (every Chat, Responses and Anthropic base
of every preset and region; local and remote magpie presets excluded, and
an api on loopback, a private address, .local or .localhost names no
vendor). For every other provider, and a moved subscription, they are
Host() and Preset as before. The gateway's vendor checks read them: 38
p.Host() sites, Mistral's, OpenRouter's, DeepSeek's, Kimi's and
DashScope's preset checks. Host() stays the plugin's id where calls are
kept and shown; requests still go only to the plugin's fetch. Search and
the video plan check are unchanged. No community plugin's api is on a
preset host today (checked at plugins 7b52e3fc), so none changes.

Any plugin gets this with no new field; documented in
docs/subsystems/provider-plugins.md and the plugin docs (en, zh, ja).

Run (mote): go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows;
go test -count=1 -timeout 45m ./internal/provider ./internal/plugin
./internal/gateway: ok (provider 209s, plugin 182s, gateway 1002s). gofmt -l clean.
Broken by hand: pluginVendor resolving nothing (the old behaviour) turns
TestPluginVendor red, and TestPluginInFrontOfMistralIsMistral red on both
halves: the translated Claude Code turn is answered Mistral's 422
extra_forbidden, and the relayed Chat request carries reasoning_content.
Not tried: a real Mistral Vibe key through the reporter's plugin; Windows
and Linux runs of the tests (no OS-specific code).
2026-11-10 10:01:59 +08:00
yetone b75aff1073 library: billion-context for Zed through its /bili/ prefix (CoMi6818 on X)
billion-context's README lists Zed, but Library's billion-context tab
offered only Pi, omp, OpenCode and Claude Code. Zed has no plugin of
bili's. Upstream gives it two routes: `bili zed`, a Linux-only launcher
that leaves a provider on loopback direct (so it never passes magpie's
gateway), and, on every system, the /bili/ prefix its docs give any
client whose model address can be edited, with `bili start` answering
on 8787.

Zed is now a URL lane (biliURLLanes, internal/library/bili_url.go).
Switched on, magpie has bili start answer (one the user runs is used;
else magpie runs its own under KeepLinked's context, logged to
bili-start.log, and starts it again at magpie's start while Zed is on),
then agent.ZedThrough sets the magpie provider's api_url to
http://127.0.0.1:8787/bili/<gateway>/v1 and saves the key for that
address in the credential store, where Zed looks it up by address. A
pick and a sync keep the prefix while magpie answers through it
(zedReach, #1985's proxy recognition). Off puts api_url back on the
gateway and ends magpie's bili start when nothing goes through it.
Zed must be on magpie first; the error says to pick a magpie model.

Run:
- bili 0.1.213 on mote: bili start --port N, then
  /bili/http://127.0.0.1:<fake magpie>/v1 forwarded GET /, GET
  /v1/models and POST /v1/chat/completions with Authorization kept and
  bili's tools injected (repro/zedroute.sh).
- mote: go test -tags nogui ./internal/library ./internal/agent (full
  packages), go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- mote: library-bili, i18n-keys, i18n-en-no-cjk GUI tests (chromium
  and webkit).
- win-run: go test ./internal/agent ./internal/library -run
  'TestZed|TestBili'.
- gofmt -l clean.

Broken by hand: SetBili without the URL-lane dispatch, and zedReach
without the proxy keep: TestBiliZedThroughPrefix and TestZedThroughBili
go red; restored, green.

Not tried: a real Zed app through bili (no Zed on mote), and the real
keychain write (zedCredential stubbed in tests, as before). Other
clients upstream lists (Cline/Roo/Kilo, Continue, OpenHands, Void,
Cursor, Warp, launcher-only lanes) are not added here.
2026-11-10 09:59:22 +08:00
yetone ffc69f0244 codex: an account can keep its access token only, never renewed (EastonXvii on X)
A Codex account can now be imported, or ticked later, as "Access token
only". magpie uses the access token it was given and never refreshes it.
The refresh token is never spent or rotated, so another computer signed
in to the same ChatGPT account stays signed in.

- Every renewal of a saved account goes through renewSaved. For an
  access-only account it calls accessOnlyToken, which hands out the
  token until it runs out and never calls codexRefresh. That covers
  requests, usage reads, the idle read, models, resets, warm-up, the
  401 recovery and the keep-alive, which also skips such accounts.
- Once the token runs out, the account is marked Lapsed with
  refreshRefused. The provider editor shows "Access expired" and
  "Import again", which opens the import with the tick set. A new
  import or sign-in replaces the entry and clears both.
- Such an account is never switched into Codex, since Codex would
  renew it. That applies to switchable, switchSavedLogin, NextLogin,
  keep-as and signInToFirst. The live or held account can't be made
  access-only (errAccessOnlyHeld). Its row says "magpie only".
- Import: ImportCodexAccessOnly accepts files that have only an access
  token, refuses an expired token or a missing id_token, and makes no
  refresh call. CLI: `magpie accounts import codex --access-only`,
  `magpie accounts access-only codex <email> [on|off]`. GUI: the
  import box tick, the row tick and POST /api/login/access-only|renewed.
- The core scripts stay within budget: app.js is smaller than main's.
  This change's own comments and nine sign-in/import comment blocks were
  cut, with no raise.

Run (on mote):
- gofmt -l clean; go vet for darwin, linux (nogui) and windows ok.
- go test ./internal/provider ./internal/cli ./internal/gui ok.
- GUI files in chromium and webkit, en and zh: codex-access-only (new),
  login-import, account-return, i18n-keys, account-row-line,
  agent-switch-accounts and signin-paste-import: 64/64 at the final
  tree. In an earlier grouped run, signin-paste-import failed once on its
  Import button's wait. It then passed 6/6 alone and in the rerun.

Broken by hand:
- With the renewSaved branch and the keep-alive skip taken out,
  TestCodexAccessOnlyNeverRefreshed went red: the keep-alive renewed
  the account. TestCodexAccessOnlyRunOutLapses went red too: a run-out
  token was handed out.
- With the branch and the import path taken out, a forced renewal went
  through and an expired-token import was "added". Both tests went red.

Not tried: a real ChatGPT account, so I did not check that another
computer stays signed in. No Windows run, since nothing here differs by
OS.
2026-11-10 09:49:30 +08:00
yetone 3aa55065a3 library: Claude Code keeps its auto-compaction beside billion-context (Kling__Lab on X)
Kling__Lab's Claude Code stopped after a little use with "Prompt is too
long", every message answered at once (作業時間 0s) with nothing sent.
bili's Claude Code install writes DISABLE_AUTO_COMPACT=1 into the shared
~/.claude/settings.json. A session bili doesn't fold then has nothing to
keep it under the window: the Claude desktop app's Code tab runs Claude
Code on that settings.json with its own ANTHROPIC_BASE_URL, past bili's
proxy (bili's own #2290), and a window bili takes larger than the one
magpie serves lets the session reach it first. With auto-compaction off,
Claude Code blocks locally at about window-3000 and returns "Prompt is
too long" without a request.

magpie now writes "0" in place of bili's added "1" right after the
install. bili leaves a value that isn't "1" as the user's, through its
SessionStart hook and a reinstall, and its remove takes only a "1". So
auto-compaction stays on as a backstop at the window magpie wrote
(CLAUDE_CODE_AUTO_COMPACT_WINDOW), which bili, when it does fold, keeps
the session under. A DISABLE_AUTO_COMPACT the user had before the install
is left as theirs. A plugin magpie installed before this is mended from
KeepLinked at start, and its bili-plugins.json record says "0" too, so
switching it off still puts the file back as it was.

Reproduced on mote with Claude Code 2.1.321 and billion-context 0.1.213
against a fake gateway reporting 195000 input tokens on a 200000 window:
with DISABLE_AUTO_COMPACT=1 the second turn is "Prompt is too long" with
no request sent; with 0 it compacts and goes on.

Run (mote-run): go test -tags nogui ./internal/library -run
'TestBili|TestParseBiliList' -v, all ok, including the new
TestBiliClaudeKeepsAutoCompact (on and off, the user's own value, a
plugin installed before), then the whole package (go test -tags nogui
./internal/library ok, 154s). gofmt -l clean; go vet ./internal/library
./internal/gui/..., GOOS=linux -tags nogui and GOOS=windows go vet
./internal/library ok.

Broken by hand: biliKeepCompact returning at once. The new test's "on
and off" and "installed before" went red (DISABLE_AUTO_COMPACT = 1 after
the install / after magpie started), "the user's own" stayed green.

Not tried: the real Claude desktop app's Code tab, and a real bili
install on a real account; the fake bili in the test copies bili 0.1.213's
"1 only when absent or 1" rule, read from its source.
2026-11-10 09:48:31 +08:00