ai 4.1.62 → 4.1.64
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 +20 -0
- package/dist/index.d.mts +1828 -1807
- package/dist/index.d.ts +1828 -1807
- package/dist/index.js +261 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -63
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/rsc/dist/index.d.ts +3 -2
- package/rsc/dist/rsc-server.d.mts +3 -2
- package/rsc/dist/rsc-server.mjs +129 -20
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "4.1.
|
3
|
+
"version": "4.1.64",
|
4
4
|
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"sideEffects": false,
|
@@ -45,10 +45,10 @@
|
|
45
45
|
}
|
46
46
|
},
|
47
47
|
"dependencies": {
|
48
|
-
"@ai-sdk/provider": "1.0.
|
49
|
-
"@ai-sdk/provider-utils": "2.1.
|
50
|
-
"@ai-sdk/react": "1.1.
|
51
|
-
"@ai-sdk/ui-utils": "1.1.
|
48
|
+
"@ai-sdk/provider": "1.0.12",
|
49
|
+
"@ai-sdk/provider-utils": "2.1.15",
|
50
|
+
"@ai-sdk/react": "1.1.25",
|
51
|
+
"@ai-sdk/ui-utils": "1.1.21",
|
52
52
|
"@opentelemetry/api": "1.9.0",
|
53
53
|
"eventsource-parser": "^3.0.0",
|
54
54
|
"jsondiffpatch": "0.6.0"
|
package/rsc/dist/index.d.ts
CHANGED
@@ -498,9 +498,10 @@ type CoreAssistantMessage = {
|
|
498
498
|
experimental_providerMetadata?: ProviderMetadata;
|
499
499
|
};
|
500
500
|
/**
|
501
|
-
Content of an assistant message.
|
501
|
+
Content of an assistant message.
|
502
|
+
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
502
503
|
*/
|
503
|
-
type AssistantContent = string | Array<TextPart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
|
504
|
+
type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
|
504
505
|
/**
|
505
506
|
A tool message. It contains the result of one or more tool calls.
|
506
507
|
*/
|
@@ -496,9 +496,10 @@ type CoreAssistantMessage = {
|
|
496
496
|
experimental_providerMetadata?: ProviderMetadata;
|
497
497
|
};
|
498
498
|
/**
|
499
|
-
Content of an assistant message.
|
499
|
+
Content of an assistant message.
|
500
|
+
It can be a string or an array of text, image, reasoning, redacted reasoning, and tool call parts.
|
500
501
|
*/
|
501
|
-
type AssistantContent = string | Array<TextPart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
|
502
|
+
type AssistantContent = string | Array<TextPart | FilePart | ReasoningPart | RedactedReasoningPart | ToolCallPart>;
|
502
503
|
/**
|
503
504
|
A tool message. It contains the result of one or more tool calls.
|
504
505
|
*/
|
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -269,15 +269,82 @@ async function download({
|
|
269
269
|
|
270
270
|
// core/util/detect-image-mimetype.ts
|
271
271
|
var mimeTypeSignatures = [
|
272
|
-
{
|
273
|
-
|
274
|
-
|
275
|
-
|
272
|
+
{
|
273
|
+
mimeType: "image/gif",
|
274
|
+
bytesPrefix: [71, 73, 70],
|
275
|
+
base64Prefix: "R0lG"
|
276
|
+
},
|
277
|
+
{
|
278
|
+
mimeType: "image/png",
|
279
|
+
bytesPrefix: [137, 80, 78, 71],
|
280
|
+
base64Prefix: "iVBORw"
|
281
|
+
},
|
282
|
+
{
|
283
|
+
mimeType: "image/jpeg",
|
284
|
+
bytesPrefix: [255, 216],
|
285
|
+
base64Prefix: "/9j/"
|
286
|
+
},
|
287
|
+
{
|
288
|
+
mimeType: "image/webp",
|
289
|
+
bytesPrefix: [82, 73, 70, 70],
|
290
|
+
base64Prefix: "UklGRg"
|
291
|
+
},
|
292
|
+
{
|
293
|
+
mimeType: "image/bmp",
|
294
|
+
bytesPrefix: [66, 77],
|
295
|
+
base64Prefix: "Qk"
|
296
|
+
},
|
297
|
+
{
|
298
|
+
mimeType: "image/tiff",
|
299
|
+
bytesPrefix: [73, 73, 42, 0],
|
300
|
+
base64Prefix: "SUkqAA"
|
301
|
+
},
|
302
|
+
{
|
303
|
+
mimeType: "image/tiff",
|
304
|
+
bytesPrefix: [77, 77, 0, 42],
|
305
|
+
base64Prefix: "TU0AKg"
|
306
|
+
},
|
307
|
+
{
|
308
|
+
mimeType: "image/avif",
|
309
|
+
bytesPrefix: [
|
310
|
+
0,
|
311
|
+
0,
|
312
|
+
0,
|
313
|
+
32,
|
314
|
+
102,
|
315
|
+
116,
|
316
|
+
121,
|
317
|
+
112,
|
318
|
+
97,
|
319
|
+
118,
|
320
|
+
105,
|
321
|
+
102
|
322
|
+
],
|
323
|
+
base64Prefix: "AAAAIGZ0eXBhdmlm"
|
324
|
+
},
|
325
|
+
{
|
326
|
+
mimeType: "image/heic",
|
327
|
+
bytesPrefix: [
|
328
|
+
0,
|
329
|
+
0,
|
330
|
+
0,
|
331
|
+
32,
|
332
|
+
102,
|
333
|
+
116,
|
334
|
+
121,
|
335
|
+
112,
|
336
|
+
104,
|
337
|
+
101,
|
338
|
+
105,
|
339
|
+
99
|
340
|
+
],
|
341
|
+
base64Prefix: "AAAAIGZ0eXBoZWlj"
|
342
|
+
}
|
276
343
|
];
|
277
344
|
function detectImageMimeType(image) {
|
278
|
-
for (const
|
279
|
-
if (image.length >=
|
280
|
-
return mimeType;
|
345
|
+
for (const signature of mimeTypeSignatures) {
|
346
|
+
if (typeof image === "string" ? image.startsWith(signature.base64Prefix) : image.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => image[index] === byte)) {
|
347
|
+
return signature.mimeType;
|
281
348
|
}
|
282
349
|
}
|
283
350
|
return void 0;
|
@@ -459,11 +526,50 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
459
526
|
// remove empty text parts:
|
460
527
|
(part) => part.type !== "text" || part.text !== ""
|
461
528
|
).map((part) => {
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
529
|
+
var _a10;
|
530
|
+
const providerOptions = (_a10 = part.providerOptions) != null ? _a10 : part.experimental_providerMetadata;
|
531
|
+
switch (part.type) {
|
532
|
+
case "file": {
|
533
|
+
return {
|
534
|
+
type: "file",
|
535
|
+
data: part.data instanceof URL ? part.data : convertDataContentToBase64String(part.data),
|
536
|
+
filename: part.filename,
|
537
|
+
mimeType: part.mimeType,
|
538
|
+
providerMetadata: providerOptions
|
539
|
+
};
|
540
|
+
}
|
541
|
+
case "reasoning": {
|
542
|
+
return {
|
543
|
+
type: "reasoning",
|
544
|
+
text: part.text,
|
545
|
+
signature: part.signature,
|
546
|
+
providerMetadata: providerOptions
|
547
|
+
};
|
548
|
+
}
|
549
|
+
case "redacted-reasoning": {
|
550
|
+
return {
|
551
|
+
type: "redacted-reasoning",
|
552
|
+
data: part.data,
|
553
|
+
providerMetadata: providerOptions
|
554
|
+
};
|
555
|
+
}
|
556
|
+
case "text": {
|
557
|
+
return {
|
558
|
+
type: "text",
|
559
|
+
text: part.text,
|
560
|
+
providerMetadata: providerOptions
|
561
|
+
};
|
562
|
+
}
|
563
|
+
case "tool-call": {
|
564
|
+
return {
|
565
|
+
type: "tool-call",
|
566
|
+
toolCallId: part.toolCallId,
|
567
|
+
toolName: part.toolName,
|
568
|
+
args: part.args,
|
569
|
+
providerMetadata: providerOptions
|
570
|
+
};
|
571
|
+
}
|
572
|
+
}
|
467
573
|
}),
|
468
574
|
providerMetadata: (_e = message.providerOptions) != null ? _e : message.experimental_providerMetadata
|
469
575
|
};
|
@@ -1009,12 +1115,11 @@ function convertToCoreMessages(messages, options) {
|
|
1009
1115
|
const content2 = [];
|
1010
1116
|
for (const part of block) {
|
1011
1117
|
switch (part.type) {
|
1012
|
-
case "
|
1013
|
-
|
1014
|
-
|
1015
|
-
text: part.text
|
1016
|
-
});
|
1118
|
+
case "file":
|
1119
|
+
case "text": {
|
1120
|
+
content2.push(part);
|
1017
1121
|
break;
|
1122
|
+
}
|
1018
1123
|
case "reasoning": {
|
1019
1124
|
for (const detail of part.details) {
|
1020
1125
|
switch (detail.type) {
|
@@ -1095,9 +1200,6 @@ function convertToCoreMessages(messages, options) {
|
|
1095
1200
|
let block = [];
|
1096
1201
|
for (const part of message.parts) {
|
1097
1202
|
switch (part.type) {
|
1098
|
-
case "reasoning":
|
1099
|
-
block.push(part);
|
1100
|
-
break;
|
1101
1203
|
case "text": {
|
1102
1204
|
if (blockHasToolInvocations) {
|
1103
1205
|
processBlock2();
|
@@ -1105,6 +1207,11 @@ function convertToCoreMessages(messages, options) {
|
|
1105
1207
|
block.push(part);
|
1106
1208
|
break;
|
1107
1209
|
}
|
1210
|
+
case "file":
|
1211
|
+
case "reasoning": {
|
1212
|
+
block.push(part);
|
1213
|
+
break;
|
1214
|
+
}
|
1108
1215
|
case "tool-invocation": {
|
1109
1216
|
if (((_b = part.toolInvocation.step) != null ? _b : 0) !== currentStep) {
|
1110
1217
|
processBlock2();
|
@@ -1220,6 +1327,7 @@ function detectSingleMessageCharacteristics(message) {
|
|
1220
1327
|
if (typeof message === "object" && message !== null && (message.role === "function" || // UI-only role
|
1221
1328
|
message.role === "data" || // UI-only role
|
1222
1329
|
"toolInvocations" in message || // UI-specific field
|
1330
|
+
"parts" in message || // UI-specific field
|
1223
1331
|
"experimental_attachments" in message)) {
|
1224
1332
|
return "has-ui-specific-parts";
|
1225
1333
|
} else if (typeof message === "object" && message !== null && "content" in message && (Array.isArray(message.content) || // Core messages can have array content
|
@@ -1349,6 +1457,7 @@ var coreAssistantMessageSchema = z6.object({
|
|
1349
1457
|
z6.array(
|
1350
1458
|
z6.union([
|
1351
1459
|
textPartSchema,
|
1460
|
+
filePartSchema,
|
1352
1461
|
reasoningPartSchema,
|
1353
1462
|
redactedReasoningPartSchema,
|
1354
1463
|
toolCallPartSchema
|