ai 7.0.31 → 7.0.33
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 +23 -0
- package/dist/index.d.ts +3 -150
- package/dist/index.js +164 -120
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +45 -1
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +10 -2
- package/docs/03-ai-sdk-harnesses/03-tools.mdx +40 -0
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +1 -1
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +1 -1
- package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +1 -1
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
- package/package.json +3 -3
- package/src/generate-text/generate-text.ts +4 -0
- package/src/prompt/convert-to-language-model-prompt.ts +13 -0
- package/src/ui/chat.ts +2 -2
- package/src/ui/process-ui-message-stream.ts +109 -61
- package/src/ui-message-stream/ui-message-chunks.ts +29 -29
package/dist/index.js
CHANGED
|
@@ -1089,7 +1089,7 @@ import {
|
|
|
1089
1089
|
} from "@ai-sdk/provider-utils";
|
|
1090
1090
|
|
|
1091
1091
|
// src/version.ts
|
|
1092
|
-
var VERSION = true ? "7.0.
|
|
1092
|
+
var VERSION = true ? "7.0.33" : "0.0.0-test";
|
|
1093
1093
|
|
|
1094
1094
|
// src/util/download/download.ts
|
|
1095
1095
|
var download = async ({
|
|
@@ -1142,6 +1142,42 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
|
|
|
1142
1142
|
)
|
|
1143
1143
|
);
|
|
1144
1144
|
|
|
1145
|
+
// src/util/merge-objects.ts
|
|
1146
|
+
function mergeObjects(base, overrides) {
|
|
1147
|
+
if (base === void 0 && overrides === void 0) {
|
|
1148
|
+
return void 0;
|
|
1149
|
+
}
|
|
1150
|
+
if (base === void 0) {
|
|
1151
|
+
return overrides;
|
|
1152
|
+
}
|
|
1153
|
+
if (overrides === void 0) {
|
|
1154
|
+
return base;
|
|
1155
|
+
}
|
|
1156
|
+
const result = { ...base };
|
|
1157
|
+
for (const key in overrides) {
|
|
1158
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
1162
|
+
const overridesValue = overrides[key];
|
|
1163
|
+
if (overridesValue === void 0)
|
|
1164
|
+
continue;
|
|
1165
|
+
const baseValue = key in base ? base[key] : void 0;
|
|
1166
|
+
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
1167
|
+
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
1168
|
+
if (isSourceObject && isTargetObject) {
|
|
1169
|
+
result[key] = mergeObjects(
|
|
1170
|
+
baseValue,
|
|
1171
|
+
overridesValue
|
|
1172
|
+
);
|
|
1173
|
+
} else {
|
|
1174
|
+
result[key] = overridesValue;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
return result;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1145
1181
|
// src/prompt/file-part-data.ts
|
|
1146
1182
|
import {
|
|
1147
1183
|
isBuffer,
|
|
@@ -1307,7 +1343,15 @@ async function convertToLanguageModelPrompt({
|
|
|
1307
1343
|
}
|
|
1308
1344
|
const lastCombinedMessage = combinedMessages.at(-1);
|
|
1309
1345
|
if ((lastCombinedMessage == null ? void 0 : lastCombinedMessage.role) === "tool") {
|
|
1346
|
+
const lastContentPart = lastCombinedMessage.content.at(-1);
|
|
1347
|
+
if (lastContentPart != null && lastCombinedMessage.providerOptions != null) {
|
|
1348
|
+
lastContentPart.providerOptions = mergeObjects(
|
|
1349
|
+
lastCombinedMessage.providerOptions,
|
|
1350
|
+
lastContentPart.providerOptions
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1310
1353
|
lastCombinedMessage.content.push(...message.content);
|
|
1354
|
+
lastCombinedMessage.providerOptions = message.providerOptions;
|
|
1311
1355
|
} else {
|
|
1312
1356
|
combinedMessages.push(message);
|
|
1313
1357
|
}
|
|
@@ -2586,42 +2630,6 @@ function mergeAbortSignals(...signals) {
|
|
|
2586
2630
|
return validSignals.length === 0 ? void 0 : validSignals.length === 1 ? validSignals[0] : AbortSignal.any(validSignals);
|
|
2587
2631
|
}
|
|
2588
2632
|
|
|
2589
|
-
// src/util/merge-objects.ts
|
|
2590
|
-
function mergeObjects(base, overrides) {
|
|
2591
|
-
if (base === void 0 && overrides === void 0) {
|
|
2592
|
-
return void 0;
|
|
2593
|
-
}
|
|
2594
|
-
if (base === void 0) {
|
|
2595
|
-
return overrides;
|
|
2596
|
-
}
|
|
2597
|
-
if (overrides === void 0) {
|
|
2598
|
-
return base;
|
|
2599
|
-
}
|
|
2600
|
-
const result = { ...base };
|
|
2601
|
-
for (const key in overrides) {
|
|
2602
|
-
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
2603
|
-
continue;
|
|
2604
|
-
}
|
|
2605
|
-
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
2606
|
-
const overridesValue = overrides[key];
|
|
2607
|
-
if (overridesValue === void 0)
|
|
2608
|
-
continue;
|
|
2609
|
-
const baseValue = key in base ? base[key] : void 0;
|
|
2610
|
-
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
2611
|
-
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
2612
|
-
if (isSourceObject && isTargetObject) {
|
|
2613
|
-
result[key] = mergeObjects(
|
|
2614
|
-
baseValue,
|
|
2615
|
-
overridesValue
|
|
2616
|
-
);
|
|
2617
|
-
} else {
|
|
2618
|
-
result[key] = overridesValue;
|
|
2619
|
-
}
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
return result;
|
|
2623
|
-
}
|
|
2624
|
-
|
|
2625
2633
|
// src/util/now.ts
|
|
2626
2634
|
function now() {
|
|
2627
2635
|
var _a22, _b;
|
|
@@ -5223,6 +5231,9 @@ async function generateText({
|
|
|
5223
5231
|
];
|
|
5224
5232
|
const pendingDeferredToolCalls = /* @__PURE__ */ new Map();
|
|
5225
5233
|
do {
|
|
5234
|
+
if (steps.length > 0) {
|
|
5235
|
+
mergedAbortSignal == null ? void 0 : mergedAbortSignal.throwIfAborted();
|
|
5236
|
+
}
|
|
5226
5237
|
const stepTimeoutId = setAbortTimeout({
|
|
5227
5238
|
abortController: stepAbortController,
|
|
5228
5239
|
label: "Step",
|
|
@@ -6254,27 +6265,27 @@ var toolMetadataSchema = z6.record(
|
|
|
6254
6265
|
var uiMessageChunkSchema = lazySchema(
|
|
6255
6266
|
() => zodSchema(
|
|
6256
6267
|
z6.union([
|
|
6257
|
-
z6.
|
|
6268
|
+
z6.looseObject({
|
|
6258
6269
|
type: z6.literal("text-start"),
|
|
6259
6270
|
id: z6.string(),
|
|
6260
6271
|
providerMetadata: providerMetadataSchema.optional()
|
|
6261
6272
|
}),
|
|
6262
|
-
z6.
|
|
6273
|
+
z6.looseObject({
|
|
6263
6274
|
type: z6.literal("text-delta"),
|
|
6264
6275
|
id: z6.string(),
|
|
6265
6276
|
delta: z6.string(),
|
|
6266
6277
|
providerMetadata: providerMetadataSchema.optional()
|
|
6267
6278
|
}),
|
|
6268
|
-
z6.
|
|
6279
|
+
z6.looseObject({
|
|
6269
6280
|
type: z6.literal("text-end"),
|
|
6270
6281
|
id: z6.string(),
|
|
6271
6282
|
providerMetadata: providerMetadataSchema.optional()
|
|
6272
6283
|
}),
|
|
6273
|
-
z6.
|
|
6284
|
+
z6.looseObject({
|
|
6274
6285
|
type: z6.literal("error"),
|
|
6275
6286
|
errorText: z6.string()
|
|
6276
6287
|
}),
|
|
6277
|
-
z6.
|
|
6288
|
+
z6.looseObject({
|
|
6278
6289
|
type: z6.literal("tool-input-start"),
|
|
6279
6290
|
toolCallId: z6.string(),
|
|
6280
6291
|
toolName: z6.string(),
|
|
@@ -6284,12 +6295,12 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6284
6295
|
dynamic: z6.boolean().optional(),
|
|
6285
6296
|
title: z6.string().optional()
|
|
6286
6297
|
}),
|
|
6287
|
-
z6.
|
|
6298
|
+
z6.looseObject({
|
|
6288
6299
|
type: z6.literal("tool-input-delta"),
|
|
6289
6300
|
toolCallId: z6.string(),
|
|
6290
6301
|
inputTextDelta: z6.string()
|
|
6291
6302
|
}),
|
|
6292
|
-
z6.
|
|
6303
|
+
z6.looseObject({
|
|
6293
6304
|
type: z6.literal("tool-input-available"),
|
|
6294
6305
|
toolCallId: z6.string(),
|
|
6295
6306
|
toolName: z6.string(),
|
|
@@ -6300,7 +6311,7 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6300
6311
|
dynamic: z6.boolean().optional(),
|
|
6301
6312
|
title: z6.string().optional()
|
|
6302
6313
|
}),
|
|
6303
|
-
z6.
|
|
6314
|
+
z6.looseObject({
|
|
6304
6315
|
type: z6.literal("tool-input-error"),
|
|
6305
6316
|
toolCallId: z6.string(),
|
|
6306
6317
|
toolName: z6.string(),
|
|
@@ -6312,14 +6323,14 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6312
6323
|
errorText: z6.string(),
|
|
6313
6324
|
title: z6.string().optional()
|
|
6314
6325
|
}),
|
|
6315
|
-
z6.
|
|
6326
|
+
z6.looseObject({
|
|
6316
6327
|
type: z6.literal("tool-approval-request"),
|
|
6317
6328
|
approvalId: z6.string(),
|
|
6318
6329
|
toolCallId: z6.string(),
|
|
6319
6330
|
isAutomatic: z6.boolean().optional(),
|
|
6320
6331
|
signature: z6.string().optional()
|
|
6321
6332
|
}),
|
|
6322
|
-
z6.
|
|
6333
|
+
z6.looseObject({
|
|
6323
6334
|
type: z6.literal("tool-approval-response"),
|
|
6324
6335
|
approvalId: z6.string(),
|
|
6325
6336
|
approved: z6.boolean(),
|
|
@@ -6327,7 +6338,7 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6327
6338
|
providerExecuted: z6.boolean().optional(),
|
|
6328
6339
|
providerMetadata: providerMetadataSchema.optional()
|
|
6329
6340
|
}),
|
|
6330
|
-
z6.
|
|
6341
|
+
z6.looseObject({
|
|
6331
6342
|
type: z6.literal("tool-output-available"),
|
|
6332
6343
|
toolCallId: z6.string(),
|
|
6333
6344
|
output: z6.unknown(),
|
|
@@ -6337,7 +6348,7 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6337
6348
|
dynamic: z6.boolean().optional(),
|
|
6338
6349
|
preliminary: z6.boolean().optional()
|
|
6339
6350
|
}),
|
|
6340
|
-
z6.
|
|
6351
|
+
z6.looseObject({
|
|
6341
6352
|
type: z6.literal("tool-output-error"),
|
|
6342
6353
|
toolCallId: z6.string(),
|
|
6343
6354
|
errorText: z6.string(),
|
|
@@ -6346,39 +6357,39 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6346
6357
|
toolMetadata: toolMetadataSchema.optional(),
|
|
6347
6358
|
dynamic: z6.boolean().optional()
|
|
6348
6359
|
}),
|
|
6349
|
-
z6.
|
|
6360
|
+
z6.looseObject({
|
|
6350
6361
|
type: z6.literal("tool-output-denied"),
|
|
6351
6362
|
toolCallId: z6.string()
|
|
6352
6363
|
}),
|
|
6353
|
-
z6.
|
|
6364
|
+
z6.looseObject({
|
|
6354
6365
|
type: z6.literal("reasoning-start"),
|
|
6355
6366
|
id: z6.string(),
|
|
6356
6367
|
providerMetadata: providerMetadataSchema.optional()
|
|
6357
6368
|
}),
|
|
6358
|
-
z6.
|
|
6369
|
+
z6.looseObject({
|
|
6359
6370
|
type: z6.literal("reasoning-delta"),
|
|
6360
6371
|
id: z6.string(),
|
|
6361
6372
|
delta: z6.string(),
|
|
6362
6373
|
providerMetadata: providerMetadataSchema.optional()
|
|
6363
6374
|
}),
|
|
6364
|
-
z6.
|
|
6375
|
+
z6.looseObject({
|
|
6365
6376
|
type: z6.literal("reasoning-end"),
|
|
6366
6377
|
id: z6.string(),
|
|
6367
6378
|
providerMetadata: providerMetadataSchema.optional()
|
|
6368
6379
|
}),
|
|
6369
|
-
z6.
|
|
6380
|
+
z6.looseObject({
|
|
6370
6381
|
type: z6.literal("custom"),
|
|
6371
6382
|
kind: z6.string().transform((value) => value),
|
|
6372
6383
|
providerMetadata: providerMetadataSchema.optional()
|
|
6373
6384
|
}),
|
|
6374
|
-
z6.
|
|
6385
|
+
z6.looseObject({
|
|
6375
6386
|
type: z6.literal("source-url"),
|
|
6376
6387
|
sourceId: z6.string(),
|
|
6377
6388
|
url: z6.string(),
|
|
6378
6389
|
title: z6.string().optional(),
|
|
6379
6390
|
providerMetadata: providerMetadataSchema.optional()
|
|
6380
6391
|
}),
|
|
6381
|
-
z6.
|
|
6392
|
+
z6.looseObject({
|
|
6382
6393
|
type: z6.literal("source-document"),
|
|
6383
6394
|
sourceId: z6.string(),
|
|
6384
6395
|
mediaType: z6.string(),
|
|
@@ -6386,19 +6397,19 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6386
6397
|
filename: z6.string().optional(),
|
|
6387
6398
|
providerMetadata: providerMetadataSchema.optional()
|
|
6388
6399
|
}),
|
|
6389
|
-
z6.
|
|
6400
|
+
z6.looseObject({
|
|
6390
6401
|
type: z6.literal("file"),
|
|
6391
6402
|
url: z6.string(),
|
|
6392
6403
|
mediaType: z6.string(),
|
|
6393
6404
|
providerMetadata: providerMetadataSchema.optional()
|
|
6394
6405
|
}),
|
|
6395
|
-
z6.
|
|
6406
|
+
z6.looseObject({
|
|
6396
6407
|
type: z6.literal("reasoning-file"),
|
|
6397
6408
|
url: z6.string(),
|
|
6398
6409
|
mediaType: z6.string(),
|
|
6399
6410
|
providerMetadata: providerMetadataSchema.optional()
|
|
6400
6411
|
}),
|
|
6401
|
-
z6.
|
|
6412
|
+
z6.looseObject({
|
|
6402
6413
|
type: z6.custom(
|
|
6403
6414
|
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
6404
6415
|
{ message: 'Type must start with "data-"' }
|
|
@@ -6407,18 +6418,18 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6407
6418
|
data: z6.unknown(),
|
|
6408
6419
|
transient: z6.boolean().optional()
|
|
6409
6420
|
}),
|
|
6410
|
-
z6.
|
|
6421
|
+
z6.looseObject({
|
|
6411
6422
|
type: z6.literal("start-step")
|
|
6412
6423
|
}),
|
|
6413
|
-
z6.
|
|
6424
|
+
z6.looseObject({
|
|
6414
6425
|
type: z6.literal("finish-step")
|
|
6415
6426
|
}),
|
|
6416
|
-
z6.
|
|
6427
|
+
z6.looseObject({
|
|
6417
6428
|
type: z6.literal("start"),
|
|
6418
6429
|
messageId: z6.string().optional(),
|
|
6419
6430
|
messageMetadata: z6.unknown().optional()
|
|
6420
6431
|
}),
|
|
6421
|
-
z6.
|
|
6432
|
+
z6.looseObject({
|
|
6422
6433
|
type: z6.literal("finish"),
|
|
6423
6434
|
finishReason: z6.enum([
|
|
6424
6435
|
"stop",
|
|
@@ -6430,11 +6441,11 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
6430
6441
|
]).optional(),
|
|
6431
6442
|
messageMetadata: z6.unknown().optional()
|
|
6432
6443
|
}),
|
|
6433
|
-
z6.
|
|
6444
|
+
z6.looseObject({
|
|
6434
6445
|
type: z6.literal("abort"),
|
|
6435
6446
|
reason: z6.string().optional()
|
|
6436
6447
|
}),
|
|
6437
|
-
z6.
|
|
6448
|
+
z6.looseObject({
|
|
6438
6449
|
type: z6.literal("message-metadata"),
|
|
6439
6450
|
messageMetadata: z6.unknown()
|
|
6440
6451
|
})
|
|
@@ -6517,11 +6528,32 @@ function processUIMessageStream({
|
|
|
6517
6528
|
async transform(chunk, controller) {
|
|
6518
6529
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
6519
6530
|
var _a22, _b, _c, _d;
|
|
6531
|
+
function getCurrentStepParts() {
|
|
6532
|
+
const parts = state.message.parts;
|
|
6533
|
+
let currentStepStartIndex = parts.length - 1;
|
|
6534
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") {
|
|
6535
|
+
currentStepStartIndex--;
|
|
6536
|
+
}
|
|
6537
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
6538
|
+
}
|
|
6539
|
+
function getCurrentStepToolInvocations() {
|
|
6540
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
6541
|
+
}
|
|
6520
6542
|
function getToolInvocation(toolCallId) {
|
|
6521
|
-
const toolInvocations =
|
|
6522
|
-
|
|
6543
|
+
const toolInvocations = getCurrentStepToolInvocations();
|
|
6544
|
+
let toolInvocation = toolInvocations.find(
|
|
6523
6545
|
(invocation) => invocation.toolCallId === toolCallId
|
|
6524
6546
|
);
|
|
6547
|
+
if (toolInvocation == null) {
|
|
6548
|
+
const parts = state.message.parts;
|
|
6549
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
6550
|
+
const part = parts[i];
|
|
6551
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
6552
|
+
toolInvocation = part;
|
|
6553
|
+
break;
|
|
6554
|
+
}
|
|
6555
|
+
}
|
|
6556
|
+
}
|
|
6525
6557
|
if (toolInvocation == null) {
|
|
6526
6558
|
throw new UIMessageStreamError({
|
|
6527
6559
|
chunkType: "tool-invocation",
|
|
@@ -6548,9 +6580,9 @@ function processUIMessageStream({
|
|
|
6548
6580
|
}
|
|
6549
6581
|
return toolInvocation;
|
|
6550
6582
|
}
|
|
6551
|
-
function updateToolPart(options) {
|
|
6583
|
+
function updateToolPart(options, existingPart) {
|
|
6552
6584
|
var _a23;
|
|
6553
|
-
const part =
|
|
6585
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
6554
6586
|
(part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
|
|
6555
6587
|
);
|
|
6556
6588
|
const anyOptions = options;
|
|
@@ -6596,9 +6628,9 @@ function processUIMessageStream({
|
|
|
6596
6628
|
});
|
|
6597
6629
|
}
|
|
6598
6630
|
}
|
|
6599
|
-
function updateDynamicToolPart(options) {
|
|
6631
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
6600
6632
|
var _a23, _b2;
|
|
6601
|
-
const part =
|
|
6633
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find(
|
|
6602
6634
|
(part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
|
|
6603
6635
|
);
|
|
6604
6636
|
const anyOptions = options;
|
|
@@ -6789,7 +6821,7 @@ function processUIMessageStream({
|
|
|
6789
6821
|
break;
|
|
6790
6822
|
}
|
|
6791
6823
|
case "tool-input-start": {
|
|
6792
|
-
const toolInvocations =
|
|
6824
|
+
const toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);
|
|
6793
6825
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
6794
6826
|
text: "",
|
|
6795
6827
|
toolName: chunk.toolName,
|
|
@@ -6892,7 +6924,7 @@ function processUIMessageStream({
|
|
|
6892
6924
|
break;
|
|
6893
6925
|
}
|
|
6894
6926
|
case "tool-input-error": {
|
|
6895
|
-
const existingPart =
|
|
6927
|
+
const existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
|
|
6896
6928
|
const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
|
|
6897
6929
|
if (isDynamic) {
|
|
6898
6930
|
updateDynamicToolPart({
|
|
@@ -6963,31 +6995,37 @@ function processUIMessageStream({
|
|
|
6963
6995
|
case "tool-output-available": {
|
|
6964
6996
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6965
6997
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6966
|
-
updateDynamicToolPart(
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6998
|
+
updateDynamicToolPart(
|
|
6999
|
+
{
|
|
7000
|
+
toolCallId: chunk.toolCallId,
|
|
7001
|
+
toolName: toolInvocation.toolName,
|
|
7002
|
+
state: "output-available",
|
|
7003
|
+
input: toolInvocation.input,
|
|
7004
|
+
output: chunk.output,
|
|
7005
|
+
preliminary: chunk.preliminary,
|
|
7006
|
+
providerExecuted: chunk.providerExecuted,
|
|
7007
|
+
providerMetadata: chunk.providerMetadata,
|
|
7008
|
+
title: toolInvocation.title,
|
|
7009
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
7010
|
+
},
|
|
7011
|
+
toolInvocation
|
|
7012
|
+
);
|
|
6978
7013
|
} else {
|
|
6979
|
-
updateToolPart(
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
7014
|
+
updateToolPart(
|
|
7015
|
+
{
|
|
7016
|
+
toolCallId: chunk.toolCallId,
|
|
7017
|
+
toolName: getStaticToolName(toolInvocation),
|
|
7018
|
+
state: "output-available",
|
|
7019
|
+
input: toolInvocation.input,
|
|
7020
|
+
output: chunk.output,
|
|
7021
|
+
providerExecuted: chunk.providerExecuted,
|
|
7022
|
+
preliminary: chunk.preliminary,
|
|
7023
|
+
providerMetadata: chunk.providerMetadata,
|
|
7024
|
+
title: toolInvocation.title,
|
|
7025
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
7026
|
+
},
|
|
7027
|
+
toolInvocation
|
|
7028
|
+
);
|
|
6991
7029
|
}
|
|
6992
7030
|
write();
|
|
6993
7031
|
break;
|
|
@@ -6995,30 +7033,36 @@ function processUIMessageStream({
|
|
|
6995
7033
|
case "tool-output-error": {
|
|
6996
7034
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
6997
7035
|
if (toolInvocation.type === "dynamic-tool") {
|
|
6998
|
-
updateDynamicToolPart(
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7036
|
+
updateDynamicToolPart(
|
|
7037
|
+
{
|
|
7038
|
+
toolCallId: chunk.toolCallId,
|
|
7039
|
+
toolName: toolInvocation.toolName,
|
|
7040
|
+
state: "output-error",
|
|
7041
|
+
input: toolInvocation.input,
|
|
7042
|
+
errorText: chunk.errorText,
|
|
7043
|
+
providerExecuted: chunk.providerExecuted,
|
|
7044
|
+
providerMetadata: chunk.providerMetadata,
|
|
7045
|
+
title: toolInvocation.title,
|
|
7046
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
7047
|
+
},
|
|
7048
|
+
toolInvocation
|
|
7049
|
+
);
|
|
7009
7050
|
} else {
|
|
7010
|
-
updateToolPart(
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7051
|
+
updateToolPart(
|
|
7052
|
+
{
|
|
7053
|
+
toolCallId: chunk.toolCallId,
|
|
7054
|
+
toolName: getStaticToolName(toolInvocation),
|
|
7055
|
+
state: "output-error",
|
|
7056
|
+
input: toolInvocation.input,
|
|
7057
|
+
rawInput: toolInvocation.rawInput,
|
|
7058
|
+
errorText: chunk.errorText,
|
|
7059
|
+
providerExecuted: chunk.providerExecuted,
|
|
7060
|
+
providerMetadata: chunk.providerMetadata,
|
|
7061
|
+
title: toolInvocation.title,
|
|
7062
|
+
toolMetadata: toolInvocation.toolMetadata
|
|
7063
|
+
},
|
|
7064
|
+
toolInvocation
|
|
7065
|
+
);
|
|
7022
7066
|
}
|
|
7023
7067
|
write();
|
|
7024
7068
|
break;
|