pub trait Client {
// Required methods
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 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;
// Provided methods
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 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 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 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 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 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 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 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_notification<'life0, 'async_trait>(
&'life0 self,
_args: ExtNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
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<'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.
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 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.
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
Provided Methods§
Sourcefn 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.
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<'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.
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 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
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<'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
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<'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
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<'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
See protocol docs: Terminals
Sourcefn 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
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<'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.
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<'life0, 'async_trait>(
&'life0 self,
_args: ExtNotification,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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 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