Expand description
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:
- Native Hooks (100%): Claude Skills, Gemini Functions, Qwen Hooks, pi-mono, oh-my-pi
- Session Monitor (95%): Process monitoring via sysinfo
- Inactivity Detector (90%): Configurable timeout detection
- Persistent Buffer (99%): Crash recovery from buffer
§Supported Agents
- Claude Code: Skills-based (SKILL.md format)
- Gemini: Function Calling
- Qwen: Hooks SubAgent
- pi-mono: Skills-based (TypeScript/Bun)
- oh-my-pi: Skills-based (TypeScript/Bun + Rust N-API)
- pi-skills: Cross-compatible skills
- CLI Agents: Amp, Droid, OpenCode, Codex (atexit/signals)
§Example
use nexus_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-exports§
pub use base::AgentHook;pub use base::HookResult;pub use buffer::PersistentBuffer;pub use detector::InactivityDetector;pub use error::HookError;pub use error::Result;pub use extractor::MultiLayerExtractor;pub use factory::HookFactory;pub use monitor::ProcessMonitor;pub use monitor::SessionMonitor;pub use session::SessionContext;pub use agents::CLIHook;pub use agents::ClaudeCodeHook;pub use agents::GeminiHook;pub use agents::OhMyPiHook;pub use agents::PiMonoHook;pub use agents::PiSkillsHook;pub use agents::QwenHook;pub use types::*;
Modules§
- agents
- Agent hook implementations
- base
- AgentHook trait definition
- buffer
- Persistent buffer for crash recovery
- detector
- Inactivity detector for session timeout detection
- error
- Error types for the hooks system
- extractor
- Multi-layer extractor combining all detection methods
- factory
- Hook factory for creating agent-specific hooks
- monitor
- Session and process monitoring
- session
- Session context for extracted data
- signal
- Signal handling for graceful shutdown
- types
- Common types for the hooks system
Constants§
- DEFAULT_
BUFFER_ FLUSH_ INTERVAL_ SECS - Default buffer flush interval in seconds
- DEFAULT_
INACTIVITY_ TIMEOUT_ SECS - Default inactivity timeout in seconds (5 minutes)
- DEFAULT_
POLLING_ INTERVAL_ SECS - Default process polling interval in seconds
- VERSION
- Hook version