import type { SessionEntry, SessionMessageEntry } from "@earendil-works/pi-coding-agent"; import type { AssistantMessage } from "@earendil-works/pi-ai"; export type NativeAgentMessage = SessionMessageEntry["message"]; export interface NativeConversationSource { /** Stable participant id (the controller keeps one reader per id). */ id: string; status: string; /** * FabricTranscriptSource-compatible path: the active worker's or latest * retained run's events.jsonl (RPC event log) — or, retained-actor fallback, * a native Pi session file. */ logFile?: string; /** Stable native Pi session file, preferred as the full history source. */ sessionFile?: string; /** Explicit events.jsonl override; wins over logFile when both are given. */ eventsFile?: string; } export interface NativeToolExecution { toolCallId: string; toolName: string; args?: Record; status: "running" | "completed" | "failed"; /** tool_execution_start observed for this call. */ executionStarted?: boolean; /** Full arguments are known (start/end observed or toolcall_end delivered). */ argsComplete?: boolean; /** Accumulated partial result while running (content + details preserved whole). */ partial?: { content?: unknown[]; details?: unknown; }; /** Final result (content + details preserved whole). */ result?: { content?: unknown[]; details?: unknown; }; isError?: boolean; } interface NativeTranscriptEntry { entryId: string; parentId: string | null; entryType: string; timestamp: string; /** Present for `message` entries; the native AgentMessage, unmodified. */ message?: NativeAgentMessage; /** The whole native session entry — compaction, branch_summary, custom, … */ entry: SessionEntry; } interface NativeConversationStreaming { /** True while a partial assistant message or a tool execution is live. */ active: boolean; /** Assistant message assembled from message_start + message_update deltas. */ partialAssistant?: AssistantMessage; /** Tool executions keyed by toolCallId, including completed ones. */ tools: NativeToolExecution[]; } export interface NativeConversationTranscript { /** Native AgentMessage union: active-branch display sequence + live tail. */ messages: NativeAgentMessage[]; /** Monotonic per reader, including source, availability and window changes. */ revision: number; /** Active branch entries (root → leaf), compaction-applied, native and whole. */ entries: NativeTranscriptEntry[]; streaming: NativeConversationStreaming; pendingMessages?: { steering: string[]; followUp: string[]; }; leafId: string | null; sourceId: string; status: string; sessionFile?: string; eventsFile?: string; sessionId?: string; /** Both file windows reached the file starts and the branch path reaches root. */ historyComplete: boolean; /** Older whole-record pages are available via loadOlder(). */ hasMore: boolean; /** New complete records exist past the window (only when reads are pinned). */ hasNewer: boolean; /** Which source files could not be read, when any were given but unreadable. */ unavailable?: { sessionFile?: boolean; eventsFile?: boolean; }; /** Bounded (≤200 char) reason for the last unreadable-file condition. */ error?: string; updatedAt: number; } export declare class NativeConversationReader { #private; /** Last transcript produced; undefined before the first successful read. */ get last(): NativeConversationTranscript | undefined; /** True when decoded history is offloaded to a private disk checkpoint. */ get suspended(): boolean; /** Release decoded history without depending on the original source files. */ suspend(): boolean; read(source: NativeConversationSource, followLatest?: boolean): NativeConversationTranscript; /** Load older whole-record pages of history. Repeated calls load all of it. */ loadOlder(pages?: number): NativeConversationTranscript | undefined; /** Consume any records newer than the current window (used when pinned). */ loadNewer(): NativeConversationTranscript | undefined; /** Drop the current windows and re-read from the tail of both files. */ loadLatest(): NativeConversationTranscript | undefined; /** Drop all cached state for a clean re-read. */ clear(): void; } export {}; //# sourceMappingURL=conversation-native-reader.d.ts.map