diff --git a/app/api/routes/device_ws.py b/app/api/routes/device_ws.py index 16a3b67..4b47f42 100644 --- a/app/api/routes/device_ws.py +++ b/app/api/routes/device_ws.py @@ -9,7 +9,7 @@ available during the WebSocket handshake). Protocol: 1. Client connects → JWT validated → connection accepted. - 2. Client sends ``device_hello`` frame: ``{ type, device_id, agent_ids }``. + 2. Client sends ``device_hello`` frame: ``{ type, device_id, scout_ids }``. 3. Backend registers the connection in ``DeviceConnectionManager``. 4. Session enters message dispatch loop + heartbeat. @@ -100,7 +100,7 @@ async def device_ws(websocket: WebSocket) -> None: if hello.get("type") != WsFrameType.device_hello: raise ValueError("expected device_hello as first frame") device_id: str = hello["device_id"] - agent_ids: list[str] = hello.get("agent_ids", []) + scout_ids: list[str] = hello.get("scout_ids", []) except (KeyError, ValueError, json.JSONDecodeError) as exc: logger.warning("device_ws: invalid device_hello from user=%s: %s", user_id, exc) await websocket.close(code=1008) @@ -109,10 +109,10 @@ async def device_ws(websocket: WebSocket) -> None: # ── 3. Register connection ──────────────────────────────────────── device_manager.register(user_id, device_id, websocket) logger.info( - "device_ws: connected user=%s device=%s agents=%s", + "device_ws: connected user=%s device=%s scouts=%s", user_id, device_id, - agent_ids, + scout_ids, ) # Trigger any overdue agent runs now that the device is connected. diff --git a/app/integrations/gmail.py b/app/integrations/gmail.py index 78ce858..06a039e 100644 --- a/app/integrations/gmail.py +++ b/app/integrations/gmail.py @@ -8,7 +8,7 @@ blocking the event loop. Token refresh is handled transparently: when the stored access token has expired, ``google.auth.transport.requests.Request`` will use the refresh token to obtain a fresh one. The caller is responsible for persisting -any refreshed credentials back to ``CloudAgentConfig.oauth_token_encrypted`` +any refreshed credentials back to ``CloudScoutConfig.oauth_token_encrypted`` (see ``agent_runner.run_cloud_agent``). Credential dict shape (Google OAuth2): diff --git a/app/schemas/__init__.py b/app/schemas/__init__.py index 9350c97..8d8e771 100644 --- a/app/schemas/__init__.py +++ b/app/schemas/__init__.py @@ -147,7 +147,7 @@ class WsDeviceHello(BaseModel): type: Literal[WsFrameType.device_hello] = WsFrameType.device_hello device_id: str - agent_ids: list[str] = Field(default_factory=list) + scout_ids: list[str] = Field(default_factory=list) diff --git a/tests/test_device_ws.py b/tests/test_device_ws.py index 638f2cc..1a730d5 100644 --- a/tests/test_device_ws.py +++ b/tests/test_device_ws.py @@ -33,9 +33,9 @@ _FREE_UID = TEST_USER_IDS["free"] _PRO_UID = TEST_USER_IDS["pro"] -def _device_hello(device_id: str = "dev-001", agent_ids: list[str] | None = None) -> str: +def _device_hello(device_id: str = "dev-001", scout_ids: list[str] | None = None) -> str: return json.dumps( - {"type": "device_hello", "device_id": device_id, "agent_ids": agent_ids or []} + {"type": "device_hello", "device_id": device_id, "scout_ids": scout_ids or []} ) diff --git a/tests/test_memory_middleware.py b/tests/test_memory_middleware.py index 325fa07..55900eb 100644 --- a/tests/test_memory_middleware.py +++ b/tests/test_memory_middleware.py @@ -322,7 +322,7 @@ def test_home_request_calls_memory_middleware(client): ): with client.websocket_connect(f"/api/v1/ws/device?token={token}") as ws: ws.send_text(json.dumps({ - "type": "device_hello", "device_id": "dev-mem", "agent_ids": [] + "type": "device_hello", "device_id": "dev-mem", "scout_ids": [] })) ws.send_text(json.dumps({ "type": "home_request", diff --git a/tests/test_ws_unified.py b/tests/test_ws_unified.py index e1c9b1b..6f7ea0b 100644 --- a/tests/test_ws_unified.py +++ b/tests/test_ws_unified.py @@ -58,7 +58,7 @@ def test_home_request_produces_stream_frames(client): with patch("app.api.routes.device_ws.run_home_stream", side_effect=_mock_home_stream): with client.websocket_connect(f"/api/v1/ws/device?token={token}") as ws: ws.send_text(json.dumps({ - "type": "device_hello", "device_id": "dev-1", "agent_ids": [] + "type": "device_hello", "device_id": "dev-1", "scout_ids": [] })) ws.send_text(json.dumps({ "type": "home_request", @@ -85,7 +85,7 @@ def test_home_request_request_id_propagated(client): with patch("app.api.routes.device_ws.run_home_stream", side_effect=_stream): with client.websocket_connect(f"/api/v1/ws/device?token={token}") as ws: ws.send_text(json.dumps({ - "type": "device_hello", "device_id": "dev-3", "agent_ids": [] + "type": "device_hello", "device_id": "dev-3", "scout_ids": [] })) ws.send_text(json.dumps({ "type": "home_request", @@ -106,7 +106,7 @@ def test_tool_result_dispatch_silent_on_unknown_id(client): with patch("app.api.routes.device_ws._HEARTBEAT_INTERVAL", 0.05): with client.websocket_connect(f"/api/v1/ws/device?token={token}") as ws: ws.send_text(json.dumps({ - "type": "device_hello", "device_id": "dev-4", "agent_ids": [] + "type": "device_hello", "device_id": "dev-4", "scout_ids": [] })) ws.send_text(json.dumps({ "type": "tool_result", "id": "no-such-id", "ok": True