diff --git a/docs/subsystems/mcp-router.md b/docs/subsystems/mcp-router.md index 68736b2de..63190d8e6 100644 --- a/docs/subsystems/mcp-router.md +++ b/docs/subsystems/mcp-router.md @@ -1,6 +1,6 @@ # MCP router -With the Library's switch "MCP router" on (#2679, @minggang123 on X), each agent is given one MCP server, `magpie`, in place of the Library's MCP servers ticked for it. magpie serves it at `/mcp/magpie/hub/` (Streamable HTTP) and hands each call on to the Library server behind it. Any other app (Cursor, VS Code, Windsurf, an app on another computer) connects at `/mcp/magpie/hub`, which serves every server in the Library. A server written once is then set up once, for every agent and app, and a command server runs once, not once in each. The servers themselves are the [Library](library.md)'s; the endpoint is the gateway's, guarded as [Plugin tools](plugin-tools.md)' `/mcp/magpie/tools` is. The switch is off by default. +With the Library's switch "MCP router" on (#2679, @minggang123 on X), each agent is given one MCP server, `magpie`, in place of the Library's MCP servers ticked for it. magpie serves it at `/mcp/magpie/hub/` (Streamable HTTP) and hands each call on to the Library server behind it. Any other app (Cursor, VS Code, Windsurf, an app on another computer) connects at `/mcp/magpie/hub`, which serves every server in the Library (but a plugin's server hidden from agents). A server written once is then set up once, for every agent and app, and a command server runs once, not once in each. The servers themselves are the [Library](library.md)'s; the endpoint is the gateway's, guarded as [Plugin tools](plugin-tools.md)' `/mcp/magpie/tools` is. The switch is off by default. ## Responsibilities and sources of truth @@ -9,7 +9,7 @@ With the Library's switch "MCP router" on (#2679, @minggang123 on X), each agent | Switch | `Library.MCPHub` (`mcpHub` in library.json) is the source of truth. `SetMCPHub` sets it through `change`, so every agent is synced at once; turning it off also ends every server the router started (`hubStopAll`). The page posts `servers/hub` `{on}`. | `SetMCPHub` in [`mcp_hub.go`](../../internal/library/mcp_hub.go); `servers/hub` in [`gui/library.go`](../../internal/gui/library.go) | | Entry | `syncMCP` gives an agent `hubServerFor(t)`, named `magpie` (`HubEntry`), in place of each server it would have written, and records it in `Applied.MCP` like any server, so turning the switch off takes out only that entry and writes each server's own again. The URL is the gateway as that agent reaches it (`gatewayOf`), so a WSL distro or a LAN computer gets its address, with `Authorization: Bearer ` when that address needs a key (`agent.KeyAt`). A LAN key or relay change re-syncs (`LANChanged`). magpie's own image server (`isSelf`) is behind the router too, except for an agent in a WSL distro (its id has `@wsl:`), which keeps its own entry to the magpie in that distro. A server the user keeps direct is not (`Server.Hub` = `direct`, `hub` in library.json; #4382, cuipengcx90): each agent given it keeps its own entry, written as with the router off, beside the router's entry for the rest, and started by that agent: Codex on magpie, which is otherwise given a command server as the gateway's `/mcp/run/` that magpie starts from home ([`mcp_run.go`](../../internal/library/mcp_run.go), #3885), is given a direct one's `command`, `args` and `env` with no `cwd`, so Codex starts it in the thread's folder (codex-mcp's `LocalStdioServerLauncher` falls back to the session's `cwd`; `TestRunDirectServerIsCodexsCommand`); an agent whose every server is direct is given no hub entry. `inHub` is the one test, so the router neither lists nor runs a direct server, at `/mcp/magpie/hub` either, and `hubPrune` ends one it held. The default (`""`; `shared` is saved as `""`) is the router's as before. Switching it (`ServerHub`, or a save) goes through `change`, so each agent is written again at once and the entry it had the other way is taken out (`TestHubDirectServer`). The policy is the server's, so a sync carries it. A per-project or per-session backend behind the router (Option B in #4382, keying `hubPool` by roots) is not built. | `hubFor`, `hubServerFor`, `inHub` in `mcp_hub.go`; `syncMCP` in [`sync.go`](../../internal/library/sync.go); [`mcp_signin.go`](../../internal/library/mcp_signin.go) | | Who keeps their entries | An agent keeps each server's own entry, and `AgentView.Hub` says why: `no-remote` (it reaches no server over HTTP: `mcpFile.supports` refuses the entry, as for Claude Desktop), `taken` (a Library server is itself called magpie), `own` (the agent has an entry called magpie that magpie didn't write; it is left as it is). `on` is an agent given the router's entry. An agent given none of the router's servers has no value. | `hubFor` in `mcp_hub.go`; `AgentView.Hub`, `View.MCPHub`, `View.HubPath` in `sync.go` | -| Serve | `tools/list` lists the tools of the servers ticked for that agent (at `/mcp/magpie/hub`, agent `""`: every server in the Library, ticked for any agent or none), but those in `DisabledTools`, as `__`: each part in `[A-Za-z0-9_-]` (other characters `_`), at most 64 characters (`cutName`), `_2`, `_3` on a name two would share. Each tool's description and `inputSchema` go on as the server listed them (an object schema with no properties when it has none). An agent that searches its MCP tools itself is given every tool in full, and its tool search keeps them out of each request: Claude Code (`ENABLE_TOOL_SEARCH`, which magpie turns on, see [agent wiring](agent-wiring.md)), Claude Desktop, Codex (`tool_search` on magpie's catalog), Pi, Droid (which defers every MCP tool to its ToolSearch) and omp (which names each in its catalog by its description's first line) (`hubSearchesItself`, by the agent's id without its `@wsl:`). So is the address for any other app (agent `""`) and an agent given 10 tools or fewer. Any other agent is given its tools on demand (below). `tools/call` runs one; an unknown name, or another agent's, is error -32602. `initialize` and `ping` are answered; other methods are -32601. Tools only: no resources or prompts. | `hubMCPCall`, `hubNamed` in [`hub_mcp.go`](../../internal/gateway/hub_mcp.go) | +| Serve | `tools/list` lists the tools of the servers ticked for that agent (at `/mcp/magpie/hub`, agent `""`: every server in the Library, ticked for any agent or none, but a plugin's server hidden from agents, `Server.Hidden`, [Plugin tools](plugin-tools.md)), but those in `DisabledTools`, as `__`: each part in `[A-Za-z0-9_-]` (other characters `_`), at most 64 characters (`cutName`), `_2`, `_3` on a name two would share. Each tool's description and `inputSchema` go on as the server listed them (an object schema with no properties when it has none). An agent that searches its MCP tools itself is given every tool in full, and its tool search keeps them out of each request: Claude Code (`ENABLE_TOOL_SEARCH`, which magpie turns on, see [agent wiring](agent-wiring.md)), Claude Desktop, Codex (`tool_search` on magpie's catalog), Pi, Droid (which defers every MCP tool to its ToolSearch) and omp (which names each in its catalog by its description's first line) (`hubSearchesItself`, by the agent's id without its `@wsl:`). So is the address for any other app (agent `""`) and an agent given 10 tools or fewer. Any other agent is given its tools on demand (below). `tools/call` runs one; an unknown name, or another agent's, is error -32602. `initialize` and `ping` are answered; other methods are -32601. Tools only: no resources or prompts. | `hubMCPCall`, `hubNamed` in [`hub_mcp.go`](../../internal/gateway/hub_mcp.go) | | What it serves | An agent that shows the router as one line, and its tools only once they are searched for, learns from that line alone which servers are behind it (a Pi asked about a GitHub repository cloned it rather than ask the DeepWiki behind the router, told only "The tools of the MCP servers in magpie's Library", 11-01). `initialize`'s `instructions` start with `HubLine`: `Tools of (), …`, every server by name, each one's first clause (`hubClause`) cut at a word to an equal share of 250 characters (`hubLineMax`, Pi's `MAX_SERVER_DESCRIPTION_CHARS`), the short ones whole; names that don't fit are counted (`and N more`). Then, for an agent given several routers to tell them apart (packinggoodsllc_07668: magpies that only share MCP servers), the router's name sentence when it has one (Router name, below), then a line for each server (`hubDetails`): `- (): . Tools: (), …`, the tools the Library turned off left out and a router's `[] ` dropped; a line too long for its share of the room says its tools by name only, then as many names as fit and `and N more`. The whole is at most 2000 characters (`hubSayMax`, half the 4096 Claude Code keeps), the closing text kept whole. What a server is for is the market's (`serverAbout`): the featured or registry server it is by `serverKey`, whatever it is named, or the featured one it is named after; otherwise the server's own words, its `serverInfo.description` or else its `instructions`' first line (`saysOf`); another magpie's `Tools of a (…), b.` is said with `Tools of` once. Its title is its `serverInfo.title`. These and its tools are what the server last answered to `initialize` and `tools/list` (`noteCard`), kept in `mcp-hub-servers.json` beside settings.json (not in the synced library folder) by server name and `cardKey` (a hash of `hubKey`: an edit or a sign-in since is another server), written through a temporary file only when they change; a router started again describes its servers before running any. A server with no card for it as it is now (`Known` false) is listed by `initialize`, which waits up to 5 s (`hubDescribeWait`) for it. No model writes any of it. Which agents show the instructions, from their installed source (11-02): Claude Code (a `# MCP Server Instructions` message, 4096 characters), Codex (the namespace's description), OpenCode (``), Gemini CLI (in a trusted folder only), Qwen Code (the opening history), Pi (the first line in its prompt, the whole through codemode); Kimi CLI reads none, and none of them shows `serverInfo.title` to the model. Pi doesn't wait for a codemode server before writing the first prompt (`waitForDirectServers` waits for direct ones), so its instructions miss that prompt; Pi's own mcp.json (`fmtPiNative`) gets the same line as the hub entry's `description`, which Pi shows before connecting (`serverSummary`). It is magpie's on the hub entry only (`mine`), read back to tell a changed list of servers (`Server.about`, `same`), and any other entry's description is the user's. | `HubLine`, `hubAbout`, `hubDetails`, `hubServerLine`, `hubServersFor` in `hub_mcp.go`; `theHub.Servers`, `hubAbouts`, `hubServerFor` in `mcp_hub.go`; `hubServerOf`, `noteCard`, `saysOf` in [`mcp_hub_cards.go`](../../internal/library/mcp_hub_cards.go); `serverAbout` in [`market.go`](../../internal/library/market.go) | | Tools on demand | An agent with no tool search of its own sends every tool, with its `inputSchema`, on every request (ArvinCharl on X, 11-04: the tools filled the context). Past `hubOnDemandOver` (10) tools, `hubOnDemand` gives it two in their place: `find_tools {query, server?}` scores each tool on the query's words (a word in its router name 3, in its description 1, the whole query in its name 5 more; `hubMatches`) and answers the best 5 with their name, description and `inputSchema`, then up to 15 more by name with their first clause; an empty query, or one nothing matches, names every tool. `find_tools`' description starts with `HubLine` (each server and what it is for: an agent such as omp shows a tool by its description's first line, and some, such as Droid, show no instructions), then how to search, then each server's tools (`hubDetails` within `hubFindSayMax`, 1200 characters; `hubFindSay`): told only how to search, a model asked for a picture searched and stopped (tao5010 on Discord, 11-04). `call_tool {name, arguments}` runs the tool by its router name as `tools/call` finds it (`hubToolNamed`), else the one tool with that name on its server in any case (`hubCallNamed`); `arguments` given as a string holding an object is that object. It runs through the same caller, roots and key limit as `tools/call` (`hubCall`), and its request-log row names the tool that ran (`mcpUse.named`). A name nothing gives is an error naming the close ones. `tools/call` takes both names whatever was listed, and still runs a tool by its own name. `initialize`'s instructions add `Its tools are given on demand: …` (counted from `HubServer.Tools`), and still name each server's tools (`hubDetails`), so the model knows what there is to find. The Library's switch Tools on demand (on by default) turns it off for every agent: `settings.RouterAllTools`, this computer's own (`KeepOwn`), set alone (`SetRouterAllTools`) and kept by the Settings page's save. | `hubOnDemand`, `hubFind`, `hubCallByName` in [`hub_ondemand.go`](../../internal/gateway/hub_ondemand.go); `hubCall` in `hub_mcp.go`; `RouterAllTools`, `SetRouterAllTools` in `settings.go`; `servers/hub-tools` in `gui/library.go`; `View.HubAllTools` in `sync.go` | | Router name | What a router says of itself, for an agent given the same tools by two routers (packinggoodsllc_07668 on Discord: one magpie in China, one in Los Angeles) to pick one. `hubWhere`: the user's words (`settings.RouterNote`, one line, 80 characters at most, `CleanRouterNote`), to every caller; with none, this computer's name (`hostName`) to a caller that isn't `local`, and nothing to one that is (one router at hand; the computer's name stays off its prompts). With a value, `initialize`'s `instructions` say `This router: . …` on their second line (at the end when no server is behind it), `serverInfo.title` is `Magpie MCP hub · `, and each tool's description starts `[] ` (once: a description that starts so already, another magpie's router behind this one, isn't given it again). It is this computer's own (`KeepOwn`): a sync never brings another's. Set in the Library's MCP tab (below) or settings.json; the Settings page's save keeps it (`POST /api/settings`). | `hubWhere` in `hub_mcp.go`; `RouterNote`, `SetRouterNote` in [`settings.go`](../../internal/settings/settings.go); `servers/hub-note` in `gui/library.go`; `View.HubNote`, `View.HubName` in `sync.go` | diff --git a/docs/subsystems/plugin-tools.md b/docs/subsystems/plugin-tools.md index 26f119e80..cf03d6e87 100644 --- a/docs/subsystems/plugin-tools.md +++ b/docs/subsystems/plugin-tools.md @@ -38,13 +38,14 @@ A tool's answer goes back to the agent that called it, on this computer or on a - The router runs its tools in this process (`gateway.PluginToolsOf`, `RunPluginToolOf`), under the same Plugin tools gate. With the router off an agent is given the gateway's address of the plugin's tools as it reaches the gateway (`through`), with a key from another machine. - It is `local`: a carry or backup never takes it to a computer that may lack the plugin. It is offered once (`pluginsOffered`): a server the user removed comes back only when the plugin is removed and added again. The plugin removed takes its server out; turned off, the server stays and lists nothing. A plugins.json that can't be read changes nothing. - `/mcp/magpie/tools`, every plugin's tools under one server, stays for agents wired to it by hand. + - Its plugin's row on the Plugins page says which way it is ("Tools for agents" or "Tools, hidden from agents") and switches it: Hide from agents takes it from every agent, and from apps at the router's address, while the plugin and its providers keep working (chengming0v0 on Discord: a plugin's MCP tools unwanted, the plugin kept). `PluginServerOn` (`servers/plugin-on` `{name, on}`) sets `Hidden` and keeps the agents it had in `Paused`; Give to agents gives them back, or, with none kept, the router's agents (`hubAgents`) or else every agent shown that can take it. The switch is the server's own state, so it holds through a plugin update, the plugin off and on, a restart and an edit in the Library; ticking any agent for it in Library › MCP clears `Hidden` (`save`). `PluginServers` gives the row its state (`toolsServer` in `/api/plugins`); a plugin with no Library server (removed by the user) shows no switch. Library › MCP tags the server "Plugin". `/mcp/magpie/tools` is not affected: it serves only an agent wired to it by hand. (`TestPluginToolsHidden`, `plugin-tools.test.cjs`) ## Verification ```sh go test ./internal/plugin/ -run Tool go test ./internal/gateway/ -run 'ToolsMCP|ServingGates|OwnMCPRejects' -timeout 45m -go test ./internal/library/ -run PluginTools +go test ./internal/library/ -run 'PluginTools|Hub' go test ./plugins/tools/ ./internal/pluginrt/ go test ./internal/gui/ -run 'Builtin|Plugins' node --test internal/gui/tests/plugin-tools.test.cjs internal/gui/tests/builtins.test.cjs diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 50d3615b0..91165e296 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -985,6 +985,10 @@ const I18N = { "1 plugin gives tools": "1 个插件提供工具", "{n} plugins give tools": "{n} 个插件提供工具", "Tools for every agent: {names}": "给每个智能体的工具:{names}", + "Tools for agents: {names}": "给智能体的工具:{names}", + "Tools, hidden from agents: {names}": "工具,已对智能体隐藏:{names}", + "Hide from agents": "对智能体隐藏", + "Give to agents": "交给智能体", "MCP server address": "MCP 服务器地址", "Copy the MCP server's address ({url}): add it to an agent as an MCP server (Streamable HTTP)": "复制 MCP 服务器地址({url}):在智能体里把它添加为 MCP 服务器(Streamable HTTP)", "Key limits": "密钥限额", @@ -5659,6 +5663,10 @@ const I18N = { "1 plugin gives tools": "1 個外掛提供工具", "{n} plugins give tools": "{n} 個外掛提供工具", "Tools for every agent: {names}": "給每個代理的工具:{names}", + "Tools for agents: {names}": "給代理的工具:{names}", + "Tools, hidden from agents: {names}": "工具,已對代理隱藏:{names}", + "Hide from agents": "對代理隱藏", + "Give to agents": "交給代理", "MCP server address": "MCP 伺服器位址", "Copy the MCP server's address ({url}): add it to an agent as an MCP server (Streamable HTTP)": "複製 MCP 伺服器位址({url}):在代理中把它新增為 MCP 伺服器(Streamable HTTP)", "Key limits": "密鑰限額", @@ -10304,6 +10312,10 @@ const I18N = { "1 plugin gives tools": "1 個のプラグインがツールを提供", "{n} plugins give tools": "{n} 個のプラグインがツールを提供", "Tools for every agent: {names}": "すべてのエージェントのツール:{names}", + "Tools for agents: {names}": "エージェントのツール:{names}", + "Tools, hidden from agents: {names}": "ツール(エージェントには非表示):{names}", + "Hide from agents": "エージェントに隠す", + "Give to agents": "エージェントに渡す", "MCP server address": "MCP サーバーのアドレス", "Copy the MCP server's address ({url}): add it to an agent as an MCP server (Streamable HTTP)": "MCP サーバーのアドレス({url})をコピー:エージェントに MCP サーバー(Streamable HTTP)として追加します", "Key limits": "キーの上限", @@ -14964,6 +14976,10 @@ const I18N = { "1 plugin gives tools": "1 Plugin bietet Werkzeuge", "{n} plugins give tools": "{n} Plugins bieten Werkzeuge", "Tools for every agent: {names}": "Werkzeuge für jeden Agenten: {names}", + "Tools for agents: {names}": "Werkzeuge für Agenten: {names}", + "Tools, hidden from agents: {names}": "Werkzeuge, vor Agenten verborgen: {names}", + "Hide from agents": "Vor Agenten verbergen", + "Give to agents": "Agenten geben", "MCP server address": "Adresse des MCP-Servers", "Copy the MCP server's address ({url}): add it to an agent as an MCP server (Streamable HTTP)": "Adresse des MCP-Servers kopieren ({url}): in einem Agenten als MCP-Server (Streamable HTTP) hinzufügen", "Key limits": "Schlüssel-Limits", diff --git a/internal/gui/assets/plugins.css b/internal/gui/assets/plugins.css index 91ff5b5ec..aac43ff66 100644 --- a/internal/gui/assets/plugins.css +++ b/internal/gui/assets/plugins.css @@ -316,3 +316,4 @@ body.window .pm-manual { --bleed-l: 16px; } .pm-card.ghost .sk, .pm-ghlook, .pm-ghlook .dots i, .pm-arrive .pm-card { animation: none; } .pm-ghlook .dots i { opacity: .5; } } +.pm-tools > .pm-tools-flip { flex: none; margin-left: auto; padding: 0 2px; } diff --git a/internal/gui/assets/plugins.js b/internal/gui/assets/plugins.js index ab6440421..201e08c7f 100644 --- a/internal/gui/assets/plugins.js +++ b/internal/gui/assets/plugins.js @@ -1,12 +1,7 @@ -// Plugins: the market of OpenCode provider plugins — subscriptions magpie -// signs in to through someone else's code. Discover lists the plugins -// magpie suggests (the community repo's list, with what npm says of each -// now) and finds the rest on npm; Installed is what was added, to sign in -// with, update, switch off or remove. Each part is drawn as it comes -// (#488): what's installed from /api/plugins, the plugins suggested from -// /api/plugins/listings, and what npm says of them (versions, downloads) -// from /api/plugins/npm after; a sign-in happens in the Providers add -// sheet, as every other subscription's does. +// Plugins: the market of OpenCode plugins. Discover lists the suggested +// ones and finds the rest on npm; Installed is what was added. Each part is +// drawn as it comes (#488): /api/plugins, /api/plugins/listings, then +// /api/plugins/npm; a sign-in happens in the Providers add sheet. (() => { const page = $("#view-plugins"); if (!page) return; @@ -169,11 +164,8 @@ own: !!(r.name || r.summary), npm: { version: r.version || "", publisher: r.owner, repository: r.url, license: r.license, weekly: 0 }, }); - // A failed ask is said, with why, whether or not a list was had before: - // an empty list was read as there being no unofficial plugins (till on - // Discord: GitHub unreachable from their desktop, the section gone). - // A list had before stands through a failed ask that brings none. - // again: Try again, which has magpie ask GitHub at once. + // A failed ask is said, with why, list or not (till on Discord); a list + // had before stands. again: Try again, which asks GitHub at once. async function loadTagged(again) { try { const r = await api("plugins/github" + (again ? "?again=1" : "")); @@ -1272,7 +1264,7 @@ if (mw && !e.off && !ask) who.append(mwLine(mw)); if (gw && !e.off && !ask) who.append(gatewayLine(gw)); if (ag && !e.off && !ask) who.append(agentLine(ag)); - if (e.tools?.length && !e.off && !ask) who.append(toolsLine(e.tools)); + if (e.tools?.length && !e.off && !ask) who.append(toolsLine(e.tools, e)); // off too: what its page may read is said before it is turned on if (e.page && !ask) who.append(pageLine(e.page)); if (e.panels?.length && !ask) who.append(panelsLine(e.panels, e.panelReads)); @@ -1477,14 +1469,25 @@ // toolsLine is the tools a plugin gives, which magpie's plugin tools MCP // server offers every agent: each by the name an agent sees, its // description on hover, and the server's address to copy into an agent - function toolsLine(tools) { - const d = el("div", "sub pm-mw pm-tools"); - d.append(el("span", "", t("Tools for every agent: {names}", { names: tools.map((x) => x.mcp || x.name).join(t(", ")) }))); + // and, with its Library server (toolsServer), a switch for every agent + function toolsLine(tools, e) { + const d = el("div", "sub pm-mw pm-tools"), sv = e.toolsServer; + const names = tools.map((x) => x.mcp || x.name).join(t(", ")); + d.append(el("span", "", t(!sv ? "Tools for every agent: {names}" : sv.on ? "Tools for agents: {names}" : "Tools, hidden from agents: {names}", { names }))); d.title = tools.map((x) => (x.mcp || x.name) + (x.description ? " — " + x.description : "")).join("\n"); const url = mcpAddress(state.settings || {}, "/mcp/magpie/tools"); const b = copyBtn(url, t("MCP server address")); b.title = t("Copy the MCP server's address ({url}): add it to an agent as an MCP server (Streamable HTTP)", { url }); d.append(b); + if (sv && !gatewayMode && !featuresOff.has("library")) { + const f = el("button", "link pm-tools-flip", t(sv.on ? "Hide from agents" : "Give to agents")); + f.onclick = (ev) => { + ev.stopPropagation(); + f.disabled = true; + api("library/servers/plugin-on", { name: sv.plugin, on: !sv.on }).then(refresh, (err) => { f.disabled = false; statusErr(err); }); + }; + d.append(f); + } return d; } diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.js index b5e53318d..ee57488a9 100644 --- a/internal/gui/assets/plugins/library/client.js +++ b/internal/gui/assets/plugins/library/client.js @@ -2138,7 +2138,9 @@ magpie.plugin("library", (ctx) => { if (s.signIn?.dead) nm.append(tag(t("Sign-in ran out"), "warn", t("Open it to sign in again"))); else if (s.signIn?.signedIn) nm.append(tag(t("Signed in"), "lib-signed", t("The agents given it use magpie's sign-in"))); // kept to this computer: sync carries it nowhere (huhuy72219405 on X) - if (s.local) nm.append(tag(t("Not synced"), "lib-local", s.bridge ? bridgedWhy() : t("Sync never carries it to your other computers"))); + // a plugin's tools say whose they are, where they are turned off too + if (s.plugin) nm.append(tag(t("Plugin"), "lib-local lib-plugin", t("{plugin}'s tools. Plugins can hide them from every agent, keeping the plugin; sync never carries them to your other computers", { plugin: s.plugin }))); + else if (s.local) nm.append(tag(t("Not synced"), "lib-local", s.bridge ? bridgedWhy() : t("Sync never carries it to your other computers"))); // out of the hub, each agent's own entry (#4382): said only while the hub is on if (lib.mcpHub && s.hub === "direct") nm.append(tag(t("Not through the router"), "lib-direct", t("Each agent is given its own entry for it, as with the MCP router off"))); // its status beside the name, not in it: the name is still the name diff --git a/internal/gui/assets/plugins/library/i18n.js b/internal/gui/assets/plugins/library/i18n.js index 726f292f1..5389ea7b5 100644 --- a/internal/gui/assets/plugins/library/i18n.js +++ b/internal/gui/assets/plugins/library/i18n.js @@ -17,6 +17,7 @@ magpie.strings({ "Through the MCP router": "经过 MCP 路由", "Off gives each agent its own entry for it, as with the router off: for a server that reads its project from the folder it starts in, or keeps a session's state": "关掉后,每个 Agent 各自有它的条目,和关掉路由时一样:适合从启动目录读取项目、或保存会话状态的服务器", "Sync never carries it to your other computers": "同步不会把它带到你的其他电脑", + "{plugin}'s tools. Plugins can hide them from every agent, keeping the plugin; sync never carries them to your other computers": "{plugin} 的工具。可在「插件」里对所有智能体隐藏,插件保留;同步不会把它们带到你的其他电脑", "Added from a Remote magpie with this computer's key for it, so it stays on this computer": "它从 Remote magpie 添加,带着这台电脑给它的密钥,所以只留在这台电脑", "Sync to your other computers": "同步到其他电脑", "Off keeps it on this computer: sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "关闭后只留在这台电脑:同步不会把它带到你的其他电脑;其他电脑同步过来时,既不会删掉它,也不会用它们的同名服务器替换它", @@ -822,6 +823,7 @@ magpie.strings({ "Through the MCP router": "經過 MCP 路由", "Off gives each agent its own entry for it, as with the router off: for a server that reads its project from the folder it starts in, or keeps a session's state": "關掉後,每個 Agent 各自有它的條目,和關掉路由時一樣:適合從啟動目錄讀取專案、或保存工作階段狀態的伺服器", "Sync never carries it to your other computers": "同步不會把它帶到你的其他電腦", + "{plugin}'s tools. Plugins can hide them from every agent, keeping the plugin; sync never carries them to your other computers": "{plugin} 的工具。可在「外掛」裡對所有代理隱藏,外掛保留;同步不會把它們帶到你的其他電腦", "Added from a Remote magpie with this computer's key for it, so it stays on this computer": "它從 Remote magpie 加入,帶著這台電腦給它的金鑰,所以只留在這台電腦", "Sync to your other computers": "同步到其他電腦", "Off keeps it on this computer: sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "關閉後只留在這台電腦:同步不會把它帶到你的其他電腦;其他電腦同步過來時,既不會刪掉它,也不會用它們的同名伺服器取代它", @@ -1627,6 +1629,7 @@ magpie.strings({ "Through the MCP router": "MCP ルーターを通す", "Off gives each agent its own entry for it, as with the router off: for a server that reads its project from the folder it starts in, or keeps a session's state": "オフにすると、各エージェントに個別のエントリを渡します(ルーターがオフのときと同じ)。起動したフォルダからプロジェクトを読むサーバーや、セッションの状態を持つサーバー向けです", "Sync never carries it to your other computers": "同期でほかのコンピュータには送られません", + "{plugin}'s tools. Plugins can hide them from every agent, keeping the plugin; sync never carries them to your other computers": "{plugin} のツール。「プラグイン」で、プラグインを残したまますべてのエージェントから隠せます。同期で他のコンピュータには送られません", "Added from a Remote magpie with this computer's key for it, so it stays on this computer": "Remote magpie から、このコンピュータのキーで追加されたため、このコンピュータにだけ残ります", "Sync to your other computers": "ほかのコンピュータと同期", "Off keeps it on this computer: sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "オフにするとこのコンピュータだけに残ります。同期でほかのコンピュータには送られず、ほかのコンピュータからの同期で削除されたり、同じ名前のサーバーに置き換えられたりすることもありません", @@ -2432,6 +2435,7 @@ magpie.strings({ "Through the MCP router": "Über den MCP-Router", "Off gives each agent its own entry for it, as with the router off: for a server that reads its project from the folder it starts in, or keeps a session's state": "Aus bekommt jeder Agent einen eigenen Eintrag dafür, wie bei ausgeschaltetem Router: für einen Server, der sein Projekt aus dem Ordner liest, in dem er startet, oder den Zustand einer Sitzung hält", "Sync never carries it to your other computers": "Die Synchronisierung bringt ihn nicht auf deine anderen Computer", + "{plugin}'s tools. Plugins can hide them from every agent, keeping the plugin; sync never carries them to your other computers": "Werkzeuge von {plugin}. Unter Erweiterungen vor allen Agenten verbergbar, die Erweiterung bleibt; die Synchronisierung bringt sie nie auf deine anderen Computer", "Added from a Remote magpie with this computer's key for it, so it stays on this computer": "Von einem Remote magpie mit dem Schlüssel dieses Computers hinzugefügt, darum bleibt er auf diesem Computer", "Sync to your other computers": "Mit deinen anderen Computern synchronisieren", "Off keeps it on this computer: sync never carries it to your other computers, and a sync from them neither removes it nor puts theirs in its place": "Aus bleibt er nur auf diesem Computer: Die Synchronisierung bringt ihn nicht auf deine anderen Computer, und eine Synchronisierung von dort entfernt ihn weder noch ersetzt sie ihn durch ihren gleichnamigen Server", diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index b29ce28ea..5cf38821d 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -16,7 +16,7 @@ import ( // raises them and says why in its commit. const ( appScriptBudget = 1_316_874 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29); 1,315,316 with the Agents row of a Claude Code or Codex not connected saying the account it is signed in to and switching it to another (Switch accounts only, the owner on X), in place of the failover line's ChatGPT accounts button, the Agents page's, the core's own, its comments cut down, with no room added (10-30); 1,317,705 with a Claude account added from a setup-token (sfss5362 on X): the sign-in's Use a setup-token instead…, its sheet, and its account row's magpie only, the provider editor's account rows, the core's own editor, its comments cut down, with no room added (10-30); back to 1,315,316 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, loaded when one is asked for (signAsk, 10-30); 1,315,479 with the provider editor lining its Advanced up with its fields (the owner: 高级这个折叠按钮为什么在一个前不着村后不着店的位置?) and a refresh on each of its accounts (在这里也要加上手动刷新用量的按钮), the core's own editor, with no room added (10-31); 1,315,603 with About's Log row, the path of the log the app writes and an Open for its folder (rayem1w on X), in app.js, its comment cut to one line, with no room added (10-31); 1,316,781 with a provider's model listed by an id of the user's (zeewell on X), the provider editor's Names & levels Listed as box beside Same as, the core's own editor, with no room added (10-31); 1,316,874 with a package manager's magpie (the AUR's magpie-bin) naming the command that updates it in Settings' Version row and lighting no Update pill (shuhai on Discord), the core's own update row, which the tray panel reads too, its comments cut to one line, with no room added (10-31); Settings › Sync's Kept on this computer row (hayden4608 on Discord) raised it to 1,317,497, which is no bound; the 1,316,874 it had came back once later trims left app.js at 1,308,363 (10-31) - coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06) + coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07) ) func TestCoreScriptBudget(t *testing.T) { diff --git a/internal/gui/library.go b/internal/gui/library.go index 7dc0b02e6..a685da519 100644 --- a/internal/gui/library.go +++ b/internal/gui/library.go @@ -543,6 +543,10 @@ func libraryRoutes(mux *http.ServeMux, w Windows) { case "servers/tools": // the tools its agents leave out (nf1qaz2w on Discord) res, err = library.ServerTools(in.Name, in.Names) + case "servers/plugin-on": + // a plugin's tools off for every agent, or on again, from its + // row on the Plugins page (Name is the plugin's) + res, err = library.PluginServerOn(in.Name, in.On) case "servers/agents-all": res, err = library.EveryServerAgents(in.Agents, in.On) case "servers/agents-some": diff --git a/internal/gui/plugins.go b/internal/gui/plugins.go index d44fedb88..a0c9c7201 100644 --- a/internal/gui/plugins.go +++ b/internal/gui/plugins.go @@ -16,6 +16,7 @@ import ( "github.com/yetone/magpie/internal/agent" "github.com/yetone/magpie/internal/gateway" "github.com/yetone/magpie/internal/ghtoken" + "github.com/yetone/magpie/internal/library" "github.com/yetone/magpie/internal/middleware" "github.com/yetone/magpie/internal/plugin" "github.com/yetone/magpie/internal/provider" @@ -171,6 +172,9 @@ type pluginEntryJSON struct { // offers every agent under MCP's name: with their descriptions while // the host runs, by name alone from what it noted last when it doesn't Tools []pluginToolJSON `json:"tools,omitempty"` + // ToolsServer is the Library's server of those tools, whose agents + // the row turns them off and on for (chengming0v0 on Discord) + ToolsServer *library.PluginServer `json:"toolsServer,omitempty"` } // pluginToolJSON is one tool a plugin gives, as its row lists it. @@ -272,6 +276,10 @@ func pluginsState(ctx context.Context, w Windows) pluginsJSON { } } toolNames := gateway.ToolNames(tools) + var servers map[string]library.PluginServer + if len(tools) > 0 { + servers = library.PluginServers() + } // each plugin's subscriptions, by the names it gave last (plugin.Cached, // which holds them without starting the host or asking anyone, and asks // the plugins again in the background when a sign-in or the plugins @@ -377,6 +385,9 @@ func pluginsState(ctx context.Context, w Windows) pluginsJSON { for _, x := range pt.Tools { j.Tools = append(j.Tools, pluginToolJSON{Name: x.Name, Description: x.Description, MCP: toolNames[e.Spec][x.Name]}) } + if sv, ok := servers[plugin.Name(e.Spec)]; ok && len(j.Tools) > 0 { + j.ToolsServer = &sv + } } j.Moved = provider.MovedOnto(e.Spec) if j.Moved == nil { diff --git a/internal/gui/tests/plugin-tools.test.cjs b/internal/gui/tests/plugin-tools.test.cjs index 5131846b4..468d52215 100644 --- a/internal/gui/tests/plugin-tools.test.cjs +++ b/internal/gui/tests/plugin-tools.test.cjs @@ -3,8 +3,10 @@ // the name magpie's plugin tools MCP server gives it, its description on // hover, and a button that copies the server's address. A plugin of tools // alone wears no Provider chip and isn't said to sign in to nothing; one -// that signs in too keeps its line; one switched off lists none. Every -// language, both engines, at a narrow width too; the API is faked here. +// that signs in too keeps its line; one switched off lists none. One with +// a server in the Library hides its tools from every agent and gives them +// back from its line (chengming0v0 on Discord). Every language, both +// engines, at a narrow width too; the API is faked here. const assert = require("node:assert/strict"); const fs = require("node:fs/promises"); const path = require("node:path"); @@ -13,8 +15,10 @@ const { chromium, webkit } = require("playwright"); const assets = path.resolve(__dirname, "../assets"); -const WEATHER = "/Users/x/pl/weather-tools", BOTH = "/Users/x/pl/both", OFF = "/Users/x/pl/off"; +const WEATHER = "/Users/x/pl/weather-tools", BOTH = "/Users/x/pl/both", OFF = "/Users/x/pl/off", VIDEO = "/Users/x/pl/video"; +const video = { spec: VIDEO, providers: ["Vid"], moved: [], named: true, tools: [{ name: "make", mcp: "video_make" }], toolsServer: { name: "video", plugin: VIDEO, on: true } }; const state = { bun: true, bunVersion: "1.3.0", named: true, plugins: [ + video, { spec: WEATHER, providers: [], moved: [], named: true, tools: [ { name: "now", description: "The weather now in a city.", mcp: "weather-tools_now" }, { name: "week", description: "Seven days ahead.", mcp: "weather-tools_week" }, @@ -23,6 +27,7 @@ const state = { bun: true, bunVersion: "1.3.0", named: true, plugins: [ { spec: OFF, off: true, providers: [], moved: [], tools: [{ name: "x", mcp: "off_x" }] }, ] }; +const shown = []; // what each Hide or Give asked the Library function server(lang) { return async (route) => { const url = new URL(route.request().url()); @@ -34,6 +39,12 @@ function server(lang) { if (url.pathname === "/api/groups") return json({ groups: [], pools: [] }); if (url.pathname === "/api/gateway/trace") return json({ routes: [] }); if (url.pathname === "/api/plugins") return json(state); + if (url.pathname === "/api/library/servers/plugin-on") { + const b = route.request().postDataJSON(); + shown.push(b); + video.toolsServer = { ...video.toolsServer, on: b.on }; + return json({}); + } if (url.pathname === "/api/plugins/listings") return json({ listings: [] }); if (url.pathname === "/api/plugins/market") return json({ listings: [], state }); if (url.pathname.startsWith("/api/")) return json({}); @@ -44,11 +55,11 @@ function server(lang) { } const L = { - en: { installed: "Installed", tools: "Tools for every agent: weather-tools_now, weather-tools_week", nothing: "Signs in to nothing", provider: "Provider" }, - zh: { installed: "已安装", tools: "给每个智能体的工具:weather-tools_now、weather-tools_week", nothing: "不能登录", provider: "供应商" }, - "zh-TW": { installed: "已安裝", tools: /^給每個代理的工具:weather-tools_now/ }, - ja: { installed: "インストール済み", tools: /^すべてのエージェントのツール:weather-tools_now/ }, - de: { installed: "Installiert", tools: /^Werkzeuge für jeden Agenten: weather-tools_now/ }, + en: { installed: "Installed", tools: "Tools for every agent: weather-tools_now, weather-tools_week", nothing: "Signs in to nothing", provider: "Provider", given: "Tools for agents: video_make", hidden: "Tools, hidden from agents: video_make", hide: "Hide from agents", give: "Give to agents" }, + zh: { installed: "已安装", tools: "给每个智能体的工具:weather-tools_now、weather-tools_week", nothing: "不能登录", provider: "供应商", given: "给智能体的工具:video_make", hidden: "工具,已对智能体隐藏:video_make", hide: "对智能体隐藏", give: "交给智能体" }, + "zh-TW": { installed: "已安裝", tools: /^給每個代理的工具:weather-tools_now/, given: "給代理的工具:video_make", hidden: "工具,已對代理隱藏:video_make", hide: "對代理隱藏", give: "交給代理" }, + ja: { installed: "インストール済み", tools: /^すべてのエージェントのツール:weather-tools_now/, given: "エージェントのツール:video_make", hidden: "ツール(エージェントには非表示):video_make", hide: "エージェントに隠す", give: "エージェントに渡す" }, + de: { installed: "Installiert", tools: /^Werkzeuge für jeden Agenten: weather-tools_now/, given: "Werkzeuge für Agenten: video_make", hidden: "Werkzeuge, vor Agenten verborgen: video_make", hide: "Vor Agenten verbergen", give: "Agenten geben" }, }; for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { @@ -92,6 +103,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", assert.ok((await both.innerText()).includes("Acme")); assert.ok((await both.locator(".pm-tools").innerText()).includes("both_lookup")); assert.equal(await row("off").locator(".pm-tools").count(), 0, "a plugin off lists no tools"); + assert.equal(await weather.locator(".pm-tools-flip").count(), 0, "no server in the Library, nothing to hide"); + + // hidden from every agent, and given back, from the row + video.toolsServer.on = true; + shown.length = 0; + const vline = row("video").locator(".pm-tools"); + assert.equal((await vline.locator("span").first().innerText()).trim(), w.given); + const flip = vline.locator(".pm-tools-flip"); + assert.equal((await flip.innerText()).trim(), w.hide); + await flip.click(); + await vline.locator(".pm-tools-flip", { hasText: w.give }).waitFor(); + assert.equal((await vline.locator("span").first().innerText()).trim(), w.hidden); + assert.deepEqual(shown, [{ name: VIDEO, on: false }]); + assert.ok(!(await row("video").innerText()).includes("Off\n"), "the plugin itself stays on"); + await vline.locator(".pm-tools-flip").click(); + await vline.locator(".pm-tools-flip", { hasText: w.hide }).waitFor(); + assert.deepEqual(shown, [{ name: VIDEO, on: false }, { name: VIDEO, on: true }]); + const [fb, vb] = await Promise.all([vline.locator(".pm-tools-flip").boundingBox(), row("video").boundingBox()]); + assert.ok(fb.x + fb.width <= vb.x + vb.width + 1, "the line's button overflows its row"); const over = await page.evaluate(() => document.scrollingElement.scrollWidth - document.scrollingElement.clientWidth); assert.ok(over <= 0, "page scrolls sideways by " + over); diff --git a/internal/library/library.go b/internal/library/library.go index 4f68fc561..3315ff3be 100644 --- a/internal/library/library.go +++ b/internal/library/library.go @@ -191,6 +191,12 @@ func load() (*Library, error) { func (l *Library) save() error { sort.Slice(l.MCP, func(i, j int) bool { return l.MCP[i].Name < l.MCP[j].Name }) + // a paused server given an agent, however, is on again + for _, s := range l.MCP { + if len(s.Agents) > 0 { + s.Hidden, s.Paused = false, nil + } + } sort.Slice(l.Skills, func(i, j int) bool { return l.Skills[i].Name < l.Skills[j].Name }) sort.Slice(l.Projects, func(i, j int) bool { return l.Projects[i].Dir < l.Projects[j].Dir }) sort.Slice(l.Hooks, func(i, j int) bool { return l.Hooks[i].Name < l.Hooks[j].Name }) diff --git a/internal/library/mcp.go b/internal/library/mcp.go index 6f50d993e..2611179a9 100644 --- a/internal/library/mcp.go +++ b/internal/library/mcp.go @@ -64,6 +64,13 @@ type Server struct { // gateway serves them at its URL, and the hub calls the plugin itself // (plugin_tools.go) Plugin string `json:"plugin,omitempty"` + // Hidden is a plugin's server whose tools were hidden from every + // agent on the Plugins page (PluginServerOn, chengming0v0 on + // Discord): no agent is given it, nor an app at the MCP router's + // address. Paused are the agents it had, given back when it is shown + // again. Both go once the server has an agent again (save). + Hidden bool `json:"hidden,omitempty"` + Paused []string `json:"paused,omitempty"` // Bridge is the Remote magpie (its provider id) whose MCP router the // server is, given a server of its own (bridge_mcp.go) Bridge string `json:"bridge,omitempty"` diff --git a/internal/library/mcp_hub.go b/internal/library/mcp_hub.go index 32c13fd64..9d059f986 100644 --- a/internal/library/mcp_hub.go +++ b/internal/library/mcp_hub.go @@ -202,7 +202,7 @@ func hubServers(agentID string) []*Server { func (l *Library) hubServers(agentID string) []*Server { var out []*Server for _, s := range l.MCP { - if (agentID == "" || slices.Contains(s.Agents, agentID)) && inHub(s, agentID) { + if (agentID == "" && !s.Hidden || slices.Contains(s.Agents, agentID)) && inHub(s, agentID) { out = append(out, s) } } diff --git a/internal/library/plugin_tools.go b/internal/library/plugin_tools.go index 71977bb4a..22358b1c4 100644 --- a/internal/library/plugin_tools.go +++ b/internal/library/plugin_tools.go @@ -29,6 +29,7 @@ package library import ( "context" "encoding/json" + "fmt" "log" "net/url" "slices" @@ -37,6 +38,7 @@ import ( "github.com/yetone/magpie/internal/gateway" "github.com/yetone/magpie/internal/plugin" + "github.com/yetone/magpie/internal/settings" ) // pluginToolsOf and runPluginToolOf are the gateway's, a test's fakes in @@ -191,3 +193,88 @@ func pluginHubCall(ctx context.Context, agentID string, s *Server, tool string, } return json.Marshal(map[string]any{"content": []map[string]any{{"type": "text", "text": said}}, "isError": false}) } + +// PluginServer is the server of a plugin's tools, as the plugin's row on +// the Plugins page shows it. +type PluginServer struct { + Name string `json:"name"` + Plugin string `json:"plugin"` // plugin.Name, which PluginServerOn takes + // On is whether any agent is given it + On bool `json:"on"` +} + +// PluginServers are the plugins' servers by plugin (plugin.Name); none +// when the library can't be read. +func PluginServers() map[string]PluginServer { + mu.Lock() + defer mu.Unlock() + l, err := load() + if err != nil { + return nil + } + out := map[string]PluginServer{} + for _, s := range l.MCP { + if s.Plugin != "" { + out[s.Plugin] = PluginServer{Name: s.Name, Plugin: s.Plugin, On: len(s.Agents) > 0} + } + } + return out +} + +// PluginServerOn hides a plugin's tools from every agent, or shows them +// again (chengming0v0 on Discord: a plugin's tools no agent should see, +// the plugin kept for its providers). Hidden, no agent is given the +// server, nor an app at the MCP router's address, and the agents it had +// are kept (Paused); shown again, they get it back. With none kept (it was given to none when added, or +// taken from each agent in the Library), on gives it to the agents the MCP +// router's entry goes to, or with the router off or given to none, to every +// agent shown that can take it, as the row's All chip in the Library does. +func PluginServerOn(pluginName string, on bool) (*Result, error) { + return change(func(l *Library) error { + var s *Server + for _, x := range l.MCP { + if x.Plugin == pluginName { + s = x + } + } + if s == nil { + return fmt.Errorf("%s has no MCP server in the library", pluginName) + } + if !on { + if !s.Hidden { + s.Hidden, s.Paused, s.Agents = true, s.Agents, []string{} + } + return nil + } + if len(s.Agents) > 0 { + s.Hidden, s.Paused = false, nil + return nil + } + want := s.Paused + if len(want) == 0 { + want = l.hubAgents() + } + r := reachNow() + if len(want) == 0 { + hidden := settings.Load().AgentsHidden + for _, a := range r.order { + if !slices.Contains(hidden, a) { + want = append(want, a) + } + } + } + var to []string + for _, a := range want { + // one kept from before goes back as it was: its distro may be + // stopped, or its file unread just now + if len(s.Paused) > 0 || r.takes(a, s) { + to = append(to, a) + } + } + if len(to) == 0 { + return fmt.Errorf("no agent can take %s", s.Name) + } + s.Agents, s.Hidden, s.Paused = slices.Compact(slices.Sorted(slices.Values(to))), false, nil + return nil + }) +} diff --git a/internal/library/plugin_tools_test.go b/internal/library/plugin_tools_test.go index 010418c52..eafc34854 100644 --- a/internal/library/plugin_tools_test.go +++ b/internal/library/plugin_tools_test.go @@ -215,3 +215,90 @@ func TestPluginToolsServerThroughAnotherAddress(t *testing.T) { t.Errorf("the stored server changed: %s", s.URL) } } + +// A plugin's tools hidden from every agent on the Plugins page +// (chengming0v0 on Discord: MiniMax's tools, the plugin kept for its +// providers): no agent's hub lists or runs them, nor an app's at the +// router's address; hidden they stay through the plugin updated, turned +// off and on, and the server edited; shown again, the agents that had +// them get them back. An agent ticked in the Library shows them too. +func TestPluginToolsHidden(t *testing.T) { + hubSandbox(t) + f := fakePluginTools(t, search1api) + fake := fakeStdio(t, "ok", nil) + fake.Agents = []string{"claude"} + ok(t)(SaveServer("", *fake)) + ok(t)(SetMCPHub(true)) + ok(t)(Sync()) + const name = "@magpie-community/tools-search1api" + ctx := context.Background() + hub := theHub{} + listed := func(agentID string) bool { + return slices.Contains(hubNames(hub.Tools(ctx, agentID)), "search1api/search") + } + if !listed("claude") || !listed("") || !PluginServers()[name].On { + t.Fatal("the plugin's tools aren't given to begin with") + } + + ok(t)(PluginServerOn(name, false)) + hidden := func(when string) { + t.Helper() + l, err := load() + if err != nil { + t.Fatal(err) + } + s := l.server("search1api") + if s == nil || !s.Hidden || len(s.Agents) != 0 || !slices.Equal(s.Paused, []string{"claude"}) { + t.Fatalf("%s: %+v", when, s) + } + if listed("claude") || listed("") || PluginServers()[name].On { + t.Fatalf("%s: still listed", when) + } + if _, err := hub.Call(ctx, "", "search1api", "search", json.RawMessage(`{}`)); err == nil { + t.Fatalf("%s: an app at the router's address ran it", when) + } + } + hidden("hidden") + f.specs = []string{"@magpie-community/tools-search1api@0.1.2"} + ok(t)(Sync()) + hidden("the plugin updated") + f.off = true + ok(t)(Sync()) + f.off = false + ok(t)(Sync()) + hidden("the plugin off and on") + l, _ := load() + ed := *l.server("search1api") + ed.Hidden, ed.Paused, ed.Note = false, nil, "videos" + ok(t)(SaveServer("search1api", ed)) + hidden("edited") + ok(t)(PluginServerOn(name, false)) + hidden("hidden twice") + ok(t)(EveryServerAgents([]string{"claude"}, true)) + hidden("every server given to claude") + if l, _ := load(); !slices.Contains(l.server("fake").Agents, "claude") { + t.Fatal("every server given to claude left out another server") + } + + ok(t)(PluginServerOn(name, true)) + if l, _ := load(); !slices.Equal(l.server("search1api").Agents, []string{"claude"}) || l.server("search1api").Hidden || !listed("claude") || !listed("") { + t.Fatalf("shown again: %+v", l.server("search1api")) + } + + // ticked for an agent in the Library, it is shown + ok(t)(PluginServerOn(name, false)) + ok(t)(ServerAgents("search1api", []string{"codex"})) + if l, _ := load(); l.server("search1api").Hidden || l.server("search1api").Paused != nil || !listed("") { + t.Fatalf("ticked in the Library, still hidden: %+v", l.server("search1api")) + } + + // none kept: shown, it goes to the agents of the router's entry + ok(t)(ServerAgents("search1api", []string{})) + ok(t)(PluginServerOn(name, true)) + if l, _ := load(); !slices.Equal(l.server("search1api").Agents, []string{"claude"}) { + t.Fatalf("shown with none kept, the router on: %v", l.server("search1api").Agents) + } + if _, err := PluginServerOn("@x/none", true); err == nil { + t.Error("a plugin with no server shown") + } +} diff --git a/internal/library/sync.go b/internal/library/sync.go index acf274234..d2acf1f5a 100644 --- a/internal/library/sync.go +++ b/internal/library/sync.go @@ -783,6 +783,10 @@ func SaveServer(old string, s Server) (*Result, error) { if p := l.MCP[i].Plugin; p != "" && s.Plugin == "" { s.Plugin, s.Local = p, true } + // still off, it still knows whom to give it back to + if len(s.Agents) == 0 && !s.Hidden { + s.Hidden, s.Paused = l.MCP[i].Hidden, l.MCP[i].Paused + } // a Remote magpie's router stays its own while it is at the // provider's address and key (bridge_mcp.go) keptBridge(l.MCP[i], &s) @@ -843,29 +847,22 @@ func serversAgents(names, agents []string, on bool) (*Result, error) { return fmt.Errorf("no server called %s", name) } } - mcp := map[string]*mcpFile{} - // a stopped distro's agents, by what magpie last knew of them - shapes := map[string]*shape{} + var r reach if on { - ts, asleep := targetsAsleep(false) - for _, t := range ts { - if t.MCP != nil { - mcp[t.Agent.ID] = t.MCP - } - } - for _, a := range asleep { - if sh := shapeOf(a); sh != nil { - shapes[a.ID] = sh - } - } + r = reachNow() } for _, s := range l.MCP { if names != nil && !slices.Contains(names, s.Name) { continue } + // an agent's every server leaves out a plugin's hidden from + // every agent on the Plugins page; named, it is shown + if names == nil && on && s.Hidden { + continue + } kept := slices.DeleteFunc(slices.Clone(s.Agents), func(a string) bool { return slices.Contains(agents, a) }) for _, a := range agents { - if on && mcp[a] != nil && mcp[a].supports(s) == nil || on && shapes[a] != nil && shapes[a].reaches(s) { + if on && r.takes(a, s) { kept = append(kept, a) } else if on && slices.Contains(s.Agents, a) { kept = append(kept, a) // one it has already stays, whatever it says of it @@ -877,6 +874,36 @@ func serversAgents(names, agents []string, on bool) (*Result, error) { }) } +// reach is which agents a server can be given: those whose MCP file +// supports it, and a stopped distro's by what magpie last knew of them. +type reach struct { + mcp map[string]*mcpFile + shapes map[string]*shape + order []string // every agent it knows, as found +} + +func reachNow() reach { + r := reach{mcp: map[string]*mcpFile{}, shapes: map[string]*shape{}} + ts, asleep := targetsAsleep(false) + for _, t := range ts { + if t.MCP != nil { + r.mcp[t.Agent.ID] = t.MCP + r.order = append(r.order, t.Agent.ID) + } + } + for _, a := range asleep { + if sh := shapeOf(a); sh != nil { + r.shapes[a.ID] = sh + r.order = append(r.order, a.ID) + } + } + return r +} + +func (r reach) takes(a string, s *Server) bool { + return r.mcp[a] != nil && r.mcp[a].supports(s) == nil || r.shapes[a] != nil && r.shapes[a].reaches(s) +} + // RemoveServer takes a server out of the library and out of every agent // magpie gave it to. func RemoveServer(name string) (*Result, error) { diff --git a/site/public/docs/ja/plugins.html b/site/public/docs/ja/plugins.html index 29f1dc3d6..689b6ffe9 100644 --- a/site/public/docs/ja/plugins.html +++ b/site/public/docs/ja/plugins.html @@ -811,6 +811,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to

設定 → プラグインには各プラグインのツールがこの名前で表示され、サーバーのアドレスをコピーできます。args は zod のフィールド定義(tool.schema は zod)、zod オブジェクト、または JSON Schema オブジェクトです。エージェントにはこれが示され、magpie は execute の前に呼び出しの引数をこれで検証します。引数が正しくなければ、その引数を示すエラーを返します。ctx は OpenCode と同じで、agent は呼び出したエージェントです。ツールの実行時間は 55 秒までで、時間切れになると ctx.abort が発火します。

このサーバーは組み込みプラグイン プラグインのツール が提供します。オンのプラグインがツールを提供している間はオンのままで、オフのときはツールが一覧に出ず、呼び出しにはオフであることが返ります。ゲートウェイキーでの呼び出しはそのキーの上限に数えられます。ツールはプロバイダープラグインと同じくあなたの権限でプラグインホスト内で動き、結果は呼び出したエージェントにだけ返ります。

ツールを提供するプラグインは、ライブラリの MCP タブにもそれぞれ独立したサーバーとして現れ、プラグインの短い名前(search1api)が付きます。アドレスを手で追加する必要はありません。MCP ルーターがオンなら、そのツールはルーターを使うすべてのエージェントに search1api__search として出ます。ほかのライブラリのサーバーと同じく、エージェントごとにオン・オフでき、ツールを一つずつ止めることもできます。削除すると、プラグインを外して追加し直すまで戻りません。

+

プロバイダーのためにプラグインは残し、ツールはどのエージェントにも渡したくないときは、プラグイン › インストール済みでそのツールの行のエージェントに隠すを押します。サーバーはどのエージェントにも、ルーターのアドレスにつなぐアプリにも渡されず、更新、オフとオン、再起動のあとも変わりません。エージェントに渡すで、元のエージェントに戻ります。

エージェントプラグイン

プラグインはエージェントを追加することもできます。magpie に組み込みの設定がないエージェントです。そのエージェントがモデルをどこに書くか、magpie のゲートウェイを使うために他に何を書くかを伝えます。するとエージェントは magpie 自身のものと同じようにエージェントページに並びます。その行で magpie のモデルを選ぶと、magpie はモデルをゲートウェイのアドレスとエージェント専用のキーと一緒に設定へ書き込み、スイッチを切るとすべてユーザーの元の状態に戻します。下の例は Aider を追加します。

diff --git a/site/public/docs/plugins.html b/site/public/docs/plugins.html index 6ee2ab41d..dc16b6c21 100644 --- a/site/public/docs/plugins.html +++ b/site/public/docs/plugins.html @@ -811,6 +811,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to

Settings → Plugins lists each plugin’s tools by these names and copies the server’s address. args is a zod shape (tool.schema is zod), a zod object or a JSON Schema object. The agent is shown it, and magpie checks a call’s arguments against it before execute runs; a wrong argument is answered as an error naming it. ctx is OpenCode’s, with agent the agent that called. A tool has 55 seconds, and ctx.abort fires when they are up.

The built-in plugin Plugin tools serves the server. It stays on while a plugin that is on gives a tool; off, no tool is listed and a call says so. A call made with a gateway key counts against that key’s limits. A tool runs in the plugin host with your rights, as a provider plugin does, and its answer goes only to the agent that called it.

Each plugin that gives tools is also a server of its own in the Library’s MCP tab, named by the plugin’s short name (search1api), so you don’t have to add the address by hand. With the MCP router on, its tools are in the router of every agent the router is given, as search1api__search; switch it on or off per agent, or turn single tools off, as with any Library server. Removed, it comes back only when you remove the plugin and add it again.

+

To keep a plugin for its providers but give its tools to no agent, press Hide from agents on its tools line under Plugins › Installed. Its server is then given to no agent, nor to an app at the router’s address, through updates, the plugin off and on, and restarts. Give to agents gives it back to the agents it had.

Agent plugins

A plugin can also add an agent: one magpie has no setup of its own for. It says where the agent keeps its model and what else to write there for the agent to use magpie’s gateway. The agent is then on the Agents page like magpie’s own: pick one of magpie’s models in its row and magpie writes it into the agent’s config, with the gateway’s address and a key of the agent’s own; switch it off and everything goes back to how the user had it. The example below adds Aider.

diff --git a/site/public/docs/zh/plugins.html b/site/public/docs/zh/plugins.html index f0a28a6b5..fcf3f3821 100644 --- a/site/public/docs/zh/plugins.html +++ b/site/public/docs/zh/plugins.html @@ -811,6 +811,7 @@ claude mcp add --transport http magpie-tools http://127.0.0.1:3425/mcp/magpie/to

设置 → 插件里会按这些名字列出每个插件的工具,并能复制服务器地址。args 可以是 zod 字段表(tool.schema 就是 zod)、zod 对象或 JSON Schema 对象。智能体会看到它,magpie 在 execute 运行前按它检查调用的参数;参数不对时回一个写明是哪个参数的错误。ctx 与 OpenCode 的相同,agent 是发起调用的智能体。每个工具最多运行 55 秒,到时 ctx.abort 触发。

这个服务器由内置插件 插件工具 提供。只要有已开启的插件提供工具,它就保持开启;关闭时不列出任何工具,调用会说明它已关闭。用网关密钥发起的调用计入该密钥的限额。工具和提供方插件一样,以你的权限在插件宿主里运行,结果只回给调用它的智能体。

每个提供工具的插件也会在资料库的 MCP 页里成为一个独立的服务器,以插件的短名命名(如 search1api),不用再手动添加地址。开启 MCP 路由时,它的工具会出现在每个接入路由的智能体里,名为 search1api__search;和资料库里其他服务器一样,可以按智能体开关,或单独关掉某个工具。删掉后,只有把插件移除再重新添加才会再出现。

+

想保留插件的供应商、却不把它的工具给任何智能体:在插件 › 已安装里,点它工具那一行的对智能体隐藏。之后它的服务器不会给任何智能体,也不会给连到路由地址的应用;插件更新、关了再开、重启都保持不变。点交给智能体,就还给原来那些智能体。

Agent 插件

插件还可以添加一个 Agent:magpie 没有内置接入的那种。它说明这个 Agent 把模型写在哪里,以及还要写些什么才能让 Agent 走 magpie 的网关。这样它就和 magpie 内置的 Agent 一样出现在 Agent 页:在它那一行选一个 magpie 的模型,magpie 就把模型连同网关地址和这个 Agent 自己的 key 写进它的配置;关掉开关,一切恢复成用户原来的样子。下面的例子添加 Aider。