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
@@ -7,7 +7,7 @@ from kilostar.core.postgres_database.model.custom_toolset import CustomToolsetMo
class CustomToolsetDatabase:
"""用户自定义工具 DAO。``tools`` 字段是工具名列表,业务层负责保证只放非 system/非 mcp 的工具"""
"""工具 DAO。包含系统预置 toolsetis_system=True)和用户自定义 toolset"""
def __init__(self, async_session_maker):
self.async_session_maker = async_session_maker
@@ -20,6 +20,8 @@ class CustomToolsetDatabase:
"description": row.description,
"owner_id": row.owner_id,
"tools": list(row.tools or []),
"is_system": bool(row.is_system),
"category": row.category,
}
@database_exception
@@ -30,6 +32,8 @@ class CustomToolsetDatabase:
tools: List[str],
description: Optional[str] = None,
owner_id: Optional[str] = None,
is_system: bool = False,
category: str = "user",
) -> Dict[str, Any]:
async with self.async_session_maker() as session:
stmt = select(CustomToolsetModel).where(
@@ -41,6 +45,8 @@ class CustomToolsetDatabase:
row.description = description
row.owner_id = owner_id
row.tools = list(tools)
row.is_system = is_system
row.category = category
else:
row = CustomToolsetModel(
toolset_id=toolset_id,
@@ -48,6 +54,8 @@ class CustomToolsetDatabase:
description=description,
owner_id=owner_id,
tools=list(tools),
is_system=is_system,
category=category,
)
session.add(row)
await session.commit()