import type { ModelInfo, ToolResultContent } from "@cline/llms"; import { CHARS_PER_TOKEN, estimateTokens, type MessageWithMetadata } from "@cline/shared"; export { CHARS_PER_TOKEN, estimateTokens }; import type { CoreCompactionSummarizerConfig } from "../../types/config"; import type { ProviderConfig } from "../../types/provider-settings"; export declare const DEFAULT_MAX_INPUT_TOKENS = 128000; /** Estimate the usable input share when only a context window is reported. */ export declare const CONTEXT_WINDOW_INPUT_RATIO = 0.9; /** Compact once the transcript consumes this share of the usable input budget. */ export declare const COMPACTION_TRIGGER_RATIO = 0.9; export declare const DEFAULT_TARGET_RATIO = 0.7; export declare const DEFAULT_PRESERVE_RECENT_TOKENS = 20000; export declare const DEFAULT_SUMMARY_MAX_OUTPUT_TOKENS = 1024; export declare const TOOL_RESULT_CHAR_LIMIT = 2000; export declare const FILE_CONTENT_CHAR_LIMIT = 2000; export declare const MIN_TRUNCATED_MESSAGE_TOKENS = 8; export interface FileOperationSummary { readFiles: string[]; modifiedFiles: string[]; } export interface CompactionSummaryMetadata { kind: "compaction_summary"; summary: string; details: FileOperationSummary; tokensBefore: number; generatedAt: number; } export type EstimateMessageTokens = (message: MessageWithMetadata) => number; /** * Resolve the model's usable prompt budget. A reported input limit is * authoritative but cannot exceed the context window. When the model only * reports a context window, retain a conservative margin for request overhead. */ export declare function resolveEffectiveMaxInputTokens(input: Pick): number | undefined; export declare function truncateText(text: string, limit: number): string; export declare function flattenToolResultContent(content: ToolResultContent["content"]): string; export declare function truncateToolResultContentForCompaction(content: ToolResultContent["content"]): ToolResultContent["content"]; export declare function formatToolInput(input: Record): string; export declare function serializeMessage(message: MessageWithMetadata): string; export declare function serializeConversation(messages: MessageWithMetadata[]): string; export declare function createTokenEstimator(): EstimateMessageTokens; export declare function isCompactionSummaryMessage(message: MessageWithMetadata): boolean; export declare function getCompactionSummaryMetadata(message: MessageWithMetadata): CompactionSummaryMetadata | undefined; export declare function isToolResultOnlyUserMessage(message: MessageWithMetadata): boolean; export declare function isTurnStartMessage(message: MessageWithMetadata): boolean; export declare function findFirstUserMessageIndex(messages: MessageWithMetadata[]): number; export declare function findLastTurnStartIndex(messages: MessageWithMetadata[]): number; export declare function findLastAssistantIndex(messages: MessageWithMetadata[]): number; export declare function findLatestSummaryIndex(messages: MessageWithMetadata[]): number; export declare function findCutIndex(messages: MessageWithMetadata[], preserveRecentTokens: number, estimateMessageTokens: EstimateMessageTokens): number; export declare function collectPaths(value: unknown): string[]; export declare function mergeUnique(base: string[], next: Iterable): string[]; export declare function extractFileOps(messages: MessageWithMetadata[]): FileOperationSummary; export declare function renderFilesSection(fileOps: FileOperationSummary): string; export declare function ensureFilesSection(summary: string, fileOps: FileOperationSummary): string; export declare function buildSummaryRequest(options: { previousSummary?: string; conversationText: string; fileOps: FileOperationSummary; }): string; export declare function resolveSummarizerConfig(options: { activeProviderConfig: ProviderConfig; summarizer?: CoreCompactionSummarizerConfig; }): ProviderConfig; export declare function buildSummaryMessage(options: { summary: string; fileOps: FileOperationSummary; tokensBefore: number; }): MessageWithMetadata;