scorpiox-bot-plugin-antigravity-login
←README.mdmarkdown
258 lines · 9 KBHEAD
BlameDownload

plugin_antigravity_login — Google Antigravity login for SCORPIOX BOT

plugin_antigravity_login is a zero-dependency C99 node plugin for

SCORPIOX BOT. It drives a Google OAuth 2.0 PKCE

login for Google Antigravity on the node it runs on: start the flow, paste

the authorization code, run the exchange and the Google Cloud companion‑project

discovery, then read the session state, token expiry and project — and refresh

the token on demand.

  • --meta → {"name":"google","desc":"Google login"}
  • --version → plugin_antigravity_login 1.0.1
  • Catalog slug antigravity-login, category devtools
  • Public source: <https://plugingit.scorpiox.net/scorpiox-bot-plugin-antigravity-login.git>
  • Prebuilt binaries: <https://dist.scorpiox.net/bot-plugins/antigravity-login/>

Two ways to consume it, both first-class:

Track What you get
Source git clone the repo above, read one C file, compile it on your node in a second, install to ~/.scorpiox/plugins/. No dependency, no build system beyond cc.
Prebuilt a static binary per platform at dist.scorpiox.net/bot-plugins/antigravity-login/1.0.1/, with manifest.json, SHA256SUMS and the exact source.tar.gz.

Why this plugin has no TLS code and no client secret

A PKCE code exchange is an HTTPS POST that carries an OAuth client identity. A

public, clean-room repository cannot ship a client secret, and a plugin that

re-implemented TLS would be a liability on every node.

So this plugin does what SCORPIOX CODE already designed its login tools for: it

drives the machine-mode CLI that ships with the product.

plugin_antigravity_login  --popen-->  scorpiox-antigravity-login --status
                                            --start
                                            --finish <code>
                                            --cancel
                          --popen-->  scorpiox-google-fetchtoken -local

Machine mode is the contract documented in sx_login_machine.h: one JSON line

per call, human progress on stderr/stdout before it, no TTY required. The plugin

takes the last line that starts with {, so the parsers are exercised

against the production layout rather than an invented one.

The plugin reads (and never writes):

Path What it is used for
~/.config/google-accounts/antigravity_accounts.json account list + refresh_token presence
~/.config/google-accounts/selected_account.txt the active Google account
~/.claude/scorpiox-env/antigravity.txt GOOGLE_PROJECT_ID, GOOGLE_ACCOUNT
~/.claude/.login-pending/antigravity-default.json the pending-flow marker

No token is ever printed, logged or returned. action=status reports

has_refresh (a boolean), expires_at and expires_in_sec. action=refresh

reports refreshed: true and the expiry — the access token the CLI prints is

read for presence and discarded, so a browser, a proxy log or a screenshot can

never capture a bearer token from this route. The test suite asserts that: a mock

token CLI prints ya29.MOCK-ACCESS-TOKEN-MUST-NOT-LEAK and the suite fails if the

string appears in any response.


Requirements on the node

Platform Needs
Linux / macOS scorpiox-antigravity-login and scorpiox-google-fetchtoken on PATH (both ship with SCORPIOX CODE)
Windows the same two binaries in %PATH%
any nothing else — the plugin has zero library dependencies

If the CLIs are absent the plugin still serves the UI and answers action=status

cli_present:false with a clear message, so a node without SCORPIOX CODE does not

show a broken panel.


Environment overrides (all optional, all for testing or relocation)

Variable Effect
ANTIGRAVITY_CREDS_PATH the accounts JSON. Its directory also anchors selected_account.txt and the profile dir, so a relocated install stays self-consistent.
ANTIGRAVITY_ENV_DIR the profile directory (default ~/.claude/scorpiox-env)
ANTIGRAVITY_PENDING_PATH the pending-flow marker
ANTIGRAVITY_LOGIN_BIN the login CLI (default scorpiox-antigravity-login)
ANTIGRAVITY_TOKEN_BIN the token CLI (default scorpiox-google-fetchtoken)
BOT_PASSWORD when set, every route except --meta requires it

API

All actions are GET (or POST for finish) against the plugin route, with the

node password supplied as X-Bot-Password, Authorization: Bearer or ?pwd=.

?action=status (also ?format=json)

{
  "ok": true,
  "plugin": "plugin_antigravity_login",
  "version": "1.0.1",
  "logged_in": true,
  "email": "someone@example.com",
  "account": "someone@example.com",
  "project_id": "proj-mock-42",
  "profile": "antigravity",
  "expires_at": 1790000000,
  "expires_in_sec": 3599,
  "expired": false,
  "has_refresh": true,
  "pending": false,
  "cli_present": true,
  "credentials_path": "/root/.config/google-accounts/antigravity_accounts.json"
}

expires_at is unix seconds (the CLI's millisecond value is normalised).

expired is only ever true for a session that exists.

?action=start

{
  "ok": true,
  "flow": "paste_code",
  "auth_url": "https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=...&code_challenge=...&code_challenge_method=S256&...",
  "expires_in": 900,
  "hint": "Sign in with Google and approve. The browser lands on antigravity.google - copy the whole address (or just the code) and paste it here."
}

The PKCE verifier lives in the CLI's pending file (mode 0600). The plugin never

sees it and never needs it.

?action=finish&code=... (or a POST body {"code":"..."})

Accepts a bare code or the whole https://antigravity.google/oauth-callback?...

address; the code= value is extracted before validation. On success the

response is the full status object with "state":"done".

Rejected before anything runs (the code is passed to a shell, so this is a real

guard, not a formality):

{"ok":false,"error":"invalid_code","detail":"the value is not an authorization code (empty, too long, or contains shell characters)"}

Shell metacharacters, quotes, backticks, $, ;, |, &, <, > and control

bytes are refused; the argument is also single-quoted with the '\'' escape, and

the test suite proves a $(touch /tmp/pwned) payload creates no file.

?action=cancel

{"ok": true, "state": "cancelled", "pending": false}

?action=refresh

Runs scorpiox-google-fetchtoken -local, reports success and the new expiry, and

drops the token:

{"ok": true, "refreshed": true, "logged_in": true, "email": "...", "project_id": "...", "expires_in_sec": 3599, ...}

Failure is structured, never a stack trace:

{"ok": false, "error": "refresh_failed", "detail": "the token CLI could not refresh the session; sign in again"}

Errors

Error HTTP Meaning
invalid node password 401 BOT_PASSWORD is set and no credential matched
missing_code 400 finish without a code
invalid_code 400 the value cannot be an authorization code
unknown_action 404 unrecognised action=
cli_unavailable 200 the login/token CLI is not on this node
exchange / finish_failed 200 Google rejected the code, or the account needs verification

The UI

One page, no framework, no CDN, no <script src=>, no external request of any

kind. It follows the bot's theme through the standard handoff:

  1. ?theme=light|dark → localStorage.bot_theme → prefers-color-scheme,

decided before first paint (no flash),

  1. then it follows {type:'sx-theme'} posts from the bot and asks once with

{type:'sx-theme-request'},

  1. every colour is a bot token from src/bot_theme_plugin.h — there is no

plugin-private palette.

Layout: a status pill (Connected / Expired / Signing in / Not Connected),

a session card, an OAuth card with the generated link and a paste box, and a

companion-project card. Fluid down to 390 px and inside the Chat floating window

(?embed=1 hides the theme button).


Build

make            # native
make musl       # static x86_64 musl (the universal Linux artifact)
make arm64      # static aarch64 (Raspberry Pi 5, ARM servers)
make win64      # MinGW-w64 static PE
make macos      # Apple clang (run on macOS)
make test       # the offline suite
make install    # ~/.scorpiox/plugins (or /workspace/.scorpiox/plugins)

src/ui_html.h is generated from src/ui.html by tools/gen_ui.py; make ui

(or the $(UI_HDR) dependency) regenerates it, and tools/gen_ui.py --check

fails when the header is stale.

Windows: powershell -ExecutionPolicy Bypass -File build.ps1.


Release

scorpiox-cli-botplugin publish .        # preferred: scan, build, upload, mirror, reindex
./release-dist.sh --standalone          # the same, self-contained

Both refuse to publish a repo whose full history contains a credential, a

private address or an internal hostname. The standalone script needs

DIST_HOST/DIST_PASS (dist) and SSHPASS (macOS leg) in the environment and

reads the plugingit write token from /etc/scorpiox-plugingit.token — no secret

is ever stored in this repository.


Layout

src/plugin_antigravity_login.c   the whole plugin (3 modes, ~1.2k lines)
src/ui.html                      the page, readable and diffable
src/ui_html.h                    generated by tools/gen_ui.py
src/bot_theme_plugin.h           the bot's theme tokens, vendored
tests/run.sh                     the offline suite (mock CLIs, fixtures)
tests/mock_login.sh              stand-in for scorpiox-antigravity-login machine mode
tests/mock_token.sh              stand-in for scorpiox-google-fetchtoken -local
tools/gen_ui.py                  ui.html -> ui_html.h

License

MIT. Copyright (c) 2026 SCORPIOX INC.