Skip to main content

on

Method
This is a method of the HookRegistry class in the registry module.
Decorator to register a function as a hook.

Signature

def on(event: HookEvent, matcher: Optional[str], sequential: bool, timeout: float) -> Callable

Parameters

event
HookEvent
required
The event to hook
matcher
Optional
Optional regex pattern to match targets
sequential
bool
default:"False"
Whether to run sequentially
timeout
float
default:"60.0"
Timeout in seconds

Returns

Returns
Callable
Decorator function

Usage

@registry.on(HookEvent.BEFORE_TOOL)
    def my_hook(event_data):
        return HookResult.allow()