Skip to content

Commit de3a0c8

Browse files
committed
Use latest version of ACP
1 parent d998ede commit de3a0c8

File tree

3 files changed

+58
-17
lines changed

3 files changed

+58
-17
lines changed

Cargo.lock

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version.workspace = true
88
license.workspace = true
99

1010
[dependencies]
11-
agent-client-protocol = "0.1.0"
11+
agent-client-protocol = "0.7.0"
1212
amzn-codewhisperer-client.workspace = true
1313
amzn-codewhisperer-streaming-client.workspace = true
1414
amzn-consolas-client.workspace = true

crates/agent/src/cli/acp_client.rs

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use std::process::ExitCode;
1313

14-
use agent_client_protocol as acp;
14+
use agent_client_protocol::{self as acp, Agent as _};
1515
use eyre::Result;
1616
use tokio_util::compat::{
1717
TokioAsyncReadCompatExt,
@@ -20,12 +20,15 @@ use tokio_util::compat::{
2020

2121
struct AcpClient;
2222

23+
#[async_trait::async_trait(?Send)]
2324
impl acp::Client for AcpClient {
24-
async fn session_notification(&self, args: acp::SessionNotification) -> Result<(), acp::Error> {
25+
async fn session_notification(&self, args: acp::SessionNotification) -> acp::Result<()> {
2526
match args.update {
26-
acp::SessionUpdate::AgentMessageChunk { content } => match content {
27-
acp::ContentBlock::Text(text) => println!("Agent: {}", text.text),
28-
_ => println!("Agent: <non-text content>"),
27+
acp::SessionUpdate::AgentMessageChunk(acp::ContentChunk { content, .. }) => {
28+
match content {
29+
acp::ContentBlock::Text(text) => println!("Agent: {}", text.text),
30+
_ => println!("Agent: <non-text content>"),
31+
}
2932
},
3033
acp::SessionUpdate::ToolCall(tool_call) => {
3134
println!("🔧 Tool Call: {:#?}", tool_call);
@@ -40,8 +43,7 @@ impl acp::Client for AcpClient {
4043
async fn request_permission(
4144
&self,
4245
args: acp::RequestPermissionRequest,
43-
) -> Result<acp::RequestPermissionResponse, acp::Error> {
44-
eprintln!("ACP Client received permission request: {:?}", args);
46+
) -> acp::Result<acp::RequestPermissionResponse> {
4547

4648
// Auto-approve first option if available
4749
let option_id = args
@@ -50,18 +52,46 @@ impl acp::Client for AcpClient {
5052
.map(|opt| opt.id.clone())
5153
.ok_or_else(|| acp::Error::internal_error())?;
5254

53-
eprintln!("ACP Client auto-approving with option: {:?}", option_id);
5455

5556
Ok(acp::RequestPermissionResponse {
5657
outcome: acp::RequestPermissionOutcome::Selected { option_id },
58+
meta: None,
5759
})
5860
}
5961

60-
async fn write_text_file(&self, _args: acp::WriteTextFileRequest) -> Result<(), acp::Error> {
62+
async fn write_text_file(&self, _args: acp::WriteTextFileRequest) -> acp::Result<acp::WriteTextFileResponse> {
63+
Err(acp::Error::method_not_found())
64+
}
65+
66+
async fn read_text_file(&self, _args: acp::ReadTextFileRequest) -> acp::Result<acp::ReadTextFileResponse> {
67+
Err(acp::Error::method_not_found())
68+
}
69+
70+
async fn create_terminal(&self, _args: acp::CreateTerminalRequest) -> acp::Result<acp::CreateTerminalResponse> {
71+
Err(acp::Error::method_not_found())
72+
}
73+
74+
async fn terminal_output(&self, _args: acp::TerminalOutputRequest) -> acp::Result<acp::TerminalOutputResponse> {
75+
Err(acp::Error::method_not_found())
76+
}
77+
78+
async fn release_terminal(&self, _args: acp::ReleaseTerminalRequest) -> acp::Result<acp::ReleaseTerminalResponse> {
79+
Err(acp::Error::method_not_found())
80+
}
81+
82+
async fn wait_for_terminal_exit(&self, _args: acp::WaitForTerminalExitRequest) -> acp::Result<acp::WaitForTerminalExitResponse> {
83+
Err(acp::Error::method_not_found())
84+
}
85+
86+
async fn kill_terminal_command(&self, _args: acp::KillTerminalCommandRequest) -> acp::Result<acp::KillTerminalCommandResponse> {
87+
Err(acp::Error::method_not_found())
88+
}
89+
90+
async fn ext_method(&self, _args: acp::ExtRequest) -> acp::Result<acp::ExtResponse> {
6191
Err(acp::Error::method_not_found())
6292
}
6393

64-
async fn read_text_file(&self, _args: acp::ReadTextFileRequest) -> Result<acp::ReadTextFileResponse, acp::Error> {
94+
async fn ext_notification(&self, _args: acp::ExtNotification) -> acp::Result<()> {
6595
Err(acp::Error::method_not_found())
6696
}
6797
}
@@ -87,16 +117,23 @@ pub async fn execute(agent_path: String) -> Result<ExitCode> {
87117
tokio::task::spawn_local(handle_io);
88118

89119
// Initialize connection
90-
acp::Agent::initialize(&conn, acp::InitializeRequest {
120+
conn.initialize(acp::InitializeRequest {
91121
protocol_version: acp::V1,
92122
client_capabilities: acp::ClientCapabilities::default(),
123+
client_info: Some(acp::Implementation {
124+
name: "acp-test-client".to_string(),
125+
title: Some("ACP Test Client".to_string()),
126+
version: "0.1.0".to_string(),
127+
}),
128+
meta: None,
93129
})
94130
.await?;
95131

96132
// Create session
97-
let session = acp::Agent::new_session(&conn, acp::NewSessionRequest {
133+
let session = conn.new_session(acp::NewSessionRequest {
98134
mcp_servers: Vec::new(),
99135
cwd: std::env::current_dir()?,
136+
meta: None,
100137
})
101138
.await?;
102139

@@ -116,12 +153,14 @@ pub async fn execute(agent_path: String) -> Result<ExitCode> {
116153
continue;
117154
}
118155

119-
acp::Agent::prompt(&conn, acp::PromptRequest {
156+
conn.prompt(acp::PromptRequest {
120157
session_id: session.session_id.clone(),
121158
prompt: vec![acp::ContentBlock::Text(acp::TextContent {
122159
text: input.to_string(),
123160
annotations: None,
161+
meta: None,
124162
})],
163+
meta: None,
125164
})
126165
.await?;
127166
}

0 commit comments

Comments
 (0)