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: jarvis-chat kit tools, headless browser deps, keyless Jarvis-Agent (#241)
Ruben Lütke40bd918293d5
diff --git a/jarvis/agent_chat/runner_brain.py b/jarvis/agent_chat/runner_brain.pyindex d5b9712fae..c94051dd6f 100644--- a/jarvis/agent_chat/runner_brain.py+++ b/jarvis/agent_chat/runner_brain.py@@ -212,6 +212,7 @@ async def kit_payload(session: AgentChatSession, brain: Any) -> tuple[dict[str,cfg = getattr(brain, "_config", None)tools: dict[str, Tool] | None = Noneextra = ""+ coding_tool: Tool | None = Noneif session.surface == "jarvis":from jarvis.society.surface import coding_tool_for_session@@ -228,6 +229,10 @@ async def kit_payload(session: AgentChatSession, brain: Any) -> tuple[dict[str,except Exception as exc: # noqa: BLE001 - the turn runs without the kit's handslog.warning("surface %s: kit tools not built: %s", session.surface, exc, exc_info=True)tools = {}+ if coding_tool is not None:+ # The kit's own hands replace the folder set; the granted+ # coding-session control must survive that replacement.+ tools = {**(tools or {}), coding_tool.name: coding_tool}elif kit.tools is not None:try:tools = kit.tools(cfg, brain)diff --git a/jarvis/brain/app_control.py b/jarvis/brain/app_control.pyindex 0eb11e43fe..beb42d47ef 100644--- a/jarvis/brain/app_control.py+++ b/jarvis/brain/app_control.py@@ -880,7 +880,12 @@ async def _switch_subagent("error_kind": "unknown_provider","error": (f"{provider!r} is not a {brand}-capable provider. Available: {known}."),}- has_credential = bool(cfg_mod.get_jarvis_agent_secret(canon))+ # Keyless local providers (Ollama, local OpenAI-compatible servers) have+ # no Agent key slot at all, so demanding one bricks the only setup a+ # keyless user has (AP-21/22).+ has_credential = canon in _NO_CREDENTIAL_PROVIDERS or bool(+ cfg_mod.get_jarvis_agent_secret(canon)+ )if canon == "claude-api" and not has_credential:try:from jarvis.missions.isolation.env import read_live_claude_oauth_tokendiff --git a/jarvis/society/browser/install.py b/jarvis/society/browser/install.pyindex 8794d350a1..3d56ccc7d6 100644--- a/jarvis/society/browser/install.py+++ b/jarvis/society/browser/install.py@@ -7,6 +7,7 @@ import jsonimport loggingimport osimport platform+import shutilimport subprocessimport sysimport threading@@ -231,6 +232,43 @@ def _run(cmd: list[str], *, env: dict[str, str], timeout: float = 900) -> str:proc.wait()+def _system_deps_installable() -> bool:+ """Whether ``playwright install-deps`` can run without a password prompt.++ It needs root: either the process already is root, or ``sudo`` works+ non-interactively. A headless or WSL install without passwordless sudo+ would otherwise stop at "a password is required" and fail the whole setup.+ """+ geteuid = getattr(os, "geteuid", None)+ if geteuid is not None and geteuid() == 0:+ return True+ sudo = shutil.which("sudo")+ if sudo is None:+ return False+ try:+ probe = subprocess.run(+ [sudo, "-n", "true"],+ stdin=subprocess.DEVNULL,+ stdout=subprocess.DEVNULL,+ stderr=subprocess.DEVNULL,+ timeout=10,+ check=False,+ creationflags=NO_WINDOW_CREATIONFLAGS,+ )+ except (OSError, subprocess.TimeoutExpired):+ log.debug("Passwordless sudo probe failed", exc_info=True)+ return False+ return probe.returncode == 0+++def _system_deps_hint(python: Path) -> str:+ return (+ "The browser's system libraries are missing and could not be installed "+ "without a password. Run once in a terminal: "+ f"sudo {python} -m playwright install-deps chromium"+ )++def ensure_installed(data_dir: Path | None = None, *, repair: bool = False, system_dependencies: bool = False) -> dict[str, Any]:@@ -292,8 +330,13 @@ def ensure_installed(env=env,)_set(data_dir, percent=60, detail="Downloading the managed browser")+ deps_skipped = Falseif system_dependencies and sys.platform.startswith("linux"):- _run([str(python), "-m", "playwright", "install-deps", "chromium"], env=env)+ if _system_deps_installable():+ _run([str(python), "-m", "playwright", "install-deps", "chromium"], env=env)+ else:+ deps_skipped = True+ log.warning("%s", _system_deps_hint(python))_run([str(python), "-m", "playwright", "install", "chromium", "--no-shell"], env=env)_set(data_dir,@@ -301,17 +344,24 @@ def ensure_installed(percent=90,detail="Checking browser rendering and input",)- output = _run(- [str(python), str(runner_path()), "--probe"],- env=worker_env(data_dir),- timeout=120,- )+ try:+ output = _run(+ [str(python), str(runner_path()), "--probe"],+ env=worker_env(data_dir),+ timeout=120,+ )+ except RuntimeError as exc:+ if deps_skipped:+ raise RuntimeError(_system_deps_hint(python)) from exc+ raiselines = [json.loads(line)for line in output.splitlines()if line.startswith('{"kind": "probe"')]if not lines or not lines[-1].get("ok"):+ if deps_skipped:+ raise RuntimeError(_system_deps_hint(python))raise RuntimeError(f"Browser render check failed: {output[-1500:]}")probe = lines[-1]executable = Path(probe["executable"]).resolve()diff --git a/jarvis/society/browser/tool.py b/jarvis/society/browser/tool.pyindex b3636fcdce..671019d65e 100644--- a/jarvis/society/browser/tool.py+++ b/jarvis/society/browser/tool.py@@ -63,7 +63,11 @@ def lead_browser_tools(session: Any = None, *, read_only: bool = False) -> dict[runtime = current_runtime()if runtime is None:return {}- pick = (session.provider, session.model) if session is not None else None+ # Not every surface passes a full ChatSession (the jarvis-chat kit hands+ # over a lightweight namespace), so only pin a model when both are known.+ provider = getattr(session, "provider", None)+ model = getattr(session, "model", None)+ pick = (provider, model) if provider and model else Nonereturn {BROWSER_TOOL_NAME: BrowserTool(runtime,diff --git a/tests/unit/brain/test_keyless_agent_switch.py b/tests/unit/brain/test_keyless_agent_switch.pynew file mode 100644index 0000000000..bca346fd15--- /dev/null+++ b/tests/unit/brain/test_keyless_agent_switch.py@@ -0,0 +1,34 @@+"""A keyless local provider must activate as the Jarvis-Agent without a key (#223)."""++from __future__ import annotations++import pytest++from jarvis.brain import app_control+from jarvis.core.config import JarvisConfig+from jarvis.missions.worker_runtime.provider_map import JARVIS_TO_WORKER_SLUG++# Every keyless provider that can also run as the Jarvis-Agent.+KEYLESS_AGENTS = sorted(app_control.LOCAL_PROVIDERS & set(JARVIS_TO_WORKER_SLUG))++[email protected]("provider", KEYLESS_AGENTS)+async def test_local_provider_switches_without_a_saved_key(monkeypatch, provider) -> None:+ assert "ollama" in KEYLESS_AGENTS+ monkeypatch.setattr(app_control.cfg_mod, "get_jarvis_agent_secret", lambda _p: None)+ result = await app_control._switch_subagent(+ provider, cfg=JarvisConfig(), persist=False, old=None+ )+ assert result["ok"], result+ assert result["new_provider"] == provider+++async def test_keyed_provider_without_a_key_is_still_refused(monkeypatch) -> None:+ monkeypatch.setattr(app_control.cfg_mod, "get_jarvis_agent_secret", lambda _p: None)+ result = await app_control._switch_subagent(+ "openai", cfg=JarvisConfig(), persist=False, old=None+ )+ assert not result["ok"]+ assert result["error_kind"] == "missing_credential"diff --git a/tests/unit/society/test_browser_install.py b/tests/unit/society/test_browser_install.pyindex 670c017d2e..c3f6e5f64c 100644--- a/tests/unit/society/test_browser_install.py+++ b/tests/unit/society/test_browser_install.py@@ -88,6 +88,49 @@ def test_missing_binary_and_corrupt_marker_trigger_repair(installer):assert len(launches) == 3+def _calls(monkeypatch):+ """Pretend to be Linux and record every command the installer runs."""+ from jarvis.society.browser import bootstrap++ monkeypatch.setattr(install.sys, "platform", "linux")+ monkeypatch.setattr(bootstrap, "ensure_uv", lambda _root: Path("uv"))+ seen = []+ original = install._run++ def run(cmd, **kwargs):+ seen.append(cmd)+ return original(cmd, **kwargs)++ monkeypatch.setattr(install, "_run", run)+ return seen+++def test_system_deps_install_when_root_or_passwordless_sudo(installer, monkeypatch):+ data, _, _, _ = installer+ monkeypatch.setattr(install, "_system_deps_installable", lambda: True)+ seen = _calls(monkeypatch)+ install.ensure_installed(data, system_dependencies=True)+ assert any("install-deps" in cmd for cmd in seen)+++def test_system_deps_skipped_without_passwordless_sudo(installer, monkeypatch):+ data, _, _, _ = installer+ monkeypatch.setattr(install, "_system_deps_installable", lambda: False)+ seen = _calls(monkeypatch)+ install.ensure_installed(data, system_dependencies=True)+ assert not any("install-deps" in cmd for cmd in seen)+ assert install.is_installed(data)+++def test_skipped_system_deps_explain_the_fix_when_the_browser_fails(installer, monkeypatch):+ data, _, _, failure = installer+ monkeypatch.setattr(install, "_system_deps_installable", lambda: False)+ _calls(monkeypatch)+ failure["stage"] = "--probe"+ with pytest.raises(RuntimeError, match="sudo .* -m playwright install-deps chromium"):+ install.ensure_installed(data, system_dependencies=True)++def test_lock_identity_survives_platform_line_endings(installer, monkeypatch, tmp_path):data, root, _, _ = installerinstall.ensure_installed(data)