Fix Windows npm-shim claude spawn + stop leaking env in spawn errors (#63) #66
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
kahliburke/Kaimon.jl!66
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/agent-spawn-error-sanitize"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #63. Two commits:
1. Resolve npm
.cmd/.ps1CLI shims (91c8ab2)On Windows,
Sys.whichresolves a bare command name only as.exe— it ignores PATHEXT. So an npm-installed CLI that ships.cmd/.ps1shims (Claude Code, gemini, …) is invisible to it and toBase.run, which ENOENTs even thoughclaude --versionworks in the user's shell.launch_argvnow falls back to aPATH×PATHEXTsearch (_which_pathext) whenSys.whichreturns nothing, so the shim is found and wrapped through its interpreter (cmd.exe /d /c/powershell -File) as before. Benefits every CLI spawn routed throughlaunch_argv, not just the agent.Verified on a real Windows instance against a
claude.cmdshim:Sys.which("claude")→nothing(the gap)_which_pathext("claude")→…\claude.cmd(the fix)launch_argv(["claude","-p","--foo"])→["cmd.exe","/d","/c","…\claude.cmd","-p","--foo"]fake-claude-cmd -p --foo(spawns, args passed through)2. Sanitize spawn failures so they never leak the environment (
dd0e45a)A failed spawn raises an
IOErrorwhose text stringifies the wholesetenv(cmd, env)— including the process environment (ANTHROPIC_API_KEY, …). That was surfaced verbatim viasprint(showerror, e)into the agent UI, so a user pastingError opening agent: …into an issue leaked their credentials.backend_startnow catches the spawn failure and re-raises a sanitizedErrorExceptionbuilt from the argv alone, with an actionable hint (Windows ENOENT → npm-shim / native-installer guidance; otherwise a PATH hint).Tests:
_which_pathextsearch,launch_argvPATHEXT fallback, and spawn-error sanitization (bothiswinbranches, asserts no secret/env in the message). 151/151 agent tests pass.