Skip to content

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.

fix(agent-runtimes): satisfy the silent-exception and async-route gates

rubenluetke10-beepb290cd83587d
diff --git a/jarvis/agent_runtimes/base.py b/jarvis/agent_runtimes/base.py
index c46c77c698..a30c204cf1 100644
--- a/jarvis/agent_runtimes/base.py
+++ b/jarvis/agent_runtimes/base.py
@@ -266,8 +266,8 @@ def write_if_changed(path: Path, text: str) -> bool:
try:
if path.read_text(encoding="utf-8") == text:
return False
- except OSError:
- pass # no readable file yet: write it below
+ except OSError: # no readable file yet: it is written below
+ pass
path.parent.mkdir(parents=True, exist_ok=True)
tmp = path.with_suffix(path.suffix + ".tmp")
tmp.write_text(text, encoding="utf-8")
@@ -315,7 +315,7 @@ def first_existing(candidates: list[Path]) -> Path | None:
try:
if candidate.is_file():
return candidate
- except OSError:
+ except OSError: # an unreadable candidate is simply not the install
continue
return None
diff --git a/jarvis/agent_runtimes/manager.py b/jarvis/agent_runtimes/manager.py
index e80988fcc3..8b2da679de 100644
--- a/jarvis/agent_runtimes/manager.py
+++ b/jarvis/agent_runtimes/manager.py
@@ -65,7 +65,7 @@ def _log_path(runtime: str) -> Any:
def log_tail(runtime: str, lines: int = 12) -> list[str]:
try:
text = _log_path(runtime).read_text(encoding="utf-8", errors="replace")
- except OSError:
+ except OSError: # no setup has written a log yet: nothing to show
return []
return [line for line in text.splitlines() if line.strip()][-lines:]
@@ -86,7 +86,7 @@ async def statuses(*, refresh: bool = False) -> list[dict[str, Any]]:
return out
-def start(runtime: str, kind: JobKind) -> RuntimeJob:
+async def start(runtime: str, kind: JobKind) -> RuntimeJob:
"""Start an install or update job; returns the running job if one exists."""
if runtime not in RUNTIME_NAMES:
raise KeyError(runtime)
@@ -133,7 +133,7 @@ async def _run(current: RuntimeJob, argv: list[str]) -> None:
tree.assign(proc.pid)
try:
code = await asyncio.wait_for(proc.wait(), timeout=_JOB_TIMEOUT_S)
- except TimeoutError:
+ except TimeoutError: # reported through the job's state and message below
with contextlib.suppress(ProcessLookupError, OSError):
proc.kill()
code = -1
diff --git a/jarvis/agent_runtimes/model_map.py b/jarvis/agent_runtimes/model_map.py
index 0730f335cf..faaa88399d 100644
--- a/jarvis/agent_runtimes/model_map.py
+++ b/jarvis/agent_runtimes/model_map.py
@@ -97,7 +97,7 @@ def usable_providers(config: Any) -> list[str]:
for provider in sorted(_ENDPOINTS):
try:
route_for(config, provider, "probe")
- except RouteUnavailable:
+ except RouteUnavailable: # not connected: the provider is simply not offered
continue
except Exception: # noqa: BLE001 — one unreadable provider must not empty the list
log.warning("agent runtimes: provider %s could not be checked", provider, exc_info=True)
diff --git a/jarvis/agent_runtimes/openclaw.py b/jarvis/agent_runtimes/openclaw.py
index ed0e5a6a86..332b2b8f12 100644
--- a/jarvis/agent_runtimes/openclaw.py
+++ b/jarvis/agent_runtimes/openclaw.py
@@ -152,7 +152,7 @@ async def _listening(port: int) -> bool:
_reader, writer = await asyncio.wait_for(
asyncio.open_connection("127.0.0.1", port), timeout=2
)
- except (OSError, TimeoutError):
+ except (OSError, TimeoutError): # not listening yet: the caller polls again
return False
writer.close()
with contextlib.suppress(OSError):
@@ -569,8 +569,8 @@ def _gateway_token(home: Path) -> str:
token = path.read_text(encoding="utf-8").strip()
if token:
return token
- except OSError:
- pass # no token yet: mint one below
+ except OSError: # no token yet: one is minted below
+ pass
token = secrets.token_urlsafe(32)
write_if_changed(path, token)
with contextlib.suppress(OSError):
@@ -604,7 +604,7 @@ async def _run_doctor(launcher: list[str], env: dict[str, str], home: Path) -> N
def _log_tail(path: Path, lines: int = 6) -> str:
try:
text = path.read_text(encoding="utf-8", errors="replace")
- except OSError:
+ except OSError: # no log to quote: the start error stands on its own
return ""
tail = [line for line in text.splitlines() if line.strip()][-lines:]
return ("\n" + "\n".join(tail)) if tail else ""
diff --git a/jarvis/ui/web/agent_runtime_routes.py b/jarvis/ui/web/agent_runtime_routes.py
index fcb0fc8341..7fcaad198b 100644
--- a/jarvis/ui/web/agent_runtime_routes.py
+++ b/jarvis/ui/web/agent_runtime_routes.py
@@ -58,11 +58,11 @@ async def run_agent_runtime_setup(
"""Start the runtime's official installer or updater (person-started only)."""
if runtime not in RUNTIME_NAMES:
raise HTTPException(404, f"unknown runtime {runtime!r}")
- return {"job": manager.start(runtime, action).to_dict()}
+ return {"job": (await manager.start(runtime, action)).to_dict()}
@router.get("/{runtime}/job")
-async def agent_runtime_job(runtime: str) -> dict[str, Any]:
+def agent_runtime_job(runtime: str) -> dict[str, Any]:
"""The running or last setup job of one runtime (``null`` when none)."""
if runtime not in RUNTIME_NAMES:
raise HTTPException(404, f"unknown runtime {runtime!r}")
diff --git a/tests/unit/agent_runtimes/test_runtime_manager.py b/tests/unit/agent_runtimes/test_runtime_manager.py
index 03b6875cfa..e442b0303d 100644
--- a/tests/unit/agent_runtimes/test_runtime_manager.py
+++ b/tests/unit/agent_runtimes/test_runtime_manager.py
@@ -63,9 +63,9 @@ async def _finish(name: str) -> manager.RuntimeJob:
async def test_an_install_runs_the_official_command_and_logs_it(fakes):
- started = manager.start("hermes", "install")
+ started = await manager.start("hermes", "install")
assert started.state == "running"
- assert manager.start("hermes", "install") is started # one job at a time
+ assert await manager.start("hermes", "install") is started # one job at a time
done = await _finish("hermes")
assert done.state == "done" and done.exit_code == 0
assert any("installing" in line for line in done.to_dict()["log_tail"])
@@ -73,7 +73,7 @@ async def test_an_install_runs_the_official_command_and_logs_it(fakes):
async def test_an_update_stops_the_runtime_first_and_reports_a_failure(fakes):
- manager.start("openclaw", "update")
+ await manager.start("openclaw", "update")
done = await _finish("openclaw")
assert fakes["openclaw"].stopped == 1
assert done.state == "failed" and done.exit_code == 3
@@ -82,7 +82,7 @@ async def test_an_update_stops_the_runtime_first_and_reports_a_failure(fakes):
async def test_unknown_runtimes_are_refused(fakes):
with pytest.raises(KeyError):
- manager.start("skynet", "install")
+ await manager.start("skynet", "install")
def test_routes_list_status_and_start_jobs(fakes):