import type { LanguageModelV2Prompt } from '@ai-sdk/provider-v5';
import type { LanguageModelV1Prompt, CoreMessage as CoreMessageV4 } from '../../_types/@internal_ai-sdk-v4/dist/index.js';
import type * as AIV4Type from '../../_types/@internal_ai-sdk-v4/dist/index.js';
import type { IMastraLogger } from '../../logger/index.js';
import type { IdGeneratorContext } from '../../types/index.js';
import type { MastraDBMessage, MastraMessagePart, MastraMessageV1, MessageSource, UIMessageWithMetadata, SerializedMessageListState } from './state/index.js';
import type { AIV5Type, AIV5ResponseMessage, MessageListInput } from './types.js';
export declare class MessageList {
    private messages;
    private systemMessages;
    private taggedSystemMessages;
    private memoryInfo;
    private stateManager;
    private get memoryMessages();
    private get newUserMessages();
    private get newResponseMessages();
    private get userContextMessages();
    private get memoryMessagesPersisted();
    private get newUserMessagesPersisted();
    private get newResponseMessagesPersisted();
    private get userContextMessagesPersisted();
    private generateMessageId?;
    private _agentNetworkAppend;
    private logger?;
    private isRecording;
    private recordedEvents;
    constructor({ threadId, resourceId, generateMessageId, logger, _agentNetworkAppend, }?: {
        threadId?: string;
        resourceId?: string;
        generateMessageId?: (context?: IdGeneratorContext) => string;
        logger?: IMastraLogger;
    });
    /**
     * Start recording mutations to the MessageList for observability/tracing
     */
    startRecording(): void;
    hasRecordedEvents(): boolean;
    getRecordedEvents(): Array<{
        type: 'add' | 'addSystem' | 'removeByIds' | 'clear';
        source?: MessageSource;
        count?: number;
        ids?: string[];
        text?: string;
        tag?: string;
        message?: CoreMessageV4;
    }>;
    /**
     * Stop recording and return the list of recorded events
     */
    stopRecording(): Array<{
        type: 'add' | 'addSystem' | 'removeByIds' | 'clear';
        source?: MessageSource;
        count?: number;
        ids?: string[];
        text?: string;
        tag?: string;
        message?: CoreMessageV4;
    }>;
    add(messages: MessageListInput, messageSource: MessageSource): this;
    serialize(): SerializedMessageListState;
    /**
     * Custom serialization for tracing/observability spans.
     * Returns a clean representation with just the essential data,
     * excluding internal state tracking, methods, and implementation details.
     *
     * This is automatically called by the span serialization system when
     * a MessageList instance appears in span input/output/attributes.
     */
    serializeForSpan(): {
        messages: Array<{
            role: string;
            content: unknown;
        }>;
        systemMessages: Array<{
            role: string;
            content: unknown;
            tag?: string;
        }>;
    };
    deserialize(state: SerializedMessageListState): this;
    makeMessageSourceChecker(): {
        memory: Set<string>;
        input: Set<string>;
        output: Set<string>;
        context: Set<string>;
        getSource: (message: MastraDBMessage) => MessageSource | null;
    };
    getLatestUserContent(): string | null;
    get get(): {
        all: {
            db: () => MastraDBMessage[];
            v1: () => MastraMessageV1[];
            aiV5: {
                model: () => AIV5Type.ModelMessage[];
                ui: () => AIV5Type.UIMessage[];
                prompt: () => AIV5Type.ModelMessage[];
                llmPrompt: (options?: {
                    downloadConcurrency?: number;
                    downloadRetries?: number;
                    supportedUrls?: Record<string, RegExp[]>;
                }) => Promise<LanguageModelV2Prompt>;
            };
            prompt: () => CoreMessageV4[];
            ui: () => UIMessageWithMetadata[];
            core: () => CoreMessageV4[];
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
                prompt: () => CoreMessageV4[];
                llmPrompt: () => LanguageModelV1Prompt;
            };
        };
        remembered: {
            db: () => MastraDBMessage[];
            v1: () => import("../../memory").MastraMessageV1[];
            aiV5: {
                model: () => AIV5Type.ModelMessage[];
                ui: () => AIV5Type.UIMessage[];
            };
            ui: () => UIMessageWithMetadata[];
            core: () => CoreMessageV4[];
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
            };
        };
        input: {
            db: () => MastraDBMessage[];
            v1: () => import("../../memory").MastraMessageV1[];
            aiV5: {
                model: () => AIV5Type.ModelMessage[];
                ui: () => AIV5Type.UIMessage[];
            };
            ui: () => UIMessageWithMetadata[];
            core: () => CoreMessageV4[];
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
            };
        };
        response: {
            db: () => MastraDBMessage[];
            v1: () => MastraMessageV1[];
            aiV5: {
                ui: () => AIV5Type.UIMessage[];
                model: () => AIV5ResponseMessage[];
                modelContent: (stepNumber?: number) => AIV5Type.StepResult<any>["content"];
                stepContent: (message?: AIV5Type.ModelMessage) => AIV5Type.StepResult<any>["content"];
            };
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
            };
        };
    };
    get getPersisted(): {
        remembered: {
            db: () => MastraDBMessage[];
            v1: () => import("../../memory").MastraMessageV1[];
            aiV5: {
                model: () => AIV5Type.ModelMessage[];
                ui: () => AIV5Type.UIMessage[];
            };
            ui: () => UIMessageWithMetadata[];
            core: () => CoreMessageV4[];
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
            };
        };
        input: {
            db: () => MastraDBMessage[];
            v1: () => MastraMessageV1[];
            aiV5: {
                model: () => AIV5Type.ModelMessage[];
                ui: () => AIV5Type.UIMessage[];
            };
            ui: () => UIMessageWithMetadata[];
            core: () => CoreMessageV4[];
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
            };
        };
        taggedSystemMessages: Record<string, AIV4Type.CoreSystemMessage[]>;
        response: {
            db: () => MastraDBMessage[];
            aiV5: {
                model: () => AIV5Type.ModelMessage[];
                ui: () => AIV5Type.UIMessage[];
            };
            ui: () => UIMessageWithMetadata[];
            aiV4: {
                ui: () => UIMessageWithMetadata[];
                core: () => CoreMessageV4[];
            };
        };
    };
    get clear(): {
        all: {
            db: () => MastraDBMessage[];
        };
        input: {
            db: () => MastraDBMessage[];
        };
        response: {
            db: () => MastraDBMessage[];
        };
    };
    /**
     * Remove messages by ID
     * @param ids - Array of message IDs to remove
     * @returns Array of removed messages
     */
    removeByIds(ids: string[]): MastraDBMessage[];
    private all;
    private remembered;
    private rememberedPersisted;
    private input;
    private inputPersisted;
    private response;
    private responsePersisted;
    drainUnsavedMessages(): MastraDBMessage[];
    getEarliestUnsavedMessageTimestamp(): number | undefined;
    /**
     * Check if a message is a new user or response message that should be saved.
     * Checks by message ID to handle cases where the message object may be a copy.
     */
    isNewMessage(messageOrId: MastraDBMessage | string): boolean;
    /**
     * Replace a tool-invocation part matching the given toolCallId with the
     * provided result part. Walks backwards through messages to find the match.
     * If the message was already persisted (e.g. as a memory message), it is
     * moved to the response source so it will be re-saved.
     *
     * @returns true if the tool call was found and updated, false otherwise.
     */
    updateToolInvocation(inputPart: Extract<MastraMessagePart, {
        type: 'tool-invocation';
    }>): boolean;
    /**
     * Append a `step-start` boundary to the last assistant message.
     * This marks the beginning of a new loop iteration so that
     * `convertToModelMessages` splits sequential tool-call turns into
     * separate message blocks instead of collapsing them into one.
     *
     * Respects sealed messages (post-observation) — if the last assistant
     * message is sealed, the step-start is not added.
     *
     * If the message was loaded from memory it is moved to the response
     * source so the updated content is re-saved.
     */
    stepStart(): boolean;
    getSystemMessages(tag?: string): CoreMessageV4[];
    /**
     * Get all system messages (both tagged and untagged)
     * @returns Array of all system messages
     */
    getAllSystemMessages(): CoreMessageV4[];
    /**
     * Clear system messages, optionally for a specific tag
     * @param tag - If provided, only clears messages with this tag. Otherwise clears untagged messages.
     */
    clearSystemMessages(tag?: string): this;
    /**
     * Replace all system messages with new ones
     * This clears both tagged and untagged system messages and replaces them with the provided array
     * @param messages - Array of system messages to set
     */
    replaceAllSystemMessages(messages: CoreMessageV4[]): this;
    addSystem(messages: CoreMessageV4 | CoreMessageV4[] | AIV5Type.ModelMessage | AIV5Type.ModelMessage[] | MastraDBMessage | MastraDBMessage[] | string | string[] | null, tag?: string): this;
    private addOneSystem;
    private isDuplicateSystem;
    private getMessageById;
    private shouldReplaceMessage;
    private addOne;
    private pushMessageToSource;
    private lastCreatedAt?;
    private generateCreatedAt;
    private newMessageId;
    private createAdapterContext;
}
//# sourceMappingURL=message-list.d.ts.map