feat(v2): migrate sidecar from raw CLI spawning to @anthropic-ai/claude-agent-sdk

Claude CLI v2.1.69 hangs silently when spawned via child_process.spawn()
with piped stdio (known bug github.com/anthropics/claude-code/issues/6775).

Replace raw CLI spawning in both sidecar runners with the SDK's query()
function, which handles subprocess management internally. SDK message
format matches CLI stream-json, so the sdk-messages.ts adapter is
unchanged.

- agent-runner.ts: use SDK query() with AbortController for stop
- agent-runner-deno.ts: use npm:@anthropic-ai/claude-agent-sdk import
- sidecar.rs: add --allow-write and --allow-net Deno permissions
- package.json: add @anthropic-ai/claude-agent-sdk ^0.2.70, build:sidecar script
This commit is contained in:
Hibryda 2026-03-06 22:57:36 +01:00
parent fdd1884015
commit 323703caba
5 changed files with 457 additions and 151 deletions

View file

@ -11,7 +11,8 @@
"tauri": "cargo tauri",
"tauri:dev": "cargo tauri dev",
"tauri:build": "cargo tauri build",
"test": "vitest run"
"test": "vitest run",
"build:sidecar": "esbuild sidecar/agent-runner.ts --bundle --platform=node --format=esm --outfile=sidecar/dist/agent-runner.mjs --external:@anthropic-ai/claude-agent-sdk"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^6.2.1",
@ -24,6 +25,7 @@
"vitest": "^4.0.18"
},
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.2.70",
"@tauri-apps/api": "^2.10.1",
"@tauri-apps/plugin-updater": "^2.10.0",
"@xterm/addon-canvas": "^0.7.0",