feat(03-02): integrate hook server into daemon with graceful degradation and dynamic poll

- Add hookPort, httpServer, lastHookTime, mu to Daemon struct
- startHookServer binds HTTP on hookPort, degrades if port busy
- Stop() closes httpServer before unix listener
- pollLoop uses time.After(currentPollInterval()) instead of fixed ticker
- currentPollInterval returns 20s when hooks active (<60s), 5s otherwise
- processHookEvent records lastHookTime on each hook event

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-03-23 19:45:48 +01:00
parent 5f13eb174b
commit 79ad8fb16a
2 changed files with 64 additions and 5 deletions

View File

@@ -71,6 +71,10 @@ func (d *Daemon) processHookEvent(event HookEvent) {
}
d.registry.UpdateFromHook(event.SessionID, state, waitType, event.Cwd)
d.mu.Lock()
d.lastHookTime = time.Now()
d.mu.Unlock()
}
// UpdateFromHook updates a session from a hook event.