Commit Graph
374 Commits
Author SHA1 Message Date
yetone 727e236378 gateway: a management API for providers, accounts and gateway keys, for a key set to manage (ljayic on X)
ljayic asked for a complete, stable management API so nothing needs a
hand-edited file. /v1/magpie/admin/ now serves the app's own /api handlers
(providers and their keys and accounts, OAuth sign-in start/poll/cancel,
gateway keys, account groups) to a gateway key set with
`magpie gateway-key admin <id> local|any`. Routes and actions not in
gui/admin.go's adminRoutes are 404, so a provider's saved key, a gateway
key's secret, sign-in export and actions on this computer's apps are not
served; "admin-key" is not served either, so the API can't raise its own
caller. Sign-in returns the vendor's page and code, opens nothing, takes no
password.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Not tried: fish (on none of the machines); a real agy run with the
plugin at 0.2.0 (the 0.1.0 design ran for real in a sandbox HOME, the
settings.json one this replaces); Windows and WSL agy with the plugin;
an install from npm: @magpie-community/agent-agy isn't on npm yet, so
until its first publish no user is moved.
2026-11-11 16:13:19 +08:00
yetone 5399c33728 healthcheck, update and status find the running gateway by its own record (ljlwlcz on X)
The gateway now writes gateway.json (addr, pid, role, version) in magpie's
config folder while it serves; healthcheck, update, status and the other
CLI clients read it when MAGPIE_ADDR is unset, trusting it only if the pid
on GET / matches. --addr overrides. New: magpie status [--json] for
watchdogs (role, pid, listen address).

Run: new gateway and cli tests on Windows via win-run (pass); broken by
hand (record disabled): they go red; gofmt; vet windows and linux nogui.
Not run: mote/Linux (SSH down, WSL broken), darwin vet, a real systemd
service. TestEveryRouteHasACommandOrIsNamed is red on the base for two
GUI routes, unrelated to this change.
2026-11-11 12:00:19 +08:00
yetone 89f66966d9 release builds: the UI's files are packed into one zip, ~5.7 MB off each binary (@ZhangXiaof48473 on X)
The Windows and Linux downloads (and the CLI builds) are the raw binary, so
what is embedded counts in full. 8.2 MB of the 12 MB under internal/gui/assets
is scripts, styles and svgs. `make assets-pack` (build/assetpack) writes them
to internal/gui/assets.zip (deflate; png/jpg/webm stored), and the release
targets and `make app` build with -tags packedassets, which embeds that zip
instead of the tree (assets_packed.go: a file is unpacked once, on first use,
and served seekable with no modification time, as an embedded one is). Plain
`go build`, `make build`, `make cli` and every test still embed the tree.
The zip is git-ignored and made before every release build.

Sizes (go build -trimpath -ldflags="-s -w", on mote, at e430e2750):
  linux/amd64 nogui   73,203,874 -> 67,502,242  (-5,701,632)
  windows/amd64 app   88,401,408 -> 82,755,584  (-5,645,824)
The macOS zip/dmg compress the binary already, so they gain nothing.

Run: assetpack, then `go test -tags packedassets -run TestPacked ./internal/gui`
(passes: every file byte for byte and no other; / and a range of the webm served;
no Last-Modified). The first try failed it with "packed has 0 files, the tree
301" (zip entries lacked the assets/ prefix), so it does go red on a bad pack.
go vet ./internal/gui on darwin, linux nogui, windows and -tags packedassets:
clean. gofmt clean.

Not run: the full suite and the GUI suite (default builds embed the tree as
before; api.go only lost the embed line), a real release through
magpie-releases (its release.yml calls these make targets), the Linux GTK
build (cgo).
2026-11-11 10:28:05 +08:00
yetone 90a028d2c1 air: JetBrains IDEs get a Magpie agent for each running WSL distro (yanghonghang on X)
IDEA 2026.3 starts a WSL project's ACP agent inside the distro through EEL.
An absolute Windows command whose environment differs from the project's is
refused ("ACP executable belongs to a different environment"), which the AI
Assistant shows as "Magpie does not run". The host entry in ~/.jetbrains/acp.json
therefore never worked for a WSL project.

Now each running distro that has opencode gets its own "Magpie (WSL <distro>)"
entry: command is the distro's opencode as a \\wsl.localhost UNC path (the
WSL descriptor, accepted), env OPENCODE_CONFIG points at a magpie-opencode.json
written in the distro's ~/.jetbrains. Set, Sync, Check and the uninstall path
all reach the entries; a stopped distro is never started. The probe now
records the binary paths (distro.Paths).

Ran: mote-run go test -run 'TestAir|TestWSLProbeKeepsPaths' ./internal/agent
(ok), the same on win-run and wsl-run (ok), gofmt, GOOS darwin/linux/windows
go vet ./internal/agent. Broke by hand: turning the WSL branch off in airAt
turns TestAirIDEAddsMagpieAgentForWSLProjects red.
Not tried: a real JetBrains IDE (none on the Windows box); the EEL rule was
read from the IDE's bytecode.
2026-11-11 10:27:44 +08:00
yetoneandRainier 5c05ac41b9 web: a LazyCat sign-in takes no peer on a public address; the manifest lists /magpie-ca.crt (forgetable024 on X, #5987)
Follows Rainier's two commits (cherry-picked with authorship, #5987).

What LazyCat's own docs say (developer.lazycat.cloud/en/http-request-headers.html,
read today): lzc-ingress authenticates a request, and after a success sets
X-HC-User-ID, -User-Role (NORMAL or ADMIN), -Device-*, -Login-Time; "if
authentication fails, it will clear the above X-HC-XX headers", and "lzcapp
developers ... can directly trust X-HC-User-ID". X-HC-User-Groups is said to
have the caller's own removed. X-HC-Source is in no page of the docs; the
sign-in's use of it only narrows who gets in. The docs name no address for
the ingress, so the peer can't be named; a TCP ingress or port forward passes
headers as sent (the docs for it say no authentication), which the manifest
section already says to keep off the page's port.

This commit: lazyCatSignIn turns away a peer that isn't on a private,
loopback or link-local address (or isn't an address), whatever headers it
sends. The client-routes list gains /magpie-ca.crt, which main added after
the branch's base (TestLazyCatManifestListsTheClientRoutes was red on it).
TestTranslatedRoutesDropProxyIdentity adds the chat and messages routes to
the vendor-leak tests (native, Codex relay and MCP were covered).

Run (mote, go1.26.8): gofmt clean; go vet on gui, gateway and cli for darwin,
linux nogui and windows; LazyCat, ProxyIdentity, OnePort and Web tests in
internal/gui and internal/gateway ok.
Broken by hand: with the peer check off, TestLazyCatSignInIgnoresAPublicPeer
is red; with X-Hc- out of proxyIdentity, TestNativeAnyDropsProxyIdentity and
TestPassthroughDropsProxyIdentity are red.
Not tried: a real LazyCat box (none here); the plugin fetch route builds its
headers from the request magpie made, read, not run. Full suite and GUI
tests follow the tag.

Co-Authored-By: Rainier <74943233+Rmosser@users.noreply.github.com>
2026-11-11 10:15:40 +08:00
RainierandClaude Opus 5.5 4d9b798d50 web: a LazyCat box's administrators open the page with the box's sign-in (MAGPIE_WEB_SIGN_IN=lazycat) (#5987)
magpie in a LazyCat app (懒猫微服) is opened from the box's app list by
someone signed in to the box already, and asks for a key they never
saw: it is in the container's log. A package can only hand the key to
every browser that reaches the app, or put a proxy in front that adds
the key's cookie to what the box signed in.

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 10:15:40 +08:00
yetone 13a9f1263a plugins: Discover counts who uses and likes each plugin
Discover showed npm's weekly downloads, which CI, mirrors and magpie's
own keepMovedCurrent updates inflate. Now each card and the hero say
how many people use a plugin, counted by magpie itself, and a plugin's
page has a like.

- The daily stats send (stats.Send) also POSTs usemagpie.ai
  /api/plugins/report with the install id and the installed, switched-on
  plugins Discover lists, by their Discover key: the npm name, or
  github:owner/repo for a repository tagged magpie-plugin
  (plugin.Public). A folder, a private repository or an unlisted
  package is never named. It goes only while "Share the agents,
  providers, models and plugins I use" is on (noUsageStats), and only
  where the day's event goes at all (Count me as a user, DO_NOT_TRACK,
  MAGPIE_NO_STATS, release builds).
- site/pluginstats.js on D1 magpie-plugins: users are the ids that
  reported a plugin in the last 7 days, reports drop after 30 days, a
  caller's address is kept only as a hash for an hour (60 asks an
  hour). /api/plugins/stats carries no id and is cached for an hour.
- A like (POST /api/plugins/like through the GUI's /api/plugins/like)
  is taken only for a plugin installed and on here, can be taken back,
  and is kept in plugin-likes.json.
- "Most liked" sorts by likes once a plugin has 20, below that by
  GitHub's stars.
- plugincounts.js is loaded with the Plugins page, not the core, and
  redraws the cards only when the counts changed.
- The privacy text follows: README.md, README.zh-CN.md, docs/reference.md,
  the site's privacy and start pages in en, zh and ja, llms-full.txt,
  and the Privacy switch's label and description in every language.

Run at this tree (on origin/main 51da6f1f5):
- Windows box (win-run): gofmt -l clean; go vet of internal/stats,
  internal/plugin, internal/gui ok for windows and linux (-tags nogui);
  node --test site/pluginstats.test.mjs site/worker.test.mjs 44 of 44;
  TestCoreScriptBudget, TestPluginCountsAndLikes ok; GUI old-webkit,
  i18n-keys, privacy-usage-stats, plugin-git, plugin-local,
  plugin-github in both engines: 45 of 46, the one red is #5919
  (.side-foot:has, d374168d0).
- mote, one commit before the rebase onto 51da6f1f5 (Go unchanged
  since): go vet darwin ok; TestSendPlugins, TestPublicPlugins,
  TestPluginCountsAndLikes, TestCoreScriptBudget ok.
- Windows, at 7bc7af1d0 (one rebase earlier): go test internal/stats
  ok; internal/plugin and internal/gui red only in TestPiPackage and
  eight gui tests that fail the same at origin/main 72f2deebe on that
  box (#4115, #5928; TestCherryStudioImportRow added to #4115 with its
  cause). Every plugin*, market*, privacy*, i18n*, old-webkit* and
  discover* GUI file (83 files, both engines, concurrency 4): the reds
  left after the fix below match origin/main 6d7862769 on the same box,
  or are flakes red there too under concurrency: plugin-update-button
  (#4500), plugin-proxy-page (#6017, new), privacy-agent-telemetry
  (#6018, new).
- Broken by hand, caught: the first run had `const like = !local && …`,
  so a local plugin's page called false?.sync() every 600ms; 136
  "like?.sync is not a function" errors across plugin-git, plugin-local,
  plugin-github and the sign-in files. Fixed before this commit.
- Live: D1 magpie-plugins created and the worker deployed;
  /api/plugins/stats answers {"plugins":{}}, a bad report or like 400,
  /api/latest and / 200. No test data was written to production.

Not tried: the full Go suite and the full GUI suite. mote had 28 suites
waiting for its lock, and WSL on the Windows box failed with
E_UNEXPECTED while another session uninstalled a distro. Not tried
either: a real like or report from a release build (source builds
never send), so the first real counts come with this release.
2026-11-11 04:28:18 +08:00
yetone 4623f54190 gateway: HTTPS for other computers, from magpie's CA or an imported certificate (zhangly1 on X)
zhangly1 on X: Claude on another computer on the LAN needed magpie at
https://. Settings → Network and sharing → HTTPS (magpie https on)
serves other computers TLS on the gateway's own port, with a
certificate magpie's CA (the mTLS one, in ~/.config/magpie/mtls) signs
for this computer's names and addresses; this computer keeps plain
http://. The switch is read per connection, so no restart.

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

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

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

Not tried: the macOS, Windows and Linux system trust commands on a real
store (they change the box's trust); Claude Desktop itself; a darwin
GUI run (mote unreachable); the full suite before the tag (started
after it).
2026-11-10 23:05:47 +08:00
yetone 065ca02c28 provider: Fireworks Nexus preset, Nexus Auto on all three APIs (CNSA0422 on X)
Fireworks Nexus is an account and plan of its own (nexus.fireworks.ai,
Pro $8, Team, Enterprise) on the platform's /inference endpoints, which
speak chat completions, Responses and Anthropic messages
(docs.fireworks.ai/nexus/apis-and-sdks). Its keys are made at
nexus.fireworks.ai/settings/api-keys; a platform key carries no Nexus
plan.

The new preset fireworks-nexus (Add sheet tile "Nexus", the Fireworks
logo) sets all three endpoints and lists only `auto`: Pro and Team
refuse an open model named directly with a 403 (nexus/open-models), so
the platform's /models would offer models the plan refuses, and no list
is asked for. Enterprise users type their open models in, or set a
models URL. The editor offers x-anthropic-api-key and x-openai-api-key,
the headers Nexus Auto takes the user's own Claude and OpenAI keys in.
No usage API is documented (only the nexus.fireworks.ai/usage
dashboard), so there is no usage card. READMEs (en, zh) and
docs/reference.md list it.

Run (mote): go test -run 'TestFireworksNexus|Preset' ./internal/provider
ok at the pushed head; go test -count=1 -timeout 45m ./internal/provider
./internal/gui ./internal/catalog at the pre-rebase base: provider and
catalog ok, gui red only in the real-window AppKit tests killed at their
deadline under mote's load (TestCoveredWindowStaysUp,
TestClosingWindowMarksPageOutOfSight,
TestPanelHiddenByWailsMarksPageOutOfSight; #2645, #4924, #4125).
gofmt clean; go vet darwin, linux (nogui) and windows of internal/provider.
Broken by hand: without NoList TestFireworksNexusPreset goes red, the
fake platform list's accounts/fireworks/models/glm-5p3 listed and its
/models asked.
Not tried: a real Nexus key (none here), so neither `auto` on each API,
the header passthrough, nor what /models answers for a Nexus key; the
`auto` context window is left to the catalog (Nexus CLI writes 1M/131K).
GUI suite not run: presets reach the Add sheet as data and no GUI file
names a preset list.
2026-11-10 22:26:38 +08:00
yetone 0baa223ec9 agent: Kun, magpie as a provider connection through its runtime API (zhongxingyuyes on X)
Kun (KunAgent 0.4.5, Electron, com.xingyuzhong.deepseekgui) keeps its
model providers in ~/.kun/data/model-connections.v2.json (or
$KUN_DATA_DIR) and changes them only through its runtime's admin API,
whose address and token are in runtime.json. magpie wires Kun by
calling that API while Kun runs:

  POST   /v1/model-connections/connect    the magpie connection
  PATCH  /v1/model-connections/:id        models, gateway address
  POST   /v1/model-connections/select     the default model
  DELETE /v1/model-connections/:id        off
  POST   /v1/provider-config/transactions/preview, then commit
         off when magpie's connection is the default: Kun refuses a
         plain DELETE of the connection its default names, so the
         transaction clears the default and removes it in one step,
         and the default the user had before is put back.

When Kun isn't running, wiring says "open Kun, then try again"; the
file is never written behind Kun's back. Kun joins the agent list,
desktop-app detection, the env guard, the icon set (kun.png), the
READMEs and docs/reference.md and docs/subsystems/agent-wiring.md.

Run:
- WSL (Ubuntu 24.04), at the rebased head: go test -tags nogui
  -run 'Kun|ListsModels|Picker|Spelled|HandWired|Sync|Drift|ListOnly|
  Moved|LAN|Proxy' ./internal/agent ./internal/agentenv ok;
  ./internal/library ok; ./internal/gui -run 'Icon|Budget|CSS|I18n|
  Picker' ok (agentenv: no tests match the filter).
- Windows (win-run): go test -run 'Kun|ListsModels|Picker|Spelled|
  HandWired|Drift|ListOnly' ./internal/agent ok. CGO_ENABLED=0 go vet
  for windows (agent, gui, agentenv), darwin nogui (agent, agentenv)
  and linux nogui (agent, agentenv, gui): clean. gofmt -l clean.
- GUI (WSL, chromium + webkit): i18n-keys, i18n-en-no-cjk,
  icon-one-tone, routing-client-icons, icon-tile together 63/63 at
  this head. An earlier run at the pre-rebase head was 60/63, the 3
  reds icon-one-tone's "Open Design one-tone ... Plugins page"
  (chromium), which passed 48/48 alone there and at origin/main: a
  load red (#5425).
- Real Kun 0.4.5 (Linux build, sandbox HOME, `kun serve`): connect,
  a second model, Sync, restart, off. `kun run`
  finished a turn through the gateway (POST /v1/chat/completions,
  Bearer magpie-kun, reply "hello from magpie"). Off restored the
  previous default, and with no previous default Kun was left with
  none and no magpie connection.

Broken by hand: off through the plain DELETE again. The fake Kun now
refuses it as the real one does, and TestKunFromNothing and
TestKunFollowsTheGateway went red with "Deleted connection still has
references: default.providerId"; green with the transaction.

Not tried: Kun's desktop window itself (the runtime was driven
headless); macOS (mote refused SSH all session); `kun run --model`
(run uses its own default model, not the registry's default, so a
CLI run picks magpie's model only with --model).
2026-11-10 22:07:34 +08:00
yetone 6a450c4982 agent: Shelley, magpie's models as its custom models (on X, tweet 2120109384315658393)
"Can support Shelley?" Shelley is boldsoftware/shelley (Apache-2.0, Go,
`shelley serve`). It keeps models and profiles in its SQLite database,
not in a config file, so magpie talks to a running Shelley through the
same API its own Models and Profiles pages use, on the Unix socket it
opens for its CLI ($SHELLEY_SOCKET, else shelley.sock / shelley-N.sock in
$XDG_CONFIG_HOME/shelley or ~/.config/shelley; read from its source).

- Connect: each magpie model is a custom model (POST /api/custom-models,
  provider_type openai, endpoint = the gateway's /v1, Shelley's own
  gateway key, model_name = the catalog id, reasoning/images/max_tokens
  from the catalog). Picking one makes it the default profile's model
  (PUT /api/profiles/{name} with the whole profile, as the API requires)
  and clears a thinking level the model can't take.
- The user's own values: the profile's model and thinking level are
  stashed once and put back on Disconnect (to the server's default if
  that model is gone); only the custom models magpie made (ids stashed)
  are deleted, so a model the user pointed at the gateway by hand stays.
- Sync re-points magpie's models when the gateway port moves; Check names
  a model left on an old address. Shelley not running is an error on a
  pick and nothing on Sync/Check; turned off while Shelley is uninstalled,
  the takeout is stashed and done when Shelley answers again (Alma's way).
- A notice: new conversations start on the pick, an open one keeps its
  model. i18n for zh, zh-TW, ja, de.
- Icon: Shelley's own S mark from its assets, one tone. README (en, zh),
  site index, docs/reference.md, docs/integrating.md, site integrate
  pages (en, zh), docs/subsystems/agent-wiring.md.
- Library: listed as "not looked at (#5897)" like the other new agents.
- Shelley has no Windows build, so there is no Windows or WSL wiring.

Run (mote refused SSH for the whole session, kex reset, so runs went to
the Linux VM and the Windows box):
- Real binary: shelley v0.1718.926152762 linux_amd64 (sha256 66cb5acb…
  checked) in a sandbox HOME/XDG_CONFIG_HOME/-db on the Linux VM, with a
  throwaway test driving it against a fake OpenAI upstream at
  MAGPIE_ADDR: connect made custom model glm-4-6-… and the default
  profile's model; POST /api/conversations/new sent two
  /v1/chat/completions with model=relay/glm-4.6, auth magpie-shelley,
  UA Shelley/58d5f200; disconnect left the profile as before and no
  custom models. Check "" and Drift nil while connected.
- Linux (wsl-run, nogui): go vet ./internal/agent ./internal/agentenv
  ./internal/library; go test ./internal/agent ./internal/agentenv
  ./internal/library ./internal/profile ./internal/sessions: ok except
  TestGrokInstalled (#3548, red on base too) and, before its fix here,
  TestEveryAgentInLibrary. internal/cli times out there in
  TestEveryAgentFieldNameWritesNothing (43m, the #5234 class).
- Windows (win-run): go vet ./internal/agent ./internal/agentenv;
  GOOS=darwin and GOOS=linux -tags nogui vet; the Shelley, applied,
  rewire, disconnect, mark and kept tests: red only in
  TestAppliedOfParsesAnUnchangedFileOnce (#5950),
  TestAsideOfflineDisconnectRestoresWithoutDaemon (#5951) and the #4786
  allocation tests, all red on base d4b4a188e too. internal/cli
  TestHelpOnEveryCommandDoesNothing, TestEveryAgentFieldNameWritesNothing
  and internal/library TestEvery*: ok.
- GUI (node --test, chromium + webkit) i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone, icon-tile,
  routing-client-icons, usage-agent-filter-icons, agent-connect,
  agent-models, agent-layout, on the Windows box at the rebased head:
  110 tests, 107 pass. Red: gui-ja "ja has every zh string" ({model}
  twice, #5943) and icon-one-tone webkit voyage-color (#5962), both red
  at origin/main a1ba92ad8 too.
- At the rebased head 2a9c7b715 (on origin/main a1ba92ad8), Linux:
  vet of agent, agentenv, library ok; go test agent, agentenv, library,
  profile ok except TestGrokInstalled (#3548). Pushed on ca7a39291,
  which changes only internal/gateway (MiniMax drawing); not rerun.
- gofmt -l clean.

Broken by hand: not restoring the profile's model on Disconnect turns
TestShelley and TestShelleyThinkingLevel red; not deleting magpie's
custom models turns TestShelley and TestShelleyKeepsHandWired red.

Not tried: a real model upstream (the upstream was a fake), macOS (mote
unreachable; the darwin build was vetted only), the GUI against a real
Shelley, Shelley's web UI after the switch.
2026-11-10 21:52:19 +08:00
yetone c2c2c82ca8 agent: Tuanjie Cowork, a magpie provider and model in its Custom Models (Charles24209792 on X)
Tuanjie Cowork (Unity China's coworker app, dev.codelycowork.desktop,
2.1.6-stable) keeps the user's own models in ~/.codely/settings.json:
customModelProviders {id, name, baseUrl, apiKey, authType} and
customModels {id, model, providerId, displayName, roles, wireApi,
supportsMultimodal}, read afresh on every lookup. Read from the app's own
core (tZ/oE for the file, Mwi for a session's OPENAI_BASE_URL/KEY, BOe
for the model list, rha/sha for its startup migrations).

magpie adds a provider and a model of its own, both id "magpie": the
gateway's /v1 with Cowork's own magpie key, the model picked, wireApi
chat. The user's providers and models and every other key stay as
written; a name or roles given magpie's entries in Cowork are kept when
the model changes. Off takes both out, and the file too when magpie made
it and nothing else is in it. A provider or model with id magpie that is
the user's own is left alone, with an error. Which model a chat is on is
Cowork's own per-workspace pick, which magpie doesn't write; a notice
says to pick "<model> (magpie)" in its model menu while it runs. Skills
go to the shared ~/.agents/skills, which its core scans. Icon from the
app's icon.icns. Lists, READMEs, reference, agent-wiring doc, i18n.

Run:
- go test ./internal/agent ./internal/library ./internal/gui on mote;
  TestTuanjieCowork* and TestHandWiredMagpieProviderSiblings on Windows
  (win-run).
- gofmt; go vet darwin, linux -tags nogui, windows.
- GUI, chromium and webkit: i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone,
  icon-tile, routing-client-icons, usage-agent-filter-icons,
  agent-connect, agent-models, agent-layout.
- Cowork's own code on magpie's output: its tZ, oE, rha, sha, cE, KGa,
  Mwi, kOe and BOe, extracted from the 2.1.6 core, run in node on the
  settings.json magpie wrote (with the user's own provider, and fresh).
  Its migrations leave magpie's entries; cE("magpie") finds the model,
  the picker label is "deepseek/pro (magpie)", a session gets
  OPENAI_BASE_URL http://127.0.0.1:3425/v1 and magpie's key, the list
  URL is /v1/models, and the user's glm-4.5 is still there.

Where: the packages, vets and GUI files above ran on mote at b834dc2a7
(this change on 4a9142ccd); at the pushed head (on 016763f23) internal/agent's
Cowork, HandWired, EveryAgent, Aliases and Icon tests, internal/library, and
the de, zh-TW and en-no-cjk i18n files ran on Windows. Reds not from this
change, both red on main already: gui-ja's {model} twice (#5943), and
TestEveryAgentInLibrary for obsidian and avibe (#5945).

Broken by hand, each red:
- rest() keeping magpie's entries: TestTuanjieCowork (two models) and
  TestTuanjieCoworkMadeFile (file left behind).
- no check for a provider id magpie of the user's own:
  TestTuanjieCoworkLeavesTheUsersMagpie/provider.
- unwire never removing a file magpie made: TestTuanjieCoworkMadeFile.

Not tried: the real app's GUI (picking magpie's model in its menu and a
chat through it), Windows detection (its NSIS per-user path isn't
known, so on Windows it shows once ~/.codely exists), Linux.
2026-11-10 20:50:10 +08:00
yetone 4a9142ccd4 agent: Obsidian, magpie's models in Copilot for Obsidian (shirotokiren on X)
shirotokiren asked for magpie to set up Obsidian's AI plugins, naming
Copilot and Smart Connections.

The new agent "obsidian" finds the vaults in Obsidian's obsidian.json:
~/Library/Application Support/obsidian on a Mac, %APPDATA%\obsidian on
Windows, and on Linux $XDG_CONFIG_HOME/obsidian or the Flatpak or Snap
folder. In each vault that has Copilot for Obsidian 4+
(.obsidian/plugins/copilot), magpie edits data.json in the shape
Copilot 4.0.19 reads:
- it adds providers.magpie, openai-compatible at /agent/obsidian/v1,
  with requiresApiKey false and no keychain id;
- it adds one configuredModels entry per magpie model, with a
  deterministic uuid v5 id, plus limits, image input and reasoning
  efforts;
- new models go into backends.chat.enabledModels;
- on the first wire it sets defaultModelKey, and stashes the old value.

A sync keeps the models the user turned off, their default, and the
name they gave the provider. It writes only the keys that change
(edit.PatchJSON, then temp and rename), and nothing when nothing
changed. A provider named magpie counts as magpie's only when its
baseUrl is magpie's Obsidian route. One the user added by hand under
that name is theirs: it doesn't read as connected, Disconnect leaves
it, and Connect says so and writes nothing. Disconnect takes magpie's entries out and puts the old default
back. Copilot 3, a data.json it can't parse, and no vault with Copilot
are each an error, and nothing is written. A notice asks the user to
reload Copilot, since Obsidian holds the settings in memory.

The gateway now answers CORS for app://obsidian.md keylessly
(appOrigin). Copilot streams through the window's fetch, and without
CORS headers it can read no reply. Only Obsidian's own window sends
that origin, so it gets no more than its calls without an Origin get.
From the network it still needs a key.

Smart Connections is not wired. Its free plugin embeds with a local
model only, and its API providers are in the closed Pro plugin, with
keys in the keychain.

Run (mote, at 401187300 + this commit, then again after rebasing on
9c39edb92):
- gofmt
- go vet for darwin, linux nogui and windows
- go test -run 'Obsidian|Notice|CORS|Craft' ./internal/agent ./internal/gateway
- GUI, chromium and webkit: i18n-keys, i18n-en-no-cjk, icon-one-tone
  (56 of 56)
At 9c39edb92 + this commit: the whole internal/agent package ok
(211s), vet for darwin, linux nogui and windows, CORS tests ok.
At 4d95d81ea + this commit: Obsidian, HandWired and Spelled tests,
vet for darwin and windows, and the three GUI files again (56 of 56).
win-run: TestObsidian* ok on Windows 11.

Broken by hand (each went red, then was restored):
- corsGuard without the appOrigin branch: TestCORSObsidian, preflight
  404.
- re-enabling every magpie model on sync: TestObsidianCopilot, "a
  model the user turned off came back on".
- dropping the user's configuredModels: TestObsidianCopilot.
- counting any provider named magpie as magpie's:
  TestObsidianCopilotHandWiredMagpieIsTheirs.

Not tried: a real Obsidian with Copilot loading the written data.json.
The fixtures follow Copilot 4.0.19's types and migrations. Not tried
over LAN either. The full suite runs after the tag.
2026-11-10 20:06:21 +08:00
yetone 5e3f14f21f agent: Paimon, magpie's models through its litellm provider (ditangongyuan on X)
Paimon (aisk/paimon, `uv tool install paimon`) is a terminal coding agent
on pydantic-ai. Read at 7f7fa51 (config.py, llm.py): its settings are one
JSON file, $PAIMON_CONFIG_HOME/config.json, else ~/.config/paimon/config.json
on every OS. "model" is provider:name, and "providers" keeps each
provider's api_base and api_key.

magpie connects it through pydantic-ai's litellm provider, an
OpenAI-compatible proxy that profiles a vendor/model name by its vendor,
as magpie's ids are spelled, and which Paimon's login never offers:
model = litellm:<catalog id>, providers.litellm = the gateway's /v1 and
magpie's key for Paimon (0600, as Paimon writes it), and
compaction.context_window = the model's window. Paimon compacts against
that only for names genai-prices doesn't know, which magpie's ids aren't;
for a model whose window magpie doesn't know it gets the user's own back,
never the last model's. What the user had in the three keys is stashed and
put back on Disconnect (or `magpie paimon default`); the rest of the file
is untouched, and a file magpie made goes again. A model picked in Paimon
itself while magpie's provider stays is the user's from then on. Requests
are told apart by Paimon's paimon/<version> User-Agent. WSL distros, the
PAIMON_CONFIG_HOME isolation, notices in every language, icon, READMEs,
docs/reference.md, agent-wiring.md and the site's list come with it.

Run:
mote refused SSH all session (kex reset), so the Linux runs went
through wsl-run (magpie-desktop) and Windows through win-run:
- go vet: linux -tags nogui, GOOS=windows, GOOS=darwin -tags nogui on
  internal/agent, agentenv, library: ok. gofmt -l: clean.
- go test -tags nogui ./internal/agent/... agentenv library gui cli (WSL,
  base f03ec97b8): all ok except TestGrokInstalled, the known WSL binfmt
  red #3548.
- Windows: TestPaimon, TestHandWired*, TestEveryNoticeIsTranslated,
  TestPortMovesEveryAgent ok (file-mode checks skipped there).
- GUI, chromium + webkit (WSL): i18n-keys, i18n-en-no-cjk,
  agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone, icon-tile,
  mono-icon-redraw, routing-client-icons, usage-agent-filter-icons,
  agent-connect(-no-models), agent-models(-own, -picker), agent-layout:
  150/151; the red is gui-ja's usage price string, untouched here, filed
  as #5943.
- Real Paimon 0.2.8 (uv pip install paimon) in a sandbox HOME on WSL,
  against a sandbox magpie gateway over a fake OpenAI upstream:
  `magpie paimon magpie/fakeup/m1` wrote litellm:fakeup/m1 and
  providers.litellm at 0600; `paimon -p ping` answered "pong from fake
  upstream", the upstream saw POST /v1/chat/completions with
  "paimon/0.2.8 (Python 3.10.19; Linux x86_64)", and magpie usage counted
  the call under Paimon; `magpie paimon default` put the file back equal
  to the user's.
- After the rebase on origin/main 9c39edb92: the three vets, the targeted
  agent tests and internal/gui ok; internal/library's
  TestEveryAgentInLibrary red for avibe from 9c39edb92 (#5945, not this
  change); i18n-keys, i18n-en-no-cjk, agent-notice-lang, gui-de, gui-zh-tw
  ok; icon-one-tone's every-logo case ok in both engines, its webkit
  Plugins-page case timed out on page.goto's 5s at WSL load 92 (#5425).

Broken by hand, each red in TestPaimon:
- the user's window not put back for a model magpie doesn't know (switch
  window: <nil>);
- stashing again while providers.litellm is magpie's (switch window: 200000);
- a file magpie made not removed (made file left: {});
- a model picked in Paimon not kept as the user's (restore after a pick).

Not tried: macOS (mote unreachable) and the GUI's own Connect click with
the real binary; Paimon's auto-compaction at a window magpie wrote (the
fake model had none, so Paimon said compaction was off, as it does for any
name it doesn't know); a model picked in Paimon's own /model while
connected beyond the unit test.
2026-11-10 19:54:37 +08:00
yetone 9c39edb92c agent: Avibe, magpie as a model source through its Model Hub (alex_metacraft on X)
Avibe (avibe-bot/avibe, avibe-os on PyPI, the `vibe` CLI) runs its own
agent, Vibey, and Claude Code, Codex and OpenCode, all on models from its
Model Hub. Its sources live in model_hub.sources of config/config.json in
$AVIBE_HOME (else ~/.avibe, else a legacy ~/.vibe_remote), but a source
can't be written there by hand: its key is sealed in the hub's credential
store and Avibe puts it into its agents' route chains as it is made.

So the Avibe row adds "magpie" the way Avibe's Models page does, through
its internal API (POST /internal/model-hub on state/dispatch.sock, or on
Windows the loopback port + bearer of runtime/control-ipc/endpoint.json):
create_source with kind api_key, vendor custom, base_url the gateway's
/v1, key agentKey("avibe"), protocol openai_chat and save_unverified.
Avibe then lists the models from /v1/models and adds the source to
Vibey's, Claude's, Codex's and OpenCode's chains itself.

- openai_chat, not openai_responses: for a Responses source Avibe's
  CLIProxyAPI runs Codex's executor, which sends codex-tui headers the
  gateway would take for Codex.
- Off is delete_source with force, sent again with the would_remove_hops
  and would_interrupt Avibe answers, as its page confirms them. Sync is
  refresh_source the same way; on a moved gateway the source is made
  again (the key goes with the address; patch_source can't change it).
- The source id is stashed; a custom source at the gateway's /v1 counts
  as magpie's too and is stashed once seen.
- Every change needs Avibe running; otherwise the switch says to run
  `vibe start` (errAvibeDown). Nothing is written to config.json.
- A sync moves the source only from the gateway's own address on an
  older port (avibeMoved). One the user pointed at a NAS's or the LAN's
  magpie, a local proxy's route, or a WSL distro's way to Windows stays,
  as kept.away keeps every file-written agent's; a Rewire after a port
  move sets it again through the field's Set.
- Every test of the package but Avibe's own finds an Avibe running for
  each home (runningAvibe, served in-process), so the tests that connect
  every agent (gateway moved, LAN and proxy addresses kept, drift,
  ListOnly) take Avibe in too.
- The logo is a tile solid to its edges, so it joins app.css's tile rule
  (icon-tile.test.cjs went red without it).
- AVIBE_HOME joins agentenv and the ~-expanding path vars (Avibe expands
  it). Icon from Avibe's assets/logo.png (MIT), 64px.

Run:
- Real Avibe 3.2.5 (uv tool install avibe-os) in a sandbox HOME in WSL
  magpie-desktop, with a fake OpenAI server as the gateway: magpie's own
  code (a throwaway test, AVIBE_HOME + MAGPIE_ADDR) connected it, Avibe
  discovered both fake models with "Authorization: Bearer magpie-avibe"
  and put the source in vibey/claude/codex/opencode chains; Sync
  refreshed; a gateway move to :3592 made the source again there and
  stashed the new id; a second run found the source by address alone
  and still followed the move; off removed it (list_sources []).
  Earlier, by hand: Anthropic /v1/messages and /v1/responses through the
  hub reached the fake as chat completions.
- wsl-run, at this head rebased on origin/main 021a6e1fd (then 401187300, where the Avibe and all-agents tests, i18n-keys, icon-tile and the gui -run set were run again: ok on Linux and Windows): go test
  -tags nogui ./internal/agent ./internal/appdir ./internal/agentenv:
  appdir, agentenv ok; agent ok but TestGrokInstalled, red on WSL2 at
  main (#3548).
- win-run: the Avibe tests and the all-agents tests (drift, port move,
  LAN, proxy, ListOnly, pickers): ok. The whole internal/agent package
  on Windows (one commit earlier) has main's known Windows reds (#4115,
  #5068, #4846, #5130, #5344, ...); its two Avibe reds (drift, ListOnly)
  are what runningAvibe fixed.
- vet (on the Windows box): windows, GOOS=darwin, GOOS=linux nogui on
  agent/appdir/agentenv: ok.
  gofmt clean.
- GUI (chromium + webkit, win-run): i18n-keys, i18n-en-no-cjk,
  icon-one-tone, routing-client-icons, icon-tile: 63 of 63 ok; go test
  ./internal/gui -run 'Icon|Budget|CSS|I18n|Picker': ok.
- mote refused SSH all session, so everything ran on wsl-run/win-run.

Broken by hand:
- a sync moving any address that isn't the gateway's: the LAN- and
  proxy-kept tests red on Avibe's config.json.
- app.css without avibe in the tile rule: icon-tile.test.cjs red.
- protocol openai_responses: TestAvibeAddsMagpieAsAModelSource red.
- confirmed() not resending the echoed hops: the add, knows-its-source
  and follows-the-gateway tests red (source_in_route_chain).

Not tried: magpie on Windows wiring an Avibe that runs inside WSL; a
real Vibey turn against the real gateway (the fake stood in for it);
macOS with a real Avibe.
2026-11-10 19:36:59 +08:00
yetone 4011873001 catalog: models.dev unreachable falls back to the last copy or a shipped one, retried in minutes (creeksuen on X)
Where models.dev can't be reached (a network in China), the catalog that
gives prices, context windows, reasoning levels and names degraded:

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

Now:

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

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

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

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

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

Run on mote, first on origin/main 720200092:
- go test -tags nogui ./internal/agent ./internal/library ./internal/agentenv: ok.
- go test ./internal/gui: ok.
- go test ./internal/proc: ok (at the pre-rebase head).
- GUI tests in chromium and webkit, 69/69: i18n-keys, i18n-en-no-cjk,
  icon-one-tone, icon-tile, tray-logos and usage-agent-filter-icons.
- gofmt -l is clean. go vet passes for darwin, GOOS=linux -tags nogui, and
  GOOS=windows.
Then rebased on 6b92824ff and run again there: go test ./internal/gui,
the Craft, hand-wired, spelled, drift and every-agent tests in
./internal/agent and ./internal/library, and i18n-keys: all ok.
Pushed rebased on 2fbead798 (provider relay URL, Windows restart, gateway cap: no
files in common), not run again there; the full suite runs after the tag.
Broken by hand: with unwire's restore of the user's default taken out,
TestCraftAgents goes red at "restore". On the old code the tests don't
compile (no craftAgents). The first run also showed every-agent tests
(drift, LAN, proxy, port move) needing a Craft fixture, which is now added.
Not tried: a real Craft Agents app or its Pi server against the gateway, or
the Windows install path on a real install.
2026-11-10 18:09:54 +08:00
yetone 987eac0aae gateway: a reported call keeps the model asked for and the one that answered (req, served) (#3534, realLemonawa on X)
POST /v1/magpie/usage/requests took a usage.jsonl line's fields except
req and served, and refused a record that carried them, so a call an
app reported showed an empty Requested and Served model on the
Requests page. Both are now optional fields: req is the model the app
asked for (an alias or a group of its own), served the one its vendor's
reply said answered. Each is checked as model is (a string, at most
256 characters, no control characters) and kept only as sent; a record
without served is never filled from model, so it says nothing of what
answered. The GUI already shows Record.Requested and Record.Served.

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

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

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

Not tried: a real app reporting its calls; the full suite runs after
the tag.
2026-11-10 17:35:15 +08:00
yetone d109ec8da8 agent: miniQ, its provider on magpie's gateway (xiancrong on X)
miniQ (LeadingThink/miniQ, 0.1.213) is a desktop coworker and a `miniq`
terminal, both clients of one miniq-daemon. Its model is one provider in
<data dir>/settings.json, {baseUrl, apiKey, model, apiProtocol}: the data
dir is $MINIQ_DATA_DIR, else the folder miniq-data-dir.json names, else
%LOCALAPPDATA%\miniq or ~/.local/share/miniq (macOS too).

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

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

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

Not tried:
- miniQ's desktop app; only the terminal and daemon ran.
- Windows and WSL with a real miniQ.
- Session titles: miniQ asks a hard-coded gemini-3.8-flash on the same
  provider for them; without such a model at magpie the chat stays
  untitled (miniQ retries later). Nothing in its settings changes that.
- A project's own model in miniQ overrides the global one, as in miniQ.
- settings.update can't remove a provider, so a daemon that had none
  before magpie keeps magpie's until it restarts; the notice says so.
2026-11-10 16:46:39 +08:00
yetone 5a02bf8c14 agent: mu, Pi with a judgment kernel, wired in ~/.mu/agent (xteam3301 on X)
mu (github.com/qybaihe/mu, npm mu-agent, the mu command and the mu
desktop app) is Pi 1.4.0 with a judgment-kernel extension. Its
kyrn/bin/mu.mjs starts Pi on its own agent folder, so Pi's settings.json
and models.json live in ~/.mu/agent, and the desktop app runs the same
Pi on the same folder. magpie now wires it as it wires Pi.

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

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

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

Not tried: the mu desktop app (its install paths are read from its
electron-builder config, not an installed copy); a real vendor behind
the gateway (fake upstream only); a Gemini model through mu; WSL with a
real distro; mu's own session files are not read for usage outside
magpie.
2026-11-10 16:27:14 +08:00
yetone 93a33d8174 agent: OpenBot's icon, its requests named its own, its skills in the Library (SSNQT on X)
SSNQT on X, magpie 0.1.3503 on macOS, OpenBot (611ce90d1): no icon in
the Agents list, its requests listed as OpenCode's, and no way to pick
it for skills or MCP servers in the Library.

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

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

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

Not tried: real OpenBot or a real OpenCode sending to the new address
(the URL is built as `${baseURL}/chat/completions` by
@ai-sdk/openai-compatible, read in its source); the full suite (runs
after the tag).
2026-11-10 15:56:21 +08:00
yetone e7fe52fdc3 minimax: follow the data folder MiniMax Code Desktop moved, not ~/.minimax (YujunT46308 on X)
YujunT46308 on X (magpie 0.1.3519, MiniMax Code 3.1.13 CN): with the
app's data folder moved to another parent (localRuntimeDataParentDir),
magpie went on writing ~/.minimax/config.yaml, which the app no longer
reads.

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

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

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

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

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

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

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

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

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

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

Not tried: a real Nginx doing mTLS; a Windows or Linux run (vet only);
installing the certificate in a browser (there is no .p12 yet); a
proxy that checks certificates itself with MAGPIE_TRUST_PROXY=1.
2026-11-10 14:27:21 +08:00
yetone 9e51c5c2a8 gateway keys: account groups a key may use or keep out (LeiWang_2000 on X)
LeiWang_2000 asked for account groups, so a gateway key can be limited to
a group of accounts, or keep a group out, instead of picking accounts one
by one (on top of v0.1.3504's "Keep accounts out").

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

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

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

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

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

Not tried: a real account's requests through a group-held key (fixture
providers only), the Windows box, the real Linux app.
2026-11-10 13:12:52 +08:00
yetone 0842bc517e gateway keys: a key may keep some accounts out and use every other, later ones too (LeiWang_2000 on X)
A gateway key could only be held to accounts picked one by one, so an
account signed in after the key was saved was never used. An entry
"<provider>/!<account>" (access.ExcludeMark) now keeps that account out:
the key uses every other account of the provider, one added later too,
and never the one kept out.

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

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

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

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

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

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

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

Not tried: a real vendor behind the gateway (fake upstream only),
nanobot's long-running `nanobot gateway`/WebUI picking the change up
live, and WSL.
2026-11-10 10:27:05 +08:00
yetone 40d39e1176 provider: Codex's account is read every 30 minutes while Codex sits idle
dludream on Discord: with Codex signed in, magpie asked chatgpt.com every
five minutes, 288 times a day, used or not, and they worry about ban
risk. KeepOnAnAccountWithRoom read the account Codex is signed in to
(/wham/usage, through SwitchWhenSpent, CodexUsedUp and the app-left
restart) on every full look, every loginSwitchEvery.

Now a full look reads Codex's accounts only when codexDue says so:
- while no Codex session file was written in 30 minutes
  (codexSessionsQuiet over CODEX_HOME/sessions) and the account isn't
  near out, the next read is codexIdleLookEvery (30m) later;
- a session written again makes the next full look (5 minutes at most)
  read it;
- near out or held, it is codexNearOutEvery (1m) as before;
- a sessions folder that can't be read counts as written, so the
  cadence stays 5 minutes.
Claude's looks, the proxy sync and noteCodexGoneNow keep their cadence.
Requests magpie sends on the account keep its windows current from the
reply headers (NoteCodexLimits), so routing doesn't lean on the poll.
docs/reference.md says the new cadence.

Run at this tree (origin/main 5c47d59b5):
- mote-run go test -count=1 -timeout 45m ./internal/provider: ok 135.7s.
- gofmt -l internal/: nothing. mote-run GOOS=windows go vet and
  GOOS=linux go vet -tags nogui of ./internal/provider: ok.

Broken by hand: codexEveryAt never idle and codexDue without the
"written again" clause: TestCodexIdleLooksLess red ("idle, not near out:
5m0s false, want 30m0s true"). Restored, green.

Not tried: the loop itself against a real Codex account over hours (the
decision functions are tested, the loop's wiring is read); other readers
of the account (the Usage page, catalog syncs' CodexUsedUp, warm-up)
keep their own cadence; the full go test ./... suite.

Reported-by: dludream (Discord)
2026-11-10 08:13:08 +08:00
yetone 62a9ab743f update: Stable's "Up to date" names the newest version out (ylspcm on X)
ylspcm (macOS) on X: Check for updates always says up to date, but the
installed version is behind, so they reinstall from the site each time.
On Settings' Stable channel the feed answers Stable's weekly version.
An app installed from the site is newer than that, so every check
answered "Up to date" while newer releases were out on Every version,
and the Version row never named the channel. `magpie update` already
said "up to date on the stable channel"; the app didn't.

Now, on Stable with nothing newer there, the check also asks the feed
on every version (update.LatestEvery, before u.mu is taken).
/api/update says channel "stable" and, when it is newer than this one,
newest. The Version row reads "Up to date on Stable · {v} is out on
Every version" with Switch to Every version, which saves the channel
and the existing channel-change path checks again. With nothing newer
it says "Up to date on Stable". On every version nothing changes, and
there is no second request. en, zh, zh-TW, ja, de. reference.md's
Update channel section says so. The row's code fits in the core
script budget with four of renderUpdate's comments cut, no raise
(1,533,753 of 1,533,802).

The cause is inferred, not confirmed: the tweet gives no channel or
version. The live feed has every version at 0.1.3476 and Stable at
0.1.3078. The rest of the check (semver compare, bundle, mirrors, the
worker's 5-minute cache) gave "Up to date" only for a feed answering a
version at or below the running one.

Run on mote at this change on 216ac6f85. Its parent is now 3cfbc19b0,
which only touches app.css and adds a GUI test, so nothing was run again
(the core script budget, measured again, is the same):
- TestStableUpToDateNamesNewest red with internal/gui/update.go and
  internal/update/update.go put back (old code: map[current:0.1.12
  latest:0.1.11 state:latest], no channel or newest), green with them.
- go test -count=1 ./internal/gui ./internal/update: ok (a run at the
  earlier base passed; after the rebase TestCoreScriptBudget was 440
  bytes over, fixed by the comment cuts above, then run again).
- gofmt -l clean. go vet darwin and windows of both packages: ok.
  GOOS=linux go vet -tags nogui: ok. Without nogui, wails needs cgo
  and fails on mote and in WSL (no gtk4), as it does on main.
- GUI (Chromium + WebKit): update-stable-newest (new: every language,
  900 and 420 wide, the switch saves "", no scroll on click),
  update-channel, update-check, update-row-steady, update-auto,
  update-release-page, update-mirror, i18n-keys and i18n-en-no-cjk:
  pass 130, fail 0.

Not tried: the real app on Stable against the live feed, and a full
suite (after the tag).
2026-11-10 07:53:53 +08:00
yetone 6fe754cb20 claude: Fable 5.2 on Vertex, Bedrock, Desktop's fable tier and Anthropic's fast mode
Anthropic launched Claude Fable 5.2 (claude-fable-5-2) on 11-09
(thelegendof2414 on X: not in magpie's list). Checked against
Anthropic's "What's new in Fable 5.2" page, AWS's model card, models.dev
and Claude Code 2.1.321's own bundle:

- Claude subscription and Anthropic API: the list follows models.dev,
  which already has claude-fable-5-2 (8/40, cache read 0.2, write 10,
  1M context, 128k out), so it shows once the catalog syncs (at most
  24h). TestClaudeAccountListsFable52 holds that with the literal
  models.dev row: listed first, priced, 1M window, low to max efforts.
- Vertex global and Bedrock presets list it
  (global.anthropic.claude-fable-5-2 is on AWS's card).
- Claude Desktop's fable tier now behaves as claude-fable-5-2 (2.1.321's
  latest_per_family); Desktop's own catalog v4371 still ends at 5.1.
- Fast mode on Anthropic's API key: Fable 5.2 has it ($16/$80; 2.1.321's
  fast-mode opt-in set is fable-5-2 and mythos-5-2). Fable 5.1 never had
  it and stays off. A Claude subscription account still gets no fast
  mode in magpie, as before.
- Claude Code's effort: 2.1.321 reads the top-level effortLevel only for
  models up to Fable 5.1 and Mythos 5.1, so 5.2 goes in modelSettings,
  as Opus 5.5 does (claudeReadsTop unchanged, test added).
- Gateway: adaptive-only thinking, no sampling, thinking off never sent,
  xhigh kept: the version rules already cover 5.2; tests now name it.

Run at this tree (mote): gofmt -l clean; go vet ./... (darwin),
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
go test -count=1 ./internal/agent ./internal/gateway ./internal/provider
-run 'Fable|Claude|Fast|Vertex|Bedrock|Effort|Thinking|Xhigh|XHigh|Desktop|Sampling|Adaptive'
ok (84s, 178s, 36s).
Not run before the push: the full go test ./... (mote had six suites
queued on suite.lock at load 420); it runs after, and a red is filed.
Not tried: a real Fable 5.2 request through magpie; fast mode on a real
API key.
2026-11-10 04:58:30 +08:00
yetone a6e4cf7635 settings: what routing does sits under Models › Routing, and the Routing page opens it
The scattered settings audit after netube99 on X. Ask again after a
refusal, the Retry-After cap and the intent classifier's timeout were
under Models › Replies beside rows about a reply's content, and Busy
models last sat in Network and sharing, far from the routing it changes.
The four are now one Routing section under Models, after Replies, and the
Routing page's header has a Settings › button that opens Settings at that
section with its first row lit. The docs (reference.md, the site's
plugins page in en, zh and ja) name the new place.

Run (mote, mote-run):
- settings-places, retry-after-cap-setting, refusal-retries-setting,
  classify-timeout-setting, model-load, i18n-keys and bare-ids, both
  engines: all pass.
- mobile-web against origin/main fdabddeb4 (a git repo made in the copy
  from git archive, since mote-run carries no .git): 30 of 30. It now
  takes the new Settings › button out of the Routing page until main has
  it, as it does for other new rows.
- go test -run 'Budget|I18n|Strings' ./internal/gui: ok. gofmt clean.

Broken by hand:
- the three rows back in Replies and busyLoadRow left where it was:
  settings-places and retry-after-cap-setting 20 of 20 red (chromium);
- the Settings › button's click handler off: settings-places 10 of 10 red.

Not tried: the real app; the GUI suite beyond these files runs with the
rest of this audit's changes.
2026-11-09 22:42:58 +08:00
yetone 88b541a25c images: every pointer names Settings › Models › Images, where the page is
The image models moved under Settings › Models, but the Library's Magpie
Image sheet, the MCP server's instructions to agents, the gateway's
"no image model" errors, the video tool's text and the docs still sent
users to "Settings › Images", a tab that no longer exists (the scattered
settings audit after netube99 on X). Every user-facing string now names
Settings › Models › Images in en, zh, zh-TW, ja and de, as do the site's
Qwen docs (en, zh, ja), llms-full.txt, the subsystem pages and comments.

Run in the tree with this change and the rest of the audit's fixes
(mote, base cd0ba05c2):
- go vet ./internal/gui ./internal/gateway ./internal/agent
  ./internal/provider ./internal/settingsapi: ok
- go test -run 'Image|Draw|Video|Hidden|Group|Settings' ./internal/gui
  ./internal/gateway ./internal/settingsapi: ok; ./internal/imagemcp,
  ./internal/library, ./internal/catalog: ok
- GUI: i18n-keys, i18n-en-no-cjk, image-models-hide,
  library-browser-setup: pass in Chromium and WebKit
- gofmt -l: nothing
Not tried: a real agent reading the new MCP instructions (text only).
2026-11-09 21:51:53 +08:00
yetone 5611e7274e plugin: a plugin's sign-in words show in the window's language when it gives them
mahiro233 on Discord (v0.1.3372, Kiro plugin 0.1.34): in a Chinese
window, the Kiro sheet's "Choose a sign-in method" and its choices read in
English, while the rest of the sheet is Chinese. magpie showed a plugin's
method labels, questions and choices only as the plugin wrote them, and no
plugin had a way to give them in another language.

A plugin may now give them by language, magpie's own fields beside
OpenCode's English, as a page gives its titles: a method's labels, a
question's messages, a select option's labels and hints, each
{"zh": "…", "zh-TW": "…", "ja": "…", "de": "…"}. host.js passes them on
(byLang: string values, codes of 1-16 characters, at most 16, empty ones
left out); plugin.Method and plugin.Prompt carry them; the app shows the
window's language, then its first part, else the English (inLang), on the
way picker, a question, its choices and their hints, a key's field and
the site step's other ways. `magpie plugin login` stays English. Kiro
0.1.35 gives its words in all four (plugins 588b3611).

Tests: TestPluginSignInWordsByLanguage (a plugin's words reach magpie as
given, bad ones left out, none for a plugin that gives none);
TestPluginOwnIconAndKeyHint compares a Method with reflect.DeepEqual now
that it holds a map. The GUI side is checked by plugin-ask-ways.test.cjs
in the next commit.

Run on mote at this tree: gofmt -l empty; go vet ./internal/plugin
./internal/provider ./internal/gui (darwin), linux -tags nogui, windows:
ok; go test -count=1 ./internal/plugin ./internal/provider ./internal/cli:
ok. Broken by hand: with origin/main's host.js the new test fails (no
labels, messages or hints reach magpie). Not tried: a real Kiro sign-in
(no keys or passwords entered anywhere); the full suite is queued on mote
under suite.lock after the push.
2026-11-09 18:29:55 +08:00
yetoneandreyoung 4314f4b776 otel: export the gateway key's name as magpie.gateway_key.name (#5751)
reyoung (#5751) shares one magpie through several gateway keys and wants
requests in Langfuse or another collector told apart by key. The ledger
row already had CallerKeyName, but the OTLP allow-list dropped it, and
the observer's root and attempt records never carried it.

Ported from reyoung's 9d82162aa (reyoung/magpie feat/otel-gateway-key-name),
applied unchanged onto current main:
- observeRequest takes access.Caller(r).KeyName when observing begins
  and puts it on every End and Attempt record (CallerKeyName), so the
  root span and every try (failures, retries, fallbacks) carry it with
  no lookup at export time.
- otlp's allow-list grows by this one attribute, on generation and
  ledger spans (otelAttributes, so the duration and token histograms
  too) and on the root span. Omitted when the name is empty. The key's
  id and secret are never sent; provider account names stay out.
- docs/reference.md, plugin-runtime.md and the en/zh/ja privacy pages
  say the name goes to the user's collector.

Added on top: docs/reference.md says each key name multiplies a
metric's series, and that keys sharing a name are counted together.

Review of the fork (read every line; run only on mote): no new address,
dependency or credential; the name is read from the auth context at
request time, the same source appendUsage uses for the ledger row;
reported rows (another computer's) already have the caller key cleared
and never reach observers; session spans of local transcripts have no
key. READMEs (en, zh) mention OTLP only as a feature, with no list of
what is sent, so they are unchanged.

Run on mote (lockf ~/suite.lock), at base c7ebb6f8d plus this change:
- gofmt -l internal/gateway internal/otlp: clean.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok.
- go test ./internal/otlp ./internal/gateway -run 'TestOTel|TestObserve':
  ok.
- go test -count=1 -timeout 45m ./internal/otlp ./internal/gateway
  ./plugins/otel: ok.
- go test -count=1 -timeout 45m ./... (macOS): every package ok (92),
  exit 0.

Rebased onto 136178803 after that run (5 commits; gateway.go and
prev_response.go, nothing in observe.go, otel*.go or internal/otlp).
The touched packages' run at the pushed head is queued behind mote's
suite lock and was not done before the push.

Broken by hand (each on mote, then restored):
- observeRequest without the name (o := &observed{}):
  TestOTelExportsGatewayKeyName/true red, "span 0: gateway key name ""
  seen 0 times".
- gatewayKeyAttr returning before adding the attribute:
  TestOTelBatchWireAndPrivacy red (attributes lack
  magpie.gateway_key.name) and TestOTelExportsGatewayKeyName/true red.

Not tried: a real Langfuse collector; Windows and Linux runtime runs (vet
only); the site pages are not deployed by this commit.

Co-authored-by: reyoung <728699+reyoung@users.noreply.github.com>
2026-11-09 17:21:48 +08:00
yetone 3fc6ee4111 site: release files from Cloudflare R2, GitHub behind them
Updates and the installer downloaded every file from github.com, which
answered 504 for every release file for hours on 2026-11-08. The site now
keeps a copy on R2 (bucket magpie-releases, binding RELEASES):

- A five-minute cron copies the newest release and the Stable one from
  github.com (or, when that fails, GitHub's API) into R2. R2's put takes a
  file only with the SHA-256 the release's SHA256SUMS gives. A run starts
  no copy after 4 minutes; the feeds' tags and the 4 newest besides are
  kept, older ones deleted.
- /files/<tag>/<file> serves R2's copy, Range and conditional asks
  included; a file R2 doesn't hold, or a failing R2, is a 302 to
  github.com.
- /api/latest (both channels) and /download name /files only for a file
  R2 holds under the release's hash, and give every file's github.com
  address as `github`, which the previous commit's clients fall back to.
  Older clients only mirror a github.com address, so a mirror never goes
  in front of the site's.
- start (en, zh, ja), privacy (en, zh, ja) and reference.md say where
  files come from.

Run (mote): node --test site/*.test.mjs 104/104, with files.test.mjs
(R2 stood in for by r2stub.mjs) and new worker tests for the feed,
/download, /files and the cron. wrangler deploy --dry-run binds RELEASES.

Broken by hand: onR2 taking any held file regardless of hash, two tests
red (the feed test and "bytes R2 holds under another hash").

Not tried yet: the real cron run and R2 serving (after deploy).
2026-11-09 05:48:23 +08:00
yetone c66cdbea97 update: a release file github.com won't serve comes through GitHub's API
On 2026-11-08 github.com answered 504 for every file of
yetone/magpie-releases (…/releases/download/<tag>/<file>) for hours, while
api.github.com/repos/yetone/magpie-releases/releases/assets/<id>, asked
with Accept: application/octet-stream, redirected to the same bytes.
Every self-update and the install script failed (kurutodenzeru, wjbdx,
isee1_1 on Discord). Retrying the same address (a46190e1f) can't help.
The site's feed was stuck at 0.1.3318 too: its SHA256SUMS read went to
the same address.

- internal/update: download() goes to the API route at the first busy
  status (5xx/429), or for the last try after connection errors. The
  feed's new per-asset `api` is used as it is; without it the address is
  looked up from the release's tag (apiroute.go). The file is checked
  exactly as before: the feed's SHA-256, and Stage's signing-team check on
  the Mac. A mirror the user set keeps precedence: through one, no API
  route is tried (its whole point is that GitHub isn't reachable). This is
  the one download every caller uses: the app's update, the CLI's
  `magpie update` and serve's auto-update.
- site/public/install.sh: when the feed's github.com URL fails and no
  mirror is set, it downloads through the feed's `api` (else looks it up
  with curl+sed, no jq), and checks the same SHA-256.
- site/worker.js: the feed lists `api` per asset. SHA256SUMS is read
  through the API when github.com fails. While it does, each file's `url`
  is usemagpie.ai/dl/<tag>/<file>, which 302s to the address GitHub's API
  gives (only *.githubusercontent.com or github.com, https), so an older
  magpie, which follows `url` only, updates too, still checked against the
  feed's SHA-256. That feed is cached 60s instead of 300s, so it goes
  back to github.com's URLs soon after github.com recovers.
- docs/reference.md: the API route, and that a mirror keeps precedence.

Run:
- mote: go test -tags nogui -count=1 ./internal/update (ok 20.3s).
- mote: node --test site/install.test.mjs site/worker.test.mjs
  site/stable.test.mjs: 76 pass.
- gofmt -l internal/update: clean. mote: GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet -tags nogui ./..., GOOS=windows go vet
  ./internal/update ./internal/cli ./internal/gui: clean.
- Real, on the Linux box (wsl-run, magpie-desktop) at 10:50Z: a nogui
  build stamped 0.1.3000, `magpie update` in a sandbox HOME
  (MAGPIE_ADDR=127.0.0.1:9). MAGPIE_UPDATE_FEED was a local feed whose
  magpie-cli-linux-amd64 url answered 504, with the real `api` of
  v0.1.3319 and the sha256 from the real SHA256SUMS. The download address
  was asked once and got 504. The file came through api.github.com, and
  the binary was replaced with exactly 89fff184… and reports 0.1.3319.
- Real: install.sh's apiroute sed against api.github.com's full
  v0.1.3319 description found the right asset id for 5 files
  (723602745 for magpie-cli-linux-amd64, the same as Go's lookup).
- Full suite: not run at push; it runs after.

Broken by hand:
- No switch to the API route in download(): 3 of the 4 new Go tests red
  ("504 Gateway Timeout, on every try").
- Mirror check and the octet-stream Accept removed:
  TestMirrorKeepsPrecedenceOverTheAPIRoute red, and
  TestDownloadGoesThroughTheAPIWhenGitHubIsBusy red (checksum: GitHub's
  JSON description instead of the file).
- worker: no API read of SHA256SUMS, no /dl location cache, and no check
  of the redirect's host: each red.
- install.sh: no API fallback, then no mirror guard: each new install
  test red.

Not tried:
- The real outage itself: github.com had recovered (302, slowly) by the
  real run, so the 504 was a local server's and the API route was real.
- An old magpie through the deployed /dl route against a failing
  github.com; it is covered by the worker test only.
- install.sh end to end against the real API (only its lookup); the Mac
  app's Stage through the API route (only the fake tests, which keep the
  signing-team check unchanged).
2026-11-08 18:52:32 +08:00
yetone b0926e81a2 import: a link can say where its key's balance is read (balance=, balance_path=, balance_method=)
A relay's "Add to magpie" link can now name the URL that tells a key its
balance, where the amount sits in the reply, and GET or POST. magpie
takes it only on the host of one of the link's own base URLs, over
https, with no userinfo or fragment, so a link can't send the key
anywhere its requests don't already go; anything else refuses the whole
link. balance_path or balance_method without balance is an error. No
header or token is taken from a link: an account-wide token is worth
more than a key, and a URL stays in browser history.

- provider.ParseImport: linkBalance checks and sets BalanceURL,
  BalancePath and BalanceMethod.
- CLI: the import preview shows the balance URL and doesn't ask it
  before yes (showProviderAsking).
- GUI: the import dialog shows method, URL and field (.imp-bal).
- Docs: docs/import in en, zh and ja (table rows, a note on headers,
  the builder's three fields with the same host check, a security
  bullet); docs/reference.md's parameter table.

Run on mote at this tree (rebased on 8fa3c60f8):
- go test -count=1 ./internal/provider ./internal/gui: ok
  (TestParseImportBalance, TestCoreScriptBudget in it).
- go test ./internal/cli: ok but TestEveryRouteHasACommandOrIsNamed,
  red on main since f418edffc (GET /api/context/session); fixed in the
  next commit, and ok there with -run 'TestEveryRoute…|Import'
  (TestImportPreviewAsksNoBalance).
- GUI import-link-balance, import-link-gemini, i18n-keys: 43/44. The
  red is i18n-keys "a plugin's words are its own", the same three
  strings on an origin/main 8fa3c60f8 copy (#5327, #5426, #5482).
- GOOS=linux go vet -tags nogui and GOOS=windows go vet of provider,
  cli, gui: ok. gofmt -l: clean.

Not tried: a real link with balance= imported into the app and read
against a real relay's balance endpoint.
2026-11-08 18:37:41 +08:00
yetone 7880a00ac6 models: a model of a key's provider can be asked on System One
axelburks on Discord: a relay serves its decision model under a name of
its own (an Ark endpoint id). A key's provider with a System One URL
beside a conversation URL can set a model's API to decide (System One
in Model settings' API row, its chip's right-click, or `magpie model
api <pid/model> decide`). The model is then a decision model there:
asked on System One by its own name, offered to routing groups, kept
out of the conversation models, and a turn for it is refused with 400
before the vendor is asked. Auto gives it back. A provider with no
System One URL, with that URL alone, an account, a remote magpie and
Vertex refuse it, saying why. Chat routing (apisAmong) ignores decide.

Broken by hand: removing the decideSet check in DecidesModel turns
TestModelSetToSystemOneIsADecisionModel and
TestModelSetToSystemOneAskedThere red.

Run, on this stack over origin/main 0fc3455e2 (mote's suite lock had
hours of queue, so the suites ran on WSL magpie-desktop under flock):
- go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx}
  on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean;
  go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok;
  TestCoreScriptBudget ok (paid by cutting comments, no raise).
- GUI, both engines, every language, on WSL at the pushed head and at
  0fc3455e2: every touched test file plus the provider-editor files a
  first run found red. No red at head that isn't red at 0fc3455e2. The
  shared reds have issues: i18n-keys #5332, model-chip-steady #4388,
  model-copy-id #4621, models-works-only #4391, plugin-move-unserved
  #4392, provider-fetch-again #5232, provider-levels-save #4394,
  provider-levels-scroll #4395, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398,
  zero-priced-free #5262, model-reasonless (webkit de) #4100,
  name-suffix-no-names #1937.
- Rebased on origin/main 4ab1191bc (gateway.go moved under it) and run
  again at the pushed head: gateway and provider ok on WSL, gofmt,
  vet (mac, linux nogui, windows) and the budget ok, i18n-keys,
  model-headers and routing-groups-back with only #5332's red.
Not run at push: the whole GUI suite (1277 files).

Not tried: a real relay's System One endpoint; fake vendors only.

Reported-by: axelburks (Discord)
2026-11-08 11:28:54 +08:00
yetone 7a6211d047 providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own.
A key's provider (built-in or custom) can give each model headers
(settings.ModelHeaders["pid/model"]). They go on that provider's
requests for that model alone, after the provider's headers and after
auth: a name both have is sent once, as the model's, so a user's value
is never overridden by the provider's or magpie's key header. The
gateway names the model (provider.WithModel) on every route that asks
one: chat on each API, translated and streamed, count_tokens, System
One's decision, embeddings, images, videos and the model test. A
fallback provider serving the same model id gets its own headers only.
Accounts and plugins carry their sign-in's headers and take none.

The editor's "Name, price and reasoning level" panel is now "Model
settings" (every language), with + Add header per model, staged and
made with the Save; Restore default takes them away.
The rows being typed are kept out of the draft's
compare, so an untouched editor still closes without asking.

Broken by hand: dropping WithModel from gateway.go turns
TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider
id check in modelOf turns TestModelHeadersStayWithTheirProvider red.

Run, on this stack over origin/main 0fc3455e2 (mote's suite lock had
hours of queue, so the suites ran on WSL magpie-desktop under flock):
- go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx}
  on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean;
  go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok;
  TestCoreScriptBudget ok (paid by cutting comments, no raise).
- GUI, both engines, every language, on WSL at the pushed head and at
  0fc3455e2: every touched test file plus the provider-editor files a
  first run found red. No red at head that isn't red at 0fc3455e2. The
  shared reds have issues: i18n-keys #5332, model-chip-steady #4388,
  model-copy-id #4621, models-works-only #4391, plugin-move-unserved
  #4392, provider-fetch-again #5232, provider-levels-save #4394,
  provider-levels-scroll #4395, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398,
  zero-priced-free #5262, model-reasonless (webkit de) #4100,
  name-suffix-no-names #1937.
- Rebased on origin/main 4ab1191bc (gateway.go moved under it) and run
  again at the pushed head: gateway and provider ok on WSL, gofmt,
  vet (mac, linux nogui, windows) and the budget ok, i18n-keys,
  model-headers and routing-groups-back with only #5332's red.
Not run at push: the whole GUI suite (1277 files).

Not tried: a real vendor that routes by header (Ark); fake vendors only.

Reported-by: axelburks (Discord)
2026-11-08 11:28:54 +08:00
yetone d32a7a70cb remote magpie: once magpie updates, the Remote magpies it uses update too
nnlrl_75403 on Discord: a magpie used as another's Remote magpie stayed on
its old version after the local one updated, and had to be updated by
hand on the other computer. Now nothing needs setting up:

- provider.KeepRemotesUpdated (started by the app's updater and by
  magpie serve) runs UpdateRemotes 30 s after start and hourly. A
  released build with automatic updates on reads each Remote magpie's
  version (GET /v1) and, when it is older, asks it through
  POST /v1/magpie/update?version=<v> with the provider's key, at most
  once in six hours per version. Off here, or a dev build: nothing asked.
- The remote updates as its own automatic update would: the app
  downloads and restarts once idle (updater.updateAsked → download,
  waitIdle); magpie serve puts the latest in where it runs from, one at
  a time, never elevated, and serveFollow restarts into it. Automatic
  updates or downloads off there: it answers "off" and stays.
- A copy that can't replace itself says why: a container (docker pull
  ghcr.io/yetone/magpie:latest), a package manager's (its command), a
  folder it can't write, a build from source. A magpie from before the
  route answers 404 ("too old"), a read-only or held key is "refused".
  The provider's row on the Providers page adds a short status to its
  line ("updating to v…" for 30 min, or "can't update itself" etc.),
  with the reason and the command in its tooltip. en/zh/zh-TW/ja/de.
- The route replaces the program, so it takes the Codex reset's
  admission: another machine only while shared, never a browser page,
  an enabled key with full access from loopback too (401 without one),
  read-only 403 gateway_key_read_only, held 403 gateway_key_held. It is
  in readOnlyRefused and the CORS route list.

App.js stays under TestCoreScriptBudget by cutting two comments; the
budget is not raised.

Run (on mote, at the tree committed here):
- gofmt -l internal/: clean. go vet of gateway, gui, cli, provider for
  darwin, GOOS=linux and GOOS=windows: ok.
- go test -count=1 ./internal/gui ./internal/cli ./internal/provider
  ./internal/gateway: gui and cli ok but for #5644's two settings tests
  (red on main since 6b7ee4a98, owned); provider and gateway were
  still running at the push, and go in the full run after it.
- Rebased on origin/main c7c05dcf2, again: gofmt, vet, the new tests,
  ReadOnlyKeyEveryRoute, CORS, TestCoreScriptBudget (not raised) and
  both GUI files 32 of 32: ok.
- New: TestRemoteUpdateNeedsAFullKey (no key from loopback, Origin null,
  an app scheme, *.localhost, a rebound Host, a foreign page with and
  without the full key, another machine with none or a wrong key,
  read-only and held keys, then not shared; the updater is never
  called until a full key asks, from LAN and loopback),
  TestRemoteMagpieAskedToFollow (UpdateRemotes against a real gateway:
  dev build, same and newer remote, NoAutoUpdate here, asked once per
  version, container answer kept, read-only key refused, a 404 magpie
  "old"), TestUpdateAskedByAnotherMagpie, TestRemoteUpdateNote,
  TestServeUpdateAsked.
- GUI: remote-update.test.cjs (new) and remote-self.test.cjs, Chromium
  and WebKit, 1100 and 420 wide, en/zh/ja/de: 32 of 32 ok, with every
  key checked in zh, zh-TW, ja and de. i18n-en-no-cjk ok. i18n-keys'
  "a plugin's words are its own" is red, the same on origin/main
  f8525323d (#5327/#5332, #5426, #5482); its other cases ok.

Broken by hand, each red, then put back: the handler's key check
(loopback without a key got 200 updating), its held-key check, the
route itself (404 = the old code), asking a remote that is current,
ignoring NoAutoUpdate here, asking again for the same version, the
app ignoring automatic updates off, the app never waiting to restart,
serve's single flight (2 downloads), serve's container answer.
The handler's own Origin and not-shared checks stay green when removed:
corsGuard and lanGuard refuse those first; they are kept as the Codex
reset keeps them.

Not tried: a real update of a real remote (a Docker magpie and an app
on another Mac) end to end; Windows and Linux runs of the new tests
(vet only); the full suite (run after the push).

Reported-by: nnlrl_75403
2026-11-08 03:13:15 +08:00
yetone 3b541a7f36 routing: Smart ranks an account by its week once its month can't be used up before it renews (#5639)
Smart ranked a Volcengine Agent Plan (5 hours 2,000, week 7,000, month
20,000) by its month, the biggest window, so it always stood behind
accounts renewing weekly, and its month could reach a point where it
could no longer be used up before it renewed.

The rule keeps #1778's reasoning: a month holding less than its weeks add
up to is the real cap while the weeks can still carry it. Once what the
biggest window has left is more than the next window (a day or longer,
same unit, counts known) can let through between its own reset and the
biggest one's (Of x time between / Span), what the week leaves at its
reset is lost, and the week ranks the account.

- provider: Allowance.Unreached counts the biggest windows to pass over.
  Renewal and Seat.Soon are unchanged for other strategies and plugins.
- routes: Seat.Unreached; Smart compares Soon past it.
- gateway: weighRouted fills it; the trace's Weighed carries `unreached`.
- GUI Routing: renewsBy skips those windows, and a new story line says the
  shorter window decides. The Smart header and the group hint say so in
  en, zh, zh-TW, ja and de.
- docs: reference.md (How magpie picks an account) and
  subsystems/gateway-routing.md.

With the issue's numbers as reported (month 696 h away, 18,372 left),
four weeks carry 28,017, so the order is unchanged. Two weeks before the
month renews, 14,017 < 18,372, and the plan goes first, ahead of the
point where a week's leftover is lost.

Run on mote at this tree (base 2dac9b84e; origin/main bb33142ea touches
none of these files):
- go test -tags nogui ./internal/provider ./internal/routes: ok
- go test of TestMonthOutOfReachRanksByWeek,
  TestSmartSpendsAWeekTheMonthCantWait, TestSmartPassesAnUnreachedWindow
  and the Smart/Renewal/Weighed tests in provider, routes, gateway: ok
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok
- gofmt -l internal/: clean
- node --test routing-key-windows.test.cjs: 52/52 in Chromium and WebKit,
  en/zh/ja/de, the new #5639 scene included

Broken by hand:
- Unreached returning 0: TestMonthOutOfReachRanksByWeek ("two weeks to
  go", "the last week") and TestSmartSpendsAWeekTheMonthCantWait went red.
- Smart comparing a.Soon, b.Soon whole: TestSmartPassesAnUnreachedWindow
  and TestSmartSpendsAWeekTheMonthCantWait went red.
- client.js without the slice and the story line: the #5639 GUI case went
  red (Chromium en).

Still running when pushed (the owner's rule not to hold a verified commit
behind the suite): the full internal/gateway package; all routing-*,
panel-routing*, gui-zh-tw/ja/de and i18n GUI files in both engines; and
the full go test ./... -timeout 45m. Any red they show gets its own issue.

Not tried: a real Volcengine Agent Plan account. Ark replies that send
only Percent carry no counts, so the rule can't apply to them. Not
changed: Use before expiry (Pace) still ranks this plan by its month;
filed as #5641.

Reported-by: louisgreen0726
Refs #5639
2026-11-08 02:08:08 +08:00
yetone c7810ea5cc gateway: /v1/decisions asks a System One decision model, and /v1/systemone a Decisions-only one (wudi_boy)
wudi_boy on Discord: a Decisions request (Python-urllib) to the Qwen
decision model, decision-model-preview, was refused, while the same
model answered on /v1/systemone. canDecide sent Decisions only to an
OpenAI key, Azure or another magpie, and nothing translated between the
two APIs.

Now a Decisions request whose model answers System One (Qwen's, Ark's,
a Jev, a Clef, a plugin's, or a decision group whose members do, none
of them a provider that serves Decisions itself) is asked there
(decisions_systemone.go): predicate -> noul, choice -> criteria map
(boolean values as "true"/"false", typed back on the answer), score ->
criteria list "label: description" least first, an unnamed question ->
question_N answered with a null name, input -> state (a string as it
is, items as {"messages":[{role, content, refusal}]}, input_json as its
JSON text). The answer comes back in the Decisions shape in the
questions' order, a missing answer as refusal, with input and output
tokens. prompt_cache_key/options and safety_identifier change no answer
and are left out. Everything with no counterpart is a 400 naming it,
before the vendor is asked: an image unless every target is a Clef or
another magpie, an http image, function/custom tool calls and outputs,
an image or refusal in a question, any other field or question type.
The reverse: /v1/systemone whose model no System One provider has but
the Decisions API serves (openai/gpt-6-luna) goes through
serveRetrieval as /v1/decisions does, and is answered as System One.
A vendor's error passes through as it was said.

Tests, against fakes with the real shapes (Ark's 2026-11-01 System One
answer, Cloudflare's result envelope, openai-python's Decision):
TestDecisionsAskSystemOne, TestDecisionsMessagesAsSystemOneState,
TestDecisionsUntranslatableRefused, TestDecisionsImagesToClef,
TestSystemOneAsksDecisions.

Run on mote (mote-run) at this change on d4712e131: go test -count=1
-timeout 45m ./internal/gateway ok (777s); go vet ./internal/gateway
for darwin, linux and windows clean; gofmt -l clean. Full suite queued
under the suite lock, not run.
Broken by hand, each red: the decide branch taken out (the qwen tests
400 "no OpenAI-style API"); the reverse call in serveSystemOne off
(404 "no Jev provider"); an image to a text-only model and a
function_call dropped silently instead of refused (200 instead of 400).
Not tried: a real Qwen or Ark key, or a real OpenAI Decisions call; a
plugin's decision model through the translation.

Reported-by: wudi_boy
2026-11-08 00:45:30 +08:00