/**
 * Session Manager - Persist and resume conversations
 * Similar to Vigthoria's session persistence
 */
import { ChatMessage } from './api.js';
export type AuthState = {
    token: string | null;
    expiresAt: number | null;
    isValid: boolean;
};
export type CliError = {
    code: string;
    message: string;
    details?: any;
    isCritical: boolean;
};
/**
 * Validate persisted authentication state without assuming any field is present.
 *
 * Production hygiene: by default this helper is SILENT.  Earlier revisions
 * wrote ``console.warn`` for every missing-token branch, which polluted
 * stderr on PowerShell (NativeCommandError styling) and surfaced as noise
 * on first-run installs.  Pass ``{ silent: false }`` only when the caller
 * actually wants the warning visible.
 */
export declare function validateSession(session: AuthState, options?: {
    silent?: boolean;
}): boolean;
/**
 * Load persisted authentication state and normalize nullable token fields safely.
 *
 * Production behaviour: first-run users (no session file yet) get a clean
 * ``{ token: null, expiresAt: null, isValid: false }`` instead of an
 * exception.  Callers that need a hard failure can inspect ``isValid``.
 */
export declare function loadSession(): Promise<AuthState>;
export interface Session {
    id: string;
    name: string;
    project: string;
    model: string;
    messages: ChatMessage[];
    memorySummary?: string;
    compactedAt?: string | null;
    createdAt: string;
    updatedAt: string;
    agentMode: boolean;
    operatorMode?: boolean;
    lastAgentRunOutcome?: Record<string, unknown> | null;
}
export declare class SessionManager {
    private sessionsDir;
    private readonly compactThreshold;
    private readonly retainRecentMessages;
    /** Keep at most this many session files on disk per CLI install. */
    private readonly maxRetainedSessions;
    /** Sessions older than this are pruned (90 days). */
    private readonly retentionWindowMs;
    /** Avoid running prune on every save — at most once per CLI process. */
    private prunedThisProcess;
    constructor();
    private ensureDir;
    /**
     * Prune sessions older than the retention window AND cap the number of
     * retained files.  This is best-effort: any unreadable file is treated
     * as stale and removed.  Pruning is bounded to once per process.
     */
    private pruneIfNeeded;
    /**
     * Generate unique session ID
     */
    private generateId;
    /**
     * Create a new session
     */
    create(project: string, model: string, agentMode?: boolean, operatorMode?: boolean): Session;
    /**
     * Save session to disk — atomic + 0600 mode so transcripts cannot be
     * read by other local users on a shared POSIX host.
     */
    save(session: Session): void;
    /**
     * Load session by ID
     */
    load(id: string): Session | null;
    private normalizeProjectKey;
    /**
     * Get the most recent session for a project
     */
    getLatest(project: string): Session | null;
    /**
     * List all sessions (metadata only) — corrupt or unreadable files are
     * skipped silently unless VIGTHORIA_DEBUG=1.
     */
    list(): Omit<Session, 'messages'>[];
    /**
     * Delete a session
     */
    delete(id: string): boolean;
    /**
     * Clear all sessions
     */
    clearAll(): number;
    /**
     * Add message to session
     */
    addMessage(session: Session, message: ChatMessage): void;
    compactInMemory(session: Session): Session;
    buildMemoryContext(session: Session | null): string;
    private compactSession;
    private isPersistentSystemMessage;
    private mergePersistentAndRecent;
    private mergeSummaries;
    private summarizeMessages;
    private normalizeMessageContent;
    /**
     * Get session summary for display
     */
    getSummary(session: Session): string;
}
