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(credentials): let Brain tiers read a Realtime-scoped key as last resort
Personal Jarvis Maintainera487bc5167bd
diff --git a/jarvis/brain/ack_brain/providers/gemini.py b/jarvis/brain/ack_brain/providers/gemini.pyindex 3b7583041e..47fe76a3f0 100644--- a/jarvis/brain/ack_brain/providers/gemini.py+++ b/jarvis/brain/ack_brain/providers/gemini.py@@ -31,9 +31,13 @@ class GeminiFlashAck:def _ensure_client(self) -> Any:if self._client is None:+ # The configured slot wins; the family resolver is the fallback so+ # an install whose only Gemini credential lives in another slot of+ # the family (e.g. the Realtime card's scoped key) still gets an+ # ack instead of a silent per-turn failure.api_key = cfg.get_secret(self._config.api_key_secret, env_fallback="GEMINI_API_KEY"- )+ ) or cfg.get_provider_secret("gemini")if not api_key:raise RuntimeError(f"No Gemini API key in keyring/env "diff --git a/jarvis/brain/ack_brain/providers/grok.py b/jarvis/brain/ack_brain/providers/grok.pyindex 86a282a8aa..29cfa1171d 100644--- a/jarvis/brain/ack_brain/providers/grok.py+++ b/jarvis/brain/ack_brain/providers/grok.py@@ -31,9 +31,12 @@ class GrokFlashAck:def _ensure_client(self) -> Any:if self._client is None:+ # Configured slot first, family resolver as last resort — mirrors+ # the Gemini adapter (grok has no realtime slot, but the resolver+ # also covers the xai_api_key alias).api_key = cfg.get_secret(self._config.api_key_secret, env_fallback="GROK_API_KEY"- )+ ) or cfg.get_provider_secret("grok")if not api_key:raise RuntimeError(f"No Grok API key in keyring/env "diff --git a/jarvis/brain/ack_brain/providers/openai.py b/jarvis/brain/ack_brain/providers/openai.pyindex f5243f7d07..f8db65a043 100644--- a/jarvis/brain/ack_brain/providers/openai.py+++ b/jarvis/brain/ack_brain/providers/openai.py@@ -28,9 +28,11 @@ class OpenAIMiniAck:def _ensure_client(self) -> Any:if self._client is None:+ # Configured slot first, family resolver (incl. the Realtime+ # card's scoped key) as last resort — mirrors the Gemini adapter.api_key = cfg.get_secret(self._config.api_key_secret, env_fallback="OPENAI_API_KEY"- )+ ) or cfg.get_provider_secret("openai")if not api_key:raise RuntimeError(f"No OpenAI API key in keyring/env "diff --git a/jarvis/brain/factory.py b/jarvis/brain/factory.pyindex d23770f814..d66dc28410 100644--- a/jarvis/brain/factory.py+++ b/jarvis/brain/factory.py@@ -1777,14 +1777,22 @@ def _pick_keyed_flash_fallback(ack_cfg: Any) -> str | None:(local Ollama) needs no credential and is always considered usable."""from jarvis.brain.ack_brain.providers import REGISTRY- from jarvis.core.config import get_secret+ from jarvis.core.config import get_provider_secret, get_secretfor name in REGISTRY:provider_cfg = getattr(ack_cfg.providers, name, None)if provider_cfg is None:continuesecret_name = getattr(provider_cfg, "api_key_secret", None)- if secret_name is None or get_secret(secret_name):+ # The family resolver is the second probe so a credential that lives+ # only in a scoped slot of the same family (e.g. the Realtime card's+ # key) still marks the provider usable — the adapters resolve their+ # key through the same two-step lookup.+ if (+ secret_name is None+ or get_secret(secret_name)+ or get_provider_secret(name)+ ):return namereturn Nonediff --git a/jarvis/core/config.py b/jarvis/core/config.pyindex f33b613143..5df7b097e6 100644--- a/jarvis/core/config.py+++ b/jarvis/core/config.py@@ -131,7 +131,13 @@ KEYRING_SERVICE = KEYRING_SERVICE_NAME# provider is configured.PROVIDER_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {"claude-api": (("anthropic_api_key", "ANTHROPIC_API_KEY"),),- "openai": (("openai_api_key", "OPENAI_API_KEY"),),+ # The trailing realtime slot is a LAST-RESORT cross-read for single-key+ # installs (see the comment above "openai-realtime" below); the generic+ # slot always wins when both exist.+ "openai": (+ ("openai_api_key", "OPENAI_API_KEY"),+ ("realtime_openai_api_key", "JARVIS_REALTIME_OPENAI_API_KEY"),+ ),# Codex-as-brain uses its own key slot, falling back to the general OpenAI key."codex": (("codex_openai_api_key", "OPENAI_API_KEY"),@@ -148,15 +154,23 @@ PROVIDER_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {("gemini_api_key", "GEMINI_API_KEY"),("google_aistudio_api_key", "GOOGLE_AIStudio_API_KEY"),("google_api_key", "GOOGLE_API_KEY"),+ ("realtime_gemini_api_key", "JARVIS_REALTIME_GEMINI_API_KEY"),),"grok": (("grok_api_key", "GROK_API_KEY"),("xai_api_key", "XAI_API_KEY"),),# Realtime owns dedicated slots. The generic family slots remain trailing- # read-only compatibility fallbacks for upgraded installations; a key saved- # from the Realtime card is therefore never visible to Brain or Jarvis-Agent- # resolution.+ # read-only compatibility fallbacks for upgraded installations. The reverse+ # direction exists too (see the trailing realtime slots on "openai" and+ # "gemini" above): a user whose ONLY credential was saved from the Realtime+ # card must still get a working Brain/Tool-Model of the same family — the+ # strict one-way scoping bricked every delegated deep turn on such an+ # install ("Kein Brain-Key gefunden" while # i18n-allow: quoted diagnostic+ # Gemini-Live answered smalltalk, Mac forensic 2026-07-21). Precedence is+ # unchanged whenever a generic family key exists: dedicated slots win on+ # their own surface, generic slots win for Brain, and the cross-read only+ # fires as last resort."openai-realtime": (("realtime_openai_api_key", "JARVIS_REALTIME_OPENAI_API_KEY"),("openai_api_key", "OPENAI_API_KEY"),@@ -174,7 +188,10 @@ PROVIDER_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {# Jarvis-Agent API credentials are independently replaceable from the Agent# tab. Generic provider slots remain a final compatibility fallback so existing# installations keep working, but scoped Agent keys always win and are never-# consumed by Brain or Realtime.+# consumed by Brain or Realtime. (Because these tuples splice the family+# candidates, a realtime-only key reaches the Agent tier through the same+# last-resort cross-read as the Brain tier — intentional: a single-key+# install must never brick a core path.)JARVIS_AGENT_SECRET_CANDIDATES: dict[str, tuple[tuple[str, str], ...]] = {"claude-api": (("jarvis_agent_anthropic_api_key", "JARVIS_AGENT_ANTHROPIC_API_KEY"),@@ -3070,7 +3087,8 @@ def get_jarvis_agent_secret(provider: str) -> str | None:"""Return the effective API key for one Jarvis-Agent provider.A dedicated Agent slot wins. Generic provider credentials are read only as- an upgrade compatibility fallback; Realtime-only slots are never candidates.+ an upgrade compatibility fallback; a Realtime-scoped key of the same family+ is the last resort (single-key installs must not brick the Agent tier).OAuth-backed Agent providers keep resolving their login separately."""candidates = JARVIS_AGENT_SECRET_CANDIDATES.get(provider, ())diff --git a/tests/unit/brain/test_ack_brain/test_flash_provider_fallback.py b/tests/unit/brain/test_ack_brain/test_flash_provider_fallback.pyindex 0027e5f283..1543ee17d9 100644--- a/tests/unit/brain/test_ack_brain/test_flash_provider_fallback.py+++ b/tests/unit/brain/test_ack_brain/test_flash_provider_fallback.py@@ -53,6 +53,25 @@ def test_falls_back_to_gemini_when_only_gemini_key_present(assert type(provider).__name__ == "GeminiFlashAck"+def test_falls_back_to_gemini_when_only_a_realtime_scoped_key_present(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """A single-key install whose only credential came from the Realtime card+ must still resolve the Flash tier to that family (2026-07-21 Mac forensic:+ the strict slot scoping bricked every non-realtime brain tier)."""++ def _fake_get_secret(key: str, env_fallback: str | None = None) -> str | None:+ return "rt-test" if key == "realtime_gemini_api_key" else None++ monkeypatch.setattr("jarvis.core.config.get_secret", _fake_get_secret)++ ack_cfg = make_ack_config(provider="follow_brain")+ provider = _build_flash_provider(_jcfg(brain_primary="claude-api"), ack_cfg)++ assert ack_cfg.provider == "gemini"+ assert type(provider).__name__ == "GeminiFlashAck"++def test_falls_back_to_ollama_when_no_key_present_at_all(monkeypatch: pytest.MonkeyPatch,) -> None:diff --git a/tests/unit/core/test_scoped_provider_credentials.py b/tests/unit/core/test_scoped_provider_credentials.pyindex 18db6fab4f..b84a294e6e 100644--- a/tests/unit/core/test_scoped_provider_credentials.py+++ b/tests/unit/core/test_scoped_provider_credentials.py@@ -23,13 +23,21 @@ def _secret_reader(values: dict[str, str]):("gemini", "jarvis_agent_gemini_api_key", "gemini-live", "realtime_gemini_api_key"),],)-def test_scoped_keys_do_not_cross_between_agent_realtime_and_brain(+def test_scoped_keys_keep_precedence_but_brain_reads_realtime_last(monkeypatch: pytest.MonkeyPatch,provider: str,agent_slot: str,realtime_provider: str,realtime_slot: str,) -> None:+ """Dedicated slots win on their surface; Brain cross-reads only last-resort.++ 2026-07-21 Mac forensic: an install whose ONLY credential was saved from+ the Realtime card had a fully working Gemini-Live session while every+ delegated Brain/Tool-Model turn failed with the spoken provider-down+ phrase. The Brain family therefore reads the Realtime-scoped key as a+ trailing fallback — never ahead of a generic family key.+ """monkeypatch.setattr(cfg,"get_secret",@@ -38,7 +46,53 @@ def test_scoped_keys_do_not_cross_between_agent_realtime_and_brain(assert cfg.get_jarvis_agent_secret(provider) == "agent-key"assert cfg.get_provider_secret(realtime_provider) == "realtime-key"- assert cfg.get_provider_secret(provider) is None+ assert cfg.get_provider_secret(provider) == "realtime-key"+++ ("provider", "generic_slot", "realtime_slot"),+ [+ ("openai", "openai_api_key", "realtime_openai_api_key"),+ ("gemini", "gemini_api_key", "realtime_gemini_api_key"),+ ],+)+def test_generic_brain_key_wins_over_realtime_scoped_key(+ monkeypatch: pytest.MonkeyPatch,+ provider: str,+ generic_slot: str,+ realtime_slot: str,+) -> None:+ monkeypatch.setattr(+ cfg,+ "get_secret",+ _secret_reader(+ {generic_slot: "generic-key", realtime_slot: "realtime-key"}+ ),+ )++ assert cfg.get_provider_secret(provider) == "generic-key"+++ ("provider", "realtime_slot"),+ [+ ("openai", "realtime_openai_api_key"),+ ("gemini", "realtime_gemini_api_key"),+ ],+)+def test_realtime_only_install_still_gets_a_brain_key(+ monkeypatch: pytest.MonkeyPatch,+ provider: str,+ realtime_slot: str,+) -> None:+ monkeypatch.setattr(+ cfg,+ "get_secret",+ _secret_reader({realtime_slot: "realtime-key"}),+ )++ assert cfg.get_provider_secret(provider) == "realtime-key"+ assert cfg.get_jarvis_agent_secret(provider) == "realtime-key"def test_agent_and_realtime_keep_generic_keys_as_upgrade_fallback(diff --git a/tests/unit/plugins/tts/test_realtime_surface_tts.py b/tests/unit/plugins/tts/test_realtime_surface_tts.pyindex 2bc1fdfeb1..04292db4e9 100644--- a/tests/unit/plugins/tts/test_realtime_surface_tts.py+++ b/tests/unit/plugins/tts/test_realtime_surface_tts.py@@ -176,16 +176,24 @@ def test_pipeline_tts_credential_map_lists_no_realtime_slots() -> None:)-def test_realtime_slots_exist_only_under_realtime_provider_ids() -> None:- """Static guard: dedicated realtime slots live ONLY under the realtime- provider ids, so brain / Jarvis-Agent / pipeline resolution (which key off- their own family ids) can structurally never reach them."""+def test_realtime_slots_are_only_trailing_fallbacks_outside_realtime_ids() -> None:+ """Static guard: outside the realtime provider ids, a dedicated realtime+ slot may appear ONLY as the last (trailing) candidate of its family.++ The trailing cross-read is deliberate (2026-07-21 Mac forensic: an install+ whose only key came from the Realtime card had every delegated Brain turn+ brick on "Kein Brain-Key gefunden"), # i18n-allow: quoted log diagnostic+ but it must never outrank a generic+ family key — and pipeline TTS keeps its own realtime-free candidate table+ (guarded above)."""for provider, candidates in PROVIDER_SECRET_CANDIDATES.items():- for keyring_key, _env in candidates:+ if provider in _REALTIME_PROVIDER_IDS:+ continue+ for position, (keyring_key, _env) in enumerate(candidates):if keyring_key.startswith("realtime_"):- assert provider in _REALTIME_PROVIDER_IDS, (- f"realtime slot {keyring_key!r} leaked into provider "- f"{provider!r}"+ assert position == len(candidates) - 1, (+ f"realtime slot {keyring_key!r} must be the LAST candidate "+ f"of provider {provider!r}, found at index {position}")