Skip to content

fix(plugins): 修复 EssentialCommands !func 兼容性并清理 HelloPlugin 调试输出 (LANG-391) - #2967

Merged
RockChinQ merged 1 commit into
masterfrom
agent/sg-agy/a71550d415ae
Nov 10, 2026
Merged

RockChinQ merged 1 commit into
masterfrom
agent/sg-agy/a71550d415ae

Conversation

@RockChinQ

Copy link
Copy Markdown
Member

背景与根因

  1. EssentialCommands 的 !func 命令报 ActionCallError: KeyError: 'manifest':

    • 根因:plugins/misc/EssentialCommands/components/commands/func.py 假设 self.plugin.list_tools() 返回的列表项中包含 'manifest' 键(tool['manifest']),但 Core 的 LIST_TOOLS 动作返回的是平铺结构(name / label / description / spec),导致读取 tool['manifest'] 时抛出 KeyError。
    • 此外,4.11.5 宿主 LIST_TOOLS 还会返回 MCP / 技能 / 内置工具,这类条目只有 name / source / source_id 等字段,没有 label / description / spec。在旧实现下同样会抛出 KeyError。
    • 修复:在 func.py 中兼容平铺字典、MCP/内置/技能工具以及嵌套 manifest 结构,安全解析 name、description(支持多语言字典回退与字符串)与 llm_prompt;同步对同插件下的 cmd.py 和 plugin.py 增加容错保护。
  2. HelloPlugin 的 !info 命令含有调试 print:

    • 根因:plugins/misc/HelloPlugin/components/commands/info.py:32 包含调试输出 print(f"发起者ID…")。作为示例插件容易被照抄,且在中文 Windows 环境下会因子进程输出编码引起 stdio 协议管道断连。
    • 修复:移除该行调试 print,确保 !info 正常返回且不向 stdout 打印。
  3. 版本更新:

    • 按 plugins/RELEASING.md 规范,bump EssentialCommands 版本至 0.1.12,bump HelloPlugin 版本至 0.1.6,并通过 python plugins/scripts/check_catalog.py --write 更新 plugins/catalog.json。

验证证据

  1. 本地真实复现与修复验证:
    • 复现前:在 Core 4.11.5 / SDK 0.7.23 下,!func 执行时必现 KeyError: 'manifest';!info 执行时 stdout 输出了 '发起者ID10001发送者ID10001消息类型LauncherTypes.PERSON\n'。
    • 修复后:
      • !func 支持包含平铺插件工具、内置工具(如 exec)、技能工具、MCP 工具等各种数据结构,在 zh_Hans 和 en_US 下均正常列出且不抛异常。
      • !info 正常返回查询结果,stdout 捕获结果为空字符串 ""。
  2. 测试套件:
    • plugins/misc/EssentialCommands/tests/test_shared_runtime.py:5 个测试全部通过(含新增的平铺工具/MCP/内置工具兼容性回归测试与 cmd/plugin 测试)。
    • plugins/misc/HelloPlugin/tests/test_shared_runtime.py:3 个测试全部通过(含新增的 !info 无 stdout 输出回归测试)。
    • 跨版本 SDK 验证:在 langbot-plugin==0.7.4 和 0.7.23 下两套测试均 100% 通过。
    • python plugins/scripts/check_catalog.py 与 python plugins/scripts/test_repository.py(15 个测试)全部通过。
    • 通过 plugins/scripts/package_plugin.py 成功构建两个插件的 .lbpkg 打包产物。

@RockChinQ
RockChinQ merged commit cce4011 into master Nov 10, 2026
12 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant