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

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

What was run:
- New tests: internal/gateway/tls_test.go (others HTTPS-only, this
  computer both, a silent local client holds no other, renewed
  certificate served, CheckTLS, addresses, Relisten keeps TLS),
  internal/cli/tls_cli_test.go and daemon TestInstallCarriesTLS (linux
  and darwin, paths with space, %, & and ").
- Each was broken by hand and went red: no wrap in listen, no reload, a
  synchronous sniff, a bad renewal dropping the certificate, http in
  publicURL or the pinned LANURLs, the carried entries removed, and
  keepTLS as a no-op.
- Real use under a sandbox HOME, with a self-signed pair, on
  0.0.0.0:3461:
  - Half a pair, a garbage certificate, a flag with no value, and the
    env set to half a pair each exit 1 with the message.
  - curl -k https://127.0.0.1 and https://<LAN IP>/v1/models with a key:
    200. Plain http on loopback: 200.
  - The cert files were swapped for a second pair while it ran.
    openssl s_client then showed the new CN and serial, and curl
    --cacert with the new pair got 200. A junk key file then kept the
    second pair, logged once.
  - From the Windows box over the LAN: plain http got 400; https with
    the key got 200, and without it 401.
  - magpie web --addr 0.0.0.0:3462: https network links. From Windows,
    http got 400 and https with the key got 303.
- gofmt -l clean. go vet passed on darwin, GOOS=linux -tags nogui and
  GOOS=windows.
- go test -tags nogui for ./internal/cli, ./internal/daemon, and the TLS
  tests of ./internal/gateway and ./internal/gui: all pass at the rebased
  head.
- Two reds in the full suite (`go test -tags nogui ./...`) are the same
  on origin/main f074996d9; both are filed:
  - TestGatewayHeldByAContainer failed 2 of 5 there (#2107).
  - The gateway package runs past go test's default 10m under load:
    1208s on main and 1221s here, both passing with -timeout 40m
    (#2108).
2026-10-14 13:36:03 +08:00
yetone ccffdadb8a gateway: /v1/audio/transcriptions passes speech-to-text through to the provider (#2053, niyoh120)
niyoh120 asked for an OpenAI-style speech-to-text endpoint so a client's
voice input can go through magpie like its chat does. magpie had no
/v1/audio route, so the request 404ed.

What changed:
- POST /v1/audio/transcriptions and /v1/audio/translations (and the
  /audio/... spellings) route through the same core as embeddings and
  rerank. embeddings.go's routing is pulled out into serveRetrieval, so
  disabled models, key access, groups, pause rules, account holds,
  failover, redaction and usage records are shared rather than copied.
- transcribe.go reads the multipart form only to find `model` (as
  provider/model) and `prompt`. The form goes to the provider byte for
  byte; it is rebuilt part by part, under the same boundary, only when
  the model name is rewritten or the prompt was masked. The audio part
  is always copied as sent.
- Only providers with an OpenAI-style base are tried; an Anthropic-only
  provider gets a 400 saying so. A body that isn't multipart, a form with
  no model, or one that doesn't parse gets a 400 and nothing is sent.
- The vendor's answer type passes through (response_format text/srt/vtt
  stays text/plain). Usage records output tokens from usage.output_tokens.
- The 404 message, the info api list, remote magpie's suffix list, the
  CORS and LAN tests, docs/reference.md, gateway-routing.md and the
  remote docs (en, zh, ja) name the new paths.

What was run, at 9c36c3a0 (this change rebased on 10f38770):
- gofmt -l internal/gateway internal/provider: empty
- go vet (darwin); GOOS=linux and GOOS=windows go vet -tags nogui on
  ./internal/gateway ./internal/provider: clean
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider:
  ok (1367s, 339s); also green on two earlier bases (b4fe6663, 06fbfd95)
- Rebased again on a0ebe003 (main had moved 5 commits, none in these
  files; routing.go's Factory rest is the nearest): gofmt, vet on darwin,
  linux (nogui) and windows (nogui) clean, and
  go test -tags nogui -run 'Transcri|Embed|Rerank|CORS|LAN|Lan|Factory|
  Retriev|NotFound|Info' ./internal/gateway ok. The full packages were not
  rerun on this last base.

Break-checks, each turned red and restored:
- routes removed (the old code): all 5 new tests fail
- model never rewritten: TestTranscriptionGoesToTheModelsProvider and
  TestTranscriptionPromptRedacted fail
- answer always labelled JSON: TestTranscriptAsTextKeepsItsType fails
- rebuild truncates the audio part: Goes + PromptRedacted fail
- prompt not masked: TestTranscriptionPromptRedacted fails
- output tokens ignored: TestTranscriptionGoesToTheModelsProvider fails

Real use: through magpie's real handler against aihubmix
(https://aihubmix.com/v1) with a `say`-made m4a: whisper-1 json 200
{"text":"Hello from the Magpie Gateway."}, response_format=text 200,
srt 200 text/plain with SRT cues, translations 200.

Not tried: OpenAI direct (the key answers 429 "account is not active"),
Groq, a local vLLM/whisper server, and any real client's voice input.
2026-10-14 09:19:16 +08:00
yetone 82f3befd29 daemon: magpie daemon install --web serves the browser page from the service, with a link that lasts (HuanCheng Bai)
HuanCheng Bai on Discord runs `magpie daemon` on a Linux server and asked
for the daemon to serve the web page too, or for an option to turn it on.
`magpie web` run beside it is a second process, and he read it as not
seeing the daemon's state.

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

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

Not tried: a real systemd on Linux. The unit text is checked by test only.
2026-10-14 08:32:41 +08:00
yetone 77f90fd84f gateway: a plugin whose config hook says searches: true is sent the client's web_search as sent (#2027, yudaleng)
A plugin in front of Anthropic's or OpenAI's own API (a CPA or sub2api
relay whose quota the plugin reads) had no way to say its upstream runs
the hosted web search tool: searchesItself returned at once for any
signed-in account, letting only Codex and Grok through, so Claude Code's
WebSearch and Codex's web_search always went through magpie's own search.

Now a plugin's config hook can set `searches: true` on its provider, as
it sets `decide` (#1514). The host passes it through
(plugin.Provider.Searches), pluginProvider sets the provider's Searches,
and searchesItself honours it for a plugin's provider only, on Anthropic
or Responses and only where the plugin has a model on that API, the same
rule a custom provider's "Searches the web by itself" has (#359). Another
sign-in's Searches is never read; Codex and Grok are unchanged. As with a
relay, searchRank leaves it out, so magpie never picks it to search for
other models; Settings can name it by hand.

Documented in docs/subsystems/provider-plugins.md and the plugin guide
(site/public/docs plugins.html, en/zh/ja).

Verified:
- TestPluginSaidToSearch (new, gateway, through the real fake plugin on
  bun and New().Handler()): with FAKE_SEARCHES the plugin's upstream gets
  web_search_20250305; without it, it gets no search tool; Chat doesn't
  search and searchRank is -1 either way.
- Broken by hand, each red: search.go reverted, plugins.go reverted,
  host.js reverted (each "searches by itself on Anthropic: false"); with
  the searchesItself assertion disabled and search.go reverted, the wire
  check fails "said to search true, the plugin was sent []".
- TestMovedGrokSearchesItself, TestGrokPluginSearchesItself,
  TestWebSearch* pass.
- go test -tags nogui ./internal/plugin ./internal/provider ok, and
  ./internal/gateway (see the run noted on #2027) under a sandbox HOME
  with pinned caches; gofmt -l clean; GOOS=linux and GOOS=windows
  go vet -tags nogui on the three packages clean.
- Not tried with a real CPA/sub2api plugin.
2026-10-14 05:17:31 +08:00
yetone 591ed58b53 provider: Nous Portal is a vendor preset, Nous Research's API with a Portal key (#392, Vocllum, laojianzi)
Nous Research makes the Hermes models and serves them, with other makers'
models, through Nous Portal. #392 was wrongly answered as a relay. A new
preset, nous ("Nous Portal", KindVendor with Hosts, lobe-icons
nousresearch icon), points chat completions at
https://inference-api.nousresearch.com/v1. A Portal API key goes in as a
Bearer, the way Hermes Agent's own nous-api provider uses NOUS_API_KEY.
The model list is the Portal's /v1/models, which uses vendor/model ids.
An entry another app has at that URL, such as Hermes Agent's base_url,
now imports as the preset.

The preset sets no Anthropic endpoint. The Portal's /v1/messages serves
only its anthropic/* models (Hermes Agent's
test_nous_portal_anthropic_wire.py), so Claude Code's requests are
translated to chat completions for every model. It sets no Responses
endpoint either, because none is documented.

The preset is added to the README (en, zh), docs/reference.md, and the
site's import pages and icon.

Sources:
- hermes-agent docs: integrations/nous-portal, integrations/providers,
  features/subscription-proxy.
- hermes-agent source at 6e7b83a2: hermes_cli/auth_constants.py
  (DEFAULT_NOUS_INFERENCE_URL), plugins/model-providers/nous,
  cli-config.yaml.example ("nous-api - Nous Portal API key (requires:
  NOUS_API_KEY)"), agent/anthropic_endpoints.py, and
  tests/e2e/core/live/_helpers.py, whose live run calls the Portal with
  NOUS_API_KEY.

Probed without a key:
- /v1/models answers 200 with 423 models.
- /v1/chat/completions with a bad Bearer answers 401 "Your API key is
  invalid, blocked or out of funds".
- /v1/messages answers an Anthropic-shaped 401.

Not tried: a real Portal key or a real request, since no key was
available. Also not built: OAuth sign-in with the 1-hour token and its
refresh (Hermes Agent's ~/.hermes/auth.json).

Run:
- TestNousPortalPreset fails without the preset (no preset "nous") and
  with an Anthropic endpoint added (endpoints: … "https://inference-api.nousresearch.com").
- go test -tags nogui of internal/provider, internal/gui and
  internal/catalog passes.
- gofmt -l is clean.
- go vet, GOOS=linux go vet and GOOS=windows go vet -tags nogui on
  ./internal/provider pass.
- add-sheet and add-button GUI tests pass in Chromium and WebKit (6/6).
2026-10-14 04:40:21 +08:00
yetone 71f796069f site: the docs bar keeps every link on one line instead of stacking it a character per line
Between 1000px and ~1300px the docs nav's links shrank to fit, so 快速上手
and "Get started" wrapped into columns of characters and the bar grew
two lines tall (owner's screenshot, zh docs). The links now never wrap
inside themselves (white-space: nowrap), the brand keeps its width, and
the link row is one 22px line: a link that doesn't fit wraps onto a
second line the bar clips. This fits every language without a per-language
breakpoint; the contents still list every page.

Run: served site/public locally and shot /docs/{zh,en,ja}/start in
headless Chrome at 1010, 1120, 1300 and 1500px: one line each, no clipped
half-links, buttons untouched. node --test site/*.test.mjs passes.
2026-10-13 18:27:27 +08:00
yetone f64d9312ff site, docs: a Privacy page lists everything magpie sends and how to turn it off (#1986)
#1986 asked what the daily count sends, where the id lives and how to stop
it. The answer was spread over one README paragraph and the reference. A
new page, /docs/privacy (en, zh, ja), lists it from the code:

- the daily PostHog batch (internal/stats): a whole example, the label
  rules for agents/providers/models, partner counts, the
  $process_person_profile:false flag;
- every switch: Settings -> Privacy's two toggles, noStats/noUsageStats,
  DO_NOT_TRACK / MAGPIE_NO_STATS, noAutoUpdate (About -> Automatic
  updates), and that a change applies at the next hourly look;
- the files: install-id (made at the first send, not at first run, as the
  issue said) and stats-sent in settings.Dir(), partner-counts.json in
  the cache folder, their paths per OS and portable, and deleting them;
- what usemagpie.ai sees whatever the settings (update feed every 6h,
  notes, partner list with its 1-in-10 sampled count, /go links, the icon
  proxy) and the Cloudflare Web Analytics on the site's own pages;
- public lists fetched (models.dev, open.er-api.com, npm, GitHub) and
  providers' quota reads with the user's own accounts;
- OTLP export, off by default, its env vars;
- why the count stays on by default in releases.

Every docs page in all three languages gets a Privacy link in its nav and
footer. README (en, zh) and start.html's "What does magpie send about
me?" (en, zh, ja) link to the page. docs/reference.md's Files list gains
install-id, stats-sent and partner-counts.json, and Counting users says
when the id is made, the hourly try, and links the page.

Checked against: internal/stats/stats.go, usage.go,
provider/partner_events.go, settings (NoStats, NoUsageStats,
NoAutoUpdate, UpdateEvery 360, otel.go), appdir, update, fx, catalog,
site/worker.js, and the GUI's Settings tabs/labels in index.html, app.js
and i18n.js (zh, ja).

Run: Playwright (Chromium and WebKit) on all three pages at 1100 and 420
wide, light and dark: no horizontal scroll, no element past the viewport,
no page errors (24/24), screenshots looked at for zh at 420 dark. Every
href/anchor in site/public/docs resolves; relative links in README and
reference resolve. node site/worker.test.mjs passes.
Not run: the page on the deployed worker (the site deploys by hand with
wrangler, so it is live at the next deploy); the language redirect for
/docs/privacy was not exercised beyond the worker's existing tests.
2026-10-13 18:02:01 +08:00
yetone 9e76fcdc68 plugin, cli, gui: a plugin's "password" question is typed unseen, as an API key is (#1982)
A sign-in method's prompts could only be "text" or "select", so a token a
plugin asks for (the Qoder plugin's PAT sign-in, magpie-community/plugins#103)
showed on screen as it was typed, in the app and in `magpie plugin login`.

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

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

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

Not tried: a real Qoder PAT through the community plugin (its PR isn't
merged), and the CLI on a real Windows console (term.ReadPassword is the
same call `magpie plugin login` already uses for an API key).
2026-10-13 18:01:20 +08:00
yetone 12ecb6d8e9 gateway: a gateway key held to a budget, models or accounts is told none of this magpie's accounts, only its own limit and routes (#1981)
321sssrt-bit shared magpie on the LAN with a gateway key held to a budget,
and that key still read every account's quota and balance. A held key
(heldKey: a budget, models or accounts) is someone else's to use, so it
now gets 403 with code gateway_key_held (refuseHeld) on
/v1/magpie/quotas, quotas/history, quotas/cards, POST quotas/refresh and
/v1/magpie/concurrency. That holds from loopback as well as the LAN, the
same as usageSummary already did. /v1/magpie/route tells it only the
routes of its own requests. Route.callerKey is set by trace.beginFor at
all five begin sites, so a route begun without it fails closed. It still
reads its own limit at /v1/magpie/limit. Unrestricted keys and the local
owner are unchanged.

Client side (remote magpie): a 403 gateway_key_held drops the cards kept
from before and shows only the key's own card, instead of "isn't shared".
The cache is now keyed by provider and key (remoteCardsID), so a changed
key never shows what the old one was told, and keepRemoteCards keeps a
read only over one asked before it, so a slow pre-held answer can't bring
cards back.

Decided against letting an account-held key see its own accounts' cards:
that would still show the host's account email and balance to the key's
holder.

Run:
- New TestHeldKeyToldNoAccounts covers keys held by budget, models and
  accounts plus one held to nothing, from 127.0.0.1 and 192.168.1.9.
  Every route goes red with the refuseHeld calls or the route filter
  removed by hand.
- New TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard goes red with the
  errKeyHeld mapping removed. TestRemoteMagpieCardsKeptByKey goes red with
  the cache keyed by p.ID alone.
- gofmt -l and go vet (darwin, linux -tags nogui, windows) are clean.
- go test -tags nogui ./internal/gateway ./internal/provider -count=1
  passes in a sandbox HOME.

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

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

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

What wasn't: no real launch agent was loaded on a Mac (deliberately: never
on this machine), so launchd's own acceptance of the plist is checked
only by plutil. The linger advice was checked by the unit test, not seen
from a real SSH login. Windows was not run beyond vet.
2026-10-13 17:05:59 +08:00
yetone eba7187368 gateway, provider, cli, gui: a group can route By weight, each member's share set beside it (#1910, DD on Discord)
DD asked for weighted round robin as a group routing, next to In turn.
A provider's keys could already route by weight (#841). Groups could not.

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

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

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

Not tried: real accounts through a running gateway. The routing is
proven by the plan-level test with synthetic providers only.
2026-10-13 13:10:30 +08:00
yetone e528aeb3ce agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (03a01a548):

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

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

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

Reported-by: foobra
2026-10-13 10:57:32 +08:00
yetone d4c2512d2d usage: apps report their own calls with POST /v1/magpie/usage/requests, backfill included (#1874)
What changed
- POST /v1/magpie/usage/requests (internal/gateway/usage_ingest.go) takes
  one record or an array, in usage.jsonl's shape:
  - the post may carry up to 5000 records and 32 MiB;
  - t, agent, provider, model and rid are required.
  Each field is checked: unknown fields, quoted numbers, negative or absurd
  counts, a status outside 100-599, a cost over 10000 USD, and a t more
  than an hour ahead or before 2000-01-01T00:00:00Z. Any fault refuses the
  whole post with a 400 that names error.index and error.param, and nothing
  is written. A past t is otherwise taken as given, so history can be
  backfilled. The reply gives accepted and skipped counts and each
  record's index, rid and status.
- Access: lanGuard's rule (this machine, or another with a key while
  shared, behind the Host check). A browser page also needs a key, since
  corsGuard lets localhost pages and Origin null through. A held key is
  refused.
- usage.IngestReported writes under usage.mu to the same file as
  usage.Append. Rows carry source "reported" and no caller key. A rid
  already reported is skipped, as is one repeated in the post. The set of
  reported rids is read back from the log: one scan after a restart (lines
  without the reported mark aren't parsed), then only what was appended.
- Pricing: a record with cost keeps it (Record.OwnCost, the rowOwnCost
  flag; packed flags widened to uint16). Otherwise it is priced at
  magpie's prices.
- Display:
  - SourceReported is a source of its own: RequestPage.Reported,
    ?via=reported, and Ledger now honours via.
  - The Requests tab gains a fourth cell "reported by apps", shown once
    there are some, and a "Reported" badge (en, zh, zh-TW, ja, de).
- Nothing live: Record.IsReported keeps reported rows out of:
  - a key's budget/spend limit (budget.counts);
  - window holds, and the log start that decides whether a window can be
    reckoned (logSnapshot.firstOwn);
  - gateway sessions and Vias;
  - Codex's sealed answers and remembered model.
  There is no OTel span, rate limit, rest or alert for them.
- Docs: gateway-sessions.md, reference.md (with a curl), integrating.md,
  site integrate.html (en, zh).

Why: the reporter's apps call vendors directly, and their usage (and
history) should show on the Usage page without becoming live traffic.

Run, in a worktree with sandbox HOME and a private GOCACHE
- gofmt -l: clean.
- go vet ./...: darwin, GOOS=linux -tags nogui, and GOOS=windows.
- go test internal/usage, usageapi, budget, gateway, gui: ok.
- -race -count=3 of the new usage/gateway tests: ok.
- GUI with playwright 1.62.0:
  - usage-ledger-reported.test.cjs, 26/26 in chromium and webkit (5
    languages, 1180 and 420 wide, light and dark);
  - usage-ledger*.test.cjs, ledger-*.test.cjs, usage-sum-whole,
    usage-unpriced-sum and i18n-keys: all pass.
- Timings with 200k reported rows (47 MB log, darwin):
  - 40 posts of 5000 took 0.40 s (worst batch 18 ms);
  - the first post after a restart took 0.45 s (rid rescan), a later one
    1.6 ms;
  - the cold index build took 2.1 s (as for gateway rows);
  - page all took 27 ms warm, page 30d 39 ms, all via=reported 0.53 s;
  - summary all took 215 ms, 30d 20 ms.

Broken by hand, each went red, then restored
- Go: dedupe against stored rids; the restart scan; CostAt ignoring own
  cost; the block pricer overwriting own cost; the Reported split;
  fromBrowser's key rule; skipping bad records instead of refusing; the
  max-records and body limits; the ingest lock (race); both locks;
  firstOwn -> first; the IsReported guards in windowHolds,
  buildGatewaySessions, buildVias, budget.counts and loggedAnswers.
- GUI: the fourth cell, the --vias column count and the badge class.

Not shown red on its own: the remote-no-key and evil.example refusals come
from lanGuard and corsGuard before the handler, so breaking only the
handler's own check stays green. The codex_memory guard is not tested
alone: a reported row has no Requested there anyway. Not tried: a real
client against a live gateway, Windows/Linux runs of the tests, the full
GUI suite.
2026-10-13 06:32:03 +08:00
yetone 5756651e3b readme: the architecture diagram shows each agent's and provider's real logo
The owner asked for real logos on the agents and the models. Each agent
row now carries its own mark (Claude Code, Codex, Gemini CLI, OpenCode),
the "+ 40 more" row shows Zed, Cursor, Cline and Goose, and every
provider name sits behind its logo (DeepSeek, Kimi, GLM, OpenRouter;
Claude, ChatGPT, Copilot, Gemini; Ollama, LM Studio). The marks are
inlined from internal/gui/assets/icons, the same files the GUI shows,
with their gradient ids prefixed per use so the four copies don't clash;
monochrome marks follow the theme's ink. Text and chip widths are now
measured from SF Pro rather than estimated per character.

Run: rendered all four SVGs in headless Chrome on #fff and #0d1117 at
2x and at the README's 880px width; no overlaps, every logo resolves.
2026-10-13 04:25:02 +08:00
yetone 77a3deaed2 readme: the architecture diagram is a drawn picture in both themes, not a mermaid flowchart
The mermaid "How it fits together" / 整体结构 chart rendered as grey
boxes in GitHub's default style. It is now four hand-made SVGs
(en/zh × light/dark) under site/public/img/architecture*.svg, shown
through <picture> with prefers-color-scheme:
- agents on the left (the 40+ others as a dashed row), providers on the
  right, joined by curves into one magpie card;
- the magpie card is inverted (black in light, near-white in dark), with
  the logo, 127.0.0.1:3425 in a mono face, and the gateway → routing
  groups → plugins stages on a rail, the four protocols as chips;
- system font stacks only, since an SVG in <img> loads no web fonts.

Run: rendered all four in headless Chrome on GitHub's backgrounds
(#fff, #0d1117) at 2x and at the README's 880px width; checked no text
overlaps or is clipped and the shadows aren't cut by the viewBox.
Both READMEs no longer contain a mermaid block. Docs-only.
2026-10-13 04:20:41 +08:00
yetone 5c82e6880d site: every sponsor link goes through usemagpie.ai/go, so its clicks are counted per place
The home page's "Sponsored by" cards and the READMEs' Sponsors logo linked
the sponsors directly, so nothing told the owner how many clicks each seat
brought. They now link /go/<id>/home and https://usemagpie.ai/go/<id>/readme.
site/sponsors.js holds where each sends the browser (the sponsor's own ref
link, unchanged: APINEBULA has one per place). The worker counts a GET as
"magpie sponsor go" {id, where, country} in PostHog, beside the in-app
partners' "magpie partner go" (whose /go links were already counted), and a
HEAD goes on uncounted. A partner's keys/site links are tried first; a
sponsor link takes no region.

A test fails if index.html or either README links a sponsor's own URL
directly, or names a /go link sponsors.js doesn't have.

Run: node --test site/worker.test.mjs (20 pass) and site/install.test.mjs
(10 pass). Broke it by hand: README.zh-CN.md back on the direct link turns
the guard red. Deployed (version e4f40cff); curl on usemagpie.ai:
/go/apinebula/readme → 302 apinebula.ai/ref/qmXqFGpr, /go/apinebula/home →
302 apinebula.ai/ref/Gs54HwyB, /go/yylx/home → 302 yylx.io/?ref=magpie,
/go/yylx/readme and /go/apinebula/home/x → 404; / and /zh/ serve the /go
hrefs. Not checked: the events arriving in PostHog (the worker's key can't
read).
2026-10-13 03:29:22 +08:00
yetone 7a9490638d gateway, gui, settings: an IP / CIDR allow list for the gateway, from MAGPIE_ALLOW_IPS or Settings beside Share on local network (lc on Discord)
What changed: lc runs magpie in Docker on a public host and asked that
only some addresses reach it at all. With a list set, a request from an
address outside it is refused 403 ("magpie answers only the addresses on
its allow list ..., and this request came from <addr>: add it there to
let it in") before its gateway key is looked at, so a leaked key is no use from
elsewhere. No list is as before.
- internal/settings/allowips.go: SplitAllowIPs, ParseAllowIP (an IP or a
  CIDR range, v4 or v6; zones dropped, v4-mapped unmapped), CleanAllowIPs.
  Settings gets AllowIPs (allowIPs).
- internal/gateway/allow.go: MAGPIE_ALLOW_IPS (comma or space separated)
  sets the list in place of Settings'. The address judged is the
  connection's own (r.RemoteAddr); X-Forwarded-For and the rest are never
  believed (magpie has no trusted-proxy list; MAGPIE_TRUST_PROXY never
  reads forwarding headers, and this follows it). Loopback and this
  computer's own interface addresses always pass. An entry that doesn't
  read lets nothing in and is logged once, so a typo never opens magpie
  to every address. lanGuard checks it after the OAuth callback and
  before the rebound-Host and key checks; `magpie web` is wrapped with
  AllowGuard too.
- GUI: Settings > Network shows an "Allowed addresses" row under Share on local
  network when sharing is on, the page is open from another computer, or
  the env var is set (then read-only, saying so). POST
  /api/settings/allowips saves it, refuses it while the env var is set,
  refuses an entry that doesn't read, and refuses a list that would shut
  out the address the page itself is open from (KeepsOut). The generic
  settings save keeps AllowIPs. Strings in zh, zh-TW, ja and de.
- Docs: the Docker page (en, zh, ja) lists MAGPIE_ALLOW_IPS with a note
  that a request from the host itself arrives from the bridge's gateway
  (172.17.0.1), that Docker Desktop and rootless Docker show clients as
  one address of their own, and that behind a proxy every request comes
  from the proxy; docs/reference.md and docs/subsystems/gateway-routing.md
  describe it. The READMEs list no env vars, so they are unchanged.

Why: a gateway key is the only lock on a public host; an allow list keeps
everyone else from even trying it.

Run (machine load average 75-140 from other sessions, so the large
packages ran in slices of their top-level tests, each slice
-timeout 9m, private GOCACHE, sandbox HOME):
- New tests: internal/gateway/allow_test.go TestAllowList (allowed,
  denied, CIDR v4/v6, IPv6 literal, link-local with zone, v4-mapped,
  loopback and own address always in, on the list still needs a key,
  a typo shuts everything out, env over settings), TestAllowListServed
  (a real connection from loopback passes lanGuard under a list naming
  nothing of this computer's; a request from elsewhere is 403 naming its
  address and MAGPIE_ALLOW_IPS), TestKeepsOut; internal/settings/allowips_test.go
  TestCleanAllowIPs; internal/gui/allowips_settings_test.go
  TestAllowIPsSetting; internal/gui/tests/allow-ips.test.cjs (14/14 in
  chromium and webkit, at a 390px panel, en and zh, keys in zh, zh-TW,
  ja and de). Broken by
  hand: with lanGuard's check removed TestAllowList and TestAllowListServed
  FAIL; with KeepsOut skipped TestAllowIPsSetting FAILs; with renderAllow
  not called the GUI test has 5 failures. Restored, all pass.
- internal/gui/settings_keep_test.go gains AllowIPs:
  TestSettingsSaveKeepsWhatItDoesNotSend failed without it, as it should
  for a new field.
- go test -tags nogui: every package ok. internal/gateway (4 slices),
  internal/agent (4), internal/provider (3), internal/gui (2),
  internal/plugin (2), the rest whole. GUI Network-settings test files
  (11) 98/98 and i18n-keys ok, both engines.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... ok; linux and windows builds ok.
- Not tried: a real Docker container on a public host (the bridge note
  is from Docker's docs, not checked here); behind a real reverse proxy.
2026-10-12 23:21:41 +08:00
yetone 908c910931 gateway, gui: Stays: Strict keeps a conversation on the account or key that answered it, even past its cap, and passes its error on rather than moving it (#1797)
miniers asked that a conversation never move to another account: a
move changes the account a vendor sees mid-conversation and loses its
prompt cache. Session affinity keeps the account while it can answer,
then moves on.

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

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

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

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

Known and left: planLevel doesn't merge a nested group's sub.held, as
before this commit.
2026-10-12 23:16:54 +08:00
yetone 0738154520 plugin, gui: an installed plugin's row and page show its own magpie.icon, not its first provider's (#1775)
peterroe's plugin signs in to several providers. Each provider gets its own
picture from the auth hook, and package.json's magpie.icon is the picture
for the plugin itself. Settings → Plugins → Installed only took a plugin
picture from the market listing. A plugin that isn't listed (installed from
a path, git or an unlisted npm package) had none, so its row and its page
showed its first provider's picture.

- plugin.InstalledIcon reads magpie.icon from the installed package.json.
  It goes through the same ownIcon check as a listing's icon (data: or
  https only).
- pluginsState stores the picture through provider.RepoIcons, as listed
  plugins' pictures are, and returns it as `icon` on each plugin entry.
- plugins.js: the installed row and the detail page use the listing's
  icon, then the plugin's own, then its first provider's, as before.
- Docs (en, zh, ja): magpie.icon is the plugin's picture (Discover card
  and Installed row) and the fallback for providers without their own. A
  plugin of several providers gives each provider auth.icon.

Run:
- go test ./internal/plugin ./internal/gui: ok.
  TestPluginsStateGivesThePluginsOwnIcon covers a data: icon (kept), no
  icon and a plain-http icon (both "").
- internal/gui/tests/plugin-own-icon.test.cjs: Chromium and WebKit, en,
  zh, zh-TW, ja, de, at 980 and 420 wide. It fails on the old plugins.js
  (the row shows pa.png).
- The plugins GUI tests: 34/34 in each engine.
- gofmt; go vet darwin, windows, and linux -tags nogui.
- Full go test ./...: the only red is gateway OTel timing under load ~79.
  That's #1794, commented there; alone it passes 3/3.

Not tried with peterroe's real package; the fixture follows the layout
the issue describes.
2026-10-12 19:38:20 +08:00
yetone bfaedf1830 gui, profile: the profile in use is ticked and named on the panel's Profiles button, not a count read as its name (superhtoooth on X)
superhtoooth (macOS): 保存方案设置了方案名字,但是应用方案没有用这个名字。
menu 里面变成了方案 1,方案 2。而且在应用里面没有显示当前使用的方案.

The bug: the tray panel's Profiles button showed the number of saved
profiles next to its label ("方案" + "2"), which reads as a profile
named 方案 2. Profiles were saved and applied under the typed name all
along; nothing anywhere said which profile was in use.

What changed:
- profile.InUse: a profile is in use while applying it would change
  nothing on this computer - every detected agent's saved field is as
  the profile has it (compared with the same renamed-ref spelling Apply
  writes), its model lists are held (provider.ModelListsHeld, a dry run
  of SetModelLists via the extracted putModelLists) and its library
  setup is as saved (library.Holds, the mirror of Restore). A profile
  that touches no agent here is not in use.
- Why not "last applied": that would stay ticked after the user changes
  a model by hand, a tick that lies. With this definition a profile
  saved from the current setup is in use at once, a hand change clears
  the tick, and applying puts it back. Two identical profiles are both
  ticked; the button names the first.
- GUI: /api/state carries inUse. The panel's button names the profile
  in use (a pop-up button showing what is picked), else counts them as
  before; its chip gets a check mark and aria-current, in panel and
  window; the chip's tooltip and its details say "In use" (string
  already in every language). CLI `magpie profiles` marks it, the TUI
  notes "in use". Docs (reference, start en/zh/ja) say so.

What was run:
- go test ./internal/profile (new TestProfileInUse: save, hand change,
  apply, hidden model list, library instructions, absent agents) and
  ./internal/gui (new TestStateProfileInUse through the HTTP handler),
  scratch HOME. Broken by hand: field compare, ModelListsHeld,
  library.Holds and state's InUse each turned a test red.
- go test -tags nogui ./... in a scratch HOME (the four slow packages
  rerun with -timeout 40m under load ~45).
- GUI: new profile-in-use.test.cjs (reporter's steps in the panel at
  360px, every language, plus the window) and panel-profiles,
  profile-confirm, profile-details, old-webkit, i18n-keys, gui-zh-tw,
  gui-ja, gui-de in chromium and webkit: all pass. Old app.js fails the
  new test.
- Real CLI in a sandbox HOME with a codex config: save/use/profiles
  show the mark, and it goes after a hand edit.
- gofmt; go vet darwin, linux (nogui), windows.
Not tried: the real tray app with real agents, and Windows/Linux at
runtime.
2026-10-12 19:14:54 +08:00
yetone 217d2f8f20 site, readme: APINEBULA joins the sponsors, a card on usemagpie.ai and a small logo under the README badges
APINEBULA paid for the website seat and the en/zh README seat. The logo is
the SVG they sent (143x37). A white-text copy is used on dark backgrounds,
through .for-light/.for-dark on the site and <picture> in the READMEs (the
.bird invert would turn the orange mark blue). The site's sponsor cards now
stack in an equal-width grid, so the two cards line up; the intro has zh, ja
and de strings.

Run: site worker and install tests (28 pass). The home page served locally and
checked in chromium and webkit, at 1200 and 390px, light and dark, in en/zh/ja/de
(dictionary applied in the page): both logos load, the right one per theme,
and there is no horizontal scroll.
2026-10-12 18:05:26 +08:00
yetone 0fcf563e61 routing: a pause rule can hold by folder, in some or outside them (#1606, Ti800)
Ti800 keeps a subscription's quota for one long task in one folder and
wants every other request kept off it (their option A). A pause rule
held by hours, days and agents only; it now holds by folder too.

What changed
- provider.Rule gains ExceptFolders (json exceptFolders, CLI
  except-folders=, aliases except-folder/not-in/outside): the folder the
  agent works in is in none of them. An agent that says no folder isn't
  known to be in one, so except-folders holds for it; folders= still
  never matches an unknown folder. Both conditions are allowed on send-to
  and pause rules (Rule.ByFolder, inFolders); cleanRules cleans and
  dedupes both and lets a pause hold by time, days, agents and folders.
- PausedOut takes the request's folder. The gateway reads it (workDir)
  only when a pause by folder is on the way (PausesByFolder); embeddings
  and System One's decision calls pass none. Paused carries Folder and
  ByFolder for the trace. ruleFor reads the folder for except-folders
  rules too.
- Group sharing drops every rule by folder, except-folders included.
- CLI usage, TUI hint, ParseRule/Line round-trip except-folders.
- GUI: the rule editor has a "not in folder" condition beside "in
  folder", both shown on a pause and kept when a rule turns into one; a
  folder that isn't a whole path and a pause with no condition are
  refused; the group's rule and the trace say "not in …", and a paused
  reason says the folder read or that the agent said none. Strings in
  zh, zh-TW, ja, de.
- Docs: gateway-routing.md, site start.html (en, zh, ja).

What was run
- go test -tags nogui ./internal/provider ./internal/gateway (folder,
  pause, share, rule tests); full go test ./... before pushing.
- Broke it by hand: with the gateway's folder read replaced by nothing,
  TestPauseByFolder fails (in-task requests went to the other member).
- GUI: routing-pause-folder.test.cjs (new), routing-pause,
  routing-folder, i18n-keys and 10 other rule-editor tests in Chromium
  and WebKit, en/zh/zh-TW/ja/de, at 1100px and 390px.
- gofmt -l; GOOS=linux and GOOS=windows go vet of the touched packages.

Not tried: a real Claude Code subagent's request against a live group;
by the documented rule a request without a folder is paused off the
kept member, which is what the reporter asked for.
2026-10-11 21:24:10 +08:00
yetone 6f1b432759 provider, gui: smart routing spends WorkBuddy credits that expire soonest first (cdredfox on X)
WorkBuddy's Credits window had no reset, so in a Smart group every
WorkBuddy account ranked alike. workbuddy plugin 0.1.14 (plugins f0274d6)
reads WorkBuddy's own package lists (billing/meter/get-user-resource-paid-
packages and -free-packages, the calls WorkBuddy's client makes) and reports
on the Credits window when the soonest-ending package that still has credits
ends (runsOutAt) and how many credits it holds (runsOut). The daily Free
Plan slice (CapacityType 4) and code 001 aren't counted: they renew daily.

magpie carries runsOutAt from the plugin's usage window into QuotaWindow and
the routing Limit. Allowance.Renewal, which only Smart ranks on, treats it
as the window's reset when it is sooner than the real one. Pace, the tiers,
For, Full and resting are unchanged. The mover's min is raised to 0.1.14 so
moved users get the plugin. The usage card and account meter say "232.4
expire in 5h" in every language.

Run:
- plugin: bun test, 63 pass; 2 of the 3 new tests fail on 0.1.13's
  index.mjs. Verified live on a workbuddy-ai account in a sandbox HOME:
  Bonus Pack 232.4 left ending 10-12T16:39Z ranked before Pro (10-28).
- TestWorkBuddyCreditsRunOutForRouting and
  TestSmartSpendsWorkBuddyCreditsRunningOutFirst: both fail with the
  Renewal change removed by hand.
- GUI: credits-run-out.test.cjs in webkit and chromium, 5 languages, at
  360/440/1000px, red on the old app.js; with i18n-keys, quota-*,
  panel-usage, reset-each-title, usage-fold: 117 pass.
- go test ./... green (agent and gateway rerun with -timeout 30m after the
  default 10m ran out under load from other sessions; 378s and 492s).
- gofmt -l clean; GOOS=linux and windows go vet of provider, plugin,
  gateway clean.

Not tried: the CN workbuddy site (its token was stale, 401), so the CN
package list is assumed to have the same shape. The built-in WorkBuddy
(not moved users) doesn't get this. The account-line tooltip has no GUI
test of its own.
2026-10-11 20:07:19 +08:00
yetone 35eea09464 gateway: a provider routed its own way keeps that order inside a group that routes another way (kchen0x on X)
kchen0x had a Smart routing group with Antigravity (9 accounts, set to
按顺序) and a Business account. Requests still went to the 9th account, the
one renewing soonest. planLevel pooled every member's keys and accounts
into one list for any group not routed in order, so the provider's own
routing was never read; Smart then put the soonest renewal first.

Now a member whose provider routes other than Smart, and other than the
group does (ownRouting), is planned as a nested group already is: a unit
weighed by the first account or key it would try (firstAwake), then tried
whole in its own order. A provider left on Smart is pooled as before.
leastHeld, which reorders a rotate group's first request, leaves such a
group alone as it does one holding a nested group (without that, a
rotate group still came back "k2 k1 k3 kb").

GUI hint (GROUP_NEST, 4 languages), start docs (en, zh, ja) and
gateway-routing.md say so.

Run:
- TestProviderKeepsItsOwnRoutingInAGroup covers outer Smart, rotate,
  usage, pace and manual, plus a Smart provider still being pooled. On
  the old planLevel it fails with "k3 k2 k1 kb" (the reported order).
- go test -tags nogui -count=1 -timeout 40m ./...: all ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/gateway.
- GUI: i18n-keys, gui-ja/de/zh-tw and every *group*/*routing* test, both
  engines: 765 pass. A first run beside the full go test had 9 webkit
  timing reds (routing-group-fold, routing-keys-fold, routing-ctx-still,
  gateway-key-groups); each file passes alone, and the whole set passes
  when nothing else runs.
2026-10-11 19:54:55 +08:00
yetone 642bea3a99 gui, tui, provider: Remote magpie has a heading of its own in the Add sheet, Another computer's magpie, after On this machine, not among the Relays (Avalon on Discord)
Avalon on Discord (v0.1.1168): "供应商添加中没有Remote magpie 的选项". It was
there, filed under Relays (中转), where nobody looks for another computer's
magpie, since it isn't a relay.

The preset is now of its own kind, KindRemote ("remote"), declared after the
local presets. Kind only groups presets for display: the GUI's add sheet,
`magpie presets` and the TUI's add list; makerCatalogs (vendors only) and
the import matcher (skips local) are unchanged for it, as it has no URL.
- GUI: a fourth section after On this machine, "Another computer's magpie"
  / "shared on its network" (zh 另一台电脑上的 magpie / 在它的局域网上共享,
  zh-TW, ja, de too). A preset's note is now also found in the words it is
  shown in, and the zh/zh-TW/ja note begins with 远程/遠端/リモート, so 远程
  finds it as remote and magpie do.
- TUI: the add list says "Remote magpie · another computer's magpie, shared
  on its network" instead of "· relay" (kindNote).
- CLI: `magpie presets` lists it under "another computer's magpie".
- Docs: reference.md, subsystems/providers-accounts.md and the site's
  remote page (en, zh, ja) say where the tile is.

Run:
- remote-magpie.test.cjs gains "Remote magpie has its own heading in the
  add sheet" (420px, en and zh, Chromium and WebKit): the heading and hint,
  right after On this machine, Remote magpie under no other heading, no
  sideways scroll, and remote / magpie / 远程 each find it alone under its
  heading. With the old app.js it fails "no heading of its own" in both
  engines and languages; with only the note search taken out, zh fails on
  远程. Its older test now wheels the sheet to the tile (now the last row;
  a scroll from code is put back by the page's guard, which made it flaky
  in WebKit at 700px): 8 of 8 WebKit runs green.
- TestTUIAddListSaysRemoteMagpieIsAnotherComputers fails on the old note
  with `listed as "Remote magpie · remote"` (and "· relay" before the kind).
- Every GUI test that opens the add sheet (40 files) plus gui-de, gui-ja,
  gui-zh-tw and i18n-keys, in Chromium and WebKit: all pass.
- site worker.test.mjs passes.
- gofmt -l clean; go vet -tags nogui on ., internal/provider, internal/tui,
  internal/gui for darwin, GOOS=linux and GOOS=windows.
- go test -tags nogui -timeout 40m ./... under a temp HOME: all 48 packages ok.
Not tried in the real Wails window.
2026-10-11 15:21:18 +08:00
yetone c05dd8b6fb provider: Tencent Cloud has Token Plan 企业版 as a region, Enterprise plan · China and · Global (#1574, undirectlookable)
#1574 asks for Tencent Cloud Token Plan's usage through TokenHub's
DescribeTokenPlan API (api/1823/132270). That API covers Token Plan
企业版, the team plan, only. magpie's Tencent Cloud preset knew the
personal plan (api.lkeap.cloud.tencent.com/plan) and TokenHub's pay as
you go, not the enterprise plan, so a provider at it had nowhere to sit.

The preset gains two regions, after the old three so imports and links
are unchanged:

- enterprise: https://tokenhub.tencentmaas.com/plan/v3 (chat completions
  and Responses) and /plan/anthropic, Guangzhou.
- enterprise-intl: the same paths on tokenhub-intl.tencentmaas.com,
  Singapore.

Both use the plan's docs (product/1823/130659, 131173 for the 轻享套餐,
same endpoints) and the Token Plan console as the key page. Their model
lists are the doc's tables for each site, with the three GLM models it
says went away on 2026-10-09 left out, and without the deepseek/… ids.

An entry imported at those endpoints, a magpie://import link with
region=enterprise(-intl) and a provider moved there in the editor land
on the region; TokenHub's pay as you go at the same hosts stays at its
own. The site's import pages (en, zh, ja) list the two regions, and the
region names are translated in zh, zh-TW, ja and de.

Run: go test ./internal/provider (TestTencentCloud,
TestTencentCloudEnterprisePlan, red before the regions), gofmt; GUI
tencent-cloud.test.cjs in Chromium and WebKit, en and zh, 8/8.
Not tried with a real enterprise plan key: we have no Tencent Cloud
account.
2026-10-11 13:06:28 +08:00
yetone ae70d8eac8 routing: a group's rule can hold by the folder the agent works in (Cario0x on X)
Cario0x on X asked to route by the project being worked on. A group's rule now has a
"folders" condition: it matches when the request's working folder is one of the listed
folders or inside one. It combines (AND) with the existing conditions: tokens, images,
intent, time, agents and quota.

- gateway/workdir.go reads the folder each agent states in its own request:
  - Claude Code: "Primary working directory", including "(was …)" after a move.
  - Codex: <environment_context><cwd>.
  - Pi: <cwd>.
  - OpenCode: <env> "Working directory".
  The last one stated wins. Assistant text and tool results are ignored. A request
  that states no folder matches no folder rule: unknown, never empty.
- provider/rulefolder.go matches a folder only at a path boundary.
  - ~ is the home folder.
  - C:\x is the same folder as /mnt/c/x, and \\wsl$\Distro\x as /x.
  - Case is ignored on macOS and Windows, and always for a drive.
  - A rule's folder must be a whole path. Pause rules can't have folders.
- The trace's RuleHit.Folder makes the Routing page say "The agent works in …".
- GUI: an "in folder" condition in the group editor, hidden on pause rules. Strings in
  zh, zh-TW, ja and de.
- CLI: `magpie group rule add … folders=~/oss,"~/My Project"`. The TUI shows the
  condition.
- Docs: docs/subsystems/gateway-routing.md and site start.html (en, zh, ja).

Fixtures are real requests from Claude Code 2.1.296, Codex 0.162.0 and Pi 1.1.0, run in
a sandbox from a folder named "a&b <c> 中文" or "My Proj", with the sandbox path
replaced.

Run at this head:
- go test ./... green.
- gofmt -l clean.
- go vet green for darwin, GOOS=linux -tags nogui and GOOS=windows.
- GUI routing-folder.test.cjs: chromium and webkit, en, zh, zh-TW, ja and de, 1100px
  and 390px (no horizontal scroll). It fails on the old routing.js.
- Related routing, group and i18n GUI tests: 85/85.
- Full GUI suite: 5611/5631 under --test-concurrency=6. Rerun alone, every failure
  passes except:
  - skill-install-agents-all (chromium, 420px), which is red on origin/main too: #1554.
  - The menu-scroll track flake, which flakes on main as well: #1550.
- e2e: a sandbox HOME, a dev build and fake upstreams, with real Claude Code 2.1.296
  (`claude -p --model group/fd`).
  - From proj/acme/web, rule 1 matched and the request went to kb.
  - From proj/acme-old, no rule matched and the request went to ka. The trace and UI
    showed the folder.
2026-10-11 10:17:16 +08:00
yetone 26816de2f9 library, agentplug: an agent a plugin adds is given the Library's instructions, MCP servers and skills where its agent.library says (AlmarionAI on X)
Agent plugins wired models and keys only: library.targetOf had no case
for them, so the Library's instructions, MCP servers and skills never
reached an agent a plugin adds, while the announcement said the
Library carries over.

An agent export can now say
  library: { instructions, mcp, mcpFormat, skills }
each a path (~ and $VAR expanded, as config is). mcpFormat names the
agent whose MCP file it is shaped like (agentplug.MCPFormats: claude,
codex, gemini, opencode, cursor, zed, ... 18 of the library's
mcpFormats). A format outside the list, or an mcp without one, keeps
the plugin from loading. library.pluginTarget makes such an agent a
Target, so it is written as any agent is: magpie's marker block in the
instructions file, servers merged beside the user's own (their fields
kept), skills linked or copied, Applied recording only magpie's part,
backups kept. Takes refuses a place the plugin doesn't name, and says
which agent.library key would give it.

Docs: docs/subsystems/library.md and agent-wiring.md; plugins.html
(en, zh, ja) gets the library field and what magpie does with it.

Run:
- internal/library/agent_plugin_test.go: TestPluginAgentGetsTheLibrary,
  TestPluginAgentWithoutAPlaceIsRefused, TestPluginAgentMCPFormat,
  TestPluginMCPFormatsAreWritten. With targetOf's plugin case and the
  check() validation taken out by hand, the first three go red.
- e2e: a nogui build in a scratchpad HOME (env -i, no live configs),
  `magpie plugin add` of a throwaway toy agent plugin; `library
  instructions set/agents`, `library mcp add/rm` wrote and took back
  only magpie's block and server, the user's "mine" server, its "note"
  field and other keys kept, backups made; with mcp dropped from the
  plugin, `library mcp add ... agents=toy` is refused naming
  agent.library.mcp.
- go test -tags nogui ./... (one unrelated FIFO flake in internal/agent,
  fixed in the commit before), gofmt -l clean, go vet for GOOS=linux
  and GOOS=windows clean. No GUI code changed.
2026-10-11 07:55:23 +08:00
yetone 8c5b9f928d provider, agent, gui: subscription accounts can be turned off, and then no agent's sign-in is read (#1535, MaxHaiCom)
What changed: Settings → Privacy → Subscription accounts (On/Off),
`magpie accounts discovery [on|off]` and MAGPIE_NO_ACCOUNTS=1 turn off
account discovery. It stays on by default. While it is off, magpie reads
none of the agents' sign-ins: ~/.claude/.credentials.json, .claude.json's
account, ~/.codex/auth.json, Copilot's, Cursor's, Devin's, Kiro's,
Gemini's, ZCode's, Command Code's and OpenCode's files. It runs no
`security` / `secret-tool` for the Keychain or Secret Service, and asks no
agent CLI who is signed in. It serves no subscription. API-key providers,
middleware plugins and Pi extensions work as before.

Why: the reporter runs magpie on machines where reading other tools'
credentials isn't wanted. The owner delegated the call.

How: settings.NoAccountDiscovery (kept per computer by KeepOwn) and
settings.AccountDiscoveryOff(). The variable only ever turns discovery
off. The gates sit at every reader (readAccountFile, discoveryOff) and at
every route that reads or writes a sign-in, so a route that skips
Accounts still reads nothing:
- Accounts, All, Logins, usage, renewal, warm-up, session identities,
  check-ins;
- switching, forgetting, SetLoginOn, StartSignIn, the imports;
- moves onto plugins.
The ones that write refuse with an error that names how to turn it back
on. On the agent side, Agent.Source and OpenCode's auth.json are gated,
and Codex wiring goes by magpie's stash instead of auth.json, so a
toggle never rewires Codex. logins.json and plugin-auth.json are left
untouched and serve again when discovery is turned back on. A change
applies at once (ForgetAccounts).

Docs: providers-accounts.md, README (en, zh-CN), and the site's CLI table
(en, zh, ja).

Run:
- TestAccountDiscoveryOffReadsNoSignIn (provider) and
  TestAccountDiscoveryOffAgentsReadNoSignIn (agent). Every credential
  path is a FIFO that records each open, and security, secret-tool,
  claude, codex, cursor-agent, devin, kiro-cli, copilot and grok are fakes
  on PATH. Both fail with the gate removed: they show the opens and
  `security find-generic-password -s Claude Code-credentials`, among
  others. Both pass with the gate in place.
- TestAccountDiscoverySetting and TestAccountsDiscoveryCmd.
- account-discovery.test.cjs: chromium and webkit, 900 and 360 wide,
  en/zh/zh-TW/ja/de, 32/32. The neighbouring privacy, redact,
  settings-sections and i18n-keys GUI tests: 49/49.
- The full `go test -tags nogui ./...`, gofmt -l, and go vet for darwin,
  linux and windows on the touched packages.

Not tried: a real machine under fs_usage, and Linux and Windows at
runtime. The FIFO tests are !windows.
2026-10-11 06:38:40 +08:00
yetone f04792f906 icon: remote icons are fetched through usemagpie.ai/api/icon, so their hosts never see the user's IP
A plugin's package.json icon, an import link's icon= and the library's
market icons sit on hosts their authors pick. magpie fetched each straight
from there, so an author could log the IP of everyone who opened Discover
or the library. The owner asked for icons to keep showing without that.

- site/worker.js: /api/icon?url=<https URL> fetches the picture from
  Cloudflare with only Accept: image/* and its own User-Agent, follows
  redirects, caps it at 1 MB (the app's MaxIcon), passes on only PNG,
  JPEG, GIF, WebP, ICO or SVG (by bytes, as StoreIcon), and counts and
  keeps nothing. It refuses http, userinfo, a non-443 port and
  usemagpie.ai itself; 404s are cached 5 minutes, 5xx not at all.
- internal/iconproxy: URL(u) is the proxied address (MAGPIE_ICON_PROXY
  for tests); a picture already on usemagpie.ai is asked for as it is.
- provider.FetchIcon (plugin, import link and partner icons) and
  library.fetchImage (market icons, avatars) fetch through it. The
  import link's checks (https, public host) still come first; there is
  no direct fallback. provider.FaviconFor still reads the user's own
  provider's site directly: they already send it their requests.
- Privacy text in README en/zh, docs/reference.md and site docs
  start/import in en/zh/ja says so.

Ran:
- node --test site/*.test.mjs: 28 pass. The new test asks with Cookie,
  UA, X-Forwarded-For and CF-Connecting-IP and checks only accept and
  user-agent go upstream; 415/413/502/400 cases; its fetch stub throws
  instead of reaching the network. With the usemagpie.ai refusal
  removed by hand it goes red (27/1).
- TestFetchIconGoesThroughTheProxy and TestIconGoesThroughTheProxy
  (author host is .invalid; an httptest server stands in for the proxy):
  with the proxy taken out by hand both go red (provider: lookup
  author.invalid; library: the proxy was never asked), green restored.
- go test ./internal/iconproxy ./internal/provider ./internal/library
  ./internal/gui: ok. gofmt -l clean; go vet darwin (those four),
  linux (iconproxy, provider, library), windows (all four): clean.
2026-10-11 01:28:22 +08:00
yetone 7af45761f7 plugin, gui: a plugin from a git repository shows Update only when its repository has new commits (ARNO on Discord)
ARNO installed opencode-codearts-auth as github:yuweihao17/codearts. Its row
on Plugins always had an Update button, and still did right after updating
it to the newest commit. The page drew Update for every git plugin whatever
its commit, since npm has no version to compare for one, and nothing asked
the repository. ba0e2a8a fixed the same complaint for pinned npm plugins
only.

A git plugin is now compared by commit:
- internal/plugin/gitrev.go reads the commit Bun installed: the package's
  .bun-tag (owner-repo-<sha7> for GitHub's, the full sha for a clone),
  else bun.lock's "#<sha>". It asks where the spec's branch or tag (the
  default branch without #ref) is now: GitHub's API (commits?per_page=1
  [&sha=ref]) for github:o/r, o/r, https://github.com/o/r and
  git+https/git+ssh/git:// URLs on github.com; git ls-remote for gitlab:,
  bitbucket: and any other git URL (an annotated tag's commit, not the
  tag's). A spec pinned to a commit is that commit, asked of nobody.
  Answers are kept 10 minutes (GitHub allows 60 unauthenticated requests
  an hour).
- updates.go: the hourly CheckUpdates and the Check for updates button
  (CheckNow) report a git plugin as current or update, with its commit
  and the repository's head, in place of the old "git" status. A waiting
  git update is dropped once the installed commit is the head.
- GUI: /api/plugins/git gives the heads, asked after load and after an
  install or update. The row shows the commit installed. Update, the
  "New commits" chip, the Discover card's Update and Update all show only
  when the repository is at another commit. Five new strings are in zh,
  zh-TW, ja and de.
- Docs: the Updates list in site/public/docs (en, zh, ja) says how a git
  plugin's update is told.

Tarball specs are unaffected, since magpie plugin add refuses them as not
a package name.

Run:
- go test -tags nogui ./internal/plugin ./internal/gui (temp HOME): ok.
- New TestGitPluginUpdateOnlyWhenItsRepositoryMoved, for
  github:yuweihao17/codearts, its #main form, owner/repo, the
  https://github.com URL, git+file and git+file#main, against a fake
  GitHub API and bare repositories. After add, nothing waits. A new
  commit at the same version is an update. After Upgrade, nothing waits
  again.
- TestGitCommitAsBunWritesIt uses ARNO's literal bun.lock line and
  .bun-tag. TestGitSource covers spec parsing and the pinned-sha form.
- Broke GitBehind by hand (any installed commit is behind): the new test
  goes red in every form. Restored.
- GUI: plugin-git.test.cjs now checks no Update at the head, then New
  commits with Update and Update all once the head moves, then none after
  Update. It went red with the old condition put back. All 28 plugin-*
  files plus click-scroll, i18n-keys, gui-ja and gui-de pass in Chromium
  and WebKit.
- Real case, sandbox HOME, magpie web on a spare port: magpie plugin add
  github:yuweihao17/codearts installed c594984. /api/plugins/git and
  /api/plugins/check say current at c594984 against the real GitHub, and
  nothing is waiting. In both engines the row shows "v0.1.0 c594984" with
  no Update and no Update all.
- gofmt -l clean; go vet -tags nogui darwin, GOOS=linux and GOOS=windows
  on internal/plugin and internal/gui.
2026-10-11 01:14:19 +08:00
yetone a98ab77fde gui, gateway: a context window's part, cell or item clicked opens the text the request sent there (masaka)
masaka on Discord asked to see the whole context behind the context window
card: click the agent's prompt, or any other part, and read it.

What changed:
- gateway: the trace keeps the last 10 request bodies in memory only
  (promptBodies; at most 32 MiB each and 64 MiB together, oldest dropped
  first), masked as the vendor got them. For a model the user let have
  the request unmasked, the masked copy is kept all the same. Never
  written to disk, never in telemetry. Route.Prompt and the routing
  history keep names and sizes only, as before.
- gateway: Server.PromptText re-reads a part's items and their text from
  that body (prompt_text.go). promptBuilder gains a keep mode that records
  each item's pieces: system text, tool definitions laid out as JSON, each
  turn's user/thinking/assistant/call pieces, tool results, and images
  or sealed reasoning named with their size. Sizes are unchanged.
- gui: GET /api/context/text?id=&kind=[&item=] (no-store; 404 "not kept"
  when the body is gone or another process serves the gateway).
- gui: in the card, a legend part, a waffle cell or a content row
  (click, Enter or Space) opens a wide modal: one item alone with "All of
  {part}", or the part's list 100 rows at a time, each item's text
  fetched when it is opened and shown 20000 characters at a time, with
  copy buttons. Strings in zh, zh-TW, ja and de.
- docs: gateway-routing and gui-shell subsystem pages; the site's start
  page (en, zh, ja) says the text is kept for the last 10 requests in
  memory and sent nowhere. The README Privacy is unchanged, since nothing
  more is sent.

What was run:
- go test -tags nogui ./... (temp HOME). internal/gateway hit the 10m
  default under the full parallel run, in TestRequestTailAfterOldLimit,
  which takes 57s alone on the base commit too; the package run alone
  with -timeout 30m: ok (700s, the machine shared with other runs). Every other package: ok.
- New tests TestPromptTextIsWhatWasSent, ...KeepsOnlyTheLastBodies,
  ...ChatPieces, TestContextTextAPI. Broken by hand: keeping the unmasked
  body fails (the key shows), and dropping keepBody fails ("not kept").
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet on internal/gateway
  and internal/gui.
- GUI: tests/context-text.test.cjs in Chromium and WebKit, en/zh/zh-TW/
  ja/de, at 1100 and 420px: legend, row, cell and keyboard open the text,
  long text grows on demand, the page never scrolls, and a gone body is
  named. It fails with the click wiring removed. Under a load average of
  ~140 one case failed once: the test read the list while the dialog
  still said "Reading…". Reproduced with a 400ms reply, fixed by waiting
  for the list; the mock now always answers after 200ms. A second case
  ("a click doesn't move the page", 662 vs 605 on the contents row) came
  from taking the page's top while a wheel scroll was still easing: the
  test now wheels to the row like the other cases, and wheelTo waits for
  three equal looks. Four full runs at load ~150 then passed (80 cases). context-window,
  i18n-keys, held-animations and the modal tests (dialog-backdrop-drag,
  editor-short-window, readable-focus, ux-safety, whats-new, add-sheet,
  api-key-theme) pass in both engines.
- Real use: a sandbox magpie (own HOME, ports 3486/3487, the Codex login)
  served a real `claude -p` (Claude Code) request on codex/gpt-6-luna
  that read a file. In its web UI, Usage > Context: each of System
  prompt, Tools, Memory, Files and Conversation, a waffle cell and a
  contents row opened the request's real text (Claude Code's system
  prompt, 21 tool definitions, the CLAUDE.md reminder, main.go's Read
  result, the turn with its thinking and call). No page errors.
2026-10-11 00:49:01 +08:00
yetoneandFourLeafTec 4b2f2ec31e provider, plugin: a plugin can serve System One for its provider, and the models it marks are a routing group's classifier (#1514, FourLeafTec)
A plugin had no way to say its provider answers TypeSafe's System One,
so a free decision model a plugin reaches (mu-zi-lee/magpie-our-free-model)
could only be listed as a chat model.

Now the plugin's config hook sets `decide: true` on the provider, and
`decides: true` on a model, in the config hook or on the models hook's
list. host.js passes both through (plugin.Provider.Decide,
plugin.Model.Decides). pluginProvider sets the provider's Decide to its
own base, plugin://<id>/v1, so System One is asked at {baseURL}/systemone
through the loader's fetch with the account's sign-in: pluginFetch sends
nowhere but the loader's host, so an address the plugin named itself
couldn't be reached. AskSystemOne now sends with Provider.Do, as the
gateway's classifier already did, so the editor's test goes through the
fetch too (Do is client.Do for every provider without an account).

decide.go treats a plugin provider's decision models as the ones it marks
plus Jev's by name (jev-*): kept from agents, refused for chat ("only
decides"), refused as a group member, offered as a group's classifier
(Deciders, DecisionModels, Jev). A mark without `decide` on the provider
changes nothing. Docs: site plugins page (en, zh, ja) and
docs/subsystems/provider-plugins.md.

Thanks to FourLeafTec, whose reference commit (bc0b3fee in their fork)
proposed the two fields and the plugin base; this is written afresh.

Run:
- internal/gateway TestPluginServesSystemOne and
  TestPluginMarksWithoutDecide, through the real bun plugin host with the
  fake plugin (FAKE_DECIDE). Red with host.js, plugins.go and decide.go
  reverted ("Decide = \"\""), with only host.js reverted, and with only
  decide.go reverted (no classifiers, offered to agents, chat to one 200).
- go test -tags nogui ./... (temp HOME): every package ok; internal/gateway
  hit the 10m default at load ~140 in TestLargeRequestEndpoints, then
  passed alone with -timeout 40m (548s).
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on
  internal/plugin, internal/provider, internal/gateway.
- Real use: a nogui build in a sandbox HOME on 127.0.0.1:3612, a local
  plugin declaring decide with judge-x marked, a fake vendor on 3613.
  `magpie group rule add ... classifier=dec1514/judge-x` saved; judge-x
  was not in /v1/models and not accepted as a member; a turn to the group
  asked /v1/systemone judge-x (levels, then intent) with the plugin's key
  and its fetch's own header, then went to chat-b; chat to judge-x
  answered 400 "only decides".
- No GUI change: a plugin's editor is the account editor, which has no
  address fields.

Co-authored-by: FourLeafTec <5875432+FourLeafTec@users.noreply.github.com>
2026-10-11 00:24:08 +08:00
yetone cc2092a4b0 plugin, gui: a market plugin's card wears the picture its package gives (magpie.icon from npm) when the market gives none
yetone: 这里的 agent plugin 为什么没有 logo. Aider's card in Discover › Agent
showed the generic agent glyph: the registry entry has no icon, and the
card only read the registry's, which is one of magpie's icon names. A
GitHub-tagged plugin's card already read package.json's magpie.icon; a
listed one didn't.

- plugin: npm's /latest answer carries package.json, so NPM.Icon is its
  magpie.icon, an https URL or data:image URI only (ownIcon, now shared
  with the GitHub listing's check).
- gui: listings, market and /api/plugins/npm keep that picture as an
  installed plugin's is (provider.RepoIcons) and send the page a file:
  icon, never the data URI or the remote URL.
- plugins.js: card, plugin page and installed row use l.icon, then
  l.npm.icon.
- Registry icons stay names, so older magpies aren't handed a URL they
  would draw as a broken mask.
- docs: magpie.icon also shows on the Discover card (en, zh, ja).

agent-aider 0.1.1 (magpie-community/plugins bcc94e5) gives aider.chat's
icon as magpie.icon and agent.icon.

Ran:
- go test ./internal/plugin ./internal/gui; go test ./internal/provider
  alone (504s, pass); go test ./... otherwise ok.
- gofmt -l; vet linux/windows ./internal/plugin.
- internal/gui/tests/plugin*.test.cjs in chromium+webkit; plugin-agent's
  new check goes red (11 fail) with the card reading l.icon only.
- Sandbox HOME with the real npm package 0.1.1: the Discover card,
  Installed row and Agents row all show Aider's icon, in chromium and
  webkit at 1100 and 420.
2026-10-10 23:57:56 +08:00
yetone 3541ec2fd5 gateway, gui: a gateway key's limit can run every N days, and Reset usage counts it from 0 again (#1509, PennyVibe)
PennyVibe asked for a key limit on a cycle of N days rather than a
calendar day, week or month, and for a way to zero a key's usage by
hand. Both are in.

Every N days (N from 1 to 3650):
- access.Limit gains Days and Since. Since is magpie's own: the
  limit-key action always works it out, and a value a client sends is
  ignored.
- The cycle starts when the limit is set. Each cycle is N×24h of
  absolute time from Since, so a restart, a time-zone change or a DST
  shift doesn't move it.
- Changing only the caps or "count cache reads" keeps the cycle.
  Changing N or the period, or turning the limit on, starts a new
  cycle now.
- A hand-written "days" limit with no Since runs from the Unix epoch.
- The GUI window menu offers "Every N days" with a Days field. The CLI
  takes `magpie gateway-key limit <id> 10d`. The refusal and status
  name the cycle ("for this 1-day cycle").

Reset usage:
- A new action, reset-limit-key, is on the editor's "Reset usage"
  button (after a confirm) and on `magpie gateway-key limit <id> reset`.
- It sets Since to now, so tokens and cost both count from 0 together.
- An N-day key starts a new cycle then.
- A day, week or month key keeps its window's end, so it stays on the
  calendar. Only the calls before the reset stop counting.
- The usage log is not touched. Authenticate reloads keys each request,
  so the reset takes effect at once.

Keys saved before keep their JSON byte for byte (omitzero, nothing
written on load).

Docs: reference.md documents the cycle and reset rules. The docker page
(en, zh, ja) mentions every-N-days.

Run:
- go test -tags nogui ./... with a temp HOME.
- New Go tests:
  - TestLimitDaysCycle covers the NY DST, UTC and UTC+8 boundaries.
  - TestLimitCalendarReset.
  - TestLimitSetAndReset covers keep/restart, an old key's JSON left
    untouched, and errors.
  - TestKeyLimitDaysCycleAndReset covers the 429 text and header, a
    restart, the cycle boundary, and Reset clearing the token and cost
    caps together.
  - TestKeyLimitCalendarReset.
  - TestGatewayKeyLimitCLI covers 10d, reset and bad args.
- Broken by hand: with reset leaving Since alone,
  TestLimitSetAndReset, TestKeyLimitDaysCycleAndReset and
  TestKeyLimitCalendarReset go red.
- gofmt -l is clean. GOOS=linux and GOOS=windows go vet -tags nogui
  pass on ., access, budget, gateway and gui.
- GUI: the new gateway-key-cycle.test.cjs runs in chromium and webkit ×
  en, zh, zh-TW, ja and de, with a narrow-width check. Also run, in both
  engines: every test using the caller-keys fixture, i18n-keys,
  gui-ja, gui-de and gui-zh-tw (80 pass).
- Real use:
  - Sandbox magpie (temp HOME, gateway 127.0.0.1:3691, dev UI 3692)
    with a fake OpenAI upstream (300+50 tokens a call).
  - `gateway-key limit <id> 1d --tokens 700` allowed 2 calls with curl,
    then a 429 "for this 1-day cycle" with X-Magpie-Limit-Reset a day
    after it was set.
  - Pressed Reset usage in the GUI with Playwright and confirmed. The
    badge was no longer spent and showed 0 of 700, and curl passed 2
    calls again before the next 429.
2026-10-10 22:53:11 +08:00
yetone 8d95ebc8c3 provider: Bailian Token Plan is a preset of its own, with its decision model for routing groups; the Qwen AI platform's decision model too, and Bailian's shows Bailian's icon (#1506, IamMiao)
Alibaba sells two Token Plans, both with sk-sp- keys, and a key works only
on its own host. qwen-token-plan is the Qwen AI platform's
(token-plan.maas.qianwenaiapi.com), but its website and keys links pointed
at Bailian's console. Bailian's own plan
(token-plan.cn-beijing.maas.aliyuncs.com) had no preset.

What changed:
- presets: new bailian-token-plan (chat /compatible-mode/v1, Anthropic
  /apps/anthropic, decide on /compatible-mode/v1/systemone, models from the
  docs' list, shared with qwen-token-plan as alibabaPlanModels).
  qwen-token-plan's links now point at the Qwen AI platform. New
  qwen-decision for Qwen's pay-as-you-go decision model at
  maas.qianwenaiapi.com/compatible-mode/v1/systemone. bailian-decision shows
  the Bailian icon instead of Qwen's.
- decide: bailianDecides also matches the bare maas.qianwenaiapi.com host.
  A chat preset that also decides on a Bailian/Qwen host (bailianApart)
  lists decision-model-preview as its only decision model, so it is offered
  for routing groups and never given to an agent as a chat model.
- gateway: dashScope() covers bailian-token-plan and maas.qianwenaiapi.com.
- CLI help, docs/reference.md and the import docs (en, zh, ja) name the new
  preset.

Usage: neither plan's docs give a usage or quota API; the remaining quota
is only on the console (百炼控制台 Token Plan > 我的订阅, Qwen 工作台
token-plan/individual), which needs a browser session. So no usage card is
added. An exhausted plan's 429 insufficient_quota is already read as out of
credit.

Not tried against the real API: no Bailian or Qwen key was available. The
stand-in is an httptest server copying the docs' systemone curl (Bearer
sk-sp-, model decision-model-preview) and its error table (401 on a wrong
key, 422 on a bad body). qwen-decision sends "Authorization: Bearer <key>";
the Qwen doc's curl shows the bare key, which is untested.

Run:
- go test -tags nogui -count=1 ./... (temp HOME)
- TestBailianTokenPlan, TestQwenDecisionPreset and TestDashScopeHosts fail
  with the old decide.go and gateway.go swapped in
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on .
  internal/provider, internal/gateway, internal/gui
- GUI: system-one, add-sheet, gateway-decide-info, routing-kind tests in
  chromium and webkit (20 pass)
2026-10-10 21:14:38 +08:00
yetone b6a263b9fd gateway, usage: the Usage page's numbers are read over the gateway, and a Claude Code subagent's call says which subagent and which started it (HoGee_xxl on X)
HoGee_xxl wants their own usage app to read magpie over the gateway,
which had no /api/usage counterpart, and asked for subagents' parent ids.

- GET /v1/magpie/usage (the /api/usage summary, ?period=) and
  GET /v1/magpie/usage/requests (the /api/usage/requests ledger page, same
  filters, offset/limit) on the gateway. The builders moved out of gui into
  internal/usageapi so both serve the same JSON; gui keeps aliases and sets
  usageapi.Clients for agent names (gateway can't import agent). Guard as
  /v1/magpie/quotas: this machine, or another with an enabled gateway key,
  behind the same Host check. A key held to a budget, models or accounts is
  refused the summary (403) and gets the ledger filtered to its own
  CallerKey, with callerKeys/agents/providers/accounts cut to its own rows
  (usageapi.OwnPage): those facets are drawn from every call in the period.
  `path` is left out for another machine.
- usage.Record gains subagent and parent_agent; session stays the parent
  conversation. Gateway rows take them from x-claude-code-agent-id and
  x-claude-code-parent-agent-id; session-file rows from the file name
  (<session>/subagents[/workflows/<run>]/agent-<id>.jsonl, no cache version
  bump) and the parentAgentId of the agent-<id>.meta.json beside it. Both
  packed into the request page's text columns (now 29, msg at 29).
  Codex sub-threads: only kind, as before; no spawned thread on disk to
  take a parent shape from.

Run: real Claude Code 2.1.296 under a sandbox CLAUDE_CONFIG_DIR against a
local fake Anthropic endpoint that made it spawn a subagent from a
subagent: the nested request carried X-Claude-Code-Agent-Id=a143287ac46b82a96
and X-Claude-Code-Parent-Agent-Id=a99ca20c03d1813d8, the first-level one
the agent id only, Session-Id the parent's throughout; the nested meta.json
had parentAgentId. Tests use those bytes. TestUsageOverGateway goes red
with OwnPage, the CallerKey pin, or the header read removed (each tried).
gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; set -o pipefail; go test ./... green.
2026-10-10 20:47:00 +08:00
yetone cb406c8425 plugins: a plugin can add an agent magpie has no setup of its own for
Plugins could be subscription providers or gateway middleware. Now a third
kind: an agent plugin, so a user whose agent magpie doesn't ship can still
put it on magpie.

- internal/agentplug: a plugin's magpie.agent module (or a *.agent.js file)
  exports agent = {id, name, config, format?, model, prefix?, bin?, dir?,
  ua?, icon?, notice?} and an optional connect({gateway, model, models,
  agent}) returning the other keys to write. Compiled in moejs, reloaded
  when plugins.json or the file changes; why one didn't load is kept.
- internal/jsmod: module compiling (imports kept inside the plugin), moved
  out of middleware so both share it.
- internal/agent/plugged.go: each becomes an Agent (Plugin set) after
  magpie's own. JSON, YAML and env files are edited key by key, comments
  kept; what each key held is stashed typed under plugin:<id>:<path>, and
  its own model or Disconnect puts every key back. A built-in id is
  refused; a connect that throws writes nothing. Key magpie-<id>; usage
  names it by key or ua (usage.PluginAgents).
- GUI Plugins page: an Agent kind chip and glyph, a Discover "Agents"
  section (market kind "agent"), and an installed row line "Adds X to
  Agents" or why it didn't load. zh, zh-TW, ja, de strings.
- Docs: site Plugins page (en, zh, ja) "Agent plugins", reference.md,
  agent-wiring.md, gateway-middleware.md.

Run:
- go test ./... (all ok); gofmt -l clean; GOOS=linux go vet -tags nogui
  ./... and GOOS=windows go vet ./... clean.
- TestPluggedYAML, TestPluggedJSONUnwire, TestPluggedRefused.
- GUI: plugin-agent.test.cjs 22/22 (en, zh, zh-TW, ja, de; 980 and 420;
  chromium and webkit); all plugin-*.test.cjs, i18n-keys,
  deprecated-subscriptions, filter-ime: 315 pass, 0 fail.
- Real use, in a sandbox HOME: an Aider plugin (~/.aider.conf.yml, prefix
  openai/, connect writes openai-api-base/key) installed in a dev build;
  picking DeepSeek V4.1 Flash on the Agents page wired the file keeping the
  user's comment and keys; real aider 0.86.2 `--message` answered through
  magpie from the real DeepSeek account; usage.jsonl recorded agent aider,
  provider deepseek, 200; Disconnect restored the file byte for byte.
2026-10-10 18:39:47 +08:00
yetone d35d47e18a site: AiHubMix sits beside OpenRouter in the homepage's model list 2026-10-10 17:53:23 +08:00
yetone ddd4f43144 provider: a routing group can be duplicated, from its menu on the Routing page or with magpie group copy (lc on Discord)
provider.CopyGroup(id, name) saves a copy of the group as it is now: its
models and patterns, routing, stays, rules, classifier, effort, context,
levels, and fast and off members. The copy is deep, so its rules' time
windows aren't shared. Its name is the one given, or "<name> copy", with a
number added past a name in use. Its id comes from the name, numbered past
any id in use, removed ones included. It is listed right after the group
it copies. The copy is a group of the user's and switched on, even when
it copies a found group or a switched-off one. The original is unchanged.

Surfaces:
- GUI: a group row's menu (right-click, or a click on its logos) has
  Duplicate under Move up and Move down. It posts /api/groups/copy with
  the id and t("{name} copy"), so the name is in the reader's language.
  It asks before discarding an editor with unsaved changes. The status
  then says "Duplicated {name}". No click scrolls the page.
- CLI: magpie group copy <id> [name]; duplicate, dup and clone work too.
- zh, zh-TW, ja and de strings. docs/reference.md and the site's start
  page (en, zh, ja) list the command.

Run:
- TestGroupCopy (internal/gui): the copy has the models, pattern,
  routing, rule and off member, is on, and is listed after the original.
  The original stays off and unchanged. A second copy is "Fast copy 2" /
  fast-copy-2. An unknown id is refused.
- TestGroupCopyCLI (root): the default name, a given name, a found
  group's copy as the user's, and the errors.
- group-duplicate.test.cjs: Chromium and WebKit, en/zh/zh-TW/ja/de at
  420px, 10/10. It fails 10/10 on the old routing.js. Siblings
  group-arrange, removed-groups-menu-scroll, group-bulk-remove and
  click-scroll pass 36/36.
- Sandbox CLI (sandbox HOME): group copy and duplicate made "DupTest copy"
  and "DupTest copy 2", listed after DupTest.
- gofmt -l clean. go vet darwin/linux/windows on the root, provider and
  gui packages: ok.
2026-10-10 15:08:14 +08:00
yetone 3ee97def30 claude: a server or container without Claude Code can have magpie download Anthropic's own build, asked first and checked against its manifest (Jorben)
A Claude subscription signs in and answers through the local `claude`, so
on a server or in the Docker image, which has none, it couldn't be used
(Jorben on Discord: could it be downloaded on first use, as Bun is).

- internal/claudecode: Anthropic's native build, as claude.ai/install.sh
  takes it: downloads.claude.ai/claude-code-releases/latest names the
  version, its manifest.json the platform's SHA-256 and size (linux
  glibc/musl, darwin, win32). A build that doesn't match both is not kept.
  It goes to <cache>/claude-code/<version>/claude, one version kept. Find
  takes the machine's own claude first, then the download.
- magpie claude-code [install [--yes]|remove]: says the version, platform,
  size, the URL it comes from, where it goes, that its checksum is checked
  and that it is Anthropic's software under Anthropic's terms, then asks
  [y/N]. magpie accounts add claude offers it when there is no Claude Code
  (not on Windows, where one in WSL may be the one).
- the gateway's claudeBinary and the sign-in's claudeExecutable take
  claudecode.Find; their "not installed" errors name the command.
- Docker docs (en, zh, ja): Claude sign-in needs `docker exec -it magpie
  magpie claude-code install` first; kept in /config/cache.
  The Dockerfile is unchanged: distroless cc-debian12 has glibc.

Run:
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok
- gofmt -l: none; go vet (darwin), GOOS=linux and GOOS=windows go vet
  -tags nogui ./...: clean; darwin, linux, windows builds
- TestClaudeSubscriptionRunsTheDownloadedClaudeCode fails on the old
  proc.FindTool lookup ("Claude Code is not installed"); taking the
  checksum compare out fails TestInstallRefusesABuildTheManifestDoesntName
- real: magpie claude-code install --yes downloaded Claude Code 2.1.296
  darwin-arm64 (230 MB) into a sandbox HOME, checked; it ran --version
- real, in gcr.io/distroless/cc-debian12:nonroot with the image's /config
  layout: install downloaded 2.1.296 linux-arm64 (245 MB) to
  /config/cache/magpie/claude-code, it ran `2.1.296 (Claude Code)` there,
  and magpie accounts add claude went on to print the claude.ai sign-in
  link and ask for the pasted address
- the claudecode tests built for linux/arm64 pass in debian:12-slim
2026-10-10 14:44:57 +08:00
yetone 4225ba1efb site: a partner's /go link and the home page's sponsor card say they came from magpie, as ref=magpie (yetone)
goTarget adds ref=magpie to the partner's key page or website, keeping the
address's own query and fragment; an address that names its own ref (a
referral code) keeps it as it is. The home page's sponsor card links to
yylx.io/?ref=magpie.

Run: node --test site/*.test.mjs (27 pass), with new cases for the query,
the fragment and a partner's own ref.
2026-10-10 14:18:05 +08:00
yetone c98160c045 gateway: a group's rule can pause one of its models at set hours, days or agents, leaving it out of the group then, not first, not a fallback, not kept by affinity (John on Discord)
John asked for a pause in a group's Rules, e.g. a model paused in its
vendor's peak hours. A time rule could only send those turns to another
member first: the paused-for model stayed behind it for failover, went
first when the other was unready, and was kept by affinity mid-turn.

What changed:
- provider: Rule.Pause (`"pause": true`, typed `pause=<model>`). It holds
  by time/days and agents only; cleanRules and ParseRule refuse any other
  condition, and refuse a pause with none. Pause rules are not send-to rules:
  MatchesBesidesIntent, ruledEntry and Ruled() leave them out.
  PausedOut(g, ms, agent, at) drops members a pause holds for, from the
  group's own rules and each nested group's (a group named = all its
  models; a model named = wherever a nested group has it, #625).
- gateway: serve and embeddings run PausedOut on ruleClock before planning,
  on every request. Every member paused -> 503 naming each rule
  (pausedError). The trace's GroupRef carries Paused.
- GUI: the rule editor's "send to" is now an app-menu action button (send
  to / pause); a pause hides the request conditions (clearing them),
  keeps hours, days and agents, and isn't saved without one. The group
  card's rule reads "→ pause <model>", and the Routing trace says which
  model was paused by which rule. Strings in zh, zh-TW, ja, de.
- CLI/TUI: `magpie group rule add <g> pause=<model> time=… days=…`.
- docs: gateway-routing.md step 2; start.html en/zh/ja "Hours and days".

Run:
- gofmt -l clean; go vet -tags nogui ./...; GOOS=linux and GOOS=windows
  go vet -tags nogui on gateway, provider, tui, root; go build ./...
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok.
- rules_pause_test.go (3 tests) fails with the PausedOut call in serve
  removed (the paused model answers mid-turn, as a fallback, and the
  all-paused case returns 200). grouprule_pause_test.go covers clean,
  parse/Line, Ruled, Pauses and nested PausedOut.
- GUI: routing-pause.test.cjs in Chromium and WebKit, en/zh at 1100px
  and en/zh/zh-TW/ja/de at 420px: 14/14; all 7 Chromium cases fail on
  the old routing.js. routing-*, group-*, i18n-keys, gui-ja, gui-de,
  click-scroll: 618 pass, 4 fail under --test-concurrency=4
  (routing-blocked, -idle-frame, -side-calls, -wb-refused), all of which
  pass run alone; routing-side-calls failed 1 of 6 alone and passes
  with the old routing.js too, so it is a load flake not touched here.
2026-10-10 13:51:09 +08:00
yetone 34f2078db8 site: a partner's website and key links go through usemagpie.ai/go, which counts the click; fetches of the partner list are counted too
The app's own partner counts only come from users who leave the stats on,
so a sponsor's reach and clicks are now also counted where the server sees
them. /api/partners hands out each partner's website and keysUrl (and a
region's) as usemagpie.ai/go/<id>/site|keys[/<region>]; /go sends a
"magpie partner go" event to PostHog (partner, link, region, country) and
302s to partners.js's own URL. One in ten list fetches sends "magpie
partners fetch" with weight 10 while someone is listed. Events carry a
random id each, no install id or address. Ended entries leave the list but
/go still resolves them, since added providers keep the links. Privacy text
updated in README (en, zh), docs/reference.md and the site docs (en, zh, ja).

Run: node --test site/*.test.mjs (27 pass); a scratch copy with a fake
partner served rewritten links, 302'd /go to the real URLs and posted both
events; PostHog's /i/v0/e/ answered 200 to the payload shape.
2026-10-10 13:48:26 +08:00
yetone 9bb2a467e4 agent: Snow CLI is an agent magpie sets up: a magpie profile in ~/.snow, made the active one, that Snow App takes in with "Sync Snow CLI API config" (#1457)
Snow CLI (npm snow-ai, MIT, MayDay-wpf/snow-cli) keeps one profile per
file under ~/.snow/profiles (or $SNOW_CONFIG_DIR), names the active one
in active-profile.json, and copies it over config.json at every start,
headless `snow --ask` included. Each profile is the whole snowcfg: base
URL, key, request method and models. Snow App (MayDay-wpf/snow-app)
reads ~/.snow/profiles/*.json when "Sync Snow CLI API config" is pressed.

magpie writes profiles/magpie.json from the profile the user was on
(their settings kept, Snow's OAuth sign-in left out): baseUrlMode base
at the gateway's /v1, requestMethod chat, the agent's key, the model as
advancedModel and basicModel, and the catalog's window and output
(200000 and 64000 when not known, the output cut to the window). It
makes that profile active and copies it to config.json. The profile the
user was on, whether there was an active-profile.json at all, and a
magpie.json of their own are stashed; Disconnect, `magpie snow
default`, or picking a model of one of the user's profiles puts those
back. A Snow from before profiles (config.json alone) gets the
default.json Snow itself would make, so its next start doesn't take
magpie's config for the user's. Check reports a base URL, key or request
method moved off magpie's; Sync rewrites the profile on a port move. A
WSL distro's ~/.snow is found and written the same way.

Registered: agents.go, the WSL kinds, SNOW_CONFIG_DIR in agentenv, the
npm update spec (snow-ai), the icon (Snow App's own, trimmed to 96px),
README, docs/reference.md, docs/subsystems/agent-wiring.md, the site's
agent list and start.html (en, zh, ja).

Run:
- go test -tags nogui ./... in a scratch HOME: 44 packages ok.
  New: TestSnow, TestSnowOwnProfile, TestSnowNoProfiles,
  TestSnowUsersMagpieProfile, TestSnowCheckSync, TestAgentSnowDefault;
  snow added to TestOwnProviderNamedAsMagpies, the WSL more-agents tests
  and TestMaxTokensWithinContextWindow. All fail before this commit
  (no agent "snow").
- go vet -tags nogui for darwin, linux and windows; gofmt -l clean.
- Real Snow CLI 0.9.2 in a sandbox HOME against a sandbox magpie
  (`magpie serve` on 127.0.0.1:3571, a fake OpenAI upstream on 3561):
  `magpie snow fake/pro` made the magpie profile active, `snow --ask`
  answered through the gateway (POST /v1/chat/completions, model pro,
  logged as agent snow), and `magpie snow default` left profiles,
  active-profile.json and config.json byte-identical to before.
- GUI: agent-layout, agent-connect, agent-models-picker,
  agent-field-names and models-add-and-icons in Chromium and WebKit;
  a Snow CLI row checked at 520-960px in en, zh, zh-TW, ja and de in
  both engines. No new GUI strings.
2026-10-10 11:46:44 +08:00
yetone 5b008f5a55 i18n: Chinese says 子代理 for subagent everywhere, not 子 agent in some places and 子代理 in others (willz on Discord)
willz asked what the difference between 子 agent and 子代理 is. There is
none: the zh and zh-TW GUI strings used 子 agent for the Agents page's
subagent row and subagent effort ("Subagents", "subagents",
"subagent effort" and its hint), and 子代理 for every other subagent
string (Codex subagents, routing's sealed subagent task, subagent model).
Both locales now say 子代理 throughout; zh-TW already used 子代理 for the
rest, so it takes the same term. The zh site docs (intent.html,
start.html) said 子 Agent / 主 Agent and now say 子代理 / 主代理, matching
the GUI's 主代理. ja already says サブエージェント everywhere; the READMEs
don't name subagents. The four GUI tests that expected 子 agent are
updated.

Run: omp-roles, profile-details, subagent-effort, tier-effort,
codex-subagent-model, routing-sealed-task, agent-tweak-fold,
claude-signin, codex-memories(-settings), gateway-mode, mobile-web,
usage-ledger-detail, gui-zh-tw, gui-ja, gui-de and i18n-keys in Chromium
(148/148) and WebKit (79/79); subagent-effort also at 420px wide in both
engines, with the zh screenshot checked (子代理推理强度).
2026-10-10 11:24:31 +08:00
yetone ca3394ff80 docs: the community's plugins update by themselves every hour, not every six hours (en, zh, ja)
internal/plugin/updates.go's KeepUpdated first runs 30 seconds after
magpie starts, then every updateEvery, which is time.Hour. #681 cut it
from six hours. The Plugins page (plugins.js) already says "within the
hour". site/public/docs/plugins.html, zh/ and ja/ still said six hours.

Other "six hours" mentions were checked and left alone, since the code
agrees with them:
- the registry.json fetch on the same pages (market.go: 6*time.Hour);
- the move retry in docs/subsystems/provider-plugins.md
  (migrate.go: moveRetry = 6*time.Hour).

Bun's own check (bunEvery) is six hours, but no doc states it. No README
or docs/ page states the plugin update interval.

Run: grep across README*.md, docs/ and site/ for six hours / 6 hours /
六小时 / 6 小时 / 6 時間. No code changed.
2026-10-10 10:28:49 +08:00
yetone ba0e2a8aa9 plugin: Update all and magpie plugin update bring a plugin pinned to an older version to npm's newest, so the update prompt clears (ARNO on Discord)
ARNO: 非官方插件安装后就算更新到最新版,magpie依然提示有更新. A third-party
plugin added as name@1.2.3 is pinned. The Plugins page still counts it
under "Update all (n)", its row says "vX out" and the Plugins dot is on.
Update all (and `magpie plugin update`) reinstalled the pinned version,
reported "Plugins updated", and the prompt stayed. The row's own Update
already installs the newest version and unpins the spec (name@latest).

Update now does the same for a pinned plugin when npm has a newer version
than the one installed: it installs that version through add, which keeps
the plugin's options and the provider picked for it. A pinned plugin that
is already at npm's newest keeps its pin. Git plugins, folders and plugins
npm didn't answer for behave as before. The plugin docs (en, zh, ja) now
say that updating a pinned plugin yourself unpins it.

Reproduced in a sandbox HOME with the real opencode-gemini-auth from npm
(magpie web on a spare port, China mirror switch on and off). Pinned at
1.4.15 with 2.0.1 out: before the fix, Update all and `magpie plugin
update` left it at 1.4.15 and /api/plugins/updates still listed it. After
the fix it is at 2.0.1 as opencode-gemini-auth@latest, the waiting list
is empty and Check for updates reports "current". The row's Update
(upgrade) path was checked too: unpinned opencode-gemini-auth, and scoped
@gitlab/opencode-gitlab-auth 1.3.1 -> 1.3.3 with the mirror on. Both
cleared the prompt before the fix as well.

TestUpdateAllUpdatesAPinnedPlugin (real bun, fake registry) fails without
the change: "Update all left opencode-someones-auth at 1.0.0, want 2.0.0".
gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows) on internal/plugin,
and go test -tags nogui of internal/plugin, internal/gui and
internal/provider under a temp HOME with pinned caches all pass.
2026-10-10 10:19:42 +08:00
yetone 83c963c466 gateway: a gateway MAGPIE_ADDR puts on the network asks callers from other machines, a container's host among them, for an enabled gateway key, as sharing does
What changed
- lanGuard: a request whose peer isn't loopback (or that carries a
  forwarding header) is remote. While the gateway is shared, or
  MAGPIE_ADDR names a host other than loopback/localhost (OnNetwork:
  0.0.0.0 in the Docker image, a server's address), a remote request is
  answered only with an enabled gateway key, on every route behind the
  guard; otherwise it is refused (403) as before. Before, a MAGPIE_ADDR on
  the network with sharing off took remote requests with any key.
  A remote request let in with a key is marked as shared-mode ones are,
  so quotas, quota cards, refresh and prices answer it.
  callerGuard follows the same condition. OpenToAnyone is replaced by
  OnNetwork.
- Loopback is unchanged: any key still works on the gateway's own
  machine and inside the container (HEALTHCHECK included).
- CLI keyNote and the console's Connect note no longer describe an open
  gateway; on the network they say other machines need a gateway key
  (`magpie gateway-key add <name>`). The console shows the Gateway keys
  block and network addresses when OnNetwork (gatewayJSON.onNetwork
  replaces open); the "Open to the network" strings are removed.
- Docs: docker.html (en/zh/ja) and remote.html (en/zh/ja) say callers
  outside the container need a gateway key, how to make one, that
  sharing isn't needed for it, and what an upgrade means for agents that
  sent `magpie`; docs/reference.md and providers-accounts.md likewise.
  A MAGPIE_ADDR pinned to one interface's address now asks a key of this
  computer's agents calling that address too (documented).

Tests
- New TestNetworkGatewayGuardsEveryRoute: from 172.17.0.1 and
  192.168.1.9 every registered route (model APIs, count_tokens,
  systemone, the Responses websocket GET, MCP, Codex backend and
  catalog, /v1/magpie/*, images, embeddings, rerank, videos, Gemini)
  gets 401 without a valid key; with one, models and quotas answer 200.
- TestNetworkGatewayNeedsAKey (was TestExplicitOpenGatewayAccepts...),
  TestLANGuard, TestProxiedLoopbackNeedsTheKey, TestQuotasOverLAN,
  TestMCPProxyStaysHere, session route and remote prices tests, TestOnNetwork,
  serve_cli and gui public_url tests updated. With the old lanGuard
  restored, TestNetworkGatewayNeedsAKey, TestNetworkGatewayGuardsEveryRoute,
  TestLANGuard and TestProxiedLoopbackNeedsTheKey fail.

Run
- go test -tags nogui -count=1 ./internal/gateway ./internal/gui
  ./internal/provider . under a temp HOME: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
  those packages: clean.
- GUI: public-url and gateway-caller-keys tests, Chromium and WebKit: 22/22.
- Locally built image (OrbStack), -p 127.0.0.1:3481:3425: from the host,
  /v1/models with no key, `magpie` and another made-up key -> 401;
  count_tokens and /mcp/x -> 401; a key from `docker exec ... magpie
  gateway-key add Host` -> models 200, quotas 200; inside the container
  wget /v1/models -> 200; healthcheck exits 0. `web --addr 0.0.0.0:3430`:
  /api/state 401 without the web key, 200 with its cookie.
2026-10-10 09:26:23 +08:00
yetone d86a4e0568 site: the docs have Docker and Remote magpie pages in English, Chinese and Japanese, listed in every docs page's contents and footer and linked from the READMEs (HuanCheng Bai on Discord)
Until now, both were only in docs/reference.md. The new pages are at
/docs/docker, /docs/remote and their zh/ and ja/ versions.

- docker: the image, its tags, ports, the /config volume and the nonroot
  user. How to run it with the browser UI (`web --addr 0.0.0.0:3430
  --no-open`, MAGPIE_WEB_KEY, the ?k= cookie). Signing in through the
  Callback URL paste or `docker exec ... magpie accounts add`. What
  /config keeps, the env vars, sharing with gateway keys, and a Compose
  file for a NAS. Healthcheck and updates.
- remote: sharing the main magpie, then adding it as a Remote magpie
  from the app, the TUI (a/w/m) or `magpie provider add remote-magpie
  <key> url=... id=office`. What comes over (models, groups, APIs,
  images, System One, embeddings, prices, quotas) and the errors magpie
  shows, quoted from remote_quotas.go and lan.go.

The facts were checked against the code, not reference.md:
- the Dockerfile ENV, VOLUME, HEALTHCHECK and EXPOSE;
- docker.yml's tags;
- web_cli.go;
- the lanGuard in internal/gateway/lan.go;
- the remote-magpie preset.

The Docker page's warning says a Docker gateway answers anyone until
sharing is on, because MAGPIE_ADDR is 0.0.0.0 there.

The new links in the top nav bar carry a toc-only class:
- docs.js still lists them in the contents;
- the bar keeps today's width, since nine links overflowed it at
  1024-1280px.

`.steps li` gets min-width: 0, so a long inline code no longer widens
the grid past a phone's width, where `overflow: hidden` clipped the
text.

Run:
- Real containers from ghcr.io/yetone/magpie:latest (v0.1.1150):
  - the documented `docker run ... web` came up healthy, and its log
    output is what the page shows;
  - with "lan": true, `Bearer magpie` got 401 and a gateway key got 200;
  - a second container ran `provider add remote-magpie <key>
    url=http://<a>:3425 id=office` and listed office/test-relay/... models.
- `node --test site/*.test.mjs`: 23 pass.
- Playwright, in Chromium and WebKit, at 1280, 1024 and 390, light and
  dark:
  - no horizontal scroll and no nav overflow on all 20 docs pages;
  - every internal link and #anchor resolves. /zh/ and /ja/ are routed
    by the worker and return 200 live.
2026-10-10 09:08:03 +08:00