/** * Reading a Pi session file into the canonical vocabulary. * * Two rules decide everything here: * - no result body crosses (FR-24). A tool result becomes one outcome line (FR-23, FR-25); * - nothing is guessed. An entry type this adapter does not know is skipped and counted, * and an unparsable line makes the whole file unreadable rather than shorter. */ import type { CanonicalTurn } from "./contract.js"; import { type PiEntry, type PiSessionHeader } from "./format.js"; export interface ParsedSessionFile { header: PiSessionHeader | null; entries: PiEntry[]; /** True when a line was not JSON: the file was cut, or written by something else. */ truncated: boolean; } export interface LoadedTurns { turns: CanonicalTurn[]; /** Entry types this adapter does not know. Visible so the preview can warn (T-PI-14). */ skippedEntryTypes: string[]; skippedCount: number; /** Set when the append-only entry graph cannot produce one trustworthy active branch. */ unreadable: string | null; } export interface ResolvedPiEntries { /** The active leaf's complete parent chain, before compaction is applied. */ activePath: PiEntry[]; /** The entries Pi would put in model context after applying its latest compaction. */ contextEntries: PiEntry[]; unreadable: string | null; } export declare function parseSessionText(text: string): ParsedSessionFile; /** Resolve Pi's active leaf and reproduce its compaction-aware context projection. */ export declare function resolveActiveEntries(entries: PiEntry[]): ResolvedPiEntries; export declare function entriesToTurns(entries: PiEntry[]): LoadedTurns; /** Short human title: the session's own name, else its first user message. */ export declare function titleFromEntries(entries: PiEntry[]): string | null; /** Files named by raw Pi tool inputs, before canonical credential redaction. */ export declare function changedPathsFromEntries(entries: PiEntry[]): string[]; /** The last timestamp the file recorded, ISO-8601 UTC, or null. */ export declare function lastTimestamp(entries: PiEntry[]): string | null;