bootstrap
Adom Hydrogen (platform base)
Public Made by Adomby adom
Layer Hydrogen's workspace onto a standard Adom workstation.
← Commit history
hydrogen-ai-agents: Quota section, reading plan usage for Claude, Codex, Antigravity and Grok, one script, across machines
1 file changed
+64−1
skills/hydrogen-ai-agents/SKILL.md+64−1@@ -1,6 +1,6 @@ --- name: hydrogen-ai-agents-description: Install, sign in, sign out and check any AI in a Hydrogen workspace (Claude Code, Codex, Kimi Code, Antigravity) from inside an AI session, through Hydrogen's /agents API, without hand-running installers. READ when the user says "install antigravity", "install kimi", "sign in to codex", "sign in to kimi", "is claude signed in", "sign out of antigravity", "add an AI", "manage AIs", "open the AI panel", or asks why an AI button is missing from the VS Code toolbar. Trigger words: install antigravity, install kimi, install codex, sign in antigravity, sign in kimi, kimi login, agy login, codex login, claude login, which AIs are signed in, manage ais, add an ai, ai toolbar button missing, agents catalog, /agents/install, /agents/login, agent-bar.json.+description: Install, sign in, sign out and check any AI in a Hydrogen workspace (Claude Code, Codex, Kimi Code, Antigravity) from inside an AI session, through Hydrogen's /agents API, without hand-running installers. READ when the user says "install antigravity", "install kimi", "sign in to codex", "sign in to kimi", "is claude signed in", "sign out of antigravity", "add an AI", "manage AIs", "open the AI panel", or asks why an AI button is missing from the VS Code toolbar. Trigger words: install antigravity, install kimi, install codex, sign in antigravity, sign in kimi, kimi login, agy login, codex login, claude login, which AIs are signed in, manage ais, add an ai, ai toolbar button missing, agents catalog, /agents/install, /agents/login, agent-bar.json, quota, usage, how much usage is left, out of codex usage, usage across my accounts, weekly limit, five hour limit, rate limit reset. --- # Hydrogen AI agents: install and sign in from a session@@ -103,6 +103,69 @@ few seconds; the human has minutes, not seconds, to click through Google or Open reached, resets in Nh") is still signed in. Hydrogen's sign-in check reads the token, not a live prompt, so it stays green; explain the quota instead of re-authenticating. +## Quota: how much of each plan is left++None of these calls runs a model, so reading quota costs nothing. Each one reads the sign-in the+AI already keeps in the workspace; never print the tokens, print only the numbers.++| AI | where the numbers come from | what comes back |+|---|---|---|+| Claude Code | `~/.claude/.credentials.json` (`claudeAiOauth.accessToken`), `GET https://api.anthropic.com/api/oauth/usage` with `anthropic-beta: oauth-2025-04-20`; `GET .../api/oauth/profile` gives the account email | `five_hour.utilization`, `seven_day.utilization` (percent used) with `resets_at`; `limits` is the list `/usage` draws, including weekly limits scoped to one model |+| Codex | `~/.codex/auth.json` (`tokens.access_token`, `tokens.account_id`), `GET https://chatgpt.com/backend-api/wham/usage` with `ChatGPT-Account-Id` | `rate_limit.primary_window.used_percent` and `reset_at` (epoch), `limit_reached`; also `credits.balance` and `rate_limit_reset_credits.available_count` (what `/status` shows) |+| Antigravity | the running hub `agy --hub` (port and CSRF token on its command line), `POST http://127.0.0.1:<port>/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary` with `x-codeium-csrf-token`, body `{}` | `response.groups[].buckets[]`: `window` (`weekly` or `5h`), `remainingFraction`, `resetTime`, for the Gemini group and the Claude and GPT group; `GetLoadCodeAssist` gives the plan name and `GetUserStatus` the signed-in email |+| Grok Bot | Windows app, no file in the workspace: `grok_settings {"page":"usage"}` then `grok_screenshot` (see the `grok-account` skill) | the plan, weekly percent and reset, the on-demand cap |+| Kimi Code | not mapped yet | |++The Title Bar widgets `claude-usage`, `codex-usage` and `antigravity-usage` show the same numbers+for this workspace (the `hydrogen-widget` skill).++```bash+python3 - <<'PY'+import json, os, re, subprocess, urllib.request+def get(url, h, data=None):+ return json.loads(urllib.request.urlopen(urllib.request.Request(url, data=data, headers=h), timeout=20).read())+try:+ c = json.load(open(os.path.expanduser('~/.claude/.credentials.json')))['claudeAiOauth']+ h = {'Authorization': 'Bearer ' + c['accessToken'], 'anthropic-beta': 'oauth-2025-04-20'}+ u = get('https://api.anthropic.com/api/oauth/usage', h); who = get('https://api.anthropic.com/api/oauth/profile', h)['account']['email']+ print('claude', who, '5h', u['five_hour']['utilization'], 'week', u['seven_day']['utilization'], 'resets', u['seven_day']['resets_at'])+except Exception as e: print('claude', e)+try:+ a = json.load(open(os.path.expanduser('~/.codex/auth.json')))['tokens']+ d = get('https://chatgpt.com/backend-api/wham/usage', {'Authorization': 'Bearer ' + a['access_token'], 'ChatGPT-Account-Id': a['account_id'], 'User-Agent': 'codex_cli_rs'})+ w = d['rate_limit']['primary_window']+ print('codex', d['email'], d['plan_type'], 'week', w['used_percent'], 'reset', w['reset_at'], 'credits', d['credits']['balance'])+except Exception as e: print('codex', e)+try:+ l = next(l for l in subprocess.run(['ps', '-eo', 'args'], capture_output=True, text=True).stdout.splitlines() if re.search(r'(^|/)agy\s.*--hub', l))+ port, csrf = re.search(r'--hub-port[= ](\d+)', l).group(1), re.search(r'--csrf_token[= ](\S+)', l).group(1)+ q = get(f'http://127.0.0.1:{port}/exa.language_server_pb.LanguageServerService/RetrieveUserQuotaSummary',+ {'Content-Type': 'application/json', 'x-codeium-csrf-token': csrf}, b'{}')['response']+ for g in q['groups']:+ for b in g['buckets']: print('antigravity', g['displayName'], b['window'], 'used', round((1 - b['remainingFraction']) * 100), 'reset', b['resetTime'])+except StopIteration: print('antigravity: hub not running (open the Antigravity panel once)')+except Exception as e: print('antigravity', e)+PY+```++**Across machines.** Each machine's workspace has its own sign-ins, and two machines can be on+different accounts. Run the same script on each one through Adom Bridge: `adom-bridge --target+<machine> --ai-thread "<thread>" wsl_exec '{"distro":"Adom-Workspace","user":"adom","scriptB64":"<base64 -w0 of the script>","reason":"read AI plan usage"}'`+(`wsl_list` names the distro). Group the rows by account email, not by machine: machines signed+in to the same account share one pool, so the same percent shows on each.++**Reading the answers.**++- Codex at 100 percent (`limit_reached: true`) still has two ways on before the reset: the+ credits balance (pay-as-you-go, if the user turns it on) and `rate_limit_reset_credits`+ (one-shot window resets). Both spend money or a scarce reset: tell the user, never use one+ on your own.+- Antigravity reports separate pools for Gemini and for its Claude and GPT models. One pool+ can be empty while the other is full.+- Grok Bot sitting on its "Update ready, Restart to update" screen shows no Settings page and+ runs no bots. Restarting it stops whatever its bots are doing, so leave that to the thread+ that drives Grok, or to the user.+ ## The VS Code toolbar and the Manage AIs dialog Hydrogen publishes `~/.adom/agent-bar.json` (`{"authed":[…],"agents":[{key, cli, extension,