Skip to content

Add daemon WebSocket event hub#744

Open
backnotprop wants to merge 8 commits into
feat/runtime-frontend-shellfrom
feat/websocket-event-hub
Open

Add daemon WebSocket event hub#744
backnotprop wants to merge 8 commits into
feat/runtime-frontend-shellfrom
feat/websocket-event-hub

Conversation

@backnotprop
Copy link
Copy Markdown
Owner

Summary

  • Replace persistent SSE streams with a single WebSocket connection per frontend instance
  • Daemon multiplexes session-scoped events (annotations, agent jobs, lifecycle) through /daemon/ws
  • Subscribe/unsubscribe messaging with connection-local subscriptions
  • Session actions over WebSocket for the approval loop
  • Reconnect/resync with snapshot-before-delta ordering
  • Auth enforcement on daemon-scope subscriptions
  • Polling fallback for WebSocket-blocked environments
  • Complete goal-setup protocol typing, feature registration, and daemon test coverage

Test plan

  • bun run typecheck passes
  • bun run test — 1,399 tests pass
  • bun run dev:debug-stack — sessions stream events over WebSocket
  • Goal-setup interview and facts scenarios complete through TUI

Single daemon process per machine manages session lifecycle, serves
browser UIs at /s/<sessionId>, and exposes control APIs. CLI commands
auto-start the daemon and create sessions via HTTP. Includes session
store, auth tokens, lock files, event broadcasting, and goal-setup
daemon integration.
Debug frontend (apps/debug-frontend) served by the daemon as the session
browser shell. Agent simulator TUI (apps/debug-tui) exercises all agent
protocols with concurrent session support. Includes reactive session
dashboard, event log, prominent session action buttons, and goal-setup
scenarios.
Replace persistent SSE streams with a single WebSocket connection per
frontend instance. Daemon multiplexes session-scoped events (annotations,
agent jobs, lifecycle) through /daemon/ws with subscribe/unsubscribe
messaging. Includes session actions over WebSocket, reconnect/resync,
auth enforcement, and polling fallback.
The goal-setup daemon integration from layers 734/738 was lost during
re-squash cascades. This commit restores all missing pieces:

- PluginGoalSetupRequest type and goal-setup action in plugin protocol
- goal-setup case in daemon session factory
- setup-goal CLI subcommand routed through runDaemonSessionRequest
- goal-setup-submit/goal-setup-exit debug frontend actions
- TUI scenarios for interview and facts with fixture bundles
- TUI completion for goal-setup sessions
- Fix getRepoInfo to use session cwd in createGoalSetupSession
- Standardize naming: "goal-setup" everywhere (was "setup-goal" in
  daemon protocol and debug frontend)
The source shim resolves workspace imports through package exports.
Without these entries, `bun apps/hook/server/index.ts` fails to find
daemon modules even though the files exist on disk.
- Add PluginGoalSetupResult to PluginActionResult union
- Add goal-setup to PLANNOTATOR_PLUGIN_FEATURES
- Use typed result in CLI instead of cast
- Add session factory tests: interview submit and facts exit
- Resolve relative bundle paths against getInvocationCwd() so
  hook/wrapper invocations find the file in the project directory
- Remove goal-setup from PLANNOTATOR_PLUGIN_FEATURES since it is
  a direct CLI command invoked by agent skills, not a plugin action
  dispatched through the plugin protocol
The onerror and onclose socket handlers both called scheduleReconnect(),
but the handleMessage error branch tore down the socket without
scheduling a reconnect — leaving the client permanently dead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant