/** * 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. */ import { type SessionSummary, type SessionStartPayload } from './types.js'; /** * Result of successfully resolving a session reference. */ export interface SessionResolution { session: SessionSummary; } /** * Result when a session reference cannot be resolved. */ export interface SessionResolutionError { error: string; } /** * Static utility class for discovering and resolving session files. * * @plan PLAN-20260211-SESSIONRECORDING.P20 * @requirement REQ-RSM-003 * @pseudocode session-management.md lines 10-67 */ export declare class SessionDiscovery { /** * List all sessions in a chats directory matching the given project hash, * sorted newest-first by file modification time. * * @pseudocode session-management.md lines 12-44 */ static listSessions(chatsDir: string, projectHash: string): Promise; /** * Resolve a user-provided session reference (session ID, prefix, or index) * against a list of known sessions. * * Resolution precedence: * 1. Exact session ID match * 2. If ref is all digits → treat as 1-based numeric index * 3. Unique prefix match (ambiguous → error listing matching IDs) * 4. Not found → error * * @pseudocode session-management.md lines 47-67 */ static resolveSessionRef(ref: string, sessions: SessionSummary[]): SessionResolution | SessionResolutionError; /** * Read only the session header (first line) from a JSONL file. * Delegates to the existing readSessionHeader in ReplayEngine. * * @pseudocode resume-flow.md header reading */ static readSessionHeader(filePath: string): Promise; /** * @plan PLAN-20260214-SESSIONBROWSER.P06 * @requirement REQ-SB-008 * @pseudocode session-discovery-extensions.md lines 10-60 * * List all sessions in a chats directory matching the given project hash, * returning both valid sessions and a count of skipped (corrupted) files. * Sessions are sorted newest-first by file modification time. */ static listSessionsDetailed(chatsDir: string, projectHash: string): Promise<{ sessions: SessionSummary[]; skippedCount: number; }>; /** * @plan PLAN-20260214-SESSIONBROWSER.P06 * @requirement REQ-SB-005 * @pseudocode session-discovery-extensions.md lines 65-91 * * Check if a session file contains any content events (user or assistant messages). * Returns false for non-existent files, empty files, or files with only session_start. */ static hasContentEvents(filePath: string): Promise; /** * @plan PLAN-20260214-SESSIONBROWSER.P06 * @requirement REQ-PV-002 * @pseudocode session-discovery-extensions.md lines 95-165 * * Read the first user message from a session file. * Extracts text from TextBlock parts only, ignoring media and tool blocks. * Returns null for non-existent files, I/O errors, or no user messages found. */ static readFirstUserMessage(filePath: string, maxLength?: number): Promise; }