astrid-hooks
User-defined extension points for the Astrid runtime.
This crate provides a flexible hook system that allows users to extend the behavior of the Astrid runtime at key points in the execution flow.
Hook Events
Hooks can be triggered on various events:
| Event | Description |
|---|---|
SessionStart |
When a session begins |
SessionEnd |
When a session ends |
UserPrompt |
When a user submits a prompt |
PreToolCall |
Before a tool is invoked |
PostToolCall |
After a tool completes successfully |
ToolCallError |
When a tool call fails |
ApprovalRequest |
When approval is requested |
ApprovalGranted |
When approval is granted |
ApprovalDenied |
When approval is denied |
SubagentSpawn |
When a subagent is created |
SubagentComplete |
When a subagent finishes |
Handler Types
| Handler | Description | Status |
|---|---|---|
| Command | Execute shell commands | Available |
| HTTP | Call webhooks | Available |
| WASM | Run WebAssembly modules | Phase 3 |
| Agent | Invoke LLM-based handlers | Phase 3 |
Usage
use ;
// Create a hook manager
let mut manager = new;
// Register a command hook for tool calls
let hook = new
.with_handler;
manager.register;
// Register an HTTP webhook for approvals
let webhook = new
.with_handler;
manager.register;
Key Exports
Hook- A single hook definitionHookEvent- Events that trigger hooksHookHandler- Handler implementations (Command, HTTP, WASM, Agent)HookManager- Manages hook registration and lookupHookExecutor- Executes hooks with contextHookProfile- Named collections of hooks
License
This crate is licensed under the MIT license.