1ccacad63281094de8a3372d5a507d38f9969e5c
77
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
4167419abf |
site: breadcrumbs in every docs page's structured data
Each docs page in en, zh and ja (98 pages, contributors left out) gets a schema.org BreadcrumbList: magpie (the language's home page) > Docs (that language's start page) > the page's h1. Search results can then show the path instead of a bare URL. The eleven pages that had no JSON-LD at all (docker, remote, intent, plugins, import, integrate, library, mcp-router, masking, start, privacy) also get a TechArticle built from their h1, meta description and canonical URL, like the other pages. zh pages' inLanguage is zh-CN everywhere, as the older pages had it. Existing JSON-LD is only appended to (the diff has no deletions besides the inLanguage fix). Run: every docs page's JSON-LD parsed with node (98 with a BreadcrumbList); mote: node --test worker.test.mjs install.test.mjs: 71 pass, 0 fail. Not tried: Google's Rich Results Test on the deployed pages. |
||
|
|
d681ad016e |
site: docs titles say what each page is for
Ten docs pages (docker, remote, intent, plugins, import, integrate, library, mcp-router, masking, start) had one-word titles like "Docker · magpie docs", in en, zh and ja. Docker and remote are among the most read docs pages, and Search Console shows searches such as "局域网远程" and "magpie docker" with no title matching them. Each <title> now names what the page does; h1, og tags and the article are unchanged. Run (mote): node --test worker.test.mjs install.test.mjs: 71 pass, 0 fail. Not tried: how Google rewrites the titles in results. |
||
|
|
016763f237 |
plugins: host.js passes a usage window's pool and family on, so Antigravity's card shows its pools (plugins#935)
mk311 (plugins#935): the Antigravity plugin's Usage card listed every
model's own window (13 rows, each Gemini one at 85.1%, Claude and
GPT-OSS at 100%), then a bare "7 days" and "5 hours" twice. The plugin
(0.1.0) already groups them as the built-in did: each model's window
carries its family and its pool ("Gemini", "Claude & GPT"), each pool's
own 5 hours and 7 days carry the pool.
|
||
|
|
86825005e2 |
plugin: a gateway hook given more than 10s gets up to 30s (#5890)
gatewayTimeoutMs was capped at 10000 and the Go side cut every hook RPC at 11s, so a recall hook (Nowledge Mem) asking for 15s was cut at 1s (any value over 10000 fell back to the default) and could never finish. - host.js: gatewayTimeoutMs takes integers 100-30000; a value outside is clamped to the nearer bound, a non-integer gets the 1000 default. gatewayBudget() is the old chain budget (sum, clamped 2-10s) or the longest hook's own timeout, whichever is larger. With no hook over 10s nothing changes. - gateway.go mirrors both (gatewayTimeout, gatewayBudget, cached with the HasGateway scan). GatewayBegin's request RPC, Finish's completion RPC and GatewaySignIn now wait the budget plus 1s, never less than the old 11s; host startup and the lock wait stay bounded at 11s. Caller cancellation still reaches the hook at once, a failing hook still rolls back, and the request-state limits are unchanged. - Docs: gateway-request-hooks subsystem page, plugins docs (en, zh, ja). site/public/llms-full.txt regenerated with `node llms-full.mjs`; it was already stale on origin/main (OpenCode 2 keys, billion-context tab, data-folder move, vendor presets, group rule), so those docs pages' text lands in it too. Run on mote at this tree (base 03a800ac6; origin/main has one newer commit touching none of these files): - gofmt -l internal/plugin internal/gateway: clean - go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: rc 0 - go test -tags nogui -count=1 -timeout 45m ./internal/plugin/... ./internal/gateway/...: ok plugin 161.6s, ok gateway 897.0s - site: node --test worker.test.mjs: 38 pass (llms-full red before the regeneration) New tests (internal/plugin/gateway_budget_test.go): a 12s onRequest and onResponse with gatewayTimeoutMs 15000 both land (24.2s); the default and 10000 are still cut with outcome "timeout"; two 8000ms hooks still share 10s; 130000 is clamped, not dropped; cancelling a 15000ms hook's request stops its fetch at once (0.07s); the Go mirror matches host.js. Broken by hand, each red: - A host.js as on main: SlowRecall red at 1.10s, Clamps red - B Go RPC kept at 11s: SlowRecall red at 11.04s, Mirror red - C chain capped at 10s: SlowRecall red at 10.13s - D default per-hook 30000: DefaultStillCuts/default red - E caller signal off the begin chain: LongBudgetCallerCancellation red - F chain budget 30s for every config: ChainStillTenSeconds red Not tried: a real Nowledge Mem server; the full ./... suite; GUI tests (no GUI change); a Windows or Linux runtime run (vet only). Reported-by: aboat0625-cpu |
||
|
|
9309e28ced |
plugins: a plugin's provider in front of a vendor's API is that vendor to the gateway (songlairui on X, #5462, #5464)
A plugin whose provider's `api` is on a vendor's preset host (a Mistral Vibe plugin's https://api.mistral.ai/v1) got none of what magpie does for that vendor, since its Host() is the plugin's id. An earlier turn's thinking went to the plugin's fetch as reasoning_content, and Mistral turned the whole request away (422 extra_forbidden); the plugin had to rewrite the body itself. provider.VendorHost and VendorPreset now resolve a plugin's declared `api` host to the preset that names it (every Chat, Responses and Anthropic base of every preset and region; local and remote magpie presets excluded, and an api on loopback, a private address, .local or .localhost names no vendor). For every other provider, and a moved subscription, they are Host() and Preset as before. The gateway's vendor checks read them: 38 p.Host() sites, Mistral's, OpenRouter's, DeepSeek's, Kimi's and DashScope's preset checks. Host() stays the plugin's id where calls are kept and shown; requests still go only to the plugin's fetch. Search and the video plan check are unchanged. No community plugin's api is on a preset host today (checked at plugins 7b52e3fc), so none changes. Any plugin gets this with no new field; documented in docs/subsystems/provider-plugins.md and the plugin docs (en, zh, ja). Run (mote): go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows; go test -count=1 -timeout 45m ./internal/provider ./internal/plugin ./internal/gateway: ok (provider 209s, plugin 182s, gateway 1002s). gofmt -l clean. Broken by hand: pluginVendor resolving nothing (the old behaviour) turns TestPluginVendor red, and TestPluginInFrontOfMistralIsMistral red on both halves: the translated Claude Code turn is answered Mistral's 422 extra_forbidden, and the relayed Chat request carries reasoning_content. Not tried: a real Mistral Vibe key through the reporter's plugin; Windows and Linux runs of the tests (no OS-specific code). |
||
|
|
ab3710de3a |
hooks: onSignIn tells a request hook of an account to sign in again
shannnnnks on X: with several Codex accounts behind the gateway, one is
now and then signed out, and they want the notify plugin to push it.
The magpie that serves the gateway now looks every 2 minutes (first
after 1) at the same sign-in states the desktop alert reads
(provider.WatchSignIns' checkSignIns, so every provider: Claude, Copilot
and plugin accounts that lapsed, and built-ins whose mark says the
sign-in expired or must be done again, Codex's revoked and refused
refreshes among them; accounts in use only). Each account to sign in
again, and each Claude sign-in ending within days, goes to every hooks
file that exports onSignIn, once until the account works again, kept in
signin-hooks.json beside the desktop alert's own file. The event is
{provider, providerName, account, state: "signed-out"|"ending", endsAt?}:
the account is its display label; no token and no vendor reason text.
It is fire-and-forget in the Bun host (gatewayRequest operation
"signIn"), each hook under its own timeout, one that throws doesn't stop
the next. With no hooks file nothing is looked at or marked. A hooks
file may now export onSignIn alone, without onRequest.
Docs: gateway-request-hooks.md (Sign-in notification),
providers-accounts.md, site plugins.html en/zh/ja.
Run on mote at d939dd699 (on origin/main 835439ebf; then rebased on
|
||
|
|
a6e4cf7635 |
settings: what routing does sits under Models › Routing, and the Routing page opens it
The scattered settings audit after netube99 on X. Ask again after a
refusal, the Retry-After cap and the intent classifier's timeout were
under Models › Replies beside rows about a reply's content, and Busy
models last sat in Network and sharing, far from the routing it changes.
The four are now one Routing section under Models, after Replies, and the
Routing page's header has a Settings › button that opens Settings at that
section with its first row lit. The docs (reference.md, the site's
plugins page in en, zh and ja) name the new place.
Run (mote, mote-run):
- settings-places, retry-after-cap-setting, refusal-retries-setting,
classify-timeout-setting, model-load, i18n-keys and bare-ids, both
engines: all pass.
- mobile-web against origin/main
|
||
|
|
8a58c0e307 |
site: a fair comparison of magpie, CC Switch and Claude Code Router (docs/alternatives, zh, ja)
New docs page in three languages: a summary of each tool, a table (agents, how it switches, protocol translation, subscription sign-ins, routing and failover, GUI and CLI, platforms, license), which one fits, and an FAQ with FAQPage JSON-LD. Linked after "Models in OpenCode" in every docs page's nav and footer, in sitemap.xml and llms.txt. CC Switch and CCR facts come only from their own READMEs (fetched raw, Nov 2026); each column is dated. Cells their README doesn't cover say "not stated": CCR subscription sign-ins, CCR macOS signing, CC Switch CLI. magpie facts from its source and llms.txt. Run: mote-run site tests (worker.test.mjs install.test.mjs), 69 of 69 pass. Generator: magpie-wt/seo-scratch/altgen.py. |
||
|
|
80ccaba641 |
site: guide to other models and subscriptions in OpenCode (en, zh, ja)
New docs/opencode-models in English, Chinese and Japanese: DeepSeek, Kimi, GLM, Qwen and Claude/ChatGPT/Copilot sign-ins in OpenCode, what magpie writes in opencode.json (internal/agent/agents.go openCodeLike, magpieProviderJSONAt), small_model, reasoning variants, cost, magpie visible, magpie opencode default. Linked from every docs page's nav and footer, sitemap.xml and llms.txt. Run: mote-run sh -c 'cd site && node --test worker.test.mjs install.test.mjs': 69 pass, 0 fail. Not tried: a real OpenCode run against the page's steps. |
||
|
|
0ac8e6634d |
site: guide to local models in Claude Code and Codex (en, zh, ja)
/docs/local-models and its zh and ja pages: Ollama, LM Studio, oMLX and MLX-Serve presets with their default addresses and the APIs magpie uses for each, which agent goes through as is and which is translated, another port or computer (Server address, the certificate switch), vLLM and llama.cpp through Custom + Detect APIs, the context window and masking. Linked from every docs page's nav and footer, the sitemap and llms.txt. Facts read from the provider presets, internal/cli/providers_cli.go's help text and i18n.js labels. Left out for lack of evidence: detecting a running Ollama, Ollama's default num_ctx, how well local models call tools, default ports for llama.cpp and vLLM. Run: mote-run sh -c 'cd site && node --test worker.test.mjs install.test.mjs' at this tree: 69 pass, 0 fail. |
||
|
|
8f74442e4d |
site: guides for other models in Gemini CLI and subscriptions in any agent
New pages, en and zh, built on the claude-code-models template (same
head, nav, footer, TechArticle + FAQPage JSON-LD, canonical, hreflang):
- /docs/gemini-cli-models: pointing Gemini CLI at the gateway's Gemini
API, the four keys magpie writes, going back to Google, subscription
models in Gemini CLI, routing.
- /docs/subscriptions: the built-in subscriptions and their model
prefixes, sign-in, using one in another agent, several accounts,
routing modes and fallback, other tools through the gateway.
Every docs page (en, zh, ja; ja links to the English URLs) gets the two
nav and footer links after the Codex guide, the 4 URLs go in
sitemap.xml and the 2 English ones in llms.txt, as
|
||
|
|
082ca55a32 |
site: guides for other models in Claude Code and Codex
Google sends 6,140 clicks in 28 days, every one on "magpie" or a misspelling of it: no one finds magpie by searching for what it does. These two guides, in English and Chinese, answer the searches it should win: "claude code deepseek", "Claude Code 接入国产模型", "codex kimi", "Codex 使用第三方模型". - docs/claude-code-models and docs/zh/claude-code-models: why Claude Code needs a gateway, the setup in the app and the CLI, how the opus/sonnet/haiku/fable tiers map, every settings.json key magpie writes and how it is undone, GPT models from a ChatGPT or Copilot sign-in, several keys, and an FAQ. - docs/codex-models and docs/zh/codex-models: the same for Codex, with /model's catalog, the two shapes of config.toml (signed in to ChatGPT or not), going back, Claude in Codex. - Each page has TechArticle and FAQPage JSON-LD, canonical, hreflang (en, zh, x-default) and og tags. Both are in every docs page's nav and footer, in the sitemap and in llms.txt. Every claim is checked against internal/agent/claude.go, codex.go, internal/codexcat, internal/provider/presets.go and the gateway, or taken from docs/start.html (Copilot models in Claude Code). No ja pages yet; the ja nav links the English ones, as it does for integrate. Run: node --test worker.test.mjs install.test.mjs on mote, 69 pass. |
||
|
|
922cc0ccf8 |
library: a plugin's tools hidden from every agent from its Plugins row
chengming0v0 (Discord) keeps a plugin for its providers but doesn't want
the MCP server it brings (minimax_query_video_generation and the rest)
shown to agents, and doesn't want to remove the plugin.
Before: a plugin that gives tools is a Library server of its own
(plugin_tools.go), switched per agent with the row's chips in Library ›
MCP, which held through updates and off/on. Nothing on the Plugins page
said so: its line read "Tools for every agent" whatever the Library had,
and an app at the router's address (/mcp/magpie/hub, agent "") was given
every server, ticked for any agent or none, so taking every chip off
still left the tools there.
Now:
- The plugin's tools line says "Tools for agents" or "Tools, hidden from
agents", with Hide from agents / Give to agents beside the copy button
(plugins.js, toolsServer in /api/plugins from library.PluginServers).
- PluginServerOn (servers/plugin-on {name, on}) sets Server.Hidden and
keeps the agents it had in Paused. Hidden, no agent is given it and
hubServers leaves it out for the router's address too. Give to agents
gives the kept agents back; with none kept, the router's agents
(hubAgents), or else every shown agent that can take it.
- It holds through a plugin update, the plugin off and on, an edit in the
Library editor (SaveServer keeps it) and an agent's "every server"
(serversAgents with no names skips a hidden one). Ticking an agent for
it in Library › MCP shows it again (save clears Hidden).
- Library › MCP tags the server "Plugin", its tooltip pointing at Plugins.
- /mcp/magpie/tools (every plugin's tools, wired by hand) is unchanged.
- Docs: plugin-tools.md, mcp-router.md, site docs plugins (en, zh, ja).
- The core script budget is not raised: two plugins.js comments cut, the
button's tooltips and status lines left out.
Run on mote at this tree (before the site docs, html only):
- go build ./..., go vet ./internal/library ./internal/gui, GOOS=windows
go vet of both, GOOS=linux go vet ./internal/library: ok.
- go test -count=1 ./internal/library/: ok (187s).
- go test -count=1 ./internal/gui/ -run 'Plugin|Library|Budget|Script':
ok (TestCoreScriptBudget 1,533,514 of 1,533,802).
- node --test plugin-tools.test.cjs (new: the line's words, Hide and Give
posting {name, on}, the button inside its row at 980 and 420, all five
languages, Chromium and WebKit): ok; builtins, every library-mcp-* and
mcp-* file: ok.
- i18n-keys "a plugin's words are its own": red, the same three words on
origin/main
|
||
|
|
1fd02d33ce |
agentplug: an agent plugin can pick the model its agent starts on in a second file (str_, PiG)
str_ on Discord (#help, v0.1.3005): PiG's row on the Agents page only
switched the model list on, where Pi's picks the model it starts on.
PiG, like Pi, keeps its providers in ~/.pig/agent/models.json and the
model a session starts on in settings.json (defaultProvider,
defaultModel; PiG's docs/site/docs/settings.md, startup_model.go). An
agent plugin could name a model key only in the one file connect
writes, so agent-pig 0.1.0 had to be connect-only.
An agent's descriptor can now say `startup: {config, format, model,
keys}`: the other file, the key that holds the model (the id without
magpie's prefix) and keys written beside it. With it the row gets a
model field as a built-in's does. Picking one of magpie's writes
connect's keys into config and the model and keys into startup.config,
each key kept aside as before; a model of magpie's picked in the agent
itself still reads as magpie's; a model of the user's own picked there
while magpie's provider is listed counts as connected (Beside), not
drift, and is kept on disconnect. Sync rewrites the list and leaves the
startup model where it is. Off, or `magpie <id> default` with the plugin
gone (RestoreGone), puts both files back. startup without connect, beside
agent.model, in config's own file, or naming the model key among keys
is refused. An older magpie ignores the field, so agent-pig 0.1.1
(plugins repo) stays connect-only there. Every other agent plugin
already names its model in its own config; pig is the only
connect-only one.
Run (mote):
- go test -count=1 ./internal/agentplug/: ok
- go test -count=1 -run 'TestPlugged|TestPlugin|TestRestoreGone|TestAgent'
./internal/agent/: ok
- go vet, GOOS=linux and GOOS=windows go vet of both packages; gofmt -l
clean
- the four TestPluggedStartup* tests on the old code: red (the row had
a provider field and only listed models)
- real PiG 0.5.3 (darwin-arm64 release, SHA256SUMS checked) in a sandbox
HOME, models.json written by agent-pig 0.1.1's own connect and
settings.json as startup writes it, against a fake OpenAI server:
`pig -p` sent model deepseek/flash with the gateway key. With an
enabledModels scope that leaves it out, PiG started on the scope's
first model (said in the plugin's README).
Broken by hand: no startRestore in Unwire (TestPluggedStartupModel and
OwnPickKept red); no Beside (OwnPickKept red, "wired false").
Not tried: the GUI and the TUI with the real row (app.js unchanged; the
row is the model field every built-in has), Windows and Linux runs of
PiG, a real magpie gateway in front of PiG, a real vendor model.
|
||
|
|
ed7aeb052f |
plugins: a package that declares magpie.agent is an agent, with a main or without (plugins#737)
miaocell's magpie-agent-deva ships a Bun module as its main beside its moejs agent file (deva.agent.js), because the agent needs a runtime. The market's GitHub list decided the kind by whether a main was there, so it listed the package under Providers, and the Installed row wore a Provider chip and a provider logo though the module serves no provider. Now readTagged gives Kind "agent" to any package that declares magpie.agent; middleware, page and hooks still need no main to be that kind. The file looked for in the repository is still the module Bun loads (its main), or the agent file when there is no main. The Installed row of an agent plugin wears Provider only when its module serves a provider, and its logo is the agent glyph unless it does. The moejs descriptor contract is unchanged. The community registry.json already gives kimi-desktop and reasonix-desktop (both with a main) kind agent; the plugins repo's check now fails an agent package listed as any other kind. Docs: docs/reference.md, docs/subsystems/provider-plugins.md, and site/public/docs plugins.html in en, zh and ja say an agent that needs a runtime keeps its agent file and adds a Bun main, and is listed as an agent either way. Run (on mote, at this head rebased on |
||
|
|
6bef4fe043 |
docs: a Library page in en, zh and ja, linked from every docs page
luckymanjc. on Discord asked for one place that says how the Library
works underneath and how to set it up. site/public/docs/library.html
(and zh/, ja/) covers each tab: where it is kept (library.json, library/,
backups/ with the last 30), instructions and their markers, MCP servers
(per-agent files, ${NAME} variables, SSE limits, single tools off, OAuth
through /mcp/<name>, link to the MCP router page), skills (folders per
agent, links vs copies and how a copy's edit is taken back, editing,
the 12h update check, ~/.agents/skills, off here), subagents (file per
agent, which agents bind skills/MCP servers, agents with none), the
subagent model (written for Codex only, laid over the spawn; the Agents
page's Codex subagent model with Lead's pick / Same as the lead / a
model, which wins over the Library's; default_subagent_model; the
ChatGPT-sealed exception; Claude Code's own order), hooks and RTK.
Every fact was read from internal/library, internal/gateway and
internal/provider codex_subagent.go, internal/agent/codex.go and the
Library page's client.js and i18n, not guessed. The nav (toc-only) and
footer of all 32 docs pages and the sitemap link the three pages.
Run (mote, through mote-run):
- a Playwright script serving site/public, in Chromium and WebKit at
1280px and 400px, on all three pages: h1, docs.css loaded, 4 tables,
no sideways scroll (scrollWidth - innerWidth = 0), every toc and
in-page anchor has its id, no 4xx on any asset, no page errors, no
left border or gradient in the article, the language menu goes to the
sibling pages; every local link on the pages resolves to a file
(except /zh/ and /ja/, which the worker serves; checked live after
deploy), and every docs page links /docs/<lang>/library twice. ok.
Screenshots looked at for desktop en and 400px zh.
- node --test site/worker.test.mjs: 30 pass, 0 fail (it includes the
sitemap-lists-every-docs-page-with-its-own-canonical test).
Broken by hand: the first script run had a wrong toc selector and
counted the toc-only nav links as missing anchors; fixed the script,
not the page.
Not tried: no Go code changed, so no go test. The Library page's
"Copies" note still says "edits made in a copy are replaced", while
skill_edits.go takes the newest edit into the library; the docs follow
the code.
|
||
|
|
cbb09383fb |
plugin: a GitHub-tagged package's card says its own name and summary (#3608, plugins#394)
MYCF711's #3608 (and plugins#394): a repository tagged magpie-plugin outside the community's list showed its repository's name and GitHub's description on its card under Discover → Unofficial, on GitHub, whatever its package.json said of itself. Ported from MYCF711's 1cc337001. Now readTagged keeps package.json's magpie.name (ownName, as main's row already does since |
||
|
|
441a2b6b16 |
plugin: a cancelled sign-in saves nothing, and a failed authorize says why (#5016)
Found reviewing magpie-community/plugins#658 (AStudio's and Agnes Code's
sign-ins wait up to 5 minutes for the vendor's desktop app).
Cancel didn't end a plugin sign-in. The window's Cancel (and the sign-in's
timeout) ended plugin.Finish's context, but "callback" was not a
cancellable call, so the host never heard: the plugin's wait went on, and
a session file written after Cancel still saved the account. Now
authorize, callback and apiKey are cancellable as gatewayRequest is
(host.go `cancellable`): magpie writes `abort`, host.js (`signInSteps`)
drops whatever the plugin answers after it, so nothing is saved, and
counts the call done at once. The plugin's wait is told too: every fetch
it makes for the sign-in carries the sign-in's signal
(`whileSigningIn`), and magpie's hook passes the signal as
callback(code, { signal }) / authorize(inputs, { signal }), which OpenCode
doesn't, so a plugin can stop polling a file. A plugin that ignores the
signal keeps running until its own deadline, but its answer is dropped.
An oauth method's authorize that returned { type: "failed", error } (no
callback) was stored and its missing callback called, so the user saw
"s.a.callback is not a function". host.js now answers that, or any result
with no callback, as the sign-in's failure, and plugin.Authorize returns
ErrFailed with the plugin's reason, for auto and code methods; an api
method's authorize already did. The GUI's start shows it as its failure,
`magpie plugin login` prints it.
Docs: provider-plugins.md, and the plugin guide (en, zh, ja) on failing
from authorize and the signal.
Not changed: #3083's timeout field, #4678's model/usage task lifetime.
Tests (testdata/signinend, no network; the vendor is testenv.FakeVendor):
TestCancelledSignInSavesNothing, TestCancelledSignInEndsThePluginsWait,
TestCancelledSignInEndsItsFetch, TestSignInFailsWithThePluginsReason
(internal/plugin), TestCancelledPluginSignInSavesNothing
(internal/provider, through StartPluginSignIn/CancelSignIn).
Run on mote (macOS 27), at this change on
|
||
|
|
1747559d02 |
plugin pages: name the scheme in a browser's policy, and the service's 'self' (#4198)
In `magpie web`, iOS Safari (18.7) loaded none of a plugin page's scripts: pagePolicy named the page's folder as a scheme-less host-source (host/_magpie/plugin/<tok>/), a sandboxed frame's origin is opaque, and that WebKit took the missing scheme from it, so the bridge never said hello and the page was broken at 10s (orinsid; YangHonghang on v0.1.2681, young02036 on Discord). - pagePolicy: a browser's policy now names the folder under both https:// and http:// (ownSources). Behind nginx or Cloudflare TLS ends before magpie and nothing magpie trusts says which scheme the page came over, so X-Forwarded-Proto is not read; both name the same host, port and folder, and an https page can't load http:// files anyway. The desktop window keeps its own transport alone (wails://, http:// on Windows, #2501). - The second layer (YangHonghang): a page's local service sends its own policy, `connect-src 'self'`, and what it sends runs under magpie's `sandbox allow-scripts`. In WebKit, 'self' there didn't match the service page's own fetch of api/x. servePageService now names the service's root (/_magpie/plugin/<tok>/_magpie/service/) under both schemes after each 'self' in a CSP header the service sends, plus ws:// and wss:// in connect-src and default-src (serviceSelf). 'self' stays, so nothing allowed before is taken away. A <meta> policy isn't rewritten; the plugin docs (en, zh, ja) say to write whole sources. Run at f0a723d4c's tree (rebased on |
||
|
|
e7fbbaab9f |
plugin: an author's own listing is kept, for a search to find (plugins#479)
On magpie-community/plugins#479 the owner ruled that registry.json
entries for packages published from their author's own repository
rightly leave out "community": true, and are shown under the
publisher's name, to a search alone. parseMarket dropped every entry
without the flag, so PinK (YuchenWell, plugins#617), and WispTerm,
CiteBox and Wisp Science (hoptoper) couldn't be found in magpie at
all.
What changed:
- parseMarket keeps a listing without the flag; Listing.Community
says which it is. The new plugin.Community(l) picks the community's.
- Every reader of the market was re-derived:
- plugins.js already browses community listings alone, matches a
search over every listing (name, package, summary, providers, npm
publisher), and shows a non-community card and page under its npm
publisher, without the magpie community badge. Unchanged.
- plugin.resolve (a short name like "river") reads the community's
alone: an author's "pink" stays npm's own name "pink".
- pluginAgents (/api/plugins/agents, the Agents page's suggestions)
reads the community's alone, as Discover's Agents section does.
- plugin.Icon's fallback by provider id reads the community's alone;
its exact-package match reads all, so PinK's own icon shows.
- pluginListings and pluginMarketState pass every listing on.
- Docs (en, zh, ja plugins.html) say such a package isn't browsed and
is found by a search, under its publisher.
Tests:
- TestMarketKeepsAuthorsOwnListings parses registry.json's River and
PinK entries as they are at plugins 486a68a5 (#617's base, lines
126-130, PinK without the flag; testdata/registry-pink.json). PinK is
kept, not community, with its kind, summary and icon; resolve("pink")
is "pink" and resolve("river") the community's package.
- TestMarketSources now expects the non-community entry kept.
- plugin-authors-listing.test.cjs: PinK isn't browsed (Agents shows
Kilo, no PinK anywhere), a search by name or publisher shows one PinK
card under "zhouzhenzhou" with no badge, its page reads
"zhouzhenzhou · magpie-plugin-pink" with no badge, River keeps its
badge. en, zh, zh-TW, ja, de; 980 and 420 wide; chromium and webkit.
Broken by hand, each red, then put back:
- parseMarket's `&& l.Community` restored: TestMarketSources and
TestMarketKeepsAuthorsOwnListings red.
- resolve without Community(): TestMarketKeepsAuthorsOwnListings red
(pink resolved to magpie-plugin-pink).
- pluginAgents without Community(): TestPluginAgentsNotInstalled red.
- plugins.js Agents without the l.community filter, and the badge shown
for every agent: plugin-authors-listing 0/22 each.
Run on mote at this head (rebased on a4916aec1; i18n-keys and plugin-authors-listing ran again there, both engines):
- gofmt -l: clean. GOOS=linux go vet -tags nogui and GOOS=windows go
vet of internal/plugin and internal/gui: ok.
- go test -timeout 45m internal/plugin, internal/provider: ok.
internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949,
mote's macOS 27, nothing here touches it).
- At 3086c650b (rebased on 541102eba; the rebase since touched
host.js, a gateway test and a provider test only): agent, agentplug,
backup, davsync, library, middleware, usage and plugins/...: ok.
cli: TestEveryRouteHasACommandOrIsNamed (#4826); gateway:
TestCodexPoolSaysTheClientsVersion (#4807). Both filed, untouched
here.
- node --test site/*.test.mjs: 80/80.
- GUI, every file that reaches the Plugins page (agent-plugin-agents,
i18n-keys, market-*, plugin*; 1078 tests, both engines): 1074 pass,
plugin-authors-listing 22/22. The 4 reds are plugin-move-unserved's
"Try again takes the models unticked" (#4410, models folded behind
"Show the other"), not reached here. The whole GUI suite wasn't run:
mote held two other sessions' full suites for over an hour, and this
changes no app.js, plugins.js, layout or API call. That run was at
f5c956b84; after the rebase on
|
||
|
|
c3048cd266 |
site: a sitemap, robots rules, a searchable title and canonical docs pages
usemagpie.ai had no sitemap, a robots.txt with Cloudflare's comments
only, a home page titled just "magpie" in every language, and docs
pages with no canonical or x-default.
- public/sitemap.xml lists the home page in en, zh, ja and de and every
docs page by its clean URL. A test fails when a docs page on disk is
missing from it, or it lists one that isn't there.
- public/robots.txt names the sitemap and keeps crawlers off /api/,
/go/, /r/ and /download, so a crawler's fetch isn't counted as a
download or a partner click.
- The home <title>, og:title and twitter:title name the agents
("magpie: one model switcher for Claude Code, Codex and Gemini CLI"),
translated by worker.js like the rest (meta.title, meta.locale in
i18n.js). og:type, og:site_name and og:locale are added, plus JSON-LD
for a free, MIT-licensed SoftwareApplication and the WebSite.
- Each docs page has rel=canonical to its own clean URL and an
x-default alternate to the English page, plus og:site_name. A test
checks each one, and that every hreflang alternate is a listed page.
Run: on mote, node --test worker.test.mjs install.test.mjs from site/
at this tree: 54 of 54 pass. Broken by hand in a copy: a docs page
without its canonical, and the sitemap without docs/zh/docker, each
turns the sitemap test red.
Not tried: Google's Rich Results test; the live check is after deploy.
|
||
|
|
dac759e54c |
site: a contributors page, everyone magpie's history credits with the releases that came of it (packinggoodsllc_07668 on Discord)
usemagpie.ai/docs/contributors, /docs/zh/contributors and
/docs/ja/contributors list each person the release notes' thanks line
would (the previous commit's rules), with the versions their reports,
ideas or code went into, newest first: three shown, the rest under
"N more", each linking its release. A name with a known GitHub login
links it; the platform a report came from (Discord, X, …) sits under it.
How it is built: wrangler.jsonc's build runs `node credits-cli.mjs wall`
at each deploy. It reads every tag's commits from git, the issue authors
from GitHub (reusing the last build's answers), and writes
public/contributors.json and the table in each language,
public/contributors/{en,zh,ja}.html (gitignored). worker.js puts that
table into the page's #wall with HTMLRewriter; without it the page keeps
a line pointing at the release notes. A build that can't read git leaves
the last list. The page says how names are found (only as already public
in the history, no emails, no maintainer, agents or bots) and how to be
left off: Discord, an issue, or a PR to site/contributors-exclude.txt.
Every docs page's footer and the home page's (foot.contrib in zh, ja, de)
link it. Styles reuse docs.css's table and tokens.
Run (mote, node 22): node --test site/*.test.mjs 77/77. The wall on a
clone of origin/main
|
||
|
|
66c0ddc19a |
gui: Busy models last takes a custom threshold, 1 to 9999 (axelburks)
axelburks on Discord: a vendor that queues reports loads past 100%, and
the only way to a threshold such as 150 was settings.json. Settings ›
Network and sharing › Busy models last now ends in Custom…, one more
choice in the same in-app switch (no <select>). It opens a small field
in the row whose sub says what the number means: a load in percent as
the plugin reports it, 100 is all the vendor serves at once, past 100
requests queue (200 is twice that), 1 to 9999. Enter or Apply saves it
through settings/busy-load, Escape or Cancel closes it untouched. A
value that is not a whole number from 1 to 9999 is said in red in the
sub and nothing is posted; the field keeps it to correct. The number
saved shows as its own choice ("Over 150%"), and Custom… opens with it
filled in. The site docs (en, zh, ja) and gateway-routing.md say
Custom… instead of settings.json. Code in plugins/gateway/settings.js
and i18n.js only, so the core budget is untouched.
Run on mote at this tree:
- node --test model-load, i18n-keys, bare-ids, gateway-port: all pass.
model-load's new test runs in Chromium and WebKit, at 420 and 900, in
en, zh, zh-TW, ja and de: Custom… focuses the field, says what the
number means, refuses abc, 0, 10000, 1.5 and -3 with nothing posted,
Escape closes, 150 posts {at:150} and shows Over 150% picked, 2000 by
Enter replaces it, the row and settings don't run sideways, and no
press moves the page more than the row changed height.
- go test ./internal/gui -run Budget: ok. gofmt -l: clean.
Broken by hand: validation turned off (if (false)) went red in every
language; the Custom… entry taken out went red in the old and new
tests; the field without flex:none was squeezed to ~20px and the width
check went red.
Not tried: the real app window (only Playwright's engines), and the
full GUI and Go suites, which run after the push (one suite on mote at
a time).
|
||
|
|
7503beee72 |
plugin, settings: a model's load goes past 100% for a vendor that queues (axelburks on Discord)
axelburks, on v0.1.2547: their vendor queues, so a model's load can be
past 100%, even 200%. magpie clamped every load to 100, and Busy models
last allowed 1-99 only.
- host.js reportLoad and plugin.noteLoads keep a load from 0 up. The
floor is still 0, null still clears it, and a sanity cap of 10000
(LOAD_MOST, plugin.LoadMost) keeps an absurd value from reaching the
UI or the trace.
- settings.BusyLoad takes 1 to 9999 (BusyLoadMost-1). The segment
choices stay Off/50/70/80/90, and a value set in settings.json (150)
shows as its own choice, as before.
- The editor's badge reads "180%". It is a badge, not a bar, so nothing
assumed 100 wide; the test checks it stays on one line.
- Docs: site plugins page (en, zh, ja) Values and Routing bullets, and
provider-plugins.md and gateway-routing.md.
Run on mote via mote-run, on origin/main 8d8df0639+ rebased:
- go test ./internal/plugin ./internal/gateway ./internal/settings -run
'ModelLoad|TestBusy' -v: all pass. TestPluginReportsModelLoad has
over:250 kept and huge:1e9 at 10000. TestBusyModelGoesBehind has 180
behind 120 at a threshold of 150, and 10000 refused.
- Broken by hand in a copy, with the old 100 clamps and the 99 limit:
TestPluginReportsModelLoad red ("ModelLoad(over) = 100; want 250"),
TestBusyModelGoesBehind red (150 refused).
- node --test model-load (with Queued 180% in every language, Chromium
and WebKit, 420 and 900, plus Over 150% picked at 420) and i18n-keys:
46/46 pass. go test ./internal/gui -run Budget: ok.
- gofmt -l: empty. GOOS=linux go vet -tags nogui and GOOS=windows go
vet on plugin, settings and gateway: ok.
Not run before the push (owner: push and tag first): go test ./... and
the whole GUI suite. They are queued on mote behind another session's
suite.
|
||
|
|
8d8df06399 |
plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.
- A provider plugin calls input.magpie.load(provider, {"<model id>":
0-100 | null}) whenever it likes, from its own timer. host.js
(reportLoad) clamps each number to 0-100, null clears a model, every
other value is dropped, at most 1000 a call, and it returns the count
taken. A provider that isn't a string or loads that isn't an object
throws a TypeError. It goes to Go as an unasked {event:"load"}.
- internal/plugin/load.go keeps each by provider and lowercased model
id. ModelLoad answers unknown once a load is older than LoadFresh
(5 minutes), never idle. model@size falls back to its model.
- The provider editor shows it by the model as a grey ctx badge
("87%", titled "87% busy now, as its plugin says").
- Settings > Network and sharing > Busy models last (settings.BusyLoad,
POST /api/settings/busy-load, Off by default, over 50/70/80/90% or
1-99 by hand): restLast puts a model reported over it behind the
ready candidates, ahead of the resting. The trace row has busy:<load>.
At a new turn affine moves a conversation off it (Why "busy",
busyBehind); within a turn it stays. after, readyForNew and leastHeld
skip it. Unknown load, a lone candidate, or all busy: nothing moves.
- Docs: site plugins page (en, zh, ja) "Model load" section and input
table; docs/subsystems provider-plugins.md and gateway-routing.md.
Run, all on mote via mote-run at a42736807's tree rebased on
origin/main
|
||
|
|
ddc225c964 |
Revert "site: the favicon and iPhone icon fill their tile, no white margin"
This reverts
|
||
|
|
25d4058146 |
site: the favicon and iPhone icon fill their tile, no white margin
On a phone a usemagpie.ai link showed its icon inside a white ring (the owner: "包了一层白边"). favicon.png and the apple-touch-icon (img/icon-256.png) were the macOS app icon, a rounded tile with ~10% transparent margin on each side; a phone fills the transparency white and rounds the square itself, so the tile sat inside a white border. - favicon.png: 64px from the GUI's full-bleed apple-touch-icon, opaque, no margin. - apple-touch-icon.png (new, 180px, also the path iOS asks for by itself): the GUI's apple-touch-icon, which already fills its square. Every page's <link rel="apple-touch-icon"> points at it. - img/icon-256.png is left as it was: install.sh takes it as the Linux desktop icon and the READMEs show it, where the macOS shape is right. Run: sips on both files (64x64 and 180x180, opaque); looked at both; grep shows no page still names /img/icon-256.png as its touch icon. Deployed with wrangler and fetched both from usemagpie.ai. Not tried: a real iPhone's home screen or Safari tab after the deploy. |
||
|
|
e40675cc19 |
middleware: onAccount can pass an account over for a request (bm_rabbit)
bm_rabbit (Discord) is building MOD_Probe, a middleware that tells
Codex accounts apart and needs to keep some requests off some of them.
onProvider could only change a try's body, never which account took
it.
A JS middleware may now export onAccount(account, ctx). The gateway
calls it before each try on a subscription account, at the top of the
candidate loop (accountSkipped). That is before anything of the try is
done: no Codex reset is spent, no body is built, nothing is sent.
account is {ref, provider, name, kind, model}. ref is 32 hex
characters: an HMAC-SHA256 of the middleware's name and the account's
agent, lower-cased user and plan. Its key is random, made once per
install in account-ref.key in magpie's config folder. It is written to
a temp file and linked into place, so it never writes over a key that
is there. The ref is the same on every request and after a restart,
and different for each middleware. The email can't be found from it
without the key. A key file that can't be read is never overwritten:
that process uses a key of its own and logs it.
{skip: true} passes the account over for this request. The next
candidate is asked, as past an account that can't be used. The call's
fallback gets a "passed over by middleware <name>" line, and the
account is not rested or held against. When the last candidate is
passed over, nothing is sent (no fail-open). The agent gets the
failure of a candidate asked before it, or, if there was none, the
usual 404 "none of <model>'s models is ready".
Anything else uses the account: undefined, {}, null, a throw, or going
past the 250ms limit. The last three count as failures. A key's try
asks no onAccount. ctx.account holds the same object for the hooks
after it on that try, and is taken away on a key's try. ownAsk clears
the Accounts runs with the Tried ones.
Note: the plan is part of the ref, so a plan change gives the account
a new ref.
Docs: docs/subsystems/gateway-middleware.md (runtime path step 4,
limits, fail open, verification), docs/reference.md,
docs/integrating.md, and site/public/docs/{,zh/,ja/}plugins.html (an
onAccount row in the hooks table). The Bun plugin host is unchanged:
middleware runs in moejs in the gateway, not in host.js.
Tests:
- internal/middleware TestOnAccount: the ref is stable across runs and
a key reload; it differs between two middlewares, users, plans and
kinds, and is the same when only case differs; no email or plan
reaches the hook. {skip:true} names the middleware; undefined,
{skip:false}, throw and null use the account (2 failures counted);
ctx.account reaches onProvider; a key's try clears it.
- internal/middleware TestAccountRefKey: the key file is made at 0600,
read back, never written over when unreadable, and no temp file is
left behind.
- internal/gateway TestOnAccountSkipMovesToNextAccount: two Codex
accounts, Ordered. The first is passed over, only acct-2 is sent
the request, acct-1 doesn't rest, and the same holds on a second
request.
- internal/gateway TestOnAccountSkipEveryAccount: every account passed
over gives a 404 "…models is ready", nothing is sent, nobody rests.
Broken by hand, each on mote, each red, then restored:
- skip ignored in accountSkipped: both gateway tests red (acct-1
reached; 200 instead of 404)
- fail open on the last candidate: SkipEveryAccount red (200)
- the skipped account rested: both gateway tests red (rests)
- a random key per ref: TestOnAccount (refs changed between requests)
and TestAccountRefKey red
- the middleware name left out of the hash: TestOnAccount red (two
middlewares told one ref)
- an unreadable key overwritten: TestAccountRefKey red
Run at this commit's tree (rebased on origin/main
|
||
|
|
d8cf4f74f9 |
plugins: a plugin's package.json names its row with magpie.name (#4558, MYCF711)
A plugin installed from git whose package.json says
"magpie": { "name": "华为云 HUAWEI" } read as its dependency key
(magpie-officeace) on Settings → Plugins. Bun takes no non-ASCII key, so
a package outside the community's list had no way to show a readable
name. magpie.name was never read at all: #3608's route (MYCF711's branch
1cc33700) didn't reach main, so no release has it, git or npm.
plugin.InstalledName reads magpie.name from the installed package's own
package.json, beside magpie.icon (installedOwn, one parse for both): one
line of at most 80 bytes, no control or format characters (a bidi
override would show it as another name), else nothing. /api/plugins gives
each row it as ownName, and plugins.js's shownName takes it after the
community list's name and before the git package or the spec, so a
listed package is still named by the list. The row's page, the "is up to
date" status and every message that names the row (options, prefer, Update
all) go through shownName; a page plugin's sidebar tab takes it when the
page names no title (windowParts). It is never used to resolve a name and
never shown with the community badge. Not changed: the CLI's plugin list
(the dependency key, as the reporter expects), Discover's cards for
uninstalled GitHub/npm packages, and magpie.summary. Documented in
docs/reference.md and site/public/docs (en, zh, ja).
Run:
- mote: go test -timeout 45m ./internal/plugin/ ./internal/gui/ — plugin
ok; gui red only in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
the AppKit window tests killed at their deadline (TestPanelCloseHidesIt,
TestPluginPageLoadsItsFilesInTheWindow, TestMainWindowCorners, …;
#4125, #2645). The first three run the same red on origin/main
|
||
|
|
33a284497e |
plugin options: a switch a provider plugin declares is saved where the plugin reads it (plugins#550)
`magpie plugin options cursor '{"wire_trace": true}'` wrote the entry's
options in plugins.json (a middleware's ctx.options), while a provider
plugin's switches (auth.options, the editor's Plugin options) are read
from settings' PluginOptions (input.magpie.option). The command said
"options set" and Wire trace stayed off.
Now a key that the plugin declares as a switch for one of its providers
(from the providers last listed, else asked of the plugin host) goes to
PluginOptions for that provider, through settings.EditPluginOptions, and
a running host is handed it (SetProviderOptions, 5s, best effort). Only
true or false is taken for a switch. The other keys go to plugins.json
as before; set with switches only, a middleware's options stay, less a
switch written there before. `off` puts every switch back to the
plugin's default and clears plugins.json's options. Shown with no value,
each switch is listed with its value. docs/reference.md and the plugins
page (en, zh, ja) say so.
Run at this head on mote: go test ./internal/cli ./internal/settings
./internal/plugin ok; gofmt -l clean; go vet darwin and GOOS=windows ok;
Linux go vet -tags gtk3 in WSL (magpie-desktop) ok.
Broken by hand: no key read as declared, and both new tests went red
(PluginOptions empty, the old switch left in plugins.json).
Not tried: the real CLI against a running magpie with the Cursor plugin
installed; a plugin not listed yet (the host path) is not in a test.
|
||
|
|
e647a1fd54 |
plugins: an npm registry of the user's own is used for installs and lookups (timwangdev on X)
timwangdev asked on X for plugins to take a custom npm registry. Zero-config
first: Registry() (internal/plugin/registry.go) takes, in order, the one set
in magpie (settings npmRegistry: `magpie plugin registry <url>|default`, or
Plugins › Discover's new npm registry row), BUN_CONFIG_REGISTRY /
NPM_CONFIG_REGISTRY / npm_config_registry in magpie's environment, then the
login shell's (cached probe only, proc.LoginEnvKnown, never waits on a
shell), install.registry in the plugins folder's or the user's .bunfig.toml,
registry= in the plugins folder's or ~/.npmrc, then the 国内镜像 switch's
npmmirror, then npm's own. The switch no longer puts npmmirror over a
registry the user named: before, bun was handed BUN_CONFIG_REGISTRY=npmmirror
whenever it was on, over the user's .npmrc. bun is told the registry only
where it wouldn't find it itself (magpie's setting, the shell's, the
switch's). magpie's own npm questions (latest version for the market,
Update and the hourly check, README, search) go to the same registry, a
package's @scope:registry= to that scope's, with the .npmrc's
//host/path/:_authToken (${VAR} expanded, longest prefix) sent to that host
alone, dropped on a redirect to another host, never logged or shown.
Download counts stay npm's. Only http(s) with a host, no userinfo, query
or fragment is taken; anything else is refused and not saved, and a bad
value hand-written into settings.json is passed over. /api/plugins says
which registry is in use and where it came from.
The GUI row is in registry.js, imported when Discover draws it, so the
core script budget isn't raised (plugins.js is 292 bytes smaller than
before, one long comment there condensed).
Left out: bunfig [install.scopes] for magpie's own lookups (bun reads them
for installs), .npmrc _auth and username/password, NPM_CONFIG_USERCONFIG
and npm's global npmrc, and internal/agent/cliupdate.go's agent CLI update
lookups, which still ask npm's own.
Run (mote and wsl-run). First at this change on
|
||
|
|
14b451c117 |
site: the MCP hub's docs are the MCP router's, and the old links redirect
The feature is called the MCP router now (the commit before). The docs pages move to mcp-router.html in en, zh and ja, their wording follows (MCP router / MCP 路由 / MCP ルーター, `magpie library mcp router on|off`), and every docs page's link and canonical/hreflang URL points at the new path. The worker answers /docs/mcp-hub, /docs/zh/mcp-hub and /docs/ja/mcp-hub (with or without .html or a trailing slash) with a 301 to the new page, keeping the query, so links already shared still open. The plugins pages' link to the router page (Search1API's tools, from the rebase) follows too. Run at e2583df31 (this stack on |
||
|
|
2f65a33aaf |
library: a tools plugin is a Library server of its own, in the MCP hub (Search1API)
chenxiang0010 (Discord #general) asked for a tools plugin's tools, Search1API's (@magpie-community/tools-search1api), to be in magpie's aggregated MCP server. Until now plugin tools were served only at /mcp/magpie/tools, wired by hand; the hub listed Library servers only. Now each plugin that is on and gives tools becomes a Library server once the plugin host has noted its tools (plugin-tools.json, new plugin.ToolsNoted): - named by the plugin's short name (search1api, search1api-plugin beside a user's server of that name), `plugin` set, `local`, its URL the new /mcp/magpie/tools/<short> (gateway ToolsMCPOne), which serves that plugin's tools alone by their own names; - added with the hub on, it is on for the agents given the hub's entry, so their hub lists search1api__search etc. at once; with the hub off it is on for none until switched on. Per agent and per tool it is switched like any server; - the hub lists and runs its tools in process (gateway.PluginToolsOf, RunPluginToolOf, under the Plugin tools gate); with the hub off an agent is given the per-plugin URL at the address it reaches the gateway (through), with a key from another machine; - offered once (pluginsOffered): removed by the user, it comes back only when the plugin is removed and added again. The plugin removed takes the server out; turned off it stays and lists nothing; an unreadable plugins.json changes nothing (plugin.ReadList). Edited in the Library's editor, which doesn't send `plugin`, it stays the plugin's. Docs: docs/subsystems/plugin-tools.md, mcp-hub.md, site docs plugins (en, zh, ja). Run (mote; full suite at this change on origin/main |
||
|
|
0745db932e |
site: an MCP hub page in the docs, in en, zh and ja
CyberCaius (Discord) asked what the Library's MCP hub is for. The page says what the switch does, how to turn it on (GUI and `magpie library mcp hub on|off`), the /mcp/magpie/hub address for other apps, which agents keep their own entries and why, and when to leave it off. Facts from docs/subsystems/mcp-hub.md and internal/library/mcp_hub.go. Every docs page's nav and footer link it after Privacy masking. Run: site's node --test on mote from the repo root, 45 of 45 pass. |
||
|
|
1319a44bbc |
docs: plugin guide says what four rules do when a plugin gets them wrong (plugins#468)
Guide (en, zh, ja) and provider-plugins.md: - usage: leave used out rather than send 0; with amount/limit it is their share, with no count the window is text and routing doesn't read it; aside keeps a window out of routing whatever its count. - sign-in: a model refused is 403/404, not 401; a 401 that says only that the model isn't served is read as kept. - free comes only from the vendor's word; rate 0 is none given, never free (magpie infers nothing from rate). - GitHub listing licence: from LICENSE as GitHub reads it, else package.json's license. Docs only. Checked each claim against the source at this tree (plugin_usage.go quotaOfPlugin, plugins.go modelOnly401, fallback.go modelRefused, plugin/providers.go Model.Rate, models.go FreeModel, github.go readTagged). Site deployed with wrangler and the pages read back with curl. |
||
|
|
60520ddb3b |
moejs: v0.1.0-alpha.11, at its new module path github.com/MoeForge/moejs
Gateway middleware and agent plugins run on moejs. alpha.11 moves the
module to github.com/MoeForge/moejs; every other API change since
alpha.4 is an addition. What magpie gets: faster calls, loops, property
lookups and JSON.parse, allocation-free await, a bytecode verifier, a
correct default.pgo, and Intl / toLocaleString in plugin code.
Checked against both tags' source: every name magpie uses (NewRuntime,
Options, Compile, Link, Hook, Value, Arg, Undefined, NativeFunc,
Referrer, the Promise results, Exception) has the same signature, and
Options' defaults (shared frozen builtins, no timers) are unchanged.
fetch, Streams, URL, node:fs and node:buffer live in the separate
webapi and node packages, installed only on request; magpie installs
neither, so a plugin still reaches no network or file.
Intl's CLDR, Unicode, ICU and V8 material is compiled into every build,
and moejs asks a program that includes it to carry sections 1 to 4 of
its notices. THIRD_PARTY_NOTICES holds them verbatim. Release archives
ship no LICENSE today either; that is not changed here.
Doc and site links (docs/, site/public/docs/{,zh/,ja/}plugins.html)
point at the new repo.
Run on mote at this tree: gofmt; go build -trimpath -s -w (60,670,658
bytes on origin/main
|
||
|
|
8bade6c5e2 |
provider: a plugin's usage window can be a prepaid wallet's balance (#3950)
SuperMagic's accounts (mycf_711's magicrew plugin) are prepaid wallets of
points with no total. A plugin can now send a usage window as
{name, balance: 6291, unit: "积分"} with no used or limit.
- host.js passes a finite balance on (at least 0), anything else as null.
plugin.UsageWindow.Balance and provider.QuotaWindow.Balance are *float64.
- quotaOfPlugin keeps the figure and does not make the window Text or
Aside, so routing knows the account with no Used invented. allowanceOf
copies it into Limit.Balance; an empty wallet counts as used up.
Allowance.Left(model) is the least balance of the windows that count
the model.
- weighRouted fills routes.Seat.Left and Seat.LeftIn (the account's
provider and unit). Smart, pace and usage (least used) put the seat
with more left first where they would otherwise tie (byLeft), only
when every seat with a balance shares one LeftIn: balances in two
units or two providers are never compared. Tiers still come first.
- The Usage card, the Routing page (Weighed.Balance: the small row's
text, no bar, a why sentence, the account list), magpie accounts and
the status line show the figure, "6,291 积分 left", never a share.
- Docs: provider-plugins (new section), gateway-routing,
providers-accounts, plugin-runtime, host.js typings and the site's
plugins page (en, zh, ja).
Run, at base
|
||
|
|
430e3050d8 |
gateway: magpie's own searches and image descriptions go without the agent's middleware (#3695)
aiirobyte (#3695): the gateway exited five times on 2026-10-26, and every client was refused until it was started again. The one exit with a stack died of "fatal error: concurrent map read and map write": two of seenBody's goroutines in middleware.(*Run).Tried at once, one of them in moejs's InternGoString. A request's middleware runs in runtimes of the request's own (serveAgent). Only one goroutine may use a runtime at a time (moejs), and Run has no lock to hold callers to it. serve runs each try's onProvider on them (triedOn) through the Tried the request's context carries. For a model that can't see, magpie has each image of the request described (seenBody), up to four at a time, and each description is a request it makes of its own gateway on a context made from the agent's (magpieChose(ctx)). So the descriptions carried the agent's Tried and ran onProvider on one runtime from as many goroutines. A model that can't search has its searches made the same way (searchWith): a search is asked beside the agent's own stream, which goes through the middleware's onEvent, and beside the round's other searches, so one search is enough to share the runtime when the middleware has onEvent. The runtime's maps were read and written from two goroutines and the gateway died. When it didn't, the calls' values crossed. In the runs below, hooks threw on values that weren't there ("Cannot read properties of undefined (reading 'push')", and "(reading 'messages')"), and a description went out as {"0":0,"messages":[0,{"content":[0,{"image_url":0}],...}],...}, its max_tokens, system prompt, text and image each turned into 0. An earlier run of the same break (tree e1c90a00, this code with older comments) had one image asked about twice and another never. ownAsk takes the request's Tried off the context of those two asks, so they go without the agent's middleware, as serveAgent's comment already said of them ("search and vision stand-ins") and as magpie's other own requests (titles, the classifier) go. The agent's own tries are as before: each runs onProvider once, on its runtime. The subsystem page now says why, and the user docs (en, zh, ja) name searches and image descriptions among magpie's own requests. Going without also keeps what the docs tell a hook. Its ctx.protocol, ctx.model and ctx.stream are the agent's request's, while a description's body is a Chat request and a search's an Anthropic one, whatever the agent speaks. A description is also kept for later requests (sights), so one asked through a request's middleware was handed to later requests, other agents' too. The one community middleware with onProvider, antigravity-cloak, rewrites Claude Code's and Codex's lines in the system prompt, which a description's or a search's prompt, magpie's own, doesn't have. Not changed: the report's other fixes, a lock over the runtime, one ask at a time, or a Run per ask. Each keeps the gateway up but still runs the agent's middleware on asks that are magpie's own, which the docs say go without it, and with the first two onProvider still gets bodies its ctx doesn't describe. With ownAsk nothing else uses a request's Run from two goroutines (holdWriter's keepalive writes under the h.mu the handler's writes hold). magpieChose is left as it is: it says whose pick a call is, and its other callers, Codex's thread titles, descriptions and predictions (codex_titles.go), run before serveAgent with no Tried to take off. What was run (tree 4f97ac18, on origin/main |
||
|
|
c28d3e8b00 |
docs: plugins document auth.checkin (plugins#392)
MYCF711 (plugins#392): the plugin docs listed the hooks magpie calls without auth.checkin, magpie's own daily check-in hook several plugins use. The page now has a Check-in section (signature, the six outcomes, done vs failed, never solving a captcha, once a Beijing day per account and again after a failure, the account's scope), the intro list and the auth hook's shape name it, and the hooks sentence names refresh and checkin. In en, zh and ja; taken from host.js's checkin contract and provider/plugin_checkin.go. Run: tag balance checked in all three pages; no test covers docs pages. Not tried: rendering on the deployed site (the site is not deployed by this commit). |
||
|
|
d153f02593 |
docs: a privacy masking how-to in en, zh and ja, linked from every docs page
YH31377807 on X asked how to use magpie's local masking (咋用?能出个 教程吗?). The docs had only a short section on the Privacy page. /docs/masking, /docs/zh/masking and /docs/ja/masking: turning it on in Settings › Privacy, settings.json for magpie serve and Docker (no CLI command exists), what each switch masks, an example, how to check it (Try it, the shield badge on Gateway and Routing, Insights › Masking, ~/.config/magpie/masking), Mask/Warn/Block and Never mask, and limits. Each docs page's nav and footer link it; the Privacy pages' masking section points to it. Checked against the source: the secret rules and personal kinds in internal/redact/redact.go and more.go (Categories and their defaults), masking.Wanted and options in internal/masking, the sealed/kept keys in redact/json.go, Hint for the Block message, gwmw.ErrUnmasked (503) and maskBlocked (400), the GUI labels from index.html/app.js and their zh and ja strings in i18n.js, plugins/redact's name. The example's output is redact.Preview's on that text, run in a throwaway test (placeholders differ per run's key). Run: node --test site/worker.test.mjs site/install.test.mjs (31 pass). The three pages rendered in Chromium and WebKit at 390 and 1280 px with no horizontal scroll and no page errors; tags balanced. Not tried: the GUI itself; labels read from source. |
||
|
|
0b72ccbeff |
agentplug: connect's models carry /v1/models' native_endpoints and pricing
cleary5779 on Discord builds an agent as an agent plugin and wants, in
connect({ gateway, model, models }), the API each model passes straight
through on and what it costs. Each entry of models (and model) now also
has, by the names /v1/models uses:
"native_endpoints": ["/v1/chat/completions"],
"pricing": {"prompt": "0.0000003", "completion": "0.0000012",
"input_cache_read": "0.00000003"}
Each is left out when not known: a group or a model translated anyway
has no native_endpoints, an unpriced model no pricing, never [] or 0.
The fields connect had (id, name, context, output, images, efforts) are
as they were.
No second lookup: nativeEndpoints moved from the gateway to
provider.NativeEndpoints, and openRouterPricing/perToken to
catalog.OpenRouterPricing/PerToken (internal/catalog/openrouter.go); the
gateway calls them as before. magpieModels already priced each model with
provider.EntryPricer, the price /v1/models gives (m.Price); it now also
keeps NativeEndpoints in catalog.Model.Endpoints (json:"-"), which
plugged's wire turns into the two keys.
Docs: reference.md's agent plugins section (what connect gets, with an
example), agent-wiring and gateway-routing subsystem pages, and the
site's Plugins page in en, zh and ja.
Run at this tree (on origin/main
|
||
|
|
d783df46cb |
plugin: a plugin's page adds items to a provider's and an agent's row menu (P6)
package.json's magpie.actions: [{id, menu, title, titles}] puts items in
the row menus magpie draws, after its own: a provider row's (right-click)
and an agent row's (its handle, or right-click). Picking one opens the
plugin's page and posts it {event: "action", data: {id, provider|agent:
{id, name}}}, nothing else of the row; the bridge's magpie.onAction(fn)
gets it, and an action picked before fn was given waits for it.
- plugin.Window reads them (page.go): menu one of ActionMenus (provider,
agent; a session's menu is left out, its title is user content), id
^[a-z0-9][a-z0-9-]{0,39}$, an id given twice is the first's, 8 at most,
none for a plugin with no page.
- /api/plugin-pages carries them on the page; a missing title is the
page's, in each language (pluginpage.go).
- pluginpages.js: magpie.actions(menu, context) gives the row menu's
items; openRowMenu draws a plugin's name as written (literal), not
through t().
- The Plugins page says which menus a plugin adds to (actionsLine),
translated in zh, zh-TW, ja and de.
- Docs: plugin-runtime.md's P6 section and verification; the site's
plugin docs (en, zh, ja) gain "Items in magpie's menus".
- The core's budget (TestCoreScriptBudget) is not raised (#2710): with
P6 the core came to 1,447,648 bytes, 648 over. pluginpages.js's header
now says P5's and P6's part in one paragraph and points to
plugin-runtime.md, which says it in full, and plugins.js's panels and
actions lines share whereLine: 1,446,845, 155 under.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own
|
||
|
|
8e44c2f351 |
gui: the dot on Plugins says what it is, and leads to the plugins with an update
The owner, on the sidebar's dot beside Plugins: no one can tell what it means, and once they click it, they should see which plugins need updating. It meant "a plugin update is waiting", said only in a hover title, and Plugins opened on whatever tab was last open. - Sidebar: under Plugins, Installed reads "1 update" / "N updates" in the dot's colour in place of its count, with a title saying where to update. - Opening Plugins while an update waits lands on Installed. - Installed names the plugins with a newer version in a bar above the list, with Update all beside them (moved there from the footer). Each row still shows its own "vX out" and Update. - Strings in zh, zh-TW, ja and de; the docs (en, zh, ja) say the same. Run: - plugin-updates.test.cjs: chromium and webkit, en zh zh-TW ja de, at 1024 (sidebar) and 600 (tab bar), 22 ok. Also ok in both engines: plugin-git, plugin-update-button, plugin-check-updates, plugin-card-update, plugin-prerelease, nav-sub-unroll, sidebar, builtins, i18n-keys. go test ./internal/gui/ -run 'TestCoreScriptBudget' ok. - Broken by hand, each red: no sidebar label (the 1024 cases), no jump to Installed, no bar (every case). - Looked at in WebKit screenshots, zh at 1024 and de at 600. Full run, with the rest of its series: this series (P5, the Plugins dot, the probe test, P6, and a built-ins-on commit since dropped for main's own |
||
|
|
b9f790d37b |
plugins: panels in magpie's pages, a page that replaces a built-in one, titles in the window's language, and a look that matches
P5 of the plugin runtime (docs/subsystems/plugin-runtime.md):
- Panels (magpie.panels): a plugin draws a frame into a slot of a
built-in page (a provider's editor, Settings, Usage); magpie.context
says where it is, and the frame is as tall as what it draws.
- A page can replace a built-in one (magpie.page.replaces); show() opens
it in that page's place, and the sidebar row goes to it.
- page.titles and a panel's titles name it in the window's language
({"zh": …}); a malformed map is dropped, the title kept
(TestWindowTitles).
- main's #2501 already names wails:// in the policy of a page in the
desktop window (through ownWindow), which is why the usage page drew as
bare HTML from v0.1.1259. TestPluginPageLoadsItsFilesInTheWindow loads
a page through ownWindow in a real WKWebView, which Playwright on http
can't; the subsystem page says how.
- The bridge adds magpie's look for what a page leaves unstyled, every
rule in :where() so any rule of the page's wins, and the theme's
colours as --magpie-* variables.
One commit: the panels, the replacing pages and the titles share hunks
in page.go, pluginpage.go, pluginpages.js and the docs, and couldn't be
split cleanly.
Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
built-ins-on commit since dropped for main's own
|
||
|
|
e44b9aef33 |
middleware: onProvider changes what one provider a request is tried on is sent
A JS gateway middleware can export onProvider(body, ctx). The gateway
calls it on each try, just before the body goes to that provider, with
ctx.provider = {id, name, account, model}: account is the subscription's
kind (claude, antigravity, …), absent for a key. Every try starts again
from the body onRequest left, so a change for one provider never reaches
another in a routing group. null and ctx.reject turn nothing away there.
A hook that throws or runs past 250ms leaves the try's body as it was.
A plugin could act only before routing until now, by the model name the
agent asked for. Claude Desktop asks for opaque aliases, so a plugin
couldn't tell which vendor a request was going to. The first user is
@magpie-community/middleware-antigravity-cloak: it changes only what an
Antigravity account is sent, so that Antigravity stops refusing Claude
Code's system prompt (xzplzpl on X). magpie itself still sends every
prompt as the agent wrote it.
- gwmw.To and gwmw.Tried; middleware.Run.Tried runs the hooks.
- serveAgent puts the runs on the request's context, and serve's
candidate loop calls triedOn before the Antigravity foresight, so it
judges the body that will be sent.
- Docs: gateway-middleware.md, reference.md, integrating.md, and the
hooks table and community list in site docs plugins.html (en, zh, ja).
Run:
- go test ./... -timeout 45m in a sandbox HOME (macOS, at
|
||
|
|
9b04c4e20f |
plugin: async gateway request hooks, run in Bun before routing and after the reply (#2118)
A package's magpie.hooks entry (or a *.hooks.{js,mjs,ts,mts} file) exports
`async onRequest(body, ctx)` and an optional `onResponse(reply, ctx)`. They
run in the Bun plugin host, so a hook can await I/O, for example a context
service like PowerContext, which the sync moejs middleware can't. The
gateway still makes one model request per client request. A hook adds
context to the body; it doesn't register tools or run a loop, so magpie
doesn't become an agent runtime.
Ported from Tsukikage7/magpie#1. Changes from the fork:
- The entry name is magpie.hooks / *.hooks.*. The fork's magpie.gateway /
*.gateway.mjs is already the middleware's alias, so a hook importing
node:fs was also loaded as moejs middleware and failed there.
TestGatewayHookNamesApartFromMiddleware fails if the two sets overlap.
- onRequest is rolled back, and counts as failed with no onResponse, when
it throws, times out, returns non-JSON, or changes tools, tool_choice,
function_call, functions, toolConfig, model or stream.
- onResponse gets the client-facing reply, merged through the gateway's own
stream decoder, collector and renderer (no second merger).
- Codex's native passthrough (/backend-api/codex) runs the hooks too,
without the sync middleware.
- The run ends with the request handler, not the client connection. Codex
hangs up on response.completed, and the reply it got is still captured
as a success. TestGatewayHookSeesReplyAfterClientHangsUp is red on the
old `r.Context().Err()` check and green with -count=3.
- ctx.origin is host-derived (local / gateway-key / remote). Headers, keys
and peer addresses never reach the hook.
- Plugins page: a hook package shows a "Request hook" chip, a diagnostics
line (outcome code, calls, avg ms, bytes, failures; no content), and
Options. Strings are in en, zh, zh-TW, ja and de.
Docs: docs/subsystems/gateway-request-hooks.md (new), provider-plugins.md,
gateway-middleware.md, and site docs plugins.html in en, zh and ja.
Real use, sandbox HOME on 127.0.0.1:3486 with the owner's real Codex Pro
sign-in. The probe hook adds a codename note and logs both callbacks:
- /v1/responses, /v1/messages, Gemini generateContent: stream and
non-stream. onRequest's note reached the model (the answer had the
codename), and onResponse got success=true and the whole reply.
- /v1/chat/completions: with the probe also changing `model`, the change
was rolled back (the reply came from the asked model) and no onResponse
ran. Without that change, earlier: stream and non-stream success.
- The real Codex CLI 0.162.1 `codex exec` through openai_base_url ->
/backend-api/codex: the hook saw origin=local, agent=codex and the
query; the answer had the codename; onResponse success=true (before the
hang-up fix it never ran: the context was already cancelled).
- `magpie plugin list` shows only "async gateway hook onRequest" for the
hook package, no failed middleware.
Tests (base origin/main
|
||
|
|
e733b0722e |
plugins: a provider plugin says which service tiers a model serves, and Codex offers them (#2514)
Lovest on Discord (#general, v0.1.1267): a provider plugin had no way to
say a model is served at Fast or Ultrafast, so Codex never offered them for
plugin models, and the host dropped the field anyway.
- host.js keeps m.serviceTiers (tiersOf: string ids or {id} objects,
trimmed, de-duplicated, anything else dropped) as plugin.Model.ServiceTiers.
- pluginCatalog puts them on catalog.Model.Tiers; CodexTiers offers a
plugin's tiers when it declares any, so codexcat writes service_tiers
(priority named Fast) into Codex's catalog and /v1/models.
- forwardTranslated keeps service_tier (OwnTier) for a plugin provider only
when the request is translated to its Chat or Responses and the tier is
one the model declares (provider.PluginTiers). A request relayed in its
own protocol was already sent as the client wrote it; unchanged. Cursor's
fast flag and #1954's ChatGPT tiers are untouched (#1954 not on main yet).
- Docs: serviceTiers in site/public/docs plugins (en, zh, ja) and a
"service tiers" section in docs/subsystems/provider-plugins.md.
Tests (internal/gateway/plugin_tiers_test.go, fake plugin FAKE_TIERS):
TestPluginModelServiceTiersListed (fake-1 priority=Fast + ultrafast,
fake-resp ultrafast, fake-claude none) and TestPluginServiceTierReachesFetch
(Responses→plugin Chat and Chat→plugin Responses send a declared tier,
drop an undeclared one; same-protocol relays as before).
Broken by hand: OwnTier branch forced false → 3 translated cases red;
CodexTiers without IsPlugin → listed test red; host.js serviceTiers: [] →
listed test red. Restored → green.
gofmt -l clean; go vet -tags nogui with GOOS=darwin, linux, windows clean.
Not tried with a real vendor plugin that serves ultrafast.
Full suite: go test -timeout 45m ./... at af9e0d6b2 (sandbox HOME, load
average ~408 from other sessions): every package ok except agent and
gateway, which timed out at 45m with no failed test (rerun whole: timed
out again, 0 failures), gui (TestMainWindowCorners killed, #1936),
TestVendorThatStopsMidAnswerIsSaid (filed #2535) and
TestSetAnswersWhileDevinAndProvidersHang (#1375). The reds and the tests
running at each timeout (TestCodexKeptOnChatGPT, TestReplyNamesMember)
pass rerun alone, except TestMainWindowCorners (#1936). CI is the gate.
|
||
|
|
b6533893a7 |
plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:
- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
"page") sections beside Subscriptions, Gateway middleware and Agents,
each card with its own chip (a new Tools chip, the Page chip). Before,
both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
magpie.page.file is a Page, and that file must be committed, as a
provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
routing strategy, tools, an agent, a page) and its "Write a plugin" link
opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
registry kinds and the community package names for each, in en, zh, ja.
Run at the reviewed head (on origin/main
|
||
|
|
dbf331211f |
agents: an agent plugin with no model key is connect only, a switch with no model picker (#2374, rocona)
A Raycast plugin wants magpie to write the gateway, the agent's key and
the model list, and leave the model to Raycast's own picker. agent.model
was required ("agent.model names no key"), and the row always had a
model picker whose pick Raycast never read.
An agent export without model is now connect only:
- its one field is provider, magpie or nothing, as an app whose one
setting is magpie as its provider (ZCode); ListsModels is set, so the
row has the model list button and no model picker; no new UI control
and no new strings
- connect is called without model and only its keys are written; the
stash, the restore on Disconnect, the agent's own key and Check work
as before; Sync calls connect again on a catalog change
- such a module must export connect (else it doesn't load, saying why),
and connect must return keys (else the connect errs and nothing is
written), so the row never says connected with nothing written
An export with model behaves as before. Docs: the plugins page (en, zh,
ja) and docs/subsystems/agent-wiring.md.
Tests (internal/agent/plugged_connect_only_test.go):
- TestPluggedConnectOnly: one provider field, menu, connect without a
model, no model key written, the user's key and theme kept, list
follows a catalog change, Check sees a base moved by hand, off puts
everything back.
- TestPluggedConnectOnlyWritesSomething: no connect is a load error;
connect returning {} errs and writes nothing.
Broken by hand (only forced false and model passed): both FAIL.
The /api/state row for such an agent was dumped through gui.state() in
a temporary test: key provider, one magpie option, menu true, the same
shape as ZCode's. zcode-models, plugin-agent and agent-connect GUI tests
pass in Chromium and WebKit (46/46; every language, 1100/980 and 420).
Run at origin/main
|
||
|
|
3f913b3de6 |
plugins: a JS gateway plugin serves routings (strategies) and watches usage rows (onUsage); plugins/middleware is "JS gateway plugins" (P4)
A plugin's gateway module (magpie.middleware, or its alias magpie.gateway,
or a *.gateway.js file) may now export, besides onRequest/onEvent/onResponse:
- strategies: {name: (pool, seats, options) => order}. Each is a routing
"<short name>/<name>", registered with routes.Register while the plugin is
on and loaded and removed when it goes off or reloads. Seats are
routes.Seat in camelCase JSON. 20ms each; it fails open: a throw, a timeout
or a result that isn't an order of the seats means the listed order. The
failure is counted and logged, rate-limited. A file's name is made into a
routing-safe prefix.
- onUsage(row, options): gets an allow-listed usage row (no bodies, prompts,
error text, sessions or request ids). The rows come from a bounded queue
(1024) with one worker, off the request path; a full queue drops the row
and counts it, and a request never waits. 250ms each.
plugins/middleware is renamed "JS gateway plugins", with a new Sub
(en/zh/zh-TW/ja/de). It registers usage.Observe(middleware.Points()). Off,
no JS hook, strategy or onUsage runs. InUse is unchanged.
providers.json keeps a routing of the form <plugin>/<name> as saved
(provider.PluginRouting) in provider and group Save, whether or not a
plugin serves it now. Before this, `group set g routing=pick/last`
stored nothing.
GUI: the settings state carries jsRoutings. Provider and group routing
pickers offer the served ones, marked data-feature=middleware. A saved
routing that no plugin serves now shows as it is, with a hint. The
Plugins page's line shows routings, how often they were asked, onUsage
rows and dropped rows. The CLI accepts `group set <id> routing=<plugin>/<name>`.
`magpie plugin` lists a module's routings and onUsage; a strategy-only
module had printed nothing after "gateway middleware".
Docs: docs/subsystems/gateway-middleware.md (Routings and usage rows,
limits, verification) and plugin-runtime.md (P4: community plugins at
every point). site/public/docs plugins.html in en, zh and ja has an
example: internal/middleware/testdata/spread.gateway.js, which
TestDocsExample runs.
What was run (worktree on 4df1ba0c6, -p 2):
- gofmt -l: clean. go vet on internal/{middleware,cli,gui,plugin,provider}
and plugins/...: darwin, GOOS=linux -tags nogui, GOOS=windows; all
clean, run after the last Go change.
- go test, after the last Go change: internal/middleware ok,
plugins/middleware ok, internal/provider ok (210s), internal/cli ok
(203s). Earlier in the work: internal/plugin ok (385s), internal/pluginrt
ok, internal/gui (Go) ok (320s), and plugins/... ok. The first
plugins/... run printed a bare FAIL line that `tail` cut off before its
cause showed. The rerun was all ok; the cause is unknown.
- GUI, both engines (routing-*, group-*, builtins, i18n-keys, gui-de/ja/zh-tw,
plugin-middleware): 1220 tests, 1204 pass, 16 fail.
- routing-manual (4): mine. A group's own "manual" was offered a second
time as a routing no plugin serves. Fixed in client.js withJS. The
coordinator is rerunning routing-manual, keys-fold, group-fold,
intent-entry and routing-js alone in both engines, so that rerun is
not recorded here.
- routing-model-rest: red alone too, and red on untouched 4df1ba0c6
(3/20). It is #2115; I commented there with the webkit cases.
- group-member-weight webkit de 420 is #2387.
- group-from-model-add webkit zh: it passes alone 2 of 2. Under load it
waits a fixed 2s for the save post. Filed as #2388.
- routing-keys-fold (webkit zh/ja/de), routing-group-fold (goto timeout)
and routing-intent-entry (browser launch timeout 180s) are load
timeouts. The coordinator is rerunning them alone.
- routing-js.test.cjs (new) passed in chromium en and zh, before the full run.
Broken by hand, each test went red, then restored:
- the permutation check: TestStrategyFailsOpen;
- the queue's non-blocking send: TestOnUsageNeverBlocks ("Ledger waited
2.04s");
- the allow-list: TestUsageRowAllowList;
- unregister on off: TestStrategiesServedWhileOn and
TestStrategiesStopWithServe;
- the CLI pattern: TestParseRoutingStays;
- Observe in plugins/middleware: TestOnServesStrategies;
- PluginRouting in provider.go and in group.go: TestPluginRoutingKept;
- the prefix sanitizing: TestRoutingFromFileName;
- the CLI list line: TestPluginListSaysMiddleware;
- the GUI's data-feature mark and its unserved-saved entry: routing-js.
Real use: a sandbox HOME, the gateway served on 127.0.0.1:3682 by a
-tags nogui build, a fake vendor on 3681, and providers fa (key ka) and
fb (key kb) in group g. pick.gateway.js has strategy last (reverse) and an
onUsage that logs.
- `group set g routing=pick/last` stored it.
- A request to group/g reached the vendor with Bearer kb, and the
"usage-row fb m in=5 keys=17" line was logged.
- `plugin off pick.gateway.js`: Bearer ka (listed order), no onUsage,
routing still pick/last.
- `plugin on`: Bearer kb and onUsage again.
- `plugin builtin off middleware` says "in use and stays on", as InUse
should.
- Not tried: the GUI against that gateway, or a real vendor account.
|