fix(toolset): 启动时自动补种系统工具集,工具集页面移至智能体侧边栏
- init_state_machine 启动时检查 DB 并补种 system_basic/system_chat/system_workflow - 修复 postgres facade 缺少 is_system/category 参数的问题 - 前端工具集从"插件"独立为侧边栏"工具集"tab,位于智能体和插件之间 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -67,14 +67,58 @@ class GlobalStateMachine:
|
||||
# Tool configs
|
||||
cfg_rows = await self.postgres_database.list_tool_configs_db.remote()
|
||||
self._tool_configs = {row["tool_name"]: row["config"] for row in cfg_rows}
|
||||
# Custom toolsets
|
||||
# Custom toolsets(含系统预置)
|
||||
ts_rows = await self.postgres_database.list_custom_toolsets.remote()
|
||||
self._custom_toolsets = {row["toolset_id"]: row for row in ts_rows}
|
||||
# 补种系统预置工具集(首次启动或 DB 被 create_all 重建后)
|
||||
await self._seed_system_toolsets()
|
||||
# 让 tool_manager 立刻把 custom toolset 装配成 FunctionToolset
|
||||
self._global_tool_manager.rebuild_custom_toolsets(self._custom_toolsets)
|
||||
# 启动期一次性发布 v1 快照,让等待中的读端立刻可用
|
||||
self._publish_snapshot()
|
||||
|
||||
_SYSTEM_TOOLSETS = [
|
||||
{
|
||||
"toolset_id": "system_basic",
|
||||
"name": "系统基础工具集",
|
||||
"description": "文件读写、搜索、代码执行等基础能力",
|
||||
"tools": ["file_reader", "write_file", "edit_file", "search_file", "python_executor", "shell_executor"],
|
||||
"is_system": True,
|
||||
"category": "system_basic",
|
||||
},
|
||||
{
|
||||
"toolset_id": "system_chat",
|
||||
"name": "系统对话工具集",
|
||||
"description": "对话场景专用工具(发送文件等)",
|
||||
"tools": ["send_file"],
|
||||
"is_system": True,
|
||||
"category": "system_chat",
|
||||
},
|
||||
{
|
||||
"toolset_id": "system_workflow",
|
||||
"name": "系统工作流工具集",
|
||||
"description": "工作流场景专用工具(审批等)",
|
||||
"tools": ["approval"],
|
||||
"is_system": True,
|
||||
"category": "system_workflow",
|
||||
},
|
||||
]
|
||||
|
||||
async def _seed_system_toolsets(self):
|
||||
"""若 DB 中缺少系统预置工具集则自动补种。"""
|
||||
for seed in self._SYSTEM_TOOLSETS:
|
||||
if seed["toolset_id"] not in self._custom_toolsets:
|
||||
await self.postgres_database.upsert_custom_toolset.remote(
|
||||
toolset_id=seed["toolset_id"],
|
||||
name=seed["name"],
|
||||
tools=seed["tools"],
|
||||
description=seed["description"],
|
||||
owner_id=None,
|
||||
is_system=True,
|
||||
category=seed["category"],
|
||||
)
|
||||
self._custom_toolsets[seed["toolset_id"]] = seed
|
||||
|
||||
# ─── Snapshot 发布(Object Store 读路径) ────────────────────
|
||||
|
||||
def _build_snapshot(self) -> GSMSnapshot:
|
||||
|
||||
Reference in New Issue
Block a user