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
impl ReadOnlyHooks
Trait Implementations§
Source§impl Default for ReadOnlyHooks
impl Default for ReadOnlyHooks
Source§impl Hooks for ReadOnlyHooks
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,
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,
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,
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,
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,
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,
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,
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§
impl Freeze for ReadOnlyHooks
impl RefUnwindSafe for ReadOnlyHooks
impl Send for ReadOnlyHooks
impl Sync for ReadOnlyHooks
impl Unpin for ReadOnlyHooks
impl UnsafeUnpin for ReadOnlyHooks
impl UnwindSafe for ReadOnlyHooks
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