Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(api): request-body, OpenAPI and event-loop contract fixes
rubenluetke10-beep26593ee002ff
diff --git a/jarvis/ui/web/agent_chat_routes.py b/jarvis/ui/web/agent_chat_routes.pyindex 1e74e04d0d..e4bd51d1bc 100644--- a/jarvis/ui/web/agent_chat_routes.py+++ b/jarvis/ui/web/agent_chat_routes.py@@ -131,7 +131,7 @@ def _archived_voice_history(request: Request, voice_session_id: str) -> Any:@router.get("/voice-chat", summary="The Jarvis chat voice calls continue")-async def get_voice_chat(request: Request) -> VoiceChatResponse:+def get_voice_chat(request: Request) -> VoiceChatResponse:return _voice_chat_answer(_service(request))@@ -719,7 +719,7 @@ async def get_provider_health(@router.get("/sessions")-async def list_sessions(+def list_sessions(request: Request,limit: int = Query(200, ge=1, le=1000),surface: SurfaceName | None = None,@@ -792,7 +792,7 @@ def _title_jarvis_chats(request: Request, svc: Any, rows: list[dict[str, Any]])@router.post("/sessions", status_code=201)-async def create_session(body: CreateSessionBody, request: Request) -> dict[str, Any]:+def create_session(body: CreateSessionBody, request: Request) -> dict[str, Any]:svc = _service(request)ladder = ladder_key(body.surface, resolve_runner(body.provider, surface=body.surface))if body.permission_mode and not is_permission_mode(ladder, body.permission_mode):@@ -822,7 +822,7 @@ async def create_session(body: CreateSessionBody, request: Request) -> dict[str,@router.get("/sessions/{session_id}")-async def get_session(+def get_session(session_id: str,request: Request,tail: int | None = Query(diff --git a/jarvis/ui/web/app_actions_routes.py b/jarvis/ui/web/app_actions_routes.pyindex e8a7a7738d..eb263fe10a 100644--- a/jarvis/ui/web/app_actions_routes.py+++ b/jarvis/ui/web/app_actions_routes.py@@ -11,6 +11,11 @@ from pydantic import BaseModel, ConfigDictrouter = APIRouter(prefix="/api/app-actions", tags=["app-actions"])+# Plain ``def`` handlers on purpose: each reads or writes the policy/history+# files, and the first catalog read generates the app's whole OpenAPI schema.+# FastAPI runs them in the threadpool, off the shared event loop; the policy+# and history modules guard their files with a threading lock.+class ModeBody(BaseModel):model_config = ConfigDict(extra="forbid")@@ -19,7 +24,7 @@ class ModeBody(BaseModel):@router.get("")-async def list_app_actions() -> dict[str, Any]:+def list_app_actions() -> dict[str, Any]:from jarvis.app_actions.catalog import live_catalogfrom jarvis.app_actions.policy import effective_tier, load_policy@@ -36,7 +41,7 @@ async def list_app_actions() -> dict[str, Any]:@router.put("/{action_id}/mode")-async def set_app_action_mode(action_id: str, body: ModeBody) -> dict[str, Any]:+def set_app_action_mode(action_id: str, body: ModeBody) -> dict[str, Any]:from jarvis.app_actions.catalog import live_catalogfrom jarvis.app_actions.policy import effective_tier, set_mode@@ -48,7 +53,7 @@ async def set_app_action_mode(action_id: str, body: ModeBody) -> dict[str, Any]:@router.get("/history")-async def app_action_history(limit: int = 50) -> dict[str, Any]:+def app_action_history(limit: int = 50) -> dict[str, Any]:from jarvis.app_actions import historyfrom jarvis.app_actions.catalog import live_catalogdiff --git a/jarvis/ui/web/outputs_routes.py b/jarvis/ui/web/outputs_routes.pyindex 56e54c7cff..63ab0af9e0 100644--- a/jarvis/ui/web/outputs_routes.py+++ b/jarvis/ui/web/outputs_routes.py@@ -1084,7 +1084,11 @@ async def download_output_artifact(# no-script inline download). FastAPI registers only GET for ``@router.get``, so# the probe used to answer 405 on every backend and the fallback ALWAYS won —# the page's own scripts never ran. FileResponse sends headers only for HEAD.[email protected]_route("/{slug}/files/{path:path}/page", methods=["GET", "HEAD"])+# Two registrations, not one ``methods=["GET", "HEAD"]`` route: FastAPI gives+# both methods of a single route the same operationId, which makes the+# published OpenAPI document invalid for client generators.[email protected]("/{slug}/files/{path:path}/page")[email protected]("/{slug}/files/{path:path}/page", include_in_schema=False)async def serve_artifact_page(slug: str, path: str, request: Request) -> FileResponse:"""Serve an HTML deliverable as an ARTIFACT PAGE — scripts allowed, network shut.diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex 6c1487740a..4b4780c1f1 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -3323,7 +3323,10 @@ async def managed_server_setup(request: Request) -> dict[str, Any]:body = await request.json()except Exception as exc: # noqa: BLE001 - malformed JSON is a client errorraise HTTPException(status_code=400, detail="a JSON request body is required") from exc- brain_model = str((body or {}).get("brain_model", "") or "").strip()+ if not isinstance(body, dict):+ # A JSON array or scalar used to reach ``.get`` and answer 500.+ raise HTTPException(status_code=400, detail="the request body must be a JSON object")+ brain_model = str(body.get("brain_model", "") or "").strip()voice_model = str((body or {}).get("voice_model", "") or "").strip()if not brain_model or not voice_model:raise HTTPException(diff --git a/scripts/ci/async-routes-baseline.json b/scripts/ci/async-routes-baseline.jsonindex b0e3d39038..7de41973d8 100644--- a/scripts/ci/async-routes-baseline.json+++ b/scripts/ci/async-routes-baseline.json@@ -1,8 +1,9 @@{"_comment": "Per-file count of async-def route handlers whose body never awaits - each one runs its disk I/O on the shared event loop. Generated by scripts/ci/check_async_routes.py --update. These numbers may go DOWN freely; an increase is a gate failure.",- "total": 96,+ "total": 98,"files": {"jarvis/ui/web/agent_chat_routes.py": 4,+ "jarvis/ui/web/agentic_ide_routes.py": 2,"jarvis/ui/web/chats_routes.py": 4,"jarvis/ui/web/commands_routes.py": 2,"jarvis/ui/web/computer_use_routes.py": 5,diff --git a/tests/integration/test_openapi_contract.py b/tests/integration/test_openapi_contract.pynew file mode 100644index 0000000000..6db568eb82--- /dev/null+++ b/tests/integration/test_openapi_contract.py@@ -0,0 +1,32 @@+"""Contract checks on the OpenAPI document the whole app publishes.++``/api/openapi.json`` is what the ``jarvis`` CLI builds its ``api`` commands+from and what any external client generator reads. A route whose methods+share one operationId (``api_route(methods=["GET", "HEAD"])``) made the+document invalid for generators; this keeps it from coming back.+"""++from __future__ import annotations++import collections++from jarvis.core.bus import EventBus+from jarvis.core.config import JarvisConfig+from jarvis.ui.web.server import WebServer+++def _spec() -> dict:+ cfg = JarvisConfig()+ cfg.ui.dev_mode = True+ return WebServer(cfg, bus=EventBus()).app.openapi()+++def test_operation_ids_are_unique() -> None:+ counts = collections.Counter(+ op.get("operationId")+ for item in _spec()["paths"].values()+ for op in item.values()+ if isinstance(op, dict)+ )+ duplicates = sorted(op_id for op_id, n in counts.items() if n > 1)+ assert duplicates == []diff --git a/tests/unit/ui/web/test_managed_local_realtime_routes.py b/tests/unit/ui/web/test_managed_local_realtime_routes.pyindex 4dfccd6b39..927b87cea7 100644--- a/tests/unit/ui/web/test_managed_local_realtime_routes.py+++ b/tests/unit/ui/web/test_managed_local_realtime_routes.py@@ -445,3 +445,14 @@ def test_card_payload_carries_managed_server_only_on_local_realtime(assert "sentence" in providers["local-realtime"]["managed_server"]cloud = next(p for pid, p in providers.items() if pid != "local-realtime")assert cloud["managed_server"] is None++[email protected]("body", [["qwen"], "qwen", 3])+def test_setup_refuses_a_non_object_body(server: WebServer, body: object) -> None:+ # A JSON array or scalar used to reach ``.get`` and answer 500.+ with TestClient(server.app) as client:+ resp = client.post(+ "/api/providers/local-realtime/managed-server/setup", json=body+ )+ assert resp.status_code == 400+