(
&self,
agent_run_id: &str,
agent_type: &str,
_project_path: &str,
executor: &ToolExecutor,
tool_call: &ParsedToolCall,
)
| 863 | } |
| 864 | |
| 865 | async fn execute_tool_call( |
| 866 | &self, |
| 867 | agent_run_id: &str, |
| 868 | agent_type: &str, |
| 869 | _project_path: &str, |
| 870 | executor: &ToolExecutor, |
| 871 | tool_call: &ParsedToolCall, |
| 872 | ) -> AppResult<ToolExecutionOutcome> { |
| 873 | let tool_call_id = Uuid::new_v4().to_string(); |
| 874 | let started_at = now_rfc3339(); |
| 875 | let input_json = serde_json::to_string(&tool_call.input)?; |
| 876 | |
| 877 | sqlx::query( |
| 878 | "INSERT INTO tool_calls (id, agent_run_id, tool_name, input, status, started_at, created_at) \ |
| 879 | VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)", |
| 880 | ) |
| 881 | .bind(&tool_call_id) |
| 882 | .bind(agent_run_id) |
| 883 | .bind(&tool_call.name) |
| 884 | .bind(&input_json) |
| 885 | .bind("running") |
| 886 | .bind(&started_at) |
| 887 | .bind(&started_at) |
| 888 | .execute(&self.db) |
| 889 | .await?; |
| 890 | |
| 891 | let _ = self.app_handle.emit( |
| 892 | "agent-tool-call", |
| 893 | AgentToolCallEvent { |
| 894 | tool_call_id: tool_call_id.clone(), |
| 895 | agent_run_id: agent_run_id.to_string(), |
| 896 | tool_name: tool_call.name.clone(), |
| 897 | input: tool_call.input.clone(), |
| 898 | }, |
| 899 | ); |
| 900 | |
| 901 | // Check if permission is needed and wait for approval |
| 902 | let permission_rx = self.emit_permission_request_if_needed( |
| 903 | agent_run_id, |
| 904 | agent_type, |
| 905 | executor, |
| 906 | tool_call, |
| 907 | ); |
| 908 | |
| 909 | if let Some(rx) = permission_rx { |
| 910 | // Wait for permission with 60 second timeout |
| 911 | match tokio::time::timeout(Duration::from_secs(60), rx).await { |
| 912 | Ok(Ok(true)) => { |
| 913 | // Permission granted, continue |
| 914 | } |
| 915 | Ok(Ok(false)) => { |
| 916 | // Permission denied |
| 917 | let error_msg = "Permission denied by user"; |
| 918 | sqlx::query( |
| 919 | "UPDATE tool_calls SET status = ?1, output = ?2, error = ?3, completed_at = ?4 WHERE id = ?5", |
| 920 | ) |
| 921 | .bind("failed") |
| 922 | .bind(error_msg) |
no test coverage detected