Skip to content

feat: hub WebSocket client + execution handling + proxy routes#51

Merged
vreshch merged 1 commit intomasterfrom
feature/phase-4-ws-execution
Mar 21, 2026
Merged

feat: hub WebSocket client + execution handling + proxy routes#51
vreshch merged 1 commit intomasterfrom
feature/phase-4-ws-execution

Conversation

@vreshch
Copy link
Contributor

@vreshch vreshch commented Mar 21, 2026

Summary

Daemon-side WebSocket connection to hub for remote agent execution.

  • Hub WS client: connects with Supabase JWT + machineId. Handles incoming messages:
    • WsExecuteRequest → finds local agent, starts run via run-manager, subscribes to events, streams WsRunEvent + WsRunStateChange back to hub
    • WsCancel → cancels local run
    • WsSendInput → sends input to waiting run
  • Hub sync updated: connects WS after registration, triggers reconnection on disconnect. Processes pending commands from heartbeat response (cancel/input queued while WS was down).
  • Hub proxy routes: GET /api/hub/machines, GET /api/hub/agents, POST /api/hub/runs — daemon proxies CLI requests to hub API. Returns 401 when not logged in.
  • Hub client: added createRun, cancelRun, sendRunInput methods
  • 131 tests passing (2 new)

Execution flow

Hub sends WsExecuteRequest → daemon finds agent → startRun()
  → onRunEvent → ws.send(WsRunEvent) to hub
  → onRunStateChange → ws.send(WsRunStateChange) to hub
Hub sends WsCancel → daemon cancelRun()

Test plan

  • npm run verify passes (type-check + lint + format + 131 tests + build)
  • Review WS message handling (hub-ws.ts)
  • Review hub proxy routes (routes.ts)
  • Review pending command processing in hub-sync

- Hub WS client: connects to hub with Supabase JWT + machineId,
  handles WsExecuteRequest (finds agent, starts run, streams events
  back as WsRunEvent/WsRunStateChange), WsCancel, WsSendInput
- Hub sync: now connects WS after registration, reconnects on
  disconnect. Processes pending commands (cancel/input) from
  heartbeat response.
- Hub proxy routes: GET /api/hub/machines, GET /api/hub/agents,
  POST /api/hub/runs — daemon proxies CLI requests to hub API
- Hub client: added createRun, cancelRun, sendRunInput methods
- Updated server test: replaced auth/callback placeholder with
  hub proxy 401 test
- 131 tests passing (2 new: hub-ws creation, hub proxy auth check)
@github-actions
Copy link

🎉 PR Validation ✅ PASSED

Commit: 752633a299124fbfa4a8ea87e4b3b792e8209a6f
Branch: feature/phase-4-ws-execution

Checks:

  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests passed
  • ✅ Build successful

Ready to merge!


🔗 View workflow run
⏰ Generated at: 2026-03-21T12:28:42.861Z

@vreshch vreshch merged commit 80fc409 into master Mar 21, 2026
1 check passed
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