@mastra/playground-ui 5.1.2-alpha.6 → 5.1.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/dist/index.cjs.js CHANGED
@@ -4647,22 +4647,26 @@ function MastraRuntimeProvider({
4647
4647
  if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
4648
4648
  if (initialMessages && threadId && memory) {
4649
4649
  const convertedMessages = initialMessages?.map((message) => {
4650
- if (message?.toolInvocations?.length > 0) {
4651
- return {
4652
- ...message,
4653
- content: [
4654
- ...typeof message.content === "string" ? [{ type: "text", text: message.content }] : [],
4655
- ...message.toolInvocations.map((toolInvocation) => ({
4656
- type: "tool-call",
4657
- toolCallId: toolInvocation?.toolCallId,
4658
- toolName: toolInvocation?.toolName,
4659
- args: toolInvocation?.args,
4660
- result: toolInvocation?.result
4661
- }))
4662
- ]
4663
- };
4664
- }
4665
- return message;
4650
+ const toolInvocationsAsContentParts = (message.toolInvocations || []).map((toolInvocation) => ({
4651
+ type: "tool-call",
4652
+ toolCallId: toolInvocation?.toolCallId,
4653
+ toolName: toolInvocation?.toolName,
4654
+ args: toolInvocation?.args,
4655
+ result: toolInvocation?.result
4656
+ }));
4657
+ const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
4658
+ type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
4659
+ mimeType: image.contentType,
4660
+ image: image.url
4661
+ }));
4662
+ return {
4663
+ ...message,
4664
+ content: [
4665
+ ...typeof message.content === "string" ? [{ type: "text", text: message.content }] : [],
4666
+ ...toolInvocationsAsContentParts,
4667
+ ...attachmentsAsContentParts
4668
+ ]
4669
+ };
4666
4670
  }).filter(Boolean);
4667
4671
  setMessages(convertedMessages);
4668
4672
  setCurrentThreadId(threadId);