Skip to content

feat(antigravity): add antigravity native Messages provider - #185

Open
chris7iu wants to merge 33 commits into
raine:mainfrom
chris7iu:feat/antigravity-argon
Open

chris7iu wants to merge 33 commits into
raine:mainfrom
chris7iu:feat/antigravity-argon

Conversation

@chris7iu

@chris7iu chris7iu commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an experimental, opt-in (default-off) native Antigravity provider (src/providers/antigravity/) for Anthropic /v1/messages and local /v1/messages/count_tokens backed directly by the Cloud Code Assist v1internal:streamGenerateContent?alt=sse API (no agy subprocess wrapper or credential import).

When disabled (the default), existing provider catalogs, model routing, aliases, and auto-review overrides are untouched.

Supported Models

  • antigravity/gemini-4-carbon-{low,medium,high}
  • antigravity/gemini-4-argon-{low,medium,high}
  • antigravity/claude-opus-5-5-{low,medium,high}

(Optional [1m] model suffixes from Claude Code are accepted.)

Highlights

  • Native wire protocol & streaming transport: Dedicated Hyper + rustls client defaulting to https://daily-cloudcode-pa.googleapis.com (baseUrl configurable), gzip response decoding, agy-aligned timeouts (300s header and SSE stream-idle budgets, 3600s turn deadline, no automatic inference retries), 15s downstream : ping\n\n SSE heartbeats while collecting buffered turns, and bounded/redacted upstream error diagnostics.
  • Signed replay & mid-session /model switching: Preserves native parts and thought signatures in a versioned ccp:antigravity:v1: carrier across tool turns, canonicalizes client-normalized tool inputs, and folds unsigned or cross-model/cross-tier prefix turns into <prior_conversation_transcript> user context so mid-session model or effort changes continue cleanly.
  • agy-style native Schema projection: Translates JSON Schema tool definitions directly into Cloud Code Assist v1main.Schema ($ref/$defs inlining with cycle guards, allOf/anyOf/oneOf normalization, const → enum, stringified enum values), skips Claude Code DeferredToolPlaceholder / defer_loading placeholders, and aliases MCP/external tool names outside [a-zA-Z_][a-zA-Z0-9_-]{0,63} via deterministic ccp_<sha256> mapping.
  • Proxy-owned OAuth & singleflight refresh: Supports PKCE S256 loopback login (antigravity auth login), bounded foreground-TTY manual code entry on Unix (antigravity auth login --manual), logout, and pure read-only status / GET /v1/models?include_capabilities=true, with sibling-locked credential storage and singleflight token refresh.
  • Effect-free token counting: /v1/messages/count_tokens estimates tokens locally without reading credentials, refreshing tokens, or making network calls.

Configuration & CLI

Enable via ~/.config/claude-code-proxy/config.json or CCP_ANTIGRAVITY_* environment variables:

{
  "antigravity": {
    "enabled": true,
    "clientId": "<oauth-client-id>",
    "clientSecret": "<oauth-client-secret>",
    "projectId": "<optional-gcp-project-id>",
    "baseUrl": "https://daily-cloudcode-pa.googleapis.com",
    "userAgent": "<optional-native-api-user-agent>"
  }
}
claude-code-proxy antigravity auth login [--manual]
claude-code-proxy antigravity auth status
claude-code-proxy antigravity auth logout

Test Plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --lib antigravity
  • cargo test --test antigravity_schema_parity --test antigravity_transport --test server --test cli
  • pytest tests/antigravity_compatibility

chris7iu and others added 8 commits October 18, 2026 12:24
Add explicit OAuth/profile storage, cancellation-safe token refresh, bounded native transport and lossless fixed-session replay/schema adaptation. Keep disabled discovery baseline-compatible, expose read-only capabilities, and provide local count estimates with documented limitations.

Validated offline under umask 022 with formatting, Clippy, build, 1206 Rust tests and 83 Python fixture/launcher tests. Native Google acceptance remains unverified; no live provider or service activation is included.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Default all outbound requests to claude-code-proxy/<version>. Apply a validated provider-specific full User-Agent only to generation and project discovery, preserving proxy identity for OAuth and exact override bytes.

Keep the independently validated OS-string override outside legacy UTF-8 environment snapshots, with redacted failures and unchanged provider-scoped invalid configuration behavior. Tests-first regressions, independent review, fmt, Clippy, build and 1222 isolated tests pass under umask 022. No live activation.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Add opt-in hosted-code completion with PKCE and strict URL/state validation, private bounded Unix terminal input, and explicit post-commit and bounded-exit semantics. Keep automatic callback login unchanged.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Render visible input with a bounded terminal viewport, preserve cancellation
and redaction guarantees, and verify native proxy routing with a local fixture.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Expose only allowlisted Google error labels and validated retry hints,
while preserving HTTP status and never retrying failed generation.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Bound refresh retries within the original deadline, preserve credentials
with scoped cooldowns, and retain fail-closed ambiguous-rotation handling.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Use the consumer Cloud Code origin for discovery and generation while
preserving explicit endpoint overrides and fixed OAuth URLs. Add
selection regressions and lossless non-streaming client-tool replay
coverage against synthetic upstream SSE.

Co-Authored-By: Claude Code <noreply@anthropic.com>
chris7iu and others added 21 commits October 25, 2026 12:30
Accept propertyNames with bounded recursive validation and complete local constraint guidance. Retain original argument validation, lossless codecs, and reference rejection. Cover optional CLI record-shaped tools and pre-auth failure ordering.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Match the observed official loadCodeAssist metadata without changing project or credential-owner behavior. Preserve allowlisted ErrorInfo reasons from the exact daily API domain, with pure privacy and boundary regressions.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Add the user role to system instructions and serialize one compiled function declaration per tool group while preserving declaration order and codecs.

Use 65536 only when max_tokens is absent or null, preserving explicit caller limits and validation. Cover request and HTTP ingress contracts for stream and non-stream callers without changing transport, authentication, replay, labels, or user-agent policy.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Use a generation-only Hyper transport with explicit proxy/TLS behavior, bounded gzip decoding and foreground cancellation. Preserve the existing OAuth and project-discovery clients and disable automatic generation retries. Add verified local TLS, framing, compression, cancellation and proxy regression coverage.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Preserve both native Antigravity routing/privacy regressions and upstream Grok classifier routing tests. Retain the published native configuration reference without hand-editing it and clarify requested-model classifier routing in the README. Combined verification follows before publication.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Select a bounded all-or-nothing compatible schema projection, preserving explicit defaults, proto-style zero omission and quoted int64 limits. Keep original validators, fallback codecs and V1 replay recipes unchanged. Emit VALIDATED for explicit auto with declarations and add synthetic verified-HTTPS regression coverage.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Require absent Accept, exact JSON content type and gzip negotiation in the combined transport/schema fixture. Preserve strict method, URL, authorization and schema assertions. Verified combined upstream suite, formatting and strict Clippy pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Reconstruct compatible synthetic caller schemas from observed typed
tool shapes and compare complete outgoing groups through prepare.
Keep names and text synthetic and preserve quoted int64 limits.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Add a closed default-legacy metadata policy and separately versioned V2 transcript state for observed main-user and signed string-tool continuations. Preserve V1 codec/session semantics, bind logical and user-execution identities separately from the backend session, and allocate dispatch IDs only after actual native binding checks.

Use value-only native count inputs and an advisory nonsecret serving snapshot without credential/profile reads, refresh, network dispatch or ID allocation. Retain legacy counting, reject unqualified transition shapes, and document scoped coverage without at-most-once or all-account claims.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Start synthetic services on kernel-selected loopback ports and discover their actual bound address from owned startup stderr. Reject early child exit rather than accepting an unrelated TCP listener, retain complete bounded stderr for security assertions, and cover foreign-listener and delayed-start cases.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…rredToolPlaceholder, and handle non-STOP tool finish reasons
…ramsToSchema

Replace Codec::Json string-wrapping, strict keyword/format whitelisting, and
post-generation jsonschema validation rejection with agy-style native
v1main.Schema projection:
- Inline local #/... $ref definitions with cycle protection
- Fold simple allOf object compositions and unwrap nullable Optional[T] /
  ["T", "null"] / string enum+const unions (e.g. TaskUpdate.status)
- Alias tool names outside ^[a-zA-Z_][a-zA-Z0-9_-]{0,63}$ via ccp_<sha256>
  for Vertex-Anthropic and Gemini parity
- Delegate semantic argument validation to downstream callers via tool_result
  (is_error: true) and drop the jsonschema crate dependency
@chris7iu chris7iu changed the title feat(antigravity): add experimental native Messages provider feat(antigravity): add antigravity native Messages provider Nov 12, 2026
@chris7iu
chris7iu marked this pull request as ready for review November 12, 2026 13:25

This branch has not been deployed

No deployments
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