Skip to main content

HookRunner

Defined in the runner module.
Executes hooks from a registry. Supports:
  • Python function hooks (sync and async)
  • Shell command hooks
  • Sequential and parallel execution
  • Timeout handling
  • Result aggregation

Constructor

registry
Optional
No description available.
default_timeout
float
default:"60.0"
No description available.
cwd
Optional
No description available.

Methods

Usage

registry = HookRegistry()
    runner = HookRunner(registry)
    
    # Execute hooks for an event
    results = await runner.execute(
        event=HookEvent.BEFORE_TOOL,
        input_data=BeforeToolInput(
            tool_name="write_file",
            tool_input={"path": "/tmp/test.txt"}
        )
    )
    
    # Check if any hook blocked
    if runner.is_blocked(results):
        print("Tool execution blocked by hook")