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
chore: auto-save WIP via Claude stop-hook safety net (2026-07-08 18:26)
Ruben Lütke157a1b209823
diff --git a/jarvis/brain/manager.py b/jarvis/brain/manager.pyindex 8d4f4aa935..21d28cb2ea 100644--- a/jarvis/brain/manager.py+++ b/jarvis/brain/manager.py@@ -2237,6 +2237,24 @@ class BrainManager:or get_tier_default_model("router", name))+ def _cu_provider(self) -> str:+ """The dedicated GLOBAL Computer-Use planner provider, or ``""``.++ Reads ``[brain.computer_use].provider`` FRESH per call (like+ ``_cu_model``), so an in-memory switch (``/api/computer-use/switch``)+ takes effect on the very next CU dispatch. ``""`` means "not+ configured" — the CU-only dispatch hoist in+ ``jarvis.cu.brain_call.call_vision_brain`` then leaves the fallback+ chain untouched (CU keeps running on ``brain.primary``, current+ behavior). Never raises (getattr-chain safe): a config hiccup must+ not break Computer-Use dispatch (AP-21/22).+ """+ try:+ cu_cfg = getattr(self._config.brain, "computer_use", None)+ return (getattr(cu_cfg, "provider", None) or "").strip()+ except Exception: # noqa: BLE001 — config hiccup must not block dispatch+ return ""+def _get_brain(self, name: str, model: str | None = None) -> Brain:"""Retrieves a Brain instance from the cache, or builds a new one."""key = (name, model)diff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex 11cbbc9191..208b39698a 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -770,6 +770,13 @@ class BrainConfig(BaseModel):# None until the user opts into realtime voice. Reuses BrainTierConfig so the# fallback shape matches [brain.router]/[brain.worker].realtime: BrainTierConfig | None = None+ # Dedicated GLOBAL Computer-Use planner provider — decoupled from+ # ``primary`` (see docs plan "dedicated Computer-Use provider"). None+ # until the user picks one; ``BrainManager._cu_provider`` then returns+ # "" and Computer-Use keeps dispatching through the normal fallback+ # chain (``primary`` first), so this is fully backward-compatible.+ # Reuses BrainTierConfig, same shape as [brain.worker]/[brain.realtime].+ computer_use: BrainTierConfig | None = None# User-facing reply language pin (desktop "Languages" view → Reply Language).# "auto" mirrors the user's input language (DE/EN/ES); "de"/"en"/"es" force# that language as a hard rule for every Jarvis reply. Consumed bydiff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.pyindex 66eadb53b6..c3ef575c7a 100644--- a/jarvis/core/config_writer.py+++ b/jarvis/core/config_writer.py@@ -52,6 +52,11 @@ _WORKER_MODEL_ENV = "JARVIS__BRAIN__WORKER__MODEL"_SUB_JARVIS_PROVIDER_ENV = _WORKER_PROVIDER_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+# from ``[brain] primary``. Same shape as ``_WORKER_PROVIDER_ENV``.+_CU_PROVIDER_ENV = "JARVIS__BRAIN__COMPUTER_USE__PROVIDER"+# Canonical User-scope ENV vars that override ``[tts] provider`` / ``[stt]# provider`` at boot. Both section + key are single words, so# ``_apply_env_overrides`` maps them cleanly to ``tts.provider`` / ``stt.provider``.@@ -126,6 +131,41 @@ def set_worker_provider(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:set_sub_jarvis_provider = set_worker_provider+def set_computer_use_provider(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:+ """Set ``[brain.computer_use] provider`` (the dedicated GLOBAL+ Computer-Use planner provider) across all persistence layers.++ This is the AUTHORITATIVE writer for the user's Computer-Use-provider+ choice and the write-side counterpart to the read-side resolution in+ ``jarvis.brain.manager.BrainManager._cu_provider`` (consumed by+ ``jarvis.cu.brain_call.call_vision_brain``'s dispatch hoist). The CU+ provider is GLOBAL — one engine for both Realtime and Pipeline voice —+ and is decoupled from ``[brain] primary`` (a new tier field, same shape+ as ``[brain.worker]``/``[brain.realtime]``).++ Mirrors :func:`set_worker_provider` exactly (same 3-layer + drift-guard+ rationale — a TOML-only write would be reverted by the drift-guard+ within minutes):++ 1. ``jarvis.toml`` ``[brain.computer_use] provider`` (TOML)+ 2. ``scripts/config-soll.json`` ``brain.computer_use.provider`` (drift-soll) # i18n-allow+ 3. ``JARVIS__BRAIN__COMPUTER_USE__PROVIDER`` User-scope ENV var (boot override)++ Raises ``FileNotFoundError`` if the TOML config file does not exist. Layers+ 2 + 3 are best-effort cloud-first enhancements: graceful no-op on a+ headless Linux VPS and never raise out of this function nor break the+ TOML write.++ NB: this writes only ``provider``. The fallback chain+ (``fallback_provider`` etc.) is left untouched, mirroring+ :func:`set_worker_provider`.+ """+ # Layer 1 — universal, runs on every platform. May raise FileNotFoundError.+ _patch_computer_use_provider_toml(path, name)+ # Layers 2 + 3 — best-effort, never raise.+ _sync_computer_use_provider_drift_soll(name) # i18n-allow++def set_worker_model(model: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:"""Set ``[brain.worker] model`` (the dedicated Jarvis-Agent LLM override)across all persistence layers.@@ -1308,6 +1348,40 @@ def _patch_realtime_provider_toml(path: Path, name: str) -> None:_atomic_write(path, out)+def _patch_computer_use_provider_toml(path: Path, name: str) -> None:+ """Set ``[brain.computer_use] provider = name`` in the TOML.++ Walks the NESTED ``brain`` -> ``computer_use`` path (like+ :func:`_patch_worker_provider_toml` / :func:`_patch_realtime_provider_toml`)+ instead of treating ``"brain.computer_use"`` as a flat top-level key.+ Creates either level if missing. Preserves comments, sibling keys, and+ the optional BOM.+ """+ path = _ensure_writable_config_path(path)++ with _WRITE_LOCK:+ raw = path.read_text(encoding="utf-8")+ had_bom = raw.startswith(_BOM)+ if had_bom:+ raw = raw[len(_BOM) :]+ doc: TOMLDocument = tomlkit.parse(raw)++ brain = doc.get("brain")+ if brain is None:+ brain = tomlkit.table()+ doc["brain"] = brain+ cu = brain.get("computer_use")+ if cu is None:+ cu = tomlkit.table()+ brain["computer_use"] = cu+ cu["provider"] = name++ out = tomlkit.dumps(doc)+ if had_bom:+ out = _BOM + out+ _atomic_write(path, out)++def _patch_worker_key_toml(path: Path, key: str, value: object) -> None:"""Set one key under the nested ``[brain.worker]`` table.@@ -1500,6 +1574,30 @@ def _sync_worker_provider_drift_soll(name: str) -> None: # i18n-allow)+def _sync_computer_use_provider_drift_soll(name: str) -> None: # i18n-allow+ """Best-effort sync of ``brain.computer_use.provider`` into config-soll + # i18n-allow+ ENV.++ NEVER raises and NEVER breaks the (already-completed) TOML write. Same+ two-step shape as :func:`_sync_worker_provider_drift_soll`.+ """+ try:+ _update_config_soll_computer_use_provider(name) # i18n-allow+ except Exception as exc: # noqa: BLE001 — best-effort, must not propagate+ log.warning(+ "Could not sync computer_use provider to config-soll.json: %s", exc # i18n-allow+ )++ try:+ _set_user_env_var(_CU_PROVIDER_ENV, name)+ except Exception as exc: # noqa: BLE001 — best-effort, must not propagate+ log.warning(+ "Could not sync %s to the User environment: %s",+ _CU_PROVIDER_ENV,+ exc,+ )++def _sync_worker_model_drift_soll(model: str) -> None: # i18n-allow"""Best-effort sync of ``brain.worker.model`` into config-soll + ENV. # i18n-allow@@ -1684,6 +1782,35 @@ def _update_config_soll_worker_provider(name: str) -> None: # i18n-allow_atomic_write_text(soll_path, out) # i18n-allow+def _update_config_soll_computer_use_provider(name: str) -> None: # i18n-allow+ """Atomically set ``data["brain.computer_use"]["provider"] = name`` in+ config-soll.json. # i18n-allow++ Note the FLAT dotted key ``"brain.computer_use"`` — same layout as+ ``"brain.worker"`` (see :func:`_update_config_soll_worker_provider`), NOT+ a nested ``data["brain"]["computer_use"]``. Preserves all other keys.+ Graceful no-op when the file is absent.+ """+ soll_path = _config_soll_path() # i18n-allow+ if not soll_path.exists(): # i18n-allow+ log.debug("config-soll.json absent (%s) — skipping drift-soll sync", soll_path) # i18n-allow+ return++ with _WRITE_LOCK:+ raw = soll_path.read_text(encoding="utf-8") # i18n-allow+ data = json.loads(raw)+ block = data.get("brain.computer_use")+ if not isinstance(block, dict):+ block = {}+ data["brain.computer_use"] = block+ if block.get("provider") == name:+ return # already in sync — avoid a needless rewrite+ block["provider"] = name++ out = json.dumps(data, indent=2, ensure_ascii=False) + "\n"+ _atomic_write_text(soll_path, out) # i18n-allow++def _update_config_soll_worker_key(key: str, value: str) -> None: # i18n-allow"""Atomically set ``data["brain.worker"][key] = value`` in config-soll.json. # i18n-allowdiff --git a/jarvis/cu/brain_call.py b/jarvis/cu/brain_call.pyindex 6ecaeef3eb..e7cb151d21 100644--- a/jarvis/cu/brain_call.py+++ b/jarvis/cu/brain_call.py@@ -204,6 +204,24 @@ async def call_vision_brain(if not chain:raise CUBrainCallError("BrainManager fallback chain is empty")+ # Dedicated GLOBAL Computer-Use provider (decoupled from brain.primary).+ # When the user has picked one ([brain.computer_use].provider), hoist it+ # to the HEAD of the chain so it is tried first; everything downstream —+ # the cu_model pin loop below, the speed tune, and the vision/health gate+ # in ComputerUsePlannerSelector — still applies to it, so a blind/dead+ # pick degrades through the rest of the chain instead of bricking CU+ # (AP-21/22). CU-ONLY: never touches ``_build_fallback_chain`` itself,+ # whose "fast" level is shared with normal voice/chat turns.+ cu_provider_fn = getattr(manager, "_cu_provider", None)+ if callable(cu_provider_fn):+ try:+ cu_provider = cu_provider_fn()+ except Exception: # noqa: BLE001 — resolver must never break dispatch+ cu_provider = ""+ if cu_provider:+ chain = [(p, m) for p, m in chain if p != cu_provider]+ chain.insert(0, (cu_provider, None))+# Per-provider CU model override (Settings can pin a dedicated CU model).# A PIN is the user's explicit word and is never second-guessed; every# unpinned candidate is speed-tuned below. CRITICAL: pin detection readsdiff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex 91db6a0ec6..d41027d3ef 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -9,6 +9,7 @@ Endpoints:POST /api/stt/switch → aktiven STT-Provider wechseln (persist in jarvis.toml)POST /api/realtime/switch → aktiven Realtime-Provider wechseln (persist)POST /api/subagent/switch → aktiven Subagent-Provider wechseln (3-layer persist)+ POST /api/computer-use/switch → switch the dedicated GLOBAL Computer-Use planner provider (3-layer persist)Wird vom WebServer in `_build_app()` eingehängt:from .provider_routes import router as provider_router@@ -276,6 +277,7 @@ def _spec_to_payload(active_tts: str | None,active_stt: str | None,active_realtime: str | None = None,+ active_computer_use: str | None = None,) -> dict[str, Any]:if spec.tier == "brain":active = spec.id == active_brain@@ -340,6 +342,13 @@ def _spec_to_payload(),"active": active,"cli_installed": _cli_installed(spec),+ # Overlay, not a new tier (see the CU-own-provider plan): a brain+ # provider can be BOTH the main Brain ("active") AND/OR the dedicated+ # Computer-Use planner ("computer_use_active") — the two selections+ # are independent, so this never touches "active" above.+ "computer_use_active": (+ spec.tier == "brain" and spec.id == active_computer_use+ ),}if antigravity_status is not None:payload["antigravity_status"] = antigravity_status@@ -431,6 +440,29 @@ def _active_realtime(request: Request) -> str | None:return "openai-realtime"+def _active_computer_use(request: Request) -> str | None:+ """The active dedicated Computer-Use planner provider.++ Falls back to ``brain.primary`` when no dedicated+ ``[brain.computer_use].provider`` is configured yet — Computer-Use runs+ on the main Brain until the user picks a dedicated CU provider (mirrors+ ``BrainManager._cu_provider``'s empty-string-means-unset default, so the+ "Active" badge and the actual dispatch chain always agree). Never raises:+ any resolver error falls back to ``None``.+ """+ try:+ cfg = _resolve_cfg(request)+ brain_cfg = getattr(cfg, "brain", None)+ cu_cfg = getattr(brain_cfg, "computer_use", None)+ provider = (getattr(cu_cfg, "provider", None) or "").strip()+ if provider:+ return provider+ return (getattr(brain_cfg, "primary", None) or "").strip() or None+ except Exception as exc: # noqa: BLE001 — the health panel must never 500+ log.debug("active-computer-use resolution failed (%s); using None.", exc)+ return None++def _resolve_cfg(request: Request):"""Liefert die JarvisConfig.@@ -533,6 +565,7 @@ async def list_providers(request: Request) -> dict[str, Any]:active_tts = _active_tts(request)active_stt = _active_stt(request)active_realtime = _active_realtime(request)+ active_computer_use = _active_computer_use(request)providers = [_spec_to_payload(@@ -541,6 +574,7 @@ async def list_providers(request: Request) -> dict[str, Any]:active_tts=active_tts,active_stt=active_stt,active_realtime=active_realtime,+ active_computer_use=active_computer_use,)for spec in PROVIDERS]@@ -2050,6 +2084,85 @@ async def realtime_switch(body: SwitchBody, request: Request) -> dict[str, Any]:}[email protected]("/computer-use/switch")+async def computer_use_switch(body: SwitchBody, request: Request) -> dict[str, Any]:+ """Switches the dedicated GLOBAL Computer-Use planner provider.++ Overlay over the brain-tier provider cards (Claude/OpenAI/OpenRouter/+ Gemini), not a new provider tier — mirrors how ``[brain.worker]`` is a+ separate selection over the same brain ids+ (see ``jarvis_agent_switch``), but simpler: the CU planner can only be a+ brain-switchable brain-tier provider (it must be able to receive+ screenshots), so this reuses the generic ``/api/brain/switch``+ validation style instead of the worker route's Codex-specific branch.++ Persists via ``config_writer.set_computer_use_provider`` (3-layer,+ drift-guarded — a TOML-only write would be reverted within minutes) and+ updates ``cfg.brain.computer_use`` in-memory so the very next+ Computer-Use dispatch (``BrainManager._cu_provider`` ->+ ``jarvis.cu.brain_call.call_vision_brain``'s hoist) uses it live — no+ restart required, unlike the worker/realtime switches.+ """+ spec = get_spec(body.provider)+ if spec is None:+ raise HTTPException(+ status_code=404, detail=f"Unknown provider: {body.provider}"+ )+ if spec.tier != "brain" or not spec.brain_switchable:+ raise HTTPException(+ status_code=400,+ detail=(+ f"Provider '{body.provider}' cannot be the Computer-Use planner "+ f"— it must be a brain-switchable provider that can receive "+ f"screenshots (tier={spec.tier})."+ ),+ )+ if not _is_credential_present(spec):+ raise HTTPException(+ status_code=409,+ detail=(+ f"{spec.label} has no saved API key. Save a key first, "+ "then activate."+ ),+ )++ if body.persist:+ try:+ from jarvis.core.config_writer import set_computer_use_provider++ set_computer_use_provider(body.provider)+ except FileNotFoundError as exc:+ raise HTTPException(status_code=500, detail=str(exc)) from exc+ except Exception as exc: # noqa: BLE001+ raise HTTPException(+ status_code=500, detail=f"TOML write failed: {exc}"+ ) from exc++ cfg = _resolve_cfg(request)+ if cfg is not None and getattr(cfg, "brain", None) is not None:+ try:+ cu_cfg = getattr(cfg.brain, "computer_use", None)+ if cu_cfg is None:+ from jarvis.core.config import BrainTierConfig++ cfg.brain.computer_use = BrainTierConfig(provider=body.provider)+ else:+ cu_cfg.provider = body.provider+ except Exception as exc: # noqa: BLE001 — frozen/detached cfg is not an error+ log.debug("In-memory computer_use.provider update skipped: %s", exc)++ await _emit(+ request, SecretConfigured(key="brain.computer_use.provider", action="set")+ )++ return {+ "ok": True,+ "active": body.provider,+ "persisted": body.persist,+ "restart_required": False,+ }++@router.post("/jarvis-agent/switch")async def jarvis_agent_switch(body: SwitchBody, request: Request) -> dict[str, Any]:"""Wechselt den aktiven SUBAGENT-Provider (``[brain.sub_jarvis].provider``).diff --git a/tests/unit/test_config_writer_computer_use_sync.py b/tests/unit/test_config_writer_computer_use_sync.pynew file mode 100644index 0000000000..1e0c987410--- /dev/null+++ b/tests/unit/test_config_writer_computer_use_sync.py@@ -0,0 +1,179 @@+"""Tests for the three-layer ``[brain.computer_use].provider`` persistence sync.++The dedicated GLOBAL Computer-Use planner provider is decoupled from+``[brain] primary`` (see the "dedicated Computer-Use provider" plan) and is+pinned in config-soll.json (``"brain.computer_use": {"provider": ...}``), so # i18n-allow+a UI switch that writes only the TOML would be rolled back by the drift-guard+within 5 minutes — exactly the bug class that hit ``brain.primary`` before it+became 3-layer. The switch must therefore write ALL THREE layers:++ 1. ``jarvis.toml`` ``[brain.computer_use] provider`` (TOML)+ 2. ``scripts/config-soll.json`` ``brain.computer_use.provider`` (drift-soll) # i18n-allow+ 3. ``JARVIS__BRAIN__COMPUTER_USE__PROVIDER`` User-scope ENV var (boot override)++Layers 2 + 3 are best-effort (cloud-first): graceful no-op on a headless VPS,+never raise out of ``set_computer_use_provider``, never break the TOML write.++Uses TEMP files + monkeypatch only — never touches the live config. Mirrors+``tests/unit/test_config_writer_worker_sync.py`` (the ``[brain.worker]``+sibling this feature copies the shape from).+"""+from __future__ import annotations++import json+from pathlib import Path++import pytest++from jarvis.core import config_writer+++def sample_toml(tmp_path: Path) -> Path:+ p = tmp_path / "jarvis.toml"+ p.write_text(+ """\+# Personal Jarvis config+[brain]+primary = "gemini"++[brain.computer_use]+provider = "claude-api"+""",+ encoding="utf-8",+ )+ return p+++def sample_soll(tmp_path: Path) -> Path: # i18n-allow+ p = tmp_path / "config-soll.json" # i18n-allow+ p.write_text(+ json.dumps(+ {+ "_comment": "do not lose me",+ "_updated": "2026-07-08",+ "brain": {"primary": "gemini"},+ "brain.computer_use": {"provider": "claude-api"},+ "tts": {"provider": "gemini-flash-tts"},+ },+ indent=2,+ ),+ encoding="utf-8",+ )+ return p+++def test_writes_all_three_layers(+ sample_toml: Path, sample_soll: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow+) -> None:+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allow+ env_calls: list[tuple[str, str]] = []+ monkeypatch.setattr(+ config_writer, "_set_user_env_var",+ lambda name, value: env_calls.append((name, value)),+ )++ config_writer.set_computer_use_provider("openai", path=sample_toml)++ # Layer 1: TOML — the [brain.computer_use] block, NOT a top-level key.+ toml_raw = sample_toml.read_text(encoding="utf-8")+ assert "[brain.computer_use]" in toml_raw+ assert 'provider = "openai"' in toml_raw+ # brain.primary must be untouched (CU is decoupled from the main Brain).+ assert 'primary = "gemini"' in toml_raw++ # Layer 2: config-soll.json flat "brain.computer_use" key. # i18n-allow+ soll = json.loads(sample_soll.read_text(encoding="utf-8")) # i18n-allow+ assert soll["brain.computer_use"]["provider"] == "openai" # i18n-allow++ # Layer 3: ENV var.+ assert env_calls == [("JARVIS__BRAIN__COMPUTER_USE__PROVIDER", "openai")]+++def test_toml_preserves_sibling_brain_primary(+ sample_toml: Path, sample_soll: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow+) -> None:+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allow+ monkeypatch.setattr(config_writer, "_set_user_env_var", lambda name, value: None)++ config_writer.set_computer_use_provider("openrouter", path=sample_toml)++ toml_raw = sample_toml.read_text(encoding="utf-8")+ assert 'provider = "openrouter"' in toml_raw+ assert 'primary = "gemini"' in toml_raw+++def test_config_soll_preserves_other_keys( # i18n-allow+ sample_toml: Path, sample_soll: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow+) -> None:+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allow+ monkeypatch.setattr(config_writer, "_set_user_env_var", lambda name, value: None)++ config_writer.set_computer_use_provider("gemini", path=sample_toml)++ soll = json.loads(sample_soll.read_text(encoding="utf-8")) # i18n-allow+ assert soll["brain.computer_use"]["provider"] == "gemini" # i18n-allow+ # Other keys in the block + other tables untouched.+ assert soll["_comment"] == "do not lose me" # i18n-allow+ assert soll["brain"]["primary"] == "gemini" # i18n-allow+ assert soll["tts"]["provider"] == "gemini-flash-tts" # i18n-allow+++def test_creates_computer_use_block_if_missing(+ tmp_path: Path, sample_soll: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow+) -> None:+ """A TOML with [brain] but no [brain.computer_use] gets the block created."""+ toml = tmp_path / "jarvis.toml"+ toml.write_text('[brain]\nprimary = "gemini"\n', encoding="utf-8")+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allow+ monkeypatch.setattr(config_writer, "_set_user_env_var", lambda name, value: None)++ config_writer.set_computer_use_provider("claude-api", path=toml)++ raw = toml.read_text(encoding="utf-8")+ assert "[brain.computer_use]" in raw+ assert 'provider = "claude-api"' in raw+++def test_missing_config_soll_does_not_break_toml( # i18n-allow+ sample_toml: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ nonexistent = tmp_path / "no-such-config-soll.json" # i18n-allow+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: nonexistent) # i18n-allow+ monkeypatch.setattr(config_writer, "_set_user_env_var", lambda name, value: None)++ config_writer.set_computer_use_provider("gemini", path=sample_toml)++ assert 'provider = "gemini"' in sample_toml.read_text(encoding="utf-8")+ assert not nonexistent.exists()+++def test_missing_toml_is_created(+ sample_soll: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow+) -> None:+ """A missing TOML file is auto-created (headless VPS / first-run path)."""+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allow+ monkeypatch.setattr(config_writer, "_set_user_env_var", lambda name, value: None)++ new_toml = tmp_path / "nope.toml"+ assert not new_toml.exists()++ config_writer.set_computer_use_provider("gemini", path=new_toml)++ assert new_toml.exists()+ assert 'provider = "gemini"' in new_toml.read_text(encoding="utf-8")+++def test_updates_live_os_environ(+ sample_toml: Path, sample_soll: Path, monkeypatch: pytest.MonkeyPatch # i18n-allow+) -> None:+ monkeypatch.setattr(config_writer, "_config_soll_path", lambda: sample_soll) # i18n-allow+ monkeypatch.setattr(config_writer, "_set_user_env_var_winreg", lambda name, value: None)+ monkeypatch.delenv("JARVIS__BRAIN__COMPUTER_USE__PROVIDER", raising=False)++ config_writer.set_computer_use_provider("openai", path=sample_toml)++ import os++ assert os.environ.get("JARVIS__BRAIN__COMPUTER_USE__PROVIDER") == "openai"