import type { Message, Model } from '@agforge/core'; /** * 压缩结果。 * * 纯数据结构,不包含消息格式。 * Compressor 只负责生成摘要文本,消息格式化由 Manager 负责。 */ export type CompressionResult = { /** 压缩后的摘要文本(为空字符串表示直接丢弃,不生成摘要) */ summary: string; /** 压缩后的 token 数量(用于后续判断和统计) */ tokenCount: number; }; /** * 压缩器执行上下文。 * 提供压缩操作所需的信息。 */ export type CompressorContext = { /** 模型实例(可用于 LLM 摘要压缩等场景) */ model: Model; /** 目标 token 数量(可选,由策略提供,指导压缩到多大) */ targetTokens?: number; }; /** * 压缩器接口。 * * 纯函数式组件,只负责将消息列表压缩成摘要文本。 * - 输入:待压缩的消息列表(已由 Strategy 分离出来) * - 输出:压缩后的摘要文本 + token 数 * - 不关心消息分区、不关心消息格式化 */ export type Compressor = { /** * 执行压缩。 * * 将给定的消息列表压缩成摘要文本。 * 压缩器可以根据 context 中的 targetTokens 来决定压缩的程度。 * * @param messages - 待压缩的消息列表(由 Strategy 分离出来的部分) * @param context - 压缩执行上下文(含可选的目标参数) * @returns 压缩结果(摘要文本 + token 数) */ compress(messages: ReadonlyArray, context: CompressorContext): Promise; };