@mastra/react 0.0.0-sidebar-window-undefined-fix-20251029233656 → 0.0.0-trace-timeline-update-20251121092347

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
@@ -424,11 +424,10 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
424
424
  const lastMessage = result[result.length - 1];
425
425
  if (!lastMessage || lastMessage.role !== "assistant") return result;
426
426
  const parts = lastMessage.parts.map((part) => {
427
- if (part.type === "text" && part.state === "streaming") {
428
- return { ...part, state: "done" };
429
- }
430
- if (part.type === "reasoning" && part.state === "streaming") {
431
- return { ...part, state: "done" };
427
+ if (typeof part === "object" && part !== null && "type" in part && "state" in part && part.state === "streaming") {
428
+ if (part.type === "text" || part.type === "reasoning") {
429
+ return { ...part, state: "done" };
430
+ }
432
431
  }
433
432
  return part;
434
433
  });
@@ -693,7 +692,9 @@ const toAssistantUIMessage = (message) => {
693
692
 
694
693
  const resolveInitialMessages = (messages) => {
695
694
  return messages.map((message) => {
696
- const networkPart = message.parts.find((part) => part.type === "text" && part.text.includes('"isNetwork":true'));
695
+ const networkPart = message.parts.find(
696
+ (part) => typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string" && part.text.includes('"isNetwork":true')
697
+ );
697
698
  if (networkPart && networkPart.type === "text") {
698
699
  try {
699
700
  const json = JSON.parse(networkPart.text);
@@ -1223,7 +1224,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1223
1224
  const [isRunning, setIsRunning] = useState(false);
1224
1225
  const generate = async ({
1225
1226
  coreUserMessages,
1226
- runtimeContext,
1227
+ requestContext,
1227
1228
  threadId,
1228
1229
  modelSettings,
1229
1230
  signal,
@@ -1261,7 +1262,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1261
1262
  topP
1262
1263
  },
1263
1264
  instructions,
1264
- runtimeContext,
1265
+ requestContext,
1265
1266
  ...threadId ? { threadId, resourceId: agentId } : {},
1266
1267
  providerOptions
1267
1268
  });
@@ -1277,7 +1278,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1277
1278
  setMessages((prev) => [...prev, ...mastraUIMessages]);
1278
1279
  }
1279
1280
  };
1280
- const stream = async ({ coreUserMessages, runtimeContext, threadId, onChunk, modelSettings, signal }) => {
1281
+ const stream = async ({ coreUserMessages, requestContext, threadId, onChunk, modelSettings, signal }) => {
1281
1282
  const {
1282
1283
  frequencyPenalty,
1283
1284
  presencePenalty,
@@ -1312,7 +1313,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1312
1313
  topP
1313
1314
  },
1314
1315
  instructions,
1315
- runtimeContext,
1316
+ requestContext,
1316
1317
  ...threadId ? { threadId, resourceId: agentId } : {},
1317
1318
  providerOptions,
1318
1319
  requireToolApproval
@@ -1329,7 +1330,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1329
1330
  };
1330
1331
  const network = async ({
1331
1332
  coreUserMessages,
1332
- runtimeContext,
1333
+ requestContext,
1333
1334
  threadId,
1334
1335
  onNetworkChunk,
1335
1336
  modelSettings,
@@ -1355,7 +1356,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1355
1356
  topP
1356
1357
  },
1357
1358
  runId: agentId,
1358
- runtimeContext,
1359
+ requestContext,
1359
1360
  ...threadId ? { thread: threadId, resourceId: agentId } : {}
1360
1361
  });
1361
1362
  const transformer = new AISdkNetworkTransformer();