/** * @fileoverview Session Manager - tracks multiple Claude Code sessions in SQLite * @module mobile/session-manager * @version 1.5.0 * * Manages session lifecycle including creation, tracking, and termination. * Sessions are persisted to SQLite for durability across server restarts. * * @example * import { SessionManager } from './session-manager'; * const manager = new SessionManager(); * await manager.initDB(); * const { sessionId, daemon } = await manager.createSession('/path/to/project'); */ import { ClaudeDaemon } from './daemon.js'; /** * Default database path */ export declare const DEFAULT_DB_PATH: string; /** * Sessions table creation SQL */ export declare const CREATE_SESSIONS_TABLE: string; /** * In-memory session data */ interface MemorySession { daemon: ClaudeDaemon; clientId: string | null; projectDir: string; createdAt: string; } /** * Session info returned from getActiveSessions */ export interface SessionInfo { id: string; projectDir: string; createdAt: string | undefined; lastActive: string | undefined; status: string; pid: number | null; clientId: string | null; isAlive: boolean; } /** * Create session result */ export interface CreateSessionResult { sessionId: string; daemon: ClaudeDaemon; } /** * SessionManager class - manages Claude Code sessions */ export declare class SessionManager { private dbPath; private sessions; private db; private initialized; private cleanupPromise; private cleanupHandlersRegistered; private handleProcessExit; /** * Create a new SessionManager instance * @param dbPath - Path to SQLite database */ constructor(dbPath?: string); /** * Initialize the SQLite database and create sessions table */ initDB(): Promise; /** * Create a new Claude Code session * @param projectDir - Working directory for the session * @returns Session ID and daemon */ createSession(projectDir: string): Promise; /** * Get all active sessions * @returns Array of active session info */ getActiveSessions(): Promise; /** * Terminate a session by ID * @param sessionId - Session to terminate * @returns True if session was terminated */ terminateSession(sessionId: string): Promise; /** * Get a session by ID * @param sessionId - Session ID to look up * @returns Session data or undefined */ getSession(sessionId: string): MemorySession | undefined; /** * Update session's last active timestamp * @param sessionId - Session ID */ touchSession(sessionId: string): void; /** * Assign a client to a session * @param sessionId - Session ID * @param clientId - Client ID */ assignClient(sessionId: string, clientId: string): void; /** * Remove client assignment from a session * @param sessionId - Session ID */ unassignClient(sessionId: string): void; /** * Get session count * @returns Number of active sessions */ getSessionCount(): number; /** * Terminate all active sessions * @returns Number of sessions terminated */ terminateAll(): Promise; /** * Setup daemon event handlers * @private */ private _setupDaemonHandlers; /** * Setup process cleanup handlers * @private */ private _setupProcessCleanup; /** * Close the database connection */ close(): void; } export {}; //# sourceMappingURL=session-manager.d.ts.map