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(config): harden the config writer and brain provider switching
rubenluetke10-beep7431b8625a5f
diff --git a/jarvis/brain/app_control.py b/jarvis/brain/app_control.pyindex 01120d6e00..ac61cfb5cb 100644--- a/jarvis/brain/app_control.py+++ b/jarvis/brain/app_control.py@@ -32,6 +32,7 @@ Layering note: this is a brain-layer service. It imports the pure-data providercatalog (``provider_spec``) and the low-layer config writer / mcp state. The UIlayer (``provider_routes``) imports *down* into this module — never the reverse."""+from __future__ import annotationsimport asyncio@@ -60,11 +61,13 @@ def get_spec(provider_id: str) -> Any:"""Provider spec by id, or ``None`` (thin wrapper over the lazy catalog)."""return _catalog().get_spec(provider_id)+# The tiers a provider switch can target. ``brain`` and ``tts`` apply live;# Jarvis-Agent workers re-resolve their provider before each mission. STT is# wired once at bootstrap and still needs a restart.SWITCHABLE_TIERS: frozenset[str] = frozenset({"brain", "tts", "stt", "subagent"})+# Local providers allowed to stay active in the airgapped privacy profile.# SPEC-DERIVED since 2026-07-25 (local-first mandate): every provider card# declaring ``auth_mode == "none"`` is local by definition — ollama and@@ -141,11 +144,10 @@ def _keyless_credential_present(provider_id: str) -> bool:try:return bool(getattr(cfg_mod, probe_name)())except Exception as exc: # noqa: BLE001 — a probe must never break a card- log.debug(- "Keyless credential probe %s for %s failed: %s", probe_name, provider_id, exc- )+ log.debug("Keyless credential probe %s for %s failed: %s", probe_name, provider_id, exc)return False+# Local providers that need no credential at all — the same spec-derived set# as LOCAL_PROVIDERS (auth_mode "none" IS the definition of "no credential").# is_credential_present() independently reports auth_mode=="none" providers as@@ -215,7 +217,8 @@ def masked_secret_preview(provider_id: str) -> dict[str, Any]:# Privacy: log only that a preview was produced, never the value or the mask.log.info("masked_secret_preview: provider=%r configured (preview=%s)",- provider_id, masked["preview"] is not None,+ provider_id,+ masked["preview"] is not None,)return {"provider": provider_id,@@ -490,10 +493,7 @@ async def apply_provider_switch(return {"ok": False,"error_kind": "unknown_tier",- "error": (- f"Unknown tier {tier!r}. Use one of: "- f"{', '.join(sorted(SWITCHABLE_TIERS))}."- ),+ "error": (f"Unknown tier {tier!r}. Use one of: {', '.join(sorted(SWITCHABLE_TIERS))}."),}# Airgapped privacy profile admits only local providers. Enforced HERE so@@ -576,7 +576,11 @@ async def apply_provider_switch(async def _switch_brain(- provider: str, *, cfg: Any, persist: bool, old: str | None,+ provider: str,+ *,+ cfg: Any,+ persist: bool,+ old: str | None,manager: Any | None = None,) -> dict[str, Any]:if manager is None:@@ -742,17 +746,13 @@ async def _switch_subagent(codex_cfg = getattr(cfg, "codex", None)binary_path = getattr(codex_cfg, "binary_path", "") or None- codex_status = await asyncio.to_thread(- CodexAuthService(binary_path).status- )+ codex_status = await asyncio.to_thread(CodexAuthService(binary_path).status)codex_connected = codex_status.connectedexcept Exception: # noqa: BLE001 — codex CLI absent is just "not connected"codex_status = Nonecodex_connected = Falsehas_key = bool(- cfg_mod.get_secret(- "codex_openai_api_key", env_fallback="CODEX_OPENAI_API_KEY"- )+ cfg_mod.get_secret("codex_openai_api_key", env_fallback="CODEX_OPENAI_API_KEY"))if codex_status is None or not codex_status.installed:return {@@ -787,9 +787,7 @@ async def _switch_subagent(antigravity_provider_ready,)- antigravity_status = await asyncio.to_thread(- GoogleCliAuthService().status- )+ antigravity_status = await asyncio.to_thread(GoogleCliAuthService().status)except Exception as exc: # noqa: BLE001 — absent CLI is a normal capability misslog.debug("Antigravity CLI readiness probe failed: %s", exc)has_key = bool(cfg_mod.get_jarvis_agent_secret("gemini"))@@ -831,9 +829,7 @@ async def _switch_subagent(grok_build_provider_ready,)- grok_build_status = await asyncio.to_thread(- GrokBuildAuthService().status- )+ grok_build_status = await asyncio.to_thread(GrokBuildAuthService().status)except Exception as exc: # noqa: BLE001 — absent CLI is a normal capability misslog.debug("Grok Build CLI readiness probe failed: %s", exc)if grok_build_status is None or not grok_build_status.installed:@@ -868,21 +864,20 @@ async def _switch_subagent(# Codex and Antigravity route through their own workers, so omitting them# produced the false "codex is not a valid provider, only claude/gemini/# openai/openrouter" reply (forensic 2026-06-27).- known = ", ".join(sorted(- set(JARVIS_TO_WORKER_SLUG)- | {- CODEX_SUBAGENT_CANONICAL,- ANTIGRAVITY_SUBAGENT_CANONICAL,- GROK_BUILD_SUBAGENT_CANONICAL,- }- ))+ known = ", ".join(+ sorted(+ set(JARVIS_TO_WORKER_SLUG)+ | {+ CODEX_SUBAGENT_CANONICAL,+ ANTIGRAVITY_SUBAGENT_CANONICAL,+ GROK_BUILD_SUBAGENT_CANONICAL,+ }+ )+ )return {"ok": False,"error_kind": "unknown_provider",- "error": (- f"{provider!r} is not a {brand}-capable provider. "- f"Available: {known}."- ),+ "error": (f"{provider!r} is not a {brand}-capable provider. Available: {known}."),}has_credential = bool(cfg_mod.get_jarvis_agent_secret(canon))if canon == "claude-api" and not has_credential:@@ -896,9 +891,7 @@ async def _switch_subagent(try:from jarvis.claude_auth import usable_native_claude_subscription- native_status = await asyncio.to_thread(- usable_native_claude_subscription- )+ native_status = await asyncio.to_thread(usable_native_claude_subscription)has_credential = native_status is not Noneexcept Exception: # noqa: BLE001 — optional native CLI auth pathhas_credential = False@@ -941,9 +934,7 @@ def _complete_agent_switch(app. An explicit non-persistent switch remains an in-memory preview only."""persisted = (- _persist(lambda: _import_writer().set_worker_provider(provider))- if persist- else False+ _persist(lambda: _import_writer().set_worker_provider(provider)) if persist else False)if persist and not persisted:return {diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex 3b57a1bd42..de5542c0c7 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -78,7 +78,7 @@ _WORKER_MODEL_ENV = "JARVIS__BRAIN__WORKER__MODEL"# Back-compat aliases for the old ENV var names — kept so any code that# references these constants by name still resolves without an ImportError._SUB_JARVIS_PROVIDER_ENV = _WORKER_PROVIDER_ENV # back-compat alias (pre-rename)-_SUB_JARVIS_MODEL_ENV = _WORKER_MODEL_ENV # back-compat alias (pre-rename)+_SUB_JARVIS_MODEL_ENV = _WORKER_MODEL_ENV # back-compat alias (pre-rename)# Canonical User-scope ENV var that overrides ``[brain.computer_use] provider``# at boot — the dedicated GLOBAL Computer-Use planner provider, decoupled@@ -102,9 +102,7 @@ _STT_MODEL_ENV = "JARVIS__STT__MODEL"_STT_LANGUAGE_ENV = "JARVIS__STT__LANGUAGE"-def set_agentic_ide_prompt_writer(- value: str, *, path: Path = DEFAULT_CONFIG_FILE-) -> None:+def set_agentic_ide_prompt_writer(value: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Set ``[agentic_ide] prompt_writer`` — who writes Agentic IDE task briefs.One layer only, deliberately. The brain-provider setters above also mirror@@ -499,9 +497,7 @@ def set_tts_volume(volume: float, *, path: Path = DEFAULT_CONFIG_FILE) -> None:log.warning("Could not sync tts.volume to config-soll.json: %s", exc) # i18n-allow-def set_audio_device(- kind: str, value: str, *, path: Path = DEFAULT_CONFIG_FILE-) -> None:+def set_audio_device(kind: str, value: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Set ``[audio] input_device`` / ``[audio] output_device``.``kind`` is ``"input"`` or ``"output"``; ``value`` is a device display@@ -657,7 +653,6 @@ def set_codex_binary_path(binary_path: str, *, path: Path = DEFAULT_CONFIG_FILE)_patch_table(path, "codex", "binary_path", binary_path)-# Voice-keybind action vocabulary. Shared with the keybinds API# (jarvis/ui/web/settings_routes.py) and the TS type KeybindAction in the# frontend (jarvis/ui/web/frontend/src/hooks/useHotkey.ts). Keep these layers in@@ -969,9 +964,7 @@ def set_screen_context_settings("""Persist a validated Screen Context patch in one atomic replacement."""unknown = set(values).difference(SCREEN_CONTEXT_SETTING_KEYS)if unknown:- raise ValueError(- f"unknown screen_context setting(s): {sorted(unknown)!r}"- )+ raise ValueError(f"unknown screen_context setting(s): {sorted(unknown)!r}")if not values:returnpath = _ensure_writable_config_path(path)@@ -1253,9 +1246,7 @@ def set_realtime_voice_selection(_atomic_write(path, out)-def migrate_removed_codex_realtime_provider(- *, path: Path = DEFAULT_CONFIG_FILE-) -> bool:+def migrate_removed_codex_realtime_provider(*, path: Path = DEFAULT_CONFIG_FILE) -> bool:"""Route a removed Codex Realtime selection onto the stable composition.The ``codex-subscription-realtime`` adapter was removed 2026-08-10 (the@@ -1287,11 +1278,7 @@ def migrate_removed_codex_realtime_provider(if realtime is None:return Falseslots = ("provider", "fallback_provider", "fallback_provider_2")- pinned = [- slot- for slot in slots- if str(realtime.get(slot) or "").strip() == removed- ]+ pinned = [slot for slot in slots if str(realtime.get(slot) or "").strip() == removed]if not pinned:return False@@ -1351,9 +1338,7 @@ def set_silence_window_ms(ms: int, *, path: Path = DEFAULT_CONFIG_FILE) -> None:_patch_table(path, "speech", "vad_silence_ms", clamped)-def set_session_idle_timeout_s(- seconds: float, *, path: Path = DEFAULT_CONFIG_FILE-) -> None:+def set_session_idle_timeout_s(seconds: float, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Persist ``[trigger] session_idle_timeout_s`` — the conversation-mode idleauto-hangup window.@@ -1401,9 +1386,7 @@ def set_bar_size_scale(scale: float, *, path: Path = DEFAULT_CONFIG_FILE) -> Non_patch_table(path, "ui", "bar_size_scale", max(0.5, min(2.0, f)))-def set_bar_follow_cursor_monitor(- enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE-) -> None:+def set_bar_follow_cursor_monitor(enabled: bool, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Persist ``[ui] bar_follow_cursor_monitor`` (the 'follow the mouse to theactive monitor' toggle).@@ -2325,9 +2308,7 @@ def clear_ollama_model_options(path = _ensure_writable_config_path(path)with _WRITE_LOCK:doc, had_bom = _read_doc(path)- models = (- (doc.get("brain") or {}).get("providers", {}).get(provider, {}).get("models")- )+ models = (doc.get("brain") or {}).get("providers", {}).get(provider, {}).get("models")if models is None or tag not in models:return Falsedel models[tag]@@ -2424,9 +2405,7 @@ def set_local_realtime_launch_command(_atomic_write(path, out)-def _command_references_root(- command: str, root: str, *, windows: bool | None = None-) -> bool:+def _command_references_root(command: str, root: str, *, windows: bool | None = None) -> bool:"""Whether a launch command points into the given directory.Separator-normalized on every platform; case-INSENSITIVE only on@@ -2816,7 +2795,7 @@ def _strip_persona_name(path: Path) -> None:raw = path.read_text(encoding="utf-8")had_bom = raw.startswith(_BOM)if had_bom:- raw = raw[len(_BOM):]+ raw = raw[len(_BOM) :]doc: TOMLDocument = tomlkit.parse(raw)persona = doc.get("persona")if persona is None or "name" not in persona:@@ -3063,7 +3042,9 @@ def _sync_computer_use_provider_drift_soll(name: str) -> None: # i18n-allow_update_config_soll_computer_use_provider(name) # i18n-allowexcept Exception as exc: # noqa: BLE001 — best-effort, must not propagatelog.warning(- "Could not sync computer_use provider to config-soll.json: %s", exc # i18n-allow+ "Could not sync computer_use provider to " # i18n-allow: literal filename+ "config-soll.json: %s", # i18n-allow: literal filename+ exc,)try: