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.mjs
CHANGED
|
@@ -716,6 +716,12 @@ function getStepTimeoutMs(timeout) {
|
|
|
716
716
|
}
|
|
717
717
|
return timeout.stepMs;
|
|
718
718
|
}
|
|
719
|
+
function getChunkTimeoutMs(timeout) {
|
|
720
|
+
if (timeout == null || typeof timeout === "number") {
|
|
721
|
+
return void 0;
|
|
722
|
+
}
|
|
723
|
+
return timeout.chunkMs;
|
|
724
|
+
}
|
|
719
725
|
|
|
720
726
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
721
727
|
import {
|
|
@@ -915,7 +921,7 @@ import {
|
|
|
915
921
|
} from "@ai-sdk/provider-utils";
|
|
916
922
|
|
|
917
923
|
// src/version.ts
|
|
918
|
-
var VERSION = true ? "6.0.
|
|
924
|
+
var VERSION = true ? "6.0.25" : "0.0.0-test";
|
|
919
925
|
|
|
920
926
|
// src/util/download/download.ts
|
|
921
927
|
var download = async ({ url }) => {
|
|
@@ -2901,12 +2907,16 @@ async function parsePartialJson(jsonText) {
|
|
|
2901
2907
|
|
|
2902
2908
|
// src/generate-text/output.ts
|
|
2903
2909
|
var text = () => ({
|
|
2910
|
+
name: "text",
|
|
2904
2911
|
responseFormat: Promise.resolve({ type: "text" }),
|
|
2905
2912
|
async parseCompleteOutput({ text: text2 }) {
|
|
2906
2913
|
return text2;
|
|
2907
2914
|
},
|
|
2908
2915
|
async parsePartialOutput({ text: text2 }) {
|
|
2909
2916
|
return { partial: text2 };
|
|
2917
|
+
},
|
|
2918
|
+
createElementStreamTransform() {
|
|
2919
|
+
return void 0;
|
|
2910
2920
|
}
|
|
2911
2921
|
});
|
|
2912
2922
|
var object = ({
|
|
@@ -2916,6 +2926,7 @@ var object = ({
|
|
|
2916
2926
|
}) => {
|
|
2917
2927
|
const schema = asSchema2(inputSchema);
|
|
2918
2928
|
return {
|
|
2929
|
+
name: "object",
|
|
2919
2930
|
responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
|
|
2920
2931
|
type: "json",
|
|
2921
2932
|
schema: jsonSchema2,
|
|
@@ -2965,6 +2976,9 @@ var object = ({
|
|
|
2965
2976
|
};
|
|
2966
2977
|
}
|
|
2967
2978
|
}
|
|
2979
|
+
},
|
|
2980
|
+
createElementStreamTransform() {
|
|
2981
|
+
return void 0;
|
|
2968
2982
|
}
|
|
2969
2983
|
};
|
|
2970
2984
|
};
|
|
@@ -2975,6 +2989,7 @@ var array = ({
|
|
|
2975
2989
|
}) => {
|
|
2976
2990
|
const elementSchema = asSchema2(inputElementSchema);
|
|
2977
2991
|
return {
|
|
2992
|
+
name: "array",
|
|
2978
2993
|
// JSON schema that describes an array of elements:
|
|
2979
2994
|
responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
2980
2995
|
const { $schema, ...itemSchema } = jsonSchema2;
|
|
@@ -3064,6 +3079,18 @@ var array = ({
|
|
|
3064
3079
|
return { partial: parsedElements };
|
|
3065
3080
|
}
|
|
3066
3081
|
}
|
|
3082
|
+
},
|
|
3083
|
+
createElementStreamTransform() {
|
|
3084
|
+
let publishedElements = 0;
|
|
3085
|
+
return new TransformStream({
|
|
3086
|
+
transform({ partialOutput }, controller) {
|
|
3087
|
+
if (partialOutput != null) {
|
|
3088
|
+
for (; publishedElements < partialOutput.length; publishedElements++) {
|
|
3089
|
+
controller.enqueue(partialOutput[publishedElements]);
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
});
|
|
3067
3094
|
}
|
|
3068
3095
|
};
|
|
3069
3096
|
};
|
|
@@ -3073,6 +3100,7 @@ var choice = ({
|
|
|
3073
3100
|
description
|
|
3074
3101
|
}) => {
|
|
3075
3102
|
return {
|
|
3103
|
+
name: "choice",
|
|
3076
3104
|
// JSON schema that describes an enumeration:
|
|
3077
3105
|
responseFormat: Promise.resolve({
|
|
3078
3106
|
type: "json",
|
|
@@ -3139,6 +3167,9 @@ var choice = ({
|
|
|
3139
3167
|
}
|
|
3140
3168
|
}
|
|
3141
3169
|
}
|
|
3170
|
+
},
|
|
3171
|
+
createElementStreamTransform() {
|
|
3172
|
+
return void 0;
|
|
3142
3173
|
}
|
|
3143
3174
|
};
|
|
3144
3175
|
};
|
|
@@ -3147,6 +3178,7 @@ var json = ({
|
|
|
3147
3178
|
description
|
|
3148
3179
|
} = {}) => {
|
|
3149
3180
|
return {
|
|
3181
|
+
name: "json",
|
|
3150
3182
|
responseFormat: Promise.resolve({
|
|
3151
3183
|
type: "json",
|
|
3152
3184
|
...name16 != null && { name: name16 },
|
|
@@ -3178,6 +3210,9 @@ var json = ({
|
|
|
3178
3210
|
return result.value === void 0 ? void 0 : { partial: result.value };
|
|
3179
3211
|
}
|
|
3180
3212
|
}
|
|
3213
|
+
},
|
|
3214
|
+
createElementStreamTransform() {
|
|
3215
|
+
return void 0;
|
|
3181
3216
|
}
|
|
3182
3217
|
};
|
|
3183
3218
|
};
|
|
@@ -4300,7 +4335,8 @@ function asContent({
|
|
|
4300
4335
|
|
|
4301
4336
|
// src/generate-text/stream-text.ts
|
|
4302
4337
|
import {
|
|
4303
|
-
getErrorMessage as getErrorMessage7
|
|
4338
|
+
getErrorMessage as getErrorMessage7,
|
|
4339
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
4304
4340
|
} from "@ai-sdk/provider";
|
|
4305
4341
|
import {
|
|
4306
4342
|
createIdGenerator as createIdGenerator2,
|
|
@@ -5693,7 +5729,9 @@ function streamText({
|
|
|
5693
5729
|
}) {
|
|
5694
5730
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
5695
5731
|
const stepTimeoutMs = getStepTimeoutMs(timeout);
|
|
5732
|
+
const chunkTimeoutMs = getChunkTimeoutMs(timeout);
|
|
5696
5733
|
const stepAbortController = stepTimeoutMs != null ? new AbortController() : void 0;
|
|
5734
|
+
const chunkAbortController = chunkTimeoutMs != null ? new AbortController() : void 0;
|
|
5697
5735
|
return new DefaultStreamTextResult({
|
|
5698
5736
|
model: resolveLanguageModel(model),
|
|
5699
5737
|
telemetry,
|
|
@@ -5703,10 +5741,13 @@ function streamText({
|
|
|
5703
5741
|
abortSignal: mergeAbortSignals(
|
|
5704
5742
|
abortSignal,
|
|
5705
5743
|
totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0,
|
|
5706
|
-
stepAbortController == null ? void 0 : stepAbortController.signal
|
|
5744
|
+
stepAbortController == null ? void 0 : stepAbortController.signal,
|
|
5745
|
+
chunkAbortController == null ? void 0 : chunkAbortController.signal
|
|
5707
5746
|
),
|
|
5708
5747
|
stepTimeoutMs,
|
|
5709
5748
|
stepAbortController,
|
|
5749
|
+
chunkTimeoutMs,
|
|
5750
|
+
chunkAbortController,
|
|
5710
5751
|
system,
|
|
5711
5752
|
prompt,
|
|
5712
5753
|
messages,
|
|
@@ -5803,6 +5844,8 @@ var DefaultStreamTextResult = class {
|
|
|
5803
5844
|
abortSignal,
|
|
5804
5845
|
stepTimeoutMs,
|
|
5805
5846
|
stepAbortController,
|
|
5847
|
+
chunkTimeoutMs,
|
|
5848
|
+
chunkAbortController,
|
|
5806
5849
|
system,
|
|
5807
5850
|
prompt,
|
|
5808
5851
|
messages,
|
|
@@ -6269,6 +6312,29 @@ var DefaultStreamTextResult = class {
|
|
|
6269
6312
|
var _a16, _b, _c, _d, _e, _f;
|
|
6270
6313
|
const includeRawChunks2 = self.includeRawChunks;
|
|
6271
6314
|
const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : void 0;
|
|
6315
|
+
let chunkTimeoutId = void 0;
|
|
6316
|
+
function resetChunkTimeout() {
|
|
6317
|
+
if (chunkTimeoutMs != null) {
|
|
6318
|
+
if (chunkTimeoutId != null) {
|
|
6319
|
+
clearTimeout(chunkTimeoutId);
|
|
6320
|
+
}
|
|
6321
|
+
chunkTimeoutId = setTimeout(
|
|
6322
|
+
() => chunkAbortController.abort(),
|
|
6323
|
+
chunkTimeoutMs
|
|
6324
|
+
);
|
|
6325
|
+
}
|
|
6326
|
+
}
|
|
6327
|
+
function clearChunkTimeout() {
|
|
6328
|
+
if (chunkTimeoutId != null) {
|
|
6329
|
+
clearTimeout(chunkTimeoutId);
|
|
6330
|
+
chunkTimeoutId = void 0;
|
|
6331
|
+
}
|
|
6332
|
+
}
|
|
6333
|
+
function clearStepTimeout() {
|
|
6334
|
+
if (stepTimeoutId != null) {
|
|
6335
|
+
clearTimeout(stepTimeoutId);
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6272
6338
|
stepFinish = new DelayedPromise();
|
|
6273
6339
|
const stepInputMessages = [...initialMessages, ...responseMessages];
|
|
6274
6340
|
const prepareStepResult = await (prepareStep == null ? void 0 : prepareStep({
|
|
@@ -6393,6 +6459,7 @@ var DefaultStreamTextResult = class {
|
|
|
6393
6459
|
new TransformStream({
|
|
6394
6460
|
async transform(chunk, controller) {
|
|
6395
6461
|
var _a17, _b2, _c2, _d2, _e2;
|
|
6462
|
+
resetChunkTimeout();
|
|
6396
6463
|
if (chunk.type === "stream-start") {
|
|
6397
6464
|
warnings = chunk.warnings;
|
|
6398
6465
|
return;
|
|
@@ -6623,9 +6690,8 @@ var DefaultStreamTextResult = class {
|
|
|
6623
6690
|
pendingDeferredToolCalls.delete(output2.toolCallId);
|
|
6624
6691
|
}
|
|
6625
6692
|
}
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
}
|
|
6693
|
+
clearStepTimeout();
|
|
6694
|
+
clearChunkTimeout();
|
|
6629
6695
|
if (
|
|
6630
6696
|
// Continue if:
|
|
6631
6697
|
// 1. There are client tool calls that have all been executed, OR
|
|
@@ -6824,6 +6890,16 @@ var DefaultStreamTextResult = class {
|
|
|
6824
6890
|
)
|
|
6825
6891
|
);
|
|
6826
6892
|
}
|
|
6893
|
+
get elementStream() {
|
|
6894
|
+
var _a16, _b, _c;
|
|
6895
|
+
const transform = (_a16 = this.outputSpecification) == null ? void 0 : _a16.createElementStreamTransform();
|
|
6896
|
+
if (transform == null) {
|
|
6897
|
+
throw new UnsupportedFunctionalityError2({
|
|
6898
|
+
functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : "text"} mode`
|
|
6899
|
+
});
|
|
6900
|
+
}
|
|
6901
|
+
return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
|
|
6902
|
+
}
|
|
6827
6903
|
get output() {
|
|
6828
6904
|
return this.finalStep.then((step) => {
|
|
6829
6905
|
var _a16;
|
|
@@ -8649,7 +8725,7 @@ import {
|
|
|
8649
8725
|
isJSONArray,
|
|
8650
8726
|
isJSONObject,
|
|
8651
8727
|
TypeValidationError as TypeValidationError4,
|
|
8652
|
-
UnsupportedFunctionalityError as
|
|
8728
|
+
UnsupportedFunctionalityError as UnsupportedFunctionalityError3
|
|
8653
8729
|
} from "@ai-sdk/provider";
|
|
8654
8730
|
import {
|
|
8655
8731
|
asSchema as asSchema4,
|
|
@@ -8674,7 +8750,7 @@ var noSchemaOutputStrategy = {
|
|
|
8674
8750
|
} : { success: true, value };
|
|
8675
8751
|
},
|
|
8676
8752
|
createElementStream() {
|
|
8677
|
-
throw new
|
|
8753
|
+
throw new UnsupportedFunctionalityError3({
|
|
8678
8754
|
functionality: "element streams in no-schema mode"
|
|
8679
8755
|
});
|
|
8680
8756
|
}
|
|
@@ -8696,7 +8772,7 @@ var objectOutputStrategy = (schema) => ({
|
|
|
8696
8772
|
return safeValidateTypes4({ value, schema });
|
|
8697
8773
|
},
|
|
8698
8774
|
createElementStream() {
|
|
8699
|
-
throw new
|
|
8775
|
+
throw new UnsupportedFunctionalityError3({
|
|
8700
8776
|
functionality: "element streams in object mode"
|
|
8701
8777
|
});
|
|
8702
8778
|
}
|
|
@@ -8885,7 +8961,7 @@ var enumOutputStrategy = (enumValues) => {
|
|
|
8885
8961
|
};
|
|
8886
8962
|
},
|
|
8887
8963
|
createElementStream() {
|
|
8888
|
-
throw new
|
|
8964
|
+
throw new UnsupportedFunctionalityError3({
|
|
8889
8965
|
functionality: "element streams in enum mode"
|
|
8890
8966
|
});
|
|
8891
8967
|
}
|
|
@@ -12116,11 +12192,9 @@ export {
|
|
|
12116
12192
|
generateObject,
|
|
12117
12193
|
generateText,
|
|
12118
12194
|
getStaticToolName,
|
|
12119
|
-
getStepTimeoutMs,
|
|
12120
12195
|
getTextFromDataUrl,
|
|
12121
12196
|
getToolName,
|
|
12122
12197
|
getToolOrDynamicToolName,
|
|
12123
|
-
getTotalTimeoutMs,
|
|
12124
12198
|
hasToolCall,
|
|
12125
12199
|
isDataUIPart,
|
|
12126
12200
|
isDeepEqualData,
|