Files
magpie/docs/subsystems
yetone 97e0ecdaab settings: a saved proxy's Test says its latency and exit region, from Settings and the provider editor (IcyLiqu1d on X)
IcyLiqu1d asked for sub2api-style proxy management: test each saved
proxy's region and latency, then pick a provider's proxy from the list.

- A saved proxy's row in Settings, once tested, reads "Reachable, 42 ms ·
  Japan": the exit's country from Cloudflare's trace page (the endpoint
  the quick check already uses), named in the reader's language by
  Intl.DisplayNames; the exit IP is in the tooltip. A failure says why.
- The latency is the round trip through the proxy, from the request
  written to the answer's first byte (httptrace). The whole request's
  time counted a new connection's dial, tunnel and TLS on a first Test
  and not on a second, which reuses the pooled connection.
- The provider editor's Saved mode has a Test beside the proxy picked;
  its answer is said where the picker's hint is, red on failure, until
  another proxy or mode is chosen.
- An editor opened before Settings was read drew its picker with no
  saved proxies (Saved mode missing, or "A proxy that is gone" for one
  chosen). It now reads the settings and draws the picker again.
- Nothing is tested until Test is clicked; nothing runs in the background.

Run (at this head's tree, rebased on c687dbdc6):
- mote: go test ./internal/gui -count=1 -timeout 45m: ok (182.9s);
  -run 'TestSavedProxy|TestProxyCheck' -race ok.
- mote: GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...
  ok; gofmt -l clean; TestCoreScriptBudget room 21 bytes, no raise.
- mica: provider-proxy-pick-test (new, 20 cases: chromium and webkit, en
  zh zh-TW ja de, 900 and 420px) 20/20; saved-proxies, saved-ssh-proxy,
  provider-proxy, i18n-keys, old-webkit pass.
- mica: whole GUI suite, still running at push: 3736 tests in, 127 red,
  none in a proxy or provider file. The reds are files red on
  origin/main: agent-details-ready and data-folder were run alone at
  c687dbdc6, 14 pass 42 fail (#6369, #6373, #6876); account-refresh-holds,
  account-arrange (#6003, #5814), api-key-theme (#6444) and the rest are
  the files another session is rerunning on mote as main's reds.
- Broken by hand: the round-trip branch off, TestSavedProxyLatencyIs
  TheRoundTrip went red ("took 1601 ms", the fake's 1.5s dial counted).

Tests reach no network: a local fake proxy answers the trace page, the
trace URL is .invalid, and the dial delay is injected.

Not tried: a real proxy's exit (the region comes from Cloudflare's loc=).
Not changed: the global proxy check in Settings still shows the raw
country code (ip (JP)).
2026-11-18 06:42:01 +08:00
..
2026-11-10 03:25:44 +08:00

Subsystem design references

These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.

Subsystem Reference
Built-in subscriptions moving to plugins Provider and plugin ownership
Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) Plugin runtime
Plugins that run on the gateway's requests and replies Gateway middleware
Tools that plugins give, offered to every agent as an MCP server Plugin tools
Plugins that await context recall and observe completed replies Asynchronous gateway request hooks
Claude subscription turns across Claude Code runs Claude subscription bridge
How the gateway picks a provider, key or account, and falls back Gateway routing and fallback
Gateway Session Aggregation Gateway Session Aggregation
Connecting an agent's config to the gateway, drift, disconnect, WSL twins Agent wiring
Providers, keys, subscription accounts, refresh and allowance Providers and accounts
Instructions, MCP servers, skills and RTK written into agents Library
One MCP server, magpie, given to every agent in place of the Library's servers MCP router
Memory shared by every agent: the memory MCP server, the digest in instructions, the Memory tab Memory
One skill, magpie-skills, listing the Library's skills in place of each agent's own Skill router
Tray, panel, window, magpie web and the page's JSON API GUI app shell
Encrypted backups and setup synchronization over WebDAV, S3 or GitHub Sync and backup

A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.

Maintain a reference

Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.

Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.

For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.

Describe a PR's semantic changes

For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.

For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.

This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.

Review a change

  1. Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
  2. Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
  3. Check that changed contracts appear in the owning reference and that source links still resolve.
  4. Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.

A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.