Skip to main content

Module hooks

Module hooks 

Source
Expand description

Hook registry — async Rust closures for all 33 hook event types.

Build it before spawning and pass it in SessionOptions::hooks: the CLI learns which hooks exist only from the initialize request, so hooks registered after spawn would never fire.

Each on() call becomes one matcher with one callback id hook_<n>; when the hook fires the CLI sends hook_callback { callback_id: "hook_<n>" }. Source: claude_agent_sdk 0.1.48 _internal/query.py:128–147, :285–300

Structs§

HookRegistry
Registry of async hook handlers. Cheap to clone.