import { Context } from "koishi"; import { HistoryConfig } from "./config"; import { AgentLogEntry, AgentObservationLog, AgentThoughtLog, L1HistoryItem, MessageData, SystemEventData } from "./types"; /** * L1 工作记忆管理器 (混合模式) * 负责将核心事件(消息、系统事件)持久化到数据库, * 将高频的 Agent 内部事件(思考、动作、观察)记录到本地文件系统, * 并提供统一的方法来检索和组合这些来源的数据,以构建线性的历史记录。 */ export declare class InteractionManager { private ctx; private config; private logger; private basePath; constructor(ctx: Context, config: HistoryConfig); private getLogFilePath; private ensureDirExists; private appendToLog; recordThought(turnId: string, platform: string, channelId: string, thoughts: AgentThoughtLog["thoughts"]): Promise; recordAction(turnId: string, platform: string, channelId: string, action: { function: string; params: Record; }): Promise; recordObservation(actionId: string, platform: string, channelId: string, observation: Omit): Promise; recordHeartbeat(turnId: string, platform: string, channelId: string, current: number, max: number): Promise; private getAgentHistoryFromFile; recordMessage(message: MessageData): Promise; recordSystemEvent(event: SystemEventData): Promise; /** * 获取指定频道的 L1 线性历史记录。 * @param channelId 频道 ID * @param limit 检索的事件数量上限 * @returns 按时间升序排列的事件数组 */ getL1History(platform: string, channelId: string, limit: number): Promise; private logEntryToHistoryItem; pruneOldData(): Promise; clearAgentHistory(platform?: string, channelId?: string): Promise; getAgentHistoryForDateRange(platform: string, channelId: string, startDate: Date, endDate: Date): Promise; }