/** * Session Store * * SQLite-based persistence for kernel sessions. * Enables recovery after server restarts. */ import { PersistedSession } from './types'; export declare class SessionStore { private db; constructor(dbPath?: string); /** * Create tables if they don't exist */ private initDb; /** * Insert or update a session */ saveSession(session: PersistedSession): void; /** * Get a session by ID */ getSession(sessionId: string): PersistedSession | null; /** * Get all active sessions */ getActiveSessions(): PersistedSession[]; /** * Get orphaned sessions (from previous server run) */ getOrphanedSessions(serverId?: string): PersistedSession[]; /** * Update heartbeat timestamp */ updateHeartbeat(sessionId: string): void; /** * Update session status */ updateStatus(sessionId: string, status: 'active' | 'orphaned' | 'terminated'): void; /** * Delete a session */ deleteSession(sessionId: string): void; /** * Mark all active sessions as orphaned (called on startup) */ markAllOrphaned(serverId?: string, serverInstanceId?: string): number; /** * Get session by file path */ getSessionByFile(filePath: string): PersistedSession | null; /** * Cleanup old terminated/orphaned sessions */ cleanupOldSessions(maxAgeHours?: number): number; /** * Get dead sessions (orphaned or terminated) - candidates for cleanup */ getDeadSessions(serverId?: string): PersistedSession[]; /** * Delete specific sessions by ID */ deleteSessions(sessionIds: string[]): number; /** * Save kernel preference for a notebook file. */ saveNotebookKernelPreference(filePath: string, kernelName: string, serverId?: string | null): void; /** * Get kernel preference for a notebook file. */ getNotebookKernelPreference(filePath: string): { kernelName: string; serverId: string | null; updatedAt: number; } | null; /** * Delete kernel preference for a notebook file. */ deleteNotebookKernelPreference(filePath: string): void; /** * Close database connection */ close(): void; /** * Convert database row to PersistedSession */ private rowToSession; }