(
&self,
agent_run_id: &str,
agent_type: &str,
executor: &ToolExecutor,
tool_call: &ParsedToolCall,
)
| 1028 | } |
| 1029 | |
| 1030 | fn emit_permission_request_if_needed( |
| 1031 | &self, |
| 1032 | agent_run_id: &str, |
| 1033 | agent_type: &str, |
| 1034 | executor: &ToolExecutor, |
| 1035 | tool_call: &ParsedToolCall, |
| 1036 | ) -> Option<oneshot::Receiver<bool>> { |
| 1037 | if tool_call.name == "run_command" { |
| 1038 | let command = tool_call |
| 1039 | .input |
| 1040 | .get("command") |
| 1041 | .and_then(Value::as_str) |
| 1042 | .map(std::string::ToString::to_string)?; |
| 1043 | |
| 1044 | let rx = self.permissions.register(agent_run_id.to_string()); |
| 1045 | |
| 1046 | let _ = self.app_handle.emit( |
| 1047 | "agent-permission-request", |
| 1048 | AgentPermissionRequestEvent { |
| 1049 | agent_run_id: agent_run_id.to_string(), |
| 1050 | permission_type: "shell_command".to_string(), |
| 1051 | path: command, |
| 1052 | agent_type: agent_type.to_string(), |
| 1053 | }, |
| 1054 | ); |
| 1055 | return Some(rx); |
| 1056 | } |
| 1057 | |
| 1058 | let path = tool_call |
| 1059 | .input |
| 1060 | .get("path") |
| 1061 | .and_then(Value::as_str) |
| 1062 | .map(std::string::ToString::to_string)?; |
| 1063 | |
| 1064 | if executor.requires_permission(&path) { |
| 1065 | let display_path = if PathBuf::from(&path).is_absolute() { |
| 1066 | path.clone() |
| 1067 | } else { |
| 1068 | executor.sandbox.join(&path).to_string_lossy().to_string() |
| 1069 | }; |
| 1070 | |
| 1071 | let rx = self.permissions.register(agent_run_id.to_string()); |
| 1072 | |
| 1073 | let _ = self.app_handle.emit( |
| 1074 | "agent-permission-request", |
| 1075 | AgentPermissionRequestEvent { |
| 1076 | agent_run_id: agent_run_id.to_string(), |
| 1077 | permission_type: "sensitive_file".to_string(), |
| 1078 | path: display_path, |
| 1079 | agent_type: agent_type.to_string(), |
| 1080 | }, |
| 1081 | ); |
| 1082 | return Some(rx); |
| 1083 | } |
| 1084 | |
| 1085 | if executor.is_outside_sandbox(&path) { |
| 1086 | let display_path = if PathBuf::from(&path).is_absolute() { |
| 1087 | path |
no test coverage detected