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
feat(providers): local providers in agents/critic/airgapped/resolver/tool-model
Ruben Lütke0067b93cb062
diff --git a/jarvis/brain/app_control.py b/jarvis/brain/app_control.pyindex e4cb9b0dc6..662e8fe632 100644--- a/jarvis/brain/app_control.py+++ b/jarvis/brain/app_control.py@@ -66,14 +66,19 @@ def get_spec(provider_id: str) -> Any:SWITCHABLE_TIERS: frozenset[str] = frozenset({"brain", "tts", "stt", "subagent"})# Local providers allowed to stay active in the airgapped privacy profile.-# Empty since v1.0.1: Ollama was removed 2026-04-21, and the local-# "faster-whisper" STT dictation provider was removed from the user-selectable-# catalog (see provider_spec.py). With no local provider left, the airgapped-# profile admits no provider switch — an honest state, not a regression:-# airgapped means "local only", and there is currently no local provider to-# switch TO. (Wake still runs its own local Whisper off this list.) Lives HERE-# (not in provider_routes) so every switch path shares the one lock.-LOCAL_PROVIDERS: frozenset[str] = frozenset()+# SPEC-DERIVED since 2026-07-25 (local-first mandate): every provider card+# declaring ``auth_mode == "none"`` is local by definition — ollama and+# local-openai today, future local STT/TTS cards automatically — never a+# hand-maintained name list (AP-21/22). (Wake still runs its own local+# Whisper off this list.) Lives HERE (not in provider_routes) so every+# switch path shares the one lock.+def _spec_local_providers() -> frozenset[str]:+ from jarvis.ui.web.provider_spec import PROVIDERS++ return frozenset(s.id for s in PROVIDERS if s.auth_mode == "none")+++LOCAL_PROVIDERS: frozenset[str] = _spec_local_providers()# Maps a provider id to the credential-manager *provider slot* used by# ``cfg.get_provider_secret`` — needed where one key backs several provider ids@@ -99,12 +104,11 @@ AUTH_PROVIDER_ALIASES: dict[str, str] = {"codex": "codex",}-# Local providers that need no credential at all. Empty since v1.0.1: the only-# entry, the local "faster-whisper" STT dictation provider, was removed from the-# user-selectable catalog (see provider_spec.py). is_credential_present() still-# reports auth_mode=="none" providers as configured, so a future local provider-# needs no change here.-_NO_CREDENTIAL_PROVIDERS: frozenset[str] = frozenset()+# 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+# configured, so the two can never disagree.+_NO_CREDENTIAL_PROVIDERS: frozenset[str] = LOCAL_PROVIDERS# A stored secret must be at least this long before we reveal a 3+3 preview.# Below it, 6 revealed characters would expose too large a fraction of the key,diff --git a/jarvis/brain/resolver.py b/jarvis/brain/resolver.pyindex e5a887ee92..468602915a 100644--- a/jarvis/brain/resolver.py+++ b/jarvis/brain/resolver.py@@ -227,6 +227,15 @@ def _resolve_chain(config: JarvisConfig) -> list[tuple[str, str | None]]:_reachable_keyed_families(config, exclude=frozenset(chain_providers)),)+ # Stage 6 — keyless local tail (local-first mandate 2026-07-25): the+ # registered local brains (spec-declared auth_mode "none": ollama,+ # local-openai) close the chain, so a ZERO-key install still lands every+ # background resolve on its own hardware. Deliberately AFTER the keyed+ # families — a cloud family the user set up stays preferred, and a dead+ # local server just fast-fails on its 2 s connect timeout.+ chain_providers = {provider for provider, _ in chain}+ chain.extend(_local_tail(config, exclude=frozenset(chain_providers)))+# Filter duplicates while preserving orderseen: set[tuple[str, str | None]] = set()deduped: list[tuple[str, str | None]] = []@@ -321,6 +330,30 @@ def _reachable_keyed_families(return tail+def _local_tail(+ config: JarvisConfig, *, exclude: frozenset[str] = frozenset(),+) -> list[tuple[str, str | None]]:+ """Keyless local brains as the chain's last resort (local-first mandate).++ Membership is SPEC-driven — every registered brain provider whose card+ declares ``auth_mode == "none"`` in ``jarvis.ui.web.provider_spec`` —+ never a hardcoded name list (AP-21/22). Card order is preserved.+ OAuth-subscription brains (codex/antigravity) declare their own auth+ modes and can never leak in here.+ """+ from jarvis.ui.web.provider_spec import PROVIDERS++ available = set(_get_registry().available())+ tail: list[tuple[str, str | None]] = []+ for spec in PROVIDERS:+ if spec.tier != "brain" or spec.auth_mode != "none":+ continue+ if spec.id in exclude or spec.id not in available:+ continue+ tail.append((spec.id, _deep_model_for(config, spec.id)))+ return tail++# ----------------------------------------------------------------------# Test-Hooks# ----------------------------------------------------------------------diff --git a/jarvis/missions/critic/runner.py b/jarvis/missions/critic/runner.pyindex a4b9c550a0..bc608978f1 100644--- a/jarvis/missions/critic/runner.py+++ b/jarvis/missions/critic/runner.py@@ -2190,7 +2190,10 @@ def _resolve_critic_provider_model() -> tuple[str | None, str | None]:# API-key brain providers that can grade IN-PROCESS via their own BrainProvider-# (no external CLI). Order = the cross-family fallback preference.+# (no external CLI). Order = the cross-family fallback preference. The keyless+# local providers close the list (2026-07-25): a zero-key install gets a local+# critic instead of NO critic, while any funded cloud family stays preferred+# (small local models grade worse than frontier models — last resort only)._API_CRITIC_PROVIDERS: tuple[str, ...] = ("openrouter","openai",@@ -2198,6 +2201,8 @@ _API_CRITIC_PROVIDERS: tuple[str, ...] = ("claude-api","grok","nvidia",+ "ollama",+ "local-openai",)diff --git a/jarvis/missions/init.py b/jarvis/missions/init.pyindex 7c9ef82aea..35a82deb20 100644--- a/jarvis/missions/init.py+++ b/jarvis/missions/init.py@@ -83,8 +83,10 @@ def _spawn_boot_cleanup(coro: Any, *, name: str) -> asyncio.Task[Any]:# ApiAgentWorker (OpenAI-compatible chat API + tool-use loop), instead of the# legacy silent ClaudeDirectWorker fallback. Single source for the routing# decision so the UI "runs on Claude" badge can never drift from reality.+# ollama/local-openai (2026-07-25): keyless local servers, same in-process+# tool-loop path — a mission can run fully on the user's own hardware._API_AGENT_SLUGS: frozenset[str] = frozenset(- {"openai", "openrouter", "grok", "nvidia"}+ {"openai", "openrouter", "grok", "nvidia", "ollama", "local-openai"})@@ -573,8 +575,18 @@ def _api_key_family_viable(provider: str) -> bool:worker already proved dead this session (fingerprinted) is skipped untilit changes."""+ from jarvis.brain.app_control import LOCAL_PROVIDERSfrom jarvis.core.config import get_jarvis_agent_secret+ if provider in LOCAL_PROVIDERS:+ # Keyless local family (spec-declared auth_mode "none"): no credential+ # can exist, so viability is reachability — a dead server fast-fails+ # at call time (2 s connect) and the walk moves on. The quota cooldown+ # still applies when a run just proved the server down.+ from jarvis.api_family_quota_state import api_family_in_cooldown++ return not api_family_in_cooldown(provider)+key = get_jarvis_agent_secret(provider)if not key:return Falsediff --git a/jarvis/missions/worker_runtime/provider_map.py b/jarvis/missions/worker_runtime/provider_map.pyindex 7b152fdf74..fa71d47dcf 100644--- a/jarvis/missions/worker_runtime/provider_map.py+++ b/jarvis/missions/worker_runtime/provider_map.py@@ -119,6 +119,14 @@ MAPPINGS: Final[tuple[ProviderMapping, ...]] = (# selectable subagent in the API-Keys "Subagents" tab and env/slug lookups# stay consistent.ProviderMapping("nvidia", "nvidia", "NVIDIA_API_KEY"),+ # Keyless local providers (2026-07-25, local-first mandate): both run+ # through the in-process ApiAgentWorker like nvidia — the row exists so+ # they are selectable in the Agents tab. The env vars are credential-shaped+ # PLACEHOLDERS only: no Agent key slot exists for them, so+ # get_jarvis_agent_secret returns None and the worker proceeds keyless+ # (the brain plugins supply their own dummy SDK key).+ ProviderMapping("ollama", "ollama", "OLLAMA_API_KEY"),+ ProviderMapping("local-openai", "local-openai", "LOCAL_OPENAI_API_KEY"),)diff --git a/jarvis/missions/workers/api_agent_worker.py b/jarvis/missions/workers/api_agent_worker.pyindex ffaa8410c6..25c9ddf629 100644--- a/jarvis/missions/workers/api_agent_worker.py+++ b/jarvis/missions/workers/api_agent_worker.py@@ -103,6 +103,12 @@ _BRAIN_BY_PROVIDER: dict[str, tuple[str, str]] = {# (subscription-first) when its binary is present; this is the API fallback."claude-api": ("jarvis.plugins.brain.claude_api", "ClaudeAPIBrain"),"gemini": ("jarvis.plugins.brain.gemini", "GeminiBrain"),+ # Keyless local providers (2026-07-25): same in-process tool loop against+ # the user's own server — heavy missions with zero cloud keys. Keyless is+ # tolerated by design: get_jarvis_agent_secret returns None and the+ # plugins supply their own dummy SDK key.+ "ollama": ("jarvis.plugins.brain.ollama", "OllamaBrain"),+ "local-openai": ("jarvis.plugins.brain.local_openai", "LocalOpenAIBrain"),}# A free OpenRouter model id — the LAST-RESORT default for the gateway providerdiff --git a/tests/unit/brain/test_cu_model_selection.py b/tests/unit/brain/test_cu_model_selection.pyindex d1f8238933..125b87468e 100644--- a/tests/unit/brain/test_cu_model_selection.py+++ b/tests/unit/brain/test_cu_model_selection.py@@ -64,6 +64,10 @@ def test_cu_model_falls_back_to_main_model_when_unset():def test_cu_model_falls_back_to_router_default_for_absent_provider():cfg = load_config()cfg.brain.router = BrainTierConfig(provider="gemini")+ # Hermetic: the HOST config may carry a real [brain.providers.openrouter]+ # block (this box does) — the test's premise is the ABSENT block, so drop+ # it from the loaded copy instead of asserting against live host state.+ cfg.brain.providers.pop("openrouter", None)mgr = BrainManager.from_tier_config("router", cfg, EventBus())# A provider with no [brain.providers.<p>] block resolves to the router default.assert mgr._cu_model("openrouter") == get_tier_default_model(diff --git a/tests/unit/brain/test_grok_provider_wiring.py b/tests/unit/brain/test_grok_provider_wiring.pyindex 055aa9bf6d..81ab5d7518 100644--- a/tests/unit/brain/test_grok_provider_wiring.py+++ b/tests/unit/brain/test_grok_provider_wiring.py@@ -113,7 +113,12 @@ def test_grok_has_authenticated_live_model_catalog() -> None:assert spec.curated and spec.curated[0].id == DEFAULT_MODELassert "grok" in CATALOG_PROVIDERSassert "groq" not in CATALOG_PROVIDERS- assert _ENDPOINTS["grok"] == ("https://api.x.ai/v1/models", "bearer")+ # Endpoint table entries resolve through resolve_provider_endpoint since+ # 2026-07-25; with no override the composed URL is byte-identical+ # (pinned by tests/unit/brain/test_model_catalog_local.py).+ grok_ep = _ENDPOINTS["grok"]+ assert grok_ep.vendor_base + grok_ep.path == "https://api.x.ai/v1/models"+ assert grok_ep.auth == "bearer"def test_grok_uses_xai_openai_compatible_endpoint(diff --git a/tests/unit/brain/test_local_provider_gates.py b/tests/unit/brain/test_local_provider_gates.pynew file mode 100644index 0000000000..65af525462--- /dev/null+++ b/tests/unit/brain/test_local_provider_gates.py@@ -0,0 +1,80 @@+"""Every gate table admits the keyless local providers (S5 parity pins).++The recurring bug class here is a provider that exists but is invisible in+one surface because a per-surface list was not extended (BUG-008 shape).+These pins make each gate's membership explicit — and spec-DERIVED where the+gate is about "local" (auth_mode "none"), never a hand-maintained name list.+"""++from __future__ import annotations++from jarvis.brain.app_control import _NO_CREDENTIAL_PROVIDERS, LOCAL_PROVIDERS+from jarvis.ui.web.provider_spec import PROVIDERS++_LOCAL_BRAIN_IDS = {"ollama", "local-openai"}+++def test_local_providers_are_spec_derived() -> None:+ spec_locals = {s.id for s in PROVIDERS if s.auth_mode == "none"}+ assert LOCAL_PROVIDERS == spec_locals+ assert _LOCAL_BRAIN_IDS <= LOCAL_PROVIDERS+ # Airgapped profile finally has providers to switch TO.+ assert LOCAL_PROVIDERS, "airgapped profile admits no provider switch again"+++def test_no_credential_set_equals_local_set() -> None:+ """auth_mode "none" IS the definition of "needs no credential" — one+ spec-derived set, two names, zero drift."""+ assert _NO_CREDENTIAL_PROVIDERS == LOCAL_PROVIDERS+++def test_worker_provider_map_has_rows_for_locals() -> None:+ from jarvis.missions.worker_runtime.provider_map import (+ to_worker_slug,+ validate_configured_providers,+ )++ assert to_worker_slug("ollama") == "ollama"+ assert to_worker_slug("local-openai") == "local-openai"+ assert validate_configured_providers(sorted(_LOCAL_BRAIN_IDS)) == []+++def test_api_agent_worker_covers_locals() -> None:+ from jarvis.missions.init import _API_AGENT_SLUGS+ from jarvis.missions.workers.api_agent_worker import supports_api_agent_worker++ for provider in _LOCAL_BRAIN_IDS:+ assert provider in _API_AGENT_SLUGS+ assert supports_api_agent_worker(provider)+++def test_api_family_viability_accepts_keyless_locals(monkeypatch) -> None:+ """No credential can exist for a local family — viability must not demand+ one (the old `if not key: return False` would silently skip them)."""+ import jarvis.core.config as cfg_mod+ from jarvis.missions.init import _api_key_family_viable++ monkeypatch.setattr(cfg_mod, "get_jarvis_agent_secret", lambda pid: None)+ for provider in _LOCAL_BRAIN_IDS:+ assert _api_key_family_viable(provider) is True+ # A keyed cloud family without a key stays non-viable — unchanged.+ assert _api_key_family_viable("openrouter") is False+++def test_critic_prefers_cloud_and_ends_local() -> None:+ from jarvis.missions.critic.runner import _API_CRITIC_PROVIDERS++ assert _API_CRITIC_PROVIDERS[-2:] == ("ollama", "local-openai")+ # Cloud graders stay ahead of the local last resort.+ assert _API_CRITIC_PROVIDERS.index("openrouter") < _API_CRITIC_PROVIDERS.index("ollama")+++def test_tool_model_static_status_treats_keyless_as_ready() -> None:+ """The Tool-Model tab must never show a local provider as blocked for a+ "missing credential" (is_credential_present is True for auth_mode none,+ unknown model capabilities default to capable)."""+ from jarvis.ui.web.tool_model_routes import _static_candidate_status++ for provider in _LOCAL_BRAIN_IDS:+ verdict = _static_candidate_status(provider, None)+ assert verdict["ready"] is True, (provider, verdict)diff --git a/tests/unit/brain/test_model_catalog.py b/tests/unit/brain/test_model_catalog.pyindex cefafbc961..2c34822a20 100644--- a/tests/unit/brain/test_model_catalog.py+++ b/tests/unit/brain/test_model_catalog.py@@ -654,7 +654,15 @@ class TestListModels:def test_every_catalog_provider_has_a_curated_family(self) -> None:from jarvis.brain.model_catalog import CURATED_MODELS+ from jarvis.brain.app_control import LOCAL_PROVIDERS+for provider in CATALOG_PROVIDERS:+ if provider in LOCAL_PROVIDERS:+ # Local providers deliberately have NO curated list: their+ # catalog is whatever the user's own server holds, and a+ # fake fallback would advertise models nobody pulled.+ assert not CURATED_MODELS.get(provider)+ continueassert CURATED_MODELS.get(provider), f"{provider} needs a curated list"# Curated ids must survive the brain-model filter (no media/embeds).assert filter_brain_models(CURATED_MODELS[provider]) == CURATED_MODELS[provider]@@ -669,6 +677,10 @@ class TestListModels:"openrouter","grok","nvidia",+ # Keyless local providers (2026-07-25): live catalog = the models+ # the user's own server holds (/api/tags resp. /v1/models).+ "ollama",+ "local-openai",}diff --git a/tests/unit/brain/test_nvidia_provider_wiring.py b/tests/unit/brain/test_nvidia_provider_wiring.pyindex c6d7780aa0..7e41092bb7 100644--- a/tests/unit/brain/test_nvidia_provider_wiring.py+++ b/tests/unit/brain/test_nvidia_provider_wiring.py@@ -79,10 +79,13 @@ def test_nvidia_has_a_live_model_catalog() -> None:assert spec.live is True # /v1/models is fetchable, like OpenRouterassert spec.curated # offline fallback existsassert "nvidia" in CATALOG_PROVIDERS- url, auth = _ENDPOINTS["nvidia"]- assert url == "https://integrate.api.nvidia.com/v1/models"+ # Endpoint entries resolve through resolve_provider_endpoint since+ # 2026-07-25; with no override the composed URL is byte-identical+ # (pinned by tests/unit/brain/test_model_catalog_local.py).+ ep = _ENDPOINTS["nvidia"]+ assert ep.vendor_base + ep.path == "https://integrate.api.nvidia.com/v1/models"# Public catalog (like OpenRouter): key attached when present, else anonymous.- assert auth == "bearer_opt"+ assert ep.auth == "bearer_opt"def test_nvidia_has_tier_defaults() -> None:diff --git a/tests/unit/brain/test_resolver_local_tail.py b/tests/unit/brain/test_resolver_local_tail.pynew file mode 100644index 0000000000..c21971898f--- /dev/null+++ b/tests/unit/brain/test_resolver_local_tail.py@@ -0,0 +1,95 @@+"""Resolver stage 6: keyless local brains close the fallback chain.++Local-first mandate 2026-07-25: a ZERO-key install must land background+resolves (bio/persona/skills) on its own hardware instead of repeat-401ing+on dead cloud defaults — but any funded cloud family stays PREFERRED, so the+local tail comes after the keyed families and never reorders them.+"""++from __future__ import annotations++import pytest++import jarvis.core.config as cfg_mod+from jarvis.brain import resolver+from jarvis.core.config import BrainConfig, BrainProviderConfig, JarvisConfig++[email protected](autouse=True)+def _hermetic(monkeypatch):+ """No real keys, no OAuth rescue, fresh resolver cache."""+ resolver._reset_for_tests()+ monkeypatch.setattr(cfg_mod, "get_provider_secret", lambda pid: None)+ import jarvis.brain.manager as manager++ monkeypatch.setattr(manager, "_keyless_provider_is_rescued_by_oauth", lambda pid: False)+ yield+ resolver._reset_for_tests()+++def _keys(monkeypatch, *providers: str) -> None:+ monkeypatch.setattr(+ cfg_mod,+ "get_provider_secret",+ lambda pid: "sk-test" if pid in providers else None,+ )+++def test_local_tail_closes_the_chain_after_keyed_families(monkeypatch) -> None:+ _keys(monkeypatch, "gemini", "openrouter")+ config = JarvisConfig(brain=BrainConfig(primary="gemini"))++ chain = resolver._resolve_chain(config)+ providers = [p for p, _ in chain]++ assert providers[0] == "gemini"+ # Keyed family the user actually holds comes before any local provider.+ assert providers.index("openrouter") < providers.index("ollama")+ # Both local brains are present, in card order, at the tail.+ assert providers[-2:] == ["ollama", "local-openai"]+++def test_local_provider_as_primary_is_not_duplicated_by_the_tail(monkeypatch) -> None:+ config = JarvisConfig(brain=BrainConfig(primary="ollama"))++ chain = resolver._resolve_chain(config)+ providers = [p for p, _ in chain]++ assert providers.count("ollama") == 1+ assert providers[0] == "ollama"+ assert "local-openai" in providers+++def test_zero_key_install_still_resolves_onto_local(monkeypatch) -> None:+ """The AP-22 acceptance shape: no key anywhere → the chain still ends on+ reachable local providers instead of only a dead keyless claude-api."""+ config = JarvisConfig()++ chain = resolver._resolve_chain(config)+ providers = [p for p, _ in chain]++ assert "ollama" in providers+ assert "local-openai" in providers+++def test_local_tail_honors_user_picked_model(monkeypatch) -> None:+ """The user's [brain.providers.ollama].model pick rides into the tail —+ never overridden by a hardcoded default (AP-21)."""+ config = JarvisConfig(+ brain=BrainConfig(+ primary="gemini",+ providers={"ollama": BrainProviderConfig(model="qwen3.5:9b")},+ )+ )+ _keys(monkeypatch, "gemini")++ chain = resolver._resolve_chain(config)+ by_provider = dict(chain)++ assert by_provider["ollama"] == "qwen3.5:9b"+++def test_local_fallback_default_is_unchanged() -> None:+ """Existing installs keep their configured local_fallback default — the+ local tail is ADDITIVE, never a silent default flip."""+ assert JarvisConfig().brain.local_fallback == "claude-api"