/** * history-payload.ts — shrink + window the WebSocket `history` frame. * * Agent prompts still read the full on-disk `.log`. This module only shapes * what the SPA receives so a large transcript does not stall first paint: * 1. Cap `activity.steps[].preview` (tool dumps dwarf the reply). * 2. Send the newest messages first (count + byte budget). * 3. Follow with `history-prepend` chunks of older turns. */ import type { ChatMessage } from '../core/types.js'; /** Tool-step previews in history / active-run replay. Disk `.log` is unchanged. */ export declare const HISTORY_PREVIEW_MAX_CHARS = 500; /** Prefer at most this many messages in the first `history` frame. */ export declare const HISTORY_TAIL_MAX_MESSAGES = 40; /** * Soft cap on estimated UTF-16 units in the first frame. One huge latest * reply still goes out in full (the user is looking at it); older bulky * turns wait for prepend chunks. */ export declare const HISTORY_TAIL_MAX_BYTES: number; /** Older messages per `history-prepend` frame (nearest-to-tail first). */ export declare const HISTORY_PREPEND_CHUNK = 40; export declare function capHistoryPreview(preview: string | undefined): string | undefined; export declare function slimActivitySteps(steps: T[]): T[]; export declare function slimHistoryMessage(message: ChatMessage): ChatMessage; export declare function slimHistoryMessages(messages: ChatMessage[]): ChatMessage[]; export declare function estimateHistoryMessageBytes(message: ChatMessage): number; /** Index where the first-paint tail begins (0 = send everything). */ export declare function historyTailStart(messages: ChatMessage[]): number; export interface HistoryPrependChunk { messages: ChatMessage[]; startIndex: number; remaining: number; } export interface HistoryDelivery { tail: ChatMessage[]; tailStart: number; olderCount: number; prepend: HistoryPrependChunk[]; } /** * Slim previews, then split into a first-paint tail + prepend chunks. * Chunks are ordered nearest-to-tail first so each prepend attaches * without leaving a gap in the SPA transcript. */ export declare function splitHistoryDelivery(messages: ChatMessage[]): HistoryDelivery; /** First non-empty user line in the full log — session rail title. */ export declare function historySessionTitle(messages: ChatMessage[]): string | undefined; /** * Cloud transcript revision for the SPA rail + cache stamp. * * Prefer the newest message timestamp when the transcript has turns — * `lastActivity` is also bumped by metadata patches (set-workspace) and * getOrCreate touches, which must not rewrite the rail age to "Just now" * when the user merely switches sessions. * * Empty threads still fall back to lastActivity. */ export declare function historyUpdatedAt(input: { lastActivity?: Date | number | string; messages: Array<{ timestamp?: Date | number | string; }>; }): number; export declare function buildHistoryWireFrames(messages: ChatMessage[], meta: Record, decorate: (m: ChatMessage, absIndex: number) => Record): Array>; //# sourceMappingURL=history-payload.d.ts.map