Expand description
§Google Antigravity Rust SDK
The Google Antigravity SDK is a Rust library for building AI agents powered by Antigravity and Gemini. It provides a secure, scalable, and stateful infrastructure layer that abstracts the agentic loop, letting you focus on what your agent does rather than how it runs.
§Core Architecture Components
Agent: High-level manager of the agent lifecycle. It handles process discovery, tool registration, hook dispatch, and starts the communication backend.Conversation: Stateful wrapper around a connection that tracks full step history, accumulates token usage metadata, and processes stream chunks.Connection: Core trait abstracted to communicate with the underlying harness (e.g. standard subprocess IPC orWebSockets).Hook: Lifecycle hooks allowing you to observe or modify agent transitions and execute custom policies.Policy: Middleware structures enforcing security rules (e.g. restricting files inside workspace viaworkspace_onlyor prompting command runs viaconfirm_run_command).Tool: Custom function capabilities written in Rust and exposed to the model.Trigger: Asynchronous workers triggered at agent start.
§Quickstart Example
use antigravity_sdk_rust::agent::Agent;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let agent = Agent::builder()
.allow_all()
.build();
let agent = agent.start().await?;
let response = agent.chat("Say hello").await?;
println!("Agent: {}", response.text);
agent.stop().await?;
Ok(())
}Modules§
- agent
- connection
- Connection abstractions for communication with the agent execution harness.
- conversation
- Stateful conversation tracking and event chunk streaming.
- hooks
- Lifecycle event hooks for the agent execution loop.
- local
- Local subprocess connection and negotiation.
- policy
- Safety policies and middleware for tool execution control.
- proto
- tools
- Custom client-side tool definition and execution.
- triggers
- Asynchronous event triggers for background connection orchestration.
- types
- Common configuration structures, enums, and SDK data models.
Functions§
- spawn_
task - Helper to spawn asynchronous tasks in a target-agnostic manner.