Skip to main content

HookDefinition

Defined in the hooks module.
Rust AI Agent SDK Hook definition

Fields

NameTypeDescription
idStringUnique ID
eventHookEventEvent to hook
matcherOption<String>Optional matcher pattern (regex for tool names, etc.)
funcHookFnHook function
enabledboolWhether hook is enabled
nameOption<String>Hook name (for debugging)

Methods

new

fn new(
        event: HookEvent,
        func: impl Fn(&HookInput) -> HookResult + Send + Sync + 'static,
    ) -> Self
Create a new hook definition Parameters:
NameType
eventHookEvent
funcimpl Fn(&HookInput

with_matcher

fn with_matcher(mut self, pattern: impl Into<String>) -> Self
Set matcher pattern Parameters:
NameType
patternimpl Into&lt;String&gt;

with_name

fn with_name(mut self, name: impl Into<String>) -> Self
Set name Parameters:
NameType
nameimpl Into&lt;String&gt;

matches

fn matches(&self, target: &str) -> bool
Check if this hook matches the target Parameters:
NameType
target&str

execute

fn execute(&self, input: &HookInput) -> HookResult
Execute the hook Parameters:
NameType
input&HookInput

Source

View on GitHub

praisonai/src/hooks/mod.rs at line 285