Skip to content

Store Windows agy tokens in Credential Manager for profile switch - #5

Open
Ishannaik wants to merge 1 commit into
zcop:mainfrom
Ishannaik:feat/lean-windows-credman
Open

Ishannaik wants to merge 1 commit into
zcop:mainfrom
Ishannaik:feat/lean-windows-credman

Conversation

@Ishannaik

@Ishannaik Ishannaik commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Why

On Windows, agy.exe reads the live Antigravity token from Credential Manager target gemini:antigravity at process start. Copying ~/.gemini files does not change that slot, so switch and login left the live Windows login in place.

What

ctypes/advapi32 Generic credentials (CRED_TYPE_GENERIC, 2560-byte blob cap):

  • Live slot: gemini:antigravity (override with AGY_WINCRED_TARGET)
  • Saved profiles: agy-cli-manager:<name>
  • switch / activate copy a profile blob onto the live target via apply_to_live
  • login snapshots the live slot, lets agy write a new blob, then copies it to agy-cli-manager:<storage>; restore the snapshot if login fails
  • Capture/activate of the real live slot refuses while agy.exe or Antigravity* is running; --force overrides
  • One-shot migrate: wincred_antigravity.json -> profile target + credential.meta.json (sha256/length only), then delete the JSON
  • Tests write only agy-cli-manager-test:*; they never touch gemini:antigravity
Windows Credential Manager  CRED_TYPE_GENERIC
┌──────────────────────────────────────────────────────────────┐
│  gemini:antigravity           live slot agy.exe reads        │
│  agy-cli-manager:<profile>    saved standby blobs            │
│  agy-cli-manager:backup:live  login-time snapshot of live    │
└──────────────────────────────────────────────────────────────┘

switch <name>
  agy-cli-manager:<name>  --apply_to_live-->  gemini:antigravity

login
  gemini:antigravity --> agy-cli-manager:backup:live
  agy CredWriteW     --> gemini:antigravity
  gemini:antigravity --> agy-cli-manager:<storage>
  success: delete backup    failure: restore backup then delete

legacy
  accounts/<name>/wincred_antigravity.json
       --> CredWriteW(agy-cli-manager:<name>)
       --> credential.meta.json (hash/length; no blob)
       --> unlink JSON
flowchart LR
  subgraph credman [Windows CredMan Generic]
    Live["gemini:antigravity"]
    Prof["agy-cli-manager:&lt;profile&gt;"]
    Backup["agy-cli-manager:backup:live"]
  end

  agy["agy.exe start"] -->|CredReadW| Live
  Prof -->|"switch / apply_to_live"| Live
  Live -->|"login snapshot"| Backup
  Backup -->|login fail restore| Live
  Live -->|"login capture"| Prof
  JSON["wincred_antigravity.json"] -->|migrate_legacy_json then unlink| Prof
  JSON --> Meta["credential.meta.json"]
Loading

Usage

agy-cli-manager login work
agy-cli-manager switch work
agy-cli-manager switch work --force

--force is the live-slot process-guard override. After a switch, restart agy; it still holds the old token in memory.

Tests

PYTHONPATH=src pytest tests/test_wincred.py tests/test_watch.py: 26 passed

agy.exe reads gemini:antigravity at process start, so file-only profile copies never switch the live Windows login.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant