HookCallback

Trait HookCallback 

Source
pub trait HookCallback: Send + Sync {
    // Required method
    fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        input: &'life1 HookInput,
        tool_use_id: Option<&'life2 str>,
        context: &'life3 HookContext,
    ) -> Pin<Box<dyn Future<Output = Result<HookJSONOutput, SdkError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Hook callback trait with strongly-typed inputs and outputs

This trait is used to implement custom hook callbacks that can intercept and modify Claude’s behavior at various points in the conversation.

Required Methods§

Source

fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, input: &'life1 HookInput, tool_use_id: Option<&'life2 str>, context: &'life3 HookContext, ) -> Pin<Box<dyn Future<Output = Result<HookJSONOutput, SdkError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Execute the hook with strongly-typed input and output

§Arguments
  • input - Strongly-typed hook input (discriminated union)
  • tool_use_id - Optional tool use identifier
  • context - Hook context with abort signal support
§Returns

A HookJSONOutput that controls Claude’s behavior

Implementors§