Skip to main content

HookResult

Defined in the hooks module.
Rust AI Agent SDK Result from a hook execution

Fields

NameTypeDescription
decisionHookDecisionDecision (allow, deny, block, ask)
reasonOption<String>Reason for the decision
modified_inputOption<HashMap<StringModified input data (optional)
serde_json:Value>>Modified input data (optional)
additional_contextOption<String>Additional context
suppress_outputboolWhether to suppress output

Methods

allow

fn allow() -> Self
Create an allow result

allow_with_reason

fn allow_with_reason(reason: impl Into<String>) -> Self
Create an allow result with reason Parameters:
NameType
reasonimpl Into&lt;String&gt;

deny

fn deny(reason: impl Into<String>) -> Self
Create a deny result Parameters:
NameType
reasonimpl Into&lt;String&gt;

block

fn block(reason: impl Into<String>) -> Self
Create a block result Parameters:
NameType
reasonimpl Into&lt;String&gt;

ask

fn ask(reason: impl Into<String>) -> Self
Create an ask result Parameters:
NameType
reasonimpl Into&lt;String&gt;

is_allowed

fn is_allowed(&self) -> bool
Check if the result allows execution

is_denied

fn is_denied(&self) -> bool
Check if the result denies execution

with_modified_input

fn with_modified_input(mut self, input: HashMap<String, serde_json::Value>) -> Self
Add modified input Parameters:
NameType
inputHashMap&lt;String
serde_json:Value&gt;

with_context

fn with_context(mut self, context: impl Into<String>) -> Self
Add additional context Parameters:
NameType
contextimpl Into&lt;String&gt;

suppress

fn suppress(mut self) -> Self
Suppress output

Source

View on GitHub

praisonai/src/hooks/mod.rs at line 177