Skip to main content

Plugin

Trait Plugin 

Source
pub trait Plugin: Send + Sync {
    // Required method
    fn name(&self) -> &str;

    // Provided methods
    fn on_user_message<'a>(
        &'a self,
        _input: &'a PluginInput,
        _state: &'a PluginStateMap,
    ) -> BoxFuture<'a, Vec<Directive>> { ... }
    fn on_event<'a>(
        &'a self,
        _event: &'a AgentEvent,
        _state: &'a PluginStateMap,
    ) -> BoxFuture<'a, Vec<Directive>> { ... }
    fn before_run<'a>(
        &'a self,
        _state: &'a PluginStateMap,
    ) -> BoxFuture<'a, Vec<Directive>> { ... }
    fn after_run<'a>(
        &'a self,
        _state: &'a PluginStateMap,
    ) -> BoxFuture<'a, Vec<Directive>> { ... }
    fn signal_routes(&self) -> Vec<SignalRoute> { ... }
    fn tools(&self) -> Vec<Arc<dyn Tool>> { ... }
}
Expand description

Plugin lifecycle trait.

All methods have default no-op implementations so plugins only need to override the hooks they care about.

Required Methods§

Source

fn name(&self) -> &str

Plugin name (used for debugging and logging).

Provided Methods§

Source

fn on_user_message<'a>( &'a self, _input: &'a PluginInput, _state: &'a PluginStateMap, ) -> BoxFuture<'a, Vec<Directive>>

Called when a user message arrives.

Source

fn on_event<'a>( &'a self, _event: &'a AgentEvent, _state: &'a PluginStateMap, ) -> BoxFuture<'a, Vec<Directive>>

Called when an agent event is emitted.

Source

fn before_run<'a>( &'a self, _state: &'a PluginStateMap, ) -> BoxFuture<'a, Vec<Directive>>

Called before each agent run loop iteration.

Source

fn after_run<'a>( &'a self, _state: &'a PluginStateMap, ) -> BoxFuture<'a, Vec<Directive>>

Called after each agent run loop iteration.

Source

fn signal_routes(&self) -> Vec<SignalRoute>

Signal routes contributed by this plugin.

Source

fn tools(&self) -> Vec<Arc<dyn Tool>>

Tools contributed by this plugin.

Called once during agent construction. The returned tools are merged into the agent’s tool registry alongside any tools provided directly via Agent::with_tools. Tool names must not conflict.

Implementors§