Skip to content

The agent that grows with you

fix(memory): migrate deps-bearing providers without a terminal under allow_lazy_installs

teknium1084a84b544cf
diff --git a/hermes_cli/memory_provider_migration.py b/hermes_cli/memory_provider_migration.py
index 28ad6a6f50b..3f46c8020ff 100644
--- a/hermes_cli/memory_provider_migration.py
+++ b/hermes_cli/memory_provider_migration.py
@@ -17,6 +17,7 @@ the user gets the exact one-liner instead of silently running without memory.
from __future__ import annotations
import logging
+import sys
from pathlib import Path
from typing import Callable, Optional
@@ -80,13 +81,26 @@ def migrate_home(home: Path, *, install: Callable[[str], dict], say: Callable[[s
return None
+def _unattended_consent() -> bool:
+ """Without a terminal (Desktop, gateway, ``hermes update`` from a script) nobody can answer the
+ dependency prompt, so every provider that declares Python deps would fail to migrate. The
+ configured ``memory.provider`` plus ``security.allow_lazy_installs`` (read for the home being
+ migrated) is the same consent that let the bundled provider install its deps on demand; with a
+ terminal the user is still asked."""
+ from pm.install import lazy_installs_allowed
+
+ interactive = sys.stdin is not None and sys.stdout is not None and sys.stdin.isatty() and sys.stdout.isatty()
+ return not interactive and lazy_installs_allowed()
+
+
def _install_into(home: Path) -> Callable[[str], dict]:
def _install(name: str) -> dict:
from hermes_cli.plugins_cmd import dashboard_install_plugin
from hermes_constants import reset_hermes_home_override, set_hermes_home_override
token = set_hermes_home_override(home)
try:
- return dashboard_install_plugin("", force=False, enable=True, catalog_name=name)
+ return dashboard_install_plugin("", force=False, enable=True, catalog_name=name,
+ assume_deps_consent=_unattended_consent())
finally:
reset_hermes_home_override(token)
return _install
diff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.py
index 58d4c5951db..0d8fffce40b 100644
--- a/hermes_cli/plugins_cmd_install.py
+++ b/hermes_cli/plugins_cmd_install.py
@@ -103,7 +103,7 @@ def _consent_python_deps(
# An explicit --yes-deps is the user's own answer, TTY or not.
if assume_yes:
console.print(
- "[dim]--yes-deps: preparing the declared dependencies without prompting.[/dim]\n"
+ "[dim]Consent given up front — preparing them without prompting.[/dim]\n"
)
return True, None
@@ -583,11 +583,13 @@ def cmd_install(
def dashboard_install_plugin(
identifier: str, *, force: bool, enable: bool, catalog_name: Optional[str] = None,
- ref: Optional[str] = None,
+ ref: Optional[str] = None, assume_deps_consent: bool = False,
) -> dict[str, Any]:
"""Non-interactive install for the dashboard/TUI. *catalog_name* installs a curated entry at its
pinned SHA (identifier may be empty); *ref* pins a custom source to one full commit SHA (same
- contract as ``--ref``); every path enforces the kill list (no GUI bypass)."""
+ contract as ``--ref``); every path enforces the kill list (no GUI bypass). *assume_deps_consent*
+ is consent the caller already holds for the catalog entry's Python deps (the memory-provider
+ migration under ``security.allow_lazy_installs``), so no terminal is needed to answer the gate."""
from hermes_cli import plugins_cmd_catalog as catalog
warnings: list[str] = []
entry = None
@@ -610,7 +612,8 @@ def dashboard_install_plugin(
return {"ok": False, "error": str(exc)}
def _install() -> tuple:
if entry is not None:
- return catalog.install_catalog_entry(entry, force=force, allow_removed=False)
+ return catalog.install_catalog_entry(entry, force=force, allow_removed=False,
+ assume_deps_consent=assume_deps_consent)
return _pc()._install_plugin_core(identifier, force=force, ref=(ref or "").strip() or None)
try:
diff --git a/tests/hermes_cli/test_memory_provider_migration.py b/tests/hermes_cli/test_memory_provider_migration.py
index 897d10b91f7..80875e34834 100644
--- a/tests/hermes_cli/test_memory_provider_migration.py
+++ b/tests/hermes_cli/test_memory_provider_migration.py
@@ -93,3 +93,30 @@ def test_startup_recovery_attempts_each_profile_home(tmp_path, monkeypatch):
assert outcomes == [True, True, False]
assert installed == homes
+
+
[email protected](("tty", "lazy", "consent"), [
+ (False, True, True), # Desktop/gateway/scripted update: nobody can answer the prompt
+ (False, False, False), # allow_lazy_installs off: still refused, with the install hint
+ (True, True, False), # a terminal: the user is asked
+])
+def test_unattended_migration_install_carries_lazy_install_consent(tmp_path, monkeypatch, tty, lazy, consent):
+ """Every provider still in core declares Python deps; without this, no non-interactive migration
+ (the whole point of the agent-start hook) can ever publish one."""
+ import io
+
+ from hermes_cli import plugins_cmd
+ from pm import install as pm_install
+
+ class _Stream(io.StringIO):
+ def isatty(self):
+ return tty
+
+ monkeypatch.setattr("sys.stdin", _Stream())
+ monkeypatch.setattr("sys.stdout", _Stream())
+ monkeypatch.setattr(pm_install, "lazy_installs_allowed", lambda: lazy)
+ seen = {}
+ monkeypatch.setattr(plugins_cmd, "dashboard_install_plugin", lambda *a, **kw: seen.update(kw) or {"ok": True})
+ assert mig._install_into(tmp_path)("hindsight") == {"ok": True}
+ assert seen["catalog_name"] == "hindsight"
+ assert seen.get("assume_deps_consent", False) is consent
diff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.md
index 9515423c2ca..7a669957b6c 100644
--- a/website/docs/developer-guide/plugins/index.md
+++ b/website/docs/developer-guide/plugins/index.md
@@ -383,6 +383,9 @@ When both exist the `pyproject.toml` wins. What Hermes does with them:
use a plugin-owned external runtime for them.
- **`--no-deps`** downloads a new plugin without dependency consent and leaves it disabled,
even with `--enable`. It cannot bypass PM admission when replacing an active plugin.
+- **`--yes-deps`** answers the dependency question up front, so a headless install (CI, SSH
+ automation, a container entrypoint) prepares the declared dependencies instead of being refused.
+ It is mutually exclusive with `--no-deps`.
- **`python_runtime: external`** keeps a sidecar's dependencies out of the shared union.
Hermes does not install that Python runtime or modify its declaration.
- **Nothing to load is an error** — `hermes plugins validate` rejects `plugin.yaml` without
diff --git a/website/docs/user-guide/features/memory-providers.md b/website/docs/user-guide/features/memory-providers.md
index beae77ee8ab..d14ffb1e3e9 100644
--- a/website/docs/user-guide/features/memory-providers.md
+++ b/website/docs/user-guide/features/memory-providers.md
@@ -493,8 +493,8 @@ See the [upstream Hermes integration docs](https://hindsight.vectorize.io/sdks/i
Hindsight used to ship inside the Hermes tree (and as the `hermes-agent[hindsight]` pip extra). If your `config.yaml` already has `memory.provider: hindsight`, there is nothing to do for most users:
-- `hermes update` installs the catalog plugin into every profile home that names the provider (this runs even when `security.allow_lazy_installs` is `false`).
-- If the plugin is still missing on the first agent start (`hermes chat`, the gateway, …), Hermes installs it and prints `✓ Memory provider 'hindsight' moved out of core — installed its plugin from the catalog (your memory.hindsight settings and data are unchanged).`
+- `hermes update` installs the catalog plugin into every profile home that names the provider. In a terminal it asks before preparing the plugin's Python dependencies. Without a terminal (the Desktop app, a script, a service) nobody can answer, so it prepares them unattended when `security.allow_lazy_installs` is on (the default) and otherwise prints the `hermes plugins install hindsight` one-liner.
+- If the plugin is still missing on the first agent start (`hermes chat`, the gateway, the Desktop app, …), Hermes installs it, dependencies included, and prints `✓ Memory provider 'hindsight' moved out of core — installed its plugin from the catalog (your memory.hindsight settings and data are unchanged).`
- With `security.allow_lazy_installs: false`, the agent-start path instead logs one line — ``Memory provider 'hindsight' is not installed; security.allow_lazy_installs is off — run `hermes plugins install hindsight`.`` — and you run `hermes plugins install hindsight` yourself.
What changes on disk: the plugin appears in `~/.hermes/plugins/hindsight/` and `config.yaml` gains `plugins.enabled: [hindsight]`. `memory.provider`, `memory.hindsight.*`, `$HERMES_HOME/hindsight/config.json`, `HINDSIGHT_API_KEY` in `.env` and your memory bank data are untouched. Verify with `hermes memory status` (provider active) and `hermes plugins list` (plugin installed and enabled).