Expand description
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:
- Session lifecycle (start, end)
- User prompts
- Tool calls (before, after, on error)
- Approval flows
- Subagent operations
§Hook Handlers
Hooks can be implemented using different handlers:
- Command: Execute shell commands
- HTTP: Call webhooks
- WASM: Run WebAssembly modules
- Agent: Invoke LLM-based handlers (stubbed)
§Example
ⓘ
use astrid_hooks::{Hook, HookEvent, HookHandler, HookManager};
let mut manager = HookManager::new();
let hook = Hook::new(HookEvent::PreToolCall)
.with_handler(HookHandler::Command {
command: "echo".to_string(),
args: vec!["Tool called: $TOOL_NAME".to_string()],
env: Default::default(),
});
manager.register(hook);Re-exports§
pub use hook::Hook;pub use hook::HookHandler;pub use hook_event::HookEvent;
Modules§
- hook
- Hook definitions and types.
- hook_
event - Hook event types.
- prelude
- Prelude module - commonly used types for convenient import.
Enums§
- Hook
Result - Result of hook execution.