import type { MastraDBMessage, MessageList } from '@mastra/core/agent';
import type { BufferedObservationChunk, ObservationalMemoryRecord } from '@mastra/core/storage';
/**
 * Find the index of the last completed observation boundary (end marker) in a message's parts.
 * Returns -1 if no completed observation is found.
 */
export declare function findLastCompletedObservationBoundary(message: MastraDBMessage): number;
/**
 * Get unobserved parts from a message.
 * If the message has a completed observation (start + end), only return parts after the end.
 * If observation is in progress (start without end), include parts before the start.
 * Otherwise, return all parts.
 */
export declare function getUnobservedParts(message: MastraDBMessage): MastraDBMessage['content']['parts'];
/**
 * Check if a message has any unobserved parts.
 */
export declare function hasUnobservedParts(message: MastraDBMessage): boolean;
/**
 * Compute a cursor pointing at the latest message by createdAt.
 * Used to derive a stable observation boundary for replay pruning.
 */
export declare function getLastObservedMessageCursor(messages: MastraDBMessage[]): {
    createdAt: string;
    id: string;
} | undefined;
/**
 * Check if a message is at or before a cursor (by createdAt then id).
 */
export declare function isMessageAtOrBeforeCursor(msg: MastraDBMessage, cursor: {
    createdAt: string;
    id: string;
}): boolean;
/**
 * Safely extract buffered observation chunks from a record.
 * Handles both array and JSON-string formats, returning empty array if malformed.
 */
/**
 * Filter out already-observed messages from the in-memory context.
 * Uses marker-boundary pruning (preferred) or record-based fallback.
 *
 * The `fallbackCursor` is optional — callers that need it should resolve it
 * from thread metadata before calling this function.
 */
export declare function filterObservedMessages(opts: {
    messageList: MessageList;
    record?: ObservationalMemoryRecord;
    useMarkerBoundaryPruning?: boolean;
    fallbackCursor?: {
        createdAt: string;
        id: string;
    };
}): void;
export declare function getBufferedChunks(record: ObservationalMemoryRecord | null | undefined): BufferedObservationChunk[];
/**
 * Sort threads by their oldest unobserved message.
 * Returns thread IDs in order from oldest to most recent.
 */
/**
 * Combine active and buffered observations for the buffering observer context.
 */
export declare function combineObservationsForBuffering(activeObservations: string | undefined, bufferedObservations: string | undefined): string | undefined;
export declare function sortThreadsByOldestMessage(messagesByThread: Map<string, MastraDBMessage[]>): string[];
/**
 * Strip any thread tags that the Observer might have added.
 * Thread attribution is handled externally by the system, not by the Observer.
 */
export declare function stripThreadTags(observations: string): string;
//# sourceMappingURL=message-utils.d.ts.map