@mastra/client-js 0.0.0-extract-tool-ui-inp-playground-ui-20251023135343 → 0.0.0-extract-tool-ui-inp-playground-ui-20251024041825

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
@@ -1,5 +1,6 @@
1
1
  import { processDataStream, parsePartialJson } from '@ai-sdk/ui-utils';
2
2
  import { v4 } from '@lukeed/uuid';
3
+ import { getErrorFromUnknown } from '@mastra/core/error';
3
4
  import { RuntimeContext } from '@mastra/core/runtime-context';
4
5
  import { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
5
6
  import { z } from 'zod';
@@ -94,11 +95,15 @@ async function sharedProcessMastraStream({
94
95
  console.info("\u{1F3C1} Stream finished");
95
96
  return;
96
97
  }
98
+ let json;
97
99
  try {
98
- const json = JSON.parse(data);
99
- await onChunk(json);
100
+ json = JSON.parse(data);
100
101
  } catch (error) {
101
102
  console.error("\u274C JSON parse error:", error, "Data:", data);
103
+ continue;
104
+ }
105
+ if (json) {
106
+ await onChunk(json);
102
107
  }
103
108
  }
104
109
  }
@@ -945,7 +950,10 @@ var Agent = class extends BaseResource {
945
950
  break;
946
951
  }
947
952
  case "error": {
948
- throw new Error(chunk.payload.error);
953
+ throw getErrorFromUnknown(chunk.payload.error, {
954
+ fallbackMessage: "Unknown error in stream",
955
+ supportSerialization: false
956
+ });
949
957
  }
950
958
  case "data": {
951
959
  data.push(...chunk.payload.data);