astrid_hooks/lib.rs
1//! Astrid Hooks - User-defined extension points for the Astrid runtime.
2//!
3//! This crate provides a flexible hook system that allows users to extend
4//! the behavior of the Astrid runtime at key points in the execution flow.
5//!
6//! # Hook Events
7//!
8//! Hooks can be triggered on various events:
9//! - Session lifecycle (start, end)
10//! - User prompts
11//! - Tool calls (before, after, on error)
12//! - Approval flows
13//! - Subagent operations
14//!
15//! # Hook Handlers
16//!
17//! Hooks can be implemented using different handlers:
18//! - **Command**: Execute shell commands
19//! - **HTTP**: Call webhooks
20//! - **WASM**: Run WebAssembly modules
21//! - **Agent**: Invoke LLM-based handlers (stubbed)
22//!
23//! # Example
24//!
25//! ```rust,ignore
26//! use astrid_hooks::{Hook, HookEvent, HookHandler, HookManager};
27//!
28//! let mut manager = HookManager::new();
29//!
30//! let hook = Hook::new(HookEvent::PreToolCall)
31//! .with_handler(HookHandler::Command {
32//! command: "echo".to_string(),
33//! args: vec!["Tool called: $TOOL_NAME".to_string()],
34//! env: Default::default(),
35//! });
36//!
37//! manager.register(hook);
38//! ```
39
40#![deny(unsafe_code)]
41#![deny(missing_docs)]
42#![deny(clippy::all)]
43#![deny(unreachable_pub)]
44#![deny(clippy::unwrap_used)]
45#![cfg_attr(test, allow(clippy::unwrap_used))]
46
47pub mod prelude;
48
49#[allow(dead_code)]
50pub(crate) mod config;
51#[allow(dead_code)]
52pub(crate) mod discovery;
53#[allow(dead_code)]
54pub(crate) mod executor;
55#[allow(dead_code)]
56pub(crate) mod handler;
57pub mod hook;
58pub mod hook_event;
59#[allow(dead_code)]
60pub(crate) mod manager;
61#[allow(dead_code)]
62pub(crate) mod profiles;
63#[allow(dead_code)]
64pub(crate) mod result;
65
66pub use hook::{Hook, HookHandler};
67pub use hook_event::HookEvent;
68pub use result::HookResult;