Determine if a tool should be confirmed based on preferences. Args: tool_name: Name of the tool Returns: True if tool should be confirmed, False otherwise
(self, tool_name: str)
| 338 | return ToolRiskLevel.MODERATE |
| 339 | |
| 340 | def should_confirm_tool(self, tool_name: str) -> bool: |
| 341 | """Determine if a tool should be confirmed based on preferences. |
| 342 | |
| 343 | Args: |
| 344 | tool_name: Name of the tool |
| 345 | |
| 346 | Returns: |
| 347 | True if tool should be confirmed, False otherwise |
| 348 | """ |
| 349 | # Check per-tool override first |
| 350 | tool_setting = self.get_tool_confirmation(tool_name) |
| 351 | if tool_setting == "always": |
| 352 | return True |
| 353 | elif tool_setting == "never": |
| 354 | return False |
| 355 | elif tool_setting == "ask": |
| 356 | return True |
| 357 | |
| 358 | # Check global mode |
| 359 | mode = self.preferences.ui.tool_confirmation.mode |
| 360 | if mode == ConfirmationMode.ALWAYS: |
| 361 | return True |
| 362 | elif mode == ConfirmationMode.NEVER: |
| 363 | return False |
| 364 | elif mode == ConfirmationMode.SMART: |
| 365 | risk_level = self.get_tool_risk_level(tool_name) |
| 366 | return self.preferences.ui.tool_confirmation.risk_thresholds.get( |
| 367 | risk_level, True |
| 368 | ) |
| 369 | |
| 370 | return True # type: ignore[unreachable] # safety fallback |
| 371 | |
| 372 | def is_trusted_domain(self, server_url: str | None) -> bool: |
| 373 | """Check if a server URL belongs to a trusted domain. |