Expand description
Hook callbacks - 10 hook kinds dispatched by opaque callback_id.
SDK’s HookMatcher / HookContext machinery. Callbacks
are registered at initialize time; the CLI emits hook_callback
control_requests with an opaque callback_id (minted by the SDK) plus
an input payload whose hook_event_name discriminates concrete types.
Wire-shape data (HookKind, HookContext, all *Input/*Output
structs) lives in forge-primitives, re-exported here. The callback
machinery (HookCallback trait, ErasedHookCallback,
Hooks/HooksBuilder registry) stays SDK-side.
Re-exports§
pub use callback::ErasedHookCallback;pub use callback::HookCallback;pub use callback::HookDecision;pub use registry::Hooks;pub use registry::HooksBuilder;
Modules§
- callback
- Hook callback trait + decision type + type-erasure plumbing.
- registry
- Hook registry - stores callbacks, mints opaque
callback_ids, and renders thehooksfield of theinitializecontrol_requestpayload.
Structs§
- Base
Hook Input - Fields shared by every hook input the CLI emits. Every concrete
input type below flattens this struct so callbacks can access
session_id,transcript_path,cwd, and (optionally)permission_modewithout reaching back intosuper::HookContext. - Hook
Context - Context carried alongside every hook invocation.
- Notification
Input - Input payload for
Notification. - Permission
Request Input - Input payload for
PermissionRequest. - Post
Tool UseFailure Input - Input payload for
PostToolUseFailure. - Post
Tool UseInput - Input payload for
PostToolUse. - PreCompact
Input - Input payload for
PreCompact. - PreTool
UseHook Specific Output hookSpecificOutputshape forPreToolUsehook responses.- PreTool
UseInput - Input payload for
PreToolUse. - Stop
Input - Input payload for
Stop. - Subagent
Context - Optional sub-agent attribution present on tool-lifecycle hook
inputs (
PreToolUse,PostToolUse,PostToolUseFailure,PermissionRequest). Fields are populated when the hook fires inside aTask-spawned sub-agent so tool events can be attributed back to the right agent when multiple sub-agents interleave over the same control channel. - Subagent
Start Input - Input payload for
SubagentStart. - Subagent
Stop Input - Input payload for
SubagentStop. - User
Prompt Submit Hook Specific Output hookSpecificOutputshape forUserPromptSubmit.- User
Prompt Submit Input - Input payload for
UserPromptSubmit.
Enums§
- Hook
Kind - Identifies which hook point a callback is registered for. Sixteen event
kinds mirrored from the CLI v0.1.64, plus
Unknownas a fallback for forward-compatibility.