fix(supervisor): restore session spawn via in-process claude-runner + bridge#96
Merged
Merged
Conversation
… bridge Phase 09 (PR #86) gutted ProcessManager.spawn() and returned every session.start with `legacy_agent_spawn_disabled`. Result: clicking Launch on a repo in Settings → Supervisor / Sidebar did nothing — the supervisor received `session.start` from the hub and immediately finalized the run as stopped. Reproduced in supervisor.log at 2026-05-27 23:51:54. Root cause: PR #86 killed the legacy external CLI agent spawn path (autonomous-loop bug in cached v0.4.1) without an in-process replacement. Fix: re-wire spawn() to construct a `SessionBridge` per run. Each bridge: - opens its own /ws/agent connection with project_dir = repoPath and role = 'agent' (mirroring what the retired external agent did); - spawns `claude --input-format stream-json --output-format stream-json --verbose` directly via a new `ClaudeRunner`; - parses Claude's stream-json events and translates them onto the hub's agent-protocol (thinking / text_delta / tool_use / tool_result / status / assistant_message / permission_request / user_question); - routes hub-originated user_message / permission_response / question_response / cancel / shutdown back into the runner. Preserved from PR #86: - sandbox-escape, not-git-repo, concurrency, dangerous-skip-permissions gates + audit-log entry per decision; - CIRCUIT_THRESHOLD (5 crashes / 10 min) and MAX_RESTART_COUNT (10) caps so a broken spawn can no longer loop forever. Phase 09 canary `no-legacy-agent-spawn.test.ts` still passes — the new runner never references the retired npm package name or forbidden flags. ProcessManager unit tests rewritten to use `bridgeFactory` instead of the old `spawnImpl` (Bun.spawn) hook. Supervisor bumped 0.5.2 → 0.5.3 in all four source-of-truth locations (supervisor/src/index.ts, supervisor/src/hub-client.ts, supervisor/tauri/src-tauri/{Cargo.toml,tauri.conf.json}, supervisor/tauri/ui/package.json) so the next MSI advertises the fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Phase 09 (PR #86) gutted `ProcessManager.spawn()` and finalized every `session.start` with reason `legacy_agent_spawn_disabled`, so clicking Launch on a repo in Settings → Supervisor / Sidebar did nothing. The retired external CLI agent had the autonomous-loop bug, so PR #86 removed it — but no in-process replacement was wired up.
Reproduced live in `supervisor.log` at 2026-05-27 23:51:54Z:
```
[security] legacy_agent_spawn_disabled: ... session.start cannot proceed until the
in-process claude-runner lands. Run will be finalized as stopped.
```
Fix
Re-wire `spawn()` to construct a per-run `SessionBridge`. Each bridge:
Preserved from PR #86:
Tests
Version bump
Supervisor: `0.5.2 → 0.5.3` in all four sources of truth, in lockstep:
The next MSI release (`supervisor-v0.5.3` tag, built by `.github/workflows/release-supervisor.yml`) will carry the fix.
Test plan
🤖 Generated with Claude Code