feat: 新增工具插件、系统日志、workflow配置及前端优化
1. 新增工具插件(edit_file, python_executor, search_file, shell_executor, write_file) 2. 新增系统事件日志模块和API 3. 新增workflow配置文件和详情API 4. 前端增加SSE、错误边界、设置引导等组件 5. 优化认证加密、速率限制、配置加载等工具模块 6. 删除废弃的cluster和health API 7. 补充单元测试和集成测试 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -203,6 +203,10 @@ class GlobalStateMachine:
|
||||
"""返回某个 scope 下的"系统 + 自定义工具组"toolset 列表(不含 MCP)。"""
|
||||
return self._global_tool_manager.get_toolsets_for_scope(scope)
|
||||
|
||||
def get_retrieval_toolsets_for_scope(self, scope: str) -> List[Any]:
|
||||
"""仅返回 retrieval 工具集(system_node 专用,不包含 generation 工具)。"""
|
||||
return self._global_tool_manager.get_retrieval_toolsets_for_scope(scope)
|
||||
|
||||
# ─── MCP Server Registry ───────────────────────────────────
|
||||
|
||||
async def add_mcp_server(self, server_id: str, config: Dict[str, Any]) -> bool:
|
||||
|
||||
@@ -34,7 +34,9 @@ class GlobalToolManager:
|
||||
def __init__(self) -> None:
|
||||
self.tool_metadata = {}
|
||||
self._tool_funcs = defaultdict(dict)
|
||||
self._retrieval_tool_funcs = defaultdict(dict)
|
||||
self._system_toolsets = {}
|
||||
self._retrieval_toolsets = {}
|
||||
self._custom_toolsets = {}
|
||||
self._third_party_funcs = {}
|
||||
self.tool_mapper = defaultdict(dict)
|
||||
@@ -75,11 +77,14 @@ class GlobalToolManager:
|
||||
is_system = bool(tool_data_cls.model_fields.get("is_system").default)
|
||||
category_field = tool_data_cls.model_fields.get("category")
|
||||
category = (category_field.default if category_field else "other") or "other"
|
||||
toolset_field = tool_data_cls.model_fields.get("toolset")
|
||||
toolset_name = (toolset_field.default if toolset_field else "other") or "other"
|
||||
|
||||
self.tool_metadata[plugin_name] = {
|
||||
"name": plugin_name,
|
||||
"is_system": is_system,
|
||||
"category": category,
|
||||
"toolset": toolset_name,
|
||||
"action_scope": list(action_scopes),
|
||||
}
|
||||
|
||||
@@ -92,12 +97,15 @@ class GlobalToolManager:
|
||||
for scope in scopes:
|
||||
self._tool_funcs[scope][plugin_name] = tool_func
|
||||
self.tool_mapper[scope][plugin_name] = tool_data_cls
|
||||
if toolset_name == "retrieval":
|
||||
self._retrieval_tool_funcs[scope][plugin_name] = tool_func
|
||||
else:
|
||||
self._third_party_funcs[plugin_name] = tool_func
|
||||
for scope in scopes:
|
||||
self.tool_mapper[scope][plugin_name] = tool_data_cls
|
||||
|
||||
self._build_system_toolsets()
|
||||
self._build_retrieval_toolsets()
|
||||
|
||||
def _build_system_toolsets(self) -> None:
|
||||
FunctionToolset = self._import_function_toolset()
|
||||
@@ -114,6 +122,21 @@ class GlobalToolManager:
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to build system toolset {scope}: {e}")
|
||||
|
||||
def _build_retrieval_toolsets(self) -> None:
|
||||
FunctionToolset = self._import_function_toolset()
|
||||
if FunctionToolset is None:
|
||||
return
|
||||
for scope, name_to_func in self._retrieval_tool_funcs.items():
|
||||
if not name_to_func:
|
||||
continue
|
||||
try:
|
||||
self._retrieval_toolsets[scope] = FunctionToolset(
|
||||
tools=list(name_to_func.values()),
|
||||
id=f"retrieval::{scope}",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to build retrieval toolset {scope}: {e}")
|
||||
|
||||
def rebuild_custom_toolsets(self, custom_defs: Dict[str, Dict[str, Any]]) -> None:
|
||||
"""根据 DB 中的自定义工具组定义重建 custom FunctionToolset。"""
|
||||
FunctionToolset = self._import_function_toolset()
|
||||
@@ -170,6 +193,15 @@ class GlobalToolManager:
|
||||
result.extend(self._custom_toolsets.values())
|
||||
return result
|
||||
|
||||
def get_retrieval_toolsets_for_scope(self, scope: str) -> List[Any]:
|
||||
"""仅返回 retrieval 工具集(system_node 专用)。"""
|
||||
result: List[Any] = []
|
||||
for s in ("default", scope):
|
||||
ts = self._retrieval_toolsets.get(s)
|
||||
if ts is not None:
|
||||
result.append(ts)
|
||||
return result
|
||||
|
||||
# ─── Metadata accessors ───
|
||||
|
||||
def is_third_party_tool(self, tool_name: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user