ac4af582301a4e8a29245dbba767eba31334ddf9
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8c93923638 |
library: no package's tests install an npx server's package or end the machine's servers (#4140)
TestLibraryMCPHub (internal/cli) adds `npx -y fs` to Claude Code, turns the MCP router on and off and keeps fs direct. Each sync gave the agent the package run by node from magpie's own install (mcp_npx.go), so it started `npm install fs` in the background under the test's temp HOME, and each change that took fs out of every agent ended the machine's processes running `npx -y fs` (mcp_reap.go). Only internal/library's TestMain turned the two off (npxInstall = nil, ending a no-op); every other package that syncs the library ran them for real. So npm was still writing .config/magpie/mcp-npm/<hash>/node_modules when TempDir cleaned up (#4140, macOS: "directory not empty"; Windows: "being used by another process"), and the user's own running fs server was ended by a test. coffemon (Discord) pointed out the second. Now the library turns both off itself in any test binary (testing.Testing(), in init), as internal/provider and internal/agent do for their own reach out of a test; internal/library's TestMain no longer sets them, and the tests about either still set their own. What was run (mote, macOS, go1.26.8): - TestTestsLeaveTheMachineAlone, new (internal/library): ok; with mcp_npx.go as on |
||
|
|
de74cb53f7 |
mcp router: each caller gets its own Magpie Browser session
The router keeps one backend per Library server for every agent, so all agents behind it shared one `magpie mcp browser`, one browser session and so one tab (packinggoodsllc_07668 on Discord: two agents through a remote router fought over one tab). - serveMCP gives a client that initializes an Mcp-Session-Id (nothing is kept or checked by it). - hubSession names each tools/call's caller: _meta magpie/session from a router in front, else hub-<agent>-<Mcp-Session-Id>. - The router passes it in _meta magpie/session to `magpie mcp browser` and to another magpie's router only (keepsSession); the bridge sends it as that call's X-Magpie-Browser-Session (callerSession). A call naming none goes as the bridge's own session, as before. Run (mote-run): go test ./internal/browsermcp; ./internal/gateway -run 'MCP|Hub'; ./internal/library -run 'TestHubTellsMagpieBrowser|TestKeepsSession|TestHubGivesMagpieImage'. ok. Broken by hand, each red: no meta from the library (library test), no Mcp-Session-Id from serveMCP and ignoring _meta in hubSession (gateway test). Not tried: a real remote router chain between two machines. |
||
|
|
b78b1de003 |
library: magpie-image is behind the MCP hub, saving into the calling agent's project
magpie-image was the one MCP server the hub left out, because it saves what it makes on disk and needs to know whose project that is. The hub now serves its tools like any other server's and tells it where the caller works: 1. the hub answers a tools/call as SSE and asks the agent roots/list on that stream (3s), as Claude Code answers; 2. else Codex's _meta x-codex-turn-metadata.workspaces (git repos only); 3. else the Codex thread's cwd from its session file (sessions.CodexThreadCwd), only with session consent; 4. else none, and the image goes to ~/Pictures/Magpie as before. The hub passes `magpie/roots` and `magpie/client` in the call's _meta; imagemcp saves into the first root and names the agent on its usage row. Its result carries `magpie/model`, which the hub's own usage row takes, so the row says which image model drew it. A WSL agent keeps magpie-image as its own entry (the hub can't reach a path inside the distro). docs/subsystems/mcp-hub.md (mcp-router.md after the next commit), gateway-routing.md and gateway-sessions.md say so. It is rebased on #4382 ( |
||
|
|
62045475b4 |
library: Codex on magpie reaches a command's MCP server through the gateway, run only while a thread uses it (#3885)
Codex starts every stdio server in its config once for each thread it has loaded and keeps them as long as the thread: YPYT1 counted 204 node processes, 21 GB, beside one Codex. While Codex is on magpie (Wired, not disconnected, this machine's gateway key, not WSL) the library now gives it a server run by a command as url = <gateway>/mcp/run/<name>, which magpie serves over streamable HTTP and runs the command for itself (internal/library/mcp_run.go): - a session (Mcp-Session-Id) starts its own child only when it sends something past initialize, the first page of tools/prompts/resources lists and ping; those are answered from what the first child said for the same command, args and env, and a list_changed from a child drops that list; - a (re)started child gets the session's own initialize replayed, so a server that keeps state per client still keeps it per thread; - a child idle for 15 minutes is stopped (a later call starts it again), DELETE stops it, and a server changed or removed from the library has its children stopped at the next sync; - server-initiated requests and notifications go to the session's newest open stream (GET, or a POST answered as SSE). The gateway route lets only this machine in: no Origin, a loopback Host, no forwarded or LAN address (TestRunMCPThisComputerOnly). A server with an env var magpie hasn't, a remote one, and Codex off magpie, in WSL or on another machine's key keep the command as before. agent.Rewired re-syncs the library when Codex is connected or disconnected, so it is handed the commands back when it leaves magpie. Tests (internal/library/mcp_run_test.go, a fake server): starts on a call and not on initialize/lists, idle end and DELETE, a server's own request round-trips, list_changed, a changed/removed spec, an unknown session, and the Codex entry in a sandbox (url when wired, the command back when not, a keyed env var kept as a command). Each was red with its part broken by hand: the init cache removed, the sweep off, runsFor forced false, forget a no-op, the Origin/Host guard dropped. Real runs: - mote, sandbox HOME, real codex 0.162.1 + @modelcontextprotocol/ server-memory: config.toml gets url = "http://127.0.0.1:3581/mcp/run/ mem"; codex app-server's mcpServerStatus/list lists its 9 tools through the bridge. - this Mac, sandbox HOME with only the DeepSeek provider copied, codex 0.162.1 on deepseek/deepseek-flash: a real turn called mem create_entities and read_graph through the bridge and answered with the stored observation. Three codex exec turns at once that used no tool started 0 memory-server node processes (before: one each). - Windows 11 (xiaomi-gpu), sandbox profile, codex 0.161.0: url entry written, app-server lists the 9 tools, 0 memory-server node.exe left after Codex closed. Run at the pushed head (mote): GOOS=linux/windows/darwin go vet -tags nogui ./internal/library/ ./internal/gateway/ ./internal/agent/: ok. go test -count=1 -timeout 45m ./internal/library/ ./internal/gateway/ ./internal/agent/ ./internal/gui/: library ok (167s), gateway ok (596s), agent ok (279s); gui FAIL only TestMainWindowCorners/macOS_26_SDK ("a toolbar doesn't change the corners ... yet the main window's was taken off"), #3949, red on mote's macOS 27 on main too; no gui or AppKit file is touched here. Windows (win-run): go test -run 'TestRun|TestFakeRunServer|TestMCPProxy' ./internal/library/ ./internal/gateway/: ok. Not tried: the Codex desktop app (the same config.toml), a server that asks the client for sampling or elicitation in a real agent. Codex picks up the new entries when it restarts. Reported-by: YPYT1 |
||
|
|
425a613224 |
library: a server run with npx -y reaches the agent as node running the package (#3885)
npx stays running as the server's parent for the server's whole life. On Windows that is cmd.exe + npx's node + a second cmd.exe beside the server: measured on xiaomi-gpu with @modelcontextprotocol/server-memory, 4 processes and 143 MB (cmd 8.1, npx node 76.2, cmd 8.2, server 50.8) for one instance. Codex starts an instance a thread; #3885 had 223 node processes under codex.exe. A library server `npx -y <registry package> args` (no other npx flag) is now installed with npm into ~/.config/magpie/mcp-npm/<hash> in the background, and the next sync writes it into each agent on this machine as `node <package bin> args`: node by name for npx by name, or the node beside an npx given by path. Until the install is done, or when npm fails (tried again after an hour), the agent keeps npx. An unpinned spec is installed again after a day, as npx would fetch the newer one; an install no library server runs any more is removed a day after its last. The library's own entry, a server's check, Copy config… and WSL agents keep npx. Taking a server off ends node's run of the program (launchedBy reads the node line), as before for npx. Run at this head (rebased on origin/main 1ff54f079; nothing it brought touches internal/library): - mote: go test -count=1 -timeout 45m ./internal/library ok (116s); GOOS=linux/windows/darwin go vet -tags nogui ./internal/library ok; ./internal/proc/... ./internal/testenv/... and the root package ok; TestNpx*/TestReadNpx under -race ok. - xiaomi-gpu (win-run): TestNpx*/TestReadNpx ok. - Real, on xiaomi-gpu, Node 22 + real npm registry, sandbox HOME: the library synced server-memory into a Codex config.toml; the install took 12.8s and the second sync wrote command = "node", args = [the install's …\server-memory\dist\index.js]. Started from that entry, the server answered initialize and tools/list, and its process tree was 1 process at 56.2 MB, against 4 processes and 143 MB through npx. - Broken by hand: without the npxDirect call in syncMCP, TestNpxServerRunsByNode is red ("the package was never installed"). Not tried: a real Codex or Claude Code session starting the node entry (the entry has the same command/args shape they already start), and macOS's process tree (npx's node and sh there too). Not done (#3885 stays open): Codex starting the same MCP once a thread. |
||
|
|
c89284ae66 |
library: a server turned off everywhere has its running processes ended (#3885)
Turning MCP servers off in the Library rewrote the agents' configs, but Codex, the Codex app and Claude Code read them only at start, so the servers they had started kept running. With every server turned off, the reporter's machine still held 17.75 GB of node processes for them. A change, and the sync at start, now record each stdio server it took out of an agent's config as that config had it. Once no agent's config runs that command and those arguments (another agent's entry, or the user's own under another name, keeps it), proc.EndTrees ends every process whose command line runs it, with all it started: the cmd /d /s /c "npx -y x" wrapper, the node npx-cli.js under it and the server under that. magpie and what it runs under are never picked, and a process under one picked goes with that one. An interpreter with nothing after it (node, npx) is never matched. It runs after the change lets go of the Library lock and before it returns, so magpie library mcp ends them too before it exits. On Windows the processes come from a Toolhelp snapshot with their command lines (no PowerShell); elsewhere from ps -o pid=,ppid=,args=. Run at base |
||
|
|
01c41e8ba2 |
library: a skill probe's download goes when it is probed again or 15 minutes are up, and one a magpie that quit left behind goes at the next probe (#2321)
ProbeSkills kept each GitHub probe's download, a magpie-skill-* folder in
the temp dir, cached for 15 minutes. An expired one went only at the
*next* probe, so a magpie that quit, or a test that ended, left it there
for good. One go test ./internal/library left 22. This machine's temp dir
had 5477, and with old test homes they filled the disk under a full run
(gateway tests failed "no space left on device").
- keepProbe: each cached probe has a timer that removes its folder when
probeLife is up. A probe of the same input replaces it and removes the
old folder at once, outside the lock.
- sweepStaleDownloads, at each probe: a magpie-skill-* in the temp dir over
an hour old goes. No live one is that old, since a probe is kept 15
minutes and a fetch takes seconds.
- internal/library's TestMain gives the tests a temp dir of their own
(TMPDIR, and TMP/TEMP for Windows), ends the cached probes, and fails a
run that leaves a skill download there. A test binary started again by a
test keeps its parent's temp dir.
Run (on origin/main
|
||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |