v3.2: heartbeat detection, session_id fix, crash recovery

- Fix: hook_monitor() now dynamically tracks session_id (was None at startup)
- Fix: is_claude_process_alive() checks if CC process is still running
- Fix: 120s stale detection → process dead? recover from hooks : report thinking
- Add: HEARTBEAT_INTERVAL=5s polling loop
- Add: STALE_THRESHOLD_SECONDS=120 configurable threshold
This commit is contained in:
2026-05-25 16:36:44 +08:00
parent e4920e9b3e
commit a3a15f2c4f
3 changed files with 866 additions and 1 deletions
+38 -1
View File
@@ -1,3 +1,40 @@
# hermes-cc-bridge
Hermes ↔ Claude Code SDK Bridge: hook-driven progress tracking, heartbeat detection, crash recovery
Hermes ↔ Claude Code SDK Bridge hook-driven progress tracking with crash recovery.
## Features
- **Hook-driven completion**: Stop event = done signal, no timeout guessing
- **Real-time progress**: PostToolUse events → tool breakdown, elapsed time
- **Heartbeat detection** (v3.2): 120s no tool calls → check process alive → auto-recover
- **Crash recovery**: CC process dead without Stop event → recover from hook state files
- **Session ID tracking** (v3.2): hook_monitor dynamically tracks session_id (was broken when None at startup)
## Usage
```bash
python3 cc_sdk.py "fix the bug" --cwd ~/project --max-turns 8 --timeout 180 --json
python3 cc_sdk.py --progress <session_id>
```
## Files
- `cc_sdk.py` — SDK bridge (v3.2)
- `hermes_hook.py` — Hook script for Claude Code settings.json
## Hook Setup
In `~/.claude/settings.json`:
```json
{
"hooks": {
"Stop": [{"matcher": "", "hooks": [{"type": "command", "command": "python3 /path/to/hermes_hook.py", "timeout": 10}]}],
"PostToolUse": [{"matcher": "", "hooks": [{"type": "command", "command": "python3 /path/to/hermes_hook.py", "timeout": 5}]}],
"Notification": [{"matcher": "", "hooks": [{"type": "command", "command": "python3 /path/to/hermes_hook.py", "timeout": 10}]}]
}
}
```
## License
MIT