@mastra/react 0.2.9 → 0.2.10-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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @mastra/react
2
2
 
3
+ ## 0.2.10-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`866cc2c`](https://github.com/mastra-ai/mastra/commit/866cc2cb1f0e3b314afab5194f69477fada745d1), [`6bcbf8a`](https://github.com/mastra-ai/mastra/commit/6bcbf8a6774d5a53b21d61db8a45ce2593ca1616), [`18c3a90`](https://github.com/mastra-ai/mastra/commit/18c3a90c9e48cf69500e308affeb8eba5860b2af), [`f35487b`](https://github.com/mastra-ai/mastra/commit/f35487bb2d46c636e22aa71d90025613ae38235a), [`6dc2192`](https://github.com/mastra-ai/mastra/commit/6dc21921aef0f0efab15cd0805fa3d18f277a76f), [`eeb3a3f`](https://github.com/mastra-ai/mastra/commit/eeb3a3f43aca10cf49479eed2a84b7d9ecea02ba), [`05f8d90`](https://github.com/mastra-ai/mastra/commit/05f8d9009290ce6aa03428b3add635268615db85), [`4b8da97`](https://github.com/mastra-ai/mastra/commit/4b8da97a5ce306e97869df6c39535d9069e563db), [`256df35`](https://github.com/mastra-ai/mastra/commit/256df3571d62beb3ad4971faa432927cc140e603)]:
8
+ - @mastra/core@1.11.0-alpha.1
9
+ - @mastra/client-js@1.8.0-alpha.1
10
+
11
+ ## 0.2.10-alpha.0
12
+
13
+ ### Patch Changes
14
+
15
+ - dependencies updates: ([#13890](https://github.com/mastra-ai/mastra/pull/13890))
16
+ - Updated dependency [`tailwind-merge@^3.5.0` ↗︎](https://www.npmjs.com/package/tailwind-merge/v/3.5.0) (from `^3.4.1`, in `dependencies`)
17
+
18
+ - Fixed @mastra/react root imports so Vite and other browser builds no longer pull in Node-only @mastra/core code. ([#14079](https://github.com/mastra-ai/mastra/pull/14079))
19
+
20
+ - Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`be60b73`](https://github.com/mastra-ai/mastra/commit/be60b731adad9f2cf3c0732d685561bc140aa827), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
21
+ - @mastra/core@1.11.0-alpha.0
22
+ - @mastra/client-js@1.8.0-alpha.0
23
+
3
24
  ## 0.2.9
4
25
 
5
26
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4,13 +4,11 @@ var clientJs = require('@mastra/client-js');
4
4
  var react = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var uuid = require('@lukeed/uuid');
7
- var loop = require('@mastra/core/loop');
8
7
  var lucideReact = require('lucide-react');
9
8
  var tailwindMerge = require('tailwind-merge');
10
9
  var reactTooltip = require('@radix-ui/react-tooltip');
11
10
  var hastUtilToJsxRuntime = require('hast-util-to-jsx-runtime');
12
11
  var web = require('shiki/bundle/web');
13
- var requestContext = require('@mastra/core/request-context');
14
12
 
15
13
  // src/mastra-client-context.tsx
16
14
  var MastraClientContext = react.createContext({});
@@ -44,6 +42,53 @@ var createMastraClient = (baseUrl, mastraClientHeaders = {}, apiPrefix) => {
44
42
  var MastraReactProvider = ({ children, baseUrl, headers, apiPrefix }) => {
45
43
  return /* @__PURE__ */ jsxRuntime.jsx(MastraClientProvider, { baseUrl, headers, apiPrefix, children });
46
44
  };
45
+
46
+ // src/lib/ai-sdk/utils/formatCompletionFeedback.ts
47
+ var formatBaseCompletionFeedback = (result, maxIterationReached, formatScorerHeading, incompleteMessage) => {
48
+ const lines = [];
49
+ lines.push("#### Completion Check Results");
50
+ lines.push("");
51
+ lines.push(`Overall: ${result.complete ? "\u2705 COMPLETE" : "\u274C NOT COMPLETE"}`);
52
+ lines.push(`Duration: ${result.totalDuration}ms`);
53
+ if (result.timedOut) {
54
+ lines.push("\u26A0\uFE0F Scoring timed out");
55
+ }
56
+ lines.push("");
57
+ for (const scorer of result.scorers) {
58
+ lines.push(formatScorerHeading(scorer));
59
+ lines.push(`Score: ${scorer.score} ${scorer.passed ? "\u2705" : "\u274C"}`);
60
+ if (scorer.reason) {
61
+ lines.push(`Reason: ${scorer.reason}`);
62
+ }
63
+ lines.push("");
64
+ }
65
+ if (result.complete) {
66
+ lines.push("\u2705 The task is complete.");
67
+ } else if (maxIterationReached) {
68
+ lines.push("\u26A0\uFE0F Max iterations reached.");
69
+ } else {
70
+ lines.push(incompleteMessage);
71
+ }
72
+ return lines.join("\n");
73
+ };
74
+ var formatCompletionFeedback = (result, maxIterationReached) => {
75
+ return formatBaseCompletionFeedback(
76
+ result,
77
+ maxIterationReached,
78
+ (scorer) => `###### ${scorer.scorerName} (${scorer.scorerId})`,
79
+ "\u{1F504} Will continue working on the task."
80
+ );
81
+ };
82
+ var formatStreamCompletionFeedback = (result, maxIterationReached) => {
83
+ return formatBaseCompletionFeedback(
84
+ result,
85
+ maxIterationReached,
86
+ (scorer) => `**${scorer.scorerName}** (${scorer.scorerId})`,
87
+ "\u{1F504} The task is not yet complete. Please continue working based on the feedback above."
88
+ );
89
+ };
90
+
91
+ // src/lib/ai-sdk/utils/toUIMessage.ts
47
92
  var mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
48
93
  if (chunk.type === "workflow-start") {
49
94
  return {
@@ -456,14 +501,12 @@ var toUIMessage = ({ chunk, conversation, metadata }) => {
456
501
  }
457
502
  case "is-task-complete": {
458
503
  if (chunk.payload.suppressFeedback) return result;
459
- const feedback = loop.formatStreamCompletionFeedback(
504
+ const feedback = formatStreamCompletionFeedback(
460
505
  {
461
506
  complete: chunk.payload.passed,
462
507
  scorers: chunk.payload.results,
463
508
  totalDuration: chunk.payload.duration,
464
- timedOut: chunk.payload.timedOut,
465
- completionReason: chunk.payload.reason
466
- },
509
+ timedOut: chunk.payload.timedOut},
467
510
  chunk.payload.maxIterationReached
468
511
  );
469
512
  const newMessage = {
@@ -1037,6 +1080,8 @@ var resolveToChildMessages = (messages) => {
1037
1080
  }
1038
1081
  return childMessages;
1039
1082
  };
1083
+
1084
+ // src/lib/ai-sdk/transformers/AISdkNetworkTransformer.ts
1040
1085
  var AISdkNetworkTransformer = class {
1041
1086
  transform({ chunk, conversation, metadata }) {
1042
1087
  const newConversation = [...conversation];
@@ -1054,14 +1099,12 @@ var AISdkNetworkTransformer = class {
1054
1099
  }
1055
1100
  if (chunk.type === "network-validation-end") {
1056
1101
  if (chunk.payload.suppressFeedback) return newConversation;
1057
- const feedback = loop.formatCompletionFeedback(
1102
+ const feedback = formatCompletionFeedback(
1058
1103
  {
1059
1104
  complete: chunk.payload.passed,
1060
1105
  scorers: chunk.payload.results,
1061
1106
  totalDuration: chunk.payload.duration,
1062
- timedOut: chunk.payload.timedOut,
1063
- completionReason: chunk.payload.reason
1064
- },
1107
+ timedOut: chunk.payload.timedOut},
1065
1108
  chunk.payload.maxIterationReached
1066
1109
  );
1067
1110
  const newMessage = {
@@ -2408,16 +2451,12 @@ function useStreamWorkflow({ debugMode, tracingOptions, onError }) {
2408
2451
  if (!isMountedRef.current) return;
2409
2452
  setIsStreaming(true);
2410
2453
  setStreamResult({ input: inputData });
2411
- const requestContext$1 = new requestContext.RequestContext();
2412
- Object.entries(playgroundRequestContext).forEach(([key, value]) => {
2413
- requestContext$1.set(key, value);
2414
- });
2415
2454
  const workflow = client.getWorkflow(workflowId);
2416
2455
  const run = await workflow.createRun({ runId });
2417
2456
  const stream = await run.stream({
2418
2457
  inputData,
2419
2458
  initialState,
2420
- requestContext: requestContext$1,
2459
+ requestContext: playgroundRequestContext,
2421
2460
  closeOnSuspend: true,
2422
2461
  tracingOptions,
2423
2462
  perStep: perStep ?? debugMode
@@ -2523,15 +2562,11 @@ function useStreamWorkflow({ debugMode, tracingOptions, onError }) {
2523
2562
  if (!isMountedRef.current) return;
2524
2563
  setIsStreaming(true);
2525
2564
  const workflow = client.getWorkflow(workflowId);
2526
- const requestContext$1 = new requestContext.RequestContext();
2527
- Object.entries(playgroundRequestContext).forEach(([key, value]) => {
2528
- requestContext$1.set(key, value);
2529
- });
2530
2565
  const run = await workflow.createRun({ runId });
2531
2566
  const stream = await run.resumeStream({
2532
2567
  step,
2533
2568
  resumeData,
2534
- requestContext: requestContext$1,
2569
+ requestContext: playgroundRequestContext,
2535
2570
  tracingOptions,
2536
2571
  perStep: perStep ?? debugMode
2537
2572
  });
@@ -2582,15 +2617,11 @@ function useStreamWorkflow({ debugMode, tracingOptions, onError }) {
2582
2617
  if (!isMountedRef.current) return;
2583
2618
  setIsStreaming(true);
2584
2619
  const workflow = client.getWorkflow(workflowId);
2585
- const requestContext$1 = new requestContext.RequestContext();
2586
- Object.entries(playgroundRequestContext).forEach(([key, value]) => {
2587
- requestContext$1.set(key, value);
2588
- });
2589
2620
  const run = await workflow.createRun({ runId });
2590
2621
  const stream = await run.timeTravelStream({
2591
2622
  ...params,
2592
2623
  perStep: perStep ?? debugMode,
2593
- requestContext: requestContext$1,
2624
+ requestContext: playgroundRequestContext,
2594
2625
  tracingOptions
2595
2626
  });
2596
2627
  if (!stream) {