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): status/login/logout routes (own router module)
Ruben Lütkec6ecb66e0671
diff --git a/jarvis/ui/web/antigravity_routes.py b/jarvis/ui/web/antigravity_routes.pynew file mode 100644index 0000000000..d07a57b0c3--- /dev/null+++ b/jarvis/ui/web/antigravity_routes.py@@ -0,0 +1,72 @@+"""REST routes for the Antigravity (Google-subscription) provider connect flow.++OAuth-only: the user signs in with Google once (via the official ``agy``/``gemini``+CLI), and Jarvis drives that CLI as a subprocess to bill the Brain/Subagents+against the Google subscription — no API key. This is the Google sibling of the+``/api/codex/*`` routes in :mod:`jarvis.ui.web.provider_routes`.++Kept in its own router module (not folded into ``provider_routes``) so the+feature ships as a self-contained unit. Mount in the web server alongside the+other routers::++ from .antigravity_routes import router as antigravity_router+ app.include_router(antigravity_router)+"""+from __future__ import annotations++import logging+from typing import Any++from fastapi import APIRouter, HTTPException++from jarvis.google_cli.auth_service import GoogleCliAuthService++log = logging.getLogger(__name__)++router = APIRouter(prefix="/api", tags=["antigravity"])++# Shown to the user when no official Google CLI is installed. The Gemini CLI+# (``npm i -g @google/gemini-cli``) is the cross-platform fallback; ``agy`` is+# the official successor (macOS/Linux installer below).+_INSTALL_HINT = "curl -fsSL https://antigravity.google/cli/install.sh | bash"++[email protected]("/antigravity/status")+async def antigravity_status() -> dict[str, Any]:+ """Honest snapshot of the Google CLI login (installed / connected / account)."""+ return GoogleCliAuthService().status().to_dict()++[email protected]("/antigravity/login")+async def antigravity_login() -> dict[str, Any]:+ """Start the interactive Google login in a terminal. 409 if no CLI is found."""+ service = GoogleCliAuthService()+ status = service.status()+ if not status.installed:+ raise HTTPException(+ status_code=409,+ detail={"message": "No Google CLI found", "install_command": _INSTALL_HINT},+ )+ try:+ proc = service.start_login()+ except FileNotFoundError as exc:+ raise HTTPException(status_code=409, detail=str(exc)) from exc+ except Exception as exc: # noqa: BLE001+ raise HTTPException(+ status_code=500,+ detail=f"Google login could not be started: {type(exc).__name__}: {exc}",+ ) from exc+ return {"ok": True, "pid": proc.pid, "message": "Google login was started in the terminal"}++[email protected]("/antigravity/logout")+async def antigravity_logout() -> dict[str, Any]:+ """Disconnect the Google login (removes the on-disk creds / agy logout)."""+ service = GoogleCliAuthService()+ status = service.status()+ if not status.installed:+ raise HTTPException(status_code=409, detail="No Google CLI found")+ ok, error = service.logout_blocking()+ if not ok:+ raise HTTPException(status_code=500, detail=error or "Google logout failed")+ return {"ok": True, "message": "Antigravity (Google) was disconnected"}diff --git a/tests/integration/test_antigravity_routes.py b/tests/integration/test_antigravity_routes.pynew file mode 100644index 0000000000..85651f0ffb--- /dev/null+++ b/tests/integration/test_antigravity_routes.py@@ -0,0 +1,71 @@+"""Routes for the Antigravity (Google-subscription) provider connect flow."""+from __future__ import annotations++from fastapi import FastAPI+from fastapi.testclient import TestClient++from jarvis.google_cli.auth_service import GoogleCliAuthStatus+from jarvis.ui.web import antigravity_routes+++def _client(monkeypatch, *, status: GoogleCliAuthStatus, login_raises=None):+ class _FakeService:+ def status(self):+ return status++ def start_login(self):+ if login_raises is not None:+ raise login_raises++ class _P:+ pid = 999++ return _P()++ def logout_blocking(self):+ return True, None++ monkeypatch.setattr(+ antigravity_routes, "GoogleCliAuthService", lambda *a, **k: _FakeService()+ )+ app = FastAPI()+ app.include_router(antigravity_routes.router)+ return TestClient(app)+++def test_status_connected(monkeypatch):+ st = GoogleCliAuthStatus(+ installed=True, connected=True, mode="oauth-personal",+ cli_kind="gemini", user_email="[email protected]", message="ok",+ )+ client = _client(monkeypatch, status=st)+ resp = client.get("/api/antigravity/status")+ assert resp.status_code == 200+ body = resp.json()+ assert body["installed"] is True+ assert body["connected"] is True+ assert body["mode"] == "oauth-personal"+ assert body["cli_kind"] == "gemini"+++def test_login_409_when_not_installed(monkeypatch):+ st = GoogleCliAuthStatus(installed=False, connected=False)+ client = _client(monkeypatch, status=st)+ resp = client.post("/api/antigravity/login")+ assert resp.status_code == 409+++def test_login_ok_when_installed(monkeypatch):+ st = GoogleCliAuthStatus(installed=True, connected=False)+ client = _client(monkeypatch, status=st)+ resp = client.post("/api/antigravity/login")+ assert resp.status_code == 200+ assert resp.json()["pid"] == 999+++def test_logout_ok(monkeypatch):+ st = GoogleCliAuthStatus(installed=True, connected=True)+ client = _client(monkeypatch, status=st)+ resp = client.post("/api/antigravity/logout")+ assert resp.status_code == 200+ assert resp.json()["ok"] is True