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 protocol docs: 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 theAgent
trait 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 protocol docs: 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.
Trait Implementations§
Source§impl Client for AgentSideConnection
impl Client for AgentSideConnection
Source§fn request_permission<'life0, 'async_trait>(
&'life0 self,
args: RequestPermissionRequest,
) -> Pin<Box<dyn Future<Output = Result<RequestPermissionResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn request_permission<'life0, 'async_trait>(
&'life0 self,
args: RequestPermissionRequest,
) -> Pin<Box<dyn Future<Output = Result<RequestPermissionResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Requests permission from the user for a tool call operation. Read more
Source§fn write_text_file<'life0, 'async_trait>(
&'life0 self,
args: WriteTextFileRequest,
) -> Pin<Box<dyn Future<Output = Result<WriteTextFileResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_text_file<'life0, 'async_trait>(
&'life0 self,
args: WriteTextFileRequest,
) -> Pin<Box<dyn Future<Output = Result<WriteTextFileResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Writes content to a text file in the client’s file system. Read more
Source§fn read_text_file<'life0, 'async_trait>(
&'life0 self,
args: ReadTextFileRequest,
) -> Pin<Box<dyn Future<Output = Result<ReadTextFileResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn read_text_file<'life0, 'async_trait>(
&'life0 self,
args: ReadTextFileRequest,
) -> Pin<Box<dyn Future<Output = Result<ReadTextFileResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reads content from a text file in the client’s file system. Read more
Source§fn create_terminal<'life0, 'async_trait>(
&'life0 self,
args: CreateTerminalRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateTerminalResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_terminal<'life0, 'async_trait>(
&'life0 self,
args: CreateTerminalRequest,
) -> Pin<Box<dyn Future<Output = Result<CreateTerminalResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Executes a command in a new terminal Read more
Source§fn terminal_output<'life0, 'async_trait>(
&'life0 self,
args: TerminalOutputRequest,
) -> Pin<Box<dyn Future<Output = Result<TerminalOutputResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn terminal_output<'life0, 'async_trait>(
&'life0 self,
args: TerminalOutputRequest,
) -> Pin<Box<dyn Future<Output = Result<TerminalOutputResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets the terminal output and exit status Read more
Source§fn release_terminal<'life0, 'async_trait>(
&'life0 self,
args: ReleaseTerminalRequest,
) -> Pin<Box<dyn Future<Output = Result<ReleaseTerminalResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn release_terminal<'life0, 'async_trait>(
&'life0 self,
args: ReleaseTerminalRequest,
) -> Pin<Box<dyn Future<Output = Result<ReleaseTerminalResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Releases a terminal Read more
Source§fn wait_for_terminal_exit<'life0, 'async_trait>(
&'life0 self,
args: WaitForTerminalExitRequest,
) -> Pin<Box<dyn Future<Output = Result<WaitForTerminalExitResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn wait_for_terminal_exit<'life0, 'async_trait>(
&'life0 self,
args: WaitForTerminalExitRequest,
) -> Pin<Box<dyn Future<Output = Result<WaitForTerminalExitResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Waits for the terminal command to exit and return its exit status Read more
Source§fn kill_terminal_command<'life0, 'async_trait>(
&'life0 self,
args: KillTerminalCommandRequest,
) -> Pin<Box<dyn Future<Output = Result<KillTerminalCommandResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn kill_terminal_command<'life0, 'async_trait>(
&'life0 self,
args: KillTerminalCommandRequest,
) -> Pin<Box<dyn Future<Output = Result<KillTerminalCommandResponse, Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Kills the terminal command without releasing the terminal Read more
Source§fn session_notification<'life0, 'async_trait>(
&'life0 self,
args: SessionNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn session_notification<'life0, 'async_trait>(
&'life0 self,
args: SessionNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handles session update notifications from the agent. 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,
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 agent. Read more
Auto Trait Implementations§
impl !Freeze for AgentSideConnection
impl !RefUnwindSafe for AgentSideConnection
impl Send for AgentSideConnection
impl Sync for AgentSideConnection
impl Unpin for AgentSideConnection
impl !UnwindSafe for AgentSideConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more