11use std:: { rc:: Rc , sync:: Arc } ;
22
3- use serde_json:: value:: RawValue ;
4-
53use agent_client_protocol_schema:: {
64 AuthenticateRequest , AuthenticateResponse , CancelNotification , Error , ExtNotification ,
75 ExtRequest , ExtResponse , InitializeRequest , InitializeResponse , LoadSessionRequest ,
86 LoadSessionResponse , NewSessionRequest , NewSessionResponse , PromptRequest , PromptResponse ,
9- SetSessionModeRequest , SetSessionModeResponse ,
7+ Result , SetSessionModeRequest , SetSessionModeResponse ,
108} ;
119#[ cfg( feature = "unstable" ) ]
1210use agent_client_protocol_schema:: { SetSessionModelRequest , SetSessionModelResponse } ;
11+ use serde_json:: value:: RawValue ;
1312
1413/// Defines the interface that all ACP-compliant agents must implement.
1514///
@@ -27,7 +26,7 @@ pub trait Agent {
2726 /// The agent should respond with its supported protocol version and capabilities.
2827 ///
2928 /// See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
30- async fn initialize ( & self , args : InitializeRequest ) -> Result < InitializeResponse , Error > ;
29+ async fn initialize ( & self , args : InitializeRequest ) -> Result < InitializeResponse > ;
3130
3231 /// Authenticates the client using the specified authentication method.
3332 ///
@@ -38,7 +37,7 @@ pub trait Agent {
3837 /// `new_session` without receiving an `auth_required` error.
3938 ///
4039 /// See protocol docs: [Initialization](https://agentclientprotocol.com/protocol/initialization)
41- async fn authenticate ( & self , args : AuthenticateRequest ) -> Result < AuthenticateResponse , Error > ;
40+ async fn authenticate ( & self , args : AuthenticateRequest ) -> Result < AuthenticateResponse > ;
4241
4342 /// Creates a new conversation session with the agent.
4443 ///
@@ -52,7 +51,7 @@ pub trait Agent {
5251 /// May return an `auth_required` error if the agent requires authentication.
5352 ///
5453 /// See protocol docs: [Session Setup](https://agentclientprotocol.com/protocol/session-setup)
55- async fn new_session ( & self , args : NewSessionRequest ) -> Result < NewSessionResponse , Error > ;
54+ async fn new_session ( & self , args : NewSessionRequest ) -> Result < NewSessionResponse > ;
5655
5756 /// Processes a user prompt within a session.
5857 ///
@@ -65,7 +64,7 @@ pub trait Agent {
6564 /// - Returns when the turn is complete with a stop reason
6665 ///
6766 /// See protocol docs: [Prompt Turn](https://agentclientprotocol.com/protocol/prompt-turn)
68- async fn prompt ( & self , args : PromptRequest ) -> Result < PromptResponse , Error > ;
67+ async fn prompt ( & self , args : PromptRequest ) -> Result < PromptResponse > ;
6968
7069 /// Cancels ongoing operations for a session.
7170 ///
@@ -78,7 +77,7 @@ pub trait Agent {
7877 /// - Respond to the original `session/prompt` request with `StopReason::Cancelled`
7978 ///
8079 /// See protocol docs: [Cancellation](https://agentclientprotocol.com/protocol/prompt-turn#cancellation)
81- async fn cancel ( & self , args : CancelNotification ) -> Result < ( ) , Error > ;
80+ async fn cancel ( & self , args : CancelNotification ) -> Result < ( ) > ;
8281
8382 /// Loads an existing session to resume a previous conversation.
8483 ///
@@ -90,7 +89,7 @@ pub trait Agent {
9089 /// - Stream the entire conversation history back to the client via notifications
9190 ///
9291 /// See protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/session-setup#loading-sessions)
93- async fn load_session ( & self , _args : LoadSessionRequest ) -> Result < LoadSessionResponse , Error > {
92+ async fn load_session ( & self , _args : LoadSessionRequest ) -> Result < LoadSessionResponse > {
9493 Err ( Error :: method_not_found ( ) )
9594 }
9695
@@ -110,7 +109,7 @@ pub trait Agent {
110109 async fn set_session_mode (
111110 & self ,
112111 _args : SetSessionModeRequest ,
113- ) -> Result < SetSessionModeResponse , Error > {
112+ ) -> Result < SetSessionModeResponse > {
114113 Err ( Error :: method_not_found ( ) )
115114 }
116115
@@ -123,7 +122,7 @@ pub trait Agent {
123122 async fn set_session_model (
124123 & self ,
125124 _args : SetSessionModelRequest ,
126- ) -> Result < SetSessionModelResponse , Error > {
125+ ) -> Result < SetSessionModelResponse > {
127126 Err ( Error :: method_not_found ( ) )
128127 }
129128
@@ -133,7 +132,7 @@ pub trait Agent {
133132 /// protocol compatibility.
134133 ///
135134 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
136- async fn ext_method ( & self , _args : ExtRequest ) -> Result < ExtResponse , Error > {
135+ async fn ext_method ( & self , _args : ExtRequest ) -> Result < ExtResponse > {
137136 Ok ( RawValue :: NULL . to_owned ( ) . into ( ) )
138137 }
139138
@@ -143,89 +142,89 @@ pub trait Agent {
143142 /// while maintaining protocol compatibility.
144143 ///
145144 /// See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)
146- async fn ext_notification ( & self , _args : ExtNotification ) -> Result < ( ) , Error > {
145+ async fn ext_notification ( & self , _args : ExtNotification ) -> Result < ( ) > {
147146 Ok ( ( ) )
148147 }
149148}
150149
151150#[ async_trait:: async_trait( ?Send ) ]
152151impl < T : Agent > Agent for Rc < T > {
153- async fn initialize ( & self , args : InitializeRequest ) -> Result < InitializeResponse , Error > {
152+ async fn initialize ( & self , args : InitializeRequest ) -> Result < InitializeResponse > {
154153 self . as_ref ( ) . initialize ( args) . await
155154 }
156- async fn authenticate ( & self , args : AuthenticateRequest ) -> Result < AuthenticateResponse , Error > {
155+ async fn authenticate ( & self , args : AuthenticateRequest ) -> Result < AuthenticateResponse > {
157156 self . as_ref ( ) . authenticate ( args) . await
158157 }
159- async fn new_session ( & self , args : NewSessionRequest ) -> Result < NewSessionResponse , Error > {
158+ async fn new_session ( & self , args : NewSessionRequest ) -> Result < NewSessionResponse > {
160159 self . as_ref ( ) . new_session ( args) . await
161160 }
162- async fn load_session ( & self , args : LoadSessionRequest ) -> Result < LoadSessionResponse , Error > {
161+ async fn load_session ( & self , args : LoadSessionRequest ) -> Result < LoadSessionResponse > {
163162 self . as_ref ( ) . load_session ( args) . await
164163 }
165164 async fn set_session_mode (
166165 & self ,
167166 args : SetSessionModeRequest ,
168- ) -> Result < SetSessionModeResponse , Error > {
167+ ) -> Result < SetSessionModeResponse > {
169168 self . as_ref ( ) . set_session_mode ( args) . await
170169 }
171- async fn prompt ( & self , args : PromptRequest ) -> Result < PromptResponse , Error > {
170+ async fn prompt ( & self , args : PromptRequest ) -> Result < PromptResponse > {
172171 self . as_ref ( ) . prompt ( args) . await
173172 }
174- async fn cancel ( & self , args : CancelNotification ) -> Result < ( ) , Error > {
173+ async fn cancel ( & self , args : CancelNotification ) -> Result < ( ) > {
175174 self . as_ref ( ) . cancel ( args) . await
176175 }
177176 #[ cfg( feature = "unstable" ) ]
178177 async fn set_session_model (
179178 & self ,
180179 args : SetSessionModelRequest ,
181- ) -> Result < SetSessionModelResponse , Error > {
180+ ) -> Result < SetSessionModelResponse > {
182181 self . as_ref ( ) . set_session_model ( args) . await
183182 }
184- async fn ext_method ( & self , args : ExtRequest ) -> Result < ExtResponse , Error > {
183+ async fn ext_method ( & self , args : ExtRequest ) -> Result < ExtResponse > {
185184 self . as_ref ( ) . ext_method ( args) . await
186185 }
187- async fn ext_notification ( & self , args : ExtNotification ) -> Result < ( ) , Error > {
186+ async fn ext_notification ( & self , args : ExtNotification ) -> Result < ( ) > {
188187 self . as_ref ( ) . ext_notification ( args) . await
189188 }
190189}
191190
192191#[ async_trait:: async_trait( ?Send ) ]
193192impl < T : Agent > Agent for Arc < T > {
194- async fn initialize ( & self , args : InitializeRequest ) -> Result < InitializeResponse , Error > {
193+ async fn initialize ( & self , args : InitializeRequest ) -> Result < InitializeResponse > {
195194 self . as_ref ( ) . initialize ( args) . await
196195 }
197- async fn authenticate ( & self , args : AuthenticateRequest ) -> Result < AuthenticateResponse , Error > {
196+ async fn authenticate ( & self , args : AuthenticateRequest ) -> Result < AuthenticateResponse > {
198197 self . as_ref ( ) . authenticate ( args) . await
199198 }
200- async fn new_session ( & self , args : NewSessionRequest ) -> Result < NewSessionResponse , Error > {
199+ async fn new_session ( & self , args : NewSessionRequest ) -> Result < NewSessionResponse > {
201200 self . as_ref ( ) . new_session ( args) . await
202201 }
203- async fn load_session ( & self , args : LoadSessionRequest ) -> Result < LoadSessionResponse , Error > {
202+ async fn load_session ( & self , args : LoadSessionRequest ) -> Result < LoadSessionResponse > {
204203 self . as_ref ( ) . load_session ( args) . await
205204 }
206205 async fn set_session_mode (
207206 & self ,
208207 args : SetSessionModeRequest ,
209- ) -> Result < SetSessionModeResponse , Error > {
208+ ) -> Result < SetSessionModeResponse > {
210209 self . as_ref ( ) . set_session_mode ( args) . await
211210 }
212- async fn prompt ( & self , args : PromptRequest ) -> Result < PromptResponse , Error > {
211+ async fn prompt ( & self , args : PromptRequest ) -> Result < PromptResponse > {
213212 self . as_ref ( ) . prompt ( args) . await
214213 }
215- async fn cancel ( & self , args : CancelNotification ) -> Result < ( ) , Error > {
214+ async fn cancel ( & self , args : CancelNotification ) -> Result < ( ) > {
216215 self . as_ref ( ) . cancel ( args) . await
217216 }
218217 #[ cfg( feature = "unstable" ) ]
219218 async fn set_session_model (
220219 & self ,
221220 args : SetSessionModelRequest ,
222- ) -> Result < SetSessionModelResponse , Error > {
221+ ) -> Result < SetSessionModelResponse > {
223222 self . as_ref ( ) . set_session_model ( args) . await
224223 }
225- async fn ext_method ( & self , args : ExtRequest ) -> Result < ExtResponse , Error > {
224+ async fn ext_method ( & self , args : ExtRequest ) -> Result < ExtResponse > {
226225 self . as_ref ( ) . ext_method ( args) . await
227226 }
228- async fn ext_notification ( & self , args : ExtNotification ) -> Result < ( ) , Error > {
227+ async fn ext_notification ( & self , args : ExtNotification ) -> Result < ( ) > {
229228 self . as_ref ( ) . ext_notification ( args) . await
230229 }
231230}
0 commit comments