@@ -19,6 +19,7 @@ use crate::{ExtResponse, SessionModeId};
1919/// Clients are typically code editors (IDEs, text editors) that provide the interface
2020/// between users and AI agents. They manage the environment, handle user interactions,
2121/// and control access to resources.
22+ #[ async_trait:: async_trait( ?Send ) ]
2223pub trait Client {
2324 /// Requests permission from the user for a tool call operation.
2425 ///
@@ -30,32 +31,32 @@ pub trait Client {
3031 /// respond to this request with `RequestPermissionOutcome::Cancelled`.
3132 ///
3233 /// See protocol docs: [Requesting Permission](https://agentclientprotocol.com/protocol/tool-calls#requesting-permission)
33- fn request_permission (
34+ async fn request_permission (
3435 & self ,
3536 args : RequestPermissionRequest ,
36- ) -> impl Future < Output = Result < RequestPermissionResponse , Error > > ;
37+ ) -> Result < RequestPermissionResponse , Error > ;
3738
3839 /// Writes content to a text file in the client's file system.
3940 ///
4041 /// Only available if the client advertises the `fs.writeTextFile` capability.
4142 /// Allows the agent to create or modify files within the client's environment.
4243 ///
4344 /// See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
44- fn write_text_file (
45+ async fn write_text_file (
4546 & self ,
4647 args : WriteTextFileRequest ,
47- ) -> impl Future < Output = Result < WriteTextFileResponse , Error > > ;
48+ ) -> Result < WriteTextFileResponse , Error > ;
4849
4950 /// Reads content from a text file in the client's file system.
5051 ///
5152 /// Only available if the client advertises the `fs.readTextFile` capability.
5253 /// Allows the agent to access file contents within the client's environment.
5354 ///
5455 /// See protocol docs: [Client](https://agentclientprotocol.com/protocol/overview#client)
55- fn read_text_file (
56+ async fn read_text_file (
5657 & self ,
5758 args : ReadTextFileRequest ,
58- ) -> impl Future < Output = Result < ReadTextFileResponse , Error > > ;
59+ ) -> Result < ReadTextFileResponse , Error > ;
5960
6061 /// Handles session update notifications from the agent.
6162 ///
@@ -68,10 +69,7 @@ pub trait Client {
6869 /// updates before responding with the cancelled stop reason.
6970 ///
7071 /// See protocol docs: [Agent Reports Output](https://agentclientprotocol.com/protocol/prompt-turn#3-agent-reports-output)
71- fn session_notification (
72- & self ,
73- args : SessionNotification ,
74- ) -> impl Future < Output = Result < ( ) , Error > > ;
72+ async fn session_notification ( & self , args : SessionNotification ) -> Result < ( ) , Error > ;
7573
7674 /// Executes a command in a new terminal
7775 ///
@@ -87,21 +85,21 @@ pub trait Client {
8785 /// method.
8886 ///
8987 /// See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)
90- fn create_terminal (
88+ async fn create_terminal (
9189 & self ,
9290 args : CreateTerminalRequest ,
93- ) -> impl Future < Output = Result < CreateTerminalResponse , Error > > ;
91+ ) -> Result < CreateTerminalResponse , Error > ;
9492
9593 /// Gets the terminal output and exit status
9694 ///
9795 /// Returns the current content in the terminal without waiting for the command to exit.
9896 /// If the command has already exited, the exit status is included.
9997 ///
10098 /// See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)
101- fn terminal_output (
99+ async fn terminal_output (
102100 & self ,
103101 args : TerminalOutputRequest ,
104- ) -> impl Future < Output = Result < TerminalOutputResponse , Error > > ;
102+ ) -> Result < TerminalOutputResponse , Error > ;
105103
106104 /// Releases a terminal
107105 ///
@@ -115,18 +113,18 @@ pub trait Client {
115113 /// the terminal, allowing the Agent to call `terminal/output` and other methods.
116114 ///
117115 /// See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)
118- fn release_terminal (
116+ async fn release_terminal (
119117 & self ,
120118 args : ReleaseTerminalRequest ,
121- ) -> impl Future < Output = Result < ReleaseTerminalResponse , Error > > ;
119+ ) -> Result < ReleaseTerminalResponse , Error > ;
122120
123121 /// Waits for the terminal command to exit and return its exit status
124122 ///
125123 /// See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)
126- fn wait_for_terminal_exit (
124+ async fn wait_for_terminal_exit (
127125 & self ,
128126 args : WaitForTerminalExitRequest ,
129- ) -> impl Future < Output = Result < WaitForTerminalExitResponse , Error > > ;
127+ ) -> Result < WaitForTerminalExitResponse , Error > ;
130128
131129 /// Kills the terminal command without releasing the terminal
132130 ///
@@ -140,10 +138,10 @@ pub trait Client {
140138 /// Note: `terminal/release` when `TerminalId` is no longer needed.
141139 ///
142140 /// See protocol docs: [Terminals](https://agentclientprotocol.com/protocol/terminals)
143- fn kill_terminal_command (
141+ async fn kill_terminal_command (
144142 & self ,
145143 args : KillTerminalCommandRequest ,
146- ) -> impl Future < Output = Result < KillTerminalCommandResponse , Error > > ;
144+ ) -> Result < KillTerminalCommandResponse , Error > ;
147145
148146 /// Handles extension method requests from the agent.
149147 ///
@@ -152,7 +150,7 @@ pub trait Client {
152150 /// protocol compatibility.
153151 ///
154152 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
155- fn ext_method ( & self , args : ExtRequest ) -> impl Future < Output = Result < ExtResponse , Error > > ;
153+ async fn ext_method ( & self , args : ExtRequest ) -> Result < ExtResponse , Error > ;
156154
157155 /// Handles extension notifications from the agent.
158156 ///
@@ -161,7 +159,7 @@ pub trait Client {
161159 /// while maintaining protocol compatibility.
162160 ///
163161 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
164- fn ext_notification ( & self , args : ExtNotification ) -> impl Future < Output = Result < ( ) , Error > > ;
162+ async fn ext_notification ( & self , args : ExtNotification ) -> Result < ( ) , Error > ;
165163}
166164
167165// Session updates
0 commit comments