From 2070475a4fd2e0d80d32b75e3a2c83be05fd37fe Mon Sep 17 00:00:00 2001 From: liusongtao Date: Wed, 15 Apr 2026 16:35:56 +0800 Subject: [PATCH] in devel --- logs/agent.log | 164 ++++++++++++++++++++++++++++++++++++++++++ mcp/skill_registry.py | 47 +++++++++--- 2 files changed, 200 insertions(+), 11 deletions(-) diff --git a/logs/agent.log b/logs/agent.log index a2a66bd..89f6c8c 100644 --- a/logs/agent.log +++ b/logs/agent.log @@ -6351,3 +6351,167 @@ The function `get_system_name()` uses `platform.system()` to determine the syste 🔵 [local ] file_reader 🔵 [local ] code_executor 2026-04-15 16:19:35 [INFO ] agent.MCP.SkillRegistry │ 🔌 SkillRegistry 已关闭所有连接 +2026-04-15 16:22:01 [INFO ] agent.MCP.SkillRegistry │ 🔌 SkillRegistry 已关闭所有连接 +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-autofix +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillRegistry │ ⚠️ 工具实例缺少 name 属性,跳过: {'name': 'opencli-autofix', 'description': 'Automatically fix broken OpenCLI adapters when commands fail. Load this skill when an opencli command fails — it guides you through diagnosing the failure via OPENCLI_DIAGNOSTIC, patching the adapter, retrying, and filing an upstream GitHub issue after a verified fix. Works with any AI agent.', 'allowed-tools': 'Bash(opencli:*), Bash(gh:*), Read, Edit, Write'} +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-browser +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillRegistry │ ⚠️ 工具实例缺少 name 属性,跳过: {'name': 'opencli-browser', 'description': 'Make websites accessible for AI agents. Navigate, click, type, extract, wait — using Chrome with existing login sessions. No LLM API key needed.', 'allowed-tools': 'Bash(opencli:*), Read, Edit, Write'} +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-explorer +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillRegistry │ ⚠️ 工具实例缺少 name 属性,跳过: {'name': 'opencli-explorer', 'description': 'Use when creating a new OpenCLI adapter from scratch, adding support for a new website or platform, exploring a site\'s API endpoints via browser DevTools, or when a user asks to automatically generate a CLI for a website (e.g. "帮我生成 xxx.com 的 cli"). Covers automated generation, API discovery workflow, authentication strategy selection, TS adapter writing, and testing.', 'tags': ['opencli', 'adapter', 'browser', 'api-discovery', 'cli', 'web-scraping', 'automation', 'generate']} +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-oneshot +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillRegistry │ ⚠️ 工具实例缺少 name 属性,跳过: {'name': 'opencli-oneshot', 'description': 'Use when quickly generating a single OpenCLI command from a specific URL and goal description. 4-step process — open page, capture API, write TS adapter, test. For full site exploration, use opencli-explorer instead.', 'tags': ['opencli', 'adapter', 'quick-start', 'ts', 'cli', 'one-shot', 'automation']} +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-usage +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillRegistry │ ⚠️ 工具实例缺少 name 属性,跳过: {'name': 'opencli-usage', 'description': 'Use when running OpenCLI commands to interact with websites (Bilibili, Twitter, Reddit, Xiaohongshu, etc.), desktop apps (Cursor, Notion), or public APIs (HackerNews, arXiv). Covers installation, command reference, and output formats for 87+ adapters.', 'version': '1.7.0', 'author': 'jackwener', 'tags': ['opencli', 'cli', 'browser', 'web', 'chrome-extension', 'cdp', 'bilibili', 'twitter', 'reddit', 'xiaohongshu', 'github', 'youtube', 'AI', 'agent', 'automation']} +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: smart-search +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillRegistry │ ⚠️ 工具实例缺少 name 属性,跳过: {'name': 'smart-search', 'description': '基于 opencli 命令的智能搜索路由器。当用户想要搜索、查询、查找或研究信息时,尤其是涉及指定网站、社交媒体、技术资料、新闻、购物、旅游、求职、金融或中文内容时,务必使用此 skill'} +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 🔧 注册本地工具: ['calculator', 'web_search', 'file_reader', 'code_executor'] +2026-04-15 16:22:04 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: calculator +2026-04-15 16:22:04 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: web_search +2026-04-15 16:22:04 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: file_reader +2026-04-15 16:22:04 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: code_executor +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillRegistry │ 🌐 开始连接在线 MCP Skills,数量=1 +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillClient │ 🌐 连接在线 MCP Skill: [hexstrike-ai] + 传输协议: stdio + 地址 : python3 + 超时 : 300s + 重试 : 2 次 +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:22:04 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=16812 +2026-04-15 16:22:04 [WARNING ] agent.MCP.SkillClient │ ⚠️ 连接失败 (attempt 1/3),1s 后重试: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:22:05 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:22:05 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:22:05 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=20244 +2026-04-15 16:22:05 [WARNING ] agent.MCP.SkillClient │ ⚠️ 连接失败 (attempt 2/3),2s 后重试: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:22:07 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:22:07 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:22:08 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=18752 +2026-04-15 16:22:08 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:22:08 [ERROR ] agent.MCP.SkillRegistry │ ❌ Skill [hexstrike-ai] 连接失败,跳过 + 错误: ❌ MCP Skill [hexstrike-ai] 连接失败(已重试 2 次) + 最后错误: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:22:08 [DEBUG ] agent.MCP.SkillClient │ 🔌 MCP Skill [hexstrike-ai] 已断开 +2026-04-15 16:22:08 [INFO ] agent.MCP.SkillRegistry │ 📊 SkillRegistry 初始化完成 + 本地工具 : 4 个 ['calculator', 'web_search', 'file_reader', 'code_executor'] + 远端工具 : 0 个 [] +2026-04-15 16:22:09 [INFO ] agent.Agent │ 🤖 Agent 初始化完成 + LLM : openai / gpt-4o + 工具总数 : 4 个 + 最大步数 : 10 + 工具列表 : + 🔵 [local ] calculator + 🔵 [local ] web_search + 🔵 [local ] file_reader + 🔵 [local ] code_executor +2026-04-15 16:22:49 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-autofix +2026-04-15 16:29:58 [INFO ] agent.MCP.SkillRegistry │ 🔌 SkillRegistry 已关闭所有连接 +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-autofix +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-autofix +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-browser +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-browser +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-explorer +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-explorer +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-oneshot +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-oneshot +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-usage +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-usage +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: smart-search +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: smart-search +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 🔧 注册本地工具: ['calculator', 'web_search', 'file_reader', 'code_executor'] +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: calculator +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: web_search +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: file_reader +2026-04-15 16:30:00 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: code_executor +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillRegistry │ 🌐 开始连接在线 MCP Skills,数量=1 +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillClient │ 🌐 连接在线 MCP Skill: [hexstrike-ai] + 传输协议: stdio + 地址 : python3 + 超时 : 300s + 重试 : 2 次 +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:30:00 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=19420 +2026-04-15 16:30:00 [WARNING ] agent.MCP.SkillClient │ ⚠️ 连接失败 (attempt 1/3),1s 后重试: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:30:01 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:30:01 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:30:01 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=20076 +2026-04-15 16:30:01 [WARNING ] agent.MCP.SkillClient │ ⚠️ 连接失败 (attempt 2/3),2s 后重试: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:30:03 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:30:03 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:30:03 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=2820 +2026-04-15 16:30:03 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:30:03 [ERROR ] agent.MCP.SkillRegistry │ ❌ Skill [hexstrike-ai] 连接失败,跳过 + 错误: ❌ MCP Skill [hexstrike-ai] 连接失败(已重试 2 次) + 最后错误: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:30:03 [DEBUG ] agent.MCP.SkillClient │ 🔌 MCP Skill [hexstrike-ai] 已断开 +2026-04-15 16:30:03 [INFO ] agent.MCP.SkillRegistry │ 📊 SkillRegistry 初始化完成 + 本地工具 : 10 个 ['opencli-autofix', 'opencli-browser', 'opencli-explorer', 'opencli-oneshot', 'opencli-usage', 'smart-search', 'calculator', 'web_search', 'file_reader', 'code_executor'] + 远端工具 : 0 个 [] +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-autofix +2026-04-15 16:33:03 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-autofix +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-browser +2026-04-15 16:33:03 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-browser +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-explorer +2026-04-15 16:33:03 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-explorer +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-oneshot +2026-04-15 16:33:03 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-oneshot +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-usage +2026-04-15 16:33:03 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-usage +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: smart-search +2026-04-15 16:33:03 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: smart-search +2026-04-15 16:33:03 [INFO ] agent.MCP.SkillRegistry │ 🔧 注册本地工具: ['calculator', 'web_search', 'file_reader', 'code_executor'] +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-autofix +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-autofix +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-browser +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-browser +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-explorer +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-explorer +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-oneshot +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-oneshot +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: opencli-usage +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: opencli-usage +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 📦 加载技能: smart-search +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: smart-search +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 🔧 注册本地工具: ['calculator', 'web_search', 'file_reader', 'code_executor'] +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: calculator +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: web_search +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: file_reader +2026-04-15 16:34:11 [DEBUG ] agent.MCP.SkillRegistry │ 📌 注册本地工具: code_executor +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillRegistry │ 🌐 开始连接在线 MCP Skills,数量=1 +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillClient │ 🌐 连接在线 MCP Skill: [hexstrike-ai] + 传输协议: stdio + 地址 : python3 + 超时 : 300s + 重试 : 2 次 +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:34:11 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=16664 +2026-04-15 16:34:11 [WARNING ] agent.MCP.SkillClient │ ⚠️ 连接失败 (attempt 1/3),1s 后重试: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:34:12 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:34:12 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:34:12 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=2384 +2026-04-15 16:34:12 [WARNING ] agent.MCP.SkillClient │ ⚠️ 连接失败 (attempt 2/3),2s 后重试: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:34:14 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:34:14 [INFO ] agent.MCP.SkillClient │ 🔌 stdio 启动子进程: python3 /Users/sontolau/Applications/hexstrike-ai/hexstrike_mcp.py --server http://localhost:8999 +2026-04-15 16:34:14 [INFO ] agent.MCP.SkillClient │ ✅ stdio 子进程已启动 PID=13276 +2026-04-15 16:34:14 [DEBUG ] agent.MCP.SkillClient │ 🔌 stdio 子进程已关闭 skill=hexstrike-ai +2026-04-15 16:34:14 [ERROR ] agent.MCP.SkillRegistry │ ❌ Skill [hexstrike-ai] 连接失败,跳过 + 错误: ❌ MCP Skill [hexstrike-ai] 连接失败(已重试 2 次) + 最后错误: stdio 子进程无响应 skill=hexstrike-ai method=initialize +2026-04-15 16:34:14 [DEBUG ] agent.MCP.SkillClient │ 🔌 MCP Skill [hexstrike-ai] 已断开 +2026-04-15 16:34:14 [INFO ] agent.MCP.SkillRegistry │ 📊 SkillRegistry 初始化完成 + 本地工具 : 10 个 ['opencli-autofix', 'opencli-browser', 'opencli-explorer', 'opencli-oneshot', 'opencli-usage', 'smart-search', 'calculator', 'web_search', 'file_reader', 'code_executor'] + 远端工具 : 0 个 [] +2026-04-15 16:34:15 [INFO ] agent.Agent │ 🤖 Agent 初始化完成 + LLM : openai / gpt-4o + 工具总数 : 10 个 + 最大步数 : 10 + 工具列表 : + 🔵 [local ] opencli-autofix + 🔵 [local ] opencli-browser + 🔵 [local ] opencli-explorer + 🔵 [local ] opencli-oneshot + 🔵 [local ] opencli-usage + 🔵 [local ] smart-search + 🔵 [local ] calculator + 🔵 [local ] web_search + 🔵 [local ] file_reader + 🔵 [local ] code_executor +2026-04-15 16:34:20 [INFO ] agent.MCP.SkillRegistry │ 🔌 SkillRegistry 已关闭所有连接 diff --git a/mcp/skill_registry.py b/mcp/skill_registry.py index f994273..1790e41 100644 --- a/mcp/skill_registry.py +++ b/mcp/skill_registry.py @@ -23,12 +23,27 @@ from utils.logger import get_logger logger = get_logger("MCP.SkillRegistry") +class BaseEntry: + def to_function_schema(self) -> dict: + raise NotImplementedError + +# ════════════════════════════════════════════════════════════════ +# 本地SKILL.md包装 +# ════════════════════════════════════════════════════════════════ +@dataclass +class LocalSkillEntry(BaseEntry): + name: str + description: str + def to_function_schema(self) -> dict: + return { + "name": self.name, + "description": self.description, + "parameters": {}, + } # ════════════════════════════════════════════════════════════════ # 本地工具包装 -# ════════════════════════════════════════════════════════════════ - -@dataclass -class LocalToolEntry: +@dataclass# ════════════════════════════════════════════════════════════════ +class LocalToolEntry(BaseEntry): """本地工具注册条目""" name: str description: str @@ -42,7 +57,6 @@ class LocalToolEntry: "parameters": self.parameters, } - # ════════════════════════════════════════════════════════════════ # 调用结果统一封装 # ════════════════════════════════════════════════════════════════ @@ -79,7 +93,7 @@ class SkillRegistry: def __init__(self): # 本地工具表: tool_name → LocalToolEntry - self._local: dict[str, LocalToolEntry] = {} + self._local: dict[str, LocalToolEntry|LocalSkillEntry] = {} # 远端工具表: tool_name → (MCPSkillClient, RemoteTool) self._remote: dict[str, tuple[MCPSkillClient, RemoteTool]] = {} # 在线 Skill 客户端列表(用于生命周期管理) @@ -91,8 +105,7 @@ class SkillRegistry: for skill_name, skill_info in skills.items(): logger.info(f"📦 加载技能: {skill_name}") # 将技能注册到远端工具表 - #self._remote[skill_name] = skill_info - self.register_local(skill_info) + self.register_local_skill(skill_info) def load_local_tools(self): enabled = settings.mcp.enabled_tools @@ -111,14 +124,26 @@ class SkillRegistry: if not issubclass(cls, BaseTool): continue if cls: - self.register_local(cls()) + self.register_local_tool(cls()) else: logger.warning(f"⚠️ 未知工具: {tool_name},跳过") + def register_local_skill(self, skill_info: dict[str, Any]) -> None: + name = skill_info.get("name", None) + if not name: + return + self._local[name] = LocalSkillEntry( + name=name, + description=skill_info.get( "description", ""), + # parameters=getattr(tool_instance, "parameters", {}), + # instance=tool_instance, + ) + logger.debug(f"📌 注册本地工具: {name}") + # ── 注册本地工具 ────────────────────────────────────────── - def register_local(self, tool_instance: Any) -> None: + def register_local_tool(self, tool_instance: Any) -> None: """ 注册本地工具实例 工具实例需具备: .name / .description / .parameters / .execute(**kwargs) @@ -137,7 +162,7 @@ class SkillRegistry: def register_local_many(self, *tool_instances: Any) -> None: for t in tool_instances: - self.register_local(t) + self.register_local_tool(t) # ── 连接在线 MCP Skill ────────────────────────────────────