/** * Copyright 2025 Vybestack LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Represents a .jsonl session file entry for cleanup evaluation. * Similar to the CLI's SessionFileEntry but tailored for JSONL files * which use header-based reading instead of full JSON parse. */ export interface JsonlSessionFileEntry { /** Full filename including .jsonl extension */ fileName: string; /** Absolute path to the file */ filePath: string; /** File stat information */ stat: { mtime: Date; size: number; }; /** Parsed session info from the JSONL header, or null if corrupted/unreadable */ sessionInfo: { id: string; lastUpdated: string; isCurrentSession: boolean; } | null; } /** * @plan PLAN-20260211-SESSIONRECORDING.P17 * @requirement REQ-CLN-001 * @pseudocode session-cleanup.md lines 13-38 * * Scans a chats directory for `session-*.jsonl` files and returns metadata * for each. Uses `readSessionHeader()` to extract session info from the * first line without reading the entire file. * * @param chatsDir - Path to the chats directory to scan * @param currentSessionId - Optional current session ID (to mark as active) * @returns Array of JSONL session file entries */ export declare function getAllJsonlSessionFiles(chatsDir: string, currentSessionId?: string): Promise; /** * @plan PLAN-20260211-SESSIONRECORDING.P17 * @requirement REQ-CLN-002 * @pseudocode session-cleanup.md lines 50-74 * * Evaluates whether a .jsonl session file should be deleted, skipped (if * actively locked), or have only its stale lock removed. Checks for a * corresponding `.lock` sidecar file and uses PID liveness to determine * lock staleness. * * @param entry - The JSONL session file entry to evaluate * @returns Disposition: `'delete'`, `'skip'`, or `'stale-lock-only'` */ export declare function shouldDeleteSession(entry: JsonlSessionFileEntry): Promise<'delete' | 'skip' | 'stale-lock-only'>; /** * @plan PLAN-20260211-SESSIONRECORDING.P17 * @requirement REQ-CLN-004 * @pseudocode session-cleanup.md lines 85-130 * * Cleans up stale and orphaned `.lock` files in the chats directory. * Orphaned locks (no corresponding `.jsonl` file) are always removed. * Stale locks (PID no longer running) are removed but the data file is * left for normal retention policy evaluation. * * @param chatsDir - Path to the chats directory to scan for lock files * @returns Number of lock files cleaned up */ export declare function cleanupStaleLocks(chatsDir: string): Promise;