@@ -121,6 +121,17 @@ fn agent_error_from_json(error: &serde_json::Value) -> AcpError {
121121 AcpError :: AgentError { code, message }
122122}
123123
124+ fn build_initialize_params ( ) -> serde_json:: Value {
125+ serde_json:: json!( {
126+ "protocolVersion" : 2 ,
127+ "clientCapabilities" : build_client_capabilities( ) ,
128+ "clientInfo" : {
129+ "name" : "buzz-acp" ,
130+ "version" : env!( "CARGO_PKG_VERSION" )
131+ } ,
132+ } )
133+ }
134+
124135/// ACP client that owns an agent subprocess and communicates over its stdio.
125136///
126137/// One `AcpClient` per agent process. Multiple sessions can be created on the
@@ -333,6 +344,29 @@ pub(crate) fn build_codex_config_env(
333344 Ok ( Some ( serde_json:: Value :: Object ( base) . to_string ( ) ) )
334345}
335346
347+ fn build_client_capabilities ( ) -> serde_json:: Value {
348+ serde_json:: json!( {
349+ // Signal to ACP adapters that Buzz can hand users to terminal-native
350+ // auth flows. Adapters decide which auth methods to expose; Buzz does
351+ // not hardcode vendor login commands from this capability.
352+ "auth" : {
353+ "terminal" : true
354+ } ,
355+ // Signal to goose that we handle `_goose/unstable/session/update`
356+ // notifications. Without this the custom notification is suppressed
357+ // on goose's side and usage data is never emitted.
358+ "_meta" : {
359+ "goose" : {
360+ "customNotifications" : true
361+ } ,
362+ // Non-standard extension used by claude-agent-acp to advertise the
363+ // exact terminal login argv for subscription auth. Unknown `_meta`
364+ // keys are ignored by other adapters.
365+ "terminal-auth" : true
366+ }
367+ } )
368+ }
369+
336370impl AcpClient {
337371 /// Kill the agent subprocess and wait for it to exit (no zombies).
338372 ///
@@ -501,28 +535,20 @@ impl AcpClient {
501535 pub async fn initialize ( & mut self ) -> Result < serde_json:: Value , AcpError > {
502536 // Requesting version 2 is an intentional temporary pin — we are squatting
503537 // on ACP v2 ahead of the upstream ACP RFD. Revisit when that RFD merges.
504- let params = serde_json:: json!( {
505- "protocolVersion" : 2 ,
506- "clientCapabilities" : {
507- // Signal to goose that we handle `_goose/unstable/session/update`
508- // notifications. Without this the custom notification is suppressed
509- // on goose's side and usage data is never emitted.
510- "_meta" : {
511- "goose" : {
512- "customNotifications" : true
513- }
514- }
515- } ,
516- "clientInfo" : {
517- "name" : "buzz-acp" ,
518- "version" : env!( "CARGO_PKG_VERSION" )
519- }
520- } ) ;
538+ let params = build_initialize_params ( ) ;
521539 let result = self . send_request ( "initialize" , params) . await ?;
522540 tracing:: debug!( target: "acp::init" , "initialize response: {result}" ) ;
523541 Ok ( result)
524542 }
525543
544+ /// Send the ACP `authenticate` request for an adapter-advertised method.
545+ pub async fn authenticate ( & mut self , method_id : & str ) -> Result < serde_json:: Value , AcpError > {
546+ let params = serde_json:: json!( {
547+ "methodId" : method_id,
548+ } ) ;
549+ self . send_request ( "authenticate" , params) . await
550+ }
551+
526552 /// Send `session/new` and return the full response alongside the session ID.
527553 ///
528554 /// `cwd` must be an absolute path. `mcp_servers` may be empty.
@@ -2067,13 +2093,7 @@ mod tests {
20672093 "method" : "initialize" ,
20682094 "params" : {
20692095 "protocolVersion" : 2 ,
2070- "clientCapabilities" : {
2071- "_meta" : {
2072- "goose" : {
2073- "customNotifications" : true
2074- }
2075- }
2076- } ,
2096+ "clientCapabilities" : build_client_capabilities( ) ,
20772097 "clientInfo" : {
20782098 "name" : "buzz-acp" ,
20792099 "version" : "0.1.0"
@@ -2086,6 +2106,11 @@ mod tests {
20862106 Some ( "buzz-acp" )
20872107 ) ;
20882108 assert ! ( msg[ "params" ] [ "clientCapabilities" ] . is_object( ) ) ;
2109+ assert_eq ! (
2110+ msg[ "params" ] [ "clientCapabilities" ] [ "auth" ] [ "terminal" ] . as_bool( ) ,
2111+ Some ( true ) ,
2112+ "terminal auth capability must be advertised so adapters can expose terminal login methods"
2113+ ) ;
20892114 assert_eq ! (
20902115 msg[ "params" ] [ "clientCapabilities" ] [ "_meta" ] [ "goose" ] [ "customNotifications" ] . as_bool( ) ,
20912116 Some ( true ) ,
0 commit comments