ai 5.0.0-canary.15 → 5.0.0-canary.17

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.
@@ -64,10 +64,6 @@ interface ImagePart {
64
64
  */
65
65
  mediaType?: string;
66
66
  /**
67
- @deprecated Use `mediaType` instead.
68
- */
69
- mimeType?: string;
70
- /**
71
67
  Additional provider-specific metadata. They are passed through
72
68
  to the provider from the AI SDK and enable provider-specific
73
69
  functionality that can be fully encapsulated in the provider.
@@ -97,10 +93,6 @@ interface FilePart {
97
93
  */
98
94
  mediaType: string;
99
95
  /**
100
- @deprecated Use `mediaType` instead.
101
- */
102
- mimeType?: string;
103
- /**
104
96
  Additional provider-specific metadata. They are passed through
105
97
  to the provider from the AI SDK and enable provider-specific
106
98
  functionality that can be fully encapsulated in the provider.
@@ -187,7 +179,7 @@ interface ToolResultPart {
187
179
  to increase the resilience against prompt injection attacks,
188
180
  and because not all providers support several system messages.
189
181
  */
190
- type CoreSystemMessage = {
182
+ type SystemModelMessage = {
191
183
  role: 'system';
192
184
  content: string;
193
185
  /**
@@ -200,7 +192,7 @@ type CoreSystemMessage = {
200
192
  /**
201
193
  A user message. It can contain text or a combination of text and images.
202
194
  */
203
- type CoreUserMessage = {
195
+ type UserModelMessage = {
204
196
  role: 'user';
205
197
  content: UserContent;
206
198
  /**
@@ -217,7 +209,7 @@ type UserContent = string | Array<TextPart | ImagePart | FilePart>;
217
209
  /**
218
210
  An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
219
211
  */
220
- type CoreAssistantMessage = {
212
+ type AssistantModelMessage = {
221
213
  role: 'assistant';
222
214
  content: AssistantContent;
223
215
  /**
@@ -235,7 +227,7 @@ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | Too
235
227
  /**
236
228
  A tool message. It contains the result of one or more tool calls.
237
229
  */
238
- type CoreToolMessage = {
230
+ type ToolModelMessage = {
239
231
  role: 'tool';
240
232
  content: ToolContent;
241
233
  /**
@@ -253,7 +245,7 @@ type ToolContent = Array<ToolResultPart>;
253
245
  A message that can be used in the `messages` field of a prompt.
254
246
  It can be a user message, an assistant message, or a tool message.
255
247
  */
256
- type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage | CoreToolMessage;
248
+ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
257
249
 
258
250
  type JSONValue = JSONValue$1;
259
251
 
@@ -293,28 +285,10 @@ type ToolInvocation = ({
293
285
  state: 'result';
294
286
  step?: number;
295
287
  } & ToolResult<string, any, any>);
296
- /**
297
- * An attachment that can be sent along with a message.
298
- */
299
- interface Attachment {
300
- /**
301
- * The name of the attachment, usually the file name.
302
- */
303
- name?: string;
304
- /**
305
- * A string indicating the [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
306
- * By default, it's extracted from the pathname's extension.
307
- */
308
- contentType?: string;
309
- /**
310
- * 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).
311
- */
312
- url: string;
313
- }
314
288
  /**
315
289
  * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
316
290
  */
317
- interface Message {
291
+ interface UIMessage {
318
292
  /**
319
293
  A unique identifier for the message.
320
294
  */
@@ -328,32 +302,26 @@ interface Message {
328
302
  */
329
303
  content: string;
330
304
  /**
331
- * Additional attachments to be sent along with the message.
305
+ The role of the message.
332
306
  */
333
- experimental_attachments?: Attachment[];
307
+ role: 'system' | 'user' | 'assistant';
334
308
  /**
335
- The 'data' role is deprecated.
336
- */
337
- role: 'system' | 'user' | 'assistant' | 'data';
338
- /**
339
- * Additional message-specific information added on the server via StreamData
309
+ Additional message-specific information added on the server via StreamData
340
310
  */
341
311
  annotations?: JSONValue$1[] | undefined;
342
312
  /**
343
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
344
- that the assistant made as part of this message.
313
+ The parts of the message. Use this for rendering the message in the UI.
345
314
 
346
- @deprecated Use `parts` instead.
347
- */
348
- toolInvocations?: Array<ToolInvocation>;
349
- /**
350
- * The parts of the message. Use this for rendering the message in the UI.
351
- *
352
- * Assistant messages can have text, reasoning and tool invocation parts.
353
- * User messages can have text parts.
315
+ System messages should be avoided (set the system prompt on the server instead).
316
+ They can have text parts.
317
+
318
+ User messages can have text parts and file parts.
319
+
320
+ Assistant messages can have text, reasoning, tool invocation, and file parts.
354
321
  */
355
- parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
322
+ parts: Array<UIMessagePart>;
356
323
  }
324
+ type UIMessagePart = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart;
357
325
  /**
358
326
  * A text part of a message.
359
327
  */
@@ -372,7 +340,7 @@ type ReasoningUIPart = {
372
340
  /**
373
341
  * The reasoning text.
374
342
  */
375
- reasoning: string;
343
+ text: string;
376
344
  /**
377
345
  * The provider metadata.
378
346
  */
@@ -410,9 +378,14 @@ type FileUIPart = {
410
378
  */
411
379
  mediaType: string;
412
380
  /**
413
- * The base64 encoded data.
381
+ * Optional filename of the file.
414
382
  */
415
- data: string;
383
+ filename?: string;
384
+ /**
385
+ * The URL of the file.
386
+ * 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).
387
+ */
388
+ url: string;
416
389
  };
417
390
  /**
418
391
  * A step boundary part of a message.
@@ -474,8 +447,8 @@ declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, Da
474
447
  text: string;
475
448
  providerMetadata?: Record<string, any> | undefined;
476
449
  }>, DataStreamPart<"h", "source", LanguageModelV2Source>, DataStreamPart<"l", "reasoning_part_finish", {}>, DataStreamPart<"k", "file", {
477
- data: string;
478
- mimeType: string;
450
+ url: string;
451
+ mediaType: string;
479
452
  }>];
480
453
  type DataStreamParts = (typeof dataStreamParts)[number];
481
454
  /**
@@ -508,7 +481,7 @@ type DataStreamPartValueType = {
508
481
  */
509
482
  declare const DataStreamStringPrefixes: { [K in DataStreamParts["name"]]: (typeof dataStreamParts)[number]["code"]; };
510
483
  /**
511
- Prepends a string with a prefix from the `StreamChunkPrefixes`, JSON-ifies it,
484
+ Prepends a string with a prefix from the `StreamChunkPrefixes`, converts it to JSON,
512
485
  and appends a new line.
513
486
 
514
487
  It ensures type-safety for the part type and value.
@@ -525,7 +498,7 @@ interface ToolExecutionOptions {
525
498
  * Messages that were sent to the language model to initiate the response that contained the tool call.
526
499
  * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
527
500
  */
528
- messages: CoreMessage[];
501
+ messages: ModelMessage[];
529
502
  /**
530
503
  * An optional abort signal that indicates that the overall operation should be aborted.
531
504
  */
@@ -603,7 +576,7 @@ type Prompt = {
603
576
  /**
604
577
  A list of messages. You can either use `prompt` or `messages` but not both.
605
578
  */
606
- messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
579
+ messages?: Array<ModelMessage> | Array<Omit<UIMessage, 'id'>>;
607
580
  };
608
581
 
609
582
  type StandardizedPrompt = {
@@ -614,7 +587,7 @@ type StandardizedPrompt = {
614
587
  /**
615
588
  * Messages.
616
589
  */
617
- messages: CoreMessage[];
590
+ messages: ModelMessage[];
618
591
  };
619
592
  declare function standardizePrompt<TOOLS extends ToolSet>({ prompt, tools, }: {
620
593
  prompt: Prompt;
@@ -64,10 +64,6 @@ interface ImagePart {
64
64
  */
65
65
  mediaType?: string;
66
66
  /**
67
- @deprecated Use `mediaType` instead.
68
- */
69
- mimeType?: string;
70
- /**
71
67
  Additional provider-specific metadata. They are passed through
72
68
  to the provider from the AI SDK and enable provider-specific
73
69
  functionality that can be fully encapsulated in the provider.
@@ -97,10 +93,6 @@ interface FilePart {
97
93
  */
98
94
  mediaType: string;
99
95
  /**
100
- @deprecated Use `mediaType` instead.
101
- */
102
- mimeType?: string;
103
- /**
104
96
  Additional provider-specific metadata. They are passed through
105
97
  to the provider from the AI SDK and enable provider-specific
106
98
  functionality that can be fully encapsulated in the provider.
@@ -187,7 +179,7 @@ interface ToolResultPart {
187
179
  to increase the resilience against prompt injection attacks,
188
180
  and because not all providers support several system messages.
189
181
  */
190
- type CoreSystemMessage = {
182
+ type SystemModelMessage = {
191
183
  role: 'system';
192
184
  content: string;
193
185
  /**
@@ -200,7 +192,7 @@ type CoreSystemMessage = {
200
192
  /**
201
193
  A user message. It can contain text or a combination of text and images.
202
194
  */
203
- type CoreUserMessage = {
195
+ type UserModelMessage = {
204
196
  role: 'user';
205
197
  content: UserContent;
206
198
  /**
@@ -217,7 +209,7 @@ type UserContent = string | Array<TextPart | ImagePart | FilePart>;
217
209
  /**
218
210
  An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
219
211
  */
220
- type CoreAssistantMessage = {
212
+ type AssistantModelMessage = {
221
213
  role: 'assistant';
222
214
  content: AssistantContent;
223
215
  /**
@@ -235,7 +227,7 @@ type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | Too
235
227
  /**
236
228
  A tool message. It contains the result of one or more tool calls.
237
229
  */
238
- type CoreToolMessage = {
230
+ type ToolModelMessage = {
239
231
  role: 'tool';
240
232
  content: ToolContent;
241
233
  /**
@@ -253,7 +245,7 @@ type ToolContent = Array<ToolResultPart>;
253
245
  A message that can be used in the `messages` field of a prompt.
254
246
  It can be a user message, an assistant message, or a tool message.
255
247
  */
256
- type CoreMessage = CoreSystemMessage | CoreUserMessage | CoreAssistantMessage | CoreToolMessage;
248
+ type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
257
249
 
258
250
  type JSONValue = JSONValue$1;
259
251
 
@@ -293,28 +285,10 @@ type ToolInvocation = ({
293
285
  state: 'result';
294
286
  step?: number;
295
287
  } & ToolResult<string, any, any>);
296
- /**
297
- * An attachment that can be sent along with a message.
298
- */
299
- interface Attachment {
300
- /**
301
- * The name of the attachment, usually the file name.
302
- */
303
- name?: string;
304
- /**
305
- * A string indicating the [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type).
306
- * By default, it's extracted from the pathname's extension.
307
- */
308
- contentType?: string;
309
- /**
310
- * 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).
311
- */
312
- url: string;
313
- }
314
288
  /**
315
289
  * AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes.
316
290
  */
317
- interface Message {
291
+ interface UIMessage {
318
292
  /**
319
293
  A unique identifier for the message.
320
294
  */
@@ -328,32 +302,26 @@ interface Message {
328
302
  */
329
303
  content: string;
330
304
  /**
331
- * Additional attachments to be sent along with the message.
305
+ The role of the message.
332
306
  */
333
- experimental_attachments?: Attachment[];
307
+ role: 'system' | 'user' | 'assistant';
334
308
  /**
335
- The 'data' role is deprecated.
336
- */
337
- role: 'system' | 'user' | 'assistant' | 'data';
338
- /**
339
- * Additional message-specific information added on the server via StreamData
309
+ Additional message-specific information added on the server via StreamData
340
310
  */
341
311
  annotations?: JSONValue$1[] | undefined;
342
312
  /**
343
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
344
- that the assistant made as part of this message.
313
+ The parts of the message. Use this for rendering the message in the UI.
345
314
 
346
- @deprecated Use `parts` instead.
347
- */
348
- toolInvocations?: Array<ToolInvocation>;
349
- /**
350
- * The parts of the message. Use this for rendering the message in the UI.
351
- *
352
- * Assistant messages can have text, reasoning and tool invocation parts.
353
- * User messages can have text parts.
315
+ System messages should be avoided (set the system prompt on the server instead).
316
+ They can have text parts.
317
+
318
+ User messages can have text parts and file parts.
319
+
320
+ Assistant messages can have text, reasoning, tool invocation, and file parts.
354
321
  */
355
- parts?: Array<TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart>;
322
+ parts: Array<UIMessagePart>;
356
323
  }
324
+ type UIMessagePart = TextUIPart | ReasoningUIPart | ToolInvocationUIPart | SourceUIPart | FileUIPart | StepStartUIPart;
357
325
  /**
358
326
  * A text part of a message.
359
327
  */
@@ -372,7 +340,7 @@ type ReasoningUIPart = {
372
340
  /**
373
341
  * The reasoning text.
374
342
  */
375
- reasoning: string;
343
+ text: string;
376
344
  /**
377
345
  * The provider metadata.
378
346
  */
@@ -410,9 +378,14 @@ type FileUIPart = {
410
378
  */
411
379
  mediaType: string;
412
380
  /**
413
- * The base64 encoded data.
381
+ * Optional filename of the file.
414
382
  */
415
- data: string;
383
+ filename?: string;
384
+ /**
385
+ * The URL of the file.
386
+ * 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).
387
+ */
388
+ url: string;
416
389
  };
417
390
  /**
418
391
  * A step boundary part of a message.
@@ -474,8 +447,8 @@ declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, Da
474
447
  text: string;
475
448
  providerMetadata?: Record<string, any> | undefined;
476
449
  }>, DataStreamPart<"h", "source", LanguageModelV2Source>, DataStreamPart<"l", "reasoning_part_finish", {}>, DataStreamPart<"k", "file", {
477
- data: string;
478
- mimeType: string;
450
+ url: string;
451
+ mediaType: string;
479
452
  }>];
480
453
  type DataStreamParts = (typeof dataStreamParts)[number];
481
454
  /**
@@ -508,7 +481,7 @@ type DataStreamPartValueType = {
508
481
  */
509
482
  declare const DataStreamStringPrefixes: { [K in DataStreamParts["name"]]: (typeof dataStreamParts)[number]["code"]; };
510
483
  /**
511
- Prepends a string with a prefix from the `StreamChunkPrefixes`, JSON-ifies it,
484
+ Prepends a string with a prefix from the `StreamChunkPrefixes`, converts it to JSON,
512
485
  and appends a new line.
513
486
 
514
487
  It ensures type-safety for the part type and value.
@@ -525,7 +498,7 @@ interface ToolExecutionOptions {
525
498
  * Messages that were sent to the language model to initiate the response that contained the tool call.
526
499
  * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
527
500
  */
528
- messages: CoreMessage[];
501
+ messages: ModelMessage[];
529
502
  /**
530
503
  * An optional abort signal that indicates that the overall operation should be aborted.
531
504
  */
@@ -603,7 +576,7 @@ type Prompt = {
603
576
  /**
604
577
  A list of messages. You can either use `prompt` or `messages` but not both.
605
578
  */
606
- messages?: Array<CoreMessage> | Array<Omit<Message, 'id'>>;
579
+ messages?: Array<ModelMessage> | Array<Omit<UIMessage, 'id'>>;
607
580
  };
608
581
 
609
582
  type StandardizedPrompt = {
@@ -614,7 +587,7 @@ type StandardizedPrompt = {
614
587
  /**
615
588
  * Messages.
616
589
  */
617
- messages: CoreMessage[];
590
+ messages: ModelMessage[];
618
591
  };
619
592
  declare function standardizePrompt<TOOLS extends ToolSet>({ prompt, tools, }: {
620
593
  prompt: Prompt;