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
impl ClientSideConnection
Sourcepub 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<()>>)
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 theClient
trait to process incoming agent requestsoutgoing_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
Sourcepub fn subscribe(&self) -> StreamReceiver
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.