pub struct AggregatedHookOutput {
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_errors: Vec<String>,
pub system_messages: Vec<String>,
}Expand description
多个 Hook 结果的聚合 — 并行执行后合并。
§聚合规则
- 权限:
Deny > Ask > Allow(最严格的获胜) - updated_input / updated_output:最后一个设置者获胜
- additional_context / blocking_errors / system_messages:合并
- prevent_continuation:任一 Hook 设置即生效
§Examples
use katu_core::hook::{AggregatedHookOutput, HookOutput, HookPermission};
let mut agg = AggregatedHookOutput::default();
// Hook A: allow
agg.merge(HookOutput::allow(), "hook_a");
assert_eq!(agg.permission, Some(HookPermission::Allow));
// Hook B: deny(更严格,覆盖 allow)
agg.merge(HookOutput::deny("unsafe"), "hook_b");
assert!(agg.permission.as_ref().unwrap().is_deny());Fields§
§permission: Option<HookPermission>聚合后的权限决策(最严格的获胜)。
updated_input: Option<Value>最终的 updated_input(最后一个设置者获胜)。
updated_output: Option<ToolOutput>最终的 updated_output。
additional_context: Vec<String>所有 Hook 注入的上下文(合并)。
prevent_continuation: bool任一 Hook 阻止继续。
stop_reason: Option<String>第一个 stop_reason。
blocking_errors: Vec<String>所有 blocking_error(合并,带 hook 名前缀)。
system_messages: Vec<String>所有 system_message(合并)。
Implementations§
Source§impl AggregatedHookOutput
impl AggregatedHookOutput
Sourcepub fn merge(&mut self, output: HookOutput, hook_name: &str)
pub fn merge(&mut self, output: HookOutput, hook_name: &str)
合并单个 Hook 的输出。
Sourcepub fn has_decision(&self) -> bool
pub fn has_decision(&self) -> bool
是否有任何 Hook 做出了实质性决策。
Sourcepub fn has_blocking_errors(&self) -> bool
pub fn has_blocking_errors(&self) -> bool
是否有阻塞性错误。
Trait Implementations§
Source§impl Clone for AggregatedHookOutput
impl Clone for AggregatedHookOutput
Source§fn clone(&self) -> AggregatedHookOutput
fn clone(&self) -> AggregatedHookOutput
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 AggregatedHookOutput
impl Debug for AggregatedHookOutput
Source§impl Default for AggregatedHookOutput
impl Default for AggregatedHookOutput
Source§fn default() -> AggregatedHookOutput
fn default() -> AggregatedHookOutput
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for AggregatedHookOutput
impl RefUnwindSafe for AggregatedHookOutput
impl Send for AggregatedHookOutput
impl Sync for AggregatedHookOutput
impl Unpin for AggregatedHookOutput
impl UnsafeUnpin for AggregatedHookOutput
impl UnwindSafe for AggregatedHookOutput
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