Skip to content

The agent that grows with you

fix: catalog re-pins ask before widening a plugin; annotated-tag pins keep reviewed trust

teknium1db8dcbe94cb2
diff --git a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
index e95817a31d7..adbd6c6a98b 100644
--- a/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
+++ b/apps/desktop/src/app/capabilities/plugins/plugins-tab.tsx
@@ -28,6 +28,7 @@ import {
$agentPluginsError,
$agentPluginsStatus,
type AgentPluginRow,
+ type AgentPluginUpdateOutcome,
type GatewayRequest,
isDesktopRelevantPlugin,
loadAgentPlugins,
@@ -636,11 +637,31 @@ export const PluginsTab = memo(function PluginsTab({
void toggleAgentPlugin(requestGateway, row.key, enable, p.toggleFailed(row.name), scope)
}}
onAgentUpdate={row => {
- void updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope).then(applied => {
- if (applied) {
+ const finish = (outcome: AgentPluginUpdateOutcome) => {
+ if (outcome.kind === 'applied') {
notify({ kind: 'success', message: p.updated(row.name) })
void rescanAll(requestGateway, scope)
}
+ }
+
+ void updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope).then(async outcome => {
+ if (outcome.kind !== 'consent') {
+ finish(outcome)
+
+ return
+ }
+
+ // The new pin widens the plugin (tools, hooks, deps, capabilities, a Desktop
+ // half); the backend changed nothing until the user confirms the delta.
+ const ok = await confirm({
+ confirmLabel: p.updateConsentConfirm,
+ description: [p.updateConsentBody(row.name, outcome.sha), ...outcome.deltaLines].join('\n'),
+ title: p.updateConsentTitle(row.name)
+ })
+
+ if (ok) {
+ finish(await updateAgentPlugin(requestGateway, row.name, p.updateFailed(row.name), scope, true))
+ }
})
}}
onDesktopRemove={record => {
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 11b383587c1..56b0db41859 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -1878,6 +1878,10 @@ export const en: Translations = {
updateToPin: (sha: string) => `Update to ${sha}`,
updateFailed: (name: string) => `Could not update ${name}`,
updated: (name: string) => `${name} updated to the current catalog pin. Restart the gateway to apply.`,
+ updateConsentTitle: (name: string) => `${name} asks for more`,
+ updateConsentBody: (name: string, sha: string) =>
+ `The new catalog pin of ${name} (${sha}) adds surfaces the installed version does not have. Apply it only if you trust them:`,
+ updateConsentConfirm: 'Apply update',
uninstall: 'Uninstall',
uninstallTip: (name: string, profile: string) => `Uninstall ${name} from ${profile}`,
uninstallConfirmTitle: (name: string) => `Uninstall ${name}?`,
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 29831a72a8a..372e28c35f1 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1602,6 +1602,9 @@ export interface Translations {
updateToPin: (sha: string) => string
updateFailed: (name: string) => string
updated: (name: string) => string
+ updateConsentTitle: (name: string) => string
+ updateConsentBody: (name: string, sha: string) => string
+ updateConsentConfirm: string
uninstall: string
uninstallTip: (name: string, profile: string) => string
uninstallConfirmTitle: (name: string) => string
diff --git a/apps/desktop/src/store/agent-plugins.ts b/apps/desktop/src/store/agent-plugins.ts
index a86abaa3888..d6a1bf8bf28 100644
--- a/apps/desktop/src/store/agent-plugins.ts
+++ b/apps/desktop/src/store/agent-plugins.ts
@@ -252,34 +252,54 @@ export async function installAgentPlugin(
}
}
+/** Outcome of `updateAgentPlugin`: `applied` when the re-pin landed, `unchanged`
+ * when already at pin, `consent` when the new pin widens the plugin — the
+ * backend changed nothing and waits for `acceptCapabilities`. */
+export type AgentPluginUpdateOutcome =
+ | { kind: 'applied' | 'unchanged' | 'failed' }
+ | { kind: 'consent'; sha: string; deltaLines: string[] }
+
/** Re-pin a catalog-installed plugin to the current catalog SHA (backend
* `plugins.manage update`; catalog installs only). Refreshes the list on
- * success. Returns whether the update applied. */
+ * success. A pin that adds tools / hooks / deps / capabilities / a Desktop half
+ * comes back as `consent` with the delta; the caller confirms and retries with
+ * `acceptCapabilities`. */
export async function updateAgentPlugin(
request: GatewayRequest,
name: string,
failMessage: string,
- profile?: string | null
-): Promise<boolean> {
+ profile?: string | null,
+ acceptCapabilities = false
+): Promise<AgentPluginUpdateOutcome> {
$agentPluginBusy.set(name)
try {
- const result = await request<{ ok?: boolean; unchanged?: boolean }>(
+ const result = await request<{
+ ok?: boolean
+ unchanged?: boolean
+ consent_required?: boolean
+ sha?: string
+ delta_lines?: string[]
+ }>(
'plugins.manage',
- withProfile({ action: 'update', name }, profile)
+ withProfile({ action: 'update', name, ...(acceptCapabilities ? { accept_capabilities: true } : {}) }, profile)
)
+ if (result?.consent_required) {
+ return { kind: 'consent', sha: (result.sha ?? '').slice(0, 8), deltaLines: result.delta_lines ?? [] }
+ }
+
if (!result?.ok) {
throw new Error(failMessage)
}
await loadAgentPlugins(request, profile)
- return !result.unchanged
+ return { kind: result.unchanged ? 'unchanged' : 'applied' }
} catch (e) {
notifyError(e, failMessage)
- return false
+ return { kind: 'failed' }
} finally {
$agentPluginBusy.set(null)
}
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index bcda369a402..ea6bb234d1f 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -3674,7 +3674,7 @@ export interface LegacyPluginRow {
version: string
enabled: boolean
}
-/** ``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name`` (+ ``force``, ``enable``, ``ref``); ``update``: ``name``; ``remove``: ``name`` (user installs 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). */
export interface PluginsManageParams {
profile?: string | null
action?: PluginsAction
@@ -3686,9 +3686,10 @@ export interface PluginsManageParams {
catalog_name?: string | null
force?: boolean | null
ref?: string | null
+ accept_capabilities?: boolean | null
}
export type PluginsAction = 'list' | 'toggle' | 'install' | 'update' | 'remove'
-/** ``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; ``update`` → ``ok``/``unchanged``/``sha``; ``remove`` → ``ok``/``name`` plus ``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``. */
+/** ``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; ``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
user_count?: number | null
@@ -3705,6 +3706,10 @@ export interface PluginsManageResult {
after_install_path?: string | null
enabled?: boolean | null
sha?: string | null
+ consent_required?: boolean | null
+ delta?: Record<string, string[]> | null
+ delta_lines?: string[] | null
+ error?: string | null
}
/** ``methods_tools._plugin_rows`` + ``plugins_cmd_catalog.catalog_row_fields`` provenance. */
export interface AgentPluginRow {
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 7c2a9ccc36f..224b30bb25a 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -18203,7 +18203,7 @@
},
"PluginsManageParams": {
"additionalProperties": false,
- "description": "``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``\n(+ ``force``, ``enable``, ``ref``); ``update``: ``name``; ``remove``: ``name`` (user installs 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).",
"properties": {
"profile": {
"anyOf": [
@@ -18316,6 +18316,18 @@
],
"default": null,
"title": "Ref"
+ },
+ "accept_capabilities": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Accept Capabilities"
}
},
"title": "PluginsManageParams",
@@ -18323,7 +18335,7 @@
},
"PluginsManageResult": {
"additionalProperties": false,
- "description": "``list`` \u2192 ``plugins`` + counts; ``toggle`` \u2192 ``ok``/``unchanged``/``restart_required``/``name``\n(the canonical key written)/``plugin``; ``install`` \u2192 ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s\nok payload; ``update`` \u2192 ``ok``/``unchanged``/``sha``; ``remove`` \u2192 ``ok``/``name`` plus\n``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``.",
+ "description": "``list`` \u2192 ``plugins`` + counts; ``toggle`` \u2192 ``ok``/``unchanged``/``restart_required``/``name``\n(the canonical key written)/``plugin``; ``install`` \u2192 ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s\nok payload; ``update`` \u2192 ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the\n``delta`` (``{surface: [added...]}``) / ``delta_lines`` a widened pin adds \u2014 nothing changed until the\nclient retries with ``accept_capabilities``; ``remove`` \u2192 ``ok``/``name`` plus\n``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``.",
"properties": {
"plugins": {
"anyOf": [
@@ -18512,6 +18524,63 @@
],
"default": null,
"title": "Sha"
+ },
+ "consent_required": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Consent Required"
+ },
+ "delta": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Delta"
+ },
+ "delta_lines": {
+ "anyOf": [
+ {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Delta Lines"
+ },
+ "error": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Error"
}
},
"title": "PluginsManageResult",
diff --git a/hermes_cli/plugins_cmd.py b/hermes_cli/plugins_cmd.py
index b7c3b45caf9..a9bd2ad11f0 100644
--- a/hermes_cli/plugins_cmd.py
+++ b/hermes_cli/plugins_cmd.py
@@ -729,15 +729,20 @@ def _install_plugin_core(
python_deps: bool = True,
catalog: Optional[dict] = None,
allow_removed: bool = False,
+ before_swap=None,
) -> tuple[Path, dict, str]:
"""Clone a Git plugin and atomically record its source and exact revision.
*reviewed_pin* is the curated-catalog sha for this install; the scan trusts the tree
- only when the checked-out revision is exactly that sha. *python_deps* False skips the
+ only when the checked-out revision is exactly that sha (an annotated-tag pin is peeled to
+ its commit first — HEAD can only ever be the commit). *python_deps* False skips the
dependency conflict gate (``--no-deps``: the user installs them by hand). *catalog*
(``{"name", "repo", "tier", "pin"}``) is recorded on the install-metadata record with the
- checked-out sha — provenance lives OUTSIDE the plugin tree, so a repo cannot forge it.
- *allow_removed* records that the user knowingly bypassed the kill list."""
+ checked-out sha — provenance lives OUTSIDE the plugin tree, so a repo cannot forge it;
+ its ``pin`` is kept only when the checkout satisfies it (a ``--ref`` install is off-pin).
+ *allow_removed* records that the user knowingly bypassed the kill list.
+ *before_swap(manifest, tree)* runs on the validated clone before anything moves into place
+ and may raise :class:`PluginOperationError` to abort (re-pin consent)."""
requested_revision = _normalize_exact_revision(ref) if ref is not None else None
try:
git_url, subdir = _resolve_git_url(identifier)
@@ -758,6 +763,9 @@ def _install_plugin_core(
with tempfile.TemporaryDirectory(prefix=".install-", dir=plugins_dir) as tmp:
tmp_clone = Path(tmp) / "plugin"
installed_revision = _clone_plugin_repo(tmp_clone, git_url, requested_revision)
+ git_exe = _resolve_git_executable()
+ at_reviewed_pin = bool(reviewed_pin) and installed_revision == (
+ _git_resolve_commit(tmp_clone, git_exe, reviewed_pin) if git_exe and reviewed_pin else reviewed_pin)
tmp_target = _resolve_subdir_within(tmp_clone, subdir) if subdir else tmp_clone
_ensure_tree_readable(tmp_target, plugins_dir)
manifest = _read_manifest_for_install(tmp_target)
@@ -770,9 +778,11 @@ def _install_plugin_core(
_check_manifest_version(manifest, plugin_name)
# Scan BEFORE anything is moved into place; raises PluginScanBlocked when blocked.
_scan_plugin_tree(tmp_target, identifier, force=force, scan_decision_cb=scan_decision_cb,
- reviewed_pin=bool(reviewed_pin) and installed_revision == reviewed_pin)
+ reviewed_pin=at_reviewed_pin)
if python_deps:
_refuse_conflicting_python_deps(tmp_target, plugin_name)
+ if before_swap is not None:
+ before_swap(manifest, tmp_target)
if target.exists() and not force:
raise PluginOperationError(
@@ -787,7 +797,9 @@ def _install_plugin_core(
record: dict[str, object] = {
"pinned": requested_revision is not None, "revision": installed_revision, "source": source}
if catalog:
- record["catalog"] = {**catalog, "sha": installed_revision}
+ # ``sha`` = the commit checked out; ``pin`` = the reviewed catalog sha it satisfies (the
+ # annotated-tag object for a tag pin), empty when installed off-pin via ``--ref``.
+ record["catalog"] = {**catalog, "sha": installed_revision, "pin": reviewed_pin if at_reviewed_pin else ""}
if allow_removed:
record["allow_removed"] = True
new_metadata = {**old_metadata, plugin_name: record}
@@ -2093,8 +2105,10 @@ def _user_installed_plugin_dir(name: str) -> Optional[Path]:
return target if target.is_dir() else None
-def dashboard_update_user_plugin(name: str) -> dict[str, Any]:
- """``git pull`` inside ``~/.hermes/plugins/<name>``."""
+def dashboard_update_user_plugin(name: str, *, accept_capabilities: bool = False) -> dict[str, Any]:
+ """``git pull`` inside ``~/.hermes/plugins/<name>``; catalog installs re-pin instead. A re-pin that
+ widens the plugin returns ``{"ok": False, "consent_required": True, "delta": {...}}`` with nothing
+ changed — the surface shows the delta and retries with *accept_capabilities*."""
from hermes_cli import plugins_cmd_catalog as catalog
target = _user_installed_plugin_dir(name)
if target is None:
@@ -2102,7 +2116,8 @@ def dashboard_update_user_plugin(name: str) -> dict[str, Any]:
sidecar = catalog.read_catalog_sidecar(target)
try:
if sidecar:
- result = catalog.repin_catalog_plugin(target, sidecar)
+ result = catalog.repin_catalog_plugin(
+ target, sidecar, consent_cb=(lambda _delta: True) if accept_capabilities else None)
warnings = list(result.warnings)
new_target = target.parent / result.installed_name
deps = _install_python_dependencies_quietly(new_target, warnings) if result.changed else []
@@ -2115,6 +2130,9 @@ def dashboard_update_user_plugin(name: str) -> dict[str, Any]:
f"run `hermes plugins install {rec.get('source', '<source>')} --force "
"--ref <40-character commit SHA>` to move it."),
lambda: f"Plugin '{name}' is not a git checkout; cannot pull updates.")
+ except catalog.RepinConsentRequired as exc:
+ return {"ok": False, "consent_required": True, "error": str(exc), "name": exc.name, "sha": exc.sha,
+ "delta": exc.delta, "delta_lines": catalog.surface_delta_lines(exc.delta)}
except PluginOperationError as exc:
return {"ok": False, "error": str(exc)}
_post_pull_housekeeping(target, _console())
diff --git a/hermes_cli/plugins_cmd_catalog.py b/hermes_cli/plugins_cmd_catalog.py
index 7c2f088bd01..d831b32d02a 100644
--- a/hermes_cli/plugins_cmd_catalog.py
+++ b/hermes_cli/plugins_cmd_catalog.py
@@ -116,9 +116,9 @@ def _adopt_legacy_sidecar(plugin_dir: Path, record: dict) -> Optional[dict]:
def read_catalog_sidecar(plugin_dir) -> Optional[dict]:
- """Catalog provenance of an installed plugin (``catalog_name``/``repo``/``sha``/``tier``), or ``None``
- for a non-catalog install. Read from the installer-owned metadata record, never from the tree: a
- URL-installed repo that ships its own ``.hermes-catalog.json`` must not render as a reviewed
+ """Catalog provenance of an installed plugin (``catalog_name``/``repo``/``sha``/``tier``/``pin``), or
+ ``None`` for a non-catalog install. Read from the installer-owned metadata record, never from the
+ tree: a URL-installed repo that ships its own ``.hermes-catalog.json`` must not render as a reviewed
catalog install nor mark the real entry installed."""
if not plugin_dir:
return None
@@ -135,6 +135,14 @@ def read_catalog_sidecar(plugin_dir) -> Optional[dict]:
"tier": block.get("tier") or "community", "pin": block.get("pin", "")}
+def at_catalog_pin(sidecar: dict, entry_sha: str) -> bool:
+ """The install satisfies the catalog pin *entry_sha*: HEAD is that commit, or the pin is an
+ annotated tag whose commit was checked out (``sha`` records the peeled commit, ``pin`` the tag
+ object the installer verified). Neither matches after a re-pin or for an off-pin ``--ref`` install."""
+ return bool(entry_sha) and entry_sha in (
+ str(sidecar.get("sha") or "").lower(), str(sidecar.get("pin") or "").lower())
+
+
def catalog_annotation(dir_path) -> Optional[str]:
"""``catalog:<tier>@<sha8>`` for a catalog install (``list`` Source column), else ``None``."""
sidecar = read_catalog_sidecar(dir_path)
@@ -161,7 +169,8 @@ def removed_annotation(name: str, dir_path, removed_entries: List[RemovedEntry])
# ── Catalog-aware install / update ───────────────────────────────────────────
def install_catalog_entry(entry: PluginCatalogEntry, *, force: bool, ref: Optional[str] = None,
- allow_removed: bool = False, scan_decision_cb=None, python_deps: bool = True) -> tuple:
+ allow_removed: bool = False, scan_decision_cb=None, python_deps: bool = True,
+ before_swap=None) -> tuple:
"""``_install_plugin_core`` at the catalog pin (an explicit *ref* wins) + provenance recorded on the
install-metadata record at the sha ACTUALLY checked out (a ``--ref`` install is not at the reviewed
pin, so ``update_available`` must say so). Returns the core's ``(target, manifest, installed_name)``."""
@@ -170,7 +179,7 @@ def install_catalog_entry(entry: PluginCatalogEntry, *, force: bool, ref: Option
raise_if_removed(entry.name, entry.repo)
target, manifest, installed_name = _install_plugin_core(
entry.install_identifier, force=force, ref=ref or entry.sha, scan_decision_cb=scan_decision_cb,
- reviewed_pin=entry.sha, python_deps=python_deps, allow_removed=allow_removed,
+ reviewed_pin=entry.sha, python_deps=python_deps, allow_removed=allow_removed, before_swap=before_swap,
catalog={"name": entry.name, "repo": entry.repo, "tier": entry.tier, "pin": entry.sha})
write_catalog_sidecar(target, entry, sha=pinned_revision(target.name))
return target, manifest, installed_name
@@ -249,32 +258,90 @@ class RepinResult(NamedTuple):
warnings: list[str]
-def repin_catalog_plugin(target: Path, sidecar: dict) -> RepinResult:
+# Surfaces a re-pin can widen without the user seeing a diff: each is a list of identifiers the
+# new manifest adds (``desktop`` = a Desktop half appeared). Compared as sets — removals are not consent events.
+_SURFACE_LABELS = {"capabilities": "host capabilities", "tools": "tools", "hooks": "hooks",
+ "python_dependencies": "Python dependencies", "desktop": "Desktop UI half"}
+
+
+def plugin_surface(manifest: dict, tree: Path) -> Dict[str, set]:
+ """What an installed tree exposes: declared host capabilities, tools, hooks, Python deps, Desktop half."""
+ from hermes_cli.plugins_cmd import _declared_capabilities_from_manifest
+ manifest = manifest or {}
+
+ def _list(key: str, *alts: str) -> set:
+ for k in (key, *alts):
+ raw = manifest.get(k)
+ if isinstance(raw, list):
+ return {str(x) for x in raw if isinstance(x, (str, int, float))}
+ return set()
+
+ return {
+ "capabilities": set(_declared_capabilities_from_manifest(manifest, str(manifest.get("name") or "?"))),
+ "tools": _list("provides_tools"), "hooks": _list("provides_hooks", "hooks"),
+ "python_dependencies": _list("python_dependencies"),
+ "desktop": {"desktop/plugin.js"} if (tree / "desktop" / "plugin.js").is_file() else set(),
+ }
+
+
+def surface_delta(old: Dict[str, set], new: Dict[str, set]) -> Dict[str, List[str]]:
+ """``{surface: [added...]}`` for every surface the new tree widens; empty when nothing widened."""
+ return {k: sorted(new.get(k, set()) - old.get(k, set())) for k in _SURFACE_LABELS
+ if new.get(k, set()) - old.get(k, set())}
+
+
+def surface_delta_lines(delta: Dict[str, List[str]]) -> List[str]:
+ return [f"{_SURFACE_LABELS[k]}: {', '.join(v)}" for k, v in delta.items()]
+
+
+class RepinConsentRequired(Exception):
+ """The new pin widens the plugin's surface and no consent was given; nothing was changed on disk.
+ ``delta`` is :func:`surface_delta`'s mapping — surfaces hand it to the user and retry with consent."""
+
+ def __init__(self, name: str, sha: str, delta: Dict[str, List[str]]):
+ self.name, self.sha, self.delta = name, sha, delta
+ super().__init__(
+ f"Updating '{name}' to {sha[:8]} adds {'; '.join(surface_delta_lines(delta))}. Confirm to continue.")
+
+
+def repin_catalog_plugin(target: Path, sidecar: dict, *, consent_cb=None) -> RepinResult:
"""Re-pin a catalog install to the current catalog SHA (never ``git pull``). The force reinstall
replaces the whole tree, so the user's untracked/ignored files (installer-created ``config.yaml``,
data) are carried into the new tree and edits to TRACKED files are saved under
``<HERMES_HOME>/plugins-backup/<name>-<sha8>/`` with a warning. A manifest rename between pins moves the
- enabled flag and removes the stale dir. Raises ``PluginOperationError`` when the entry left the catalog."""
+ enabled flag and removes the stale dir. Raises ``PluginOperationError`` when the entry left the catalog.
+
+ A new pin that WIDENS the plugin (new tools, hooks, Python deps, host capabilities or a Desktop half
+ vs the installed manifest) is a new grant, not a refresh: ``consent_cb(delta) -> bool`` decides
+ before anything moves; absent or declined → :class:`RepinConsentRequired`, tree untouched."""
from hermes_cli.plugins_cmd import (
- PluginOperationError, _get_enabled_set, _plugins_dir, _remove_plugin_core, _save_enabled_set)
+ PluginOperationError, _get_enabled_set, _plugins_dir, _read_manifest, _remove_plugin_core,
+ _save_enabled_set)
catalog_name = str(sidecar["catalog_name"])
entry = get_live_catalog_entry(catalog_name)
if entry is None:
raise PluginOperationError(
f"Plugin '{catalog_name}' is no longer in the catalog — it may have been removed. "
"See `hermes plugins info` and the removed blocklist.")
- if str(sidecar.get("sha") or "").strip().lower() == entry.sha:
+ if at_catalog_pin(sidecar, entry.sha):
return RepinResult(entry.sha, False, target.name, [])
was_enabled = _get_enabled_set() # the force reinstall must not flip activation state
local, modified = _local_changes(target)
old_sha8 = str(sidecar.get("sha") or "old")[:8]
+ installed_surface = plugin_surface(_read_manifest(target), target)
+
+ def _consent_gate(manifest: dict, tree: Path) -> None:
+ delta = surface_delta(installed_surface, plugin_surface(manifest, tree))
+ if delta and not (consent_cb is not None and consent_cb(delta)):
+ raise RepinConsentRequired(catalog_name, entry.sha, delta)
+
with tempfile.TemporaryDirectory(prefix=".repin-", dir=_plugins_dir()) as tmp:
stash = Path(tmp) / "local"
_stash_local_files(target, local, stash)
# Outside the plugins dir: the discovery scanners recurse into every subdirectory there.
backup = _plugins_dir().parent / "plugins-backup" / f"{target.name}-{old_sha8}"
_stash_local_files(target, modified, backup)
- new_target, _manifest, installed_name = install_catalog_entry(entry, force=True)
+ new_target, _manifest, installed_name = install_catalog_entry(entry, force=True, before_swap=_consent_gate)
if stash.exists():
shutil.copytree(stash, new_target, dirs_exist_ok=True)
warnings: list[str] = []
@@ -291,10 +358,26 @@ def repin_catalog_plugin(target: Path, sidecar: dict) -> RepinResult:
def cmd_update_catalog(name: str, target: Path, sidecar: dict, console) -> None:
- from hermes_cli.plugins_cmd import PluginOperationError, _fail
+ from hermes_cli.plugins_cmd import (
+ PluginOperationError, _ask_yes, _declared_capabilities_from_manifest, _fail, _is_tty, _read_manifest,
+ _run_capability_consent)
console.print(f"[dim]Checking catalog pin for {name}...[/dim]")
+
+ def _confirm_widening(delta: Dict[str, List[str]]) -> bool:
+ console.print(f"\n [yellow]The new pin of [bold]{name}[/bold] adds:[/yellow]")
+ for line in surface_delta_lines(delta):
+ console.print(f" {line}")
+ if not _is_tty():
+ console.print(" [yellow]Non-interactive session: update NOT applied (fail closed). "
+ "Re-run `hermes plugins update` in a terminal to review and confirm.[/yellow]")
+ return False
+ return _ask_yes(" Apply this update? [y/N]: ")
+
try:
- result = repin_catalog_plugin(target, sidecar)
+ result = repin_catalog_plugin(target, sidecar, consent_cb=_confirm_widening)
+ except RepinConsentRequired as exc:
+ _fail(console, f"[yellow]Update of {name} not applied:[/yellow] {exc}")
+ raise SystemExit(1)
except PluginOperationError as exc:
_fail(console, f"[red]Error:[/red] {exc}")
raise SystemExit(1)
@@ -304,7 +387,15 @@ def cmd_update_catalog(name: str, target: Path, sidecar: dict, console) -> None:
console.print(f"[yellow]⚠ {warning}[/yellow]")
if result.changed:
from hermes_cli.plugins_cmd import _install_python_dependencies
- _install_python_dependencies(target.parent / result.installed_name, console)
+ new_target = target.parent / result.installed_name
+ _install_python_dependencies(new_target, console)
+ # Same grant path as the git-pull ``update``: host capabilities the new pin declares stay
+ # ungranted (fail closed) until the user says yes here.
+ declared = _declared_capabilities_from_manifest(_read_manifest(new_target), result.installed_name)
+ if declared:
+ from hermes_cli.plugin_capabilities import declared_set_changed, pending_capabilities
+ if pending_capabilities(result.installed_name, declared) or declared_set_changed(result.installed_name, declared):
+ _run_capability_consent(console, result.installed_name, declared, context="update")
# ── search / browse / info / validate ────────────────────────────────────────
@@ -435,7 +526,7 @@ def installed_catalog_state(installed: Dict[str, Dict[str, Any]]) -> Dict[str, A
**entry.to_dict(), "sha_short": entry.sha[:7],
"capability_summary": entry_capability_summary(entry),
"installed": local is not None, "installed_sha": installed_sha,
- "update_available": bool(installed_sha) and installed_sha != entry.sha,
+ "update_available": bool(installed_sha) and not at_catalog_pin(sidecar or {}, entry.sha),
"runtime_status": local["runtime_status"] if local else None,
})
return {
@@ -461,7 +552,7 @@ def catalog_row_fields(dir_path, pins: Dict[str, str], versions: Optional[Dict[s
if pin:
row["catalog_sha"] = pin
row["catalog_version"] = versions.get(str(sidecar["catalog_name"])) or None
- row["update_available"] = bool(installed_sha) and installed_sha != pin
+ row["update_available"] = bool(installed_sha) and not at_catalog_pin(sidecar, pin)
return row
diff --git a/hermes_cli/web_routers/dashboard_ui.py b/hermes_cli/web_routers/dashboard_ui.py
index b323fbf27de..83ad205d1bd 100644
--- a/hermes_cli/web_routers/dashboard_ui.py
+++ b/hermes_cli/web_routers/dashboard_ui.py
@@ -166,7 +166,10 @@ async def get_plugins_hub(request: Request):
def _plugin_action(result: dict, fallback_error: str, *, rescan: bool) -> dict:
"""Common tail of agent-plugin mutations: 400 on ``ok=False``, then invalidate caches
- (rescanning discovery when files changed on disk)."""
+ (rescanning discovery when files changed on disk). A ``consent_required`` answer is not a failure:
+ nothing changed, the client shows the delta and retries with consent."""
+ if result.get("consent_required"):
+ return result
if not result.get("ok"):
raise HTTPException(status_code=400, detail=result.get("error") or fallback_error)
if rescan:
@@ -266,7 +269,16 @@ async def post_agent_plugin_disable(request: Request, name: str):
@router.post("/api/dashboard/agent-plugins/{name:path}/update")
async def post_agent_plugin_update(request: Request, name: str):
from hermes_cli.plugins_cmd import dashboard_update_user_plugin
- return await _named_plugin_action(request, name, dashboard_update_user_plugin, "Update failed.", rescan=True)
+ # Body is optional: ``{"accept_capabilities": true}`` applies a re-pin the user confirmed after a
+ # ``consent_required`` answer.
+ try:
+ body = await request.json()
+ except Exception:
+ body = {}
+ accept = isinstance(body, dict) and body.get("accept_capabilities") is True
+ return await _named_plugin_action(
+ request, name, lambda n: dashboard_update_user_plugin(n, accept_capabilities=accept), "Update failed.",
+ rescan=True)
@router.delete("/api/dashboard/agent-plugins/{name:path}")
diff --git a/tests/hermes_cli/test_plugins_cmd_catalog.py b/tests/hermes_cli/test_plugins_cmd_catalog.py
index 1c3436566cd..7f6a5fdf777 100644
--- a/tests/hermes_cli/test_plugins_cmd_catalog.py
+++ b/tests/hermes_cli/test_plugins_cmd_catalog.py
@@ -191,3 +191,54 @@ def test_kill_list_covers_update_enable_and_load_of_an_installed_plugin(world, t
# Explicit bypass at install time is remembered.
pc.cmd_install((tmp_path / "later-killed").as_uri(), force=True, enable=False, allow_removed=True)
assert gate_manifest(manifest, set(), {"killed"}).action == "load"
+
+
+def test_annotated_tag_pin_keeps_reviewed_trust_and_reads_as_at_pin(world, monkeypatch):
+ """A pin recorded as `git rev-parse <tag>` names the TAG object; HEAD can only ever be the commit it
+ points at. Trust (scan skips the caution prompt) and the at-pin check must both use the peeled commit,
+ or every tag-pinned entry prompts at install and shows 'update available' forever."""
+ repo = world["repo"]
+ sp.run(["git", "tag", "-a", "v1", world["sha1"], "-m", "v1"], cwd=repo, check=True, env=_GIT_ENV)
+ tag_obj = sp.run(["git", "rev-parse", "v1"], cwd=repo, check=True, capture_output=True, text=True).stdout.strip()
+ assert tag_obj != world["sha1"]
+ world["state"]["pin"] = tag_obj
+ seen = {}
+ real_scan = pc._scan_plugin_tree
+ monkeypatch.setattr(pc, "_scan_plugin_tree", lambda *a, **k: seen.update(k) or real_scan(*a, **k))
+ entry = pc_cat.get_live_catalog_entry("cat-plugin")
+ target, _m, _n = cat.install_catalog_entry(entry, force=False)
+ assert _head(target) == world["sha1"] and seen["reviewed_pin"] is True
+ sidecar = cat.read_catalog_sidecar(target)
+ assert (sidecar["sha"], sidecar["pin"]) == (world["sha1"], tag_obj)
+ assert cat.catalog_row_fields(target, cat.catalog_pins())["update_available"] is False
+ assert cat.installed_catalog_state({"cat-plugin": {"dir": str(target), "runtime_status": None}})["entries"][0]["update_available"] is False
+ assert pc.dashboard_update_user_plugin("cat-plugin")["unchanged"] is True
+ # A bump to a commit sha is still an update.
+ world["state"]["pin"] = world["sha2"]
+ assert cat.catalog_row_fields(target, cat.catalog_pins())["update_available"] is True
+
+
+def test_repin_that_widens_the_plugin_requires_consent_on_every_surface(world, monkeypatch):
+ """A new pin adding tools / a Desktop half is a new grant: the dashboard/TUI answer consent_required
+ with the delta and touch nothing; a retry with consent applies it; the CLI asks y/N and a decline
+ leaves the tree at the old pin. A pin that widens nothing (sha2) needs no consent."""
+ entry = pc_cat.get_live_catalog_entry("cat-plugin")
+ target, _m, _n = cat.install_catalog_entry(entry, force=False)
+ repo = world["repo"]
+ (repo / "plugin.yaml").write_text("name: cat-plugin\nversion: 3.0.0\ndescription: d\nprovides_tools: [shell_out]\n")
+ (repo / "desktop").mkdir()
+ (repo / "desktop" / "plugin.js").write_text("export default {}\n")
+ world["state"]["pin"] = wide = _commit(repo, "widen")
+ result = pc.dashboard_update_user_plugin("cat-plugin")
+ assert result["ok"] is False and result["consent_required"] is True
+ assert result["delta"] == {"tools": ["shell_out"], "desktop": ["desktop/plugin.js"]}
+ assert _head(target) == world["sha1"] # nothing moved
+ # CLI: non-interactive (or 'n') → refused, tree untouched.
+ monkeypatch.setattr(pc, "_is_tty", lambda: True)
+ monkeypatch.setattr(pc, "_ask_yes", lambda *a, **k: False)
+ with pytest.raises(SystemExit):
+ pc.cmd_update("cat-plugin")
+ assert _head(target) == world["sha1"]
+ # Consent given → applied.
+ assert pc.dashboard_update_user_plugin("cat-plugin", accept_capabilities=True)["unchanged"] is False
+ assert _head(target) == wide
diff --git a/tui_gateway/contracts/tools_mcp_plugins.py b/tui_gateway/contracts/tools_mcp_plugins.py
index 24f75877dbb..b87d8807348 100644
--- a/tui_gateway/contracts/tools_mcp_plugins.py
+++ b/tui_gateway/contracts/tools_mcp_plugins.py
@@ -578,7 +578,8 @@ class PluginsAction(WireEnum):
class PluginsManageParams(ProfileParams):
"""``toggle``: ``key``/``name`` + ``enable``; ``install``: ``identifier``/``repo`` or ``catalog_name``
- (+ ``force``, ``enable``, ``ref``); ``update``: ``name``; ``remove``: ``name`` (user installs only)."""
+ (+ ``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)."""
action: PluginsAction = PluginsAction.list
key: str | None = None
@@ -589,6 +590,7 @@ class PluginsManageParams(ProfileParams):
catalog_name: str | None = None
force: bool | None = None
ref: str | None = None
+ accept_capabilities: bool | None = None
class AgentPluginRow(Result):
@@ -615,7 +617,9 @@ class AgentPluginRow(Result):
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
- ok payload; ``update`` → ``ok``/``unchanged``/``sha``; ``remove`` → ``ok``/``name`` plus
+ ok payload; ``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``."""
plugins: list[AgentPluginRow] | None = None
@@ -633,6 +637,10 @@ class PluginsManageResult(Result):
after_install_path: str | None = None
enabled: bool | None = None
sha: str | None = None
+ consent_required: bool | None = None
+ delta: dict[str, list[str]] | None = None
+ delta_lines: list[str] | None = None
+ error: str | None = None
method("plugins.manage", params=PluginsManageParams, result=PluginsManageResult,
diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.py
index fb0c74c8b82..d222fbf771d 100644
--- a/tui_gateway/methods_tools.py
+++ b/tui_gateway/methods_tools.py
@@ -1501,7 +1501,10 @@ def _plugins_install(rid, params):
def _plugins_update(rid, params):
- """Catalog installs only: re-pin to the current catalog SHA (non-catalog installs update via the CLI)."""
+ """Catalog installs only: re-pin to the current catalog SHA (non-catalog installs update via the CLI).
+ A pin that widens the plugin (new tools/hooks/deps/capabilities/Desktop half) answers
+ ``{ok: false, consent_required: true, delta, delta_lines}`` with nothing changed; the client shows the
+ delta and retries with ``accept_capabilities: true``."""
name = (params.get("name") or "").strip()
if not name:
return _err(rid, 4019, "plugins.update requires a 'name'")
@@ -1511,7 +1514,11 @@ def _plugins_update(rid, params):
if not sidecar:
return _err(rid, 4020, f"'{name}' is not a catalog install — update it via the CLI")
try:
- result = cat.repin_catalog_plugin(target, sidecar)
+ result = cat.repin_catalog_plugin(
+ target, sidecar, consent_cb=(lambda _delta: True) if params.get("accept_capabilities") else None)
+ except cat.RepinConsentRequired as e:
+ return _ok(rid, {"ok": False, "consent_required": True, "name": e.name, "sha": e.sha, "delta": e.delta,
+ "delta_lines": cat.surface_delta_lines(e.delta), "error": str(e)})
except pc.PluginOperationError as e:
return _err(rid, 4021, str(e))
return _ok(rid, {"ok": True, "unchanged": not result.changed, "sha": result.sha, "name": result.installed_name,
diff --git a/web/src/i18n/en.ts b/web/src/i18n/en.ts
index 6357a642595..41daace2aad 100644
--- a/web/src/i18n/en.ts
+++ b/web/src/i18n/en.ts
@@ -430,6 +430,8 @@ export const en: Translations = {
authRequired: "Auth required",
authRequiredHint: "Run this command to authenticate:",
updateGit: "Git pull",
+ updateConsentBody: (name: string, sha: string) =>
+ `The new catalog pin of ${name} (${sha}) adds surfaces the installed version does not have. Apply it only if you trust them:`,
versionBadge: "Version",
showInSidebar: "Show in sidebar",
hideFromSidebar: "Hide from sidebar",
diff --git a/web/src/i18n/types.ts b/web/src/i18n/types.ts
index 79966bd980d..f96afda6321 100644
--- a/web/src/i18n/types.ts
+++ b/web/src/i18n/types.ts
@@ -374,6 +374,8 @@ export interface Translations {
authRequired: string;
authRequiredHint: string;
updateGit: string;
+ /** Optional: locales without it fall back to the English body at the call site. */
+ updateConsentBody?: (name: string, sha: string) => string;
versionBadge: string;
showInSidebar: string;
hideFromSidebar: string;
diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts
index c2e02765b2f..47e063f37d7 100644
--- a/web/src/lib/api.ts
+++ b/web/src/lib/api.ts
@@ -1075,10 +1075,14 @@ export const api = {
method: "POST",
}),
- updateAgentPlugin: (name: string) =>
+ updateAgentPlugin: (name: string, acceptCapabilities = false) =>
fetchJSON<AgentPluginUpdateResponse>(
`/api/dashboard/agent-plugins/${pluginPath(name)}/update`,
- { method: "POST" },
+ {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ accept_capabilities: acceptCapabilities }),
+ },
),
removeAgentPlugin: (name: string) =>
@@ -2793,6 +2797,11 @@ export interface AgentPluginUpdateResponse {
output?: string;
unchanged?: boolean;
error?: string;
+ /** The new catalog pin widens the plugin; nothing changed until the client
+ * retries with `accept_capabilities`. */
+ consent_required?: boolean;
+ sha?: string;
+ delta_lines?: string[];
}
export interface PluginProvidersPutRequest {
diff --git a/web/src/pages/PluginsPage.tsx b/web/src/pages/PluginsPage.tsx
index e54f50710f9..98c584155b6 100644
--- a/web/src/pages/PluginsPage.tsx
+++ b/web/src/pages/PluginsPage.tsx
@@ -28,6 +28,7 @@ import { Label } from "@nous-research/ui/ui/components/label";
import { useToast } from "@nous-research/ui/hooks/use-toast";
import { Toast } from "@nous-research/ui/ui/components/toast";
import { useI18n } from "@/i18n";
+import { en } from "@/i18n/en";
import { PluginSlot } from "@/plugins";
import { cn } from "@/lib/utils";
import { usePageHeader } from "@/contexts/usePageHeader";
@@ -1178,7 +1179,19 @@ function PluginRowCard(props: PluginRowCardProps) {
size="sm"
onClick={() => {
void setRuntimeLoading(row.name, async () => {
- await api.updateAgentPlugin(row.name);
+ const res = await api.updateAgentPlugin(row.name);
+ if (res.consent_required) {
+ // The new pin widens the plugin; the backend changed nothing until confirmed.
+ const body = [
+ (t.pluginsPage.updateConsentBody ?? en.pluginsPage.updateConsentBody!)(
+ row.name,
+ (res.sha ?? "").slice(0, 8),
+ ),
+ ...(res.delta_lines ?? []),
+ ].join("\n");
+ if (!window.confirm(body)) return;
+ await api.updateAgentPlugin(row.name, true);
+ }
showToast(t.pluginsPage.updateGit, "success");
});
}}
diff --git a/website/docs/user-guide/features/plugins.md b/website/docs/user-guide/features/plugins.md
index 2e59e2d55f5..6a4bc0460a0 100644
--- a/website/docs/user-guide/features/plugins.md
+++ b/website/docs/user-guide/features/plugins.md
@@ -461,7 +461,12 @@ gracefully.
**Update re-consent:** if a plugin update declares capabilities you haven't
granted, `hermes plugins update` surfaces the additions and asks again. New
capabilities stay off until you consent — a plugin update can never silently
-widen its access.
+widen its access. Catalog re-pins go one step further: when the new pin adds
+tools, hooks, Python dependencies, host capabilities or a Desktop UI half the
+installed version did not have, the CLI shows the delta and asks `y/N` before
+anything moves, and the Desktop / dashboard **Update** button opens the same
+confirmation. Declining (or a non-interactive session) leaves the plugin at
+the old pin.
**Non-interactive sessions fail closed:** installing or updating without a
TTY completes the install, but declared capabilities are *not* granted. Run