step 3.3 complete: device WS endpoint + DeviceConnectionManager

This commit is contained in:
2026-03-05 15:51:58 +01:00
parent 19ad5be97f
commit 608d6c784f
5 changed files with 784 additions and 12 deletions

View File

@@ -348,7 +348,7 @@ Cloud Agent:
- **Outcome:** Full CRUD for agent configs with tier-gated creation limits.
### Step 3.3 — Device WS endpoint
- [ ] Create `app/api/routes/device_ws.py`:
- [x] Create `app/api/routes/device_ws.py`:
- `WebSocket /api/v1/ws/device?token=<jwt>` — persistent connection from Electron
- On connect:
- Authenticate JWT
@@ -364,7 +364,7 @@ Cloud Agent:
- Remove from `DeviceConnectionManager`
- Mark any in-progress agent runs as `error` with "device disconnected"
- Heartbeat: send `ping` every 30s, disconnect if no `pong` within 10s
- [ ] Create `app/core/device_manager.py`:
- [x] Create `app/core/device_manager.py`:
- `DeviceConnectionManager` (singleton):
- `register(user_id, device_id, ws)` — stores active connection
- `unregister(user_id)` — removes connection