@mastra/react 0.2.33 → 0.2.34-alpha.1

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.js CHANGED
@@ -226,30 +226,24 @@ var mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
226
226
  var toUIMessage = ({ chunk, conversation, metadata }) => {
227
227
  const result = [...conversation];
228
228
  if (chunk.type.startsWith("data-")) {
229
+ const dataPart = {
230
+ type: chunk.type,
231
+ data: "data" in chunk ? chunk.data : void 0,
232
+ ..."id" in chunk && typeof chunk.id === "string" ? { id: chunk.id } : {}
233
+ };
229
234
  const lastMessage = result[result.length - 1];
230
235
  if (!lastMessage || lastMessage.role !== "assistant") {
231
236
  const newMessage = {
232
237
  id: `data-${chunk.runId}-${Date.now()}`,
233
238
  role: "assistant",
234
- parts: [
235
- {
236
- type: chunk.type,
237
- data: "data" in chunk ? chunk.data : void 0
238
- }
239
- ],
239
+ parts: [dataPart],
240
240
  metadata
241
241
  };
242
242
  return [...result, newMessage];
243
243
  }
244
244
  const updatedMessage = {
245
245
  ...lastMessage,
246
- parts: [
247
- ...lastMessage.parts,
248
- {
249
- type: chunk.type,
250
- data: "data" in chunk ? chunk.data : void 0
251
- }
252
- ]
246
+ parts: [...lastMessage.parts, dataPart]
253
247
  };
254
248
  return [...result.slice(0, -1), updatedMessage];
255
249
  }