File tree Expand file tree Collapse file tree 2 files changed +18
-13
lines changed
src/agent-client-protocol Expand file tree Collapse file tree 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change 1414
1515use std:: cell:: Cell ;
1616
17- use agent_client_protocol:: { self as acp, Client as _, SessionConfigOptionValue } ;
17+ use agent_client_protocol:: { self as acp, Client as _} ;
1818use serde_json:: json;
1919use tokio:: sync:: { mpsc, oneshot} ;
2020use tokio_util:: compat:: { TokioAsyncReadCompatExt as _, TokioAsyncWriteCompatExt as _} ;
@@ -120,9 +120,11 @@ impl acp::Agent for ExampleAgent {
120120 args : acp:: SetSessionConfigOptionRequest ,
121121 ) -> Result < acp:: SetSessionConfigOptionResponse , acp:: Error > {
122122 log:: info!( "Received set session config option request {args:?}" ) ;
123- let SessionConfigOptionValue :: ValueId { value } = args. value else {
124- return Err ( acp:: Error :: invalid_params ( ) ) ;
125- } ;
123+ let value = args
124+ . value
125+ . as_value_id ( )
126+ . ok_or ( acp:: Error :: invalid_params ( ) ) ?
127+ . clone ( ) ;
126128 let option = acp:: SessionConfigOption :: select (
127129 args. config_id ,
128130 "Example Option" ,
Original file line number Diff line number Diff line change @@ -156,13 +156,14 @@ impl TestAgent {
156156#[ async_trait:: async_trait( ?Send ) ]
157157impl Agent for TestAgent {
158158 async fn initialize ( & self , arguments : InitializeRequest ) -> Result < InitializeResponse > {
159+ let mut capabilities = AgentCapabilities :: new ( ) ;
160+ #[ cfg( feature = "unstable_logout" ) ]
161+ {
162+ capabilities. auth . logout =
163+ Some ( agent_client_protocol_schema:: LogoutCapabilities :: default ( ) ) ;
164+ }
159165 Ok ( InitializeResponse :: new ( arguments. protocol_version )
160- . agent_capabilities (
161- AgentCapabilities :: new ( ) . auth (
162- agent_client_protocol_schema:: AgentAuthCapabilities :: new ( )
163- . logout ( agent_client_protocol_schema:: LogoutCapabilities :: new ( ) ) ,
164- ) ,
165- )
166+ . agent_capabilities ( capabilities)
166167 . agent_info ( Implementation :: new ( "test-agent" , "0.0.0" ) . title ( "Test Agent" ) ) )
167168 }
168169
@@ -271,9 +272,11 @@ impl Agent for TestAgent {
271272 & self ,
272273 args : agent_client_protocol_schema:: SetSessionConfigOptionRequest ,
273274 ) -> Result < agent_client_protocol_schema:: SetSessionConfigOptionResponse > {
274- let SessionConfigOptionValue :: ValueId { value } = args. value else {
275- return Err ( Error :: invalid_params ( ) ) ;
276- } ;
275+ let value = args
276+ . value
277+ . as_value_id ( )
278+ . ok_or ( agent_client_protocol_schema:: Error :: invalid_params ( ) ) ?
279+ . clone ( ) ;
277280 let option = agent_client_protocol_schema:: SessionConfigOption :: select (
278281 args. config_id ,
279282 "Test Option" ,
You can’t perform that action at this time.
0 commit comments