@mastra/react 0.2.2 → 0.2.3
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 +52 -0
- package/dist/{chunk-REDZDNFN-C5a6GuK0.js → chunk-REDZDNFN-B1ouuY83.js} +2 -2
- package/dist/{chunk-REDZDNFN-C5a6GuK0.js.map → chunk-REDZDNFN-B1ouuY83.js.map} +1 -1
- package/dist/{chunk-REDZDNFN-vi5yKtN5.cjs → chunk-REDZDNFN-CbkG5d3w.cjs} +2 -2
- package/dist/{chunk-REDZDNFN-vi5yKtN5.cjs.map → chunk-REDZDNFN-CbkG5d3w.cjs.map} +1 -1
- package/dist/{index-OZrcVzMn.js → index-BQSALCsO.js} +57 -22
- package/dist/index-BQSALCsO.js.map +1 -0
- package/dist/{index-DUTv-1fm.cjs → index-DT_KGByV.cjs} +57 -22
- package/dist/index-DT_KGByV.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{token-6GSAFR2W-XRCSVUPZ-CxcM_lpA.cjs → token-6GSAFR2W-XRCSVUPZ-D4lFShVi.cjs} +3 -3
- package/dist/{token-6GSAFR2W-XRCSVUPZ-CxcM_lpA.cjs.map → token-6GSAFR2W-XRCSVUPZ-D4lFShVi.cjs.map} +1 -1
- package/dist/{token-6GSAFR2W-XRCSVUPZ-oh_q0WOI.js → token-6GSAFR2W-XRCSVUPZ-nW1dYF0l.js} +3 -3
- package/dist/{token-6GSAFR2W-XRCSVUPZ-oh_q0WOI.js.map → token-6GSAFR2W-XRCSVUPZ-nW1dYF0l.js.map} +1 -1
- package/dist/{token-util-NEHG7TUY-U7CX7GS4-CwzYo-I6.cjs → token-util-NEHG7TUY-U7CX7GS4-BZFIAvf9.cjs} +2 -2
- package/dist/{token-util-NEHG7TUY-U7CX7GS4-CwzYo-I6.cjs.map → token-util-NEHG7TUY-U7CX7GS4-BZFIAvf9.cjs.map} +1 -1
- package/dist/{token-util-NEHG7TUY-U7CX7GS4-D2Go4cJt.js → token-util-NEHG7TUY-U7CX7GS4-IihD8c3p.js} +2 -2
- package/dist/{token-util-NEHG7TUY-U7CX7GS4-D2Go4cJt.js.map → token-util-NEHG7TUY-U7CX7GS4-IihD8c3p.js.map} +1 -1
- package/package.json +3 -3
- package/dist/index-DUTv-1fm.cjs.map +0 -1
- package/dist/index-OZrcVzMn.js.map +0 -1
|
@@ -114,6 +114,25 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
|
|
|
114
114
|
steps: newSteps
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
+
if (chunk.type === "workflow-step-progress") {
|
|
118
|
+
const progressSteps = {
|
|
119
|
+
...prev?.steps,
|
|
120
|
+
[chunk.payload.id]: {
|
|
121
|
+
...prev?.steps?.[chunk.payload.id],
|
|
122
|
+
foreachProgress: {
|
|
123
|
+
completedCount: chunk.payload.completedCount,
|
|
124
|
+
totalCount: chunk.payload.totalCount,
|
|
125
|
+
currentIndex: chunk.payload.currentIndex,
|
|
126
|
+
iterationStatus: chunk.payload.iterationStatus,
|
|
127
|
+
iterationOutput: chunk.payload.iterationOutput
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return {
|
|
132
|
+
...prev,
|
|
133
|
+
steps: progressSteps
|
|
134
|
+
};
|
|
135
|
+
}
|
|
117
136
|
if (chunk.type === "workflow-step-result") {
|
|
118
137
|
return {
|
|
119
138
|
...prev,
|
|
@@ -3269,8 +3288,8 @@ var require_get_vercel_oidc_token = __commonJS$3({
|
|
|
3269
3288
|
}
|
|
3270
3289
|
try {
|
|
3271
3290
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
3272
|
-
await Promise.resolve().then(() => require('./token-util-NEHG7TUY-U7CX7GS4-
|
|
3273
|
-
await Promise.resolve().then(() => require('./token-6GSAFR2W-XRCSVUPZ-
|
|
3291
|
+
await Promise.resolve().then(() => require('./token-util-NEHG7TUY-U7CX7GS4-BZFIAvf9.cjs')),
|
|
3292
|
+
await Promise.resolve().then(() => require('./token-6GSAFR2W-XRCSVUPZ-D4lFShVi.cjs'))
|
|
3274
3293
|
]);
|
|
3275
3294
|
if (!token || isExpired(getTokenPayload(token))) {
|
|
3276
3295
|
await refreshToken();
|
|
@@ -10207,6 +10226,16 @@ function findToolCallArgs(messages, toolCallId) {
|
|
|
10207
10226
|
function filterDataParts(parts) {
|
|
10208
10227
|
return parts.filter((part) => !part.type.startsWith("data-"));
|
|
10209
10228
|
}
|
|
10229
|
+
function filterEmptyTextParts(parts) {
|
|
10230
|
+
const hasNonEmptyParts = parts.some((part) => !(part.type === "text" && part.text === ""));
|
|
10231
|
+
if (!hasNonEmptyParts) return parts;
|
|
10232
|
+
return parts.filter((part) => {
|
|
10233
|
+
if (part.type === "text") {
|
|
10234
|
+
return part.text !== "";
|
|
10235
|
+
}
|
|
10236
|
+
return true;
|
|
10237
|
+
});
|
|
10238
|
+
}
|
|
10210
10239
|
var AIV4Adapter = class {
|
|
10211
10240
|
/**
|
|
10212
10241
|
* Convert MastraDBMessage to AI SDK V4 UIMessage
|
|
@@ -10342,9 +10371,10 @@ var AIV4Adapter = class {
|
|
|
10342
10371
|
* Convert AI SDK V4 UIMessage to MastraDBMessage
|
|
10343
10372
|
*/
|
|
10344
10373
|
static fromUIMessage(message, ctx, messageSource) {
|
|
10374
|
+
const filteredParts = message.parts ? filterEmptyTextParts(message.parts) : [];
|
|
10345
10375
|
const content = {
|
|
10346
10376
|
format: 2,
|
|
10347
|
-
parts:
|
|
10377
|
+
parts: filteredParts
|
|
10348
10378
|
};
|
|
10349
10379
|
if (message.toolInvocations) content.toolInvocations = message.toolInvocations;
|
|
10350
10380
|
if (message.reasoning) content.reasoning = message.reasoning;
|
|
@@ -10541,9 +10571,10 @@ var AIV4Adapter = class {
|
|
|
10541
10571
|
}
|
|
10542
10572
|
}
|
|
10543
10573
|
}
|
|
10574
|
+
const filteredParts = filterEmptyTextParts(parts);
|
|
10544
10575
|
const content = {
|
|
10545
10576
|
format: 2,
|
|
10546
|
-
parts
|
|
10577
|
+
parts: filteredParts
|
|
10547
10578
|
};
|
|
10548
10579
|
if (toolInvocations.length) content.toolInvocations = toolInvocations;
|
|
10549
10580
|
if (typeof coreMessage.content === `string`) content.content = coreMessage.content;
|
|
@@ -10569,6 +10600,16 @@ var AIV4Adapter = class {
|
|
|
10569
10600
|
};
|
|
10570
10601
|
|
|
10571
10602
|
// src/agent/message-list/adapters/AIV5Adapter.ts
|
|
10603
|
+
function filterEmptyTextParts2(parts) {
|
|
10604
|
+
const hasNonEmptyParts = parts.some((part) => !(part.type === "text" && part.text === ""));
|
|
10605
|
+
if (!hasNonEmptyParts) return parts;
|
|
10606
|
+
return parts.filter((part) => {
|
|
10607
|
+
if (part.type === "text") {
|
|
10608
|
+
return part.text !== "";
|
|
10609
|
+
}
|
|
10610
|
+
return true;
|
|
10611
|
+
});
|
|
10612
|
+
}
|
|
10572
10613
|
function getToolName(type) {
|
|
10573
10614
|
if (typeof type === "object" && type && "type" in type) {
|
|
10574
10615
|
type = type.type;
|
|
@@ -10901,6 +10942,7 @@ var AIV5Adapter = class {
|
|
|
10901
10942
|
}
|
|
10902
10943
|
return null;
|
|
10903
10944
|
}).filter((p) => p !== null);
|
|
10945
|
+
const filteredV2Parts = filterEmptyTextParts2(v2Parts);
|
|
10904
10946
|
return {
|
|
10905
10947
|
id: uiMsg.id,
|
|
10906
10948
|
role: uiMsg.role,
|
|
@@ -10909,7 +10951,7 @@ var AIV5Adapter = class {
|
|
|
10909
10951
|
resourceId,
|
|
10910
10952
|
content: {
|
|
10911
10953
|
format: 2,
|
|
10912
|
-
parts:
|
|
10954
|
+
parts: filteredV2Parts,
|
|
10913
10955
|
toolInvocations,
|
|
10914
10956
|
reasoning,
|
|
10915
10957
|
experimental_attachments,
|
|
@@ -10969,7 +11011,6 @@ var AIV5Adapter = class {
|
|
|
10969
11011
|
const toolInvocations = [];
|
|
10970
11012
|
const reasoningParts = [];
|
|
10971
11013
|
const experimental_attachments = [];
|
|
10972
|
-
let lastPartWasToolResult = false;
|
|
10973
11014
|
for (const part of content) {
|
|
10974
11015
|
if (part.type === "text") {
|
|
10975
11016
|
const textPart = {
|
|
@@ -10980,7 +11021,6 @@ var AIV5Adapter = class {
|
|
|
10980
11021
|
textPart.providerMetadata = part.providerOptions;
|
|
10981
11022
|
}
|
|
10982
11023
|
mastraDBParts.push(textPart);
|
|
10983
|
-
lastPartWasToolResult = false;
|
|
10984
11024
|
} else if (part.type === "tool-call") {
|
|
10985
11025
|
const toolCallPart = part;
|
|
10986
11026
|
const toolInvocationPart = {
|
|
@@ -11002,7 +11042,6 @@ var AIV5Adapter = class {
|
|
|
11002
11042
|
args: toolCallPart.input,
|
|
11003
11043
|
state: "call"
|
|
11004
11044
|
});
|
|
11005
|
-
lastPartWasToolResult = false;
|
|
11006
11045
|
} else if (part.type === "tool-result") {
|
|
11007
11046
|
const toolResultPart = part;
|
|
11008
11047
|
const matchingCall = toolInvocations.find((inv) => inv.toolCallId === toolResultPart.toolCallId);
|
|
@@ -11040,7 +11079,6 @@ var AIV5Adapter = class {
|
|
|
11040
11079
|
updateMatchingCallInvocationResult(toolResultPart, toolInvocationPart.toolInvocation);
|
|
11041
11080
|
mastraDBParts.push(toolInvocationPart);
|
|
11042
11081
|
}
|
|
11043
|
-
lastPartWasToolResult = true;
|
|
11044
11082
|
} else if (part.type === "reasoning") {
|
|
11045
11083
|
const v2ReasoningPart = {
|
|
11046
11084
|
type: "reasoning",
|
|
@@ -11052,7 +11090,6 @@ var AIV5Adapter = class {
|
|
|
11052
11090
|
}
|
|
11053
11091
|
mastraDBParts.push(v2ReasoningPart);
|
|
11054
11092
|
reasoningParts.push(part.text);
|
|
11055
|
-
lastPartWasToolResult = false;
|
|
11056
11093
|
} else if (part.type === "image") {
|
|
11057
11094
|
const imagePart = part;
|
|
11058
11095
|
const mimeType = imagePart.mediaType || "image/jpeg";
|
|
@@ -11070,7 +11107,6 @@ var AIV5Adapter = class {
|
|
|
11070
11107
|
url: imageData,
|
|
11071
11108
|
contentType: mimeType
|
|
11072
11109
|
});
|
|
11073
|
-
lastPartWasToolResult = false;
|
|
11074
11110
|
} else if (part.type === "file") {
|
|
11075
11111
|
const filePart = part;
|
|
11076
11112
|
const mimeType = filePart.mediaType || "application/octet-stream";
|
|
@@ -11088,17 +11124,10 @@ var AIV5Adapter = class {
|
|
|
11088
11124
|
url: fileData,
|
|
11089
11125
|
contentType: mimeType
|
|
11090
11126
|
});
|
|
11091
|
-
lastPartWasToolResult = false;
|
|
11092
|
-
}
|
|
11093
|
-
}
|
|
11094
|
-
if (modelMsg.role === "assistant" && lastPartWasToolResult && mastraDBParts.length > 0) {
|
|
11095
|
-
const lastPart = mastraDBParts[mastraDBParts.length - 1];
|
|
11096
|
-
if (lastPart && lastPart.type !== "text") {
|
|
11097
|
-
const emptyTextPart = { type: "text", text: "" };
|
|
11098
|
-
mastraDBParts.push(emptyTextPart);
|
|
11099
11127
|
}
|
|
11100
11128
|
}
|
|
11101
|
-
const
|
|
11129
|
+
const filteredMastraDBParts = filterEmptyTextParts2(mastraDBParts);
|
|
11130
|
+
const contentString = filteredMastraDBParts.filter((p) => p.type === "text").map((p) => p.text).join("\n");
|
|
11102
11131
|
const metadata = "metadata" in modelMsg && modelMsg.metadata !== null && modelMsg.metadata !== void 0 ? modelMsg.metadata : {};
|
|
11103
11132
|
const id = `id` in modelMsg && typeof modelMsg.id === `string` ? modelMsg.id : `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
11104
11133
|
const message = {
|
|
@@ -11107,7 +11136,7 @@ var AIV5Adapter = class {
|
|
|
11107
11136
|
createdAt: /* @__PURE__ */ new Date(),
|
|
11108
11137
|
content: {
|
|
11109
11138
|
format: 2,
|
|
11110
|
-
parts:
|
|
11139
|
+
parts: filteredMastraDBParts,
|
|
11111
11140
|
toolInvocations: toolInvocations.length > 0 ? toolInvocations : void 0,
|
|
11112
11141
|
reasoning: reasoningParts.length > 0 ? reasoningParts.join("\n") : void 0,
|
|
11113
11142
|
experimental_attachments: experimental_attachments.length > 0 ? experimental_attachments : void 0,
|
|
@@ -11666,6 +11695,12 @@ function sanitizeV5UIMessages(messages, filterIncompleteToolCalls = false) {
|
|
|
11666
11695
|
if (typeof p.type === "string" && p.type.startsWith("data-")) {
|
|
11667
11696
|
return false;
|
|
11668
11697
|
}
|
|
11698
|
+
if (p.type === "text" && (!("text" in p) || p.text === "" || p.text?.trim() === "")) {
|
|
11699
|
+
const hasNonEmptyParts = m.parts.some(
|
|
11700
|
+
(part) => !(part.type === "text" && (!("text" in part) || part.text === "" || part.text?.trim() === ""))
|
|
11701
|
+
);
|
|
11702
|
+
if (hasNonEmptyParts) return false;
|
|
11703
|
+
}
|
|
11669
11704
|
if (!isToolUIPart(p)) return true;
|
|
11670
11705
|
if (filterIncompleteToolCalls) {
|
|
11671
11706
|
return p.state === "output-available" || p.state === "output-error";
|
|
@@ -27751,4 +27786,4 @@ exports.useCreateWorkflowRun = useCreateWorkflowRun;
|
|
|
27751
27786
|
exports.useEntity = useEntity;
|
|
27752
27787
|
exports.useMastraClient = useMastraClient;
|
|
27753
27788
|
exports.useStreamWorkflow = useStreamWorkflow;
|
|
27754
|
-
//# sourceMappingURL=index-
|
|
27789
|
+
//# sourceMappingURL=index-DT_KGByV.cjs.map
|