import type { CoreMessage as CoreMessageV4 } from '../../../_types/@internal_ai-sdk-v4/dist/index.js'; import type { ModelMessage, ToolResultPart } from '../../../_types/@internal_ai-sdk-v5/dist/index.js'; import type { IMastraLogger } from '../../../logger/index.js'; import type { MastraDBMessage } from '../state/types.js'; /** * Tool result with input field (Anthropic requirement) */ export type ToolResultWithInput = ToolResultPart & { input: Record; }; /** * Ensures message array is compatible with Gemini API requirements. * * Gemini API requires: * 1. The first non-system message must be from the user role * 2. Cannot have only system messages - at least one user/assistant is required * * @param messages - Array of model messages to validate and fix * @param logger - Optional logger for warnings * @returns Modified messages array that satisfies Gemini requirements * * @see https://github.com/mastra-ai/mastra/issues/7287 - Tool call ordering * @see https://github.com/mastra-ai/mastra/issues/8053 - Single turn validation * @see https://github.com/mastra-ai/mastra/issues/13045 - Empty thread support */ export declare function ensureGeminiCompatibleMessages(messages: T[], logger?: IMastraLogger): T[]; /** * Ensures model messages are compatible with Anthropic API requirements. * * Anthropic API requires tool-result parts to include an 'input' field * that matches the original tool call arguments. * * @param messages - Array of model messages to transform * @param dbMessages - MastraDB messages to look up tool call args from * @returns Messages with tool-result parts enriched with input field * * @see https://github.com/mastra-ai/mastra/issues/11376 - Anthropic models fail with empty object tool input */ export declare function ensureAnthropicCompatibleMessages(messages: ModelMessage[], dbMessages: MastraDBMessage[]): ModelMessage[]; /** * Checks if a message part has OpenAI reasoning itemId * * OpenAI reasoning items are tracked via `providerMetadata.openai.itemId` (e.g., `rs_...`). * Each reasoning item has a unique itemId that must be preserved for proper deduplication. * * @param part - A message part to check * @returns true if the part has an OpenAI itemId * * @see https://github.com/mastra-ai/mastra/issues/9005 - OpenAI reasoning items filtering */ export declare function hasOpenAIReasoningItemId(part: unknown): boolean; /** * Extracts the OpenAI itemId from a message part if present * * @param part - A message part to extract from * @returns The itemId string or undefined if not present */ export declare function getOpenAIReasoningItemId(part: unknown): string | undefined; /** * Finds the tool call args for a given toolCallId by searching through messages. * This is used to reconstruct the input field when converting tool-result parts to StaticToolResult. * * Searches through messages in reverse order (most recent first) for better performance. * Checks both content.parts (v2 format) and toolInvocations (legacy AIV4 format). * * @param messages - Array of MastraDB messages to search through * @param toolCallId - The ID of the tool call to find args for * @returns The args object from the matching tool call, or an empty object if not found */ export declare function findToolCallArgs(messages: MastraDBMessage[], toolCallId: string): Record; //# sourceMappingURL=provider-compat.d.ts.map