The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(plugins): requires.gpu gates a plugin server on the host's GPU vendor
alt-glitchf1c79255feaf
diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsxindex 03ff2ab519c..90d01851990 100644--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx@@ -162,7 +162,8 @@ const SERVER_TONE = {no_interactive_session: 'warn',unknown: 'warn',version_too_old: 'destructive',- missing_app: 'destructive'+ missing_app: 'destructive',+ unsupported_gpu: 'destructive'} as const satisfies Record<AgentPluginServerState, 'destructive' | 'success' | 'warn'>function KindBadge({ kind }: { kind: PackageKind }) {diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 80f3f042b10..3aa66eec66b 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -2864,6 +2864,7 @@ export const deOverrides = {no_interactive_session: 'keine interaktive Session',version_too_old: 'Version zu alt',missing_app: 'App fehlt',+ unsupported_gpu: 'GPU nicht unterstützt',unknown: 'Status unbekannt'},catalogTitle: 'Plugin-Katalog',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex a421de462e9..53a4dbf757a 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -2515,6 +2515,7 @@ export const en: Translations = {no_interactive_session: 'no interactive session',version_too_old: 'version too old',missing_app: 'app missing',+ unsupported_gpu: 'GPU not supported',unknown: 'status unknown'},catalogTitle: 'Plugin catalog',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex 7ba42e468a6..8b670c6c4e2 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -2857,6 +2857,7 @@ export const esOverrides = {no_interactive_session: 'sin sesión interactiva',version_too_old: 'versión demasiado antigua',missing_app: 'falta la app',+ unsupported_gpu: 'GPU no compatible',unknown: 'estado desconocido'},catalogTitle: 'Catálogo de plugins',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex 9a232edabd0..dc3b51a006b 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -2875,6 +2875,7 @@ export const frOverrides = {no_interactive_session: 'aucune session interactive',version_too_old: 'version trop ancienne',missing_app: 'application manquante',+ unsupported_gpu: 'GPU non prise en charge',unknown: 'état inconnu'},catalogTitle: 'Catalogue de plugins',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 443eca85435..7dbe926e0e5 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -2125,6 +2125,7 @@ export interface Translations {no_interactive_session: stringversion_too_old: stringmissing_app: string+ unsupported_gpu: stringunknown: string}catalogTitle: stringdiff --git a/apps/desktop/src/store/agent-plugins.ts b/apps/desktop/src/store/agent-plugins.tsindex 534b41a21c6..37fff96255f 100644--- a/apps/desktop/src/store/agent-plugins.ts+++ b/apps/desktop/src/store/agent-plugins.ts@@ -23,6 +23,7 @@ export type AgentPluginServerState =| 'no_interactive_session'| 'version_too_old'| 'missing_app'+ | 'unsupported_gpu'| 'unknown'export interface AgentPluginServer {diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 5b44ec35186..eb2f289fc82 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -4282,7 +4282,7 @@ export interface PluginServerRow {state: PluginServerStatesentence: string}-export type PluginServerState = 'connected' | 'app_not_running' | 'hermes_not_connected' | 'endpoint_unavailable' | 'no_interactive_session' | 'version_too_old' | 'missing_app' | 'unknown'+export type PluginServerState = 'connected' | 'app_not_running' | 'hermes_not_connected' | 'endpoint_unavailable' | 'no_interactive_session' | 'version_too_old' | 'missing_app' | 'unsupported_gpu' | 'unknown'/** One ``config_schema`` key of a plugin manifest, rendered by the Plugins hub (``hermes_cli.plugins_settings.plugin_settings_fields``). ``secret`` fields carry no value: ``env`` names the ``.env`` variable and ``has_value`` whether it is set. */export interface PluginSettingField {key: stringdiff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex c9f3bd79c22..25d5a218c92 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -21967,6 +21967,7 @@"no_interactive_session","version_too_old","missing_app",+ "unsupported_gpu","unknown"],"title": "PluginServerState",diff --git a/hermes_cli/plugin_catalog_presence.py b/hermes_cli/plugin_catalog_presence.pyindex 509dd2e693f..53a2c085220 100644--- a/hermes_cli/plugin_catalog_presence.py+++ b/hermes_cli/plugin_catalog_presence.py@@ -67,6 +67,7 @@ def _pinned_manifest(repo: str, sha: str, subdir: str) -> Optional[Dict[str, Anydef _server_presence(decl: Any, liveness_raw: Any, title: str) -> Presence:+ from hermes_platform.declaration import gpu_labelfrom hermes_platform.host import factsfrom hermes_platform.resolver.app import AppResolverfrom hermes_platform.resolver.availability import availability@@ -78,6 +79,8 @@ def _server_presence(decl: Any, liveness_raw: Any, title: str) -> Presence:return UNKNOWNif available.state in ("missing_app", "unsupported_os"):return Presence("missing_app", f"needs {title}")+ if available.state == "unsupported_gpu":+ return Presence("missing_app", f"needs {gpu_label(decl.required_gpu)}")if available.state == "version_too_old":found = f" (found {available.version})" if available.version else ""return Presence("missing_app", f"needs {title} {available.min_version} or newer{found}")diff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.pyindex 88ad0d74559..1e99c387818 100644--- a/hermes_cli/plugins_cmd_install.py+++ b/hermes_cli/plugins_cmd_install.py@@ -283,6 +283,7 @@ def _refuse_unavailable_portable_plugin(plugin_name: str, tree: Path) -> None:if not (tree / "plugin.json").is_file():returnfrom hermes_cli.agent_plugins import load_agent_plugin+ from hermes_platform.declaration import gpu_labelfrom hermes_platform.resolver.availability import availabilitytry:@@ -294,6 +295,8 @@ def _refuse_unavailable_portable_plugin(plugin_name: str, tree: Path) -> None:if result.offerable:continuefound = f", found version {result.version}" if result.version else ""+ if result.state == "unsupported_gpu":+ found = f", needs {gpu_label(server_decl.declaration.required_gpu)}"raise _pc().PluginOperationError(f"Plugin '{plugin_name}' server '{server_name}' is unavailable: {result.state}{found}.")diff --git a/hermes_platform/declaration.py b/hermes_platform/declaration.pyindex cc2ef5b2cff..197be7bb6de 100644--- a/hermes_platform/declaration.py+++ b/hermes_platform/declaration.py@@ -14,6 +14,7 @@ __all__ = ["RequiresSpec","Declaration","DeclarationError",+ "gpu_label","parse_app","parse_requires","parse_declaration",@@ -44,6 +45,7 @@ class RequiresSpec:app: bool = Falsemin_version: Optional[str] = None+ gpu: Optional[str] = None@dataclass(frozen=True)@@ -62,6 +64,10 @@ class Declaration:def min_version(self) -> Optional[str]:return self.requires.min_version+ @property+ def required_gpu(self) -> Optional[str]:+ return self.requires.gpu+def app_for(self, os_family: str) -> Optional[AppDef]:return self.app.for_os(os_family) if self.app else None@@ -71,6 +77,15 @@ _APP_PRESENCE = ("executable", "bundle")_APP_VERSION_KINDS = {"pe_resource": "win32", "uninstall_registry": "win32", "plist": "darwin", "none": None}_APP_LIVENESS_KINDS = ("server_json", "none")_VERSION_RE = re.compile(r"^\d+(\.\d+)*$")+# `requires.gpu` values and how a sentence names them. Only NVIDIA: `facts.gpu_class()` reports the+# highest-priority vendor present, which answers "is an NVIDIA GPU here" exactly and would not answer+# it for AMD or Intel on a machine that also has an NVIDIA GPU.+GPU_LABELS = {"nvidia": "an NVIDIA GPU"}+++def gpu_label(gpu: Optional[str]) -> str:+ """How a user-facing sentence names a ``requires.gpu`` value."""+ return GPU_LABELS.get(gpu or "", "a supported GPU")def _require_mapping(where: str, key: str, raw: Any) -> dict:@@ -148,9 +163,12 @@ def parse_requires(raw: Any, app: Optional[AppSpec], *, where: str) -> RequiresSif raw is None:return RequiresSpec()_require_mapping(where, "requires", raw)- unknown = set(raw) - {"app", "min_version"}+ unknown = set(raw) - {"app", "min_version", "gpu"}if unknown:raise DeclarationError(f"{where}: requires has unknown keys {sorted(unknown)}")+ gpu = raw.get("gpu")+ if gpu is not None and (not isinstance(gpu, str) or gpu not in GPU_LABELS):+ raise DeclarationError(f"{where}: requires.gpu must be one of {sorted(GPU_LABELS)}")needs_app = raw.get("app", False)if not isinstance(needs_app, bool):raise DeclarationError(f"{where}: requires.app must be a boolean")@@ -167,7 +185,7 @@ def parse_requires(raw: Any, app: Optional[AppSpec], *, where: str) -> RequiresSif unversioned:raise DeclarationError(f"{where}: requires.min_version needs a version source under app.{unversioned[0]} (kind is none)")- return RequiresSpec(app=needs_app, min_version=min_version)+ return RequiresSpec(app=needs_app, min_version=min_version, gpu=gpu)def parse_declaration(name: str, raw_app: Any, raw_requires: Any, *, where: str) -> Declaration:diff --git a/hermes_platform/resolver/availability.py b/hermes_platform/resolver/availability.pyindex 1827160e31a..295dcf8dc48 100644--- a/hermes_platform/resolver/availability.py+++ b/hermes_platform/resolver/availability.py@@ -1,7 +1,7 @@"""Whether a catalog entry can be offered on this host, from its `app` and `requires` blocks.-`availability` runs `locate` and `inspect` only. It never probes, never spawns, never connects, and holds-no cache: the callers that need a TTL (the tool registry) already have one.+`availability` runs `locate`, `inspect` and the host's cached GPU fact only. It never probes, never spawns,+never connects, and holds no cache: the callers that need a TTL (the tool registry) already have one."""from __future__ import annotations@@ -20,6 +20,7 @@ AvailabilityState = Literal["missing_app","version_too_old","unsupported_os",+ "unsupported_gpu","no_requirements",]@@ -35,6 +36,9 @@ class _HasRequirements(Protocol):@propertydef min_version(self) -> str | None: ...+ @property+ def required_gpu(self) -> str | None: ...+def app_for(self, os_family: str) -> AppDef | None: ...@@ -74,12 +78,20 @@ def version_at_least(found: str, minimum: str) -> bool:def availability(entry: _HasRequirements, *, os_family: str | None = None) -> Availability:- if not entry.requires_app:+ gpu = entry.required_gpu+ if not entry.requires_app and gpu is None:return Availability("no_requirements")osf = os_family or facts.os_family()- definition = entry.app_for(osf)- if definition is None:+ definition = entry.app_for(osf) if entry.requires_app else None+ if entry.requires_app and definition is None:return Availability("unsupported_os", min_version=entry.min_version)+ # An unreadable GPU (`unknown`) passes: refusing on a failed registry or sysfs read would lock out+ # the machines that have the GPU, and the MCP connection check still applies.+ if gpu is not None and facts.gpu_class() not in (gpu, "unknown"):+ return Availability("unsupported_gpu", min_version=entry.min_version)+ if not entry.requires_app:+ return Availability("no_requirements")+ assert definition is not Noneresolver = AppResolver(definition)res = resolver.locate()looked_at = res.command[0] if res.command else (res.candidates[0].value if res.candidates else None)diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex f77aee45c4a..b37bf2be69c 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -4383,6 +4383,7 @@"skills.plugins.serverStates.missing_app","skills.plugins.serverStates.no_interactive_session","skills.plugins.serverStates.unknown",+ "skills.plugins.serverStates.unsupported_gpu","skills.plugins.serverStates.version_too_old","skills.plugins.settingsForm.optional","skills.plugins.settingsForm.save",diff --git a/tests/hermes_platform/test_declaration.py b/tests/hermes_platform/test_declaration.pyindex 54c823d0c77..cbdc7ca0f8a 100644--- a/tests/hermes_platform/test_declaration.py+++ b/tests/hermes_platform/test_declaration.py@@ -63,6 +63,7 @@ def test_app_block_parses_into_one_appdef_per_os():({"darwin": {"presence": "bundle", "location": "Relative/Thing.app"}}, None, "must be absolute"),({"darwin": {"presence": "bundle", "location": "https://example.test/Thing.app"}}, None, "must be absolute"),({"win32": {"presence": "executable", "location": "Thing/thing.exe"}}, None, "must be absolute"),+ (None, {"gpu": "amd"}, "requires.gpu must be one of"),])def test_invalid_blocks_name_the_rule(raw_app, raw_requires, message):with pytest.raises(DeclarationError, match=message):@@ -75,6 +76,28 @@ def test_availability_no_requirements_does_no_io():assert result.state == "no_requirements" and result.offerable[email protected]("gpu_class, state", [+ ("nvidia", "no_requirements"),+ ("unknown", "no_requirements"),+ ("intel", "unsupported_gpu"),+ ("apple_silicon", "unsupported_gpu"),+ ("none", "unsupported_gpu"),+])+def test_requires_gpu_gates_on_the_host_gpu_class(monkeypatch, gpu_class, state):+ """No `app:` block is needed; an unreadable GPU passes; the OS gate runs first and reads no GPU."""+ from hermes_platform.host import facts++ monkeypatch.setattr(facts, "gpu_class", lambda: gpu_class)+ decl = parse_declaration("thing-mcp", None, {"gpu": "nvidia"}, where=WHERE)+ result = availability(decl, os_family="win32")+ assert result.state == state and result.offerable == (state == "no_requirements")++ monkeypatch.setattr(facts, "gpu_class", lambda: pytest.fail("the OS gate must not read the GPU"))+ both = parse_declaration("thing-mcp", {"win32": {"presence": "executable", "location": "C:/x/y.exe"}},+ {"app": True, "gpu": "nvidia"}, where=WHERE)+ assert availability(both, os_family="darwin").state == "unsupported_os"++def test_availability_unsupported_os_when_no_block_for_host():decl = parse_declaration("thing-mcp",diff --git a/tests/tools/test_mcp_liveness.py b/tests/tools/test_mcp_liveness.pyindex 623be3d90de..b05dd4057c2 100644--- a/tests/tools/test_mcp_liveness.py+++ b/tests/tools/test_mcp_liveness.py@@ -213,6 +213,31 @@ def test_static_liveness_cannot_claim_the_app_is_not_running(tmp_path, monkeypatassert "MCP connection is missing" in sentenceassert "is not running" not in sentence+def test_gpu_requirement_hides_a_connected_server_and_says_which_gpu(monkeypatch):+ """A connected server whose `requires.gpu` the host misses is not offered, and its status is a+ state the Plugins tab can carry, with a sentence that names the GPU instead of "Install <app>"."""+ import hermes_cli.agent_plugins as agent_plugins+ from hermes_platform.host import facts+ from tools import mcp_liveness, mcp_tool_handlers+ from tui_gateway.contracts.tools_mcp_plugins import PluginServerState++ monkeypatch.setattr(facts, "gpu_class", lambda: "intel")+ monkeypatch.setattr(agent_plugins, "liveness_for", lambda name: None, raising=False)+ decl = declaration.parse_declaration("RTX Tool", None, {"gpu": "nvidia"}, where="test")+ declaration.register("example-server", decl)+ try:+ offerable = mcp_tool_handlers._declared_app_offerable("example-server")+ current = mcp_liveness.status("example-server")+ finally:+ declaration.unregister("example-server")++ assert offerable is False+ assert current is not None and current.state in {s.value for s in PluginServerState}+ assert current.retry == "never_here"+ sentence = mcp_liveness.describe(decl, current.availability, current.state)+ assert "an NVIDIA GPU" in sentence and "Install" not in sentence++def test_describe_prefers_the_plugin_title_over_the_server_slug(tmp_path):"""The Plugins tab knows the plugin's catalog title; the sentence should name the app byit instead of the declaration's slug (#119975)."""diff --git a/tools/mcp_liveness.py b/tools/mcp_liveness.pyindex 26be12ff563..fc190216189 100644--- a/tools/mcp_liveness.py+++ b/tools/mcp_liveness.py@@ -23,6 +23,7 @@ LivenessState = Literal["no_interactive_session","version_too_old","missing_app",+ "unsupported_gpu",]Retry = Literal["after_user_action", "never_here"]@@ -107,7 +108,7 @@ def liveness_for(server_name: str) -> Liveness:return Liveness("static")-def _action(state: LivenessState, app_name: str) -> tuple[str, Retry]:+def _action(state: LivenessState, app_name: str, gpu_label: str = "") -> tuple[str, Retry]:actions: dict[LivenessState, tuple[str, Retry]] = {"app_not_running": (f"Start {app_name}, then try again.", "after_user_action"),"hermes_not_connected": (f"Reconnect {app_name} in Hermes, then try again.", "after_user_action"),@@ -115,6 +116,7 @@ def _action(state: LivenessState, app_name: str) -> tuple[str, Retry]:"no_interactive_session": (f"Open an interactive desktop session and start {app_name}, then try again.", "never_here"),"version_too_old": (f"Update {app_name}, then try again.", "after_user_action"),"missing_app": (f"Install {app_name}, then try again.", "after_user_action"),+ "unsupported_gpu": (f"Use {app_name} on a machine with {gpu_label}.", "never_here"),}return actions[state]@@ -128,6 +130,8 @@ def status(server_name: str) -> Status | None:live = liveness_for(server_name)if available.state in {"missing_app", "unsupported_os"}:state: LivenessState = "missing_app"+ elif available.state == "unsupported_gpu":+ state = "unsupported_gpu"elif available.state == "version_too_old":state = "version_too_old"elif live.kind == "interactive_session" and not facts.interactive_session():@@ -153,7 +157,7 @@ def status(server_name: str) -> Status | None:# static / unknown liveness kinds cannot observe the app, so they cannot conclude it# is not running; the honest answer is that Hermes is not connected (#119975).state = "hermes_not_connected"- action, retry = _action(state, decl.name)+ action, retry = _action(state, decl.name, declaration.gpu_label(decl.required_gpu))return Status(state, available, live, action, retry)@@ -164,9 +168,12 @@ def describe(decl: declaration.Declaration, available: Availability, liveness_st``display_name`` overrides the declaration's slug when the caller knows the plugin'scatalog/manifest title — the Plugins tab does, and a raw slug reads like an error code."""app_name = display_name or decl.name- action, _retry = _action(liveness_state, app_name)+ gpu = declaration.gpu_label(decl.required_gpu)+ action, _retry = _action(liveness_state, app_name, gpu)if liveness_state == "missing_app":reason = f"{app_name} is not installed."+ elif liveness_state == "unsupported_gpu":+ reason = f"{app_name} needs {gpu}; none was found on this machine."elif liveness_state == "version_too_old":found = f" version {available.version}" if available.version else ""minimum = f"; version {available.min_version} or newer is required" if available.min_version else ""diff --git a/tui_gateway/contracts/tools_mcp_plugins.py b/tui_gateway/contracts/tools_mcp_plugins.pyindex 74444958b94..0d0d26cf340 100644--- a/tui_gateway/contracts/tools_mcp_plugins.py+++ b/tui_gateway/contracts/tools_mcp_plugins.py@@ -644,6 +644,7 @@ class PluginServerState(WireEnum):no_interactive_session = "no_interactive_session"version_too_old = "version_too_old"missing_app = "missing_app"+ unsupported_gpu = "unsupported_gpu"unknown = "unknown"diff --git a/website/docs/developer-guide/plugins/application-declarations.md b/website/docs/developer-guide/plugins/application-declarations.mdindex 20c465be6e3..93e5e147d57 100644--- a/website/docs/developer-guide/plugins/application-declarations.md+++ b/website/docs/developer-guide/plugins/application-declarations.md@@ -67,9 +67,12 @@ requires:|---|---|---|| `app` | bool | when true, `app:` must exist and the server is gated on presence || `min_version` | str | requires `app: true`; dotted numeric; every applicable `app.<os>` must declare a real `version.kind`; compared numerically per segment, non-numeric characters in a segment are dropped (`2.3.0.12594` ≥ `2.3.0`; prerelease suffixes are not ordered) |+| `gpu` | str | `nvidia`; the server is offered only on a host where `hermes_platform.host.facts.gpu_class()` reports that vendor. Independent of `app`: a server with no `app:` block can require a GPU. |`requires.app: true` with no `app:` block is a `DeclarationError`.+`gpu` is for an application that has no install location to check, or that needs the hardware whatever is installed. `gpu_class()` reads the registry on Windows, sysfs on Linux and the CPU architecture on macOS, never a subprocess or a driver library. When it cannot read the GPU (`unknown`), the requirement passes: a failed read must not lock out a machine that has the GPU, and the connection check still applies. Only `nvidia` is accepted: `gpu_class()` reports the highest-priority vendor present, which answers "is an NVIDIA GPU here" exactly and would not answer the same question for AMD or Intel on a machine that also has an NVIDIA GPU.+## Availability: the one evaluation every reader uses`hermes_platform/resolver/availability.py::availability(decl) -> Availability`@@ -77,21 +80,22 @@ requires:```Availability(state: available | installed_not_running | missing_app | version_too_old- | unsupported_os | no_requirements,+ | unsupported_os | unsupported_gpu | no_requirements,version: str | None, # inspected, when presentpath: str | None, # where the app was found or looked formin_version: str | None, # from requires)```-- `no_requirements`: no `requires.app`; the application gate passes, but the connection check still applies.+- `no_requirements`: no `requires.app`, and `requires.gpu` (if any) is met; the application gate passes, but the connection check still applies.- `unsupported_os`: `requires.app` and no `app.<this os>` block. Zero I/O.+- `unsupported_gpu`: `requires.gpu` names a vendor this host's GPU is not. The install is refused (`… is unavailable: unsupported_gpu, needs an NVIDIA GPU.`), and a registered server's status sentence is "`<app>` needs an NVIDIA GPU; none was found on this machine. Use `<app>` on a machine with an NVIDIA GPU."- `missing_app`: `locate` found nothing at `location`.- `version_too_old`: the version is below the minimum or cannot be read.- `available`: present, version acceptable or not required.- `installed_not_running`: reserved vocabulary; this evaluator never produces it.-Evaluation uses `locate` and optional version inspection. It never probes a server, launches an application, or connects. The tool registry retains its existing availability cache.+Evaluation uses `locate`, optional version inspection and the cached GPU fact. It never probes a server, launches an application, or connects. The tool registry retains its existing availability cache.## The two gates