MCPcopy Create free account
hub / github.com/AI45Lab/Code / confirm

Method confirm

core/src/hitl.rs:280–307  ·  view source on GitHub ↗

Handle a confirmation response from the user Returns Ok(true) if the confirmation was found and processed, Ok(false) if no pending confirmation was found.

(
        &self,
        tool_id: &str,
        approved: bool,
        reason: Option<String>,
    )

Source from the content-addressed store, hash-verified

278 /// Returns Ok(true) if the confirmation was found and processed,
279 /// Ok(false) if no pending confirmation was found.
280 pub async fn confirm(
281 &self,
282 tool_id: &str,
283 approved: bool,
284 reason: Option<String>,
285 ) -> Result<bool, String> {
286 let pending = {
287 let mut pending_map = self.pending.write().await;
288 pending_map.remove(tool_id)
289 };
290
291 if let Some(confirmation) = pending {
292 // Emit confirmation received event
293 let _ = self.event_tx.send(AgentEvent::ConfirmationReceived {
294 tool_id: tool_id.to_string(),
295 approved,
296 reason: reason.clone(),
297 });
298
299 // Send the response
300 let response = ConfirmationResponse { approved, reason };
301 let _ = confirmation.response_tx.send(response);
302
303 Ok(true)
304 } else {
305 Ok(false)
306 }
307 }
308
309 /// Check for and handle timed out confirmations
310 ///

Calls 4

writeMethod · 0.80
removeMethod · 0.80
sendMethod · 0.45
cloneMethod · 0.45