import type { FinishReason, JSONValue, Source, ToolCall, ToolResult } from './types.js'; export type DataStreamString = `${(typeof DataStreamStringPrefixes)[keyof typeof DataStreamStringPrefixes]}:${string}\n`; export interface DataStreamPart { code: CODE; name: NAME; parse: (value: JSONValue) => { type: NAME; value: TYPE; }; } declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, DataStreamPart<"2", "data", JSONValue[]>, DataStreamPart<"3", "error", string>, DataStreamPart<"8", "message_annotations", JSONValue[]>, DataStreamPart<"9", "tool_call", ToolCall>, DataStreamPart<"a", "tool_result", Omit, "args" | "toolName">>, DataStreamPart<"b", "tool_call_streaming_start", { toolCallId: string; toolName: string; }>, DataStreamPart<"c", "tool_call_delta", { toolCallId: string; argsTextDelta: string; }>, DataStreamPart<"d", "finish_message", { finishReason: FinishReason; usage?: { promptTokens: number; completionTokens: number; }; }>, DataStreamPart<"e", "finish_step", { isContinued: boolean; finishReason: FinishReason; usage?: { promptTokens: number; completionTokens: number; }; }>, DataStreamPart<"f", "start_step", { messageId: string; }>, DataStreamPart<"g", "reasoning", string>, DataStreamPart<"h", "source", Source>, DataStreamPart<"i", "redacted_reasoning", { data: string; }>, DataStreamPart<"j", "reasoning_signature", { signature: string; }>, DataStreamPart<"k", "file", { data: string; mimeType: string; }>]; export declare const dataStreamPartsByCode: { [K in (typeof dataStreamParts)[number]['code']]: (typeof dataStreamParts)[number]; }; type DataStreamParts = (typeof dataStreamParts)[number]; /** * Maps the type of a stream part to its value type. */ type DataStreamPartValueType = { [P in DataStreamParts as P['name']]: ReturnType['value']; }; export type DataStreamPartType = ReturnType; /** * The map of prefixes for data in the stream * * - 0: Text from the LLM response * - 1: (OpenAI) function_call responses * - 2: custom JSON added by the user using `Data` * - 6: (OpenAI) tool_call responses * * Example: * ``` * 0:Vercel * 0:'s * 0: AI * 0: AI * 0: SDK * 0: is great * 0:! * 2: { "someJson": "value" } * 1: {"function_call": {"name": "get_current_weather", "arguments": "{\\n\\"location\\": \\"Charlottesville, Virginia\\",\\n\\"format\\": \\"celsius\\"\\n}"}} * 6: {"tool_call": {"id": "tool_0", "type": "function", "function": {"name": "get_current_weather", "arguments": "{\\n\\"location\\": \\"Charlottesville, Virginia\\",\\n\\"format\\": \\"celsius\\"\\n}"}}} *``` */ export declare const DataStreamStringPrefixes: { [K in DataStreamParts['name']]: (typeof dataStreamParts)[number]['code']; }; export declare const validCodes: ("0" | "2" | "3" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k")[]; /** Parses a stream part from a string. @param line The string to parse. @returns The parsed stream part. @throws An error if the string cannot be parsed. */ export declare const parseDataStreamPart: (line: string) => DataStreamPartType; /** Prepends a string with a prefix from the `StreamChunkPrefixes`, JSON-ifies it, and appends a new line. It ensures type-safety for the part type and value. */ export declare function formatDataStreamPart(type: T, value: DataStreamPartValueType[T]): DataStreamString; export {}; //# sourceMappingURL=data-stream-parts.d.ts.map