feat: 统一安全层 - AI 风险识别 + 三模式切换
安全检查流程: - 工具调用前统一经过 safety.check() 拦截 - 普通模式: AI 独立分析指令风险(不带历史对话) - 识别出风险后展示: 指令/风险等级/影响,请求 y/n 确认 - 安全操作快速预检放行(读取类/查询类直接跳过) 三种模式 (/safe 切换): - 普通模式 (默认): AI 识别风险,有风险才确认 - 人工确认模式: 所有指令都需确认 - 无限制模式: 直接执行,不检查 特殊指令始终需确认: - cmd_executor: rm/chmod/chown - file_manager: delete - git_tools: checkout -b
This commit is contained in:
1 parent
3c8ca42bfa
commit
5147662b88
4 files changed
+328
No files matched your search
@@ -6,6 +6,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from colorama import Fore, Style
|
||||
|
||||
from .constants import UNIFIED_TOOL_MANAGER_AVAILABLE
|
||||
from .safety import get_safety
|
||||
|
||||
|
||||
class ToolMixin:
|
||||
@@ -93,6 +94,12 @@ class ToolMixin:
|
||||
args = tool_call_data.get('args', '')
|
||||
arguments = tool_call_data.get('arguments')
|
||||
|
||||
# ── 安全检查 ──
|
||||
safety = get_safety()
|
||||
allowed, msg = safety.check(tool_name, str(args))
|
||||
if not allowed:
|
||||
return {"result": f"🚫 已取消: {msg}"}
|
||||
|
||||
if UNIFIED_TOOL_MANAGER_AVAILABLE and hasattr(self.liugin_manager, 'execute'):
|
||||
if arguments and isinstance(arguments, dict):
|
||||
result = self.liugin_manager.execute(tool_name, args, **arguments)
|
||||
|
||||
Reference in new issue
Block a user