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.
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
package library
|
|
|
|
// A command that an agent in WSL starts runs in its distro: `node
|
|
// /home/me/tools/x.js` is a Linux program there, which on Windows is
|
|
// another node or none at all (loong on Discord: a server his agents in
|
|
// WSL start fine was checked on Windows, where it "exited (1)"). So the
|
|
// check starts a command where the agents given it start it: on this
|
|
// machine for its own agents, and through wsl.exe (wslrun, as magpie runs
|
|
// a distro's Claude Code) in each distro whose agents have it.
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"slices"
|
|
"strings"
|
|
|
|
"github.com/yetone/magpie/internal/settings"
|
|
"github.com/yetone/magpie/internal/wslrun"
|
|
)
|
|
|
|
// wslCommand starts a check's command in t's distro; a var for tests.
|
|
var wslCommand = func(ctx context.Context, t wslrun.Tool, args ...string) *exec.Cmd {
|
|
return t.Command(ctx, args...)
|
|
}
|
|
|
|
// checkSides are where s's command is checked: "" for this machine, a
|
|
// distro's name for its agents there, this machine first. Everything is
|
|
// checked here for a server no agent has, with no WSL to start one in or
|
|
// Settings' Detect agents in WSL off, and for a Windows program (magpie's
|
|
// own image server, the one an agent in WSL is given, which runs on
|
|
// Windows whoever starts it). Nothing here asks WSL anything.
|
|
func checkSides(s *Server) []string {
|
|
here := false
|
|
var distros []string
|
|
for _, id := range s.Agents {
|
|
_, d, ok := strings.Cut(id, "@wsl:")
|
|
if !ok || d == "" {
|
|
here = true
|
|
} else if !slices.Contains(distros, d) {
|
|
distros = append(distros, d)
|
|
}
|
|
}
|
|
if len(distros) == 0 || !wslrun.On || windowsPath.MatchString(s.Command) || settings.Shared().NoWSLAgents {
|
|
return []string{""}
|
|
}
|
|
slices.Sort(distros)
|
|
if here {
|
|
return append([]string{""}, distros...)
|
|
}
|
|
return distros
|
|
}
|