Refactor tool execution pipeline

This commit is contained in:
2026-06-21 14:30:40 +08:00
parent 3e5f0658b3
commit 99c1e9cd6c
81 changed files with 3587 additions and 5317 deletions
+10 -5
View File
@@ -131,7 +131,11 @@ impl ApprovalManager {
/// 处理用户回复(由消息循环调用)
/// 返回 (技能名, 决策);匹配失败返回 None
pub async fn handle_reply(&self, user_id: &str, reply: &str) -> Option<(String, ApprovalDecision)> {
pub async fn handle_reply(
&self,
user_id: &str,
reply: &str,
) -> Option<(String, ApprovalDecision)> {
let (result, name, code_hash) = {
let mut map = self.pending.lock().await;
let entries = map.get_mut(user_id)?;
@@ -216,10 +220,11 @@ impl ApprovalManager {
let mut map = self.pending.lock().await;
for (uid, i, _) in expired.iter().rev() {
if let Some(entries) = map.get_mut(uid)
&& *i < entries.len() {
let entry = entries.remove(*i);
let _ = entry.sender.send(ApprovalDecision::Expired);
}
&& *i < entries.len()
{
let entry = entries.remove(*i);
let _ = entry.sender.send(ApprovalDecision::Expired);
}
}
map.retain(|_, v| !v.is_empty());
}