@mastra/react 0.0.0-monorepo-binary-20251013210052 → 0.0.0-usechat-duplicate-20251016110554

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,6 +1,15 @@
1
1
  # @mastra/react-hooks
2
2
 
3
- ## 0.0.0-monorepo-binary-20251013210052
3
+ ## 0.0.0-usechat-duplicate-20251016110554
4
+
5
+ ### Patch Changes
6
+
7
+ - Add @mastra/react to peer deps ([#8857](https://github.com/mastra-ai/mastra/pull/8857))
8
+
9
+ - Updated dependencies []:
10
+ - @mastra/client-js@0.0.0-usechat-duplicate-20251016110554
11
+
12
+ ## 0.0.6
4
13
 
5
14
  ### Patch Changes
6
15
 
@@ -10,14 +19,52 @@
10
19
 
11
20
  - Improve the surface API of the react sdk ([#8715](https://github.com/mastra-ai/mastra/pull/8715))
12
21
 
22
+ - Move react and react-dom deps to peer and dev deps ([#8698](https://github.com/mastra-ai/mastra/pull/8698))
23
+
13
24
  - Fix back the tripwire verification inside the new react system ([#8674](https://github.com/mastra-ai/mastra/pull/8674))
14
25
 
15
26
  - handle error case in react sdk ([#8676](https://github.com/mastra-ai/mastra/pull/8676))
16
27
 
17
28
  - fix maxSteps model settings not being passed to generate and stream endpoints ([#8627](https://github.com/mastra-ai/mastra/pull/8627))
18
29
 
30
+ - Stream finalResult from network loop ([#8795](https://github.com/mastra-ai/mastra/pull/8795))
31
+
19
32
  - Updated dependencies [[`7b1ef57`](https://github.com/mastra-ai/mastra/commit/7b1ef57fc071c2aa2a2e32905b18cd88719c5a39), [`78cfb6b`](https://github.com/mastra-ai/mastra/commit/78cfb6b66fe88bc848105fccb6459fd75413ec87)]:
20
- - @mastra/client-js@0.0.0-monorepo-binary-20251013210052
33
+ - @mastra/client-js@0.16.0
34
+
35
+ ## 0.0.6-alpha.4
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies []:
40
+ - @mastra/client-js@0.16.0-alpha.4
41
+
42
+ ## 0.0.6-alpha.3
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies []:
47
+ - @mastra/client-js@0.16.0-alpha.3
48
+
49
+ ## 0.0.6-alpha.2
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies []:
54
+ - @mastra/client-js@0.16.0-alpha.2
55
+
56
+ ## 0.0.6-alpha.1
57
+
58
+ ### Patch Changes
59
+
60
+ - Improve the surface API of the react sdk ([#8715](https://github.com/mastra-ai/mastra/pull/8715))
61
+
62
+ - Move react and react-dom deps to peer and dev deps ([#8698](https://github.com/mastra-ai/mastra/pull/8698))
63
+
64
+ - Stream finalResult from network loop ([#8795](https://github.com/mastra-ai/mastra/pull/8795))
65
+
66
+ - Updated dependencies []:
67
+ - @mastra/client-js@0.16.0-alpha.1
21
68
 
22
69
  ## 0.0.6-alpha.0
23
70
 
package/dist/index.cjs CHANGED
@@ -554,6 +554,9 @@ const toAssistantUIMessage = (message) => {
554
554
  class AISdkNetworkTransformer {
555
555
  transform({ chunk, conversation, metadata }) {
556
556
  const newConversation = [...conversation];
557
+ if (chunk.type === "routing-agent-text-delta") {
558
+ return this.handleRoutingAgentConversation(chunk, newConversation);
559
+ }
557
560
  if (chunk.type.startsWith("agent-execution-")) {
558
561
  return this.handleAgentConversation(chunk, newConversation, metadata);
559
562
  }
@@ -564,22 +567,80 @@ class AISdkNetworkTransformer {
564
567
  return this.handleToolConversation(chunk, newConversation, metadata);
565
568
  }
566
569
  if (chunk.type === "network-execution-event-step-finish") {
567
- const newMessage = {
568
- id: `network-execution-event-step-finish-${chunk.runId}-${Date.now()}`,
569
- role: "assistant",
570
- parts: [
570
+ const lastMessage = newConversation[newConversation.length - 1];
571
+ if (!lastMessage || lastMessage.role !== "assistant") return newConversation;
572
+ const agentChunk = chunk.payload;
573
+ const parts = [...lastMessage.parts];
574
+ const textPartIndex = parts.findIndex((part) => part.type === "text");
575
+ if (textPartIndex === -1) {
576
+ parts.push({
577
+ type: "text",
578
+ text: agentChunk.result,
579
+ state: "done"
580
+ });
581
+ return [
582
+ ...newConversation.slice(0, -1),
571
583
  {
572
- type: "text",
573
- text: chunk.payload?.result || "",
574
- state: "done"
584
+ ...lastMessage,
585
+ parts
575
586
  }
576
- ],
577
- metadata
578
- };
579
- return [...newConversation, newMessage];
587
+ ];
588
+ }
589
+ const textPart = parts[textPartIndex];
590
+ if (textPart.type === "text") {
591
+ parts[textPartIndex] = {
592
+ ...textPart,
593
+ state: "done"
594
+ };
595
+ return [
596
+ ...newConversation.slice(0, -1),
597
+ {
598
+ ...lastMessage,
599
+ parts
600
+ }
601
+ ];
602
+ }
603
+ return newConversation;
580
604
  }
581
605
  return newConversation;
582
606
  }
607
+ handleRoutingAgentConversation = (chunk, newConversation) => {
608
+ const lastMessage = newConversation[newConversation.length - 1];
609
+ if (!lastMessage || lastMessage.role !== "assistant") return newConversation;
610
+ const agentChunk = chunk.payload;
611
+ const parts = [...lastMessage.parts];
612
+ const textPartIndex = parts.findIndex((part) => part.type === "text");
613
+ if (textPartIndex === -1) {
614
+ parts.push({
615
+ type: "text",
616
+ text: agentChunk.text,
617
+ state: "streaming"
618
+ });
619
+ return [
620
+ ...newConversation.slice(0, -1),
621
+ {
622
+ ...lastMessage,
623
+ parts
624
+ }
625
+ ];
626
+ }
627
+ const textPart = parts[textPartIndex];
628
+ if (textPart.type === "text") {
629
+ parts[textPartIndex] = {
630
+ ...textPart,
631
+ text: textPart.text + agentChunk.text,
632
+ state: "streaming"
633
+ };
634
+ return [
635
+ ...newConversation.slice(0, -1),
636
+ {
637
+ ...lastMessage,
638
+ parts
639
+ }
640
+ ];
641
+ }
642
+ return newConversation;
643
+ };
583
644
  handleAgentConversation = (chunk, newConversation, metadata) => {
584
645
  if (chunk.type === "agent-execution-start") {
585
646
  const primitiveId = chunk.payload?.args?.primitiveId;