import type { Message } from './types.js'; export interface Session { id: string; name: string; cwd: string; model: string; provider: string; messages: Message[]; createdAt: string; updatedAt: string; tokenCount: number; turnCount: number; mode: string; /** * Permission mode active when the session was last saved. Optional * for back-compat — pre-v1.30.2 session files don't have this field. * Restored by /resume so a yolo session resumes in yolo, not in * whatever mode the current REPL happens to be in. */ permissionMode?: 'ask' | 'auto' | 'yolo'; } export declare function generateSessionId(): string; export declare function saveSession(session: Session): Promise; export declare function loadSession(id: string): Session | null; export declare function listSessions(): Pick[]; export declare function deleteSession(id: string): boolean; /** * Resolve a user-provided session reference to a canonical session ID. * Accepts: * - Exact session ID (any length) * - Unique prefix match (like `git checkout `). If multiple * sessions share the prefix, returns null + the candidate list via * the second return slot so the caller can show a helpful error. * - "last" or "latest" → the most-recently-updated session * * Wrappers (``, `"id"`, etc.) are stripped before matching — the * same forgiving input handling as /stitch-config. This matches user * muscle memory: "/resume " gets typed instinctively because the * /help line shows `` as a placeholder. * * Returns: * { id: string } on success * { error: string, candidates?: string[] } on ambiguity or no match */ export declare function resolveSessionRef(raw: string): { id: string; } | { error: string; candidates?: string[]; }; export declare function createSession(cwd: string, model: string, provider: string, mode: string): Session; /** * Optional snapshot of the live state that should be written into the * session file alongside messages. Without this, the saved session * captures only the values that happened to be on the Session object * at create time — mode/perm switches mid-session never make it to * disk, and /resume restores stale values. */ export interface AutoSaveSnapshot { model?: string; provider?: string; mode?: string; permissionMode?: 'ask' | 'auto' | 'yolo'; cwd?: string; } export declare function autoSave(session: Session, messages: Message[], snapshot?: AutoSaveSnapshot): Promise;