A Claude Code found in a WSL distro (Windows has none of its own) was always claude -p, the entrypoint the plan counts at about twice the interactive mode's. Many Windows users run it there. The Windows helper now runs wsl.exe in its pseudo console. The gateway hands it MAGPIE_CLAUDE_TUI_WSL (claudetui.WSL, claudeCLI.tuiWSL): the wsl.exe arguments up to Claude Code's (wslrun.Tool.Args, with MAGPIE_WSL_RUN), the distro's mount, and the projects folder as Windows reads it. That is the account's config directory, handed in through CLAUDE_CONFIG_DIR/p, or the distro user's own ~/.claude/projects through \\wsl$\<distro> (wslrun.Tool.Home, a new line in the probe; wslrun.Tool.Windows). TERM is added to WSLENV, and an image's path is pasted as the distro reads it (/mnt/c/…). The helper is the Windows magpie.exe, not the /mnt/c/… path the MCP helper starts at; the first real run failed on exactly that (fork/exec /mnt/c/...magpie.exe). The gate keeps -p for a WSL Claude Code whose home is unknown, and, in the distro user's own folder, when Windows can't stat \\wsl$\<distro>\<home> (tuiWSLUnread): over ssh it can't (no 9P redirector), and the helper would wait for a transcript it can't see. Doc updated. Run: - go test ./internal/claudetui ./internal/wslrun on mote and on Windows 11 (xiaomi-gpu): ok. New: TestShimInWSL (image path, WSLENV), TestClaudeTUIWSL (projects folder both ways, wsl args), the home in the probe and Windows() in wslrun, the gate's two WSL cases, TestClaudeTUIWSLUnread. - go test -run 'Claude|Refusal|Thinking' ./internal/gateway on mote: ok. - go vet of claudetui, gateway, wslrun for darwin, linux, windows (-tags nogui, and the main package for windows); gofmt -l clean. - Real account on xiaomi-gpu: a sandbox HOME gateway (3462) with no Windows Claude Code reachable (PATH trimmed, MAGPIE_TEST_SANDBOX so the registry PATH isn't read), the Claude Max account, Claude Code 2.1.289 in magpie-desktop, haiku-5-5. Tree: helper -> wsl.exe -> claude on a pts in the distro, TERM=xterm-256color, CLAUDE_CONFIG_DIR=/mnt/c/..., no CLAUDE_CODE_ENTRYPOINT. One tool call, two in one message, text then a call, and two image turns: all right. Every transcript row "entrypoint":"cli", no "-p" line in the log, images noted as /mnt/c/.../magpie-claude-images-*/image-N.png and no folder left. Killing the gateway ended its four claude processes in the distro within 3s. The token wasn't refreshed; the copied credentials were deleted. Broken by hand: shim.path returning the Windows path unchanged, TestShimInWSL red; tuiWSLUnread ignoring the stat error, TestClaudeTUIWSLUnread red. Not tried: a WSL Claude Code run from the distro user's own ~/.claude for real (only the account config directory ran; over ssh \\wsl$\magpie-desktop is unreadable, so that run would be -p, and a desktop session's \\wsl$ wasn't tried), a distro whose default user is root, a distro not sharing Windows' loopback (wslrun.Tool.Host set), WSL1.
27 lines
1.1 KiB
Go
27 lines
1.1 KiB
Go
package claudetui
|
|
|
|
// Command is the hidden subcommand that runs it.
|
|
const Command = "claude-tui-helper"
|
|
|
|
// TrustEnv, "1", has the shim tell Claude Code yes when it asks whether
|
|
// to trust the folder it runs in: the bridge sets it for magpie's own
|
|
// folder, and for a caller's in an account folder of magpie's, whose
|
|
// Claude Code no one else runs. Otherwise the question is the user's to
|
|
// answer in their own Claude Code, and the run is -p.
|
|
const TrustEnv = "MAGPIE_CLAUDE_TUI_TRUST"
|
|
|
|
// WSLEnv holds, as JSON (WSL), how to run a Claude Code that is in a WSL
|
|
// distro: the helper, on Windows, runs wsl.exe in its pseudo console.
|
|
const WSLEnv = "MAGPIE_CLAUDE_TUI_WSL"
|
|
|
|
// WSL is a Claude Code in a WSL distro, as the helper runs it.
|
|
type WSL struct {
|
|
// Args are wsl.exe's arguments up to Claude Code's own, its path last
|
|
Args []string `json:"args"`
|
|
// Mount is where the distro mounts Windows' drives ("/mnt/"): an
|
|
// image's path is pasted as Claude Code there reads it
|
|
Mount string `json:"mount"`
|
|
// Projects is Claude Code's projects folder, as Windows reads it
|
|
Projects string `json:"projects"`
|
|
}
|