/** Recorded facts stay whole; only the metadata returned beside a read window is bounded. */ import { Type, type Static } from "typebox"; /** Oversized arguments remain readable in the document, but become a byte count in metadata. */ export declare const MAX_EXECUTION_ARGUMENT_BYTES: number; /** Bound nested metadata by omitting whole records, with an explicit omission count. */ export declare const MAX_NESTED_CALLS_BYTES: number; /** The four public roles a history event carries on the wire, in presentation order. */ export declare const HistoryRoleSchema: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"assistant">, Type.TLiteral<"tool">, Type.TLiteral<"context">]>; export type HistoryRole = Static; /** How a recorded tool run ended. A call with no recorded result has not ended. */ export declare const ToolCallStatusSchema: Type.TUnion<[Type.TLiteral<"ok">, Type.TLiteral<"error">, Type.TLiteral<"unfinished">]>; export type ToolCallStatus = Static; /** Native nested-call evidence: no invented child result body or history seq. */ export declare const NestedCallRecordSchema: Type.TObject<{ id: Type.TString; name: Type.TString; arguments: Type.TOptional>; argumentsBytes: Type.TOptional; status: Type.TUnion<[Type.TLiteral<"ok">, Type.TLiteral<"error">, Type.TLiteral<"unfinished">]>; durationMs: Type.TOptional; error: Type.TOptional; }>; export type NestedCallRecord = Static; /** Recorded facts as the host stored them: whole records, unbounded. */ export type RecordedNestedCalls = Pick; /** Preserve the host's completeness flag; report our omissions separately. */ export declare const NestedCallsSchema: Type.TObject<{ calls: Type.TArray>; argumentsBytes: Type.TOptional; status: Type.TUnion<[Type.TLiteral<"ok">, Type.TLiteral<"error">, Type.TLiteral<"unfinished">]>; durationMs: Type.TOptional; error: Type.TOptional; }>>; complete: Type.TBoolean; trimmed: Type.TOptional; omittedCalls: Type.TOptional; }>; export type NestedCalls = Static; /** Metadata beside the read window, without a second copy of the output. */ export declare const ToolExecutionSchema: Type.TObject<{ name: Type.TString; status: Type.TUnion<[Type.TLiteral<"ok">, Type.TLiteral<"error">, Type.TLiteral<"unfinished">]>; arguments: Type.TOptional>; argumentsBytes: Type.TOptional; outputTruncated: Type.TOptional; fullOutputPath: Type.TOptional; nestedCalls: Type.TOptional>; argumentsBytes: Type.TOptional; status: Type.TUnion<[Type.TLiteral<"ok">, Type.TLiteral<"error">, Type.TLiteral<"unfinished">]>; durationMs: Type.TOptional; error: Type.TOptional; }>>; complete: Type.TBoolean; trimmed: Type.TOptional; omittedCalls: Type.TOptional; }>>; }>; export type ToolExecution = Static; /** Tool facts as recorded, unbounded. `HistoryEvent` holds these; the wire sees a bounded projection. */ export type ToolExecutionFacts = Omit & { nestedCalls?: RecordedNestedCalls; }; /** One projection event: its facts, and the document they render to. */ export type HistoryEvent = { seq: number; windowId: string; role: HistoryRole; createdAt: string | undefined; /** Message body for user/assistant/context; the run's output for a tool event. */ text: string; /** Whole recorded facts; executionMetadata bounds only the returned copy. */ execution?: ToolExecutionFacts; }; export type HistoryWindow = { windowId: string; createdAt?: string; items: HistoryEvent[]; }; /** Paired result seqs stay on the branch but redirect readers to the call's event. */ export type HistoryProjection = { windows: HistoryWindow[]; highestSeq: number; branchSeqs: Set; pairedResults: Map; }; export type HistoryFilter = { window_id?: string | null; roles?: HistoryRole[] | null; }; /** Native entries after the adapter allocates seqs and selects the active branch. */ export type DecodedHistoryItem = { seq: number; windowId: string; role: "user" | "assistant" | "tool_call" | "tool" | "system" | "developer"; /** Message body; for a tool call or result, the arguments or output text respectively. */ text: string; createdAt?: string; toolName?: string; /** Internal pairing key; never serialized. */ toolCallId?: string; /** The recorded arguments object, exactly as the host stored it. */ arguments?: Record; outputTruncated?: boolean; fullOutputPath?: string; /** The run reported an error. */ toolError?: boolean; /** Native outcome for a standalone run (e.g. bash exit status). */ recordedStatus?: ToolCallStatus; /** toolResult only: the calls this run made to other tools. */ nestedCalls?: RecordedNestedCalls; }; export type DecodedHistoryWindow = { windowId: string; createdAt?: string; items: DecodedHistoryItem[]; }; export declare function contentText(content: unknown): string; /** Bound metadata without changing the facts used for documents and search. */ export declare function executionMetadata(event: HistoryEvent): ToolExecution | undefined; /** Canonical searchable/readable text, without UI headers or continuation footers. */ export declare function historyDocument(event: HistoryEvent): string; /** Memoized `historyDocument`: search, preview, and read must agree on the same characters. */ export declare function eventDocument(event: HistoryEvent): string; /** Pair results into call events; consumed result seqs are not alternate read addresses. */ export declare function projectHistory(rawWindows: DecodedHistoryWindow[], highestSeq: number, branchSeqs: Set): HistoryProjection; /** Pages count all recorded nested calls; history_read carries the bounded records. */ export declare const NestedCallSummarySchema: Type.TObject<{ call_count: Type.TInteger; complete: Type.TBoolean; }>; /** Stable identity and a verbatim preview, starting at the search match when present. */ export declare const HistoryPageItemSchema: Type.TObject<{ seq: Type.TInteger; window_id: Type.TString; role: Type.TUnion<[Type.TLiteral<"user">, Type.TLiteral<"assistant">, Type.TLiteral<"tool">, Type.TLiteral<"context">]>; created_at: Type.TUnion<[Type.TString, Type.TNull]>; tool: Type.TOptional; tool_name_omitted: Type.TOptional; tool_status: Type.TOptional, Type.TLiteral<"error">, Type.TLiteral<"unfinished">]>>; output_truncated: Type.TOptional; full_output_path: Type.TOptional>; nested_calls: Type.TOptional>; truncated: Type.TBoolean; total_chars: Type.TInteger; content: Type.TString; offset_chars: Type.TOptional; }>; export type HistoryPageItem = Static; /** A run of tool/context events the conversation view replaces with counts. */ export declare const HistoryFoldedRowSchema: Type.TObject<{ folded: Type.TLiteral; first_seq: Type.TInteger; last_seq: Type.TInteger; count: Type.TInteger; tools: Type.TRecord<"^.*$", Type.TInteger>; omitted_tools: Type.TOptional; }>; export type HistoryFoldedRow = Static; /** Bound fold summaries while preserving exact counts in count/omitted_tools. */ export declare const MAX_FOLD_TOOL_NAMES = 20; /** Longest tool name a fold row lists; longer names are counted in `omitted_tools` instead. */ export declare const MAX_FOLD_TOOL_NAME_CHARS = 120; /** A bounded preview of one event from `matchOffset` on, plus its identity facts. */ export declare function visibleItem(event: HistoryEvent, maxChars: number, matchOffset?: number): HistoryPageItem; export declare function allItems(projection: HistoryProjection): HistoryEvent[]; export declare function unknownWindowId(projection: HistoryProjection, params: HistoryFilter): { message: string; known: string[]; } | undefined; /** Default list is a conversation; explicit roles and search show the requested events. */ export declare function filteredItems(projection: HistoryProjection, params: HistoryFilter, mode: "list" | "search"): HistoryEvent[];