pub struct ExtensionRegistry { /* private fields */ }Expand description
Manages a collection of loaded extensions.
Supports:
- Registering / unregistering extensions by name
- Enabling / disabling at runtime
- Hot-reloading from the original source path
- Broadcasting events to all enabled extensions with graceful error handling
- Collecting tools and commands from enabled extensions
Implementations§
Source§impl ExtensionRegistry
impl ExtensionRegistry
Sourcepub fn register(&mut self, ext: Arc<dyn Extension>)
pub fn register(&mut self, ext: Arc<dyn Extension>)
Register an extension (in-memory).
If an extension with the same name already exists it is replaced.
Sourcepub fn register_with_library(
&mut self,
ext: Arc<dyn Extension>,
source_path: PathBuf,
library: Library,
)
pub fn register_with_library( &mut self, ext: Arc<dyn Extension>, source_path: PathBuf, library: Library, )
Register an extension that was loaded from a shared library, keeping the library handle alive for hot-reload.
Sourcepub fn unregister(&mut self, name: &str) -> bool
pub fn unregister(&mut self, name: &str) -> bool
Unregister an extension by name.
Calls on_unload on the extension before removing it.
Returns false if the extension was not found.
Sourcepub fn disable(&mut self, name: &str) -> Result<(), ExtensionError>
pub fn disable(&mut self, name: &str) -> Result<(), ExtensionError>
Disable an extension at runtime.
Disabled extensions are skipped during event broadcasting and tool/command collection, but remain loaded.
Sourcepub fn enable(
&mut self,
name: &str,
ctx: &ExtensionContext,
) -> Result<(), ExtensionError>
pub fn enable( &mut self, name: &str, ctx: &ExtensionContext, ) -> Result<(), ExtensionError>
Enable a previously disabled extension.
Sourcepub fn is_enabled(&self, name: &str) -> bool
pub fn is_enabled(&self, name: &str) -> bool
Check whether an extension is currently enabled.
Sourcepub fn hot_reload(
&mut self,
name: &str,
ctx: &ExtensionContext,
) -> Result<(), ExtensionError>
pub fn hot_reload( &mut self, name: &str, ctx: &ExtensionContext, ) -> Result<(), ExtensionError>
Hot-reload an extension from its original source path.
The old extension is unloaded, the shared library is re-opened, and the new extension is loaded in its place. Tools and commands from the old extension are no longer returned.
Sourcepub fn all_tools(&self) -> Vec<Arc<dyn AgentTool>>
pub fn all_tools(&self) -> Vec<Arc<dyn AgentTool>>
Collect all tools from every enabled extension.
Sourcepub fn all_commands(&self) -> Vec<Command>
pub fn all_commands(&self) -> Vec<Command>
Collect all commands from every enabled extension.
Sourcepub fn emit_load(&self, ctx: &ExtensionContext)
pub fn emit_load(&self, ctx: &ExtensionContext)
Broadcast on_load to all enabled extensions.
Sourcepub fn emit_unload(&self)
pub fn emit_unload(&self)
Broadcast on_unload to all enabled extensions.
Sourcepub fn emit_message_sent(&self, msg: &str)
pub fn emit_message_sent(&self, msg: &str)
Broadcast on_message_sent to all enabled extensions.
Sourcepub fn emit_message_received(&self, msg: &str)
pub fn emit_message_received(&self, msg: &str)
Broadcast on_message_received to all enabled extensions.
Sourcepub fn emit_tool_call(&self, tool: &str, params: &Value)
pub fn emit_tool_call(&self, tool: &str, params: &Value)
Broadcast on_tool_call to all enabled extensions.
Sourcepub fn emit_tool_result(&self, tool: &str, result: &AgentToolResult)
pub fn emit_tool_result(&self, tool: &str, result: &AgentToolResult)
Broadcast on_tool_result to all enabled extensions.
Sourcepub fn emit_session_start(&self, session_id: &str)
pub fn emit_session_start(&self, session_id: &str)
Broadcast on_session_start to all enabled extensions.
Sourcepub fn emit_session_end(&self, session_id: &str)
pub fn emit_session_end(&self, session_id: &str)
Broadcast on_session_end to all enabled extensions.
Sourcepub fn emit_settings_changed(&self, settings: &Settings)
pub fn emit_settings_changed(&self, settings: &Settings)
Broadcast on_settings_changed to all enabled extensions.
Sourcepub fn emit_event(&self, event: &AgentEvent)
pub fn emit_event(&self, event: &AgentEvent)
Broadcast an agent event to every enabled extension.
Sourcepub fn get(&self, name: &str) -> Option<Arc<dyn Extension>>
pub fn get(&self, name: &str) -> Option<Arc<dyn Extension>>
Get a reference to an extension by name.
Sourcepub fn extensions(&self) -> impl Iterator<Item = &Arc<dyn Extension>>
pub fn extensions(&self) -> impl Iterator<Item = &Arc<dyn Extension>>
Iterate over registered extensions.
Sourcepub fn manifest(&self, name: &str) -> Option<ExtensionManifest>
pub fn manifest(&self, name: &str) -> Option<ExtensionManifest>
Get the manifest for an extension by name.
Sourcepub fn errors(&self) -> Vec<ExtensionErrorRecord>
pub fn errors(&self) -> Vec<ExtensionErrorRecord>
Get all recorded errors.
Sourcepub fn clear_errors(&self)
pub fn clear_errors(&self)
Clear all recorded errors.
Trait Implementations§
Source§impl Debug for ExtensionRegistry
impl Debug for ExtensionRegistry
Auto Trait Implementations§
impl Freeze for ExtensionRegistry
impl !RefUnwindSafe for ExtensionRegistry
impl Send for ExtensionRegistry
impl Sync for ExtensionRegistry
impl Unpin for ExtensionRegistry
impl UnsafeUnpin for ExtensionRegistry
impl !UnwindSafe for ExtensionRegistry
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().