Commit Graph
341 Commits
Author SHA1 Message Date
yetone f5e1b10913 settings: longest context can hold a model's own window too (WJaunita45604 on X)
v0.1.3681's Longest context left a window the user set for a model, or "*"
on its provider, alone even when longer. Settings > Models > Routing now has
a menu beside the field: "Models without their own" (the default, as before)
or "Every model". In both modes the shorter of the cap and the user's own
window is told; they differ only when the user's own is longer (own keeps it,
every model brings it down). Settings.ContextCapAll, Settings.CappedOwn,
POST /api/settings/context-cap-mode {all}, magpie model context-cap all|own.
Applied in provider.windowIn (so /v1/models, catalogs, compaction), Codex's
CodexNativeWindow/CodexWindow (the list's ETag tag carries the mode) and the
gateway fallback window. i18n in zh, zh-TW, ja, de.

Run (wsl-run, mote's disk was full): provider (full), settings, settingsapi,
codexcat packages; cli -run ContextCap; gateway -run ContextCap|ModelsList;
GUI context-cap, i18n-keys, model-load, settings-places, settings-general in
chromium and webkit; TestCoreScriptBudget; gofmt; go vet nogui and
GOOS=windows vet. Broken by hand: windowIn's CappedOwn removed turns
TestContextCapAllHoldsTheUsersOwnWindowsToo red.
Not tried: the whole Go and GUI suites, a real Codex reading the list, macOS
or Windows runs, GUI in zh-TW/ja/de beyond the i18n-keys check.
2026-11-11 14:28:17 +08:00
yetone 4a7d222dc8 providers: an OpenCode Go key takes the usage cap an account does (@wanggenjidev on X)
Backend only; GUI follows. Tests: provider TestKeyTakesUsageCap, gateway TestKeyUsageCapPassesTheKeyOver (red with the hold removed by hand).
2026-11-11 14:18:10 +08:00
yetone 1315ac7d99 update: the first update finds a magpie without gateway.json, and a restart waits a bounded time (ljlwlcz on X)
Two edges of v0.1.3687's gateway.json:

1. The first update from a magpie older than the record found no gateway.json,
   asked 3425, said "isn't running" and left a service on MAGPIE_ADDR=0.0.0.0:10100
   on the old version. With no record, no MAGPIE_ADDR and no answer at the usual
   address, `magpie update` now tries the installed service's MAGPIE_ADDR (read
   from its unit or launch agent, daemon.Addr), the port in Settings and 3425,
   and takes the first that answers as magpie. --addr and MAGPIE_ADDR stay the
   user's word.
2. A restart asked by `magpie update` waited on "N requests" with no end (Windows
   hands nothing over, long streams never finish). The app and magpie serve now
   wait at most 10 minutes for that ask, then restart; the output says so
   ("or in 10 min at the latest, which cuts what is still running"). `magpie
   update --force` restarts at once (gateway.SetForceRestarter), and says if the
   running magpie is too old to know --force. The app's own look at the disk
   (followReplaced) and autonomous serve follow still never cut a request.

Run (mote refused SSH; win-run on xiaomi-gpu): go vet cli/gui/gateway/daemon
(windows), linux nogui vet; go test -run TestUpdate|TestServeFollow|
TestTerminalUpdate|TestRestart over cli, gui, gateway, daemon: ok except
TestUpdateThatWontStart, red on origin/main on the same box too (#6059).
Broken by hand: drain bound off, record fallback off, serve bound off: the new
tests TestTerminalUpdateWaitIsBoundedAndCanBeForced, TestUpdateFindsAMagpieThatWroteNoRecord,
TestServeFollowDrainIsBounded go red.
Not tried: a real systemd service upgrade; darwin cross vet (cgo) and the full
suite (started after the tag if mote is back).
2026-11-11 13:01:11 +08:00
yetone dd3c9042c5 tests: the saved proxies' routes and settings are named in the guards
58fb07095 (named proxies) added POST /api/proxies/save, /delete and /test
and settings.Proxies and ProxyNames with no line in either guard, so
TestEveryRouteHasACommandOrIsNamed and
TestSettingsSaveKeepsWhatItDoesNotSend went red again a minute after
c1a072636 mended them for context-cap.

The three routes are a setting saved by its own route (stage 2), beside
POST /api/proxy/check. The settings-keep test sets a saved proxy and its
name, and a Settings save keeps both (KeepOwn already carries them; no
code change).

Run on mote at origin/main 61a93b531 plus this: both guards red at
61a93b531, naming these five; ok with this, with TestCoreScriptBudget and
the gui, cli and settings packages' Proxy tests.
2026-11-11 12:28:15 +08:00
yetone c1a0726369 tests: context-cap and the catalog's model list are named in the route and settings guards
747632890 added POST /api/settings/context-cap and settings.ContextCap,
and eb56de0b5 added GET /api/catalog/models, with no line in either guard,
so TestEveryRouteHasACommandOrIsNamed and
TestSettingsSaveKeepsWhatItDoesNotSend were red on CI from 8aae124b0 on
(run 42954436265, ubuntu and macOS).

context-cap has its command, magpie model context-cap; the catalog list
is the model editor's Same as picker, with no command yet (stage 2). The
settings-keep test now sets ContextCap, which has its own route, and checks
a Settings save keeps it (it does: the test passes with no code change).

Run on mote at origin/main 245f07b19 plus this: go test -count=1
./internal/cli ok (42s). ./internal/gui: both guards ok; the package's red
tests there were TestCoreScriptBudget (next commit) and eight AppKit window
tests that wait 30s for a window over ssh (TestPanelCloseHidesIt,
TestMainWindowCorners and the like), which this change doesn't reach.
Red before: both guards on CI at 8aae124b0, naming these three.
2026-11-11 12:26:53 +08:00
yetone 5399c33728 healthcheck, update and status find the running gateway by its own record (ljlwlcz on X)
The gateway now writes gateway.json (addr, pid, role, version) in magpie's
config folder while it serves; healthcheck, update, status and the other
CLI clients read it when MAGPIE_ADDR is unset, trusting it only if the pid
on GET / matches. --addr overrides. New: magpie status [--json] for
watchdogs (role, pid, listen address).

Run: new gateway and cli tests on Windows via win-run (pass); broken by
hand (record disabled): they go red; gofmt; vet windows and linux nogui.
Not run: mote/Linux (SSH down, WSL broken), darwin vet, a real systemd
service. TestEveryRouteHasACommandOrIsNamed is red on the base for two
GUI routes, unrelated to this change.
2026-11-11 12:00:19 +08:00
yetone 7476328901 settings: one longest context for every model (WJaunita45604 on X)
Settings > Models > Routing has a Longest context field (magpie model
context-cap [<size>|off], POST /api/settings/context-cap). It lowers every
model's window to it, so a user need not set each model. A window the user
set on a model, or on its provider with "*", wins and is not capped; a model
whose window is unknown stays unknown.

It is applied where the window is derived, provider.windowIn, so /v1/models,
every agent's catalog, group windows and the compaction thresholds that
follow the window all agree. Codex's own models take it through
CodexNativeWindow, CodexWindow and codexcat.Cap on the list the gateway
serves; the list's ETag carries the cap so Codex asks again. The provider
editor's Listed value stays the vendor's.

Run (mote): provider, codexcat, cli, settings, settingsapi, gateway tests;
GUI context-cap, model-load, settings-places, i18n-keys, settings-general in
chromium and webkit (en, zh); TestCoreScriptBudget; gofmt; vet on darwin,
linux nogui and windows. Broken by hand: windowIn without the cap turns
TestContextCapHoldsEveryModelButTheOnesTheUserSet and TestModelsListContextCap
red.
Not tried: the whole GUI suite (one row added to an existing list, no new API
read on page load), a real Codex reading the capped list, Windows run.
Not covered: Claude Code's own [1m] choice (claudeRunName) and agent/claude.go's
fallback when a ref has no window.
2026-11-11 11:07:57 +08:00
yetone 0cc91af3db agy: magpie's models go in a settings file of its own, so agy's remote control works (baysonfox on X)
magpie wrote modelProvider gemini, the model and its custom models into
agy's settings.json. That made every agy an API-key session: no Google
account, so no remote control (needs the sign-in plus Google's server-side
flag), and a plain agy asked for GEMINI_API_KEY too.

Now they go in ~/.gemini/antigravity-cli/magpie-settings.json, handed to agy
as --settings for the one session (the launch command, magpie agy run, and
the function in a shell or a WSL distro). settings.json stays the user's.
An older wiring is given back (stashed model and provider) at the next Sync
or pick. agy remote-control and --remote-control run plain, on the sign-in.

Run (mote): go vet, GOOS=windows and linux nogui vet, agent/cli/sessions/update
packages (see push note). Real agy 1.5.3 in a sandbox HOME: plain agy with
the user's untouched settings.json now asks for sign-in (no GEMINI_API_KEY
error); the new launch reached a stub gateway at /v1beta/models/<m>:streamGenerateContent.
Broken by hand: remote-control bypass removed, TestAgyRun red; TestAgy red
on the old code (settings.json written).
Not tried: real remote control (needs a Google sign-in, none in the sandbox);
signed-in BYOM custom models; Windows PowerShell function run.
2026-11-11 10:31:52 +08:00
RainierandClaude Opus 5.5 4d9b798d50 web: a LazyCat box's administrators open the page with the box's sign-in (MAGPIE_WEB_SIGN_IN=lazycat) (#5987)
magpie in a LazyCat app (懒猫微服) is opened from the box's app list by
someone signed in to the box already, and asks for a key they never
saw: it is in the container's log. A package can only hand the key to
every browser that reaches the app, or put a proxy in front that adds
the key's cookie to what the box signed in.

The box's ingress, lzc-ingress, sends a browser that isn't signed in to
the box's login page, and puts on every request it passes the app the
box account (X-HC-User-ID), its role (X-HC-User-Role, ADMIN or NORMAL)
and what sent it (X-HC-Source, client for a browser), in place of what
the caller sent. With MAGPIE_WEB_SIGN_IN=lazycat webGuard takes that
sign-in besides the key: lazyCatSignIn lets in an ADMIN account sent by
a browser, each of the three named once, and tells anyone else the box's
reason.

The box's sign-in is a cookie of the box's, and the box's apps are one
site, so a browser sends it with another app's page's requests too: an
earlier build of this change let another app's page on the box include
/boot.js and read window.bootPrefs. So it is taken only for what the
page itself or the user asked for (boxFetched, the Fetch Metadata:
Sec-Fetch-Site same-origin or none, or a GET or HEAD navigation to a
document from another page), never for another page's script, frame,
fetch or form POST, nor from a browser that sends no Fetch Metadata.

It sets no cookie of the page's own, so signing out of the box signs out
of the page. The key's link and cookie work as before, /api still
answers the page alone (webOwnPage), and the gateway's client routes on
the page's port go to the gateway first (onePort), which asks for a
gateway key. StartWeb refuses another value, and lazycat where
LAZYCAT_APP_DOMAIN, which LazyCat sets in an app's containers, isn't
set: all magpie can check, so the setting is the package's word that the
box's ingress is the only way to the page's port. magpie web prints the
box's address beside the link.

Docs: reference.md's new LazyCat section, with a manifest and what must
never reach the page's port, and gui-shell.md's Browser mode row.

On a box (lzcos 1.6.2+fix.4), a probe app that echoes its request
headers: a signed-in browser's request carries X-HC-User-ID,
X-HC-User-Role ADMIN and X-HC-Source client, forged ones replaced; not
signed in, / goes to the login page and a public path gets none of the
three (forged ones taken off, repeated or in lower case too), while
X-HC-User-Groups passes on as the caller wrote it, so it is never read;
a TCP ingress passes every header as sent. Another app's container
reaches the app through the ingress alone (straight to the app's
container it times out); the box itself, and a container in its network
(network_mode: host, which a manifest may set), reach the port.

A test app made from the docs' manifest, running a build of this change
on 68cb92e8e in the image's place as its user (uid 65532): the box's
administrator opens the console with no key, and no cookie is set;
/v1/models still asks for a gateway key; from another app's page a
navigation opens the console, while a script include of /boot.js and a
frame are turned away; in the container, past the ingress, a request
with no Fetch Metadata, no X-HC-Source, NORMAL or a header twice gets a
401. Bound to /lzcapp/var/config, which the box makes as root's, magpie
couldn't write /config; bound to /lzcapp/var it can, and a gateway key
outlived the container.

Tests, through webServed with the headers the probe saw:
TestLazyCatSignInOpensThePage, TurnsAway, AsksWhereFrom, IsAskedEachTime
and IsNoGatewayKey (the client routes, with each sign-in that opens the
page), and TestWebBoxSignInChecksItsValue.
TestRemoteOpensTheOtherMagpie, new on main, gives webHandler no box
sign-in.

Run, at this tree, on 6c3f113ce: Docker golang:1.26.8 (linux/arm64):
gofmt clean; go vet -tags gtk3 ./... (with the GTK and WebKitGTK
headers, as CI), -tags nogui and GOOS=windows clean; both builds ok.
macOS 27.2 (go1.26.8, not root, a temporary HOME): go vet ./... and the
two cross vets clean, the three builds ok; go test -tags nogui ./...,
TestScriptFindsClaudeMoved skipped (it runs the real
/Applications/Claude.app, #5989): 92 packages ok; red outside
this change, each red the same at 6c3f113ce:
TestBunProxyLoginWithReservedCharacters (#3397),
TestGitUpdateInstallsTheBranchsCommitNow and
TestGitUpdateKeepsACommitPin (#5988), on this Mac's bun 1.3.11,
older than MinBun; TestEveryRouteHasACommandOrIsNamed: POST
/api/settings/join, new with e053c337a, has no command. /join, new
with it too, is a client route, so the docs' manifest lists it.

Broken by hand, each red, all green again put back; a break that lets in
what must be turned away was seen to reach the page: TurnsAway with the
once-each check out, no sender taken, the role in any case, the role or
the sender check out (IsAskedEachTime too), app:… and system alone
turned away, or the key's "open the link" kept in the box's 401;
AsksWhereFrom with boxFetched out, no Fetch Metadata taken, another
page's navigation taken of any method or into a frame, an object or an
embed (or anything but an iframe), its request for a document that isn't
a navigation, or another app's page's script (same-site, no-cors);
OpensThePage with another page's navigation taken by GET alone, or none
taken (IsNoGatewayKey too), a cookie set, or webOwnPage out;
IsAskedEachTime with the first sign-in kept; ChecksItsValue with lazycat
taken outside LazyCat or StartWeb not asking webBoxSignIn's error;
IsNoGatewayKey with the client routes behind the box's sign-in, or one
the box signs in on, or a HEAD to one, given to the page;
TestLazyCatManifestListsTheClientRoutes with /me out of the docs.

Not tried: a NORMAL account in a real browser (the box has one
account); signing out of the box in a browser; the box's own client
apps opening the page; a browser without Fetch Metadata; a header named
twice on a signed-in request through the ingress (a browser can't send
one); a multi-instance app; another lzcos version; a community plugin's
page on the box; a real vendor call through the box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 10:15:40 +08:00
yetone bf4d8f3e5d gateway keys: a model may be a re: pattern, and a key may rename a model (tsingchao on X)
Access layer, CLI and gateway; GUI and docs follow. Tests: access pattern and alias tests; gateway TestGatewayKeyModelPatternHoldsEveryRoute and TestGatewayKeyAliasRenamesAModel, each red with the pattern match or aliasRequest switched off by hand.
2026-11-11 06:24:47 +08:00
yetone 966ddff209 cli tests: Discover's plugin counts and likes routes are named in notYet
13a9f1263 added GET /api/plugins/counts and POST /api/plugins/like,
with no command or notYet line, so TestEveryRouteHasACommandOrIsNamed
went red again right after 91d4eaa70. Both are plugin routes past what
`magpie plugin` does (stage 2).

Run on mote: go test -count=1 ./internal/cli/ ok at 13a9f1263's child
91d4eaa70 plus this; red on 91d4eaa70 alone, naming the two routes.
2026-11-11 04:30:32 +08:00
yetone 91d4eaa70a cli tests: plugins/probe and Bark's two routes are named in notYet
TestEveryRouteHasACommandOrIsNamed was red on origin/main: 6af54dc9a
added POST /api/library/plugins/probe and 71c4ef2d0 added POST
/api/settings/bark and POST /api/bark/test, none with a command or a
notYet line. plugins/probe goes with skills/probe (stage 3, the
library); Bark's server, key, daily time and test push are a setting
with its own route (stage 2).

Run on mote (macOS 27, Go 1.26.8): go test -count=1 ./internal/cli/ ok
at 6fa02550a plus this. Without it, the test fails naming the three
routes.
2026-11-11 04:28:31 +08:00
yetone d77eb6d236 memory: search by meaning, on a small model on this computer
A memory search now finds what means the same in other words or another
language ("什么时候上线" finds "Releases go out on Tuesdays"), for the
MCP server's memory_search and the Library's Memory tab alike. It is off
until switched on under Memory → Search by meaning, since it downloads
paraphrase-multilingual-MiniLM-L12-v2 (Xenova's int8 ONNX, ~135 MB,
pinned revision, size and sha256 checked); switched off, the model is
deleted.

- internal/pii/guard: the BERT code runs the embedder too (LoadEmbedder,
  mean pooling; the tokenizer reads 250,002 pieces and WhitespaceSplit).
  Its vectors match ONNX Runtime's int8 to cosine >= 0.995 and are no
  further from fp32 than ORT's own; testdata carries both.
- internal/memembed: the switch, the download, vectors.bin keyed by each
  memory's sha256 (read once, again when the text changes, a cut-short
  file read as none), Keep reading in the backend, the model let go after
  10 minutes unused.
- internal/memory: memory.Semantic fuses the meaning ranking with the word
  ranking by reciprocal rank; a tie goes to the nearer in meaning, since
  a first word hit may hold one common word ("when do we release" had
  "Never delete images when..." first). Near 0.30 / Within 0.15 come from
  97 real memories and 16 queries, half Chinese for English memories:
  12 of 16 sought found with ~4 others each. Rank searches without noting
  memories used.
- GUI: the Search by meaning row (download %, memories read, failures),
  and the tab's search lists what the backend ranked first
  (POST /api/memory/rank), then word matches. zh, zh-TW, ja, de.
- docs/subsystems/memory.md: the section, out of "Not built yet".

Why not multilingual-e5-small, which this was built on first: run for
real, its cosines sat at 0.78-0.89 for everything, and a Chinese search
ranked Chinese memories over the English one it meant. e5-small, e5-base
and MiniLM were compared in ONNX Runtime on the same 97 memories; MiniLM
put the sought one first 9 of 16 and in the top 3 12 of 16, with the
rest at a median cosine of 0.16.

Run before the rebases (mote, on origin/main as of the work):
- gofmt -l internal/ clean; go vet of memembed, memory, pii/..., gui,
  library; GOOS=linux and GOOS=windows vet of memembed and pii/guard.
- MAGPIE_EMBED_DIR=~/models/pml go test -run Embedder ./internal/pii/guard:
  7 texts (CJK, full width, emoji, digits before runs of spaces) at
  0.9962-1.0000 with ORT int8.
- go test memembed, memory, memdistill, pii/..., library, browsermcp.
- Linux (magpie-desktop, -tags nogui, mote's disk was full): go test
  memembed, memory, pii/guard, gui (461s), cli (1228s, past the default
  10m timeout, so -timeout 30m); gateway -run 'MemoryMCP|OwnMCP'.
- Rebased on origin/main 3ebb1ba2c, on mote at this tree: gofmt -l
  internal/ clean; go vet of memembed, memory, pii/..., library, gui,
  gateway, and GOOS=linux and GOOS=windows vet of the first four; go
  test memembed, memory, pii/..., library, browsermcp (Embedder test on
  ~/models/pml); gateway -run 'MemoryMCP|OwnMCP'; cli -run
  'Settings|Parity|Budget'.
- Rebased again on origin/main 5d6935b11 (title bar, cli parity,
  account export, provider catalog): go vet of gui and cli; go test -run
  'Settings|Parity|Budget' of cli and gui, ok with the Bark test fix two
  commits up (TestSettingsSaveKeepsWhatItDoesNotSend, red on main).
- GUI on mote, this commit plus the next (90f4a377b, which fixes
  library-bar-more for #5982): every library-*.test.cjs, i18n-keys and
  i18n-en-no-cjk, BROWSER=chromium and webkit, 701/702 each. The red is
  library-loading's tab list, which has no "Claude plugins" (6af54dc9a)
  and is red alone at origin/main faffb1e95 (#5997). library-bili's
  webkit saved count times out about 1 run in 3, on main too (#6015).
- A real switch-on: the pinned files downloaded from Hugging Face and
  checked in 11s, 5 memories read; 什么时候上线, 端口被占用怎么办, 清理磁盘,
  回复用什么语言 and "when do we release" each find their memory first.
  缩进用什么 finds nothing (0.23 to the tabs memory, under Near).
- Broken by hand: without the tie rule, TestSearchFindsByMeaning's new
  case is red (images first).

Not run: the whole Go suite and the whole GUI suite; go test of
internal/gui and the whole of internal/cli after the rebases (WSL kept
restarting, and they passed on Linux before).
2026-11-11 04:14:58 +08:00
yetone 36b02474e0 cli: the parity table names POST /api/signin/export 2026-11-11 04:07:09 +08:00
yetone b9f8548d22 accounts: export ChatGPT and Claude accounts as Sub2API or CLIProxyAPI files (heyiwei5 and Rk1ngggg on X)
WIP commit before the full checks; body rewritten at ship.
2026-11-11 04:07:09 +08:00
yetone 696556e26c provider: Google Vertex AI takes an API key (express mode) and a base URL (Langanpaibian on X)
Vertex AI could only be signed with gcloud credentials and a project id.
A provider now takes one API key instead: a Key with no project is Vertex
express mode, asked at https://aiplatform.googleapis.com/v1/publishers/
google/models/<model>:streamGenerateContent with the key in x-goog-api-key
(Google's docs), no project, no token minted. Express serves Gemini
models only, so Base(Chat)/Base(Anthropic) are empty and the models list
drops partner and Claude models. A key with a project is asked at the
project's address, signed by the key. Vertex.BaseURL (optional, /v1
stripped) replaces Google's host for a keyed provider, such as a proxy.

Security: a Google token or gcloud credentials go only to Google's own
address. A BaseURL is honoured only with a key, and the key is the only
credential sent there; without a key Save refuses it and a providers.json
holding one has it dropped on load.

Wired through: provider.Save/normalize/Sign/Base/planModels, `magpie
provider add google-vertex <key>`, `provider key`, `provider set ... url=`,
`provider <id>` and the list, the editor's API key and Base URL fields
(app.js, 4 translations each), the Providers row pill, and the
providers-accounts subsystem page.

Run (mote-run): gofmt -l clean; go vet for darwin, linux -tags nogui and
windows over ./...; go test -run Vertex for provider, cli, gui, gateway
and tui, all green, with new tests TestVertexExpressKey,
TestVertexExpressBaseURL, TestVertexExpressEditor (fake server) and the
gateway's TestVertexExpressStreams (chat, streamed and whole, asks
/v1/publishers/google/models/... with the key header, no token minted);
vertex-editor, i18n-keys and ledger-protocol GUI files in chromium and
webkit (en and zh editor flows; the i18n check covers zh, zh-TW, ja, de).
Broken by hand: Sign without x-goog-api-key turns the provider, gui and
gateway express tests red. The existing tests that pinned "a key is
refused" now pin the new rules.

Not tried: a real Vertex AI key (no account on hand; the endpoint and
header are from Google's express-mode docs, the tests use fakes), the
full GUI suite in webkit, Windows and Linux runs of the tests.
2026-11-11 03:54:21 +08:00
yetone 5df062f0f2 provider, gui: a Claude account with its provider switched off shows its last reading, or says it is switched off, not "No allowance reported" (Kunlin03 on X)
Kunlin03 (Pro subscription, "Claude Code" switch off): the account's card
said "暂无额度数据". LoginUsage returns nothing for a provider magpie leaves
alone (switched off or removed, leftAlone), so /api/login/usage answered {}
and the card had neither a reading nor an error, although left_alone.go says
what was last known is still shown. Pro versus Max is not the cause: the
read itself (Claude Code's /usage) is the same for both.

LoginUsageShown, used by /api/login/usage and `magpie accounts`, answers such
an account from keepLast (its last reading, readDeferred, "not refreshed this
time") and, with none kept, errLeftAlone, which the card words as "Switched
off, so no allowance is read — switch it on and refresh" (4 languages).
LoginUsage itself is unchanged: warm-ups and switching act on it and must
not take a kept reading for a fresh one. Nothing is requested for a provider
left alone.

Not changed: the Usage page and a card refresh for an off provider (they
read through loginReading as before). Not tried with a real Claude Pro
account; the sandbox has none.

Run (mote): TestLoginUsageShownOfSwitchedOffClaude (red without errLeftAlone
in readDeferred), claude-off-usage-card.test.cjs in chromium and webkit, 5
languages, 2 widths (red with the quotaError branch removed), gofmt, vet
darwin/linux nogui/windows, the provider, cli and gui packages, i18n and
account/usage GUI files.
2026-11-11 02:40:18 +08:00
yetone 1d41799f2a agent: turn off every agent's telemetry from Settings › Privacy (OipsAnthony on X)
OipsAnthony on X: "magpie 设置 - 隐私,支持统一关闭所有 Agent 的遥测功能,
这个统一管理的地方优先级最高". v0.1.3562 gave Codex, Claude Code, Gemini
CLI and Qwen Code a Telemetry row each; there was no one switch for all.

Settings › Privacy now has "Turn off telemetry for all agents"
(settings.AgentTelemetryOff, POST /api/settings/agent-telemetry,
agent.SetTelemetryAll in internal/agent/telemetry_all.go):

- On: every agent found here with a telemetry switch is turned off through
  its own switch and that switch's rules (only keys the file lacks are
  written; a value of the user's own that keeps telemetry on is never
  written over: the agent stays on and the reply's "refused" names it
  and why). Each agent the switch turned off gets a stash marker,
  <id>.telemetry.all. An agent found later is turned off on the next
  state the window reads and by a one-minute gateway loop
  (KeepTelemetryAllOff, in WhileServing).
- While on, each agent's own Telemetry row shows off, says "Off for all
  agents in Settings › Privacy" and its buttons are disabled; the API
  refuses it too (ErrTelemetryAllOff).
- Off: only the marked agents are turned back on, which takes out only
  magpie's keys. An agent off by its own row or the user's own config
  before stays off.
- An unreadable settings.json is unknown: nothing is written.
- The setting is per computer (KeepOwn) and the generic settings POST
  can't change it (settingsapi.Merge carries it).

app.js pays for its ~650 bytes with ten Privacy-section comments cut
(core 1,533,550, under its 1,533,802 budget, no raise).

Run (mote, first on 10bef5fe0):
- go test -count=1 ./internal/agent ./internal/gui ./internal/cli
  ./internal/settings ./internal/settingsapi: ok, except gui's
  TestSettingsSaveKeepsWhatItDoesNotSend, red as it should be for a new
  field; with AgentTelemetryOff in its fixture it and the budget and
  parity tests pass (-run).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: clean. gofmt -l: clean.
- GUI, chromium and webkit: privacy-*.test.cjs (new
  privacy-agent-telemetry: 5 languages x 1100/640px plus a refused case
  in each engine, no scroll on click, no native select), i18n-*,
  agent-telemetry, settings-search, click-scroll: 218 of 218 pass.
- The whole GUI suite (1,367 files) was started under ~/suite.lock and
  never got it: lockf gave up after 4h with the lock held by other runs.

- Rebased on 6a81a3c62 (this commit's parent), again: go vet
  ./internal/... (darwin) and GOOS=windows vet of agent, gui, cli; the
  Telemetry, budget, settings-keep, CLI parity and route tests; GUI
  privacy-agent-telemetry, agent-telemetry, i18n-keys and
  privacy-usage-stats in both engines: 64 of 64.

Broken by hand:
- no stash marker in keepTelemetryOff: TestTelemetryAllOff red, "Gemini
  CLI not back on".
- SetTelemetry without the ErrTelemetryAllOff check: TestTelemetryAllOff
  red, "Gemini CLI's row turned on under the switch".

Not tried: a real agent's config on this computer (sandbox HOME only);
Windows runs of the new Go tests (they skip there, a #! stand-in isn't a
command on Windows; the switch's code has no OS-specific path).
2026-11-11 02:38:58 +08:00
yetone 418bb6c9e1 codex: Show Codex's own models off leaves them out of Codex's own picker (iiiiiimone on X)
The switch (#1642) only narrowed the Agents page's pickers. Codex's own list,
which the gateway hands it beside its sign-in and as the Codex app's list
file, kept every model of the ChatGPT account, also with the Codex provider
switched off. codexMerged now leaves the sign-in's visible models out when the
switch is off (provider.CodexOwnLeftOut); the model Codex is set to, models
magpie serves on a ChatGPT account and hidden jobs stay, and the list's ETag
carries the switch so Codex asks again. Codex has one openai_base_url for every
model, so one it is still set to goes through the gateway to OpenAI on its own
sign-in; a model of it can't be sent direct beside magpie's models.

Run: TestCodexListWithOwnModelsOff, red with the filter turned off (own models
all listed, ETag unchanged); gateway, provider tests at this tree.
Not tried: a real Codex app against the list.
2026-11-11 01:54:05 +08:00
yetone 025123431c library: add and remove a project's skills from the CLI (Sephiro_Lan on X, #5193)
magpie library project … does what the window's Library › Projects page
does, through the same library calls its page makes (AddProject,
RemoveProject, ProjectSkills, ProjectSkill, ProjectCopy):

  magpie library project [--json]                 the projects and their skills
  magpie library project add <dir>
  magpie library project rm <dir> [--keep-files]
  magpie library project skills <dir> [--json]
  magpie library project skill add <dir> <skill…> [agents=a,b…]
  magpie library project skill rm <dir> <skill…>
  magpie library project skill agents <dir> <skill> <a,b…|none>
  magpie library project copy <dir> on|off

<dir> may be relative or "." (library.ProjectPath / ProjectAt find the
listed project, through a link too). A skill added with no agents= goes
to the agents the page's Skills menu picks: those the project's skills
are for already, else every agent here with a project skills folder.
Each skill added says where it was placed; one that wasn't (a folder
there that isn't magpie's, left as it is) is named with why, and the
command exits 1, so a script tells "installed" from "left as it is" by
the status. --help prints the project usage; an unknown flag, command,
skill, agent or on/off value is refused, and so is rm of a skill the
project doesn't have.

Docs: the Projects row of docs/subsystems/library.md, and the site's
library page in en/zh/ja. site/public/llms-full.txt rebuilt with
`node llms-full.mjs`; it also picks up a line (Alma, Shelley) another
docs change left out of it.

Run (mote, at this tree):
- go test -count=1 -run TestLibraryProject ./internal/cli: ok; the same
  on Windows (win-run, xiaomi-gpu): ok.
- go vet ./internal/cli ./internal/library for darwin, linux (-tags nogui)
  and windows: ok. go test -count=1 ./internal/cli ./internal/library:
  ok (45s, 99s), at this head after the rebase. site: node --test worker.test.mjs: 38 pass. gofmt -l:
  clean.
- A sandbox HOME end to end with the built binary: claude and codex
  installed, three library skills, a git project. add ., skill add with
  no agents= (links in .claude/skills and .agents/skills, listed
  in .git/info/exclude, the .gitignore left as it is), a folder of the user's in .claude/skills/pdf (named,
  exit 1, untouched), agents=codex, skill agents, unknown
  skill/agent/flag/command refused, skills --json, skill rm, rm .: the
  links, magpie's folders and the exclude block gone, the user's
  folder kept.

Broken by hand: with the not-placed exit taken out, TestLibraryProjectCmd
goes red ("a folder of the user's in the way: <nil>").

Not tried: a project's MCP servers from the CLI (the issue asks for
skills; servers stay on the page), WSL agents, and a real Linux box.
2026-11-11 00:44:41 +08:00
yetone 20aff50d4f cli: name the join and HTTPS settings routes
e053c337a added POST /api/settings/join and 4623f5419 added the five
/api/settings/https routes, none named in cliForRoute or notYet, so
TestEveryRouteHasACommandOrIsNamed was red at origin/main 4623f5419.
The HTTPS routes map to 4623f5419's own `magpie https` subcommands
(status, on, ca, import, remove). Setting the join password has no
command yet (S2, with the other settings).

Ran: go test -tags nogui ./internal/cli on WSL magpie-desktop: red on
these six routes before (join first, then the five https), ok after.
2026-11-10 23:17:55 +08:00
yetone 4623f54190 gateway: HTTPS for other computers, from magpie's CA or an imported certificate (zhangly1 on X)
zhangly1 on X: Claude on another computer on the LAN needed magpie at
https://. Settings → Network and sharing → HTTPS (magpie https on)
serves other computers TLS on the gateway's own port, with a
certificate magpie's CA (the mTLS one, in ~/.config/magpie/mtls) signs
for this computer's names and addresses; this computer keeps plain
http://. The switch is read per connection, so no restart.

- Certificate row: Import… takes the user's own PEM certificate (with
  chain) and unencrypted key, in any files and order; a pair that can't
  be served (no key, no cert, a stranger key, a passphrase, run out,
  nothing PEM) is refused with the reason in the page's language and
  leaves nothing behind. Remove goes back to magpie's CA. --tls-cert
  still comes first.
- magpie's CA row: SHA-256 shown, Save puts magpie-ca.crt in Downloads;
  the gateway serves it without a key at /magpie-ca.crt to any address
  the share lets in. Rows under it give curl -kO, macOS, Windows, Linux
  and NODE_EXTRA_CA_CERTS steps with Copy.
- A page open from another computer can't turn HTTPS on or off under
  itself (it would lose its own address).
- magpie https status|on|off|import|remove|ca --out; the serve banner
  names magpie's CA or the imported file instead of "(mTLS)".
- docs/reference.md and gateway-routing.md say all of it, and that
  Windows' curl.exe needs --ssl-no-revoke for any private CA.

Run:
- gofmt -l clean; go vet linux -tags nogui ./internal/..., GOOS=windows
  and GOOS=darwin -tags nogui vet of the touched packages (WSL, mote
  refused ssh all evening).
- WSL: go test -tags nogui gateway -run HTTPS|MTLS|ClientCert|CAFile|TLS|LAN
  ok; gui -run HTTPS|MTLS|Keep ok; settings, settingsapi, mtls ok;
  cli -run Help|HTTPS|TLS|Serve|Banner|Flag|Unknown ok. The whole cli
  package hit its 40m timeout in TestEveryAgentFieldNameWritesNothing
  (#5234, #4247, not this change).
- GUI (WSL Playwright, chromium + webkit): https-settings (en, zh, 390px,
  strings in all four languages) ok, plus mtls-settings, allow-ips,
  browser-access, cors-origins, gui-de/ja/zh-tw, i18n-keys,
  i18n-en-no-cjk, lan-*, public-url*, api-key-theme,
  connect-address-kept, gateway-connect-keys, gateway-caller-keys,
  side-gateway-lan, menu-scroll. Reds at load ~130: api-key-theme
  (#5044), connect-address-kept (#5972), gateway-caller-keys (#2572),
  gui-ja (#5943), lan-docker (#4692), all red the same at base
  10bef5fe0 run beside it; allow-ips and gateway-connect-keys went red
  once under that load and pass 18/18 at concurrency 1, base and this
  change side by side.
- Real: a sandbox HOME gateway built from this tree on WSL
  (MAGPIE_ADDR=0.0.0.0:3593, a gateway key, magpie https on, magpie
  serve). From the Windows host: curl -k /magpie-ca.crt 200 without a
  key; Node fetch with NODE_EXTRA_CA_CERTS=magpie-ca.crt 200 on
  /v1/models, 401 without the key, SELF_SIGNED_CERT_IN_CHAIN without
  the CA; plain http:// 400; curl.exe --cacert needs --ssl-no-revoke
  (schannel), then 200. Cert SANs: localhost, the hostname, .local,
  127.0.0.1, ::1 and every address. magpie https import of an openssl
  CA's leaf on the running gateway: Node trusting that CA 200, magpie's
  CA alone refused. remove + off on the running gateway: plain http://
  from Windows 200. This computer's plain http:// 200 throughout.
- At the pushed tree (on origin/main ee818e8bc), WSL:
  gofmt -l clean; go vet -tags nogui linux, GOOS=windows, GOOS=darwin
  nogui of gateway, gui, cli ok; go test -run 'HTTPS|CAFile|MTLS|LAN'
  gateway, gui ok. GUI https-settings, mtls-settings, i18n-keys,
  gui-de/ja/zh-tw, allow-ips, lan-* (both engines): 147/155; reds are
  gui-ja (#5943), lan-docker (#4692), allow-ips webkit under load, and
  gui-zh-tw chromium under load (2 of 3 green alone, filed #5983).

Broken by hand:
- TLSOn without HTTPSOn: TestHTTPSOtherComputer red.
- lanGuard without the caFileOpen exemption: TestHTTPSCAFile red.
- mtls config without GetCertificate = settingsCert: all three
  serving tests red.
- app.js without renderHTTPS(s): https-settings red in both engines.

Not tried: the macOS, Windows and Linux system trust commands on a real
store (they change the box's trust); Claude Desktop itself; a darwin
GUI run (mote unreachable); the full suite before the tag (started
after it).
2026-11-10 23:05:47 +08:00
yetone 72e804d2b5 gateway: a provider set Never a fallback takes no other model's request (sonnnnnnnnnnnna on X)
sonnnnnnnnnnnna asked that a request a local uncensored model was given
never falls back to an online provider (Anthropic, OpenAI) when the local
model is full (kv slots) or down, where it could get the account banned.

A provider now has Never a fallback (NoStandIn), off by default: the
Providers page's right-click, under Use first, ticks it; the CLI's
`magpie provider set <id> fallback-for-others=no` sets it. Its keys and
accounts are dropped from a request's plan once a candidate of an
unmarked provider was planned before them (standInsOut, run in planPaused
and in planGroup before restLast and sinkPlanned, so a local model that
failed and is resting still counts as first; a primary with nothing
planned counts too). A request that goes to a marked provider first still
moves on as before, and a weighed group (Smart, Cheapest) that picks a
marked member first sends it there. The dropped rows go to the trace's
left-out list as StandIn; the Routing page says why ("it is set never to
be a fallback for another model"), and the cap, held and barred refusal
checks ignore them so a refusal keeps its old status.

No classifier was built: the model that would judge the request is the
local one that is down, and any other would send the text somewhere the
user didn't choose.

Run on mote (macOS 27) at this tree on 065ca02c2: gofmt -l clean; go
vet darwin, GOOS=linux -tags nogui, GOOS=windows over gateway, provider,
gui, cli; go test ./internal/cli ./internal/gui ./internal/provider ok
(TestCoreScriptBudget after four comments cut in app.js, core 1,533,187
of 1,533,802, no raise), ./internal/gateway -run
'StandIn|UseFirst|Fallback|Barred|Capped|Group' ok (the whole package
ok at e6f151507); GUI in chromium and webkit, 126 of 126: stand-in (new,
5 languages, 1100 and 420 wide), provider-find (with the next commit),
use-first, menu-first-second, routing-held-member, unlisted-models,
i18n-keys, i18n-en-no-cjk; plugin-actions, routing-wb-refused and
group-found-skip ok at ca7a39291. provider-models-rest is red the same
at ca7a39291 (10 !== 83), #4396.

Broken by hand: standInsOut's drop turned off (`other && false`), and
TestNoStandInTakesNoOtherModelsRequest went red ("local down: 200 ...
from cloud2, want the spare").

Not tried: a real local model (llama.cpp/Ollama) going full or down, the
Windows box, a click in the real app.
2026-11-10 22:53:58 +08:00
yetone 7e1858515b remote magpie: name its models by the provider serving them there (lcc580 on X)
lcc580 asked for a pass-through on the Remote magpie provider: show the
upstream magpie's own provider beside each model, so an agent can tell the
same model from two of its providers apart. Before, the names followed
both magpies' Provider in model names: with either one Off, both relays'
DeepSeek Chat reached the agents as "DeepSeek Chat · Office" (or plain
"DeepSeek Chat").

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

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

Not tried: the full suite (starts after the tag); the real desktop app's
editor by hand; a chain of three real magpies (the third magpie's
magpie_by is covered by the gateway test only).
2026-11-10 22:20:17 +08:00
yetone a1ba92ad8c library: a market of Pi's packages, installed and removed by pi itself (nineruiing on X)
Library -> Pi now has a Discover list of Pi packages: npm packages with
the pi-package keyword (pi's own docs: the keyword makes a package
eligible for the pi.dev/packages gallery), sorted by monthly downloads,
with search. Like the other markets it ships a 500-entry snapshot
(market_pi.json), keeps a 6h memory and disk cache, and refreshes from
npm. Install and remove run that Pi's own `pi install npm:<name>` /
`pi remove npm:<name>` with PI_CODING_AGENT_DIR set to its folder, so
settings.json's packages list and <agentDir>/npm are written by pi, not
by magpie. Each card says which Pis have it; Install goes straight to
the only Pi without it or asks which one; the Pi's list gets a remove
button behind a confirm. New routes: GET /api/library/market/pi, POST
/api/library/pi/install and /api/library/pi/remove.

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

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

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

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

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

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

Not tried: the real app on any OS (only Playwright's engines and the Go
tests), WebKitGTK, and a real update downloaded and applied. A dialog
left open with no more input holds the restart for 15 minutes, then it
goes ahead; the wait still gives up after an hour (waitMost) as before.
2026-11-10 21:09:39 +08:00
yetone a1181b4dfe cli: name /api/speeds with the Sessions routes
e6f151507 added GET /api/speeds (the Sessions row's speed curve) with no
command and no notYet line, so TestEveryRouteHasACommandOrIsNamed was red.

Ran: go test -tags nogui ./internal/cli ./internal/library on WSL
magpie-desktop: cli red on /api/speeds before, both ok after.
2026-11-10 20:44:57 +08:00
yetone db9f0652a8 cli: name /api/gateway/pause with the gateway's restart and take-over
e8fbee60e added POST /api/gateway/pause with no command and no notYet
line, so TestEveryRouteHasACommandOrIsNamed was red at 18c932385:
"POST /api/gateway/pause has no command". It waits for stage 3 beside
/api/gateway/restart and take-over.

Run on magpie-desktop: go test -tags nogui -run
TestEveryRouteHasACommandOrIsNamed ./internal/cli red at 18c932385 with
that line, ok with this.
2026-11-10 19:56:36 +08:00
yetone e115b96411 plugin: an api sign-in whose prompts ask the key asks no second key
An OpenCode plugin's "api" auth method with its own prompts and an
authorize (inkstone's API key ways, Devin's session token in
magpie-community/plugins#928) asks the key in its prompts and returns it
from authorize(inputs). The GUI asked those prompts and then always showed
a key field of its own, so the user typed the same token twice and the
second entry went nowhere. The host's save() also copied every answer into
the account's metadata, so the token sat there a second time in plain
text.

- host.js marks such a method keyAsked (type api, prompts, authorize).
  The GUI's startPluginSignIn signs in with no key field for it, as for
  keyless, and a rejected answer asks the prompts again on Try again.
  PluginAPIKey and `magpie plugin` login skip the empty-key check for it
  (Method.NoKey).
- save() keeps only select answers (choices, never secrets) beside the
  authorize result's own metadata. A method with no authorize still keeps
  every answer, as OpenCode does.
- An authorize that gives no key, with no key typed, is now an error
  instead of an "ok" that saved nothing.

OpenCode itself differs: its v1 CLI (providers.ts) asks the prompts, then
always asks "Enter your API key", saves result.key ?? the typed key, and
merges the answers into metadata; its TUI never calls authorize for api
methods. magpie-community plugins are written for magpie's flow and read
the key from inputs, so this follows them.

Plugins that read prompt answers back from metadata (grep of
magpie-community/plugins packages): zcode (site, a select), joycode
(tenant) and agnes (keyProfile, consoleToken). None has an authorize, so
none changes. Every api+authorize plugin (inkstone, cloudflare-workers-ai,
sensenova, agnes-code, astudio, sap-aicore, Devin #928) puts what it needs
in its result's metadata itself; sensenova's apiKey: undefined
workaround is now moot.

Run on mote (macOS 27, Go 1.26.8, Playwright 1.62.0) at this change on
origin/main 9c39edb92: gofmt -l clean; go vet of internal/plugin/...
internal/gui/... internal/provider internal/cli, also GOOS=windows and
GOOS=linux -tags nogui: ok. go test ./internal/plugin/...
./internal/gui/... ./internal/provider: ok. ./internal/cli: ok but
TestEveryRouteHasACommandOrIsNamed, red the same alone on 9c39edb92
(POST /api/gateway/pause from e8fbee60e has no command), filed as #5946.
node --test, chromium and webkit, of plugin-api-prompt-key (new),
plugin-keyless-signin, plugin-password-prompt, plugin-signin,
plugin-ask-ways, plugin-key-hint, plugin-other-ways, signin-paste-key,
plugin-signin-opened, plugin-signin-scrolls, plugin-pick-sub,
plugin-two-subs, zcode-site-layout and i18n-keys: 176 of 176 ok. The new
GUI test passed 3 of 3 alone. plugin-signin-no-url is red 22 of 22 at
the base too (987eac0aa); that is #5938, commented with the macOS run.

Broken by hand: GUI back to keyless-only and host without keyAsked ->
TestAPIPromptsKeyAskedAndMetadata and plugin-api-prompt-key 22 of 22 red;
save() copying every answer again -> the Go test red (token kept twice,
the note answer kept).

Not tried: a real plugin sign-in (inkstone, Devin), the CLI path (no
test), a run on the Windows or Linux boxes, the full ./... suite.
2026-11-10 19:53:54 +08:00
yetone ea310a8c90 cli: the Vertex show test reads the "as" row by its label
07af9f86a gave every provider's show a "billing  pay as you go" row, and
TestProvidersShowVertexCredentials looked for the impersonated account
with lineWith(out, " as "), which found the billing row first. It was red
on ubuntu and macOS CI at b46f23ffa (run 42803557084): "show,
impersonating: no  as  vertex@…". The checks now take the row that its
label heads.

Run on magpie-desktop: go test -tags nogui -run
'TestProvidersShowVertex|TestProvidersAddVertex' ./internal/cli ok.
2026-11-10 19:34:34 +08:00
yetone 4011873001 catalog: models.dev unreachable falls back to the last copy or a shipped one, retried in minutes (creeksuen on X)
Where models.dev can't be reached (a network in China), the catalog that
gives prices, context windows, reasoning levels and names degraded:

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

Now:

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

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

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

Not tried: the real app started with models.dev blocked; the full suite
(started after the tag).
2026-11-10 19:26:13 +08:00
yetone 07af9f86a6 providers: mark a provider and a routing group on a plan or pay as you go (EV_John_Liu on X)
EV_John_Liu on X asked for pay-as-you-go and token plans to be marked on
providers and routing groups. A provider row now carries a quiet grey
badge, Plan, Pay as you go, or Plan + pay as you go when its keys are
on both (Volcengine's Coding Plan beside a pay-as-you-go key). It is
read from what magpie knows: a signed-in subscription is a plan; a
plan preset (Kimi Code, Qwen/Bailian token plans, OpenCode Go,
ClinePass) is a plan; a preset region's own name (Coding Plan, Token
Plan, Pay as you go) decides; other vendor and relay presets are pay as
you go. Presets whose billing magpie can't tell (MiniMax, Ollama Cloud,
ModelScope and others) and custom endpoints show nothing until the
user says: the provider editor's Advanced has Billing (Auto / Plan /
Pay as you go), and `magpie providers set <id> billing=plan|payg|auto`.
The user's word always wins. A routing group gets the same tag when
every on member is known; its title lists each member.

Run on mote with these changes on origin/main ccc96b4a7; pushed rebased
on 901e641f2, no conflict, where the core scripts weigh 1,531,382 of
their 1,533,802 (at ccc96b4a7 they were 1,934 over; main has since
moved code out, so no raise):
- go test -run 'Billing|CountFree|KeyPlan|GroupModelsCarry|ProviderSet'
  ./internal/provider ./internal/gui ./internal/cli: ok.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows.
- provider-billing.test.cjs: 5 languages, 900 and 440px, chromium and
  webkit, green (54 of 54 together with the ticks file); i18n-keys and
  i18n-en-no-cjk green.

Broken by hand: BillingKind returning "" turns TestBillingKind,
TestBillingKindMixedKeys, TestBillingEveryRegion and
TestProviderBilling red; dropping the badge turns
provider-billing.test.cjs red in every run.

Not tried: real accounts of each vendor (the marker reads saved
settings only, nothing goes upstream); the real app window. The whole
GUI suite was started after this record.
2026-11-10 18:58:03 +08:00
yetone 901e641f27 cli: name /api/model-price and /api/remote's routes
40ca0c88d (a model's price set from the Usage page, soilzhu80 on X)
added GET and POST /api/model-price with no entry in cliForRoute or
notYet, so TestEveryRouteHasACommandOrIsNamed was red on main.
`magpie model price <model>` already reads and sets a model's price
from any provider (the */model key the route stores at, anyModelPrice
in model_cli.go), so both routes are named for it.

b35867730 (a server's magpie in a window of the app, xuanwo on X) added
GET and POST /api/remote and POST /api/remote/forget the same way. They
keep the address and key of a magpie the app opens in its own window,
so they are the window's own (W) in notYet.

Run: internal/cli's TestEveryRoute and parity tests on mote at this
change, ok. Red before it: "GET /api/model-price has no command" and the POST
one (the run at 9d82986ea), and the three /api/remote lines at
b35867730 with only the model-price lines in.
2026-11-10 18:57:17 +08:00
yetone 99b080e2ee agents: an agent can have its own Provider in model names (KillTry27355 on X)
"希望 可以在不同的 agent中选择是否显示供应商名字,现在只能统一开关":
Provider in model names was one switch for every agent. An agent's
Details on the Agents page now has a Provider in model names row: As in
Settings · <mode> (the default, kept for everyone), On, Not on names I
set, or Off, for that agent alone. The CLI has the same thing:
`magpie model suffix <agent> [on|own|off|every]`.

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

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

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

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

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

Not tried: a real agent with a real account picking its own mode; WSL and
Windows agents (the @wsl: key is covered by a unit test only).
2026-11-10 18:57:16 +08:00
yetone 82962db79a routing: a rule can match the system prompt or the last user message, by words or a regex, with no model asked (SucroseMoE on X)
SucroseMoE asked for routing on plain string and regex matches instead
of an intent model: `system[0] matches /^你是对话标题命名/` → model A,
`user[-1] matches /^正在上下文压缩/` → model B, so any harness's title
and compaction calls can be routed without a classifier.

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

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

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

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

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

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

Not tried: a real harness's title or compaction request end to end
through a live gateway; the fixtures are Claude Code's, Codex's and pi's
recorded system prompts.
2026-11-10 18:48:13 +08:00
yetone 208b89422d routing: a group carries a note of its own (ConatusMoon2222 on X)
ConatusMoon2222 asked whether a routing group can have a note. It
couldn't: a group had an id and a name, nothing else of the user's.

A group now has an optional one-line note (provider.Group.Note,
"note" in providers.json). SaveGroup cleans it: whitespace and newlines
run together, cut at 200 characters (in runes), and an empty one is no
note. It is the user's own word and is never sent to an agent or a
vendor.

- Routing page: the note shows under the group's name as one muted,
  ellipsized line, the whole of it on hover, and only when there is
  one. The group editor has a Note field under Name (Enter saves, as in
  Name). Every save of the group sends it: the editor, a manual group's
  pick and a routing picked from the row, so none of them wipes it.
- CLI: `magpie group set <id> note=...` (note= clears it),
  `magpie group add ... note=...`; `magpie group <id>` and the list
  print it.
- TUI: N in a group's view edits it; the view shows it under the head.
- A copy, a shared group, a backup (StoredGroups/RestoreGroups) and
  sync (Mirror) carry it: they move whole Group structs. TestGroupNote
  checks each.

Two existing GUI tests clicked rows that the extra editor row pushed
under the view's foot bar at 420px in WebKit, which doesn't scroll the
page's own scroller to a click: group-defaults' reach() now counts in
sight as above the foot bar, and group-unlists' openAdvanced wheels the
summary into view as its other helpers do. Both passed on origin/main
and failed on this change before the fix.

Run (on mote, at this head rebased on origin/main):
- go test ./internal/provider ./internal/cli ./internal/tui ./internal/gui: ok
- gofmt -l: clean; go vet ./... darwin, GOOS=linux -tags nogui,
  GOOS=windows: ok
- GUI, chromium + webkit: group-note (en, zh, zh-TW, ja, de, and 390px),
  every group-*, routing-group-*, routing-groups-*, settings-groups,
  routing-manual, routing-save*, routing-tag-whole, fallback-group and
  i18n-* file: 752 tests, 752 pass

Broken by hand, each red:
- SaveGroup without CleanNote, and the CLI's note= without it:
  TestGroupNote and TestGroupNoteCLI fail on the uncleaned note.
- the editor's Save body without note: group-note fails (the typed note
  never posted).
- the pick and route-tag bodies without note: group-note fails (the
  note wiped by a pick).

Not tried: the real TUI by hand, the real app in Linux WebKitGTK, and
Windows (the change has no OS-specific code; windows vet ran).
2026-11-10 17:56:42 +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
yetone 488d0f9fc2 cli: name /api/memory/status with the Memory tab's routes
6a253f8af added POST /api/memory/status without a line in
settings_parity_test.go, so TestEveryRouteHasACommandOrIsNamed has been
red on ubuntu and macOS CI since (run 42779311609). It joins its
siblings under the library stage of #4745, as 71fbb33a7 did for
/api/memory/distill/stop.

Run (wsl-run, magpie-desktop; mote's ssh was resetting):
go test -tags nogui -count=1 -run TestEveryRouteHasACommandOrIsNamed
./internal/cli: red on origin/main without the line (the CI message),
ok with it.
2026-11-10 17:00:10 +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 662546e78d usage: a cache hit rate reads 100% only when all of the prompt was cached (ZhangXiaof48473 on X)
Routing's request list showed "缓存 100%" for Codex requests of 77.5K
tokens that read 77,200 of them from the cache (99.6%), beside rows at
99%, and the route line said "请求缓存命中率 99%". Every hit rate was
Math.round(100 * h) + "%", so anything from 99.5% up read 100%.

One formatter now says every hit rate: hitPct(h, d) in app.js, whole
percents (d decimals) unless rounding would say 100% or 0% of a prompt
not all or none cached, then one or two decimals (99.6%, 99.95%; never
past 99.99% or under 0.01%). Its callers: Routing's request rows, their
route line and a session's Avg. cache (plugins/routing/client.js); the
tray panel's Cache hit rate and the ranking rows' hit rate (app.js); the
Usage page's tiles, agent rows, Requests table, request detail and its
KPI strip, which keeps its one decimal (plugins/usage/page.js); the
context card's Prompt cache and the session traits Cache-friendly,
Cache misses and Cache hit (context.js). The TUI's and CLI's sessions
line, which floored the integer, use usage.HitPct, the same rule in Go;
it rounds now, so the TUI test's 67% (25.2K of 37.3K, 67.6%) reads 68%.
No new strings; app.js pays its bytes with six ledger comments cut, so
the core scripts are 15 bytes smaller than at its parent, no raise. Main
is over the core budget already (1,534,476 > 1,533,802 at the parent,
#5918); this commit doesn't add to it.

Run on mote:
- new internal/gui/tests/cache-hit-pct.test.cjs (Routing rows 99.6% /
  100% / 99%, the route line, hitPct at its edges) in chromium and
  webkit, en and zh: green; with the escalation line removed by hand,
  red (99.99% where 99.6% is wanted).
- cache-hit-pct, panel-usage, context-window, i18n-keys, usage-ledger,
  tray-totals, ctx-route, ledger-cache-hit, usage-hit-rate,
  routing-request-metrics (both engines; ledger-cache-unknown and
  ledger-cache-tokens in an earlier run): 186 pass, 6 red, all in
  usage-ledger's 'newest live route needs no return-to-live button',
  red the same on origin/main 00e8242e8 (#5048, #4078).
- go test ./internal/usage ./internal/cli ./internal/tui: ok, with
  TestHitPctNeverRoundsToAllOrNone and a 99.6% case in
  TestHitRateCountsCacheWrites (red on the old floor: 99%).
- go test ./internal/gui at the first base: TestCoreScriptBudget ok; one red,
  TestGatewayModeStatsNameTheGatewaySessions, run at 00:25 local (#5690,
  the first hour of a local day).
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
At the pushed head (rebased, comments cut): cache-hit-pct and
routing-request-metrics again, both engines, 8 of 8.
Not tried: the real app's window, or GUI files beyond those above (a
65-file run waited on mote's suite lock behind four full suites).
2026-11-10 16:28:04 +08:00
yetone 8417ae6da1 cli: the Codex service tier route is named in notYet
add0dadd4 added POST /api/settings/codex-service-tier with no command
and no notYet entry, so TestEveryRouteHasACommandOrIsNamed was red on
main. It is a setting saved by its own route, like codex-async-compact
beside it (S2).

Run (mote): go test ./internal/cli ok, red before this line
("POST /api/settings/codex-service-tier has no command").
2026-11-10 15:43:41 +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 71fbb33a79 cli: name /api/memory/distill/stop with the Memory tab's routes
350856f51 added POST /api/memory/distill/stop without a line in
settings_parity_test.go, so TestEveryRouteHasACommandOrIsNamed is red on
origin/main 031938ca9 (run on mote: red there, red at the mTLS commit
before this). It joins its siblings under the library stage of #4745
(b4a0a2a1a).

Run on mote: go test -count=1 ./internal/cli ok.
2026-11-10 14:27:21 +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 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 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 e4197144a8 perf: every package's package-level regexps compile on first use
v0.1.3516 made gateway's and redact's patterns lazy. The other 299
package-level regexp.MustCompile calls, in 148 files across agent,
provider, gui, library, codexcat, sessions, usage, plugin and the rest,
now go through lazyre.New too, so a launch that never reaches them
(`magpie statusline`, run by Claude Code on every message) doesn't
compile them. Fields, maps and params that held them are *lazyre.RE.

Measured on mote (M5 Pro), sandbox HOME, v0.1.3516-equivalent build
(t42) against this one (t43):
- GODEBUG=inittrace=1 sum: 7.39 MB / 69,837 allocs -> 4.62 MB / 46,765
- `magpie statusline`, 3 runs each: instructions retired ~212M -> ~176M,
  peak memory footprint 19.2-19.4 MB -> 16.8-17.0 MB

Run: go vet ./... (darwin) ok; GOOS=windows go vet on each of the 30
changed packages ok; GOOS=linux go vet ok except ., internal/cli and
internal/gui, which stop in wails v3's cgo files when cross-compiled
(the same at main). New TestAllLazyPatternsCompile at the root compiles
all 574 registered patterns (ok), so a bad pattern fails a test rather
than a first use.
Not run before push: the changed packages' own test suites; they run
on mote after it.
2026-11-10 12:54:39 +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 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