@mastra/ai-sdk 1.7.1 → 1.7.2
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/_types/@internal_ai-sdk-v5/dist/index.d.ts +16 -217
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +31 -378
- package/dist/index.cjs +139 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +139 -51
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
|
32
32
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
33
33
|
let _mastra_core_di = require("@mastra/core/di");
|
|
34
34
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
35
|
-
//#region ../../packages/_vendored/ai_v5/dist/dist-
|
|
35
|
+
//#region ../../packages/_vendored/ai_v5/dist/dist-BuEMdYEn.js
|
|
36
36
|
var marker$1$4 = "vercel.ai.error";
|
|
37
37
|
var symbol$1$5 = Symbol.for(marker$1$4);
|
|
38
38
|
var _a$1$5;
|
|
@@ -556,6 +556,26 @@ async function cancelResponseBody$1(response) {
|
|
|
556
556
|
await ((_a2 = response.body) == null ? void 0 : _a2.cancel());
|
|
557
557
|
} catch (e) {}
|
|
558
558
|
}
|
|
559
|
+
var initialGlobalFetch$1 = globalThis.fetch;
|
|
560
|
+
isNodeDefaultFetch$1(initialGlobalFetch$1);
|
|
561
|
+
function isNodeDefaultFetch$1(fetch) {
|
|
562
|
+
const source = Function.prototype.toString.call(fetch);
|
|
563
|
+
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
564
|
+
}
|
|
565
|
+
function getCurrentModulePath$1() {
|
|
566
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
567
|
+
try {
|
|
568
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
569
|
+
const error = /* @__PURE__ */ new Error("Capture current module path");
|
|
570
|
+
Error.captureStackTrace(error, getCurrentModulePath$1);
|
|
571
|
+
const [caller] = error.stack;
|
|
572
|
+
const fileName = caller == null ? void 0 : caller.getFileName();
|
|
573
|
+
if (fileName == null) throw new Error("Unable to determine the current module path");
|
|
574
|
+
return fileName;
|
|
575
|
+
} finally {
|
|
576
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
559
579
|
var DEFAULT_MAX_DOWNLOAD_SIZE$1 = 2 * 1024 * 1024 * 1024;
|
|
560
580
|
async function readResponseWithSizeLimit$1({ response, url, maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE$1 }) {
|
|
561
581
|
const contentLength = response.headers.get("content-length");
|
|
@@ -659,11 +679,11 @@ function withUserAgentSuffix$1(headers, ...userAgentSuffixParts) {
|
|
|
659
679
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
660
680
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
661
681
|
}
|
|
662
|
-
var VERSION$4 = "3.0.
|
|
682
|
+
var VERSION$4 = "3.0.31";
|
|
663
683
|
var getOriginalFetch = () => globalThis.fetch;
|
|
664
|
-
var getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch
|
|
684
|
+
var getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch() }) => {
|
|
665
685
|
try {
|
|
666
|
-
const response = await
|
|
686
|
+
const response = await fetch(url, {
|
|
667
687
|
method: "GET",
|
|
668
688
|
headers: withUserAgentSuffix$1(headers, `ai-sdk/provider-utils/${VERSION$4}`, getRuntimeEnvironmentUserAgent$1()),
|
|
669
689
|
signal: abortSignal
|
|
@@ -889,7 +909,7 @@ function parseJsonEventStream({ stream, schema }) {
|
|
|
889
909
|
} }));
|
|
890
910
|
}
|
|
891
911
|
var getOriginalFetch2 = () => globalThis.fetch;
|
|
892
|
-
var postJsonToApi = async ({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch
|
|
912
|
+
var postJsonToApi = async ({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch }) => postToApi({
|
|
893
913
|
url,
|
|
894
914
|
headers: {
|
|
895
915
|
"Content-Type": "application/json",
|
|
@@ -902,11 +922,11 @@ var postJsonToApi = async ({ url, headers, body, failedResponseHandler, successf
|
|
|
902
922
|
failedResponseHandler,
|
|
903
923
|
successfulResponseHandler,
|
|
904
924
|
abortSignal,
|
|
905
|
-
fetch
|
|
925
|
+
fetch
|
|
906
926
|
});
|
|
907
|
-
var postToApi = async ({ url, headers = {}, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch
|
|
927
|
+
var postToApi = async ({ url, headers = {}, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch2() }) => {
|
|
908
928
|
try {
|
|
909
|
-
const response = await
|
|
929
|
+
const response = await fetch(url, {
|
|
910
930
|
method: "POST",
|
|
911
931
|
headers: withUserAgentSuffix$1(headers, `ai-sdk/provider-utils/${VERSION$4}`, getRuntimeEnvironmentUserAgent$1()),
|
|
912
932
|
body: body.content,
|
|
@@ -2968,7 +2988,7 @@ async function getVercelRequestId() {
|
|
|
2968
2988
|
var _a10;
|
|
2969
2989
|
return (_a10 = getContext().headers) == null ? void 0 : _a10["x-vercel-id"];
|
|
2970
2990
|
}
|
|
2971
|
-
var VERSION$2 = "2.0.
|
|
2991
|
+
var VERSION$2 = "2.0.125";
|
|
2972
2992
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
2973
2993
|
function createGatewayProvider(options = {}) {
|
|
2974
2994
|
var _a10, _b10;
|
|
@@ -4418,19 +4438,48 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4418
4438
|
return stream.pipeThrough(new TransformStream({ async transform(chunk, controller) {
|
|
4419
4439
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
4420
4440
|
var _a16, _b, _c, _d;
|
|
4441
|
+
function getCurrentStepParts() {
|
|
4442
|
+
const parts = state.message.parts;
|
|
4443
|
+
let currentStepStartIndex = parts.length - 1;
|
|
4444
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") currentStepStartIndex--;
|
|
4445
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
4446
|
+
}
|
|
4447
|
+
function getCurrentStepToolInvocations() {
|
|
4448
|
+
return getCurrentStepParts().filter(isToolUIPart$1);
|
|
4449
|
+
}
|
|
4421
4450
|
function getToolInvocation(toolCallId) {
|
|
4422
|
-
|
|
4451
|
+
let toolInvocation = getCurrentStepToolInvocations().find((invocation) => invocation.toolCallId === toolCallId);
|
|
4452
|
+
if (toolInvocation == null) {
|
|
4453
|
+
const parts = state.message.parts;
|
|
4454
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
4455
|
+
const part = parts[i];
|
|
4456
|
+
if (isToolUIPart$1(part) && part.toolCallId === toolCallId) {
|
|
4457
|
+
toolInvocation = part;
|
|
4458
|
+
break;
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4423
4462
|
if (toolInvocation == null) throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
4424
4463
|
return toolInvocation;
|
|
4425
4464
|
}
|
|
4426
4465
|
function getDynamicToolInvocation(toolCallId) {
|
|
4427
|
-
|
|
4466
|
+
let toolInvocation = getCurrentStepParts().filter((part) => part.type === "dynamic-tool").find((invocation) => invocation.toolCallId === toolCallId);
|
|
4467
|
+
if (toolInvocation == null) {
|
|
4468
|
+
const parts = state.message.parts;
|
|
4469
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
4470
|
+
const part = parts[i];
|
|
4471
|
+
if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) {
|
|
4472
|
+
toolInvocation = part;
|
|
4473
|
+
break;
|
|
4474
|
+
}
|
|
4475
|
+
}
|
|
4476
|
+
}
|
|
4428
4477
|
if (toolInvocation == null) throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
4429
4478
|
return toolInvocation;
|
|
4430
4479
|
}
|
|
4431
|
-
function updateToolPart(options) {
|
|
4480
|
+
function updateToolPart(options, existingPart) {
|
|
4432
4481
|
var _a17;
|
|
4433
|
-
const part =
|
|
4482
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => isToolUIPart$1(part2) && part2.toolCallId === options.toolCallId);
|
|
4434
4483
|
const anyOptions = options;
|
|
4435
4484
|
const anyPart = part;
|
|
4436
4485
|
if (part != null) {
|
|
@@ -4455,9 +4504,9 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4455
4504
|
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
4456
4505
|
});
|
|
4457
4506
|
}
|
|
4458
|
-
function updateDynamicToolPart(options) {
|
|
4507
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
4459
4508
|
var _a17, _b2;
|
|
4460
|
-
const part =
|
|
4509
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
4461
4510
|
const anyOptions = options;
|
|
4462
4511
|
const anyPart = part;
|
|
4463
4512
|
if (part != null) {
|
|
@@ -4578,7 +4627,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4578
4627
|
write();
|
|
4579
4628
|
break;
|
|
4580
4629
|
case "tool-input-start": {
|
|
4581
|
-
const toolInvocations =
|
|
4630
|
+
const toolInvocations = getCurrentStepParts().filter(isToolUIPart$1);
|
|
4582
4631
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
4583
4632
|
text: "",
|
|
4584
4633
|
toolName: chunk.toolName,
|
|
@@ -4673,7 +4722,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4673
4722
|
input: toolInvocation.input,
|
|
4674
4723
|
output: chunk.output,
|
|
4675
4724
|
preliminary: chunk.preliminary
|
|
4676
|
-
});
|
|
4725
|
+
}, toolInvocation);
|
|
4677
4726
|
} else {
|
|
4678
4727
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4679
4728
|
updateToolPart({
|
|
@@ -4684,7 +4733,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4684
4733
|
output: chunk.output,
|
|
4685
4734
|
providerExecuted: chunk.providerExecuted,
|
|
4686
4735
|
preliminary: chunk.preliminary
|
|
4687
|
-
});
|
|
4736
|
+
}, toolInvocation);
|
|
4688
4737
|
}
|
|
4689
4738
|
write();
|
|
4690
4739
|
break;
|
|
@@ -4698,7 +4747,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4698
4747
|
input: toolInvocation.input,
|
|
4699
4748
|
errorText: chunk.errorText,
|
|
4700
4749
|
providerExecuted: chunk.providerExecuted
|
|
4701
|
-
});
|
|
4750
|
+
}, toolInvocation);
|
|
4702
4751
|
} else {
|
|
4703
4752
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4704
4753
|
updateToolPart({
|
|
@@ -4709,7 +4758,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4709
4758
|
rawInput: toolInvocation.rawInput,
|
|
4710
4759
|
errorText: chunk.errorText,
|
|
4711
4760
|
providerExecuted: chunk.providerExecuted
|
|
4712
|
-
});
|
|
4761
|
+
}, toolInvocation);
|
|
4713
4762
|
}
|
|
4714
4763
|
write();
|
|
4715
4764
|
break;
|
|
@@ -5000,7 +5049,7 @@ function createUIMessageStream$1({ execute, onError = () => "An error occurred."
|
|
|
5000
5049
|
});
|
|
5001
5050
|
}
|
|
5002
5051
|
//#endregion
|
|
5003
|
-
//#region ../../packages/_vendored/ai_v6/dist/dist-
|
|
5052
|
+
//#region ../../packages/_vendored/ai_v6/dist/dist-BTWHzT8H.js
|
|
5004
5053
|
var marker$1 = "vercel.ai.error";
|
|
5005
5054
|
var symbol$1 = Symbol.for(marker$1);
|
|
5006
5055
|
var _a$1;
|
|
@@ -5340,6 +5389,26 @@ var _b;
|
|
|
5340
5389
|
return AISDKError.hasMarker(error, marker$2);
|
|
5341
5390
|
}
|
|
5342
5391
|
});
|
|
5392
|
+
var initialGlobalFetch = globalThis.fetch;
|
|
5393
|
+
isNodeDefaultFetch(initialGlobalFetch);
|
|
5394
|
+
function isNodeDefaultFetch(fetch) {
|
|
5395
|
+
const source = Function.prototype.toString.call(fetch);
|
|
5396
|
+
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
5397
|
+
}
|
|
5398
|
+
function getCurrentModulePath() {
|
|
5399
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
5400
|
+
try {
|
|
5401
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
5402
|
+
const error = /* @__PURE__ */ new Error("Capture current module path");
|
|
5403
|
+
Error.captureStackTrace(error, getCurrentModulePath);
|
|
5404
|
+
const [caller] = error.stack;
|
|
5405
|
+
const fileName = caller == null ? void 0 : caller.getFileName();
|
|
5406
|
+
if (fileName == null) throw new Error("Unable to determine the current module path");
|
|
5407
|
+
return fileName;
|
|
5408
|
+
} finally {
|
|
5409
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5343
5412
|
var createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator = "-" } = {}) => {
|
|
5344
5413
|
const generator = () => {
|
|
5345
5414
|
const alphabetLength = alphabet.length;
|
|
@@ -7290,6 +7359,25 @@ _a16 = symbol16;
|
|
|
7290
7359
|
function asArray(value) {
|
|
7291
7360
|
return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
7292
7361
|
}
|
|
7362
|
+
function mergeObjects(base, overrides) {
|
|
7363
|
+
if (base === void 0 && overrides === void 0) return;
|
|
7364
|
+
if (base === void 0) return overrides;
|
|
7365
|
+
if (overrides === void 0) return base;
|
|
7366
|
+
const result = { ...base };
|
|
7367
|
+
for (const key in overrides) {
|
|
7368
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
7369
|
+
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
7370
|
+
const overridesValue = overrides[key];
|
|
7371
|
+
if (overridesValue === void 0) continue;
|
|
7372
|
+
const baseValue = key in base ? base[key] : void 0;
|
|
7373
|
+
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
7374
|
+
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
7375
|
+
if (isSourceObject && isTargetObject) result[key] = mergeObjects(baseValue, overridesValue);
|
|
7376
|
+
else result[key] = overridesValue;
|
|
7377
|
+
}
|
|
7378
|
+
}
|
|
7379
|
+
return result;
|
|
7380
|
+
}
|
|
7293
7381
|
var dataContentSchema = zod_v4.z.union([
|
|
7294
7382
|
zod_v4.z.string(),
|
|
7295
7383
|
zod_v4.z.instanceof(Uint8Array),
|
|
@@ -7473,25 +7561,6 @@ zod_v4.z.union([
|
|
|
7473
7561
|
assistantModelMessageSchema,
|
|
7474
7562
|
toolModelMessageSchema
|
|
7475
7563
|
]);
|
|
7476
|
-
function mergeObjects(base, overrides) {
|
|
7477
|
-
if (base === void 0 && overrides === void 0) return;
|
|
7478
|
-
if (base === void 0) return overrides;
|
|
7479
|
-
if (overrides === void 0) return base;
|
|
7480
|
-
const result = { ...base };
|
|
7481
|
-
for (const key in overrides) {
|
|
7482
|
-
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
7483
|
-
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
7484
|
-
const overridesValue = overrides[key];
|
|
7485
|
-
if (overridesValue === void 0) continue;
|
|
7486
|
-
const baseValue = key in base ? base[key] : void 0;
|
|
7487
|
-
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
7488
|
-
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
7489
|
-
if (isSourceObject && isTargetObject) result[key] = mergeObjects(baseValue, overridesValue);
|
|
7490
|
-
else result[key] = overridesValue;
|
|
7491
|
-
}
|
|
7492
|
-
}
|
|
7493
|
-
return result;
|
|
7494
|
-
}
|
|
7495
7564
|
new TextEncoder();
|
|
7496
7565
|
__export({}, {
|
|
7497
7566
|
array: () => array,
|
|
@@ -8103,8 +8172,27 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8103
8172
|
return stream.pipeThrough(new TransformStream({ async transform(chunk, controller) {
|
|
8104
8173
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
8105
8174
|
var _a22, _b, _c, _d;
|
|
8175
|
+
function getCurrentStepParts() {
|
|
8176
|
+
const parts = state.message.parts;
|
|
8177
|
+
let currentStepStartIndex = parts.length - 1;
|
|
8178
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") currentStepStartIndex--;
|
|
8179
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
8180
|
+
}
|
|
8181
|
+
function getCurrentStepToolInvocations() {
|
|
8182
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
8183
|
+
}
|
|
8106
8184
|
function getToolInvocation(toolCallId) {
|
|
8107
|
-
|
|
8185
|
+
let toolInvocation = getCurrentStepToolInvocations().find((invocation) => invocation.toolCallId === toolCallId);
|
|
8186
|
+
if (toolInvocation == null) {
|
|
8187
|
+
const parts = state.message.parts;
|
|
8188
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
8189
|
+
const part = parts[i];
|
|
8190
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
8191
|
+
toolInvocation = part;
|
|
8192
|
+
break;
|
|
8193
|
+
}
|
|
8194
|
+
}
|
|
8195
|
+
}
|
|
8108
8196
|
if (toolInvocation == null) throw new UIMessageStreamError({
|
|
8109
8197
|
chunkType: "tool-invocation",
|
|
8110
8198
|
chunkId: toolCallId,
|
|
@@ -8112,9 +8200,9 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8112
8200
|
});
|
|
8113
8201
|
return toolInvocation;
|
|
8114
8202
|
}
|
|
8115
|
-
function updateToolPart(options) {
|
|
8203
|
+
function updateToolPart(options, existingPart) {
|
|
8116
8204
|
var _a23;
|
|
8117
|
-
const part =
|
|
8205
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);
|
|
8118
8206
|
const anyOptions = options;
|
|
8119
8207
|
const anyPart = part;
|
|
8120
8208
|
if (part != null) {
|
|
@@ -8148,9 +8236,9 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8148
8236
|
...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
8149
8237
|
});
|
|
8150
8238
|
}
|
|
8151
|
-
function updateDynamicToolPart(options) {
|
|
8239
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
8152
8240
|
var _a23, _b2;
|
|
8153
|
-
const part =
|
|
8241
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
8154
8242
|
const anyOptions = options;
|
|
8155
8243
|
const anyPart = part;
|
|
8156
8244
|
if (part != null) {
|
|
@@ -8305,7 +8393,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8305
8393
|
write();
|
|
8306
8394
|
break;
|
|
8307
8395
|
case "tool-input-start": {
|
|
8308
|
-
const toolInvocations =
|
|
8396
|
+
const toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);
|
|
8309
8397
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
8310
8398
|
text: "",
|
|
8311
8399
|
toolName: chunk.toolName,
|
|
@@ -8390,7 +8478,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8390
8478
|
if (onToolCall && !chunk.providerExecuted) await onToolCall({ toolCall: chunk });
|
|
8391
8479
|
break;
|
|
8392
8480
|
case "tool-input-error": {
|
|
8393
|
-
const existingPart =
|
|
8481
|
+
const existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
|
|
8394
8482
|
if (existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic) updateDynamicToolPart({
|
|
8395
8483
|
toolCallId: chunk.toolCallId,
|
|
8396
8484
|
toolName: chunk.toolName,
|
|
@@ -8444,7 +8532,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8444
8532
|
providerMetadata: chunk.providerMetadata,
|
|
8445
8533
|
title: toolInvocation.title,
|
|
8446
8534
|
toolMetadata: toolInvocation.toolMetadata
|
|
8447
|
-
});
|
|
8535
|
+
}, toolInvocation);
|
|
8448
8536
|
else updateToolPart({
|
|
8449
8537
|
toolCallId: chunk.toolCallId,
|
|
8450
8538
|
toolName: getStaticToolName(toolInvocation),
|
|
@@ -8456,7 +8544,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8456
8544
|
providerMetadata: chunk.providerMetadata,
|
|
8457
8545
|
title: toolInvocation.title,
|
|
8458
8546
|
toolMetadata: toolInvocation.toolMetadata
|
|
8459
|
-
});
|
|
8547
|
+
}, toolInvocation);
|
|
8460
8548
|
write();
|
|
8461
8549
|
break;
|
|
8462
8550
|
}
|
|
@@ -8472,7 +8560,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8472
8560
|
providerMetadata: chunk.providerMetadata,
|
|
8473
8561
|
title: toolInvocation.title,
|
|
8474
8562
|
toolMetadata: toolInvocation.toolMetadata
|
|
8475
|
-
});
|
|
8563
|
+
}, toolInvocation);
|
|
8476
8564
|
else updateToolPart({
|
|
8477
8565
|
toolCallId: chunk.toolCallId,
|
|
8478
8566
|
toolName: getStaticToolName(toolInvocation),
|
|
@@ -8484,7 +8572,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8484
8572
|
providerMetadata: chunk.providerMetadata,
|
|
8485
8573
|
title: toolInvocation.title,
|
|
8486
8574
|
toolMetadata: toolInvocation.toolMetadata
|
|
8487
|
-
});
|
|
8575
|
+
}, toolInvocation);
|
|
8488
8576
|
write();
|
|
8489
8577
|
break;
|
|
8490
8578
|
}
|