Holds an agent's hooks, finds the ones that match an event, and runs them.
Each agent has its own registry in agent$hooks; add hooks with
agent$add_hook().
Methods
HookRegistry$get_hooks()
Get the hooks that match an event.
Arguments
eventA HookEvent.
tool_nameOptional tool name to match against hook patterns.
Returns
A list of HookMatcher objects.
HookRegistry$fire()
Run the matching hooks in the order they were added and return the
first non-NULL result. Later hooks don't run.
A failing callback is recorded in last_errors(). For PreToolUse the
failure denies the tool call; for other events it is reported and the
next hook runs.
Arguments
eventA HookEvent.
tool_nameOptional tool name, matched against hook patterns and passed to the callback.
...Other arguments for the callback.
HookRegistry$last_errors()
Get the errors raised by hook callbacks since the registry was created or last cleared. Use it to check logging hooks, whose failures don't stop the run.