Skip to main content
Singleton plugin manager wrapper with session-tag filtering.

Functions

FUNC has_plugins

has_plugins(hook_type: HookType | None = None) -> bool
Fast check: are plugins configured and available for the given hook type. When hook_type is provided, also checks whether any plugin has registered a handler for that specific hook, enabling callers to skip payload construction entirely when no plugin subscribes.

FUNC get_plugin_manager

get_plugin_manager() -> Any | None
Returns the initialized PluginManager, or None if plugins are not configured.

FUNC ensure_plugin_manager

ensure_plugin_manager() -> Any
Lazily initialize the PluginManager if not already created.

FUNC initialize_plugins

initialize_plugins(config_path: str | None = None) -> Any
Initialize the PluginManager with Mellea hook registrations and optional YAML config. Args:
  • config_path: Optional path to a YAML plugin configuration file.
  • timeout: Maximum execution time per plugin in seconds.

FUNC shutdown_plugins

shutdown_plugins() -> None
Shut down the PluginManager and reset all state.

FUNC track_session_plugin

track_session_plugin(session_id: str, plugin_name: str) -> None
Track a plugin as belonging to a session for later deregistration.

FUNC deregister_session_plugins

deregister_session_plugins(session_id: str) -> None
Deregister all plugins scoped to the given session.

FUNC invoke_hook

invoke_hook(hook_type: HookType, payload: MelleaBasePayload, **context_fields: Any) -> tuple[Any | None, MelleaBasePayload]
Invoke a hook if plugins are configured. Returns (result, possibly-modified-payload). If plugins are not configured, returns (None, original_payload) immediately. Three layers of no-op guards ensure zero overhead when plugins are not configured:
  1. _plugins_enabled boolean — single pointer dereference
  2. has_hooks_for(hook_type) — skips when no plugin subscribes
  3. Returns immediately when either guard fails