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(antigravity): drive the real agy CLI (winget) over the Google subscription
Ruben Lütke298587f92dc6
diff --git a/jarvis/google_cli/resolver.py b/jarvis/google_cli/resolver.pyindex 58e765e537..86374ff4df 100644--- a/jarvis/google_cli/resolver.py+++ b/jarvis/google_cli/resolver.py@@ -17,6 +17,7 @@ import shutilimport subprocessimport sysfrom collections.abc import Callable+from contextlib import suppressfrom dataclasses import dataclass, fieldfrom jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS@@ -100,17 +101,53 @@ def _default_npm_bundle(return None+def _agy_winget_roots() -> list[str]:+ """Well-known locations where the winget ``Google.AntigravityCLI`` package and+ its PATH shim drop ``agy.exe`` (Windows). winget appends ``WinGet\\Links`` to+ the user PATH only after a shell restart, so the running process / a fresh+ subprocess does not see ``agy`` on PATH yet — probe the install dirs directly.+ """+ roots: list[str] = []+ local = os.environ.get("LOCALAPPDATA")+ if local:+ roots.append(os.path.join(local, "Microsoft", "WinGet", "Links"))+ pkgs = os.path.join(local, "Microsoft", "WinGet", "Packages")+ with suppress(OSError):+ for entry in os.listdir(pkgs):+ if entry.startswith("Google.AntigravityCLI"):+ roots.append(os.path.join(pkgs, entry))+ return roots+++def _default_agy_path(+ *,+ roots: list[str] | None = None,+ isfile: Callable[[str], bool] = os.path.isfile,+) -> str | None:+ """Path to a winget-installed ``agy.exe``, or ``None``. Best-effort, never raises."""+ for root in roots if roots is not None else _agy_winget_roots():+ cand = os.path.join(root, "agy.exe")+ if isfile(cand):+ return cand+ return None++def resolve_google_cli(*,which: Callable[[str], str | None] = shutil.which,npm_bundle: Callable[[], str | None] = _default_npm_bundle,+ agy_path: Callable[[], str | None] = _default_agy_path,) -> GoogleCli | None:- """Resolve the preferred official Google CLI. ``which``/``npm_bundle`` are- injectable seams for tests."""+ """Resolve the preferred official Google CLI. ``which``/``npm_bundle``/+ ``agy_path`` are injectable seams for tests. Order: Antigravity ``agy`` (on+ PATH, then its winget install dir) > Gemini CLI (on PATH, then npm bundle)."""for name in _AGY:path = which(name)if path:return GoogleCli(kind="agy", argv_prefix=[path])+ agy = agy_path()+ if agy:+ return GoogleCli(kind="agy", argv_prefix=[agy])for name in _GEMINI:path = which(name)if path:diff --git a/jarvis/plugins/brain/antigravity.py b/jarvis/plugins/brain/antigravity.pyindex 8a0db2a563..f7c77990ea 100644--- a/jarvis/plugins/brain/antigravity.py+++ b/jarvis/plugins/brain/antigravity.py@@ -29,7 +29,7 @@ from contextlib import suppressfrom jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGSfrom jarvis.core.protocols import BrainDelta, BrainRequest-from jarvis.google_cli.resolver import resolve_google_cli+from jarvis.google_cli.resolver import GoogleCli, resolve_google_clilog = logging.getLogger(__name__)@@ -105,6 +105,33 @@ def _build_cli_prompt(req: BrainRequest) -> str:return "\n".join(lines)+def _build_argv(cli: GoogleCli, prompt: str, model: str) -> list[str]:+ """Build the headless argv for the resolved CLI — flags differ per binary.++ * ``agy`` (Antigravity CLI 1.0.9): ``--print <prompt> --model <id>``. It has+ neither ``--approval-mode`` nor ``-o json`` (live ``agy --help`` 2026-06-20);+ output is plain text, which ``_parse_cli_answer`` handles via its raw+ fallback. A read-only conversational answer needs no tool permissions.+ * ``gemini`` (Gemini CLI): read-only ``--approval-mode plan`` + ``--skip-trust``+ (so the throwaway workdir is trusted and the sandbox policy is not loaded —+ forensic 2026-06-20) + ``-o json``.+ """+ if cli.kind == "agy":+ return [*cli.argv_prefix, "--print", prompt, "--model", model]+ return [+ *cli.argv_prefix,+ "-p",+ prompt,+ "-m",+ model,+ "--approval-mode",+ "plan",+ "--skip-trust",+ "-o",+ "json",+ ]++class AntigravityBrain:name: str = "antigravity"context_window: int = 1_048_576@@ -123,17 +150,7 @@ class AntigravityBrain:)prompt = _build_cli_prompt(req)- argv = [- *cli.argv_prefix,- "-p",- prompt,- "-m",- self._model,- "--approval-mode",- "plan",- "-o",- "json",- ]+ argv = _build_argv(cli, prompt, self._model)workdir = tempfile.mkdtemp(prefix="jarvis-antigravity-brain-")env = {k: v for k, v in os.environ.items() if k not in _DROP_ENV}creationflags = NO_WINDOW_CREATIONFLAGS if sys.platform == "win32" else 0diff --git a/tests/unit/google_cli/test_resolver.py b/tests/unit/google_cli/test_resolver.pyindex 2f7f4e8c7b..3ebeb953e5 100644--- a/tests/unit/google_cli/test_resolver.py+++ b/tests/unit/google_cli/test_resolver.py@@ -18,7 +18,7 @@ def test_falls_back_to_gemini_on_path():def which(name: str) -> str | None:return f"/usr/bin/{name}" if name in ("gemini", "gemini.cmd") else None- cli = resolve_google_cli(which=which, npm_bundle=lambda: None)+ cli = resolve_google_cli(which=which, npm_bundle=lambda: None, agy_path=lambda: None)assert cli is not Noneassert cli.kind == "gemini"assert cli.argv_prefix == ["/usr/bin/gemini"]@@ -31,14 +31,21 @@ def test_falls_back_to_npm_bundle(tmp_path):def which(name: str) -> str | None:return "/usr/bin/node" if name == "node" else None- cli = resolve_google_cli(which=which, npm_bundle=lambda: str(bundle))+ cli = resolve_google_cli(+ which=which, npm_bundle=lambda: str(bundle), agy_path=lambda: None+ )assert cli is not Noneassert cli.kind == "gemini"assert cli.argv_prefix == ["/usr/bin/node", str(bundle)]def test_none_when_nothing_available():- assert resolve_google_cli(which=lambda name: None, npm_bundle=lambda: None) is None+ assert (+ resolve_google_cli(+ which=lambda name: None, npm_bundle=lambda: None, agy_path=lambda: None+ )+ is None+ )def test_default_npm_bundle_finds_known_root(tmp_path):@@ -58,3 +65,32 @@ def test_default_npm_bundle_none_when_absent(tmp_path):from jarvis.google_cli.resolver import _default_npm_bundleassert _default_npm_bundle(roots=[str(tmp_path)], which=lambda n: None) is None+++def test_prefers_agy_via_winget_location_when_not_on_path(tmp_path):+ """winget installs agy.exe but does not put it on the live PATH until a shell+ restart, so resolve must probe the known install location (like the gemini+ bundle fallback) and still PREFER agy over the gemini CLI."""+ agy = tmp_path / "agy.exe"+ agy.write_text("// stub")++ def which(name: str) -> str | None:+ # agy not on PATH; the gemini CLI IS on PATH (must still lose to agy).+ return "/usr/bin/gemini" if name == "gemini" else None++ cli = resolve_google_cli(+ which=which, npm_bundle=lambda: None, agy_path=lambda: str(agy)+ )+ assert cli is not None+ assert cli.kind == "agy"+ assert cli.argv_prefix == [str(agy)]+++def test_default_agy_path_finds_winget_binary(tmp_path):+ from jarvis.google_cli.resolver import _default_agy_path++ links = tmp_path / "WinGet" / "Links"+ links.mkdir(parents=True)+ (links / "agy.exe").write_text("// stub")+ found = _default_agy_path(roots=[str(links)])+ assert found == str(links / "agy.exe")diff --git a/tests/unit/plugins/brain/test_antigravity_brain.py b/tests/unit/plugins/brain/test_antigravity_brain.pyindex 7f75d102c3..10db45c789 100644--- a/tests/unit/plugins/brain/test_antigravity_brain.py+++ b/tests/unit/plugins/brain/test_antigravity_brain.py@@ -92,6 +92,40 @@ async def test_complete_raises_without_cli(monkeypatch):pass+async def test_argv_trusts_the_ephemeral_workdir(monkeypatch):+ """The CLI must trust its own throwaway workdir, else it self-degrades.++ Forensic 2026-06-20: the brain spawned the Gemini CLI in a fresh+ ``tempfile.mkdtemp`` folder with ``--approval-mode plan``. Because that+ folder is not a trusted workspace, the CLI logged "Approval mode overridden+ to 'default' because the current folder is not trusted", then "Failed to+ parse default sandbox policy" and exited rc=1 with an empty answer — forcing+ a fallback to a different provider on every turn. ``--skip-trust`` trusts the+ workspace for the session so ``plan`` (read-only) mode survives and no+ sandbox policy is loaded.+ """+ monkeypatch.setattr(+ agmod, "resolve_google_cli",+ lambda: GoogleCli(kind="gemini", argv_prefix=["gemini"]),+ )+ captured: dict[str, object] = {}++ async def _fake_exec(*args, **kwargs):+ captured["argv"] = list(args)+ return _FakeProc(b'{"response": "ok"}')++ monkeypatch.setattr(asyncio, "create_subprocess_exec", _fake_exec)+ brain = AntigravityBrain()+ async for _ in brain.complete(_req()):+ pass+ argv = captured["argv"]+ assert "--skip-trust" in argv+ # Read-only conversational brain: approval mode stays "plan" (assert the+ # value of the flag, not just that the word appears somewhere in argv).+ assert argv[argv.index("--approval-mode") + 1] == "plan"++@pytest.mark.asyncioasync def test_complete_scrubs_api_key_env(monkeypatch):"""The child must not inherit GEMINI_API_KEY (so the subscription login wins)."""@@ -113,3 +147,31 @@ async def test_complete_scrubs_api_key_env(monkeypatch):env = captured["env"]assert env is not Noneassert "GEMINI_API_KEY" not in env+++def test_build_argv_agy_uses_print_and_model():+ """agy 1.0.9 has --print/--model but NOT the gemini-CLI flags --approval-mode+ / -o json / --skip-trust (forensic 2026-06-20, live `agy --help`)."""+ from jarvis.plugins.brain.antigravity import _build_argv++ cli = GoogleCli(kind="agy", argv_prefix=["agy"])+ argv = _build_argv(cli, "hello", "gemini-3.1-pro-preview")+ assert argv[0] == "agy"+ assert "--print" in argv+ assert "hello" in argv+ assert "--model" in argv+ assert "gemini-3.1-pro-preview" in argv+ assert "--approval-mode" not in argv+ assert "-o" not in argv+ assert "--skip-trust" not in argv+++def test_build_argv_gemini_keeps_skip_trust():+ """The Gemini-CLI branch is unchanged (read-only plan + skip-trust + json)."""+ from jarvis.plugins.brain.antigravity import _build_argv++ cli = GoogleCli(kind="gemini", argv_prefix=["gemini"])+ argv = _build_argv(cli, "hello", "gemini-3.5-flash")+ assert "--print" in argv or "-p" in argv+ assert "--skip-trust" in argv+ assert "plan" in argv