4794de398ea8337d223a91e207181c56fcf4ad76
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c112d2a448 |
gateway: the Claude subscription answers when magpie runs as root (FrierenF)
Run as root (a server, a Docker container), every Claude subscription request failed with "Claude Code: exited before it answered magpie's initialize request (exit status 1): --dangerously-skip-permissions cannot be used with root/sudo privileges for security reasons". Claude Code 2.1.296's setup refuses bypassPermissions/ --dangerously-skip-permissions when process.getuid() === 0, IS_SANDBOX is not "1" and CLAUDE_CODE_BUBBLEWRAP is unset (read from the installed binary; --permission-mode bypassPermissions is refused the same way). The bridge's run has no tool of Claude Code's own that touches the machine, only magpie's MCP tools, answered by the client, and Anthropic's web search, so the bridge run as root is now given IS_SANDBOX=1 (claudeCLI.asRoot). Its args are unchanged, and a run as anyone else has its env exactly as before. A WSL distro whose default user is root is the same case: the WSL probe now prints `id -u` (wslrun.Tool.Root), and IS_SANDBOX goes into the distro (WSLENV) only then. The warm-up and /usage runs don't pass the flag and are untouched. Run: - Docker node:22-bookworm-slim as root, @anthropic-ai/claude-code@2.1.296, fake API: the bridge's exact argv refuses with the message above without IS_SANDBOX, and with IS_SANDBOX=1 answers from the fake API (permissionMode bypassPermissions). - The gateway's serveClaudeSubscription as root in that container (linux test binary, real claude, no credentials): before, 502 "Claude Code ended without an answer"; after, it gets past the check to Claude Code's own "Not logged in". - TestClaudeRunsAsRoot (a fake that refuses as root does) goes red with asRoot removed from the launch; TestClaudeAsRootEnv; TestParseProbe. - go test -tags nogui ./internal/gateway ./internal/wslrun ./internal/agent, gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows). WSL root path is unit-tested only, not tried on the Windows box. |
||
|
|
1b29cb81a2 |
agent, wslrun, sessions, gui: Settings → General has Detect agents in WSL; off, magpie asks wsl.exe nothing and shows no WSL agents or sessions (#1264)
On Windows magpie lists the running distros and probes each one for agents, their sessions and Claude Code. Etsuya233 asked for a way to turn that off. settings.NoWSLAgents (per machine, kept by KeepOwn) now gates every auto-discovery path: agent.wslAgents/wslHomes/WSLRunning, sessions' wslFiles/wslDirs (via the new sessions.WSLOff hook), and wslrun.Find, which the Claude subscription uses to run Claude Code in WSL. The toggle is shown on Windows only and is on by default. Verified: - red without the change: TestWSLDetectionOff (1 WSL agent with detection off; with only sessions reverted, a distro's session is listed), TestFindWithDetectionOff (Find returned Ubuntu after asking wsl.exe). - go test -tags nogui ./... in a sandbox HOME: every package ok except TestPluginLoginTakesTheLapseOff, which timed out at 63.7s under the full run and passes alone (-count=3) and with its package (-count=1); it doesn't reach WSL. - go vet -tags nogui on agent, wslrun, sessions, settings and gui for darwin, linux and windows. - GUI: wsl-agents-setting (en/zh/zh-TW/ja/de, 900 and 440px) 30/30; gui-ja, gui-de, gui-zh-tw, i18n-keys, keep-awake, lightweight, settings-sections, settings-groups 44/44 in Chromium and 44/44 in WebKit. - Windows box (10.0.0.132), nogui magpie.exe in a sandbox profile with a logging wsl.exe first on PATH: on, `magpie agents` listed Claude Code · WSL magpie-desktop after 3 wsl.exe calls; off, `agents`, `ls` and `sessions` made no wsl.exe call and wrote no wsl.json. Not tried: the toggle in the real Windows GUI window, and Claude Code in WSL through the Claude subscription with the setting off (unit-tested only). |
||
|
|
eeee883f11 |
agent, wslrun: an agent in a WSL distro under consomme networking is pointed at 127.0.0.1, not the distro's default route (#1230: Codex in WSL 3.0.2 consomme written with 198.18.0.2)
Consomme (WSL 2.9's name for virtioproxy) relays the distro's 127.0.0.1 to Windows' own while localhostForwarding is on (microsoft/WSL ConsommeTests::LoopbackGuestToHost); its default route is Windows' next hop, a TUN proxy's 198.18.0.2 for the reporter, never Windows. wslrun.HostLoopback names the modes where 127.0.0.1 reaches Windows (mirrored, consomme, virtioproxy); every agent magpie writes into a distro (d.base), Claude Code's stand-in, and wslrun's proxy rewrite follow it. An unknown mode, or a WSL without wslinfo whose .wslconfig says Consomme, is not taken for one. An agent an older magpie left on the route is offered 127.0.0.1 (wslMovedFrom); localhostForwarding=false under consomme gets a notice. |
||
|
|
da5f7a8115 |
wsl: background work never touches a WSL distro that has stopped since it was last seen running — it booted it again (TJHHHH on Discord: while they were repairing WSL, magpie kept starting it). Detection already listed only running distros, but the running set was kept for a minute (wslListAge), agents built while a distro ran kept its home and read its files from their Get/Sync/Check/Reached/Routed closures later, the sessions listing kept a distro's Running for 30s+ and read its \\wsl.localhost files, and wslrun.Find reused a tool it had found in a distro for a minute and ran wsl.exe -d on it. Any wsl.exe -d or \\wsl.localhost read boots a stopped distro, so a wsl --shutdown was undone within a minute, and the distro, running again, kept it going. Now wsl.exe -l --running -q (it starts nothing; UTF-16 with or without BOM, or UTF-8 under WSL_UTF8) is asked again after 3s, and a distro not in it is not touched: a WSL agent's Get gives the last values seen, Sync/Check/Reached do nothing and Routed/Joined/Beside/Added say no; sessions aren't listed or read from it (wslCold says cold); wslrun.Find (Claude subscription sign-in and usage) doesn't reuse or run a tool there; the Library gives skills to no target in it and its MCP probe says it isn't running. An explicit action still starts it: setting a WSL agent's field, a Set on a running agent, resuming a WSL session. TestWSLStoppedSinceNotOpened (agent, sessions), TestWSLStoppedSinceNoTarget (library) and TestFindStoppedSince (wslrun) fail without the change and pass; TestUp covers the -l --running parse. On the Windows box (10.0.0.132) a test binary that had seen magpie-fedora running ran Values/Check/Reached/wslDistros/wslAgents/sessions.List/wslrun.Find against it for 4 rounds while it was stopped: it stayed Stopped and wsl -l -v was unchanged; wslrun and agent WSL tests pass there. No distro was terminated for the check (magpie-desktop is in use, the stopped ones aren't ours). go test ./... (nogui), -race on the WSL tests, go vet, windows and linux (nogui) builds pass.
|
||
|
|
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. |
||
|
|
ee508d0ce9 | claude: on Windows with no Claude Code of its own, the gateway runs the one in WSL (X: kyotiger, Claude Code installed in WSL only, magpie on Windows found no claude) — claudeBinary and the sign-in's findClaudeCLI now fall back, when no claude is on Windows, to one in a running WSL distro (internal/wslrun: the default distro first, Docker Desktop's left out, a stopped one never started; found by a login shell, then an interactive one for nvm's node, then ~/.local/bin and /usr/local/bin, never Windows' own under /mnt). A run is wsl.exe -d <distro> --exec /usr/bin/env PATH=<its PATH> <claude> …, so no shell rc runs and Claude Code there uses its own sign-in and quota; what the bridge sets goes in through WSLENV, CLAUDE_CONFIG_DIR (a saved account's folder) and the sign-in's BROWSER as paths (/p), the proxy variables with a loopback proxy pointed at the Windows host under NAT networking. The MCP tools server stays magpie.exe on Windows, started from WSL by its /mnt path. Killing wsl.exe leaves the Linux process running, so each run is marked (MAGPIE_WSL_RUN) and a canceled one is ended inside the distro by that mark. The Claude provider's editor says "Runs through WSL · <distro>" under Accounts (en, zh); the page never waits on WSL for it. A claude on Windows itself is still used first. With the owner's real Claude account on the Windows test box (Claude Code 2.1.289 in WSL only, magpie in a sandbox): /v1/models listed the Claude models, a haiku request answered from WSL with the MCP server at /mnt/c/…/magpie.exe, a tool_use round trip worked, the quotas came from its headers (5h 13%, 7d 37%), "Add another Claude account" opened claude.com's OAuth page through the BROWSER hand-off with its localhost callback reachable from Windows, canceling it ended claude auth login in WSL, and the editor showed the line in en and zh. Not tried: finishing a browser sign-in (needs a person). Tests: internal/wslrun (the probe's parsing, path and WSLENV translation, the proxy rewrite, Find's distro order and cache, a run's argv). go vet (darwin, GOOS=windows), builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass (the gateway package flaked once under load and passes alone). |