The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(memory): catalog memory-provider installs stop failing on every start and every Install click
Teknium03f545ebcfd7
diff --git a/hermes_cli/memory_provider_migration.py b/hermes_cli/memory_provider_migration.pyindex cf291306a10..4624d73837e 100644--- a/hermes_cli/memory_provider_migration.py+++ b/hermes_cli/memory_provider_migration.py@@ -158,14 +158,15 @@ def _home_consent(home: Path) -> bool:reset_hermes_home_override(token)-def _install_into(home: Path) -> Callable[[str], dict]:+def _install_into(home: Path, *, consent: Optional[bool] = None) -> Callable[[str], dict]:def _install(name: str) -> dict:from hermes_cli.plugins_cmd import dashboard_install_pluginfrom hermes_constants import reset_hermes_home_override, set_hermes_home_overridetoken = set_hermes_home_override(home)try:return dashboard_install_plugin("", force=False, enable=True, catalog_name=name,- assume_deps_consent=name in _LEFT_CORE and _unattended_consent())+ assume_deps_consent=(name in _LEFT_CORE and _unattended_consent())+ if consent is None else consent)finally:reset_hermes_home_override(token)return _install@@ -254,4 +255,14 @@ def recover_at_startup(name: str, *, say: Optional[Callable[[str], None]] = Nonef"security.allow_lazy_installs is off, so Hermes did not fetch it: "f"run `{_install_command(name, home)}`.")return False- return migrate_home(home, install=_install_into(home), say=report) == name+ # Agent init cannot answer a dependency prompt: under the CLI the prompt_toolkit input owns the+ # terminal (the question hangs the turn), elsewhere there is no terminal (the install is refused,+ # every process). So it installs with consent or not at all: a provider that shipped in core+ # carries the consent its built-in had; any other one needs the user's own install.+ if name not in _LEFT_CORE:+ if _pending_provider(home, say=report) == name:+ report(f"⚠ Memory provider '{name}' is not installed, so external memory is off for this session. "+ f"It never shipped with Hermes, so Hermes installs it only when you ask: "+ f"run `{_install_command(name, home)}`.")+ return False+ return migrate_home(home, install=_install_into(home, consent=True), say=report) == namediff --git a/hermes_cli/plugins_cmd_install.py b/hermes_cli/plugins_cmd_install.pyindex 2684d04d771..a113d7d84ef 100644--- a/hermes_cli/plugins_cmd_install.py+++ b/hermes_cli/plugins_cmd_install.py@@ -673,13 +673,17 @@ def _select_memory_provider(name: str, console, *, select: bool) -> None:def dashboard_install_plugin(identifier: str, *, force: bool, enable: bool, catalog_name: Optional[str] = None,- ref: Optional[str] = None, assume_deps_consent: bool = False,+ ref: Optional[str] = None, assume_deps_consent: Optional[bool] = None,) -> dict[str, Any]:"""Non-interactive install for the dashboard/TUI. *catalog_name* installs a curated entry at itspinned SHA (identifier may be empty); *ref* pins a custom source to one full commit SHA (samecontract 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."""+ is consent the caller holds for the Python deps, so no terminal is needed to answer the gate.+ None (a user's Install click) is the consent the fresh-install enable already acts on: a plugin+ the config already selects (``memory.provider``) would otherwise be refused every time, while+ the same plugin unselected installs and enables. A forced replacement still needs explicit consent."""+ if assume_deps_consent is None:+ assume_deps_consent = enable and not forcefrom hermes_cli import plugins_cmd_catalog as catalogwarnings: list[str] = []entry = None@@ -704,7 +708,8 @@ def dashboard_install_plugin(if entry is not None: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)+ return _pc()._install_plugin_core(identifier, force=force, ref=(ref or "").strip() or None,+ assume_deps_consent=assume_deps_consent)try:target, installed_manifest, installed_name = recorded_install(diff --git a/tests/hermes_cli/test_memory_provider_migration.py b/tests/hermes_cli/test_memory_provider_migration.pyindex f9dd5814121..4a0fa049b4d 100644--- a/tests/hermes_cli/test_memory_provider_migration.py+++ b/tests/hermes_cli/test_memory_provider_migration.py@@ -70,10 +70,11 @@ def test_startup_recovery_attempts_each_profile_home(tmp_path, monkeypatch):(profile_home / "config.yaml").write_text("memory:\n provider: twin\n", encoding="utf-8")monkeypatch.setattr(mig, "_attempted", set())monkeypatch.setattr(mig, "catalog_source", lambda name: name)+ monkeypatch.setattr(mig, "_LEFT_CORE", frozenset({"twin"}))monkeypatch.setattr(pm_install, "lazy_installs_allowed", lambda: True)installed = []- def fake_installer(profile_home):+ def fake_installer(profile_home, **_kw):def install(name):plugin_dir = profile_home / "plugins" / nameplugin_dir.mkdir(parents=True)@@ -124,6 +125,36 @@ def test_unattended_migration_install_carries_lazy_install_consent(tmp_path, monassert seen.get("assume_deps_consent", False) is consent[email protected](("name", "installs"), [("hindsight", True), ("someplugin", False)])+def test_startup_recovery_never_asks_a_dependency_question(tmp_path, monkeypatch, name, installs):+ """Agent init cannot answer a prompt: in the CLI the question hangs the turn behind the chat input,+ with no terminal it is refused on every process start. A provider that shipped in core installs+ with its built-in's consent even on a terminal; any other one is not attempted and names the command."""+ import io++ from hermes_cli import plugins_cmd+ from pm import install as pm_install++ class _Tty(io.StringIO):+ def isatty(self):+ return True++ (tmp_path / "config.yaml").write_text(f"memory:\n provider: {name}\n", encoding="utf-8")+ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ monkeypatch.setattr("sys.stdin", _Tty())+ monkeypatch.setattr("sys.stdout", _Tty())+ monkeypatch.setattr(mig, "_attempted", set())+ monkeypatch.setattr(mig, "catalog_source", lambda n: n)+ monkeypatch.setattr(pm_install, "lazy_installs_allowed", lambda: True)+ monkeypatch.setattr("builtins.input", lambda *_a: pytest.fail("agent init asked a question"))+ seen: list[dict] = []+ monkeypatch.setattr(plugins_cmd, "dashboard_install_plugin", lambda *a, **kw: seen.append(kw) or {"ok": False})+ said: list[str] = []+ mig.recover_at_startup(name, say=said.append)+ assert [kw["assume_deps_consent"] for kw in seen] == ([True] if installs else [])+ assert installs or f"`hermes plugins install {name}`" in said[-1]++def test_update_asks_once_and_names_each_profile(tmp_path, monkeypatch):"""Profiles sharing one environment face one dependency question for a migrating provider(#125794); every line names its profile, and a decline names the rest once with their commands."""diff --git a/tests/hermes_cli/test_plugin_dependency_consent.py b/tests/hermes_cli/test_plugin_dependency_consent.pyindex 1d2f1507158..7d6db00901f 100644--- a/tests/hermes_cli/test_plugin_dependency_consent.py+++ b/tests/hermes_cli/test_plugin_dependency_consent.py@@ -96,6 +96,33 @@ def test_yes_deps_carries_consent_through_non_interactive_install(admission_env,assert 'dependency install skipped (non-interactive)' not in output+def test_dashboard_install_publishes_a_plugin_the_config_already_selects(admission_env, monkeypatch):+ """The Desktop/dashboard Install click on a plugin memory.provider already names (a provider that+ left core, a synced config, a re-install after remove) publishes like any fresh install instead of+ the non-interactive 'Install declined' that a retry can never get past. A forced replacement of an+ installed plugin keeps the veto: that is the reinstall the click did not review."""+ root, home = admission_env+ source = root / 'mem-source'+ source.mkdir()+ (source / 'plugin.yaml').write_text(yaml.safe_dump({'name': 'mem-twin'}), encoding='utf-8')+ (source / '__init__.py').write_text('class Twin(MemoryProvider): ...\n', encoding='utf-8')+ (source / 'pyproject.toml').write_text(+ '[project]\nname="mem-twin"\nversion="1.0"\nrequires-python=">=3.11"\n', encoding='utf-8')+ env = {k: v for k, v in os.environ.items() if k not in {'GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE'}}+ for args in [('init', '-q'), ('add', '.'), ('-c', 'user.name=test', '-c', '[email protected]', 'commit', '-qm', 'fixture')]:+ subprocess.run(['git', *args], cwd=source, env=env, check=True, capture_output=True, timeout=30)+ config = yaml.safe_load((home / 'config.yaml').read_text(encoding='utf-8'))+ config['memory'] = {'provider': 'mem-twin'}+ (home / 'config.yaml').write_text(yaml.safe_dump(config), encoding='utf-8')+ monkeypatch.setattr(plugins_cmd.sys.stdin, 'isatty', lambda: False)++ result = plugins_cmd.dashboard_install_plugin(source.as_uri(), force=False, enable=True)+ assert result['ok'], result+ assert (home / 'plugins' / 'mem-twin' / 'plugin.yaml').is_file()+ again = plugins_cmd.dashboard_install_plugin(source.as_uri(), force=True, enable=True)+ assert not again['ok'] and 'Reinstall declined' in again['error']++def test_publish_assume_consent_skips_replacement_veto(tmp_path, monkeypatch):"""The active-replacement veto at publication honors --yes-deps: with theexplicit answer the PM handoff runs; the default without it stays thediff --git a/tests/tui_gateway/test_plugins_manage_late_activation.py b/tests/tui_gateway/test_plugins_manage_late_activation.pyindex 3dcd1401865..7cf656570af 100644--- a/tests/tui_gateway/test_plugins_manage_late_activation.py+++ b/tests/tui_gateway/test_plugins_manage_late_activation.py@@ -19,7 +19,7 @@ from hermes_cli.plugins import get_plugin_managerfrom tui_gateway import server-def _fake_install_core(identifier, *, force=False, ref=None):+def _fake_install_core(identifier, *, force=False, ref=None, **_kwargs):"""Stand-in for the git clone: a portable plugin (mcp.json + a skill) under the sandbox plugins dir,returning ``(target, manifest, name)`` like the real core."""from hermes_cli.agent_plugins import MCP_SCHEMA_V1, PLUGIN_SCHEMA_V1diff --git a/website/docs/user-guide/features/memory-providers.md b/website/docs/user-guide/features/memory-providers.mdindex 5c38dc7b313..62c198c834a 100644--- a/website/docs/user-guide/features/memory-providers.md+++ b/website/docs/user-guide/features/memory-providers.md@@ -506,6 +506,7 @@ Hindsight used to ship inside the Hermes tree (and as the `hermes-agent[hindsigh- `hermes update` installs the catalog plugin into every profile home that names the provider. Each line names the profile it is about. In a terminal it asks before preparing the plugin's Python dependencies; when several profiles use the provider, the questions are asked once and the answers apply to all of them. Without a terminal (the Desktop app, a script, a service) nobody can answer, so each profile prepares them unattended when its `security.allow_lazy_installs` is on (the default); a profile with it off gets the exact `hermes -p <profile> plugins install hindsight` command instead, and the other profiles still migrate.- If the plugin is still missing on the first agent start (`hermes chat`, Desktop, the gateway, …), Hermes installs it, dependencies included, and shows ``✓ Memory provider 'hindsight' moved out of core — installed its plugin from the catalog (memory.provider and your stored memories are unchanged; check its settings with `hermes memory status`).`` Messaging platforms get the line with the first reply.- When the agent-start install cannot happen, you see why instead of silently running without external memory: with `security.allow_lazy_installs: false` the warning names the install command for that profile; offline or declined installs show the error and the same command.+- Agent start never asks a question (the chat prompt owns the terminal). A catalog provider that never shipped with Hermes (for example `mnemosyne`) is therefore not installed on agent start: the warning names `hermes plugins install <name>` for that profile, or install it from the dashboard/Desktop Plugins page.What changes on disk: the plugin appears in `~/.hermes/plugins/hindsight/` and `config.yaml` gains `plugins.enabled: [hindsight]`. `memory.provider`, `$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).