Skip to main content

Module plugin_host

Module plugin_host 

Source
Expand description

NexoPlugin trait + PluginInitContext + lifecycle errors. The runtime contract every native Rust plugin implements.

A plugin ships as a Rust crate that:

  1. Includes a nexo-plugin.toml manifest at its crate root (parsed by nexo-plugin-manifest).
  2. Implements NexoPlugin in its public surface.
  3. Exports an Arc<dyn NexoPlugin> constructor (e.g. pub fn new() -> Arc<dyn NexoPlugin>).

[PluginRegistry] walks the workspace + user plugin dirs at boot, parses manifests, instantiates plugin handles, and calls init in deterministic order. PluginInitContext gives plugins typed handles to every daemon subsystem they may need: tool registry, advisor registry (advisory_hook), hook registry, broker, LLM registry, reload coordinator, sessions, long-term memory, shutdown signal.

Provider-agnostic: the trait + context expose no LLM-provider specifics. Plugins reach providers through LlmRegistry::build which itself is provider-agnostic.

§Distinction from existing crate::agent::plugin::Plugin

Plugin (in crate::agent::plugin) is the Channel plugin trait — runtime-side I/O for browser / WhatsApp / Telegram / email channels. NexoPlugin is the boot-time lifecycle trait — the plug-and-play registration contract. Distinct concept, distinct file, distinct trait name.

A plugin’s resources clean up when its Arc<dyn NexoPlugin> is dropped (via Rust Drop semantics) or via an explicit shutdown() call. The activation surface is just the manifest + the PluginInitContext.

Structs§

PluginInitContext
Bundle of handles a plugin’s init receives. Lifetimes tied to the boot scope; plugins that need long-lived clones must clone the Arc<...> fields explicitly.

Enums§

PluginConfigureError
Errors a plugin’s configure hook (Phase 93.2) can surface.
PluginInitError
Errors a plugin’s init can return. Boundary type — every failure mode the registry needs to discriminate is its own variant; freeform errors land in Other.
PluginShutdownError

Constants§

DEFAULT_PLUGIN_SHUTDOWN_TIMEOUT
Default per-plugin shutdown budget. The registry shutdown sequence wraps plugin.shutdown() in tokio::time::timeout at this duration so a stuck plugin can’t hold the daemon at exit.

Traits§

NexoPlugin
Lifecycle contract for native Rust plugins.