@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.es.js CHANGED
@@ -5391,27 +5391,46 @@ function MastraRuntimeProvider({
5391
5391
  if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
5392
5392
  if (initialMessages && threadId && memory) {
5393
5393
  const convertedMessages = initialMessages?.map((message) => {
5394
- const toolInvocationsAsContentParts = (message.toolInvocations || []).map((toolInvocation) => ({
5395
- type: "tool-call",
5396
- toolCallId: toolInvocation?.toolCallId,
5397
- toolName: toolInvocation?.toolName,
5398
- args: toolInvocation?.args,
5399
- result: toolInvocation?.result
5400
- }));
5401
5394
  const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
5402
5395
  type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
5403
5396
  mimeType: image.contentType,
5404
5397
  image: image.url
5405
5398
  }));
5406
- const reasoning = message?.parts?.find(({ type }) => type === "reasoning")?.details?.map((detail) => detail?.text)?.join(" ");
5399
+ const formattedParts = (message.parts || []).map((part) => {
5400
+ if (part.type === "reasoning") {
5401
+ return {
5402
+ type: "reasoning",
5403
+ text: part.reasoning || part?.details?.filter((detail) => detail.type === "text")?.map((detail) => detail.text).join(" ")
5404
+ };
5405
+ }
5406
+ if (part.type === "tool-invocation") {
5407
+ if (part.toolInvocation.state === "result") {
5408
+ return {
5409
+ type: "tool-call",
5410
+ toolCallId: part.toolInvocation.toolCallId,
5411
+ toolName: part.toolInvocation.toolName,
5412
+ args: part.toolInvocation.args,
5413
+ result: part.toolInvocation.result
5414
+ };
5415
+ }
5416
+ }
5417
+ if (part.type === "file") {
5418
+ return {
5419
+ type: "file",
5420
+ mimeType: part.mimeType,
5421
+ data: part.data
5422
+ };
5423
+ }
5424
+ if (part.type === "text") {
5425
+ return {
5426
+ type: "text",
5427
+ text: part.text
5428
+ };
5429
+ }
5430
+ }).filter(Boolean);
5407
5431
  return {
5408
5432
  ...message,
5409
- content: [
5410
- ...reasoning ? [{ type: "reasoning", text: reasoning }] : [],
5411
- ...typeof message.content === "string" ? [{ type: "text", text: message.content }] : [],
5412
- ...toolInvocationsAsContentParts,
5413
- ...attachmentsAsContentParts
5414
- ]
5433
+ content: [...formattedParts, ...attachmentsAsContentParts]
5415
5434
  };
5416
5435
  }).filter(Boolean);
5417
5436
  setMessages(convertedMessages);