ai 5.0.0-canary.16 → 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.
- package/CHANGELOG.md +40 -0
- package/dist/index.d.mts +105 -75
- package/dist/index.d.ts +105 -75
- package/dist/index.js +168 -215
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -216
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +24 -45
- package/dist/internal/index.d.ts +24 -45
- package/dist/internal/index.js +192 -324
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +185 -317
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
@@ -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
|
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
|
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
|
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
|
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
|
248
|
+
type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
|
257
249
|
|
258
250
|
type JSONValue = JSONValue$1;
|
259
251
|
|
@@ -293,24 +285,6 @@ 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
|
*/
|
@@ -328,10 +302,6 @@ interface UIMessage {
|
|
328
302
|
*/
|
329
303
|
content: string;
|
330
304
|
/**
|
331
|
-
Additional attachments to be sent along with the message.
|
332
|
-
*/
|
333
|
-
experimental_attachments?: Attachment[];
|
334
|
-
/**
|
335
305
|
The role of the message.
|
336
306
|
*/
|
337
307
|
role: 'system' | 'user' | 'assistant';
|
@@ -342,8 +312,12 @@ interface UIMessage {
|
|
342
312
|
/**
|
343
313
|
The parts of the message. Use this for rendering the message in the UI.
|
344
314
|
|
345
|
-
|
346
|
-
|
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.
|
347
321
|
*/
|
348
322
|
parts: Array<UIMessagePart>;
|
349
323
|
}
|
@@ -404,9 +378,14 @@ type FileUIPart = {
|
|
404
378
|
*/
|
405
379
|
mediaType: string;
|
406
380
|
/**
|
407
|
-
*
|
381
|
+
* Optional filename of the file.
|
408
382
|
*/
|
409
|
-
|
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;
|
410
389
|
};
|
411
390
|
/**
|
412
391
|
* A step boundary part of a message.
|
@@ -468,8 +447,8 @@ declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, Da
|
|
468
447
|
text: string;
|
469
448
|
providerMetadata?: Record<string, any> | undefined;
|
470
449
|
}>, DataStreamPart<"h", "source", LanguageModelV2Source>, DataStreamPart<"l", "reasoning_part_finish", {}>, DataStreamPart<"k", "file", {
|
471
|
-
|
472
|
-
|
450
|
+
url: string;
|
451
|
+
mediaType: string;
|
473
452
|
}>];
|
474
453
|
type DataStreamParts = (typeof dataStreamParts)[number];
|
475
454
|
/**
|
@@ -502,7 +481,7 @@ type DataStreamPartValueType = {
|
|
502
481
|
*/
|
503
482
|
declare const DataStreamStringPrefixes: { [K in DataStreamParts["name"]]: (typeof dataStreamParts)[number]["code"]; };
|
504
483
|
/**
|
505
|
-
Prepends a string with a prefix from the `StreamChunkPrefixes`,
|
484
|
+
Prepends a string with a prefix from the `StreamChunkPrefixes`, converts it to JSON,
|
506
485
|
and appends a new line.
|
507
486
|
|
508
487
|
It ensures type-safety for the part type and value.
|
@@ -519,7 +498,7 @@ interface ToolExecutionOptions {
|
|
519
498
|
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
520
499
|
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
521
500
|
*/
|
522
|
-
messages:
|
501
|
+
messages: ModelMessage[];
|
523
502
|
/**
|
524
503
|
* An optional abort signal that indicates that the overall operation should be aborted.
|
525
504
|
*/
|
@@ -597,7 +576,7 @@ type Prompt = {
|
|
597
576
|
/**
|
598
577
|
A list of messages. You can either use `prompt` or `messages` but not both.
|
599
578
|
*/
|
600
|
-
messages?: Array<
|
579
|
+
messages?: Array<ModelMessage> | Array<Omit<UIMessage, 'id'>>;
|
601
580
|
};
|
602
581
|
|
603
582
|
type StandardizedPrompt = {
|
@@ -608,7 +587,7 @@ type StandardizedPrompt = {
|
|
608
587
|
/**
|
609
588
|
* Messages.
|
610
589
|
*/
|
611
|
-
messages:
|
590
|
+
messages: ModelMessage[];
|
612
591
|
};
|
613
592
|
declare function standardizePrompt<TOOLS extends ToolSet>({ prompt, tools, }: {
|
614
593
|
prompt: Prompt;
|
package/dist/internal/index.d.ts
CHANGED
@@ -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
|
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
|
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
|
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
|
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
|
248
|
+
type ModelMessage = SystemModelMessage | UserModelMessage | AssistantModelMessage | ToolModelMessage;
|
257
249
|
|
258
250
|
type JSONValue = JSONValue$1;
|
259
251
|
|
@@ -293,24 +285,6 @@ 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
|
*/
|
@@ -328,10 +302,6 @@ interface UIMessage {
|
|
328
302
|
*/
|
329
303
|
content: string;
|
330
304
|
/**
|
331
|
-
Additional attachments to be sent along with the message.
|
332
|
-
*/
|
333
|
-
experimental_attachments?: Attachment[];
|
334
|
-
/**
|
335
305
|
The role of the message.
|
336
306
|
*/
|
337
307
|
role: 'system' | 'user' | 'assistant';
|
@@ -342,8 +312,12 @@ interface UIMessage {
|
|
342
312
|
/**
|
343
313
|
The parts of the message. Use this for rendering the message in the UI.
|
344
314
|
|
345
|
-
|
346
|
-
|
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.
|
347
321
|
*/
|
348
322
|
parts: Array<UIMessagePart>;
|
349
323
|
}
|
@@ -404,9 +378,14 @@ type FileUIPart = {
|
|
404
378
|
*/
|
405
379
|
mediaType: string;
|
406
380
|
/**
|
407
|
-
*
|
381
|
+
* Optional filename of the file.
|
408
382
|
*/
|
409
|
-
|
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;
|
410
389
|
};
|
411
390
|
/**
|
412
391
|
* A step boundary part of a message.
|
@@ -468,8 +447,8 @@ declare const dataStreamParts: readonly [DataStreamPart<"0", "text", string>, Da
|
|
468
447
|
text: string;
|
469
448
|
providerMetadata?: Record<string, any> | undefined;
|
470
449
|
}>, DataStreamPart<"h", "source", LanguageModelV2Source>, DataStreamPart<"l", "reasoning_part_finish", {}>, DataStreamPart<"k", "file", {
|
471
|
-
|
472
|
-
|
450
|
+
url: string;
|
451
|
+
mediaType: string;
|
473
452
|
}>];
|
474
453
|
type DataStreamParts = (typeof dataStreamParts)[number];
|
475
454
|
/**
|
@@ -502,7 +481,7 @@ type DataStreamPartValueType = {
|
|
502
481
|
*/
|
503
482
|
declare const DataStreamStringPrefixes: { [K in DataStreamParts["name"]]: (typeof dataStreamParts)[number]["code"]; };
|
504
483
|
/**
|
505
|
-
Prepends a string with a prefix from the `StreamChunkPrefixes`,
|
484
|
+
Prepends a string with a prefix from the `StreamChunkPrefixes`, converts it to JSON,
|
506
485
|
and appends a new line.
|
507
486
|
|
508
487
|
It ensures type-safety for the part type and value.
|
@@ -519,7 +498,7 @@ interface ToolExecutionOptions {
|
|
519
498
|
* Messages that were sent to the language model to initiate the response that contained the tool call.
|
520
499
|
* The messages **do not** include the system prompt nor the assistant response that contained the tool call.
|
521
500
|
*/
|
522
|
-
messages:
|
501
|
+
messages: ModelMessage[];
|
523
502
|
/**
|
524
503
|
* An optional abort signal that indicates that the overall operation should be aborted.
|
525
504
|
*/
|
@@ -597,7 +576,7 @@ type Prompt = {
|
|
597
576
|
/**
|
598
577
|
A list of messages. You can either use `prompt` or `messages` but not both.
|
599
578
|
*/
|
600
|
-
messages?: Array<
|
579
|
+
messages?: Array<ModelMessage> | Array<Omit<UIMessage, 'id'>>;
|
601
580
|
};
|
602
581
|
|
603
582
|
type StandardizedPrompt = {
|
@@ -608,7 +587,7 @@ type StandardizedPrompt = {
|
|
608
587
|
/**
|
609
588
|
* Messages.
|
610
589
|
*/
|
611
|
-
messages:
|
590
|
+
messages: ModelMessage[];
|
612
591
|
};
|
613
592
|
declare function standardizePrompt<TOOLS extends ToolSet>({ prompt, tools, }: {
|
614
593
|
prompt: Prompt;
|