pub trait Extension: Send + Sync {
Show 15 methods
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
// Provided methods
fn manifest(&self) -> ExtensionManifest { ... }
fn register_tools(&self) -> Vec<Arc<dyn AgentTool>> { ... }
fn register_commands(&self) -> Vec<Command> { ... }
fn on_load(&self, _ctx: &ExtensionContext) { ... }
fn on_unload(&self) { ... }
fn on_message_sent(&self, _msg: &str) { ... }
fn on_message_received(&self, _msg: &str) { ... }
fn on_tool_call(&self, _tool: &str, _params: &Value) { ... }
fn on_tool_result(&self, _tool: &str, _result: &AgentToolResult) { ... }
fn on_session_start(&self, _session_id: &str) { ... }
fn on_session_end(&self, _session_id: &str) { ... }
fn on_settings_changed(&self, _settings: &Settings) { ... }
fn on_event(&self, _event: &AgentEvent) { ... }
}Expand description
Core trait that every oxi extension must implement.
Extensions can register custom tools, custom slash-commands, hook into the agent event stream, and respond to lifecycle events.
All lifecycle hooks provide default no-op implementations so that extensions only need to override the hooks they care about.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description.
Provided Methods§
Sourcefn manifest(&self) -> ExtensionManifest
fn manifest(&self) -> ExtensionManifest
Return the extension manifest for metadata, permissions, and config.
The default implementation builds a minimal manifest from
name and description.
Sourcefn register_tools(&self) -> Vec<Arc<dyn AgentTool>>
fn register_tools(&self) -> Vec<Arc<dyn AgentTool>>
Return custom tools this extension contributes.
Sourcefn register_commands(&self) -> Vec<Command>
fn register_commands(&self) -> Vec<Command>
Return custom slash-commands this extension contributes.
Sourcefn on_load(&self, _ctx: &ExtensionContext)
fn on_load(&self, _ctx: &ExtensionContext)
Called once when the extension is loaded and before any other hooks.
Use this to perform initialization such as reading configuration, establishing connections, or validating permissions.
Sourcefn on_unload(&self)
fn on_unload(&self)
Called when the extension is about to be unloaded.
Use this to release resources, flush buffers, or perform cleanup.
Sourcefn on_message_sent(&self, _msg: &str)
fn on_message_sent(&self, _msg: &str)
Called after a user message is sent to the agent.
Sourcefn on_message_received(&self, _msg: &str)
fn on_message_received(&self, _msg: &str)
Called when an assistant message is received.
Sourcefn on_tool_call(&self, _tool: &str, _params: &Value)
fn on_tool_call(&self, _tool: &str, _params: &Value)
Called before a tool is executed. The tool name and raw parameters are provided. This can be used for logging, auditing, or preprocessing.
Sourcefn on_tool_result(&self, _tool: &str, _result: &AgentToolResult)
fn on_tool_result(&self, _tool: &str, _result: &AgentToolResult)
Called after a tool finishes execution.
Sourcefn on_session_start(&self, _session_id: &str)
fn on_session_start(&self, _session_id: &str)
Called when a new session starts.
Sourcefn on_session_end(&self, _session_id: &str)
fn on_session_end(&self, _session_id: &str)
Called when a session ends.
Sourcefn on_settings_changed(&self, _settings: &Settings)
fn on_settings_changed(&self, _settings: &Settings)
Called when settings have changed (e.g. user ran oxi config).
Sourcefn on_event(&self, _event: &AgentEvent)
fn on_event(&self, _event: &AgentEvent)
Called when the agent emits an event.
This is the low-level catch-all. Prefer the typed hooks above when possible.