/** * session-compactor.ts — summarize a session's chunks into a compact restart document. * * Uses OpenAI chat completions with a map-reduce strategy for long sessions: * 1. Single-pass for sessions whose estimated token count fits within the limit. * 2. Multi-pass for longer sessions: map each window → reduce all partials → final format. * * Environment variables: * OPENAI_API_KEY Required. Passed to the OpenAI client. * OPENAI_SUMMARY_MODEL Override model (default: "gpt-5-nano"). * CSM_SUMMARY_MAX_OUTPUT_TOKENS Override max output tokens (default: 5000). */ import type { ChunkRow } from "./database"; export interface CompactOptions { /** Override the summarizer model. Default: OPENAI_SUMMARY_MODEL env var or "gpt-5-nano". */ model?: string; /** Override the max output token budget. Default: CSM_SUMMARY_MAX_OUTPUT_TOKENS env var or 5000. */ maxOutputTokens?: number; } export interface CompactResult { summary: string; model: string; /** Total number of LLM passes performed (map passes + reduce + final format). */ passes: number; usage: { inputTokens: number; outputTokens: number; totalTokens: number; }; } /** * Summarizes the given ordered chunks into a restart document ready to paste * into a new AI coding session. * * @throws Error if OPENAI_API_KEY is missing or any OpenAI call fails. */ export declare function compactSession(chunks: ChunkRow[], options?: CompactOptions): Promise; /** * Builds a human-readable transcript from ordered chunk rows. * Groups consecutive chunks with the same section label under a single header. */ export declare function buildTranscript(chunks: ChunkRow[]): string; /** * Splits `text` into windows of at most `windowChars` characters. * Splits on newline boundaries when possible. */ export declare function splitIntoWindows(text: string, windowChars: number): string[]; //# sourceMappingURL=session-compactor.d.ts.map