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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.233
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fe410e7: fix: detect MP4 audio from its ftyp box during transcription
|
|
8
|
+
- af7188c: fix(ai): preserve tool parts when tool call IDs repeat across steps
|
|
9
|
+
- Updated dependencies [a09f944]
|
|
10
|
+
- @ai-sdk/gateway@3.0.155
|
|
11
|
+
|
|
3
12
|
## 6.0.232
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1200,7 +1200,17 @@ var audioMediaTypeSignatures = [
|
|
|
1200
1200
|
},
|
|
1201
1201
|
{
|
|
1202
1202
|
mediaType: "audio/mp4",
|
|
1203
|
-
bytesPrefix: [
|
|
1203
|
+
bytesPrefix: [
|
|
1204
|
+
0,
|
|
1205
|
+
0,
|
|
1206
|
+
0,
|
|
1207
|
+
null,
|
|
1208
|
+
102,
|
|
1209
|
+
116,
|
|
1210
|
+
121,
|
|
1211
|
+
112
|
|
1212
|
+
// ftyp
|
|
1213
|
+
]
|
|
1204
1214
|
},
|
|
1205
1215
|
{
|
|
1206
1216
|
mediaType: "audio/webm",
|
|
@@ -1282,7 +1292,7 @@ function detectMediaType({
|
|
|
1282
1292
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1283
1293
|
|
|
1284
1294
|
// src/version.ts
|
|
1285
|
-
var VERSION = true ? "6.0.
|
|
1295
|
+
var VERSION = true ? "6.0.233" : "0.0.0-test";
|
|
1286
1296
|
|
|
1287
1297
|
// src/util/download/download.ts
|
|
1288
1298
|
var download = async ({
|
|
@@ -5786,11 +5796,32 @@ function processUIMessageStream({
|
|
|
5786
5796
|
async transform(chunk, controller) {
|
|
5787
5797
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
5788
5798
|
var _a22, _b, _c, _d;
|
|
5799
|
+
function getCurrentStepParts() {
|
|
5800
|
+
const parts = state.message.parts;
|
|
5801
|
+
let currentStepStartIndex = parts.length - 1;
|
|
5802
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") {
|
|
5803
|
+
currentStepStartIndex--;
|
|
5804
|
+
}
|
|
5805
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
5806
|
+
}
|
|
5807
|
+
function getCurrentStepToolInvocations() {
|
|
5808
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
5809
|
+
}
|
|
5789
5810
|
function getToolInvocation(toolCallId) {
|
|
5790
|
-
const toolInvocations =
|
|
5791
|
-
|
|
5811
|
+
const toolInvocations = getCurrentStepToolInvocations();
|
|
5812
|
+
let toolInvocation = toolInvocations.find(
|
|
5792
5813
|
(invocation) => invocation.toolCallId === toolCallId
|
|
5793
5814
|
);
|
|
5815
|
+
if (toolInvocation == null) {
|
|
5816
|
+
const parts = state.message.parts;
|
|
5817
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
5818
|
+
const part = parts[i];
|
|
5819
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
5820
|
+
toolInvocation = part;
|
|
5821
|
+
break;
|
|
5822
|
+
}
|
|
5823
|
+
}
|
|
5824
|
+
}
|
|
5794
5825
|
if (toolInvocation == null) {
|
|
5795
5826
|
throw new UIMessageStreamError({
|
|
5796
5827
|
chunkType: "tool-invocation",
|
|
@@ -5800,9 +5831,9 @@ function processUIMessageStream({
|
|
|
5800
5831
|
}
|
|
5801
5832
|
return toolInvocation;
|
|
5802
5833
|
}
|
|
5803
|
-
function updateToolPart(options) {
|
|
5834
|
+
function updateToolPart(options, existingPart) {
|
|
5804
5835
|
var _a23;
|
|
5805
|
-
const part =
|
|
5836
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
5806
5837
|
(part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
5807
5838
|
);
|
|
5808
5839
|
const anyOptions = options;
|
|
@@ -5848,9 +5879,9 @@ function processUIMessageStream({
|
|
|
5848
5879
|
});
|
|
5849
5880
|
}
|
|
5850
5881
|
}
|
|
5851
|
-
function updateDynamicToolPart(options) {
|
|
5882
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
5852
5883
|
var _a23, _b2;
|
|
5853
|
-
const part =
|
|
5884
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
5854
5885
|
(part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
|
|
5855
5886
|
);
|
|
5856
5887
|
const anyOptions = options;
|
|
@@ -6030,7 +6061,7 @@ function processUIMessageStream({
|
|
|
6030
6061
|
break;
|
|
6031
6062
|
}
|
|
6032
6063
|
case "tool-input-start": {
|
|
6033
|
-
const toolInvocations =
|
|
6064
|
+
const toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);
|
|
6034
6065
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
6035
6066
|
text: "",
|
|
6036
6067
|
toolName: chunk.toolName,
|
|
@@ -6133,7 +6164,7 @@ function processUIMessageStream({
|
|
|
6133
6164
|
break;
|
|
6134
6165
|
}
|
|
6135
6166
|
case "tool-input-error": {
|
|
6136
|
-
const existingPart =
|
|
6167
|
+
const existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
|
|
6137
6168
|
const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
|
|
6138
6169
|
if (isDynamic) {
|
|
6139
6170
|
updateDynamicToolPart({
|
|
@@ -6181,31 +6212,37 @@ function processUIMessageStream({
|
|
|
6181
6212
|
case "tool-output-available": {
|
|
6182
6213
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6183
6214
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6184
|
-
updateDynamicToolPart(
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6215
|
+
updateDynamicToolPart(
|
|
6216
|
+
{
|
|
6217
|
+
toolCallId: chunk.toolCallId,
|
|
6218
|
+
toolName: toolInvocation.toolName,
|
|
6219
|
+
state: "output-available",
|
|
6220
|
+
input: toolInvocation.input,
|
|
6221
|
+
output: chunk.output,
|
|
6222
|
+
preliminary: chunk.preliminary,
|
|
6223
|
+
providerExecuted: chunk.providerExecuted,
|
|
6224
|
+
providerMetadata: chunk.providerMetadata,
|
|
6225
|
+
title: toolInvocation.title,
|
|
6226
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6227
|
+
},
|
|
6228
|
+
toolInvocation
|
|
6229
|
+
);
|
|
6196
6230
|
} else {
|
|
6197
|
-
updateToolPart(
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6231
|
+
updateToolPart(
|
|
6232
|
+
{
|
|
6233
|
+
toolCallId: chunk.toolCallId,
|
|
6234
|
+
toolName: getStaticToolName(toolInvocation),
|
|
6235
|
+
state: "output-available",
|
|
6236
|
+
input: toolInvocation.input,
|
|
6237
|
+
output: chunk.output,
|
|
6238
|
+
providerExecuted: chunk.providerExecuted,
|
|
6239
|
+
preliminary: chunk.preliminary,
|
|
6240
|
+
providerMetadata: chunk.providerMetadata,
|
|
6241
|
+
title: toolInvocation.title,
|
|
6242
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6243
|
+
},
|
|
6244
|
+
toolInvocation
|
|
6245
|
+
);
|
|
6209
6246
|
}
|
|
6210
6247
|
write();
|
|
6211
6248
|
break;
|
|
@@ -6213,30 +6250,36 @@ function processUIMessageStream({
|
|
|
6213
6250
|
case "tool-output-error": {
|
|
6214
6251
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6215
6252
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6216
|
-
updateDynamicToolPart(
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6253
|
+
updateDynamicToolPart(
|
|
6254
|
+
{
|
|
6255
|
+
toolCallId: chunk.toolCallId,
|
|
6256
|
+
toolName: toolInvocation.toolName,
|
|
6257
|
+
state: "output-error",
|
|
6258
|
+
input: toolInvocation.input,
|
|
6259
|
+
errorText: chunk.errorText,
|
|
6260
|
+
providerExecuted: chunk.providerExecuted,
|
|
6261
|
+
providerMetadata: chunk.providerMetadata,
|
|
6262
|
+
title: toolInvocation.title,
|
|
6263
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6264
|
+
},
|
|
6265
|
+
toolInvocation
|
|
6266
|
+
);
|
|
6227
6267
|
} else {
|
|
6228
|
-
updateToolPart(
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6268
|
+
updateToolPart(
|
|
6269
|
+
{
|
|
6270
|
+
toolCallId: chunk.toolCallId,
|
|
6271
|
+
toolName: getStaticToolName(toolInvocation),
|
|
6272
|
+
state: "output-error",
|
|
6273
|
+
input: toolInvocation.input,
|
|
6274
|
+
rawInput: toolInvocation.rawInput,
|
|
6275
|
+
errorText: chunk.errorText,
|
|
6276
|
+
providerExecuted: chunk.providerExecuted,
|
|
6277
|
+
providerMetadata: chunk.providerMetadata,
|
|
6278
|
+
title: toolInvocation.title,
|
|
6279
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
6280
|
+
},
|
|
6281
|
+
toolInvocation
|
|
6282
|
+
);
|
|
6240
6283
|
}
|
|
6241
6284
|
write();
|
|
6242
6285
|
break;
|