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(clis): live Test button for the Claude/Codex/Antigravity agent cards
Ruben Lütke378a25f459e1
diff --git a/jarvis/agent_cli_probe.py b/jarvis/agent_cli_probe.pynew file mode 100644index 0000000000..95372ee5bf--- /dev/null+++ b/jarvis/agent_cli_probe.py@@ -0,0 +1,218 @@+"""Live installation test for the agent CLIs (Claude / Codex / Antigravity).++Backs the "Test" button on the three agent connection cards: an on-demand,+cache-busting probe that answers *is this CLI REALLY installed, where, which+version, and is it logged in?* — with the searched PATH directories included,+so a miss is diagnosable instead of a bare "not installed" (the recurring+macOS symptom: the CLI is installed for the user's shell, but the GUI-launched+process searches a minimal PATH and cannot see it).++Design:++* Re-runs :func:`jarvis.core.path_augment.ensure_cli_paths` first, so a CLI+ installed *after* app start (winget/npm just finished) becomes visible+ without a restart.+* Clears the per-process ``--version`` caches (Claude/Codex) so the result is+ a genuine spawn of the binary — proving it is executable, not just present.+* Never raises to the caller: every failure degrades to an honest+ ``ok=False`` result with a message.++All functions are synchronous/blocking (subprocess probes with tight+timeouts); routes must call them via ``asyncio.to_thread``.+"""+from __future__ import annotations++import os+import subprocess+import time+from dataclasses import dataclass, field+from typing import Any, Literal++from jarvis.core.path_augment import ensure_cli_paths+from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS++_VERSION_TIMEOUT_S = 8.0++AgentCliName = Literal["claude", "codex", "antigravity"]+++@dataclass(frozen=True)+class AgentCliTestResult:+ """Outcome of one live CLI test — display-safe, no secret ever included."""++ cli: str+ ok: bool # binary found AND a live version spawn answered+ installed: bool+ binary_path: str | None+ version: str | None+ connected: bool+ auth_mode: str+ account: str | None+ message: str+ searched_path: list[str] = field(default_factory=list)+ duration_ms: int = 0+ cli_kind: str | None = None # antigravity only: "agy" | "gemini"++ def to_dict(self) -> dict[str, Any]:+ return {+ "cli": self.cli,+ "ok": self.ok,+ "installed": self.installed,+ "binary_path": self.binary_path,+ "version": self.version,+ "connected": self.connected,+ "auth_mode": self.auth_mode,+ "account": self.account,+ "message": self.message,+ "searched_path": self.searched_path,+ "duration_ms": self.duration_ms,+ "cli_kind": self.cli_kind,+ }+++def _searched_path_dirs() -> list[str]:+ return [p for p in os.environ.get("PATH", "").split(os.pathsep) if p]+++def _live_version(argv: list[str]) -> str | None:+ """Spawn ``<cli> --version`` and return the trimmed output, ``None`` on failure."""+ try:+ proc = subprocess.run(+ [*argv, "--version"],+ capture_output=True,+ text=True,+ timeout=_VERSION_TIMEOUT_S,+ creationflags=NO_WINDOW_CREATIONFLAGS,+ )+ except (OSError, subprocess.SubprocessError):+ return None+ out = (proc.stdout or proc.stderr or "").strip()+ return out or None+++def _not_installed(cli: str, hint: str, t0: float) -> AgentCliTestResult:+ return AgentCliTestResult(+ cli=cli,+ ok=False,+ installed=False,+ binary_path=None,+ version=None,+ connected=False,+ auth_mode="unknown",+ account=None,+ message=f"Binary not found on the app's PATH. {hint}",+ searched_path=_searched_path_dirs(),+ duration_ms=int((time.monotonic() - t0) * 1000),+ )+++def test_claude() -> AgentCliTestResult:+ from jarvis import claude_auth++ t0 = time.monotonic()+ ensure_cli_paths()+ claude_auth.clear_version_cache()+ status = claude_auth.ClaudeAuthService().status()+ if not status.installed:+ return _not_installed(+ "claude", "Install with: npm i -g @anthropic-ai/claude-code", t0+ )+ # status() already paid a fresh (cache-cleared) --version spawn; a None+ # version therefore means the binary exists but did not answer.+ ok = status.version is not None+ message = status.message if ok else (+ f"Found at {status.binary_path}, but 'claude --version' did not answer "+ "— the install looks broken."+ )+ return AgentCliTestResult(+ cli="claude",+ ok=ok,+ installed=True,+ binary_path=status.binary_path,+ version=status.version,+ connected=status.connected,+ auth_mode=status.mode,+ account=status.user_email or status.account_label,+ message=message,+ searched_path=_searched_path_dirs(),+ duration_ms=int((time.monotonic() - t0) * 1000),+ )+++def test_codex(binary_path: str | None = None) -> AgentCliTestResult:+ from jarvis import codex_auth++ t0 = time.monotonic()+ ensure_cli_paths()+ codex_auth.clear_version_cache()+ status = codex_auth.CodexAuthService(binary_path).status()+ if not status.installed:+ return _not_installed("codex", "Install with: npm i -g @openai/codex", t0)+ ok = status.version is not None+ message = status.message if ok else (+ f"Found at {status.binary_path}, but 'codex --version' did not answer "+ "— the install looks broken."+ )+ return AgentCliTestResult(+ cli="codex",+ ok=ok,+ installed=True,+ binary_path=status.binary_path,+ version=status.version,+ connected=status.connected,+ auth_mode=status.mode,+ account=status.user_email,+ message=message,+ searched_path=_searched_path_dirs(),+ duration_ms=int((time.monotonic() - t0) * 1000),+ )+++def test_antigravity() -> AgentCliTestResult:+ from jarvis.google_cli.auth_service import GoogleCliAuthService+ from jarvis.google_cli.resolver import resolve_google_cli++ t0 = time.monotonic()+ ensure_cli_paths()+ cli = resolve_google_cli()+ if cli is None:+ return _not_installed(+ "antigravity",+ "Install Antigravity (agy) or the Gemini CLI (npm i -g @google/gemini-cli)",+ t0,+ )+ # The resolver never runs the binary — do it here so "installed" is proven+ # executable, and so the card can show which CLI actually answered.+ version = _live_version(list(cli.argv_prefix))+ status = GoogleCliAuthService().status()+ kind_label = "Antigravity (agy)" if cli.kind == "agy" else "the Gemini CLI"+ if version is None:+ message = (+ f"Found {kind_label} at {cli.argv_prefix[0]}, but '--version' did "+ "not answer — the install looks broken."+ )+ else:+ message = f"{kind_label.capitalize()} answered. {status.message}"+ return AgentCliTestResult(+ cli="antigravity",+ ok=version is not None,+ installed=True,+ binary_path=cli.argv_prefix[0] if cli.argv_prefix else None,+ version=version,+ connected=status.connected,+ auth_mode=status.mode,+ account=status.user_email,+ message=message,+ searched_path=_searched_path_dirs(),+ duration_ms=int((time.monotonic() - t0) * 1000),+ cli_kind=cli.kind,+ )+++__all__ = [+ "AgentCliName",+ "AgentCliTestResult",+ "test_antigravity",+ "test_claude",+ "test_codex",+]diff --git a/jarvis/google_cli/auth_service.py b/jarvis/google_cli/auth_service.pyindex d92fb80120..d2e218cc49 100644--- a/jarvis/google_cli/auth_service.py+++ b/jarvis/google_cli/auth_service.py@@ -165,8 +165,14 @@ class GoogleCliAuthService:)email = _email_from_accounts(_gemini_home()) if connected else None+ # Name WHAT was detected: the card is titled "Antigravity", but the+ # resolver also accepts a Gemini-CLI install (incl. a PATH-less npm+ # bundle). Without the kind in the message, a machine that never+ # installed agy shows a bare "Installed" and the user rightly asks+ # "installed WHAT?" (test-machine report 2026-07-18).+ kind_label = "Antigravity (agy)" if cli.kind == "agy" else "Gemini CLI"if not connected:- message = "Installed but not logged in — run the Google login."+ message = f"{kind_label} installed but not logged in — run the Google login."elif mode == "oauth-personal":message = (f"Connected via Google subscription ({email})."diff --git a/jarvis/ui/web/antigravity_routes.py b/jarvis/ui/web/antigravity_routes.pyindex 9aa321303e..71d6410111 100644--- a/jarvis/ui/web/antigravity_routes.py+++ b/jarvis/ui/web/antigravity_routes.py@@ -49,6 +49,20 @@ async def antigravity_status() -> dict[str, Any]:return GoogleCliAuthService().status().to_dict()[email protected]("/antigravity/test")+async def antigravity_test() -> dict[str, Any]:+ """Live CLI test: which Google CLI resolved (agy vs Gemini), version, login.++ Re-augments PATH first, so a CLI installed after app start is found without+ a restart. Runs off the event loop — the probe spawns the real binary.+ """+ import asyncio++ from jarvis.agent_cli_probe import test_antigravity++ return (await asyncio.to_thread(test_antigravity)).to_dict()++@router.post("/antigravity/login")async def antigravity_login() -> dict[str, Any]:"""Start the interactive Google login in a terminal. 409 if no CLI is found."""diff --git a/jarvis/ui/web/claude_routes.py b/jarvis/ui/web/claude_routes.pyindex 5d29fe6c5b..aa3fa19154 100644--- a/jarvis/ui/web/claude_routes.py+++ b/jarvis/ui/web/claude_routes.py@@ -61,6 +61,20 @@ async def claude_status() -> dict[str, Any]:return _service().status().to_dict()[email protected]("/claude/test")+async def claude_test() -> dict[str, Any]:+ """Live CLI test: cache-busting binary + version + login probe.++ Re-augments PATH first, so a CLI installed after app start is found without+ a restart. Runs off the event loop — the probe spawns the real binary.+ """+ import asyncio++ from jarvis.agent_cli_probe import test_claude++ return (await asyncio.to_thread(test_claude)).to_dict()++@router.post("/claude/login")async def claude_login() -> dict[str, Any]:"""Start the interactive Claude sign-in in a terminal. 409 if no CLI is found."""diff --git a/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx b/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsxindex f8c374e70f..707a17e9cc 100644--- a/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx+++ b/jarvis/ui/web/frontend/src/components/JarvisAgentSection.tsx@@ -1,5 +1,5 @@import { useCallback, useEffect, useState } from "react";-import { ArrowUp, Bot, CreditCard, Laptop, Lock, LogIn, LogOut, Sparkles, Terminal, type LucideIcon } from "lucide-react";+import { ArrowUp, Bot, CreditCard, FlaskConical, Laptop, Lock, LogIn, LogOut, Sparkles, Terminal, type LucideIcon } from "lucide-react";import { agentBrandNow, useAgentBrand } from "@/lib/agentBrand";import { cn } from "@/lib/utils";import { useT } from "@/i18n";@@ -13,6 +13,8 @@ import {saveSubagentModel,startCodexLogin,switchSubagentProvider,+ testAgentCli,+ type AgentCliTestResult,type AntigravityStatus,type Billing,type ClaudeStatus,@@ -732,6 +734,102 @@ function ConnectButton({);}+/**+ * "Test" button + inline result panel shared by the three agent-CLI cards.+ *+ * POSTs the card's live-test endpoint (the backend re-augments PATH, clears+ * the version caches, and spawns the real binary), then reports found /+ * not-found with the binary path, version and login state. A miss lists the+ * PATH directories that were searched — making "installed in the shell but+ * invisible to the app" (the macOS GUI-PATH trap) diagnosable on the card.+ */+function CliTestControl({+ endpoint,+ onChanged,+}: {+ endpoint: string;+ onChanged?: () => void | Promise<void>;+}) {+ const [running, setRunning] = useState(false);+ const [result, setResult] = useState<AgentCliTestResult | null>(null);+ const [error, setError] = useState<string | null>(null);++ async function run() {+ setRunning(true);+ setError(null);+ try {+ setResult(await testAgentCli(endpoint));+ // The test may have just discovered a freshly-installed CLI (PATH was+ // re-augmented) — refresh the section so the card state follows.+ await onChanged?.();+ } catch (e) {+ setResult(null);+ setError((e as Error).message);+ } finally {+ setRunning(false);+ }+ }++ return (+ <>+ <button+ type="button"+ onClick={run}+ disabled={running}+ data-agent-card-control+ className="inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-muted-foreground hover:text-foreground disabled:opacity-50"+ >+ <FlaskConical className={cn("h-3.5 w-3.5", running && "animate-pulse")} />+ {running ? "Testing…" : "Test"}+ </button>+ {(result || error) && (+ <div+ data-agent-card-control+ className="basis-full rounded-lg border border-border bg-muted/40 p-2 text-[11px] leading-relaxed"+ >+ {error ? (+ <p className="text-red-500">Test failed: {error}</p>+ ) : result ? (+ <>+ <p className={result.ok ? "text-emerald-600" : "text-amber-600"}>+ {result.ok ? "✓ " : "✗ "}+ {result.message}+ </p>+ {result.installed && (+ <p className="mt-1 text-muted-foreground">+ {result.binary_path && (+ <>+ Binary: <code className="break-all">{result.binary_path}</code>+ <br />+ </>+ )}+ {result.version && <>Version: {result.version} · </>}+ Login: {result.connected ? `connected (${result.auth_mode})` : "not connected"}+ {result.account ? ` · ${result.account}` : ""}+ </p>+ )}+ {!result.installed && result.searched_path.length > 0 && (+ <details className="mt-1 text-muted-foreground">+ <summary className="cursor-pointer select-none">+ Searched {result.searched_path.length} PATH directories+ </summary>+ <ul className="mt-1 max-h-32 overflow-y-auto">+ {result.searched_path.map((p) => (+ <li key={p} className="break-all">+ {p}+ </li>+ ))}+ </ul>+ </details>+ )}+ </>+ ) : null}+ </div>+ )}+ </>+ );+}+/** Disconnect (ghost) action shared by the OAuth-login cards. */function DisconnectButton({onClick,@@ -870,6 +968,7 @@ function CodexConnectionCard({) : (<ConnectButton onClick={connect} disabled={pending || !installed} />)}+ <CliTestControl endpoint="/api/codex/test" onChanged={onChanged} /></>}/>@@ -965,6 +1064,7 @@ function AntigravityConnectionCard({) : (<ConnectButton onClick={connect} disabled={pending || !installed} />)}+ <CliTestControl endpoint="/api/antigravity/test" onChanged={onChanged} /></>}/>@@ -1063,6 +1163,7 @@ function ClaudeConnectionCard({) : (<ConnectButton onClick={connect} disabled={pending || !installed} />)}+ <CliTestControl endpoint="/api/claude/test" onChanged={onChanged} /></>}/>diff --git a/jarvis/ui/web/frontend/src/hooks/useProviders.ts b/jarvis/ui/web/frontend/src/hooks/useProviders.tsindex d4a8d1a47e..2c4d27d945 100644--- a/jarvis/ui/web/frontend/src/hooks/useProviders.ts+++ b/jarvis/ui/web/frontend/src/hooks/useProviders.ts@@ -434,6 +434,36 @@ export async function codexLogout(): Promise<void> {}}+/**+ * Result of a live agent-CLI test (POST /api/{claude,codex,antigravity}/test).+ * Cache-busting on the backend: PATH re-augmented, the real binary spawned —+ * so the card can show WHERE the CLI was found (or which dirs were searched).+ */+export interface AgentCliTestResult {+ cli: string;+ ok: boolean;+ installed: boolean;+ binary_path: string | null;+ version: string | null;+ connected: boolean;+ auth_mode: string;+ account: string | null;+ message: string;+ searched_path: string[];+ duration_ms: number;+ cli_kind: string | null;+}++/** Runs the live CLI test behind the "Test" button on the agent cards. */+export async function testAgentCli(endpoint: string): Promise<AgentCliTestResult> {+ const res = await fetch(endpoint, { method: "POST" });+ const body = await res.json().catch(() => ({}));+ if (!res.ok) {+ throw new Error(body.detail ?? `HTTP ${res.status}`);+ }+ return body as AgentCliTestResult;+}+/*** Starts the interactive "Sign in with Google" flow by driving the official* `agy`/`gemini` CLI as a subprocess (POST /api/antigravity/login). The Googlediff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.pyindex 94ebd40485..e4027bf438 100644--- a/jarvis/ui/web/provider_routes.py+++ b/jarvis/ui/web/provider_routes.py@@ -2107,6 +2107,21 @@ async def codex_status(request: Request) -> dict[str, Any]:return CodexAuthService(_codex_binary_path(request)).status().to_dict()[email protected]("/codex/test")+async def codex_test(request: Request) -> dict[str, Any]:+ """Live CLI test: cache-busting binary + version + login probe.++ Re-augments PATH first, so a CLI installed after app start is found without+ a restart. Runs off the event loop — the probe spawns the real binary.+ """+ import asyncio++ from jarvis.agent_cli_probe import test_codex++ binary_path = _codex_binary_path(request)+ return (await asyncio.to_thread(test_codex, binary_path)).to_dict()++@router.post("/codex/binary-path")async def codex_set_binary_path(body: CodexBinaryPathBody, request: Request) -> dict[str, Any]:value = body.binary_path.strip()diff --git a/tests/unit/test_agent_cli_probe.py b/tests/unit/test_agent_cli_probe.pynew file mode 100644index 0000000000..4954ed5f5d--- /dev/null+++ b/tests/unit/test_agent_cli_probe.py@@ -0,0 +1,164 @@+"""Tests for jarvis.agent_cli_probe — the live "Test" button probe.++Contract under guard: the probe never raises, reports an honest not-installed+result WITH the searched PATH (so a GUI-PATH miss is diagnosable), busts the+version caches so a test is a real spawn, and names which Google CLI resolved+(agy vs Gemini) on the Antigravity card.+"""+from __future__ import annotations++import pytest++from jarvis import agent_cli_probe, claude_auth, codex_auth+from jarvis.claude_auth import ClaudeAuthStatus+from jarvis.codex_auth import CodexAuthStatus+from jarvis.google_cli.resolver import GoogleCli++[email protected](autouse=True)+def _quiet_path_augment(monkeypatch):+ """Keep the probe from mutating the test process PATH."""+ monkeypatch.setattr(agent_cli_probe, "ensure_cli_paths", lambda: [])+++def test_claude_not_installed_reports_searched_path(monkeypatch):+ monkeypatch.setattr(+ claude_auth.ClaudeAuthService,+ "status",+ lambda self: ClaudeAuthStatus(installed=False),+ )+ result = agent_cli_probe.test_claude()+ assert result.ok is False+ assert result.installed is False+ assert result.searched_path, "a miss must list the searched PATH dirs"+ assert "npm i -g @anthropic-ai/claude-code" in result.message+++def test_claude_installed_and_answering_is_ok(monkeypatch):+ monkeypatch.setattr(+ claude_auth.ClaudeAuthService,+ "status",+ lambda self: ClaudeAuthStatus(+ installed=True,+ connected=True,+ mode="subscription",+ message="Connected via Claude Max.",+ version="2.1.0",+ user_email="[email protected]",+ binary_path="/usr/local/bin/claude",+ ),+ )+ result = agent_cli_probe.test_claude()+ assert result.ok is True+ assert result.binary_path == "/usr/local/bin/claude"+ assert result.version == "2.1.0"+ assert result.connected is True+ assert result.account == "[email protected]"+++def test_claude_present_but_mute_binary_is_not_ok(monkeypatch):+ """Binary resolves but --version never answered → honest broken-install."""+ monkeypatch.setattr(+ claude_auth.ClaudeAuthService,+ "status",+ lambda self: ClaudeAuthStatus(+ installed=True, version=None, binary_path="/x/claude"+ ),+ )+ result = agent_cli_probe.test_claude()+ assert result.ok is False+ assert result.installed is True+ assert "did not answer" in result.message+++def test_claude_test_busts_the_version_cache(monkeypatch):+ calls: list[str] = []+ monkeypatch.setattr(+ claude_auth, "clear_version_cache", lambda: calls.append("cleared")+ )+ monkeypatch.setattr(+ claude_auth.ClaudeAuthService,+ "status",+ lambda self: ClaudeAuthStatus(installed=False),+ )+ agent_cli_probe.test_claude()+ assert calls == ["cleared"]+++def test_codex_honors_configured_binary_path(monkeypatch):+ seen: dict[str, str | None] = {}++ real_init = codex_auth.CodexAuthService.__init__++ def spy_init(self, binary_path=None):+ seen["binary_path"] = binary_path+ real_init(self, binary_path)++ monkeypatch.setattr(codex_auth.CodexAuthService, "__init__", spy_init)+ monkeypatch.setattr(+ codex_auth.CodexAuthService,+ "status",+ lambda self: CodexAuthStatus(installed=False),+ )+ result = agent_cli_probe.test_codex("/custom/codex")+ assert seen["binary_path"] == "/custom/codex"+ assert result.ok is False+ assert "npm i -g @openai/codex" in result.message+++def test_antigravity_names_the_resolved_cli_kind(monkeypatch):+ from jarvis.google_cli import auth_service as gsvc++ monkeypatch.setattr(+ "jarvis.google_cli.resolver.resolve_google_cli",+ lambda: GoogleCli(kind="gemini", argv_prefix=["/usr/local/bin/gemini"]),+ )+ monkeypatch.setattr(agent_cli_probe, "_live_version", lambda argv: "0.9.0")+ monkeypatch.setattr(+ gsvc.GoogleCliAuthService,+ "status",+ lambda self: gsvc.GoogleCliAuthStatus(+ installed=True,+ connected=False,+ mode="unknown",+ cli_kind="gemini",+ message="Gemini CLI installed but not logged in — run the Google login.",+ ),+ )+ result = agent_cli_probe.test_antigravity()+ assert result.ok is True+ assert result.cli_kind == "gemini"+ assert "Gemini CLI" in result.message+++def test_antigravity_not_installed(monkeypatch):+ monkeypatch.setattr(+ "jarvis.google_cli.resolver.resolve_google_cli", lambda: None+ )+ result = agent_cli_probe.test_antigravity()+ assert result.ok is False+ assert result.installed is False+ assert result.searched_path+++def test_results_serialize_without_secrets(monkeypatch):+ monkeypatch.setattr(+ claude_auth.ClaudeAuthService,+ "status",+ lambda self: ClaudeAuthStatus(installed=False),+ )+ payload = agent_cli_probe.test_claude().to_dict()+ assert set(payload) == {+ "cli",+ "ok",+ "installed",+ "binary_path",+ "version",+ "connected",+ "auth_mode",+ "account",+ "message",+ "searched_path",+ "duration_ms",+ "cli_kind",+ }