/**
 * SessionPersistence -- Save/restore agent state across sessions.
 *
 * Handles session start recovery, pre-compact state dumps,
 * and session end summaries. Ensures zero context loss during
 * compaction or session boundaries.
 *
 * @connexum/ai-governance
 */
export interface SessionState {
    sessionId: string;
    agentName: string;
    startedAt: string;
    lastSavedAt: string;
    /** Active tasks at time of save */
    activeTasks: TaskSnapshot[];
    /** Files modified in this session */
    modifiedFiles: string[];
    /** Pending decisions awaiting human input */
    pendingDecisions: PendingDecision[];
    /** Token usage so far */
    tokenUsage: {
        input: number;
        output: number;
        cost: number;
    };
    /** Custom state the agent wants to persist */
    customState: Record<string, unknown>;
    /** SHA-256 of the serialized state (excluding this field) */
    integrity: string;
}
export interface TaskSnapshot {
    id: string;
    description: string;
    status: 'in_progress' | 'blocked' | 'waiting';
    startedAt: string;
    context?: string;
}
export interface PendingDecision {
    id: string;
    description: string;
    options: string[];
    requestedAt: string;
    requiredApprover?: string;
}
export interface SessionSummary {
    sessionId: string;
    agentName: string;
    duration: string;
    tasksCompleted: number;
    tasksRemaining: number;
    filesModified: string[];
    tokenUsage: {
        input: number;
        output: number;
        cost: number;
    };
    decisionsResolved: number;
    decisionsPending: number;
    summary: string;
}
/** Minimal encryption interface for loose coupling with EncryptedStorage (T-033) */
export interface SessionEncryption {
    writeEncrypted(filePath: string, data: string): void;
    readEncrypted(filePath: string): string;
}
export interface SessionPersistenceConfig {
    /** Base directory for session data */
    stateDir: string;
    /** Agent name */
    agentName: string;
    /** Daily logs directory */
    dailyLogDir?: string;
    /** Maximum session states to keep (default: 10) */
    maxStates?: number;
    /** T-033: Encryption for session state at rest */
    encryption?: SessionEncryption;
}
export declare class SessionPersistence {
    private config;
    private currentState;
    private encryption?;
    constructor(config: SessionPersistenceConfig);
    private ensureDirectories;
    /**
     * Start a new session. Checks for interrupted work from previous session.
     * Returns the previous state if one exists (for recovery).
     */
    startSession(): {
        sessionId: string;
        previousState: SessionState | null;
        interrupted: boolean;
    };
    /**
     * Save current session state to disk. Call before compaction or periodically.
     */
    saveState(updates?: Partial<Pick<SessionState, 'activeTasks' | 'modifiedFiles' | 'pendingDecisions' | 'tokenUsage' | 'customState'>>): void;
    /**
     * Record a file modification in the current session.
     */
    recordFileModification(filePath: string): void;
    /**
     * Record token usage.
     */
    recordTokenUsage(input: number, output: number, cost: number): void;
    /**
     * Add or update a task in the current session.
     */
    updateTask(task: TaskSnapshot): void;
    /**
     * Remove a completed task.
     */
    completeTask(taskId: string): TaskSnapshot | undefined;
    /**
     * Pre-compact dump: saves full state + writes daily log entry.
     * Called by pre-compact hook before context compaction.
     */
    preCompactDump(): string;
    /**
     * End session: generate summary, write final state + daily log.
     */
    endSession(summary: string): SessionSummary;
    /**
     * Load the most recent session state from disk.
     */
    loadLatestState(): SessionState | null;
    /**
     * Search past session logs by keyword.
     */
    searchSessionLogs(query: string, maxResults?: number): Array<{
        date: string;
        entry: Record<string, unknown>;
    }>;
    /**
     * Get session metrics for the current session.
     */
    getMetrics(): {
        tokenUsage: SessionState['tokenUsage'];
        filesModified: number;
        activeTasks: number;
        elapsed: string;
    } | null;
    /**
     * Get the current state (read-only snapshot).
     */
    getCurrentState(): Readonly<SessionState> | null;
    private stateFilePath;
    private listStateFiles;
    private loadAndVerifyState;
    private computeIntegrity;
    private pruneOldStates;
}
//# sourceMappingURL=session-persistence.d.ts.map