Skip to main content

HookCallback

Type Alias HookCallback 

Source
pub type HookCallback = Arc<dyn Fn(HookInput, Option<String>, CancellationToken) -> Pin<Box<dyn Future<Output = Result<HookOutput>> + Send>> + Send + Sync>;
Expand description

Type alias for hook callback functions.

A hook callback receives:

  • input: typed hook input data
  • tool_use_id: optional correlation ID for tool-related hooks
  • cancellation: a tokio CancellationToken for aborting

Returns a HookOutput that controls the agent’s behavior.

§Example

use starpod_hooks::{hook_fn, HookInput, HookOutput};

let callback = hook_fn(|input, _tool_use_id, _cancel| async move {
    println!("Hook fired for: {}", input.event_name());
    Ok(HookOutput::default())
});

Aliased Type§

pub struct HookCallback { /* private fields */ }