ai 4.0.20 → 4.0.21
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 +7 -0
- package/dist/index.js +99 -87
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/rsc/dist/rsc-server.mjs +7 -4
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
@@ -1229,6 +1229,7 @@ async function downloadAssets(messages, downloadImplementation, modelSupportsIma
|
|
1229
1229
|
);
|
1230
1230
|
}
|
1231
1231
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
1232
|
+
var _a13;
|
1232
1233
|
if (part.type === "text") {
|
1233
1234
|
return {
|
1234
1235
|
type: "text",
|
@@ -1279,9 +1280,9 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1279
1280
|
normalizedData = convertDataContentToUint8Array(content);
|
1280
1281
|
}
|
1281
1282
|
switch (type) {
|
1282
|
-
case "image":
|
1283
|
-
if (
|
1284
|
-
mimeType = detectImageMimeType(normalizedData);
|
1283
|
+
case "image": {
|
1284
|
+
if (normalizedData instanceof Uint8Array) {
|
1285
|
+
mimeType = (_a13 = detectImageMimeType(normalizedData)) != null ? _a13 : mimeType;
|
1285
1286
|
}
|
1286
1287
|
return {
|
1287
1288
|
type: "image",
|
@@ -1289,7 +1290,8 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1289
1290
|
mimeType,
|
1290
1291
|
providerMetadata: part.experimental_providerMetadata
|
1291
1292
|
};
|
1292
|
-
|
1293
|
+
}
|
1294
|
+
case "file": {
|
1293
1295
|
if (mimeType == null) {
|
1294
1296
|
throw new Error(`Mime type is missing for file part`);
|
1295
1297
|
}
|
@@ -1299,6 +1301,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1299
1301
|
mimeType,
|
1300
1302
|
providerMetadata: part.experimental_providerMetadata
|
1301
1303
|
};
|
1304
|
+
}
|
1302
1305
|
}
|
1303
1306
|
}
|
1304
1307
|
|
@@ -1845,12 +1848,10 @@ var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
1845
1848
|
var import_ui_utils2 = require("@ai-sdk/ui-utils");
|
1846
1849
|
|
1847
1850
|
// core/util/async-iterable-stream.ts
|
1848
|
-
function createAsyncIterableStream(source
|
1849
|
-
const
|
1850
|
-
|
1851
|
-
|
1852
|
-
transformedStream[Symbol.asyncIterator] = () => {
|
1853
|
-
const reader = transformedStream.getReader();
|
1851
|
+
function createAsyncIterableStream(source) {
|
1852
|
+
const stream = source.pipeThrough(new TransformStream());
|
1853
|
+
stream[Symbol.asyncIterator] = () => {
|
1854
|
+
const reader = stream.getReader();
|
1854
1855
|
return {
|
1855
1856
|
async next() {
|
1856
1857
|
const { done, value } = await reader.read();
|
@@ -1858,7 +1859,7 @@ function createAsyncIterableStream(source, transformer) {
|
|
1858
1859
|
}
|
1859
1860
|
};
|
1860
1861
|
};
|
1861
|
-
return
|
1862
|
+
return stream;
|
1862
1863
|
}
|
1863
1864
|
|
1864
1865
|
// core/generate-object/output-strategy.ts
|
@@ -1988,29 +1989,35 @@ var arrayOutputStrategy = (schema) => {
|
|
1988
1989
|
},
|
1989
1990
|
createElementStream(originalStream) {
|
1990
1991
|
let publishedElements = 0;
|
1991
|
-
return createAsyncIterableStream(
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1992
|
+
return createAsyncIterableStream(
|
1993
|
+
originalStream.pipeThrough(
|
1994
|
+
new TransformStream({
|
1995
|
+
transform(chunk, controller) {
|
1996
|
+
switch (chunk.type) {
|
1997
|
+
case "object": {
|
1998
|
+
const array = chunk.object;
|
1999
|
+
for (; publishedElements < array.length; publishedElements++) {
|
2000
|
+
controller.enqueue(array[publishedElements]);
|
2001
|
+
}
|
2002
|
+
break;
|
2003
|
+
}
|
2004
|
+
case "text-delta":
|
2005
|
+
case "finish":
|
2006
|
+
break;
|
2007
|
+
case "error":
|
2008
|
+
controller.error(chunk.error);
|
2009
|
+
break;
|
2010
|
+
default: {
|
2011
|
+
const _exhaustiveCheck = chunk;
|
2012
|
+
throw new Error(
|
2013
|
+
`Unsupported chunk type: ${_exhaustiveCheck}`
|
2014
|
+
);
|
2015
|
+
}
|
1998
2016
|
}
|
1999
|
-
break;
|
2000
2017
|
}
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
case "error":
|
2005
|
-
controller.error(chunk.error);
|
2006
|
-
break;
|
2007
|
-
default: {
|
2008
|
-
const _exhaustiveCheck = chunk;
|
2009
|
-
throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
|
2010
|
-
}
|
2011
|
-
}
|
2012
|
-
}
|
2013
|
-
});
|
2018
|
+
})
|
2019
|
+
)
|
2020
|
+
);
|
2014
2021
|
}
|
2015
2022
|
};
|
2016
2023
|
};
|
@@ -3206,25 +3213,29 @@ var DefaultStreamObjectResult = class {
|
|
3206
3213
|
return this.responsePromise.value;
|
3207
3214
|
}
|
3208
3215
|
get partialObjectStream() {
|
3209
|
-
return createAsyncIterableStream(
|
3210
|
-
|
3211
|
-
|
3212
|
-
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3216
|
-
|
3217
|
-
|
3218
|
-
|
3219
|
-
|
3220
|
-
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3216
|
+
return createAsyncIterableStream(
|
3217
|
+
this.stitchableStream.stream.pipeThrough(
|
3218
|
+
new TransformStream({
|
3219
|
+
transform(chunk, controller) {
|
3220
|
+
switch (chunk.type) {
|
3221
|
+
case "object":
|
3222
|
+
controller.enqueue(chunk.object);
|
3223
|
+
break;
|
3224
|
+
case "text-delta":
|
3225
|
+
case "finish":
|
3226
|
+
break;
|
3227
|
+
case "error":
|
3228
|
+
controller.error(chunk.error);
|
3229
|
+
break;
|
3230
|
+
default: {
|
3231
|
+
const _exhaustiveCheck = chunk;
|
3232
|
+
throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
|
3233
|
+
}
|
3234
|
+
}
|
3224
3235
|
}
|
3225
|
-
}
|
3226
|
-
|
3227
|
-
|
3236
|
+
})
|
3237
|
+
)
|
3238
|
+
);
|
3228
3239
|
}
|
3229
3240
|
get elementStream() {
|
3230
3241
|
return this.outputStrategy.createElementStream(
|
@@ -3232,32 +3243,32 @@ var DefaultStreamObjectResult = class {
|
|
3232
3243
|
);
|
3233
3244
|
}
|
3234
3245
|
get textStream() {
|
3235
|
-
return createAsyncIterableStream(
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
|
3240
|
-
|
3241
|
-
|
3242
|
-
|
3243
|
-
|
3244
|
-
|
3245
|
-
|
3246
|
-
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3246
|
+
return createAsyncIterableStream(
|
3247
|
+
this.stitchableStream.stream.pipeThrough(
|
3248
|
+
new TransformStream({
|
3249
|
+
transform(chunk, controller) {
|
3250
|
+
switch (chunk.type) {
|
3251
|
+
case "text-delta":
|
3252
|
+
controller.enqueue(chunk.textDelta);
|
3253
|
+
break;
|
3254
|
+
case "object":
|
3255
|
+
case "finish":
|
3256
|
+
break;
|
3257
|
+
case "error":
|
3258
|
+
controller.error(chunk.error);
|
3259
|
+
break;
|
3260
|
+
default: {
|
3261
|
+
const _exhaustiveCheck = chunk;
|
3262
|
+
throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
|
3263
|
+
}
|
3264
|
+
}
|
3250
3265
|
}
|
3251
|
-
}
|
3252
|
-
|
3253
|
-
|
3266
|
+
})
|
3267
|
+
)
|
3268
|
+
);
|
3254
3269
|
}
|
3255
3270
|
get fullStream() {
|
3256
|
-
return createAsyncIterableStream(this.stitchableStream.stream
|
3257
|
-
transform(chunk, controller) {
|
3258
|
-
controller.enqueue(chunk);
|
3259
|
-
}
|
3260
|
-
});
|
3271
|
+
return createAsyncIterableStream(this.stitchableStream.stream);
|
3261
3272
|
}
|
3262
3273
|
pipeTextStreamToResponse(response, init) {
|
3263
3274
|
writeToServerResponse({
|
@@ -3930,6 +3941,7 @@ async function executeTools({
|
|
3930
3941
|
}
|
3931
3942
|
});
|
3932
3943
|
return {
|
3944
|
+
type: "tool-result",
|
3933
3945
|
toolCallId,
|
3934
3946
|
toolName,
|
3935
3947
|
args,
|
@@ -5007,22 +5019,22 @@ var DefaultStreamTextResult = class {
|
|
5007
5019
|
return stream1;
|
5008
5020
|
}
|
5009
5021
|
get textStream() {
|
5010
|
-
return createAsyncIterableStream(
|
5011
|
-
|
5012
|
-
|
5013
|
-
|
5014
|
-
|
5015
|
-
|
5016
|
-
|
5017
|
-
|
5018
|
-
|
5022
|
+
return createAsyncIterableStream(
|
5023
|
+
this.teeStream().pipeThrough(
|
5024
|
+
new TransformStream({
|
5025
|
+
transform(chunk, controller) {
|
5026
|
+
if (chunk.type === "text-delta") {
|
5027
|
+
controller.enqueue(chunk.textDelta);
|
5028
|
+
} else if (chunk.type === "error") {
|
5029
|
+
controller.error(chunk.error);
|
5030
|
+
}
|
5031
|
+
}
|
5032
|
+
})
|
5033
|
+
)
|
5034
|
+
);
|
5019
5035
|
}
|
5020
5036
|
get fullStream() {
|
5021
|
-
return createAsyncIterableStream(this.teeStream()
|
5022
|
-
transform(chunk, controller) {
|
5023
|
-
controller.enqueue(chunk);
|
5024
|
-
}
|
5025
|
-
});
|
5037
|
+
return createAsyncIterableStream(this.teeStream());
|
5026
5038
|
}
|
5027
5039
|
toDataStreamInternal({
|
5028
5040
|
getErrorMessage: getErrorMessage5 = () => "An error occurred.",
|