ai 6.0.23 → 6.0.25
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 +12 -0
- package/dist/index.d.mts +1756 -1747
- package/dist/index.d.ts +1756 -1747
- package/dist/index.js +80 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -96,11 +96,9 @@ __export(src_exports, {
|
|
|
96
96
|
generateObject: () => generateObject,
|
|
97
97
|
generateText: () => generateText,
|
|
98
98
|
getStaticToolName: () => getStaticToolName,
|
|
99
|
-
getStepTimeoutMs: () => getStepTimeoutMs,
|
|
100
99
|
getTextFromDataUrl: () => getTextFromDataUrl,
|
|
101
100
|
getToolName: () => getToolName,
|
|
102
101
|
getToolOrDynamicToolName: () => getToolOrDynamicToolName,
|
|
103
|
-
getTotalTimeoutMs: () => getTotalTimeoutMs,
|
|
104
102
|
hasToolCall: () => hasToolCall,
|
|
105
103
|
isDataUIPart: () => isDataUIPart,
|
|
106
104
|
isDeepEqualData: () => isDeepEqualData,
|
|
@@ -826,6 +824,12 @@ function getStepTimeoutMs(timeout) {
|
|
|
826
824
|
}
|
|
827
825
|
return timeout.stepMs;
|
|
828
826
|
}
|
|
827
|
+
function getChunkTimeoutMs(timeout) {
|
|
828
|
+
if (timeout == null || typeof timeout === "number") {
|
|
829
|
+
return void 0;
|
|
830
|
+
}
|
|
831
|
+
return timeout.chunkMs;
|
|
832
|
+
}
|
|
829
833
|
|
|
830
834
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
831
835
|
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
@@ -1020,7 +1024,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
|
1020
1024
|
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
1021
1025
|
|
|
1022
1026
|
// src/version.ts
|
|
1023
|
-
var VERSION = true ? "6.0.
|
|
1027
|
+
var VERSION = true ? "6.0.25" : "0.0.0-test";
|
|
1024
1028
|
|
|
1025
1029
|
// src/util/download/download.ts
|
|
1026
1030
|
var download = async ({ url }) => {
|
|
@@ -2991,12 +2995,16 @@ async function parsePartialJson(jsonText) {
|
|
|
2991
2995
|
|
|
2992
2996
|
// src/generate-text/output.ts
|
|
2993
2997
|
var text = () => ({
|
|
2998
|
+
name: "text",
|
|
2994
2999
|
responseFormat: Promise.resolve({ type: "text" }),
|
|
2995
3000
|
async parseCompleteOutput({ text: text2 }) {
|
|
2996
3001
|
return text2;
|
|
2997
3002
|
},
|
|
2998
3003
|
async parsePartialOutput({ text: text2 }) {
|
|
2999
3004
|
return { partial: text2 };
|
|
3005
|
+
},
|
|
3006
|
+
createElementStreamTransform() {
|
|
3007
|
+
return void 0;
|
|
3000
3008
|
}
|
|
3001
3009
|
});
|
|
3002
3010
|
var object = ({
|
|
@@ -3006,6 +3014,7 @@ var object = ({
|
|
|
3006
3014
|
}) => {
|
|
3007
3015
|
const schema = (0, import_provider_utils13.asSchema)(inputSchema);
|
|
3008
3016
|
return {
|
|
3017
|
+
name: "object",
|
|
3009
3018
|
responseFormat: (0, import_provider_utils13.resolve)(schema.jsonSchema).then((jsonSchema2) => ({
|
|
3010
3019
|
type: "json",
|
|
3011
3020
|
schema: jsonSchema2,
|
|
@@ -3055,6 +3064,9 @@ var object = ({
|
|
|
3055
3064
|
};
|
|
3056
3065
|
}
|
|
3057
3066
|
}
|
|
3067
|
+
},
|
|
3068
|
+
createElementStreamTransform() {
|
|
3069
|
+
return void 0;
|
|
3058
3070
|
}
|
|
3059
3071
|
};
|
|
3060
3072
|
};
|
|
@@ -3065,6 +3077,7 @@ var array = ({
|
|
|
3065
3077
|
}) => {
|
|
3066
3078
|
const elementSchema = (0, import_provider_utils13.asSchema)(inputElementSchema);
|
|
3067
3079
|
return {
|
|
3080
|
+
name: "array",
|
|
3068
3081
|
// JSON schema that describes an array of elements:
|
|
3069
3082
|
responseFormat: (0, import_provider_utils13.resolve)(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
3070
3083
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
@@ -3154,6 +3167,18 @@ var array = ({
|
|
|
3154
3167
|
return { partial: parsedElements };
|
|
3155
3168
|
}
|
|
3156
3169
|
}
|
|
3170
|
+
},
|
|
3171
|
+
createElementStreamTransform() {
|
|
3172
|
+
let publishedElements = 0;
|
|
3173
|
+
return new TransformStream({
|
|
3174
|
+
transform({ partialOutput }, controller) {
|
|
3175
|
+
if (partialOutput != null) {
|
|
3176
|
+
for (; publishedElements < partialOutput.length; publishedElements++) {
|
|
3177
|
+
controller.enqueue(partialOutput[publishedElements]);
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
});
|
|
3157
3182
|
}
|
|
3158
3183
|
};
|
|
3159
3184
|
};
|
|
@@ -3163,6 +3188,7 @@ var choice = ({
|
|
|
3163
3188
|
description
|
|
3164
3189
|
}) => {
|
|
3165
3190
|
return {
|
|
3191
|
+
name: "choice",
|
|
3166
3192
|
// JSON schema that describes an enumeration:
|
|
3167
3193
|
responseFormat: Promise.resolve({
|
|
3168
3194
|
type: "json",
|
|
@@ -3229,6 +3255,9 @@ var choice = ({
|
|
|
3229
3255
|
}
|
|
3230
3256
|
}
|
|
3231
3257
|
}
|
|
3258
|
+
},
|
|
3259
|
+
createElementStreamTransform() {
|
|
3260
|
+
return void 0;
|
|
3232
3261
|
}
|
|
3233
3262
|
};
|
|
3234
3263
|
};
|
|
@@ -3237,6 +3266,7 @@ var json = ({
|
|
|
3237
3266
|
description
|
|
3238
3267
|
} = {}) => {
|
|
3239
3268
|
return {
|
|
3269
|
+
name: "json",
|
|
3240
3270
|
responseFormat: Promise.resolve({
|
|
3241
3271
|
type: "json",
|
|
3242
3272
|
...name16 != null && { name: name16 },
|
|
@@ -3268,6 +3298,9 @@ var json = ({
|
|
|
3268
3298
|
return result.value === void 0 ? void 0 : { partial: result.value };
|
|
3269
3299
|
}
|
|
3270
3300
|
}
|
|
3301
|
+
},
|
|
3302
|
+
createElementStreamTransform() {
|
|
3303
|
+
return void 0;
|
|
3271
3304
|
}
|
|
3272
3305
|
};
|
|
3273
3306
|
};
|
|
@@ -5771,7 +5804,9 @@ function streamText({
|
|
|
5771
5804
|
}) {
|
|
5772
5805
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
5773
5806
|
const stepTimeoutMs = getStepTimeoutMs(timeout);
|
|
5807
|
+
const chunkTimeoutMs = getChunkTimeoutMs(timeout);
|
|
5774
5808
|
const stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;
|
|
5809
|
+
const chunkAbortController = chunkTimeoutMs != null ? new AbortController() : void 0;
|
|
5775
5810
|
return new DefaultStreamTextResult({
|
|
5776
5811
|
model: resolveLanguageModel(model),
|
|
5777
5812
|
telemetry,
|
|
@@ -5781,10 +5816,13 @@ function streamText({
|
|
|
5781
5816
|
abortSignal: mergeAbortSignals(
|
|
5782
5817
|
abortSignal,
|
|
5783
5818
|
totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0,
|
|
5784
|
-
stepAbortController == null ? void 0 : stepAbortController.signal
|
|
5819
|
+
stepAbortController == null ? void 0 : stepAbortController.signal,
|
|
5820
|
+
chunkAbortController == null ? void 0 : chunkAbortController.signal
|
|
5785
5821
|
),
|
|
5786
5822
|
stepTimeoutMs,
|
|
5787
5823
|
stepAbortController,
|
|
5824
|
+
chunkTimeoutMs,
|
|
5825
|
+
chunkAbortController,
|
|
5788
5826
|
system,
|
|
5789
5827
|
prompt,
|
|
5790
5828
|
messages,
|
|
@@ -5881,6 +5919,8 @@ var DefaultStreamTextResult = class {
|
|
|
5881
5919
|
abortSignal,
|
|
5882
5920
|
stepTimeoutMs,
|
|
5883
5921
|
stepAbortController,
|
|
5922
|
+
chunkTimeoutMs,
|
|
5923
|
+
chunkAbortController,
|
|
5884
5924
|
system,
|
|
5885
5925
|
prompt,
|
|
5886
5926
|
messages,
|
|
@@ -6347,6 +6387,29 @@ var DefaultStreamTextResult = class {
|
|
|
6347
6387
|
var _a16, _b, _c, _d, _e, _f;
|
|
6348
6388
|
const includeRawChunks2 = self.includeRawChunks;
|
|
6349
6389
|
const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : void 0;
|
|
6390
|
+
let chunkTimeoutId = void 0;
|
|
6391
|
+
function resetChunkTimeout() {
|
|
6392
|
+
if (chunkTimeoutMs != null) {
|
|
6393
|
+
if (chunkTimeoutId != null) {
|
|
6394
|
+
clearTimeout(chunkTimeoutId);
|
|
6395
|
+
}
|
|
6396
|
+
chunkTimeoutId = setTimeout(
|
|
6397
|
+
() => chunkAbortController.abort(),
|
|
6398
|
+
chunkTimeoutMs
|
|
6399
|
+
);
|
|
6400
|
+
}
|
|
6401
|
+
}
|
|
6402
|
+
function clearChunkTimeout() {
|
|
6403
|
+
if (chunkTimeoutId != null) {
|
|
6404
|
+
clearTimeout(chunkTimeoutId);
|
|
6405
|
+
chunkTimeoutId = void 0;
|
|
6406
|
+
}
|
|
6407
|
+
}
|
|
6408
|
+
function clearStepTimeout() {
|
|
6409
|
+
if (stepTimeoutId != null) {
|
|
6410
|
+
clearTimeout(stepTimeoutId);
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6350
6413
|
stepFinish = new import_provider_utils19.DelayedPromise();
|
|
6351
6414
|
const stepInputMessages = [...initialMessages, ...responseMessages];
|
|
6352
6415
|
const prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({
|
|
@@ -6471,6 +6534,7 @@ var DefaultStreamTextResult = class {
|
|
|
6471
6534
|
new TransformStream({
|
|
6472
6535
|
async transform(chunk, controller) {
|
|
6473
6536
|
var _a17, _b2, _c2, _d2, _e2;
|
|
6537
|
+
resetChunkTimeout();
|
|
6474
6538
|
if (chunk.type === "stream-start") {
|
|
6475
6539
|
warnings = chunk.warnings;
|
|
6476
6540
|
return;
|
|
@@ -6701,9 +6765,8 @@ var DefaultStreamTextResult = class {
|
|
|
6701
6765
|
pendingDeferredToolCalls.delete(output2.toolCallId);
|
|
6702
6766
|
}
|
|
6703
6767
|
}
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
}
|
|
6768
|
+
clearStepTimeout();
|
|
6769
|
+
clearChunkTimeout();
|
|
6707
6770
|
if (
|
|
6708
6771
|
// Continue if:
|
|
6709
6772
|
// 1. There are client tool calls that have all been executed, OR
|
|
@@ -6902,6 +6965,16 @@ var DefaultStreamTextResult = class {
|
|
|
6902
6965
|
)
|
|
6903
6966
|
);
|
|
6904
6967
|
}
|
|
6968
|
+
get elementStream() {
|
|
6969
|
+
var _a16, _b, _c;
|
|
6970
|
+
const transform = (_a16 = this.outputSpecification) == null ? void 0 : _a16.createElementStreamTransform();
|
|
6971
|
+
if (transform == null) {
|
|
6972
|
+
throw new import_provider24.UnsupportedFunctionalityError({
|
|
6973
|
+
functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : "text"} mode`
|
|
6974
|
+
});
|
|
6975
|
+
}
|
|
6976
|
+
return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
|
|
6977
|
+
}
|
|
6905
6978
|
get output() {
|
|
6906
6979
|
return this.finalStep.then((step) => {
|
|
6907
6980
|
var _a16;
|
|
@@ -12154,11 +12227,9 @@ var TextStreamChatTransport = class extends HttpChatTransport {
|
|
|
12154
12227
|
generateObject,
|
|
12155
12228
|
generateText,
|
|
12156
12229
|
getStaticToolName,
|
|
12157
|
-
getStepTimeoutMs,
|
|
12158
12230
|
getTextFromDataUrl,
|
|
12159
12231
|
getToolName,
|
|
12160
12232
|
getToolOrDynamicToolName,
|
|
12161
|
-
getTotalTimeoutMs,
|
|
12162
12233
|
hasToolCall,
|
|
12163
12234
|
isDataUIPart,
|
|
12164
12235
|
isDeepEqualData,
|