Skip to main content

HooksBuilder

Struct HooksBuilder 

Source
pub struct HooksBuilder {
    inner: Hooks,
}
Expand description

Builder for Hooks.

Fields§

§inner: Hooks

Implementations§

Source§

impl HooksBuilder

Source

pub fn new() -> Self

Start empty.

Source

pub fn default_timeout_secs(self, secs: u64) -> Self

Override the per-hook timeout (seconds) emitted in the initialize control_request. The CLI uses this to decide how long to wait on each hook_callback reply before giving up and emitting a control_cancel_request. Default when unset is 120 seconds. Lower it for scenarios that deliberately provoke cancellation; raise it for long-running callbacks (e.g. LLM sub-calls inside a hook).

Source

pub fn pre_tool_use<C>(self, matcher: impl Into<String>, callback: C) -> Self
where C: HookCallback<PreToolUseInput> + 'static,

Register a PreToolUse hook. matcher is a glob against tool names ("*" matches all); pass "Bash" to match only the Bash tool.

Source

pub fn post_tool_use<C>(self, matcher: impl Into<String>, callback: C) -> Self
where C: HookCallback<PostToolUseInput> + 'static,

Register a PostToolUse hook.

Source

pub fn user_prompt_submit<C>(self, callback: C) -> Self
where C: HookCallback<UserPromptSubmitInput> + 'static,

Register a UserPromptSubmit hook.

Source

pub fn stop<C>(self, callback: C) -> Self
where C: HookCallback<StopInput> + 'static,

Register a Stop hook.

Source

pub fn subagent_stop<C>(self, callback: C) -> Self
where C: HookCallback<SubagentStopInput> + 'static,

Register a SubagentStop hook.

Source

pub fn pre_compact<C>(self, callback: C) -> Self
where C: HookCallback<PreCompactInput> + 'static,

Register a PreCompact hook.

Source

pub fn post_tool_use_failure<C>( self, matcher: impl Into<String>, callback: C, ) -> Self

Register a PostToolUseFailure hook. matcher follows the same tool-name glob semantics as Self::pre_tool_use / Self::post_tool_use.

Source

pub fn notification<C>(self, callback: C) -> Self
where C: HookCallback<NotificationInput> + 'static,

Register a Notification hook.

Source

pub fn subagent_start<C>(self, callback: C) -> Self
where C: HookCallback<SubagentStartInput> + 'static,

Register a SubagentStart hook.

Source

pub fn permission_request<C>( self, matcher: impl Into<String>, callback: C, ) -> Self

Register a PermissionRequest hook (observational; matcher globs against tool names the same way as Self::pre_tool_use).

Source

pub fn build(self) -> Hooks

Finalise.

Trait Implementations§

Source§

impl Debug for HooksBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HooksBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more