Skip to main content

InProcessHooks

Struct InProcessHooks 

Source
pub struct InProcessHooks { /* private fields */ }
Expand description

Lane 1 — in-process Rust hooks: the compiled-in registry that the shell adapter (lane 2) and any future third-party lane register against.

Implementations§

Source§

impl InProcessHooks

Source

pub fn new() -> Self

Source

pub fn on_pre_tool( self, f: impl Fn(&str, &Value) -> PreToolDecision + Send + Sync + 'static, ) -> Self

Matcher::All sugar — fires on every tool (back-compat shape).

Source

pub fn on_pre_tool_matching( self, matcher: Matcher, f: impl Fn(&str, &Value) -> PreToolDecision + Send + Sync + 'static, ) -> Self

Source

pub fn on_post_tool( self, f: impl Fn(&str, &str) -> Option<String> + Send + Sync + 'static, ) -> Self

Matcher::All sugar — fires on every tool (back-compat shape).

Source

pub fn on_post_tool_matching( self, matcher: Matcher, f: impl Fn(&str, &str) -> Option<String> + Send + Sync + 'static, ) -> Self

Source

pub fn on_user_prompt( self, f: impl Fn(&str) -> Option<String> + Send + Sync + 'static, ) -> Self

Source

pub fn on_notification( self, f: impl Fn(NotificationKind, &str) + Send + Sync + 'static, ) -> Self

Source

pub fn on_stop( self, f: impl Fn(&str) -> StopDecision + Send + Sync + 'static, ) -> Self

Source

pub fn on_session_end(self, f: impl Fn() + Send + Sync + 'static) -> Self

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Default for InProcessHooks

Source§

fn default() -> InProcessHooks

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

impl Hooks for InProcessHooks

Source§

fn pre_tool<'a>( &'a self, name: &'a str, input: &'a Value, ) -> BoxFuture<'a, PreToolDecision>

Before a tool runs. The hook sees the tool name and full input.
Source§

fn post_tool<'a>( &'a self, name: &'a str, result: &'a str, ) -> BoxFuture<'a, Option<String>>

After a tool succeeds. result is byte-capped to HOOK_PAYLOAD_CAP. Some(replacement) swaps the result the model sees; None leaves it.
Source§

fn on_user_prompt<'a>( &'a self, prompt: &'a str, ) -> BoxFuture<'a, Option<String>>

UserPromptSubmit: runs when a prompt is admitted, before the turn it starts samples. Some(context) becomes one SyntheticReason::SystemReminder user item committed right after the prompt — a tagged user item, never a system-prompt edit (prefix-cache stability). Default: no-op (None), so a lane that hasn’t wired this event compiles and behaves inertly.
Source§

fn on_notification<'a>( &'a self, kind: NotificationKind, detail: &'a str, ) -> BoxFuture<'a, ()>

Notification: fire-and-forget — the engine tells hooks the agent blocked on a human (Blocked), went idle (Idle), or finished (Done). Callers MUST NOT await this on the hot path (see spawn_notification); the default is a no-op.
Source§

fn on_stop<'a>(&'a self, outcome: &'a str) -> BoxFuture<'a, StopDecision>

Stop: a bounded veto at the turn’s Done branch (tech-debt #10, node-style: it returns a decision, it doesn’t wrap the branch). Default: Allow — a hook-less build never delays turn-end.
Source§

fn on_session_end<'a>(&'a self) -> BoxFuture<'a, ()>

SessionEnd: fire-and-forget, called once at actor shutdown. Default: no-op.
Source§

fn event_mask(&self) -> EventMask

The union of event kinds this impl actually wants dispatched (§S1 HookRouter gate, Task 5). Default: EventMask::ALL — an external/unknown impl (a third-party lane, a test double) that hasn’t overridden this stays correct: every event still reaches it exactly as it did before this method existed. ShellHooks overrides it from its loaded specs, narrowing to the events actually configured. Used only as the one-time fallback when Hooks::mask_handle is None — an impl that provides a live handle is read through that instead.
Source§

fn mask_handle(&self) -> Option<Arc<AtomicU8>>

A live, shareable cell backing this impl’s mask, if it has one to offer — the “Arc-swapped on registry change” mechanism (§S1) resolved without a per-event hook table: the SAME AtomicU8 the impl narrows on eviction (ShellHooks::refresh_mask_bit) is what the engine reads at every hook_gate! site, so a mid-session narrowing is visible immediately — no second, disconnected snapshot to go stale. Default: None — an impl with no live state to expose (an external/unknown lane, anything built from InProcessHooks) keeps working exactly as before: the engine falls back to a single event_mask() snapshot taken once at session start.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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