ai 5.0.0-canary.4 → 5.0.0-canary.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,14 +1,47 @@
1
- import { IDGenerator } from '@ai-sdk/provider-utils';
1
+ import { ToolCall, ToolResult, FetchFunction, Validator, IDGenerator } from '@ai-sdk/provider-utils';
2
2
  export { CoreToolCall, CoreToolResult, IDGenerator, ToolCall, ToolResult, createIdGenerator, generateId } from '@ai-sdk/provider-utils';
3
- import { DataStreamString, Message, Schema, DeepPartial, JSONValue as JSONValue$1 } from '@ai-sdk/ui-utils';
4
- export { Attachment, ChatRequest, ChatRequestOptions, CreateMessage, DataStreamPart, DeepPartial, IdGenerator, JSONValue, Message, RequestOptions, Schema, ToolInvocation, UIMessage, formatDataStreamPart, jsonSchema, parseDataStreamPart, processDataStream, processTextStream, zodSchema } from '@ai-sdk/ui-utils';
5
- import { LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2LogProbs, LanguageModelV2CallWarning, LanguageModelV2Source, JSONValue, EmbeddingModelV1, EmbeddingModelV1Embedding, ImageModelV1, ImageModelV1CallWarning, LanguageModelV2ProviderMetadata, LanguageModelV2CallOptions, AISDKError, LanguageModelV2FunctionToolCall, JSONSchema7, JSONParseError, TypeValidationError, TranscriptionModelV1CallWarning, TranscriptionModelV1, LanguageModelV2ProviderOptions, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
3
+ import { EmbeddingModelV1, EmbeddingModelV1Embedding, ImageModelV1, ImageModelV1CallWarning, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2LogProbs, LanguageModelV2CallWarning, LanguageModelV2Source, LanguageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2CallOptions, AISDKError, LanguageModelV2FunctionToolCall, JSONSchema7 as JSONSchema7$1, JSONParseError, TypeValidationError, TranscriptionModelV1CallWarning, TranscriptionModelV1, LanguageModelV2ProviderOptions, LanguageModelV2Middleware, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
6
4
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Prompt, LanguageModelV2StreamPart, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
7
5
  import { ServerResponse } from 'node:http';
8
6
  import { AttributeValue, Tracer } from '@opentelemetry/api';
9
7
  import { z } from 'zod';
8
+ import { JSONSchema7 } from 'json-schema';
10
9
  import { ServerResponse as ServerResponse$1 } from 'http';
11
10
 
11
+ /**
12
+ Embedding model that is used by the AI SDK Core functions.
13
+ */
14
+ type EmbeddingModel<VALUE> = EmbeddingModelV1<VALUE>;
15
+ /**
16
+ Embedding.
17
+ */
18
+ type Embedding = EmbeddingModelV1Embedding;
19
+
20
+ /**
21
+ Image model that is used by the AI SDK Core functions.
22
+ */
23
+ type ImageModel = ImageModelV1;
24
+ /**
25
+ Warning from the model provider for this call. The call will proceed, but e.g.
26
+ some settings might not be supported, which can lead to suboptimal results.
27
+ */
28
+ type ImageGenerationWarning = ImageModelV1CallWarning;
29
+
30
+ type ImageModelResponseMetadata = {
31
+ /**
32
+ Timestamp for the start of the generated response.
33
+ */
34
+ timestamp: Date;
35
+ /**
36
+ The ID of the response model that was used to generate the response.
37
+ */
38
+ modelId: string;
39
+ /**
40
+ Response headers.
41
+ */
42
+ headers?: Record<string, string>;
43
+ };
44
+
12
45
  /**
13
46
  Language model that is used by the AI SDK Core functions.
14
47
  */
@@ -57,120 +90,6 @@ type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'requ
57
90
  */
58
91
  type CoreToolChoice<TOOLS extends Record<string, unknown>> = ToolChoice<TOOLS>;
59
92
 
60
- interface DataStreamWriter {
61
- /**
62
- * Appends a data part to the stream.
63
- */
64
- write(data: DataStreamString): void;
65
- /**
66
- * Appends a data part to the stream.
67
- */
68
- writeData(value: JSONValue): void;
69
- /**
70
- * Appends a message annotation to the stream.
71
- */
72
- writeMessageAnnotation(value: JSONValue): void;
73
- /**
74
- * Appends a source part to the stream.
75
- */
76
- writeSource(source: Source): void;
77
- /**
78
- * Merges the contents of another stream to this stream.
79
- */
80
- merge(stream: ReadableStream<DataStreamString>): void;
81
- /**
82
- * Error handler that is used by the data stream writer.
83
- * This is intended for forwarding when merging streams
84
- * to prevent duplicated error masking.
85
- */
86
- onError: ((error: unknown) => string) | undefined;
87
- }
88
-
89
- declare function createDataStream({ execute, onError, }: {
90
- execute: (dataStream: DataStreamWriter) => Promise<void> | void;
91
- onError?: (error: unknown) => string;
92
- }): ReadableStream<DataStreamString>;
93
-
94
- declare function createDataStreamResponse({ status, statusText, headers, execute, onError, }: ResponseInit & {
95
- execute: (dataStream: DataStreamWriter) => Promise<void> | void;
96
- onError?: (error: unknown) => string;
97
- }): Response;
98
-
99
- declare function pipeDataStreamToResponse(response: ServerResponse, { status, statusText, headers, execute, onError, }: ResponseInit & {
100
- execute: (writer: DataStreamWriter) => Promise<void> | void;
101
- onError?: (error: unknown) => string;
102
- }): void;
103
-
104
- /**
105
- * Telemetry configuration.
106
- */
107
- type TelemetrySettings = {
108
- /**
109
- * Enable or disable telemetry. Disabled by default while experimental.
110
- */
111
- isEnabled?: boolean;
112
- /**
113
- * Enable or disable input recording. Enabled by default.
114
- *
115
- * You might want to disable input recording to avoid recording sensitive
116
- * information, to reduce data transfers, or to increase performance.
117
- */
118
- recordInputs?: boolean;
119
- /**
120
- * Enable or disable output recording. Enabled by default.
121
- *
122
- * You might want to disable output recording to avoid recording sensitive
123
- * information, to reduce data transfers, or to increase performance.
124
- */
125
- recordOutputs?: boolean;
126
- /**
127
- * Identifier for this function. Used to group telemetry data by function.
128
- */
129
- functionId?: string;
130
- /**
131
- * Additional information to include in the telemetry data.
132
- */
133
- metadata?: Record<string, AttributeValue>;
134
- /**
135
- * A custom tracer to use for the telemetry data.
136
- */
137
- tracer?: Tracer;
138
- };
139
-
140
- /**
141
- Embedding model that is used by the AI SDK Core functions.
142
- */
143
- type EmbeddingModel<VALUE> = EmbeddingModelV1<VALUE>;
144
- /**
145
- Embedding.
146
- */
147
- type Embedding = EmbeddingModelV1Embedding;
148
-
149
- /**
150
- Image model that is used by the AI SDK Core functions.
151
- */
152
- type ImageModel = ImageModelV1;
153
- /**
154
- Warning from the model provider for this call. The call will proceed, but e.g.
155
- some settings might not be supported, which can lead to suboptimal results.
156
- */
157
- type ImageGenerationWarning = ImageModelV1CallWarning;
158
-
159
- type ImageModelResponseMetadata = {
160
- /**
161
- Timestamp for the start of the generated response.
162
- */
163
- timestamp: Date;
164
- /**
165
- The ID of the response model that was used to generate the response.
166
- */
167
- modelId: string;
168
- /**
169
- Response headers.
170
- */
171
- headers?: Record<string, string>;
172
- };
173
-
174
93
  type LanguageModelRequestMetadata = {
175
94
  /**
176
95
  Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
@@ -252,7 +171,7 @@ type ProviderOptions = LanguageModelV2ProviderMetadata;
252
171
  /**
253
172
  Represents the number of tokens used in a prompt and completion.
254
173
  */
255
- type LanguageModelUsage = {
174
+ type LanguageModelUsage$1 = {
256
175
  /**
257
176
  The number of tokens used in the prompt.
258
177
  */
@@ -276,6 +195,803 @@ type EmbeddingModelUsage = {
276
195
  tokens: number;
277
196
  };
278
197
 
198
+ /**
199
+ Represents the number of tokens used in a prompt and completion.
200
+ */
201
+ type LanguageModelUsage = {
202
+ /**
203
+ The number of tokens used in the prompt.
204
+ */
205
+ promptTokens: number;
206
+ /**
207
+ The number of tokens used in the completion.
208
+ */
209
+ completionTokens: number;
210
+ /**
211
+ The total number of tokens used (promptTokens + completionTokens).
212
+ */
213
+ totalTokens: number;
214
+ };
215
+
216
+ type IdGenerator = () => string;
217
+ /**
218
+ Tool invocations are either tool calls or tool results. For each assistant tool call,
219
+ there is one tool invocation. While the call is in progress, the invocation is a tool call.
220
+ Once the call is complete, the invocation is a tool result.
221
+
222
+ The step is used to track how to map an assistant UI message with many tool invocations
223
+ back to a sequence of LLM assistant/tool result message pairs.
224
+ It is optional for backwards compatibility.
225
+ */
226
+ type ToolInvocation = ({
227
+ state: 'partial-call';
228
+ step?: number;
229
+ } & ToolCall<string, any>) | ({
230
+ state: 'call';
231
+ step?: number;
232
+ } & ToolCall<string, any>) | ({
233
+ state: 'result';
234
+ step?: number;
235
+ } & ToolResult<string, any, any>);
236
+ /**
237
+ * An attachment that can be sent along with a message.
238
+ */
239
+ interface Attachment {
240
+ /**
241
+ * The name of the attachment, usually the file name.
242
+ */
243
+ name?: string;
244
+ /**
245
+ * A string indicating the [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
246
+ * By default, it's extracted from the pathname's extension.
247
+ */
248
+ contentType?: string;
249
+ /**
250
+ * The URL of the attachment. It can either be a URL to a hosted file or a [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs).
251
+ */
252
+ url: string;
253
+ }
254
+ /**
255
+ * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
256
+ */
257
+ interface Message {
258
+ /**
259
+ A unique identifier for the message.
260
+ */
261
+ id: string;
262
+ /**
263
+ The timestamp of the message.
264
+ */
265
+ createdAt?: Date;
266
+ /**
267
+ Text content of the message. Use parts when possible.
268
+ */
269
+ content: string;
270
+ /**
271
+ Reasoning for the message.
272
+
273
+ @deprecated Use `parts` instead.
274
+ */
275
+ reasoning?: string;
276
+ /**
277
+ * Additional attachments to be sent along with the message.
278
+ */
279
+ experimental_attachments?: Attachment[];
280
+ /**
281
+ The 'data' role is deprecated.
282
+ */
283
+ role: 'system' | 'user' | 'assistant' | 'data';
284
+ /**
285
+ For data messages.
286
+
287
+ @deprecated Data messages will be removed.
288
+ */
289
+ data?: JSONValue;
290
+ /**
291
+ * Additional message-specific information added on the server via StreamData
292
+ */
293
+ annotations?: JSONValue[] | undefined;
294
+ /**
295
+ Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
296
+ that the assistant made as part of this message.
297
+
298
+ @deprecated Use `parts` instead.
299
+ */
300
+ toolInvocations?: Array<ToolInvocation>;
301
+ /**
302
+ * The parts of the message. Use this for rendering the message in the UI.
303
+ *
304
+ * Assistant messages can have text, reasoning and tool invocation parts.
305
+ * User messages can have text parts.
306
+ */
307
+ parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
308
+ }
309
+ type UIMessage = Message & {
310
+ /**
311
+ * The parts of the message. Use this for rendering the message in the UI.
312
+ *
313
+ * Assistant messages can have text, reasoning and tool invocation parts.
314
+ * User messages can have text parts.
315
+ */
316
+ parts: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
317
+ };
318
+ /**
319
+ * A text part of a message.
320
+ */
321
+ type TextUIPart = {
322
+ type: 'text';
323
+ /**
324
+ * The text content.
325
+ */
326
+ text: string;
327
+ };
328
+ /**
329
+ * A reasoning part of a message.
330
+ */
331
+ type ReasoningUIPart = {
332
+ type: 'reasoning';
333
+ /**
334
+ * The reasoning text.
335
+ */
336
+ reasoning: string;
337
+ details: Array<{
338
+ type: 'text';
339
+ text: string;
340
+ signature?: string;
341
+ } | {
342
+ type: 'redacted';
343
+ data: string;
344
+ }>;
345
+ };
346
+ /**
347
+ * A tool invocation part of a message.
348
+ */
349
+ type ToolInvocationUIPart = {
350
+ type: 'tool-invocation';
351
+ /**
352
+ * The tool invocation.
353
+ */
354
+ toolInvocation: ToolInvocation;
355
+ };
356
+ /**
357
+ * A source part of a message.
358
+ */
359
+ type SourceUIPart = {
360
+ type: 'source';
361
+ /**
362
+ * The source.
363
+ */
364
+ source: LanguageModelV2Source;
365
+ };
366
+ /**
367
+ * A file part of a message.
368
+ */
369
+ type FileUIPart = {
370
+ type: 'file';
371
+ /**
372
+ * IANA media type of the file.
373
+ *
374
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
375
+ */
376
+ mediaType: string;
377
+ /**
378
+ * The base64 encoded data.
379
+ */
380
+ data: string;
381
+ };
382
+ /**
383
+ * A step boundary part of a message.
384
+ */
385
+ type StepStartUIPart = {
386
+ type: 'step-start';
387
+ };
388
+ type CreateMessage = Omit<Message, 'id'> & {
389
+ id?: Message['id'];
390
+ };
391
+ type ChatRequest = {
392
+ /**
393
+ An optional object of headers to be passed to the API endpoint.
394
+ */
395
+ headers?: Record<string, string> | Headers;
396
+ /**
397
+ An optional object to be passed to the API endpoint.
398
+ */
399
+ body?: object;
400
+ /**
401
+ The messages of the chat.
402
+ */
403
+ messages: Message[];
404
+ /**
405
+ Additional data to be sent to the server.
406
+ */
407
+ data?: JSONValue;
408
+ };
409
+ type RequestOptions = {
410
+ /**
411
+ An optional object of headers to be passed to the API endpoint.
412
+ */
413
+ headers?: Record<string, string> | Headers;
414
+ /**
415
+ An optional object to be passed to the API endpoint.
416
+ */
417
+ body?: object;
418
+ };
419
+ type ChatRequestOptions = {
420
+ /**
421
+ Additional headers that should be to be passed to the API endpoint.
422
+ */
423
+ headers?: Record<string, string> | Headers;
424
+ /**
425
+ Additional body JSON properties that should be sent to the API endpoint.
426
+ */
427
+ body?: object;
428
+ /**
429
+ Additional data to be sent to the API endpoint.
430
+ */
431
+ data?: JSONValue;
432
+ /**
433
+ * Additional files to be sent to the server.
434
+ */
435
+ experimental_attachments?: FileList | Array<Attachment>;
436
+ /**
437
+ * Allow submitting an empty message. Defaults to `false`.
438
+ */
439
+ allowEmptySubmit?: boolean;
440
+ };
441
+ type UseChatOptions = {
442
+ /**
443
+ Keeps the last message when an error happens. Defaults to `true`.
444
+
445
+ @deprecated This option will be removed in the next major release.
446
+ */
447
+ keepLastMessageOnError?: boolean;
448
+ /**
449
+ * The API endpoint that accepts a `{ messages: Message[] }` object and returns
450
+ * a stream of tokens of the AI chat response. Defaults to `/api/chat`.
451
+ */
452
+ api?: string;
453
+ /**
454
+ * A unique identifier for the chat. If not provided, a random one will be
455
+ * generated. When provided, the `useChat` hook with the same `id` will
456
+ * have shared states across components.
457
+ */
458
+ id?: string;
459
+ /**
460
+ * Initial messages of the chat. Useful to load an existing chat history.
461
+ */
462
+ initialMessages?: Message[];
463
+ /**
464
+ * Initial input of the chat.
465
+ */
466
+ initialInput?: string;
467
+ /**
468
+ Optional callback function that is invoked when a tool call is received.
469
+ Intended for automatic client-side tool execution.
470
+
471
+ You can optionally return a result for the tool call,
472
+ either synchronously or asynchronously.
473
+ */
474
+ onToolCall?: ({ toolCall, }: {
475
+ toolCall: ToolCall<string, unknown>;
476
+ }) => void | Promise<unknown> | unknown;
477
+ /**
478
+ * Callback function to be called when the API response is received.
479
+ */
480
+ onResponse?: (response: Response) => void | Promise<void>;
481
+ /**
482
+ * Optional callback function that is called when the assistant message is finished streaming.
483
+ *
484
+ * @param message The message that was streamed.
485
+ * @param options.usage The token usage of the message.
486
+ * @param options.finishReason The finish reason of the message.
487
+ */
488
+ onFinish?: (message: Message, options: {
489
+ usage: LanguageModelUsage;
490
+ finishReason: LanguageModelV2FinishReason;
491
+ }) => void;
492
+ /**
493
+ * Callback function to be called when an error is encountered.
494
+ */
495
+ onError?: (error: Error) => void;
496
+ /**
497
+ * A way to provide a function that is going to be used for ids for messages and the chat.
498
+ * If not provided the default AI SDK `generateId` is used.
499
+ */
500
+ generateId?: IdGenerator;
501
+ /**
502
+ * The credentials mode to be used for the fetch request.
503
+ * Possible values are: 'omit', 'same-origin', 'include'.
504
+ * Defaults to 'same-origin'.
505
+ */
506
+ credentials?: RequestCredentials;
507
+ /**
508
+ * HTTP headers to be sent with the API request.
509
+ */
510
+ headers?: Record<string, string> | Headers;
511
+ /**
512
+ * Extra body object to be sent with the API request.
513
+ * @example
514
+ * Send a `sessionId` to the API along with the messages.
515
+ * ```js
516
+ * useChat({
517
+ * body: {
518
+ * sessionId: '123',
519
+ * }
520
+ * })
521
+ * ```
522
+ */
523
+ body?: object;
524
+ /**
525
+ * Whether to send extra message fields such as `message.id` and `message.createdAt` to the API.
526
+ * Defaults to `false`. When set to `true`, the API endpoint might need to
527
+ * handle the extra fields before forwarding the request to the AI service.
528
+ */
529
+ sendExtraMessageFields?: boolean;
530
+ /**
531
+ Streaming protocol that is used. Defaults to `data`.
532
+ */
533
+ streamProtocol?: 'data' | 'text';
534
+ /**
535
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
536
+ or to provide a custom fetch implementation for e.g. testing.
537
+ */
538
+ fetch?: FetchFunction;
539
+ };
540
+ type UseCompletionOptions = {
541
+ /**
542
+ * The API endpoint that accepts a `{ prompt: string }` object and returns
543
+ * a stream of tokens of the AI completion response. Defaults to `/api/completion`.
544
+ */
545
+ api?: string;
546
+ /**
547
+ * An unique identifier for the chat. If not provided, a random one will be
548
+ * generated. When provided, the `useChat` hook with the same `id` will
549
+ * have shared states across components.
550
+ */
551
+ id?: string;
552
+ /**
553
+ * Initial prompt input of the completion.
554
+ */
555
+ initialInput?: string;
556
+ /**
557
+ * Initial completion result. Useful to load an existing history.
558
+ */
559
+ initialCompletion?: string;
560
+ /**
561
+ * Callback function to be called when the API response is received.
562
+ */
563
+ onResponse?: (response: Response) => void | Promise<void>;
564
+ /**
565
+ * Callback function to be called when the completion is finished streaming.
566
+ */
567
+ onFinish?: (prompt: string, completion: string) => void;
568
+ /**
569
+ * Callback function to be called when an error is encountered.
570
+ */
571
+ onError?: (error: Error) => void;
572
+ /**
573
+ * The credentials mode to be used for the fetch request.
574
+ * Possible values are: 'omit', 'same-origin', 'include'.
575
+ * Defaults to 'same-origin'.
576
+ */
577
+ credentials?: RequestCredentials;
578
+ /**
579
+ * HTTP headers to be sent with the API request.
580
+ */
581
+ headers?: Record<string, string> | Headers;
582
+ /**
583
+ * Extra body object to be sent with the API request.
584
+ * @example
585
+ * Send a `sessionId` to the API along with the prompt.
586
+ * ```js
587
+ * useChat({
588
+ * body: {
589
+ * sessionId: '123',
590
+ * }
591
+ * })
592
+ * ```
593
+ */
594
+ body?: object;
595
+ /**
596
+ Streaming protocol that is used. Defaults to `data`.
597
+ */
598
+ streamProtocol?: 'data' | 'text';
599
+ /**
600
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
601
+ or to provide a custom fetch implementation for e.g. testing.
602
+ */
603
+ fetch?: FetchFunction;
604
+ };
605
+ /**
606
+ A JSON value can be a string, number, boolean, object, array, or null.
607
+ JSON values can be serialized and deserialized by the JSON.stringify and JSON.parse methods.
608
+ */
609
+ type JSONValue = null | string | number | boolean | {
610
+ [value: string]: JSONValue;
611
+ } | Array<JSONValue>;
612
+
613
+ declare const getOriginalFetch$1: () => typeof fetch;
614
+ declare function callChatApi({ api, body, streamProtocol, credentials, headers, abortController, restoreMessagesOnFailure, onResponse, onUpdate, onFinish, onToolCall, generateId, fetch, lastMessage, }: {
615
+ api: string;
616
+ body: Record<string, any>;
617
+ streamProtocol: 'data' | 'text' | undefined;
618
+ credentials: RequestCredentials | undefined;
619
+ headers: HeadersInit | undefined;
620
+ abortController: (() => AbortController | null) | undefined;
621
+ restoreMessagesOnFailure: () => void;
622
+ onResponse: ((response: Response) => void | Promise<void>) | undefined;
623
+ onUpdate: (options: {
624
+ message: UIMessage;
625
+ data: JSONValue[] | undefined;
626
+ replaceLastMessage: boolean;
627
+ }) => void;
628
+ onFinish: UseChatOptions['onFinish'];
629
+ onToolCall: UseChatOptions['onToolCall'];
630
+ generateId: IdGenerator;
631
+ fetch: ReturnType<typeof getOriginalFetch$1> | undefined;
632
+ lastMessage: UIMessage | undefined;
633
+ }): Promise<void>;
634
+
635
+ declare const getOriginalFetch: () => typeof fetch;
636
+ declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onResponse, onFinish, onError, onData, fetch, }: {
637
+ api: string;
638
+ prompt: string;
639
+ credentials: RequestCredentials | undefined;
640
+ headers: HeadersInit | undefined;
641
+ body: Record<string, any>;
642
+ streamProtocol: 'data' | 'text' | undefined;
643
+ setCompletion: (completion: string) => void;
644
+ setLoading: (loading: boolean) => void;
645
+ setError: (error: Error | undefined) => void;
646
+ setAbortController: (abortController: AbortController | null) => void;
647
+ onResponse: ((response: Response) => void | Promise<void>) | undefined;
648
+ onFinish: ((prompt: string, completion: string) => void) | undefined;
649
+ onError: ((error: Error) => void) | undefined;
650
+ onData: ((data: JSONValue[]) => void) | undefined;
651
+ fetch: ReturnType<typeof getOriginalFetch> | undefined;
652
+ }): Promise<string | null | undefined>;
653
+
654
+ type DataStreamString = `${(typeof DataStreamStringPrefixes)[keyof typeof DataStreamStringPrefixes]}:${string}\n`;
655
+ interface DataStreamPart<CODE extends string, NAME extends string, TYPE> {
656
+ code: CODE;
657
+ name: NAME;
658
+ parse: (value: JSONValue) => {
659
+ type: NAME;
660
+ value: TYPE;
661
+ };
662
+ }
663
+ 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<string, any>>, DataStreamPart<"a", "tool_result", Omit<ToolResult<string, any, any>, "args" | "toolName">>, DataStreamPart<"b", "tool_call_streaming_start", {
664
+ toolCallId: string;
665
+ toolName: string;
666
+ }>, DataStreamPart<"c", "tool_call_delta", {
667
+ toolCallId: string;
668
+ argsTextDelta: string;
669
+ }>, DataStreamPart<"d", "finish_message", {
670
+ finishReason: LanguageModelV2FinishReason;
671
+ usage?: {
672
+ promptTokens: number;
673
+ completionTokens: number;
674
+ };
675
+ }>, DataStreamPart<"e", "finish_step", {
676
+ isContinued: boolean;
677
+ finishReason: LanguageModelV2FinishReason;
678
+ usage?: {
679
+ promptTokens: number;
680
+ completionTokens: number;
681
+ };
682
+ }>, DataStreamPart<"f", "start_step", {
683
+ messageId: string;
684
+ }>, DataStreamPart<"g", "reasoning", string>, DataStreamPart<"h", "source", LanguageModelV2Source>, DataStreamPart<"i", "redacted_reasoning", {
685
+ data: string;
686
+ }>, DataStreamPart<"j", "reasoning_signature", {
687
+ signature: string;
688
+ }>, DataStreamPart<"k", "file", {
689
+ data: string;
690
+ mimeType: string;
691
+ }>];
692
+ type DataStreamParts = (typeof dataStreamParts)[number];
693
+ /**
694
+ * Maps the type of a stream part to its value type.
695
+ */
696
+ type DataStreamPartValueType = {
697
+ [P in DataStreamParts as P['name']]: ReturnType<P['parse']>['value'];
698
+ };
699
+ type DataStreamPartType = ReturnType<DataStreamParts['parse']>;
700
+ /**
701
+ * The map of prefixes for data in the stream
702
+ *
703
+ * - 0: Text from the LLM response
704
+ * - 1: (OpenAI) function_call responses
705
+ * - 2: custom JSON added by the user using `Data`
706
+ * - 6: (OpenAI) tool_call responses
707
+ *
708
+ * Example:
709
+ * ```
710
+ * 0:Vercel
711
+ * 0:'s
712
+ * 0: AI
713
+ * 0: AI
714
+ * 0: SDK
715
+ * 0: is great
716
+ * 0:!
717
+ * 2: { "someJson": "value" }
718
+ * 1: {"function_call": {"name": "get_current_weather", "arguments": "{\\n\\"location\\": \\"Charlottesville, Virginia\\",\\n\\"format\\": \\"celsius\\"\\n}"}}
719
+ * 6: {"tool_call": {"id": "tool_0", "type": "function", "function": {"name": "get_current_weather", "arguments": "{\\n\\"location\\": \\"Charlottesville, Virginia\\",\\n\\"format\\": \\"celsius\\"\\n}"}}}
720
+ *```
721
+ */
722
+ declare const DataStreamStringPrefixes: { [K in DataStreamParts["name"]]: (typeof dataStreamParts)[number]["code"]; };
723
+ /**
724
+ Parses a stream part from a string.
725
+
726
+ @param line The string to parse.
727
+ @returns The parsed stream part.
728
+ @throws An error if the string cannot be parsed.
729
+ */
730
+ declare const parseDataStreamPart: (line: string) => DataStreamPartType;
731
+ /**
732
+ Prepends a string with a prefix from the `StreamChunkPrefixes`, JSON-ifies it,
733
+ and appends a new line.
734
+
735
+ It ensures type-safety for the part type and value.
736
+ */
737
+ declare function formatDataStreamPart<T extends keyof DataStreamPartValueType>(type: T, value: DataStreamPartValueType[T]): DataStreamString;
738
+
739
+ /**
740
+ * Converts a data URL of type text/* to a text string.
741
+ */
742
+ declare function getTextFromDataUrl(dataUrl: string): string;
743
+
744
+ /**
745
+ Create a type from an object with all keys and nested keys set to optional.
746
+ The helper supports normal objects and Zod schemas (which are resolved automatically).
747
+ It always recurses into arrays.
748
+
749
+ Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
750
+ */
751
+ type DeepPartial<T> = T extends z.ZodTypeAny ? DeepPartialInternal<z.infer<T>> : DeepPartialInternal<T>;
752
+ type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
753
+ type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
754
+ type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
755
+ type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
756
+ type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
757
+ type PartialObject<ObjectType extends object> = {
758
+ [KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
759
+ };
760
+
761
+ declare function extractMaxToolInvocationStep(toolInvocations: ToolInvocation[] | undefined): number | undefined;
762
+
763
+ declare function fillMessageParts(messages: Message[]): UIMessage[];
764
+
765
+ declare function getMessageParts(message: Message | CreateMessage | UIMessage): (TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart)[];
766
+
767
+ /**
768
+ * Performs a deep-equal comparison of two parsed JSON objects.
769
+ *
770
+ * @param {any} obj1 - The first object to compare.
771
+ * @param {any} obj2 - The second object to compare.
772
+ * @returns {boolean} - Returns true if the two objects are deeply equal, false otherwise.
773
+ */
774
+ declare function isDeepEqualData(obj1: any, obj2: any): boolean;
775
+
776
+ declare function parsePartialJson(jsonText: string | undefined): {
777
+ value: JSONValue$1 | undefined;
778
+ state: 'undefined-input' | 'successful-parse' | 'repaired-parse' | 'failed-parse';
779
+ };
780
+
781
+ declare function prepareAttachmentsForRequest(attachmentsFromOptions: FileList | Array<Attachment> | undefined): Promise<Attachment[]>;
782
+
783
+ declare function processDataStream({ stream, onTextPart, onReasoningPart, onReasoningSignaturePart, onRedactedReasoningPart, onSourcePart, onFilePart, onDataPart, onErrorPart, onToolCallStreamingStartPart, onToolCallDeltaPart, onToolCallPart, onToolResultPart, onMessageAnnotationsPart, onFinishMessagePart, onFinishStepPart, onStartStepPart, }: {
784
+ stream: ReadableStream<Uint8Array>;
785
+ onTextPart?: (streamPart: (DataStreamPartType & {
786
+ type: 'text';
787
+ })['value']) => Promise<void> | void;
788
+ onReasoningPart?: (streamPart: (DataStreamPartType & {
789
+ type: 'reasoning';
790
+ })['value']) => Promise<void> | void;
791
+ onReasoningSignaturePart?: (streamPart: (DataStreamPartType & {
792
+ type: 'reasoning_signature';
793
+ })['value']) => Promise<void> | void;
794
+ onRedactedReasoningPart?: (streamPart: (DataStreamPartType & {
795
+ type: 'redacted_reasoning';
796
+ })['value']) => Promise<void> | void;
797
+ onFilePart?: (streamPart: (DataStreamPartType & {
798
+ type: 'file';
799
+ })['value']) => Promise<void> | void;
800
+ onSourcePart?: (streamPart: (DataStreamPartType & {
801
+ type: 'source';
802
+ })['value']) => Promise<void> | void;
803
+ onDataPart?: (streamPart: (DataStreamPartType & {
804
+ type: 'data';
805
+ })['value']) => Promise<void> | void;
806
+ onErrorPart?: (streamPart: (DataStreamPartType & {
807
+ type: 'error';
808
+ })['value']) => Promise<void> | void;
809
+ onToolCallStreamingStartPart?: (streamPart: (DataStreamPartType & {
810
+ type: 'tool_call_streaming_start';
811
+ })['value']) => Promise<void> | void;
812
+ onToolCallDeltaPart?: (streamPart: (DataStreamPartType & {
813
+ type: 'tool_call_delta';
814
+ })['value']) => Promise<void> | void;
815
+ onToolCallPart?: (streamPart: (DataStreamPartType & {
816
+ type: 'tool_call';
817
+ })['value']) => Promise<void> | void;
818
+ onToolResultPart?: (streamPart: (DataStreamPartType & {
819
+ type: 'tool_result';
820
+ })['value']) => Promise<void> | void;
821
+ onMessageAnnotationsPart?: (streamPart: (DataStreamPartType & {
822
+ type: 'message_annotations';
823
+ })['value']) => Promise<void> | void;
824
+ onFinishMessagePart?: (streamPart: (DataStreamPartType & {
825
+ type: 'finish_message';
826
+ })['value']) => Promise<void> | void;
827
+ onFinishStepPart?: (streamPart: (DataStreamPartType & {
828
+ type: 'finish_step';
829
+ })['value']) => Promise<void> | void;
830
+ onStartStepPart?: (streamPart: (DataStreamPartType & {
831
+ type: 'start_step';
832
+ })['value']) => Promise<void> | void;
833
+ }): Promise<void>;
834
+
835
+ declare function processTextStream({ stream, onTextPart, }: {
836
+ stream: ReadableStream<Uint8Array>;
837
+ onTextPart: (chunk: string) => Promise<void> | void;
838
+ }): Promise<void>;
839
+
840
+ /**
841
+ * Used to mark schemas so we can support both Zod and custom schemas.
842
+ */
843
+ declare const schemaSymbol: unique symbol;
844
+ type Schema<OBJECT = unknown> = Validator<OBJECT> & {
845
+ /**
846
+ * Used to mark schemas so we can support both Zod and custom schemas.
847
+ */
848
+ [schemaSymbol]: true;
849
+ /**
850
+ * Schema type for inference.
851
+ */
852
+ _type: OBJECT;
853
+ /**
854
+ * The JSON Schema for the schema. It is passed to the providers.
855
+ */
856
+ readonly jsonSchema: JSONSchema7;
857
+ };
858
+ /**
859
+ * Create a schema using a JSON Schema.
860
+ *
861
+ * @param jsonSchema The JSON Schema for the schema.
862
+ * @param options.validate Optional. A validation function for the schema.
863
+ */
864
+ declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validate, }?: {
865
+ validate?: (value: unknown) => {
866
+ success: true;
867
+ value: OBJECT;
868
+ } | {
869
+ success: false;
870
+ error: Error;
871
+ };
872
+ }): Schema<OBJECT>;
873
+ declare function asSchema<OBJECT>(schema: z.Schema<OBJECT, z.ZodTypeDef, any> | Schema<OBJECT>): Schema<OBJECT>;
874
+
875
+ declare function shouldResubmitMessages({ originalMaxToolInvocationStep, originalMessageCount, maxSteps, messages, }: {
876
+ originalMaxToolInvocationStep: number | undefined;
877
+ originalMessageCount: number;
878
+ maxSteps: number;
879
+ messages: UIMessage[];
880
+ }): boolean;
881
+ /**
882
+ Check if the message is an assistant message with completed tool calls.
883
+ The last step of the message must have at least one tool invocation and
884
+ all tool invocations must have a result.
885
+ */
886
+ declare function isAssistantMessageWithCompletedToolCalls(message: UIMessage): message is UIMessage & {
887
+ role: 'assistant';
888
+ };
889
+
890
+ /**
891
+ * Updates the result of a specific tool invocation in the last message of the given messages array.
892
+ *
893
+ * @param {object} params - The parameters object.
894
+ * @param {UIMessage[]} params.messages - An array of messages, from which the last one is updated.
895
+ * @param {string} params.toolCallId - The unique identifier for the tool invocation to update.
896
+ * @param {unknown} params.toolResult - The result object to attach to the tool invocation.
897
+ * @returns {void} This function does not return anything.
898
+ */
899
+ declare function updateToolCallResult({ messages, toolCallId, toolResult: result, }: {
900
+ messages: UIMessage[];
901
+ toolCallId: string;
902
+ toolResult: unknown;
903
+ }): void;
904
+
905
+ declare function zodSchema<OBJECT>(zodSchema: z.Schema<OBJECT, z.ZodTypeDef, any>, options?: {
906
+ /**
907
+ * Enables support for references in the schema.
908
+ * This is required for recursive schemas, e.g. with `z.lazy`.
909
+ * However, not all language models and providers support such references.
910
+ * Defaults to `false`.
911
+ */
912
+ useReferences?: boolean;
913
+ }): Schema<OBJECT>;
914
+
915
+ interface DataStreamWriter {
916
+ /**
917
+ * Appends a data part to the stream.
918
+ */
919
+ write(data: DataStreamString): void;
920
+ /**
921
+ * Appends a data part to the stream.
922
+ */
923
+ writeData(value: JSONValue$1): void;
924
+ /**
925
+ * Appends a message annotation to the stream.
926
+ */
927
+ writeMessageAnnotation(value: JSONValue$1): void;
928
+ /**
929
+ * Appends a source part to the stream.
930
+ */
931
+ writeSource(source: Source): void;
932
+ /**
933
+ * Merges the contents of another stream to this stream.
934
+ */
935
+ merge(stream: ReadableStream<DataStreamString>): void;
936
+ /**
937
+ * Error handler that is used by the data stream writer.
938
+ * This is intended for forwarding when merging streams
939
+ * to prevent duplicated error masking.
940
+ */
941
+ onError: ((error: unknown) => string) | undefined;
942
+ }
943
+
944
+ declare function createDataStream({ execute, onError, }: {
945
+ execute: (dataStream: DataStreamWriter) => Promise<void> | void;
946
+ onError?: (error: unknown) => string;
947
+ }): ReadableStream<DataStreamString>;
948
+
949
+ declare function createDataStreamResponse({ status, statusText, headers, execute, onError, }: ResponseInit & {
950
+ execute: (dataStream: DataStreamWriter) => Promise<void> | void;
951
+ onError?: (error: unknown) => string;
952
+ }): Response;
953
+
954
+ declare function pipeDataStreamToResponse(response: ServerResponse, { status, statusText, headers, execute, onError, }: ResponseInit & {
955
+ execute: (writer: DataStreamWriter) => Promise<void> | void;
956
+ onError?: (error: unknown) => string;
957
+ }): void;
958
+
959
+ /**
960
+ * Telemetry configuration.
961
+ */
962
+ type TelemetrySettings = {
963
+ /**
964
+ * Enable or disable telemetry. Disabled by default while experimental.
965
+ */
966
+ isEnabled?: boolean;
967
+ /**
968
+ * Enable or disable input recording. Enabled by default.
969
+ *
970
+ * You might want to disable input recording to avoid recording sensitive
971
+ * information, to reduce data transfers, or to increase performance.
972
+ */
973
+ recordInputs?: boolean;
974
+ /**
975
+ * Enable or disable output recording. Enabled by default.
976
+ *
977
+ * You might want to disable output recording to avoid recording sensitive
978
+ * information, to reduce data transfers, or to increase performance.
979
+ */
980
+ recordOutputs?: boolean;
981
+ /**
982
+ * Identifier for this function. Used to group telemetry data by function.
983
+ */
984
+ functionId?: string;
985
+ /**
986
+ * Additional information to include in the telemetry data.
987
+ */
988
+ metadata?: Record<string, AttributeValue>;
989
+ /**
990
+ * A custom tracer to use for the telemetry data.
991
+ */
992
+ tracer?: Tracer;
993
+ };
994
+
279
995
  /**
280
996
  The result of an `embed` call.
281
997
  It contains the embedding, the value, and additional information.
@@ -2104,7 +2820,7 @@ type StepResult<TOOLS extends ToolSet> = {
2104
2820
  /**
2105
2821
  The token usage of the generated text.
2106
2822
  */
2107
- readonly usage: LanguageModelUsage;
2823
+ readonly usage: LanguageModelUsage$1;
2108
2824
  /**
2109
2825
  Warnings from the model provider (e.g. unsupported settings).
2110
2826
  */
@@ -2201,7 +2917,7 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
2201
2917
  /**
2202
2918
  The token usage of the generated text.
2203
2919
  */
2204
- readonly usage: LanguageModelUsage;
2920
+ readonly usage: LanguageModelUsage$1;
2205
2921
  /**
2206
2922
  Warnings from the model provider (e.g. unsupported settings)
2207
2923
  */
@@ -2271,7 +2987,7 @@ interface Output<OUTPUT, PARTIAL> {
2271
2987
  text: string;
2272
2988
  }, context: {
2273
2989
  response: LanguageModelResponseMetadata;
2274
- usage: LanguageModelUsage;
2990
+ usage: LanguageModelUsage$1;
2275
2991
  finishReason: FinishReason;
2276
2992
  }): OUTPUT;
2277
2993
  }
@@ -2374,7 +3090,7 @@ type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
2374
3090
  tools: TOOLS;
2375
3091
  parameterSchema: (options: {
2376
3092
  toolName: string;
2377
- }) => JSONSchema7;
3093
+ }) => JSONSchema7$1;
2378
3094
  error: NoSuchToolError | InvalidToolArgumentsError;
2379
3095
  }) => Promise<LanguageModelV2FunctionToolCall | null>;
2380
3096
 
@@ -2515,8 +3231,8 @@ declare class StreamData {
2515
3231
  private warningTimeout;
2516
3232
  constructor();
2517
3233
  close(): Promise<void>;
2518
- append(value: JSONValue$1): void;
2519
- appendMessageAnnotation(value: JSONValue$1): void;
3234
+ append(value: JSONValue): void;
3235
+ appendMessageAnnotation(value: JSONValue): void;
2520
3236
  }
2521
3237
 
2522
3238
  type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
@@ -2574,7 +3290,7 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
2574
3290
 
2575
3291
  Resolved when the response is finished.
2576
3292
  */
2577
- readonly usage: Promise<LanguageModelUsage>;
3293
+ readonly usage: Promise<LanguageModelUsage$1>;
2578
3294
  /**
2579
3295
  Sources that have been used as input to generate the response.
2580
3296
  For multi-step generation, the sources are accumulated from all steps.
@@ -2799,7 +3515,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2799
3515
  request: LanguageModelRequestMetadata;
2800
3516
  warnings: CallWarning[] | undefined;
2801
3517
  response: LanguageModelResponseMetadata;
2802
- usage: LanguageModelUsage;
3518
+ usage: LanguageModelUsage$1;
2803
3519
  finishReason: FinishReason;
2804
3520
  providerMetadata: ProviderMetadata | undefined;
2805
3521
  /**
@@ -2810,7 +3526,7 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2810
3526
  } | {
2811
3527
  type: 'finish';
2812
3528
  finishReason: FinishReason;
2813
- usage: LanguageModelUsage;
3529
+ usage: LanguageModelUsage$1;
2814
3530
  providerMetadata: ProviderMetadata | undefined;
2815
3531
  /**
2816
3532
  * @deprecated Use `providerMetadata` instead.
@@ -3135,7 +3851,7 @@ declare function generateImage({ model, prompt, n, size, aspectRatio, seed, prov
3135
3851
  }
3136
3852
  ```
3137
3853
  */
3138
- providerOptions?: Record<string, Record<string, JSONValue>>;
3854
+ providerOptions?: Record<string, Record<string, JSONValue$1>>;
3139
3855
  /**
3140
3856
  Maximum number of retries per embedding model call. Set to 0 to disable retries.
3141
3857
 
@@ -3168,7 +3884,7 @@ interface GenerateObjectResult<OBJECT> {
3168
3884
  /**
3169
3885
  The token usage of the generated text.
3170
3886
  */
3171
- readonly usage: LanguageModelUsage;
3887
+ readonly usage: LanguageModelUsage$1;
3172
3888
  /**
3173
3889
  Warnings from the model provider (e.g. unsupported settings).
3174
3890
  */
@@ -3465,7 +4181,7 @@ functionality that can be fully encapsulated in the provider.
3465
4181
  generateId?: () => string;
3466
4182
  currentDate?: () => Date;
3467
4183
  };
3468
- }): Promise<GenerateObjectResult<JSONValue>>;
4184
+ }): Promise<GenerateObjectResult<JSONValue$1>>;
3469
4185
 
3470
4186
  /**
3471
4187
  The result of a `streamObject` call that contains the partial object stream and additional information.
@@ -3478,7 +4194,7 @@ interface StreamObjectResult<PARTIAL, RESULT, ELEMENT_STREAM> {
3478
4194
  /**
3479
4195
  The token usage of the generated response. Resolved when the response is finished.
3480
4196
  */
3481
- readonly usage: Promise<LanguageModelUsage>;
4197
+ readonly usage: Promise<LanguageModelUsage$1>;
3482
4198
  /**
3483
4199
  Additional provider-specific metadata. They are passed through
3484
4200
  from the provider to the AI SDK and enable provider-specific
@@ -3554,7 +4270,7 @@ type ObjectStreamPart<PARTIAL> = {
3554
4270
  type: 'finish';
3555
4271
  finishReason: FinishReason;
3556
4272
  logprobs?: LogProbs;
3557
- usage: LanguageModelUsage;
4273
+ usage: LanguageModelUsage$1;
3558
4274
  response: LanguageModelResponseMetadata;
3559
4275
  providerMetadata?: ProviderMetadata;
3560
4276
  };
@@ -3576,7 +4292,7 @@ type StreamObjectOnFinishCallback<RESULT> = (event: {
3576
4292
  /**
3577
4293
  The token usage of the generated response.
3578
4294
  */
3579
- usage: LanguageModelUsage;
4295
+ usage: LanguageModelUsage$1;
3580
4296
  /**
3581
4297
  The generated object. Can be undefined if the final object does not match the schema.
3582
4298
  */
@@ -3799,7 +4515,7 @@ The stream processing will pause until the callback promise is resolved.
3799
4515
  /**
3800
4516
  Callback that is called when the LLM response and the final object validation are finished.
3801
4517
  */
3802
- onFinish?: StreamObjectOnFinishCallback<JSONValue>;
4518
+ onFinish?: StreamObjectOnFinishCallback<JSONValue$1>;
3803
4519
  /**
3804
4520
  * Internal. For test use only. May change without notice.
3805
4521
  */
@@ -3808,7 +4524,7 @@ Callback that is called when the LLM response and the final object validation ar
3808
4524
  currentDate?: () => Date;
3809
4525
  now?: () => number;
3810
4526
  };
3811
- }): StreamObjectResult<JSONValue, JSONValue, never>;
4527
+ }): StreamObjectResult<JSONValue$1, JSONValue$1, never>;
3812
4528
 
3813
4529
  /**
3814
4530
  Warning from the model provider for this call. The call will proceed, but e.g.
@@ -3879,7 +4595,7 @@ interface TranscriptionResult {
3879
4595
  /**
3880
4596
  Provider metadata from the provider.
3881
4597
  */
3882
- readonly providerMetadata: Record<string, Record<string, JSONValue>>;
4598
+ readonly providerMetadata: Record<string, Record<string, JSONValue$1>>;
3883
4599
  }
3884
4600
 
3885
4601
  /**
@@ -4147,7 +4863,7 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
4147
4863
  type: 'finish';
4148
4864
  finishReason: FinishReason;
4149
4865
  logprobs?: LogProbs;
4150
- usage: LanguageModelUsage;
4866
+ usage: LanguageModelUsage$1;
4151
4867
  experimental_providerMetadata?: ProviderMetadata;
4152
4868
  } | {
4153
4869
  type: 'error';
@@ -4211,7 +4927,7 @@ declare class NoObjectGeneratedError extends AISDKError {
4211
4927
  /**
4212
4928
  The usage of the model.
4213
4929
  */
4214
- readonly usage: LanguageModelUsage | undefined;
4930
+ readonly usage: LanguageModelUsage$1 | undefined;
4215
4931
  /**
4216
4932
  Reason why the model finished generating a response.
4217
4933
  */
@@ -4221,7 +4937,7 @@ declare class NoObjectGeneratedError extends AISDKError {
4221
4937
  cause?: Error;
4222
4938
  text?: string;
4223
4939
  response: LanguageModelResponseMetadata;
4224
- usage: LanguageModelUsage;
4940
+ usage: LanguageModelUsage$1;
4225
4941
  finishReason: FinishReason;
4226
4942
  });
4227
4943
  static isInstance(error: unknown): error is NoObjectGeneratedError;
@@ -4255,11 +4971,11 @@ declare const symbol$6: unique symbol;
4255
4971
  declare class ToolExecutionError extends AISDKError {
4256
4972
  private readonly [symbol$6];
4257
4973
  readonly toolName: string;
4258
- readonly toolArgs: JSONValue;
4974
+ readonly toolArgs: JSONValue$1;
4259
4975
  readonly toolCallId: string;
4260
4976
  constructor({ toolArgs, toolName, toolCallId, cause, message, }: {
4261
4977
  message?: string;
4262
- toolArgs: JSONValue;
4978
+ toolArgs: JSONValue$1;
4263
4979
  toolName: string;
4264
4980
  toolCallId: string;
4265
4981
  cause: unknown;
@@ -4442,4 +5158,4 @@ declare namespace llamaindexAdapter {
4442
5158
  };
4443
5159
  }
4444
5160
 
4445
- export { AssistantContent, CallSettings, CallWarning, ChunkDetector, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolCallUnion, CoreToolChoice, CoreToolMessage, CoreToolResultUnion, CoreUserMessage, DataContent, DataStreamOptions, DataStreamWriter, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedFile, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelResponseMetadata, ImagePart, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, langchainAdapter as LangChainAdapter, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, RepairTextFunction, RetryError, StepResult, StreamData, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextPart, TextStreamPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolResultPart, ToolResultUnion, ToolSet, UserContent, appendClientMessage, appendResponseMessages, convertToCoreMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, transcribe as experimental_transcribe, experimental_wrapLanguageModel, extractReasoningMiddleware, generateObject, generateText, pipeDataStreamToResponse, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, tool, wrapLanguageModel };
5161
+ export { AssistantContent, Attachment, CallSettings, CallWarning, ChatRequest, ChatRequestOptions, ChunkDetector, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolCallUnion, CoreToolChoice, CoreToolMessage, CoreToolResultUnion, CoreUserMessage, CreateMessage, DataContent, DataStreamOptions, DataStreamPart, DataStreamString, DataStreamWriter, DeepPartial, DownloadError, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, TranscriptionResult as Experimental_TranscriptionResult, FilePart, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedFile, IdGenerator, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelResponseMetadata, ImagePart, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolArgumentsError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, langchainAdapter as LangChainAdapter, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage$1 as LanguageModelUsage, llamaindexAdapter as LlamaIndexAdapter, LogProbs, MCPClientError, MCPTransport, Message, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Prompt, Provider, ProviderMetadata, ProviderOptions, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RequestOptions, RetryError, Schema, SourceUIPart, StepResult, StepStartUIPart, StreamData, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextPart, TextStreamPart, TextUIPart, Tool, ToolCallPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolContent, ToolExecutionError, ToolExecutionOptions, ToolInvocation, ToolInvocationUIPart, ToolResultPart, ToolResultUnion, ToolSet, UIMessage, UseChatOptions, UseCompletionOptions, UserContent, appendClientMessage, appendResponseMessages, asSchema, callChatApi, callCompletionApi, convertToCoreMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDataStream, createDataStreamResponse, createProviderRegistry, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, transcribe as experimental_transcribe, experimental_wrapLanguageModel, extractMaxToolInvocationStep, extractReasoningMiddleware, fillMessageParts, formatDataStreamPart, generateObject, generateText, getMessageParts, getTextFromDataUrl, isAssistantMessageWithCompletedToolCalls, isDeepEqualData, jsonSchema, parseDataStreamPart, parsePartialJson, pipeDataStreamToResponse, prepareAttachmentsForRequest, processDataStream, processTextStream, shouldResubmitMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, streamObject, streamText, tool, updateToolCallResult, wrapLanguageModel, zodSchema };