import type { SnapshotStorage, SnapshotLocation } from './storage.js';
import type { Snapshot, SnapshotManifest } from './types.js';
/**
 * File-based implementation of SnapshotStorage.
 * Persists session snapshots to the local filesystem under a configurable base directory.
 *
 * Directory layout:
 * ```
 * <baseDir>/<sessionId>/scopes/<scope>/<scopeId>/snapshots/
 *   snapshot_latest.json
 *   immutable_history/
 *     snapshot_<uuid7>.json
 * ```
 */
export declare class FileStorage implements SnapshotStorage {
    /** Absolute path to the root directory where all session data is stored. */
    private readonly _baseDir;
    /**
     * @param baseDir - Absolute path to the root directory for storing session snapshots.
     */
    constructor(baseDir: string);
    /**
     * Resolves the absolute file path for a given scope location and filename.
     * Validates sessionId and scopeId before constructing the path.
     */
    private _getPath;
    /**
     * Resolves the absolute path to the root directory for a session.
     * Used by deleteSession to remove all data under `<baseDir>/<sessionId>/`.
     */
    private _getSessionDir;
    /**
     * Persists a snapshot to disk.
     * If `isLatest` is true, writes to `snapshot_latest.json` (overwriting any previous).
     * Otherwise, writes to `immutable_history/snapshot_<snapshotId>.json`.
     */
    saveSnapshot(params: {
        location: SnapshotLocation;
        snapshotId: string;
        isLatest: boolean;
        snapshot: Snapshot;
    }): Promise<void>;
    /**
     * Loads a snapshot from disk.
     * If `snapshotId` is omitted, loads `snapshot_latest.json`.
     * Returns null if the file does not exist.
     */
    loadSnapshot(params: {
        location: SnapshotLocation;
        snapshotId?: string;
    }): Promise<Snapshot | null>;
    /**
     * Lists immutable snapshot IDs for a scope, sorted chronologically.
     * Since IDs are UUID v7, lexicographic sort equals chronological order.
     * `startAfter` filters to IDs after the given UUID v7 (exclusive cursor).
     * `limit` caps the number of returned IDs.
     * Returns an empty array if no snapshots exist yet.
     */
    listSnapshotIds(params: {
        location: SnapshotLocation;
        limit?: number;
        startAfter?: string;
    }): Promise<string[]>;
    /**
     * Deletes all data for a session by removing its root directory (`<baseDir>/<sessionId>/`) recursively.
     * No-ops if the session directory does not exist.
     */
    deleteSession(params: {
        sessionId: string;
    }): Promise<void>;
    /**
     * Loads the snapshot manifest for a scope.
     * Returns a default manifest with the current timestamp if none exists yet.
     */
    loadManifest(params: {
        location: SnapshotLocation;
    }): Promise<SnapshotManifest>;
    /**
     * Persists the snapshot manifest for a scope to disk.
     */
    saveManifest(params: {
        location: SnapshotLocation;
        manifest: SnapshotManifest;
    }): Promise<void>;
    /**
     * Atomically writes JSON to a file using a `.tmp` intermediary to prevent partial writes.
     * Creates parent directories if they do not exist.
     */
    private _writeJSON;
    /**
     * Reads and parses a JSON file. Returns null if the file does not exist.
     * Throws SessionError on parse failure or unexpected filesystem errors.
     */
    private _readJSON;
    /** Returns true if the error represents a missing file or directory (ENOENT). */
    private _isFileNotFoundError;
    /** Returns the file path for `snapshot_latest.json` within the given scope. */
    private _getLatestSnapshotPath;
    /**
     * Returns the file path for an immutable snapshot in `immutable_history/`.
     * Validates the snapshotId and guards against path traversal outside `_baseDir`.
     */
    private _getHistorySnapshotPath;
}
//# sourceMappingURL=file-storage.d.ts.map