pub struct EnhancedPluginManager { /* private fields */ }plugin only.Expand description
Manages enhanced plugins with priority-based pipeline execution.
Plugins are stored sorted by priority (ascending). All pipeline methods iterate plugins in this order, passing each plugin’s output as input to the next plugin in the chain.
§Thread Safety
EnhancedPluginManager is Send + Sync and can be shared across async tasks
via Arc<EnhancedPluginManager>.
Implementations§
Source§impl EnhancedPluginManager
impl EnhancedPluginManager
Sourcepub fn new(plugins: Vec<Arc<dyn EnhancedPlugin>>) -> EnhancedPluginManager
pub fn new(plugins: Vec<Arc<dyn EnhancedPlugin>>) -> EnhancedPluginManager
Creates a new EnhancedPluginManager with the given plugins.
Plugins are sorted by priority in ascending order using a stable sort, so plugins with the same priority retain their registration order.
§Examples
use std::sync::Arc;
use adk_plugin::{EnhancedPluginManager, EnhancedPlugin};
let plugins: Vec<Arc<dyn EnhancedPlugin>> = vec![
Arc::new(MyPlugin),
];
let manager = EnhancedPluginManager::new(plugins);Sourcepub fn with_config(
plugins: Vec<Arc<dyn EnhancedPlugin>>,
config: PluginManagerConfig,
) -> EnhancedPluginManager
pub fn with_config( plugins: Vec<Arc<dyn EnhancedPlugin>>, config: PluginManagerConfig, ) -> EnhancedPluginManager
Creates a new EnhancedPluginManager with custom configuration.
Sourcepub fn add_plugin(&mut self, plugin: Arc<dyn EnhancedPlugin>)
pub fn add_plugin(&mut self, plugin: Arc<dyn EnhancedPlugin>)
Adds a plugin after construction, re-sorting by priority.
The plugin is inserted and the entire list is re-sorted using a stable sort to maintain registration order for same-priority plugins.
Sourcepub fn context(&self) -> &Arc<PluginContext> ⓘ
pub fn context(&self) -> &Arc<PluginContext> ⓘ
Returns a reference to the shared plugin context.
The context is shared across all hook invocations and persists for the lifetime of this manager.
Sourcepub fn plugin_count(&self) -> usize
pub fn plugin_count(&self) -> usize
Returns the number of registered plugins.
Sourcepub fn plugin_names(&self) -> Vec<&str>
pub fn plugin_names(&self) -> Vec<&str>
Returns the names of all registered plugins in execution order.
Sourcepub async fn run_before_tool_call(
&self,
tool: Arc<dyn Tool>,
args: Value,
ctx: Arc<dyn CallbackContext>,
) -> Result<BeforeToolCallResult, AdkError>
pub async fn run_before_tool_call( &self, tool: Arc<dyn Tool>, args: Value, ctx: Arc<dyn CallbackContext>, ) -> Result<BeforeToolCallResult, AdkError>
Executes the before_tool_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) arguments from the previous plugin.
If a plugin returns ShortCircuit, the pipeline stops and the synthetic result
is returned. If a plugin returns an error, the pipeline stops and the error
is propagated.
§Arguments
tool- The tool about to be executedargs- The initial tool call argumentsctx- The callback context for the current invocation
§Returns
Ok(BeforeToolCallResult::Continue(args))— final modified arguments for tool executionOk(BeforeToolCallResult::ShortCircuit(result))— synthetic result, skip tool executionErr(e)— pipeline error, skip tool execution
Sourcepub async fn run_after_tool_call(
&self,
tool: Arc<dyn Tool>,
args: &Value,
result: Value,
ctx: Arc<dyn CallbackContext>,
) -> Result<AfterToolCallResult, AdkError>
pub async fn run_after_tool_call( &self, tool: Arc<dyn Tool>, args: &Value, result: Value, ctx: Arc<dyn CallbackContext>, ) -> Result<AfterToolCallResult, AdkError>
Executes the after_tool_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) result from the previous plugin.
The args parameter contains the final modified arguments from the before-hook
pipeline (not the original arguments).
§Arguments
tool- The tool that was executedargs- The final arguments used for tool execution (after before-hook modifications)result- The initial tool execution resultctx- The callback context for the current invocation
§Returns
Ok(AfterToolCallResult::Continue(result))— final modified resultErr(e)— pipeline error
Sourcepub async fn run_before_model_call(
&self,
request: LlmRequest,
ctx: Arc<dyn CallbackContext>,
) -> Result<BeforeModelCallResult, AdkError>
pub async fn run_before_model_call( &self, request: LlmRequest, ctx: Arc<dyn CallbackContext>, ) -> Result<BeforeModelCallResult, AdkError>
Executes the before_model_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) request from the previous plugin.
If a plugin returns ShortCircuit, the pipeline stops and the synthetic response
is returned. If a plugin returns an error, the pipeline stops and the error
is propagated.
§Arguments
request- The initial LLM requestctx- The callback context for the current invocation
§Returns
Ok(BeforeModelCallResult::Continue(request))— final modified request for model callOk(BeforeModelCallResult::ShortCircuit(response))— synthetic response, skip model callErr(e)— pipeline error, skip model call
Sourcepub async fn run_after_model_call(
&self,
response: LlmResponse,
ctx: Arc<dyn CallbackContext>,
) -> Result<AfterModelCallResult, AdkError>
pub async fn run_after_model_call( &self, response: LlmResponse, ctx: Arc<dyn CallbackContext>, ) -> Result<AfterModelCallResult, AdkError>
Executes the after_model_call pipeline across all plugins in priority order.
Each plugin receives the (possibly modified) response from the previous plugin. If a plugin returns an error, the pipeline stops and the error is propagated.
§Arguments
response- The initial LLM responsectx- The callback context for the current invocation
§Returns
Ok(AfterModelCallResult::Continue(response))— final modified responseErr(e)— pipeline error
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EnhancedPluginManager
impl !UnwindSafe for EnhancedPluginManager
impl Freeze for EnhancedPluginManager
impl Send for EnhancedPluginManager
impl Sync for EnhancedPluginManager
impl Unpin for EnhancedPluginManager
impl UnsafeUnpin for EnhancedPluginManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.