Commit a128f38
committed
feat(windows): claudePathForSdk helper — unblocks LLM scanners + auditor
Full Windows E2E was blocked by Agent SDK `spawn EINVAL` on every
sdk.query() call. Root cause: our findClaudePath resolves to
`C:\...\claude.cmd` on Windows, we pass that as
`pathToClaudeCodeExecutable`, and Node's child_process.spawn refuses
to run .cmd/.bat without `shell: true` since CVE-2024-27980 (Node
20.12+). The SDK does not set shell:true, so every spawn throws
before the user's auth is even checked.
Fix: new `claudePathForSdk()` helper in utils/agent-options.ts that
returns undefined on win32 (lets the SDK fall back to its own bundled
cli.js which it spawns correctly) and the concrete path on POSIX
(where the CJS bundle fileURLToPath(undefined) crash from B-006 /
D-121 still matters). All three manual queryOpts sites migrated:
- src/agents/session-auditor.ts (2 queryOpts blocks)
- src/agents/memory-extractor.ts (1 queryOpts block)
- src/utils/agent-options.ts::buildAgentQueryOptions (was inline)
Regression test test/agent-sdk-paths.test.ts updated to accept either
`claudePathForSdk` or `findClaudePath` as the auth-safe import.
Also bumped @anthropic-ai/claude-agent-sdk ^0.2.84 → ^0.2.112 in the
same pass (latest) — no behavior change from our side, but aligns
with the version installed during Windows testing.
Verified on Azure Win11 Pro 24H2 (Standard_D2s_v5, native Node
20.20.2, Claude Code 2.1.112 from npm install -g):
- axme-code setup --force real OAuth: 26 LLM decisions + 13 presets
= 39, $0.97, 211s, zero errors (was 0 LLM + 13 presets + 3x
spawn EINVAL warnings before fix)
- claude --print with Bash+Read tools: 22s, substantive answer
identical to Linux baseline
- PreToolUse + PostToolUse + SessionEnd hooks all fire
- Detached audit worker: session_end → check_result PASS →
audit_complete ($0.14), auditRan: true (was false before fix)
Linux: npm test 511/511 pass, no regression.1 parent 1bbf00c commit a128f38
6 files changed
Lines changed: 53 additions & 18 deletions
File tree
- src
- agents
- utils
- test
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
628 | | - | |
| 628 | + | |
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| |||
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
889 | | - | |
| 889 | + | |
890 | 890 | | |
891 | 891 | | |
892 | 892 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
113 | 132 | | |
114 | 133 | | |
115 | 134 | | |
| |||
176 | 195 | | |
177 | 196 | | |
178 | 197 | | |
179 | | - | |
| 198 | + | |
| 199 | + | |
180 | 200 | | |
181 | 201 | | |
182 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | | - | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
0 commit comments