/** * Pi Sidecar Persister — append-only JSONL persistence for Pi child * process session events. * * Each parsed JSON event from the Pi CLI is appended to a sidecar file * at `.rolebox/pi-sessions/{sessionId}.jsonl`. On recovery, these files * are scanned and replayed to reconstruct in-memory session state. * * The notify-dedup file is also stored in the same directory for * persistent deduplication of parent notifications across restarts. * * @module */ /** * Resolve the sidecar directory path. * Uses process.cwd()/.rolebox/pi-sessions by default. */ export declare function getSidecarDir(): string; /** * Resolve the sidecar file path for a given session ID. */ export declare function getSidecarPath(sessionId: string): string; /** * Resolve the notify-dedup file path. */ export declare function getNotifyDedupPath(): string; /** * Append a single JSON event to the session sidecar file. * Creates the directory and file if needed. Best-effort — never throws. */ export declare function appendEvent(sessionId: string, event: unknown): Promise; /** * Read all JSON lines from a session sidecar file. * Returns an array of parsed JSON objects, or null if the file does not exist. * Corrupt lines are skipped. */ export declare function readSession(sessionId: string): Promise; /** * Delete the sidecar file for a session. Best-effort — never throws. * * NOTE: The process-session exit path no longer calls this — child * transcripts are retained for diagnosis/recovery and bounded by * {@link pruneSidecars}. This remains exported for explicit teardown * (e.g. tests, session deletion flows). */ export declare function cleanup(sessionId: string): Promise; /** * Scan the sidecar directory for orphaned session sidecar files. * Returns an array of session IDs (filename without .jsonl extension), * excluding the notify-dedup file. */ export declare function scanOrphanedSessions(): string[]; /** * Maximum number of child-transcript sidecars (`{sessionId}.jsonl`) * retained in the sidecar directory. Older transcripts beyond this cap * are pruned by mtime. The just-finished transcript is never pruned — * `pruneSidecars()` is only invoked AFTER a child exits, so the most * recent file (by mtime) is always the one just written. This bounds * disk growth while keeping completed/failed children inspectable. */ export declare const MAX_RETAINED_SIDECARS = 50; /** * Prune sidecar transcripts down to the most recent `keep` (by mtime). * * Only `{sessionId}.jsonl` transcripts are counted — `notify-dedup.json` * and `{sessionId}.systemprompt.txt` companions are never eligible. * System-prompt companions are removed in lockstep with their transcript: * when a `.jsonl` is pruned (or is missing entirely, leaving an orphaned * companion), the matching `.systemprompt.txt` is removed too. * * Best-effort — never throws. Returns the number of files removed. */ export declare function pruneSidecars(keep?: number): number; /** * Resolve the system-prompt companion path for a session. * The effective system prompt (delivered via `--append-system-prompt`) * is persisted next to the child transcript so completed/failed children * can be inspected after the fact. */ export declare function getSystemPromptPath(sessionId: string): string; /** * Persist the effective system prompt next to the session transcript. * Best-effort — never throws. */ export declare function writeSystemPrompt(sessionId: string, text: string): Promise; /** * Load the notification dedup set from disk. * Returns an empty Set if the file does not exist or is corrupt. */ export declare function loadNotifyDedup(): Set; /** * Persist the notification dedup set to disk. * Best-effort — never throws. */ export declare function persistNotifyDedup(set: Set): Promise; /** * Synchronously persist the notification dedup set to disk. * Used in process exit handlers where async operations may not complete. */ export declare function persistNotifyDedupSync(set: Set): void; //# sourceMappingURL=sidecar-persister.d.ts.map