import type { CoreMessage } from "acp-kernel"; export interface SnapRenderOptions { size: number; font?: string; cellWidth?: number; cellHeight?: number; stretch?: boolean; variant?: string; lineRepeat?: number; columns?: number; } export interface Shape { font: "5x8" | "8x8" | "6x12" | "8x13" | "silver"; cellWidth: number; cellHeight: number; stretch?: boolean; variant: "sent" | "bw"; stopwordDim?: boolean; columns?: number; lineRepeat: number; frameSize: number; frameTokenEstimate: number; imageDetail?: "auto" | "low" | "high" | "original"; } export declare const SHAPE_VARIANTS: { readonly "8x8r-bw": { readonly font: "8x8"; readonly cellWidth: 8; readonly cellHeight: 8; readonly variant: "bw"; readonly lineRepeat: 2; readonly frameSize: 1568; }; readonly "8x8r-sent": { readonly font: "8x8"; readonly cellWidth: 8; readonly cellHeight: 8; readonly variant: "sent"; readonly lineRepeat: 2; readonly frameSize: 1568; }; readonly "8x8u-bw": { readonly font: "8x8"; readonly cellWidth: 8; readonly cellHeight: 8; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "8x8u-sent": { readonly font: "8x8"; readonly cellWidth: 8; readonly cellHeight: 8; readonly variant: "sent"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "6x6u-bw": { readonly font: "8x8"; readonly cellWidth: 6; readonly cellHeight: 6; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "6x6u-sent": { readonly font: "8x8"; readonly cellWidth: 6; readonly cellHeight: 6; readonly variant: "sent"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "5x8-bw": { readonly font: "5x8"; readonly cellWidth: 5; readonly cellHeight: 8; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 2576; }; readonly "5x8-sent": { readonly font: "5x8"; readonly cellWidth: 5; readonly cellHeight: 8; readonly variant: "sent"; readonly lineRepeat: 1; readonly frameSize: 2576; }; readonly "6x12-dim": { readonly font: "6x12"; readonly cellWidth: 6; readonly cellHeight: 12; readonly variant: "bw"; readonly stopwordDim: true; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "8x13-bw": { readonly font: "8x13"; readonly cellWidth: 8; readonly cellHeight: 13; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "8on16-bw": { readonly font: "8x13"; readonly cellWidth: 8; readonly cellHeight: 16; readonly stretch: false; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "8on22-bw": { readonly font: "8x13"; readonly cellWidth: 8; readonly cellHeight: 22; readonly stretch: false; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "11on16-bw": { readonly font: "8x13"; readonly cellWidth: 11; readonly cellHeight: 16; readonly stretch: false; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "silver16-bw": { readonly font: "silver"; readonly cellWidth: 16; readonly cellHeight: 16; readonly variant: "bw"; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "doc-8on16-bw": { readonly font: "8x13"; readonly cellWidth: 8; readonly cellHeight: 16; readonly stretch: false; readonly variant: "bw"; readonly columns: 2; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "doc-8on16-sent": { readonly font: "8x13"; readonly cellWidth: 8; readonly cellHeight: 16; readonly stretch: false; readonly variant: "sent"; readonly columns: 2; readonly lineRepeat: 1; readonly frameSize: 1568; }; readonly "doc-8on16-sent-dim": { readonly font: "8x13"; readonly cellWidth: 8; readonly cellHeight: 16; readonly stretch: false; readonly variant: "sent"; readonly stopwordDim: true; readonly columns: 2; readonly lineRepeat: 1; readonly frameSize: 1568; }; }; export type ShapeVariantName = keyof typeof SHAPE_VARIANTS; export declare function isShapeVariantName(value: unknown): value is ShapeVariantName; /** What will read the frames: the wire API (billing) and model id (shape). */ export interface ShapeTarget { api?: string; id?: string; } export declare function resolveShape(model?: ShapeTarget, variant?: ShapeVariantName | "auto"): Shape; export declare const FRAME_TOKEN_ESTIMATE = 5024; export declare const DIM_ON = "\u000E"; export declare const DIM_OFF = "\u000F"; /** Printed in place of newline runs: the native renderer fills this cell black. */ export declare const NEWLINE_GLYPH = "\u2588"; export declare function normalize(text: string, shape?: Pick): string; /** Unsafe = more than 5% of graphic characters would hit the `?` fallback. */ export declare function scanRenderability(text: string, shape?: Pick): { isSafe: boolean; unrenderableRatio: number; }; export declare function resolveShapeForText(text: string, model?: ShapeTarget, variant?: ShapeVariantName | "auto"): Shape; export declare function dimStopwords(text: string): string; interface Geometry { cols: number; rows: number; capacity: number; } export declare function geometry(shape: Shape, size?: number): Geometry; export interface RenderedFrame { data: string; cols: number; rows: number; chars: number; } /** Split normalized text into per-frame page strings for a shape. */ export declare function paginate(text: string, shape: Shape, frameSize?: number): string[]; /** Serialize acp-kernel core messages into archive text (¶-scoped sections, * tool output dimmed and merged under its call). */ export declare function serializeCore(messages: CoreMessage[]): string; export interface SnapFrame { sha: string; bytes: number; tokens: number; } export interface SnapBatch { /** Block ids rendered into this batch's frames (all of them). */ blockIds: string[]; /** Frame shas in page order. */ shas: string[]; tokens: number; archivedAt: number; } export interface SnapManifest { frames: SnapFrame[]; archivedIds: string[]; /** v2 block-snap batches; flat `frames` is rebuilt from these when present. */ batches?: SnapBatch[]; } export declare const DEFAULT_MAX_FRAMES = 16; /** Official hard cap: a caller-supplied maxFrames can only lower, never raise. */ export declare const MAX_FRAMES_HARD = 80; export declare function emptyManifest(): SnapManifest; export declare function loadManifest(sessionFile: string): SnapManifest; export declare function saveManifest(sessionFile: string, manifest: SnapManifest): void; export declare function frameTokens(manifest: SnapManifest): number; /** Render discarded core messages into frames, persist PNGs content-addressed * under the snap store dir, and extend the session manifest. */ export declare function archiveDiscarded(options: { sessionFile: string; discarded: CoreMessage[]; manifest: SnapManifest; model?: ShapeTarget; variant?: ShapeVariantName; maxFrames: number; }): Promise<{ manifest: SnapManifest; added: number; }>; export interface BlockSnapshot { blockId: string; tier: number; topic?: string; summary: string; /** Official-style scoped serialization of the block's original messages * (¶user:/¶ai:/¶call:, tool output dimmed). Preferred over `summary` when * present — frames then read like official archives instead of flat text. */ source?: string; } /** Serialize block archives the way the official serializer bounds source * text: one labeled section per block, chronological. Scoped source wins so * frames visually match official snapcompact; summary is the fallback for * callers without the original messages (idle maintenance). */ export declare function serializeBlocks(blocks: BlockSnapshot[]): string; /** Rebuild the flat frame list from batches (GC + FIFO cap). Frames whose PNG * vanished from disk are dropped here too (buildSnapMessage would skip them * anyway, but billing estimates must not count missing frames). */ export declare function rebuildFramesFromBatches(manifest: SnapManifest, maxFrames: number): SnapManifest; /** Render block summaries into frames and append them as one batch. Source * text is re-serialized from the blocks themselves (official-style: frames * are a pure function of Archive.text, never blind carry-forward). */ export declare function archiveBlocks(options: { sessionFile: string; blocks: BlockSnapshot[]; manifest: SnapManifest; model?: ShapeTarget; variant?: ShapeVariantName; maxFrames: number; }): Promise<{ manifest: SnapManifest; added: number; }>; /** Drop batches whose blocks are ALL gone from the active set (consumed by * tier-2 distillation or deactivated), then rebuild + cap the frame list. */ export declare function gcManifest(manifest: SnapManifest, activeBlockIds: Set, maxFrames: number): SnapManifest; export interface SnapUserMessage { role: "user"; content: Array<{ type: "text"; text: string; } | { type: "image"; data: string; mimeType: string; }>; } /** Rebuild the per-turn attachment message: one header plus every persisted * frame, oldest first. Missing PNG files are skipped (cache dir cleaned). */ export declare function buildSnapMessage(manifest: SnapManifest): SnapUserMessage | undefined; export {};