Skip to main content

ReadOnlyHooks

Struct ReadOnlyHooks 

Source
pub struct ReadOnlyHooks;
Expand description

Enforced read-only (D1): while installed, refuse the workspace-mutating tools and mutating bash/bg. A guardrail, NOT a sandbox (the same FP/FN budget as plan mode’s bash gate — docs/plan-mode.md §2.4). Stateless: a unit struct.

Implementations§

Source§

impl ReadOnlyHooks

Source

pub fn new() -> Self

Kept for symmetry with BashRiskHooks::new (hooks.rs:zmKr5), so the CLI wiring reads Arc::new(ReadOnlyHooks::new()) like every other built-in.

Trait Implementations§

Source§

impl Default for ReadOnlyHooks

Source§

fn default() -> Self

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

impl Hooks for ReadOnlyHooks

Source§

fn before_tool_call<'life0, 'life1, 'async_trait>( &'life0 self, call: &'life1 ToolCall, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Some(reason) — the loop shows blocked: {reason}, so the reason starts read-only worker: — for: any MUTATING_TOOLS name (hooks.rs:osi4C); bg (background bash can mutate); bash whose command satisfies the private looks_mutating (hooks.rs:SsKd8). Everything else passes.

Source§

fn transform_tool_input<'life0, 'life1, 'async_trait>( &'life0 self, _call: &'life1 mut ToolCall, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

May mutate the tool call’s arguments before it is executed (e.g. to rewrite a bash command through rtk). Mutations are what actually executes, so before_tool_call/after_tool_call observe the rewrite.
Source§

fn after_tool_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _call: &'life1 ToolCall, _out: &'life2 mut ToolOutput, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Runs after every tool execution; may mutate the output before it is recorded and sent to the LLM.
Source§

fn before_inbound<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _from: Option<&'life1 SessionId>, _request: &'life2 mut Request, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Policy for an inbound peer message (an A2A Notify/Interrupt/Wake): the mirror of Hooks::before_tool_call. May rewrite the request in place (the rewrite is what is delivered); Some(reason) drops it — the reason is returned to the sender when it is an ask. A message dropped here never reaches the context or starts a turn.
Source§

fn transform_context<'life0, 'life1, 'async_trait>( &'life0 self, _msgs: &'life1 mut Vec<AgentMessage>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs at every turn start, after steering is drained, before streaming.
Source§

fn should_stop_after_turn<'life0, 'life1, 'async_trait>( &'life0 self, _ctx: &'life1 [AgentMessage], ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checked after tool execution completes; true ends the run with StopReason::Stop.
Source§

fn after_run<'life0, 'life1, 'async_trait>( &'life0 self, _ctx: &'life1 [AgentMessage], _stop: StopReason, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Runs once when a run finishes, with the final context and why it stopped. The A2A auto-report rides this (a worker forwards its result to its orchestrator); a no-op by default.

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.

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

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

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