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(onboarding): local path in first-run wizard
Ruben Lütke73b6d3fbf647
diff --git a/jarvis/setup/wizard.py b/jarvis/setup/wizard.pyindex 1d1abb6c87..4bb29dac16 100644--- a/jarvis/setup/wizard.py+++ b/jarvis/setup/wizard.py@@ -173,6 +173,17 @@ SECRETS: list[SecretSpec] = [required_for="Grok Brain and xAI TTS",section="brain",),+ # Optional key for the generic local OpenAI-compatible provider (vLLM+ # --api-key, proxied LM Studio, ...). App-only: local servers usually need+ # no key, so it must not lengthen first-run onboarding.+ SecretSpec(+ key="local_openai_api_key",+ env_fallback="LOCAL_OPENAI_API_KEY",+ label="Local OpenAI-compatible server key (optional)",+ help_url="https://huggingface.co/docs/transformers/main/serving",+ required_for="Local server brain (only if your server enforces a key)",+ prompt=False,+ ),# Scoped Realtime credentials. They are app-only fields in the Realtime tab,# not extra first-run questions. Generic credentials remain compatibility# fallbacks for existing installations.@@ -466,6 +477,21 @@ SECRETS: list[SecretSpec] = [optional=True,prompt=False,),+ # Drives the guided Supabase link flow in the UltraWiki storage card: the+ # token is read-only plumbing (list projects, read the pooler host) and is+ # never what the store connects with — that stays 'ultrawiki_db_url'. It+ # belongs in this allowlist because the same slot is already used by the+ # Supabase CLI integration, and without the entry the app's own secrets+ # route would refuse to save a token the user just pasted.+ SecretSpec(+ key="supabase_access_token",+ env_fallback="SUPABASE_ACCESS_TOKEN",+ label="Supabase Personal Access Token",+ help_url="https://supabase.com/dashboard/account/tokens",+ required_for="UltraWiki Supabase store (guided link) and the Supabase CLI",+ optional=True,+ prompt=False,+ ),]@@ -620,8 +646,62 @@ def _api_keys_intro() -> None:_console.print(Panel(body, border_style="brand", padding=(1, 2)))+def _ollama_reachable(timeout_s: float = 1.0) -> bool:+ """One quick ``/api/version`` probe against the local Ollama default.++ Interactive-wizard-only (never on the boot path, AP-26). Honors+ OLLAMA_HOST via the plugin's own root resolution so wizard and runtime+ can never disagree about where the server lives.+ """+ try:+ import httpx++ from jarvis.plugins.brain.ollama import default_server_root++ resp = httpx.get(f"{default_server_root()}/api/version", timeout=timeout_s)+ return resp.status_code == 200+ except Exception: # noqa: BLE001 — no local server is a normal state+ return False+++def _offer_local_brain() -> bool:+ """First-sixty-seconds local path: when a local Ollama already answers,+ offer to run WITHOUT any API key before a single key question is asked.++ Returns True when the user accepted (brain.primary pinned to ollama) —+ the key sections still render afterwards (cloud keys stay optional+ upgrades), so accepting never hides anything.+ """+ if not _ollama_reachable():+ return False+ _console.print()+ _console.print(+ Panel(+ "[ok]Ollama detected on this machine.[/] Jarvis can run its brain "+ "[brand.bold]fully local — no API key, nothing leaves this "+ "computer[/]. Cloud keys below stay optional upgrades.",+ border_style="ok",+ padding=(1, 2),+ )+ )+ answer = _ask(" Use the local Ollama as the brain? [Y/n]", default="y")+ if answer.strip().lower() not in ("y", "yes", "j", "ja", "s", "si", "sí"):+ return False+ try:+ from jarvis.core import config_writer++ config_writer.set_brain_primary("ollama")+ _console.print(" [ok]→ Brain set to Ollama (local). No key needed.[/]")+ return True+ except Exception as exc: # noqa: BLE001 — a config hiccup must not kill setup+ _console.print(f" [bad]⚠ Could not persist the choice ({exc}) — "+ "you can switch to Ollama any time under Settings → API Keys.[/]")+ return False++def step_api_keys() -> dict[str, str]:_api_keys_intro()+ _offer_local_brain()stored: dict[str, str] = {}for section in _SECTIONS:diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsxindex 49eb9c083b..b4eaf60df9 100644--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.test.tsx@@ -1,11 +1,36 @@-import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";import { afterEach, expect, it, vi } from "vitest";vi.mock("@/i18n", () => ({ useT: () => (key: string) => key }));import { ApiKeysStep } from "./ApiKeysStep";-afterEach(cleanup);+afterEach(() => {+ cleanup();+ vi.unstubAllGlobals();+});++type ProbeShape = { source: string; models: { id: string }[] } | null;++/** Stub fetch for the local-path probe (+ the brain switch). `null` = network error. */+function stubFetch(probe: ProbeShape) {+ const calls: { url: string; init?: RequestInit }[] = [];+ vi.stubGlobal(+ "fetch",+ vi.fn(async (url: string, init?: RequestInit) => {+ calls.push({ url, init });+ if (url === "/api/providers/ollama/models") {+ if (probe === null) throw new Error("network down");+ return { ok: true, json: async () => probe } as Response;+ }+ if (url === "/api/brain/switch") {+ return { ok: true, json: async () => ({ ok: true }) } as Response;+ }+ throw new Error(`unexpected fetch: ${url}`);+ }),+ );+ return calls;+}function renderStep(overrides: Record<string, unknown> = {}) {const props = {@@ -22,6 +47,7 @@ function renderStep(overrides: Record<string, unknown> = {}) {}it("shows the real API Keys view with the navigation and voice-mode switch marked", () => {+ stubFetch(null);renderStep();const screenshot = screen.getByRole("img", {@@ -37,18 +63,69 @@ it("shows the real API Keys view with the navigation and voice-mode switch markeexpect(screen.getByText("onboarding.api_keys.pipeline_label")).toBeDefined();});-it("keeps credential entry out of the onboarding modal", () => {+it("keeps credential entry out of the onboarding modal", async () => {+ stubFetch(null);renderStep();+ await screen.findByText("onboarding.api_keys.local_missing");+ // No key can ever be typed here — that is the step's security contract.expect(screen.queryByRole("textbox")).toBeNull();- expect(screen.queryByRole("link")).toBeNull();+ // The only link the step may carry is the Ollama install pointer (no+ // provider dashboards, no key pages).+ for (const link of screen.queryAllByRole("link")) {+ expect(link.getAttribute("href")).toBe("https://ollama.com/download");+ }});-it("offers one clear action to continue onboarding", () => {+it("offers one clear action to continue onboarding", async () => {+ stubFetch(null);const props = renderStep();- const buttons = screen.getAllByRole("button");- expect(buttons).toHaveLength(1);- fireEvent.click(buttons[0]);+ await screen.findByText("onboarding.api_keys.local_missing");++ const cont = screen.getByRole("button", { name: "onboarding.api_keys.continue" });+ fireEvent.click(cont);expect(props.goNext).toHaveBeenCalledTimes(1);expect(props.skip).not.toHaveBeenCalled();});++it("probes through the backend and offers one-click local activation", async () => {+ const calls = stubFetch({ source: "live", models: [{ id: "qwen3.5:9b" }] });+ renderStep();++ await screen.findByText("onboarding.api_keys.local_detected");+ const useLocal = screen.getByRole("button", {+ name: "onboarding.api_keys.local_use_button",+ });+ fireEvent.click(useLocal);++ await screen.findByText("onboarding.api_keys.local_active");+ const switchCall = calls.find((c) => c.url === "/api/brain/switch");+ expect(switchCall).toBeDefined();+ expect(JSON.parse(String(switchCall?.init?.body))).toMatchObject({+ provider: "ollama",+ });+ // The probe went through the backend catalog route — never a+ // browser-direct localhost:11434 call.+ expect(calls[0].url).toBe("/api/providers/ollama/models");+});++it("tells a running-but-empty Ollama to pull a model first", async () => {+ stubFetch({ source: "live", models: [] });+ renderStep();++ await screen.findByText("onboarding.api_keys.local_detected_empty");+ expect(+ screen.queryByRole("button", { name: "onboarding.api_keys.local_use_button" }),+ ).toBeNull();+});++it("shows the honest install pointer when no local server answers", async () => {+ stubFetch({ source: "static", models: [] });+ renderStep();++ await screen.findByText("onboarding.api_keys.local_missing");+ const link = screen.getByRole("link", {+ name: "onboarding.api_keys.local_missing_link",+ });+ expect(link.getAttribute("href")).toBe("https://ollama.com/download");+});diff --git a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsxindex 87834ac8f1..92f370de9f 100644--- a/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx+++ b/jarvis/ui/web/frontend/src/components/onboarding/steps/ApiKeysStep.tsx@@ -1,10 +1,112 @@-import { CheckCircle2, KeyRound, Radio, Waypoints } from "lucide-react";+import { useEffect, useState } from "react";+import { CheckCircle2, HardDrive, KeyRound, Radio, Waypoints } from "lucide-react";import { Button } from "@/components/ui/button";+import { switchBrainProvider } from "@/hooks/useProviders";import { useT } from "@/i18n";import type { StepProps } from "../OnboardingFlow";const GUIDE_SCREENSHOT = "/onboarding/api-keys-realtime-guide.png";+/**+ * First-sixty-seconds local path (maintainer amendment 2026-07-25): a+ * zero-key user with Ollama running must SEE the local option during+ * onboarding, not discover it later in settings. The probe goes through the+ * backend catalog route (never a browser-direct localhost:11434 call, which+ * CORS would block anyway) and runs once on step mount only (AP-26).+ */+function LocalPathCard() {+ const t = useT();+ const [probe, setProbe] = useState<"checking" | "reachable" | "empty" | "unreachable">(+ "checking",+ );+ const [activating, setActivating] = useState(false);+ const [active, setActive] = useState(false);+ const [error, setError] = useState<string | null>(null);++ useEffect(() => {+ let cancelled = false;+ (async () => {+ try {+ const res = await fetch("/api/providers/ollama/models");+ const data = res.ok ? await res.json() : null;+ const live = data?.source === "live" || data?.source === "cache";+ const models = Array.isArray(data?.models) ? data.models.length : 0;+ if (!cancelled) {+ setProbe(live ? (models > 0 ? "reachable" : "empty") : "unreachable");+ }+ } catch {+ if (!cancelled) setProbe("unreachable");+ }+ })();+ return () => {+ cancelled = true;+ };+ }, []);++ async function useLocal() {+ setActivating(true);+ setError(null);+ try {+ await switchBrainProvider("ollama");+ setActive(true);+ } catch (e) {+ setError(e instanceof Error ? e.message : String(e));+ } finally {+ setActivating(false);+ }+ }++ return (+ <section className="rounded-xl border border-border bg-muted/30 p-4">+ <div className="mb-2 flex items-center gap-2 text-sm font-semibold">+ <HardDrive aria-hidden="true" className="h-4 w-4 text-primary" />+ {t("onboarding.api_keys.local_title")}+ </div>+ {probe === "checking" && (+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("onboarding.api_keys.local_checking")}+ </p>+ )}+ {probe === "reachable" && (+ <div className="space-y-2">+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("onboarding.api_keys.local_detected")}+ </p>+ {active ? (+ <p className="flex items-center gap-2 text-xs font-medium text-emerald-600">+ <CheckCircle2 aria-hidden="true" className="h-4 w-4 shrink-0" />+ {t("onboarding.api_keys.local_active")}+ </p>+ ) : (+ <Button size="sm" variant="secondary" onClick={useLocal} disabled={activating}>+ {t("onboarding.api_keys.local_use_button")}+ </Button>+ )}+ {error && <p className="text-xs text-destructive">{error}</p>}+ </div>+ )}+ {probe === "empty" && (+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("onboarding.api_keys.local_detected_empty")}+ </p>+ )}+ {probe === "unreachable" && (+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("onboarding.api_keys.local_missing")}{" "}+ <a+ href="https://ollama.com/download"+ target="_blank"+ rel="noreferrer"+ className="font-medium text-primary underline-offset-2 hover:underline"+ >+ {t("onboarding.api_keys.local_missing_link")}+ </a>+ </p>+ )}+ </section>+ );+}+/*** Introduces the credential path without embedding the full provider console in* a first-run modal. The screenshot is captured from the real API Keys view;@@ -110,6 +212,8 @@ export function ApiKeysStep({ goNext }: StepProps) {</section></div>+ <LocalPathCard />+<p className="flex items-start gap-2 rounded-lg bg-emerald-500/10 px-3 py-2.5 text-xs leading-relaxed text-emerald-600"><CheckCircle2 aria-hidden="true" className="mt-0.5 h-4 w-4 shrink-0" />{t("onboarding.api_keys.security_note")}diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.jsonindex 67b04e8766..fec5dabe04 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json@@ -1761,6 +1761,14 @@"pipeline_label": "Pipeline (nicht empfohlen):","pipeline_body": "Füge nur Schlüssel für die ausgewählten Anbieter für Denken, Sprachausgabe und Spracheingabe hinzu.","security_note": "Füge Schlüssel ausschließlich in der sicheren API-Keys-Ansicht ein — niemals im Chat oder per Sprache.",+ "local_title": "Kein API-Key? Komplett lokal starten",+ "local_checking": "Suche nach einem lokalen Ollama…",+ "local_detected": "Ollama auf diesem Rechner gefunden — Jarvis kann komplett lokal denken, ganz ohne Key.",+ "local_detected_empty": "Ollama läuft, hat aber noch kein Modell — lade zuerst eins (z. B. ollama pull qwen3.5).",+ "local_use_button": "Lokales Modell verwenden",+ "local_active": "Lokales Gehirn aktiv — Ollama antwortet von diesem Rechner.",+ "local_missing": "Kein API-Key zur Hand? Installiere Ollama und Jarvis läuft komplett lokal — ohne Cloud-Konto.",+ "local_missing_link": "Ollama holen","continue": "Onboarding fortsetzen"},"mic_test": {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.jsonindex d298c0667a..f7fe51271f 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json@@ -1762,6 +1762,14 @@"pipeline_label": "Pipeline (not recommended):","pipeline_body": "Add keys only for the Brain, Voice Output, and Voice Input providers you choose.","security_note": "Paste keys only into the secure API Keys view — never into chat or voice.",+ "local_title": "No API key? Run fully local",+ "local_checking": "Checking for a local Ollama…",+ "local_detected": "Ollama detected on this machine — Jarvis can think fully local, no key needed.",+ "local_detected_empty": "Ollama is running but has no model yet — pull one first (e.g. ollama pull qwen3.5).",+ "local_use_button": "Use local model",+ "local_active": "Local brain active — Ollama answers from this machine.",+ "local_missing": "No API key at hand? Install Ollama and Jarvis runs fully local — no cloud account needed.",+ "local_missing_link": "Get Ollama","continue": "Continue onboarding"},"mic_test": {diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.jsonindex f916696adb..f90fd5e75e 100644--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json@@ -1771,6 +1771,14 @@"pipeline_label": "Pipeline (no recomendado):","pipeline_body": "Añade claves únicamente para los proveedores de razonamiento, salida de voz y entrada de voz que elijas.","security_note": "Pega las claves únicamente en la vista segura de Claves API, nunca en el chat ni por voz.",+ "local_title": "¿Sin clave API? Funciona totalmente en local",+ "local_checking": "Buscando un Ollama local…",+ "local_detected": "Ollama detectado en este equipo: Jarvis puede pensar totalmente en local, sin clave.",+ "local_detected_empty": "Ollama está en marcha pero aún no tiene ningún modelo: descarga uno primero (p. ej. ollama pull qwen3.5).",+ "local_use_button": "Usar modelo local",+ "local_active": "Cerebro local activo: Ollama responde desde este equipo.",+ "local_missing": "¿Sin clave API a mano? Instala Ollama y Jarvis funciona totalmente en local, sin cuenta en la nube.",+ "local_missing_link": "Obtener Ollama","continue": "Continuar la introducción"},"mic_test": {diff --git a/tests/unit/setup/test_wizard_local_brain_offer.py b/tests/unit/setup/test_wizard_local_brain_offer.pynew file mode 100644index 0000000000..ff6897dd80--- /dev/null+++ b/tests/unit/setup/test_wizard_local_brain_offer.py@@ -0,0 +1,65 @@+"""First-run wizard: the local-brain offer (first-sixty-seconds mandate).++A zero-key user with a running Ollama must be OFFERED the local path before+any key question; a host without one must never see the prompt or a probe+delay on the boot path (the probe lives inside the interactive step only).+"""++from __future__ import annotations++import pytest++from jarvis.setup import wizard++[email protected](autouse=True)+def _no_real_network(monkeypatch):+ """The probe must never hit a real server in tests."""+ monkeypatch.delenv("OLLAMA_HOST", raising=False)+++def test_offer_skipped_when_no_local_server(monkeypatch) -> None:+ monkeypatch.setattr(wizard, "_ollama_reachable", lambda **kw: False)++ def _fail_ask(*a, **kw): # pragma: no cover - defended path+ raise AssertionError("no prompt may render without a reachable server")++ monkeypatch.setattr(wizard, "_ask", _fail_ask)+ assert wizard._offer_local_brain() is False+++def test_accepting_pins_ollama_as_primary(monkeypatch) -> None:+ from jarvis.core import config_writer++ monkeypatch.setattr(wizard, "_ollama_reachable", lambda **kw: True)+ monkeypatch.setattr(wizard, "_ask", lambda *a, **kw: "y")+ pinned: list[str] = []+ monkeypatch.setattr(config_writer, "set_brain_primary", lambda name: pinned.append(name))++ assert wizard._offer_local_brain() is True+ assert pinned == ["ollama"]+++def test_declining_changes_nothing(monkeypatch) -> None:+ from jarvis.core import config_writer++ monkeypatch.setattr(wizard, "_ollama_reachable", lambda **kw: True)+ monkeypatch.setattr(wizard, "_ask", lambda *a, **kw: "n")+ pinned: list[str] = []+ monkeypatch.setattr(config_writer, "set_brain_primary", lambda name: pinned.append(name))++ assert wizard._offer_local_brain() is False+ assert pinned == []+++def test_probe_failure_is_a_quiet_no(monkeypatch) -> None:+ """A refused connection is the NORMAL no-server state — never an error."""++ class _Refused:+ def get(self, *a, **kw):+ raise OSError("connection refused")++ import httpx++ monkeypatch.setattr(httpx, "get", _Refused().get)+ assert wizard._ollama_reachable(timeout_s=0.01) is False