Hook Runner • Rust AI Agent SDK
HookRunner: Hook runner for executing hooks in a workflow
HookRunner
Defined in the hooks module.
Rust AI Agent SDK
Hook runner for executing hooks in a workflow
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph TD
event["Event Trigger"] --> hook["Hook: HookRunner"]
hook --> decision{"Decision"}
decision -- "Allow" --> proc["Process"]
decision -- "Deny" --> block["Block"]
style hook fill:#189AB4,color:#fff
style event fill:#8B0000,color:#fff
style proc fill:#8B0000,color:#fff
style block fill:#8B0000,color:#fffFields
| Name | Type | Description |
|---|---|---|
registry | Arc<HookRegistry> | – |
Methods
new
fn new(registry: HookRegistry) -> SelfCreate a new hook runner
Parameters:
| Name | Type |
|---|---|
registry | HookRegistry |
before_tool
fn before_tool(
&self,
session_id: &str,
tool_name: &str,
args: serde_json::Value,
) -> Result<HookResult>Run before-tool hooks
Parameters:
| Name | Type |
|---|---|
session_id | &str |
tool_name | &str |
args | serde_json::Value |
after_tool
fn after_tool(
&self,
session_id: &str,
tool_name: &str,
result: serde_json::Value,
) -> Result<HookResult>Run after-tool hooks
Parameters:
| Name | Type |
|---|---|
session_id | &str |
tool_name | &str |
result | serde_json::Value |
before_agent
fn before_agent(
&self,
session_id: &str,
agent_name: &str,
message: &str,
) -> Result<HookResult>Run before-agent hooks
Parameters:
| Name | Type |
|---|---|
session_id | &str |
agent_name | &str |
message | &str |
after_agent
fn after_agent(
&self,
session_id: &str,
agent_name: &str,
response: &str,
) -> Result<HookResult>Run after-agent hooks
Parameters:
| Name | Type |
|---|---|
session_id | &str |
agent_name | &str |
response | &str |
on_error
fn on_error(&self, session_id: &str, error: &str) -> Result<HookResult>Run on-error hooks
Parameters:
| Name | Type |
|---|---|
session_id | &str |
error | &str |
Source
View on GitHubpraisonai/src/hooks/mod.rs at line 461