ClientSideConnection

Struct ClientSideConnection 

Source
pub struct ClientSideConnection { /* private fields */ }
Expand description

A client-side connection to an agent.

This struct provides the client’s view of an ACP connection, allowing clients (such as code editors) to communicate with agents. It implements the Agent trait to provide methods for initializing sessions, sending prompts, and managing the agent lifecycle.

See protocol docs: Client

Implementations§

Source§

impl ClientSideConnection

Source

pub fn new( client: impl MessageHandler<ClientSide> + 'static, outgoing_bytes: impl Unpin + AsyncWrite, incoming_bytes: impl Unpin + AsyncRead, spawn: impl Fn(LocalBoxFuture<'static, ()>) + 'static, ) -> (Self, impl Future<Output = Result<()>>)

Creates a new client-side connection to an agent.

This establishes the communication channel between a client and agent following the ACP specification.

§Arguments
  • client - A handler that implements the Client trait to process incoming agent requests
  • outgoing_bytes - The stream for sending data to the agent (typically stdout)
  • incoming_bytes - The stream for receiving data from the agent (typically stdin)
  • spawn - A function to spawn async tasks (e.g., tokio::spawn)
§Returns

Returns a tuple containing:

  • The connection instance for making requests to the agent
  • An I/O future that must be spawned to handle the underlying communication

See protocol docs: Communication Model

Source

pub fn subscribe(&self) -> StreamReceiver

Subscribe to receive stream updates from the agent.

This allows the client to receive real-time notifications about agent activities, such as tool calls, content updates, and progress reports.

§Returns

A StreamReceiver that can be used to receive stream messages.

Trait Implementations§

Source§

impl Agent for ClientSideConnection

Source§

fn initialize<'life0, 'async_trait>( &'life0 self, args: InitializeRequest, ) -> Pin<Box<dyn Future<Output = Result<InitializeResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Establishes the connection with a client and negotiates protocol capabilities. Read more
Source§

fn authenticate<'life0, 'async_trait>( &'life0 self, args: AuthenticateRequest, ) -> Pin<Box<dyn Future<Output = Result<AuthenticateResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Authenticates the client using the specified authentication method. Read more
Source§

fn new_session<'life0, 'async_trait>( &'life0 self, args: NewSessionRequest, ) -> Pin<Box<dyn Future<Output = Result<NewSessionResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new conversation session with the agent. Read more
Source§

fn load_session<'life0, 'async_trait>( &'life0 self, args: LoadSessionRequest, ) -> Pin<Box<dyn Future<Output = Result<LoadSessionResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads an existing session to resume a previous conversation. Read more
Source§

fn set_session_mode<'life0, 'async_trait>( &'life0 self, args: SetSessionModeRequest, ) -> Pin<Box<dyn Future<Output = Result<SetSessionModeResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the current mode for a session. Read more
Source§

fn prompt<'life0, 'async_trait>( &'life0 self, args: PromptRequest, ) -> Pin<Box<dyn Future<Output = Result<PromptResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Processes a user prompt within a session. Read more
Source§

fn cancel<'life0, 'async_trait>( &'life0 self, args: CancelNotification, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Cancels ongoing operations for a session. Read more
Source§

fn ext_method<'life0, 'async_trait>( &'life0 self, args: ExtRequest, ) -> Pin<Box<dyn Future<Output = Result<ExtResponse, Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles extension method requests from the client. Read more
Source§

fn ext_notification<'life0, 'async_trait>( &'life0 self, args: ExtNotification, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles extension notifications from the client. 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, 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.