import { type FileHandle } from "node:fs/promises";
import { type PendingInputJournal, type PendingInputJournalRecord } from "./pending-input-store.ts";
import type { SessionManager } from "./session-manager.ts";
type JournalSession = Pick<SessionManager, "appendCustomEntry" | "persistHeaderNow" | "getEntries" | "getSessionFile" | "isPersisted" | "isTranscriptFlushed">;
/** How the journal makes an append durable: the file's data, and once the directory entry that names it. */
export interface JournalDurability {
    syncFile(path: string): Promise<void>;
    syncDirectory(path: string): Promise<void>;
}
export type JournalFileOpener = (path: string, flags: "r" | "r+") => Promise<Pick<FileHandle, "sync" | "close">>;
/**
 * Windows flushes only through a handle with write access (FlushFileBuffers on a read-only handle fails with EPERM,
 * senpi#3866), so the file is synced through an `r+` handle. A directory cannot be opened for writing anywhere, and
 * on Windows a directory handle cannot be flushed at all, so the directory sync is skipped there.
 */
export declare function fsJournalDurability(platform?: NodeJS.Platform, openFile?: JournalFileOpener): JournalDurability;
/**
 * The session JSONL as the pending-input journal (senpi#3549): each transition is one `custom` entry,
 * on disk and synced before the store publishes or dispatches it, even before the session's first message.
 */
export declare class SessionPendingInputJournal implements PendingInputJournal {
    private readonly session;
    private readonly durability;
    private directorySynced;
    constructor(session: JournalSession, durability?: JournalDurability);
    /**
     * A session opened without persistence (--no-session) keeps the journal in memory only, like the rest of
     * that session. A persisted session must have its file on disk before the entry counts: the header is
     * forced, the entry must reach the file itself (not the pre-conversation buffer), and the file and, once,
     * its directory are synced before this returns.
     */
    append(record: PendingInputJournalRecord): Promise<void>;
    read(): Promise<readonly PendingInputJournalRecord[]>;
    /**
     * A persisted session's transitions come from one streaming pass over its file, never from `getEntries()`:
     * on a trimmed session that would materialize and keep the whole history (senpi#3519, #3535). An in-memory
     * session has no file, so its entries are the journal.
     */
    private transitionEntries;
}
export declare class PendingInputJournalCorruptError extends Error {
    readonly code = "pending_input_journal_corrupt";
    constructor(lineNumber: number);
}
/** The entry reached the file but could not be synced: it may or may not survive a crash. */
export declare class PendingInputAppendUncertainError extends Error {
    readonly code = "pending_input_append_uncertain";
    constructor(cursor: number, file: string, cause: unknown);
}
export declare class PendingInputNotDurableError extends Error {
    readonly code = "pending_input_journal_not_durable";
    constructor();
}
export declare class PendingInputJournalGapError extends Error {
    readonly code = "pending_input_journal_gap";
    constructor(missingCursor: number);
}
export declare class PendingInputJournalError extends Error {
    readonly code = "pending_input_journal_invalid";
    constructor(entryId: string);
}
export {};
//# sourceMappingURL=pending-input-journal.d.ts.map