pub struct PluginInitContext<'a> {Show 15 fields
pub config_dir: &'a Path,
pub state_root: &'a Path,
pub tool_registry: Arc<ScopedToolRegistry>,
pub advisor_registry: Arc<RwLock<AdvisorRegistry>>,
pub hook_registry: Arc<HookRegistry>,
pub broker: AnyBroker,
pub llm_registry: Arc<LlmRegistry>,
pub llm_config: Arc<LlmConfig>,
pub reload_coord: Arc<ConfigReloadCoordinator>,
pub sessions: Arc<SessionManager>,
pub long_term_memory: Option<Arc<LongTermMemory>>,
pub shutdown: CancellationToken,
pub channel_adapter_registry: Arc<ChannelAdapterRegistry>,
pub plugin_config: Arc<Value>,
pub sandbox: Arc<SandboxRunner>,
}Expand description
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.
Fields§
§config_dir: &'a PathResolved YAML config root. The plugin’s own config
namespace lives at <config_dir>/plugins/<plugin_id>/
— use plugin_config_dir.
state_root: &'a PathProcess-wide state root (NEXO_STATE_ROOT env or XDG
default). The plugin’s own state namespace lives at
<state_root>/plugins/<plugin_id>/ — use
plugin_state_dir.
tool_registry: Arc<ScopedToolRegistry>Per-plugin scoped tool registry. Plugin registers
<plugin_id>_* tools here. Names MUST match
manifest.tools.expose and respect the reserved-prefix
denylist; collisions are always rejected. See
ScopedToolRegistry for the enforcement model.
advisor_registry: Arc<RwLock<AdvisorRegistry>>Advisor registry (advisory_hook). RwLock so multiple
plugins can register without contention. Plugin acquires
a write lock per registration:
ctx.advisor_registry.write().await.register(...).
hook_registry: Arc<HookRegistry>Hook registry. For per-message lifecycle
extensions (before_message / after_message).
broker: AnyBrokerNATS broker handle. Plugin publishes/subscribes via
broker.publish(topic, payload).await.
llm_registry: Arc<LlmRegistry>LLM provider builder. Plugin builds clients via
llm_registry.build(&cfg.llm, &model_cfg)?.
llm_config: Arc<LlmConfig>LLM config the registry needs at build
time (provider table with API keys, retry knobs, tenant
overrides). Subprocess plugins (SubprocessNexoPlugin)
pair this with llm_registry to construct LlmServices
for the llm.complete JSON-RPC handler. In-tree plugins
that build their own clients also use it.
reload_coord: Arc<ConfigReloadCoordinator>Reload coordinator. Plugin registers post-hooks
via reload_coord.register_post_hook(Box::new(...)).await
for hot-reload-aware behavior.
sessions: Arc<SessionManager>Process-shared session manager.
long_term_memory: Option<Arc<LongTermMemory>>Long-term memory (None when not configured by operator).
Plugins that declare
manifest.requires.nexo_capabilities = ["long_term_memory"]
should validate this is Some and return
PluginInitError::MissingNexoCapability otherwise.
shutdown: CancellationTokenDaemon-wide shutdown signal. Plugin’s background tasks
should tokio::select! on this to exit cleanly.
channel_adapter_registry: Arc<ChannelAdapterRegistry>Extension point for plugins shipping new
channel kinds (SMS, Discord, IRC, Matrix, custom webhooks).
Plugin’s init() calls
ctx.channel_adapter_registry.register(Arc::new(MyAdapter), self.manifest().plugin.id.clone())?;
First-registers-wins-rest-rejected — see
crate::agent::channel_adapter::ChannelAdapterRegistrationError.
plugin_config: Arc<Value>Pre-loaded + pre-validated plugin config
from <config_dir>/plugins/<plugin_id>/*.yaml. Always at
least an empty mapping. Plugin treats it as read-only;
typed views via serde_yaml::from_value(cfg.clone()).
Validation errors short-circuit init() with
InitOutcome::Failed BEFORE the plugin runs.
sandbox: Arc<SandboxRunner>Shared sandbox runner. Subprocess plugin
adapters consume this at spawn time to wrap the child
Command with bwrap argv when the plugin’s manifest
declares [plugin.sandbox] enabled = true. In-tree
plugins ignore the field. Built once by
SubprocessRuntime at boot.
Implementations§
Source§impl PluginInitContext<'_>
impl PluginInitContext<'_>
Sourcepub fn plugin_config_dir(&self, plugin_id: &str) -> PathBuf
pub fn plugin_config_dir(&self, plugin_id: &str) -> PathBuf
<config_dir>/plugins/<plugin_id>/. Plugin-scoped config
namespace (the config loader reads this dir).
Sourcepub fn plugin_state_dir(&self, plugin_id: &str) -> PathBuf
pub fn plugin_state_dir(&self, plugin_id: &str) -> PathBuf
<state_root>/plugins/<plugin_id>/. Plugin-scoped state
namespace (databases, caches, etc).
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for PluginInitContext<'a>
impl<'a> !UnwindSafe for PluginInitContext<'a>
impl<'a> Freeze for PluginInitContext<'a>
impl<'a> Send for PluginInitContext<'a>
impl<'a> Sync for PluginInitContext<'a>
impl<'a> Unpin for PluginInitContext<'a>
impl<'a> UnsafeUnpin for PluginInitContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more