pub struct HookRegistry { /* private fields */ }Expand description
Composable in-process Rust hook registry with middleware chaining and short-circuiting.
Implementations§
Source§impl HookRegistry
impl HookRegistry
Sourcepub fn before_model_step<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(BeforeModelStepContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = BeforeModelDecision> + Send + 'static,
pub fn before_model_step<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(BeforeModelStepContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = BeforeModelDecision> + Send + 'static,
Registers a before_model_step async hook.
Sourcepub fn after_model_step<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(AfterModelStepContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AfterModelDecision> + Send + 'static,
pub fn after_model_step<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(AfterModelStepContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AfterModelDecision> + Send + 'static,
Registers an after_model_step async hook.
Sourcepub fn before_tool_call<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(BeforeToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = BeforeToolDecision> + Send + 'static,
pub fn before_tool_call<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(BeforeToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = BeforeToolDecision> + Send + 'static,
Registers a before_tool_call async hook matching all tools.
Sourcepub fn before_tool_call_for<I, F, Fut>(self, tools: I, callback: F) -> Selfwhere
I: IntoIterator<Item = ToolName>,
F: Fn(BeforeToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = BeforeToolDecision> + Send + 'static,
pub fn before_tool_call_for<I, F, Fut>(self, tools: I, callback: F) -> Selfwhere
I: IntoIterator<Item = ToolName>,
F: Fn(BeforeToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = BeforeToolDecision> + Send + 'static,
Registers a before_tool_call async hook matching only tools.
Sourcepub fn after_tool_call<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(AfterToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AfterToolDecision> + Send + 'static,
pub fn after_tool_call<F, Fut>(self, callback: F) -> Selfwhere
F: Fn(AfterToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AfterToolDecision> + Send + 'static,
Registers an after_tool_call async hook matching all tools.
Sourcepub fn after_tool_call_for<I, F, Fut>(self, tools: I, callback: F) -> Selfwhere
I: IntoIterator<Item = ToolName>,
F: Fn(AfterToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AfterToolDecision> + Send + 'static,
pub fn after_tool_call_for<I, F, Fut>(self, tools: I, callback: F) -> Selfwhere
I: IntoIterator<Item = ToolName>,
F: Fn(AfterToolCallContext) -> Fut + Send + Sync + 'static,
Fut: Future<Output = AfterToolDecision> + Send + 'static,
Registers an after_tool_call async hook matching only tools.
Trait Implementations§
Source§impl Clone for HookRegistry
impl Clone for HookRegistry
Source§impl Debug for HookRegistry
impl Debug for HookRegistry
Source§impl Default for HookRegistry
impl Default for HookRegistry
Source§impl RuntimeHookHandler for HookRegistry
impl RuntimeHookHandler for HookRegistry
Source§fn subscriptions(&self) -> HookSubscriptions
fn subscriptions(&self) -> HookSubscriptions
Declares which hook points and tool names this handler cares about.
Source§fn before_model_step<'a>(
&'a self,
context: BeforeModelStepContext,
cancellation_token: CancellationToken,
) -> HookFuture<'a, BeforeModelDecision>
fn before_model_step<'a>( &'a self, context: BeforeModelStepContext, cancellation_token: CancellationToken, ) -> HookFuture<'a, BeforeModelDecision>
Intercepts execution before a model step is compiled and sent.
Source§fn after_model_step<'a>(
&'a self,
context: AfterModelStepContext,
cancellation_token: CancellationToken,
) -> HookFuture<'a, AfterModelDecision>
fn after_model_step<'a>( &'a self, context: AfterModelStepContext, cancellation_token: CancellationToken, ) -> HookFuture<'a, AfterModelDecision>
Intercepts execution after a model step finishes.
Source§fn before_tool_call<'a>(
&'a self,
context: BeforeToolCallContext,
cancellation_token: CancellationToken,
) -> HookFuture<'a, BeforeToolDecision>
fn before_tool_call<'a>( &'a self, context: BeforeToolCallContext, cancellation_token: CancellationToken, ) -> HookFuture<'a, BeforeToolDecision>
Intercepts a tool call before execution.
Source§fn after_tool_call<'a>(
&'a self,
context: AfterToolCallContext,
cancellation_token: CancellationToken,
) -> HookFuture<'a, AfterToolDecision>
fn after_tool_call<'a>( &'a self, context: AfterToolCallContext, cancellation_token: CancellationToken, ) -> HookFuture<'a, AfterToolDecision>
Intercepts a tool call after execution, before durable commit.
Auto Trait Implementations§
impl !RefUnwindSafe for HookRegistry
impl !UnwindSafe for HookRegistry
impl Forget for HookRegistry
impl Freeze for HookRegistrywhere
*const u8 is !null: Freeze,
PhantomData<Arc<dyn Fn(BeforeModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeModelDecision, HookError>> + Send>> + Sync + Send>>: Freeze,
PhantomData<Arc<dyn Fn(AfterModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterModelDecision, HookError>> + Send>> + Sync + Send>>: Freeze,
PhantomData<FilteredToolHook<Arc<dyn Fn(BeforeToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeToolDecision, HookError>> + Send>> + Sync + Send>>>: Freeze,
PhantomData<FilteredToolHook<Arc<dyn Fn(AfterToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterToolDecision, HookError>> + Send>> + Sync + Send>>>: Freeze,
impl Move for HookRegistry
impl Send for HookRegistrywhere
RawVecInner: Send,
Arc<dyn Fn(BeforeModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeModelDecision, HookError>> + Send>> + Sync + Send>: Send,
Arc<dyn Fn(AfterModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterModelDecision, HookError>> + Send>> + Sync + Send>: Send,
NodeRef<Owned, ToolName, SetValZST, LeafOrInternal>: Send,
BoxRaw<(ToolName, SetValZST)>: Send,
Arc<dyn Fn(BeforeToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeToolDecision, HookError>> + Send>> + Sync + Send>: Send,
Arc<dyn Fn(AfterToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterToolDecision, HookError>> + Send>> + Sync + Send>: Send,
impl Sync for HookRegistrywhere
RawVecInner: Sync,
Arc<dyn Fn(BeforeModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeModelDecision, HookError>> + Send>> + Sync + Send>: Sync,
Arc<dyn Fn(AfterModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterModelDecision, HookError>> + Send>> + Sync + Send>: Sync,
NodeRef<Owned, ToolName, SetValZST, LeafOrInternal>: Sync,
BoxRaw<(ToolName, SetValZST)>: Sync,
Arc<dyn Fn(BeforeToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeToolDecision, HookError>> + Send>> + Sync + Send>: Sync,
Arc<dyn Fn(AfterToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterToolDecision, HookError>> + Send>> + Sync + Send>: Sync,
impl Unpin for HookRegistrywhere
*const u8 is !null: Unpin,
Arc<dyn Fn(BeforeModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeModelDecision, HookError>> + Send>> + Sync + Send>: Unpin,
Arc<dyn Fn(AfterModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterModelDecision, HookError>> + Send>> + Sync + Send>: Unpin,
*const LeafNode<ToolName, SetValZST> is !null: Unpin,
Box<(ToolName, SetValZST)>: Unpin,
Arc<dyn Fn(BeforeToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeToolDecision, HookError>> + Send>> + Sync + Send>: Unpin,
Arc<dyn Fn(AfterToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterToolDecision, HookError>> + Send>> + Sync + Send>: Unpin,
impl UnsafeUnpin for HookRegistrywhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Arc<dyn Fn(BeforeModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeModelDecision, HookError>> + Send>> + Sync + Send>>: UnsafeUnpin,
PhantomData<Arc<dyn Fn(AfterModelStepContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterModelDecision, HookError>> + Send>> + Sync + Send>>: UnsafeUnpin,
PhantomData<FilteredToolHook<Arc<dyn Fn(BeforeToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<BeforeToolDecision, HookError>> + Send>> + Sync + Send>>>: UnsafeUnpin,
PhantomData<FilteredToolHook<Arc<dyn Fn(AfterToolCallContext, CancellationToken) -> Pin<Box<dyn Future<Output = Result<AfterToolDecision, HookError>> + Send>> + Sync + Send>>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more