ai 5.0.217 → 5.0.218
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 +9 -0
- package/dist/index.js +98 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -45
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1 -1
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -641,7 +641,17 @@ var audioMediaTypeSignatures = [
|
|
|
641
641
|
},
|
|
642
642
|
{
|
|
643
643
|
mediaType: "audio/mp4",
|
|
644
|
-
bytesPrefix: [
|
|
644
|
+
bytesPrefix: [
|
|
645
|
+
0,
|
|
646
|
+
0,
|
|
647
|
+
0,
|
|
648
|
+
null,
|
|
649
|
+
102,
|
|
650
|
+
116,
|
|
651
|
+
121,
|
|
652
|
+
112
|
|
653
|
+
// ftyp
|
|
654
|
+
]
|
|
645
655
|
},
|
|
646
656
|
{
|
|
647
657
|
mediaType: "audio/webm",
|
|
@@ -689,7 +699,7 @@ import {
|
|
|
689
699
|
} from "@ai-sdk/provider-utils";
|
|
690
700
|
|
|
691
701
|
// src/version.ts
|
|
692
|
-
var VERSION = true ? "5.0.
|
|
702
|
+
var VERSION = true ? "5.0.218" : "0.0.0-test";
|
|
693
703
|
|
|
694
704
|
// src/util/download/download.ts
|
|
695
705
|
var download = async ({
|
|
@@ -3543,11 +3553,32 @@ function processUIMessageStream({
|
|
|
3543
3553
|
async transform(chunk, controller) {
|
|
3544
3554
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
3545
3555
|
var _a16, _b, _c, _d;
|
|
3556
|
+
function getCurrentStepParts() {
|
|
3557
|
+
const parts = state.message.parts;
|
|
3558
|
+
let currentStepStartIndex = parts.length - 1;
|
|
3559
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") {
|
|
3560
|
+
currentStepStartIndex--;
|
|
3561
|
+
}
|
|
3562
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
3563
|
+
}
|
|
3564
|
+
function getCurrentStepToolInvocations() {
|
|
3565
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
3566
|
+
}
|
|
3546
3567
|
function getToolInvocation(toolCallId) {
|
|
3547
|
-
const toolInvocations =
|
|
3548
|
-
|
|
3568
|
+
const toolInvocations = getCurrentStepToolInvocations();
|
|
3569
|
+
let toolInvocation = toolInvocations.find(
|
|
3549
3570
|
(invocation) => invocation.toolCallId === toolCallId
|
|
3550
3571
|
);
|
|
3572
|
+
if (toolInvocation == null) {
|
|
3573
|
+
const parts = state.message.parts;
|
|
3574
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
3575
|
+
const part = parts[i];
|
|
3576
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
3577
|
+
toolInvocation = part;
|
|
3578
|
+
break;
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3551
3582
|
if (toolInvocation == null) {
|
|
3552
3583
|
throw new Error(
|
|
3553
3584
|
"tool-output-error must be preceded by a tool-input-available"
|
|
@@ -3556,12 +3587,22 @@ function processUIMessageStream({
|
|
|
3556
3587
|
return toolInvocation;
|
|
3557
3588
|
}
|
|
3558
3589
|
function getDynamicToolInvocation(toolCallId) {
|
|
3559
|
-
const toolInvocations =
|
|
3590
|
+
const toolInvocations = getCurrentStepParts().filter(
|
|
3560
3591
|
(part) => part.type === "dynamic-tool"
|
|
3561
3592
|
);
|
|
3562
|
-
|
|
3593
|
+
let toolInvocation = toolInvocations.find(
|
|
3563
3594
|
(invocation) => invocation.toolCallId === toolCallId
|
|
3564
3595
|
);
|
|
3596
|
+
if (toolInvocation == null) {
|
|
3597
|
+
const parts = state.message.parts;
|
|
3598
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
3599
|
+
const part = parts[i];
|
|
3600
|
+
if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) {
|
|
3601
|
+
toolInvocation = part;
|
|
3602
|
+
break;
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3565
3606
|
if (toolInvocation == null) {
|
|
3566
3607
|
throw new Error(
|
|
3567
3608
|
"tool-output-error must be preceded by a tool-input-available"
|
|
@@ -3569,9 +3610,9 @@ function processUIMessageStream({
|
|
|
3569
3610
|
}
|
|
3570
3611
|
return toolInvocation;
|
|
3571
3612
|
}
|
|
3572
|
-
function updateToolPart(options) {
|
|
3613
|
+
function updateToolPart(options, existingPart) {
|
|
3573
3614
|
var _a17;
|
|
3574
|
-
const part =
|
|
3615
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
3575
3616
|
(part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
3576
3617
|
);
|
|
3577
3618
|
const anyOptions = options;
|
|
@@ -3602,9 +3643,9 @@ function processUIMessageStream({
|
|
|
3602
3643
|
});
|
|
3603
3644
|
}
|
|
3604
3645
|
}
|
|
3605
|
-
function updateDynamicToolPart(options) {
|
|
3646
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
3606
3647
|
var _a17, _b2;
|
|
3607
|
-
const part =
|
|
3648
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
3608
3649
|
(part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
|
|
3609
3650
|
);
|
|
3610
3651
|
const anyOptions = options;
|
|
@@ -3736,7 +3777,7 @@ function processUIMessageStream({
|
|
|
3736
3777
|
break;
|
|
3737
3778
|
}
|
|
3738
3779
|
case "tool-input-start": {
|
|
3739
|
-
const toolInvocations =
|
|
3780
|
+
const toolInvocations = getCurrentStepParts().filter(isToolUIPart);
|
|
3740
3781
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
3741
3782
|
text: "",
|
|
3742
3783
|
toolName: chunk.toolName,
|
|
@@ -3846,25 +3887,31 @@ function processUIMessageStream({
|
|
|
3846
3887
|
const toolInvocation = getDynamicToolInvocation(
|
|
3847
3888
|
chunk.toolCallId
|
|
3848
3889
|
);
|
|
3849
|
-
updateDynamicToolPart(
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3890
|
+
updateDynamicToolPart(
|
|
3891
|
+
{
|
|
3892
|
+
toolCallId: chunk.toolCallId,
|
|
3893
|
+
toolName: toolInvocation.toolName,
|
|
3894
|
+
state: "output-available",
|
|
3895
|
+
input: toolInvocation.input,
|
|
3896
|
+
output: chunk.output,
|
|
3897
|
+
preliminary: chunk.preliminary
|
|
3898
|
+
},
|
|
3899
|
+
toolInvocation
|
|
3900
|
+
);
|
|
3857
3901
|
} else {
|
|
3858
3902
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
3859
|
-
updateToolPart(
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3903
|
+
updateToolPart(
|
|
3904
|
+
{
|
|
3905
|
+
toolCallId: chunk.toolCallId,
|
|
3906
|
+
toolName: getToolName(toolInvocation),
|
|
3907
|
+
state: "output-available",
|
|
3908
|
+
input: toolInvocation.input,
|
|
3909
|
+
output: chunk.output,
|
|
3910
|
+
providerExecuted: chunk.providerExecuted,
|
|
3911
|
+
preliminary: chunk.preliminary
|
|
3912
|
+
},
|
|
3913
|
+
toolInvocation
|
|
3914
|
+
);
|
|
3868
3915
|
}
|
|
3869
3916
|
write();
|
|
3870
3917
|
break;
|
|
@@ -3874,25 +3921,31 @@ function processUIMessageStream({
|
|
|
3874
3921
|
const toolInvocation = getDynamicToolInvocation(
|
|
3875
3922
|
chunk.toolCallId
|
|
3876
3923
|
);
|
|
3877
|
-
updateDynamicToolPart(
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3924
|
+
updateDynamicToolPart(
|
|
3925
|
+
{
|
|
3926
|
+
toolCallId: chunk.toolCallId,
|
|
3927
|
+
toolName: toolInvocation.toolName,
|
|
3928
|
+
state: "output-error",
|
|
3929
|
+
input: toolInvocation.input,
|
|
3930
|
+
errorText: chunk.errorText,
|
|
3931
|
+
providerExecuted: chunk.providerExecuted
|
|
3932
|
+
},
|
|
3933
|
+
toolInvocation
|
|
3934
|
+
);
|
|
3885
3935
|
} else {
|
|
3886
3936
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
3887
|
-
updateToolPart(
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3937
|
+
updateToolPart(
|
|
3938
|
+
{
|
|
3939
|
+
toolCallId: chunk.toolCallId,
|
|
3940
|
+
toolName: getToolName(toolInvocation),
|
|
3941
|
+
state: "output-error",
|
|
3942
|
+
input: toolInvocation.input,
|
|
3943
|
+
rawInput: toolInvocation.rawInput,
|
|
3944
|
+
errorText: chunk.errorText,
|
|
3945
|
+
providerExecuted: chunk.providerExecuted
|
|
3946
|
+
},
|
|
3947
|
+
toolInvocation
|
|
3948
|
+
);
|
|
3896
3949
|
}
|
|
3897
3950
|
write();
|
|
3898
3951
|
break;
|