Skip to content

Commit d998ede

Browse files
committed
temp change. doesn't work
1 parent 9932799 commit d998ede

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

crates/agent/src/cli/acp_agent.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ use sacp::{
4242
JrRequestCx,
4343
NewSessionRequest,
4444
NewSessionResponse,
45+
PermissionOption,
46+
PermissionOptionId,
47+
PermissionOptionKind,
4548
PromptRequest,
4649
PromptResponse,
50+
RequestPermissionRequest,
4751
SessionId,
4852
SessionNotification,
4953
SessionUpdate,
@@ -52,6 +56,8 @@ use sacp::{
5256
ToolCall,
5357
ToolCallId,
5458
ToolCallStatus,
59+
ToolCallUpdate,
60+
ToolCallUpdateFields,
5561
ToolKind,
5662
V1,
5763
};
@@ -115,6 +121,7 @@ impl AcpSession {
115121
match agent.recv().await {
116122
Ok(event) => match event {
117123
AgentEvent::Update(update_event) => {
124+
eprintln!("Received update_event: {:?}", update_event);
118125
// Forward updates to ACP client via notifications
119126
if let Some(session_update) = convert_update_event(update_event) {
120127
request_cx.send_notification(SessionNotification {
@@ -124,6 +131,51 @@ impl AcpSession {
124131
})?;
125132
}
126133
},
134+
AgentEvent::ApprovalRequest { id, tool_use, context } => {
135+
eprintln!("Received ApprovalRequest: id={}, tool_use={:?}, context={:?}", id, tool_use, context);
136+
137+
let permission_request = RequestPermissionRequest {
138+
session_id: session_id.clone(),
139+
tool_call: ToolCallUpdate {
140+
id: ToolCallId(tool_use.tool_use_id.clone().into()),
141+
fields: ToolCallUpdateFields {
142+
status: Some(ToolCallStatus::Pending),
143+
title: Some(tool_use.name.clone()),
144+
raw_input: Some(tool_use.input.clone()),
145+
..Default::default()
146+
},
147+
meta: None,
148+
},
149+
options: vec![
150+
PermissionOption {
151+
id: PermissionOptionId("allow".into()),
152+
name: "Allow".to_string(),
153+
kind: PermissionOptionKind::AllowOnce,
154+
meta: None,
155+
},
156+
PermissionOption {
157+
id: PermissionOptionId("deny".into()),
158+
name: "Deny".to_string(),
159+
kind: PermissionOptionKind::RejectOnce,
160+
meta: None,
161+
},
162+
],
163+
meta: None,
164+
};
165+
166+
eprintln!("Sending permission_request: {:?}", permission_request);
167+
168+
match request_cx.send_request(permission_request).block_task().await {
169+
Ok(response) => {
170+
eprintln!("Permission response: {:?}", response);
171+
},
172+
Err(err) => {
173+
eprintln!("Permission request failed: {:?}", err);
174+
}
175+
}
176+
177+
eprintln!("End permission_request");
178+
},
127179
AgentEvent::EndTurn(_metadata) => {
128180
// Conversation complete - respond and exit task
129181
return request_cx.respond(PromptResponse {

crates/agent/src/cli/acp_client.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ impl acp::Client for AcpClient {
4141
&self,
4242
args: acp::RequestPermissionRequest,
4343
) -> Result<acp::RequestPermissionResponse, acp::Error> {
44+
eprintln!("ACP Client received permission request: {:?}", args);
45+
4446
// Auto-approve first option if available
4547
let option_id = args
4648
.options
4749
.first()
4850
.map(|opt| opt.id.clone())
4951
.ok_or_else(|| acp::Error::internal_error())?;
5052

53+
eprintln!("ACP Client auto-approving with option: {:?}", option_id);
54+
5155
Ok(acp::RequestPermissionResponse {
5256
outcome: acp::RequestPermissionOutcome::Selected { option_id },
5357
})

0 commit comments

Comments
 (0)