Skip to content

feat(integrations): connect the Antigravity app and agy CLI to the gateway - #8736

Closed
andrew05060414 wants to merge 9 commits into
lidge-jun:devfrom
andrew05060414:feat/antigravity-gateway-connect
Closed

andrew05060414 wants to merge 9 commits into
lidge-jun:devfrom
andrew05060414:feat/antigravity-gateway-connect

Conversation

@andrew05060414

@andrew05060414 andrew05060414 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Google's own Antigravity clients had no way to run through OpenCodex. Users with many Antigravity accounts in the OpenCodex pool still had to sign the desktop app and the agy CLI into one Google account at a time. After this change, one click on the dashboard (or ocx connect antigravity|agy) points either client at OpenCodex, so its requests get the same routing, account rotation, request log and redaction as every other client. Disconnect puts the user's own settings back.

Both connectors use Google's documented enterprise-gateway configuration rather than replacing tokens or binaries:

  • Antigravity desktop app (2.15+). Writes the gateway block (enabled, url, apiKey, wireProtocol: "openai") and, if given, models.defaultModelId in ~/.antigravity/settings.json. A user models.list is set aside while connected because it would hide OpenCodex models from the picker. The app then calls the existing /v1/models and /v1/chat/completions.
  • agy CLI (1.2.15+). Adds an agy shell function between # >>> opencodex agy >>> markers in the existing bash/zsh and PowerShell profiles. It sets AGY_LLM_GATEWAY_URL, AGY_LLM_GATEWAY_API_KEY and AGY_LLM_GATEWAY_WIRE_PROTOCOL=genai for that one command. No agy settings file is changed. The genai protocol is the Gemini API, served by feat(server): accept Gemini API requests (generateContent, streamGenerateContent, models) #8732.
  • Restore. Before the first write, the original bytes go to a restore record in the OpenCodex config directory. Disconnect writes them back byte for byte when the file is unchanged since connect. If the user edited the file meanwhile, only the keys or the marked block OpenCodex wrote are reverted and their other edits stay. Writes use temp-and-rename. A settings file that is not strict JSON is refused untouched.
  • Honest status. GET /api/gateway-clients and ocx connect <client> status report connected, disconnected or drifted. They also warn when an organization admin_settings.json sets a gateway (it wins over the user file) or when AGY_LLM_GATEWAY_URL is exported (it wins over the user file for agy).
  • No secrets in client files. The URL comes from localInferenceDestination, and the key written is a fixed non-secret placeholder. If the bind requires a data-plane credential, connect refuses with the same advice ocx claude gives (enable unauthenticatedLoopbackListener or bind to loopback).
  • Surfaces. Management routes GET /api/gateway-clients, POST /api/gateway-clients/{id}/connect|disconnect (same session/origin checks as other management POSTs). CLI ocx connect antigravity|agy [--model] [status] and ocx disconnect antigravity|agy, branched before any hub logic. It uses the running proxy, or works locally when none is running. A new Antigravity tab on the Integrations page. A structure/clients/antigravity-gateway.md doc and a docs-site section.

Scope: client configuration only. The provider-side google-antigravity accounts are untouched and separate. Gateway mode means the clients do not use their own Google sign-in, which the UI states.

Antigravity tab with both clients connected

Verification

  • bun test, each file run on its own: tests/clients/gateway-clients.test.ts 11, gateway-client-routes.test.ts 4, gateway-client-command.test.ts 4, management-route-registry.test.ts 31 (+1 skip), skill-ocx.test.ts 15, test-layout.test.ts 2, file-size-ratchet.test.ts 9, all pass. The GUI tests also pass: gateway-clients-page.test.tsx (new, 3), locale-parity, fr-localization, i18n-locales, integrations-tab-coverage, integration-marks and integrations-surfaces.
  • bun run typecheck, GUI tsc -b and lint, structure:check, skill:surface:check, privacy:scan pass.
  • End to end on a local test instance with fake home directories and a stub upstream. CLI connect then disconnect returned a CRLF settings.json (with a user gateway, models.list and other keys), a .bashrc without a trailing newline and a CRLF PowerShell profile byte for byte. A second connect reported no change. The written functions parse in real PowerShell (0 parse errors) and Git Bash (bash -n, type -t agy = function). The dashboard Connect buttons wrote and reported both clients as shown above. An app-shaped /v1/chat/completions request and a Gemini-shaped request (with feat(server): accept Gemini API requests (generateContent, streamGenerateContent, models) #8732) both reached the stub.
  • Not run: the full suite and test:changed. Several agents share the test machine, so only new and changed files ran, and full coverage is left to CI. Local test-layout-tooling (4), structure-ssot (2) and one case of integrations-invariants fail on this machine's git 2.56 rejecting GIT_CONFIG_GLOBAL=NUL. That matches the machine's known baseline and was not re-run on a clean checkout.
  • Not verified with a real Antigravity app or agy binary.

Readiness (2026-11-13)

  • Fixed the new_suppression hygiene finding: the model-selector check no longer needs eslint-disable-next-line no-control-regex; it tests the code points directly. The existing "a\nb" refusal case covers it; the connector, route and CLI tests pass (19 pass).
  • Branch is 1 commit(s) behind dev (873ec9b), inside the gate's window; no rebase for review.
  • No Codex or CodeRabbit findings are open on this PR (CodeRabbit skipped the draft; there are no inline review comments).
  • Also merged into a local integration build with the other open PRs of this series and deployed on a real install. The combined build passed bun run typecheck, structure:check, skill:surface:check, privacy:scan, the layout and file-size guards and this PR's focused tests; after the deploy one real request each through Claude, GPT, Gemini, DeepSeek and Grok returned 200 and the error rate did not rise.
  • Still needs the maintainer-sponsored label: the hygiene gate flags src/server/management-api.ts. Everything else is ready for review.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

…nCodex gateway

Adds src/integrations/gateway-clients with a connector per client. The app
connector edits ~/.antigravity/settings.json behind a stash and restores it
byte for byte (path-wise when the user edited since). The agy connector writes
a marked shell function into bash, zsh and PowerShell profiles.
…and agy

The Integrations page gets an Antigravity tab backed by /api/gateway-clients. Each client shows its state, the files it changes, override warnings from admin_settings.json or the environment, and the server's notes. Connect (with an optional default model for the desktop app) and Disconnect relay the server's message, including refusals, and reread status. The tab label is allowlisted as a product name in the zh-TW and French placeholder guards.
Drives the page against a fetch mock for status, a connect with a model, and a 409 refusal.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • new_suppression — A new TypeScript, lint, formatter, or similar suppression was added. Fix the underlying issue or obtain suppression-approved. Paths: src/integrations/gateway-clients/index.ts.
  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/management-api.ts.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: unsponsored_surface.

What to do

  • Fix unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/management-api.ts.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

Hygiene

⚠️ Deterministic hygiene checks failed.

  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/server/management-api.ts.

@andrew05060414

Copy link
Copy Markdown
Contributor Author

Superseded by #8742, which carries this change together with the related Antigravity gateway PR as one commit each on current dev, with no stacking. The design notes in this description still apply.

lidge-jun added a commit that referenced this pull request Nov 19, 2026
…and agy CLI connection (#8742)

* feat(server): accept Gemini API requests (generateContent, streamGenerateContent, models)

Original PR: #8732

* feat(integrations): connect the Antigravity app and agy CLI to the gateway

Original PR: #8736

* refactor(server): dispatch /api/gateway-clients from the integration routes

The connector routes were mounted from management-api.ts, a sponsored surface.
integration-routes.ts already owns the client-integration namespace, so the lazy
import moves there and management-api.ts is unchanged from dev.

* fix(integrations): give gateway-client notes and overrides stable codes

Status notes and override warnings were English sentences only, so the
dashboard could not translate them. Each now carries a code beside its
English text (one table in types.ts), and the Antigravity status reports
the current models.defaultModelId. CLI output is unchanged.

* fix(gui): translate the Antigravity tab and show the current default model

Notes, warnings and action results were shown in the server's English under
every locale, and the restart hint appeared twice after Connect. The tab now
renders them from codes in all 11 locales, says the restart hint once,
prefills the default model, names the state Connected / Not connected to
match its buttons, and drops the untranslated file role.

* fix(cli): describe offline status and disconnect accurately for gateway clients

* fix(cli): refuse an offline gateway-client connect when the configured port is 0

* fix(integrations): keep gateway-client restores correct across edits, failed writes, UTF-16 profiles and unreadable admin settings

* fix(gui): word an unconfirmed gateway-client action honestly and reset cards per target

* fix(docs): state which gateway-client edits disconnect keeps

* fix(gemini): keep text answers open in VALIDATED mode and carry images returned inside functionResponse.parts

* docs(es): mirror the Antigravity app and agy CLI section

* test(cli): map /api/gateway-clients to ocx connect/disconnect antigravity|agy in the GUI parity sweep

* fix(gui): note why gateway client actions read refusal bodies (react-doctor)

* fix(integrations): protect gateway client writes and uninstall recovery

* test(gateway): verify Gemini admission and selected locale copy

* fix(ci): keep test layout and Spanish docs within current gates

* fix(gateway-clients): confine canonical client file destinations

* fix(uninstall): retire empty gateway restore directories

* fix(cli): scope gateway connect model selection to Antigravity

* test(uninstall): exercise owned gateway cleanup on unelevated fixtures

* Confine gateway client updates to exact profile paths

* Recover agy profiles when untracked candidates cannot be read

* Default the gateway context during uninstall teardown

* Require explicit gateway context for injected uninstall teardown

---------

Co-authored-by: JUN <jun@lidgeai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant