Repository navigation
fix(wsl-host): refuse Windows-only agent CLIs in terminal launches - #34674
Conversation
On a WSL host (orcad inside WSL with ORCA_WSL_ORCAD_HOST), interactive terminal agent launches now check if the agent is Windows-only before typing the command. If only a Windows copy exists, show the same error message as other spawn paths: "installed only on Windows, not in this WSL distro." This ensures terminal launches have feature parity with chat and background agent spawns added in PR #34590. When an agent is found as an absolute path in the WSL distro, terminal launches prefer that resolved path over the bare command name, improving consistency across launch paths. Desktop, native Linux, macOS, and SSH terminal launches are unchanged — WSL host path resolution only applies when isWslHostOrcadProcess() returns true. Test coverage: 9 tests verify desktop/Linux/macOS/SSH launches remain unchanged, and WSL host resolution behavior (Windows-only detection, absolute path preference, bare command fallback).
…thout touching the terminal env
d0bf7d2 to
b020315
Compare
|
STATUS: safety-review fixes done, rebased on origin/main 478743d. Head b020315. One resolver (resolveGuestNativeAgentCommand fed the raw PATH, plus the WINDOWS_ONLY_AGENT_CLI_DIR marker), so the refusal now fires. It skips explicit Command settings, remote launches and non-WSL hosts, and never writes settings. The terminal env is untouched. The old mocked test is replaced by unmocked tests in wsl-host-agent-terminal-launch.test.ts. Checks: pnpm tc, typecheck:ci, 5 runtime test files (34 tests passing), check:code-quality:changed, anti-slop oxlint, ast-grep scan and gates. Open question: the lookup uses the service PATH, not .bashrc (same as chat; standard install dirs are covered). Not merged. |
|
STATUS: reviewer B's points are in. Head bed0106. (1) Every program name the agent has is now tried in order, and the first one installed in the distro wins. A launch is refused only when no name is installed in the distro and at least one is installed only on Windows. A new test covers Qoder (qodercli only on Windows, qoder in the distro). (2) The PR body now names the launch paths this PR doesn't cover. Checks: pnpm tc, typecheck:ci, 35 runtime tests, check:code-quality:changed, anti-slop oxlint, ast-grep scan and gates. Reviewer A's verdict is still pending. Not merged. |
|
STATUS: reviewer A's extra is in. Head cbeb168. A launch is now refused when a CLI that the agent's command runs is installed only on Windows (Agent Teams needs Claude, dsh needs dsh). The Agent Teams command is never rewritten, including when the headless launch types plain |
ELI5
When Orca runs inside a WSL Linux distro, an agent like Claude or Codex might be installed only on the Windows side. Chat already refuses to start it there. Starting the same agent in a terminal now refuses the same way, instead of quietly running the Windows copy.
What Changed
Before: on a WSL host (Orca's background service running inside the distro,
ORCA_WSL_ORCAD_HOST=1), starting an agent in a terminal typed the bare name (claude). If the only copy was the Windows one, the shell found it through the Windows folders WSL adds to PATH (/mnt/c/...) and ran the Windows program against Linux paths.After:
kiro-cli chat --tui) are kept.qodercliandqoder) use the first name installed inside the distro. A launch is refused only when no name is installed in the distro and at least one is installed only on Windows.dsh). The Agent Teams command itself is never rewritten.code .,explorer.exeand other interop still work inside the agent's terminal.Mechanism: one function,
resolveWslHostAgentLaunchInputs(src/main/runtime/wsl-host-agent-terminal-launch.ts), runs on the launch inputs before the startup plan is built. It uses the resolver chat and status already use (resolveGuestNativeAgentCommandwith the Windows-only marker). It returns the inputs unchanged, as the same object, when any of these hold:The resolved path is applied only to this launch's inputs. Settings are never written.
Why
This is the same rule as chat (#34590), and it reuses chat's resolver and marker instead of adding a second copy. The alternative, stripping Windows folders from the whole terminal's PATH, would break interop commands users rely on inside the agent's terminal. Typing the absolute path pins only the agent program.
Known limitation (shared with chat): the lookup uses the PATH of Orca's background service, not the interactive shell's
.bashrc. A distro install that only.bashrcadds to PATH is still found when it is in a standard location (nvm,~/.local/bin, volta, asdf, mise, bun, pnpm). Tests cover nvm and~/.local/bin. An install in a custom directory added only by.bashrcwould be refused. The message tells the user to set the agent's Command setting in that case.Launch paths not covered here (follow-ups): this PR covers agent terminals created through the runtime's terminal startup. These paths build launch commands separately and still type the bare name on a WSL host: mobile terminal startup (
src/main/runtime/terminal/launch/mobile-terminal-startup.ts), the agent session execution path (src/main/runtime/session-construction/agent-session/get-agent-session-execution-namespace.ts), and the resume launch builders (src/shared/tui-agent-resume-startup.ts,src/shared/ai-vault-resume-startup.ts).Flag-off: with
ORCA_WSL_ORCAD_HOSTunset (and so withORCA_INTERNAL_WSL_HOSTSunset), the function returns its input unchanged. Desktop, native Linux, macOS, Windows and SSH terminal launches are unchanged.User-risk: low. This affects only agent terminals started by a WSL-host Orca. The worst case is the limitation above: a refusal for an agent installed only in a custom
.bashrcdirectory, fixed by setting the Command setting.Linked Issue
Follow-up to #34590.
Visual Proof
N/A. This changes which program a terminal launch types, or adds a refusal message, on WSL hosts only. Covered by unit tests and a call-site test.
Testing
src/main/runtime/wsl-host-agent-terminal-launch.test.ts(real files, no mocks; a temp directory stands in for the Windows drive mount via the resolver'smountsparameter):dsh→ refusedqoderclionly on Windows,qoderin the distro → launches the distroqoder~/.local/bininstalls missing from the service PATH → still foundChecks run:
pnpm tc,pnpm run typecheck:ci, touched and adjacent runtime tests (38 passing),pnpm run check:code-quality:changed, anti-slop oxlint, ast-grep scan and flaky-test gates. No WSL distro was booted.Review
Agent skill upstream boundary
Notes
SSH: remote launches are skipped explicitly. Folder workspaces: the logic does not depend on git. Wire compatibility: nothing new is exchanged between client and host.
Status
Reworked after safety review. Ready for lead review; not merged.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)