Files
magpie/internal/wslrun
yetone c2636b7b5b library: an MCP command given to agents in WSL is checked in their distro
loong on Discord, Windows host with agents in WSL: a stdio server whose
command is a WSL program (`node /home/loong/tools/xxx.js`), given only to
WSL agents, showed "exited (1) … Node.js v24.9.0" on the Library's MCP
page. The check started it on Windows, where his agents never do; a
sibling written as `wsl -d Ubuntu … node …` checked fine.

What changed:
- checkSides (mcp_check_wsl.go) reads each agent id's `@wsl:<distro>`.
  No WSL agent, not Windows, a Windows path for the command
  (windowsPath: magpie's own image server, `C:/x/npx.cmd`) or Settings'
  Detect agents in WSL off: this computer, as before. Otherwise each
  distro is a side, after this computer when an agent here has it too.
- In a distro the command is found as the agents' shell finds it
  (new wslrun.In: the same login-then-interactive probe Find uses, so
  nvm's node is found; cached for findAge) and started through
  wslrun.Tool.Command, the existing `wsl.exe -d D --exec /usr/bin/env
  PATH=… MAGPIE_WSL_RUN=… <path> args` path, so no new quoting. Its
  env goes over WSLENV (Tool.Env); its Cancel stops the run inside the
  distro.
- A distro that isn't running is never started for a check: Why
  "wsldown", naming it, painted as not checked (ring), like novar.
  Beside a side that was checked it is left out.
- Mixed: each side in turn, the first failure ends it. ServerHealth
  gains Checked (where it started, "" for this computer); the row says
  " · WSL Ubuntu" / " · Windows" on a failure, the tooltip "Failed in" /
  "Checked in". New strings in zh, zh-TW, ja, de.
- healthKey (Go and client.js) includes the sides, so agents moving into
  WSL is a check anew.
- docs/subsystems/library.md says all this.

Tests:
- TestCheckWSLOnlyServerInItsDistro: ok in Ubuntu with the exact wsl.exe
  argv; a stopped Arch is wsldown with no probe and no run; a command
  the distro lacks is notfound there.
- TestCheckWindowsServerHere: a Windows-only server checked here, WSL
  never asked; Windows-path commands stay here.
- TestCheckMixedServerEachSide: ok in both; WSL exit named Ubuntu's;
  Windows failure stops before WSL; stopped distro = checked here only;
  healthKey differs when agents move into WSL.
  All force wslrun.On and fake wsl.exe (Run) and the distro run
  (wslCommand runs this test binary as the fake server).
- library-mcp-health-wsl.test.cjs: chromium + webkit, en/zh/zh-TW/ja/de.

Broken by hand, each red:
- checkSides always this computer: WSLOnly and Mixed red.
- windowsPath exemption removed: WindowsServerHere red.
- mixed drops this computer: Mixed red.
- healthKey without sides: Mixed red.
- stopped distro reported as a failure: WSLOnly and Mixed red.
- client.js without the " · <place>" on a failure: the GUI test 12 of 12 red.

Run:
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- GUI: the 94 library-*/mcp-*/i18n-* files, both engines: 780 of 783;
  library-loading (webkit) and library-pick-remove (chromium zh-TW) red at
  --test-concurrency=4, load ~45, pass alone 3 of 3; filed #3300, #3299.
- Full suite at 3831de1a3 (base 1d1c5cf9c), go test -tags nogui -timeout 45m ./..., alone on the machine: every package ok, no FAIL (library 334s, gateway 515s, agent 394s).

Not tried:
- A real Windows + WSL run: the Windows box (10.0.0.132) didn't answer
  ssh. The argv is magpie's existing WSL launch path, unchanged.
- In a distro the command's cwd is what wsl.exe gives it (the Windows
  home under /mnt/c), not the Linux home an agent starts in.
- A Windows program reached from WSL by interop (npx.cmd under /mnt/c)
  given to WSL agents is skipped by the probe and can show notfound.
- A command the probe can't take as a plain name (spaces, quotes): an
  absolute path runs with the default PATH, anything else is notfound.
- A stopped distro beside an ok Windows side isn't shown on the row.
2026-10-23 01:00:44 +08:00
..