Expand description
Core session management functionality
This module provides the foundational components for AI-optimized terminal session management. The core functionality includes session creation, lifecycle management, and AI context integration.
§Key Features
- AISession: Advanced terminal session with AI capabilities
- SessionManager: Pool-based session management with automatic cleanup
- SessionConfig: Comprehensive configuration for AI features and performance
- Context Integration: Seamless integration with AI conversation context
§Quick Start
use ai_session::{SessionManager, SessionConfig, ContextConfig};
use tokio;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let manager = SessionManager::new();
// Create a basic session
let session = manager.create_session().await?;
session.start().await?;
// Send a command
session.send_input("echo 'Hello AI Session!'\n").await?;
// Read the output
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
let output = session.read_output().await?;
println!("Output: {}", String::from_utf8_lossy(&output));
// Clean up
session.stop().await?;
Ok(())
}§Advanced Configuration
use ai_session::{SessionManager, SessionConfig, ContextConfig};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let manager = SessionManager::new();
// Configure session with AI features
let mut config = SessionConfig::default();
config.enable_ai_features = true;
config.agent_role = Some("rust-developer".to_string());
config.context_config = ContextConfig {
max_tokens: 8192,
compression_threshold: 0.8,
};
// Set environment variables
config.environment.insert("RUST_LOG".to_string(), "debug".to_string());
config.working_directory = "/path/to/project".into();
let session = manager.create_session_with_config(config).await?;
session.start().await?;
// Session is now ready for AI-enhanced development
Ok(())
}Modules§
- headless
- Headless (non-PTY) terminal management used when PTYs are unavailable.
- lifecycle
- Session lifecycle management
- process
- Process management for AI sessions
- pty
- PTY (Pseudo-Terminal) management
- terminal
- Terminal handle abstraction that can wrap either a PTY or the headless fallback.
Structs§
- AISession
- AI-optimized session
- Context
Config - Context configuration for AI features
- Session
Config - Session configuration
- Session
Id - Unique session identifier
- Session
Manager - AI-optimized session manager for creating and managing multiple terminal sessions.
Enums§
- Session
Error - Session error type
- Session
Status - Session status
Type Aliases§
- Session
Result - Session result type