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(realtime): brain model picker on the managed voice-server card
rubenluetke10-beep741b7de7c2c3
diff --git a/jarvis/realtime/local_server/brain_link.py b/jarvis/realtime/local_server/brain_link.pyindex 2fa9ecc7e1..0d14c8787c 100644--- a/jarvis/realtime/local_server/brain_link.py+++ b/jarvis/realtime/local_server/brain_link.py@@ -153,6 +153,73 @@ def _openai_key() -> str:return ""+def list_brain_choices(+ *, timeout: float = 2.5, usable_gb: float = 0.0, current_model: str = ""+) -> dict[str, object]:+ """Every brain candidate for the voice server, annotated for THIS machine.++ The data behind the card's model picker (maintainer ask 2026-08-08: the+ user could not CHOOSE the server brain, only watch the resolver pick).+ Installed chat-capable Ollama tags come first, then curated+ recommendations that are not installed yet; every entry carries the+ honest fit verdict against the accelerator — the same ``_fits`` rule the+ resolver applies, so the picker and the resolver can never disagree.+ """+ base = _ollama_base()+ served = _ollama_models(base, timeout)+ reachable = served is not None+ choices: list[dict[str, object]] = []+ seen: set[str] = set()+ for name, size in served or []:+ if not _usable_tag(name):+ continue+ seen.add(name)+ fits = _fits(size, usable_gb)+ choices.append(+ {+ "id": name,+ "label": name,+ "size_gb": round(size, 1),+ "installed": True,+ "fits": fits,+ "note": "" if fits else _no_fit_note(size, usable_gb),+ "recommended": name in _PREFERRED_MODELS,+ "current": bool(current_model) and name == current_model,+ }+ )+ from jarvis.brain.ollama_pull import RECOMMENDED_MODELS # lazy (AP-26)++ for entry in RECOMMENDED_MODELS:+ if entry.role != "chat" or entry.id in seen:+ continue+ fits = _fits(entry.size_gb, usable_gb)+ choices.append(+ {+ "id": entry.id,+ "label": entry.label,+ "size_gb": round(entry.size_gb, 1),+ "installed": False,+ "fits": fits,+ "note": "" if fits else _no_fit_note(entry.size_gb, usable_gb),+ "recommended": entry.id in _PREFERRED_MODELS,+ "current": False,+ }+ )+ return {+ "reachable": reachable,+ "usable_gb": round(usable_gb, 1),+ "current": current_model,+ "models": choices,+ }+++def _no_fit_note(size_gb: float, usable_gb: float) -> str:+ return (+ f"~{size_gb:.0f} GB does not fit next to the voice stack on "+ f"{usable_gb:.0f} GB of accelerator memory."+ )++def resolve_brain(*, timeout: float = 2.5, preferred_model: str = "", usable_gb: float = 0.0) -> BrainResolution:diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsxindex b4693c68cd..cd4f68f5b3 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx@@ -14,22 +14,24 @@ import {localInstallStatus,logoutAntigravity,managedServerBrain,+ managedServerBrainModels,managedServerInstall,managedServerPreflight,managedServerStart,managedServerStatus,managedServerStop,managedServerUninstall,+ modelPullStatus,ollamaRuntime,ollamaRuntimeInstall,ollamaRuntimeStart,+ startModelPull,+ type ManagedBrainChoice,type ManagedServerRuntime,type OllamaRuntimeInstallProgress,type OllamaRuntimeStatus,- modelPullStatus,pullableModels,startLocalInstall,- startModelPull,type LocalInstallProgress,type ManagedInstallProgress,type ManagedPreflight,@@ -1920,6 +1922,10 @@ function ManagedServerPanel({const [progress, setProgress] = useState<ManagedInstallProgress | null>(null);const [runtime, setRuntime] = useState<ManagedServerRuntime | null>(null);const [brainNote, setBrainNote] = useState<string | null>(null);+ const [brainModels, setBrainModels] = useState<Awaited<+ ReturnType<typeof managedServerBrainModels>+ > | null>(null);+ const [brainBusy, setBrainBusy] = useState<string | null>(null);const [error, setError] = useState<string | null>(null);const [checking, setChecking] = useState(false);const [lifecycleBusy, setLifecycleBusy] = useState(false);@@ -2054,6 +2060,7 @@ function ManagedServerPanel({try {const result = await managedServerBrain();setBrainNote(result.brain.note);+ void loadBrainModels();} catch (err) {setError(err instanceof Error ? err.message : String(err));} finally {@@ -2061,6 +2068,53 @@ function ManagedServerPanel({}};+ const loadBrainModels = useCallback(async () => {+ try {+ setBrainModels(await managedServerBrainModels());+ } catch {+ setBrainModels(null);+ }+ }, []);++ useEffect(() => {+ if (!installed || running) return;+ void loadBrainModels();+ }, [installed, running, loadBrainModels]);++ const chooseBrain = async (choice: ManagedBrainChoice) => {+ setError(null);+ setBrainNote(null);+ setBrainBusy(choice.id);+ try {+ if (!choice.installed) {+ // Download through the SAME pull machinery the Ollama card uses,+ // then adopt — never adopt a model the server cannot serve yet.+ await startModelPull("ollama", choice.id);+ for (;;) {+ const pull = await modelPullStatus("ollama", choice.id);+ if (pull.state === "done") break;+ if (pull.state === "error") {+ throw new Error(pull.message || "model download failed");+ }+ setBrainNote(+ `${choice.label}: ${Math.round(pull.percent ?? 0)}%`,+ );+ await new Promise((resolve) => window.setTimeout(resolve, 2500));+ }+ }+ const result = await managedServerBrain(choice.id);+ setBrainNote(+ `${result.brain.note} ${t("apikeys_view.managed_brain_next_start")}`,+ );+ await loadBrainModels();+ onChanged();+ } catch (err) {+ setError(err instanceof Error ? err.message : String(err));+ } finally {+ setBrainBusy(null);+ }+ };+const stopServer = async () => {setError(null);setLifecycleBusy(true);@@ -2176,6 +2230,67 @@ function ManagedServerPanel({</p>)}+ {!running && installed && brainModels && brainModels.models.length > 0 && (+ <div className="space-y-1" data-testid="managed-brain-picker">+ <p className="text-[11px] font-medium text-foreground">+ {t("apikeys_view.managed_brain_picker_title")}+ </p>+ <ul className="space-y-1">+ {brainModels.models.map((choice) => (+ <li+ key={choice.id}+ className="flex items-center gap-2 text-[11px] text-muted-foreground"+ >+ <span className="min-w-0 flex-1 truncate">+ {choice.label}+ <span className="text-muted-foreground/70">+ {" "}+ · ~{choice.size_gb} GB+ </span>+ {choice.current && (+ <span className="ml-1.5 text-emerald-400">+ {t("apikeys_view.managed_brain_current")}+ </span>+ )}+ {!choice.current && choice.recommended && choice.fits && (+ <span className="ml-1.5 text-primary/80">+ {t("apikeys_view.managed_brain_recommended")}+ </span>+ )}+ </span>+ {!choice.fits ? (+ <span+ className="shrink-0 text-amber-500/90"+ title={choice.note}+ >+ {t("apikeys_view.managed_brain_no_fit")}+ </span>+ ) : choice.current ? null : (+ <Button+ size="sm"+ variant="ghost"+ onClick={() => void chooseBrain(choice)}+ disabled={brainBusy !== null}+ className="h-6 shrink-0 gap-1.5 px-2 text-[11px]"+ >+ {brainBusy === choice.id ? (+ <Loader2 className="h-3 w-3 animate-spin" />+ ) : choice.installed ? (+ <Check className="h-3 w-3" />+ ) : (+ <Download className="h-3 w-3" />+ )}+ {choice.installed+ ? t("apikeys_view.managed_brain_use")+ : t("apikeys_view.managed_brain_pull_use")}+ </Button>+ )}+ </li>+ ))}+ </ul>+ </div>+ )}+{running && (<div className="space-y-1"><div className="h-1.5 w-full overflow-hidden rounded bg-muted">diff --git a/jarvis/ui/web/frontend/src/hooks/useProviders.ts b/jarvis/ui/web/frontend/src/hooks/useProviders.tsindex f2fa538cfd..c89349a2d8 100644--- a/jarvis/ui/web/frontend/src/hooks/useProviders.ts+++ b/jarvis/ui/web/frontend/src/hooks/useProviders.ts@@ -923,6 +923,38 @@ export async function managedServerStart(): Promise<ManagedServerRuntime | null>return (body.runtime ?? null) as ManagedServerRuntime | null;}+/** One brain candidate for the voice server, annotated for this machine. */+export interface ManagedBrainChoice {+ id: string;+ label: string;+ size_gb: number;+ installed: boolean;+ fits: boolean;+ /** Honest reason when it does not fit; empty otherwise. */+ note: string;+ recommended: boolean;+ current: boolean;+}++export async function managedServerBrainModels(): Promise<{+ reachable: boolean;+ usable_gb: number;+ current: string;+ models: ManagedBrainChoice[];+}> {+ const res = await fetch(+ "/api/providers/local-realtime/managed-server/brain-models",+ );+ const body = await res.json().catch(() => ({}));+ if (!res.ok) throw new Error(body.detail ?? `HTTP ${res.status}`);+ return body as {+ reachable: boolean;+ usable_gb: number;+ current: string;+ models: ManagedBrainChoice[];+ };+}+/** Re-resolve the Ollama brain model and rewrite the launch command in place. */export async function managedServerBrain(model?: string): Promise<{ok: boolean;diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex d9986ab76b..b276b7964b 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1185,6 +1185,13 @@"ollama_install_confirm": "Erneut klicken, um Ollama jetzt zu installieren","ollama_install_hint": "Lädt die offizielle Ollama-Laufzeit von ollama.com und startet sie — ganz ohne Terminal. Lokale Modelle laufen vollständig auf diesem Rechner.","ollama_start_cta": "Ollama starten",+ "managed_brain_picker_title": "Denkmodell für den Sprachserver",+ "managed_brain_current": "aktiv",+ "managed_brain_recommended": "empfohlen",+ "managed_brain_no_fit": "passt nicht",+ "managed_brain_use": "Verwenden",+ "managed_brain_pull_use": "Laden & verwenden",+ "managed_brain_next_start": "Gilt ab dem nächsten Server-Start.","managed_brain_recheck": "Aktuelles Denkmodell übernehmen","managed_brain_recheck_hint": "Prüft neu, welches Ollama-Modell auf diese Maschine passt, und stellt das Server-Gehirn darauf um — ohne Neuinstallation. Gilt ab dem nächsten Server-Start.","shared_delete_prefix": "Dieser Schlüssel wird auch verwendet von:",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex 0ca2d81510..b302a04380 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1185,6 +1185,13 @@"ollama_install_confirm": "Click again to install Ollama now","ollama_install_hint": "Downloads the official Ollama runtime from ollama.com and starts it — no terminal needed. Local models run entirely on this machine.","ollama_start_cta": "Start Ollama",+ "managed_brain_picker_title": "Brain model for the voice server",+ "managed_brain_current": "active",+ "managed_brain_recommended": "recommended",+ "managed_brain_no_fit": "does not fit",+ "managed_brain_use": "Use",+ "managed_brain_pull_use": "Download & use",+ "managed_brain_next_start": "Takes effect on the next server start.","managed_brain_recheck": "Use current brain model","managed_brain_recheck_hint": "Re-check which Ollama model fits this machine and switch the server's brain to it — no reinstall. Takes effect on the next server start.","shared_delete_prefix": "This key is also used by:",diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex 0a47bd009a..3311ac2932 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1185,6 +1185,13 @@"ollama_install_confirm": "Haz clic de nuevo para instalar Ollama ahora","ollama_install_hint": "Descarga el runtime oficial de Ollama desde ollama.com y lo inicia — sin terminal. Los modelos locales se ejecutan por completo en esta máquina.","ollama_start_cta": "Iniciar Ollama",+ "managed_brain_picker_title": "Modelo de razonamiento del servidor de voz",+ "managed_brain_current": "activo",+ "managed_brain_recommended": "recomendado",+ "managed_brain_no_fit": "no cabe",+ "managed_brain_use": "Usar",+ "managed_brain_pull_use": "Descargar y usar",+ "managed_brain_next_start": "Se aplica en el próximo arranque del servidor.","managed_brain_recheck": "Usar el modelo de razonamiento actual","managed_brain_recheck_hint": "Vuelve a comprobar qué modelo de Ollama cabe en esta máquina y cambia el cerebro del servidor a él — sin reinstalar. Se aplica en el próximo arranque del servidor.","shared_delete_prefix": "Esta clave también la usan:",diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex 304f83a65d..ea13f182c5 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -2886,6 +2886,29 @@ async def managed_server_stop(request: Request) -> dict[str, Any]:return {"ok": True, "message": message, "runtime": runtime}[email protected]("/providers/local-realtime/managed-server/brain-models")+async def managed_server_brain_models(request: Request) -> dict[str, Any]:+ """Brain candidates for the voice server, annotated for THIS machine.++ Installed chat-capable Ollama tags first, then curated recommendations+ not installed yet; every entry carries the same fit verdict the resolver+ itself applies (picker and resolver can never disagree), plus which one+ the persisted launch command currently uses.+ """+ from jarvis.realtime.local_server.brain_link import list_brain_choices+ from jarvis.realtime.local_server.preflight import _usable_accelerator_gb+ from jarvis.realtime.local_server.supervisor import _brain_endpoint++ _base_url, command = _local_realtime_card(request)++ def _collect() -> dict[str, Any]:+ usable_gb, _source = _usable_accelerator_gb()+ current_model, _brain_base = _brain_endpoint(command)+ return list_brain_choices(usable_gb=usable_gb, current_model=current_model)++ return await asyncio.to_thread(_collect)++@router.post("/providers/local-realtime/managed-server/brain")async def managed_server_brain(request: Request) -> dict[str, Any]:"""Re-resolve the brain model and rewrite the launch command in place.@@ -2928,6 +2951,18 @@ async def managed_server_brain(request: Request) -> dict[str, Any]:or "no usable local brain was found — install one via Ollama first"),)+ if requested and brain.model != requested:+ # An EXPLICIT choice is never silently swapped (user autonomy): the+ # resolver's fallback pick is fine for automatic re-resolution, but a+ # user who named a model gets the honest refusal with the reason.+ raise HTTPException(+ status_code=409,+ detail=(+ brain.note+ or f"'{requested}' is not served by Ollama or does not fit "+ "this machine."+ ),+ )changed = await asyncio.to_thread(lambda: update_local_realtime_launch_model(brain.model, only_if_under=str(install_root())diff --git a/tests/unit/realtime/local_server/test_engine.py b/tests/unit/realtime/local_server/test_engine.pyindex 745e8130e0..95ba969dff 100644--- a/tests/unit/realtime/local_server/test_engine.py+++ b/tests/unit/realtime/local_server/test_engine.py@@ -83,6 +83,42 @@ class TestBrainResolution:)assert chosen == "mystery-model:latest"+ def test_brain_choices_annotate_fit_and_installed_state(self, monkeypatch) -> None:+ """The picker's data: installed tags first with the SAME fit rule the+ resolver applies, then curated not-yet-installed recommendations."""+ monkeypatch.setattr(+ brain_link,+ "_ollama_models",+ lambda base, timeout: [+ ("qwen2.5:7b", 4.7),+ ("nemotron-cascade-2:latest", 24.0),+ ("nomic-embed-text:latest", 0.3), # never a voice brain+ ],+ )+ payload = brain_link.list_brain_choices(+ usable_gb=16.0, current_model="qwen2.5:7b"+ )+ assert payload["reachable"] is True+ by_id = {entry["id"]: entry for entry in payload["models"]}+ assert "nomic-embed-text:latest" not in by_id+ assert by_id["qwen2.5:7b"]["installed"] is True+ assert by_id["qwen2.5:7b"]["fits"] is True+ assert by_id["qwen2.5:7b"]["current"] is True+ assert by_id["qwen2.5:7b"]["recommended"] is True+ assert by_id["nemotron-cascade-2:latest"]["fits"] is False+ assert "does not fit" in by_id["nemotron-cascade-2:latest"]["note"]+ # Curated chat entries that are not installed join the list.+ assert any(+ not entry["installed"] for entry in payload["models"]+ ), "curated recommendations must be offered for download"++ def test_brain_choices_survive_an_unreachable_ollama(self, monkeypatch) -> None:+ monkeypatch.setattr(brain_link, "_ollama_models", lambda base, timeout: None)+ payload = brain_link.list_brain_choices(usable_gb=16.0)+ assert payload["reachable"] is False+ # Curated entries still render so the user sees what COULD run here.+ assert payload["models"]+def test_running_ollama_with_model_is_fully_local(self, monkeypatch) -> None:monkeypatch.setattr(brain_link, "_ollama_models", lambda base, timeout: [("qwen2.5:7b", 4.7)]diff --git a/tests/unit/ui/web/test_managed_local_realtime_routes.py b/tests/unit/ui/web/test_managed_local_realtime_routes.pyindex 2d4f1a7859..4b5592aedc 100644--- a/tests/unit/ui/web/test_managed_local_realtime_routes.py+++ b/tests/unit/ui/web/test_managed_local_realtime_routes.py@@ -306,6 +306,53 @@ def test_brain_route_rewrites_the_model_without_reinstall(assert "--model_name llama3.1:8b" in cfg_file.read_text(encoding="utf-8")+def test_brain_models_route_lists_annotated_choices(+ server: WebServer, monkeypatch: pytest.MonkeyPatch+) -> None:+ from jarvis.core.config import BrainProviderConfig++ server.app.state.config.brain.providers["local-realtime"] = BrainProviderConfig(+ launch_command="serve --model_name qwen2.5:7b"+ )+ monkeypatch.setattr(preflight, "_usable_accelerator_gb", lambda: (16.0, "nvidia-smi"))+ monkeypatch.setattr(+ brain_link, "_ollama_models", lambda base, timeout: [("qwen2.5:7b", 4.7)]+ )+ with TestClient(server.app) as client:+ resp = client.get(+ "/api/providers/local-realtime/managed-server/brain-models"+ )+ assert resp.status_code == 200+ body = resp.json()+ assert body["reachable"] is True+ assert body["current"] == "qwen2.5:7b"+ by_id = {entry["id"]: entry for entry in body["models"]}+ assert by_id["qwen2.5:7b"]["current"] is True+++def test_brain_route_refuses_to_swap_an_explicit_choice(+ server: WebServer, monkeypatch: pytest.MonkeyPatch+) -> None:+ """A named model that does not fit gets an honest 409 — never a silent+ substitution (user autonomy)."""+ monkeypatch.setattr(preflight, "_usable_accelerator_gb", lambda: (16.0, "nvidia-smi"))+ monkeypatch.setattr(+ brain_link,+ "_ollama_models",+ lambda base, timeout: [+ ("nemotron-cascade-2:latest", 24.0),+ ("qwen2.5:7b", 4.7),+ ],+ )+ with TestClient(server.app) as client:+ resp = client.post(+ "/api/providers/local-realtime/managed-server/brain",+ json={"model": "nemotron-cascade-2:latest"},+ )+ assert resp.status_code == 409+ assert "does not fit" in resp.json()["detail"]++def test_brain_route_answers_409_without_a_local_brain(server: WebServer, monkeypatch: pytest.MonkeyPatch) -> None: