Skip to content

The agent that grows with you

feat(plugins): presence by catalog name; plugins.manage action presence

alt-glitch3399df06b554
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 7ad8a98f2bc..a46b746d3d9 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -4353,7 +4353,7 @@ export interface LegacyPluginRow {
version: string
enabled: boolean
}
-/** ``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name`` (+ ``force``, ``enable``, ``ref``); ``update``: ``name`` (+ ``accept_capabilities`` to apply a re-pin that widened the plugin after the user confirmed the ``delta``); ``remove``: ``name`` (user installs only); ``settings``: ``key`` + ``values`` (``{setting_key: value}``, non-secret schema keys only). */
+/** ``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name`` (+ ``force``, ``enable``, ``ref``); ``update``: ``name`` (+ ``accept_capabilities`` to apply a re-pin that widened the plugin after the user confirmed the ``delta``); ``remove``: ``name`` (user installs only); ``settings``: ``key`` + ``values`` (``{setting_key: value}``, non-secret schema keys only); ``presence``: ``names`` (catalog names, answered in that order). */
export interface PluginsManageParams {
profile?: string | null
action?: PluginsAction
@@ -4367,8 +4367,9 @@ export interface PluginsManageParams {
ref?: string | null
accept_capabilities?: boolean | null
values?: Record<string, unknown> | null
+ names?: string[] | null
}
-export type PluginsAction = 'list' | 'toggle' | 'install' | 'update' | 'remove' | 'settings' | 'onboarding'
+export type PluginsAction = 'list' | 'toggle' | 'install' | 'update' | 'remove' | 'settings' | 'onboarding' | 'presence'
/** ``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``restart_required``/``name`` (the canonical key written)/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the running gateway picked it up and re-wired its handlers) and ``activation`` — the honest split of what is live now vs deferred, so ``restart_required`` is True only when no gateway answered; ``update`` → ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the ``delta`` (``{surface: [added...]}``) / ``delta_lines`` a widened pin adds — nothing changed until the client retries with ``accept_capabilities``; ``remove`` → ``ok``/``name`` plus ``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``. */
export interface PluginsManageResult {
plugins?: AgentPluginRow[] | null
@@ -4396,6 +4397,7 @@ export interface PluginsManageResult {
error?: string | null
written?: string[] | null
onboarding?: OnboardingCatalogPlugin[] | null
+ presence?: CatalogPluginPresence[] | null
}
/** ``methods_tools._plugin_rows`` + ``plugins_cmd_catalog.catalog_row_fields`` provenance. */
export interface AgentPluginRow {
@@ -4472,6 +4474,14 @@ export interface OnboardingCatalogPlugin {
app_state: CatalogAppState
sentence: string
}
+/** A named catalog plugin this OS runs. ``state`` is the pinned ``plugin.json`` app declaration judged on this host; ``sentence`` names what is missing (empty when present or unknown); ``disclosure`` is the catalog description's ``Disclosure:`` sentence (empty when it has none). */
+export interface CatalogPluginPresence {
+ name: string
+ title: string
+ state: CatalogAppState
+ sentence: string
+ disclosure: string
+}
export interface PluginCatalogLookupParams {
profile?: string | null
name: string
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 7fb16d03604..43e60574c3a 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -7753,6 +7753,40 @@
"title": "CatalogApproved",
"type": "object"
},
+ "CatalogPluginPresence": {
+ "additionalProperties": false,
+ "description": "A named catalog plugin this OS runs. ``state`` is the pinned ``plugin.json`` app declaration judged\non this host; ``sentence`` names what is missing (empty when present or unknown); ``disclosure`` is the\ncatalog description's ``Disclosure:`` sentence (empty when it has none).",
+ "properties": {
+ "name": {
+ "title": "Name",
+ "type": "string"
+ },
+ "title": {
+ "title": "Title",
+ "type": "string"
+ },
+ "state": {
+ "$ref": "#/components/schemas/CatalogAppState"
+ },
+ "sentence": {
+ "title": "Sentence",
+ "type": "string"
+ },
+ "disclosure": {
+ "title": "Disclosure",
+ "type": "string"
+ }
+ },
+ "required": [
+ "name",
+ "title",
+ "state",
+ "sentence",
+ "disclosure"
+ ],
+ "title": "CatalogPluginPresence",
+ "type": "object"
+ },
"CatalogScan": {
"additionalProperties": false,
"description": "The catalog's security scan of the pinned commit; read-only on the card.",
@@ -22977,7 +23011,8 @@
"update",
"remove",
"settings",
- "onboarding"
+ "onboarding",
+ "presence"
],
"title": "PluginsAction",
"type": "string"
@@ -23007,7 +23042,7 @@
},
"PluginsManageParams": {
"additionalProperties": false,
- "description": "``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``\n(+ ``force``, ``enable``, ``ref``); ``update``: ``name`` (+ ``accept_capabilities`` to apply a re-pin\nthat widened the plugin after the user confirmed the ``delta``); ``remove``: ``name`` (user installs only);\n``settings``: ``key`` + ``values`` (``{setting_key: value}``, non-secret schema keys only).",
+ "description": "``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``\n(+ ``force``, ``enable``, ``ref``); ``update``: ``name`` (+ ``accept_capabilities`` to apply a re-pin\nthat widened the plugin after the user confirmed the ``delta``); ``remove``: ``name`` (user installs only);\n``settings``: ``key`` + ``values`` (``{setting_key: value}``, non-secret schema keys only);\n``presence``: ``names`` (catalog names, answered in that order).",
"properties": {
"profile": {
"anyOf": [
@@ -23145,6 +23180,21 @@
],
"default": null,
"title": "Values"
+ },
+ "names": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Names"
}
},
"title": "PluginsManageParams",
@@ -23481,6 +23531,21 @@
],
"default": null,
"title": "Onboarding"
+ },
+ "presence": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/components/schemas/CatalogPluginPresence"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Presence"
}
},
"title": "PluginsManageResult",
diff --git a/hermes_cli/plugin_catalog_presence.py b/hermes_cli/plugin_catalog_presence.py
index 15ce5b63fda..c2a30d3647d 100644
--- a/hermes_cli/plugin_catalog_presence.py
+++ b/hermes_cli/plugin_catalog_presence.py
@@ -19,6 +19,7 @@ logger = logging.getLogger(__name__)
_GITHUB = re.compile(r"^https://github\.com/([A-Za-z0-9_.-]+)/([A-Za-z0-9_.-]+?)(?:\.git)?/?$")
_TIMEOUT = 5.0
_MAX_BYTES = 256 * 1024
+_DISCLOSURE = re.compile(r"\bDisclosure\s*[:\u2014]\s*(.+)")
# (repo, sha, subdir) -> manifest dict, or None when the pin has no readable plugin.json. A pin is
# immutable, so the process keeps the answer.
_manifests: dict[tuple[str, str, str], Optional[dict[str, Any]]] = {}
@@ -148,6 +149,35 @@ def onboarding_entries() -> list[dict[str, Any]]:
return rows
+def presence_for(names: list[str]) -> list[dict[str, Any]]:
+ """The named catalog plugins this OS runs, in the order asked, each with its app state and the
+ catalog description's disclosure. A name the live catalog does not carry (unknown or removed) is dropped."""
+ from concurrent.futures import ThreadPoolExecutor
+
+ from hermes_cli.plugin_catalog import load_catalog_live
+ from hermes_cli.plugins_cmd_catalog import normalized_platforms
+ from hermes_platform.host.facts import os_family
+
+ here = os_family()
+ by_name = {entry.name: entry for entry in load_catalog_live()}
+ entries = [by_name[name] for name in dict.fromkeys(names) if name in by_name
+ and (not by_name[name].platforms or here in normalized_platforms(by_name[name].platforms))]
+ if not entries:
+ return []
+ # Each manifest read is bounded by _TIMEOUT; in parallel the whole answer waits one timeout, not one per name.
+ with ThreadPoolExecutor(max_workers=len(entries)) as pool:
+ found = list(pool.map(presence, entries))
+ return [{"name": entry.name, "title": entry.title or entry.name, "state": state.state,
+ "sentence": state.sentence, "disclosure": _disclosure(entry.description)}
+ for entry, state in zip(entries, found)]
+
+
+def _disclosure(text: str) -> str:
+ """The sentence after the description's ``Disclosure:`` (or ``Disclosure —``) marker; empty when absent."""
+ match = _DISCLOSURE.search(" ".join(str(text or "").split()))
+ return _first_sentence(match.group(1)) if match else ""
+
+
def _first_sentence(text: str) -> str:
text = " ".join(str(text or "").split())
head, dot, _rest = text.partition(". ")
diff --git a/tests/hermes_cli/test_plugin_presence_by_name.py b/tests/hermes_cli/test_plugin_presence_by_name.py
new file mode 100644
index 00000000000..fa9de664102
--- /dev/null
+++ b/tests/hermes_cli/test_plugin_presence_by_name.py
@@ -0,0 +1,86 @@
+"""``presence_for(names)``: catalog plugins by name for the desktop questionnaire — unknown and removed
+names dropped, other-OS entries dropped, order kept, manifests read in parallel, ``unknown`` when the
+pinned manifest cannot be read."""
+
+from __future__ import annotations
+
+import json
+import threading
+from types import SimpleNamespace
+
+import httpx
+import pytest
+
+from hermes_cli import plugin_catalog as pc
+from hermes_cli import plugin_catalog_presence as presence_mod
+
+SHA = "0" * 40
+NEEDS_APP = {"extensions": {"com.nousresearch.hermes": {"servers": {"srv": {
+ "app": {"darwin": {"presence": "executable", "location": "/nonexistent/fx-app"},
+ "linux": {"presence": "executable", "location": "/nonexistent/fx-app"},
+ "win32": {"presence": "executable", "location": "C:/nonexistent/fx-app.exe"}},
+ "requires": {"app": True}}}}}}
+
+
+def _entry(name, *, platforms=(), title="", description=""):
+ return pc.entry_from_mapping({"name": name, "repo": f"https://github.com/fx/{name}", "sha": SHA,
+ "description": description or f"{name} does things.", "maintainer": "fx",
+ "tier": "official", "category": "tools", "platforms": list(platforms),
+ "title": title}, name)
+
+
+def catalog(monkeypatch):
+ from hermes_platform.host import facts
+
+ here = {"darwin": "macos", "win32": "windows"}.get(facts.os_family(), "linux")
+ other = "windows" if here != "windows" else "macos"
+ entries = [
+ _entry("app", title="Fx App", platforms=[here],
+ description="Drives Fx. Disclosure: the tools change Fx settings; nothing leaves loopback. Needs Fx 2."),
+ _entry("dashed", description="Pane. Disclosure \u2014 reads the cron file under HERMES_HOME."),
+ _entry("broken", title="Broken"),
+ _entry("elsewhere", platforms=[other]),
+ ]
+ monkeypatch.setattr(pc, "load_catalog_live", lambda: entries)
+ monkeypatch.setattr(presence_mod, "_manifests", {})
+ # Every fetch waits for the other two: a serial reader would break the barrier and read nothing.
+ barrier = threading.Barrier(3, timeout=5)
+ manifests = {"app": NEEDS_APP, "dashed": {"name": "dashed"}}
+
+ def get(url, **kwargs):
+ barrier.wait()
+ repo = url.split("/")[4]
+ if repo not in manifests:
+ raise httpx.ConnectError("unreachable")
+ return SimpleNamespace(status_code=200, content=json.dumps(manifests[repo]).encode())
+
+ monkeypatch.setattr(httpx, "get", get)
+ return entries
+
+
+def test_rows_in_the_order_asked_without_removed_or_other_os_names(catalog):
+ rows = presence_mod.presence_for(["broken", "removed-from-catalog", "elsewhere", "app", "dashed", "app"])
+
+ assert [row["name"] for row in rows] == ["broken", "app", "dashed"]
+
+
+def test_row_shape_state_and_disclosure(catalog):
+ rows = {row["name"]: row for row in presence_mod.presence_for(["app", "dashed", "broken"])}
+
+ assert rows["app"] == {"name": "app", "title": "Fx App", "state": "missing_app", "sentence": "needs Fx App",
+ "disclosure": "the tools change Fx settings; nothing leaves loopback."}
+ assert rows["dashed"]["title"] == "dashed"
+ assert rows["dashed"]["disclosure"] == "reads the cron file under HERMES_HOME."
+ assert rows["dashed"]["state"] == "unknown" # a manifest without a declared app
+ assert rows["broken"]["state"] == "unknown" and rows["broken"]["sentence"] == "" # manifest unreadable
+ assert rows["broken"]["disclosure"] == ""
+
+
+def test_plugins_manage_presence_over_the_wire(catalog):
+ from tui_gateway import server
+
+ response = server.handle_request({"jsonrpc": "2.0", "id": 9, "method": "plugins.manage",
+ "params": {"action": "presence", "names": ["dashed", "app", "broken"]}})
+
+ assert [row["name"] for row in response["result"]["presence"]] == ["dashed", "app", "broken"]
diff --git a/tui_gateway/contracts/tools_mcp_plugins.py b/tui_gateway/contracts/tools_mcp_plugins.py
index a601c689a44..dd33d37aaf3 100644
--- a/tui_gateway/contracts/tools_mcp_plugins.py
+++ b/tui_gateway/contracts/tools_mcp_plugins.py
@@ -589,13 +589,15 @@ class PluginsAction(WireEnum):
remove = "remove"
settings = "settings"
onboarding = "onboarding"
+ presence = "presence"
class PluginsManageParams(ProfileParams):
"""``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``
(+ ``force``, ``enable``, ``ref``); ``update``: ``name`` (+ ``accept_capabilities`` to apply a re-pin
that widened the plugin after the user confirmed the ``delta``); ``remove``: ``name`` (user installs only);
- ``settings``: ``key`` + ``values`` (``{setting_key: value}``, non-secret schema keys only)."""
+ ``settings``: ``key`` + ``values`` (``{setting_key: value}``, non-secret schema keys only);
+ ``presence``: ``names`` (catalog names, answered in that order)."""
action: PluginsAction = PluginsAction.list
key: str | None = None
@@ -608,6 +610,7 @@ class PluginsManageParams(ProfileParams):
ref: str | None = None
accept_capabilities: bool | None = None
values: dict[str, JsonValue] | None = None
+ names: list[str] | None = None
class PluginSettingFieldType(WireEnum):
@@ -729,6 +732,18 @@ class OnboardingCatalogPlugin(Result):
sentence: str
+class CatalogPluginPresence(Result):
+ """A named catalog plugin this OS runs. ``state`` is the pinned ``plugin.json`` app declaration judged
+ on this host; ``sentence`` names what is missing (empty when present or unknown); ``disclosure`` is the
+ catalog description's ``Disclosure:`` sentence (empty when it has none)."""
+
+ name: str
+ title: str
+ state: CatalogAppState
+ sentence: str
+ disclosure: str
+
+
class PluginsManageResult(Result):
"""``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``restart_required``/``name``
(the canonical key written)/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s
@@ -767,6 +782,8 @@ class PluginsManageResult(Result):
written: list[str] | None = None
# ``onboarding`` → the curated catalog plugins for the onboarding card.
onboarding: list[OnboardingCatalogPlugin] | None = None
+ # ``presence`` → the named catalog plugins this OS runs, in the order asked; unknown names dropped.
+ presence: list[CatalogPluginPresence] | None = None
method("plugins.manage", params=PluginsManageParams, result=PluginsManageResult,
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index 08cdc9dc45a..11dba529f5b 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -1911,7 +1911,13 @@ def _plugins_onboarding(rid, params):
return _ok(rid, {"onboarding": _tools_mod("hermes_cli.plugin_catalog_presence").onboarding_entries()})
-_PLUGINS_ACTIONS = {"list": _plugins_list, "onboarding": _plugins_onboarding, "toggle": _plugins_toggle, "install": _plugins_install,
+def _plugins_presence(rid, params):
+ """Named catalog plugins this OS runs, in the order asked, each with its app state and disclosure."""
+ return _ok(rid, {"presence": _tools_mod("hermes_cli.plugin_catalog_presence").presence_for(params.get("names") or [])})
+
+
+_PLUGINS_ACTIONS = {"list": _plugins_list, "onboarding": _plugins_onboarding, "presence": _plugins_presence,
+ "toggle": _plugins_toggle, "install": _plugins_install,
"update": _plugins_update, "remove": _plugins_remove, "settings": _plugins_settings}