mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-19 05:19:42 +03:00
ffe2f6411c
When an update had to disable a plugin it also cleared memory.provider, so the memory provider stayed lost even after the plugin was re-enabled, and nothing ever retried the plugin: one transient failure (a TLS proxy, a mirror outage, a since-fixed resolver bug) left it off for good. - The dependency union now honours plugins.disabled for memory.provider the same way the provider loader already does, so eviction no longer has to blank the selection. Re-enabling the plugin brings the provider back. - The eviction is recorded in the home's config under plugins.disabled_by_update (was it enabled, and why). Every later update retries recorded plugins after the enabled ones and undoes exactly the edit once a plugin fits again. - A user's own enable/disable/remove takes the decision back: PM's selection publication forgets the record for the plugin the user settled, and `hermes plugins disable` on an update-disabled plugin now writes that. - Spellings come from the plugin's own manifest instead of a plugin scan of the PM process's home, so a profile's plugins are matched in that profile. - A parked provider is reported, not re-installed: agent init tells the user once why external memory is off (naming the update's reason), and `hermes memory status` and `hermes doctor` show it instead of "plugin not found" or "All checks passed". Doctor lists every update-disabled plugin.
84 lines
3.2 KiB
Python
84 lines
3.2 KiB
Python
"""Submit proposed plugin selections to the independent PM publisher."""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Iterable, Optional
|
|
|
|
|
|
class AdmissionRefused(RuntimeError):
|
|
"""The candidate set was refused; config and environment untouched."""
|
|
|
|
|
|
class DependencyConflict(AdmissionRefused):
|
|
"""PM's resolver proved the candidate set cannot co-install with the pinned dependency set.
|
|
|
|
The raw ``uv lock`` output names hashed workspace members, not the plugin the user asked for, so
|
|
the message leads with the plugin and keeps the resolver's cause for the details.
|
|
"""
|
|
|
|
def __init__(self, cause: str, *, plugin: Optional[str] = None):
|
|
self.cause = cause
|
|
self.plugin = plugin
|
|
who = f"Plugin '{plugin}'" if plugin else "The plugin selection"
|
|
super().__init__(
|
|
f"{who} conflicts with the dependencies pinned by Hermes core or an enabled plugin, "
|
|
f"so it was not admitted. Resolver: {cause}")
|
|
|
|
|
|
def candidate_member_dirs(
|
|
candidate_enabled: Iterable[str],
|
|
candidate_disabled: Iterable[str] = (),
|
|
*,
|
|
active_plugins_dir: Optional[Path] = None,
|
|
extra_dirs: Iterable[Path] = (),
|
|
) -> list[Path]:
|
|
"""Shipped callers' member-list adapter; new discovery belongs to PM.
|
|
|
|
Without an active plugins dir, preserve every home's recorded selection.
|
|
"""
|
|
from pm.publication import candidate_members
|
|
|
|
active = Path(active_plugins_dir) if active_plugins_dir else None
|
|
return candidate_members(
|
|
extra_dirs,
|
|
proposed_home=active.parent if active else None,
|
|
enabled=candidate_enabled,
|
|
disabled=candidate_disabled,
|
|
)
|
|
|
|
|
|
def admit_plugin_set_change(
|
|
candidate_enabled: set,
|
|
candidate_disabled: set,
|
|
*,
|
|
active_plugins_dir: Optional[Path] = None,
|
|
extra_dirs: Iterable[Path] = (),
|
|
expected_config: str | None = None,
|
|
plugin: Optional[str] = None,
|
|
settled: Iterable[str] = (),
|
|
) -> None:
|
|
"""PM discovers and validates the proposed union under its install lock.
|
|
|
|
No config or dependency selection is written by this application process. *plugin* names the
|
|
plugin being admitted so a resolver conflict is reported against it (:class:`DependencyConflict`).
|
|
*settled* names the plugins the user just decided on, so an update never undoes that decision.
|
|
"""
|
|
from hermes_constants import get_hermes_home
|
|
from pm.client import sync_venv
|
|
from pm.plugin_inputs import Selection
|
|
|
|
home = Path(active_plugins_dir).parent if active_plugins_dir is not None else get_hermes_home()
|
|
try:
|
|
sync_venv(explicit=True, plugins=Selection({
|
|
"home": str(home.resolve()), "enabled": sorted(candidate_enabled),
|
|
"disabled": sorted(candidate_disabled), "extra_dirs": [str(Path(d).resolve()) for d in extra_dirs],
|
|
"settled": sorted(settled),
|
|
**({"expected_config": expected_config} if expected_config is not None else {}),
|
|
}))
|
|
except Exception as exc:
|
|
from pm.workspace import ResolutionConflict
|
|
|
|
if isinstance(exc, ResolutionConflict):
|
|
raise DependencyConflict(exc.cause, plugin=plugin) from exc
|
|
raise AdmissionRefused(str(exc)) from exc
|