Commit Graph
413 Commits
Author SHA1 Message Date
yetone c01988e439 routing: a group's Small context first sends a request to the smallest window that holds it
yg6888 on X (tweet 2123308968848379920): in a group routed Smart, Cursor
Plus's Composer and Grok 4.7 were never used. Not a bug: Smart orders by
allowance tier, then soonest renewal, then listed order, and never weighs
the context window, so the 1M members listed ahead always answered. The
small ones were only ever reached as a fallback.

Smart itself is unchanged; changing its order would move every Smart
user's traffic. A group gets a new routing instead, `fit` (Small context
first; 小上下文优先, 小上下文優先, 小さいコンテキスト優先, Kleiner
Kontext zuerst):

- routes.SmallFirst takes Smart's order and sorts it stably by band (a
  provider set to be used first, the rest with room, the all but used up)
  and then by window, the smaller known first, an unknown one last.
- Its strategy sets ByWindow, so weighRouted fills Seat.Window from
  windowIn (the provider's own Contexts, else the catalog's).
- roomy already leaves out every member the request is estimated past, so
  the first left is the smallest that holds it: a small model is never
  asked for a request too long for it, and keeps its last-resort place as
  under every routing.
- The trace's rows carry `context`; the Routing page says "its 200K
  context window is the smallest that holds this request".
- A group's only: provider.normalize already drops it from a provider and
  the CLI refuses it there. GUI menu, hint, why-lines, TUI and CLI
  (`routing=fit`, small-first) carry it; docs/reference.md, the
  gateway-routing and plugin-runtime pages and the en/zh/ja start pages
  say it, with the search index rebuilt (via docs-index.mjs; #7065).

Run first at the tree rebased on origin/main 6e5882109, then at this
head's (on 856423806; search index rebuilt; gateway/routes vet, routes, rotation, ./internal/gui,
the gateway's new tests and routing-small-first, routing-group-strategy
and i18n-keys 42/42 again), mote over its
cores with another session's full suite on it and mica's disk full, so on
the Linux box (wsl-run) and the Windows box:
- go test -tags nogui ./internal/routes ./internal/cli ./internal/tui
  ./plugins/rotation ./internal/gateway -count=1 -timeout 45m: all ok but
  gateway, whose one red was this commit's own new test asserting a single
  group while an auto group for the shared model exists; fixed (FindGroup
  "group/g") and the window/strategy tests rerun ok, both new ones pass.
  ./internal/provider ok (its only FAIL was the stale search index, since
  rebuilt). ./internal/gui -run Budget ok.
- Broken by hand: SmallFirst returning Smart's order makes
  TestSmallFirstOrdersByWindow and the gateway test red ("a short request
  went to big first"); dropping fit from SaveGroup's whitelist makes the
  gateway test red ("the group didn't keep Small context first").
- GUI (Chromium + WebKit, en zh zh-TW ja de): routing-small-first,
  routing-group-strategy, i18n-keys, routing-cheapest-first,
  routing-free-expiring 112/112 before and after the rebase;
  every routing*, group* and builtins* file (253): 4139 of 4198, the 59
  reds in 11 files that fail the same at origin/main 239da9991 run alone
  (57; routing-many-keys moves between languages each run), all filed:
  #7016, #7097, #6520, #5049, #6512, #4711, #3954, #3799, #4082.
- Windows: CGO_ENABLED=0 go vet -tags nogui ./internal/... ./plugins/...
  ok. gofmt -l clean.

Not tried: the full `go test ./...` and darwin vet (mote busy, mica out
of disk); a real Cursor/Grok account in a group (the window comes from
the same windowIn roomy already trusts). Seen on the way: a recovered
"close of closed channel" in continuation_test.go's doneHold fake, no
test failed from it.
2026-11-19 17:34:30 +08:00
yetone 9bf5848c1f gateway: a Kubernetes rolling update runs two pods on one volume safely
@justforlxz on X asked for a RollingUpdate (maxSurge 1, maxUnavailable
0) with no request dropped. The docs said strategy: Recreate, because
the work only the serving magpie may do (renewing sign-ins, check-ins,
moves, plugin updates, WhileServing) was kept to one magpie only by the
gateway's port: a second couldn't bind it. Two pods each bind their own
network namespace, so in an overlap both did it, and two renewals of
one refresh token can spend it (a single-use token rotates).

Design: both pods answer requests at once (each refresh and file write
is already locked across processes: filelock, host.js lockRenew); the
serving work is held to whichever gateway holds gateway.serving.lock
(flock on the config folder, serving.go). The new pod retries every
second and takes the work over as the old pod's gateway ends (its drain
lets go first). A file system without locks is read as no other magpie,
as before.

Pods share the volume but not a pid namespace (both run magpie as pid
1), so the locks that judged a holder by its pid now judge it by host:
- host.js lockRenew records host (hostname + pid namespace); a lock of
  another host is stale by age only, never by "pid 1 is alive here".
- lockMoves (migrate.go) the same.
- gateway.json records Host; forgetListening removes only its own, so
  the old pod's end no longer removes the new pod's file (same pid,
  same Started second was enough before).
- temp and run-mark names get a random part (writeDurable, Claude run
  marks, gateway.json's temp file).

While draining (SIGTERM), every reply says Connection: close, on the
gateway and on magpie web's page port, so an agent that kept its
connection to the old pod alive dials the Service again for its next
request. Without it, the real rollout below had one broken pipe per
kept-alive connection, ~5.8s after each SIGTERM, when the drain's end
closed them.

Docs (en/zh/ja docker, reference.md): RollingUpdate maxSurge 1 /
maxUnavailable 0, the readiness probe, a required podAffinity on
kubernetes.io/hostname (a ReadWriteOnce volume mounts on one node), and
one Recreate update from a version before this one, whose old pod
doesn't take the lock.

Run:
- Real overlap, podman 4.9.3 in WSL magpie-desktop: three pods
  (pa -> pb -> pc) on one volume, each its own container (pid 1, own
  hostname and network), a Service proxy over a readiness-probed
  endpoint list (1s probe, endpoint removed 1s after SIGTERM as
  kube-proxy does), 12 agents streaming 3s SSE turns through it, half
  keeping connections alive, no retries. Before Connection: close: 226
  ok, 10 failed (broken pipe, kept-alive). After: 209 ok, 0 failed;
  second run 207 ok, 0 failed. Each new pod logged "another magpie serves", then
  "let go" as the old pod's gateway ended; gateway.json named the last
  pod.
- Broken by hand, each red then green: TestServingWorkWaitsForTheOther-
  Magpie, TestServingWaitEndsWithItsGateway, TestForgetListeningKeeps-
  AnotherPods, TestMoveLockOfAnotherPod, TestRenewLockOfAnotherPodIs-
  WaitedFor, TestDrainingRepliesCloseTheirConnection,
  TestPagePortClosesWhileDraining.
- Full suite, go test -count=1 -timeout 45m ./..., at 85305a82d (this
  change on 2926b7bef): macOS on mote, 102 packages ok; Linux
  (-tags nogui) in WSL magpie-desktop, 101 ok. Reds:
  - TestAuthLockWaitDoesNotFreezeTheHost, both: this change's
    writeDurable called randomUUID, which the test's sandbox of host.js
    doesn't give. It now names the temp file with Math.random; plugin
    then ok on mote and on Linux.
  - Not this change, filed: TestCappedIsSmall (Linux, #5975),
    TestRequestStateKeptAcrossACatalogFetchedAgain (Linux, #6572),
    TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (macOS, #7117).
  - Not a red, filed: the macOS log has a recovered "http: panic
    serving ...: close of closed channel" in the doneHold test fake
    (continuation_test.go:781); no test failed on it. It is #6505
    (also filed as #6339 and #6690).
- go vet ./..., GOOS=linux -tags nogui and GOOS=windows go vet ./... ok
  on mote; go vet -tags nogui ./... ok on Linux; gofmt -l clean.
- At the pushed head (rebased on 6e5882109), on mote: go vet (macOS,
  GOOS=linux -tags nogui, GOOS=windows) of gateway, gui, plugin and
  provider ok; go test -count=1 of gui, plugin, provider ok, gateway
  ok but #7117's TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes;
  site node --test 135 pass, 0 fail.
- New tests on Windows (win-run): gateway, provider, plugin, gui ok.

Not tried: a real Kubernetes cluster and kube-proxy (the podman harness
stands in for both); a real OAuth plugin's renewal across two pods (the
plugin test uses a fake vendor); an RWX/NFS volume's locks. A stream
that began before SIGTERM and outlasts the drain's 20s still ends with
the old pod. Pods exit 2 on SIGTERM as pid 1 (before this change too).
2026-11-19 16:20:34 +08:00
yetone 72f7c1f41a agents: Nowledge Mem's own AI runs on magpie (xiaomaomiloulou on X)
Nowledge Mem asks for "选择一个 AI" on its first page and in Settings >
AI, and Mem 0.10 has a provider type of magpie's own. Picking a magpie
model for the new agent nowledge-mem now sets it up from magpie:

- Mem keeps its providers in remote_llm.json with each key encrypted, so
  the file is only read. Changes go through its backend (nmem-server,
  127.0.0.1:14242, $NMEM_API_URL when it names this computer), as its
  Settings and `nmem config provider` do: POST /remote-llm/config saves
  provider "magpie" at the gateway's /v1 with agentKey("nowledge-mem")
  and the model, which makes it active and turns the AI on.
- Mem puts temperature, max_tokens and timeout back to its defaults
  when a save leaves them out, so every save sends the provider's own.
- What Mem had is stashed once: the active provider, whether the AI was
  on, and a "magpie" provider the user made, which keeps its key and
  gets its model, base and parameters back. Stepping out activates the
  provider Mem had (unless one was picked in Mem since), removes
  magpie's provider and turns the AI off again if it was off.
- Mem has to run to change it (errMemDown); a sync moves the base only
  when the gateway's port moved. Detected by its config folder or the
  installed app (co.nowledge.mem.desktop). Icon from its icon.icns.

Run (mote):
- go test -count=1 -run 'NowledgeMem|TestEveryAgent|TestListOnly|TestSync|Desktop'
  ./internal/agent ./internal/library ./internal/agentenv ok; -run Icon
  ./internal/gui ok.
- GUI: icon-one-tone, icon-tile, routing-client-icons, i18n-keys in
  Chromium and WebKit, 58 of 59; the red is icon-tile's dim-color, red
  on origin/main since 2649d5d72 (#6759), not this icon.
- Real Nowledge Mem 0.10.121 (free tier) in a sandbox HOME on mote, its
  nmem-server on its own port behind a logging proxy, and a sandbox
  magpie (go build of this tree) with a fake OpenAI vendor:
  `magpie nowledge-mem fakeoa/fake-model` made magpie Mem's active
  provider at the sandbox gateway; Mem's own `nmem config provider test`
  answered "Connection OK — magpie/fakeoa/fake-model", the vendor got
  the request, and `magpie usage` counted it under Nowledge Mem.
  `magpie nowledge-mem default` put openai_compatible/u2 back as active,
  removed magpie's provider, and Mem's test passed on it again.
- That run found NMEM_API_URL dropped as "not an absolute path";
  NotPaths has it now (the AGY sibling is the commit before).

- On 681f2ee7f, then rebased onto 6af38c0ee (internal/gui providers
  only, none of these packages): gofmt -l clean; go vet, GOOS=linux
  and GOOS=windows go vet of ./internal/agent ./internal/agentenv
  ./internal/library ok; the tests above again ok.
- Not run: the full go test ./... suite. mote had another session's full
  suite running and mica's disk is full (323 MB free); it runs on mote
  once that one ends, and a red gets its own issue and fix.

Broken by hand: without the check that magpie's provider is still the
active one, TestNowledgeMemKeepsALaterPick is red; without re-sending
temperature, or sending a key over the user's own magpie provider,
TestNowledgeMemKeepsTheUsersMagpie is red; with NMEM_API_URL out of
NotPaths, TestNowledgeMemOnlyOnThisComputer is red.

Not tried: Mem's window itself (the run used its API and CLI), magpie's
GUI connect row clicked, Windows and Linux (config folder per OS is
from Mem's source, not a real install), a paid Mem plan.
2026-11-19 15:44:48 +08:00
yetone 2926b7beff usage, routing: the model id a request went out under is kept and shown
daoche_wuzui on X asked how magpie serves Antigravity and whether a
request goes out under a suffixed model: nothing showed the id actually
sent. Antigravity's plugin turns gemini-3.7-flash at high effort into
gemini-3.7-flash-high, and a relay's upstream name (ModelWires) renames
a model too; the ledger and Routing showed only the routed model.

- A plugin's reply may carry X-Magpie-Sent-Model
  (provider.SentModelHeader). forward() reads it from plugin providers
  only (a non-plugin's header is ignored) and deletes it, so it never
  reaches the agent. Without it, provider.SentNameOnIn (the upstream
  name, or Antigravity's variant) is used.
- wireName keeps the id only when it differs from the model. It goes in
  usage.Record.Wire (`wire`, omitempty), the trace's Try.Wire, the
  ledger cache and a last CSV column, sent_model (docs/reference.md).
- Usage › Requests: the Sent cell and the detail show the sent id when
  there is one, with "model → sent id" on hover. Routing: a try sent
  under another id gets one aside line, "Sent to the vendor as {model}"
  (zh, zh-TW, ja, de).
- Antigravity's mover min is 0.2.4: plugins 67fb1258 sets the header on
  every reply (stream, whole and errors); its tgz is on the plugins
  repo's dist branch.

Run at this head (ef997d186 + this), on mote:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gateway, red only in TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes,
  red 5 of 5 alone at origin/main ef997d186 too (#7117, taken).
- GUI: the 46 files that reach the Usage ledger, Routing's tries and
  i18n (i18n-*, ledger-*, usage-ledger-*, routing-try-fixed, sent-model
  and the files that read the Sent cell or an aside): 230 ok; red only
  aside-native (#6212) and usage-ledger-chart's remembered metric
  (#6790), both red the same way at origin/main ef997d186. The whole
  GUI suite (1609 files) was still running at push; its reds so far are
  in account-arrange and the Codex lone-capped-account files.
- sent-model.test.cjs: 10/10, Chromium and WebKit, en zh zh-TW ja de.
- Plugin: bun test packages/antigravity 136 pass, check.mjs ok.

Rebased onto 593ea437d (three gateway/routing commits) before the push,
then again: gofmt; vet of gateway, usage and provider for darwin, linux
and windows; the new tests with the gateway's Wire, Ultrafast and Prefix
tests; sent-model and i18n-keys (14 pass): ok.

Broken by hand, each red:
- no noteWireModel call: TestPluginSentModelIsKept;
- the IsPlugin check removed: the spoofed-header case;
- no SentNameOnIn fallback: TestUpstreamNameSentIsKept;
- an id equal to the model kept: both tests;
- the old GUI assets: every sent-model case; the old usage page.js
  alone: the Sent cell assertion;
- the plugin's old index.mjs: its new test (31 pass, 1 fail).

Not tried: a real Antigravity account (the plugin's header was tested
with its fake vendor only).
2026-11-19 14:45:14 +08:00
yetone ef997d186c serve: a SIGTERM finishes the requests in flight, for Kubernetes rolling updates
@justforlxz on X runs magpie in Kubernetes and every update cut the
requests in flight. A SIGTERM ended the gateway like Ctrl+C: the
listener closed at once and Shutdown cut what was left after 2s, an
agent's stream included, with no unready phase for the Service to see.

Now a SIGTERM to `magpie serve`, `magpie web` or `serve --web`:
- GET / answers 503 {"draining":true} at once, so `magpie healthcheck`
  (the image's HEALTHCHECK, and the readiness probe the docs give) fails
  and the pod leaves its Service's endpoints;
- in a pod (KUBERNETES_SERVICE_HOST) it keeps accepting for 5s while
  that reaches kube-proxy and the ingress, then stops accepting;
- the requests in flight, streams included, get up to MAGPIE_DRAIN to
  finish: unset, 20s in a pod (k8s' default grace is 30s, with room to
  save after) and 7s elsewhere (docker stop and Compose kill at 10s,
  and a drain past that would lose the state saved at the end);
  seconds or a Go duration; 0 ends after 2s as before; an unreadable
  value logs and uses the default. magpie web's page port (which
  serves /v1 too) shuts down within the same grace.
Ctrl+C and SIGHUP end as before. Nothing to configure.

A request still answering at the end of any drain was logged as "cut"
but kept running, its upstream call too, until the process exited:
Shutdown doesn't close active connections. The gateway now closes them
after a failed Shutdown, so a gateway restarted in-process (the GUI's
restart, a test) leaves nothing holding the provider catalog
(holdCatalog). TestDrainEndsAtItsGrace's cut request, still in flight
after it returned, made the next test, TestGrokGetsAgentMessageAsUser,
read migrations.json through that hold and fail in a full gateway run
on WSL; the test now waits for it to end, and without the Close that
wait fails at 30s.

PID 1: the image's ENTRYPOINT is exec form, so magpie is PID 1 and gets
the SIGTERM itself (it calls signal.Notify). As PID 1 it exits 2 rather
than 143 after the drain, the same on the old code.

/config shared by two pods (a RollingUpdate overlap) is not verified
safe: files are flock'd and written by rename, but the serving magpie's
sign-in renewal, plugin sign-in renewal and check-ins would run in both.
The docs say one pod per volume with strategy: Recreate (an RWO volume
on another node also stalls a RollingUpdate). Requests sent between the
old pod's end and the new one's start are refused; the drain covers what
was in flight.

Docs: a Kubernetes section (Deployment with an exec readiness probe,
terminationGracePeriodSeconds, Recreate, the RWO note) and a
MAGPIE_DRAIN row on docker.html in en, zh and ja; docs/reference.md's
Docker section; site index regenerated.

Run:
- TestDrainedGatewayFinishesItsStream, TestDrainEndsAtItsGrace,
  TestHandedOverGatewayFinishesItsStream, TestReadOnlyKeyEveryRoute,
  TestDrainGrace, TestDrainOnSignal and the cli Signal tests: ok (mica).
- Broken by hand: without Drain's grace in drainFor,
  TestDrainedGatewayFinishesItsStream fails "the gateway ended with a
  stream in flight".
- Real binary (before the 7s default, which applies outside a pod
  only, and the Close), sandbox HOME, fake SSE upstream streaming 10s, SIGTERM
  at +2s, KUBERNETES_SERVICE_HOST set, magpie as PID 1 in its own pid
  namespace (unshare) on Linux (WSL magpie-desktop), serve and web:
  new: healthcheck fails while draining, a new request 1s after SIGTERM
  200, the stream completes at +10s, exit at +11s. origin/main: the new
  request is refused, the stream is cut at +4s after 4 chunks. Also
  serve on macOS (mica): same, exit status 143.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build: ok (mica), before the 7s default
  and the Close.
- Full suite, go test -count=1 -timeout 45m ./..., on Linux (WSL
  magpie-desktop; mote and mica were each running another session's
  suite) at the first version of this change on 2051dfc23: every
  package ok except root, internal/cli and internal/gui, which can't
  build there (no gtk4/webkitgtk-6.0 dev packages), and
  internal/gateway, red on TestGrokGetsAgentMessageAsUser (the hold
  above, fixed here). The doneHold "close of closed channel" panic in
  the log is #6339/#6505/#6690, not this change.
- After the fixes: internal/gateway and internal/provider whole on WSL
  ok (1075s, 156s); root, internal/cli, internal/gui on mote ok.
- At this head, rebased on 1c9c359f9: internal/cli whole and the drain,
  handover, Codex tool and Grok gateway tests ok (mote); go vet of
  gateway/cli/gui, GOOS=windows the same, GOOS=linux -tags nogui of
  gateway/cli ok (mote).

Not tried: the real Docker image build and a real Kubernetes cluster
(no Docker daemon on mote, mica or WSL; Docker Desktop on xiaomi-gpu is
not running).
2026-11-19 13:04:38 +08:00
yetone d01e0a465a agent: Dim's built-in Magpie provider is filled in, so a plain dima runs on magpie (T_t__biu on X)
T_t__biu on X: Dim alpha has a provider named Magpie built in, and
magpie's one-click connect left it empty, relying on DIM_* variables a
shell function set for each run. Dim launched any other way (its app, a
terminal opened before, an IDE) was not on magpie.

Dim keeps providers in a database only its daemon writes, so magpie now
talks to the daemon the way Dim's own clients do (JSON-RPC 2.0 after a
hello of protocol 4, on <home>/rust/daemon.sock, or on Windows through
Dim's pipe bridge `dimcode-server app-server --connect-pipe`; read from
Dim's crates/dim-app-server and dim-client source). Picking a magpie
model:
- writes the gateway's /v1 (the port magpie is on), magpie's key and
  enabled onto the `magpie` provider only, each against the record's
  version (provider.update);
- refreshes it, gives a model its token limits when the gateway doesn't
  know them (provider.models.edit), and makes it Dim's pick
  (provider.select against the pick's version);
- records first, in magpie's own dim.json (temp+rename), what was there
  and the pick to give back.
A key or address the user set on that entry themselves is kept: magpie
writes nothing to the provider and only picks the model. Sync writes the
port and key again when they change. Disconnect (`magpie dim default`
or the switch) turns the entry off with the key cleared (Dim clears a
key only on a provider turned off), puts the address back, and puts
back the model Dim was on. No other provider is read or written. The
per-run env and shell function stay only as the fallback when Dim's
daemon can't be reached or started.

Run at this commit's tree (on origin/main d048939da, then rebased over
3 commits that touch neither internal/agent nor the docs here):
- go test -run TestDim ./internal/agent on mica: 8 ok. Red on the old
  dim.go (with a stub for the new test helpers): FillsItsMagpieProvider
  (key empty), MagpieProviderPort, MagpieProviderUsersOwn/key (not
  picked), SyncMovesToProvider.
- Real Dim 0.1.0-alpha.24 (npm dimcode-alpha) in a sandbox HOME on
  mote, with a sandbox `magpie serve` on 38725 and a fake upstream:
  the user's own deepseek provider set and picked first. `magpie dim
  up/m1` left deepseek at v3 untouched, set magpie to on, 38725/v1, a
  key, and picked magpie/up/m1; a plain `dima exec -p` with no DIM_*
  set answered PONG-FROM-UPSTREAM through the gateway. `magpie dim
  default` turned magpie off, no key, 3425/v1, pick back to
  deepseek/fake/known. With a key and address set on the Magpie entry
  by hand first, connect wrote nothing to it (wrote:false) and only
  picked; disconnect gave the pick back and left the entry as set.
- Windows (xiaomi-gpu, real Dim alpha.24 in a sandbox DIMCODE_HOME):
  dimConnect through the pipe bridge did the hello and read the magpie
  provider and selection (a throwaway probe test, not committed).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... on mote: clean.
- go test -tags nogui -count=1 -timeout 45m ./... on mote (suite.lock):
  every package ok (internal/agent 372 s) except 6 reds, each red the
  same on a clean origin/main d048939da copy and already filed:
  internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr,
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223); internal/gateway
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117),
  TestLaneLimitRoutes (#5150); internal/gui
  TestSettingsSaveKeepsWhatItDoesNotSend (#7127).

Not tried: a full connect/disconnect on Windows or Linux with a real
magpie serve (only the Windows pipe read); Dim's desktop app (the CLI
and daemon only); a UNC or symlinked DIMCODE_HOME on Windows.
2026-11-19 01:38:23 +08:00
yetone 2ab2f69132 agent: Codex's status line shows the account's quota or the relay's balance (opt-in)
lyj1115 on X asked for the current account's quota, or the relay key's
balance, under Codex's chat box, off by default. Codex's TUI draws its
footer from a status line provider from 0.171.0-alpha.12 on: a stdio
MCP server whose tool advertises a statusline entrypoint, picked in
[tui] status_line_provider behind [features] tui_extensions_statusline.
Codex reads it about once a second with the thread's id. Nothing is put
into the prompt or the model's reply.

- `magpie statusline --codex` is that server. Each read asks the local
  gateway for the thread's latest route and the kept quotas (no vendor
  read). It answers `→ provider/model` and that provider's account that
  answered last, with its windows or a key's balance. A gateway that is
  down gives a null tree, never an error, because an error stops Codex's
  reads. The tool's name and words name neither magpie nor a vendor,
  since the tool is listed to the model.
- A status line square on Codex's row (`magpie codex statusline on`)
  writes the flag, [mcp_servers.quota_line] (this magpie by full path,
  args statusline --codex, env_vars = ["MAGPIE_ADDR"]) and the
  provider. Every write is read back, and the file is restored on a
  mismatch. Off and Disconnect take out only magpie's keys, and the flag
  only when the stash says magpie wrote it.
- Nothing of the user's is written over. A provider of their own, a
  quota_line of theirs, the flag turned off or an unreadable file keeps
  the square away and refuses on.
- The switch is offered only when a Codex CLI here is 0.171.0-alpha.12
  or newer (0.170.0 reads the keys and draws nothing), and only on this
  computer, not in a WSL distro.
- In the GUI, the status line square's title takes the note of its
  field's on option, which Claude Code's field already sent with the
  same words TOGGLES kept, so Codex's says its own words in en, zh,
  zh-TW, ja and de. TOGGLES' copy of Claude's note went, and app.js
  stays under its budget (30 bytes of room) without a raise.

The Codex desktop app has no such footer. cockpit-tools reaches it
through a debug port, and magpie doesn't.

Run (WSL magpie-desktop, since mote's load was over 18):
- go vet -tags nogui ./...; GOOS=windows go vet of agent, cli, provider
  and gui; gofmt -l clean.
- go test -tags nogui of ./internal/cli and ./internal/provider: ok.
- ./internal/agent -run "CodexStatus|Statusline|StatusLine|TestCodex|
  TestWSLCodex": ok.
- ./internal/gui -run "CoreScript|Budget|I18n|Keys" and node --test of
  codex-statusline, claude-statusline and i18n-keys (both engines, every
  language, window and panel), with vet (and GOOS=linux and windows
  vet) of agent, cli, provider and gui, on mote at the rebased head
  (on 1bd1a08a3): all ok, 64 of 64 GUI cases.

Broken by hand:
- free() reduced to `readable`: TestCodexStatusLineLeavesTheUsers is red
  on their provider, their server and flag off.
- The field not appended: TestCodexStatusLineSwitch is red ("no
  statusline field").
- The first build checked `at.base == nil` after codexIn had set base.
  Every agent test went red, which is how that bug was found.

Real Codex, in a sandbox HOME on WSL with a fake gateway:
- 0.171.0-alpha.13, with `magpie codex statusline on` writing config.toml,
  draws `→ relay/glm-5  relay $4.20` under the prompt, and the server is
  read about once a second.
- Without env_vars, Codex starts the server without MAGPIE_ADDR: nothing
  was asked and nothing was drawn. That is why env_vars is written.
- On a second time leaves the file byte for byte. Off brings it back to
  what it was, apart from Codex's own NUX counter.
- 0.170.0 lists quota_line from the same file and runs fine.

Not tried: macOS and Windows Codex; a real gateway with real accounts
(the server was fed through MAGPIE_ADDR); whether an open Codex session
picks the footer up without a restart.

Full suite: run after push.
2026-11-19 00:44:40 +08:00
yetone 78b6d47ccc update: a version newer than its channel's says nothing comes until the channel passes it (realfxw on X)
realfxw on X (tweet 2123033167170814171): "升级无效,重启了无数次,一直卡在这个版本",
on 0.1.4445. Every release around it has its 17 assets, so nothing was
missing to download. Their Update channel is Daily, and Daily's pick
(the 11-17 20:00 UTC cut) is 0.1.4395, older than what they run. The app
keeps the newer version and installs nothing until Daily passes it, which
is right, but the version row said "Up to date on Daily" (每日版已是最新)
and, before a check, Automatic updates are off with a bare Restart. They
restarted again and again waiting for an update that couldn't come.

- update.go: the update JSON says ahead when the state is latest and
  this version is newer than the channel's.
- app.js: the row says "Newer than Daily's 0.1.4395; it updates once
  Daily passes it", the newest on Every version after it, and Switch to
  Every version as before; one t() for both channels and the Every
  version tail shared with Up to date. Translated in zh, zh-TW, ja, de.
- update_cli.go: `magpie update check` says the same, with
  `magpie update channel every` to get it now.
- core_budget_test.go: +68 bytes of code on app.js and the core scripts,
  packed to the shortest form; renderUpdate draws on every window, so
  there is no page to move it to.
- docs/reference.md: the channel section names Daily and the line.

Red on the old code (upd-ahead-red, origin/main b855cfee9):
TestUpdateAheadOfChannel FAIL (no ahead key in the JSON),
TestUpdateAheadOfChannelSaysSo FAIL ("up to date"), and
update-stable-newest.test.cjs timed out on the ahead line in every
language.

Run at this head (253547908's tree, rebased on 4d79bebfa), on mote:
- gofmt -l clean; go vet ./internal/gui ./internal/cli ./internal/update
  for darwin, GOOS=linux -tags nogui and GOOS=windows; go build . for all
  three.
- go test -count=1 ./internal/gui ./internal/cli ./internal/update
  ./internal/settings: update and settings ok; the new tests pass; gui
  and cli red only on TestLaneLimitRoutes (#5150),
  TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
  TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr (#6471) and
  TestUpdateFindsAMagpieThatWroteNoRecord (#6223), the same on
  origin/main b855cfee9 on mote, where an ssh forward holds
  127.0.0.1:3425.
- GUI, BROWSER=chromium and webkit: update-*, i18n-*, gui-zh-tw/ja/de,
  settings-search(-reach), 28 files, 296/296 each, before the rebase;
  update-stable-newest and i18n-keys 15/15 each after it, with
  TestCoreScriptBudget ok.

Not run: the full go test ./... suite. mote and mica each had another
session's full suite running, and mica's disk is full; CI runs it.
Not tried: a real Daily install moving past it.
2026-11-18 21:44:37 +08:00
yetone 4d79bebfa7 usage: speed counts all output, reasoning and tool calls too, from the first output (Archivemylife on X)
Archivemylife on X: speed should be the upstream's usage over the local
time, with no split into reasoning, tools and answer, since reasoning and
tool calls are tokens too.

Speed is now every output token the vendor's usage counts (reasoning and
tool-call arguments included) over the time from the first output of any
kind to the end of the reply. The first output is the earlier of the first
content (TTFT) and the first sign of reasoning, firstToken.reasoningMs in
ttft.go, which works the same in every protocol:
- a Responses reasoning item's start;
- an Anthropic thinking or redacted_thinking block's start;
- sealed (hidden) thinking;
- reasoning deltas spread over 100 ms or more. Deltas that came at once
  are a buffered burst and tell none.

A summary is no sign (summaryPart: a Responses reasoning summary, a Gemini
thought, or a summary translated from another protocol via
firstToken.summarized), because it is written after some of the reasoning
it sums up (#1463). A reply that reasoned with no sign of when it began
counts only its answer, its output less the reasoning, from its first text,
and none with no text. Before this, a reply that reasoned always counted
only its answer, and a reply that wrote tool calls after reasoning told no
speed. Burst and held-content checks judge the answer's part.

The same definition holds everywhere:
- gateway: speed.go, trace.go, codex_backend.go;
- usage.DecodeOf, for the Usage cards, rows and `magpie usage`;
- the Usage page's ledDecode;
- the Routing page's decodeOf and its ranking (fast routing reads
  noteTrySpeed, which uses DecodeOf).

settledCountVersion goes to 8, so settled heat totals are counted again.
The rule text is in en, zh, zh-TW, ja and de. Docs: reference.md, and
gui-shell.md under "Streamed output speed".

Red on the old code (scratch worktree at 589e4ba6d):
- TestCodexPreambleThenReasoningTellsSpeed: "reasoning seen from 0 ms;
  want 3166".
- TestVisibleReasoningSpeed: 100/1000 and 0/0 where 1500/14000 was
  wanted.

Run at this head (rebased on dc507aefd), on mote:
- go test -tags nogui -count=1 -timeout 45m ./...
  - gateway ok (1132s), usage ok, routes ok.
  - Red, filed, and caused by mote's own gateway on 127.0.0.1:3425:
    internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
    TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
    TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471); internal/gui
    TestLaneLimitRoutes (#5150).
- go vet for gateway and usage on darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok. gofmt -l: clean.
- GUI, 18 files in Chromium and WebKit (reasoning-speed, usage-speed-*,
  usage-ledger, routing and the i18n files): 242 of 270 pass. The rest are
  usage-ledger "newest live route needs no return-to-live button" (#6003)
  and usage-speed-all-models "asked for 7d" (#5834). Both are red the same
  way on origin/main dc507aefd, in a run of its own.

Rebased again on 70ad7cf30, which touches gateway.go and usage/page.js.
At that head, on mote: go vet for gateway and usage; go test -run
"Reasoning|Speed|Decode|Ultra|Uncounted" for gateway and usage, ok;
reasoning-speed, usage-reads-note, usage-speed-every-row and i18n-keys in
both engines, 66 of 66.

Not tried: a real account per vendor. The timing is taken from recorded
stream shapes in the tests: Responses, Anthropic, Chat and Gemini, native
and translated.
2026-11-18 21:30:25 +08:00
yetone 1c0ecec0f6 library: a magpie in Docker keeps skills and prompts for its clients
fenglian980510 on X: in the Docker gateway the Library had MCP and no
Skills. Since f285426ac a page that shows no agent (no agents found, as
in a container, or gateway mode) drew the MCP tab alone. 5a9b5720d then
let another computer's magpie take a remote's skills and prompts (Use its
skills and prompts, GET /v1/magpie/library), but a Docker magpie had no
way to hold any, and anything it held was ticked for no agent, so Borrow
gave it to none on the client. The borrow change didn't re-derive the
agentless page.

- client.js: with no agent shown, the Library has Instructions, MCP
  servers and Skills (AGENTLESS_TABS), with nothing of agents (no chips,
  agents' own skills, projects or Agents list) and a line saying a
  magpie that adds this one as a provider takes them. It opens on MCP
  unless the reader picked one of the three. Strings in zh, zh-TW, ja, de.
- library: Shared says NoAgents when the page shows none (NoAgentsShown,
  set by gui.gatewayMode). Borrow gives such a new skill or set ticked
  for none to the agents here that take skills or instructions and
  aren't hidden (givenHere); one ticked for agents keeps them.
- docs: docker.html en/zh/ja (zh and ja still said there is no Library
  at all), reference.md, library, gui-shell and mcp-router pages; the
  search index rebuilt.

Rebased on origin/main 5cf1d3846 (runs below at 589e4ba6d; the five
commits since touch none of these files but gui-shell.md, which
rebased clean, and docs-index.mjs writeAll left the index unchanged).
The search index was rebuilt through
docs-index.mjs's writeAll after the rebase). What was run:
- At this head, on Linux (WSL magpie-desktop): gofmt -l (0 files),
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: ok
  (mote and mica were over their load bars).
- At this head, on WSL: go test -tags nogui ./internal/library
  ./internal/gui ./internal/gateway ./internal/provider
  ./internal/testenv -count=1 -timeout 45m: all ok.
- At this head, on WSL: library-agentless-skills, library-mcp-agentless,
  i18n-keys, gateway-mode*, library-* and i18n-* (both engines, every
  language the files run): 1975 of 2010 ok. The 35 reds are in 11
  tests, all red on main too: library-all, library-commands-import,
  library-group-steady, library-mcp-copy-config, library-mcp-off-fold,
  library-open-again (#7097), library-bili (#6015: 82/2 alone, with and
  without this change), gateway-model-chip-height (#7108: red 2 of 3
  alone at main). library-bili-settings and library-mcp-json pass alone
  at both (22/22, 32/32).
- At 998e40c85 (the same change on origin/main 48fffb60c), on mica
  (load 25-35 on 12 cores): go test ./... -timeout 45m, 100 packages ok
  and 3 red, each also red or passing alone at the base 534b85bf9:
  internal/dirent (4 tests, red alone at both, #7031), internal/gui
  TestGatewayModeListsNoOwnSessions (passes alone 3/3, #7064),
  internal/sessions TestWSLStoppedDistroKept (passes alone, #7071).
  gofmt and darwin/linux/windows vet ok there too.
- At 998e40c85, on WSL: 239 GUI files that reach the Library (library-*,
  i18n-*, gateway-mode*, web-page*, any file naming the Library):
  4530 of 4688 ok. The 24 red files rerun at concurrency 2: 151 red at
  998e40c85, 155 at 48fffb60c, the same files (#7097, with #6990,
  #4566, #3922, #6570, #4716 for segs-press-redraw, old-webkit and
  title-bar-tools).
- Not on macOS this round: mote and mica each had another session's full
  GUI suite running all the while.

Broken by hand:
- Borrow's two NoAgents branches set to false:
  TestBorrowFromAMagpieWithNoAgents red ("a skill ticked for none there
  went to [] here, not [claude gemini]").
- origin/main's client.js and i18n.js: library-agentless-skills and
  library-mcp-agentless red at "the tabs", 44 of 44.

Not tried: a real Docker magpie with a second magpie borrowing from it
across two machines. site/search-index.mjs run as a script hangs on its
circular import of docs-index.mjs (as on main); the index was written
through docs-index.mjs's writeAll.
2026-11-18 21:29:39 +08:00
yetone 888d4eba52 library: the MCP market puts the most used servers first, counted from the day's report
gugediyige666 and freedomf26 on X asked for an MCP list ranked by
downloads, searchable and installable. Search and install from the list
were already there; skills were already ranked by skills.sh's install
counts. What was missing was a count of who uses each MCP server.

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

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

Not run before the push: the full Go suite and the whole GUI suite.
mote and mica were both running other sessions' full and GUI suites
(load 45 to 270); they run after, on mote. Not tried: a real day's
report reaching usemagpie.ai from a live install (the worker is
checked with curl after deploy).
2026-11-18 13:39:27 +08:00
yetone e1e454398e agent, gateway: the web search path is Settings › Models › Web search
dsh's and DS Bot's "nothing to search with" notices, and the gateway's
"searcher picked in Settings" errors, sent people to Settings › Web
search. There is no such tab: Web search is a section of Settings ›
Models. The notices in every language, the gateway errors, the DS Bot
docs page (en, ja; zh says no path) and the subsystem docs now name the
real path. llms-full.txt, the search indexes and docs-index.sums are
rebuilt with `node docs-index.mjs`.

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

Not broken by hand: a text change, with no test that names the path.
Not tried: the real app window.
2026-11-18 12:28:47 +08:00
yetone 6c6d3bc842 gateway: Codex's web.run goes to a relay set to search by itself (YIXIE233 on X)
YIXIE233's GPT relay serves /v1/alpha/search itself, but Codex's web.run
(<base>/alpha/search) only went upstream for ChatGPT accounts; for every
API-key provider magpie ran its own searcher. The per-provider "Searches
the web by itself" switch (search=yes, Advanced > Web search, default
off) already sent Responses' web_search tool and Claude's WebSearch
through as sent; now it covers web.run too.

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

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

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

Not tried: a real relay serving /alpha/search (tests use a local fake);
a plugin-served provider (excluded on purpose).
2026-11-17 23:50:29 +08:00
yetone 50c5a52dbd backup: a backup file carries the usage history, and a restore merges it (JasonLeeForOnly on Discord)
JasonLeeForOnly moved magpie to a new server with magpie backup / magpie
restore and lost every call's usage history: a backup file held the setup
only.

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

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

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

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

Not tried: the GUI's export and import against a real gateway (the GUI
tests use a fixture API); the full go test ./... and the whole GUI suite,
since mote and mica were each running other sessions' full suites.
2026-11-17 22:41:26 +08:00
yetone 00b2c11a6b agent: Open Code Review (ocr) is an agent magpie sets up (@AlanWang1027713 on X)
Open Code Review (github.com/alibaba/open-code-review, npm
@alibaba-group/open-code-review) is a Go CLI, `ocr`, that reviews a diff
with a model. Its Claude Code, Codex, Cursor, Kimi Code and OpenCode
plugins and its skills all run that command, which reads
~/.opencodereview/config.json on every run.

Picking one of magpie's models on its row writes a custom provider
"magpie" there (protocol openai, the gateway's /v1, a key naming Open
Code Review, the model) and points provider at it. The user's own
provider and model are stashed and come back on Disconnect, which also
drops a custom_providers left empty. A model of the user's own can be
picked too (written the way `ocr config model` writes it). Check reports
a hand-edited url or key, or a removed entry. The `ocr` command counts
only under a folder named for Open Code Review, since other programs
share the name. WSL distros get the row too (cold distros not opened).
Its User-Agent, open-code-review/<version>, already counts as this agent.
CLI update via npm. Docs, READMEs, site and icon (OCR's own logo,
Apache-2.0).

Run (mica, at 593517bf0; origin/main has one unrelated usage commit since):
- go test ./internal/agent -run 'TestOCR|WSL|Wsl|TestOwnProviderNamedAsMagpies|TestHandWiredMagpieProviderSiblings|TestAgentOf|TestEveryAgentNamedByItsKey|TestMarkedLinesEveryAgent': ok
- gofmt -l: clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- Broken by hand: url dropped from Check -> TestOCRWiring red; stash
  turned off -> red at the Disconnect restore. TestWSLColdPlaceOpensNothing
  went red before the row's options were given an asleep path.
- Real e2e in a sandbox HOME: npm-installed ocr v1.13.10 (7e5ce06c)
  darwin/arm64, magpie built from this tree, a fake OpenAI upstream that
  calls tools. `magpie agents` lists the row with the user's
  deepseek/deepseek-chat; `magpie open-code-review magpie/fake/m1` wrote
  the entry and kept the user's keys and settings; `ocr llm test`:
  connection ok, tool-call round trip verified; `ocr review` on a repo
  with a nil dereference: 2 findings "[bug · high]" through magpie
  (8 /v1/chat/completions calls, UA open-code-review/v1.13.10, model m1,
  its six review tools); `magpie usage` counts them under Open Code
  Review; `magpie open-code-review default` put deepseek/deepseek-chat
  back and removed custom_providers.
- Full suite: not run before this push (ship at once; mote was running
  another session's suite). It runs on mica right after, at this head.

Not tried: a real vendor model behind magpie; WSL and Windows/Linux
machines for real; the Claude Code / OpenCode plugin path itself (it runs
the same `ocr`); an ocr installed by the curl script outside a folder
named for it is found by ~/.opencodereview only.
2026-11-17 11:10:43 +08:00
yetone ead91a9a50 gui: a browser tab's title names this magpie: MAGPIE_NAME or Settings › Network and sharing › Advanced › Name (starballl on X)
starballl on X (tweet 2122376116220633444) runs several magpie web pages
and every tab is titled "magpie", so they can't be told apart. A magpie
now has a name, and a browser tab's title is "<name> · magpie" (plain
"magpie" with none).

- settings.Name, set in Settings › Network and sharing › Advanced › Name
  (instancename.js, imported when Settings is drawn, so nothing is added
  to app.js's core). Advanced is closed until a name is set.
- MAGPIE_NAME (Docker, magpie web) names it while the field is empty and
  is the field's placeholder. It is read, never written, so a name typed
  in Settings always wins and clearing the field goes back to it.
- One line, at most 60 characters (settings.CleanName).
- This computer's own (KeepOwn): sync and a restored backup never bring
  another magpie's name. A Settings save that leaves `name` out keeps it
  (settingsapi.Merge).
- boot.js titles a browser tab itself for the first paint, so app.js's
  core gains only the line in applyPrefs, which sets the title again from
  every settings read (TestCoreScriptBudget was 74 bytes over with a
  title function in app.js). Only a browser page (web) is retitled: the
  app's windows and tray keep "magpie".
- Docker docs (en, zh, ja) list MAGPIE_NAME; docs/reference.md and
  docs/subsystems/gui-shell.md say how it works.

Tests:
- TestInstanceName (internal/gui): the variable alone names it at boot;
  a saved name wins over it, trimmed; a save without `name` keeps it;
  KeepOwn keeps it; cleared goes back to the variable; no name, none at
  boot. Broken by hand, each red: KeepOwn without Name ("KeepOwn took
  \"other\""), Merge without the keep ("a save without the name changed
  it to \"\""), boot.js with s.Name in place of InstanceName ("named by
  the variable alone: boot <nil>"), boot.js not setting the title ("a
  browser tab's boot.js sets no title"). The app window's boot.js sets
  none.
- TestSettingsSaveKeepsWhatItDoesNotSend now sets Name: the page's other
  saves leave it out, and it is kept.
- instance-name.test.cjs: title from the first paint, the field under a
  closed Advanced, save and clear retitle the tab, Advanced open after a
  reload, 360px, the app's window keeps "magpie"; en, zh, zh-TW, ja, de,
  Chromium and WebKit, 16/16. 14 of 16 red with applyPrefs not setting
  the title.

Run, at this commit on dbbb2f26b plus 9d5d8baf2 (the site index):
- go test ./... -count=1 -timeout 45m on Linux (WSL magpie-desktop, Go
  1.26.8), at the tree before the boot.js move: 99 packages ok,
  internal/gateway included (959s); ., internal/cli and internal/gui
  don't build there without GTK headers. On mica (macOS): . and
  internal/cli ok; internal/gui/... ok at this commit, after the two
  reds that run found (the core budget, the keep test) were fixed.
- go vet and GOOS=linux -tags nogui / GOOS=windows go vet of
  internal/gui and internal/settings, earlier the whole tree on all
  three: ok. gofmt -l clean.
- site: node --test *.test.mjs, 132/132.
- GUI: the 135 files the change reaches (settings, network, LAN, i18n,
  old-webkit, core budget) on mica: 16 files had reds. Run again on this
  tree and on its base, the same tests are red on both (allow-ips
  #4357, settings-hints #6107/#6353, lan-join #6353, i18n-keys #6877,
  old-webkit #6030/#5919 and the rest of the 16) but two:
  search-mcp-library (WebKit, #4756) and gateway-pause (WebKit de 420px,
  #6684), red only beside other files: alone, 0 of 10 and 0 of 3 red on
  both trees.
2026-11-17 03:11:31 +08:00
yetone e0f9218f91 update: Restart to update goes into the newest version out, not an older download (char1es_lu on X)
char1es_lu on X: Restart to update put in a version downloaded a while
ago, and right after the restart magpie offered an update again. Since
b05a525a3 (0.1.4051) a restart never asked the feed while a copy was
downloaded and waiting (keepsStaged). The clock's check runs every half
hour or more and magpie releases many times a day, so that copy was
often a release or more behind.

Every restart now asks the feed first (recheck, a check marked
restarting). This covers the page's Restart to update, the tray's, and
the restart AutoRestart or a click waits for. If a newer version is out
it is downloaded in place of the waiting copy, and the restart goes
into it once it is in. A restart waiting for an idle gateway takes it
too: run's waiting rule doesn't apply to the restart's own check. The
clock's check during that wait still keeps the waiting copy.

The feed is still not asked in two cases:
- The copy was downloaded by a restart's own check, or that check found
  it to be the newest (restartGot). The header's Update restarts once a
  click's download is in, and asking again there was elis_pina's loop of
  downloads that never restarted. This also stops a feed slower than
  recheck's wait from asking on every poll.
- Downloads wait for a click (NoAutoDownload). The copy clicked for is
  what goes in (sakamotokurome, iiiiiimone on X).

The update dialog's freshen still names the waiting copy (keep).

Trade-off: a click may now wait for a download (canlee886's earlier
complaint). The header's Update and the tray restart by themselves once
it is in. Settings' Version card shows the download and needs a second
click, which restarts without asking again. Making the card follow by
itself needs app.js bytes, and its budget has no room (tried: 337 over).

Tests:
- TestRestartTakesTheNewestOut replaces TestRestartTakesTheDownloadWaiting.
  With a fake feed it steps 0.1.11 waiting, 0.1.12 out, through the
  page's click, the restart once it is in (0.1.13 out, feed not asked),
  the tray (0.1.14), AutoRestart's wait (0.1.16) and the dialog.
- TestUpdateStagedGivesWayToNewer now checks that a restart's recheck
  takes 0.1.13 with downloads automatic, and keeps 0.1.11 on a click.
- The recheck lines in TestUpdateClockFetchesNewerThanWaiting asserted
  the old rule and are gone.

Run (mote-run, at 9c4e87736 + this change):
- go test ./internal/gui ./internal/update -count=1 -timeout 45m: ok, ok
- gofmt -l internal/: clean
- On the old update.go, TestRestartTakesTheNewestOut and
  TestUpdateStagedGivesWayToNewer fail: "the page's click ... Latest:0.1.11,
  1 downloads, want 0.1.12 after 2".
- Broken by hand:
  - Without restartGot set: "the restart once it is in: Latest:0.1.13,
    the feed asked 1 times".
  - With run's old waiting rule: "AutoRestart restarted into 0.1.15,
    want 0.1.16".

Docs: gui-shell.md "When an update downloads" and reference.md.
Not tried: a real release feed and real app restart; the fake feed
covers the updater only.
2026-11-16 16:37:40 +08:00
yetone 56c988cb5e gateway: /v1/realtime passes a Realtime API session on to its provider (Qwen Token Plan's realtime voice)
gaubeebangeel (X) set up Qwen's Token Plan in magpie and couldn't use its
realtime voice: magpie had no /v1/realtime, so the WebSocket upgrade got a
404. Token Plan does cover realtime: qwen-audio-3.0-realtime-plus at
wss://<plan host>/api-ws/v1/realtime?model=… with the plan's sk-sp- key,
OpenAI Realtime events
(platform.qianwenai.com/docs/token-plan/best-practices/realtime-voice).

GET /v1/realtime and /realtime upgrade to a WebSocket after the same Front
guards as every route (lanGuard, corsGuard, keys, the rebinding check),
plus a same-origin check on the socket's Origin. The model resolves as on
the other routes (a bare id unlisted anywhere goes to the one DashScope
provider that is on), with key, model and account holds, and each try is
dialled in turn with the account's key. A DashScope base ending
/compatible-mode/v1 dials /api-ws/v1/realtime; any other base dials
base+/realtime (OpenAI). Frames go both ways as they are; a close goes on
with its code and reason. Text frames are masked going up and restored
coming down (audio appends and deltas are not), failing closed. Each
response.done's usage is recorded as a "realtime" call (cached input as
cache read). openai-insecure-api-key / organization / project
subprotocols never go upstream. Shutdown ends open sessions with 1001.
/realtime is a client route on magpie web's port (and in the LazyCat
manifest), and a read-only key is refused it.

Run (mote, at this tree):
- TestRealtime* (fake upstream WebSocket, no network): Token Plan path,
  echo, binary, close both ways, usage 60 in / 40 cache read / 20 out,
  OpenAI-style path, subprotocol filter, masking; guards: 426, 400, 404,
  Origin evil/null/localhost subdomain 403, rebound host, remote without
  key 401, key held to another provider 403, vendor 401 passed on.
- Broken by hand, each went red: subprotocol filter removed, masking off,
  cached tokens not subtracted.
- GOOS=linux and GOOS=windows go vet ./internal/gateway: clean.
- go test -count=1 -timeout 45m ./internal/gateway ./internal/masking
  ./internal/gui: the first run found TestClientPathCoversHandler,
  TestReadOnlyKeyEveryRoute and then TestLazyCatManifestListsTheClientRoutes
  red, all fixed here and rerun green. Otherwise ok. The log has one
  recovered "close of closed channel" in continuation_test.go:781's
  doneHold fake upstream (a test fake this change doesn't touch; in both
  runs), already filed as #6505 (and its duplicate #6690).
- Rebased on origin/main 6dbd6e5b1 and rerun at the rebased head: the
  TestRealtime* tests, the three route-list guard tests, gofmt -l, and
  GOOS=linux / GOOS=windows go vet ./internal/gateway.

Not run: the full ./... suite at any head (mote at load ~22-33 of 18, mica ~66 of
12). Not tried with a real Token Plan account or a real Realtime client.
2026-11-16 15:31:53 +08:00
yetone 50f7a8e01f routing: a Smart row behind one renewing sooner says so; Smart says new conversations go there too
YsiCing on X: in Smart, every conversation went to one Codex account (pro,
74% of its week) while Business and team, both at 0%, said "已用 0% · 会话留在另一个账号" ("0% used · the conversation stays on another account").
That is what Smart is meant to do. It sends every request, new
conversations included, to the one account whose quota renews soonest, and
only Stays: Session or Strict spreads new conversations. But the row blamed
a kept conversation, and the Smart description said "one account at a time"
without saying that covers new conversations, plus "at 90%", which is wrong
for a week since d5d48f4f9.

- routing plugin client.js behindWhy: when the account in use also renews
  sooner, a row says "{n} used · one renewing sooner goes first" (and
  "renews in"/expires as before), not "kept"; "kept" is left for a row that
  would have gone first without the kept conversation. Four languages.
- The Smart description (app.js, i18n.js) now says every request, new
  conversations too, goes to the one account renewing soonest until it
  runs low. app.js is 4 bytes shorter; the budget is not raised.
- docs/reference.md: Smart is not load balancing; to spread conversations,
  set Stays to Session or pick Least used first.

Run:
- routing-behind-why.test.cjs on mote with the old client.js: 62 fail,
  40 pass (the "kept on the one renewing sooner" and "fresh" cases, both
  engines, all 5 languages). Green on the new code.
- mica-run go test -tags nogui ./internal/gui -run
  'TestCoreScriptBudget|I18n|Lang': ok. gofmt -l internal/: clean.
- GUI subset on mica at base c867a12c5: routing-*, i18n-*, account-arrange,
  account-weight, builtins, gateway-model-info, key-weight, rotate-figure
  and update-blocked (203 files). 3482 passed, 20 failed. I reran the 7
  red files at base c867a12c5 and with this change, one after the other:
  the same 17 are red at base (#6520 routing-signin, #6010 account-arrange,
  #6512 pin-away, #3799 row-swap, #3954 story-shrinks, #5647 pulse under
  load). routing-stage-routes 420px is red once in en and once in zh, on
  rows with no Smart account, a single read of the on class: #6830.

Not tried: real Codex accounts (fixtures only), and the Linux app's
WebKitGTK.
2026-11-16 14:40:53 +08:00
yetone 2649d5d727 agents: Dim alpha (dima) is an agent, started on magpie's gateway (T_t__biu on X)
Dim alpha (arcships/dim, npm dimcode-alpha, command dima) gets a row on
the Agents page. Picking a magpie model there starts dima with the
variables Dim documents for any OpenAI-compatible endpoint
(docs/design/model-startup.md): DIM_BASE_URL (gateway /v1),
DIM_API_FORMAT=openai-compatible, DIM_API_KEY (magpie-dim), DIM_MODEL
and both DIM_MAX_*_TOKENS (the catalog's, else 128000/32000). They hold
for that run only; Dim's saved Providers, settings and database are not
written. The pick is in magpie's own dim.json; a dima function in the
user's shell profiles runs `magpie dim run`, and the row gives the
command for an open terminal. Picking Dim's own (or Disconnect) removes
both. Nothing signs in to, reads or proxies Dim's own account or the
DimAgent subscription (removed at its vendor's request, v0.1.471).

Run:
- mica, at this tree (rebased on 574b7b96f): gofmt -l clean; go vet (darwin), GOOS=linux
  -tags nogui and GOOS=windows go vet of internal/agent, cli, agentenv;
  go test -tags nogui -count=1 -timeout 45m ./... -> ok, 101 packages. An earlier run on mote
  was red in internal/library's TestEveryAgentInLibrary (dim had no
  Library place); dim is now in noLibrary as "not looked at (#5897)".
- Broken by hand: DIM_API_FORMAT=openai-chat turns TestDim and
  TestDimRun red; dropping shell(false) turns TestDim red (function
  kept in .zshrc).
- Real dima 0.1.0-alpha.24 on mote, sandbox HOME, sandbox magpie serve
  on 127.0.0.1:38600 with a fake OpenAI upstream: `magpie dim
  magpie/fakeup/echo-1` wrote dim.json and the .zshrc function; `zsh -ic
  'dima exec -p "reply with one word"'` answered through the gateway
  (upstream got POST /v1/chat/completions, model echo-1); usage.jsonl
  recorded agent "dim"; `magpie dim default` removed the file and the
  function, and dima ran as npm installed it. Dim's home was never
  written by magpie.

Not tried: a real model provider (only the fake upstream); Windows and
WSL runs (the shell function is this machine's home only, no WSL
distro support); a Library target (skills, MCP, instructions; #5897); Dim's interactive TUI beyond
exec -p and --version.
2026-11-15 17:16:57 +08:00
yetone bbe5c952f1 settings: Update source moves from Network to About, under Download source (WeltAn_X on X)
WeltAn_X on X: the source updates come from sits in Settings › Network and
sharing, though it is an update setting. Update source (Automatic,
usemagpie.ai only, GitHub only) is now the row right under Download source
in Settings › About, with Automatic updates, Update channel and the other
update rows. Same menu, same updateSource value, same save; the Network page
loses the row. App updates' proxy stays on Network, beside the other
proxies. No new tab, label or line.

It goes under Download source rather than above it: placed above, the
About page scrolled at update-mirror's 420px window, and Use a mirror…
then slid Download source 2-10px. That slide is on main too in a shorter
window (#6739), not fixed here.

Docs: the Mirrors page (en, zh, ja) and reference.md say About › Update
source; llms-full.txt and the search indexes are regenerated.

Run at 60ebaea03 + this change, on mica; rebased since onto 02f1cee79,
which touches only internal/plugin, internal/provider, internal/cli and a
subsystem page:
- gofmt -l internal: clean. go test -tags nogui ./internal/gui/...: ok
  (TestCoreScriptBudget included). node --test site/*.test.mjs: 132/132.
- GUI, chromium and webkit: settings-update-source (en, zh, zh-TW, ja, de at
  1100 and 420px; now opens About, the row is under Download source, none
  on Network), update-mirror, update-channel, update-auto, update-restart,
  settings-search, settings-sections, settings-places, settings-general,
  settings-update-proxy, settings-plugin-proxy, about-log, about-notices,
  about-report, about-website, cli-path, uninstall-settings, click-scroll,
  i18n-keys, i18n-en-no-cjk: all ok.
- Reds that fail the same on origin/main 2e1c0a377, run there on mote:
  old-webkit's two (#6030, #5919), settings-hints ja/de 420px (#6107),
  settings-lines-wrap chromium de 440px (#6353).
- The new settings-update-source is red 20/20 on origin/main 2e1c0a377.

Not tried: the real app; the GUI tests stand in for it.
2026-11-15 14:55:33 +08:00
yetone b466aa2803 update: a Daily channel, one release a day that passed its tests, for the app and Docker (fishmagic80 on X)
fishmagic80 on X: Stable is too slow (community plugins need a newer
magpie than it has), every release is too fast, and Docker users have
nothing in between. Daily sits between them.

What it is:
- site/worker.js keepDaily: at the daily cut (20:00 UTC, the quarter-hour
  cron) the newest tag whose commit has a successful Test run and whose
  release has all 17 assets is picked and kept in LEDGER "daily". A day
  with none keeps the day before's; a failed GitHub read writes nothing.
  /api/latest?channel=daily (503 until a pick exists), /download/daily/<p>,
  and an urgent release overlays it as on Stable.
- .github/workflows/docker-daily.yml reads that feed and points
  ghcr.io/yetone/magpie:daily at the picked version's image.
- App: settings.UpdateDaily ("daily"); update.Channel()/Picked() (Stable()
  kept); the feed is asked channel=daily, never falls back to GitHub's
  latest, What's new lists every change since yours. Settings > About >
  Update channel has Every version / Daily / Stable; the version row says
  "Up to date on Daily (· {v} is out on Every version)". CLI: magpie
  update channel [stable|daily|every].
- Words in en, zh, zh-TW, ja, de, on top of 7f832b2f2's 尝鲜版/搶先版/先行版
  for Every version (kept as it landed).
- The channel row wraps its switch under its name when narrow (ja at
  420px was 18px past the window with three segments).
- app.js budget +338: the segment, its line and the two Up to date on
  Daily words, packed to one t() per choice; Settings and renderUpdate
  draw on every window, nothing lazy to move them to.
- Docs: docs/reference.md, site docs (docker, privacy in en/zh/ja),
  llms-full.txt, search indexes.

Red on the old code (a daily-old worktree, then only settings allowing
"daily"): the feed was not asked channel=daily, 40 notes instead of all,
Picked false, notesKey "zh" not "zh|daily", the Daily row showed
"available"; the GUI tests had no Daily segment.

Run on mote at this commit's tree (on origin/main ec1a1a7a5; the Daily pick itself is live on the deployed worker: /api/latest?channel=daily answers 0.1.4171, /download/daily 302s to its dmg):
- go test -count=1 ./internal/settings ./internal/settingsapi
  ./internal/update ./internal/cli ./internal/gui: all ok (TestCoreScriptBudget
  included).
- GUI, chromium and webkit, every language: update-*.test.cjs (22 files),
  i18n-*.test.cjs, settings-search.test.cjs: 554 of 554 pass.
- site: node --test site/*.test.mjs, 132 of 132 (130 before the rebuild).
- gofmt -l clean; go vet darwin, windows (gui/update/cli) and
  GOOS=linux -tags nogui.

Also: site/public/search/*.json and llms-full.txt rebuilt
(search-index.mjs, llms-full.mjs); they still listed Antigravity's old
sign-in after 9cd5f3652, so the two site freshness tests were red.

Filed: #6730, engines.magpie is never read, so a plugin needing a newer
magpie installs on Stable (0.1.3078) and fails without saying why
(page-amp-usage >=0.1.3681, middleware-company-guard >=0.1.3841,
page-day-card >=0.1.3427).

Not tried: a real self-update on Daily, a real docker-daily workflow run,
the whole GUI suite, the worker's unauthenticated GitHub reads under a
rate limit.
2026-11-15 13:10:18 +08:00
yetone 6256d9956a gateway keys: a limit can follow a subscription account's own window (ljayic on X)
A key's limit gains the period "account": it names one subscription
account ("<provider>/<user>") and one of its windows (5h, Weekly, Monthly,
...), and starts and resets when that account's window does, at the reset
time in the account's last good reading (quotas.json), never asked of the
vendor on the request's path (provider.AccountWindow).

When the window can't be read (no reading yet, no such window, or its reset
has passed with no reading since), the limit is "reset unknown": it is
neither reset nor lifted. It counts from the latest time the window can't
have begun before (the reset that passed, else when the limit was set), so
it counts at least the window's calls; a refused call gets Retry-After 300
and a 429 saying the window can't be read now, and the accounts are read
again in the background at most once a minute.

GUI: Gateway keys -> a key's limit -> Window -> "An account's window", then
an app-menu picker of the accounts' windows as read (GET
/api/caller-keys/account-windows); the row reads "$x / $y · 5h of
codex/...", and an unknown reset reads "resets with the account's window".
CLI: magpie gateway-key limit <id> account --account codex/me@example.com
--window 5h --tokens 2m. i18n zh, zh-TW, ja, de. reference.md and
gateway-routing.md say it, with the fallback.

Run (at this tree, base ec8125e68, rebased onto 1ac137e10 which touches
none of these files):
- gofmt -l clean; go vet darwin, linux (-tags nogui), windows clean (mica).
- go test -count=1: internal/access, internal/budget, internal/provider,
  internal/cli, internal/gui ok (mica). TestEveryRouteHasACommandOrIsNamed
  was red until the new route was named (magpie quota).
- New: TestAccountWindowLimit (budget), TestAccountWindowFromLastReading and
  TestReadAccountWindowsOnceAMinute (provider), TestParseAccountWindowLimit
  (cli), TestCallerKeyAccountWindowsRoute (gui). Broken by hand: the unknown
  branch made to guess a 5h window from now -> TestAccountWindowLimit red
  ("let through on a window not read").
- GUI: gateway-key-account-window.test.cjs, chromium + webkit, en zh zh-TW
  ja de, 500px, no native select: 10 of 10 (red without the keys.js and
  i18n change). Every GUI file that loads the caller-keys fixture or the
  Gateway keys page, plus i18n*: 1064 tests, 1046 pass, 18 red, the same
  18 red on origin/main ec8125e68 alone: api-key-theme (6, #6444),
  gateway-key-arrange 420px (10, #6268), text-size webkit (a subtest and its test, #6561).
Not tried: a real Codex/Claude account's window through a live gateway;
the full GUI suite (mote and mica each had a full suite running).
2026-11-15 03:50:46 +08:00
yetone cd030691a3 gateway: the chat page's turn is held to its key's MaxConcurrency (#6688)
6bdeedc6f added the /deepseek-chat routes without judging them for a
gateway key's MaxConcurrency or the LazyCat manifest, so
TestKeySlotEveryRoute and TestLazyCatManifestListsTheClientRoutes were red
on main. The first was a real gap. The page's turn asks a model through
the Messages route's handler, called in process (chatInner), past
keySlots. A key capped at one slot could therefore run a chat page turn
beside an agent's request, with nothing waiting.

- keySlotRoutes: the page's messages route is lazy, so its rounds' tries
  take the key's slot (chatInner's clone keeps the hold in its context),
  and asr and tts are eager. The file upload and delete routes are free
  (keySlotFree): they are kept in magpie and never sent to a model.
- docs/reference.md's LazyCat manifest makes /deepseek-chat public, as it
  does the key page (/me), for a key's holder who isn't signed in to the
  box. The page's static files are keyless already; every call it makes
  still needs a gateway key.

gofmt realigned keySlotRoutes for the longer key.

Run: go test -tags nogui -count=1 -timeout 45m ./internal/gateway on
mica: ok (1005s). The new TestKeyConcurrencyChatPage is red with the
messages entry taken out of keySlotRoutes ("timed out waiting for the
chat page's turn waits for the key's slot"), broken by hand on mica.
2026-11-15 00:38:06 +08:00
yetone 3ffac60480 docs: the management API's routing groups and the app's switch for it (#6307)
docs/reference.md's Management API lists the routing-groups routes
(list, get, create, update and the Routing page's actions), says they are
checked as the app checks them and that found/skip are not served, names
the key menu's Advanced switch beside `magpie gateway-key admin`, and
drops "this first part leaves out Routing Groups": what is left out on
purpose is the export of sign-ins, which would hand out every account's
secrets. docs/subsystems/gateway-routing.md says how the routes reach
/api/groups (adminGroupActions, adminGroupWrite over provider.SaveGroup)
and names the tests. The site's remote page says the same in en, zh and
ja, and public/llms-full.txt is built again from it (node llms-full.mjs,
on mica).

Run: site's worker.test.mjs (llms-full current) in the full run before
the push; no code changes here.

Run for the three #6307 commits (mica, at 4eafd9963 on 90efddaba's
successor, then the touched tests again after rebasing onto 221c91fae):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok. Builds (darwin, linux nogui, windows): ok.
- site worker.test.mjs: 41/41 (llms-full.txt current).
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  two, both red on origin/main and filed: internal/cli
  TestEveryRouteHasACommandOrIsNamed (POST /api/providers/delete, #6677)
  and internal/tui TestEveryWordHasZh ("permission mode", #6686).
- At 221c91fae + these: go test -run 'Admin|Group' ./internal/gui ok;
  gateway-card, gateway-key-admin, gateway-chat-page in both engines
  62/62; i18n-keys, i18n-en-no-cjk 8/8.
2026-11-15 00:16:11 +08:00
yetone ed82d8fab1 agent: a plugin's connect is given magpie's decision models as decisionModels
An agent plugin's connect() got only chat models in `models`, and
/v1/models leaves decision models out too, so a plugin had no way to
learn magpie's Jev, Clef or plugin `decides` models, though
/v1/systemone and /v1/decisions answer them (baranwang on X,
tweet 2121551068022915149).

connect's input now has `decisionModels`, apart from `models`:
provider.OfferedDeciders (what /v1/models lists under
X-Magpie-Deciders), then the decision routing groups, each
{ id, name, provider | group: true,
  endpoints: ["/v1/systemone", "/v1/decisions"] }, [] for none.
`models` and /v1/models are unchanged. Docs: reference.md,
agent-wiring.md, site plugins page (en, zh, ja) and llms-full.txt.

Run at 87f358b70's tree rebased on 659ca3f02 (a gateway-only parent; the
plugged tests re-run there: ok), on wsl-run, magpie-desktop; mote was at load 75-150, mica's disk full):
- go test -tags nogui -count=1 ./internal/agent ./internal/agentplug: ok
  (agent 191s)
- go vet (linux), GOOS=windows and GOOS=darwin go vet of both: ok
- site: node --test worker.test.mjs -n llms-full: ok
- gofmt -l: clean
Broken by hand: connect given decisionModels [] makes
TestPluggedConnectSeesDecisionModels red (jev and the group missing).
Not run: the full go test ./... before the tag (another session's full
suite held the WSL box, mote over its load); run after, recorded on
the issue/next commit. No real third-party agent plugin tried with it.
2026-11-14 18:55:12 +08:00
yetone 9f4e1120f3 agent: a Codex not connected is never pointed at magpie for account failover
TylerBai_loveai on X (tweet 2121532671180632290): with several ChatGPT
accounts added in magpie and Codex not connected, Codex's requests went
through magpie anyway; only adding Codex in Agents, then Disconnect,
put it back.

Cause: Sync's `failover` in codex.go wrote
`openai_base_url = "http://127.0.0.1:3425/backend-api/codex"` (stash
codex.failover), or pointed a CC Switch OpenAI mirror's base_url at the
gateway (codex.mirror_failover), for any Codex signed in to ChatGPT with
another of its accounts on (#1385), on every start and Sync, unless the
user had disconnected Codex or turned on "Only switch Codex's sign-in".
The row said not connected while every request went through magpie.

Fix: failover writes nothing any more. A Codex that isn't wired or
using magpie as its provider gets what failover wrote before taken out
by Sync: the marked base URL, or the mirror's base_url. A base URL the
user wrote by hand has no mark and stays (#856). Failover between Codex
accounts comes with connecting Codex. modelOptions no longer counts
failover as through magpie, so a pick of Codex's own model on the
Agents page doesn't go via magpie. codexProxyOK (the proxy probe only
failover waited for) is gone. The CLI's and GUI's switch-only lines,
reference.md and the subsystem pages say failover is for a connected
Codex.

Users already affected: the first Sync after updating (magpie's start)
removes the marked openai_base_url or mirror base_url, and the route
change restarts Codex's app-server; Codex then goes straight to OpenAI
on its own sign-in. A thread opened while it was on magpie keeps its
provider until reopened, as after Disconnect.

Tests:
- TestCodexNotConnectedStaysOffMagpie: two spare accounts on, Codex
  not connected; SyncCatalog, Sync twice and a model pick leave no
  base URL, no model_provider, not Wired/FailingOver/CodexOwnOnly.
- TestCodexFailoverFromBeforeTakenOut: a marked base URL and a marked
  mirror base_url from before are taken out, bytes restored exactly.
- TestCodexSwitchOnlyKeepsCodexOffTheGateway, the CC Switch mirror,
  disconnect-stays and proxy/EndFailover tests reworked to seed the
  old state by hand; TestCodexFailoverHeldWhileProxyDoesNotPassOn
  deleted with codexProxyOK.

Red on the old code (old codex.go + codex_proxy.go, new tests, mote):
TestCodexNotConnectedStaysOffMagpie, TestCodexFailoverFromBeforeTakenOut
and TestCodexSwitchOnlyKeepsCodexOffTheGateway fail with the reporter's
line `openai_base_url = "http://127.0.0.1:3425/backend-api/codex"`;
TestCodexCCSwitchOfficialOpenAIMirror fails with the mirror pointed at
magpie.

Run (mote; mica's disk is full, 100% with other sessions' runs, and
mote's load was ~17-25 of 18):
- At base b592c1fde: go vet ./... (darwin, GOOS=linux, GOOS=windows)
  ok; go test -timeout 45m ./... 98 ok, two reds:
  TestEveryRouteHasACommandOrIsNamed (fixed on main by 69946f43c) and
  TestCoreScriptBudget, mine (+24 bytes) - the GUI string was shortened
  to fit, no raise.
- Rebased on a63923e3d (what main changed since the base: agent, cli,
  gateway, gui, provider, sessions): gofmt -l clean; go test
  ./internal/agent ./internal/cli ./internal/gui ./internal/provider
  ./internal/sessions all ok. Then rebased on 943404477 (GUI tests
  only below run there).
- GUI (chromium + webkit, every language, both widths): switch-only,
  agent-failover, i18n-keys, i18n-en-no-cjk, claude-switch-only,
  panel-switch-accounts: 115 of 116; the red is claude-switch-only
  chromium 1100 en "the page doesn't move" (scrollTop 3), 4 of 12
  alone here, 0 of 9 on origin/main 943404477, on a path this change
  doesn't touch; filed as #6645 with its output. agent-switch-accounts is 20 of 24
  red the same on a fresh origin/main 69946f43c (#5925, Claude Code
  path, untouched here).

Not tried: a real Codex with real ChatGPT accounts across the update
(sandbox HOME tests only), Codex in WSL, Windows.
2026-11-14 18:40:09 +08:00
yetone 7ea1e6a4b3 usage: the tray panel and the TUI leave out what the Usage page hides
onkashiko on X: a provider whose allowance card was hidden in the main
window (Usage > Overview, "Hide from Overview") still showed in the menu
bar's panel. The panel's Allowances tab had only its own Arrange list
(panelUsageHidden) and read the full cards.

Now the panel leaves out a card whose cardHideKey is in usageCardsHidden
and the rows in usageWindowsHidden (withoutHiddenRows), as Overview does;
a menu bar cell's card still shows (panelPeek). A subscription whose
every card the page hides counts in the foot's "{n} hidden" and shows as
hidden in Arrange; Show there
also drops its keys from usageCardsHidden, since the panel follows the
page. All of it is panelPageCut in the Usage plugin's page.js, which every
window loads, so the core scripts get no bigger (TestCoreScriptBudget
unchanged). Hiding from the panel alone still leaves the page as it is. The
panel reads settings again each time it is shown (loadBack), so a hide or
unhide in the main window reaches it with no restart.

Siblings: magpie tui's Usage page leaves out the same cards and rows
(usageShown, read at every quota read). The menu bar's cells and tooltip
show only the cards picked in Settings, so they keep a hidden card as
before; routing, caps and counting are unchanged.

Run:
- panel-page-hidden.test.cjs (new): chromium + webkit, en/zh/zh-TW/ja/de,
  10/10 green; red on the old app.js/panelarrange.js (cards still drawn).
- TestUsagePageLeavesOutWhatTheAppHides (new): green; red on the old
  pages.go (balance, account and row still listed).
- GUI: the 128 files that read the panel, Usage or tray code, chromium +
  webkit, every language, on mote: 17 files red, rerun alone at
  concurrency 1 here 123/449 red and at origin/main 015860f2d 122/449,
  the same tests but tray-cell-click's chromium en, which is red alone on
  main too (#5215); the rest noted on #5475. tray-cell-click + panel-arrange +
  panel-page-hidden together before the last rebase (no GUI file changed
  in it): 21 of 22, the one red tray-cell-click's (#5215). At this head
  (after the move into page.js): panel-page-hidden, panel-arrange,
  panel-balance-order and i18n-keys green; the reds in key-balance-card
  (de), panel-fold, tray-cell-click (zh) and usage-cards-hide are each
  in the origin/main 015860f2d record above.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./...) on mica
  under suite.lock at 734f06b64 (this change before the move into
  page.js): 97 packages ok; internal/gui red only on TestCoreScriptBudget
  (fixed by the move), internal/gateway red from "too many open files in
  system" at mica's load ~65. At this head on mote: internal/gateway,
  internal/gui, internal/tui, internal/settings and internal/redact (the
  one commit rebased over) ok; gofmt -l clean; go vet, GOOS=linux go vet
  -tags nogui and GOOS=windows go vet ./... clean; go build ok.
- Rebased onto origin/main 667ac8bd6 (5faed634d): internal/gui (budget
  included), internal/tui and internal/settings ok on mote;
  panel-page-hidden + panel-arrange 18 of 18.
Not tried: the real tray panel by hand on a live install.
2026-11-14 14:10:24 +08:00
yetone b005d1a473 update: a fresh install of Stable's version stays on Stable (fishmagic80 on X)
The site now offers Stable's downloads, but the app's Update channel is
Every version until changed, so a Stable install was offered the newest
at its first check. Before that check, a fresh install (no version run
before and magpie's folder new, from whatsNew.start) asks the feed for
Stable's version and the newest; when it is Stable's and a newer one is
out, settings take "updateChannel": "stable" (settings.TakeStable, under
the file lock, keeping a channel already set). A feed that can't be read
is unknown and asked again at the next check. A version that is both
Stable's and the newest stays on Every version: its download can't be
told apart. update.LatestStable never falls back to GitHub.

docs/reference.md and the privacy pages (en, zh, ja, llms-full.txt) say
a fresh install asks ?channel=stable once.

Old installs: nothing changes for them. Until a release with this
becomes Stable, a Stable download (0.1.3078 today) is still offered the
newest unless Settings → Update channel is set to Stable.

Run at 936c70756, on mote: gofmt -l internal/ clean; go vet (darwin),
GOOS=linux and GOOS=windows go vet of internal/gui, update, settings ok;
go test -count=1 ./internal/update ./internal/settings ./internal/gui ok
(gui 99.9s). TestFreshStableInstallStaysOnStable goes red (2 subtests)
with the takeStable call removed (broken by hand, on mica). llms-full.txt
regenerated and current.
Not run: the full go test ./... (mote and mica each had several suites
queued on the lock); not tried with a real Stable install.
2026-11-14 12:17:40 +08:00
yetone b325718f0a antigravity: turned-away lines go reworded, not broken up; Antigravity min 0.1.12 (#1118)
Since 11-14 Google's check reads past invisible characters. A system
prompt with Claude Code's billing line and Agent SDK line, broken up
with two U+200B in every word as the cloak sent them, was turned away
5 of 5 with the bare 429 "Resource has been exhausted". Claude Desktop's
Code tab through magpie to Antigravity failed every turn (hc295971796
on X, tweet 2121429628019781849), and on v0.1.4110 with the Antigravity
Cloak plugin Antigravity hit 429 very often (daoche_wuzui, tweet
2121432333769433178).

The built-in cloak (codeassist.go) now rewords each line Google turns
away, in plain words:
- the x-anthropic-billing-header line is left out to its line's end; a
  system part or message holding only it is dropped;
- "built on Anthropic's Claude Agent SDK" -> "built on the Claude Agent
  SDK by Anthropic";
- Codex's "based on GPT-5" -> "built on GPT-5";
- Hermes' "created by Nous Research" -> "built by Nous Research";
- omp's RFC "keywords" -> "key words".
A copy an older magpie or middleware broke up (U+200B, U+2060, soft
hyphen, inside or between words) is matched and reworded as the line.
The Code tab's main line passes as written and is kept.

The plugins repo's packages carry the same rewording (plugins 5bb41941:
opencode-antigravity-auth 0.1.12, opencode-agy-cli-auth 0.1.41,
middleware-antigravity-cloak 0.1.7 on the dist branch). The Antigravity
mover's min goes to 0.1.12, the version dist has (these packages are
not on npm); the cloak middleware is Official and updates itself.

Run:
- real Antigravity account, sandbox HOME, gemini-3.8-flash, 10
  sequential requests each through the new plugin: Code tab main prompt
  as Claude Desktop sends it 10/10 200, Agent SDK subagent line 10/10,
  an old two-U+200B copy 10/10, Codex GPT-5 10/10, Hermes' earlier
  persona 10/10, omp's RFC line 10/10. The zero-width break went 0/5.
- mote-run: gofmt -l; go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of internal/gateway, provider, cli;
  go test -count=1 -timeout 45m ./internal/gateway/ ./internal/provider/
  ./internal/cli/ ./internal/middleware/: all ok (gateway 926s);
  vet clean, gofmt clean.
Broken by hand: codeassist.go from origin/main with these tests: 6 fail
(TestAntigravityCloakClaudeCode2316, ...RewordsEveryLineItTurnsAway,
...AnswersHermesAndCodexByDefault, TestOnlyAntigravityIsSentThePrompt
Reworded, ...LineWrappedOrWidened, ...TurnsCodexsGPT5ThreadAwayOnce).
Not tried: models other than gemini-3.8-flash; the whole go test ./...
(only the four packages this touches); Claude Desktop itself (its Code
tab's system prompt was captured and replayed instead).
2026-11-14 11:42:32 +08:00
yetone 0fda3a1c12 cli: provider set resolve.<host>=…, the editor's Connect to from the CLI (quantum_lsfc on X)
v0.1.4012 added Advanced › Connect to (Provider.Resolve) in the GUI
only; the reporter asked for it from the CLI. `magpie provider set <id>
resolve.<host>=<IP or dns:name>[,…]` sets a host's connect addresses,
an empty value takes the host out, and `resolve=` clears them all (any
other resolve= value is refused, never saved). provider.Save checks
them as the GUI's do (netproxy.CheckResolve, TakesResolve), so a bad
place or a vendor's own host is refused with nothing written. `magpie
provider <id>` lists them as "connect". Usage and docs/reference.md say
how.

Run on mote: go test -count=1 ./internal/cli ok (166s);
TestProviderSetResolve ok; go vet ./internal/cli for darwin, linux
(-tags nogui) and windows ok; gofmt -l clean. A nogui build in a
sandbox HOME on mote: provider add + set resolve.api.corp.example=
10.0.0.5,dns:gw.corp.example saved and shown as connect; resolve=oops
and a bad place refused; resolve= cleared it; provider set --help
printed usage.
Broken by hand: not deleting the host on an empty value, and taking a
non-empty resolve=, each turn TestProviderSetResolve red.
Rebased on origin/main 9572a2b4c and run again on mote: the resolve,
Pair and Help tests of internal/cli ok.
Not tried: a request actually dialled through the rule from the CLI
(the dial is the GUI's, covered by netproxy's and provider's tests),
nor the reporter's managed network; Windows and Linux beyond go vet.
2026-11-13 16:39:09 +08:00
yetone 51c3ecc573 vertex: Gemini 4 Carbon and Hydrogen in the preset, and Gemini 4 at us and eu (#6452)
Google Vertex AI's model list lacked gemini-4-carbon (released 2026-11-10)
and gemini-4-hydrogen (2026-11-12); SunsetBirdW and T_t__biu on X, #6452.
Google's model-versions page lists both ids, and each model's page lists
PayGo at global, us and eu, as Argon's now does too, so the us/eu list
gains all three Gemini 4 models.

Their window, output, prices and thinking levels come from models.dev's
google-vertex entry as for every Vertex model, which matches Google's own
pages today: Hydrogen 1,048,576 in / 65,536 out, $1.50 / $0.075 cached /
$7.50 at global, levels low to xhigh; Carbon 1M / 65,536, $2 / $0.10 / $10,
levels low to high. The provider test asks both at thinkingLevel low.

Run (mote): go test -tags nogui ./internal/provider ./internal/gateway
./internal/catalog -run 'Vertex|GeminiEffort|Preset|Effort'; go vet ./...,
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...; gofmt -l.
Broken by hand: presets.go reverted, TestVertexProviderListed red (no
gemini-4-carbon/hydrogen at global); vertex.go's us/eu list reverted, red
at us and eu.
Not tried: a real Vertex project (no Google credentials here). Carbon and
Argon go to $4 / $0.20 / $20 on 2026-12-01 (Google's pricing page); the
price comes from models.dev and follows it when it changes. The bundled
offline catalog (2026-11-10) has neither model until it is refreshed.

Rerun after rebasing onto origin/main 96558cfde: go test of provider,
gateway and catalog -run Vertex|GeminiEffort|Preset|Effort, ok on mote.
2026-11-13 15:06:26 +08:00
yetone 04776ec6cb providers: a plugin subscription imports accounts from a file through its own auth.import, WorkBuddy's from 0.2.32 (marchen_cc on X)
marchen_cc on X: 「从文件导入账号」 took no WorkBuddy sign-in file. The cause
was not WorkBuddy's: magpie's import reached only built-ins (Codex,
Claude, Antigravity, Factory), and a plugin had no way to say it could
read a file. This adds that for every plugin subscription:

- A plugin's auth may have import(texts, {signal}), returning sign-in
  results, with importFrom (and importFroms by language) saying which
  file to choose. The host's importFiles op keeps each one as a sign-in
  is kept (keptAs, saved under signInKey, settled), so an account
  already there comes back "updated"; it is cancellable (signInSteps)
  and takes at most 100.
- /api/signin/import and `magpie accounts import <plugin> <files>` go
  to provider.ImportPluginFiles when PluginImportable(id); the editor's
  「从文件导入账号…」 row and the import sheet show for such a plugin, in
  its own words (importSay), moved subscriptions included (subOf).
- docs/subsystems/provider-plugins.md: "Accounts from a file".
- WorkBuddy's mover min goes to 0.2.32, which reads the desktop app's
  .info sign-in or a JSON credential, and sends a cloud-hosted
  enterprise account (*.sso.copilot.tencent.com, *.copilot.qq.com,
  *.sso.codebuddy.cn, iOA apart) to its enterprise's address (emilochen
  on X), published and checked with npm view --prefer-online.
- TestCoreScriptBudget +468 for the import branch, packed to one
  statement. importSay is read as the Providers rows draw, so it has
  no lazy page; nothing else was moved out (#2710). The budget's
  arithmetic was checked over this tree: 1,267,762, at the new cap.

Run on mote (mica's disk is full; mote over its cores) at this change
on 3f6b1b0c9; ac1702c33 (the library plugin and its GUI test, no core
script) landed after, and the core budget's arithmetic was redone at
this head:
gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/{gui,plugin,provider,cli}; go test -count=1 of those four:
all ok. GUI (chromium + webkit, en and zh): plugin-import,
login-import, factory-key, plugin-moved-signin, i18n-keys: 23 pass, 1 fail: i18n-keys "a plugin's words are its own",
memory_mcp.go's "No folder", red on main since 72facf72e (#6422).
Plugins repo: workbuddy import.test.mjs 6 of 6, bun scripts/check.mjs
ok, root bun test 8534 pass / 1 fail (agy-cli smoke under load, green on a rerun: 8535 pass, 0 fail;
unrelated, plugins #1070).

Broken by hand: without the host's importFiles handler,
TestPluginImportFiles goes red; without importable in pluginSubs,
plugin-import.test.cjs goes red ("WorkBuddy lists no import").

Not tried: a real WorkBuddy desktop .info file or a real enterprise
account on a cloud-hosted domain; the fixtures follow WorkBuddy's own
client source. Not tried on Windows or Linux beyond vet.
2026-11-13 13:32:32 +08:00
yetone d6a6865b1f update: a file from usemagpie.ai has its attestation from usemagpie.ai, GitHub's API after (ArcticLampyrid on X)
The site's cron keeps each release's SLSA bundles on R2 as
/files/<tag>/attestations.jsonl (728f3de40, 5e51e241c), but the updater
still asked api.github.com for every file, 60 an hour unsigned, and with
Update source set to the site alone it never checked an attestation at all.

attestation() now takes the asset. A file the feed names on the site
(Site/files/<tag>/<file>) has its release's bundles read from the same
site first; GitHub's API is asked as before when the site misses: a pruned
tag's 302 to GitHub's release (not followed; that asset doesn't exist),
any other status, a body with no bundle, or the site unreachable.

The trust model is unchanged. The site is only transport: its bundles go
through the same verifyBundle (embedded Sigstore root, release.yml of
yetone/magpie-releases, the digest from the ed25519-signed SHA256SUMS).
A site bundle that fails sends the updater to GitHub's API, where a valid
bundle holds; if that API can't be read it is a refusal, not unknown, so a
tampered mirror plus a blocked GitHub can't go through as "unattested".
Update source "site alone": the site's bundles are checked, GitHub never
asked; a miss is unknown as before. Update source "GitHub": the API alone.
docs/reference.md and the start page (en, zh, ja) say so; no
docs/subsystems page covers updates. llms-full.txt regenerated.

Run (mote):
- go test -count=1 ./internal/update/ ok; go vet darwin, GOOS=linux
  -tags nogui, GOOS=windows ok; gofmt -l clean.
- node --test site/*.test.mjs 120/120.
- New tests (attest_site_test.go, fixture = the site's real
  v0.1.3986/attestations.jsonl): the site serves it and GitHub isn't asked;
  site-alone source attested; another digest refused; misses (302, 404,
  502, html, empty, cut mid-line, site down) go to GitHub; site-alone miss
  stays unknown; a tampered site bundle refused with GitHub 403/503/404 and
  with site-alone, and passes on GitHub's valid bundle; wrong identity
  refused; GitHub source and github.com files never ask the site. No test
  reaches the network (TestMain points the site at 127.0.0.1:1).
- Broken by hand, each red: never asking the site (4 tests), taking a site
  bundle unchecked (3), following the redirect (1), a failing site bundle
  plus unreadable GitHub kept unknown (2).
- Live once (a throwaway test, not committed): usemagpie.ai's real
  v0.1.3986 bundles attested magpie-cli-android-arm64 with the API pointed
  at a dead address; pruned v0.1.3985 (302) fell back to api.github.com
  and attested.

Not tried: a full app update from the site end to end; Windows and Linux
runs of the package (the change is OS-independent).
2026-11-13 12:49:24 +08:00
yetone 52830b077b site: the build attestations are kept on R2 beside the release files (ArcticLampyrid on X)
The SLSA attestations live behind GitHub's API only, so with GitHub down
they could not be fetched while the mirrored files could. The five-minute
cron now also asks api.github.com/.../attestations/sha256:<digest> for every
file of a release from v0.1.3891 on and, once every file has one, writes
<tag>/attestations.jsonl to R2 (a Sigstore bundle per line, deduped), served
at usemagpie.ai/files/<tag>/attestations.jsonl. It is written only whole, so
a file with no attestation yet is asked again next run, and it is pruned
with its tag. `gh attestation verify <file> -R yetone/magpie-releases
--bundle attestations.jsonl` checks a download with it. It is not a release
asset: the GitHub release keeps its 17 assets and release CI is unchanged.
start (en, zh, ja), llms-full.txt and reference.md say where it is and how to
verify. The updater does not read it yet.

Run (mote): node --test site/*.test.mjs 118/118; gofmt n/a.
New tests: bundles land once and only whole; pre-0.1.3891 release not asked.
Broken by hand: ATTESTED set to 9.9.9 turns the bundles test red.
Not tried yet: the real cron run and the file on R2 (after deploy), the
updater reading it from R2, gh --bundle on a real downloaded file.
2026-11-13 11:23:30 +08:00
yetone bbce1fc1ab update: the updater checks a download's GitHub build attestation too (ArcticLampyrid on X)
Release CI attests every file (SLSA provenance through Sigstore, v0.1.3891
on). The updater now fetches the bundle for a file's signed SHA-256 from
api.github.com/repos/yetone/magpie-releases/attestations/sha256:<digest>
before it downloads the file, and verifies it with sigstore-go against the
Sigstore trusted root embedded in the binary (attest_root.json, public
good instance): certificate chain, certificate timestamp, Rekor entry,
issuer token.actions.githubusercontent.com, subject release.yml of
yetone/magpie-releases on main or a v* tag, source repository
yetone/magpie-releases, and the digest among the statement's subjects. It is
in addition to the ed25519 check over SHA256SUMS, which still runs first
and still works offline and from the R2 mirror; the attestation is asked
about the digest that signed list gives, so both speak of the same bytes.

When the attestation can't be had (a failed read means "unknown", but an
outage of GitHub must not take updates away):
- a bundle that is there and fails (signature, identity, digest, a chain
  outside the trusted root), GitHub answering 404, or an empty list: the
  file is refused. GitHub was asked and says these bytes weren't built by
  that workflow.
- GitHub unreachable, rate limited (60/hour anonymously), 5xx, a body that
  isn't JSON, or Settings' update source set to the site alone (which never
  goes to GitHub): the update goes on, since the ed25519 check has held, and
  the log says the file went unattested and why. Someone who can only drop
  the API call downgrades an update to the ed25519 check, never below it.
- releases before 0.1.3891 and a MAGPIE_UPDATE_FEED of your own are not
  asked.
The bundle checks itself, so the API call goes through source.Do and may use
a mirror.

Cost: go.mod gains sigstore-go v1.1.4 and its tree (go.sum +350 lines).
The embedded root has to be renewed (gh attestation trusted-root, first
line) when Sigstore rotates its keys; docs/reference.md says so. Until then
a chain under a new key fails as "not attested" and is refused: a known
cost, in the doc.

Run (mote, sandbox HOME via testenv): go test ./internal/update (ok),
site node tests (112 of 114; docker-tags and the sponsors README test fail
because mote-run -C site cannot see ../README.md, unrelated), gofmt -l
empty, go vet darwin, GOOS=linux -tags nogui and GOOS=windows on
internal/update, go build ./... on all three. Fixture: the real answer
api.github.com gave for v0.1.3925's SHA256SUMS (testdata/attest), verified
offline; the whole run reaches no network.
New tests: TestAttestationOfARealBundleHolds, ...OfAnotherDigestRefused,
...TamperedRefused, ...EditedPayloadRefused, ...WrongIdentityRefused (repo,
workflow, ref, source repo, issuer each), ...NoneListedRefused,
...UnknownGoesOnAndSaysSo (403, 429, 502, HTML, nothing listening),
...OnlyWhereItIsOwed, TestVerifyMarksAttestedReleases,
TestDownloadRefusedWithoutAttestation.
Broken by hand: identity check swapped for WithoutIdentitiesUnsafe turns
WrongIdentityRefused red on all five cases; the attestedFile call removed
from download turns DownloadRefusedWithoutAttestation red (the file was
fetched). The first full run of the package, before TestMain pointed the
attestation API at a closed port, had TestSourceSiteAndAutomaticUseTheSite
reach the real GitHub with a made-up digest and be refused: now closed.
Not tried: a real update end to end (needs a release newer than the
running binary; the unit path covers download), Windows box, the
GUI, full suite (starts after the tag).
Docs: docs/reference.md, start.html (en, zh, ja) and llms-full.txt say what
the app checks now.
2026-11-13 00:01:01 +08:00
yetone 477bbb7a15 usage: GET /v1/magpie/usage/requests?cursor= reads requests as changes, with stable ids (rdsaltbo on X, #6060)
A program keeping a ledger of its own (a WakaToken plugin) can now read the
requests incrementally: cursor=start or cursor=now, then each next_cursor.
Rows carry a stable content-derived id (same after a restart), origin, and
original_ids (request_id, response_id, client_response_id, message_id,
session_id, native_session_id), each only when the source gave it. A call
read late, a corrected row (same id, higher seq) and a native row replaced by
the gateway's (deleted, with seq) all come through a persisted journal
(usage-feed.jsonl, appended and synced before answering). Cursors magpie
cannot resume from are refused: 400 cursor_invalid / cursor_filter_changed,
410 cursor_expired / cursor_reset. A held key sees only its own rows and
tombstones. Without cursor, offset/limit mode is unchanged.

Also: Record.MessageID (not persisted) from the agent file's message id, and
usageapi's row decoration moved into a namer shared by both modes.
Docs: reference.md, integrating.md, gateway-routing.md, gateway-sessions.md,
site remote.html (en/zh/ja), llms-full.txt.

Run (mote, this tree): go vet darwin, GOOS=windows, GOOS=linux -tags nogui on
usage, usageapi, gateway (gui on darwin); go test -count=1 for
internal/usage, usageapi, gui, gateway: all ok. New tests: resume gets exactly
the new rows, ids and cursors survive a restart, correction keeps the id,
gateway takeover retires the native row, refused cursors, expiry, now cursor,
identical records, and the feed over the gateway (held key, 401 without key,
offset mode). Broken by hand: an unconditional memo made the new-rows test
red (fixed to memo only the next page).
Not tried: real Claude Code/Codex session files, a huge (700k+) history,
Windows run of the tests, GUI browser suites (no GUI file touched).
2026-11-12 22:40:15 +08:00
yetone a2feeb11a0 update: pick the update source by hand, Automatic, usemagpie.ai only or GitHub only (RootSir, Sakugar_ on X)
usemagpie.ai's download is slow for some users (Cloudflare R2) and GitHub
is the one that works for others. Settings > Network has an "Update source"
menu button under App updates' proxy (the app's menu, no native select):
Automatic (default, as before: the site, then GitHub when the feed can't be
reached), usemagpie.ai only, GitHub only. Settings.UpdateSource ""/site/
github, this computer's own (KeepOwn), in settingsapi.Keys and Choices so
`magpie settings set updateSource github` works; any other value is refused
on save. The menu loads from assets/updatesource.js, so app.js (at its
budget) grows by one line.

GitHub only: latestAt reads yetone/magpie-releases without asking the feed,
and download starts at the file's github.com address (mirror and GitHub's
API route as before), never the site. usemagpie.ai only: no fallback to
GitHub for the release (fallsBack) nor for a file (toGitHub, toAPI off).
Stable and a MAGPIE_UPDATE_FEED of your own keep reading the site's feed
whatever the source says (Stable's release list is only the site's; its
files still come from GitHub on GitHub only). Every source goes through
Release.verify: ed25519 signature against the embedded key, the version in
the signed text, each hash from the signed list; a release read from GitHub
must be signed whatever its version. The update private key is untouched.

Run (mote, tree before the commit): gofmt clean; go vet update/settings/gui,
GOOS=windows and linux vet of update; go test internal/update, settings,
settingsapi, backup, cli ok; internal/gui TestCoreScriptBudget, assets and
i18n tests ok. GUI: settings-update-source (chromium and webkit x en, zh,
zh-TW, ja, de x 1100 and 420px: three menu items, each pick saves updateSource
alone, tick, no overflow), settings-update-proxy, i18n-keys, i18n-en-no-cjk,
settings-*, gui-* ok except the 22 subtests (gui-de/ja "has every zh string",
settings-hints, settings-lines-wrap de 440, settings-search) that fail the
same on origin/main 5a3d73039 (#6234, #6073, #6156, #6133 are open for them).
New Go tests use a fake GitHub and a live fake site feed that count their
hits: GitHub only never asks the feed and downloads from GitHub, the site and
Automatic never ask GitHub, the site only never falls back (release or file),
GitHub only refuses wrong key, swapped sums, no/junk signature and an
unsigned old version, a custom feed is never overridden. Broken by hand:
without the githubOnly branch and the two download switches, 3 of them go red.
Not tried: the real github.com or R2, a Windows run, Stable with GitHub only.
2026-11-12 19:35:57 +08:00
yetone 5241308212 settings: a day can start at 0 to 6 o'clock (ssharpcc on X)
Settings > Usage > "Day starts at" (dayStart, 0 to 6, default 0; also
magpie settings set dayStart 4). With 4, a call at 01:30 counts toward the
day before: the Usage page (summary, charts, heatmap, ledger day filter,
hour labels of Today) and the daily and monthly key caps (access.Window,
provider.SpendCap.Window).

internal/dayzone makes a time.Location whose midnight is the real day's
hour:00 (TZif built from the zone's own offsets, same DST instants), so
every place that cuts days by a Zone's midnight follows without edits;
usage.Zone returns it and the "now" reads use it too.

Run (mote): go test usage, settings, settingsapi, access, provider, gui,
dayzone, also with TZ=UTC and TZ=Pacific/Kiritimati; gofmt; go vet darwin,
linux nogui and windows; day-start, currency, number-units and i18n-keys
GUI files in chromium and webkit, en zh zh-TW ja de; TestCoreScriptBudget.
Broken by hand: TestDayStartsAfterMidnight red with 9 failures when the
hour is ignored. New tests: dayzone over 5 zones x hours 1/4/6 x two years
of days, usage, limit window, spend-cap window, day-start GUI.
Not tried: a real log history in a real window.
Not shifted, filed as #6314: the Sessions page, TUI sessions filter,
davsync shared per-day files, gateway_sessions day keys, credits_daily.
Rows are never stored in the shifted zone.
2026-11-12 18:31:50 +08:00
yetone 727e236378 gateway: a management API for providers, accounts and gateway keys, for a key set to manage (ljayic on X)
ljayic asked for a complete, stable management API so nothing needs a
hand-edited file. /v1/magpie/admin/ now serves the app's own /api handlers
(providers and their keys and accounts, OAuth sign-in start/poll/cancel,
gateway keys, account groups) to a gateway key set with
`magpie gateway-key admin <id> local|any`. Routes and actions not in
gui/admin.go's adminRoutes are 404, so a provider's saved key, a gateway
key's secret, sign-in export and actions on this computer's apps are not
served; "admin-key" is not served either, so the API can't raise its own
caller. Sign-in returns the vendor's page and code, opens nothing, takes no
password.

Guard (gateway/admin.go), in order: any Origin or Sec-Fetch-Site/-Mode is
403 with or without a key (Origin null, foreign, listed, *.localhost, an
app scheme); no key 401; a key without Key.Admin 403; from loopback the Host
must be ownHost (a rebound page's GET has no Origin); from the network the
key must be "any"; a proxied request counts as remote. Key.Admin is dropped
(adminOf) for a read-only, Browser, issued, expiring or default key, and
setting read-only clears it. The route is in readOnlyRefused and keySlotFree.

Docs: docs/reference.md "Management API", gateway-routing.md, and the
remote page in en, zh and ja. Routing Groups, sign-in export and a GUI
switch for the level are left to #6307.

Run (mica, the worktree before the rebase onto 9 newer commits): go vet of
access, cli, gateway, gui (darwin), GOOS=windows vet of the same four,
GOOS=linux -tags nogui vet of access, cli, gateway; gofmt -l empty;
go test -count=1 -timeout 45m ./internal/access ./internal/cli
./internal/gateway ./internal/gui: all ok but TestKeySlotEveryRoute, which
named the new route and is fixed here, then it and the read-only, admin and
guard tests pass again. After the rebase the same tests ran again.
Broken by hand, each red in TestAdminAPIGuards: browser check off (a
browser case served), Admin check off (a key without it served), Host check
off (a rebound name served), the "any" requirement off (a local-only key
from the network served, and a proxied request).
Tests: TestAdminAPIGuards (no key, unknown key, non-admin, read-only,
local/any, x-api-key, 8 browser headers x 3 callers, rebound Host, proxy,
no handler), TestAdminKey (access: levels, read-only, Browser, issued),
TestGatewayKeyCLIAdmin, TestAdminAPIGatewayKeys / Providers (a canary key
is never told) / SignIn, TestAdminRoutesEveryAPIRoute.
Not tried: a real sign-in against a vendor through the API, a request from
a second computer on the LAN, the GUI suite (no page or app.js changed), a
Linux/Windows run of the new tests.
2026-11-12 17:47:11 +08:00
yetone cfd3367df8 usage: a request's details show its service tier (JackyFill on X)
The ledger has kept each call's service tier since #1784 (tier_asked,
tier_sent, tier_served in the log, the CSV and the JSON), but the
Requests page never showed it. A request's details now have a Service
tier line: "asked X", then "sent Y" only when it differs, then
"answered Z" only when the reply named a tier. A call with none shows
no line. Row flag bits are untouched: the tiers are string slots, so no
bit is taken.

Run, on mica: new ledger-service-tier.test.cjs (3 rows: all three tiers,
asked+sent without an answer, none) in chromium and webkit, en zh
zh-TW ja de, 12 of 12 green; with the add("Service tier") line removed
by hand it is 0 of 12; i18n-keys caught a duplicate "Service tier" key
(the core table already has all four languages), which is removed;
ledger-*, i18n-keys, i18n-en-no-cjk and gui-* files rerun green after
(ledger-cache-hit chromium was red once in the first batch, green on
rerun in the same batch's second run).

Not tried: a real Codex priority call end to end (the gateway side is
#1784's); the full suite runs after the tag.
2026-11-12 17:22:03 +08:00
yetone 65e1422c4a update: fall back to the GitHub release when usemagpie.ai can't be reached (ssharpcc on X)
A company network that allows github.com and no other domain could not
update magpie at all: the feed (usemagpie.ai/api/latest) failed and that
was the end. When the default feed fails (20s limit, so dropped packets
don't hold the check for 10 minutes), the newest release is now read from
yetone/magpie-releases: the API, or the release page's redirect when the
API is rate-limited, plus SHA256SUMS and SHA256SUMS.sig from github.com
(or the API route when github.com's address is busy). The result goes
through Release.verify like the feed's: ed25519 signature against the
embedded key, the version inside the signed message, every hash from the
signed list. Unlike the feed, a release read this way must be signed
whatever its version. Files download from github.com (Asset.GitHub),
checked by hash as before; feed files named on the site now also get a
github.com address, so a download falls back too. Covers the app,
`magpie update` and the Windows and Linux builds (all go through
latestAt). Not on Stable (the site's choice) nor on MAGPIE_UPDATE_FEED.

Run (mica, tree at this head): gofmt clean; go vet update/cli/gui, GOOS=windows
and linux vet of update; go test internal/update, internal/cli, internal/gui all ok.
New tests use a feed port nobody listens on and a fake GitHub (API and
rate-limited redirect paths): update succeeds and stages the file by hash;
wrong key, swapped sums, missing and junk signature, signature for another
version, unsigned old version are refused with no download. Broken by hand:
with verify() removed from the fallback, 4 of those tests go red.
Not tried: the real github.com, a real allow-listed network, Windows run.

Other usemagpie.ai-only on such a network: install.sh, plugin catalog
(falls to raw.githubusercontent.com, ok), npm registry for plugin
installs, models.dev catalog, partners/icons, telemetry.
2026-11-12 17:19:40 +08:00
yetone c1a91b5a52 agents: Mistral Vibe is an agent, and a Library target (alterxyz4 on X)
Vibe (mistralai/mistral-vibe, the `vibe` CLI) keeps its settings in
config.toml in $VIBE_HOME, else ~/.vibe. magpie now connects it: a
[[providers]] entry named magpie (the gateway's /v1, api_style openai,
backend generic), one [[models]] entry per catalog model aliased
magpie/<provider>/<model>, and active_model set to the alias, with the
previous value stashed and put back on Disconnect. Vibe reads keys only from
the environment, the keyring or ~/.vibe/.env, so the key naming Vibe goes in
the provider's extra_headers as an Authorization header; nothing is put in
the user's environment. Avibe's `vibe` command is turned away by binNot.

Library (#5595): instructions are $VIBE_HOME/AGENTS.md and skills
$VIBE_HOME/skills (vibe/core/system_prompt.py,
vibe/core/config/harness_files/_paths.py, read at 3.1.2). VIBE_HOME is in
appdir's usable list and agentenv. README (en, zh), docs/reference.md and
docs/subsystems/agent-wiring.md list it; the restart notice is in zh, zh-TW,
ja, de.

Run (mica, sandbox HOME):
- go test -count=1 ./internal/agent ./internal/library ./internal/appdir
  ./internal/agentenv ./internal/gateway ./internal/gui: ok.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows on the touched
  packages: clean.
- Real vibe 3.1.2 (uv tool install mistral-vibe) with the file shape magpie
  writes, against a fake OpenAI upstream: the alias with slashes resolves as
  active_model, the request goes to /v1/chat/completions with model kimi/k2,
  Authorization: Bearer <key> from extra_headers and user-agent
  Mistral-Vibe/3.1.2.
- GUI: agent-notice-lang, i18n-keys, i18n-en-no-cjk, gui-zh-tw pass.
- Broken by hand: vibeMine returning false fails TestVibe,
  TestVibeOwnModelTakesMagpieOut and TestVibeSyncKeepsTheirs.

Not tried: the file written by the built magpie binary itself (the unit tests
write it through the same code), Windows runs of the new tests, a Vibe
signed in to Mistral with its own models alongside. gui-de and gui-ja
"every zh string" were red on the base for the "{agent} isn't installed
here" string, not for this change.
2026-11-12 17:07:23 +08:00
yetone c4f7ba9d3a update: only a release whose SHA256SUMS carries the release key's signature is installed (danny0dong on X)
The updater took a file and its SHA-256 from the same feed answer, so
whoever could change /api/latest could swap both; only the Mac app also
checked its signing team. Now release CI (yetone/magpie-releases) signs
"magpie release <version>\n" + SHA256SUMS with an ed25519 key held as that
repo's UPDATE_SIGNING_KEY secret and publishes SHA256SUMS.sig (release
assets: 16 -> 17). The site worker carries the list and signature in the
feed; internal/update/signed.go checks them against the public key built
into the binary, takes each file's hash from the signed list and refuses a
missing or bad signature or a feed hash that differs. Versions from
0.1.3862 require it; older ones and binaries older than the key update as
before. MAGPIE_UPDATE_FEED lifts the requirement for local test servers.
mirror-release waits for 17 assets; docs/reference.md and code-standards
say 17 and describe the transition.

Run: go test internal/update, internal/cli, internal/gui -run Update|WhatsNew
(ok); node --test site/*.test.mjs (116 ok); gofmt; go vet darwin, linux
nogui, windows on internal/update. Broken by hand: signature check skipped
(tamper and other-key tests red), feed-hash comparison skipped (swapped
hash and feed tests red), worker not attaching signed (worker test red).
The embedded key is checked against a sample signed by the real key with
openssl, as CI does. Signing script run against a throwaway key.
Not tried: a real signed release before this tag; install.sh does not
verify the signature.
2026-11-12 16:43:23 +08:00
yetone a5e805f574 Codex: Ultrafast beside Fast in a group member, and a Fast/Ultrafast setting per model (kdajenks on X)
kdajenks (magpie 0.1.3739, Codex on ChatGPT Pro) could set Fast only from a
routing group's member row and had no Ultrafast there, and no way to set the
speed in the model's own settings. Ultrafast exists: Codex's catalog lists
the `ultrafast` service tier, the code already sent it for agent picks and
Codex's service-tier row, and the live account's service_tiers hold it.

- Group member: the button steps Standard speed, Fast, Ultrafast (where an
  account offers it, `ultraOK`), back to Standard. `Group.Ultra` is a subset of
  `Fast`, kept through rename, fold, share, gone-filter and the CLI
  (`magpie group ... ultra=`). The gateway marks the candidate `ultra`.
- Per model: `settings.ModelTiers` ("<provider>/<model>" to priority or
  ultrafast), `provider.SetModelTier` (refused where CanFast/CanUltra say no),
  `ModelPref.Tier` in Model settings (Standard speed / Fast / Ultrafast, in
  modellimits.js), and `magpie model tier <provider/model> [fast|ultrafast|usual]`.
  The gateway sends it on a direct pick for an agent with no fast pick of its
  own, through fastPick, so an account without Ultrafast gets priority. A group
  member goes as the group says.
- Docs: gateway-routing, providers-accounts, reference.

Run (mica, at the rebased head over a6d84e13a):
- gofmt -l clean; go vet darwin, linux nogui, windows clean.
- go test internal/provider, internal/settings ok; internal/gui and
  internal/cli ran: the one red of mine (TestSettingsSaveKeepsWhatItDoesNotSend
  wanting ModelTiers) is fixed in this commit; the others are not mine and
  red on a clean origin/main: TestEveryRouteHasACommandOrIsNamed (#6202),
  TestPanelHiddenByWailsMarksPageOutOfSight (#6203, not checked on main).
- internal/gateway ok (984s).
- GUI, chromium and webkit: new model-speed.test.cjs (30, five languages, 1200
  and 420px), plus model-*, group-*, fast-*, i18n-*, text-size,
  codex-service-tier, panel-*, routing-group*, routing-save* files. Red and not
  mine, same on a clean origin/main worktree: fast-pick and fast-ultra (#6201),
  group-editor-selected (#5049).
- New tests TestModelTierSentToEveryAgent, TestGroupMemberUltrafast,
  TestCleanModelTier, TestSaveGroupUltra.

Broken by hand: removing the gateway's model-tier branch and the candidate
`ultra` copies turned both gateway tests red; turning off the Ultrafast choice
in Model settings turned 20 of 30 GUI tests red; reverting the member button to
two states turned 10 of 30 red.

Not tried: a real ChatGPT account sending Ultrafast through the new setting;
the agent picker's bolt does not show a model-level default; Windows and Linux
GUI runs.
2026-11-12 01:56:26 +08:00
yetone fc615339f0 provider: Alibaba Cloud Token Plan quota read with the account's AccessKey; intl Token Plan preset (pppMathew on X, #2940)
Cause: a Token Plan sk-sp- key only authorizes inference. The plan's
usage sits on the Bailian console gateway, which wants a console token
(the key gets BailianGateway.Login.NotLogined) that Alibaba's own `bl` CLI
makes from the account's AccessKey through GenerateCLIAccessToken (ACS3
signed). magpie had no such path, so the usage card showed no quota.

Change:
- alibaba_usage.go: ACS3-HMAC-SHA256 signing, the console token (kept 20
  minutes per AccessKey and region, made again once on NotLogined), the
  personal plan's usage API, and per<N><Unit>Percentage/ResetTime read as
  5 hours / Weekly / Month windows. Hooked in as AccessKeyVendor "alibaba"
  (editor asks AccessKey ID and Secret, a keyless card says so),
  accountPlanOf (routing), PlanQuotas and the key card tag.
- Hosts: token-plan.cn-beijing.maas.aliyuncs.com (bailian-token-plan) and
  the new token-plan.ap-southeast-1.maas.aliyuncs.com preset
  alibaba-token-plan (Alibaba Cloud international Token Plan, #2940), also
  an OpenCode import target.
- Editor hint in zh, zh-TW, ja, de; docs (providers-accounts, reference).

Not covered: qwen-token-plan (Qwen AI platform) and qwencloud-token-plan
have no AccessKey route (browser-session console, #5829); team plans.

Run on mica at this tree: go test ./internal/gui ./internal/provider ok;
go vet darwin, linux nogui, windows on provider/gui clean; GUI files
i18n-keys, i18n-en-no-cjk, tencent-access-key, volc-access-key,
usage-access-key-card, tencent-cloud in chromium and webkit: 60 of 64 pass,
the 4 reds are tencent-cloud's "region clicked right after the strip
scrolled", red the same at origin/main 319753d89 (filed: #4321, #4399,
#4625). Broke it by hand: dropping the *100 on the percentage turns
TestAliReadWindows and TestAliPlanQuotas red.
Tests never reach the network (httptest behind a rewriting transport).

Not tried: no real Alibaba Cloud account, so neither the mint nor the
usage reply was seen live; the field names and the envelope come from the
official client's source. The international gateway host
(bailian-singapore-cs.alibabacloud.com) and the RAM-user case are the least
certain. The full suite was not run before the tag.
2026-11-12 01:20:52 +08:00
yetone 8016205e3f provider: trust a self-signed server's certificate by fingerprint, for Remote magpie and any https address of your own (Zhangzhangi on X)
Zhangzhangi on X couldn't add a Remote magpie at a domain with a
self-signed certificate ("x509: "api.magpie.local" certificate is not
standards compliant") and asked for a skip-verification option. A
follow-up asked for the same on other self-signed hosts.

This adds a pin (trust on first use), not a blind skip. It is off by
default and kept per provider:
- Advanced → Server certificate → "Trust its certificate…" fetches the
  certificate the server shows (provider/peekcert) and lists its SHA-256,
  subject, issuer and expiry. "Trust this certificate" keeps the
  fingerprint as the provider's serverPin.
- From then on only that certificate is accepted (netproxy pinTLS:
  InsecureSkipVerify plus VerifyConnection comparing the leaf's DER
  SHA-256). Another one fails with PinMismatchError, saying the server
  showed a certificate other than the one trusted.
- The editor shows a red "Certificate not verified: only this one is
  accepted" with the fingerprint, and "Verify it again" drops the pin.
- The pin is set only on the provider's own hosts (provider.PinHosts):
  - every address of Remote magpie and of a provider added by URL;
  - for a preset (Ollama, LM Studio, OpenAI at your own box), only https
    addresses whose host is not one of the preset's or its regions' own
    hosts. A vendor's host never takes a pin.
  - Never for an account, Vertex or a subscription. Save refuses one
    elsewhere.
- The client certificate and Server CA still go only to the providers
  that took them before (TakesClientCert). A preset gets the pin alone.
- The editor's certificate rows (Client certificate and the new Server
  certificate) are drawn by a lazily imported tlscerts.js. The Client
  certificate row moved out of app.js with it, so the core scripts stay
  under TestCoreScriptBudget without a raise.

Run (Go 1.26.8):
- WSL magpie-desktop, before the rebase:
  - go test -tags nogui -count=1 ./internal/netproxy ./internal/provider
    ./internal/gui all ok;
  - GOOS=darwin -tags nogui vet of gui fails on traywindows_darwin_test.go's
    undefined trayImagePNG, the same at the base (a cgo-only helper).
- mote and mica, after the rebase on ab5824aee:
  - gofmt -l clean; node --check app.js;
  - go vet darwin (cgo), GOOS=linux -tags nogui, GOOS=windows: ok;
  - go test ./internal/netproxy ./internal/provider: ok.
- mote, at the final tree: node --check app.js and tlscerts.js; go test
  ./internal/gui -run 'Budget|ServerPin|InsecureTLS|ClientCert|OnDemand|Lazy'
  ok (TestCoreScriptBudget under 1,533,802) at the base ab5824aee.
  Rebased on fe5a0cf6d, TestCoreScriptBudget is red, as it is on that
  main alone: main's core is 1,534,708 (16ed1a952 took it to 1,535,318);
  this change takes it to 1,534,484, 224 bytes less (#5918, commented).
  The rest of the run above passes at the pushed head.
- mica, GUI files at the final tree, both engines inside each file:
  - green: provider-server-pin (54), mtls-settings (16),
    provider-insecure-tls (60), provider-socket (60), provider-http1 (60),
    i18n-keys, i18n-en-no-cjk, editor-advanced-align, provider-advanced-fold
    (50);
  - old-webkit: headerpresets.js not loaded (#6030) and Safari 15's :has()
    (#5919), both on main too;
  - menu-scroll: 24 of 24 red on /api/update/using, the same alone at
    origin/main fe5a0cf6d (#5982, commented).
  - Earlier flakes of provider-http1 beside another session's suite:
    #6159.
- Broken by hand, each red:
  - presets never take a pin: TestServerPinSaveChecks,
    TestServerPinPresetAtOwnServer, TestServerPinNoVendorHost;
  - vendor hosts pinned (the own-host check dropped):
    TestServerPinNoVendorHost;
  - client cert and CA sent to presets: TestServerPinPresetAtOwnServer;
  - the pin never compared: TestPinOnlyThatCertificate,
    TestServerPinRemoteMagpie.
  Restored: both packages ok.

Not tried:
- a real self-signed domain from the macOS app (httptest servers with
  their own certificates only);
- the Responses WebSocket dial (read only: it takes the same netproxy
  transport);
- go test ./internal/cli and the whole GUI suite before the tag (the
  full Go suite runs after it, under suite.lock).
2026-11-11 21:13:43 +08:00
yetone ab5824aeea gateway keys: a limit in total never resets by the period, only by Reset usage (Cyrus_4433 on X)
The Limit window menu gains "in total" (period "total", CLI: gateway-key limit <id> total). It counts from when it is set or last reset and ends a century off (access.Limit.Window), so only Reset usage starts it again; its 429 says it stays refused until reset or raised, the row reads "$0.00 / $300 · 总额" with no reset time, and a remote key's window is "Tokens/Spend in total" with no reset. Old settings files read the same (new period only). i18n in zh, zh-TW, ja, de; reference.md and gateway-routing.md say it.

Run: TestLimitTotal and TestTotalLimitNeverResetsByThePeriod, red on the old code (Valid refuses "total"); gateway-key-total.test.cjs red without the keys.js change (5 of 5). Not tried: a real key through a live gateway; full suite follows after the tag.

Run (before this push):
- gofmt -l clean; go vet darwin, linux (nogui), windows clean.
- go test: internal/access, internal/budget, internal/cli, internal/provider ok.
- Go tests for the total period are red on the old code (Valid refuses "total"); the GUI test is 0 of 5 languages passing without the keys.js change.
- gateway-key-total.test.cjs and i18n-keys: 9 pass in chromium and in webkit (zh, zh-TW, ja, de, en; 500px width; no native select).
- Full GUI suite on mica, chromium: 46 reds in files this change does not touch (accounts, Pi/OpenCode Go, panel sheet, check-in, Aside provider, API key theme, allowed addresses); none is a key-limit test. Webkit pass still running; reds are to be compared with origin/main and filed after.
- TestCoreScriptBudget is red on origin/main 2d12e8274 by 7 bytes (1,533,809 > 1,533,802); this change touches no counted core script (#5918).
Not tried: a real key through a live gateway; the full Go suite (started after the tag).
2026-11-11 20:35:13 +08:00
yetone 5c02be05b8 agent: agy moves onto the community agent-agy plugin
The built-in agy agent (Antigravity CLI) is the first built-in agent a
community agent plugin serves, as the retired subscriptions moved onto
provider plugins. While @magpie-community/agent-agy is installed and on,
magpie's agy is the plugin's: the built-in leaves the list (here and in
WSL), its id and aliases are the plugin's, and what the built-in wired
is handed over. Turned off or removed, the built-in is back. Nothing is
forced yet; the forced install and the built-in's retirement come once
the plugin is on npm and a real run with it is on record.

The plugin (plugins ebcff866, 0.2.0) follows the built-in since
0cc91af3d: its config is magpie's own magpie-settings.json, handed to
agy with --settings, agy's settings.json is only read, and
remote-control runs as agy is.

What an agent plugin can say now (agentplug; docs/reference.md and the
site's plugins pages, en/zh/ja, and llms-full.txt):
- base: the agent's own settings file, read for the user's own model
  and passed to connect and own; needs launch.args with {config}, and
  stepping out removes magpie's config file whole;
- launch {env, model, args, plain}: `magpie start <id>` and the shell
  functions (posix, fish, PowerShell, a WSL distro's) put args before
  the model flag, and run a plain word or flag as the agent is;
- own({config, base, model}), effort, wsl, aliases.

Moving over (plugged_moved.go): agentMovers names agy's package;
agyHandover gives back a settings.json an older built-in wired (Sync),
then makes magpie-settings.json the plugin's stash, so the plugin's
agent reads as connected and stepping out removes the file.

Run (mote, macOS 27, Go 1.26.8) at fe8c05e0c, the base before the last
rebase:
- go test internal/agent (507s), agentplug, sessions, edit, update,
  plugin: ok.
- internal/cli and internal/gui: red only on main's own reds, the same
  at origin/main 8fe720453: TestModelUsageAlignsEveryDescription and
  TestModelUsageLinesUpItsDescriptions (#6104),
  TestSettingsSaveKeepsWhatItDoesNotSend (#6103), TestCoreScriptBudget
  (#6116, filed now).
- GUI, both engines, and site node --test: agy-effort, agy-launch,
  library-rtk-agy, gui-de, gui-zh-tw, i18n-en-no-cjk, i18n-keys,
  plugin-page-foreign-error, site/*.test.mjs: 114 pass.
- vet: macOS, GOOS=windows, Linux in WSL (-tags gtk3); gofmt clean.
- The shell functions with a config path holding a space: bash and zsh
  on mote, PowerShell on Windows (win-run), bash in WSL.
- Broken by hand: TestAgyPlugin red with Args, Plain or the file's
  removal taken out.
At 20d807d92 (rebased on 8fe720453): vet (macOS, windows) ok, agentplug
and internal/agent -run 'Agy|Plugged' ok, agy-launch and i18n-keys
pass; plugin-page-foreign-error is red there and at plain origin/main
8fe720453, from that commit (#6117), not this change.
Plugins repo: bun test packages/agent-agy 4 pass.

Not tried: fish (on none of the machines); a real agy run with the
plugin at 0.2.0 (the 0.1.0 design ran for real in a sandbox HOME, the
settings.json one this replaces); Windows and WSL agy with the plugin;
an install from npm: @magpie-community/agent-agy isn't on npm yet, so
until its first publish no user is moved.
2026-11-11 16:13:19 +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