/** * Session Management * Generates unique session IDs for each command execution */ /** * Generate a short, readable session ID * Format: - * Example: 20250122-a3f2 */ export declare function generateSessionId(): string; /** * Get the session log file path for a given session ID * @param sessionId The session ID * @param active If true, return path in active directory, otherwise inactive (default: true) */ export declare function getSessionLogPath(sessionId: string, active?: boolean): string; /** * Get the master index file path * This file tracks all session IDs in chronological order */ export declare function getMasterIndexPath(): string; /** * Register a new session in the master index * @param sessionId The session ID to register * @param command The command being executed * @param args The command arguments * @param cwd The working directory where the command was executed */ export declare function registerSession(sessionId: string, command: string, args: string[], cwd: string): void; /** * Get all session IDs from the master index * @returns Array of session IDs in chronological order */ export declare function getAllSessionIds(): string[]; /** * Get the most recent N session IDs * @param count Number of recent sessions to retrieve * @returns Array of session IDs (most recent first) */ export declare function getRecentSessionIds(count: number): string[]; /** * Get the active sessions file path * This file tracks currently running sessions */ export declare function getActiveSessionsPath(): string; /** * Check if a process with the given PID is still alive. * Uses `kill(pid, 0)` which doesn't send a signal — just probes existence. * EPERM means the process exists but we don't own it (treat as alive). * ESRCH (or any other error) means it's gone. */ export declare function isProcessAlive(pid: number | undefined | null): boolean; /** * Mark a session as active (running) * @param sessionId The session ID * @param projectDir The project directory * @param pid The PID of the process owning this session (defaults to current process) */ export declare function markSessionActive(sessionId: string, projectDir: string, pid?: number): void; /** * Reap sessions whose owning process is no longer alive. * Legacy entries without a PID are also reaped (they predate PID tracking). * Safe to call on every read — it's cheap (a kill(pid, 0) per entry) and only * writes when something actually died. * @returns Number of sessions reaped */ export declare function reapDeadSessions(): number; /** * End ALL currently-active sessions unconditionally (dead or alive) and * archive their logs. Called at wrapper startup so there is only ever one * active session at a time — the fresh one about to register. This is the * simplest possible invariant that makes "stale zombie sessions" impossible * by construction: the state file never holds more than one entry. * @returns Number of sessions ended */ export declare function endAllActiveSessions(): number; /** * Mark a session as completed and move its log to inactive directory * @param sessionId The session ID * @param archiveLog Whether to archive the log file to inactive directory (default: true) */ export declare function markSessionCompleted(sessionId: string, archiveLog?: boolean): void; /** * Get all active session IDs for a specific project * @param projectDir The project directory (optional - returns all if not specified) * @returns Array of active session IDs */ export declare function getActiveSessions(projectDir?: string): string[]; /** * Clean up stale sessions. Reaps by PID (dead process → dead session), which * is the authoritative signal — a long-running `npm start` idle overnight is * still alive and shouldn't be reaped. * The `maxAgeMinutes` param is kept for backwards compatibility but unused; * PID liveness replaces the age heuristic. * @returns Number of stale sessions cleaned up */ export declare function cleanupStaleSessions(_maxAgeMinutes?: number): number; /** * Clean up old inactive logs (logs older than retentionDays) * @param retentionDays Number of days to retain inactive logs (default: 7) * @returns Number of old logs deleted */ export declare function cleanupOldInactiveLogs(retentionDays?: number): number; //# sourceMappingURL=session.d.ts.map