import { TransformStream } from 'node:stream/web';
import type { InferUIMessageChunk, UIMessage, UIMessageStreamOptions } from './_types/@internal_ai-sdk-v5/dist/index.d.ts';
import type { InferUIMessageChunk as InferUIMessageChunkV6, UIMessage as UIMessageV6, UIMessageStreamOptions as UIMessageStreamOptionsV6 } from './_types/@internal_ai-v6/dist/index.d.ts';
import type { LLMStepResult } from '@mastra/core/agent';
import type { ChunkType, DataChunkType, NetworkChunkType } from '@mastra/core/stream';
import type { WorkflowRunStatus, WorkflowStepStatus } from '@mastra/core/workflows';
import type { ToolAgentChunkType, ToolWorkflowChunkType, ToolNetworkChunkType } from './helpers.js';
type LanguageModelV2Usage = {
    /**
  The number of input (prompt) tokens used.
     */
    inputTokens: number | undefined;
    /**
  The number of output (completion) tokens used.
     */
    outputTokens: number | undefined;
    /**
  The total number of tokens as reported by the provider.
  This number might be different from the sum of `inputTokens` and `outputTokens`
  and e.g. include reasoning tokens or other overhead.
     */
    totalTokens: number | undefined;
    /**
  The number of reasoning tokens used.
     */
    reasoningTokens?: number | undefined;
    /**
  The number of cached input tokens.
     */
    cachedInputTokens?: number | undefined;
};
type StepResult = {
    name: string;
    status: WorkflowStepStatus;
    input: Record<string, unknown> | null;
    output: unknown | null;
    suspendPayload: Record<string, unknown> | null;
    resumePayload: Record<string, unknown> | null;
};
export type WorkflowDataPart = {
    type: 'data-workflow' | 'data-tool-workflow';
    id: string;
    data: {
        name: string;
        status: WorkflowRunStatus;
        steps: Record<string, StepResult>;
        output: {
            usage: {
                inputTokens: number;
                outputTokens: number;
                totalTokens: number;
            };
        } | null;
    };
};
export type WorkflowStepDataPart = {
    type: 'data-workflow-step' | 'data-tool-workflow-step';
    id: string;
    data: {
        name: string;
        status: WorkflowRunStatus;
        stepId: string;
        step: StepResult;
    };
};
export type NetworkDataPart = {
    type: 'data-network' | 'data-tool-network';
    id: string;
    data: {
        name: string;
        status: 'running' | 'finished';
        steps: StepResult[];
        usage: LanguageModelV2Usage | null;
        output: unknown | null;
    };
};
export type AgentDataPart = {
    type: 'data-tool-agent';
    id: string;
    data: LLMStepResult;
};
declare const PRIMITIVE_CACHE_SYMBOL: unique symbol;
type ConvertMastraChunkToAISDK = <OUTPUT>(args: {
    chunk: ChunkType<OUTPUT>;
    mode?: 'generate' | 'stream';
}) => any;
type BufferedWorkflowState = {
    name: string;
    steps: Record<string, StepResult>;
};
export declare function createWorkflowStreamToAISDKTransformer<UI_CHUNK>(convertMastraChunkToAISDK: ConvertMastraChunkToAISDK, { includeTextStreamParts, sendReasoning, sendSources, }?: {
    includeTextStreamParts?: boolean;
    sendReasoning?: boolean;
    sendSources?: boolean;
}): TransformStream<ChunkType<any>, ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | WorkflowDataPart | WorkflowStepDataPart | UI_CHUNK | {
    data?: string;
    type?: "start" | "finish";
} | ChunkType>;
export declare function WorkflowStreamToAISDKTransformer({ includeTextStreamParts, sendReasoning, sendSources, }?: {
    includeTextStreamParts?: boolean;
    sendReasoning?: boolean;
    sendSources?: boolean;
}): TransformStream<ChunkType<any>, ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | WorkflowDataPart | WorkflowStepDataPart | ChunkType | InferUIMessageChunk<UIMessage<unknown, import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").UIDataTypes, import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").UITools>> | {
    data?: string;
    type?: "start" | "finish";
}>;
export declare function WorkflowStreamToAISDKV6Transformer({ includeTextStreamParts, sendReasoning, sendSources, }?: {
    includeTextStreamParts?: boolean;
    sendReasoning?: boolean;
    sendSources?: boolean;
}): TransformStream<ChunkType<any>, ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | InferUIMessageChunkV6<UIMessageV6<unknown, import("./_types/@internal_ai-v6/dist/index.d.ts").UIDataTypes, import("./_types/@internal_ai-v6/dist/index.d.ts").UITools>> | WorkflowDataPart | WorkflowStepDataPart | ChunkType | {
    data?: string;
    type?: "start" | "finish";
}>;
export declare function createAgentNetworkToAISDKTransformer<UI_CHUNK>(): TransformStream<NetworkChunkType, DataChunkType | NetworkDataPart | UI_CHUNK | {
    data?: string;
    type?: "start" | "finish";
}>;
export declare function AgentNetworkToAISDKTransformer(): TransformStream<NetworkChunkType, DataChunkType | NetworkDataPart | InferUIMessageChunk<UIMessage<unknown, import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").UIDataTypes, import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").UITools>> | {
    data?: string;
    type?: "start" | "finish";
}>;
export declare function AgentNetworkToAISDKV6Transformer(): TransformStream<NetworkChunkType, DataChunkType | InferUIMessageChunkV6<UIMessageV6<unknown, import("./_types/@internal_ai-v6/dist/index.d.ts").UIDataTypes, import("./_types/@internal_ai-v6/dist/index.d.ts").UITools>> | NetworkDataPart | {
    data?: string;
    type?: "start" | "finish";
}>;
export declare function createAgentStreamToAISDKTransformer<OUTPUT>(convertMastraChunkToAISDK: ConvertMastraChunkToAISDK, { lastMessageId, sendStart, sendFinish, sendReasoning, sendSources, messageMetadata, onError, }: {
    lastMessageId?: string;
    sendStart?: boolean;
    sendFinish?: boolean;
    sendReasoning?: boolean;
    sendSources?: boolean;
    messageMetadata?: (args: {
        part: any;
    }) => unknown;
    onError?: (error: unknown) => string;
}): TransformStream<ChunkType<OUTPUT>, object>;
export declare function AgentStreamToAISDKTransformer<OUTPUT>({ lastMessageId, sendStart, sendFinish, sendReasoning, sendSources, messageMetadata, onError, }: {
    lastMessageId?: string;
    sendStart?: boolean;
    sendFinish?: boolean;
    sendReasoning?: boolean;
    sendSources?: boolean;
    messageMetadata?: UIMessageStreamOptions<UIMessage>['messageMetadata'];
    onError?: UIMessageStreamOptions<UIMessage>['onError'];
}): TransformStream<ChunkType<OUTPUT>, object>;
export declare function AgentStreamToAISDKV6Transformer<OUTPUT>({ lastMessageId, sendStart, sendFinish, sendReasoning, sendSources, messageMetadata, onError, }: {
    lastMessageId?: string;
    sendStart?: boolean;
    sendFinish?: boolean;
    sendReasoning?: boolean;
    sendSources?: boolean;
    messageMetadata?: UIMessageStreamOptionsV6<UIMessageV6>['messageMetadata'];
    onError?: UIMessageStreamOptionsV6<UIMessageV6>['onError'];
}): TransformStream<ChunkType<OUTPUT>, object>;
export declare function transformAgent<OUTPUT>(payload: ChunkType<OUTPUT>, bufferedSteps: Map<string, any>): {
    type: "data-tool-agent";
    id: string;
    data: any;
} | null;
export declare function transformWorkflow<OUTPUT>(payload: ChunkType<OUTPUT>, bufferedWorkflows: Map<string, BufferedWorkflowState>, isNested?: boolean, includeTextStreamParts?: boolean, streamOptions?: {
    sendReasoning?: boolean;
    sendSources?: boolean;
}, convertMastraChunkToAISDK?: ConvertMastraChunkToAISDK): {
    type: "error";
    errorText: string;
} | {
    type: "tool-input-available";
    toolCallId: string;
    toolName: string;
    input: unknown;
    providerExecuted?: boolean;
    providerMetadata?: import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").ProviderMetadata;
    dynamic?: boolean;
} | {
    type: "tool-input-error";
    toolCallId: string;
    toolName: string;
    input: unknown;
    providerExecuted?: boolean;
    providerMetadata?: import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").ProviderMetadata;
    dynamic?: boolean;
    errorText: string;
} | {
    type: "tool-output-available";
    toolCallId: string;
    output: unknown;
    providerExecuted?: boolean;
    dynamic?: boolean;
    preliminary?: boolean;
} | {
    type: "tool-output-error";
    toolCallId: string;
    errorText: string;
    providerExecuted?: boolean;
    dynamic?: boolean;
} | {
    type: "tool-input-start";
    toolCallId: string;
    toolName: string;
    providerExecuted?: boolean;
    dynamic?: boolean;
} | {
    type: "tool-input-delta";
    toolCallId: string;
    inputTextDelta: string;
} | {
    type: "start-step";
} | {
    type: "finish-step";
} | {
    type: "abort";
} | {
    type: "text-start";
    id: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "text-delta";
    delta: string;
    id: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "text-end";
    id: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "reasoning-start";
    id: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "reasoning-delta";
    id: string;
    delta: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "reasoning-end";
    id: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "tool-input-available";
    toolCallId: string;
    toolName: string;
    input: unknown;
    providerExecuted?: boolean;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
    toolMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").JSONObject;
    dynamic?: boolean;
    title?: string;
} | {
    type: "tool-input-error";
    toolCallId: string;
    toolName: string;
    input: unknown;
    providerExecuted?: boolean;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
    toolMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").JSONObject;
    dynamic?: boolean;
    errorText: string;
    title?: string;
} | {
    type: "tool-approval-request";
    approvalId: string;
    toolCallId: string;
} | {
    type: "tool-output-denied";
    toolCallId: string;
} | {
    type: "source-url";
    sourceId: string;
    url: string;
    title?: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "source-document";
    sourceId: string;
    mediaType: string;
    title: string;
    filename?: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | {
    type: "file";
    url: string;
    mediaType: string;
    providerMetadata?: import("./_types/@internal_ai-v6/dist/index.d.ts").ProviderMetadata;
} | ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | {
    type: `data-${string}`;
    id?: string;
    data: unknown;
    transient?: boolean;
} | {
    type: "start";
    messageId?: string;
    messageMetadata?: unknown;
} | {
    type: "message-metadata";
    messageMetadata: unknown;
} | {
    type: "finish";
    finishReason?: import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").FinishReason;
    messageMetadata?: unknown;
} | readonly [WorkflowDataPart, WorkflowStepDataPart] | (ToolAgentChunkType | ToolWorkflowChunkType | ToolNetworkChunkType | InferUIMessageChunkV6<UIMessageV6<unknown, import("./_types/@internal_ai-v6/dist/index.d.ts").UIDataTypes, import("./_types/@internal_ai-v6/dist/index.d.ts").UITools>> | InferUIMessageChunk<UIMessage<unknown, import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").UIDataTypes, import("./_types/@internal_ai-sdk-v5/dist/index.d.ts").UITools>> | undefined)[] | {
    id?: string | undefined;
    type: `data-${string}`;
    data: any;
} | null | undefined;
type TransformNetworkResult = InferUIMessageChunk<UIMessage> | NetworkDataPart | DataChunkType | WorkflowStepDataPart;
export declare function transformNetwork(payload: NetworkChunkType, bufferedNetworks: Map<string, {
    name: string;
    steps: (StepResult & {
        id: string;
        iteration: number;
        task: null | Record<string, unknown>;
        input: StepResult['input'];
        [PRIMITIVE_CACHE_SYMBOL]: Map<string, any>;
    })[];
    usage: LanguageModelV2Usage | null;
    output: unknown | null;
    hasEmittedText?: boolean;
}>, isNested?: boolean): TransformNetworkResult | TransformNetworkResult[] | null;
export {};
//# sourceMappingURL=transformers.d.ts.map