import { generateText, type LanguageModel, type ModelMessage, type TelemetryOptions } from "ai"; import type { RuntimeModelReference } from "#runtime/agent/bootstrap.js"; import type { CompactionConfig, ToolLoopHarnessConfig } from "#harness/types.js"; /** * Rough token estimate: serialized JSON length / 4. Good enough for * deciding whether compaction is needed; the real token count comes back * from the model each step via {@link CompactionConfig.lastKnownInputTokens}. * * Accepts any JSON-serializable value so the reactive pruning system can * apply the same heuristic to individual tool-result parts — keeping * every layer of context management on one consistent token ruler. */ export declare function estimateTokens(value: unknown): number; /** * Best available input-token count: the model-reported count from the last * step, plus a rough character-based estimate of whatever messages have been * appended since. */ export declare function getInputTokenCount(messages: readonly ModelMessage[], config: CompactionConfig): number; /** * Returns true when the message history exceeds the compaction threshold. */ export declare function shouldCompact(messages: readonly ModelMessage[], config: CompactionConfig): boolean; /** * Resolves the model used to summarize older context during compaction. * * Reuses the active turn model when compaction should summarize with the same * reference, and resolves the authored compaction model only when configured. */ export declare function resolveCompactionModel(input: { readonly compactionModelReference?: RuntimeModelReference; readonly model: LanguageModel; readonly modelReference: RuntimeModelReference; readonly resolveModel: ToolLoopHarnessConfig["resolveModel"]; }): Promise<{ readonly model: LanguageModel; readonly providerOptions: Parameters[0]["providerOptions"]; }>; /** * Compacts messages by summarizing older history and keeping only the most * recent messages. */ export declare function compactMessages(messages: ModelMessage[], model: LanguageModel, config: CompactionConfig, providerOptions?: Parameters[0]["providerOptions"], telemetry?: TelemetryOptions, headers?: Record): Promise;