Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
library: Connect an app is two tabs, agents in groups with a switch each (#2679)
yetone85d159a288a6
diff --git a/docs/subsystems/mcp-hub.md b/docs/subsystems/mcp-hub.mdindex 4db225667..fc6738301 100644--- a/docs/subsystems/mcp-hub.md+++ b/docs/subsystems/mcp-hub.md@@ -13,7 +13,7 @@ With the Library's switch "MCP hub" on (#2679, @minggang123 on X), each agent is| Guard | `serveMCP`, as `/mcp/magpie/tools`: a local request, or one with a gateway key; a browser page's Origin that `corsAllowed` doesn't allow is 403; POST only; a 4 MiB body (`hubBody`). The outer `lanGuard`/`corsGuard` already refuse `Origin: null`, a foreign site and a rebound Host. Each call is held to the calling key's limit (`reserveFor`) before anything runs. | `hubMCP`, `hubMCPRun` in `hub_mcp.go`; `serveMCP` in [`search_mcp.go`](../../internal/gateway/search_mcp.go) || Backends | One `backend` per Library server, shared by every agent (`hubPool`, keyed by the server's name; an edit or a sign-in since makes it a new one and ends the old). A command is started as `CheckServers` starts one (`startServer`: `proc` tree, home as its folder, `${NAME}` env expanded), on its first list or call, and initialized once. A URL (`http`, `sse`) is reached with its headers and the Library's MCP sign-in (`mcpauth`), and a session the server forgot is opened again once. A `notifications/tools/list_changed` from a server makes the next list ask it again. | `backendOf`, `connect`, `dialHub`, `dialStdio`, `dialSSE`, `dialHTTP` in `mcp_hub.go`; `startServer`, `httpSession` in [`mcp_check.go`](../../internal/library/mcp_check.go) || Lifetime | A server with no call for `hubIdle` (10 minutes) is ended; the tools it listed are kept, so a list doesn't start it again, and the next call does. A command that died is started again on the next call. Turning the switch off, an edit, and the gateway stopping (`StopHub` on drain) end them: stdin closed, then the process tree. The switch can be turned off, or a server edited or unticked, by another magpie (the window while `magpie serve` runs, the CLI), and an agent given each server's own entry again never asks the hub, so the serving gateway also prunes every `hubPruneEvery` (5s) while it holds a server: each one the library no longer has as it was started, or every one once the switch is off, is ended (`hubPrune`). A server ticked for no agent is still served at `/mcp/magpie/hub`, so it is kept. | `use`, `done`, `stop`, `hubStopAll`, `hubPrune` in `mcp_hub.go`; `StopHub`, `keepHubPruned` in `hub_mcp.go` |-| GUI | Below the server list in the Library's MCP tab: a row with the switch (`.lib-switch`, role=switch) saying what it does; on, a line counting what it serves (`.lib-hubstats`: servers, tools, the agents given it), then a row "Other apps" with the address (`.lib-hubURL`, copied with a click) and Connect…, and under them the agents that keep their own entries, grouped by why (`.lib-hub-why[data-why]`). The address is `mcpAddress`: the public one in a browser, the gateway in the app. Connect… opens a sheet (`connectHub`, `.lib-hubsheet`). First come the agents magpie looks after: every one `mcpAgents` lists (each detected, shown agent that takes MCP servers), each with where it stands (`.lib-hubagent[data-state]`): `on` (connected, and how many servers it gets through magpie), `own`, `taken` or `no-remote` (why it keeps each server's own entry; an agent that reaches no server over HTTP says so even with none ticked), or `none`, given none of the hub's servers, which has a Connect (`.lib-hubgo`) that posts `servers/agents-all` `{agents:[id], on:true}`, as By agent's Turn all on does, so `hubFor` gives it the entry. The sheet stays open and the row then says connected. An agent is never handed to the user as a command to run. Then any other app: the address, and a picker of Cursor (only when it isn't one of the agents), VS Code and Other (any JSON app), with each one's JSON copied with a click. In the app, Cursor and VS Code also get "Add to {app}": the page posts `servers/hub-open` `{app}` and the window opens that app's install link (`HubLink`), which the app asks the user to confirm. The page never sends a link; an app with none is an error, and nothing is opened. In a browser there is no such button. | `hubPart`, `hubStats`, `connectHub` in [`client.js`](../../internal/gui/assets/plugins/library/client.js), [`library.css`](../../internal/gui/assets/plugins/library/library.css), [`i18n.js`](../../internal/gui/assets/plugins/library/i18n.js); `HubLink` in `mcp_hub.go`; `servers/hub-open` in `gui/library.go` | `hubPart` in [`client.js`](../../internal/gui/assets/plugins/library/client.js), [`library.css`](../../internal/gui/assets/plugins/library/library.css), [`i18n.js`](../../internal/gui/assets/plugins/library/i18n.js) |+| GUI | Below the server list in the Library's MCP tab: a row with the switch (`.lib-switch`, role=switch) saying what it does; on, a line counting what it serves (`.lib-hubstats`: servers, tools, the agents given it), then a row "Other apps" with the address (`.lib-hubURL`, copied with a click) and Connect…, and under them the agents that keep their own entries, grouped by why (`.lib-hub-why[data-why]`). The address is `mcpAddress`: the public one in a browser, the gateway in the app. Connect… opens a sheet (`connectHub`, `.lib-hubsheet`) of two tabs. Agents: agents → magpie → servers, drawn as icons with magpie's bird in the middle, a line of where things stand, then every agent `mcpAgents` lists (each detected, shown agent that takes MCP servers) in groups (`.lib-hubgrp[data-group]`): `off` (not connected), `on` (connected), `kept` (keeps each server's own entry). Each row (`.lib-hubagent[data-state]`: `on`, `none`, `own`, `taken`, `no-remote`) has a switch that posts `servers/agents-all` `{agents:[id], on}`, as By agent's Turn all on/off does: on gives it every Library server, so `hubFor` gives it the entry; off takes every Library server from it. A kept agent has a word for why and the reason in full behind (i) (`.lib-hubinfo`, `.lib-hubwhy`); an agent that reaches no server over HTTP says so even with none ticked. Connect all (`.lib-huball`) posts every `none` agent at once. With more than 8 agents a search (`.lib-hubsearch`) narrows every group, and the connected and the kept fold to one row each (`.lib-hubfolded`) until unfolded. The sheet stays open while it changes, and an agent is never handed to the user as a command to run. Other apps: the address (`.lib-hubaddr`), and a row per app (`.lib-hubapp[data-app]`): Cursor (only when it isn't one of the agents), VS Code, Windsurf and any JSON app, each with where its entry goes and a Copy entry (`.lib-hubcopy`) that copies its JSON. In the app, Cursor and VS Code also get Add (`.lib-hubadd`): the page posts `servers/hub-open` `{app}` and the window opens that app's install link (`HubLink`), which the app asks the user to confirm. The page never sends a link; an app with none is an error, and nothing is opened. In a browser there is no Add. | `hubPart`, `hubStats`, `connectHub` in [`client.js`](../../internal/gui/assets/plugins/library/client.js), [`library.css`](../../internal/gui/assets/plugins/library/library.css), [`i18n.js`](../../internal/gui/assets/plugins/library/i18n.js); `HubLink` in `mcp_hub.go`; `servers/hub-open` in `gui/library.go` |The CLI's `magpie library mcp hub on|off` calls `SetMCPHub`, and `magpie library` lists the agents given magpie's entry and those that keep their own, with why (`libraryStatus` in [`library_cli.go`](../../internal/cli/library_cli.go)).diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.jsindex 958791073..a8096ac5b 100644--- a/internal/gui/assets/i18n.js+++ b/internal/gui/assets/i18n.js@@ -509,6 +509,9 @@ const I18N = {"Search models": "搜索模型","Shown": "已显示","Show all": "全部显示",+ "Why": "原因",+ "Not connected": "未连接",+ "Connected": "已连接","Hide all": "全部隐藏","Current": "在用","{agent} is set to it, so it stays": "{agent} 正在使用它,不能隐藏",@@ -4574,6 +4577,9 @@ const I18N = {"Search models": "搜尋模型","Shown": "已顯示","Show all": "全部顯示",+ "Why": "原因",+ "Not connected": "未連線",+ "Connected": "已連線","Hide all": "全部隱藏","Current": "在用","{agent} is set to it, so it stays": "{agent} 正在使用它,不能隱藏",@@ -8605,6 +8611,9 @@ const I18N = {"Search models": "モデルを検索","Shown": "表示中","Show all": "すべて表示",+ "Why": "理由",+ "Not connected": "未接続",+ "Connected": "接続済み","Hide all": "すべて非表示","Current": "使用中","{agent} is set to it, so it stays": "{agent} で使用中のため非表示にできません",@@ -12653,6 +12662,9 @@ const I18N = {"Search models": "Modelle suchen","Shown": "Angezeigt","Show all": "Alle anzeigen",+ "Why": "Warum",+ "Not connected": "Nicht verbunden",+ "Connected": "Verbunden","Hide all": "Alle ausblenden","Current": "Aktuell","{agent} is set to it, so it stays": "{agent} verwendet es, daher bleibt es",diff --git a/internal/gui/assets/plugins/library/client.js b/internal/gui/assets/plugins/library/client.jsindex 42483aa7f..72f5f15a5 100644--- a/internal/gui/assets/plugins/library/client.js+++ b/internal/gui/assets/plugins/library/client.js@@ -1604,118 +1604,249 @@ magpie.plugin("library", (ctx) => {}const hubURL = () => mcpAddress(state.settings || {}, lib.hubPath.replace(/\/+$/, ""));- // Connect to the hub: every agent magpie looks after first, each with- // where it stands (connected, connected with a click, or why it keeps- // each server's own entry), then the one address any other app connects- // at, with what adds it there. The agents are magpie's to connect, never- // a command for the user to run; Cursor is among them when it's here,- // and only an app magpie doesn't look after is set up by hand: by its- // install link, which magpie builds (servers/hub-open) and the app- // confirms, or by copying its entry.- let hubApp = "";+ // Connect to the hub (#2679): two tabs. Agents: every agent magpie looks+ // after, in three groups, each a switch of its own. Not connected+ // comes first, then connected, then the agents that keep each server's+ // own entry, with why. Over them is one line of how many go through+ // magpie, and in the bar a Connect all for the rest. With many agents,+ // the connected and the kept fold to one row each and a search narrows+ // them all. Other apps: the one address, and a row per app with what+ // adds it, by its install link (servers/hub-open, which the app+ // confirms) or by copying its entry. The agents are magpie's to+ // connect, never a command for the user to run; Cursor is among them+ // when it's here.+ let hubTab = "agents";+ const hubFold = { on: true, kept: true };function connectHub() {const url = hubURL();const json = (o) => JSON.stringify(o, null, 2);+ const served = () => lib.servers.filter((s) => !(s.transport === "stdio" && s.args?.[0] === "mcp" && s.args?.[1] === "image"));const ed = el("div", "editor lib-editor lib-hubsheet");const head = el("div", "ehead");head.append(glyph(GLYPH.hub), el("b", "", t("Connect an app")));ed.append(head);- ed.append(el("p", "lib-confirm lib-hublead", t("magpie connects the agents on this computer itself. Any other app that speaks MCP connects at the address below.")));+ const pane = el("div", "lib-hubpane");+ const bar = el("div", "bar");+ let busy = false, changed = false, q = "";+ const why = new Set();+ if (!mcpAgents().length) hubTab = "apps";+ if (mcpAgents().length) ed.append(segs([["agents", t("Agents")], ["apps", t("Other apps")]], hubTab, (k) => { hubTab = k; draw(); }));+ ed.append(pane, bar);++ // posts agents-all for some agents, on or off, and says what came of it+ const give = async (ids, on, b) => {+ if (busy) return;+ busy = true;+ for (const x of ed.querySelectorAll(".lib-hubpane button, .bar button")) x.disabled = true;+ b?.classList.add("busy");+ const named = mcpAgents().filter((a) => ids.includes(a.id));+ try {+ take(await api("library/servers/agents-all", { agents: ids, on }));+ changed = true;+ const now = mcpAgents().filter((a) => ids.includes(a.id));+ const failed = now.filter((a) => on ? a.hub !== "on" : a.hub === "on");+ if (failed.length) status(t("{agent} couldn't be connected", { agent: failed.map((a) => a.name).join(", ") }), "warn", 8000);+ else if (!on) status(t("{agent} no longer has the library's servers — restart it to read the change", { agent: named[0]?.name || "" }), "ok");+ else if (named.length === 1) status(t("{agent} is connected — restart it to use magpie's tools", { agent: named[0].name }), "ok");+ else status(t("{n} agents are connected — restart them to use magpie's tools", { n: named.length }), "ok");+ render();+ } catch (e) {+ status(e.message, "err", 6000);+ }+ busy = false;+ if (ed.isConnected) draw();+ };- // the agents: every one here that takes MCP servers- const list = el("div", "list lib-list lib-hubagents");- let busy = false;- const served = () => lib.servers.filter((s) => !(s.transport === "stdio" && s.args?.[0] === "mcp" && s.args?.[1] === "image"));- const drawAgents = () => list.replaceChildren(...mcpAgents().map((a) => {- // one given none of the hub's servers has no state of its own; one- // that reaches no server over HTTP couldn't take it either way+ // an agent's row: a switch, or, kept, why in a word and in full+ const agentRow = (a) => {const st = a.hub || (a.noRemote ? "no-remote" : "");const row = el("div", "row lib-row lib-hubagent");row.dataset.agent = a.id;row.dataset.state = st || "none";const who = el("div", "who");who.append(el("div", "name", a.name));- const n = served().filter((s) => s.agents?.includes(a.id)).length;- const line = {- on: n === 1 ? t("1 server, through magpie") : t("{n} servers, through magpie", { n }),+ if (a.aside && st !== "no-remote") who.append(el("div", "sub", a.aside));+ row.append(agentIcon(a.icon), who);+ if (st === "on" || !st) {+ const sw = toggle(st === "on", t("{agent} through magpie", { agent: a.name }), (on) => give([a.id], on, sw));+ if (!st && !served().length) { sw.disabled = true; sw.title = t("The library has no MCP servers yet"); }+ row.append(sw);+ return [row];+ }+ row.classList.add("lib-hubkept");+ row.append(el("span", "lib-hubtag", { "no-remote": t("No HTTP"), own: t("Has its own magpie"), taken: t("Name taken") }[st]));+ const open = why.has(a.id);+ const i = el("button", "lib-hubinfo");+ i.type = "button";+ i.setAttribute("aria-expanded", open ? "true" : "false");+ i.setAttribute("aria-label", t("Why"));+ i.title = t("Why");+ i.append(svg("M8 2.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11z M8 7.2v3.6 M8 5.2v.1", 14, 1.3));+ i.onclick = (e) => { e.stopPropagation(); open ? why.delete(a.id) : why.add(a.id); draw(); };+ row.append(i);+ if (!open) return [row];+ const p = el("p", "lib-hubwhy", {"no-remote": t("It reaches no MCP server over HTTP, so it keeps each server's own entry"),own: t("It has a server called magpie of its own, which magpie leaves as it is"),taken: t("A server in the library is called magpie: give it another name to connect"),- "": served().length ? t("None of the library's servers is on for it yet") : t("The library has no MCP servers yet"),- }[st];- who.append(el("div", "sub", a.aside && st === "on" ? line + " · " + a.aside : line));- row.append(agentIcon(a.icon), who);- if (st === "on") {- const ok = el("span", "lib-hubok", t("On the hub"));- ok.prepend(svg("M3.5 8.5l3 3 6-7", 12, 1.8));- row.append(ok);- } else if (!st && served().length) {- const go = button(t("Connect"), "action lib-updall lib-hubgo", async (e, b) => {- if (busy) return;- busy = true;- for (const x of list.querySelectorAll("button")) x.disabled = true;- b.classList.add("busy");- try {- take(await api("library/servers/agents-all", { agents: [a.id], on: true }));- const now = mcpAgents().find((x) => x.id === a.id);- if (now?.hub === "on") status(t("{agent} is connected — restart it to use magpie's tools", { agent: a.name }), "ok");- else status(t("{agent} couldn't be connected", { agent: a.name }), "warn", 8000);- render();- } catch (e) {- status(e.message, "err", 6000);- }- busy = false;- if (list.isConnected) drawAgents();- });- go.title = t("Give {agent} every server it can reach, through magpie", { agent: a.name });- row.append(go);+ }[st]);+ p.dataset.why = st;+ return [row, p];+ };+ // a group: its name and count, a fold when there are many, its rows+ const group = (key, title, list, many) => {+ if (!list.length) return [];+ const sec = el("div", "lib-hubgrp");+ sec.dataset.group = key;+ const h = el("div", "lib-hubsec");+ h.append(el("span", "", title), el("span", "lib-hubn", String(list.length)));+ const folds = many && key !== "off" && !q;+ const folded = folds && hubFold[key];+ if (folds) {+ const f = button(folded ? t("Show all") : t("Hide"), "lib-hubfold", () => { hubFold[key] = !hubFold[key]; draw(); });+ f.setAttribute("aria-expanded", folded ? "false" : "true");+ h.append(f);}- return row;- }));- if (mcpAgents().length) {- ed.append(el("div", "lib-hubsec", t("Agents magpie looks after")), list);- drawAgents();- }+ const box = el("div", "list lib-list lib-hubagents");+ if (folded) {+ // one row for them all: a few icons, a couple of names, how many+ const row = el("button", "row lib-row lib-hubfolded");+ row.type = "button";+ const stack = el("span", "lib-hubstack");+ for (const a of list.slice(0, 4)) stack.append(agentIcon(a.icon));+ const names = list.length > 2+ ? t("{first} and {n} more", { first: list.slice(0, 2).map((a) => a.name).join(", "), n: list.length - 2 })+ : list.map((a) => a.name).join(", ");+ row.append(stack, el("span", "name", names), svg("M6 3.5l4.5 4.5L6 12.5", 12, 1.6));+ row.onclick = (e) => { e.stopPropagation(); hubFold[key] = false; draw(); };+ box.append(row);+ } else box.append(...list.flatMap(agentRow));+ sec.append(h, box);+ return [sec];+ };- // any other app: the address, and what adds it- ed.append(el("div", "lib-hubsec", t("Any other app")));- const addr = el("div", "lib-hubaddr");- addr.append(el("code", "", url), copyBtn(url, t("Address")));- ed.append(addr);- const apps = {- ...(mcpAgents().some((a) => a.id === "cursor") ? {} : { cursor: { name: "Cursor", link: true, where: t("Or add it to ~/.cursor/mcp.json:"), text: json({ mcpServers: { magpie: { url } } }) } }),- vscode: { name: "VS Code", link: true, where: t("Or add it to .vscode/mcp.json, or to your user mcp.json:"), text: json({ servers: { magpie: { type: "http", url } } }) },- json: { name: t("Other"), where: t("For any app that takes MCP servers as JSON (Windsurf, Cline, LM Studio and more):"), text: json({ mcpServers: { magpie: { type: "http", url } } }) },+ const drawAgents = () => {+ const all = mcpAgents();+ const st = (a) => a.hub || (a.noRemote ? "no-remote" : "");+ const can = all.filter((a) => st(a) === "on" || !st(a));+ const on = can.filter((a) => st(a) === "on");+ const kept = all.filter((a) => !can.includes(a));+ const many = all.length > 8;+ // agents → magpie → servers, and the one line of where things stand+ const flow = el("div", "lib-hubflow");+ const route = el("div", "lib-hubroute");+ const ends = (items, more) => {+ const s = el("span", "lib-hubstack");+ s.append(...items);+ if (more > 0) s.append(el("span", "ic lib-hubmore", "+" + more));+ return s;+ };+ // magpie itself in the middle: the bird the sidebar shows, on a plain tile+ const node = el("span", "lib-hubnode");+ node.innerHTML = '<svg viewBox="0 0 44 44" width="22" height="22" aria-hidden="true"><use href="#bird"/></svg>';+ const srv = served();+ route.append(ends(on.slice(0, 3).map((a) => agentIcon(a.icon)), on.length - 3), el("span", "lib-hubwire"), node, el("span", "lib-hubwire"),+ ends(srv.slice(0, 3).map((s) => mark(s.icon, s.transport === "stdio" ? GLYPH.cmd : GLYPH.web)), srv.length - 3));+ flow.append(route);+ flow.append(el("p", "lib-hublead", !srv.length ? t("The library has no MCP servers yet")+ : can.length === 1 ? t(on.length ? "{agent} uses the library's servers through magpie" : "{agent} can use the library's servers through magpie", { agent: can[0].name })+ : t("{on} of {all} agents use the library's servers through magpie", { on: on.length, all: can.length })));+ const left = can.length - on.length;+ const sub = [left ? t("{n} more can be connected", { n: left }) : t("Each server runs once, for all of them")];+ if (kept.length) sub.push(kept.length === 1 ? t("1 keeps each server's own entry") : t("{n} keep each server's own entry", { n: kept.length }));+ // each part whole on its line, the dot kept with the part before it+ const line = el("p", "lib-hubsub");+ sub.forEach((x, i) => line.append(...(i ? [" "] : []), el("span", "", x + (i < sub.length - 1 ? "\u00a0·" : ""))));+ flow.append(line);+ const out = [flow];+ if (many) {+ const box = el("label", "lib-hubsearch");+ box.append(svg("M7 2.5a4.5 4.5 0 1 0 0 9 4.5 4.5 0 0 0 0-9z M10.3 10.3l3.2 3.2", 13, 1.5));+ const inp = el("input");+ inp.type = "search";+ inp.id = "lib-hubq";+ inp.placeholder = t("Find an agent");+ inp.setAttribute("aria-label", t("Find an agent"));+ inp.value = q;+ inp.oninput = () => { q = inp.value.trim(); draw(); };+ box.append(inp);+ out.push(box);+ }+ const m = (a) => !q || a.name.toLowerCase().includes(q.toLowerCase());+ const groups = [+ ...group("off", t("Not connected"), can.filter((a) => !st(a) && m(a)), many),+ ...group("on", t("Connected"), on.filter(m), many),+ ...group("kept", t("Keep each server's own entry"), kept.filter(m), many),+ ];+ out.push(...(groups.length ? groups : [el("p", "lib-hubnone", t("No agent called “{q}”", { q }))]));+ return out;};- if (!apps[hubApp]) hubApp = Object.keys(apps)[0];- const pane = el("div", "lib-hubpane");++ // any other app: the address, and a row per app with what adds it+ const drawApps = () => {+ const out = [el("p", "lib-hublead lib-hubapps", t("Any app that speaks MCP connects at this address"))];+ const addr = el("div", "lib-hubaddr");+ addr.append(el("code", "", url), copyBtn(url, t("Address")));+ out.push(addr, el("p", "lib-hubcap", t("From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.")));+ const apps = [+ ...(mcpAgents().some((a) => a.id === "cursor") ? [] : [{ id: "cursor", icon: "cursor", name: "Cursor", link: true, where: t("Or add it to ~/.cursor/mcp.json"), text: json({ mcpServers: { magpie: { url } } }) }]),+ { id: "vscode", icon: "vscode", name: "VS Code", link: true, where: t("Or add it to .vscode/mcp.json, or to your user mcp.json"), text: json({ servers: { magpie: { type: "http", url } } }) },+ { id: "windsurf", icon: "windsurf", name: "Windsurf", where: t("Paste it into ~/.codeium/windsurf/mcp_config.json"), text: json({ mcpServers: { magpie: { serverUrl: url } } }) },+ { id: "json", icon: "generic", name: t("Other"), where: t("Cline, LM Studio and any app that takes MCP servers as JSON"), text: json({ mcpServers: { magpie: { type: "http", url } } }) },+ ];+ const sec = el("div", "lib-hubgrp");+ sec.append(el("div", "lib-hubsec", t("Add to an app")));+ const box = el("div", "list lib-list lib-hubappl");+ for (const a of apps) {+ const row = el("div", "row lib-row lib-hubapp");+ row.dataset.app = a.id;+ const who = el("div", "who");+ const link = a.link && !web;+ who.append(el("div", "name", a.name), el("div", "sub", link ? t("{app} asks you to confirm, then it's ready", { app: a.name }) : a.where));+ row.append(icon(a.icon), who);+ if (link) {+ const go = button(t("Add"), "lib-hubpill lib-hubadd", async () => {+ go.disabled = true;+ try {+ await api("library/servers/hub-open", { app: a.id });+ status(t("{app} asks you to confirm adding magpie", { app: a.name }));+ } catch (e) { status(e.message, "err"); }+ go.disabled = false;+ });+ go.title = t("Add to {app}", { app: a.name });+ row.append(go);+ }+ const cp = button(t("Copy entry"), "lib-hubpill lib-hubcopy", () => copy(a.text, a.name, cp, t("{app}'s entry copied", { app: a.name })));+ cp.title = a.text;+ if (link) cp.classList.add("quiet");+ row.append(cp);+ box.append(row);+ }+ sec.append(box);+ out.push(sec);+ return out;+ };++ const done = button(t("Done"), "", () => closeLibModal(true));const draw = () => {- const a = apps[hubApp];- pane.replaceChildren();- if (a.link && !web) {- const go = button(t("Add to {app}", { app: a.name }), "primary lib-hubadd", async () => {- go.disabled = true;- try {- await api("library/servers/hub-open", { app: hubApp });- status(t("{app} asks you to confirm adding magpie", { app: a.name }));- } catch (e) { status(e.message, "err"); }- go.disabled = false;- });- pane.append(go);+ const top = pane.scrollTop;+ const focus = document.activeElement?.id === "lib-hubq";+ pane.replaceChildren(...(hubTab === "agents" ? drawAgents() : drawApps()));+ pane.scrollTop = top;+ if (focus) { const i = pane.querySelector("#lib-hubq"); i.focus(); i.setSelectionRange(i.value.length, i.value.length); }+ // the one primary action: Connect all while there are agents to connect+ const rest = hubTab === "agents" && served().length ? mcpAgents().filter((a) => !a.hub && !a.noRemote) : [];+ bar.replaceChildren(el("span", "grow lib-hubnote", changed ? t("Restart an agent for it to read the change") : ""), done);+ done.className = "text" + (rest.length ? "" : " primary");+ done.disabled = false;+ if (rest.length) {+ const all = button(t("Connect all"), "primary lib-huball", (e, b) => give(rest.map((a) => a.id), true, b));+ all.title = rest.map((a) => a.name).join(", ");+ bar.append(all);}- pane.append(el("p", "lib-hubwhere", a.where));- const block = el("div", "lib-hubcode");- block.append(el("pre", "", a.text), copyBtn(a.text, a.name));- pane.append(block);- if (hubApp === "json") pane.append(el("p", "lib-aside", t("Its transport is Streamable HTTP. From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.")));};- ed.append(segs(Object.entries(apps).map(([k, a]) => [k, a.name]), hubApp, (k) => { hubApp = k; draw(); }), pane);draw();- const bar = el("div", "bar");- const done = button(t("Done"), "primary", () => closeLibModal(true));- bar.append(el("span", "grow"), done);- ed.append(bar);- modal = { save: () => done.click() };+ modal = { save: () => (bar.querySelector(".lib-huball") || done).click() };openLib(ed);}diff --git a/internal/gui/assets/plugins/library/i18n.js b/internal/gui/assets/plugins/library/i18n.jsindex c5573be70..35c68f59b 100644--- a/internal/gui/assets/plugins/library/i18n.js+++ b/internal/gui/assets/plugins/library/i18n.js@@ -43,25 +43,41 @@ magpie.strings({"Other apps": "其他应用","Connect…": "连接…","Connect an app": "连接应用",- "magpie connects the agents on this computer itself. Any other app that speaks MCP connects at the address below.": "这台电脑上的 Agent 由 magpie 直接连好。其他支持 MCP 的应用,连接下面这个地址即可。",- "Agents magpie looks after": "magpie 管理的 Agent",- "Any other app": "其他任何应用",- "1 server, through magpie": "1 个服务器,经由 magpie",- "{n} servers, through magpie": "{n} 个服务器,经由 magpie",+ "{agent} no longer has the library's servers — restart it to read the change": "{agent} 不再使用资源库的服务器——重启它后生效",+ "{n} agents are connected — restart them to use magpie's tools": "已接入 {n} 个 Agent——重启它们即可使用 magpie 的工具",+ "{agent} through magpie": "{agent} 经由 magpie",+ "No HTTP": "不支持 HTTP",+ "Has its own magpie": "自带 magpie 条目",+ "Name taken": "名称已被占用",+ "{on} of {all} agents use the library's servers through magpie": "{all} 个 Agent 中有 {on} 个经由 magpie 使用资源库的服务器",+ "{agent} uses the library's servers through magpie": "{agent} 经由 magpie 使用资源库的服务器",+ "{agent} can use the library's servers through magpie": "{agent} 可以经由 magpie 使用资源库的服务器",+ "{n} more can be connected": "还有 {n} 个可以接入",+ "Each server runs once, for all of them": "每个服务器只运行一份,供所有 Agent 共用",+ "1 keeps each server's own entry": "1 个保留各自的配置",+ "{n} keep each server's own entry": "{n} 个保留各自的配置",+ "Find an agent": "搜索 Agent",+ "Keep each server's own entry": "保留各自的配置",+ "No agent called “{q}”": "没有找到「{q}」",+ "Any app that speaks MCP connects at this address": "任何支持 MCP 的应用,连接这个地址即可",+ "From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "从另一台电脑连接时,请使用那台电脑访问 magpie 的地址,并带上网关密钥:Authorization: Bearer <key>。",+ "Or add it to ~/.cursor/mcp.json": "或者添加到 ~/.cursor/mcp.json",+ "Or add it to .vscode/mcp.json, or to your user mcp.json": "或者添加到 .vscode/mcp.json,或用户级的 mcp.json",+ "Paste it into ~/.codeium/windsurf/mcp_config.json": "粘贴到 ~/.codeium/windsurf/mcp_config.json",+ "Cline, LM Studio and any app that takes MCP servers as JSON": "Cline、LM Studio 等以 JSON 配置 MCP 服务器的应用",+ "Add to an app": "添加到应用",+ "{app} asks you to confirm, then it's ready": "在 {app} 里确认后即可使用",+ "Copy entry": "拷贝配置",+ "{app}'s entry copied": "已拷贝 {app} 的配置",+ "Restart an agent for it to read the change": "重启 Agent 后生效",+ "Connect all": "全部接入","It reaches no MCP server over HTTP, so it keeps each server's own entry": "它不能通过 HTTP 连接 MCP 服务器,所以保留每个服务器各自的条目","It has a server called magpie of its own, which magpie leaves as it is": "它自己有一个名为 magpie 的服务器,magpie 不会改动它","A server in the library is called magpie: give it another name to connect": "资源库里有一个名为 magpie 的服务器:给它换个名字即可连接",- "None of the library's servers is on for it yet": "资源库里的服务器还都没有给它开启",- "On the hub": "已连接","{agent} is connected — restart it to use magpie's tools": "{agent} 已连接——重启它即可使用 magpie 的工具","{agent} couldn't be connected": "{agent} 没能连接",- "Give {agent} every server it can reach, through magpie": "经由 magpie,把它能用的服务器全部给 {agent}","Add to {app}": "添加到 {app}","{app} asks you to confirm adding magpie": "{app} 会请你确认添加 magpie",- "Or add it to ~/.cursor/mcp.json:": "或者添加到 ~/.cursor/mcp.json:",- "Or add it to .vscode/mcp.json, or to your user mcp.json:": "或者添加到 .vscode/mcp.json,或用户级的 mcp.json:",- "For any app that takes MCP servers as JSON (Windsurf, Cline, LM Studio and more):": "适用于任何以 JSON 配置 MCP 服务器的应用(Windsurf、Cline、LM Studio 等):",- "Its transport is Streamable HTTP. From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "传输方式为 Streamable HTTP。从另一台电脑连接时,请使用那台电脑访问 magpie 的地址,并带上网关密钥:Authorization: Bearer <key>。","The agents are given magpie's one MCP server — restart them to use it": "各 Agent 现在拿到的是 magpie 这一个 MCP 服务器——重启它们后生效","The agents are given each server's own entry again — restart them to use it": "各 Agent 重新拿到每个服务器各自的条目——重启它们后生效","{agents} reaches no MCP server over HTTP, so it keeps each server's own entry.": "{agents} 不能通过 HTTP 连接 MCP 服务器,所以仍保留每个服务器各自的条目。",@@ -714,25 +730,41 @@ magpie.strings({"Other apps": "其他應用程式","Connect…": "連線…","Connect an app": "連線應用程式",- "magpie connects the agents on this computer itself. Any other app that speaks MCP connects at the address below.": "這台電腦上的 Agent 由 magpie 直接連好。其他支援 MCP 的應用程式,連線下面這個位址即可。",- "Agents magpie looks after": "magpie 管理的 Agent",- "Any other app": "其他任何應用程式",- "1 server, through magpie": "1 個伺服器,經由 magpie",- "{n} servers, through magpie": "{n} 個伺服器,經由 magpie",+ "{agent} no longer has the library's servers — restart it to read the change": "{agent} 不再使用資源庫的伺服器——重新啟動後生效",+ "{n} agents are connected — restart them to use magpie's tools": "已連線 {n} 個 Agent——重新啟動即可使用 magpie 的工具",+ "{agent} through magpie": "{agent} 經由 magpie",+ "No HTTP": "不支援 HTTP",+ "Has its own magpie": "自帶 magpie 項目",+ "Name taken": "名稱已被佔用",+ "{on} of {all} agents use the library's servers through magpie": "{all} 個 Agent 中有 {on} 個經由 magpie 使用資源庫的伺服器",+ "{agent} uses the library's servers through magpie": "{agent} 經由 magpie 使用資源庫的伺服器",+ "{agent} can use the library's servers through magpie": "{agent} 可以經由 magpie 使用資源庫的伺服器",+ "{n} more can be connected": "還有 {n} 個可以連線",+ "Each server runs once, for all of them": "每個伺服器只執行一份,供所有 Agent 共用",+ "1 keeps each server's own entry": "1 個保留各自的設定",+ "{n} keep each server's own entry": "{n} 個保留各自的設定",+ "Find an agent": "搜尋 Agent",+ "Keep each server's own entry": "保留各自的設定",+ "No agent called “{q}”": "沒有找到「{q}」",+ "Any app that speaks MCP connects at this address": "任何支援 MCP 的應用程式,連線這個位址即可",+ "From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "從另一台電腦連線時,請使用那台電腦存取 magpie 的位址,並帶上閘道金鑰:Authorization: Bearer <key>。",+ "Or add it to ~/.cursor/mcp.json": "或者新增到 ~/.cursor/mcp.json",+ "Or add it to .vscode/mcp.json, or to your user mcp.json": "或者新增到 .vscode/mcp.json,或使用者層級的 mcp.json",+ "Paste it into ~/.codeium/windsurf/mcp_config.json": "貼到 ~/.codeium/windsurf/mcp_config.json",+ "Cline, LM Studio and any app that takes MCP servers as JSON": "Cline、LM Studio 等以 JSON 設定 MCP 伺服器的應用程式",+ "Add to an app": "新增到應用程式",+ "{app} asks you to confirm, then it's ready": "在 {app} 裡確認後即可使用",+ "Copy entry": "複製設定",+ "{app}'s entry copied": "已複製 {app} 的設定",+ "Restart an agent for it to read the change": "重新啟動 Agent 後生效",+ "Connect all": "全部連線","It reaches no MCP server over HTTP, so it keeps each server's own entry": "它無法透過 HTTP 連線 MCP 伺服器,所以保留每個伺服器各自的項目","It has a server called magpie of its own, which magpie leaves as it is": "它自己有一個名為 magpie 的伺服器,magpie 不會更動它","A server in the library is called magpie: give it another name to connect": "資源庫裡有一個名為 magpie 的伺服器:替它換個名稱即可連線",- "None of the library's servers is on for it yet": "資源庫裡的伺服器都還沒有為它開啟",- "On the hub": "已連線","{agent} is connected — restart it to use magpie's tools": "{agent} 已連線——重新啟動它即可使用 magpie 的工具","{agent} couldn't be connected": "{agent} 無法連線",- "Give {agent} every server it can reach, through magpie": "經由 magpie,把它能用的伺服器全部給 {agent}","Add to {app}": "新增到 {app}","{app} asks you to confirm adding magpie": "{app} 會請你確認新增 magpie",- "Or add it to ~/.cursor/mcp.json:": "或者新增到 ~/.cursor/mcp.json:",- "Or add it to .vscode/mcp.json, or to your user mcp.json:": "或者新增到 .vscode/mcp.json,或使用者層級的 mcp.json:",- "For any app that takes MCP servers as JSON (Windsurf, Cline, LM Studio and more):": "適用於任何以 JSON 設定 MCP 伺服器的應用程式(Windsurf、Cline、LM Studio 等):",- "Its transport is Streamable HTTP. From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "傳輸方式為 Streamable HTTP。從另一台電腦連線時,請使用那台電腦存取 magpie 的位址,並帶上閘道金鑰:Authorization: Bearer <key>。","The agents are given magpie's one MCP server — restart them to use it": "各 Agent 現在拿到的是 magpie 這一個 MCP 伺服器——重新啟動它們後生效","The agents are given each server's own entry again — restart them to use it": "各 Agent 重新拿到每個伺服器各自的項目——重新啟動它們後生效","{agents} reaches no MCP server over HTTP, so it keeps each server's own entry.": "{agents} 無法透過 HTTP 連線 MCP 伺服器,所以仍保留每個伺服器各自的項目。",@@ -1381,25 +1413,41 @@ magpie.strings({"Other apps": "ほかのアプリ","Connect…": "接続…","Connect an app": "アプリを接続",- "magpie connects the agents on this computer itself. Any other app that speaks MCP connects at the address below.": "このコンピュータのエージェントは magpie が接続します。MCP に対応したほかのアプリは、下のアドレスに接続してください。",- "Agents magpie looks after": "magpie が管理するエージェント",- "Any other app": "ほかのアプリ",- "1 server, through magpie": "1 個のサーバー、magpie 経由",- "{n} servers, through magpie": "{n} 個のサーバー、magpie 経由",+ "{agent} no longer has the library's servers — restart it to read the change": "{agent} はライブラリのサーバーを使わなくなりました。再起動すると反映されます",+ "{n} agents are connected — restart them to use magpie's tools": "{n} 個のエージェントを接続しました。再起動すると magpie のツールを使えます",+ "{agent} through magpie": "{agent} を magpie 経由に",+ "No HTTP": "HTTP 非対応",+ "Has its own magpie": "独自の magpie あり",+ "Name taken": "名前が使用中",+ "{on} of {all} agents use the library's servers through magpie": "{all} 個中 {on} 個のエージェントが magpie 経由でライブラリのサーバーを使用中",+ "{agent} uses the library's servers through magpie": "{agent} は magpie 経由でライブラリのサーバーを使用中",+ "{agent} can use the library's servers through magpie": "{agent} は magpie 経由でライブラリのサーバーを使えます",+ "{n} more can be connected": "あと {n} 個を接続できます",+ "Each server runs once, for all of them": "各サーバーは 1 つだけ起動し、全員で共有します",+ "1 keeps each server's own entry": "1 個は各サーバーの設定をそのまま使用",+ "{n} keep each server's own entry": "{n} 個は各サーバーの設定をそのまま使用",+ "Find an agent": "エージェントを検索",+ "Keep each server's own entry": "各サーバーの設定をそのまま使用",+ "No agent called “{q}”": "「{q}」に一致するエージェントはありません",+ "Any app that speaks MCP connects at this address": "MCP に対応したアプリは、このアドレスに接続します",+ "From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "別のコンピューターからは、そこから magpie に届くアドレスとゲートウェイキーを使います:Authorization: Bearer <key>。",+ "Or add it to ~/.cursor/mcp.json": "または ~/.cursor/mcp.json に追加",+ "Or add it to .vscode/mcp.json, or to your user mcp.json": "または .vscode/mcp.json かユーザーの mcp.json に追加",+ "Paste it into ~/.codeium/windsurf/mcp_config.json": "~/.codeium/windsurf/mcp_config.json に貼り付け",+ "Cline, LM Studio and any app that takes MCP servers as JSON": "Cline、LM Studio など、MCP サーバーを JSON で設定するアプリ",+ "Add to an app": "アプリに追加",+ "{app} asks you to confirm, then it's ready": "{app} で確認すると使えます",+ "Copy entry": "設定をコピー",+ "{app}'s entry copied": "{app} の設定をコピーしました",+ "Restart an agent for it to read the change": "エージェントを再起動すると反映されます",+ "Connect all": "すべて接続","It reaches no MCP server over HTTP, so it keeps each server's own entry": "HTTP で MCP サーバーに接続できないため、各サーバーのエントリをそのまま使います","It has a server called magpie of its own, which magpie leaves as it is": "独自の magpie という名前のサーバーがあり、magpie はそれを変更しません","A server in the library is called magpie: give it another name to connect": "ライブラリに magpie という名前のサーバーがあります。名前を変えると接続できます",- "None of the library's servers is on for it yet": "ライブラリのサーバーはまだどれもオンになっていません",- "On the hub": "接続済み","{agent} is connected — restart it to use magpie's tools": "{agent} を接続しました。再起動すると magpie のツールを使えます","{agent} couldn't be connected": "{agent} を接続できませんでした",- "Give {agent} every server it can reach, through magpie": "{agent} が使えるサーバーをすべて magpie 経由で渡す","Add to {app}": "{app} に追加","{app} asks you to confirm adding magpie": "{app} で magpie の追加を確認してください",- "Or add it to ~/.cursor/mcp.json:": "または ~/.cursor/mcp.json に追加:",- "Or add it to .vscode/mcp.json, or to your user mcp.json:": "または .vscode/mcp.json か、ユーザーの mcp.json に追加:",- "For any app that takes MCP servers as JSON (Windsurf, Cline, LM Studio and more):": "MCP サーバーを JSON で設定するアプリ向け(Windsurf、Cline、LM Studio など):",- "Its transport is Streamable HTTP. From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "トランスポートは Streamable HTTP です。別のコンピューターからは、そこから magpie に届くアドレスとゲートウェイキーを使います:Authorization: Bearer <key>。","The agents are given magpie's one MCP server — restart them to use it": "エージェントには magpie の 1 つの MCP サーバーが渡されました — 使うには再起動してください","The agents are given each server's own entry again — restart them to use it": "エージェントには各サーバーのエントリーが再び渡されました — 使うには再起動してください","{agents} reaches no MCP server over HTTP, so it keeps each server's own entry.": "{agents} は HTTP で MCP サーバーに接続できないため、各サーバーのエントリーをそのまま使います。",@@ -2050,25 +2098,41 @@ magpie.strings({"Other apps": "Andere Apps","Connect…": "Verbinden…","Connect an app": "App verbinden",- "magpie connects the agents on this computer itself. Any other app that speaks MCP connects at the address below.": "Die Agents auf diesem Computer verbindet magpie selbst. Jede andere App, die MCP spricht, verbindet sich mit der Adresse unten.",- "Agents magpie looks after": "Von magpie verwaltete Agents",- "Any other app": "Jede andere App",- "1 server, through magpie": "1 Server, über magpie",- "{n} servers, through magpie": "{n} Server, über magpie",+ "{agent} no longer has the library's servers — restart it to read the change": "{agent} hat die Server der Bibliothek nicht mehr – starte es neu, damit es die Änderung liest",+ "{n} agents are connected — restart them to use magpie's tools": "{n} Agenten sind verbunden – starte sie neu, um magpies Werkzeuge zu nutzen",+ "{agent} through magpie": "{agent} über magpie",+ "No HTTP": "Kein HTTP",+ "Has its own magpie": "Hat ein eigenes magpie",+ "Name taken": "Name vergeben",+ "{on} of {all} agents use the library's servers through magpie": "{on} von {all} Agenten nutzen die Server der Bibliothek über magpie",+ "{agent} uses the library's servers through magpie": "{agent} nutzt die Server der Bibliothek über magpie",+ "{agent} can use the library's servers through magpie": "{agent} kann die Server der Bibliothek über magpie nutzen",+ "{n} more can be connected": "{n} weitere lassen sich verbinden",+ "Each server runs once, for all of them": "Jeder Server läuft einmal, für alle",+ "1 keeps each server's own entry": "1 behält die eigenen Einträge der Server",+ "{n} keep each server's own entry": "{n} behalten die eigenen Einträge der Server",+ "Find an agent": "Agent suchen",+ "Keep each server's own entry": "Behalten die eigenen Einträge",+ "No agent called “{q}”": "Kein Agent namens „{q}“",+ "Any app that speaks MCP connects at this address": "Jede App, die MCP spricht, verbindet sich mit dieser Adresse",+ "From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "Von einem anderen Computer aus nutze die Adresse, unter der magpie dort erreichbar ist, mit einem Gateway-Schlüssel: Authorization: Bearer <key>.",+ "Or add it to ~/.cursor/mcp.json": "Oder trage es in ~/.cursor/mcp.json ein",+ "Or add it to .vscode/mcp.json, or to your user mcp.json": "Oder trage es in .vscode/mcp.json oder deine Benutzer-mcp.json ein",+ "Paste it into ~/.codeium/windsurf/mcp_config.json": "Füge es in ~/.codeium/windsurf/mcp_config.json ein",+ "Cline, LM Studio and any app that takes MCP servers as JSON": "Cline, LM Studio und jede App, die MCP-Server als JSON nimmt",+ "Add to an app": "Zu einer App hinzufügen",+ "{app} asks you to confirm, then it's ready": "{app} fragt nach, dann ist es fertig",+ "Copy entry": "Eintrag kopieren",+ "{app}'s entry copied": "Eintrag für {app} kopiert",+ "Restart an agent for it to read the change": "Starte einen Agenten neu, damit er die Änderung liest",+ "Connect all": "Alle verbinden","It reaches no MCP server over HTTP, so it keeps each server's own entry": "Erreicht keinen MCP-Server über HTTP und behält daher die Einträge der einzelnen Server","It has a server called magpie of its own, which magpie leaves as it is": "Hat einen eigenen Server namens magpie, den magpie unverändert lässt","A server in the library is called magpie: give it another name to connect": "Ein Server in der Bibliothek heißt magpie: Benenne ihn um, um zu verbinden",- "None of the library's servers is on for it yet": "Noch keiner der Server der Bibliothek ist dafür aktiv",- "On the hub": "Verbunden","{agent} is connected — restart it to use magpie's tools": "{agent} ist verbunden – starte es neu, um die Tools von magpie zu nutzen","{agent} couldn't be connected": "{agent} konnte nicht verbunden werden",- "Give {agent} every server it can reach, through magpie": "{agent} alle erreichbaren Server über magpie geben","Add to {app}": "Zu {app} hinzufügen","{app} asks you to confirm adding magpie": "{app} bittet dich, das Hinzufügen von magpie zu bestätigen",- "Or add it to ~/.cursor/mcp.json:": "Oder füge es zu ~/.cursor/mcp.json hinzu:",- "Or add it to .vscode/mcp.json, or to your user mcp.json:": "Oder füge es zu .vscode/mcp.json oder zu deiner Benutzer-mcp.json hinzu:",- "For any app that takes MCP servers as JSON (Windsurf, Cline, LM Studio and more):": "Für jede App, die MCP-Server als JSON einträgt (Windsurf, Cline, LM Studio und mehr):",- "Its transport is Streamable HTTP. From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>.": "Der Transport ist Streamable HTTP. Von einem anderen Computer aus nutze die Adresse, unter der magpie dort erreichbar ist, mit einem Gateway-Schlüssel: Authorization: Bearer <key>.","The agents are given magpie's one MCP server — restart them to use it": "Die Agents erhalten jetzt magpies einen MCP-Server — starte sie neu, um ihn zu nutzen","The agents are given each server's own entry again — restart them to use it": "Die Agents erhalten wieder den eigenen Eintrag jedes Servers — starte sie neu, um sie zu nutzen","{agents} reaches no MCP server over HTTP, so it keeps each server's own entry.": "{agents} erreicht keinen MCP-Server über HTTP und behält daher den eigenen Eintrag jedes Servers.",diff --git a/internal/gui/assets/plugins/library/library.css b/internal/gui/assets/plugins/library/library.cssindex b121340d7..253a58a26 100644--- a/internal/gui/assets/plugins/library/library.css+++ b/internal/gui/assets/plugins/library/library.css@@ -65,31 +65,71 @@ body.window .lib-head { top: -2px; margin: -2px 0 0; padding: 8px 0 4px; --bleed.lib-hubat .who { min-width: 0; }.lib-hubat .lib-hubURL { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: text; }.lib-hubat .lib-hubconnect { flex: none; }-/* Connect an app: the agents here and where each stands, then the address, a picker of apps, and what adds it */+/* Connect an app: Agents | Other apps, as System Settings draws a pane:+ one line of where things stand, then inset groups with hairlines *//* one column: the dialog's body (.ebody) is the editor's label/field grid */-.modal .editor.lib-hubsheet > .ebody { grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: 12px; }+.modal .editor.lib-hubsheet > .ebody { grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: 16px; }.lib-hubsheet .ebody > * { min-width: 0; margin-top: 0; margin-bottom: 0; }-.lib-hubsheet .lib-hublead { color: var(--fg-2); text-wrap: pretty; }-.lib-hubsheet .lib-hubsec { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }-.lib-hubsheet .lib-hubagents { max-height: min(40vh, 300px); overflow: auto; }-.lib-list .row.lib-hubagent { gap: 10px; flex-wrap: nowrap; align-items: center; }-.lib-hubagent > .ic { width: 20px; height: 20px; flex: none; }-.lib-hubagent .who { flex: 1; min-width: 0; }-.lib-hubagent .sub { white-space: normal; text-wrap: pretty; }-.lib-hubok { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--green); }-.lib-hubagent .lib-hubgo { height: 24px; padding: 0 10px; font-size: 12px; flex: none; }-.lib-hubaddr { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 8px 8px 8px 12px; border-radius: 8px; background: var(--pill); }-.lib-hubaddr code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; user-select: all; }-.lib-hubsheet .segs { justify-self: start; max-width: 100%; overflow-x: auto; scrollbar-width: none; }+.lib-hubsheet .ebody > .segs { justify-self: center; max-width: 100%; }.lib-hubsheet .segs .opt { flex: none; }-.lib-hubpane { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; min-height: 132px; }-.lib-hubpane .lib-hubadd { margin-bottom: 2px; }-.lib-hubwhere, .lib-hubdone { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--fg-2); }-.lib-hubdone { color: var(--muted); }-.lib-hubcode { position: relative; align-self: stretch; min-width: 0; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg-2, var(--pill)); }-.lib-hubcode pre { margin: 0; padding: 10px 40px 10px 12px; overflow-x: auto; font-family: var(--code-font, var(--code)); font-size: 12px; line-height: 1.55; white-space: pre; user-select: text; }-.lib-hubcode .copy { position: absolute; top: 6px; right: 6px; }-.lib-hubpane .lib-aside { margin: 0; }+.lib-hubpane { display: flex; flex-direction: column; gap: 18px; min-width: 0; min-height: 240px; }+/* agents → magpie → servers */+.lib-hubflow { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 2px; text-align: center; }+.lib-hubroute { display: flex; align-items: center; width: 100%; max-width: 320px; margin-bottom: 10px; }+.lib-hubstack { display: inline-flex; align-items: center; flex: none; }+.lib-hubstack > * { flex: none; box-shadow: 0 0 0 2px var(--card); border-radius: 7px; background: var(--card); }+.lib-hubstack > * + * { margin-left: -7px; }+.lib-hubroute .lib-hubstack > :is(.ic, .lib-glyph, .lib-logo) { width: 24px; height: 24px; }+.lib-hubmore { display: grid; place-items: center; min-width: 24px; padding: 0 5px; border-radius: 7px; background: var(--pill); color: var(--muted); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }+.lib-hubwire { flex: 1; min-width: 12px; height: 1px; margin: 0 8px; background: linear-gradient(90deg, var(--line), var(--faint), var(--line)); }+.lib-hubnode { flex: none; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--fg); background: var(--card); box-shadow: 0 0 0 0.5px var(--line), 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px -4px rgb(0 0 0 / 12%); }+.lib-hubsheet .lib-hublead { margin: 0; font-size: 13px; font-weight: 500; color: var(--fg); text-wrap: balance; font-variant-numeric: tabular-nums; }+.lib-hubsheet .lib-hubapps { align-self: center; text-align: center; font-weight: 400; color: var(--fg-2); }+.lib-hubsub { margin: 0; font-size: 12px; color: var(--muted); text-wrap: balance; }+.lib-hubsub > span { display: inline-block; }+.lib-hubsearch { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: 7px; background: var(--pill); color: var(--muted); }+.lib-hubsearch input { flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; font: inherit; font-size: 13px; color: var(--fg); outline: none; box-shadow: none; }+.lib-hubsheet .lib-hubsearch input:is(:focus, :focus-visible) { border: 0; box-shadow: none; outline: none; }+.lib-hubsearch input::-webkit-search-cancel-button { -webkit-appearance: none; }+.lib-hubsearch:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }+/* a group: a quiet heading, its count, a fold; then its inset list */+.lib-hubgrp { display: flex; flex-direction: column; gap: 6px; min-width: 0; }+.lib-hubsheet .lib-hubsec { display: flex; align-items: baseline; gap: 6px; padding: 0 12px; font-size: 11.5px; font-weight: 500; color: var(--muted); }+.lib-hubn { color: var(--faint); font-variant-numeric: tabular-nums; }+.lib-hubsec .lib-hubfold { margin-left: auto; height: auto; padding: 0; border: 0; background: none; color: var(--accent); font-size: 11.5px; }+.lib-hubsheet .lib-list .row { min-height: 40px; padding: 6px 12px; gap: 10px; flex-wrap: nowrap; }+.lib-hubsheet .lib-list .row + .row { border-top: 0; box-shadow: inset 44px 0 0 var(--card), inset 0 1px 0 var(--line-2); }+.lib-hubsheet .lib-list .row > .ic { width: 22px; height: 22px; flex: none; }+.lib-hubagent .name, .lib-hubapp .name { font-weight: 400; }+.lib-hubagent .sub { white-space: normal; text-wrap: pretty; }+.lib-hubkept .name { color: var(--muted); }+.lib-hubkept > .ic { opacity: .7; }+.lib-hubtag { flex: none; font-size: 11.5px; color: var(--muted); white-space: nowrap; }+.lib-hubinfo { flex: none; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: none; color: var(--faint); }+.lib-hubinfo:hover, .lib-hubinfo[aria-expanded="true"] { color: var(--accent); }+.lib-hubwhy { margin: 0; padding: 0 12px 10px 44px; margin-top: -4px; font-size: 12px; line-height: 1.5; color: var(--muted); text-wrap: pretty; }+button.row.lib-hubfolded { width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; }+button.row.lib-hubfolded:hover { background: var(--pill); }+.lib-hubfolded .lib-hubstack > * { width: 18px; height: 18px; border-radius: 5px; box-shadow: 0 0 0 1.5px var(--card); }+.lib-hubfolded .lib-hubstack > * + * { margin-left: -5px; }+.lib-hubfolded .name { flex: 1; min-width: 0; }+.lib-hubfolded > svg { flex: none; color: var(--faint); }+.lib-hubnone { margin: 16px 0; text-align: center; color: var(--muted); }+/* other apps */+.lib-hubaddr { display: flex; align-items: center; gap: 6px; min-width: 0; height: 36px; padding: 0 6px 0 12px; border-radius: 9px; background: var(--card); border: 1px solid var(--line); }+.lib-hubaddr code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--fg-2); user-select: all; }+.lib-hubcap { margin: -10px 12px 0; font-size: 12px; line-height: 1.5; color: var(--muted); text-wrap: pretty; }+.lib-hubapp .sub { white-space: normal; text-wrap: pretty; }+.lib-hubpill { flex: none; height: 24px; padding: 0 11px; border: 0; border-radius: 12px; background: var(--pill); color: var(--fg); font-size: 12px; font-weight: 500; white-space: nowrap; }+.lib-hubpill:hover { background: var(--pill-hover); }+.lib-hubpill.lib-hubadd { background: var(--accent-soft); color: var(--accent); }+.lib-hubpill.quiet { background: none; color: var(--muted); padding: 0 6px; }+.lib-hubpill.quiet:hover { color: var(--fg); background: var(--pill); }+.lib-hubsheet .bar .lib-hubnote { font-size: 12px; color: var(--muted); }+@media (max-width: 560px) {+ .lib-hubsheet .lib-list .row { flex-wrap: nowrap; }+ .lib-hubtag { display: none; }+}/* the glyph at the front of a row: drawn, in the text colour */.lib-glyph { flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: var(--fg-2); background: var(--pill); }diff --git a/internal/gui/tests/library-mcp-hub.test.cjs b/internal/gui/tests/library-mcp-hub.test.cjsindex 2a3bd057e..93a2ab6f8 100644--- a/internal/gui/tests/library-mcp-hub.test.cjs+++ b/internal/gui/tests/library-mcp-hub.test.cjs@@ -7,18 +7,21 @@// (Claude Desktop reaches no server over HTTP; Codex has a "magpie" of its// own). On, it counts what it serves (servers, tools, the agents given it)// and shows the one address any other app connects at, with Connect…: a-// sheet listing every agent magpie found that takes MCP servers, each with-// where it stands (connected, why it keeps each server's own entry, or a-// Connect that gives it every server, posting servers/agents-all, after-// which it says connected), then that address and, for Cursor (when it-// isn't one of the agents), VS Code and any JSON app, what adds it. Cursor-// and VS Code get an "Add to" button in the app (it posts servers/hub-open-// with the app's name, never a link) and none in a browser. No agent is-// told to the user as a command to run. The address is the public one in a-// browser and the gateway in the app. A-// click again turns it off. In every language, both engines, a wide window-// in the app and a narrow one in a browser: no sideways scroll, and the-// switch beside its text.+// sheet of two tabs. Agents: every agent magpie found that takes MCP+// servers, in groups (not connected, connected, keeping each server's own+// entry), each a switch that posts servers/agents-all, or a word for why it+// keeps its entries with the reason in full behind (i); a Connect all in+// the bar gives the rest at once. With 25 agents the connected and the+// kept fold to a row each, a search narrows them, and the sheet still fits+// the window. Other apps: the address and a row per app (Cursor when it+// isn't one of the agents, VS Code, Windsurf, any JSON app) whose Copy+// entry copies what adds it. Cursor and VS Code get an Add in the app (it+// posts servers/hub-open with the app's name, never a link) and none in a+// browser. No agent is told to the user as a command to run. The address+// is the public one in a browser and the gateway in the app. A click again+// turns it off. In every language, both engines, a wide window in the app+// and a narrow one in a browser: no sideways scroll, and the switch beside+// its text.// No backend: the API is faked here.const assert = require("node:assert/strict");const fs = require("node:fs/promises");@@ -29,6 +32,8 @@ const { strings } = require("./strings.cjs");const assets = path.resolve(__dirname, "../assets");const HOME = "/Users/mg";+// 21 more agents, for a sheet with 25: the first 17 are connected+const MANY = Array.from({ length: 21 }, (_, i) => ({ id: "agent" + (i + 1), name: "Agent " + String(i + 1).padStart(2, "0"), icon: "generic", mcp: `${HOME}/.agent${i + 1}/mcp.json` }));const fixture = (on, st = {}) => ({dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,mcpHub: on, hubPath: "/mcp/magpie/hub/",@@ -38,6 +43,7 @@ const fixture = (on, st = {}) => ({{ id: "claude-desktop", name: "Claude Desktop", icon: "claude-color", mcp: `${HOME}/Library/Application Support/Claude/claude_desktop_config.json`, noRemote: true, ...(on ? { hub: "no-remote" } : {}) },// given none of the library's servers yet: Connect gives it them...(st.cursor ? [{ id: "cursor", name: "Cursor", icon: "cursor", mcp: `${HOME}/.cursor/mcp.json`, ...(on && st.cursorOn ? { hub: "on" } : {}) }] : []),+ ...(st.many ? MANY.map((a, i) => ({ ...a, ...(on && (i < 17 || st.manyOn) ? { hub: "on" } : {}) })) : []),],instructions: { agents: [], sets: [] }, foundServers: [], projects: [], foundSkills: [], skills: [], problems: [],servers: [@@ -75,9 +81,15 @@ function server(lang, st) {return json(fixture(st.on, st));}if (url.pathname === "/api/library/servers/agents-all") {- st.all.push(req.postDataJSON());- st.cursorOn = true;- return json({ ...fixture(st.on, st), result: { changed: ["cursor"] } });+ const body = req.postDataJSON();+ st.all.push(body);+ if (body.agents.includes("cursor")) st.cursorOn = body.on;+ if (body.agents.includes("agent18")) st.manyOn = body.on;+ return json({ ...fixture(st.on, st), result: { changed: body.agents } });+ }+ if (url.pathname === "/api/copy") {+ st.copied.push(req.postDataJSON().text);+ return json({});}if (url.pathname === "/api/library/mcp/check") return json({ servers: Object.fromEntries(req.postDataJSON().names.map((n) => [n, { state: "ok", tools: 2 }])) });if (url.pathname === "/api/plugins") return json({ plugins: [] });@@ -92,11 +104,19 @@ function server(lang, st) {};}+// ARTIFACT_DIR keeps a picture of the sheet at each step+const shot = async (page, name) => {+ if (!process.env.ARTIFACT_DIR) return;+ await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });+ await page.evaluate(() => Promise.all(document.getAnimations().map((a) => a.finished.catch(() => {}))));+ await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `hub-${name}.png`) });+};+const sideways = (page) => page.evaluate(() => {const over = [];const w = document.documentElement.clientWidth;if (document.documentElement.scrollWidth > w) over.push("page " + document.documentElement.scrollWidth);- for (const e of document.querySelectorAll("#view-library .lib-hub, #view-library .lib-hub .lib-switch, #view-library .lib-hub-why, #view-library .lib-hubat, #view-library .lib-hubat .lib-hubconnect, #view-library .lib-hubat .copy, .lib-hubsheet, .lib-hubsheet .segs, .lib-hubsheet .lib-hubcode, .lib-hubsheet .lib-hubagent, .lib-hubsheet .lib-hubagent .lib-hubgo, .lib-hubsheet .lib-hubok, .lib-hubsheet .bar button")) {+ for (const e of document.querySelectorAll("#view-library .lib-hub, #view-library .lib-hub .lib-switch, #view-library .lib-hub-why, #view-library .lib-hubat, #view-library .lib-hubat .lib-hubconnect, #view-library .lib-hubat .copy, .lib-hubsheet, .lib-hubsheet .segs, .lib-hubsheet .lib-hubroute, .lib-hubsheet .lib-hubsearch, .lib-hubsheet .lib-hubagent, .lib-hubsheet .lib-hubagent .lib-switch, .lib-hubsheet .lib-hubinfo, .lib-hubsheet .lib-hubfolded, .lib-hubsheet .lib-hubaddr, .lib-hubsheet .lib-hubapp, .lib-hubsheet .lib-hubpill, .lib-hubsheet .bar button")) {const r = e.getBoundingClientRect();if (r.width && (r.right > w + 0.5 || r.left < -0.5)) over.push((e.className || e.tagName) + " " + Math.round(r.left) + "–" + Math.round(r.right));}@@ -115,7 +135,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const w = (key, vars) => tr(lang, key, vars);const web = width < 800;// Cursor is one of the agents in the app, and not in a browser- const st = { on: false, sent: [], opened: [], all: [], web, cursor: !web };+ const st = { on: false, sent: [], opened: [], all: [], copied: [], web, cursor: !web };const url = (web ? "https://mac.tail0.ts.net" : "http://127.0.0.1:3425") + "/mcp/magpie/hub";const errors = [];const ctx = await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" });@@ -174,36 +194,62 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.ok(fits, "the switch is outside its row");assert.deepEqual(await sideways(page), [], "sideways scroll, on");- // Connect…: every agent here and where it stands, then the address- // and what adds it, app by app+ // Connect…: the agents, in their groups, each with where it standsawait at.locator(".lib-hubconnect").click();const sheet = page.locator(".lib-hubsheet");await sheet.waitFor();assert.equal((await sheet.locator(".ehead b").textContent()).trim(), w("Connect an app"));- assert.equal((await sheet.locator(".lib-hublead").textContent()).trim(), w("magpie connects the agents on this computer itself. Any other app that speaks MCP connects at the address below."));- assert.deepEqual((await sheet.locator(".lib-hubsec").allTextContents()).map((x) => x.trim()), [w("Agents magpie looks after"), w("Any other app")]);+ const tabs = sheet.locator(".ebody > .segs .opt");+ assert.deepEqual((await tabs.allTextContents()).map((x) => x.trim()), [w("Agents"), w("Other apps")]);+ const lead = () => sheet.locator(".lib-hublead").textContent().then((x) => x.trim());+ // one agent that can be: named, not counted+ assert.equal(await lead(), web ? w("{agent} uses the library's servers through magpie", { agent: "Claude Code" }) : w("{on} of {all} agents use the library's servers through magpie", { on: 1, all: 2 }));+ assert.equal((await sheet.locator(".lib-hubsub").textContent()).trim().replace(/\u00a0/g, " "),+ [web ? w("Each server runs once, for all of them") : w("{n} more can be connected", { n: 1 }), w("{n} keep each server's own entry", { n: 2 })].join(" · "));+ // a few agents: no search, nothing folded+ assert.equal(await sheet.locator(".lib-hubsearch, .lib-hubfolded, .lib-hubfold").count(), 0);+ const groups = () => sheet.locator(".lib-hubgrp").evaluateAll((gs) => gs.map((g) => [g.dataset.group, [...g.querySelectorAll(".lib-hubagent")].map((r) => r.dataset.agent)]));+ assert.deepEqual(await groups(), [...(web ? [] : [["off", ["cursor"]]]), ["on", ["claude"]], ["kept", ["codex", "claude-desktop"]]]);+ assert.deepEqual((await sheet.locator(".lib-hubsec > span:first-child").allTextContents()).map((x) => x.trim()),+ [...(web ? [] : [w("Not connected")]), w("Connected"), w("Keep each server's own entry")]);const rows = sheet.locator(".lib-hubagent");const states = () => rows.evaluateAll((rs) => rs.map((r) => [r.dataset.agent, r.dataset.state]));- assert.deepEqual(await states(), [["claude", "on"], ["codex", "own"], ["claude-desktop", "no-remote"], ...(web ? [] : [["cursor", "none"]])]);- const line = (id) => sheet.locator(`.lib-hubagent[data-agent="${id}"] .sub`).textContent().then((x) => x.trim());- assert.equal(await line("claude"), w("{n} servers, through magpie", { n: 2 }));- assert.equal((await sheet.locator('.lib-hubagent[data-agent="claude"] .lib-hubok').textContent()).trim(), w("On the hub"));- assert.equal(await line("codex"), w("It has a server called magpie of its own, which magpie leaves as it is"));- assert.equal(await line("claude-desktop"), w("It reaches no MCP server over HTTP, so it keeps each server's own entry"));- // only the one with nothing yet can be connected, and nothing is a command to run- assert.equal(await sheet.locator(".lib-hubgo").count(), web ? 0 : 1);- assert.equal(await sheet.locator(".lib-hubok").count(), 1);+ assert.deepEqual(await states(), [...(web ? [] : [["cursor", "none"]]), ["claude", "on"], ["codex", "own"], ["claude-desktop", "no-remote"]]);+ const agent = (id) => sheet.locator(`.lib-hubagent[data-agent="${id}"]`);+ assert.equal(await agent("claude").locator(".lib-switch").getAttribute("aria-checked"), "true");+ // the kept: a word for why, the reason in full behind (i)+ assert.equal(await agent("codex").locator(".lib-switch").count(), 0);+ assert.equal((await agent("codex").locator(".lib-hubtag").textContent()).trim(), w("Has its own magpie"));+ assert.equal((await agent("claude-desktop").locator(".lib-hubtag").textContent()).trim(), w("No HTTP"));+ assert.equal(await sheet.locator(".lib-hubwhy").count(), 0);+ await agent("claude-desktop").locator(".lib-hubinfo").click();+ assert.equal((await sheet.locator('.lib-hubwhy[data-why="no-remote"]').textContent()).trim(), w("It reaches no MCP server over HTTP, so it keeps each server's own entry"));+ assert.equal(await agent("claude-desktop").locator(".lib-hubinfo").getAttribute("aria-expanded"), "true");+ await agent("codex").locator(".lib-hubinfo").click();+ assert.equal((await sheet.locator('.lib-hubwhy[data-why="own"]').textContent()).trim(), w("It has a server called magpie of its own, which magpie leaves as it is"));assert.doesNotMatch(await sheet.textContent(), /mcp add/);- if (!web) {- assert.equal(await line("cursor"), w("None of the library's servers is on for it yet"));- const go = sheet.locator('.lib-hubagent[data-agent="cursor"] .lib-hubgo');- assert.equal((await go.textContent()).trim(), w("Connect"));- await go.click();+ await shot(page, `${engine}-${lang}-${width}-agents`);+ const bar = sheet.locator(".bar");+ if (web) {+ // nothing to connect: Done is the one primary+ assert.equal(await bar.locator(".lib-huball").count(), 0);+ assert.equal((await bar.locator("button.primary").textContent()).trim(), w("Done"));+ } else {+ // one switch on, then off, then Connect all+ assert.equal((await bar.locator(".lib-huball").textContent()).trim(), w("Connect all"));+ await agent("cursor").locator(".lib-switch").click();await page.waitForFunction((x) => document.querySelector("#status")?.textContent === x, w("{agent} is connected — restart it to use magpie's tools", { agent: "Cursor" }));- assert.deepEqual(st.all, [{ agents: ["cursor"], on: true }]);await page.waitForFunction(() => document.querySelector('.lib-hubagent[data-agent="cursor"]')?.dataset.state === "on");- assert.equal(await line("cursor"), w("{n} servers, through magpie", { n: 2 }));- assert.equal(await sheet.locator(".lib-hubgo").count(), 0);+ assert.deepEqual(await groups(), [["on", ["claude", "cursor"]], ["kept", ["codex", "claude-desktop"]]]);+ assert.equal(await lead(), w("{on} of {all} agents use the library's servers through magpie", { on: 2, all: 2 }));+ assert.equal(await bar.locator(".lib-huball").count(), 0);+ assert.equal((await bar.locator(".lib-hubnote").textContent()).trim(), w("Restart an agent for it to read the change"));+ await agent("cursor").locator(".lib-switch").click();+ await page.waitForFunction((x) => document.querySelector("#status")?.textContent === x, w("{agent} no longer has the library's servers — restart it to read the change", { agent: "Cursor" }));+ await page.waitForFunction(() => document.querySelector('.lib-hubagent[data-agent="cursor"]')?.dataset.state === "none");+ await bar.locator(".lib-huball").click();+ await page.waitForFunction(() => document.querySelector('.lib-hubagent[data-agent="cursor"]')?.dataset.state === "on");+ assert.deepEqual(st.all, [{ agents: ["cursor"], on: true }, { agents: ["cursor"], on: false }, { agents: ["cursor"], on: true }]);// the sheet stays open over the page drawn againassert.ok(await sheet.isVisible());}@@ -215,36 +261,83 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.deepEqual(beside, [], "an agent's icon isn't beside its name");assert.deepEqual(await sideways(page), [], "sideways scroll, agents");+ // Other apps: the address, and a row per app with what adds it+ await tabs.last().click();assert.equal((await sheet.locator(".lib-hubaddr code").textContent()).trim(), url);- const opts = sheet.locator(".segs .opt");+ const apps = sheet.locator(".lib-hubapp");// Cursor is set up by hand only when magpie doesn't look after it- assert.deepEqual((await opts.allTextContents()).map((x) => x.trim()), [...(web ? ["Cursor"] : []), "VS Code", w("Other")]);- const pane = sheet.locator(".lib-hubpane");- const code = async () => JSON.parse(await pane.locator(".lib-hubcode pre").textContent());+ assert.deepEqual(await apps.evaluateAll((rs) => rs.map((r) => r.dataset.app)), [...(web ? ["cursor"] : []), "vscode", "windsurf", "json"]);+ const app = (id) => sheet.locator(`.lib-hubapp[data-app="${id}"]`);+ const copied = async (id, name) => {+ await app(id).locator(".lib-hubcopy").click();+ await page.waitForFunction((x) => document.querySelector("#status")?.textContent === x, w("{app}'s entry copied", { app: name }));+ return JSON.parse(st.copied.at(-1));+ };if (web) {- assert.equal((await pane.locator(".lib-hubwhere").textContent()).trim(), w("Or add it to ~/.cursor/mcp.json:"));- assert.deepEqual(await code(), { mcpServers: { magpie: { url } } });- assert.equal(await pane.locator(".lib-hubadd").count(), 0);- await opts.nth(1).click();- }- // VS Code: its install link in the app, its file either way- assert.equal((await pane.locator(".lib-hubwhere").textContent()).trim(), w("Or add it to .vscode/mcp.json, or to your user mcp.json:"));- assert.deepEqual(await code(), { servers: { magpie: { type: "http", url } } });- if (web) assert.equal(await pane.locator(".lib-hubadd").count(), 0);- else {- assert.equal((await pane.locator(".lib-hubadd").textContent()).trim(), w("Add to {app}", { app: "VS Code" }));- await pane.locator(".lib-hubadd").click();+ assert.equal(await sheet.locator(".lib-hubadd").count(), 0);+ assert.equal((await app("cursor").locator(".sub").textContent()).trim(), w("Or add it to ~/.cursor/mcp.json"));+ assert.deepEqual(await copied("cursor", "Cursor"), { mcpServers: { magpie: { url } } });+ assert.equal((await app("vscode").locator(".sub").textContent()).trim(), w("Or add it to .vscode/mcp.json, or to your user mcp.json"));+ } else {+ assert.equal((await app("vscode").locator(".sub").textContent()).trim(), w("{app} asks you to confirm, then it's ready", { app: "VS Code" }));+ assert.equal((await app("vscode").locator(".lib-hubadd").textContent()).trim(), w("Add"));+ await app("vscode").locator(".lib-hubadd").click();await page.waitForFunction((x) => document.querySelector("#status")?.textContent === x, w("{app} asks you to confirm adding magpie", { app: "VS Code" }));- assert.deepEqual(st.opened, [{ app: "vscode" }]);}- assert.deepEqual(await sideways(page), [], "sideways scroll, VS Code");- await opts.last().click();- assert.deepEqual(await code(), { mcpServers: { magpie: { type: "http", url } } });- assert.equal((await pane.locator(".lib-aside").textContent()).trim(), w("Its transport is Streamable HTTP. From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>."));- assert.deepEqual(await sideways(page), [], "sideways scroll, Other");assert.deepEqual(st.opened, web ? [] : [{ app: "vscode" }]);- await sheet.locator(".bar button").click();+ assert.deepEqual(await copied("vscode", "VS Code"), { servers: { magpie: { type: "http", url } } });+ assert.equal((await app("windsurf").locator(".sub").textContent()).trim(), w("Paste it into ~/.codeium/windsurf/mcp_config.json"));+ assert.deepEqual(await copied("windsurf", "Windsurf"), { mcpServers: { magpie: { serverUrl: url } } });+ assert.deepEqual(await copied("json", w("Other")), { mcpServers: { magpie: { type: "http", url } } });+ assert.equal((await sheet.locator(".lib-hubcap").textContent()).trim(), w("From another computer, use the address magpie is reached at there, with a gateway key: Authorization: Bearer <key>."));+ assert.deepEqual(await sideways(page), [], "sideways scroll, apps");+ await shot(page, `${engine}-${lang}-${width}-apps`);+ await bar.locator("button.primary").click();+ await sheet.waitFor({ state: "hidden" });++ // 25 agents: the connected and the kept fold, a search narrows+ // them, and the sheet still fits the window+ st.many = true;+ await page.reload();+ await page.locator('button[data-view="library"]').click();+ await v.locator(".lib-hubconnect").click();+ await sheet.waitFor();+ await tabs.first().click();+ const can = web ? 22 : 23, on = web ? 18 : 19;+ assert.equal(await lead(), w("{on} of {all} agents use the library's servers through magpie", { on, all: can }));+ assert.equal(await sheet.locator(".lib-hubsearch input").count(), 1);+ assert.deepEqual(await sheet.locator(".lib-hubgrp").evaluateAll((gs) => gs.map((g) => [g.dataset.group, g.querySelectorAll(".lib-hubagent").length, g.querySelectorAll(".lib-hubfolded").length])),+ [["off", 4, 0], ["on", 0, 1], ["kept", 0, 1]]);+ assert.equal((await sheet.locator('.lib-hubgrp[data-group="on"] .lib-hubfolded .name').textContent()).trim(),+ w("{first} and {n} more", { first: web ? "Claude Code, Agent 01" : "Claude Code, Cursor", n: on - 2 }));+ const inWindow = await page.evaluate(() => {+ const d = document.querySelector(".lib-hubsheet").getBoundingClientRect();+ return d.top >= 0 && d.bottom <= innerHeight;+ });+ assert.ok(inWindow, "the sheet is taller than the window");+ assert.deepEqual(await sideways(page), [], "sideways scroll, 25 agents");+ await shot(page, `${engine}-${lang}-${width}-many`);+ // unfold the connected: every one, each a switch+ await sheet.locator('.lib-hubgrp[data-group="on"] .lib-hubfold').click();+ assert.equal(await sheet.locator('.lib-hubgrp[data-group="on"] .lib-hubagent .lib-switch[aria-checked="true"]').count(), on);+ assert.equal((await sheet.locator('.lib-hubgrp[data-group="on"] .lib-hubfold').textContent()).trim(), w("Hide"));+ // search: across every group, folded or not, and none+ await sheet.locator(".lib-hubsearch input").fill("agent 2");+ assert.deepEqual(await rows.evaluateAll((rs) => rs.map((r) => r.dataset.agent)), ["agent20", "agent21"]);+ assert.equal(await sheet.locator(".lib-hubsearch input").evaluate((i) => i === document.activeElement), true);+ await shot(page, `${engine}-${lang}-${width}-search`);+ await sheet.locator(".lib-hubsearch input").fill("zzz");+ assert.equal((await sheet.locator(".lib-hubnone").textContent()).trim(), w("No agent called “{q}”", { q: "zzz" }));+ await sheet.locator(".lib-hubsearch input").fill("");+ // Connect all: the four given nothing yet, in one post+ st.all.length = 0;+ await bar.locator(".lib-huball").click();+ await page.waitForFunction((x) => document.querySelector("#status")?.textContent === x, w("{n} agents are connected — restart them to use magpie's tools", { n: 4 }));+ assert.deepEqual(st.all, [{ agents: ["agent18", "agent19", "agent20", "agent21"], on: true }]);+ assert.equal(await bar.locator(".lib-huball").count(), 0);+ await bar.locator("button.primary").click();await sheet.waitFor({ state: "hidden" });+ st.many = false;// off againawait v.locator(".lib-hub .lib-switch").click();