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(google-cli): detect keyring logins (#1029)
Jayden29a9d67f1138
diff --git a/dodaios/google_cli/auth_service.py b/dodaios/google_cli/auth_service.pyindex a05993fdc1..9669df0b68 100644--- a/dodaios/google_cli/auth_service.py+++ b/dodaios/google_cli/auth_service.py@@ -80,7 +80,56 @@ def _oauth_login_present(home: Path) -> bool:return Trueexcept OSError:continue- return False+ return _agy_keyring_login_present()+++# agy 1.4 keeps its login in the OS keyring instead of the token file above+# (verified live 2026-10-27 with agy 1.4.7 on Windows; cli.log: "ChainedAuth:+# authenticated via keyring"). On Windows that is a generic Credential Manager+# entry with this target. Presence only — the blob is freed unread (Google ToS,+# same rule as the files). Other platforms keep the file-only check.+_AGY_KEYRING_TARGET = "gemini:antigravity"+_CRED_TYPE_GENERIC = 1+_ERROR_NOT_FOUND = 1168+++def _advapi32() -> Any:+ import ctypes++ return ctypes.WinDLL("advapi32", use_last_error=True)+++def _agy_keyring_login_present() -> bool:+ """True when agy's Windows Credential Manager login entry exists."""+ if sys.platform != "win32":+ return False+ try:+ import ctypes++ advapi32 = _advapi32()+ cred = ctypes.c_void_p()+ found = advapi32.CredReadW(+ ctypes.c_wchar_p(_AGY_KEYRING_TARGET), _CRED_TYPE_GENERIC, 0, ctypes.byref(cred)+ )+ if found:+ advapi32.CredFree(cred)+ return bool(found)+ except Exception: # noqa: BLE001 — a probe failure means "not detected"+ return False+++def _delete_agy_keyring_login() -> None:+ """Remove agy's Credential Manager login entry; absent is not an error."""+ if sys.platform != "win32":+ return+ import ctypes++ advapi32 = _advapi32()+ if advapi32.CredDeleteW(ctypes.c_wchar_p(_AGY_KEYRING_TARGET), _CRED_TYPE_GENERIC, 0):+ return+ err = ctypes.get_last_error()+ if err != _ERROR_NOT_FOUND:+ raise OSError(err, f"could not remove the {_AGY_KEYRING_TARGET} credential")def _derive_google_auth(@@ -291,13 +340,16 @@ class GoogleCliAuthService:the disconnect; this clears BOTH the Gemini CLI's ``oauth_creds.json`` andthe agy token under ``antigravity-cli/`` (else Disconnect is a no-op for anagy login). The isolated brain home re-syncs to the absent login on the- next turn (see ``isolated_home``), so agy logs out there too.+ next turn (see ``isolated_home``), so agy logs out there too. agy 1.4+ logs in through the OS keyring instead, so its Credential Manager entry+ is removed as well.Returns ``(ok, error)``; ``ok`` is True when the login files are gone."""try:for path in _oauth_login_paths(_gemini_home()):path.unlink(missing_ok=True)+ _delete_agy_keyring_login()return True, Noneexcept OSError as exc:return False, str(exc)diff --git a/tests/unit/google_cli/test_auth_service.py b/tests/unit/google_cli/test_auth_service.pyindex c227daa597..c79af0dd21 100644--- a/tests/unit/google_cli/test_auth_service.py+++ b/tests/unit/google_cli/test_auth_service.py@@ -3,6 +3,8 @@ from __future__ import annotationsimport json+import pytest+import dodaios.google_cli.auth_service as auth_modfrom dodaios.google_cli.auth_service import (GoogleCliAuthService,@@ -11,6 +13,14 @@ from dodaios.google_cli.auth_service import (from dodaios.google_cli.resolver import GoogleCli[email protected](autouse=True)+def _no_real_keyring(monkeypatch):+ # Keep every test off the real Windows Credential Manager: a developer+ # machine with agy 1.4 signed in would otherwise read as connected.+ monkeypatch.setattr(auth_mod, "_agy_keyring_login_present", lambda: False)+ monkeypatch.setattr(auth_mod, "_delete_agy_keyring_login", lambda: None)++def test_derive_oauth_personal():settings = {"security": {"auth": {"selectedType": "oauth-personal"}}}assert _derive_google_auth(creds_present=True, settings=settings) == (@@ -141,6 +151,39 @@ def test_status_agy_empty_token_file_is_not_connected(tmp_path, monkeypatch):assert not svc.status().connected+def test_status_connected_via_agy_keyring_login(tmp_path, monkeypatch):+ # agy 1.4 keeps its login in the OS keyring and writes no token file; the+ # card stayed on "waiting for sign-in" after a successful login.+ gem = tmp_path / ".gemini"+ gem.mkdir()+ monkeypatch.setenv("GEMINI_HOME", str(gem))+ monkeypatch.setattr(auth_mod, "_agy_keyring_login_present", lambda: True)+ svc = GoogleCliAuthService()+ svc._resolve = lambda: GoogleCli( # type: ignore[method-assign]+ kind="agy", argv_prefix=["agy.exe"], version="1.4.7"+ )+ st = svc.status()+ assert st.installed and st.connected+ assert st.mode == "oauth-personal"+++def test_logout_removes_agy_keyring_login(tmp_path, monkeypatch):+ # Disconnect must also clear the keyring login, else it is a no-op for agy 1.4.+ gem = tmp_path / ".gemini"+ gem.mkdir()+ monkeypatch.setenv("GEMINI_HOME", str(gem))+ keyring = {"present": True}+ monkeypatch.setattr(auth_mod, "_agy_keyring_login_present", lambda: keyring["present"])+ monkeypatch.setattr(+ auth_mod, "_delete_agy_keyring_login", lambda: keyring.update(present=False)+ )+ svc = GoogleCliAuthService()+ svc._resolve = lambda: GoogleCli(kind="agy", argv_prefix=["agy.exe"]) # type: ignore[method-assign]+ ok, err = svc.logout_blocking()+ assert ok and err is None+ assert not svc.status().connected++def test_logout_removes_agy_token(tmp_path, monkeypatch):# Disconnect must clear the agy token too, not only oauth_creds.json — else# the Disconnect button is a no-op for an agy login.