@@ -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 {
0 commit comments