/** * Bounded, read-only projection of host-authorized Pi transcripts. * * Callers never supply transcript paths. Each inventory candidate is opened * once, without following symlinks where the platform exposes O_NOFOLLOW, * then fstat, snapshot read, parse, active-chain selection, and projection all * operate from that same handle snapshot. No transcript bytes are cached. */ export declare const SESSION_HISTORY_VERSION: 1; export declare const SESSION_HISTORY_URI_SCHEME: "session://"; export declare const MAX_SESSION_HISTORY_FILES = 100; /** @deprecated History reads no longer have a byte budget. */ export declare const MAX_SESSION_HISTORY_BYTES: number; export declare const MAX_SESSION_HISTORY_MATCHES = 20; export declare const MAX_SESSION_HISTORY_SNIPPET_CHARS = 1000; export declare const MAX_SESSION_HISTORY_QUERY_CHARS = 4096; export declare const MAX_SESSION_HISTORY_OMISSIONS = 64; export declare const SESSION_HISTORY_INCLUDES: readonly ["user", "assistant", "visible_custom", "compaction", "tool_result"]; export declare const DEFAULT_SESSION_HISTORY_INCLUDE: readonly ["user", "assistant", "visible_custom", "compaction"]; export type SessionHistoryInclude = (typeof SESSION_HISTORY_INCLUDES)[number]; /** Paths exist only in the host-side inventory and are never returned. */ export interface SessionHistoryInventoryEntry { path: string; sessionId?: string; fileName?: string; id?: string; sizeBytes?: number; modified?: Date | number | string; revision?: string; headerValid?: boolean; cwd?: string; } export interface SessionHistoryInventory { generation?: number; entries: readonly SessionHistoryInventoryEntry[]; /** Absolute candidate offset of this supplied window (default 0). */ offset?: number; /** Additional candidates exist beyond this window (default false). */ hasMore?: boolean; /** Discovery itself was not budget-truncated (default true). */ complete?: boolean; } export type SessionHistoryInventoryValue = SessionHistoryInventory | readonly SessionHistoryInventoryEntry[]; export type SessionHistoryInventoryProvider = (signal?: AbortSignal) => SessionHistoryInventoryValue | Promise; export interface SessionHistoryInventoryProviderObject { list(signal?: AbortSignal): SessionHistoryInventoryValue | Promise; } export type SessionHistoryInventorySource = SessionHistoryInventoryValue | SessionHistoryInventoryProvider | SessionHistoryInventoryProviderObject; export interface SessionHistoryServiceOptions { inventory: SessionHistoryInventorySource; } export type SessionHistoryOmissionReason = "invalid-inventory" | "missing" | "symlink" | "non-regular" | "over-budget" | "invalid-header" | "session-id-mismatch" | "duplicate" | "duplicate-session-id" | "read-error" | "inventory-error" | "file-limit" | "result-limit"; export interface SessionHistoryOmission { reason: SessionHistoryOmissionReason; fileName?: string; sessionId?: string; id?: string; message?: string; count?: number; } export interface SessionHistoryOptions { include?: readonly SessionHistoryInclude[]; /** One result limit: sessions for list, matches for search, entries for reads. */ limit?: number; signal?: AbortSignal; } export type SessionHistoryListOptions = SessionHistoryOptions; export interface SessionHistorySearchOptions extends SessionHistoryOptions { /** Literal matching is the compatibility default; terms require every unique normalized term in one projected entry. */ mode?: "literal" | "terms"; /** Relevance ranks exact text, continuous phrase, then the tightest term span; ties retain source order. */ sort?: "source" | "relevance"; /** Zero-based match offset within this fresh scan (not a snapshot cursor). */ offset?: number; /** Zero-based unique candidate offset; independent of match pagination. */ scanOffset?: number; } export interface SessionHistoryReadOptions extends SessionHistoryOptions { /** Zero-based projected entry offset within the selected turn or entry. */ offset?: number; } export interface SessionHistoryCompactionOptions extends Omit { /** Zero-based checkpoint offset in the newest-first timeline. */ offset?: number; } /** Minimal allowlisted identity, never the persisted recovery state. */ export interface SessionHistoryCheckpoint { checkpointId: string; previousCheckpointId?: string; source: "compaction" | "new-context"; } export interface SessionHistorySession { sessionId: string; resourceUri: string; startedAt?: number; updatedAt: number; sizeBytes: number; entryCount: number; messageCount: number; turnCount: number; firstMessage?: string; compacted: boolean; } export interface SessionHistoryEntry { sessionId: string; entryId: string; turn: number; resourceUri: string; kind: SessionHistoryInclude; text: string; timestamp: number; /** Present only for recognized Maestro compaction details. */ checkpoint?: SessionHistoryCheckpoint; } export interface SessionHistoryTurn { sessionId: string; turn: number; startedAt: number; userText: string; rowCount: number; textLength: number; entries: readonly SessionHistoryEntry[]; } interface ScanMetrics { filesRead: number; bytesRead: number; truncated: boolean; omissions: readonly SessionHistoryOmission[]; omissionCounts: Readonly>>; omissionsTruncated: boolean; } export interface SessionHistoryListResult extends ScanMetrics { version: typeof SESSION_HISTORY_VERSION; generation?: number; sessions: readonly SessionHistorySession[]; } export interface SessionHistorySearchMatch { sessionId: string; entryId: string; turn: number; resourceUri: string; kind: SessionHistoryInclude; timestamp: number; snippet: string; } export interface SessionHistorySearchResult extends ScanMetrics { version: typeof SESSION_HISTORY_VERSION; generation?: number; query: string; matches: readonly SessionHistorySearchMatch[]; /** Matches in the current file window, not cumulative across scan pages. */ matchCount: number; matchCountRelation: "exact" | "lower_bound"; coverage: "complete" | "partial" | "failed"; /** Match pagination within the current file window only. */ hasMore: boolean; nextOffset?: number; scan: { offset: number; hasMore: boolean; nextOffset?: number; }; } export interface SessionHistoryCompactionResult extends ScanMetrics { version: typeof SESSION_HISTORY_VERSION; generation?: number; checkpoints: readonly SessionHistoryEntry[]; checkpointCount: number; hasMore: boolean; nextOffset?: number; } export interface SessionHistoryEntryRead { sessionId: string; entryId: string; turn: number; resourceUri: string; entries: readonly SessionHistoryEntry[]; } export interface SessionHistoryReadResult extends ScanMetrics { version: typeof SESSION_HISTORY_VERSION; generation?: number; sessionId: string; found: boolean; hasMore: boolean; nextOffset?: number; selectedTurn?: number; selectedEntryId?: string; turn?: SessionHistoryTurn; selectedEntry?: SessionHistoryEntryRead; } export interface SessionHistoryReadRequest extends SessionHistoryReadOptions { sessionId: string; entryId?: string; /** Exact checkpoint identity or compaction entry id; never a text search. */ checkpointId?: string; turn?: number; } export declare function sessionHistoryUri(sessionId: string): string; export declare function sessionEntryUri(sessionId: string, entryId: string): string; export declare const sessionHistoryEntryUri: typeof sessionEntryUri; export interface ParsedSessionHistoryUri { sessionId: string; entryId?: string; } export declare function parseSessionHistoryUri(value: string): ParsedSessionHistoryUri | undefined; export declare class SessionHistoryService { #private; constructor(source: SessionHistoryInventorySource | SessionHistoryServiceOptions); list(options?: SessionHistoryListOptions): Promise; listSessions(options?: SessionHistoryListOptions): Promise; search(query: string, options?: SessionHistorySearchOptions): Promise; searchSessions(query: string, options?: SessionHistorySearchOptions): Promise; compactions(options?: SessionHistoryCompactionOptions): Promise; listCompactions(options?: SessionHistoryCompactionOptions): Promise; read(sessionId: string, options?: SessionHistoryReadOptions): Promise; read(request: SessionHistoryReadRequest): Promise; readSession(sessionId: string, options?: SessionHistoryReadOptions): Promise; readEntry(sessionId: string, entryId: string, options?: SessionHistoryReadOptions): Promise; readTurn(sessionId: string, turn: number, options?: SessionHistoryReadOptions): Promise; readUri(uri: string, options?: SessionHistoryReadOptions): Promise; } export declare function createSessionHistoryService(source: SessionHistoryInventorySource | SessionHistoryServiceOptions): SessionHistoryService; export declare function listSessionHistory(source: SessionHistoryInventorySource | SessionHistoryServiceOptions, options?: SessionHistoryListOptions): Promise; export declare function searchSessionHistory(source: SessionHistoryInventorySource | SessionHistoryServiceOptions, query: string, options?: SessionHistorySearchOptions): Promise; export declare function listSessionCompactions(source: SessionHistoryInventorySource | SessionHistoryServiceOptions, options?: SessionHistoryCompactionOptions): Promise; export declare function readSessionHistory(source: SessionHistoryInventorySource | SessionHistoryServiceOptions, request: SessionHistoryReadRequest): Promise; export declare function readSessionHistoryEntry(source: SessionHistoryInventorySource | SessionHistoryServiceOptions, sessionId: string, entryId: string, options?: SessionHistoryReadOptions): Promise; export declare function readSessionHistoryTurn(source: SessionHistoryInventorySource | SessionHistoryServiceOptions, sessionId: string, turn: number, options?: SessionHistoryReadOptions): Promise; /** Structured identity wins; exact summary labels retain legacy lookup support. */ export declare function sessionHistoryCheckpoint(entry: SessionHistoryEntry): SessionHistoryCheckpoint | undefined; export {};