pub struct AgentSideConnection { /* private fields */ }Expand description
An agent-side connection to a client.
This struct provides the agent’s view of an ACP connection, allowing
agents to communicate with clients. It implements the Client trait
to provide methods for requesting permissions, accessing the file system,
and sending session updates.
See: https://agentclientprotocol.com/protocol/overview#agent
Implementations§
Source§impl AgentSideConnection
impl AgentSideConnection
Sourcepub fn new(
agent: impl MessageHandler<AgentSide> + '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( agent: impl MessageHandler<AgentSide> + '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 agent-side connection to a client.
This establishes the communication channel from the agent’s perspective following the ACP specification.
§Arguments
agent- A handler that implements theAgenttrait to process incoming client requestsoutgoing_bytes- The stream for sending data to the client (typically stdout)incoming_bytes- The stream for receiving data from the client (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 client
- An I/O future that must be spawned to handle the underlying communication
See: https://agentclientprotocol.com/protocol/overview#communication-model
Sourcepub fn subscribe(&self) -> StreamReceiver
pub fn subscribe(&self) -> StreamReceiver
Subscribe to receive stream updates from the client.
This allows the agent to receive real-time notifications about client activities and cancellation requests.
§Returns
A StreamReceiver that can be used to receive stream messages.