Skip to content

Commit 8d3666c

Browse files
tlongwell-blocknpub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757
andauthored
Guide CLI installation and subscription sign-in (#1980)
Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
1 parent d52dedb commit 8d3666c

13 files changed

Lines changed: 1129 additions & 69 deletions

File tree

‎crates/buzz-acp/src/acp.rs‎

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
336370
impl 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),

‎crates/buzz-acp/src/config.rs‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ impl std::fmt::Display for PermissionMode {
175175
about = "Query available models from the configured agent"
176176
)]
177177
pub struct ModelsArgs {
178+
/// Agent binary to spawn (e.g. "goose", "claude-agent-acp", "codex-acp").
179+
#[command(flatten)]
180+
pub agent: AuthAgentArgs,
181+
182+
/// Output structured JSON instead of human-readable text.
183+
#[arg(long)]
184+
pub json: bool,
185+
}
186+
187+
/// Shared agent-spawn flags for lightweight local ACP helper subcommands.
188+
#[derive(Debug, Parser)]
189+
pub struct AuthAgentArgs {
178190
/// Agent binary to spawn (e.g. "goose", "claude-agent-acp", "codex-acp").
179191
#[arg(long, env = "BUZZ_ACP_AGENT_COMMAND", default_value = "goose")]
180192
pub agent_command: String,
@@ -187,12 +199,38 @@ pub struct ModelsArgs {
187199
value_delimiter = ','
188200
)]
189201
pub agent_args: Vec<String>,
202+
}
203+
204+
/// CLI args for `buzz-acp auth-methods` — query adapter-advertised login methods.
205+
#[derive(Debug, Parser)]
206+
#[command(
207+
name = "buzz-acp auth-methods",
208+
about = "Query adapter-advertised ACP authentication methods"
209+
)]
210+
pub struct AuthMethodsArgs {
211+
#[command(flatten)]
212+
pub agent: AuthAgentArgs,
190213

191214
/// Output structured JSON instead of human-readable text.
192215
#[arg(long)]
193216
pub json: bool,
194217
}
195218

219+
/// CLI args for `buzz-acp authenticate` — start an adapter-owned login flow.
220+
#[derive(Debug, Parser)]
221+
#[command(
222+
name = "buzz-acp authenticate",
223+
about = "Start an adapter-owned ACP authentication flow"
224+
)]
225+
pub struct AuthenticateArgs {
226+
#[command(flatten)]
227+
pub agent: AuthAgentArgs,
228+
229+
/// Adapter-advertised auth method id to invoke.
230+
#[arg(long)]
231+
pub method_id: String,
232+
}
233+
196234
#[derive(Debug, Parser)]
197235
#[command(
198236
name = "buzz-acp",

0 commit comments

Comments
 (0)