pub struct HookOutput {
pub permission: Option<HookPermission>,
pub updated_input: Option<Value>,
pub updated_output: Option<ToolOutput>,
pub additional_context: Vec<String>,
pub prevent_continuation: bool,
pub stop_reason: Option<String>,
pub blocking_error: Option<String>,
pub system_message: Option<String>,
}Expand description
Hook 的执行结果 — 告诉 Agent loop 如何继续。
§设计要点
Default= 无操作(passthrough),不影响正常流程- 多个字段独立,可同时设置(如 allow + 注入 context)
- 权限聚合优先级由
AggregatedHookOutput处理
§Examples
use katu_core::hook::HookOutput;
// passthrough — 什么都不做
let out = HookOutput::passthrough();
assert!(!out.has_decision());
// deny + context
let out = HookOutput::deny("dangerous")
.with_context("This command modifies system files");
assert!(out.has_decision());Fields§
§permission: Option<HookPermission>权限决策 — 仅对 PreToolUse 有意义。
updated_input: Option<Value>修改后的工具输入 — PreToolUse 时替换原始 input。
updated_output: Option<ToolOutput>修改后的工具输出 — PostToolUse 时替换原始 output。
additional_context: Vec<String>注入给 LLM 的额外上下文。
prevent_continuation: bool是否阻止 Agent 继续执行。
stop_reason: Option<String>阻止原因(prevent_continuation = true 时展示给用户)。
blocking_error: Option<String>阻塞性错误 — 反馈给 model 的错误消息。
system_message: Option<String>系统消息 — 展示给用户的提示/警告。
Implementations§
Source§impl HookOutput
impl HookOutput
Sourcepub fn passthrough() -> Self
pub fn passthrough() -> Self
无操作 — 不影响正常流程。
Sourcepub fn with_updated_input(self, input: Value) -> Self
pub fn with_updated_input(self, input: Value) -> Self
设置修改后的工具输入(builder 模式)。
Sourcepub fn with_updated_output(self, output: ToolOutput) -> Self
pub fn with_updated_output(self, output: ToolOutput) -> Self
设置修改后的工具输出(builder 模式)。
Sourcepub fn with_context(self, ctx: impl Into<String>) -> Self
pub fn with_context(self, ctx: impl Into<String>) -> Self
追加额外上下文(builder 模式)。
Sourcepub fn with_blocking_error(self, error: impl Into<String>) -> Self
pub fn with_blocking_error(self, error: impl Into<String>) -> Self
设置阻塞性错误(builder 模式)。
Sourcepub fn with_system_message(self, message: impl Into<String>) -> Self
pub fn with_system_message(self, message: impl Into<String>) -> Self
设置系统消息(builder 模式)。
Sourcepub fn has_decision(&self) -> bool
pub fn has_decision(&self) -> bool
是否做出了实质性决策(非 passthrough)。
Trait Implementations§
Source§impl Clone for HookOutput
impl Clone for HookOutput
Source§fn clone(&self) -> HookOutput
fn clone(&self) -> HookOutput
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HookOutput
impl Debug for HookOutput
Source§impl Default for HookOutput
impl Default for HookOutput
Source§fn default() -> HookOutput
fn default() -> HookOutput
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for HookOutput
impl<'de> Deserialize<'de> for HookOutput
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HookOutput
impl RefUnwindSafe for HookOutput
impl Send for HookOutput
impl Sync for HookOutput
impl Unpin for HookOutput
impl UnsafeUnpin for HookOutput
impl UnwindSafe for HookOutput
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