Skip to content

The agent that grows with you

feat(gateway): plugins.manage remove action for user-installed plugins

teknium1180975a3cb19
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index be20e5dab8e..e8f793ee7cb 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -3673,7 +3673,7 @@ export interface LegacyPluginRow {
version: string
enabled: boolean
}
-/** ``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name`` (+ ``force``, ``enable``, ``ref``); ``update``: ``name``. */
+/** ``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name`` (+ ``force``, ``enable``, ``ref``); ``update``: ``name``; ``remove``: ``name`` (user installs only). */
export interface PluginsManageParams {
profile?: string | null
action?: PluginsAction
@@ -3686,8 +3686,8 @@ export interface PluginsManageParams {
force?: boolean | null
ref?: string | null
}
-export type PluginsAction = 'list' | 'toggle' | 'install' | 'update'
-/** ``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``name``/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``update`` → ``ok``/``unchanged``/``sha``. */
+export type PluginsAction = 'list' | 'toggle' | 'install' | 'update' | 'remove'
+/** ``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``name``/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``update`` → ``ok``/``unchanged``/``sha``; ``remove`` → ``ok``/``name``. */
export interface PluginsManageResult {
plugins?: AgentPluginRow[] | null
user_count?: number | null
@@ -4433,7 +4433,7 @@ export interface RpcMethods {
ping: { params: PingParams; result: PingResult }
/** Loaded plugin manager entries (legacy flat view); the Plugins Hub uses plugins.manage list. */
'plugins.list': { params: PluginsListParams; result: PluginsListResult }
- /** Plugins Hub backend: list installed plugins, toggle, git-install or re-pin a catalog install. */
+ /** Plugins Hub backend: list installed plugins, toggle, git-install, re-pin a catalog install, or remove a user install. */
'plugins.manage': { params: PluginsManageParams; result: PluginsManageResult }
/** Spawn a hidden agent that brings the desktop preview's dev server back up. */
'preview.restart': { params: PreviewRestartParams; result: TaskIdResult }
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 05ab54998dd..e3b388bc6ef 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -1988,7 +1988,7 @@
},
{
"name": "plugins.manage",
- "summary": "Plugins Hub backend: list installed plugins, toggle, git-install or re-pin a catalog install.",
+ "summary": "Plugins Hub backend: list installed plugins, toggle, git-install, re-pin a catalog install, or remove a user install.",
"params": [
{
"name": "params",
@@ -18172,7 +18172,8 @@
"list",
"toggle",
"install",
- "update"
+ "update",
+ "remove"
],
"title": "PluginsAction",
"type": "string"
@@ -18202,7 +18203,7 @@
},
"PluginsManageParams": {
"additionalProperties": false,
- "description": "``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``\n(+ ``force``, ``enable``, ``ref``); ``update``: ``name``.",
+ "description": "``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``\n(+ ``force``, ``enable``, ``ref``); ``update``: ``name``; ``remove``: ``name`` (user installs only).",
"properties": {
"profile": {
"anyOf": [
@@ -18322,7 +18323,7 @@
},
"PluginsManageResult": {
"additionalProperties": false,
- "description": "``list`` \u2192 ``plugins`` + counts; ``toggle`` \u2192 ``ok``/``unchanged``/``name``/``plugin``;\n``install`` \u2192 ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``update`` \u2192\n``ok``/``unchanged``/``sha``.",
+ "description": "``list`` \u2192 ``plugins`` + counts; ``toggle`` \u2192 ``ok``/``unchanged``/``name``/``plugin``;\n``install`` \u2192 ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``update`` \u2192\n``ok``/``unchanged``/``sha``; ``remove`` \u2192 ``ok``/``name``.",
"properties": {
"plugins": {
"anyOf": [
diff --git a/tests/tui_gateway/test_plugins_manage_remove.py b/tests/tui_gateway/test_plugins_manage_remove.py
new file mode 100644
index 00000000000..562edb4ffdc
--- /dev/null
+++ b/tests/tui_gateway/test_plugins_manage_remove.py
@@ -0,0 +1,45 @@
+"""Gateway ``plugins.manage remove`` — the Desktop Plugins hub's Uninstall door.
+
+Drives the real ``hermes_cli.plugins_cmd`` removal core against a temp HERMES_HOME so the RPC is
+proven to delete the plugin tree AND its install metadata, and to refuse anything that is not a user
+install under ``<HERMES_HOME>/plugins/``.
+"""
+
+import json
+
+import pytest
+
+from tui_gateway import server
+
+
+def plugins_home(tmp_path, monkeypatch):
+ home = tmp_path / "hermes-home"
+ (home / "plugins" / "demo-plugin").mkdir(parents=True)
+ (home / "plugins" / "demo-plugin" / "plugin.yaml").write_text("name: demo-plugin\nversion: 1.0.0\n", encoding="utf-8")
+ (home / "plugins" / ".install-metadata.json").write_text(
+ json.dumps({"demo-plugin": {"pinned_sha": "a" * 40}, "other": {"pinned_sha": "b" * 40}}), encoding="utf-8")
+ monkeypatch.setenv("HERMES_HOME", str(home))
+ return home
+
+
+def _remove(name):
+ return server.handle_request({"id": "1", "method": "plugins.manage", "params": {"action": "remove", "name": name}})
+
+
+def test_remove_deletes_user_install_and_its_metadata(plugins_home):
+ resp = _remove("demo-plugin")
+
+ assert resp["result"] == {"ok": True, "name": "demo-plugin"}
+ assert not (plugins_home / "plugins" / "demo-plugin").exists()
+ metadata = json.loads((plugins_home / "plugins" / ".install-metadata.json").read_text(encoding="utf-8"))
+ assert "demo-plugin" not in metadata and "other" in metadata # sibling metadata survives
+
+
+def test_remove_refuses_missing_name_and_unknown_plugin(plugins_home):
+ resp = server.handle_request({"id": "1", "method": "plugins.manage", "params": {"action": "remove"}})
+ assert resp["error"]["code"] == 4019
+
+ resp = _remove("../not-a-plugin")
+ assert "error" in resp and "not found" in resp["error"]["message"]
+ assert (plugins_home / "plugins" / "demo-plugin").exists()
diff --git a/tui_gateway/contracts/tools_mcp_plugins.py b/tui_gateway/contracts/tools_mcp_plugins.py
index 7f4a7f528e2..e41f2c13917 100644
--- a/tui_gateway/contracts/tools_mcp_plugins.py
+++ b/tui_gateway/contracts/tools_mcp_plugins.py
@@ -573,11 +573,12 @@ class PluginsAction(WireEnum):
toggle = "toggle"
install = "install"
update = "update"
+ remove = "remove"
class PluginsManageParams(ProfileParams):
"""``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``
- (+ ``force``, ``enable``, ``ref``); ``update``: ``name``."""
+ (+ ``force``, ``enable``, ``ref``); ``update``: ``name``; ``remove``: ``name`` (user installs only)."""
action: PluginsAction = PluginsAction.list
key: str | None = None
@@ -614,7 +615,7 @@ class AgentPluginRow(Result):
class PluginsManageResult(Result):
"""``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``name``/``plugin``;
``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``update`` →
- ``ok``/``unchanged``/``sha``."""
+ ``ok``/``unchanged``/``sha``; ``remove`` → ``ok``/``name``."""
plugins: list[AgentPluginRow] | None = None
user_count: int | None = None
@@ -632,4 +633,5 @@ class PluginsManageResult(Result):
method("plugins.manage", params=PluginsManageParams, result=PluginsManageResult,
- doc="Plugins Hub backend: list installed plugins, toggle, git-install or re-pin a catalog install.")
+ doc="Plugins Hub backend: list installed plugins, toggle, git-install, re-pin a catalog install, "
+ "or remove a user install.")
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index 942573a92d2..ed246afcec1 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -1504,8 +1504,18 @@ def _plugins_update(rid, params):
return _ok(rid, {"ok": True, "unchanged": not changed, "sha": sha})
+def _plugins_remove(rid, params):
+ """Uninstall a user install (``<HERMES_HOME>/plugins/<name>``) — the same core as ``hermes plugins
+ remove`` and the dashboard; bundled plugins and paths outside the plugins dir are refused there."""
+ name = (params.get("name") or "").strip()
+ if not name:
+ return _err(rid, 4019, "plugins.remove requires a 'name'")
+ result = _tools_mod("hermes_cli.plugins_cmd").dashboard_remove_user_plugin(name)
+ return _ok(rid, result) if result.get("ok") else _err(rid, 5026, result.get("error") or "remove failed")
+
+
_PLUGINS_ACTIONS = {"list": _plugins_list, "toggle": _plugins_toggle, "install": _plugins_install,
- "update": _plugins_update}
+ "update": _plugins_update, "remove": _plugins_remove}
@_scoped_rpc("plugins.manage", 5026, catch_resolve=False)
@@ -1513,7 +1523,8 @@ def _(rid, params: dict) -> dict:
"""TUI Plugins Hub backend (shares primitives with ``hermes plugins`` / the dashboard):
``list`` → {plugins, user_count, bundled_count}; ``toggle`` flips ``key``/``name`` per ``enable``;
``install`` git-clones ``identifier``/``repo`` or a curated ``catalog_name`` (``force``, ``enable``
- default True); ``update`` re-pins a catalog install to the current catalog SHA."""
+ default True); ``update`` re-pins a catalog install to the current catalog SHA; ``remove`` deletes
+ a user install by ``name``."""
return _run_action(rid, params, _PLUGINS_ACTIONS, "plugins")