1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! Nexus Hooks - Agent hooks system for automated memory extraction
//!
//! This crate provides a four-layer extraction system for capturing
//! agent session context with 95-100% reliability:
//!
//! 1. **Native Hooks** (98-100%): Claude Skills, pi-mono, oh-my-pi, pi-skills
//! 2. **Session Monitor** (95%): Process monitoring via sysinfo
//! 3. **Inactivity Detector** (90%): Configurable timeout detection
//! 4. **Persistent Buffer** (99%): Crash recovery from buffer
//!
//! # Supported Agents
//!
//! ## Native Lifecycle (dedicated hook implementation + skill installation)
//!
//! - **Claude Code**: Skills-based (SKILL.md format) — session start, end, checkpoint, error, compact
//! - **pi-mono**: Skills-based (TypeScript/Bun) — session end, checkpoint, compact
//! - **oh-my-pi**: Skills-based (TypeScript/Bun + Rust N-API) — session end, checkpoint, error, compact
//! - **pi-skills**: Cross-compatible skills — session end, checkpoint, compact
//!
//! ## Monitor Only (process detection, no native hooks)
//!
//! - **Gemini**: Process monitoring only (function calling not yet wired)
//! - **Qwen**: Process monitoring only (hooks subagent not yet wired)
//!
//! ## Wrapper Lifecycle (generic CLI wrapper, atexit + process detection)
//!
//! - **CLI Agents**: Amp, Droid, OpenCode, Codex, Hermes (shared CLIHook implementation)
//!
//! # Example
//!
//! ```rust,no_run
//! use nexus_memory_hooks::{HookFactory, AgentHook, MultiLayerExtractor};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create hook for specific agent
//! let factory = HookFactory::new();
//! let mut hook = factory.create_hook("claude-code")?;
//!
//! // Check if session is active
//! let activity = hook.detect_session_activity().await?;
//! println!("Session active: {}", activity.is_active);
//!
//! // Extract session context
//! if activity.is_active {
//! let context = hook.extract_session_context().await?;
//! println!("Extracted context: {:?}", context);
//! }
//!
//! Ok(())
//! }
//! ```
// Re-export main types
pub use ;
pub use PersistentBuffer;
pub use ;
pub use ;
pub use InactivityDetector;
pub use ;
pub use ;
pub use MultiLayerExtractor;
pub use HookFactory;
pub use ;
pub use ;
pub use ;
pub use SessionContext;
pub use ;
// Re-export agent hooks
pub use ;
/// Hook version
pub const VERSION: &str = env!;
/// Default inactivity timeout in seconds (5 minutes)
pub const DEFAULT_INACTIVITY_TIMEOUT_SECS: u64 = 300;
/// Default buffer flush interval in seconds
pub const DEFAULT_BUFFER_FLUSH_INTERVAL_SECS: u64 = 10;
/// Default process polling interval in seconds
pub const DEFAULT_POLLING_INTERVAL_SECS: u64 = 5;