ai 6.0.329 → 6.0.331
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 +16 -0
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +685 -432
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +582 -326
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +9 -10
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +70 -33
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +8 -1
- package/docs/07-reference/02-ai-sdk-ui/32-prune-messages.mdx +9 -0
- package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +3 -1
- package/package.json +4 -3
- package/src/generate-object/output-strategy.ts +8 -0
- package/src/generate-object/stream-object.ts +22 -0
- package/src/generate-text/output.ts +21 -25
- package/src/generate-text/stream-text-result.ts +21 -2
- package/src/generate-text/stream-text.ts +48 -3
- package/src/ui/validate-ui-messages.ts +424 -266
- package/src/util/array-output-stream.ts +161 -0
package/dist/index.mjs
CHANGED
|
@@ -1225,7 +1225,7 @@ import {
|
|
|
1225
1225
|
} from "@ai-sdk/provider-utils";
|
|
1226
1226
|
|
|
1227
1227
|
// src/version.ts
|
|
1228
|
-
var VERSION = true ? "6.0.
|
|
1228
|
+
var VERSION = true ? "6.0.331" : "0.0.0-test";
|
|
1229
1229
|
|
|
1230
1230
|
// src/util/download/download.ts
|
|
1231
1231
|
var download = async ({
|
|
@@ -3462,12 +3462,124 @@ import {
|
|
|
3462
3462
|
import {
|
|
3463
3463
|
asSchema as asSchema3,
|
|
3464
3464
|
resolve,
|
|
3465
|
-
safeParseJSON as
|
|
3465
|
+
safeParseJSON as safeParseJSON3,
|
|
3466
|
+
safeValidateTypes as safeValidateTypes4
|
|
3467
|
+
} from "@ai-sdk/provider-utils";
|
|
3468
|
+
|
|
3469
|
+
// src/util/array-output-stream.ts
|
|
3470
|
+
import {
|
|
3471
|
+
safeParseJSON,
|
|
3466
3472
|
safeValidateTypes as safeValidateTypes3
|
|
3467
3473
|
} from "@ai-sdk/provider-utils";
|
|
3474
|
+
var arrayStreamParserFactories = /* @__PURE__ */ new WeakMap();
|
|
3475
|
+
function createArrayStreamParser(output) {
|
|
3476
|
+
var _a23;
|
|
3477
|
+
return (_a23 = arrayStreamParserFactories.get(output)) == null ? void 0 : _a23();
|
|
3478
|
+
}
|
|
3479
|
+
function createArrayOutputStreamParser(schema, skipInvalidElements) {
|
|
3480
|
+
let phase = 0 /* Prefix */;
|
|
3481
|
+
let prefix = "";
|
|
3482
|
+
let elementText = "";
|
|
3483
|
+
let depth = 0;
|
|
3484
|
+
let inString = false;
|
|
3485
|
+
let escaped = false;
|
|
3486
|
+
let afterComma = false;
|
|
3487
|
+
let pending = [];
|
|
3488
|
+
const elements = [];
|
|
3489
|
+
let publishedCount;
|
|
3490
|
+
async function finishElement() {
|
|
3491
|
+
const parsed = await safeParseJSON({ text: elementText });
|
|
3492
|
+
if (!parsed.success) {
|
|
3493
|
+
return false;
|
|
3494
|
+
}
|
|
3495
|
+
const validated = await safeValidateTypes3({ value: parsed.value, schema });
|
|
3496
|
+
if (validated.success) {
|
|
3497
|
+
pending = [validated.value];
|
|
3498
|
+
} else if (!skipInvalidElements) {
|
|
3499
|
+
return false;
|
|
3500
|
+
}
|
|
3501
|
+
elementText = "";
|
|
3502
|
+
return true;
|
|
3503
|
+
}
|
|
3504
|
+
function publishPending() {
|
|
3505
|
+
elements.push(...pending);
|
|
3506
|
+
pending = [];
|
|
3507
|
+
}
|
|
3508
|
+
return async (textDelta) => {
|
|
3509
|
+
for (const char of textDelta) {
|
|
3510
|
+
if (phase === 0 /* Prefix */) {
|
|
3511
|
+
prefix += char;
|
|
3512
|
+
if (char === "[") {
|
|
3513
|
+
if (!/^\s*\{\s*"elements"\s*:\s*\[$/.test(prefix)) {
|
|
3514
|
+
return "fallback";
|
|
3515
|
+
}
|
|
3516
|
+
phase = 1 /* Elements */;
|
|
3517
|
+
} else if (prefix.length > 256) {
|
|
3518
|
+
return "fallback";
|
|
3519
|
+
}
|
|
3520
|
+
continue;
|
|
3521
|
+
}
|
|
3522
|
+
if (phase === 2 /* Suffix */ || phase === 3 /* Done */) {
|
|
3523
|
+
if (/\s/.test(char)) {
|
|
3524
|
+
continue;
|
|
3525
|
+
}
|
|
3526
|
+
if (phase === 2 /* Suffix */ && char === "}") {
|
|
3527
|
+
publishPending();
|
|
3528
|
+
phase = 3 /* Done */;
|
|
3529
|
+
continue;
|
|
3530
|
+
}
|
|
3531
|
+
return "fallback";
|
|
3532
|
+
}
|
|
3533
|
+
if (!inString && depth === 0 && (char === "," || char === "]")) {
|
|
3534
|
+
if (elementText.length > 0) {
|
|
3535
|
+
if (!await finishElement()) {
|
|
3536
|
+
return "fallback";
|
|
3537
|
+
}
|
|
3538
|
+
} else if (char === "," || afterComma) {
|
|
3539
|
+
return "fallback";
|
|
3540
|
+
}
|
|
3541
|
+
afterComma = char === ",";
|
|
3542
|
+
if (char === "]") {
|
|
3543
|
+
phase = 2 /* Suffix */;
|
|
3544
|
+
}
|
|
3545
|
+
continue;
|
|
3546
|
+
}
|
|
3547
|
+
if (elementText.length === 0) {
|
|
3548
|
+
if (/\s/.test(char)) {
|
|
3549
|
+
continue;
|
|
3550
|
+
}
|
|
3551
|
+
publishPending();
|
|
3552
|
+
afterComma = false;
|
|
3553
|
+
}
|
|
3554
|
+
elementText += char;
|
|
3555
|
+
if (inString) {
|
|
3556
|
+
if (escaped) {
|
|
3557
|
+
escaped = false;
|
|
3558
|
+
} else if (char === "\\") {
|
|
3559
|
+
escaped = true;
|
|
3560
|
+
} else if (char === '"') {
|
|
3561
|
+
inString = false;
|
|
3562
|
+
}
|
|
3563
|
+
} else if (char === '"') {
|
|
3564
|
+
inString = true;
|
|
3565
|
+
} else if (char === "{" || char === "[") {
|
|
3566
|
+
depth++;
|
|
3567
|
+
} else if (char === "}" || char === "]") {
|
|
3568
|
+
depth--;
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
if (phase === 0 /* Prefix */ || publishedCount === elements.length) {
|
|
3572
|
+
return void 0;
|
|
3573
|
+
}
|
|
3574
|
+
const previousCount = publishedCount != null ? publishedCount : 0;
|
|
3575
|
+
const delta = (publishedCount == null ? "[" : "") + (previousCount > 0 && elements.length > previousCount ? "," : "") + elements.slice(previousCount).map((value) => JSON.stringify(value)).join(",") + (phase === 3 /* Done */ ? "]" : "");
|
|
3576
|
+
publishedCount = elements.length;
|
|
3577
|
+
return { partial: elements.slice(), textDelta: delta };
|
|
3578
|
+
};
|
|
3579
|
+
}
|
|
3468
3580
|
|
|
3469
3581
|
// src/util/parse-partial-json.ts
|
|
3470
|
-
import { safeParseJSON } from "@ai-sdk/provider-utils";
|
|
3582
|
+
import { safeParseJSON as safeParseJSON2 } from "@ai-sdk/provider-utils";
|
|
3471
3583
|
|
|
3472
3584
|
// src/util/fix-json.ts
|
|
3473
3585
|
function fixJson(input) {
|
|
@@ -3811,11 +3923,11 @@ async function parsePartialJson(jsonText) {
|
|
|
3811
3923
|
if (jsonText === void 0) {
|
|
3812
3924
|
return { value: void 0, state: "undefined-input" };
|
|
3813
3925
|
}
|
|
3814
|
-
let result = await
|
|
3926
|
+
let result = await safeParseJSON2({ text: jsonText });
|
|
3815
3927
|
if (result.success) {
|
|
3816
3928
|
return { value: result.value, state: "successful-parse" };
|
|
3817
3929
|
}
|
|
3818
|
-
result = await
|
|
3930
|
+
result = await safeParseJSON2({ text: fixJson(jsonText) });
|
|
3819
3931
|
if (result.success) {
|
|
3820
3932
|
return { value: result.value, state: "repaired-parse" };
|
|
3821
3933
|
}
|
|
@@ -3851,29 +3963,25 @@ var object = ({
|
|
|
3851
3963
|
...description != null && { description }
|
|
3852
3964
|
})),
|
|
3853
3965
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
3854
|
-
const parseResult = await
|
|
3966
|
+
const parseResult = await safeParseJSON3({ text: text2 });
|
|
3855
3967
|
if (!parseResult.success) {
|
|
3856
3968
|
throw new NoObjectGeneratedError({
|
|
3969
|
+
...context2,
|
|
3857
3970
|
message: "No object generated: could not parse the response.",
|
|
3858
3971
|
cause: parseResult.error,
|
|
3859
|
-
text: text2
|
|
3860
|
-
response: context2.response,
|
|
3861
|
-
usage: context2.usage,
|
|
3862
|
-
finishReason: context2.finishReason
|
|
3972
|
+
text: text2
|
|
3863
3973
|
});
|
|
3864
3974
|
}
|
|
3865
|
-
const validationResult = await
|
|
3975
|
+
const validationResult = await safeValidateTypes4({
|
|
3866
3976
|
value: parseResult.value,
|
|
3867
3977
|
schema
|
|
3868
3978
|
});
|
|
3869
3979
|
if (!validationResult.success) {
|
|
3870
3980
|
throw new NoObjectGeneratedError({
|
|
3981
|
+
...context2,
|
|
3871
3982
|
message: "No object generated: response did not match schema.",
|
|
3872
3983
|
cause: validationResult.error,
|
|
3873
|
-
text: text2
|
|
3874
|
-
response: context2.response,
|
|
3875
|
-
usage: context2.usage,
|
|
3876
|
-
finishReason: context2.finishReason
|
|
3984
|
+
text: text2
|
|
3877
3985
|
});
|
|
3878
3986
|
}
|
|
3879
3987
|
return validationResult.value;
|
|
@@ -3905,7 +4013,7 @@ var array = ({
|
|
|
3905
4013
|
description
|
|
3906
4014
|
}) => {
|
|
3907
4015
|
const elementSchema = asSchema3(inputElementSchema);
|
|
3908
|
-
|
|
4016
|
+
const output = {
|
|
3909
4017
|
name: "array",
|
|
3910
4018
|
// JSON schema that describes an array of elements:
|
|
3911
4019
|
responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
@@ -3926,45 +4034,39 @@ var array = ({
|
|
|
3926
4034
|
};
|
|
3927
4035
|
}),
|
|
3928
4036
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
3929
|
-
const parseResult = await
|
|
4037
|
+
const parseResult = await safeParseJSON3({ text: text2 });
|
|
3930
4038
|
if (!parseResult.success) {
|
|
3931
4039
|
throw new NoObjectGeneratedError({
|
|
4040
|
+
...context2,
|
|
3932
4041
|
message: "No object generated: could not parse the response.",
|
|
3933
4042
|
cause: parseResult.error,
|
|
3934
|
-
text: text2
|
|
3935
|
-
response: context2.response,
|
|
3936
|
-
usage: context2.usage,
|
|
3937
|
-
finishReason: context2.finishReason
|
|
4043
|
+
text: text2
|
|
3938
4044
|
});
|
|
3939
4045
|
}
|
|
3940
4046
|
const outerValue = parseResult.value;
|
|
3941
4047
|
if (outerValue == null || typeof outerValue !== "object" || !("elements" in outerValue) || !Array.isArray(outerValue.elements)) {
|
|
3942
4048
|
throw new NoObjectGeneratedError({
|
|
4049
|
+
...context2,
|
|
3943
4050
|
message: "No object generated: response did not match schema.",
|
|
3944
4051
|
cause: new TypeValidationError2({
|
|
3945
4052
|
value: outerValue,
|
|
3946
4053
|
cause: "response must be an object with an elements array"
|
|
3947
4054
|
}),
|
|
3948
|
-
text: text2
|
|
3949
|
-
response: context2.response,
|
|
3950
|
-
usage: context2.usage,
|
|
3951
|
-
finishReason: context2.finishReason
|
|
4055
|
+
text: text2
|
|
3952
4056
|
});
|
|
3953
4057
|
}
|
|
3954
4058
|
const validatedElements = [];
|
|
3955
4059
|
for (const element of outerValue.elements) {
|
|
3956
|
-
const validationResult = await
|
|
4060
|
+
const validationResult = await safeValidateTypes4({
|
|
3957
4061
|
value: element,
|
|
3958
4062
|
schema: elementSchema
|
|
3959
4063
|
});
|
|
3960
4064
|
if (!validationResult.success) {
|
|
3961
4065
|
throw new NoObjectGeneratedError({
|
|
4066
|
+
...context2,
|
|
3962
4067
|
message: "No object generated: response did not match schema.",
|
|
3963
4068
|
cause: validationResult.error,
|
|
3964
|
-
text: text2
|
|
3965
|
-
response: context2.response,
|
|
3966
|
-
usage: context2.usage,
|
|
3967
|
-
finishReason: context2.finishReason
|
|
4069
|
+
text: text2
|
|
3968
4070
|
});
|
|
3969
4071
|
}
|
|
3970
4072
|
validatedElements.push(validationResult.value);
|
|
@@ -3987,7 +4089,7 @@ var array = ({
|
|
|
3987
4089
|
const rawElements = result.state === "repaired-parse" && outerValue.elements.length > 0 ? outerValue.elements.slice(0, -1) : outerValue.elements;
|
|
3988
4090
|
const parsedElements = [];
|
|
3989
4091
|
for (const rawElement of rawElements) {
|
|
3990
|
-
const validationResult = await
|
|
4092
|
+
const validationResult = await safeValidateTypes4({
|
|
3991
4093
|
value: rawElement,
|
|
3992
4094
|
schema: elementSchema
|
|
3993
4095
|
});
|
|
@@ -4012,6 +4114,12 @@ var array = ({
|
|
|
4012
4114
|
});
|
|
4013
4115
|
}
|
|
4014
4116
|
};
|
|
4117
|
+
const parsePartialOutput = output.parsePartialOutput;
|
|
4118
|
+
arrayStreamParserFactories.set(
|
|
4119
|
+
output,
|
|
4120
|
+
() => output.parsePartialOutput === parsePartialOutput ? createArrayOutputStreamParser(elementSchema, true) : void 0
|
|
4121
|
+
);
|
|
4122
|
+
return output;
|
|
4015
4123
|
};
|
|
4016
4124
|
var choice = ({
|
|
4017
4125
|
options: choiceOptions,
|
|
@@ -4036,29 +4144,25 @@ var choice = ({
|
|
|
4036
4144
|
...description != null && { description }
|
|
4037
4145
|
}),
|
|
4038
4146
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
4039
|
-
const parseResult = await
|
|
4147
|
+
const parseResult = await safeParseJSON3({ text: text2 });
|
|
4040
4148
|
if (!parseResult.success) {
|
|
4041
4149
|
throw new NoObjectGeneratedError({
|
|
4150
|
+
...context2,
|
|
4042
4151
|
message: "No object generated: could not parse the response.",
|
|
4043
4152
|
cause: parseResult.error,
|
|
4044
|
-
text: text2
|
|
4045
|
-
response: context2.response,
|
|
4046
|
-
usage: context2.usage,
|
|
4047
|
-
finishReason: context2.finishReason
|
|
4153
|
+
text: text2
|
|
4048
4154
|
});
|
|
4049
4155
|
}
|
|
4050
4156
|
const outerValue = parseResult.value;
|
|
4051
4157
|
if (outerValue == null || typeof outerValue !== "object" || !("result" in outerValue) || typeof outerValue.result !== "string" || !choiceOptions.includes(outerValue.result)) {
|
|
4052
4158
|
throw new NoObjectGeneratedError({
|
|
4159
|
+
...context2,
|
|
4053
4160
|
message: "No object generated: response did not match schema.",
|
|
4054
4161
|
cause: new TypeValidationError2({
|
|
4055
4162
|
value: outerValue,
|
|
4056
4163
|
cause: "response must be an object that contains a choice value."
|
|
4057
4164
|
}),
|
|
4058
|
-
text: text2
|
|
4059
|
-
response: context2.response,
|
|
4060
|
-
usage: context2.usage,
|
|
4061
|
-
finishReason: context2.finishReason
|
|
4165
|
+
text: text2
|
|
4062
4166
|
});
|
|
4063
4167
|
}
|
|
4064
4168
|
return outerValue.result;
|
|
@@ -4104,15 +4208,13 @@ var json = ({
|
|
|
4104
4208
|
...description != null && { description }
|
|
4105
4209
|
}),
|
|
4106
4210
|
async parseCompleteOutput({ text: text2 }, context2) {
|
|
4107
|
-
const parseResult = await
|
|
4211
|
+
const parseResult = await safeParseJSON3({ text: text2 });
|
|
4108
4212
|
if (!parseResult.success) {
|
|
4109
4213
|
throw new NoObjectGeneratedError({
|
|
4214
|
+
...context2,
|
|
4110
4215
|
message: "No object generated: could not parse the response.",
|
|
4111
4216
|
cause: parseResult.error,
|
|
4112
|
-
text: text2
|
|
4113
|
-
response: context2.response,
|
|
4114
|
-
usage: context2.usage,
|
|
4115
|
-
finishReason: context2.finishReason
|
|
4217
|
+
text: text2
|
|
4116
4218
|
});
|
|
4117
4219
|
}
|
|
4118
4220
|
return parseResult.value;
|
|
@@ -4139,8 +4241,8 @@ var json = ({
|
|
|
4139
4241
|
// src/generate-text/parse-tool-call.ts
|
|
4140
4242
|
import {
|
|
4141
4243
|
asSchema as asSchema4,
|
|
4142
|
-
safeParseJSON as
|
|
4143
|
-
safeValidateTypes as
|
|
4244
|
+
safeParseJSON as safeParseJSON4,
|
|
4245
|
+
safeValidateTypes as safeValidateTypes5
|
|
4144
4246
|
} from "@ai-sdk/provider-utils";
|
|
4145
4247
|
|
|
4146
4248
|
// src/generate-text/tool-call.ts
|
|
@@ -4203,7 +4305,7 @@ async function parseToolCall({
|
|
|
4203
4305
|
return await doParseToolCall({ toolCall: repairedToolCall, tools });
|
|
4204
4306
|
}
|
|
4205
4307
|
} catch (error) {
|
|
4206
|
-
const parsedInput = await
|
|
4308
|
+
const parsedInput = await safeParseJSON4({ text: toolCall.input });
|
|
4207
4309
|
const input = parsedInput.success ? parsedInput.value : toolCall.input;
|
|
4208
4310
|
const tool2 = tools == null ? void 0 : tools[toolCall.toolName];
|
|
4209
4311
|
return {
|
|
@@ -4222,7 +4324,7 @@ async function parseToolCall({
|
|
|
4222
4324
|
}
|
|
4223
4325
|
}
|
|
4224
4326
|
async function parseProviderExecutedDynamicToolCall(toolCall) {
|
|
4225
|
-
const parseResult = toolCall.input.trim() === "" ? { success: true, value: {} } : await
|
|
4327
|
+
const parseResult = toolCall.input.trim() === "" ? { success: true, value: {} } : await safeParseJSON4({ text: toolCall.input });
|
|
4226
4328
|
if (parseResult.success === false) {
|
|
4227
4329
|
throw new InvalidToolInputError({
|
|
4228
4330
|
toolName: toolCall.toolName,
|
|
@@ -4256,7 +4358,7 @@ async function doParseToolCall({
|
|
|
4256
4358
|
});
|
|
4257
4359
|
}
|
|
4258
4360
|
const schema = asSchema4(tool2.inputSchema);
|
|
4259
|
-
const parseResult = toolCall.input.trim() === "" ? await
|
|
4361
|
+
const parseResult = toolCall.input.trim() === "" ? await safeValidateTypes5({ value: {}, schema }) : await safeParseJSON4({ text: toolCall.input, schema });
|
|
4260
4362
|
if (parseResult.success === false) {
|
|
4261
4363
|
throw new InvalidToolInputError({
|
|
4262
4364
|
toolName,
|
|
@@ -7570,9 +7672,13 @@ function createOutputTransformStream(output) {
|
|
|
7570
7672
|
let text2 = "";
|
|
7571
7673
|
let textChunk = "";
|
|
7572
7674
|
let textProviderMetadata = void 0;
|
|
7675
|
+
let arrayStreamParser = createArrayStreamParser(output);
|
|
7676
|
+
let lastArrayPartial;
|
|
7573
7677
|
let lastPublishedValue = void 0;
|
|
7574
7678
|
let hasPublishedValue = false;
|
|
7575
7679
|
function resetOutputState() {
|
|
7680
|
+
arrayStreamParser = createArrayStreamParser(output);
|
|
7681
|
+
lastArrayPartial = void 0;
|
|
7576
7682
|
firstTextChunkId = void 0;
|
|
7577
7683
|
text2 = "";
|
|
7578
7684
|
textChunk = "";
|
|
@@ -7631,6 +7737,21 @@ function createOutputTransformStream(output) {
|
|
|
7631
7737
|
controller.enqueue({ part: chunk, partialOutput: void 0 });
|
|
7632
7738
|
return;
|
|
7633
7739
|
}
|
|
7740
|
+
if (arrayStreamParser != null) {
|
|
7741
|
+
const result2 = await arrayStreamParser(chunk.text);
|
|
7742
|
+
if (result2 !== "fallback") {
|
|
7743
|
+
if (result2 != null) {
|
|
7744
|
+
lastArrayPartial = result2.partial;
|
|
7745
|
+
publishTextChunk({ controller, partialOutput: lastArrayPartial });
|
|
7746
|
+
}
|
|
7747
|
+
return;
|
|
7748
|
+
}
|
|
7749
|
+
arrayStreamParser = void 0;
|
|
7750
|
+
if (lastArrayPartial != null) {
|
|
7751
|
+
lastPublishedValue = JSON.stringify(lastArrayPartial);
|
|
7752
|
+
hasPublishedValue = true;
|
|
7753
|
+
}
|
|
7754
|
+
}
|
|
7634
7755
|
const result = await output.parsePartialOutput({ text: text2 });
|
|
7635
7756
|
if (result !== void 0) {
|
|
7636
7757
|
const currentValue = typeof result.partial === "string" ? result.partial : JSON.stringify(result.partial);
|
|
@@ -9051,9 +9172,21 @@ var DefaultStreamTextResult = class {
|
|
|
9051
9172
|
sendSources = false,
|
|
9052
9173
|
sendStart = true,
|
|
9053
9174
|
sendFinish = true,
|
|
9054
|
-
onError
|
|
9055
|
-
|
|
9175
|
+
onError: onErrorOption,
|
|
9176
|
+
redactToolErrors = onErrorOption != null
|
|
9056
9177
|
} = {}) {
|
|
9178
|
+
const onError = onErrorOption != null ? onErrorOption : () => "An error occurred.";
|
|
9179
|
+
const getToolErrorText = (error) => {
|
|
9180
|
+
var _a23;
|
|
9181
|
+
if (redactToolErrors) {
|
|
9182
|
+
return onError(error);
|
|
9183
|
+
}
|
|
9184
|
+
try {
|
|
9185
|
+
return (_a23 = getErrorMessage6(error)) != null ? _a23 : onError(error);
|
|
9186
|
+
} catch (e) {
|
|
9187
|
+
return onError(error);
|
|
9188
|
+
}
|
|
9189
|
+
};
|
|
9057
9190
|
let outcome = { status: "unknown" };
|
|
9058
9191
|
let hasFatalFailure = false;
|
|
9059
9192
|
const setSourceOutcome = (newOutcome) => {
|
|
@@ -9240,7 +9373,7 @@ var DefaultStreamTextResult = class {
|
|
|
9240
9373
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
9241
9374
|
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
9242
9375
|
...dynamic != null ? { dynamic } : {},
|
|
9243
|
-
errorText: onError(part.error),
|
|
9376
|
+
errorText: part.providerExecuted ? onError(part.error) : getToolErrorText(part.error),
|
|
9244
9377
|
...part.title != null ? { title: part.title } : {}
|
|
9245
9378
|
});
|
|
9246
9379
|
} else {
|
|
@@ -9292,7 +9425,7 @@ var DefaultStreamTextResult = class {
|
|
|
9292
9425
|
controller.enqueue({
|
|
9293
9426
|
type: "tool-output-error",
|
|
9294
9427
|
toolCallId: part.toolCallId,
|
|
9295
|
-
errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) :
|
|
9428
|
+
errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) : getToolErrorText(part.error),
|
|
9296
9429
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
9297
9430
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
9298
9431
|
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|
|
@@ -9395,6 +9528,7 @@ var DefaultStreamTextResult = class {
|
|
|
9395
9528
|
sendFinish,
|
|
9396
9529
|
sendStart,
|
|
9397
9530
|
onError,
|
|
9531
|
+
redactToolErrors,
|
|
9398
9532
|
...init
|
|
9399
9533
|
} = {}) {
|
|
9400
9534
|
return pipeUIMessageStreamToResponse({
|
|
@@ -9408,7 +9542,8 @@ var DefaultStreamTextResult = class {
|
|
|
9408
9542
|
sendSources,
|
|
9409
9543
|
sendFinish,
|
|
9410
9544
|
sendStart,
|
|
9411
|
-
onError
|
|
9545
|
+
onError,
|
|
9546
|
+
redactToolErrors
|
|
9412
9547
|
}),
|
|
9413
9548
|
...init
|
|
9414
9549
|
});
|
|
@@ -9430,6 +9565,7 @@ var DefaultStreamTextResult = class {
|
|
|
9430
9565
|
sendFinish,
|
|
9431
9566
|
sendStart,
|
|
9432
9567
|
onError,
|
|
9568
|
+
redactToolErrors,
|
|
9433
9569
|
...init
|
|
9434
9570
|
} = {}) {
|
|
9435
9571
|
return createUIMessageStreamResponse({
|
|
@@ -9442,7 +9578,8 @@ var DefaultStreamTextResult = class {
|
|
|
9442
9578
|
sendSources,
|
|
9443
9579
|
sendFinish,
|
|
9444
9580
|
sendStart,
|
|
9445
|
-
onError
|
|
9581
|
+
onError,
|
|
9582
|
+
redactToolErrors
|
|
9446
9583
|
}),
|
|
9447
9584
|
...init
|
|
9448
9585
|
});
|
|
@@ -10038,15 +10175,67 @@ import {
|
|
|
10038
10175
|
} from "@ai-sdk/provider";
|
|
10039
10176
|
import {
|
|
10040
10177
|
lazySchema as lazySchema2,
|
|
10041
|
-
safeValidateTypes as
|
|
10178
|
+
safeValidateTypes as safeValidateTypes6,
|
|
10042
10179
|
validateTypes as validateTypes3,
|
|
10043
10180
|
zodSchema as zodSchema2
|
|
10044
10181
|
} from "@ai-sdk/provider-utils";
|
|
10045
10182
|
import { z as z8 } from "zod/v4";
|
|
10046
|
-
|
|
10183
|
+
function findInvalidJsonValuePath(value, path = [], visited = /* @__PURE__ */ new WeakSet()) {
|
|
10184
|
+
switch (typeof value) {
|
|
10185
|
+
case "number":
|
|
10186
|
+
return Number.isFinite(value) ? void 0 : [...path];
|
|
10187
|
+
case "bigint":
|
|
10188
|
+
case "symbol":
|
|
10189
|
+
case "function":
|
|
10190
|
+
return [...path];
|
|
10191
|
+
case "object": {
|
|
10192
|
+
if (value === null || visited.has(value)) {
|
|
10193
|
+
return void 0;
|
|
10194
|
+
}
|
|
10195
|
+
visited.add(value);
|
|
10196
|
+
const keys = Array.isArray(value) ? value.keys() : Object.keys(value);
|
|
10197
|
+
for (const key of keys) {
|
|
10198
|
+
if (key === "__proto__")
|
|
10199
|
+
continue;
|
|
10200
|
+
path.push(key);
|
|
10201
|
+
const invalidPath = findInvalidJsonValuePath(
|
|
10202
|
+
value[key],
|
|
10203
|
+
path,
|
|
10204
|
+
visited
|
|
10205
|
+
);
|
|
10206
|
+
if (invalidPath != null)
|
|
10207
|
+
return invalidPath;
|
|
10208
|
+
path.pop();
|
|
10209
|
+
}
|
|
10210
|
+
return void 0;
|
|
10211
|
+
}
|
|
10212
|
+
default:
|
|
10213
|
+
return void 0;
|
|
10214
|
+
}
|
|
10215
|
+
}
|
|
10216
|
+
function withJsonValueCheck(schema, jsonValuePath = []) {
|
|
10217
|
+
return z8.unknown().check((context2) => {
|
|
10218
|
+
let jsonValue = context2.value;
|
|
10219
|
+
for (const key of jsonValuePath) {
|
|
10220
|
+
jsonValue = jsonValue != null && typeof jsonValue === "object" ? jsonValue[key] : void 0;
|
|
10221
|
+
}
|
|
10222
|
+
const invalidPath = findInvalidJsonValuePath(jsonValue);
|
|
10223
|
+
if (invalidPath != null) {
|
|
10224
|
+
context2.issues.push({
|
|
10225
|
+
code: "custom",
|
|
10226
|
+
message: "Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.",
|
|
10227
|
+
input: context2.value,
|
|
10228
|
+
path: [...jsonValuePath, ...invalidPath]
|
|
10229
|
+
});
|
|
10230
|
+
}
|
|
10231
|
+
}).pipe(schema);
|
|
10232
|
+
}
|
|
10233
|
+
var toolMetadataRecordSchema = z8.record(
|
|
10047
10234
|
z8.string(),
|
|
10048
10235
|
jsonValueSchema.optional()
|
|
10049
10236
|
);
|
|
10237
|
+
var toolMetadataSchema2 = withJsonValueCheck(toolMetadataRecordSchema);
|
|
10238
|
+
var providerMetadataSchema2 = withJsonValueCheck(providerMetadataSchema);
|
|
10050
10239
|
function isEmptyObject(value) {
|
|
10051
10240
|
return value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
10052
10241
|
}
|
|
@@ -10061,6 +10250,25 @@ function asDynamicToolPart(toolPart) {
|
|
|
10061
10250
|
function getToolPartInputSchemaInput(toolPart) {
|
|
10062
10251
|
return toolPart.approval != null && Object.prototype.hasOwnProperty.call(toolPart.approval, "inputSchemaInput") ? { value: toolPart.approval.inputSchemaInput } : void 0;
|
|
10063
10252
|
}
|
|
10253
|
+
function arrayUntilFirstInvalidElement(selectElementSchema) {
|
|
10254
|
+
return z8.array(z8.unknown()).transform((elements, context2) => {
|
|
10255
|
+
const validatedElements = [];
|
|
10256
|
+
for (const [index, element] of elements.entries()) {
|
|
10257
|
+
const result = selectElementSchema(element).safeParse(element);
|
|
10258
|
+
if (!result.success) {
|
|
10259
|
+
for (const issue of result.error.issues) {
|
|
10260
|
+
context2.issues.push({
|
|
10261
|
+
...issue,
|
|
10262
|
+
path: [index, ...issue.path]
|
|
10263
|
+
});
|
|
10264
|
+
}
|
|
10265
|
+
return z8.NEVER;
|
|
10266
|
+
}
|
|
10267
|
+
validatedElements.push(result.data);
|
|
10268
|
+
}
|
|
10269
|
+
return validatedElements;
|
|
10270
|
+
});
|
|
10271
|
+
}
|
|
10064
10272
|
var uiMessagesSchema = lazySchema2(() => {
|
|
10065
10273
|
const approvalRequestedSchema = z8.object({
|
|
10066
10274
|
id: z8.string(),
|
|
@@ -10080,267 +10288,292 @@ var uiMessagesSchema = lazySchema2(() => {
|
|
|
10080
10288
|
const approvalDeniedSchema = approvalRespondedSchema.extend({
|
|
10081
10289
|
approved: z8.literal(false)
|
|
10082
10290
|
});
|
|
10083
|
-
|
|
10084
|
-
|
|
10291
|
+
const invalidPartTypeMessage = 'Invalid UI message part type. Expected a known part type (for example "text" or "dynamic-tool") or a type starting with "data-" or "tool-".';
|
|
10292
|
+
const staticPartSchema = z8.discriminatedUnion(
|
|
10293
|
+
"type",
|
|
10294
|
+
[
|
|
10085
10295
|
z8.object({
|
|
10086
|
-
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
filename: z8.string().optional(),
|
|
10123
|
-
url: z8.string(),
|
|
10124
|
-
providerMetadata: providerMetadataSchema.optional()
|
|
10125
|
-
}),
|
|
10126
|
-
z8.object({
|
|
10127
|
-
type: z8.literal("step-start")
|
|
10128
|
-
}),
|
|
10129
|
-
z8.object({
|
|
10130
|
-
type: z8.string().startsWith("data-"),
|
|
10131
|
-
id: z8.string().optional(),
|
|
10132
|
-
data: z8.unknown()
|
|
10133
|
-
}),
|
|
10134
|
-
z8.object({
|
|
10135
|
-
type: z8.literal("dynamic-tool"),
|
|
10136
|
-
dynamic: z8.literal(false).optional(),
|
|
10137
|
-
toolName: z8.string(),
|
|
10138
|
-
toolCallId: z8.string(),
|
|
10139
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10140
|
-
state: z8.literal("input-streaming"),
|
|
10141
|
-
input: z8.unknown().optional(),
|
|
10142
|
-
rawInput: z8.string().optional(),
|
|
10143
|
-
inputEncoding: z8.enum(["json", "text"]).optional(),
|
|
10144
|
-
providerExecuted: z8.boolean().optional(),
|
|
10145
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10146
|
-
output: z8.never().optional(),
|
|
10147
|
-
errorText: z8.never().optional(),
|
|
10148
|
-
approval: z8.never().optional()
|
|
10149
|
-
}),
|
|
10150
|
-
z8.object({
|
|
10151
|
-
type: z8.literal("dynamic-tool"),
|
|
10152
|
-
dynamic: z8.literal(false).optional(),
|
|
10153
|
-
toolName: z8.string(),
|
|
10154
|
-
toolCallId: z8.string(),
|
|
10155
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10156
|
-
state: z8.literal("input-available"),
|
|
10157
|
-
input: z8.unknown(),
|
|
10158
|
-
providerExecuted: z8.boolean().optional(),
|
|
10159
|
-
output: z8.never().optional(),
|
|
10160
|
-
errorText: z8.never().optional(),
|
|
10161
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10162
|
-
approval: z8.never().optional()
|
|
10163
|
-
}),
|
|
10164
|
-
z8.object({
|
|
10165
|
-
type: z8.literal("dynamic-tool"),
|
|
10166
|
-
dynamic: z8.literal(false).optional(),
|
|
10167
|
-
toolName: z8.string(),
|
|
10168
|
-
toolCallId: z8.string(),
|
|
10169
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10170
|
-
state: z8.literal("approval-requested"),
|
|
10171
|
-
input: z8.unknown(),
|
|
10172
|
-
providerExecuted: z8.boolean().optional(),
|
|
10173
|
-
output: z8.never().optional(),
|
|
10174
|
-
errorText: z8.never().optional(),
|
|
10175
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10176
|
-
approval: approvalRequestedSchema
|
|
10177
|
-
}),
|
|
10178
|
-
z8.object({
|
|
10179
|
-
type: z8.literal("dynamic-tool"),
|
|
10180
|
-
dynamic: z8.literal(false).optional(),
|
|
10181
|
-
toolName: z8.string(),
|
|
10182
|
-
toolCallId: z8.string(),
|
|
10183
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10184
|
-
state: z8.literal("approval-responded"),
|
|
10185
|
-
input: z8.unknown(),
|
|
10186
|
-
providerExecuted: z8.boolean().optional(),
|
|
10187
|
-
output: z8.never().optional(),
|
|
10188
|
-
errorText: z8.never().optional(),
|
|
10189
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10190
|
-
approval: approvalRespondedSchema
|
|
10191
|
-
}),
|
|
10192
|
-
z8.object({
|
|
10193
|
-
type: z8.literal("dynamic-tool"),
|
|
10194
|
-
dynamic: z8.literal(false).optional(),
|
|
10195
|
-
toolName: z8.string(),
|
|
10196
|
-
toolCallId: z8.string(),
|
|
10197
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10198
|
-
state: z8.literal("output-available"),
|
|
10199
|
-
input: z8.unknown(),
|
|
10200
|
-
providerExecuted: z8.boolean().optional(),
|
|
10201
|
-
output: z8.unknown(),
|
|
10202
|
-
errorText: z8.never().optional(),
|
|
10203
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10204
|
-
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
10205
|
-
preliminary: z8.boolean().optional(),
|
|
10206
|
-
approval: approvalGrantedSchema.optional()
|
|
10207
|
-
}),
|
|
10208
|
-
z8.object({
|
|
10209
|
-
type: z8.literal("dynamic-tool"),
|
|
10210
|
-
dynamic: z8.literal(false).optional(),
|
|
10211
|
-
toolName: z8.string(),
|
|
10212
|
-
toolCallId: z8.string(),
|
|
10213
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10214
|
-
state: z8.literal("output-error"),
|
|
10215
|
-
input: z8.unknown().optional(),
|
|
10216
|
-
rawInput: z8.unknown().optional(),
|
|
10217
|
-
providerExecuted: z8.boolean().optional(),
|
|
10218
|
-
output: z8.never().optional(),
|
|
10219
|
-
errorText: z8.string(),
|
|
10220
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10221
|
-
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
10222
|
-
approval: approvalGrantedSchema.optional()
|
|
10223
|
-
}),
|
|
10224
|
-
z8.object({
|
|
10225
|
-
type: z8.literal("dynamic-tool"),
|
|
10226
|
-
dynamic: z8.literal(false).optional(),
|
|
10227
|
-
toolName: z8.string(),
|
|
10228
|
-
toolCallId: z8.string(),
|
|
10229
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10230
|
-
state: z8.literal("output-denied"),
|
|
10231
|
-
input: z8.unknown(),
|
|
10232
|
-
providerExecuted: z8.boolean().optional(),
|
|
10233
|
-
output: z8.never().optional(),
|
|
10234
|
-
errorText: z8.never().optional(),
|
|
10235
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10236
|
-
approval: approvalDeniedSchema
|
|
10237
|
-
}),
|
|
10238
|
-
z8.object({
|
|
10239
|
-
type: z8.string().startsWith("tool-"),
|
|
10240
|
-
toolCallId: z8.string(),
|
|
10241
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10242
|
-
state: z8.literal("input-streaming"),
|
|
10243
|
-
providerExecuted: z8.boolean().optional(),
|
|
10244
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10245
|
-
input: z8.unknown().optional(),
|
|
10246
|
-
rawInput: z8.string().optional(),
|
|
10247
|
-
inputEncoding: z8.enum(["json", "text"]).optional(),
|
|
10248
|
-
output: z8.never().optional(),
|
|
10249
|
-
errorText: z8.never().optional(),
|
|
10250
|
-
approval: z8.never().optional()
|
|
10251
|
-
}),
|
|
10252
|
-
z8.object({
|
|
10253
|
-
type: z8.string().startsWith("tool-"),
|
|
10254
|
-
toolCallId: z8.string(),
|
|
10255
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10256
|
-
state: z8.literal("input-available"),
|
|
10257
|
-
providerExecuted: z8.boolean().optional(),
|
|
10258
|
-
input: z8.unknown(),
|
|
10259
|
-
output: z8.never().optional(),
|
|
10260
|
-
errorText: z8.never().optional(),
|
|
10261
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10262
|
-
approval: z8.never().optional()
|
|
10263
|
-
}),
|
|
10264
|
-
z8.object({
|
|
10265
|
-
type: z8.string().startsWith("tool-"),
|
|
10266
|
-
toolCallId: z8.string(),
|
|
10267
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10268
|
-
state: z8.literal("approval-requested"),
|
|
10269
|
-
input: z8.unknown(),
|
|
10270
|
-
providerExecuted: z8.boolean().optional(),
|
|
10271
|
-
output: z8.never().optional(),
|
|
10272
|
-
errorText: z8.never().optional(),
|
|
10273
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10274
|
-
approval: approvalRequestedSchema
|
|
10275
|
-
}),
|
|
10276
|
-
z8.object({
|
|
10277
|
-
type: z8.string().startsWith("tool-"),
|
|
10278
|
-
toolCallId: z8.string(),
|
|
10279
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10280
|
-
state: z8.literal("approval-responded"),
|
|
10281
|
-
input: z8.unknown(),
|
|
10282
|
-
providerExecuted: z8.boolean().optional(),
|
|
10283
|
-
output: z8.never().optional(),
|
|
10284
|
-
errorText: z8.never().optional(),
|
|
10285
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10286
|
-
approval: approvalRespondedSchema
|
|
10287
|
-
}),
|
|
10288
|
-
z8.object({
|
|
10289
|
-
type: z8.string().startsWith("tool-"),
|
|
10290
|
-
toolCallId: z8.string(),
|
|
10291
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10292
|
-
state: z8.literal("output-available"),
|
|
10293
|
-
providerExecuted: z8.boolean().optional(),
|
|
10294
|
-
input: z8.unknown(),
|
|
10295
|
-
output: z8.unknown(),
|
|
10296
|
-
errorText: z8.never().optional(),
|
|
10297
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10298
|
-
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
10299
|
-
preliminary: z8.boolean().optional(),
|
|
10300
|
-
approval: approvalGrantedSchema.optional()
|
|
10301
|
-
}),
|
|
10302
|
-
z8.object({
|
|
10303
|
-
type: z8.string().startsWith("tool-"),
|
|
10304
|
-
toolCallId: z8.string(),
|
|
10305
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10306
|
-
state: z8.literal("output-error"),
|
|
10307
|
-
providerExecuted: z8.boolean().optional(),
|
|
10308
|
-
input: z8.unknown().optional(),
|
|
10309
|
-
rawInput: z8.unknown().optional(),
|
|
10310
|
-
output: z8.never().optional(),
|
|
10311
|
-
errorText: z8.string(),
|
|
10312
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10313
|
-
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
10314
|
-
approval: approvalGrantedSchema.optional()
|
|
10315
|
-
}),
|
|
10316
|
-
z8.object({
|
|
10317
|
-
type: z8.string().startsWith("tool-"),
|
|
10318
|
-
toolCallId: z8.string(),
|
|
10319
|
-
toolMetadata: toolMetadataSchema2.optional(),
|
|
10320
|
-
state: z8.literal("output-denied"),
|
|
10321
|
-
providerExecuted: z8.boolean().optional(),
|
|
10322
|
-
input: z8.unknown(),
|
|
10323
|
-
output: z8.never().optional(),
|
|
10324
|
-
errorText: z8.never().optional(),
|
|
10325
|
-
callProviderMetadata: providerMetadataSchema.optional(),
|
|
10326
|
-
approval: approvalDeniedSchema
|
|
10327
|
-
})
|
|
10328
|
-
])
|
|
10329
|
-
)
|
|
10330
|
-
}).superRefine((message, context2) => {
|
|
10331
|
-
if (message.role !== "assistant" && message.parts.length === 0) {
|
|
10332
|
-
context2.addIssue({
|
|
10333
|
-
origin: "array",
|
|
10334
|
-
code: "too_small",
|
|
10335
|
-
minimum: 1,
|
|
10336
|
-
inclusive: true,
|
|
10337
|
-
input: message.parts,
|
|
10338
|
-
path: ["parts"],
|
|
10339
|
-
message: "Message must contain at least one part"
|
|
10340
|
-
});
|
|
10341
|
-
}
|
|
10296
|
+
type: z8.literal("text"),
|
|
10297
|
+
text: z8.string(),
|
|
10298
|
+
state: z8.enum(["streaming", "done"]).optional(),
|
|
10299
|
+
providerMetadata: providerMetadataSchema2.optional()
|
|
10300
|
+
}),
|
|
10301
|
+
z8.object({
|
|
10302
|
+
type: z8.literal("reasoning"),
|
|
10303
|
+
id: z8.string().optional(),
|
|
10304
|
+
text: z8.string(),
|
|
10305
|
+
state: z8.enum(["streaming", "done"]).optional(),
|
|
10306
|
+
providerMetadata: providerMetadataSchema2.optional()
|
|
10307
|
+
}),
|
|
10308
|
+
z8.object({
|
|
10309
|
+
type: z8.literal("source-url"),
|
|
10310
|
+
sourceId: z8.string(),
|
|
10311
|
+
url: z8.string(),
|
|
10312
|
+
title: z8.string().optional(),
|
|
10313
|
+
providerMetadata: providerMetadataSchema2.optional()
|
|
10314
|
+
}),
|
|
10315
|
+
z8.object({
|
|
10316
|
+
type: z8.literal("source-document"),
|
|
10317
|
+
sourceId: z8.string(),
|
|
10318
|
+
mediaType: z8.string(),
|
|
10319
|
+
title: z8.string(),
|
|
10320
|
+
filename: z8.string().optional(),
|
|
10321
|
+
providerMetadata: providerMetadataSchema2.optional()
|
|
10322
|
+
}),
|
|
10323
|
+
z8.object({
|
|
10324
|
+
type: z8.literal("file"),
|
|
10325
|
+
mediaType: z8.string(),
|
|
10326
|
+
filename: z8.string().optional(),
|
|
10327
|
+
url: z8.string(),
|
|
10328
|
+
providerMetadata: providerMetadataSchema2.optional()
|
|
10329
|
+
}),
|
|
10330
|
+
z8.object({
|
|
10331
|
+
type: z8.literal("step-start")
|
|
10342
10332
|
})
|
|
10343
|
-
|
|
10333
|
+
],
|
|
10334
|
+
{
|
|
10335
|
+
error: (issue) => issue.code === "invalid_union" ? invalidPartTypeMessage : void 0
|
|
10336
|
+
}
|
|
10337
|
+
);
|
|
10338
|
+
const dataPartSchema = z8.object({
|
|
10339
|
+
type: z8.string().startsWith("data-"),
|
|
10340
|
+
id: z8.string().optional(),
|
|
10341
|
+
data: z8.unknown()
|
|
10342
|
+
});
|
|
10343
|
+
const dynamicToolPartSchema = z8.discriminatedUnion("state", [
|
|
10344
|
+
z8.object({
|
|
10345
|
+
type: z8.literal("dynamic-tool"),
|
|
10346
|
+
dynamic: z8.literal(false).optional(),
|
|
10347
|
+
toolName: z8.string(),
|
|
10348
|
+
toolCallId: z8.string(),
|
|
10349
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10350
|
+
state: z8.literal("input-streaming"),
|
|
10351
|
+
input: z8.unknown().optional(),
|
|
10352
|
+
rawInput: z8.string().optional(),
|
|
10353
|
+
inputEncoding: z8.enum(["json", "text"]).optional(),
|
|
10354
|
+
providerExecuted: z8.boolean().optional(),
|
|
10355
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10356
|
+
output: z8.never().optional(),
|
|
10357
|
+
errorText: z8.never().optional(),
|
|
10358
|
+
approval: z8.never().optional()
|
|
10359
|
+
}),
|
|
10360
|
+
z8.object({
|
|
10361
|
+
type: z8.literal("dynamic-tool"),
|
|
10362
|
+
dynamic: z8.literal(false).optional(),
|
|
10363
|
+
toolName: z8.string(),
|
|
10364
|
+
toolCallId: z8.string(),
|
|
10365
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10366
|
+
state: z8.literal("input-available"),
|
|
10367
|
+
input: z8.unknown(),
|
|
10368
|
+
providerExecuted: z8.boolean().optional(),
|
|
10369
|
+
output: z8.never().optional(),
|
|
10370
|
+
errorText: z8.never().optional(),
|
|
10371
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10372
|
+
approval: z8.never().optional()
|
|
10373
|
+
}),
|
|
10374
|
+
z8.object({
|
|
10375
|
+
type: z8.literal("dynamic-tool"),
|
|
10376
|
+
dynamic: z8.literal(false).optional(),
|
|
10377
|
+
toolName: z8.string(),
|
|
10378
|
+
toolCallId: z8.string(),
|
|
10379
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10380
|
+
state: z8.literal("approval-requested"),
|
|
10381
|
+
input: z8.unknown(),
|
|
10382
|
+
providerExecuted: z8.boolean().optional(),
|
|
10383
|
+
output: z8.never().optional(),
|
|
10384
|
+
errorText: z8.never().optional(),
|
|
10385
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10386
|
+
approval: approvalRequestedSchema
|
|
10387
|
+
}),
|
|
10388
|
+
z8.object({
|
|
10389
|
+
type: z8.literal("dynamic-tool"),
|
|
10390
|
+
dynamic: z8.literal(false).optional(),
|
|
10391
|
+
toolName: z8.string(),
|
|
10392
|
+
toolCallId: z8.string(),
|
|
10393
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10394
|
+
state: z8.literal("approval-responded"),
|
|
10395
|
+
input: z8.unknown(),
|
|
10396
|
+
providerExecuted: z8.boolean().optional(),
|
|
10397
|
+
output: z8.never().optional(),
|
|
10398
|
+
errorText: z8.never().optional(),
|
|
10399
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10400
|
+
approval: approvalRespondedSchema
|
|
10401
|
+
}),
|
|
10402
|
+
z8.object({
|
|
10403
|
+
type: z8.literal("dynamic-tool"),
|
|
10404
|
+
dynamic: z8.literal(false).optional(),
|
|
10405
|
+
toolName: z8.string(),
|
|
10406
|
+
toolCallId: z8.string(),
|
|
10407
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10408
|
+
state: z8.literal("output-available"),
|
|
10409
|
+
input: z8.unknown(),
|
|
10410
|
+
providerExecuted: z8.boolean().optional(),
|
|
10411
|
+
output: z8.unknown(),
|
|
10412
|
+
errorText: z8.never().optional(),
|
|
10413
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10414
|
+
resultProviderMetadata: providerMetadataSchema2.optional(),
|
|
10415
|
+
preliminary: z8.boolean().optional(),
|
|
10416
|
+
approval: approvalGrantedSchema.optional()
|
|
10417
|
+
}),
|
|
10418
|
+
z8.object({
|
|
10419
|
+
type: z8.literal("dynamic-tool"),
|
|
10420
|
+
dynamic: z8.literal(false).optional(),
|
|
10421
|
+
toolName: z8.string(),
|
|
10422
|
+
toolCallId: z8.string(),
|
|
10423
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10424
|
+
state: z8.literal("output-error"),
|
|
10425
|
+
input: z8.unknown().optional(),
|
|
10426
|
+
rawInput: z8.unknown().optional(),
|
|
10427
|
+
providerExecuted: z8.boolean().optional(),
|
|
10428
|
+
output: z8.never().optional(),
|
|
10429
|
+
errorText: z8.string(),
|
|
10430
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10431
|
+
resultProviderMetadata: providerMetadataSchema2.optional(),
|
|
10432
|
+
approval: approvalGrantedSchema.optional()
|
|
10433
|
+
}),
|
|
10434
|
+
z8.object({
|
|
10435
|
+
type: z8.literal("dynamic-tool"),
|
|
10436
|
+
dynamic: z8.literal(false).optional(),
|
|
10437
|
+
toolName: z8.string(),
|
|
10438
|
+
toolCallId: z8.string(),
|
|
10439
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10440
|
+
state: z8.literal("output-denied"),
|
|
10441
|
+
input: z8.unknown(),
|
|
10442
|
+
providerExecuted: z8.boolean().optional(),
|
|
10443
|
+
output: z8.never().optional(),
|
|
10444
|
+
errorText: z8.never().optional(),
|
|
10445
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10446
|
+
approval: approvalDeniedSchema
|
|
10447
|
+
})
|
|
10448
|
+
]);
|
|
10449
|
+
const toolPartSchema = z8.discriminatedUnion("state", [
|
|
10450
|
+
z8.object({
|
|
10451
|
+
type: z8.string().startsWith("tool-"),
|
|
10452
|
+
toolCallId: z8.string(),
|
|
10453
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10454
|
+
state: z8.literal("input-streaming"),
|
|
10455
|
+
providerExecuted: z8.boolean().optional(),
|
|
10456
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10457
|
+
input: z8.unknown().optional(),
|
|
10458
|
+
rawInput: z8.string().optional(),
|
|
10459
|
+
inputEncoding: z8.enum(["json", "text"]).optional(),
|
|
10460
|
+
output: z8.never().optional(),
|
|
10461
|
+
errorText: z8.never().optional(),
|
|
10462
|
+
approval: z8.never().optional()
|
|
10463
|
+
}),
|
|
10464
|
+
z8.object({
|
|
10465
|
+
type: z8.string().startsWith("tool-"),
|
|
10466
|
+
toolCallId: z8.string(),
|
|
10467
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10468
|
+
state: z8.literal("input-available"),
|
|
10469
|
+
providerExecuted: z8.boolean().optional(),
|
|
10470
|
+
input: z8.unknown(),
|
|
10471
|
+
output: z8.never().optional(),
|
|
10472
|
+
errorText: z8.never().optional(),
|
|
10473
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10474
|
+
approval: z8.never().optional()
|
|
10475
|
+
}),
|
|
10476
|
+
z8.object({
|
|
10477
|
+
type: z8.string().startsWith("tool-"),
|
|
10478
|
+
toolCallId: z8.string(),
|
|
10479
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10480
|
+
state: z8.literal("approval-requested"),
|
|
10481
|
+
input: z8.unknown(),
|
|
10482
|
+
providerExecuted: z8.boolean().optional(),
|
|
10483
|
+
output: z8.never().optional(),
|
|
10484
|
+
errorText: z8.never().optional(),
|
|
10485
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10486
|
+
approval: approvalRequestedSchema
|
|
10487
|
+
}),
|
|
10488
|
+
z8.object({
|
|
10489
|
+
type: z8.string().startsWith("tool-"),
|
|
10490
|
+
toolCallId: z8.string(),
|
|
10491
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10492
|
+
state: z8.literal("approval-responded"),
|
|
10493
|
+
input: z8.unknown(),
|
|
10494
|
+
providerExecuted: z8.boolean().optional(),
|
|
10495
|
+
output: z8.never().optional(),
|
|
10496
|
+
errorText: z8.never().optional(),
|
|
10497
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10498
|
+
approval: approvalRespondedSchema
|
|
10499
|
+
}),
|
|
10500
|
+
z8.object({
|
|
10501
|
+
type: z8.string().startsWith("tool-"),
|
|
10502
|
+
toolCallId: z8.string(),
|
|
10503
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10504
|
+
state: z8.literal("output-available"),
|
|
10505
|
+
providerExecuted: z8.boolean().optional(),
|
|
10506
|
+
input: z8.unknown(),
|
|
10507
|
+
output: z8.unknown(),
|
|
10508
|
+
errorText: z8.never().optional(),
|
|
10509
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10510
|
+
resultProviderMetadata: providerMetadataSchema2.optional(),
|
|
10511
|
+
preliminary: z8.boolean().optional(),
|
|
10512
|
+
approval: approvalGrantedSchema.optional()
|
|
10513
|
+
}),
|
|
10514
|
+
z8.object({
|
|
10515
|
+
type: z8.string().startsWith("tool-"),
|
|
10516
|
+
toolCallId: z8.string(),
|
|
10517
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10518
|
+
state: z8.literal("output-error"),
|
|
10519
|
+
providerExecuted: z8.boolean().optional(),
|
|
10520
|
+
input: z8.unknown().optional(),
|
|
10521
|
+
rawInput: z8.unknown().optional(),
|
|
10522
|
+
output: z8.never().optional(),
|
|
10523
|
+
errorText: z8.string(),
|
|
10524
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10525
|
+
resultProviderMetadata: providerMetadataSchema2.optional(),
|
|
10526
|
+
approval: approvalGrantedSchema.optional()
|
|
10527
|
+
}),
|
|
10528
|
+
z8.object({
|
|
10529
|
+
type: z8.string().startsWith("tool-"),
|
|
10530
|
+
toolCallId: z8.string(),
|
|
10531
|
+
toolMetadata: toolMetadataSchema2.optional(),
|
|
10532
|
+
state: z8.literal("output-denied"),
|
|
10533
|
+
providerExecuted: z8.boolean().optional(),
|
|
10534
|
+
input: z8.unknown(),
|
|
10535
|
+
output: z8.never().optional(),
|
|
10536
|
+
errorText: z8.never().optional(),
|
|
10537
|
+
callProviderMetadata: providerMetadataSchema2.optional(),
|
|
10538
|
+
approval: approvalDeniedSchema
|
|
10539
|
+
})
|
|
10540
|
+
]);
|
|
10541
|
+
const messageSchema = z8.object({
|
|
10542
|
+
id: z8.string(),
|
|
10543
|
+
role: z8.enum(["system", "user", "assistant"]),
|
|
10544
|
+
metadata: z8.unknown().optional(),
|
|
10545
|
+
// Validate each part only against the schemas for its type. A union of
|
|
10546
|
+
// all part schemas would report the issues of every alternative for
|
|
10547
|
+
// each invalid part.
|
|
10548
|
+
parts: arrayUntilFirstInvalidElement((part) => {
|
|
10549
|
+
const type = part == null ? void 0 : part.type;
|
|
10550
|
+
if (typeof type === "string") {
|
|
10551
|
+
if (type.startsWith("data-"))
|
|
10552
|
+
return dataPartSchema;
|
|
10553
|
+
if (type.startsWith("tool-"))
|
|
10554
|
+
return toolPartSchema;
|
|
10555
|
+
if (type === "dynamic-tool")
|
|
10556
|
+
return dynamicToolPartSchema;
|
|
10557
|
+
}
|
|
10558
|
+
return staticPartSchema;
|
|
10559
|
+
})
|
|
10560
|
+
}).superRefine((message, context2) => {
|
|
10561
|
+
if (message.role !== "assistant" && message.parts.length === 0) {
|
|
10562
|
+
context2.addIssue({
|
|
10563
|
+
origin: "array",
|
|
10564
|
+
code: "too_small",
|
|
10565
|
+
minimum: 1,
|
|
10566
|
+
inclusive: true,
|
|
10567
|
+
input: message.parts,
|
|
10568
|
+
path: ["parts"],
|
|
10569
|
+
message: "Message must contain at least one part"
|
|
10570
|
+
});
|
|
10571
|
+
}
|
|
10572
|
+
});
|
|
10573
|
+
return zodSchema2(
|
|
10574
|
+
arrayUntilFirstInvalidElement(() => messageSchema).check(
|
|
10575
|
+
z8.minLength(1, "Messages array must not be empty")
|
|
10576
|
+
)
|
|
10344
10577
|
);
|
|
10345
10578
|
});
|
|
10346
10579
|
async function safeValidateUIMessagesInternal({
|
|
@@ -10446,7 +10679,7 @@ async function safeValidateUIMessagesInternal({
|
|
|
10446
10679
|
const inputToValidate = inputSchemaInput == null ? toolPart.input : inputSchemaInput.value;
|
|
10447
10680
|
let convertToDynamic = false;
|
|
10448
10681
|
if (toolPart.state !== "input-streaming" && (toolPart.state !== "output-error" || inputSchemaInput != null || toolPart.input !== void 0)) {
|
|
10449
|
-
const result = await
|
|
10682
|
+
const result = await safeValidateTypes6({
|
|
10450
10683
|
value: inputToValidate,
|
|
10451
10684
|
schema: tool2.inputSchema,
|
|
10452
10685
|
context: inputValidationContext
|
|
@@ -11302,7 +11535,7 @@ import {
|
|
|
11302
11535
|
} from "@ai-sdk/provider";
|
|
11303
11536
|
import {
|
|
11304
11537
|
asSchema as asSchema5,
|
|
11305
|
-
safeValidateTypes as
|
|
11538
|
+
safeValidateTypes as safeValidateTypes7
|
|
11306
11539
|
} from "@ai-sdk/provider-utils";
|
|
11307
11540
|
var noSchemaOutputStrategy = {
|
|
11308
11541
|
type: "no-schema",
|
|
@@ -11342,7 +11575,7 @@ var objectOutputStrategy = (schema) => ({
|
|
|
11342
11575
|
};
|
|
11343
11576
|
},
|
|
11344
11577
|
async validateFinalResult(value) {
|
|
11345
|
-
return
|
|
11578
|
+
return safeValidateTypes7({ value, schema });
|
|
11346
11579
|
},
|
|
11347
11580
|
createElementStream() {
|
|
11348
11581
|
throw new UnsupportedFunctionalityError3({
|
|
@@ -11353,6 +11586,7 @@ var objectOutputStrategy = (schema) => ({
|
|
|
11353
11586
|
var arrayOutputStrategy = (schema) => {
|
|
11354
11587
|
return {
|
|
11355
11588
|
type: "array",
|
|
11589
|
+
createArrayStreamParser: () => createArrayOutputStreamParser(schema, false),
|
|
11356
11590
|
// wrap in object that contains array of elements, since most LLMs will not
|
|
11357
11591
|
// be able to generate an array directly:
|
|
11358
11592
|
// possible future optimization: use arrays directly when model supports grammar-guided generation
|
|
@@ -11388,7 +11622,7 @@ var arrayOutputStrategy = (schema) => {
|
|
|
11388
11622
|
const resultArray = [];
|
|
11389
11623
|
for (let i = 0; i < inputArray.length; i++) {
|
|
11390
11624
|
const element = inputArray[i];
|
|
11391
|
-
const result = await
|
|
11625
|
+
const result = await safeValidateTypes7({ value: element, schema });
|
|
11392
11626
|
if (i === inputArray.length - 1 && !isFinalDelta) {
|
|
11393
11627
|
continue;
|
|
11394
11628
|
}
|
|
@@ -11430,7 +11664,7 @@ var arrayOutputStrategy = (schema) => {
|
|
|
11430
11664
|
const inputArray = value.elements;
|
|
11431
11665
|
const resultArray = [];
|
|
11432
11666
|
for (const element of inputArray) {
|
|
11433
|
-
const result = await
|
|
11667
|
+
const result = await safeValidateTypes7({ value: element, schema });
|
|
11434
11668
|
if (!result.success) {
|
|
11435
11669
|
return result;
|
|
11436
11670
|
}
|
|
@@ -11565,9 +11799,9 @@ function getOutputStrategy({
|
|
|
11565
11799
|
|
|
11566
11800
|
// src/generate-object/parse-and-validate-object-result.ts
|
|
11567
11801
|
import { JSONParseError as JSONParseError2, TypeValidationError as TypeValidationError5 } from "@ai-sdk/provider";
|
|
11568
|
-
import { safeParseJSON as
|
|
11802
|
+
import { safeParseJSON as safeParseJSON5 } from "@ai-sdk/provider-utils";
|
|
11569
11803
|
async function parseAndValidateObjectResult(result, outputStrategy, context2) {
|
|
11570
|
-
const parseResult = await
|
|
11804
|
+
const parseResult = await safeParseJSON5({ text: result });
|
|
11571
11805
|
if (!parseResult.success) {
|
|
11572
11806
|
throw new NoObjectGeneratedError({
|
|
11573
11807
|
message: "No object generated: could not parse the response.",
|
|
@@ -12294,6 +12528,7 @@ var DefaultStreamObjectResult = class {
|
|
|
12294
12528
|
endWhenDone: false,
|
|
12295
12529
|
endOnError: true,
|
|
12296
12530
|
fn: async (rootSpan) => {
|
|
12531
|
+
var _a23;
|
|
12297
12532
|
const standardizedPrompt = await standardizePrompt({
|
|
12298
12533
|
system,
|
|
12299
12534
|
prompt,
|
|
@@ -12381,6 +12616,7 @@ var DefaultStreamObjectResult = class {
|
|
|
12381
12616
|
let object2;
|
|
12382
12617
|
let error;
|
|
12383
12618
|
let terminalError;
|
|
12619
|
+
let arrayStreamParser = (_a23 = outputStrategy.createArrayStreamParser) == null ? void 0 : _a23.call(outputStrategy);
|
|
12384
12620
|
let accumulatedText = "";
|
|
12385
12621
|
let textDelta = "";
|
|
12386
12622
|
let fullResponse = {
|
|
@@ -12395,7 +12631,7 @@ var DefaultStreamObjectResult = class {
|
|
|
12395
12631
|
const transformedStream = stream.pipeThrough(new TransformStream(transformer)).pipeThrough(
|
|
12396
12632
|
new TransformStream({
|
|
12397
12633
|
async transform(chunk, controller) {
|
|
12398
|
-
var
|
|
12634
|
+
var _a24, _b, _c;
|
|
12399
12635
|
if (typeof chunk === "object" && chunk.type === "stream-start") {
|
|
12400
12636
|
warnings = chunk.warnings;
|
|
12401
12637
|
return;
|
|
@@ -12413,6 +12649,26 @@ var DefaultStreamObjectResult = class {
|
|
|
12413
12649
|
if (typeof chunk === "string") {
|
|
12414
12650
|
accumulatedText += chunk;
|
|
12415
12651
|
textDelta += chunk;
|
|
12652
|
+
if (arrayStreamParser != null) {
|
|
12653
|
+
const result = await arrayStreamParser(chunk);
|
|
12654
|
+
if (result !== "fallback") {
|
|
12655
|
+
if (result != null) {
|
|
12656
|
+
latestObject = result.partial;
|
|
12657
|
+
controller.enqueue({
|
|
12658
|
+
type: "object",
|
|
12659
|
+
object: latestObject
|
|
12660
|
+
});
|
|
12661
|
+
controller.enqueue({
|
|
12662
|
+
type: "text-delta",
|
|
12663
|
+
textDelta: result.textDelta
|
|
12664
|
+
});
|
|
12665
|
+
textDelta = "";
|
|
12666
|
+
isFirstDelta = false;
|
|
12667
|
+
}
|
|
12668
|
+
return;
|
|
12669
|
+
}
|
|
12670
|
+
arrayStreamParser = void 0;
|
|
12671
|
+
}
|
|
12416
12672
|
const { value: currentObjectJson, state: parseState } = await parsePartialJson(accumulatedText);
|
|
12417
12673
|
if (currentObjectJson !== void 0 && !isDeepEqualData(latestObjectJson, currentObjectJson)) {
|
|
12418
12674
|
const validationResult = await outputStrategy.validatePartialResult({
|
|
@@ -12445,7 +12701,7 @@ var DefaultStreamObjectResult = class {
|
|
|
12445
12701
|
switch (chunk.type) {
|
|
12446
12702
|
case "response-metadata": {
|
|
12447
12703
|
fullResponse = {
|
|
12448
|
-
id: (
|
|
12704
|
+
id: (_a24 = chunk.id) != null ? _a24 : fullResponse.id,
|
|
12449
12705
|
timestamp: (_b = chunk.timestamp) != null ? _b : fullResponse.timestamp,
|
|
12450
12706
|
modelId: (_c = chunk.modelId) != null ? _c : fullResponse.modelId
|
|
12451
12707
|
};
|