| 125 | } |
| 126 | |
| 127 | async fn apply(&self, event: &AgentEvent) { |
| 128 | match event { |
| 129 | AgentEvent::ToolStart { id, name } => { |
| 130 | self.active_tools.write().await.insert( |
| 131 | id.clone(), |
| 132 | ActiveToolState { |
| 133 | tool_name: name.clone(), |
| 134 | started_at_ms: session_clock::now_ms(), |
| 135 | }, |
| 136 | ); |
| 137 | } |
| 138 | AgentEvent::ToolEnd { id, .. } |
| 139 | | AgentEvent::PermissionDenied { tool_id: id, .. } |
| 140 | | AgentEvent::ConfirmationRequired { tool_id: id, .. } |
| 141 | | AgentEvent::ConfirmationReceived { tool_id: id, .. } |
| 142 | | AgentEvent::ConfirmationTimeout { tool_id: id, .. } => { |
| 143 | self.active_tools.write().await.remove(id); |
| 144 | } |
| 145 | _ => {} |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | #[derive(Clone)] |