diff --git a/crates/acp/src/server.rs b/crates/acp/src/server.rs index 4e1214b635a42dfa9f111a37e3997b1e9d0320eb..d8b4fa115e027bb5d6eecaa46f729dcabee8507f 100644 --- a/crates/acp/src/server.rs +++ b/crates/acp/src/server.rs @@ -178,29 +178,58 @@ impl acp::Client for AcpClientDelegate { todo!() } - async fn request_tool_call( + async fn request_tool_call_confirmation( &self, - request: acp::RequestToolCallParams, - ) -> Result { + request: acp::RequestToolCallConfirmationParams, + ) -> Result { let (tx, rx) = oneshot::channel(); let cx = &mut self.cx.clone(); let entry_id = cx .update(|cx| { self.update_thread(&request.thread_id.into(), cx, |thread, cx| { + // todo! Should we pass through richer data than a description? + let description = match request.confirmation { + acp::ToolCallConfirmation::Edit { + file_name, + file_diff, + } => { + // todo! Nicer syntax/presentation based on file extension? Better way to communicate diff? + format!("Edit file `{file_name}` with diff:\n```\n{file_diff}\n```") + } + acp::ToolCallConfirmation::Execute { + command, + root_command: _, + } => { + format!("Execute command `{command}`") + } + acp::ToolCallConfirmation::Mcp { + server_name, + tool_name: _, + tool_display_name, + } => { + format!("MCP: {server_name} - {tool_display_name}") + } + acp::ToolCallConfirmation::Info { prompt, urls } => { + format!("Info: {prompt}\n{urls:?}") + } + }; // todo! tools that don't require confirmation - thread.push_tool_call(request.tool_name, request.description, tx, cx) + thread.push_tool_call(request.title, description, tx, cx) }) })? .context("Failed to update thread")?; - if rx.await? { - Ok(acp::RequestToolCallResponse::Allowed { - id: entry_id.into(), - }) + let outcome = if rx.await? { + // todo! Handle other outcomes + acp::ToolCallConfirmationOutcome::Allow } else { - Ok(acp::RequestToolCallResponse::Rejected) - } + acp::ToolCallConfirmationOutcome::Reject + }; + Ok(acp::RequestToolCallConfirmationResponse { + id: entry_id.into(), + outcome, + }) } async fn update_tool_call( @@ -300,7 +329,7 @@ impl From for acp::ThreadId { impl From for ToolCallId { fn from(tool_call_id: acp::ToolCallId) -> Self { - Self(ThreadEntryId(tool_call_id.0.into())) + Self(ThreadEntryId(tool_call_id.0)) } }