ai 5.0.0-canary.3 → 5.0.0-canary.4
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 +151 -7
- package/dist/index.d.ts +151 -7
- package/dist/index.js +226 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +182 -60
- package/dist/index.mjs.map +1 -1
- package/{rsc/dist/rsc-server.d.mts → dist/internal/index.d.mts} +212 -368
- package/dist/internal/index.d.ts +592 -0
- package/dist/internal/index.js +1429 -0
- package/dist/internal/index.js.map +1 -0
- package/{rsc/dist/rsc-server.mjs → dist/internal/index.mjs} +1032 -1772
- package/dist/internal/index.mjs.map +1 -0
- package/mcp-stdio/dist/index.js +1 -1
- package/mcp-stdio/dist/index.js.map +1 -1
- package/mcp-stdio/dist/index.mjs +1 -1
- package/mcp-stdio/dist/index.mjs.map +1 -1
- package/mcp-stdio/get-environment.test.ts +13 -0
- package/mcp-stdio/get-environment.ts +1 -1
- package/package.json +11 -26
- package/rsc/dist/index.d.ts +0 -813
- package/rsc/dist/index.mjs +0 -18
- package/rsc/dist/rsc-client.d.mts +0 -1
- package/rsc/dist/rsc-client.mjs +0 -18
- package/rsc/dist/rsc-client.mjs.map +0 -1
- package/rsc/dist/rsc-server.mjs.map +0 -1
- package/rsc/dist/rsc-shared.d.mts +0 -101
- package/rsc/dist/rsc-shared.mjs +0 -308
- package/rsc/dist/rsc-shared.mjs.map +0 -1
package/dist/index.mjs
CHANGED
@@ -830,12 +830,12 @@ import {
|
|
830
830
|
var DefaultGeneratedFile = class {
|
831
831
|
constructor({
|
832
832
|
data,
|
833
|
-
|
833
|
+
mediaType
|
834
834
|
}) {
|
835
835
|
const isUint8Array = data instanceof Uint8Array;
|
836
836
|
this.base64Data = isUint8Array ? void 0 : data;
|
837
837
|
this.uint8ArrayData = isUint8Array ? data : void 0;
|
838
|
-
this.
|
838
|
+
this.mediaType = mediaType;
|
839
839
|
}
|
840
840
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|
841
841
|
get base64() {
|
@@ -859,45 +859,45 @@ var DefaultGeneratedFileWithType = class extends DefaultGeneratedFile {
|
|
859
859
|
}
|
860
860
|
};
|
861
861
|
|
862
|
-
// core/util/detect-
|
863
|
-
var
|
862
|
+
// core/util/detect-media-type.ts
|
863
|
+
var imageMediaTypeSignatures = [
|
864
864
|
{
|
865
|
-
|
865
|
+
mediaType: "image/gif",
|
866
866
|
bytesPrefix: [71, 73, 70],
|
867
867
|
base64Prefix: "R0lG"
|
868
868
|
},
|
869
869
|
{
|
870
|
-
|
870
|
+
mediaType: "image/png",
|
871
871
|
bytesPrefix: [137, 80, 78, 71],
|
872
872
|
base64Prefix: "iVBORw"
|
873
873
|
},
|
874
874
|
{
|
875
|
-
|
875
|
+
mediaType: "image/jpeg",
|
876
876
|
bytesPrefix: [255, 216],
|
877
877
|
base64Prefix: "/9j/"
|
878
878
|
},
|
879
879
|
{
|
880
|
-
|
880
|
+
mediaType: "image/webp",
|
881
881
|
bytesPrefix: [82, 73, 70, 70],
|
882
882
|
base64Prefix: "UklGRg"
|
883
883
|
},
|
884
884
|
{
|
885
|
-
|
885
|
+
mediaType: "image/bmp",
|
886
886
|
bytesPrefix: [66, 77],
|
887
887
|
base64Prefix: "Qk"
|
888
888
|
},
|
889
889
|
{
|
890
|
-
|
890
|
+
mediaType: "image/tiff",
|
891
891
|
bytesPrefix: [73, 73, 42, 0],
|
892
892
|
base64Prefix: "SUkqAA"
|
893
893
|
},
|
894
894
|
{
|
895
|
-
|
895
|
+
mediaType: "image/tiff",
|
896
896
|
bytesPrefix: [77, 77, 0, 42],
|
897
897
|
base64Prefix: "TU0AKg"
|
898
898
|
},
|
899
899
|
{
|
900
|
-
|
900
|
+
mediaType: "image/avif",
|
901
901
|
bytesPrefix: [
|
902
902
|
0,
|
903
903
|
0,
|
@@ -915,7 +915,7 @@ var mimeTypeSignatures = [
|
|
915
915
|
base64Prefix: "AAAAIGZ0eXBhdmlm"
|
916
916
|
},
|
917
917
|
{
|
918
|
-
|
918
|
+
mediaType: "image/heic",
|
919
919
|
bytesPrefix: [
|
920
920
|
0,
|
921
921
|
0,
|
@@ -933,10 +933,45 @@ var mimeTypeSignatures = [
|
|
933
933
|
base64Prefix: "AAAAIGZ0eXBoZWlj"
|
934
934
|
}
|
935
935
|
];
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
936
|
+
var audioMediaTypeSignatures = [
|
937
|
+
{
|
938
|
+
mediaType: "audio/mpeg",
|
939
|
+
bytesPrefix: [255, 251],
|
940
|
+
base64Prefix: "//s="
|
941
|
+
},
|
942
|
+
{
|
943
|
+
mediaType: "audio/wav",
|
944
|
+
bytesPrefix: [82, 73, 70, 70],
|
945
|
+
base64Prefix: "UklGR"
|
946
|
+
},
|
947
|
+
{
|
948
|
+
mediaType: "audio/ogg",
|
949
|
+
bytesPrefix: [79, 103, 103, 83],
|
950
|
+
base64Prefix: "T2dnUw"
|
951
|
+
},
|
952
|
+
{
|
953
|
+
mediaType: "audio/flac",
|
954
|
+
bytesPrefix: [102, 76, 97, 67],
|
955
|
+
base64Prefix: "ZkxhQw"
|
956
|
+
},
|
957
|
+
{
|
958
|
+
mediaType: "audio/aac",
|
959
|
+
bytesPrefix: [64, 21, 0, 0],
|
960
|
+
base64Prefix: "QBUA"
|
961
|
+
},
|
962
|
+
{
|
963
|
+
mediaType: "audio/mp4",
|
964
|
+
bytesPrefix: [102, 116, 121, 112],
|
965
|
+
base64Prefix: "ZnR5cA"
|
966
|
+
}
|
967
|
+
];
|
968
|
+
function detectMediaType({
|
969
|
+
data,
|
970
|
+
signatures
|
971
|
+
}) {
|
972
|
+
for (const signature of signatures) {
|
973
|
+
if (typeof data === "string" ? data.startsWith(signature.base64Prefix) : data.length >= signature.bytesPrefix.length && signature.bytesPrefix.every((byte, index) => data[index] === byte)) {
|
974
|
+
return signature.mediaType;
|
940
975
|
}
|
941
976
|
}
|
942
977
|
return void 0;
|
@@ -992,7 +1027,10 @@ async function generateImage({
|
|
992
1027
|
var _a18;
|
993
1028
|
return new DefaultGeneratedFile({
|
994
1029
|
data: image,
|
995
|
-
|
1030
|
+
mediaType: (_a18 = detectMediaType({
|
1031
|
+
data: image,
|
1032
|
+
signatures: imageMediaTypeSignatures
|
1033
|
+
})) != null ? _a18 : "image/png"
|
996
1034
|
});
|
997
1035
|
}
|
998
1036
|
)
|
@@ -1051,6 +1089,9 @@ var NoObjectGeneratedError = class extends AISDKError4 {
|
|
1051
1089
|
};
|
1052
1090
|
_a4 = symbol4;
|
1053
1091
|
|
1092
|
+
// core/prompt/convert-to-language-model-prompt.ts
|
1093
|
+
import { convertUint8ArrayToBase64 as convertUint8ArrayToBase643 } from "@ai-sdk/provider-utils";
|
1094
|
+
|
1054
1095
|
// util/download-error.ts
|
1055
1096
|
import { AISDKError as AISDKError5 } from "@ai-sdk/provider";
|
1056
1097
|
var name5 = "AI_DownloadError";
|
@@ -1092,7 +1133,7 @@ async function download({ url }) {
|
|
1092
1133
|
}
|
1093
1134
|
return {
|
1094
1135
|
data: new Uint8Array(await response.arrayBuffer()),
|
1095
|
-
|
1136
|
+
mediaType: (_a17 = response.headers.get("content-type")) != null ? _a17 : void 0
|
1096
1137
|
};
|
1097
1138
|
} catch (error) {
|
1098
1139
|
if (DownloadError.isInstance(error)) {
|
@@ -1208,12 +1249,12 @@ function splitDataUrl(dataUrl) {
|
|
1208
1249
|
try {
|
1209
1250
|
const [header, base64Content] = dataUrl.split(",");
|
1210
1251
|
return {
|
1211
|
-
|
1252
|
+
mediaType: header.split(";")[0].split(":")[1],
|
1212
1253
|
base64Content
|
1213
1254
|
};
|
1214
1255
|
} catch (error) {
|
1215
1256
|
return {
|
1216
|
-
|
1257
|
+
mediaType: void 0,
|
1217
1258
|
base64Content: void 0
|
1218
1259
|
};
|
1219
1260
|
}
|
@@ -1278,7 +1319,7 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
1278
1319
|
// remove empty text parts:
|
1279
1320
|
(part) => part.type !== "text" || part.text !== ""
|
1280
1321
|
).map((part) => {
|
1281
|
-
var _a18;
|
1322
|
+
var _a18, _b2;
|
1282
1323
|
const providerOptions = (_a18 = part.providerOptions) != null ? _a18 : part.experimental_providerMetadata;
|
1283
1324
|
switch (part.type) {
|
1284
1325
|
case "file": {
|
@@ -1286,7 +1327,7 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
1286
1327
|
type: "file",
|
1287
1328
|
data: part.data instanceof URL ? part.data : convertDataContentToBase64String(part.data),
|
1288
1329
|
filename: part.filename,
|
1289
|
-
|
1330
|
+
mediaType: (_b2 = part.mediaType) != null ? _b2 : part.mimeType,
|
1290
1331
|
providerOptions
|
1291
1332
|
};
|
1292
1333
|
}
|
@@ -1374,7 +1415,7 @@ async function downloadAssets(messages, downloadImplementation, modelSupportsIma
|
|
1374
1415
|
);
|
1375
1416
|
}
|
1376
1417
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
1377
|
-
var _a17, _b, _c, _d;
|
1418
|
+
var _a17, _b, _c, _d, _e;
|
1378
1419
|
if (part.type === "text") {
|
1379
1420
|
return {
|
1380
1421
|
type: "text",
|
@@ -1382,7 +1423,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1382
1423
|
providerOptions: (_a17 = part.providerOptions) != null ? _a17 : part.experimental_providerMetadata
|
1383
1424
|
};
|
1384
1425
|
}
|
1385
|
-
let
|
1426
|
+
let mediaType = (_b = part.mediaType) != null ? _b : part.mimeType;
|
1386
1427
|
let data;
|
1387
1428
|
let content;
|
1388
1429
|
let normalizedData;
|
@@ -1404,19 +1445,19 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1404
1445
|
}
|
1405
1446
|
if (content instanceof URL) {
|
1406
1447
|
if (content.protocol === "data:") {
|
1407
|
-
const {
|
1448
|
+
const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(
|
1408
1449
|
content.toString()
|
1409
1450
|
);
|
1410
|
-
if (
|
1451
|
+
if (dataUrlMediaType == null || base64Content == null) {
|
1411
1452
|
throw new Error(`Invalid data URL format in part ${type}`);
|
1412
1453
|
}
|
1413
|
-
|
1454
|
+
mediaType = dataUrlMediaType;
|
1414
1455
|
normalizedData = convertDataContentToUint8Array(base64Content);
|
1415
1456
|
} else {
|
1416
1457
|
const downloadedFile = downloadedAssets[content.toString()];
|
1417
1458
|
if (downloadedFile) {
|
1418
1459
|
normalizedData = downloadedFile.data;
|
1419
|
-
|
1460
|
+
mediaType != null ? mediaType : mediaType = downloadedFile.mediaType;
|
1420
1461
|
} else {
|
1421
1462
|
normalizedData = content;
|
1422
1463
|
}
|
@@ -1427,25 +1468,30 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1427
1468
|
switch (type) {
|
1428
1469
|
case "image": {
|
1429
1470
|
if (normalizedData instanceof Uint8Array) {
|
1430
|
-
|
1471
|
+
mediaType = (_c = detectMediaType({
|
1472
|
+
data: normalizedData,
|
1473
|
+
signatures: imageMediaTypeSignatures
|
1474
|
+
})) != null ? _c : mediaType;
|
1431
1475
|
}
|
1432
1476
|
return {
|
1433
|
-
type: "
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1477
|
+
type: "file",
|
1478
|
+
mediaType: mediaType != null ? mediaType : "image/*",
|
1479
|
+
// any image
|
1480
|
+
filename: void 0,
|
1481
|
+
data: normalizedData instanceof Uint8Array ? convertUint8ArrayToBase643(normalizedData) : normalizedData,
|
1482
|
+
providerOptions: (_d = part.providerOptions) != null ? _d : part.experimental_providerMetadata
|
1437
1483
|
};
|
1438
1484
|
}
|
1439
1485
|
case "file": {
|
1440
|
-
if (
|
1441
|
-
throw new Error(`
|
1486
|
+
if (mediaType == null) {
|
1487
|
+
throw new Error(`Media type is missing for file part`);
|
1442
1488
|
}
|
1443
1489
|
return {
|
1444
1490
|
type: "file",
|
1445
|
-
|
1491
|
+
mediaType,
|
1446
1492
|
filename: part.filename,
|
1447
|
-
|
1448
|
-
providerOptions: (
|
1493
|
+
data: normalizedData instanceof Uint8Array ? convertDataContentToBase64String(normalizedData) : normalizedData,
|
1494
|
+
providerOptions: (_e = part.providerOptions) != null ? _e : part.experimental_providerMetadata
|
1449
1495
|
};
|
1450
1496
|
}
|
1451
1497
|
}
|
@@ -1575,7 +1621,7 @@ function attachmentsToParts(attachments) {
|
|
1575
1621
|
parts.push({
|
1576
1622
|
type: "file",
|
1577
1623
|
data: url,
|
1578
|
-
|
1624
|
+
mediaType: attachment.contentType
|
1579
1625
|
});
|
1580
1626
|
}
|
1581
1627
|
break;
|
@@ -1583,14 +1629,14 @@ function attachmentsToParts(attachments) {
|
|
1583
1629
|
case "data:": {
|
1584
1630
|
let header;
|
1585
1631
|
let base64Content;
|
1586
|
-
let
|
1632
|
+
let mediaType;
|
1587
1633
|
try {
|
1588
1634
|
[header, base64Content] = attachment.url.split(",");
|
1589
|
-
|
1635
|
+
mediaType = header.split(";")[0].split(":")[1];
|
1590
1636
|
} catch (error) {
|
1591
1637
|
throw new Error(`Error processing data URL: ${attachment.url}`);
|
1592
1638
|
}
|
1593
|
-
if (
|
1639
|
+
if (mediaType == null || base64Content == null) {
|
1594
1640
|
throw new Error(`Invalid data URL format: ${attachment.url}`);
|
1595
1641
|
}
|
1596
1642
|
if ((_b = attachment.contentType) == null ? void 0 : _b.startsWith("image/")) {
|
@@ -1614,7 +1660,7 @@ function attachmentsToParts(attachments) {
|
|
1614
1660
|
parts.push({
|
1615
1661
|
type: "file",
|
1616
1662
|
data: base64Content,
|
1617
|
-
|
1663
|
+
mediaType: attachment.contentType
|
1618
1664
|
});
|
1619
1665
|
}
|
1620
1666
|
break;
|
@@ -1689,14 +1735,23 @@ function convertToCoreMessages(messages, options) {
|
|
1689
1735
|
case "assistant": {
|
1690
1736
|
if (message.parts != null) {
|
1691
1737
|
let processBlock2 = function() {
|
1738
|
+
var _a18;
|
1692
1739
|
const content2 = [];
|
1693
1740
|
for (const part of block) {
|
1694
1741
|
switch (part.type) {
|
1695
|
-
case "file":
|
1696
1742
|
case "text": {
|
1697
1743
|
content2.push(part);
|
1698
1744
|
break;
|
1699
1745
|
}
|
1746
|
+
case "file": {
|
1747
|
+
content2.push({
|
1748
|
+
type: "file",
|
1749
|
+
data: part.data,
|
1750
|
+
mediaType: (_a18 = part.mediaType) != null ? _a18 : part.mimeType
|
1751
|
+
// TODO migration, remove
|
1752
|
+
});
|
1753
|
+
break;
|
1754
|
+
}
|
1700
1755
|
case "reasoning": {
|
1701
1756
|
for (const detail of part.details) {
|
1702
1757
|
switch (detail.type) {
|
@@ -1953,7 +2008,7 @@ var toolResultContentSchema = z4.array(
|
|
1953
2008
|
z4.object({
|
1954
2009
|
type: z4.literal("image"),
|
1955
2010
|
data: z4.string(),
|
1956
|
-
|
2011
|
+
mediaType: z4.string().optional()
|
1957
2012
|
})
|
1958
2013
|
])
|
1959
2014
|
);
|
@@ -1968,6 +2023,7 @@ var textPartSchema = z5.object({
|
|
1968
2023
|
var imagePartSchema = z5.object({
|
1969
2024
|
type: z5.literal("image"),
|
1970
2025
|
image: z5.union([dataContentSchema, z5.instanceof(URL)]),
|
2026
|
+
mediaType: z5.string().optional(),
|
1971
2027
|
mimeType: z5.string().optional(),
|
1972
2028
|
providerOptions: providerMetadataSchema.optional(),
|
1973
2029
|
experimental_providerMetadata: providerMetadataSchema.optional()
|
@@ -1976,7 +2032,8 @@ var filePartSchema = z5.object({
|
|
1976
2032
|
type: z5.literal("file"),
|
1977
2033
|
data: z5.union([dataContentSchema, z5.instanceof(URL)]),
|
1978
2034
|
filename: z5.string().optional(),
|
1979
|
-
|
2035
|
+
mediaType: z5.string(),
|
2036
|
+
mimeType: z5.string().optional(),
|
1980
2037
|
providerOptions: providerMetadataSchema.optional(),
|
1981
2038
|
experimental_providerMetadata: providerMetadataSchema.optional()
|
1982
2039
|
});
|
@@ -3975,7 +4032,7 @@ function toResponseMessages({
|
|
3975
4032
|
...files.map((file) => ({
|
3976
4033
|
type: "file",
|
3977
4034
|
data: file.base64,
|
3978
|
-
|
4035
|
+
mediaType: file.mediaType
|
3979
4036
|
})),
|
3980
4037
|
{ type: "text", text: text2 },
|
3981
4038
|
...toolCalls
|
@@ -4855,7 +4912,7 @@ function runToolsTransformation({
|
|
4855
4912
|
controller.enqueue(
|
4856
4913
|
new DefaultGeneratedFileWithType({
|
4857
4914
|
data: chunk.data,
|
4858
|
-
|
4915
|
+
mediaType: chunk.mediaType
|
4859
4916
|
})
|
4860
4917
|
);
|
4861
4918
|
break;
|
@@ -6035,7 +6092,7 @@ var DefaultStreamTextResult = class {
|
|
6035
6092
|
case "file": {
|
6036
6093
|
controller.enqueue(
|
6037
6094
|
formatDataStreamPart2("file", {
|
6038
|
-
mimeType: chunk.
|
6095
|
+
mimeType: chunk.mediaType,
|
6039
6096
|
data: chunk.base64
|
6040
6097
|
})
|
6041
6098
|
);
|
@@ -6239,6 +6296,70 @@ var DefaultStreamTextResult = class {
|
|
6239
6296
|
}
|
6240
6297
|
};
|
6241
6298
|
|
6299
|
+
// errors/no-transcript-generated-error.ts
|
6300
|
+
import { AISDKError as AISDKError18 } from "@ai-sdk/provider";
|
6301
|
+
var NoTranscriptGeneratedError = class extends AISDKError18 {
|
6302
|
+
constructor(options) {
|
6303
|
+
super({
|
6304
|
+
name: "AI_NoTranscriptGeneratedError",
|
6305
|
+
message: "No transcript generated."
|
6306
|
+
});
|
6307
|
+
this.responses = options.responses;
|
6308
|
+
}
|
6309
|
+
};
|
6310
|
+
|
6311
|
+
// core/transcribe/transcribe.ts
|
6312
|
+
async function transcribe({
|
6313
|
+
model,
|
6314
|
+
audio,
|
6315
|
+
providerOptions = {},
|
6316
|
+
maxRetries: maxRetriesArg,
|
6317
|
+
abortSignal,
|
6318
|
+
headers
|
6319
|
+
}) {
|
6320
|
+
const { retry } = prepareRetries({ maxRetries: maxRetriesArg });
|
6321
|
+
const audioData = audio instanceof URL ? (await download({ url: audio })).data : convertDataContentToUint8Array(audio);
|
6322
|
+
const result = await retry(
|
6323
|
+
() => {
|
6324
|
+
var _a17;
|
6325
|
+
return model.doGenerate({
|
6326
|
+
audio: audioData,
|
6327
|
+
abortSignal,
|
6328
|
+
headers,
|
6329
|
+
providerOptions,
|
6330
|
+
mediaType: (_a17 = detectMediaType({
|
6331
|
+
data: audioData,
|
6332
|
+
signatures: audioMediaTypeSignatures
|
6333
|
+
})) != null ? _a17 : "audio/wav"
|
6334
|
+
});
|
6335
|
+
}
|
6336
|
+
);
|
6337
|
+
if (!result.text) {
|
6338
|
+
throw new NoTranscriptGeneratedError({ responses: [result.response] });
|
6339
|
+
}
|
6340
|
+
return new DefaultTranscriptionResult({
|
6341
|
+
text: result.text,
|
6342
|
+
segments: result.segments,
|
6343
|
+
language: result.language,
|
6344
|
+
durationInSeconds: result.durationInSeconds,
|
6345
|
+
warnings: result.warnings,
|
6346
|
+
responses: [result.response],
|
6347
|
+
providerMetadata: result.providerMetadata
|
6348
|
+
});
|
6349
|
+
}
|
6350
|
+
var DefaultTranscriptionResult = class {
|
6351
|
+
constructor(options) {
|
6352
|
+
var _a17;
|
6353
|
+
this.text = options.text;
|
6354
|
+
this.segments = options.segments;
|
6355
|
+
this.language = options.language;
|
6356
|
+
this.durationInSeconds = options.durationInSeconds;
|
6357
|
+
this.warnings = options.warnings;
|
6358
|
+
this.responses = options.responses;
|
6359
|
+
this.providerMetadata = (_a17 = options.providerMetadata) != null ? _a17 : {};
|
6360
|
+
}
|
6361
|
+
};
|
6362
|
+
|
6242
6363
|
// core/util/merge-objects.ts
|
6243
6364
|
function mergeObjects(target, source) {
|
6244
6365
|
if (target === void 0 && source === void 0) {
|
@@ -6556,13 +6677,13 @@ function appendClientMessage({
|
|
6556
6677
|
import {
|
6557
6678
|
extractMaxToolInvocationStep
|
6558
6679
|
} from "@ai-sdk/ui-utils";
|
6559
|
-
import { AISDKError as
|
6680
|
+
import { AISDKError as AISDKError19 } from "@ai-sdk/provider";
|
6560
6681
|
function appendResponseMessages({
|
6561
6682
|
messages,
|
6562
6683
|
responseMessages,
|
6563
6684
|
_internal: { currentDate = () => /* @__PURE__ */ new Date() } = {}
|
6564
6685
|
}) {
|
6565
|
-
var _a17, _b, _c, _d;
|
6686
|
+
var _a17, _b, _c, _d, _e;
|
6566
6687
|
const clonedMessages = structuredClone(messages);
|
6567
6688
|
for (const message of responseMessages) {
|
6568
6689
|
const role = message.role;
|
@@ -6639,14 +6760,14 @@ function appendResponseMessages({
|
|
6639
6760
|
break;
|
6640
6761
|
case "file":
|
6641
6762
|
if (part.data instanceof URL) {
|
6642
|
-
throw new
|
6763
|
+
throw new AISDKError19({
|
6643
6764
|
name: "InvalidAssistantFileData",
|
6644
6765
|
message: "File data cannot be a URL"
|
6645
6766
|
});
|
6646
6767
|
}
|
6647
6768
|
parts.push({
|
6648
6769
|
type: "file",
|
6649
|
-
|
6770
|
+
mediaType: (_a17 = part.mediaType) != null ? _a17 : part.mimeType,
|
6650
6771
|
data: convertDataContentToBase64String(part.data)
|
6651
6772
|
});
|
6652
6773
|
break;
|
@@ -6657,12 +6778,12 @@ function appendResponseMessages({
|
|
6657
6778
|
const maxStep = extractMaxToolInvocationStep(
|
6658
6779
|
lastMessage.toolInvocations
|
6659
6780
|
);
|
6660
|
-
(
|
6781
|
+
(_b = lastMessage.parts) != null ? _b : lastMessage.parts = [];
|
6661
6782
|
lastMessage.content = textContent;
|
6662
6783
|
lastMessage.reasoning = reasoningTextContent;
|
6663
6784
|
lastMessage.parts.push(...parts);
|
6664
6785
|
lastMessage.toolInvocations = [
|
6665
|
-
...(
|
6786
|
+
...(_c = lastMessage.toolInvocations) != null ? _c : [],
|
6666
6787
|
...getToolInvocations2(maxStep === void 0 ? 0 : maxStep + 1)
|
6667
6788
|
];
|
6668
6789
|
getToolInvocations2(maxStep === void 0 ? 0 : maxStep + 1).map((call) => ({
|
@@ -6692,13 +6813,13 @@ function appendResponseMessages({
|
|
6692
6813
|
break;
|
6693
6814
|
}
|
6694
6815
|
case "tool": {
|
6695
|
-
(
|
6816
|
+
(_d = lastMessage.toolInvocations) != null ? _d : lastMessage.toolInvocations = [];
|
6696
6817
|
if (lastMessage.role !== "assistant") {
|
6697
6818
|
throw new Error(
|
6698
6819
|
`Tool result must follow an assistant message: ${lastMessage.role}`
|
6699
6820
|
);
|
6700
6821
|
}
|
6701
|
-
(
|
6822
|
+
(_e = lastMessage.parts) != null ? _e : lastMessage.parts = [];
|
6702
6823
|
for (const contentPart of message.content) {
|
6703
6824
|
const toolCall = lastMessage.toolInvocations.find(
|
6704
6825
|
(call) => call.toolCallId === contentPart.toolCallId
|
@@ -6773,7 +6894,7 @@ function customProvider({
|
|
6773
6894
|
var experimental_customProvider = customProvider;
|
6774
6895
|
|
6775
6896
|
// core/registry/no-such-provider-error.ts
|
6776
|
-
import { AISDKError as
|
6897
|
+
import { AISDKError as AISDKError20, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
|
6777
6898
|
var name16 = "AI_NoSuchProviderError";
|
6778
6899
|
var marker16 = `vercel.ai.error.${name16}`;
|
6779
6900
|
var symbol16 = Symbol.for(marker16);
|
@@ -6792,7 +6913,7 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
|
|
6792
6913
|
this.availableProviders = availableProviders;
|
6793
6914
|
}
|
6794
6915
|
static isInstance(error) {
|
6795
|
-
return
|
6916
|
+
return AISDKError20.hasMarker(error, marker16);
|
6796
6917
|
}
|
6797
6918
|
};
|
6798
6919
|
_a16 = symbol16;
|
@@ -7777,6 +7898,7 @@ export {
|
|
7777
7898
|
experimental_createProviderRegistry,
|
7778
7899
|
experimental_customProvider,
|
7779
7900
|
generateImage as experimental_generateImage,
|
7901
|
+
transcribe as experimental_transcribe,
|
7780
7902
|
experimental_wrapLanguageModel,
|
7781
7903
|
extractReasoningMiddleware,
|
7782
7904
|
formatDataStreamPart3 as formatDataStreamPart,
|