Skip to main content

Crate antigravity_codes

Crate antigravity_codes 

Source
Expand description

A typed Rust interface for the Google Antigravity agent runtime.

Maturity warning: this crate is new and should be considered highly untested. The wire types are generated from the protobuf descriptor embedded in the shipped localharness binary, and the handshake is locked against captures from a live harness, but real-world mileage is minimal and the API may change between releases while the surface settles. The upstream SDK is itself alpha (0.1.x) and reserves extension ranges on its hottest messages, so expect churn. Bug reports and wire captures that break the types are very welcome at https://github.com/meawoppl/rust-code-agent-sdks/issues.

§What this actually wraps

google-antigravity on PyPI is a Python client for a compiled Go binary called localharness, which is where the agent loop, the built-in tools, and the model calls all live. This crate is a client for that same binary — it is a sibling of the Python SDK, not a binding to it, and no Python is involved at runtime.

The binary ships only inside the platform-specific wheels published to PyPI. See process::find_harness for how the crate locates it.

§The protocol in one screen

Unlike its sibling crates — claude-codes and codex-codes, which speak JSON-Lines over stdio, and opencode-codes, which speaks HTTP+SSE — Antigravity uses stdio only to bootstrap, then moves to a loopback WebSocket:

  1. Handshake (binary protobuf, u32le-length-prefixed, over stdio). The client writes an protocol::InputConfig; the harness replies with an protocol::OutputConfig carrying the port it bound and a single-use API key. See handshake.
  2. Connect to ws://127.0.0.1:{port}/ with an x-goog-api-key header.
  3. Initialize by sending an protocol::InitializeConversationEvent; the harness replies with an protocol::InitializeConversationResponse holding the conversation id and any replayed history.
  4. Converse — send protocol::InputEvents, receive protocol::OutputEvents. Every frame after the handshake is protobuf’s canonical JSON mapping, so the wire is text: camelCase members, 64-bit integers as strings, bytes as base64, enums as value names.

Note that a conversation must be configured with at least one model. A harness initialised with no protocol::ModelConfig exits immediately and closes the socket without an error frame.

§Choosing a client

TypeWhat it gives you
RawClientThe frames, unchanged. You drive the loop and answer the harness’s requests yourself.
ClientTurn-oriented: Client::send returns a Turn that streams assembled Steps and answers tool calls, hooks, and policy checks from handlers you register.

A worked end-to-end example lives on Client. At the protocol tier, a frame off the wire decodes like this:

use antigravity_codes::protocol::{OutputEvent, OutputEventEvent};

// Exactly as a live harness emits it — note the stringified `seqNum`.
let frame = r#"{
  "stepUpdate": {"cascadeId": "abc", "stepIndex": 0, "state": "STATE_DONE", "text": "hi"},
  "seqNum": "3",
  "timestampMicros": "1786220347646352"
}"#;

let event: OutputEvent = serde_json::from_str(frame).unwrap();
assert_eq!(event.sequence(), Some(3));

let Some(OutputEventEvent::StepUpdate(step)) = event.into_event() else {
    panic!("expected a step update")
};
assert_eq!(step.text.as_deref(), Some("hi"));
assert!(step.is_terminal());

§Feature Flags

FeatureDescriptionWASM-compatible
typesWire types and the handshake codec only (serde)Yes
async-clientAsync WebSocket client using tokioNo
integration-testsEnables tests that need a real harness binaryNo

All features are enabled by default. For WASM or type-sharing use cases:

[dependencies]
antigravity-codes = { version = "0.1", default-features = false, features = ["types"] }

§Versioning

The crate version tracks the google-antigravity release whose harness it was generated from and tested against — see TESTED_SDK_VERSION.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use process::Harness;async-client
pub use process::HarnessOptions;async-client
pub use process::ModelBuilder;async-client
pub use steps::Step;async-client
pub use steps::StepKind;async-client

Modules§

error
Error types for the harness client.
handlersasync-client
Answering the requests the harness sends back to the client.
handshake
The length-prefixed stdio handshake that precedes the WebSocket session.
processasync-client
Finding, launching, and handshaking with the localharness binary.
protocol
The protobuf-JSON wire types, re-exported flat.
stepsasync-client
Turning a stream of StepUpdate frames into coherent steps.
wire
serde adapters for the quirks of the protobuf-JSON encoding.

Structs§

Clientasync-client
A harness session that drives whole turns.
RawClientasync-client
A harness session with no interpretation layered on top.
Turnasync-client
One turn of the conversation: everything between a prompt and the agent going idle again.

Constants§

TESTED_SDK_VERSION
The google-antigravity release this crate’s types were generated from and tested against.