mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-10-20 05:15:31 +00:00
refactor(runtime): consolidate Relay lifecycle ownership
Signed-off-by: Alex Fournier <afournier@nvidia.com>
This commit is contained in:
parent
9bc521b138
commit
4dedaa4237
33 changed files with 1648 additions and 1747 deletions
|
|
@ -2047,32 +2047,10 @@ def discover_plugins(force: bool = False) -> None:
|
|||
|
||||
|
||||
def invoke_hook(hook_name: str, **kwargs: Any) -> List[Any]:
|
||||
"""Invoke a lifecycle hook on built-in observers and loaded plugins.
|
||||
"""Invoke a lifecycle hook on loaded plugins.
|
||||
|
||||
Returns a list of non-``None`` return values from plugin callbacks.
|
||||
"""
|
||||
if hook_name == "on_session_start":
|
||||
try:
|
||||
from hermes_cli.observability import prepare_lifecycle
|
||||
|
||||
prepare_lifecycle(hook_name, **kwargs)
|
||||
except Exception:
|
||||
logger.warning("Built-in observability preparation failed", exc_info=True)
|
||||
results = get_plugin_manager().invoke_hook(hook_name, **kwargs)
|
||||
try:
|
||||
from hermes_cli.observability import observe_lifecycle
|
||||
|
||||
observe_lifecycle(hook_name, **kwargs)
|
||||
except Exception:
|
||||
logger.warning("Built-in observability hook failed", exc_info=True)
|
||||
return results
|
||||
|
||||
try:
|
||||
from hermes_cli.observability import observe_lifecycle
|
||||
|
||||
observe_lifecycle(hook_name, **kwargs)
|
||||
except Exception:
|
||||
logger.warning("Built-in observability hook failed", exc_info=True)
|
||||
return get_plugin_manager().invoke_hook(hook_name, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -2094,14 +2072,7 @@ def has_middleware(kind: str) -> bool:
|
|||
|
||||
|
||||
def has_hook(hook_name: str) -> bool:
|
||||
"""Return True when a built-in observer or plugin handles a hook."""
|
||||
try:
|
||||
from hermes_cli.observability import handles_hook
|
||||
|
||||
if handles_hook(hook_name):
|
||||
return True
|
||||
except Exception:
|
||||
logger.warning("Unable to inspect built-in shared-metrics hooks", exc_info=True)
|
||||
"""Return True when a loaded plugin handles a hook."""
|
||||
return get_plugin_manager().has_hook(hook_name)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue