Skip to main content

Extension

Trait Extension 

Source
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§

Source

fn name(&self) -> &str

Unique name of the extension.

Source

fn description(&self) -> &str

Human-readable description.

Provided Methods§

Source

fn manifest(&self) -> ExtensionManifest

Return the extension manifest for metadata, permissions, and config.

The default implementation builds a minimal manifest from name and description.

Source

fn register_tools(&self) -> Vec<Arc<dyn AgentTool>>

Return custom tools this extension contributes.

Source

fn register_commands(&self) -> Vec<Command>

Return custom slash-commands this extension contributes.

Source

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.

Source

fn on_unload(&self)

Called when the extension is about to be unloaded.

Use this to release resources, flush buffers, or perform cleanup.

Source

fn on_message_sent(&self, _msg: &str)

Called after a user message is sent to the agent.

Source

fn on_message_received(&self, _msg: &str)

Called when an assistant message is received.

Source

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.

Source

fn on_tool_result(&self, _tool: &str, _result: &AgentToolResult)

Called after a tool finishes execution.

Source

fn on_session_start(&self, _session_id: &str)

Called when a new session starts.

Source

fn on_session_end(&self, _session_id: &str)

Called when a session ends.

Source

fn on_settings_changed(&self, _settings: &Settings)

Called when settings have changed (e.g. user ran oxi config).

Source

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.

Implementors§