import type { ToolSet } from '../../../_types/@internal_ai-sdk-v5/dist/index.js';
import type { MastraDBMessage } from '../../../agent/message-list/index.js';
/**
 * A raw chunk collected during the stream.
 * We only store the type and payload — everything needed to reconstruct messages post-stream.
 */
export type CollectedChunk = {
    type: string;
    payload: any;
    metadata?: Record<string, any>;
};
/**
 * Build MastraDBMessage entries from the full sequence of stream chunks.
 *
 * This replaces the previous approach of flushing text/reasoning deltas into
 * messages mid-stream. By walking the complete chunk sequence we:
 *
 * 1. Produce exactly one text part per text-start/text-end span (no duplicates)
 * 2. Produce exactly one reasoning part per reasoning-start/reasoning-end span
 * 3. Preserve correct stream ordering (text before tool-call if that's how they arrived)
 * 4. Use providerMetadata with "last seen wins" semantics per AI SDK convention
 * 5. Skip empty text spans (empty-string deltas only) — no more empty text parts in DB
 * 6. Merge tool-call + tool-result into a single part with state: 'result' when applicable
 */
export declare function buildMessagesFromChunks({ chunks, messageId, responseModelMetadata, tools, createdAt, }: {
    chunks: CollectedChunk[];
    messageId: string;
    responseModelMetadata?: {
        metadata: Record<string, unknown>;
    };
    tools?: ToolSet;
    createdAt?: Date;
}): MastraDBMessage[];
//# sourceMappingURL=build-messages-from-chunks.d.ts.map