import { O as SessionMessage, a as alignBoundaryForward, c as createCompactFunction, d as sanitizeToolPairs, i as alignBoundaryBackward, l as findTailCutByTokens, n as CompactOptions, o as buildSummaryPrompt, r as CompactResult, s as computeSummaryBudget, t as COMPACTION_PREFIX, u as isCompactionMessage } from "../../../compaction-helpers-CzCq1-fF.js"; //#region src/experimental/memory/utils/tokens.d.ts /** Approximate characters per token for English text */ declare const CHARS_PER_TOKEN = 4; /** Approximate token multiplier per whitespace-separated word */ declare const WORDS_TOKEN_MULTIPLIER = 1.3; /** Approximate overhead tokens per message (role, framing) */ declare const TOKENS_PER_MESSAGE = 4; /** * Estimate token count for a string using a hybrid heuristic. * * Takes the max of two estimates: * - Character-based: `length / 4` — better for dense content (JSON, code, URLs) * - Word-based: `words * 1.3` — better for natural language prose * * This is a heuristic. Do not use where exact counts are required. */ declare function estimateStringTokens(text: string): number; /** * Estimate total token count for an array of UIMessages. * * Walks each message's parts (text, tool invocations, tool results) * and applies per-message overhead. * * This is a heuristic. Do not use where exact counts are required. */ declare function estimateMessageTokens(messages: SessionMessage[]): number; //#endregion //#region src/experimental/memory/utils/compaction.d.ts interface TruncateOptions { /** Number of recent messages to keep intact (default: 4) */ keepRecent?: number; /** Max chars for tool outputs in older messages (default: 500) */ maxToolOutputChars?: number; /** Max chars for text parts in older messages (default: 10000) */ maxTextChars?: number; } /** * Truncate tool outputs and long text in older messages. * Returns a new array — input messages are not mutated. * * Recent messages (last `keepRecent`) are left intact. * Older messages get tool outputs and long text truncated. * * Use in assembleContext() before sending to the LLM: * ```typescript * async assembleContext() { * const history = this.sessions.getHistory(this._sessionId); * const truncated = truncateOlderMessages(history); * return convertToModelMessages(truncated); * } * ``` */ declare function truncateOlderMessages(messages: SessionMessage[], options?: TruncateOptions): SessionMessage[]; //#endregion export { CHARS_PER_TOKEN, COMPACTION_PREFIX, type CompactOptions, type CompactResult, TOKENS_PER_MESSAGE, type TruncateOptions, WORDS_TOKEN_MULTIPLIER, alignBoundaryBackward, alignBoundaryForward, buildSummaryPrompt, computeSummaryBudget, createCompactFunction, estimateMessageTokens, estimateStringTokens, findTailCutByTokens, isCompactionMessage, sanitizeToolPairs, truncateOlderMessages }; //# sourceMappingURL=index.d.ts.map