Commit Graph
43 Commits
Author SHA1 Message Date
yetone d9ca84a2f4 gateway: built-in TLS, magpie serve/web/daemon install --tls-cert --tls-key, reloaded on renewal (RoderickZH)
magpie serve, magpie web and magpie daemon install take --tls-cert <file>
--tls-key <file> (or MAGPIE_TLS_CERT / MAGPIE_TLS_KEY). The gateway and the
web UI on its listener then serve HTTPS to other computers. Without them
nothing changes.

- Half a pair, a file that doesn't parse, or a flag with no value is
  refused at start with a message naming the missing flag.
- The pair is re-read when either file's mtime or size changes (certbot
  renewal), with no restart. A renewal that doesn't parse keeps the
  certificate already served and is logged once.
- Other computers get HTTPS only. Plain HTTP from them gets net/http's
  400 "Client sent an HTTP request to an HTTPS server".
- This computer (loopback, or a peer address equal to the local one) may
  still use plain http on the same port. Its connections are sniffed on
  their own goroutine (a first byte of 0x16 is TLS) for up to 10s, so a
  silent client holds nobody else up. gateway.URL() stays
  http://127.0.0.1:<port>, which agents, MCP servers, ServedBy, the
  healthcheck and daemon status all use, and no certificate covers
  loopback.
- WSL NAT and containers count as other computers.
- ALPN is http/1.1 only (hijacked connections and websockets need it), with
  TLS 1.2 as the minimum.
- Printed links, LAN addresses, publicURL, the serve/web banners and
  daemon install show https:// for other computers' addresses.
- The DNS-rebinding Host checks (foreignPage, rebound, the MCP
  loopbackHost) don't depend on the scheme and are unchanged.
- daemon install carries MAGPIE_TLS_* into the unit or plist. A reinstall
  or `daemon web on` that names no certificate keeps the installed pair,
  and --no-tls removes it.
- Docs: reference.md gets an HTTPS section that names Caddy as the
  alternative, gateway-routing.md gets a TLS row, and docker.html (en,
  zh, ja) gets the env rows.

What was run:
- New tests: internal/gateway/tls_test.go (others HTTPS-only, this
  computer both, a silent local client holds no other, renewed
  certificate served, CheckTLS, addresses, Relisten keeps TLS),
  internal/cli/tls_cli_test.go and daemon TestInstallCarriesTLS (linux
  and darwin, paths with space, %, & and ").
- Each was broken by hand and went red: no wrap in listen, no reload, a
  synchronous sniff, a bad renewal dropping the certificate, http in
  publicURL or the pinned LANURLs, the carried entries removed, and
  keepTLS as a no-op.
- Real use under a sandbox HOME, with a self-signed pair, on
  0.0.0.0:3461:
  - Half a pair, a garbage certificate, a flag with no value, and the
    env set to half a pair each exit 1 with the message.
  - curl -k https://127.0.0.1 and https://<LAN IP>/v1/models with a key:
    200. Plain http on loopback: 200.
  - The cert files were swapped for a second pair while it ran.
    openssl s_client then showed the new CN and serial, and curl
    --cacert with the new pair got 200. A junk key file then kept the
    second pair, logged once.
  - From the Windows box over the LAN: plain http got 400; https with
    the key got 200, and without it 401.
  - magpie web --addr 0.0.0.0:3462: https network links. From Windows,
    http got 400 and https with the key got 303.
- gofmt -l clean. go vet passed on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test -tags nogui for ./internal/cli, ./internal/daemon, and the TLS
  tests of ./internal/gateway and ./internal/gui: all pass at the rebased
  head.
- Two reds in the full suite (`go test -tags nogui ./...`) are the same
  on origin/main f074996d9; both are filed:
  - TestGatewayHeldByAContainer failed 2 of 5 there (#2107).
  - The gateway package runs past go test's default 10m under load:
    1208s on main and 1221s here, both passing with -timeout 40m
    (#2108).
2026-10-14 13:36:03 +08:00
yetone 33da86c71a provider: removing a plugin sets its providers' model picks in providers.json aside, and adding it again puts them back (#2057, dawn1095)
A plugin's provider leaves a record in providers.json once the user
picks its models: its id and nothing of its own (OnlyPicks). Removing
the plugin left those records behind. Nothing listed them, `magpie
provider rm` couldn't reach them, and a sync or backup asked for a
sign-in to them on every run.

RemovePlugin now finds the ids the plugin's providers are stored under
(PluginID of each provider plugin.Listed gives for its spec), and moves
the records with those ids that hold only picks into providers.json's
new pluginLeft, under the plugin's package name. Left alone:
- any record with an endpoint or a key (the user's own provider,
  whatever its id);
- a built-in's ids (accountIDs) and "magpie";
- an id another installed plugin serves too;
- everything, when the plugins' listing isn't known (no cache and no
  plugin-providers.json): unknown is not "none is the user's".
provider.AddPlugin (CLI, GUI, backup restore) puts the set-aside
records back, each one whose id has no record now; one the user has
given to a provider since stays aside. plugin.Listed is new: the cached
listing, or plugin-providers.json.

Run:
- plugin_left_test.go, four tests with user-owned records beside the
  plugin's (a user "zap" with an endpoint next to the plugin's
  zap-plugin, a hand-made "mine", a built-in's picks, another plugin's
  and a shared id). Each guarantee broken by hand turned its test red:
  no set-aside, no OnlyPicks check, no other-plugin exclusion, no
  unknown-listing guard, take-back over the user's record, no take-back.
- go test ./... in a sandbox HOME; gofmt -l; go vet darwin, linux
  (-tags nogui), windows.
Not done: records left by plugins removed before this change stay where
they are; turning a plugin off (not removing it) sets nothing aside;
`magpie provider rm` still can't name such a leftover. The move flow
(installPlugin) still adds through plugin.Add, since its own
migration owns those records. Not tried with a real plugin removal in
the GUI.
2026-10-14 13:20:13 +08:00
yetone f074996d93 provider, gateway, gui: a model with none of its levels ticked is sent no reasoning field, on every route and in a routing group (yuexian7)
yuexian7 on Discord: models.dev lists their model as reasoning, and the
vendor answers any reasoning parameter with 422 while the same request
without it works. In a routing group they couldn't set an effort per
model, and the model editor refused to untick the last level ("Keep at
least one level"). The learned refusals (bed306ae, #1062) don't cover
this: they learn a refusal of reasoning *off* and of Gemini levels, and
optionalFields holds thinking/enable_thinking, not reasoning_effort.

- settings.ModelReasonless, set by provider.SetModelReasonless (the
  provider editor's Names & levels with every level unticked, saved as
  modelPrefs {reasonless: true}; `magpie model efforts <ref> off`).
  Ticking levels again or Restore default clears it (setModelEfforts);
  setting it drops the model's kept levels.
- entryFor and Efforts/Thinks/Levelless: the model offers no levels and
  is Quiet, so agents are given none for it.
- Gateway: the candidate loop strips the body with withoutAnyReasoning
  in the agent's protocol (Chat/Responses reasoning_effort, reasoning,
  thinking, enable_thinking, include's reasoning.encrypted_content;
  Anthropic thinking of any type and output_config.effort; Gemini
  thinkingConfig). The Anthropic relay doesn't add
  thinking:{type:disabled} for it, and forwardTranslated clears Effort,
  ThinkOff and Thinking for its other callers (continuation, search).
- A routing group with it as a member keeps the other members' levels
  (it `continue`s like a member whose levels are unknown, #597), and the
  member that reasons is still sent the effort asked.
- GUI: none ticked shows "No reasoning field sent" beside the levels, in
  zh, zh-TW, ja and de too; a model with one known level now shows its
  picker so it can be unticked. A model whose levels aren't known
  (m.given) keeps none ticked meaning no levels known.

Run (worktree on origin/main 82f3befd2, sandbox HOME, private GOCACHE):
gofmt -l clean; with set -o pipefail go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./... all clean; node --check
app.js. go test -count=1 ./internal/provider ./internal/gateway
./internal/settings ./internal/cli: ok. ./internal/gui: ok except
TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline under
load (AppKit window measurement, untouched here; #1936, noted there).
The run caught TestSettingsSaveKeepsWhatItDoesNotSend (ModelReasonless
added to it) and the CLI usage alignment tests (fixed).
New tests and what breaking the change does: TestReasonlessModelSentNoReasoning
(Chat, Chat+enable_thinking, Responses with include, Anthropic->Chat
translated; by name and through group/mix) and TestReasonlessAnthropicRelay
fail with gateway.go/quiet.go reverted; TestGroupReasonlessMemberKeepsLevels
fails with group.go's reasonless branch disabled; TestModelReasonless
needs the new API. model-reasonless.test.cjs in chromium and webkit, at
1100 and 420, in en, zh, zh-TW, ja, de: 20/20; on the old assets all
fail. Related GUI tests 418/418 (one model-copy-id failure on a first
run under load, passed alone; #2066).
Not tried against the reporter's real vendor: the 422 is taken from
their report.
2026-10-14 09:38:12 +08:00
yetone b319657301 gui: a sign-in whose browser didn't open says why and shows its link, and Windows names rundll32 by its path (#2043)
xiaobaifly7: on Windows, signing in to Cloudflare's MCP server (and any
sign-in) opened no browser, and the window said to finish in the
browser until the sign-in timed out. Wails' Browser.OpenURL starts
rundll32 by its bare name, which Go looks up with PATHEXT's extensions;
a PATHEXT without .EXE (WSL passes one on as ".CPL") finds nothing, and
host.OpenURL dropped the error.

- proc.OpenBrowser starts %SystemRoot%\System32\rundll32.exe by its
  path (open / xdg-open / termux-open-url elsewhere) and returns the
  launcher's error. host.OpenURL falls back to it when Wails' fails, and
  the CLI's account sign-in uses it.
- Windows.OpenURL returns the error. /api/signin, the plugin sign-in and
  /api/library/mcp-signin answer it as openError; /api/open fails with
  it, so Open again says why.
- The sign-in card shows "magpie couldn't open your browser: {error}.
  Open the sign-in link below in a browser yourself." where it said
  magpie opened the page, with the link already shown below; the MCP
  editor shows the error with the link and a copy button. Translated
  (zh, zh-TW, ja, de).
- Open again matched its sign-in by identity, so a poll that put a fresh
  copy of the same sign-in in place kept the old error after a
  successful retry; it now matches by id.

Run:
- TestBrowserNamesRundll32ByItsPath, TestMCPSignInSaysTheBrowserDidntOpen
  and the /api/open and /api/signin tests in signin_open_2043_test.go.
  Broken by hand: the bare name back in browserCommand fails the first;
  openError returning "" fails the gui tests.
- On the Windows box (amd64, cmd with PATHEXT=.CPL): exec.Command
  ("rundll32", ...).Start() gave `exec: "rundll32": executable file not
  found in %PATH%`; proc.OpenBrowser started it (nil). The proc test
  binary's TestBrowserNamesRundll32ByItsPath passed there.
- signin-browser-down.test.cjs (new): the card's text, the link, no
  sideways overflow, Open again failing then succeeding, and the MCP
  editor's error and link, in Chromium and WebKit at 1100 and 420 in
  every language: 20/20. The related sign-in GUI tests: 451/452, the
  one a signin-proxy flake also on main (fixed in its own commit).
- gofmt -l clean; go vet darwin, linux -tags nogui, windows; GOOS=linux
  and windows builds; go test -tags nogui ./internal/gui/
  ./internal/proc/ ./internal/cli/.

Not tried: the real Wails app on Windows under PATHEXT=.CPL (the
fallback path is exercised only through proc.OpenBrowser), WSL itself,
the reporter's machine. Not covered: internal/tui/sessions.go and
internal/provider/install.go start `powershell` by its bare name, which
would miss the same way under such a PATHEXT.
2026-10-14 08:36:07 +08:00
yetone 82f3befd29 daemon: magpie daemon install --web serves the browser page from the service, with a link that lasts (HuanCheng Bai)
HuanCheng Bai on Discord runs `magpie daemon` on a Linux server and asked
for the daemon to serve the web page too, or for an option to turn it on.
`magpie web` run beside it is a second process, and he read it as not
seeing the daemon's state.

- `magpie serve --web[=host:port]` serves the gateway and `magpie web`'s
  page from one process (stats, StartWeb, Wait). The default page address
  is 127.0.0.1:3430. Any other argument is refused, where before it was
  ignored.
- `magpie daemon install --web | --lan | --addr host:port | --no-web` and
  `magpie daemon web [on|off] [--lan] [--addr host:port]`. The unit's
  ExecStart and the plist's ProgramArguments become `serve --web=<addr>`,
  and the key goes into the 0600 file's environment as MAGPIE_WEB_KEY. The
  key is made once. A reinstall with no flags keeps the page and its key
  (read back from the file by daemon.Web), so the link survives restarts
  and reinstalls. `web off` drops it. MAGPIE_WEB_KEY in the shell, when
  set, is used and checked like magpie web's. The page defaults to
  loopback; --lan or a non-loopback --addr prints the network links and
  magpie web --lan's warning.
- `magpie daemon status`, install and `daemon web` print the page's link.
- `magpie web` while the service serves a page prints that page's link and
  exits. Beside a gateway another magpie serves, it says so and points to
  `magpie daemon web on`.
- docs/reference.md (the service section and the Use list), and the
  site's start page (en, zh, ja). The READMEs don't cover the daemon.

Run:
- Tests: TestInstallWithWeb (systemd and launchd, plutil lint, read back,
  reinstall without the page, the shell's key not carried, no key
  refused), TestWebNotInstalled, TestParseDaemon, TestWebOptions,
  TestDaemonStatusPrintsPage and TestServeArgs. Each of these went red
  with its line reverted by hand: withKey, prevKey in webOptions, and the
  status page line.
- Sandbox HOME with a fake launchctl:
  - `daemon install --web --lan` wrote a 0600 plist with
    `serve --web=0.0.0.0:3430` and the key. plutil said OK, and it printed
    the link, the network links and the warning.
  - Reinstalling with no flags kept the key. `daemon status` showed the
    link.
  - `daemon web off` / `daemon web` / `daemon web on` behaved as above,
    with a new key after off.
  - `daemon web bogus` and `serve --lan` gave the usage errors.
- `serve --web=127.0.0.1:3462` served the gateway (3461) and the page in
  one process. The page answered 200 with the key and 401 without, and the
  page and /v1/models both showed 3 models. `magpie web --no-open` beside
  it printed the service's link and exited 0.
- gofmt -l; go vet (gui), and go vet -tags nogui for darwin, linux and
  windows; go test -tags nogui ./... in a sandbox HOME.

Not tried: a real systemd on Linux. The unit text is checked by test only.
2026-10-14 08:32:41 +08:00
yetone 8f03b78069 cli, gateway: magpie statusline prints the session's model and each account's windows for Claude Code's status line (#1997, kensenzhao)
kensenzhao asked for magpie's routing and quota in Claude Code's status
line. Claude Code runs the statusLine command on every update and cancels
the run that is still going, so the command must answer fast. It must never
make a vendor read.

- `magpie statusline [<provider|account>]` reads Claude Code's statusLine
  JSON from stdin. It prints "→ <served model>" from
  /v1/magpie/route?session=<session_id>, then each subscription account's
  windows ("claude a@x* 5h 62% 7d 41%"). `*` marks the account that served
  last. A window whose reset has passed shows 0%. With the gateway off it
  prints an empty line. Each request times out after 1s.
- /v1/magpie/quotas?kept=1 (provider.KeptQuotaReport) builds the same
  report from the kept cards (CachedCards) and never starts a vendor read.
  The plain endpoint can take up to 12s.
- magpie never writes statusLine into Claude Code's settings. The user
  adds `"statusLine": {"type": "command", "command": "magpie statusline"}`
  themselves (magpie statusline's help, docs/reference.md).

Run: go test -tags nogui ./internal/cli ./internal/provider
./internal/gateway in a sandbox HOME; gofmt -l; go vet natively and with
GOOS=linux and GOOS=windows.

Broken by hand, each went red:
- the CLI asking without kept=1 (TestStatuslineTellsRouteAndEveryAccount);
- dropping the route line (same test);
- KeptQuotaReport calling QuotaReport (TestKeptQuotaReportAsksNobody).

Real use: a built binary against a sandbox gateway on 127.0.0.1:3517.
- kept=1 answered in 0.07s and route in under 1ms.
- `magpie statusline` with Claude-style stdin printed an empty line, since
  the sandbox has no accounts.
- Its ~1.1s wall time matches `magpie version`, so that is process start.
Not tried: real accounts, or the line inside a real Claude Code statusLine.
2026-10-14 08:26:04 +08:00
yetone a5d72a095b gateway, gui, cli: a search API's keys take turns, a refused one rests, and each Tavily key shows what it has used (SlouchyQuill)
SlouchyQuill on Discord asked for a Tavily key pool after
dsh-tavily-pool: several keys, each key's quota shown, keys rotated.
Before this, the comma-separated keys (#1477) always started from the
key that last answered, so one key took every search until it was
refused, a refused key kept no rest of its own, and nothing showed what
a key had left.

What changed:
- Turns (internal/gateway/search_keys.go). Searches take turns over the
  keys by default (round robin, a counter per vendor). pick=order (CLI)
  or In order (Settings) always starts from the first key; the pick is
  saved in SearchAPI.Pick.
- Rests. A refused key rests: 401/403 for 10m ("turned away"), 402 for
  1h ("out of credit"), 429 for its Retry-After held to 30s-10m (1m
  without one). 432/433 count as out of credit from Tavily only; from
  any other vendor they rest as a rate limit. A resting key is asked
  after the others, soonest back first, so failover is kept, and it
  wakes when it answers. Rests are keyed by a hash of the key.
- Quota (internal/gateway/search_quota.go). Each Tavily key's quota is
  read from GET /usage with that key. The fixture is the documented
  reply from docs.tavily.com. The key's own limit is used when it has
  one; otherwise its plan's plan_limit/plan_usage, which the account's
  keys share. A failed read, or a reply missing those fields, says
  unknown and why, never 0. A read is kept 2m unless asked fresh. A key
  found used up with no pay-as-you-go credit rests 1h; a later read
  with credit wakes it.
- Keys never appear in full. The vendor's error has the key masked
  (tvly-…abcd), and errors name "key N (tvly-…abcd)".
- GUI. Settings › Models › Web search adds a "Keys of <API>" row under
  an API with several keys or with Tavily's: In turn / In order, each
  key masked with what it has used and why it is asked last, and Check
  again. There is an API for it (POST /api/settings/search-quota), and
  13 strings in zh, zh-TW, ja and de.
- CLI. `magpie search` lists the pick and each Tavily key's quota, read
  fresh; `magpie search add … pick=turns|order`.
- Docs. gateway-routing.md has a new section "A search API's keys";
  both READMEs have a line on web search.

What was run:
- go test -tags nogui ./internal/gateway ./internal/provider
  ./internal/cli ./internal/gui: ok. After the last rebase, provider
  and cli again, and gateway -race -run Search.
- New tests: TestReadTavilyUsage, TestSearchKeysTakeTurnsRoundRobin,
  TestSearchKeyRefusedRests, TestSearchRestFor, TestSearchQuotas and
  TestSearchKeyNeverInFull. Each guarantee was broken by hand and its
  tests went red:
  - turns pinned to the first key: RoundRobin and RefusedRests;
  - rests ignored: TestSearchAPIKeysTakeTurns, RefusedRests and
    TestSearchQuotas;
  - key masking removed: NeverInFull;
  - a failed read reported as known: TestSearchQuotas.
- gofmt -l; go vet -tags nogui for darwin, linux and windows on the
  four packages.
- GUI: search-keys.test.cjs covers en, zh, zh-TW, ja and de ×
  Chromium and WebKit × 1100 and 420px: 20/20. Without the new
  .search-keys .val wrap rule, de at 420px fails ("Erneut prüfen" went
  past the window's edge).
  - search-api, search-first, search-instead, search-mcp,
    searcher-pick, settings-search, provider-search, gui-de, gui-ja and
    i18n-keys: 56/56 in each engine.
  - Full suite in Chromium (concurrency 6, load ~40): 4498/4504. The
    files that failed (gateway-key-groups, rest-try-now,
    routing-wb-restricted, text-size, usage-sum-whole) were rerun
    alone. All pass except usage-sum-whole, which fails now and then
    on an origin/main worktree too under the same load (#1864, #2023;
    rest-try-now and routing-wb-restricted are #1905). None of them
    touch search.
- Real Tavily API with two invalid keys: /search returns 401
  {"detail":{"error":"Unauthorized: missing or invalid API key."}},
  which counts as a refusal. Both keys rest 10m as turned away, the
  error names them only masked, and both quotas read "unknown · 401".
  Checked through a test and through the nogui CLI binary in a sandbox
  HOME.

Not tried: a valid key's /usage against the real API. No Tavily key
was at hand, so the quota parsing is checked against the documented
bytes only.
2026-10-14 08:24:03 +08:00
yetone f71155591e provider: a provider at a vendor's own endpoint is priced from that endpoint's models.dev catalog (#2052, mengyianx)
A custom provider added by its address alone, with no catalog named, was
priced only by the model's maker. Qwen3.8-27B, whose maker (Alibaba) sells
no such model on any of its seven models.dev catalogs, read "no price is
known for it" even at AMD's own endpoint, where models.dev's amd lists it
at $0, a price.

- catalog: models.dev's provider "api" is read; AtEndpoint names the
  catalogs at a base URL (trailing slash and case ignored).
- provider: EndpointCatalog is the one catalog models.dev lists at one of
  a key's provider's endpoints (an Anthropic base, kept as its root, also
  with /v1), used by ListPrice when the provider has no catalog of its
  own. Never for a subscription's account, never when two catalogs share
  the address (minimax / minimax-coding-plan), never a plan's catalog
  (an id with -plan, or membershipCatalogs), whose $0 is the membership's.
  A user's price and a named catalog still come first; a relay's endpoint
  matches nothing and its model stays unpriced (no reseller guess).
- cli: `magpie model price p/m` with no price gives the two commands that
  set one (p/m and */m); a price from an endpoint's catalog names it.
- gui: the Catalog field's hint says it also sets list prices (en, zh,
  zh-TW, ja, de).
- docs: reference.md's "What a model costs", providers-accounts.md row.

What was run:
- Reporter's exact case, built binary (go build -tags nogui), sandbox
  HOME with a copy of this machine's models.dev cache (2026-10-14, same
  amd entry as the report), providers 001 (relay), 002 and amd at
  https://developer.amd.com.cn/radeon/api/v1:
    001/gpt-5.5      $5/$30, tiers, as before
    001/Qwen3.8-27B  no price, now with the two commands to set one
    002/Qwen3.8-27B  $0/$0, "what models.dev's amd lists at its endpoint"
    amd/Qwen3.8-27B  $0/$0
  The two suggested commands were run and took effect.
- TestEndpointCatalogPrices / TestEndpointCatalogOnlyItsOwn, fixture
  testdata/endpoint_catalog.json trimmed from the real models.dev cache.
  Break checks, each FAILs with the case named:
    ListPrice not using EndpointCatalog -> 002/amd/001 at AMD unpriced,
      EffectivePrice(002, Qwen3.8-27B) unpriced
    plan exclusion removed -> "a plan's endpoint: EndpointCatalog() =
      alibaba-coding-plan", qwen3.5-plus at $0 instead of $0.4/$2.4
    single-match rule removed -> "an endpoint two catalogs share:
      EndpointCatalog() = minimax"
    Account check removed -> "a subscription's account ... = amd"
    Anthropic /v1 match removed -> thinkingmachines unmatched
- GUI: internal/gui/tests/catalog-hint.test.cjs, chromium and webkit, en
  zh zh-TW ja de, widths 1100 and 420: 20/20 pass, plus i18n-keys; with
  the old app.js/i18n.js it fails "one hint names list prices".
- go test -tags nogui -timeout 45m ./internal/catalog ./internal/provider
  ./internal/cli: ok (provider 244s, cli 125s, catalog 3s). gofmt -l
  clean; go vet (darwin), GOOS=linux go vet -tags nogui and GOOS=windows
  go vet -tags nogui on those packages: clean.
2026-10-14 07:51:41 +08:00
youheyu c8392cf7d5 cli: a magpie model picked for an agent not connected connects it first (#1900)
GUI 的 Pick/ConnectHow 会先 connect()(把用户原有模型记进 stash),CLI 的
set 直接 Apply,绕过了 stash:magpie opencode a/m 接上后,magpie opencode
default 无从恢复用户自己的 model/small_model。CLI set 改走 a.Pick——与
Agents 页选择器同一入口,未接线时先连接,已接线与空值行为不变。

对所有以此方式接线的 agent 一致生效(issue 要求的不只 OpenCode/DevEco)。

验证:新测试 TestAgentOpenCodeDefaultPutsBackTheModel——用户自有模型 +
small_model + theme,CLI 接线再 default,旧代码 model 丢失,修复后完整
还原;其相连的 claude/snow default 测试不回归。基线(无此改动)6 个
agent 包失败(Aside×4、版本检测×2)与改动无关,在干净 worktree 同样失败。

Rebased onto main's set (which now keeps `wired` for #2000's notice);
the test now also runs DevEco Code, OpenCode's fork in its own folder,
as the issue asked for both.

Run: TestAgentOpenCodeDefaultPutsBackTheModel opencode+deveco pass;
with set put back on a.Apply both subtests FAIL (model lost). Full
internal/cli -count=1: ok. a.Pick is the GUI's picker path, so every
agent the CLI sets a magpie model on is connected (and stashed) the way
the Agents page connects it; a Native agent still goes to its Apply.
Not changed here: profile.Apply also writes a field with a.Apply.
2026-10-14 05:43:48 +08:00
yetone bf25842714 gateway: a provider's own cap on how long a key that keeps failing rests (#2008, Gaudi-XIX)
A key that keeps failing doubles its rest from a minute up to 10 minutes,
and one rate limited again as soon as its rest is over up to 30; both
caps were fixed, so a free key down for hours was asked again every 10
or 30 minutes all the while.

`magpie provider rest-cap <id> 4h` (Provider.RestCap, minutes, at most
MaxQuotaRest, 8 days) sets where both ladders stop for that provider's
keys and accounts (RestCapOr in restAfterMarked's default branch and in
rateRest); `default` gives back the gateway's own. A time the vendor names
still stands over it. Unset, nothing differs. It is kept by the editor's
save, the account copy and normalize.

Run: go test -tags nogui ./internal/provider ./internal/gateway
./internal/cli ./internal/gui (temp HOME). Broken by hand: both ladders
back on the fixed caps fail TestOwnRestCap (rate-long #6: 30m, want 32m);
the GUI keep removed fails TestSaveKeepsQuotaResetAt. Not tried against a
real vendor's outage.
2026-10-14 05:22:40 +08:00
yetone 064cffdbfd gateway: a key out of a daily allowance rests until the time of day it comes back (#2008, Gaudi-XIX)
A free tier's "You've reached today's free-model token quota" says
nothing of when it is back, so it rested 15 minutes (or the provider's
own quota-rest), and was asked again all day. A vendor Retry-After over
an hour was cut to the hour, and that hour then stood over the user's own
longer rest.

- Provider.QuotaResetAt: "08:00" on this computer's clock, or
  "00:00+08:00" on the vendor's. `magpie provider quota-rest <id> until
  08:00` sets it; a number of minutes set after it replaces it, and
  default clears both. normalize drops one that isn't a time of day.
  It is kept by the editor's save and the account copy.
- restAfterMarked's quota branch rests until its next occurrence
  (OwnQuotaRest). A time the vendor names, or a window's end, still
  stands over it; a Retry-After stands unless it was cut to longestWait
  while the user's own rest is longer.
- Defaults are unchanged: nothing set, nothing differs.

Run: go test -tags nogui ./internal/provider ./internal/gateway
./internal/cli ./internal/gui (temp HOME). Broken by hand, each fails:
OwnQuotaRest replaced by QuotaRestFor (TestQuotaRestsUntilTheTimeOfDaySet,
3 asserts), the Retry-After guard removed (the 7200 case), the GUI keep
removed (TestSaveKeepsQuotaResetAt), default not clearing it
(TestQuotaRestUntil). Not tried against a real free-tier vendor.
2026-10-14 05:22:39 +08:00
yetone 80211e7075 provider: a balance field sums, maxes or counts a list's items, and one amount it can't read is "—" (#1993, RicardoWYP)
A relay's /api/subscription/self tells usage per subscription, a list.
A balance path could only name one index (subscriptions.0), so several
active subscriptions read as the first, ".0 + .1" failed whole when only
one existed, and a weekly cap of 0 ("divides by 0") hid every amount of
the field.

Now a path goes through a list's items with "*" (a.*.used), or those
that match with "[key=value]" / "[key!=value]" (a[status=active].used,
also on an object: a.*.subscription[status=active].used). Such a path is
several values, made one by sum(), max(), min() or count(); arithmetic
between two of them goes item by item, so max(a.*.used / a.*.cap) is the
fullest window. Several values left outside a function are an error
naming the functions, not a guessed sum. Within a list an item without
the path, or divided by 0, is left out; max/min of nothing is an error.

In a field of several ";" amounts, one that can't be read shows "—"
(BalancePart.Error says why, as the card's hover on the Usage page and
in the panel) and the others still show; the read fails only when none
can be read. A single amount alone still fails as before.

The GUI hint (zh, zh-TW, ja, de) and `magpie provider` help say the new
syntax.

Run:
- TestBalancePathLists, with the reporter's literal JSON: against the
  old balance.go it fails ("nothing at \"sum\" in the reply", and the
  "—" cases error); passes now. TestReadBalancePath's one case that
  expected a whole-field failure with one bad amount now expects it
  only when every amount fails.
- go test -tags nogui ./internal/provider ./internal/cli ./internal/gui
  under a temp HOME: ok.
- balance-parts, gui-de, gui-ja, gui-zh-tw, i18n-keys in Chromium and
  WebKit: 14 pass. With the title lines removed, balance-parts fails on
  the missing hover text.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  provider and cli.
Not tried against the reporter's real relay.
2026-10-14 04:37:43 +08:00
yetone b26c083c84 cli: setting Claude Code's sonnet/opus/haiku/fable while it is on magpie says magpie is out, and help says the aliases take it out (#2000, marshalys)
`magpie claude sonnet` sets Claude Code's model to its own alias. That
isn't a model magpie serves, so magpie steps out (unroute) and puts back
the endpoint Claude Code had before magpie. In #2000 that endpoint was
DeepSeek's, which refused Sonnet with a 400. The command printed only
"✓ Claude Code model sonnet". An agent had run it as a read-only query of
the sonnet tier, and nothing in the output said the routing had changed.

set() now checks whether the agent was wired into magpie before the
write. When a non-empty value leaves it unwired, set() prints
"disconnected from magpie: <model> is <agent>'s own, sent to the endpoint
it had before magpie; magpie <agent> <model> with one of magpie's models
connects it again". This covers every agent and field set through
`magpie <agent> …`, not only Claude's aliases. Setting a field back to
default (empty) is left as it was. `magpie <agent> default` already says
it disconnects.

The behaviour itself is unchanged. On an Anthropic sign-in or a Claude
relay the aliases are a deliberate one-word way back to Claude Code's own
models.

`magpie claude help` now has a line under the aliases: "they are Claude
Code's own models, not magpie's: setting one takes magpie out; magpie
claude alone shows each".

Verified:
- TestClaudeAliasSaysItTookMagpieOut covers opus, sonnet, haiku and
  fable. It starts from a DeepSeek-style own endpoint (.invalid host),
  wires Claude Code to group/advanced and sets the alias. It checks the
  notice, that the old endpoint is back, that nothing is printed when the
  alias is set again while off magpie, and the help line.
- With the notice disabled by hand, the test fails:
  "magpie claude opus: <nil> "✓ Claude Code model opus\n", want it to say
  magpie is out" (and the same for the other three).
- TestAgentDefaultInAnyCase first went red on "codex model DEFAULT", so
  empty values are excluded.
- HOME=<sandbox> go test -tags nogui ./internal/cli: ok.
- gofmt -l clean. go vet and GOOS=linux/windows go vet -tags nogui
  ./internal/cli: clean.
2026-10-13 23:30:17 +08:00
yetone c4e6abf3cc gui, cli: a model id typed with a space in it stays one model, "Opus 5.5" not Opus and 5.5 (#1976)
elonnzhang on #1976: on a Baidu OneAPI relay, typing `Opus 5.5` in the
provider editor's add box (or the add form's Models field) and pressing
Enter added two models, `Opus` and `5.5`. Both read the box with
split(/[,\s]+/), while their hints say "comma separated".

- app.js: one typedIds() for both, split at commas (and line breaks)
  with each id trimmed. chosenIds() (the add box, and an id left in it
  at Save) and the add form's Models field use it.
- CLI siblings, which split the same way: `magpie provider set
  models=` now splits at commas only. A group's models=, models-=,
  fast= and weight= split at commas, and an item with a space that
  names no model the group can have is still split at its spaces, so
  `models=m,b/x a/m` (TestApplyGroupPairs) still works. levels= and
  `magpie visible` (effort levels and family names) are unchanged.
- Tests: the reporter's two GUI assertions in models-add-and-icons
  (from their fork branch). A new model-id-space.test.cjs covers both
  boxes in en, zh, zh-TW, ja and de, Chromium and WebKit, at 1100 and
  420 wide. TestModelIDsKeepTheirSpace covers the CLI. The fork's change
  to provider-add-models.test.cjs is not taken: filling the Models field
  there replaces the picks it holds, so it failed on its own terms.

Run: on the old split, model-id-space fails (4/4 for en and de at 420
in Chromium) and TestModelIDsKeepTheirSpace fails (models = ["Opus"
"5.5" ...]). With the whole-item check forced off, it fails on members.
With the fix: model-id-space 40/40, models-add-and-icons 4/4 and
provider-add-models 4/4 pass. `go test -tags nogui ./internal/cli` is
ok. gofmt is clean, and go vet passes for darwin, linux (-tags nogui)
and windows.
Not tried: a real relay with a spaced model id served end to end.
2026-10-13 18:16:03 +08:00
yetone 9e76fcdc68 plugin, cli, gui: a plugin's "password" question is typed unseen, as an API key is (#1982)
A sign-in method's prompts could only be "text" or "select", so a token a
plugin asks for (the Qoder plugin's PAT sign-in, magpie-community/plugins#103)
showed on screen as it was typed, in the app and in `magpie plugin login`.

What changed:
- internal/gui/assets/app.js renderPluginAsk: a prompt of type "password"
  gets a password field (masked), the same field an "api" method's key
  gets. A "text" prompt is unchanged.
- internal/cli/plugins_cli.go askPrompt: on a terminal a "password" prompt
  is read with term.ReadPassword (no echo); piped in it is read as a line,
  as a script answers it, and an empty answer still goes to the plugin's
  validate, as a text one does.
- internal/plugin/providers.go: the Prompt type lists "password". host.js
  passes the type through untouched, so nothing there changes. The TUI has
  no plugin sign-in.
- Docs: docs/reference.md and site/public/docs (en, zh, ja) plugins.html
  say what "password" does and that it is magpie's own (OpenCode has text
  and select).

The answer is only sent to /api/plugin-signin/prompt and the sign-in, as a
text answer is; nothing logs or shows it.

What was run:
- TestAskPromptPasswordIsUnseen (internal/cli): with the password branch
  disabled by hand it fails with `password on a terminal =
  "typed-in-the-open", <nil>, hidden reads 0; want pt-secret read unseen`;
  restored it passes.
- plugin-password-prompt.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de,
  1100 and 420 wide, 11/11 each. With app.js put back it fails with
  expected 'password', actual 'text'. plugin-signin and
  plugin-signed-out-account 16/16 in both engines; i18n-keys passes in both.
- gofmt -l clean; go vet for darwin, GOOS=linux -tags nogui and
  GOOS=windows on internal/cli, internal/plugin, internal/gui; go test
  -tags nogui of those three packages in a sandbox HOME: ok.

Not tried: a real Qoder PAT through the community plugin (its PR isn't
merged), and the CLI on a real Windows console (term.ReadPassword is the
same call `magpie plugin login` already uses for an API key).
2026-10-13 18:01:20 +08:00
yetone 4795f56469 provider, gui, cli: a Codex account's card says the last reset magpie used, when and why (foobra12 on Discord)
foobra12: "magpie会自动使用codex重置卡吗 我发现刚才好像不小心自动给我使用了
一张". Auto-use is off by default and spends only for accounts switched on
(the week used up with no other account to answer, or a reset ~30 min
before it expires), but a reset magpie spent was said only in the gateway's
log. A reset gone from the card read the same whether magpie used it, the
user did, or it ran out.

Each reset magpie spends is now kept in codex-resets-used.json (by account,
when, why: week / expiring / hand, windows started again; 90 days, 200 at
most, under a cross-process filelock, written with steady.WriteFile; a file
that doesn't parse is copied aside to .bad-<ts>, never read as empty). Only
a consume whose outcome is "reset" is kept. useCodexReset carries why:
AutoUseCodexReset passes week, SpendExpiringCodexResets expiring, and
UseCodexReset (Usage page, panel, CLI) hand.

loginReading, the choke point for LoginUsage and the Usage page, attaches
an account's last 5 uses to its reading (cached readings too, so a reading
kept from before a use still says it), and Quota/SubscriptionQuota carry
resetsUsed. The auto-use row on the Usage page's and the panel's card adds
a line "Last reset used: {when} · {why}" (zh 上次用卡:… · 自动,重置卡到期前),
every kept use in its title; an account in brief has it in its switch's
title. `magpie quota auto-reset <account>` lists them. en, zh, zh-TW, ja, de.

The default (off) and the expiry rule are unchanged: both are documented in
the switch's title and only reach accounts the user turned on.

Run:
- go test -tags nogui -count=10 -run TestResetUse ./internal/provider/
- break by hand: noteResetUsed call removed -> TestResetUsesKept red
  ("kept [], want [week hand expiring]"); loginReading attach removed ->
  red ("the card's reading has []")
- node --test codex-resets-used.test.cjs: chromium+webkit, 1100 and 420,
  en zh zh-TW ja de, the Usage page card, brief title, the panel card; 3
  runs green; with the say.append removed, 5/5 red
- codex-auto-reset, routing-auto-reset, quota-curve, click-scroll,
  tray-usages, i18n-keys, gui-ja, gui-de, gui-zh-tw: green.
  old-webkit is red on "Safari 15.0 styles" at app.css .prefs
  .val:has(> .side-effort), from dc2f0da82, the same on origin/main
  692a779d3; not this change's.
- gofmt -l, go vet (darwin, linux -tags nogui, windows), full tests of
  internal/provider, internal/cli, internal/gui, internal/gateway

Not tried: no real Codex account and no real reset spent (the ChatGPT
endpoints are faked); no notification when magpie spends one.
2026-10-13 17:32:39 +08:00
yetone 05edac2c36 daemon: the service's PATH has the Node a terminal gets, nvm's default among them (bookyue on Discord)
What changed: `magpie daemon install` now widens PATH before writing it
into the systemd unit or launch agent, the way the app does when opened
from the Dock (proc.UserPath): the version managers' and npm's folders
that exist, nvm's default Node (not its newest), then the login shell's
own PATH (proc.LoginPath), each after the folders the install's shell
already had. When no node is found even then, the install says so.

Why: the service has only the PATH written into it. With nvm loaded
lazily, or an install run over ssh without a login shell, that PATH had
no node, and plugins (and the MCP servers and agent CLIs they start)
couldn't find it under systemd (bookyue, #feedback 838099).

Run: gofmt -l; go vet darwin, linux -tags nogui, windows (daemon, cli);
go test ./internal/daemon ./internal/cli -count=1 on macOS; the daemon
test binary for linux/arm64 in debian:bookworm-slim (all pass).
TestInstallFindsNvmNode uses the real widening with a sandbox HOME
holding nvm v20 (default) and v22: the unit's PATH has v20's bin, not
v22's, after the shell's own. With the widenPath() call removed by hand
it fails (PATH is the shell's alone, Node() empty).

Not run: a real systemd install with nvm since this change (the earlier
container run, before it, covered install/restart/linger); not tried
with fnm or volta, which UserPath handles the same way for the app.
2026-10-13 17:15:51 +08:00
yetone 5617281f55 cli: magpie daemon install|uninstall|start|stop|restart|status keeps the gateway running as a service (HuanCheng on Discord)
What changed: a new internal/daemon package and `magpie daemon`, which run
`magpie serve` as the user's own service, with no window and no desktop
session.
- Linux: a systemd user unit at ~/.config/systemd/user/magpie.service
  (Restart=on-failure), driven by systemctl --user. status reads
  `systemctl --user show`, and says `sudo loginctl enable-linger $USER`
  when the user doesn't linger. su/sudo without the user's bus, no
  systemd, and WSL without systemd each get an error that says what to
  do.
- macOS: a launch agent, com.yetone.magpie.serve (RunAtLoad, KeepAlive on
  failure), loaded with launchctl bootstrap gui/$UID. Its log is
  ~/Library/Logs/magpie/serve.log.
- Windows and Android: refused, pointing to `magpie autostart on` (or to
  WSL).
- The service carries PATH, the proxy variables, MAGPIE_*, the XDG folders
  and the agents' folder variables from the install shell. The file is
  0600 because a proxy can hold a password. It runs magpie by its PATH
  name when that is the same file, so Homebrew's link survives updates.
  It refuses a go-build binary and an AppTranslocation copy.
- Install is refused while `magpie autostart` is on: the tray app serves
  the gateway too, and the two would crash-loop on the port.
- Docs: a reference.md section, and one sentence on the site's start page
  (en, zh, ja).

Why: users on headless Linux boxes asked for a supported way to keep
`magpie serve` up across reboots instead of hand-written units. The
existing `magpie autostart` needs a desktop session (an XDG autostart
entry).

What was run:
- gofmt -l; go vet on darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test ./internal/daemon ./internal/cli on macOS, at origin/main
  5b9530b56.
- The daemon tests cross-built for linux/arm64 and run in a Debian
  container.
- The tests use fake systemctl, launchctl and loginctl on PATH in a test
  home.
- Each guarantee was broken by hand and its test went red: the % escape,
  the autostart refusal, the 0600 chmod, the bootout before re-bootstrap,
  the go-build refusal, the bus advice, the last-exit filter and the
  PATH link.
- Real use on Linux: a Debian bookworm container running systemd as PID 1,
  with the linux/arm64 build, as an unprivileged user.
  - install: the gateway answered on :3425, and the unit was 0600.
  - kill -9: systemd restarted it 5s later.
  - Container restart with linger on: it came back by itself.
  - restart, stop, start and uninstall worked, and the unit and its wants
    link were gone afterwards.
  - Under sudo without XDG_RUNTIME_DIR it printed the bus advice.
- macOS: the darwin build ran `magpie daemon install` under a sandbox HOME
  with a fake launchctl. plutil -lint passed on the plist, and the calls
  were print and then bootstrap.

What wasn't: no real launch agent was loaded on a Mac (deliberately: never
on this machine), so launchd's own acceptance of the plist is checked
only by plutil. The linger advice was checked by the unit test, not seen
from a real SSH login. Windows was not run beyond vet.
2026-10-13 17:05:59 +08:00
yetone 3ccbe6bc15 plugins: a runtime for built-in plugins, and Plugins › Built-in to switch them (P0)
Lxxyx on X (https://x.com/Lxxyx_/status/2109506752656150974): magpie has
too much in it. This is P0 of making magpie's parts plugins, as DeepSeek
Harness does: a runtime, plugins.yml, and the first five built-in plugins
the user can switch off.

- internal/pluginrt: a registry (Register from init), a manifest (API
  caret range, Requires/Provides, Essential, InUse, Apply, Parts,
  Defaults) and Reconcile: the plugins no longer wanted, with whatever
  needs a service they provided, are disposed newest first; the wanted
  ones are applied once their services are there. A plugin that fails or
  panics is failed and the rest run. TestPluginsImportOnlyCore keeps the
  boundary: nothing outside plugins/ imports one, none imports another.
- plugins.yml (appdir.Config()): default → preset (essentials | all) →
  the user's rows → in use. A new install is written Essentials, a magpie
  that ran here before (settings.RanBefore) All, so existing users keep
  everything. Writes are locked, whole and keep a .bak; a file that
  doesn't parse is an error, never empty, and is never written over.
- plugins/groups, library, otel, sessions, warmups. In P0 a plugin off
  is the window's alone: its page, sections and rows (data-feature) leave
  the window; the gateway, TUI and CLI serve the same, nothing is
  deleted. One in use stays on.
- The window: Plugins › Built-in, the first tab, a switch per plugin;
  GET/POST /api/plugins/builtin; boot.js says which are off before the
  first paint. CLI: magpie plugin builtin [on|off <id>], plugin preset,
  plugin dump [--json].
- docs/subsystems/plugin-runtime.md, gui-shell.md.

Run: go test ./internal/pluginrt/ ./internal/settings/ ./internal/gui/;
gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...; GOOS=windows
go vet ./.... GUI: builtins.test.cjs in Chromium and WebKit, 5 languages,
1100/800/420; list-sort, mobile-web, routing-keys-fold, routing-sessions
pass. By hand under a sandbox HOME: a new install gets essentials, an
existing one all, a broken plugins.yml is refused and kept, dump works.
Full suite results after the rebase are in the push notes.
2026-10-13 16:19:13 +08:00
yetone b8e23db45a backup, davsync: an import or a sync installs the plugins and names the subscriptions to sign in to (yapechan)
yapechan on Discord (Windows, Synology WebDAV): after an import or a WebDAV
sync no providers showed on the other computer; adding the same provider by
hand made the synced settings and usage apply. No error, a restart didn't
help.

Cause. A backup and a sync carry providers.json as stored. For a
subscription that is its model picks and settings alone (no endpoint, no
key), and sign-ins are never carried by design; allProviders lists such an
entry only once an account is signed in here. plugins.json was not carried
at all, so a provider served by a plugin (every moved subscription, any
plugin provider) had nothing to come from on the other side. The import
said "N added" and "Needs a key: , " (the picks entries have no name and no
key), and the sync said nothing. API-key providers do come over: tried with
a nogui build in two sandbox HOMEs (DeepSeek, a custom relay, Kimi Code all
listed after `magpie restore`). No Windows-only path issue found.

What changed:
- provider.Carried(keys): the plugins added from npm or git, on/off and
  their options (without keys, options whose names look like a key are left
  out, as secret headers are). Folder plugins and plugin-auth.json stay.
- backup.Bundle.Plugins (nil from an older magpie). Restore installs the
  ones not here through provider.AddPlugins (plugin.Add, then Off and
  Options, then HandOver once); it never removes or changes one already
  here. A failed install is reported, not a failed restore.
- Result.SignIn / provider.NotSignedIn: the subscriptions brought with no
  account here. NeedKey no longer lists picks-only entries (provider.OnlyPicks).
- davsync: the providers part's hash covers the plugins (unchanged for a
  setup without any), take/bring carry them, bring installs (logged on
  failure), and Status().SignIn names what to sign in to.
- CLI restore and `magpie webdav`/`s3` status print both; the GUI's import
  result and the sync row show them (en, zh, zh-TW, ja, de).
- docs/reference.md says what a backup carries now.

Run:
- go test -tags nogui ./internal/provider ./internal/backup ./internal/davsync
  ./internal/cli ./internal/gui in a sandbox HOME.
- New tests fail with the change broken by hand: TestPluginsCarried
  (installed-skip and the HandOver guard), TestNotSignedIn,
  TestRestorePluginsAndSignIn ("Needs a key: [ Acme]" without OnlyPicks),
  TestSyncPluginsAndSignIn (bring not installing, Status not naming),
  sync-sign-in.test.cjs (the lines removed).
- sync-sign-in.test.cjs: Chromium and WebKit, en/zh/ja/de, 900 and 440px,
  16/16; it also caught subNames throwing while providers was still null.
  sync-*.test.cjs, s3-sync, i18n-keys, gui-ja, gui-de pass.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui on the
  touched packages.
Not tried: a real plugin install from a real sync (the installs are stubbed
in tests); a real Synology server.
2026-10-13 15:52:17 +08:00
yetone f82aba090b davsync, gui, cli: GitHub sync refuses a repository that isn't private (#1130)
The sealed setup is committed on every sync, so a public repository would
hand anyone every version of it, the whole history, to try passphrases on
offline. prepare now reads the repository's "private" field and refuses
before writing when it is false or missing, naming the repository and what
to do. The form's hint, the CLI usage and docs/reference.md say the
repository must be private; sync-backup.md lists the rule and its
verification command now points at ./internal/cli.

Run: go test -tags nogui ./internal/davsync/ and the cli tests
(TestGitHubCmd|TestWebdavCmd|TestS3Cmd|Help) green;
TestGitHubPublicRepositoryRefused goes red with the check removed. GUI:
github-sync, s3-sync, webdav-settings-refresh, sync-other-kind,
sync-not-backup, i18n-keys, gui-zh-tw, gui-ja, gui-de in Chromium and
WebKit, 72/72. Not tried against the real GitHub API.
2026-10-13 15:25:10 +08:00
bingqilinweimaotai 1af326806f sync: magpie's setup syncs to an encrypted file in a GitHub repository, beside WebDAV and S3 (#1130)
A third sync kind: github://owner/repo[/folder] keeps the same sealed
backup WebDAV and S3 keep, as <folder>/magpie/magpie.magpie-backup in a
repository the user already has, written through GitHub's Contents API
with a fine-grained token of its own (Contents read and write), kept in
sync.json apart from the library's GitHub token. The token goes only to
api.github.com: a redirect anywhere else is refused, and the passphrase
may not equal it. Each update is a commit; an empty repository is
initialised by the first backup. Settings › Sync gets a GitHub kind with
Repository, Branch, Folder and token; magpie github mirrors magpie s3.
Inactive servers of every kind are kept in Config.Servers (Other stays
for older clients).

Squashed from yetone/magpie#1130 at 6b5b1c693e1a3a23e177b4d376f3f7f70f3bc23d
onto main. Merge resolutions: the CLI moved to internal/cli since the PR
was cut, so github_cli_test.go moved there (package cli) and the github
command, its help line and `magpie help github` were wired in
internal/cli/main.go and help_cli.go; README's Sync row kept main's
links and took the PR's wording; i18n.js zh-TW kept both sides.
2026-10-13 15:25:06 +08:00
yetone 494609866b cli tests: TestAgentQwenDefault expects the model's name as Names in agents' lists gives it
6fa3109ea made Qwen's modelProviders entry name the model as
provider.Labels does ("m · A"), not "magpie/a/m", and ran agent, gui and
provider but not internal/cli, whose TestAgentQwenDefault still asked for
the old name. main has been red on ubuntu and macOS since (run for
9492e5db8). The entry is still found by its id, which the test checks too.

Run: go test -tags nogui -count=1 ./internal/cli (ok, 145s); gofmt -l
clean. On origin/main before this change the same test failed with
"name": "magpie/a/m" missing.
2026-10-13 14:41:10 +08:00
yetone d6fd9b3a36 provider, agent, gui, cli: Codex can switch only its own sign-in between accounts, never through the gateway (#1907, foobra)
foobra wants Codex Desktop and the CLI kept on their own ChatGPT
subscription, moved to the next saved account when the signed-in one is
used up and back when it resets, without magpie's gateway in the way.
magpie already did the switch (codex_switch.go: 98%, 100% In order, back
under 90%, unknown usage never switches), but with more than one Codex
account on it also wrote openai_base_url into config.toml so a refused
request fails over through the gateway (codexFailover). There was no way
to have the first without the second.

Now Codex's subscription has SwitchOnly (providers.json "switchOnly",
opt-in, off by default so nothing changes for anyone who doesn't tick it):
- provider.SetSwitchOnly / provider.SwitchOnly; only Codex's own
  subscription takes it. An unreadable providers.json reads as on, so
  magpie's own failover is never written on a guess.
- agent.codexFailover is false when it is on: no openai_base_url, no
  failover note, no magpie models in Codex's list. A base URL the user
  wrote stays.
- The account Save copy keeps it.
- GUI: "Only switch Codex's sign-in" tick under Providers > Codex's
  accounts (with more than one on), posting provider/switchonly; the
  Agents row's failover title points at it. zh, zh-TW, ja, de.
- CLI: magpie accounts switch-only codex [on|off].
- docs/reference.md and providers-accounts.md say what it does and that
  an open Codex app or app-server stays on its account until reopened.

Run (darwin, sandbox HOME, -tags nogui):
- go test ./internal/provider -run 'TestCodexSwitchOnly|TestCodexSwitchedWhenUsedUp|KeepLogin'
- go test ./internal/agent -run 'TestCodexSwitchOnly|TestCodexFailover|TestCodexOwnModelThroughMagpie|TestCodexHandWritten'
- Broken by hand, each red: codexFailover guard removed (agent test),
  SwitchOnly dropped from the Save copy, SwitchOnly reading false on an
  unreadable file (provider test), the tick drawn unticked (GUI, 16/16).
- GUI: switch-only (new), keep-login, agent-failover, gui-ja, gui-de,
  gui-zh-tw in Chromium and WebKit, en/zh/ja/de at 1100 and 420: 77 pass.
- The built binary's `accounts switch-only` in an empty sandbox HOME:
  reads off, refuses on with no Codex provider, refuses claude.
- gofmt -l clean; darwin go vet.

Reviewed and rerun after rebasing onto eba718736 (darwin, sandbox HOME).
The rebase met #1899's withPicks; SwitchOnly is copied there now.
- gofmt -l clean; go vet -tags nogui on darwin, GOOS=linux and
  GOOS=windows for internal/provider, agent, cli, gui.
- go test -tags nogui -timeout 40m ./internal/provider ./internal/agent
  ./internal/cli ./internal/gui: all ok. (On the base before, provider's
  TestCopilotSecretToolUsername timed out once under load: #1627,
  untouched code, 3 of 3 alone.)
- Broken by hand, each red: the codexFailover guard removed
  (TestCodexSwitchOnlyKeepsCodexOffTheGateway), SwitchOnly dropped from
  the Save copy, from withPicks, and an unreadable providers.json
  reading off (TestCodexSwitchOnlyStillSwitchesTheSignIn).
- GUI: switch-only, keep-login, agent-failover, gui-ja, gui-de, gui-zh-tw
  in Chromium and WebKit at 1100 and 420: 77 of 77 pass.

Rebased again onto 81f587d7b (clean; it touches provider, cli, gui but
not agent): vet on all three OSes again, go test -timeout 40m
./internal/provider ./internal/cli ./internal/gui all ok, -run TestCodex
./internal/agent ok, and the 77 GUI cases above pass again.

Rebased once more onto d45b20757 (clean; no lines of this change touched):
vet on all three OSes, -run 'TestCodex|KeepLogin|SwitchOnly'
./internal/provider ./internal/agent ok, switch-only and agent-failover
in Chromium and WebKit pass.

Not run: not tried with real ChatGPT accounts or the Codex app.
2026-10-13 14:35:08 +08:00
timonwong 79099d6adb provider, gui, tui: Ollama, LM Studio and oMLX take an address, so a server on another port or computer is the preset's provider (#1165)
The three On this machine presets were pinned to localhost and their
default port: one started on another port, or on another computer on
the LAN, had to be rebuilt as a custom provider or typed URL by URL in
the CLI. They now take an Address (scheme, host and port), and each of
their URLs keeps its own path there (provider.AtAddress, AddressOf; no
scheme means http, only http/https, port 1-65535, a pasted path is
dropped, anything else refused with nothing changed).

- GUI: the add and edit editors have a Server address section under the
  key, folded unless the saved address isn't the preset's, opened and
  focused on a refused one. The Endpoints, Test and Refresh follow what
  is typed; URLs are sent only when the address changed, so ones set
  apart (an import, the CLI) are left alone. zh, zh-TW, ja, de.
- TUI: adding a local preset asks for its address before the key (Enter
  keeps the default), and w edits it.
- CLI: the usage shows provider add ollama url=... anthropic=....
- LM Studio's and oMLX's notes say "port N by default".

timonwong's PR head e63cf18e, merged onto main, which had given oMLX a
decision API (#1641) since: presets.go keeps main's oMLX Decide; app.js
keeps both the Vertex block and the address one; the docs row and -run
list take both.

Run: see the next commit.
2026-10-13 13:47:58 +08:00
yetone eba7187368 gateway, provider, cli, gui: a group can route By weight, each member's share set beside it (#1910, DD on Discord)
DD asked for weighted round robin as a group routing, next to In turn.
A provider's keys could already route by weight (#841). Groups could not.

What changes:
- provider: Group.Weights maps a member's spelling to its weight, 1 to
  1000. A member left out, or set to 0, weighs 1. SaveGroup accepts
  routing "weight". It also cleans weights the way it cleans fast and
  off: it strips :fast, drops weights of members that are gone and of
  members weighing 1, and refuses a weight below 0 or above 1000.
  Weights follow a member when it is renamed (RenameMember, Rename,
  RenameGroup) and survive Share/Import.
- gateway: planLevel treats each member of a weight-routed group as one
  unit: a model with its keys in its provider's order, or a nested group
  routed its own way. weightedUnits orders the units by smooth WRR on a
  round per group ("group/<id>"), sharing wrrPick with the keys. The
  round's pick goes first and the rest stay in member order for
  failover. A unit whose head is resting leaves the round. When a
  conversation is kept on another member (session/turn/cache/strict),
  the charge moves to that member (wrrSeat, wrrMove).
- cli: routing=weight (also weighted, wrr). weight=<model>=<n>[,...]
  sets weights and keeps the rest; weight= on its own clears them. The
  group view shows "· weight N" for each member.
- tui: By weight is in the group routing list.
- gui: the group editor offers By weight. Each member then shows
  "Weight N · S%", its share among the members that are on. Clicking it
  edits the number in place: Enter or blur keeps it, Escape cancels,
  and a value outside 1 to 1000 shows a warning. The trace header uses
  group wording for a weight-routed group. Strings are added in zh,
  zh-TW, ja and de.
- docs: reference.md, gateway-routing.md, and site start pages in en,
  zh and ja.

Run:
- go test -tags nogui ./internal/provider ./internal/cli ./internal/tui:
  ok.
- ./internal/gateway: ok in 988s with -timeout 45m. The first run hit
  the default 10m timeout at load average ~170. The test running at
  that moment had been running for 2s; it was not a hang.
- go vet -tags nogui on those packages, for darwin, GOOS=linux and
  GOOS=windows: clean. gofmt -l: clean.
- New group-member-weight.test.cjs: 8/8 in Chromium and WebKit, en and
  zh at 1100, en and de at 420. The WebKit de 420 case also passed six
  runs at once.
- gui-zh-tw, gui-ja, gui-de, i18n-keys, routing-*, group-*,
  panel-routing*, settings-groups and agent-model-groups: all green
  except two.
  - routing-steady (WebKit) is #1804. It is red 2/3 alone on origin/main
    e1b70c13d too.
  - routing-save-blank (chromium en) was red under load only, and 3/3
    green alone. The overshoot in its wheel loop is filed as #1924.

Broken by hand, each red, then restored:
- byWeight forced false:
  --- FAIL: TestWeightedGroup (weighted_group_test.go:69 its turn ...)
- cleanWeights call skipped:
  --- FAIL: TestSaveGroupWeights (groupweight_test.go:39 weights map[...
  an/claude-opus-5-5:0 ... oa/gpt-6.1-sol:high:fast:3 ...])
- CLI weight case renamed:
  --- FAIL: TestGroupWeightCLI (unknown field "weight")
- GUI chip not appended: group-member-weight chromium en 1100 timed out
  on the weight button.
- Not red: the test's "moved nothing" check. A scroll forced on click,
  or padding added above, did not turn it red, because the view's own
  scroll guard and scroll anchoring hold the clicked row in place. It
  only shows that the row stays under the pointer.

Not tried: real accounts through a running gateway. The routing is
proven by the plan-level test with synthetic providers only.
2026-10-13 13:10:30 +08:00
yetone bde11c7780 plugin, cli tests: stay off the network, so a host start never waits 30s on the real models.dev (#1922)
What: internal/plugin's and internal/cli's TestMain now call
testenv.Offline, as gateway's and provider's already do, and each package
has TestStaysOffTheNetwork. TestPluginListSaysMiddleware runs on
testenv.Bun via MAGPIE_BUN like its siblings, instead of downloading
Bun 1.4.2 from GitHub on every run (the guard turned that up).

Why: every plugin test's sandbox is a new home with no models.dev
catalog, so startOn fetched the real https://models.dev/api.json, with a
30s cap, on each host start until one succeeded. When models.dev didn't
answer the macOS runner, a test that starts two hosts (Add, then Restart
or a list changed elsewhere) spent 30s + 30s; the second start reached
its init call with the test's one-minute ctx already gone: "starting
plugins: context deadline exceeded" at 60s, TestPluginsChangedElsewhere
at 90s. Ubuntu's runner got models.dev's answer in time.

What was run:
- Injected the delay on the old code: a DialContext that holds every
  non-loopback dial. TestFallenBackListKeepsTheLastOne/throws=,=1,=own
  60.1-60.4s, TestUnloadedPluginKeepsProviders 60.32s,
  TestPluginsChangedElsewhere 90.36s, each "starting plugins: context
  deadline exceeded" - CI's signature. With Offline on top of the same
  slow dial: all pass in 0.4-1.0s.
- TestStaysOffTheNetwork fails on the old TestMain ("models.dev answered
  200 OK"), passes with the change.
- 8 parallel -race processes x -count=6 of the three tests on the old
  code: all passed (models.dev answering here), so the delay, not load,
  is the cause.
- go test -tags nogui ./internal/plugin/... ./internal/cli/... pass;
  go vet (darwin, linux, windows), gofmt -l clean.

Not tried: on a macOS CI runner itself (the push's run is the check).
The product path is unchanged: a magpie whose models.dev fetch hangs
still waits up to 30s on each host start until one succeeds.
2026-10-13 13:02:58 +08:00
Jianyu c984adfbc7 sessions: a renamed or moved Claude Code project folder is relocated with its sessions, from the Sessions page or the CLI (#1131)
Renaming or moving a project folder left Claude Code's transcripts under
the old encoded project path: magpie listed them with a resume command
for a folder that no longer exists, and Claude Code in the new folder
didn't find them. A Claude Code folder row on the Sessions page now has
Relocate project, which opens magpie's own dialog with the new absolute
path, a read-only preview and a confirm that carries the preview's
token; `magpie sessions relocate-claude --from --to [--confirm <token>]`
does the same in a terminal (inside WSL too).

The whole project store moves, session ids, subagents, tool results and
memory with it; the transcripts' top-level cwd and the sessions index
are rewritten, message text is not. The originals and a recovery
manifest are kept outside Claude's project list, writes are staged
before the originals are renamed, a change since the preview is
refused, and a failed publish rolls back. An existing target store,
recently written files, a malformed transcript, a symlink, an ambiguous
encoded path or a long hashed name are refused. Desktop's stores are
left alone. Recovery is in docs/session-relocation.md.

Jianyu's PR head e8263cde, which conflicted with main: the button moved
into main's folder() row, the CLI test into internal/cli beside
sessions_cli.go, and both sides of sessions_manage.go and i18n.js kept.

Run: see the next commit, which adds the zh-TW/ja/de strings and the
GUI test.
2026-10-13 13:02:09 +08:00
yetone e528aeb3ce agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (03a01a548):

- Config in ~/.config/deveco. magpie writes the first of deveco.jsonc,
  deveco.json, config.json there (the one DevEco reads last wins its
  merge), or DEVECO_CONFIG_DIR when that is an absolute folder; agentenv
  carries DEVECO_CONFIG_DIR. Auth at ~/.local/share/deveco/auth.json.
- Its provider block carries the key magpie-deveco, not the plain one.
  0.2.3 sends "deveco/0.2.3 ai-sdk/provider-utils/4.0.23 runtime/bun/1.4.2"
  on chat, but parts of its code still send opencode/<version>, so the key
  keeps its usage DevEco's whichever it sends. Check flags the plain key,
  and Sync writes DevEco's back. OpenCode's own key is unchanged.
- The user's own provider, small_model, $schema and comments stay; the
  model they were on comes back on Disconnect.
- Library: AGENTS.md instructions (with the "reads Claude Code's
  CLAUDE.md" note, as OpenCode and MiMo Code), MCP in OpenCode's shape,
  skills. No WSL folder.
- Install/update: npm @deveco/deveco-code on macOS and Windows only, as the
  package has no Linux binary (new cliSpec.only); the self installer under
  ~/.local/share/deveco/versions updates with `deveco upgrade`.
- Icon: DevEco's own logo, byte for byte from its IntelliJ plugin's
  pluginIcon.svg. Model picker /models. Route hue, READMEs (en, zh), site
  agent lists (en, zh, ja), docs/reference.md, subsystem pages, CLI help.

What was run
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -tags nogui: internal/library, agentenv, proc, cli, gui, usage
  pass; internal/agent passes in 559s with -timeout 40m;
  its first run, at the default 10m with load average ~40 from other
  sessions, was cut off by the timeout (no test had failed).
- New deveco_test.go: config lookup and DEVECO_CONFIG_DIR, the key, and
  Connect/Check/Sync/Disconnect against a deveco.jsonc holding the user's
  own model, provider, small_model, $schema and a comment. Made
  openCodeKeyAt return the plain key by hand: TestDevEcoKeyNamesIt and
  TestDevEcoConnectKeepsTheUsersOwn go red.
- GUI: new library-deveco.test.cjs (the note in en, zh, zh-TW, ja, de,
  and the icon draws), chromium and webkit; red with deveco taken out of
  library.js's note. library-instr-sets, library-instr-busy,
  panel-routing, agent-connect, library-desktop-skills, getting-started,
  filter-ime, routing-account-identity pass in both engines.
- Real use, sandbox HOME: npm-installed @deveco/deveco-code 0.2.3,
  `deveco auth consent --accept` (sandbox only, no Huawei sign-in). magpie
  serve on 127.0.0.1:3592 with a fake upstream; `magpie deveco fake/fake-1`
  wrote provider magpie (magpie-deveco, http://127.0.0.1:3592/v1) beside
  the user's own and kept the file's comment; `deveco run "Reply with one
  word: ping"` answered from the fake, and `magpie usage today` counted it
  under DevEco Code. The User-Agent above is what it sent.

Not tried
- Windows, and DevEco Studio's plugin mode; a Huawei-signed-in DevEco.
- `magpie deveco <model>` then `magpie deveco default` doesn't bring back
  the model the user was on before: the CLI set path doesn't stash. It is
  the same for OpenCode today; Connect/Disconnect in the GUI does.

Reported-by: foobra
2026-10-13 10:57:32 +08:00
AnxForever 6794cccd53 cli: models and visible find a WSL agent by its id, in any case (#271)
`magpie models --agent` and `magpie visible <agent>` turned the typed name
into an agent through usage's AgentOf, which knows the built-in agents
only, so a WSL agent's id (claude@wsl:Ubuntu) was "no agent". Both now
use agent.Find, as every other agent command does, and visible keeps its
key lowered, as VisibleTo looks it up.

Landed from #271 (AnxForever), merged onto main by hand. The test moved
from the repo root into internal/cli, where the code it tests lives, with
one more case added: TestWSLAgentByIDInModelsAndVisible.

Run (merged onto 5b14ebf49): gofmt clean; go vet darwin, GOOS=linux -tags
nogui, GOOS=windows ok; go test -tags nogui ./... ok (agent, gateway,
plugin and provider passed on a rerun with -timeout 45m, after timing out
at 10m under load average ~30). Break-check: with providers_cli.go and
visible_cli.go put back to main's, TestWSLAgentByIDInModelsAndVisible
fails. Not run: a real WSL distro.
2026-10-13 09:56:06 +08:00
wei 920d96af55 tests: provider, plugin, gateway, codexcat, gui and tui tests pass in any order and on any -count (#1146)
Squashed from wei's #1146, onto main. Each test now starts from state of
its own instead of what an earlier test (or an earlier -count run) left:

- plugin: changed() counts the OnChange hooks still running; Told waits
  for them, and Settle ends with Told and UseCached(nil), so a change one
  test made isn't told in the next and the next test's plugin list isn't
  read as changed. Only tests call Settle/Told; in production changed()
  only counts. New TestSettleWaitsForTheHooksItTold and
  TestSettleForgetsTheFoldersPlugins.
- provider: isolate forgets Copilot's state, the plans' quota cards and
  balances; the warm-up, Cursor sign-in, hold and moved-plugin tests wait
  for what they started.
- gateway: fresh() forgets refused seals, and TestRouting,
  TestSmartRouting and TestQuotaRestsUntilItsReset start from
  forgetRouting; codexSignedIn and TestForeignReasoningIsLeftOut start
  from fresh.
- codexcat: XDG_CONFIG_HOME under the test's home. tui: costAt reset.
  gui: the fake Cursor account no longer outlives its test. cli: Settle.

Left out as already on main: the cli_identity keepIdentities switch
(9c3772311 keeps the asks in a sandbox via testenv's marker) and the
omarchy reset (main's TestCurrent already resets cached/seen/asked).

Run (darwin, loaded machine):
- On main 043e0cfc7, -count=3: TestRouting, TestSmartRouting,
  TestQuotaRestsUntilItsReset, TestForeignReasoningIsLeftOut,
  TestStandaloneNativeFallback fail; codexcat and tui fail; provider
  -shuffle=1791359851244745000 fails TestCopilotAuto and
  TestCopilotSignAndModels, and -count=2 -shuffle=1791856220860256000
  -run 'Copilot|TestPlanQuotas|TestCachedCardsAskNobody' fails
  TestPlanQuotas and TestCachedCardsAskNobody. With this change, that
  provider run (-shuffle=on, -count=2), the same gateway tests,
  ./internal/codexcat, ./internal/tui and the Settle/Hold/warm-up tests
  in plugin and provider pass -count=3.
- Breaking Settle by hand: without Told(),
  TestSettleWaitsForTheHooksItTold fails; without UseCached(nil),
  TestSettleForgetsTheFoldersPlugins fails.
- gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows.
Not run: the whole ./... suite at once (the machine's load times it out)
and Windows/Linux test runs.
2026-10-13 09:52:14 +08:00
wei 4419ebf7d6 cli, agent: magpie <agent> <field> shows that field and a field's name or DEFAULT is no longer written as the agent's model (#1129, waitingsnow)
What: `magpie codex model` wrote model = "model" into config.toml (and
applied.json, stash.json); any agent's field name given alone, or as a
value, was set as its model, and `magpie codex DEFAULT` wrote
model = "DEFAULT". Now:
- `magpie <agent> <field>` (any case) prints that one field and writes
  nothing;
- a field's name given as a value is refused with a hint
  (`magpie claude effort Ultracode`);
- DEFAULT in any case takes magpie out, as `default` does;
- Claude Code's tier names (opus/sonnet/haiku/fable) still set the model,
  since agent.ModelAliases marks them, and the agent's help says so.
agent.Field matches key and label in any case; agent.Running is a var
so the cli tests can say Codex isn't open.

Why: ported from waitingsnow's #1129 (commits bbe75c91f, 00bb38581,
244b24a67) onto internal/cli, where the CLI moved after the PR was
opened. The PR's --help part landed earlier as 76db4c6c2 (#1457).

Run: the five new internal/cli tests fail on origin/main without the
cli change (TestAgentFieldNameShowsIt: "✓ Codex model model" and
model = "model" written; TestAgentDefaultInAnyCase: "✓ Codex model
DEFAULT"; the tier-name help line and the Ultracode hint missing) and
pass with it. gofmt -l clean; go vet darwin, GOOS=linux -tags nogui,
GOOS=windows clean; go build for all three; go test -tags nogui ./...
green (an earlier run's internal/agent 10m timeout was a stuck open()
in TestWSLStoppedDistro under a 100%-full disk and load ~44; the WSL
tests pass alone and the full rerun passed).
2026-10-13 09:47:25 +08:00
yetone 23c6e865a7 plugin: a musl Linux (Alpine) runs plugins on Bun's musl build, kept apart from the glibc one (#1877)
emptyteeth found it: bunTarget picked Bun's build from GOOS/GOARCH alone,
so Alpine got bun-linux-x64-baseline, a glibc build whose interpreter
(/lib64/ld-linux-x86-64.so.2) Alpine lacks. exec then said "fork/exec
…/bun/1.4.2/magpie-bun: no such file or directory", which reads as a
missing file, and no plugin could be added or run.

- bunTarget: a musl Linux gets bun-linux-x64-musl-baseline or
  bun-linux-aarch64-musl. The musl check moves out of internal/claudecode
  into internal/libc (libc.Musl, unchanged rule: Anthropic's installer's
  /lib/libc.musl-*.so.1), which claudecode, the plugin host and the CLI
  test that skipped on musl now share.
- bunSums: the two musl builds' checksums, checked against Bun v1.4.2's
  own SHASUMS256.txt (downloaded from the GitHub release; they match the
  issue's numbers).
- Cache: a musl Linux keeps its Buns and state.json under bun/musl, so a
  machine whose C library changed never runs the other build, nor takes
  its state, whose Bad may list versions only the glibc build failed
  (CheckBun on Alpine set aside every newer Bun). glibc, macOS and Windows
  stay in bun/<v>, so a Bun downloaded before is used as it is, with no
  new download.
- A bun on disk that exec can't start with ENOENT says it is a build for
  another C library and names MAGPIE_BUN (cantStart), for the host's start
  and for bun add/bun update. The same for a $MAGPIE_BUN.
- Bun's musl build needs libstdc++ and libgcc, which a bare Alpine lacks:
  the loader then prints "Error loading shared library libstdc++.so.6"
  above ~40 "Error relocating" lines, and bun add cut it off. bun add,
  bun update and a host that died starting now say which library is
  missing and `apk add libstdc++ libgcc` (missingLibs, whyDied).

Decided: a Bun that can't be started at all is not counted as crashed.
The fallback goes to the version before, which is the same build for
this system and fails the same way, and setting the current one aside
would mark a good version bad for good. The libc check happens before the
download instead (the target), so Alpine never fetches the glibc build.

Run:
- docker alpine:3.20 (arm64, and amd64 under emulation), sandbox HOME in
  the container, linux nogui builds. origin/main's binary reproduces the
  report: "bun add …: fork/exec /sbx/.cache/magpie/bun/1.4.2/magpie-bun:
  no such file or directory". This one on bare Alpine downloads
  bun/musl/1.4.2 and says "this system lacks libstdc++.so.6 … apk add
  libstdc++ libgcc"; after apk add, `magpie plugin add
  @magpie-community/opencode-cursor-auth` adds it and `plugin list` starts
  the host and lists cursor (arm64 and amd64), with the old glibc
  bun/1.4.2 left beside it unused. With libstdc++ removed again, plugin
  list says the library; MAGPIE_BUN pointed at the glibc build gives the
  C library message.
- New tests (bunmusl_test.go, libc_test.go), each broken by hand and seen
  red: no musl branch (TestBunTargetForMusl, TestMuslBunKeptApartFromGlibc),
  no bun/musl root (TestMuslBunKeptApartFromGlibc), cantStart returning
  the error as is (TestCantStartSaysCLibrary,
  TestHostOnUnstartableBunSaysCLibrary, which fails with the reporter's
  exact message), host.go without it, no musl sum (TestBunDefaultSums),
  no hint in bun add (TestMissingLibsNamesThem) or in the host's start
  (TestHostOnBunLackingLibsSaysWhich), muslAt always false (TestMuslAt).
  -race -count=20 on them: green.
- gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows;
  go build for darwin, linux nogui, windows; go test -tags nogui for
  internal/plugin, libc, claudecode, cli in a sandbox HOME, and
  go test -tags nogui ./... (all green). One earlier run of
  internal/plugin with the other three packages went red, and its output
  was lost to a tail; four reruns of it, alone and together, were green,
  and the new tests were green under -race -count=20, so which test it
  was isn't known.

Not tried: a glibc Linux end to end after the change (the unit test
covers that its Bun stays at bun/<v>); a musl Linux other than Alpine
(the detection is unchanged and looks for Alpine's libc.musl-*.so.1).
The old glibc bun/<v> on an Alpine machine stays on disk (~90 MB); it
isn't removed, as a volume shared with a glibc container could be using
it.
2026-10-13 07:25:22 +08:00
yetone 841af36bfc gateway: models the user disabled are refused on every route, and leave every list (#1867)
oxsean asked for one place to turn a model (claude-fable-5) off for good:
not reached by a direct request, an old session, a routing group member,
a fallback, a sub-agent, count_tokens or a decision model.

What changed:
- settings.DisabledModels: patterns, an exact id or a glob (* any run, /
  included; ? one), matched ignoring case against provider/model, the
  bare id and its last segment (provider/disabled.go). Empty by default,
  so nothing changes for anyone who doesn't set it.
- Lists: buildEntries (entriesOff) leaves a disabled model out of the
  catalog, so /v1/models, agents' model files and pickers, Codex's list
  and every group go without it; membersIn skips it as a member, Deciders
  as a decision model; codexModels drops Codex's own disabled slugs and
  codexListTag changes so Codex refetches.
- Requests (gateway/disabled.go): 403 "model <id> is disabled in magpie"
  in each API's error shape, at #882's choke points: serve (idOff),
  perKeyBarred (no candidate: group next member, provider Fallback),
  count_tokens and Gemini :countTokens, serveSystemOne,
  serveDecisionGroup and postDecide, draw/video/embeddings, and
  codexBackend for Codex's own bare models. A group with a member left
  goes on without it; one with none left is refused naming them. A bare
  id the catalog no longer has is refused as disabled, not 404. A Codex
  sub-agent pick onto a disabled model stays on its lead's model.
- An unreadable settings.json is never "none disabled": the list read
  last stays; with none read, every request is refused; nothing is
  written over the file.
- CLI: magpie model disable <model|glob>..., enable ..., disabled
  (list-disabled).
- GUI: Settings > Models > Disabled models: each pattern with the models
  it matches now and Enable; Disable... opens the model picker, which
  also takes a typed glob. Says only requests through magpie are covered.
  POST /api/settings/disabled-models; POST /api/settings keeps the list.
  Strings in zh, zh-TW, ja, de.
- docs/subsystems/gateway-routing.md: Disabled models section.

What was run (worktree at origin/main 091593f7d, private GOCACHE, temp HOME):
- gofmt -l clean; go vet on darwin (touched pkgs), GOOS=linux -tags nogui
  ./..., GOOS=windows ./... clean; go build ./...
- go test -count=1 ./internal/provider ./internal/gateway ./internal/cli
  ./internal/gui ./internal/settings: all ok (gui after adding the field to
  TestSettingsSaveKeepsWhatItDoesNotSend's fixture, which it asked for).
- node --test internal/gui/tests/disabled-models.test.cjs: 16/16 (chromium
  + webkit, en/zh/ja/de, 1100/420); neighbouring Settings > Models tests
  and i18n-keys: 131/131.
- Broken by hand, each turned TestDisabled* red: serve's idOff (404
  instead of 403), perKeyBarred's filter (fallback reached spare), the
  catalog filter (/v1/models and Codex list), countOff (count_tokens 200),
  postDecide's check (decision call went out).
- Not tried with a real vendor account or a real agent.

Ref #1867
2026-10-13 05:34:13 +08:00
yetone 8b9d63f58a usage: a cost total says how many calls it couldn't price, never reads them as free (#1856)
cnlove7777777-art's Kimi K3 Auto and GLM-5.3 Max calls had "no price",
and Usage's sum counted them as $0 with nothing beside it but a "+" and a
tooltip. Now every total that sums cost says the count:

- GUI: Overview's and Requests' heads read "≈$0.001+  2 calls unpriced";
  with nothing priced, the count alone (Requests showed nothing at all
  before). Overview's calls tile adds "2 unpriced". Sessions, which prices
  by model, says "1 model unpriced" in its head and cost tile. The count
  stays at every width: the narrow and .tight rules no longer hide it,
  and the head goes tight when the count would be cut, sum or not.
  "no price for these models" is no longer shown, its key removed.
- CLI `magpie usage`: "≈$0.001+ (2 calls unpriced)". TUI Usage page: the
  same after its cost.
- docs/reference.md: unpriced calls are left out, said beside the total;
  magpie doesn't guess a variant's price from a similar name.

No variant price is mapped: models.dev lists neither "Kimi K3 Auto" nor
"GLM-5.3 Max", Zhipu's "Max" is a Coding Plan tier, and -fast variants
are 1.5x their base, so a suffix strip would be a guess. The existing
per-model price override (provider editor, `magpie model price`) covers it.

Run: go test ./internal/cli ./internal/tui ./internal/gui (ok);
TestUsageSaysCallsUnpriced and TestUsagePageSaysCallsUnpriced fail with
the fix taken out. usage-unpriced-sum.test.cjs (new) passes in Chromium
and WebKit, en/zh/zh-TW/ja/de, 360-1240px, and fails 5 of 5 on
origin/main's assets. Related GUI files (every test naming usageCost,
unpriced, effective prices, usage-head or "{n} failed", plus i18n-keys,
gui-zh-tw/ja/de, number-units, text-size, usage-ledger, ledger-protocol,
usage-range, mobile-web, phone-web, view-no-sideways): 655 pass; the
WebKit text-size foot case and routing-sessions fail the same run alone
on origin/main 5c82e6880 (filed #1672, #1307). gofmt -l clean; go vet
darwin, GOOS=linux -tags nogui, GOOS=windows clean. Not tried in the
real app window.
2026-10-13 04:31:07 +08:00
yetone 248a68598c gateway, provider, gui, cli: a key+URL provider may be sent the agent's own User-Agent in place of magpie's (#1851)
Every forward went with User-Agent magpie/<version>. A coding plan that
serves only the agents it names (pi, OpenCode, Claude Code…) knows them by
their User-Agent, so it turned magpie away.

What changed
- provider: PassUserAgent (passUserAgent in providers.json), off by
  default. PassesUserAgent takes it only for a key+URL provider: never a
  signed-in account, a plugin's, or a vendor whose own client magpie goes
  as (OwnClient: OpenCode, Cline, Kilo, another magpie). A copy keeps it.
- gateway: userAgentFor in forwardOnce (chat, Anthropic, Responses,
  Gemini, count_tokens) sends the inbound User-Agent unchanged where the
  provider passes it on. It sends magpie's where it doesn't, where the
  agent sent none, and on magpie's own requests (magpiesOwn: magpie/…,
  magpie-router/vision/search, the image tool's "<client> magpie-image/1",
  which is built from MCP clientInfo, not a User-Agent). magpie never
  invents another client's. The claude-cli/Codex header copies, the
  OpenCode/Cline/Kilo overrides and account signing run after it as
  before, and the user's header.User-Agent is put on at signing, so it
  wins.
- gateway: embeddings, images and videos (retrieveFrom, sendWith,
  remoteVideoContent) now stamp the same for a key+URL provider through
  stampUA, from the caller's User-Agent kept on the request ctx
  (caller.ua, withCaller). Before, they went with Go's default
  (Go-http-client/1.1). Account and remote-magpie paths are untouched.
- cli: `magpie provider set <id> user-agent=agent|magpie`, refused for a
  signed-in account; `magpie provider <id>` shows it.
- gui: the provider editor's User-Agent row, "Send the agent's own
  User-Agent", with an explanation, for a provider with a key only (the
  JSON says ownClient for presets and providers); en/zh/zh-TW/ja/de.
  The TUI only adds presets, so it has no field for this.
- docs: reference.md (provider set) and subsystems/gateway-routing.md.

What was run
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test -count=1 ./internal/gateway ./internal/provider ./internal/cli
  ./internal/gui: all ok (sandbox HOME, private GOCACHE).
- TestUserAgentPassedOn covers 7 routes (messages, count_tokens, chat,
  responses, gemini, embeddings, images) x off / on / on with no UA / on
  with magpie-router/1 / on with the image tool's UA / the user's header
  with it on and off. TestUserAgentAccountUntouched: a Factory account
  with passUserAgent in providers.json is still asked as factory-cli/.
  Also TestUserAgentClaudeCodeAsBefore, TestUserAgentFor,
  TestPassesUserAgent, TestAddCopyPassUserAgent, TestProviderUserAgentPair.
- Broken by hand, each went red: forwardOnce back to magpie's UA (5
  routes red); stampUA removed from embeddings/draw (both red, seen as
  Go-http-client/1.1); PassesUserAgent ignoring accounts/OwnClient;
  magpiesOwn dropped (the internal UAs leaked on all 7 routes); the GUI
  row shown for OpenCode and Save not posting it.
- provider-user-agent.test.cjs: 60/60 in chromium and webkit, en, zh,
  zh-TW, ja, de, at 900 and 440 wide. The provider/editor/add/i18n GUI
  tests in chromium: 244/244.

Not run
- Not tried against a real coding plan that checks User-Agent, nor with a
  real agent through a live gateway. Videos have no test of their own
  (they go through sendWith, which the images test covers).
- The GUI suite was not run in full; the Windows box was not used.
2026-10-13 02:56:34 +08:00
yetone 10d60b1899 provider: a provider saved with Select none serves no models, unlisted or not (#1818)
Select none saved `models: []`, which omitempty wrote as no models key at
all, so the provider read back as "no picks" and served the first 24 of
the vendor's list on /v1/models, in auto groups and on the card, while
the editor said none would be served.

What changed:
- Provider.NoModels (json noModels) records the choice; ServesNone() is
  NoModels with no picks. A file with no models key still serves the
  vendor's list as before.
- Exposed() is empty for it, so the catalog, /v1/models and auto groups
  leave it out; resolveIn refuses an explicit pid/model to it; listedBy
  and Deciders skip it (a decide-only provider is still a decider).
- SetModels and normalize clear NoModels once there are picks.
- GUI: the editor sends noModels on Save, an edit that omits it keeps it,
  the card's exposed count is 0, the hint says nothing is served; with
  unlisted the dashed chips explain they are only for groups. Strings in
  en, zh, zh-TW, ja, de.
- CLI: `magpie provider models <id> none`.
- docs/subsystems/providers-accounts.md describes it.

Decision (owner delegated): Select none means none, whether or not
unlisted is on; unlisted keeps meaning "hide from the list, still
usable by groups that name it".

Run:
- go test ./internal/provider ./internal/gui ./internal/cli -count=1
  (green; second pass ran too) with private GOCACHE and sandbox HOME.
- Broke Exposed's ServesNone check: TestSelectNoneServesNone red
  ("exposed 24"); broke resolveIn's: red ("watched/m0 resolved"); broke
  the GUI keep line: TestProviderSaveSelectNone red ("exposed 24").
- GUI tests chromium + webkit, 5 languages: provider-none-picked 20/20,
  provider-draft-picks 10/10 (red with noneChosen broken), plus 12
  related model/group/editor tests green.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows clean for the
  three packages.

Not run: the gateway package; Codex native model narrowing is unchanged.
searcher-pick.test.cjs fails 3 webkit cases (hover timeout) identically
on the unmodified base 556c01c80, unrelated.
2026-10-12 23:45:06 +08:00
yetone 908c910931 gateway, gui: Stays: Strict keeps a conversation on the account or key that answered it, even past its cap, and passes its error on rather than moving it (#1797)
miniers asked that a conversation never move to another account: a
move changes the account a vendor sees mid-conversation and loses its
prompt cache. Session affinity keeps the account while it can answer,
then moves on.

The new affinity mode "strict" (Stays: Strict) does what session does
for a new conversation. Once one has an account, strictKeep asks that
account alone (its other models too) and no other account, key or
provider:
- one resting or spent is still asked, and its error (429, 402, 5xx)
  goes to the agent rather than to the next candidate;
- one over a user cap is asked past it (plan's capped candidates,
  capHeldOnly);
- one held for credits answers 429 naming Stays: Strict rather than
  moving;
- one removed, turned off, barred or not allowed for the key counts as
  gone, and the conversation is routed as usual.
A last try that fails verification is not rested for a strict
conversation that had nowhere else to go.

Set in the provider editor and the Routing page's pool row (GUI, all
five languages), `magpie groups ... stays=strict` (strict-session,
never-move), and the TUI ("stays strictly"). Documented in
gateway-routing.md, reference.md and the site's start pages (en, zh,
ja).

Run:
- go test -tags nogui ./internal/gateway (-timeout 30m under load ~150),
  ./internal/provider ./internal/tui ./internal/cli: ok. The three
  TestStrictAffinity* tests fail on the code before this commit (200
  where 429 was expected, acct-2 answering).
- GUI: stays-strict.test.cjs, chromium and webkit, 900 and 560px, en,
  zh, zh-TW, ja, de: 30 of 30. On the assets before this commit it
  fails 15 of 15 in chromium. routing-*.test.cjs pass but for
  routing-steady's webkit 1.69px shift, which fails on the old assets
  too: filed as #1804.
- gofmt -l, go vet (darwin, linux, windows), full go test ./... before
  the push.

Not tried: a real agent conversation held on a real rate-limited
account.

Known and left: planLevel doesn't merge a nested group's sub.held, as
before this commit.
2026-10-12 23:16:54 +08:00
yetone 712d3c20ae build: the Windows app's icon group is resource 3, the one Wails gives its window, so the taskbar shows the bird and not a blank page (#1777)
Wails v3 sets a Windows window's icon from the icon group with numeric
resource ID 3 (NewIconFromResource(GetModuleHandle(""), 3) in
webview_window_windows.go). build/windows/winres.json named the group
"APP", and go-winres makes a numeric ID only of a "#n" key, so the exe
had no group 3: the window got no icon, and the taskbar and Alt-Tab drew
Windows' blank page. The group is now "#3".

internal/cli/winres_test.go fails while the group isn't under "#3".

Run:
- go-winres v0.3.3 make as the Makefile's release-windows, an amd64 build
  of each on the Windows box (yeton@10.0.0.132): the new exe has group 3
  and LoadImage(3) succeeds; the old one has neither.
- TestWindowsIconIsResourceThree red on the old winres.json, green now.
- gofmt -l, go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., sandboxed go test ./... at the rebased head.
Not run: the taskbar of the running app seen with the eye; the release
build (signed) wasn't made.
2026-10-12 22:55:22 +08:00
yetone af7d97fa2f gateway: a Responses provider set codex=as-sent gets Codex's requests as Codex sent them, for a relay that checks they are Codex's own (#1758)
A relay that checks a request is Codex's own answered magpie 400
"Codex 客户端请求特征无效" (10014). magpie fits every Codex request
for a Responses backend that isn't OpenAI's: Responses Lite's
additional_tools item is lifted into tools (#350), the tool search
goes as a function, and OpenAI-only fields such as
stream_options.reasoning_summary_delivery are left out. The reporter
found that the relay takes the request when additional_tools is left
as an input item, and that the lifted shape is what it refuses.

The lifting stays the default, because backends that aren't OpenAI's
refuse additional_tools or silently drop it (#350). A provider can now
opt out: `magpie provider set <id> codex=as-sent` (`codexAsSent` in
providers.json; `codex=default` turns it back off). With it on, a
request from Codex (fromCodex: Codex's User-Agent or originator) goes
as Codex sent it, with only its model name swapped. Codex's own
headers go with it as before. A subscription account is never sent
this way, and the GUI's provider save keeps the setting.

What was run:
- TestCodexAsSent: by default the request is still fitted; with
  codexAsSent the upstream gets exactly what Codex sent, with model
  m1, X-Codex-Turn-Metadata and the Responses Lite header. It fails
  on the old gateway.go and passes now. TestAdditionalTools and the
  gateway's Codex tests pass.

Not verified: not tried against the reporter's relay. Their check
was made by hand outside magpie, so which other fields that relay
looks at is not known. There is no GUI control for the setting
(CLI or providers.json only).
2026-10-12 22:42:47 +08:00
yetone ff930886a2 gateway: keys all out of their allowance are answered from their rests with a Retry-After, not asked again on every request, and a key listed twice is asked once (#1772)
A fleet on four Ollama Cloud keys, every one out of its weekly allowance:
each new request asked every key again (the first twice) and answered
429 with no Retry-After, so an agent that waits as told asked again at
once, and the vendor saw four refused requests a turn.

What changed:
- The first key twice: the reporter's providers.json named the first key
  in "keys" as well as "key". KeysOn now lists a key once.
- When every key left for a request rests out of its allowance (a 429 or
  402 that failure() calls quota or credit, keys only), the request is
  answered from the rest without asking: the vendor's own words, "not
  asked again before HH:MM", and Retry-After until the first of them is
  back (quotaHeld, soonestBack). Accounts are left out, so autoReset
  can still spend a reset for them; a 403 or 400 worded as quota is
  asked as before.
- The last key out of its allowance now rests as the ones before it do
  (before, the last one left was never rested), and a 429 the vendor gave
  no Retry-After for gets the soonest rest's end as one.
- A provider can set how long its keys rest when the vendor says nothing
  of when the allowance is back: quotaRest (minutes) in providers.json,
  or `magpie provider quota-rest <id> 7d`; default stays 15 minutes, at
  most 8 days. A time the vendor names (resets_at, Retry-After, a
  window) still wins. A GUI save keeps it.

What was run:
- TestAllRestingAnswersFromRest, TestFirstKeyListedTwiceAskedOnce and
  TestOwnQuotaRest fail on the old code (no Retry-After, keys re-asked;
  "dead-1 dead-1 dead-2 ok-3", the reporter's log); they pass now, with
  TestQuotaHeldOnlyForKeysOutOfAllowance, TestDeadChainWalksEachOnce and
  TestRestMinutes. The mock answers with the reporter's literal 429 body.
- go test -tags nogui ./internal/provider ./internal/gui pass. A gateway
  package run at load ~60 hit its 20m timeout mid-suite with only
  TestMaxRPM* red; those pass 8/8 alone here and on origin/main
  17c12621b (timing under load, filed as #1791).

Not verified: no run against real Ollama Cloud keys; quotaRest has no
field in the provider editor (CLI and providers.json only).
2026-10-12 22:42:46 +08:00
yetone 94aa153973 tui, provider, serve: a signed-in account's models are fetched at start, so Routing offers Cursor's whole list without m (#1789, reyoung)
The terminal and `magpie serve` never called provider.FetchNew, which the
window calls at start: a signed-in Cursor account's list exists only at
Cursor, so the TUI's Routing pickers (and a headless gateway's /v1/models)
offered the fallback cursor/auto alone until the list was fetched by hand
with m on the Providers page.

- tui: Init fetches the new lists (fetchModelsCmd, alongside the catalog
  sync). A model picker open when they arrive (Routing members, the
  classifier, a provider's models, an agent's model field) is filled in
  place through its relist, keeping its filter and the model under the
  cursor. A list left missing (no network) is asked for again a minute
  later (modelsRetry). Built on reyoung's branch and test.
- serve: FetchNew at start, again each minute while a list is missing.
- provider: FetchNew reports whether a list is missing, and waits for a
  CLI asked who is signed in for the first time (awaitIdentities), then
  lists the accounts again. With the real Cursor account in a fresh
  sandbox, `cursor-agent about` answered after a look's 3s firstAsk, so
  FetchNew saw no Cursor account and `magpie serve` still listed 1 model
  with the TUI fix alone. The window's startBackend gets the same wait.
- docs: providers-accounts.md says who fetches the lists and when.

Run:
- internal/tui TestTUIFetchesSubscriptionModels (6 views) and
  TestTUIAsksAgainForAMissingList, -race x3; red with the Init fetch,
  the relist, the cursor restore or the retry tick each removed by hand.
  A first `about` slowed to 12s injected: passes (the test re-asks).
- internal/provider TestFetchNewWaitsForASlowSignIn: red without
  awaitIdentities (no provider "cursor"); TestFetchNewAccount covers the
  missing result.
- Real Cursor account, sandbox HOME with a keychain holding only Cursor's
  two items: TUI on main showed cursor/auto only in Routing; the fix shows
  the full list and "24 models" on Providers. `magpie serve`: main 1
  Cursor model at /v1/models, the fix 24 within 5s.
- gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows), go test ./... in a
  sandbox HOME.

Not tried: Linux and Windows real Cursor CLIs (the fake CLI tests skip on
Windows); Devin's CLI identity goes through the same wait but wasn't
tried with a real account.
2026-10-12 20:49:41 +08:00
yetone 23e764d0e0 cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are
to internal/cli (package cli), with git mv so history follows them. The
only code change is main() becoming cli.Main(version): the root's new
main.go keeps `var version` in package main, so -ldflags "-X
main.version=…" in the Makefile, the Dockerfile and magpie-releases, and
every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land
next to package main in the root.

Tests that read testdata by a root-relative path now go up one level
(../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links
point at internal/cli/.

Run:
- go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui)
- builds with tags production, dev, "production nogui"; windows
  -H windowsgui; linux CGO_ENABLED=0
- make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64
  android/arm64" VERSION=9.9.9-tidy: all four built, binary prints
  "magpie 9.9.9-tidy"
- docker build --build-arg VERSION=7.7.7-tidy: container prints
  "magpie 7.7.7-tidy"
- go test ./internal/cli (default and nogui): 152 tests, the same count
  as the root on main
- go test ./...: all packages pass (agent, gateway, library, provider
  timed out at 10m under other sessions' load and passed rerun alone
  with -timeout 40m; none of them changed)
- the built binary in a sandbox HOME: version, help, ls, providers,
  claude, and an unknown command's error
2026-10-12 20:40:22 +08:00