pub trait Client {
// Required methods
fn request_permission(
&self,
args: RequestPermissionRequest,
) -> impl Future<Output = Result<RequestPermissionResponse, Error>>;
fn write_text_file(
&self,
args: WriteTextFileRequest,
) -> impl Future<Output = Result<WriteTextFileResponse, Error>>;
fn read_text_file(
&self,
args: ReadTextFileRequest,
) -> impl Future<Output = Result<ReadTextFileResponse, Error>>;
fn session_notification(
&self,
args: SessionNotification,
) -> impl Future<Output = Result<(), Error>>;
fn create_terminal(
&self,
args: CreateTerminalRequest,
) -> impl Future<Output = Result<CreateTerminalResponse, Error>>;
fn terminal_output(
&self,
args: TerminalOutputRequest,
) -> impl Future<Output = Result<TerminalOutputResponse, Error>>;
fn release_terminal(
&self,
args: ReleaseTerminalRequest,
) -> impl Future<Output = Result<ReleaseTerminalResponse, Error>>;
fn wait_for_terminal_exit(
&self,
args: WaitForTerminalExitRequest,
) -> impl Future<Output = Result<WaitForTerminalExitResponse, Error>>;
fn kill_terminal_command(
&self,
args: KillTerminalCommandRequest,
) -> impl Future<Output = Result<KillTerminalCommandResponse, Error>>;
fn ext_method(
&self,
method: Arc<str>,
params: Arc<RawValue>,
) -> impl Future<Output = Result<Arc<RawValue>, Error>>;
fn ext_notification(
&self,
method: Arc<str>,
params: Arc<RawValue>,
) -> impl Future<Output = Result<(), Error>>;
}Expand description
Defines the interface that ACP-compliant clients must implement.
Clients are typically code editors (IDEs, text editors) that provide the interface between users and AI agents. They manage the environment, handle user interactions, and control access to resources.
Required Methods§
Sourcefn request_permission(
&self,
args: RequestPermissionRequest,
) -> impl Future<Output = Result<RequestPermissionResponse, Error>>
fn request_permission( &self, args: RequestPermissionRequest, ) -> impl Future<Output = Result<RequestPermissionResponse, Error>>
Requests permission from the user for a tool call operation.
Called by the agent when it needs user authorization before executing a potentially sensitive operation. The client should present the options to the user and return their decision.
If the client cancels the prompt turn via session/cancel, it MUST
respond to this request with RequestPermissionOutcome::Cancelled.
See protocol docs: Requesting Permission
Sourcefn write_text_file(
&self,
args: WriteTextFileRequest,
) -> impl Future<Output = Result<WriteTextFileResponse, Error>>
fn write_text_file( &self, args: WriteTextFileRequest, ) -> impl Future<Output = Result<WriteTextFileResponse, Error>>
Writes content to a text file in the client’s file system.
Only available if the client advertises the fs.writeTextFile capability.
Allows the agent to create or modify files within the client’s environment.
See protocol docs: Client
Sourcefn read_text_file(
&self,
args: ReadTextFileRequest,
) -> impl Future<Output = Result<ReadTextFileResponse, Error>>
fn read_text_file( &self, args: ReadTextFileRequest, ) -> impl Future<Output = Result<ReadTextFileResponse, Error>>
Reads content from a text file in the client’s file system.
Only available if the client advertises the fs.readTextFile capability.
Allows the agent to access file contents within the client’s environment.
See protocol docs: Client
Sourcefn session_notification(
&self,
args: SessionNotification,
) -> impl Future<Output = Result<(), Error>>
fn session_notification( &self, args: SessionNotification, ) -> impl Future<Output = Result<(), Error>>
Handles session update notifications from the agent.
This is a notification endpoint (no response expected) that receives real-time updates about session progress, including message chunks, tool calls, and execution plans.
Note: Clients SHOULD continue accepting tool call updates even after
sending a session/cancel notification, as the agent may send final
updates before responding with the cancelled stop reason.
See protocol docs: Agent Reports Output
Sourcefn create_terminal(
&self,
args: CreateTerminalRequest,
) -> impl Future<Output = Result<CreateTerminalResponse, Error>>
fn create_terminal( &self, args: CreateTerminalRequest, ) -> impl Future<Output = Result<CreateTerminalResponse, Error>>
Executes a command in a new terminal
Only available if the terminal Client capability is set to true.
Returns a TerminalId that can be used with other terminal methods
to get the current output, wait for exit, and kill the command.
The TerminalId can also be used to embed the terminal in a tool call
by using the ToolCallContent::Terminal variant.
The Agent is responsible for releasing the terminal by using the terminal/release
method.
See protocol docs: Terminals
Sourcefn terminal_output(
&self,
args: TerminalOutputRequest,
) -> impl Future<Output = Result<TerminalOutputResponse, Error>>
fn terminal_output( &self, args: TerminalOutputRequest, ) -> impl Future<Output = Result<TerminalOutputResponse, Error>>
Gets the terminal output and exit status
Returns the current content in the terminal without waiting for the command to exit. If the command has already exited, the exit status is included.
See protocol docs: Terminals
Sourcefn release_terminal(
&self,
args: ReleaseTerminalRequest,
) -> impl Future<Output = Result<ReleaseTerminalResponse, Error>>
fn release_terminal( &self, args: ReleaseTerminalRequest, ) -> impl Future<Output = Result<ReleaseTerminalResponse, Error>>
Releases a terminal
The command is killed if it hasn’t exited yet. Use terminal/wait_for_exit
to wait for the command to exit before releasing the terminal.
After release, the TerminalId can no longer be used with other terminal/* methods,
but tool calls that already contain it, continue to display its output.
The terminal/kill method can be used to terminate the command without releasing
the terminal, allowing the Agent to call terminal/output and other methods.
See protocol docs: Terminals
Sourcefn wait_for_terminal_exit(
&self,
args: WaitForTerminalExitRequest,
) -> impl Future<Output = Result<WaitForTerminalExitResponse, Error>>
fn wait_for_terminal_exit( &self, args: WaitForTerminalExitRequest, ) -> impl Future<Output = Result<WaitForTerminalExitResponse, Error>>
Waits for the terminal command to exit and return its exit status
See protocol docs: Terminals
Sourcefn kill_terminal_command(
&self,
args: KillTerminalCommandRequest,
) -> impl Future<Output = Result<KillTerminalCommandResponse, Error>>
fn kill_terminal_command( &self, args: KillTerminalCommandRequest, ) -> impl Future<Output = Result<KillTerminalCommandResponse, Error>>
Kills the terminal command without releasing the terminal
While terminal/release will also kill the command, this method will keep
the TerminalId valid so it can be used with other methods.
This method can be helpful when implementing command timeouts which terminate the command as soon as elapsed, and then get the final output so it can be sent to the model.
Note: terminal/release when TerminalId is no longer needed.
See protocol docs: Terminals
Sourcefn ext_method(
&self,
method: Arc<str>,
params: Arc<RawValue>,
) -> impl Future<Output = Result<Arc<RawValue>, Error>>
fn ext_method( &self, method: Arc<str>, params: Arc<RawValue>, ) -> impl Future<Output = Result<Arc<RawValue>, Error>>
Handles extension method requests from the agent.
Allows the Agent to send an arbitrary request that is not part of the ACP spec. Extension methods provide a way to add custom functionality while maintaining protocol compatibility.
See protocol docs: Extensibility
Sourcefn ext_notification(
&self,
method: Arc<str>,
params: Arc<RawValue>,
) -> impl Future<Output = Result<(), Error>>
fn ext_notification( &self, method: Arc<str>, params: Arc<RawValue>, ) -> impl Future<Output = Result<(), Error>>
Handles extension notifications from the agent.
Allows the Agent to send an arbitrary notification that is not part of the ACP spec. Extension notifications provide a way to send one-way messages for custom functionality while maintaining protocol compatibility.
See protocol docs: Extensibility
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.