@mastra/playground-ui 5.1.19 → 5.1.20-alpha.0
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/dist/index.cjs.js +33 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +33 -14
- package/dist/index.es.js.map +1 -1
- package/dist/src/types.d.ts +2 -19
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -5424,27 +5424,46 @@ function MastraRuntimeProvider({
|
|
|
5424
5424
|
if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
|
|
5425
5425
|
if (initialMessages && threadId && memory) {
|
|
5426
5426
|
const convertedMessages = initialMessages?.map((message) => {
|
|
5427
|
-
const toolInvocationsAsContentParts = (message.toolInvocations || []).map((toolInvocation) => ({
|
|
5428
|
-
type: "tool-call",
|
|
5429
|
-
toolCallId: toolInvocation?.toolCallId,
|
|
5430
|
-
toolName: toolInvocation?.toolName,
|
|
5431
|
-
args: toolInvocation?.args,
|
|
5432
|
-
result: toolInvocation?.result
|
|
5433
|
-
}));
|
|
5434
5427
|
const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
|
|
5435
5428
|
type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
|
|
5436
5429
|
mimeType: image.contentType,
|
|
5437
5430
|
image: image.url
|
|
5438
5431
|
}));
|
|
5439
|
-
const
|
|
5432
|
+
const formattedParts = (message.parts || []).map((part) => {
|
|
5433
|
+
if (part.type === "reasoning") {
|
|
5434
|
+
return {
|
|
5435
|
+
type: "reasoning",
|
|
5436
|
+
text: part.reasoning || part?.details?.filter((detail) => detail.type === "text")?.map((detail) => detail.text).join(" ")
|
|
5437
|
+
};
|
|
5438
|
+
}
|
|
5439
|
+
if (part.type === "tool-invocation") {
|
|
5440
|
+
if (part.toolInvocation.state === "result") {
|
|
5441
|
+
return {
|
|
5442
|
+
type: "tool-call",
|
|
5443
|
+
toolCallId: part.toolInvocation.toolCallId,
|
|
5444
|
+
toolName: part.toolInvocation.toolName,
|
|
5445
|
+
args: part.toolInvocation.args,
|
|
5446
|
+
result: part.toolInvocation.result
|
|
5447
|
+
};
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
if (part.type === "file") {
|
|
5451
|
+
return {
|
|
5452
|
+
type: "file",
|
|
5453
|
+
mimeType: part.mimeType,
|
|
5454
|
+
data: part.data
|
|
5455
|
+
};
|
|
5456
|
+
}
|
|
5457
|
+
if (part.type === "text") {
|
|
5458
|
+
return {
|
|
5459
|
+
type: "text",
|
|
5460
|
+
text: part.text
|
|
5461
|
+
};
|
|
5462
|
+
}
|
|
5463
|
+
}).filter(Boolean);
|
|
5440
5464
|
return {
|
|
5441
5465
|
...message,
|
|
5442
|
-
content: [
|
|
5443
|
-
...reasoning ? [{ type: "reasoning", text: reasoning }] : [],
|
|
5444
|
-
...typeof message.content === "string" ? [{ type: "text", text: message.content }] : [],
|
|
5445
|
-
...toolInvocationsAsContentParts,
|
|
5446
|
-
...attachmentsAsContentParts
|
|
5447
|
-
]
|
|
5466
|
+
content: [...formattedParts, ...attachmentsAsContentParts]
|
|
5448
5467
|
};
|
|
5449
5468
|
}).filter(Boolean);
|
|
5450
5469
|
setMessages(convertedMessages);
|