The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(plugins): enabling a plugin from Desktop/TUI/dashboard no longer strips the core tools
teknium182b9bfedd6e1
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.pyindex 1e6bb076a1f..5148b6be365 100644--- a/hermes_cli/plugins_cmd.py+++ b/hermes_cli/plugins_cmd.py@@ -917,8 +917,10 @@ def _get_plugin_toolset_key(name: str) -> Optional[str]:def _toggle_plugin_toolset(name: str, *, enable: bool) -> None:- """Add/remove a plugin's toolset in ``platform_toolsets`` for all platforms (no-op when the- plugin provides no tools)."""+ """Add/remove a plugin's toolset in every SAVED ``platform_toolsets`` list (no-op when the plugin+ provides no tools). Platforms with no saved list are left alone: a plugin toolset is already on+ there by default, and seeding ``[<plugin_ts>]`` would replace the core composite and strip every+ built-in tool."""toolset_key = _get_plugin_toolset_key(name)if not toolset_key:return@@ -935,10 +937,6 @@ def _toggle_plugin_toolset(name: str, *, enable: bool) -> None:(ts_list.append if enable else ts_list.remove)(toolset_key)platform_toolsets[platform] = ts_listchanged = True- # Enabling with no platform lists yet: seed "cli" at minimum.- if enable and not changed and not platform_toolsets:- platform_toolsets["cli"] = [toolset_key]- changed = Trueif changed:save_config(config)diff --git a/hermes_cli/plugins_cmd_remove.py b/hermes_cli/plugins_cmd_remove.pyindex b18fe083e12..4bcdccf844b 100644--- a/hermes_cli/plugins_cmd_remove.py+++ b/hermes_cli/plugins_cmd_remove.py@@ -133,8 +133,7 @@ def _remove_user_plugin(plugins_dir: Path, name: str, target: Path) -> dict[str,entry = next((e for e in _pc()._discover_all_plugins() if Path(str(e[4])) == target), None)key = entry[5] if entry else target.namealiases = _pc()._plugin_aliases(key) | {target.name}- if _pc()._read_manifest(target).get("provides_tools"):- _pc()._toggle_plugin_toolset(key, enable=False)+ _pc()._toggle_plugin_toolset(key, enable=False)_remove_plugin_core(target)return {"ok": True, "name": name, **_pc()._forget_plugin_config(aliases)}diff --git a/tests/hermes_cli/test_plugins_cmd_activation_keys.py b/tests/hermes_cli/test_plugins_cmd_activation_keys.pyindex d05f39fd893..c57d31c0133 100644--- a/tests/hermes_cli/test_plugins_cmd_activation_keys.py+++ b/tests/hermes_cli/test_plugins_cmd_activation_keys.py@@ -22,6 +22,17 @@ def _write_plugin(root, rel, name, extra=""):return d+def _write_tool_plugin(root, name):+ """User plugin registering one tool in its own toolset, WITHOUT ``provides_tools`` in plugin.yaml."""+ d = _write_plugin(root, name, name)+ (d / "__init__.py").write_text(+ "def register(ctx):\n"+ f" ctx.register_tool(name='{name}_tool', toolset='{name}_ts', handler=lambda args, **kw: '{{}}',\n"+ f" schema={{'name': '{name}_tool', 'description': 'probe', 'parameters': {{'type': 'object', 'properties': {{}}}}}})\n",+ encoding="utf-8")+ return d++@pytest.fixturedef home(tmp_path, monkeypatch):hermes_home = tmp_path / "hermes-home"@@ -85,6 +96,23 @@ def test_dashboard_toggle_writes_canonical_key_and_clears_stale_aliases(home):assert again["unchanged"] is True and again["restart_required"] is False+def test_dashboard_enable_on_a_fresh_config_keeps_the_core_tools(home):+ """Desktop/TUI/dashboard enable with no saved ``platform_toolsets`` must not write one: the old+ seed ``platform_toolsets.cli: [<plugin_ts>]`` replaced the ``hermes-cli`` composite, so the model+ lost every built-in tool (27 -> 2, no ``terminal``). The plugin toolset is on by default anyway."""+ from hermes_cli.tools_config import _get_platform_tools+ from tools.registry import registry++ _write_tool_plugin(home / "plugins", "zzseed")+ try:+ assert plugins_cmd.dashboard_set_agent_plugin_enabled("zzseed", enabled=True)["ok"] is True+ cfg = load_config()+ assert not cfg.get("platform_toolsets")+ assert {"terminal", "file", "zzseed_ts"} <= _get_platform_tools(cfg, "cli")+ finally:+ registry.deregister("zzseed_tool")++def test_status_reports_bundled_defaults_and_the_live_memory_provider(home):"""Bundled backends (auto-load) and the plugin selected by ``memory.provider`` run without a``plugins.enabled`` entry; status must not call them "not enabled" (#73131, #82898)."""diff --git a/tests/hermes_cli/test_plugins_cmd_remove_bookkeeping.py b/tests/hermes_cli/test_plugins_cmd_remove_bookkeeping.pyindex 8300615188c..f929fd56d81 100644--- a/tests/hermes_cli/test_plugins_cmd_remove_bookkeeping.py+++ b/tests/hermes_cli/test_plugins_cmd_remove_bookkeeping.py@@ -55,6 +55,31 @@ def test_remove_forgets_every_config_trace_and_resets_the_memory_provider(home):assert not cfg["memory"]["provider"]+def test_remove_clears_the_toolset_of_a_plugin_without_provides_tools(home):+ """``remove`` drops the plugin's toolset from a saved ``platform_toolsets`` list even when+ plugin.yaml never declared ``provides_tools``; otherwise ``hermes config check`` warns about an+ unknown toolset forever."""+ from tools.registry import registry++ d = _write_plugin(home / "plugins", "zznodecl", "zznodecl")+ (d / "__init__.py").write_text(+ "def register(ctx):\n"+ " ctx.register_tool(name='zznodecl_tool', toolset='zznodecl_ts', handler=lambda args, **kw: '{}',\n"+ " schema={'name': 'zznodecl_tool', 'description': 'probe',\n"+ " 'parameters': {'type': 'object', 'properties': {}}})\n",+ encoding="utf-8")+ (home / "config.yaml").write_text(yaml.safe_dump({+ "plugins": {"enabled": ["zznodecl"]},+ "platform_toolsets": {"cli": ["hermes-cli", "zznodecl_ts"], "telegram": ["hermes-telegram"]},+ }), encoding="utf-8")+ try:+ assert plugins_cmd.dashboard_remove_user_plugin("zznodecl")["ok"] is True+ finally:+ registry.deregister("zznodecl_tool")++ assert _config(home)["platform_toolsets"] == {"cli": ["hermes-cli"], "telegram": ["hermes-telegram"]}++def test_remove_of_a_symlink_inside_the_plugins_dir_unlinks_only_the_link(home):"""A dev alias pointing at a sibling install resolves INSIDE the plugins dir, so the containmentcheck passes; removing the alias must not delete the sibling (or its install metadata)."""diff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.mdindex 20cd97d25f4..80751ac7278 100644--- a/website/docs/developer-guide/plugins/index.md+++ b/website/docs/developer-guide/plugins/index.md@@ -280,6 +280,13 @@ provides_hooks:This tells Hermes: "I'm a plugin called calculator, I provide tools and hooks." The `provides_tools` and `provides_hooks` fields are lists of what the plugin registers.+List every tool your `register()` registers in `provides_tools`. The field does **not** decide whether a user-installed plugin's tools load: once the plugin is enabled, everything `register()` registers is available, declared or not. What it does drive:++- **`hermes plugins validate`**: the "declared tools" check fails when the registered tools don't match the list, which blocks catalog admission.+- **Catalog listing**: the "N tools" chips and tool-name search in the catalog and the dashboard/Desktop Plugins page.+- **Dashboard auth hint**: only declared tools' availability checks are used to show "needs auth" and the `hermes auth <name>` command.+- **Bundled `kind: platform` plugins only**: the field is the switch that loads `tools.py` in CLI/TUI sessions while the adapter stays deferred. See [Outbound client tools](../adding-platform-adapters.md#outbound-client-tools-provides_tools).+Optional fields you could add:```yamlauthor: Your Namediff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/plugins/index.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/plugins/index.mdindex 3dcbf12bf6c..486ec4e8c91 100644--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/plugins/index.md+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/developer-guide/plugins/index.md@@ -67,6 +67,13 @@ provides_hooks:这告诉 Hermes:"我是一个名为 calculator 的插件,我提供工具和钩子。" `provides_tools` 和 `provides_hooks` 字段是插件注册内容的列表。+请在 `provides_tools` 中列出 `register()` 注册的每一个工具。该字段**不**决定用户安装的插件的工具是否加载:插件启用后,`register()` 注册的所有工具都可用,无论是否声明。它实际影响的是:++- **`hermes plugins validate`**:注册的工具与列表不一致时,“declared tools”检查失败,插件无法进入目录(catalog)。+- **目录展示**:目录及仪表盘/桌面端插件页中的“N 个工具”标签和按工具名搜索。+- **仪表盘认证提示**:只有已声明工具的可用性检查会用于显示“需要认证”及 `hermes auth <name>` 命令。+- **仅限内置的 `kind: platform` 插件**:该字段决定是否在 CLI/TUI 会话中加载 `tools.py`(适配器本身仍延迟加载)。参见 [添加平台适配器](../adding-platform-adapters.md)。+可选字段示例:```yamlauthor: Your Name