/** * Session store - file-based persistence */ import type { Session, SessionCommand, SessionSummary } from '../types/session.types.js'; import type { SessionCleanupScheduler } from './cleanup-scheduler.js'; /** * Session Snapshot - lightweight version of session for fast resume * Contains only essential data needed to quickly restore session state */ export interface SessionSnapshot { created_at: string; last_command?: string; session_id: string; status: Session['status']; total_tokens_used?: number; updated_at: string; /** Last N commands for quick context */ recent_commands: SessionCommand[]; /** Essential context keys for optimization */ essential_context: { _loaderCache?: unknown; _stageOutputs?: unknown; }; /** Snapshot metadata */ full_command_count: number; snapshot_version: number; } /** * Session Store - File-based session persistence with automatic cleanup * * IMPORTANT: Background cleanup is managed by the unified cleanup coordinator. * The coordinator initializes both log and session cleanup schedulers together. * The scheduler will: * - Run every N hours (configured in config.json: cleanup_interval_hours) * - Compress sessions older than compress_after_days * - Delete sessions older than max_age_days * - Enforce max_count and max_size_mb limits * * To disable automatic cleanup: * - Set NODE_ENV=test or AI_TEST_MODE=true environment variables * - Set sessions.enabled=false in config.json * - MCP mode automatically disables cleanup * * See: documentation/architecture/session-optimization.md for full documentation * See: cleanup/coordinator.ts for unified scheduler initialization */ export declare class SessionStore { private initialized; private sessionsDir; constructor(sessionsDir?: string); /** * Defer initialization to prevent race conditions */ private deferInitialize; /** * Initialize session store * * Note: Cleanup scheduler is initialized separately via cleanup/coordinator.ts */ private initialize; /** * Create a new session */ createSession(sessionId?: string): Promise; /** * Load a session by ID */ loadSession(sessionId: string): Promise; /** * Save a session */ saveSession(session: Session): Promise; /** * Delete a session */ deleteSession(sessionId: string): Promise; /** * List all sessions */ listSessions(): Promise; /** * Check if a session exists */ sessionExists(sessionId: string): Promise; /** * Get the most recent session */ getRecentSession(): Promise; /** * Archive old sessions */ archiveSessions(beforeDate: Date): Promise; /** * Clean up completed sessions older than specified days */ cleanupOldSessions(daysOld?: number): Promise; /** * Get session file path */ private getSessionPath; /** * Get snapshot file path */ private getSnapshotPath; /** * Get sessions directory */ getSessionsDir(): string; /** * Get the session cleanup scheduler instance * Note: Scheduler is now initialized via cleanup/coordinator.ts */ getCleanupScheduler(): null | SessionCleanupScheduler; /** * Create a snapshot from a full session * Snapshots contain lightweight data for fast resume */ private createSnapshot; /** * Save a session snapshot for fast resume */ saveSnapshot(session: Session): Promise; /** * Load a session snapshot (fast resume) * Returns null if snapshot doesn't exist or is invalid */ loadSnapshot(sessionId: string): Promise; /** * Check if a snapshot is sufficient for the current operation * Snapshots are sufficient for quick context access, but not for full history */ isSnapshotSufficient(snapshot: SessionSnapshot, needsFullHistory: boolean): boolean; /** * Delete a session snapshot */ deleteSnapshot(sessionId: string): Promise; } //# sourceMappingURL=store.d.ts.map