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
impl InProcessHooks
pub fn new() -> Self
Sourcepub fn on_pre_tool(
self,
f: impl Fn(&str, &Value) -> PreToolDecision + Send + Sync + 'static,
) -> Self
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).
pub fn on_pre_tool_matching( self, matcher: Matcher, f: impl Fn(&str, &Value) -> PreToolDecision + Send + Sync + 'static, ) -> Self
Sourcepub fn on_post_tool(
self,
f: impl Fn(&str, &str) -> Option<String> + Send + Sync + 'static,
) -> Self
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).
pub fn on_post_tool_matching( self, matcher: Matcher, f: impl Fn(&str, &str) -> Option<String> + Send + Sync + 'static, ) -> Self
pub fn on_user_prompt( self, f: impl Fn(&str) -> Option<String> + Send + Sync + 'static, ) -> Self
pub fn on_notification( self, f: impl Fn(NotificationKind, &str) + Send + Sync + 'static, ) -> Self
pub fn on_stop( self, f: impl Fn(&str) -> StopDecision + Send + Sync + 'static, ) -> Self
pub fn on_session_end(self, f: impl Fn() + Send + Sync + 'static) -> Self
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Default for InProcessHooks
impl Default for InProcessHooks
Source§fn default() -> InProcessHooks
fn default() -> InProcessHooks
Returns the “default value” for a type. Read more
Source§impl Hooks for InProcessHooks
impl Hooks for InProcessHooks
Source§fn pre_tool<'a>(
&'a self,
name: &'a str,
input: &'a Value,
) -> BoxFuture<'a, PreToolDecision>
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>>
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>>
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, ()>
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>
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, ()>
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
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>>
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§
impl !RefUnwindSafe for InProcessHooks
impl !UnwindSafe for InProcessHooks
impl Freeze for InProcessHooks
impl Send for InProcessHooks
impl Sync for InProcessHooks
impl Unpin for InProcessHooks
impl UnsafeUnpin for InProcessHooks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more