pub struct ExtensionRegistry { /* private fields */ }Expand description
Registry that manages extensions and provides integration wrappers.
Extensions are registered before the agent loop starts. Once hooks or event
sinks are wrapped via wrap_hooks or
wrap_event_sink, the registry should not be
modified further.
Implementations§
Source§impl ExtensionRegistry
impl ExtensionRegistry
Sourcepub fn register(
&mut self,
ext: Box<dyn Extension>,
) -> Result<(), ExtensionError>
pub fn register( &mut self, ext: Box<dyn Extension>, ) -> Result<(), ExtensionError>
Register an extension.
Returns an error if an extension with the same name already exists.
Returns ExtensionError::RegistryLocked if called after
wrap_hooks() or wrap_event_sink() has been called (i.e., the
extension list is shared).
Sourcepub fn collect_tools(&self) -> Vec<Box<dyn Tool>>
pub fn collect_tools(&self) -> Vec<Box<dyn Tool>>
Collect all tools from all registered extensions.
Sourcepub fn collect_providers(&self) -> Vec<Box<dyn Provider>>
pub fn collect_providers(&self) -> Vec<Box<dyn Provider>>
Collect all custom providers from all registered extensions.
Each extension’s providers method is called
and the results are concatenated. Extensions should return fresh
provider instances since Box<dyn Provider> is not Clone.
Sourcepub fn collect_model_overrides(&self) -> Vec<(String, ModelInfo)>
pub fn collect_model_overrides(&self) -> Vec<(String, ModelInfo)>
Collect all model overrides from all registered extensions.
Each extension’s model_overrides method
is called and the results are concatenated.
Sourcepub fn dispatch_event(&self, event: &AgentEvent)
pub fn dispatch_event(&self, event: &AgentEvent)
Dispatch an event to all registered extensions.
Sourcepub async fn dispatch_command(
&self,
command: &ExtensionCommand,
) -> Result<Option<Value>, ExtensionError>
pub async fn dispatch_command( &self, command: &ExtensionCommand, ) -> Result<Option<Value>, ExtensionError>
Dispatch a custom command to extensions in registration order.
Returns the first Some response, or None if no extension handled
the command.
Sourcepub fn serialize_states(&self) -> Result<Value, ExtensionError>
pub fn serialize_states(&self) -> Result<Value, ExtensionError>
Serialize all extension states into a JSON object keyed by extension name.
Sourcepub fn restore_states(&self, states: Value) -> Result<(), ExtensionError>
pub fn restore_states(&self, states: Value) -> Result<(), ExtensionError>
Restore extension states from a JSON object keyed by extension name.
Sourcepub fn wrap_hooks(&self, base: Box<dyn AgentHooks>) -> Box<dyn AgentHooks>
pub fn wrap_hooks(&self, base: Box<dyn AgentHooks>) -> Box<dyn AgentHooks>
Create a composite AgentHooks that wraps the base hooks with
extension lifecycle callbacks.
Extension hooks are called after the base hooks. If any extension
returns ExtensionHookResult::Block, the chain stops and the block
propagates as a denial.
Sourcepub fn wrap_event_sink(&self, base_sink: AgentEventSink) -> AgentEventSink
pub fn wrap_event_sink(&self, base_sink: AgentEventSink) -> AgentEventSink
Wrap an event sink to dispatch events to all registered extensions before forwarding to the base sink.