pub struct Client { /* private fields */ }async-client only.Expand description
A harness session that drives whole turns.
Client wraps RawClient with the three things every caller ends up
writing otherwise: Step assembly from delta frames, replies to the
harness’s tool, hook, policy, and question requests, and
turn-completion detection from trajectory state.
use antigravity_codes::{Client, HarnessOptions, ModelBuilder};
let mut client = Client::launch(
HarnessOptions::new()
.workspace("/tmp/project")
.model(ModelBuilder::gemini("gemini-flash-latest", std::env::var("GEMINI_API_KEY").unwrap())),
)
.await?;
let mut turn = client.send("What files are here?").await?;
while let Some(step) = turn.next_step().await? {
if let Some(text) = step.user_facing_text() {
println!("{text}");
}
}
client.shutdown().await?;Implementations§
Source§impl Client
impl Client
Sourcepub async fn launch(options: HarnessOptions) -> Result<Self>
pub async fn launch(options: HarnessOptions) -> Result<Self>
Launches a harness with no client-side handlers registered.
Sourcepub async fn launch_with(
options: HarnessOptions,
handlers: Handlers,
) -> Result<Self>
pub async fn launch_with( options: HarnessOptions, handlers: Handlers, ) -> Result<Self>
Launches a harness with handlers for its callbacks.
Sourcepub fn cascade_id(&self) -> Option<&str>
pub fn cascade_id(&self) -> Option<&str>
The conversation id, which the harness calls a “cascade id”.
Pass it to HarnessOptions::cascade_id to resume this conversation in
a later process.
Sourcepub fn initialize_response(&self) -> &InitializeConversationResponse
pub fn initialize_response(&self) -> &InitializeConversationResponse
The initialize reply, including any replayed history.
Sourcepub fn usage(&self) -> Option<&UsageMetadata>
pub fn usage(&self) -> Option<&UsageMetadata>
Cumulative token usage for the conversation, as last reported.
Sourcepub fn trajectory_usage(&self) -> &HashMap<String, UsageMetadata>
pub fn trajectory_usage(&self) -> &HashMap<String, UsageMetadata>
Per-trajectory token usage, which separates subagent spend from the main conversation’s.
Sourcepub fn raw(&mut self) -> &mut RawClient
pub fn raw(&mut self) -> &mut RawClient
The underlying frame-level client, for anything this layer does not model.
Sourcepub async fn send(&mut self, prompt: impl Into<String>) -> Result<Turn<'_>>
pub async fn send(&mut self, prompt: impl Into<String>) -> Result<Turn<'_>>
Sends a prompt and returns the turn it started.
Sourcepub async fn send_event(&mut self, event: InputEvent) -> Result<Turn<'_>>
pub async fn send_event(&mut self, event: InputEvent) -> Result<Turn<'_>>
Sends an arbitrary input frame and treats it as the start of a turn.
Use this for multimodal input
(complex_user_input)
or to fire an
automated_trigger.