005ce566a8
- Provider model_settings (Provider+Model 级别参数配置): DB JSONB → API → GSM → AgentFactory.resolve → 三节点 agent.run 注入 - 新增 data/toolset/regulatory_toolset/: 监管节点专属工具(query_workflow_status / query_task_list / send_file) - send_file 从 interactive_toolset 迁移至 regulatory_toolset,interactive 仅保留 approval - mcp_helper 合入 GlobalPluginManager dispatch tools - 前端 Provider 弹窗参数设置区加 JSON 编辑器(model_settings) - 前端 Plugin 页面新增"重型插件"Tab(HeavyPluginList 占位) - .gitignore 精简:去除系统默认项,修复 data/ 子目录追踪 - data/toolset/ 与 data/plugin/ 首次纳入版本控制 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
107 lines
3.8 KiB
Python
107 lines
3.8 KiB
Python
"""``data/toolset/`` manifest.json 加载正确性测试。
|
|
|
|
验证 GlobalToolManager 从 manifest.json 正确读取工具元数据。
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
_toolset_dir = Path(__file__).parent.parent.parent / "data" / "toolset"
|
|
_base_toolset_dir = _toolset_dir / "base_toolset"
|
|
_interactive_toolset_dir = _toolset_dir / "interactive_toolset"
|
|
_regulatory_toolset_dir = _toolset_dir / "regulatory_toolset"
|
|
|
|
|
|
def _read_manifest(toolset_dir=_base_toolset_dir):
|
|
with open(toolset_dir / "manifest.json", "r", encoding="utf-8") as f:
|
|
return json.load(f)
|
|
|
|
|
|
def _get_tool_def(manifest, name):
|
|
for tool in manifest["tools"]:
|
|
if tool["name"] == name:
|
|
return tool
|
|
return None
|
|
|
|
|
|
def test_manifest_json_exists():
|
|
assert (_base_toolset_dir / "manifest.json").exists()
|
|
assert (_interactive_toolset_dir / "manifest.json").exists()
|
|
assert (_regulatory_toolset_dir / "manifest.json").exists()
|
|
|
|
|
|
def test_manifest_has_all_tools():
|
|
base_names = {t["name"] for t in _read_manifest(_base_toolset_dir)["tools"]}
|
|
interactive_names = {
|
|
t["name"] for t in _read_manifest(_interactive_toolset_dir)["tools"]
|
|
}
|
|
regulatory_names = {t["name"] for t in _read_manifest(_regulatory_toolset_dir)["tools"]}
|
|
assert base_names == {
|
|
"shell_executor", "file_reader", "edit_file", "write_file",
|
|
"search_file", "python_executor", "tavily_search",
|
|
}
|
|
assert interactive_names == {"approval"}
|
|
assert regulatory_names == {"query_workflow_status", "query_task_list", "send_file"}
|
|
|
|
|
|
def test_approval_metadata():
|
|
manifest = _read_manifest(_interactive_toolset_dir)
|
|
tool = _get_tool_def(manifest, "approval")
|
|
assert tool["is_system"] is True
|
|
assert tool["category"] == "system"
|
|
assert tool["action_scope"] == []
|
|
|
|
|
|
def test_regulatory_toolset_scope():
|
|
manifest = _read_manifest(_regulatory_toolset_dir)
|
|
for name in ("query_workflow_status", "query_task_list", "send_file"):
|
|
tool = _get_tool_def(manifest, name)
|
|
assert tool is not None
|
|
assert tool["is_system"] is True
|
|
assert tool["action_scope"] == ["regulatory_node"]
|
|
|
|
|
|
def test_tavily_search_metadata():
|
|
manifest = _read_manifest()
|
|
tool = _get_tool_def(manifest, "tavily_search")
|
|
assert tool["is_system"] is False
|
|
assert tool["category"] == "search"
|
|
assert "control_node" in tool["action_scope"]
|
|
assert "consciousness_node" in tool["action_scope"]
|
|
assert "api_key" in tool["config_args"]
|
|
|
|
|
|
def test_all_tool_files_exist():
|
|
for toolset_dir in (_base_toolset_dir, _interactive_toolset_dir, _regulatory_toolset_dir):
|
|
manifest = _read_manifest(toolset_dir)
|
|
for tool in manifest["tools"]:
|
|
file_path = toolset_dir / tool["file"]
|
|
assert file_path.exists(), f"Missing tool file: {tool['file']}"
|
|
|
|
|
|
def test_tool_manager_loads_all_tools():
|
|
from kilostar.core.global_state_machine.tool_manager import GlobalToolManager
|
|
|
|
tm = GlobalToolManager()
|
|
# base_toolset(7) + interactive_toolset(1) + regulatory_toolset(3) = 11
|
|
assert len(tm.tool_metadata) == 11
|
|
assert "shell_executor" in tm.tool_metadata
|
|
assert "tavily_search" in tm.tool_metadata
|
|
assert "approval" in tm.tool_metadata
|
|
assert "query_workflow_status" in tm.tool_metadata
|
|
assert "query_task_list" in tm.tool_metadata
|
|
assert "send_file" in tm.tool_metadata
|
|
|
|
|
|
def test_tool_manager_system_vs_third_party():
|
|
from kilostar.core.global_state_machine.tool_manager import GlobalToolManager
|
|
|
|
tm = GlobalToolManager()
|
|
system_tools = tm.get_system_tools()
|
|
third_party = tm.get_third_party_tools()
|
|
system_names = {t["name"] for t in system_tools}
|
|
tp_names = {t["name"] for t in third_party}
|
|
assert "shell_executor" in system_names
|
|
assert "tavily_search" in tp_names
|
|
assert "tavily_search" not in system_names
|