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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-08 19:16)

Ruben Lütkeaca982179fd8
diff --git a/jarvis/browser_voice/route.py b/jarvis/browser_voice/route.py
index 888888ab2b..36abb29ed2 100644
--- a/jarvis/browser_voice/route.py
+++ b/jarvis/browser_voice/route.py
@@ -56,13 +56,20 @@ def _build_browser_session(
"""
# Realtime mode branch (default OFF): only when [voice].mode == "realtime"
# AND an OpenAI key exists. Otherwise fall through to the classic bridge.
- from jarvis.realtime.factory import build_realtime_session
-
- rt = build_realtime_session(
- cfg=cfg, bus=bus, session_id=session_id, send_binary=send_binary, send_json=send_json
- )
- if rt is not None:
- return rt
+ # The realtime engine is an optional, still-internal module stripped from
+ # public distribution snapshots (distribution-denylist), so its absence just
+ # means "no realtime" — fall through instead of crashing the voice session.
+ try:
+ from jarvis.realtime.factory import build_realtime_session
+ except ImportError:
+ build_realtime_session = None # type: ignore[assignment]
+
+ if build_realtime_session is not None:
+ rt = build_realtime_session(
+ cfg=cfg, bus=bus, session_id=session_id, send_binary=send_binary, send_json=send_json
+ )
+ if rt is not None:
+ return rt
factory = getattr(state, "browser_voice_session_factory", None)
if factory is not None:
diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.py
index ee714e256c..0f0d8952f9 100644
--- a/jarvis/ui/web/settings_routes.py
+++ b/jarvis/ui/web/settings_routes.py
@@ -35,7 +35,6 @@ from pydantic import BaseModel, Field, model_validator
from jarvis.brain.manager import SUPPORTED_REPLY_LANGUAGES
from jarvis.memory.wiki.integration import get_running_curator
-from jarvis.realtime.factory import realtime_available_provider
if TYPE_CHECKING:
from jarvis.core.config import WikiCuratorConfig
@@ -45,6 +44,24 @@ log = logging.getLogger(__name__)
router = APIRouter(prefix="/api/settings", tags=["settings"])
+def _realtime_available_provider(cfg: object) -> str | None:
+ """Reachable realtime provider name for ``cfg``, or ``None``.
+
+ The realtime voice engine (``jarvis.realtime``) is an optional module that is
+ stripped from public distribution snapshots (distribution-denylist) while it
+ is still internal. Import it lazily and treat its absence as "no realtime
+ available", so the settings router still IMPORTS (the server boots) and the
+ ``/voice-mode`` endpoint degrades honestly instead of taking the whole app
+ down. When the module is present (the full/local build) this delegates to it
+ unchanged.
+ """
+ try:
+ from jarvis.realtime.factory import realtime_available_provider
+ except ImportError:
+ return None
+ return realtime_available_provider(cfg)
+
+
class ReplyLanguageBody(BaseModel):
language: str = Field(..., min_length=1)
persist: bool = Field(default=True, description="Persist as boot default in jarvis.toml")
@@ -133,7 +150,7 @@ async def get_voice_mode(request: Request) -> dict[str, object]:
# session factory uses, so this never disagrees with what a realtime
# session would actually build (Gemini-only users now get `true` too,
# not just OpenAI — Feature A2).
- prov = realtime_available_provider(cfg)
+ prov = _realtime_available_provider(cfg)
return {
"mode": mode,
"realtime_available": prov is not None,
diff --git a/tests/unit/ui/web/test_settings_realtime_optional.py b/tests/unit/ui/web/test_settings_realtime_optional.py
new file mode 100644
index 0000000000..71005d049a
--- /dev/null
+++ b/tests/unit/ui/web/test_settings_realtime_optional.py
@@ -0,0 +1,33 @@
+"""The settings router must import + serve even when the realtime module is absent.
+
+The realtime voice engine is an optional, still-internal module that is stripped
+from public distribution snapshots (distribution-denylist). Two shipped sites
+reference it — this guards the boot-critical one: ``settings_routes`` imported
+``jarvis.realtime.factory`` at MODULE level, so a realtime-stripped public build
+would fail to import the whole settings router and the server would not boot. The
+reference must be lazy + guarded, degrading to "realtime not available".
+"""
+from __future__ import annotations
+
+import sys
+
+from jarvis.ui.web import settings_routes
+
+
+def test_realtime_available_helper_degrades_when_module_stripped(monkeypatch) -> None:
+ # Simulate the realtime engine being stripped from a public snapshot: the
+ # import raises, and the helper must report "no realtime", not blow up.
+ monkeypatch.setitem(sys.modules, "jarvis.realtime.factory", None)
+ monkeypatch.setitem(sys.modules, "jarvis.realtime", None)
+ assert settings_routes._realtime_available_provider(object()) is None
+
+
+def test_realtime_available_helper_resolves_when_module_present(monkeypatch) -> None:
+ # When the module IS present, the helper delegates to it (here: a stub that
+ # reports a reachable provider), so the local/full build is unchanged.
+ import types
+
+ stub = types.ModuleType("jarvis.realtime.factory")
+ stub.realtime_available_provider = lambda cfg: "openai-realtime" # type: ignore[attr-defined]
+ monkeypatch.setitem(sys.modules, "jarvis.realtime.factory", stub)
+ assert settings_routes._realtime_available_provider(object()) == "openai-realtime"