ai 6.0.232 → 6.0.233
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 +100 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +100 -57
- 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/src/ui/process-ui-message-stream.ts +109 -61
- package/src/util/detect-media-type.ts +10 -1
package/dist/index.mjs
CHANGED
|
@@ -1081,7 +1081,17 @@ var audioMediaTypeSignatures = [
|
|
|
1081
1081
|
},
|
|
1082
1082
|
{
|
|
1083
1083
|
mediaType: "audio/mp4",
|
|
1084
|
-
bytesPrefix: [
|
|
1084
|
+
bytesPrefix: [
|
|
1085
|
+
0,
|
|
1086
|
+
0,
|
|
1087
|
+
0,
|
|
1088
|
+
null,
|
|
1089
|
+
102,
|
|
1090
|
+
116,
|
|
1091
|
+
121,
|
|
1092
|
+
112
|
|
1093
|
+
// ftyp
|
|
1094
|
+
]
|
|
1085
1095
|
},
|
|
1086
1096
|
{
|
|
1087
1097
|
mediaType: "audio/webm",
|
|
@@ -1171,7 +1181,7 @@ import {
|
|
|
1171
1181
|
} from "@ai-sdk/provider-utils";
|
|
1172
1182
|
|
|
1173
1183
|
// src/version.ts
|
|
1174
|
-
var VERSION = true ? "6.0.
|
|
1184
|
+
var VERSION = true ? "6.0.233" : "0.0.0-test";
|
|
1175
1185
|
|
|
1176
1186
|
// src/util/download/download.ts
|
|
1177
1187
|
var download = async ({
|
|
@@ -5712,11 +5722,32 @@ function processUIMessageStream({
|
|
|
5712
5722
|
async transform(chunk, controller) {
|
|
5713
5723
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
5714
5724
|
var _a22, _b, _c, _d;
|
|
5725
|
+
function getCurrentStepParts() {
|
|
5726
|
+
const parts = state.message.parts;
|
|
5727
|
+
let currentStepStartIndex = parts.length - 1;
|
|
5728
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") {
|
|
5729
|
+
currentStepStartIndex--;
|
|
5730
|
+
}
|
|
5731
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
5732
|
+
}
|
|
5733
|
+
function getCurrentStepToolInvocations() {
|
|
5734
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
5735
|
+
}
|
|
5715
5736
|
function getToolInvocation(toolCallId) {
|
|
5716
|
-
const toolInvocations =
|
|
5717
|
-
|
|
5737
|
+
const toolInvocations = getCurrentStepToolInvocations();
|
|
5738
|
+
let toolInvocation = toolInvocations.find(
|
|
5718
5739
|
(invocation) => invocation.toolCallId === toolCallId
|
|
5719
5740
|
);
|
|
5741
|
+
if (toolInvocation == null) {
|
|
5742
|
+
const parts = state.message.parts;
|
|
5743
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
5744
|
+
const part = parts[i];
|
|
5745
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
5746
|
+
toolInvocation = part;
|
|
5747
|
+
break;
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5720
5751
|
if (toolInvocation == null) {
|
|
5721
5752
|
throw new UIMessageStreamError({
|
|
5722
5753
|
chunkType: "tool-invocation",
|
|
@@ -5726,9 +5757,9 @@ function processUIMessageStream({
|
|
|
5726
5757
|
}
|
|
5727
5758
|
return toolInvocation;
|
|
5728
5759
|
}
|
|
5729
|
-
function updateToolPart(options) {
|
|
5760
|
+
function updateToolPart(options, existingPart) {
|
|
5730
5761
|
var _a23;
|
|
5731
|
-
const part =
|
|
5762
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
5732
5763
|
(part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
5733
5764
|
);
|
|
5734
5765
|
const anyOptions = options;
|
|
@@ -5774,9 +5805,9 @@ function processUIMessageStream({
|
|
|
5774
5805
|
});
|
|
5775
5806
|
}
|
|
5776
5807
|
}
|
|
5777
|
-
function updateDynamicToolPart(options) {
|
|
5808
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
5778
5809
|
var _a23, _b2;
|
|
5779
|
-
const part =
|
|
5810
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
5780
5811
|
(part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
|
|
5781
5812
|
);
|
|
5782
5813
|
const anyOptions = options;
|
|
@@ -5956,7 +5987,7 @@ function processUIMessageStream({
|
|
|
5956
5987
|
break;
|
|
5957
5988
|
}
|
|
5958
5989
|
case "tool-input-start": {
|
|
5959
|
-
const toolInvocations =
|
|
5990
|
+
const toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);
|
|
5960
5991
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
5961
5992
|
text: "",
|
|
5962
5993
|
toolName: chunk.toolName,
|
|
@@ -6059,7 +6090,7 @@ function processUIMessageStream({
|
|
|
6059
6090
|
break;
|
|
6060
6091
|
}
|
|
6061
6092
|
case "tool-input-error": {
|
|
6062
|
-
const existingPart =
|
|
6093
|
+
const existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
|
|
6063
6094
|
const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
|
|
6064
6095
|
if (isDynamic) {
|
|
6065
6096
|
updateDynamicToolPart({
|
|
@@ -6107,31 +6138,37 @@ function processUIMessageStream({
|
|
|
6107
6138
|
case "tool-output-available": {
|
|
6108
6139
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6109
6140
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6110
|
-
updateDynamicToolPart(
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6141
|
+
updateDynamicToolPart(
|
|
6142
|
+
{
|
|
6143
|
+
toolCallId: chunk.toolCallId,
|
|
6144
|
+
toolName: toolInvocation.toolName,
|
|
6145
|
+
state: "output-available",
|
|
6146
|
+
input: toolInvocation.input,
|
|
6147
|
+
output: chunk.output,
|
|
6148
|
+
preliminary: chunk.preliminary,
|
|
6149
|
+
providerExecuted: chunk.providerExecuted,
|
|
6150
|
+
providerMetadata: chunk.providerMetadata,
|
|
6151
|
+
title: toolInvocation.title,
|
|
6152
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6153
|
+
},
|
|
6154
|
+
toolInvocation
|
|
6155
|
+
);
|
|
6122
6156
|
} else {
|
|
6123
|
-
updateToolPart(
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6157
|
+
updateToolPart(
|
|
6158
|
+
{
|
|
6159
|
+
toolCallId: chunk.toolCallId,
|
|
6160
|
+
toolName: getStaticToolName(toolInvocation),
|
|
6161
|
+
state: "output-available",
|
|
6162
|
+
input: toolInvocation.input,
|
|
6163
|
+
output: chunk.output,
|
|
6164
|
+
providerExecuted: chunk.providerExecuted,
|
|
6165
|
+
preliminary: chunk.preliminary,
|
|
6166
|
+
providerMetadata: chunk.providerMetadata,
|
|
6167
|
+
title: toolInvocation.title,
|
|
6168
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6169
|
+
},
|
|
6170
|
+
toolInvocation
|
|
6171
|
+
);
|
|
6135
6172
|
}
|
|
6136
6173
|
write();
|
|
6137
6174
|
break;
|
|
@@ -6139,30 +6176,36 @@ function processUIMessageStream({
|
|
|
6139
6176
|
case "tool-output-error": {
|
|
6140
6177
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6141
6178
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6142
|
-
updateDynamicToolPart(
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6179
|
+
updateDynamicToolPart(
|
|
6180
|
+
{
|
|
6181
|
+
toolCallId: chunk.toolCallId,
|
|
6182
|
+
toolName: toolInvocation.toolName,
|
|
6183
|
+
state: "output-error",
|
|
6184
|
+
input: toolInvocation.input,
|
|
6185
|
+
errorText: chunk.errorText,
|
|
6186
|
+
providerExecuted: chunk.providerExecuted,
|
|
6187
|
+
providerMetadata: chunk.providerMetadata,
|
|
6188
|
+
title: toolInvocation.title,
|
|
6189
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6190
|
+
},
|
|
6191
|
+
toolInvocation
|
|
6192
|
+
);
|
|
6153
6193
|
} else {
|
|
6154
|
-
updateToolPart(
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6194
|
+
updateToolPart(
|
|
6195
|
+
{
|
|
6196
|
+
toolCallId: chunk.toolCallId,
|
|
6197
|
+
toolName: getStaticToolName(toolInvocation),
|
|
6198
|
+
state: "output-error",
|
|
6199
|
+
input: toolInvocation.input,
|
|
6200
|
+
rawInput: toolInvocation.rawInput,
|
|
6201
|
+
errorText: chunk.errorText,
|
|
6202
|
+
providerExecuted: chunk.providerExecuted,
|
|
6203
|
+
providerMetadata: chunk.providerMetadata,
|
|
6204
|
+
title: toolInvocation.title,
|
|
6205
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6206
|
+
},
|
|
6207
|
+
toolInvocation
|
|
6208
|
+
);
|
|
6166
6209
|
}
|
|
6167
6210
|
write();
|
|
6168
6211
|
break;
|