Skip to main content

RawClient

Struct RawClient 

Source
pub struct RawClient { /* private fields */ }
Available on crate feature async-client only.
Expand description

A harness session with no interpretation layered on top.

RawClient owns the process and the socket and does exactly three things: the handshake, the initialize exchange, and frame codec. Answering the harness’s tool calls, hooks, and policy checks is the caller’s job — see crate::Client for a version that does that for you.

use antigravity_codes::{HarnessOptions, ModelBuilder, RawClient};
use antigravity_codes::protocol::{InputEvent, OutputEventEvent};

let mut client = RawClient::launch(
    HarnessOptions::new()
        .workspace("/tmp/project")
        .model(ModelBuilder::gemini("gemini-flash-latest", "…")),
)
.await?;

client.send(&InputEvent::user("hello")).await?;
while let Some(event) = client.next_event().await? {
    if let Some(OutputEventEvent::StepUpdate(step)) = event.into_event() {
        println!("{:?}", step.text_or_delta());
    }
}

Implementations§

Source§

impl RawClient

Source

pub async fn launch(options: HarnessOptions) -> Result<Self>

Launches a harness, connects, and completes the initialize exchange.

Source

pub fn initialize_response(&self) -> &InitializeConversationResponse

The harness’s reply to initialize: the conversation id, any replayed history, and cumulative usage for a resumed session.

Source

pub fn cascade_id(&self) -> Option<&str>

The conversation id, which the harness calls a “cascade id”.

Source

pub fn harness(&self) -> &Harness

The running process, for its stderr tail and port.

Source

pub async fn send(&mut self, event: &InputEvent) -> Result<()>

Sends one frame.

Source

pub async fn next_event(&mut self) -> Result<Option<OutputEvent>>

Reads the next frame, or None once the harness has closed the socket.

Non-text frames (pings, pongs, the close frame itself) are handled and skipped rather than surfaced.

Source

pub fn is_closed(&self) -> bool

True once the socket has closed in either direction.

Source

pub async fn shutdown(self) -> Result<()>

Asks the harness to end the session, waits for it to acknowledge, then stops the process.

The acknowledgement matters: the harness flushes conversation state to its storage directory on the way out, so killing it early loses the transcript a later cascade_id resume would have replayed.

Trait Implementations§

Source§

impl Debug for RawClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V