pub struct HookRegistry { /* private fields */ }Expand description
Registry of lifecycle hooks with typed registration and timeout enforcement.
Implementations§
Source§impl HookRegistry
impl HookRegistry
Sourcepub fn on_pre_tool_use<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_pre_tool_use<F>(&mut self, matcher: HookMatcher, f: F)
Register a pre-tool-use hook.
Sourcepub fn on_post_tool_use<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_post_tool_use<F>(&mut self, matcher: HookMatcher, f: F)
Register a post-tool-use hook.
Sourcepub fn on_post_tool_use_failure<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_post_tool_use_failure<F>(&mut self, matcher: HookMatcher, f: F)
Register a post-tool-use failure hook.
Sourcepub fn on_notification<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_notification<F>(&mut self, matcher: HookMatcher, f: F)
Register a notification hook.
Sourcepub fn on_subagent_start<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_subagent_start<F>(&mut self, matcher: HookMatcher, f: F)
Register a subagent start hook.
Sourcepub fn on_subagent_stop<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_subagent_stop<F>(&mut self, matcher: HookMatcher, f: F)
Register a subagent stop hook.
Sourcepub fn on_pre_compact<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_pre_compact<F>(&mut self, matcher: HookMatcher, f: F)
Register a pre-compact hook.
Sourcepub fn on_post_compact<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_post_compact<F>(&mut self, matcher: HookMatcher, f: F)
Register a post-compact hook.
Sourcepub fn on_session_start<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_session_start<F>(&mut self, matcher: HookMatcher, f: F)
Register a session start hook.
Sourcepub fn on_session_end<F>(&mut self, matcher: HookMatcher, f: F)
pub fn on_session_end<F>(&mut self, matcher: HookMatcher, f: F)
Register a session end hook.
Sourcepub async fn run_pre_tool_use(
&self,
ctx: PreToolUseContext,
) -> Result<HookResult, AgentError>
pub async fn run_pre_tool_use( &self, ctx: PreToolUseContext, ) -> Result<HookResult, AgentError>
Run all matching pre-tool-use hooks in registration order.
Returns the first Abort result encountered, or Continue if all pass.
Hooks that exceed their timeout are skipped with a warn! log.
Sourcepub async fn run_post_tool_use(
&self,
ctx: PostToolUseContext,
) -> Result<HookResult, AgentError>
pub async fn run_post_tool_use( &self, ctx: PostToolUseContext, ) -> Result<HookResult, AgentError>
Run all matching post-tool-use hooks.
Sourcepub async fn run_post_tool_use_failure(
&self,
ctx: PostToolUseFailureContext,
) -> Result<HookResult, AgentError>
pub async fn run_post_tool_use_failure( &self, ctx: PostToolUseFailureContext, ) -> Result<HookResult, AgentError>
Run all matching post-tool-use failure hooks.
Sourcepub async fn run_notification(
&self,
ctx: NotificationContext,
) -> Result<HookResult, AgentError>
pub async fn run_notification( &self, ctx: NotificationContext, ) -> Result<HookResult, AgentError>
Run all notification hooks.
Sourcepub async fn run_session_start(
&self,
ctx: SessionStartContext,
) -> Result<HookResult, AgentError>
pub async fn run_session_start( &self, ctx: SessionStartContext, ) -> Result<HookResult, AgentError>
Run all session start hooks.
Sourcepub async fn run_session_end(
&self,
ctx: SessionEndContext,
) -> Result<HookResult, AgentError>
pub async fn run_session_end( &self, ctx: SessionEndContext, ) -> Result<HookResult, AgentError>
Run all session end hooks.
Sourcepub async fn run_subagent_start(
&self,
ctx: SubagentStartContext,
) -> Result<HookResult, AgentError>
pub async fn run_subagent_start( &self, ctx: SubagentStartContext, ) -> Result<HookResult, AgentError>
Run all subagent start hooks.
Sourcepub async fn run_subagent_stop(
&self,
ctx: SubagentStopContext,
) -> Result<HookResult, AgentError>
pub async fn run_subagent_stop( &self, ctx: SubagentStopContext, ) -> Result<HookResult, AgentError>
Run all subagent stop hooks.
Sourcepub async fn run_pre_compact(
&self,
ctx: PreCompactContext,
) -> Result<HookResult, AgentError>
pub async fn run_pre_compact( &self, ctx: PreCompactContext, ) -> Result<HookResult, AgentError>
Run all pre-compact hooks.
Sourcepub async fn run_post_compact(
&self,
ctx: PostCompactContext,
) -> Result<HookResult, AgentError>
pub async fn run_post_compact( &self, ctx: PostCompactContext, ) -> Result<HookResult, AgentError>
Run all post-compact hooks.