UNPKG

@mastra/core

Version:
35 lines • 1.43 kB
import type { MastraDBMessage } from '../agent/message-list/index.js'; import type { MemoryStorage, StorageListMessagesInput } from '../storage/index.js'; import type { MemoryTokenBoundary } from './message-history-config.js'; type TokenCounter = { countMessage(message: MastraDBMessage): number | Promise<number>; }; type HistoryLimits = { maxMessages?: number; maxTokens?: number; atMaxRemoveTokens?: number; }; export type LoadMessageHistoryArgs = HistoryLimits & { storage: MemoryStorage; threadId: string; resourceId?: string; boundary?: MemoryTokenBoundary; filter?: StorageListMessagesInput['filter']; tokenCounter?: TokenCounter; initialTokens?: number; includeOverflow?: boolean; pageSize?: number; }; export type LoadMessageHistoryResult = { messages: MastraDBMessage[]; overflow: MastraDBMessage[]; }; export declare function groupLinkedToolMessages(messages: MastraDBMessage[]): MastraDBMessage[][]; /** * Loads newest message history through finite storage pages and applies count/token limits. * Pages use an inclusive timestamp cursor plus ID de-duplication so messages sharing a * timestamp are not skipped. Messages linked by a tool-call ID are retained or omitted together. */ export declare function loadMessageHistory(args: LoadMessageHistoryArgs): Promise<LoadMessageHistoryResult>; export {}; //# sourceMappingURL=load-message-history.d.ts.map