@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.js
CHANGED
|
@@ -9,7 +9,7 @@ import { MASTRA_RESOURCE_ID_KEY } from "@mastra/core/request-context";
|
|
|
9
9
|
import { MessageList, TripWire, aiV5ModelMessageToV2PromptMessage } from "@mastra/core/agent";
|
|
10
10
|
import { RequestContext } from "@mastra/core/di";
|
|
11
11
|
import { MessageHistory, SemanticRecall, WorkingMemory } from "@mastra/core/processors";
|
|
12
|
-
//#region ../../packages/_vendored/ai_v5/dist/dist-
|
|
12
|
+
//#region ../../packages/_vendored/ai_v5/dist/dist-BuEMdYEn.js
|
|
13
13
|
var marker$1$4 = "vercel.ai.error";
|
|
14
14
|
var symbol$1$5 = Symbol.for(marker$1$4);
|
|
15
15
|
var _a$1$5;
|
|
@@ -533,6 +533,26 @@ async function cancelResponseBody$1(response) {
|
|
|
533
533
|
await ((_a2 = response.body) == null ? void 0 : _a2.cancel());
|
|
534
534
|
} catch (e) {}
|
|
535
535
|
}
|
|
536
|
+
var initialGlobalFetch$1 = globalThis.fetch;
|
|
537
|
+
isNodeDefaultFetch$1(initialGlobalFetch$1);
|
|
538
|
+
function isNodeDefaultFetch$1(fetch) {
|
|
539
|
+
const source = Function.prototype.toString.call(fetch);
|
|
540
|
+
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
541
|
+
}
|
|
542
|
+
function getCurrentModulePath$1() {
|
|
543
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
544
|
+
try {
|
|
545
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
546
|
+
const error = /* @__PURE__ */ new Error("Capture current module path");
|
|
547
|
+
Error.captureStackTrace(error, getCurrentModulePath$1);
|
|
548
|
+
const [caller] = error.stack;
|
|
549
|
+
const fileName = caller == null ? void 0 : caller.getFileName();
|
|
550
|
+
if (fileName == null) throw new Error("Unable to determine the current module path");
|
|
551
|
+
return fileName;
|
|
552
|
+
} finally {
|
|
553
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
536
556
|
var DEFAULT_MAX_DOWNLOAD_SIZE$1 = 2 * 1024 * 1024 * 1024;
|
|
537
557
|
async function readResponseWithSizeLimit$1({ response, url, maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE$1 }) {
|
|
538
558
|
const contentLength = response.headers.get("content-length");
|
|
@@ -636,11 +656,11 @@ function withUserAgentSuffix$1(headers, ...userAgentSuffixParts) {
|
|
|
636
656
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
637
657
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
638
658
|
}
|
|
639
|
-
var VERSION$4 = "3.0.
|
|
659
|
+
var VERSION$4 = "3.0.31";
|
|
640
660
|
var getOriginalFetch = () => globalThis.fetch;
|
|
641
|
-
var getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch
|
|
661
|
+
var getFromApi = async ({ url, headers = {}, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch() }) => {
|
|
642
662
|
try {
|
|
643
|
-
const response = await
|
|
663
|
+
const response = await fetch(url, {
|
|
644
664
|
method: "GET",
|
|
645
665
|
headers: withUserAgentSuffix$1(headers, `ai-sdk/provider-utils/${VERSION$4}`, getRuntimeEnvironmentUserAgent$1()),
|
|
646
666
|
signal: abortSignal
|
|
@@ -866,7 +886,7 @@ function parseJsonEventStream({ stream, schema }) {
|
|
|
866
886
|
} }));
|
|
867
887
|
}
|
|
868
888
|
var getOriginalFetch2 = () => globalThis.fetch;
|
|
869
|
-
var postJsonToApi = async ({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch
|
|
889
|
+
var postJsonToApi = async ({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, fetch }) => postToApi({
|
|
870
890
|
url,
|
|
871
891
|
headers: {
|
|
872
892
|
"Content-Type": "application/json",
|
|
@@ -879,11 +899,11 @@ var postJsonToApi = async ({ url, headers, body, failedResponseHandler, successf
|
|
|
879
899
|
failedResponseHandler,
|
|
880
900
|
successfulResponseHandler,
|
|
881
901
|
abortSignal,
|
|
882
|
-
fetch
|
|
902
|
+
fetch
|
|
883
903
|
});
|
|
884
|
-
var postToApi = async ({ url, headers = {}, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch
|
|
904
|
+
var postToApi = async ({ url, headers = {}, body, successfulResponseHandler, failedResponseHandler, abortSignal, fetch = getOriginalFetch2() }) => {
|
|
885
905
|
try {
|
|
886
|
-
const response = await
|
|
906
|
+
const response = await fetch(url, {
|
|
887
907
|
method: "POST",
|
|
888
908
|
headers: withUserAgentSuffix$1(headers, `ai-sdk/provider-utils/${VERSION$4}`, getRuntimeEnvironmentUserAgent$1()),
|
|
889
909
|
body: body.content,
|
|
@@ -2945,7 +2965,7 @@ async function getVercelRequestId() {
|
|
|
2945
2965
|
var _a10;
|
|
2946
2966
|
return (_a10 = getContext().headers) == null ? void 0 : _a10["x-vercel-id"];
|
|
2947
2967
|
}
|
|
2948
|
-
var VERSION$2 = "2.0.
|
|
2968
|
+
var VERSION$2 = "2.0.125";
|
|
2949
2969
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
2950
2970
|
function createGatewayProvider(options = {}) {
|
|
2951
2971
|
var _a10, _b10;
|
|
@@ -4395,19 +4415,48 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4395
4415
|
return stream.pipeThrough(new TransformStream({ async transform(chunk, controller) {
|
|
4396
4416
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
4397
4417
|
var _a16, _b, _c, _d;
|
|
4418
|
+
function getCurrentStepParts() {
|
|
4419
|
+
const parts = state.message.parts;
|
|
4420
|
+
let currentStepStartIndex = parts.length - 1;
|
|
4421
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") currentStepStartIndex--;
|
|
4422
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
4423
|
+
}
|
|
4424
|
+
function getCurrentStepToolInvocations() {
|
|
4425
|
+
return getCurrentStepParts().filter(isToolUIPart$1);
|
|
4426
|
+
}
|
|
4398
4427
|
function getToolInvocation(toolCallId) {
|
|
4399
|
-
|
|
4428
|
+
let toolInvocation = getCurrentStepToolInvocations().find((invocation) => invocation.toolCallId === toolCallId);
|
|
4429
|
+
if (toolInvocation == null) {
|
|
4430
|
+
const parts = state.message.parts;
|
|
4431
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
4432
|
+
const part = parts[i];
|
|
4433
|
+
if (isToolUIPart$1(part) && part.toolCallId === toolCallId) {
|
|
4434
|
+
toolInvocation = part;
|
|
4435
|
+
break;
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4400
4439
|
if (toolInvocation == null) throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
4401
4440
|
return toolInvocation;
|
|
4402
4441
|
}
|
|
4403
4442
|
function getDynamicToolInvocation(toolCallId) {
|
|
4404
|
-
|
|
4443
|
+
let toolInvocation = getCurrentStepParts().filter((part) => part.type === "dynamic-tool").find((invocation) => invocation.toolCallId === toolCallId);
|
|
4444
|
+
if (toolInvocation == null) {
|
|
4445
|
+
const parts = state.message.parts;
|
|
4446
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
4447
|
+
const part = parts[i];
|
|
4448
|
+
if (part.type === "dynamic-tool" && part.toolCallId === toolCallId) {
|
|
4449
|
+
toolInvocation = part;
|
|
4450
|
+
break;
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4405
4454
|
if (toolInvocation == null) throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
4406
4455
|
return toolInvocation;
|
|
4407
4456
|
}
|
|
4408
|
-
function updateToolPart(options) {
|
|
4457
|
+
function updateToolPart(options, existingPart) {
|
|
4409
4458
|
var _a17;
|
|
4410
|
-
const part =
|
|
4459
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => isToolUIPart$1(part2) && part2.toolCallId === options.toolCallId);
|
|
4411
4460
|
const anyOptions = options;
|
|
4412
4461
|
const anyPart = part;
|
|
4413
4462
|
if (part != null) {
|
|
@@ -4432,9 +4481,9 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4432
4481
|
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
4433
4482
|
});
|
|
4434
4483
|
}
|
|
4435
|
-
function updateDynamicToolPart(options) {
|
|
4484
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
4436
4485
|
var _a17, _b2;
|
|
4437
|
-
const part =
|
|
4486
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
4438
4487
|
const anyOptions = options;
|
|
4439
4488
|
const anyPart = part;
|
|
4440
4489
|
if (part != null) {
|
|
@@ -4555,7 +4604,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4555
4604
|
write();
|
|
4556
4605
|
break;
|
|
4557
4606
|
case "tool-input-start": {
|
|
4558
|
-
const toolInvocations =
|
|
4607
|
+
const toolInvocations = getCurrentStepParts().filter(isToolUIPart$1);
|
|
4559
4608
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
4560
4609
|
text: "",
|
|
4561
4610
|
toolName: chunk.toolName,
|
|
@@ -4650,7 +4699,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4650
4699
|
input: toolInvocation.input,
|
|
4651
4700
|
output: chunk.output,
|
|
4652
4701
|
preliminary: chunk.preliminary
|
|
4653
|
-
});
|
|
4702
|
+
}, toolInvocation);
|
|
4654
4703
|
} else {
|
|
4655
4704
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4656
4705
|
updateToolPart({
|
|
@@ -4661,7 +4710,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4661
4710
|
output: chunk.output,
|
|
4662
4711
|
providerExecuted: chunk.providerExecuted,
|
|
4663
4712
|
preliminary: chunk.preliminary
|
|
4664
|
-
});
|
|
4713
|
+
}, toolInvocation);
|
|
4665
4714
|
}
|
|
4666
4715
|
write();
|
|
4667
4716
|
break;
|
|
@@ -4675,7 +4724,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4675
4724
|
input: toolInvocation.input,
|
|
4676
4725
|
errorText: chunk.errorText,
|
|
4677
4726
|
providerExecuted: chunk.providerExecuted
|
|
4678
|
-
});
|
|
4727
|
+
}, toolInvocation);
|
|
4679
4728
|
} else {
|
|
4680
4729
|
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
4681
4730
|
updateToolPart({
|
|
@@ -4686,7 +4735,7 @@ function processUIMessageStream$1({ stream, messageMetadataSchema, dataPartSchem
|
|
|
4686
4735
|
rawInput: toolInvocation.rawInput,
|
|
4687
4736
|
errorText: chunk.errorText,
|
|
4688
4737
|
providerExecuted: chunk.providerExecuted
|
|
4689
|
-
});
|
|
4738
|
+
}, toolInvocation);
|
|
4690
4739
|
}
|
|
4691
4740
|
write();
|
|
4692
4741
|
break;
|
|
@@ -4977,7 +5026,7 @@ function createUIMessageStream$1({ execute, onError = () => "An error occurred."
|
|
|
4977
5026
|
});
|
|
4978
5027
|
}
|
|
4979
5028
|
//#endregion
|
|
4980
|
-
//#region ../../packages/_vendored/ai_v6/dist/dist-
|
|
5029
|
+
//#region ../../packages/_vendored/ai_v6/dist/dist-BTWHzT8H.js
|
|
4981
5030
|
var marker$1 = "vercel.ai.error";
|
|
4982
5031
|
var symbol$1 = Symbol.for(marker$1);
|
|
4983
5032
|
var _a$1;
|
|
@@ -5317,6 +5366,26 @@ var _b;
|
|
|
5317
5366
|
return AISDKError.hasMarker(error, marker$2);
|
|
5318
5367
|
}
|
|
5319
5368
|
});
|
|
5369
|
+
var initialGlobalFetch = globalThis.fetch;
|
|
5370
|
+
isNodeDefaultFetch(initialGlobalFetch);
|
|
5371
|
+
function isNodeDefaultFetch(fetch) {
|
|
5372
|
+
const source = Function.prototype.toString.call(fetch);
|
|
5373
|
+
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
5374
|
+
}
|
|
5375
|
+
function getCurrentModulePath() {
|
|
5376
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
5377
|
+
try {
|
|
5378
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
5379
|
+
const error = /* @__PURE__ */ new Error("Capture current module path");
|
|
5380
|
+
Error.captureStackTrace(error, getCurrentModulePath);
|
|
5381
|
+
const [caller] = error.stack;
|
|
5382
|
+
const fileName = caller == null ? void 0 : caller.getFileName();
|
|
5383
|
+
if (fileName == null) throw new Error("Unable to determine the current module path");
|
|
5384
|
+
return fileName;
|
|
5385
|
+
} finally {
|
|
5386
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5320
5389
|
var createIdGenerator = ({ prefix, size = 16, alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator = "-" } = {}) => {
|
|
5321
5390
|
const generator = () => {
|
|
5322
5391
|
const alphabetLength = alphabet.length;
|
|
@@ -7267,6 +7336,25 @@ _a16 = symbol16;
|
|
|
7267
7336
|
function asArray(value) {
|
|
7268
7337
|
return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
7269
7338
|
}
|
|
7339
|
+
function mergeObjects(base, overrides) {
|
|
7340
|
+
if (base === void 0 && overrides === void 0) return;
|
|
7341
|
+
if (base === void 0) return overrides;
|
|
7342
|
+
if (overrides === void 0) return base;
|
|
7343
|
+
const result = { ...base };
|
|
7344
|
+
for (const key in overrides) {
|
|
7345
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
7346
|
+
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
7347
|
+
const overridesValue = overrides[key];
|
|
7348
|
+
if (overridesValue === void 0) continue;
|
|
7349
|
+
const baseValue = key in base ? base[key] : void 0;
|
|
7350
|
+
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
7351
|
+
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
7352
|
+
if (isSourceObject && isTargetObject) result[key] = mergeObjects(baseValue, overridesValue);
|
|
7353
|
+
else result[key] = overridesValue;
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
return result;
|
|
7357
|
+
}
|
|
7270
7358
|
var dataContentSchema = z.union([
|
|
7271
7359
|
z.string(),
|
|
7272
7360
|
z.instanceof(Uint8Array),
|
|
@@ -7450,25 +7538,6 @@ z.union([
|
|
|
7450
7538
|
assistantModelMessageSchema,
|
|
7451
7539
|
toolModelMessageSchema
|
|
7452
7540
|
]);
|
|
7453
|
-
function mergeObjects(base, overrides) {
|
|
7454
|
-
if (base === void 0 && overrides === void 0) return;
|
|
7455
|
-
if (base === void 0) return overrides;
|
|
7456
|
-
if (overrides === void 0) return base;
|
|
7457
|
-
const result = { ...base };
|
|
7458
|
-
for (const key in overrides) {
|
|
7459
|
-
if (key === "__proto__" || key === "constructor" || key === "prototype") continue;
|
|
7460
|
-
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
7461
|
-
const overridesValue = overrides[key];
|
|
7462
|
-
if (overridesValue === void 0) continue;
|
|
7463
|
-
const baseValue = key in base ? base[key] : void 0;
|
|
7464
|
-
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
7465
|
-
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
7466
|
-
if (isSourceObject && isTargetObject) result[key] = mergeObjects(baseValue, overridesValue);
|
|
7467
|
-
else result[key] = overridesValue;
|
|
7468
|
-
}
|
|
7469
|
-
}
|
|
7470
|
-
return result;
|
|
7471
|
-
}
|
|
7472
7541
|
new TextEncoder();
|
|
7473
7542
|
__export({}, {
|
|
7474
7543
|
array: () => array,
|
|
@@ -8080,8 +8149,27 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8080
8149
|
return stream.pipeThrough(new TransformStream({ async transform(chunk, controller) {
|
|
8081
8150
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
8082
8151
|
var _a22, _b, _c, _d;
|
|
8152
|
+
function getCurrentStepParts() {
|
|
8153
|
+
const parts = state.message.parts;
|
|
8154
|
+
let currentStepStartIndex = parts.length - 1;
|
|
8155
|
+
while (currentStepStartIndex >= 0 && parts[currentStepStartIndex].type !== "step-start") currentStepStartIndex--;
|
|
8156
|
+
return parts.slice(currentStepStartIndex + 1);
|
|
8157
|
+
}
|
|
8158
|
+
function getCurrentStepToolInvocations() {
|
|
8159
|
+
return getCurrentStepParts().filter(isToolUIPart);
|
|
8160
|
+
}
|
|
8083
8161
|
function getToolInvocation(toolCallId) {
|
|
8084
|
-
|
|
8162
|
+
let toolInvocation = getCurrentStepToolInvocations().find((invocation) => invocation.toolCallId === toolCallId);
|
|
8163
|
+
if (toolInvocation == null) {
|
|
8164
|
+
const parts = state.message.parts;
|
|
8165
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
8166
|
+
const part = parts[i];
|
|
8167
|
+
if (isToolUIPart(part) && part.toolCallId === toolCallId) {
|
|
8168
|
+
toolInvocation = part;
|
|
8169
|
+
break;
|
|
8170
|
+
}
|
|
8171
|
+
}
|
|
8172
|
+
}
|
|
8085
8173
|
if (toolInvocation == null) throw new UIMessageStreamError({
|
|
8086
8174
|
chunkType: "tool-invocation",
|
|
8087
8175
|
chunkId: toolCallId,
|
|
@@ -8089,9 +8177,9 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8089
8177
|
});
|
|
8090
8178
|
return toolInvocation;
|
|
8091
8179
|
}
|
|
8092
|
-
function updateToolPart(options) {
|
|
8180
|
+
function updateToolPart(options, existingPart) {
|
|
8093
8181
|
var _a23;
|
|
8094
|
-
const part =
|
|
8182
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId);
|
|
8095
8183
|
const anyOptions = options;
|
|
8096
8184
|
const anyPart = part;
|
|
8097
8185
|
if (part != null) {
|
|
@@ -8125,9 +8213,9 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8125
8213
|
...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
8126
8214
|
});
|
|
8127
8215
|
}
|
|
8128
|
-
function updateDynamicToolPart(options) {
|
|
8216
|
+
function updateDynamicToolPart(options, existingPart) {
|
|
8129
8217
|
var _a23, _b2;
|
|
8130
|
-
const part =
|
|
8218
|
+
const part = existingPart != null ? existingPart : getCurrentStepParts().find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
8131
8219
|
const anyOptions = options;
|
|
8132
8220
|
const anyPart = part;
|
|
8133
8221
|
if (part != null) {
|
|
@@ -8282,7 +8370,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8282
8370
|
write();
|
|
8283
8371
|
break;
|
|
8284
8372
|
case "tool-input-start": {
|
|
8285
|
-
const toolInvocations =
|
|
8373
|
+
const toolInvocations = getCurrentStepParts().filter(isStaticToolUIPart);
|
|
8286
8374
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
8287
8375
|
text: "",
|
|
8288
8376
|
toolName: chunk.toolName,
|
|
@@ -8367,7 +8455,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8367
8455
|
if (onToolCall && !chunk.providerExecuted) await onToolCall({ toolCall: chunk });
|
|
8368
8456
|
break;
|
|
8369
8457
|
case "tool-input-error": {
|
|
8370
|
-
const existingPart =
|
|
8458
|
+
const existingPart = getCurrentStepParts().filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
|
|
8371
8459
|
if (existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic) updateDynamicToolPart({
|
|
8372
8460
|
toolCallId: chunk.toolCallId,
|
|
8373
8461
|
toolName: chunk.toolName,
|
|
@@ -8421,7 +8509,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8421
8509
|
providerMetadata: chunk.providerMetadata,
|
|
8422
8510
|
title: toolInvocation.title,
|
|
8423
8511
|
toolMetadata: toolInvocation.toolMetadata
|
|
8424
|
-
});
|
|
8512
|
+
}, toolInvocation);
|
|
8425
8513
|
else updateToolPart({
|
|
8426
8514
|
toolCallId: chunk.toolCallId,
|
|
8427
8515
|
toolName: getStaticToolName(toolInvocation),
|
|
@@ -8433,7 +8521,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8433
8521
|
providerMetadata: chunk.providerMetadata,
|
|
8434
8522
|
title: toolInvocation.title,
|
|
8435
8523
|
toolMetadata: toolInvocation.toolMetadata
|
|
8436
|
-
});
|
|
8524
|
+
}, toolInvocation);
|
|
8437
8525
|
write();
|
|
8438
8526
|
break;
|
|
8439
8527
|
}
|
|
@@ -8449,7 +8537,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8449
8537
|
providerMetadata: chunk.providerMetadata,
|
|
8450
8538
|
title: toolInvocation.title,
|
|
8451
8539
|
toolMetadata: toolInvocation.toolMetadata
|
|
8452
|
-
});
|
|
8540
|
+
}, toolInvocation);
|
|
8453
8541
|
else updateToolPart({
|
|
8454
8542
|
toolCallId: chunk.toolCallId,
|
|
8455
8543
|
toolName: getStaticToolName(toolInvocation),
|
|
@@ -8461,7 +8549,7 @@ function processUIMessageStream({ stream, messageMetadataSchema, dataPartSchemas
|
|
|
8461
8549
|
providerMetadata: chunk.providerMetadata,
|
|
8462
8550
|
title: toolInvocation.title,
|
|
8463
8551
|
toolMetadata: toolInvocation.toolMetadata
|
|
8464
|
-
});
|
|
8552
|
+
}, toolInvocation);
|
|
8465
8553
|
write();
|
|
8466
8554
|
break;
|
|
8467
8555
|
}
|