ai 5.0.284 → 5.0.286
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 +29 -0
- package/dist/index.js +45 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -35
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +114 -64
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +103 -51
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.286
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f15d448: hide provider metadata from telemetry when recordOutputs is false
|
|
8
|
+
- 417a92c: Preserve `toolChoice: 'none'` when SDK tools are omitted or empty so providers can disable native tools configured through provider options.
|
|
9
|
+
|
|
10
|
+
For Perplexity native tools, also update `@ai-sdk/perplexity` to `2.1.6` or a later compatible version, which includes the provider-side guard.
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [c6c7ae0]
|
|
13
|
+
- Updated dependencies [49c554d]
|
|
14
|
+
- Updated dependencies [ebc2cd9]
|
|
15
|
+
- Updated dependencies [b753c03]
|
|
16
|
+
- Updated dependencies [a7ebf30]
|
|
17
|
+
- @ai-sdk/gateway@2.0.177
|
|
18
|
+
- @ai-sdk/provider-utils@3.0.45
|
|
19
|
+
|
|
20
|
+
## 5.0.285
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 0a069bd: fix(ai): support cross-realm Uint8Array and ArrayBuffer in DefaultGeneratedFile
|
|
25
|
+
- 0a069bd: fix(ai): handle cross-realm Uint8Array and ArrayBuffer in prompt data validation and conversion
|
|
26
|
+
- Updated dependencies [0a069bd]
|
|
27
|
+
- Updated dependencies [0a069bd]
|
|
28
|
+
- Updated dependencies [0a069bd]
|
|
29
|
+
- @ai-sdk/provider-utils@3.0.44
|
|
30
|
+
- @ai-sdk/gateway@2.0.176
|
|
31
|
+
|
|
3
32
|
## 5.0.284
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -847,7 +847,7 @@ function detectMediaType({
|
|
|
847
847
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
848
848
|
|
|
849
849
|
// src/version.ts
|
|
850
|
-
var VERSION = true ? "5.0.
|
|
850
|
+
var VERSION = true ? "5.0.286" : "0.0.0-test";
|
|
851
851
|
|
|
852
852
|
// src/util/download/download.ts
|
|
853
853
|
var download = async ({
|
|
@@ -924,8 +924,8 @@ function splitDataUrl(dataUrl) {
|
|
|
924
924
|
// src/prompt/data-content.ts
|
|
925
925
|
var dataContentSchema = import_v4.z.union([
|
|
926
926
|
import_v4.z.string(),
|
|
927
|
-
import_v4.z.
|
|
928
|
-
import_v4.z.
|
|
927
|
+
import_v4.z.custom(import_provider_utils3.isUint8Array, { message: "Must be a Uint8Array" }),
|
|
928
|
+
import_v4.z.custom(import_provider_utils3.isArrayBuffer, { message: "Must be an ArrayBuffer" }),
|
|
929
929
|
import_v4.z.custom(
|
|
930
930
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
931
931
|
(value) => {
|
|
@@ -936,10 +936,13 @@ var dataContentSchema = import_v4.z.union([
|
|
|
936
936
|
)
|
|
937
937
|
]);
|
|
938
938
|
function convertToLanguageModelV2DataContent(content) {
|
|
939
|
-
if (
|
|
940
|
-
return {
|
|
939
|
+
if ((0, import_provider_utils3.isUint8Array)(content)) {
|
|
940
|
+
return {
|
|
941
|
+
data: convertDataContentToUint8Array(content),
|
|
942
|
+
mediaType: void 0
|
|
943
|
+
};
|
|
941
944
|
}
|
|
942
|
-
if (
|
|
945
|
+
if ((0, import_provider_utils3.isArrayBuffer)(content)) {
|
|
943
946
|
return { data: new Uint8Array(content), mediaType: void 0 };
|
|
944
947
|
}
|
|
945
948
|
if (typeof content === "string") {
|
|
@@ -966,14 +969,15 @@ function convertDataContentToBase64String(content) {
|
|
|
966
969
|
if (typeof content === "string") {
|
|
967
970
|
return content;
|
|
968
971
|
}
|
|
969
|
-
|
|
970
|
-
return (0, import_provider_utils3.convertUint8ArrayToBase64)(new Uint8Array(content));
|
|
971
|
-
}
|
|
972
|
-
return (0, import_provider_utils3.convertUint8ArrayToBase64)(content);
|
|
972
|
+
return (0, import_provider_utils3.convertUint8ArrayToBase64)(convertDataContentToUint8Array(content));
|
|
973
973
|
}
|
|
974
974
|
function convertDataContentToUint8Array(content) {
|
|
975
|
-
if (
|
|
976
|
-
|
|
975
|
+
if ((0, import_provider_utils3.isUint8Array)(content)) {
|
|
976
|
+
if (content instanceof Uint8Array) {
|
|
977
|
+
return content;
|
|
978
|
+
}
|
|
979
|
+
const { buffer, byteOffset, byteLength } = content;
|
|
980
|
+
return new Uint8Array(buffer, byteOffset, byteLength);
|
|
977
981
|
}
|
|
978
982
|
if (typeof content === "string") {
|
|
979
983
|
try {
|
|
@@ -986,7 +990,7 @@ function convertDataContentToUint8Array(content) {
|
|
|
986
990
|
});
|
|
987
991
|
}
|
|
988
992
|
}
|
|
989
|
-
if (
|
|
993
|
+
if ((0, import_provider_utils3.isArrayBuffer)(content)) {
|
|
990
994
|
return new Uint8Array(content);
|
|
991
995
|
}
|
|
992
996
|
throw new InvalidDataContentError({ content });
|
|
@@ -1337,7 +1341,8 @@ function prepareToolsAndToolChoice({
|
|
|
1337
1341
|
if (!isNonEmptyObject(tools)) {
|
|
1338
1342
|
return {
|
|
1339
1343
|
tools: void 0,
|
|
1340
|
-
|
|
1344
|
+
// Providers can configure native tools without SDK tools.
|
|
1345
|
+
toolChoice: toolChoice === "none" ? { type: "none" } : void 0
|
|
1341
1346
|
};
|
|
1342
1347
|
}
|
|
1343
1348
|
const filteredTools = activeTools != null ? Object.entries(tools).filter(
|
|
@@ -2035,9 +2040,8 @@ var DefaultGeneratedFile = class {
|
|
|
2035
2040
|
data,
|
|
2036
2041
|
mediaType
|
|
2037
2042
|
}) {
|
|
2038
|
-
|
|
2039
|
-
this.
|
|
2040
|
-
this.uint8ArrayData = isUint8Array ? data : void 0;
|
|
2043
|
+
this.base64Data = typeof data === "string" ? data : void 0;
|
|
2044
|
+
this.uint8ArrayData = typeof data === "string" ? void 0 : convertDataContentToUint8Array(data);
|
|
2041
2045
|
this.mediaType = mediaType;
|
|
2042
2046
|
}
|
|
2043
2047
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|
|
@@ -2580,9 +2584,9 @@ async function generateText({
|
|
|
2580
2584
|
"ai.response.id": responseData.id,
|
|
2581
2585
|
"ai.response.model": responseData.modelId,
|
|
2582
2586
|
"ai.response.timestamp": responseData.timestamp.toISOString(),
|
|
2583
|
-
"ai.response.providerMetadata":
|
|
2584
|
-
result.providerMetadata
|
|
2585
|
-
|
|
2587
|
+
"ai.response.providerMetadata": {
|
|
2588
|
+
output: () => JSON.stringify(result.providerMetadata)
|
|
2589
|
+
},
|
|
2586
2590
|
// TODO rename telemetry attributes to inputTokens and outputTokens
|
|
2587
2591
|
"ai.usage.promptTokens": result.usage.inputTokens,
|
|
2588
2592
|
"ai.usage.completionTokens": result.usage.outputTokens,
|
|
@@ -2728,9 +2732,9 @@ async function generateText({
|
|
|
2728
2732
|
return toolCalls == null ? void 0 : JSON.stringify(toolCalls);
|
|
2729
2733
|
}
|
|
2730
2734
|
},
|
|
2731
|
-
"ai.response.providerMetadata":
|
|
2732
|
-
currentModelResponse.providerMetadata
|
|
2733
|
-
|
|
2735
|
+
"ai.response.providerMetadata": {
|
|
2736
|
+
output: () => JSON.stringify(currentModelResponse.providerMetadata)
|
|
2737
|
+
},
|
|
2734
2738
|
// TODO rename telemetry attributes to inputTokens and outputTokens
|
|
2735
2739
|
"ai.usage.promptTokens": currentModelResponse.usage.inputTokens,
|
|
2736
2740
|
"ai.usage.completionTokens": currentModelResponse.usage.outputTokens
|
|
@@ -5425,9 +5429,9 @@ var DefaultStreamTextResult = class {
|
|
|
5425
5429
|
return ((_a17 = finalStep.toolCalls) == null ? void 0 : _a17.length) ? JSON.stringify(finalStep.toolCalls) : void 0;
|
|
5426
5430
|
}
|
|
5427
5431
|
},
|
|
5428
|
-
"ai.response.providerMetadata":
|
|
5429
|
-
finalStep.providerMetadata
|
|
5430
|
-
|
|
5432
|
+
"ai.response.providerMetadata": {
|
|
5433
|
+
output: () => JSON.stringify(finalStep.providerMetadata)
|
|
5434
|
+
},
|
|
5431
5435
|
"ai.usage.inputTokens": totalUsage.inputTokens,
|
|
5432
5436
|
"ai.usage.outputTokens": totalUsage.outputTokens,
|
|
5433
5437
|
"ai.usage.totalTokens": totalUsage.totalTokens,
|
|
@@ -5826,7 +5830,9 @@ var DefaultStreamTextResult = class {
|
|
|
5826
5830
|
"ai.response.id": stepResponse.id,
|
|
5827
5831
|
"ai.response.model": stepResponse.modelId,
|
|
5828
5832
|
"ai.response.timestamp": stepResponse.timestamp.toISOString(),
|
|
5829
|
-
"ai.response.providerMetadata":
|
|
5833
|
+
"ai.response.providerMetadata": {
|
|
5834
|
+
output: () => JSON.stringify(stepProviderMetadata)
|
|
5835
|
+
},
|
|
5830
5836
|
"ai.usage.inputTokens": stepUsage.inputTokens,
|
|
5831
5837
|
"ai.usage.outputTokens": stepUsage.outputTokens,
|
|
5832
5838
|
"ai.usage.totalTokens": stepUsage.totalTokens,
|
|
@@ -7938,9 +7944,9 @@ async function generateObject(options) {
|
|
|
7938
7944
|
"ai.response.id": responseData.id,
|
|
7939
7945
|
"ai.response.model": responseData.modelId,
|
|
7940
7946
|
"ai.response.timestamp": responseData.timestamp.toISOString(),
|
|
7941
|
-
"ai.response.providerMetadata":
|
|
7942
|
-
result2.providerMetadata
|
|
7943
|
-
|
|
7947
|
+
"ai.response.providerMetadata": {
|
|
7948
|
+
output: () => JSON.stringify(result2.providerMetadata)
|
|
7949
|
+
},
|
|
7944
7950
|
// TODO rename telemetry attributes to inputTokens and outputTokens
|
|
7945
7951
|
"ai.usage.promptTokens": result2.usage.inputTokens,
|
|
7946
7952
|
"ai.usage.completionTokens": result2.usage.outputTokens,
|
|
@@ -7989,9 +7995,9 @@ async function generateObject(options) {
|
|
|
7989
7995
|
"ai.response.object": {
|
|
7990
7996
|
output: () => JSON.stringify(object2)
|
|
7991
7997
|
},
|
|
7992
|
-
"ai.response.providerMetadata":
|
|
7993
|
-
resultProviderMetadata
|
|
7994
|
-
|
|
7998
|
+
"ai.response.providerMetadata": {
|
|
7999
|
+
output: () => JSON.stringify(resultProviderMetadata)
|
|
8000
|
+
},
|
|
7995
8001
|
// TODO rename telemetry attributes to inputTokens and outputTokens
|
|
7996
8002
|
"ai.usage.promptTokens": usage.inputTokens,
|
|
7997
8003
|
"ai.usage.completionTokens": usage.outputTokens
|
|
@@ -8586,7 +8592,9 @@ var DefaultStreamObjectResult = class {
|
|
|
8586
8592
|
"ai.response.id": fullResponse.id,
|
|
8587
8593
|
"ai.response.model": fullResponse.modelId,
|
|
8588
8594
|
"ai.response.timestamp": fullResponse.timestamp.toISOString(),
|
|
8589
|
-
"ai.response.providerMetadata":
|
|
8595
|
+
"ai.response.providerMetadata": {
|
|
8596
|
+
output: () => JSON.stringify(providerMetadata)
|
|
8597
|
+
},
|
|
8590
8598
|
"ai.usage.inputTokens": finalUsage.inputTokens,
|
|
8591
8599
|
"ai.usage.outputTokens": finalUsage.outputTokens,
|
|
8592
8600
|
"ai.usage.totalTokens": finalUsage.totalTokens,
|
|
@@ -8614,7 +8622,9 @@ var DefaultStreamObjectResult = class {
|
|
|
8614
8622
|
"ai.response.object": {
|
|
8615
8623
|
output: () => JSON.stringify(object2)
|
|
8616
8624
|
},
|
|
8617
|
-
"ai.response.providerMetadata":
|
|
8625
|
+
"ai.response.providerMetadata": {
|
|
8626
|
+
output: () => JSON.stringify(providerMetadata)
|
|
8627
|
+
}
|
|
8618
8628
|
}
|
|
8619
8629
|
})
|
|
8620
8630
|
);
|