Expand description
Lifecycle hook callbacks (pre/post tool use, prompt submission, session start/end). Lifecycle hook callbacks invoked at key session points.
Hooks let you intercept and modify CLI behavior — approve or deny tool
use, rewrite user prompts, inject context at session start, and handle
errors. Implement SessionHooks and pass it to
Client::create_session.
Structs§
- Error
Occurred Input - Input for the
errorOccurredhook. - Error
Occurred Output - Output for the
errorOccurredhook. - Hook
Context - Context provided to every hook invocation.
- Post
Tool UseInput - Input for the
postToolUsehook — received after a tool executes. - Post
Tool UseOutput - Output for the
postToolUsehook. - PreTool
UseInput - Input for the
preToolUsehook — received before a tool executes. - PreTool
UseOutput - Output for the
preToolUsehook. - Session
EndInput - Input for the
sessionEndhook. - Session
EndOutput - Output for the
sessionEndhook. - Session
Start Input - Input for the
sessionStarthook. - Session
Start Output - Output for the
sessionStarthook. - User
Prompt Submitted Input - Input for the
userPromptSubmittedhook — received when the user sends a message. - User
Prompt Submitted Output - Output for the
userPromptSubmittedhook.
Enums§
- Hook
Event - Events dispatched to
SessionHooks::on_hookat CLI lifecycle points. - Hook
Output - Response from
SessionHooks::on_hookback to the SDK.
Traits§
- Session
Hooks - Callback trait for session hooks — invoked by the CLI at key lifecycle points (tool use, prompt submission, session start/end, errors).