feat(toolset): 工具系统重构为 toolset 统一管理,新增系统预置工具集

将工具管理从"agent 挂单个 tool"改为"agent 挂 toolset"模式:
- 三个系统预置工具集(system_basic/system_chat/system_workflow)入 DB
- 新增 send_file 工具(系统对话工具集)、修复 approval actor 调用 bug
- 后端 agent 加载全部走 toolset 链路,移除 load_tools_from_list
- 前端工具集中心卡片展示 + agent 配置改为 toolset 多选
- resource API 增加 category 过滤与系统 toolset 保护

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 18:03:49 +00:00
parent d39c80743d
commit 0e57c5cf16
23 changed files with 584 additions and 169 deletions
+10 -5
View File
@@ -14,7 +14,7 @@
"""MCP 辅助模块:根据全局状态机中的配置创建 pydantic-ai MCPServer 实例。"""
from typing import Dict, List, Any, Sequence
from typing import Dict, List, Any, Optional, Sequence
from kilostar.utils.logger import get_logger
@@ -100,10 +100,16 @@ async def get_mcp_toolsets_from_gsm() -> List[Any]:
return []
async def get_all_toolsets_for_scope(scope: str) -> List[Any]:
async def get_all_toolsets_for_scope(
scope: str, toolset_ids: Optional[List[str]] = None
) -> List[Any]:
"""汇总某个 scope 下的全部 toolsetsystem + personal + mcp。
返回顺序保持稳定:先本地 toolsetsystem → personal),再 MCP toolset。
Args:
scope: 调用方所属 scope。
toolset_ids: agent 配置的 toolset 列表;为 None 表示返回全部。
返回顺序保持稳定:先本地 toolset(按 toolset_ids),再 MCP toolset。
任意一类拉取失败仅记录日志,不影响其他类。
"""
toolsets: List[Any] = []
@@ -113,9 +119,8 @@ async def get_all_toolsets_for_scope(scope: str) -> List[Any]:
fetch_snapshot,
)
# 一次快照拉取覆盖 system + custom toolsets,本地按 scope 重建 FunctionToolset
snapshot = await fetch_snapshot()
local = build_toolsets_for_scope(snapshot, scope)
local = build_toolsets_for_scope(snapshot, scope, toolset_ids=toolset_ids)
if local:
toolsets.extend(local)
except Exception as e: