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:
- Handshake (binary protobuf,
u32le-length-prefixed, over stdio). The client writes anprotocol::InputConfig; the harness replies with anprotocol::OutputConfigcarrying the port it bound and a single-use API key. Seehandshake. - Connect to
ws://127.0.0.1:{port}/with anx-goog-api-keyheader. - Initialize by sending an
protocol::InitializeConversationEvent; the harness replies with anprotocol::InitializeConversationResponseholding the conversation id and any replayed history. - Converse — send
protocol::InputEvents, receiveprotocol::OutputEvents. Every frame after the handshake is protobuf’s canonical JSON mapping, so the wire is text:camelCasemembers, 64-bit integers as strings,bytesas 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
| Type | What it gives you |
|---|---|
RawClient | The frames, unchanged. You drive the loop and answer the harness’s requests yourself. |
Client | Turn-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
| Feature | Description | WASM-compatible |
|---|---|---|
types | Wire types and the handshake codec only (serde) | Yes |
async-client | Async WebSocket client using tokio | No |
integration-tests | Enables tests that need a real harness binary | No |
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-clientpub use process::HarnessOptions;async-clientpub use process::ModelBuilder;async-clientpub use steps::Step;async-clientpub use steps::StepKind;async-client
Modules§
- error
- Error types for the harness client.
- handlers
async-client - Answering the requests the harness sends back to the client.
- handshake
- The length-prefixed stdio handshake that precedes the WebSocket session.
- process
async-client - Finding, launching, and handshaking with the
localharnessbinary. - protocol
- The protobuf-JSON wire types, re-exported flat.
- steps
async-client - Turning a stream of
StepUpdateframes into coherent steps. - wire
- serde adapters for the quirks of the protobuf-JSON encoding.
Structs§
- Client
async-client - A harness session that drives whole turns.
- RawClient
async-client - A harness session with no interpretation layered on top.
- Turn
async-client - One turn of the conversation: everything between a prompt and the agent going idle again.
Constants§
- TESTED_
SDK_ VERSION - The
google-antigravityrelease this crate’s types were generated from and tested against.