Commit 3ed48c9
committed
fix(audit): set pathToClaudeCodeExecutable on all direct SDK call sites
Audit worker in the bundled CJS build crashed on every session close with
`TypeError: fileURLToPath(undefined)`. The Claude Agent SDK resolves its
own executable via `import.meta.url`, which is undefined in bundled CJS,
so every direct `sdk.query()` must pass `pathToClaudeCodeExecutable`
explicitly (D-121).
D-121 was applied to the shared `buildAgentQueryOptions()` helper, but
session-auditor and memory-extractor built their options objects by hand
and bypassed the helper. Result: main MCP server worked, but every
detached audit worker failed silently (14 consecutive audit_complete=
failed in telemetry, 2026-04-13). Auto-learning effectively dead on
v0.2.7.
Changes:
- Export `findClaudePath()` from src/utils/agent-options.ts so ad-hoc
queryOpts can set pathToClaudeCodeExecutable without going through
the full builder (different roles want different tool allowlists).
- Set `pathToClaudeCodeExecutable: claudePath` on the three direct
SDK call sites: runSingleAuditCall, formatAuditResult,
runMemoryExtraction.
- Add regression test (test/agent-sdk-paths.test.ts) that walks
src/agents/**.ts and fails if any file calling `sdk.query(` does
not import `buildAgentQueryOptions` or `findClaudePath`. Static —
no SDK, no claude binary, no network.
Verified:
- 478/478 unit tests pass
- `tsc --noEmit` clean
- `npm run build` clean
- `grep pathToClaudeCodeExecutable dist/cli.mjs` = 3 hits
(helper + both session-auditor call sites; memory-extractor is
currently tree-shaken but fixed for future reuse).
Fixes B-006.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> #!axme pr=none repo=AxmeAI/axme-code1 parent e05de98 commit 3ed48c9
4 files changed
Lines changed: 98 additions & 2 deletions
File tree
- src
- agents
- utils
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
624 | 625 | | |
625 | 626 | | |
626 | 627 | | |
| 628 | + | |
627 | 629 | | |
628 | 630 | | |
629 | 631 | | |
630 | 632 | | |
631 | 633 | | |
632 | 634 | | |
| 635 | + | |
633 | 636 | | |
634 | 637 | | |
635 | 638 | | |
| |||
883 | 886 | | |
884 | 887 | | |
885 | 888 | | |
| 889 | + | |
886 | 890 | | |
887 | 891 | | |
888 | 892 | | |
889 | 893 | | |
890 | 894 | | |
891 | 895 | | |
| 896 | + | |
892 | 897 | | |
893 | 898 | | |
894 | 899 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | | - | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
0 commit comments