@mastra/react 0.0.0-sidebar-window-undefined-fix-20251029233656 → 0.0.0-top-level-fix-20251211103030

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,224 @@
1
1
  # @mastra/react-hooks
2
2
 
3
- ## 0.0.0-sidebar-window-undefined-fix-20251029233656
3
+ ## 0.0.0-top-level-fix-20251211103030
4
+
5
+ ### Minor Changes
6
+
7
+ - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
8
+
9
+ - Rename RuntimeContext to RequestContext ([#9511](https://github.com/mastra-ai/mastra/pull/9511))
10
+
11
+ - Renamed `MastraMessageV2` to `MastraDBMessage` ([#9255](https://github.com/mastra-ai/mastra/pull/9255))
12
+ Made the return format of all methods that return db messages consistent. It's always `{ messages: MastraDBMessage[] }` now, and messages can be converted after that using `@mastra/ai-sdk/ui`'s `toAISdkV4/5Messages()` function
13
+
14
+ - Fix "MessagePartRuntime is not available" error when chatting with agents in Studio playground by replacing deprecated `useMessagePart` hook with `useAssistantState` ([#11039](https://github.com/mastra-ai/mastra/pull/11039))
15
+
16
+ ### Patch Changes
17
+
18
+ - Adjust the types to accept tracingOptions ([#10742](https://github.com/mastra-ai/mastra/pull/10742))
19
+
20
+ - Configurable resourceId in react useChat ([#10461](https://github.com/mastra-ai/mastra/pull/10461))
21
+
22
+ - Add tool call approval ([#8649](https://github.com/mastra-ai/mastra/pull/8649))
23
+
24
+ - fix(agent): persist messages before tool suspension ([#10369](https://github.com/mastra-ai/mastra/pull/10369))
25
+
26
+ Fixes issues where thread and messages were not saved before suspension when tools require approval or call suspend() during execution. This caused conversation history to be lost if users refreshed during tool approval or suspension.
27
+
28
+ **Backend changes (@mastra/core):**
29
+ - Add assistant messages to messageList immediately after LLM execution
30
+ - Flush messages synchronously before suspension to persist state
31
+ - Create thread if it doesn't exist before flushing
32
+ - Add metadata helpers to persist and remove tool approval state
33
+ - Pass saveQueueManager and memory context through workflow for immediate persistence
34
+
35
+ **Frontend changes (@mastra/react):**
36
+ - Extract runId from pending approvals to enable resumption after refresh
37
+ - Convert `pendingToolApprovals` (DB format) to `requireApprovalMetadata` (runtime format)
38
+ - Handle both `dynamic-tool` and `tool-{NAME}` part types for approval state
39
+ - Change runId from hardcoded `agentId` to unique `uuid()`
40
+
41
+ **UI changes (@mastra/playground-ui):**
42
+ - Handle tool calls awaiting approval in message initialization
43
+ - Convert approval metadata format when loading initial messages
44
+
45
+ Fixes #9745, #9906
46
+
47
+ - Fix multi modal in react sdk ([#9373](https://github.com/mastra-ai/mastra/pull/9373))
48
+
49
+ - Support new Workflow tripwire run status. Tripwires that are thrown from within a workflow will now bubble up and return a graceful state with information about tripwires. ([#10947](https://github.com/mastra-ai/mastra/pull/10947))
50
+
51
+ When a workflow contains an agent step that triggers a tripwire, the workflow returns with `status: 'tripwire'` and includes tripwire details:
52
+
53
+ ```typescript showLineNumbers copy
54
+ const run = await workflow.createRun();
55
+ const result = await run.start({ inputData: { message: 'Hello' } });
56
+
57
+ if (result.status === 'tripwire') {
58
+ console.log('Workflow terminated by tripwire:', result.tripwire?.reason);
59
+ console.log('Processor ID:', result.tripwire?.processorId);
60
+ console.log('Retry requested:', result.tripwire?.retry);
61
+ }
62
+ ```
63
+
64
+ Adds new UI state for tripwire in agent chat and workflow UI.
65
+
66
+ This is distinct from `status: 'failed'` which indicates an unexpected error. A tripwire status means a processor intentionally stopped execution (e.g., for content moderation).
67
+
68
+ - fix: persist data-\* chunks from writer.custom() to memory storage ([#10884](https://github.com/mastra-ai/mastra/pull/10884))
69
+ - Add persistence for custom data chunks (`data-*` parts) emitted via `writer.custom()` in tools
70
+ - Data chunks are now saved to message storage so they survive page refreshes
71
+ - Update `@assistant-ui/react` to v0.11.47 with native `DataMessagePart` support
72
+ - Convert `data-*` parts to `DataMessagePart` format (`{ type: 'data', name: string, data: T }`)
73
+ - Update related `@assistant-ui/*` packages for compatibility
74
+
75
+ - Updated dependencies [[`6edf340`](https://github.com/mastra-ai/mastra/commit/6edf3402f6a46ee8def2f42a2287785251fbffd6), [`3852192`](https://github.com/mastra-ai/mastra/commit/3852192c81b2a4f1f883f17d80ce50e0c60dba55), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`f0a07e0`](https://github.com/mastra-ai/mastra/commit/f0a07e0111b3307c5fabfa4094c5c2cfb734fbe6), [`aaa40e7`](https://github.com/mastra-ai/mastra/commit/aaa40e788628b319baa8e889407d11ad626547fa), [`dd1c38d`](https://github.com/mastra-ai/mastra/commit/dd1c38d1b75f1b695c27b40d8d9d6ed00d5e0f6f), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`ad7e8f1`](https://github.com/mastra-ai/mastra/commit/ad7e8f16ac843cbd16687ad47b66ba96bcffe111), [`dff01d8`](https://github.com/mastra-ai/mastra/commit/dff01d81ce1f4e4087cfac20fa868e6db138dd14), [`e1b7118`](https://github.com/mastra-ai/mastra/commit/e1b7118f42ca0a97247afc75e57dcd5fdf987752), [`441c7b6`](https://github.com/mastra-ai/mastra/commit/441c7b6665915cfa7fd625fded8c0f518530bf10), [`b7de533`](https://github.com/mastra-ai/mastra/commit/b7de53361667eb51fefd89fcaed924f3c57cee8d), [`5a1ede1`](https://github.com/mastra-ai/mastra/commit/5a1ede1f7ab527b9ead11f7eee2f73e67aeca9e4), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`1ee3411`](https://github.com/mastra-ai/mastra/commit/1ee34113192b11aa8bcdd8d9d5830ae13254b345), [`dbd9db0`](https://github.com/mastra-ai/mastra/commit/dbd9db0d5c2797a210b9098e7e3e613718e5442f), [`6a86fe5`](https://github.com/mastra-ai/mastra/commit/6a86fe56b8ff53ca2eb3ed87ffc0748749ebadce), [`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f), [`0793497`](https://github.com/mastra-ai/mastra/commit/079349753620c40246ffd673e3f9d7d9820beff3), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`f93d992`](https://github.com/mastra-ai/mastra/commit/f93d992a37d5431ab4a71246835d403ef7c4ce85), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`595a3b8`](https://github.com/mastra-ai/mastra/commit/595a3b8727c901f44e333909c09843c711224440), [`ea0b8de`](https://github.com/mastra-ai/mastra/commit/ea0b8dec0d4bc86a72a7e75b2f56c6017c58786d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`eb09742`](https://github.com/mastra-ai/mastra/commit/eb09742197f66c4c38154c3beec78313e69760b2), [`a1bd7b8`](https://github.com/mastra-ai/mastra/commit/a1bd7b8571db16b94eb01588f451a74758c96d65), [`0633100`](https://github.com/mastra-ai/mastra/commit/0633100a911ad22f5256471bdf753da21c104742), [`354ad0b`](https://github.com/mastra-ai/mastra/commit/354ad0b7b1b8183ac567f236a884fc7ede6d7138), [`519d9e6`](https://github.com/mastra-ai/mastra/commit/519d9e6d31910457c54bdae8b7b7cb3a69f41831), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`5fe71bc`](https://github.com/mastra-ai/mastra/commit/5fe71bc925dfce597df69c89241f33b378028c63), [`dfe3f8c`](https://github.com/mastra-ai/mastra/commit/dfe3f8c7376ffe159236819e19ca522143c1f972), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`e8dcd71`](https://github.com/mastra-ai/mastra/commit/e8dcd71fa5e473c8ba1d6dad99eef182d20a0491), [`e849603`](https://github.com/mastra-ai/mastra/commit/e849603a596269069f58a438b98449ea2770493d), [`63f2f18`](https://github.com/mastra-ai/mastra/commit/63f2f1863dffe3ad23221d0660ed4e4f2b81789d), [`c23200d`](https://github.com/mastra-ai/mastra/commit/c23200ddfd60830effb39329674ba4ca93be6aac), [`363284b`](https://github.com/mastra-ai/mastra/commit/363284bb974e850f06f40f89a28c79d9f432d7e4), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`b7959e6`](https://github.com/mastra-ai/mastra/commit/b7959e6e25a46b480f9ea2217c4c6c588c423791), [`0bddc6d`](https://github.com/mastra-ai/mastra/commit/0bddc6d8dbd6f6008c0cba2e4960a2da75a55af1), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`3bf6c5f`](https://github.com/mastra-ai/mastra/commit/3bf6c5f104c25226cd84e0c77f9dec15f2cac2db), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365)]:
76
+ - @mastra/client-js@0.0.0-top-level-fix-20251211103030
77
+
78
+ ## 0.1.0-beta.11
79
+
80
+ ### Patch Changes
81
+
82
+ - Support new Workflow tripwire run status. Tripwires that are thrown from within a workflow will now bubble up and return a graceful state with information about tripwires. ([#10947](https://github.com/mastra-ai/mastra/pull/10947))
83
+
84
+ When a workflow contains an agent step that triggers a tripwire, the workflow returns with `status: 'tripwire'` and includes tripwire details:
85
+
86
+ ```typescript showLineNumbers copy
87
+ const run = await workflow.createRun();
88
+ const result = await run.start({ inputData: { message: 'Hello' } });
89
+
90
+ if (result.status === 'tripwire') {
91
+ console.log('Workflow terminated by tripwire:', result.tripwire?.reason);
92
+ console.log('Processor ID:', result.tripwire?.processorId);
93
+ console.log('Retry requested:', result.tripwire?.retry);
94
+ }
95
+ ```
96
+
97
+ Adds new UI state for tripwire in agent chat and workflow UI.
98
+
99
+ This is distinct from `status: 'failed'` which indicates an unexpected error. A tripwire status means a processor intentionally stopped execution (e.g., for content moderation).
100
+
101
+ - Updated dependencies [[`3bf6c5f`](https://github.com/mastra-ai/mastra/commit/3bf6c5f104c25226cd84e0c77f9dec15f2cac2db)]:
102
+ - @mastra/client-js@1.0.0-beta.11
103
+
104
+ ## 0.1.0-beta.10
105
+
106
+ ### Minor Changes
107
+
108
+ - Fix "MessagePartRuntime is not available" error when chatting with agents in Studio playground by replacing deprecated `useMessagePart` hook with `useAssistantState` ([#11039](https://github.com/mastra-ai/mastra/pull/11039))
109
+
110
+ ### Patch Changes
111
+
112
+ - fix: persist data-\* chunks from writer.custom() to memory storage ([#10884](https://github.com/mastra-ai/mastra/pull/10884))
113
+ - Add persistence for custom data chunks (`data-*` parts) emitted via `writer.custom()` in tools
114
+ - Data chunks are now saved to message storage so they survive page refreshes
115
+ - Update `@assistant-ui/react` to v0.11.47 with native `DataMessagePart` support
116
+ - Convert `data-*` parts to `DataMessagePart` format (`{ type: 'data', name: string, data: T }`)
117
+ - Update related `@assistant-ui/*` packages for compatibility
118
+
119
+ - Updated dependencies [[`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d)]:
120
+ - @mastra/client-js@1.0.0-beta.10
121
+
122
+ ## 0.1.0-beta.9
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies [[`5a1ede1`](https://github.com/mastra-ai/mastra/commit/5a1ede1f7ab527b9ead11f7eee2f73e67aeca9e4)]:
127
+ - @mastra/client-js@1.0.0-beta.9
128
+
129
+ ## 0.1.0-beta.8
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies:
134
+ - @mastra/client-js@1.0.0-beta.8
135
+
136
+ ## 0.1.0-beta.7
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [[`5fe71bc`](https://github.com/mastra-ai/mastra/commit/5fe71bc925dfce597df69c89241f33b378028c63), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141)]:
141
+ - @mastra/client-js@1.0.0-beta.7
142
+
143
+ ## 0.1.0-beta.6
144
+
145
+ ### Patch Changes
146
+
147
+ - Adjust the types to accept tracingOptions ([#10742](https://github.com/mastra-ai/mastra/pull/10742))
148
+
149
+ - Updated dependencies [[`6edf340`](https://github.com/mastra-ai/mastra/commit/6edf3402f6a46ee8def2f42a2287785251fbffd6), [`ad7e8f1`](https://github.com/mastra-ai/mastra/commit/ad7e8f16ac843cbd16687ad47b66ba96bcffe111), [`e1b7118`](https://github.com/mastra-ai/mastra/commit/e1b7118f42ca0a97247afc75e57dcd5fdf987752), [`441c7b6`](https://github.com/mastra-ai/mastra/commit/441c7b6665915cfa7fd625fded8c0f518530bf10), [`e849603`](https://github.com/mastra-ai/mastra/commit/e849603a596269069f58a438b98449ea2770493d)]:
150
+ - @mastra/client-js@1.0.0-beta.6
151
+
152
+ ## 0.1.0-beta.5
153
+
154
+ ### Patch Changes
155
+
156
+ - Configurable resourceId in react useChat ([#10461](https://github.com/mastra-ai/mastra/pull/10461))
157
+
158
+ - fix(agent): persist messages before tool suspension ([#10369](https://github.com/mastra-ai/mastra/pull/10369))
159
+
160
+ Fixes issues where thread and messages were not saved before suspension when tools require approval or call suspend() during execution. This caused conversation history to be lost if users refreshed during tool approval or suspension.
161
+
162
+ **Backend changes (@mastra/core):**
163
+ - Add assistant messages to messageList immediately after LLM execution
164
+ - Flush messages synchronously before suspension to persist state
165
+ - Create thread if it doesn't exist before flushing
166
+ - Add metadata helpers to persist and remove tool approval state
167
+ - Pass saveQueueManager and memory context through workflow for immediate persistence
168
+
169
+ **Frontend changes (@mastra/react):**
170
+ - Extract runId from pending approvals to enable resumption after refresh
171
+ - Convert `pendingToolApprovals` (DB format) to `requireApprovalMetadata` (runtime format)
172
+ - Handle both `dynamic-tool` and `tool-{NAME}` part types for approval state
173
+ - Change runId from hardcoded `agentId` to unique `uuid()`
174
+
175
+ **UI changes (@mastra/playground-ui):**
176
+ - Handle tool calls awaiting approval in message initialization
177
+ - Convert approval metadata format when loading initial messages
178
+
179
+ Fixes #9745, #9906
180
+
181
+ - Updated dependencies [[`898a972`](https://github.com/mastra-ai/mastra/commit/898a9727d286c2510d6b702dfd367e6aaf5c6b0f)]:
182
+ - @mastra/client-js@1.0.0-beta.5
183
+
184
+ ## 0.1.0-beta.4
185
+
186
+ ### Patch Changes
187
+
188
+ - Updated dependencies [[`6a86fe5`](https://github.com/mastra-ai/mastra/commit/6a86fe56b8ff53ca2eb3ed87ffc0748749ebadce), [`595a3b8`](https://github.com/mastra-ai/mastra/commit/595a3b8727c901f44e333909c09843c711224440)]:
189
+ - @mastra/client-js@1.0.0-beta.4
190
+
191
+ ## 0.1.0-beta.3
192
+
193
+ ### Patch Changes
194
+
195
+ - Updated dependencies [[`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365)]:
196
+ - @mastra/client-js@1.0.0-beta.3
197
+
198
+ ## 0.1.0-beta.2
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies []:
203
+ - @mastra/client-js@1.0.0-beta.2
204
+
205
+ ## 0.1.0-beta.1
206
+
207
+ ### Patch Changes
208
+
209
+ - Updated dependencies [[`dbd9db0`](https://github.com/mastra-ai/mastra/commit/dbd9db0d5c2797a210b9098e7e3e613718e5442f)]:
210
+ - @mastra/client-js@1.0.0-beta.1
211
+
212
+ ## 0.1.0-beta.0
213
+
214
+ ### Minor Changes
215
+
216
+ - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
217
+
218
+ - Rename RuntimeContext to RequestContext ([#9511](https://github.com/mastra-ai/mastra/pull/9511))
219
+
220
+ - Renamed `MastraMessageV2` to `MastraDBMessage` ([#9255](https://github.com/mastra-ai/mastra/pull/9255))
221
+ Made the return format of all methods that return db messages consistent. It's always `{ messages: MastraDBMessage[] }` now, and messages can be converted after that using `@mastra/ai-sdk/ui`'s `toAISdkV4/5Messages()` function
4
222
 
5
223
  ### Patch Changes
6
224
 
@@ -8,8 +226,8 @@
8
226
 
9
227
  - Fix multi modal in react sdk ([#9373](https://github.com/mastra-ai/mastra/pull/9373))
10
228
 
11
- - Updated dependencies [[`1ee3411`](https://github.com/mastra-ai/mastra/commit/1ee34113192b11aa8bcdd8d9d5830ae13254b345), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`ea0b8de`](https://github.com/mastra-ai/mastra/commit/ea0b8dec0d4bc86a72a7e75b2f56c6017c58786d), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`63f2f18`](https://github.com/mastra-ai/mastra/commit/63f2f1863dffe3ad23221d0660ed4e4f2b81789d), [`c23200d`](https://github.com/mastra-ai/mastra/commit/c23200ddfd60830effb39329674ba4ca93be6aac)]:
12
- - @mastra/client-js@0.0.0-sidebar-window-undefined-fix-20251029233656
229
+ - Updated dependencies [[`3852192`](https://github.com/mastra-ai/mastra/commit/3852192c81b2a4f1f883f17d80ce50e0c60dba55), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`3443770`](https://github.com/mastra-ai/mastra/commit/3443770662df8eb24c9df3589b2792d78cfcb811), [`f0a07e0`](https://github.com/mastra-ai/mastra/commit/f0a07e0111b3307c5fabfa4094c5c2cfb734fbe6), [`aaa40e7`](https://github.com/mastra-ai/mastra/commit/aaa40e788628b319baa8e889407d11ad626547fa), [`dd1c38d`](https://github.com/mastra-ai/mastra/commit/dd1c38d1b75f1b695c27b40d8d9d6ed00d5e0f6f), [`5948e6a`](https://github.com/mastra-ai/mastra/commit/5948e6a5146c83666ba3f294b2be576c82a513fb), [`dff01d8`](https://github.com/mastra-ai/mastra/commit/dff01d81ce1f4e4087cfac20fa868e6db138dd14), [`b7de533`](https://github.com/mastra-ai/mastra/commit/b7de53361667eb51fefd89fcaed924f3c57cee8d), [`7051bf3`](https://github.com/mastra-ai/mastra/commit/7051bf38b3b122a069008f861f7bfc004a6d9f6e), [`1ee3411`](https://github.com/mastra-ai/mastra/commit/1ee34113192b11aa8bcdd8d9d5830ae13254b345), [`0793497`](https://github.com/mastra-ai/mastra/commit/079349753620c40246ffd673e3f9d7d9820beff3), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`f93d992`](https://github.com/mastra-ai/mastra/commit/f93d992a37d5431ab4a71246835d403ef7c4ce85), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`9f4a683`](https://github.com/mastra-ai/mastra/commit/9f4a6833e88b52574665c028fd5508ad5c2f6004), [`ea0b8de`](https://github.com/mastra-ai/mastra/commit/ea0b8dec0d4bc86a72a7e75b2f56c6017c58786d), [`eb09742`](https://github.com/mastra-ai/mastra/commit/eb09742197f66c4c38154c3beec78313e69760b2), [`a1bd7b8`](https://github.com/mastra-ai/mastra/commit/a1bd7b8571db16b94eb01588f451a74758c96d65), [`0633100`](https://github.com/mastra-ai/mastra/commit/0633100a911ad22f5256471bdf753da21c104742), [`354ad0b`](https://github.com/mastra-ai/mastra/commit/354ad0b7b1b8183ac567f236a884fc7ede6d7138), [`519d9e6`](https://github.com/mastra-ai/mastra/commit/519d9e6d31910457c54bdae8b7b7cb3a69f41831), [`844ea5d`](https://github.com/mastra-ai/mastra/commit/844ea5dc0c248961e7bf73629ae7dcff503e853c), [`dfe3f8c`](https://github.com/mastra-ai/mastra/commit/dfe3f8c7376ffe159236819e19ca522143c1f972), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`e8dcd71`](https://github.com/mastra-ai/mastra/commit/e8dcd71fa5e473c8ba1d6dad99eef182d20a0491), [`63f2f18`](https://github.com/mastra-ai/mastra/commit/63f2f1863dffe3ad23221d0660ed4e4f2b81789d), [`c23200d`](https://github.com/mastra-ai/mastra/commit/c23200ddfd60830effb39329674ba4ca93be6aac), [`363284b`](https://github.com/mastra-ai/mastra/commit/363284bb974e850f06f40f89a28c79d9f432d7e4), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`b7959e6`](https://github.com/mastra-ai/mastra/commit/b7959e6e25a46b480f9ea2217c4c6c588c423791), [`0bddc6d`](https://github.com/mastra-ai/mastra/commit/0bddc6d8dbd6f6008c0cba2e4960a2da75a55af1), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014)]:
230
+ - @mastra/client-js@1.0.0-beta.0
13
231
 
14
232
  ## 0.0.10
15
233
 
package/dist/index.cjs CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
  const jsxRuntime = require('react/jsx-runtime');
6
6
  const react = require('react');
7
7
  const clientJs = require('@mastra/client-js');
8
+ const uuid = require('@lukeed/uuid');
8
9
  const lucideReact = require('lucide-react');
9
10
  const tailwindMerge = require('tailwind-merge');
10
11
  const hastUtilToJsxRuntime = require('hast-util-to-jsx-runtime');
@@ -50,7 +51,7 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
50
51
  return {
51
52
  ...prev,
52
53
  status: chunk.payload.workflowStatus,
53
- ...finalStatus === "success" && lastStep?.status === "success" ? { result: lastStep?.output } : finalStatus === "failed" && lastStep?.status === "failed" ? { error: lastStep?.error } : {}
54
+ ...finalStatus === "success" && lastStep?.status === "success" ? { result: lastStep?.output } : finalStatus === "failed" && lastStep?.status === "failed" ? { error: lastStep?.error } : finalStatus === "tripwire" && chunk.payload.tripwire ? { tripwire: chunk.payload.tripwire } : {}
54
55
  };
55
56
  }
56
57
  const { stepCallId, stepName, ...newPayload } = chunk.payload ?? {};
@@ -102,6 +103,34 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
102
103
  };
103
104
  const toUIMessage = ({ chunk, conversation, metadata }) => {
104
105
  const result = [...conversation];
106
+ if (chunk.type.startsWith("data-")) {
107
+ const lastMessage = result[result.length - 1];
108
+ if (!lastMessage || lastMessage.role !== "assistant") {
109
+ const newMessage = {
110
+ id: `data-${chunk.runId}-${Date.now()}`,
111
+ role: "assistant",
112
+ parts: [
113
+ {
114
+ type: chunk.type,
115
+ data: "data" in chunk ? chunk.data : void 0
116
+ }
117
+ ],
118
+ metadata
119
+ };
120
+ return [...result, newMessage];
121
+ }
122
+ const updatedMessage = {
123
+ ...lastMessage,
124
+ parts: [
125
+ ...lastMessage.parts,
126
+ {
127
+ type: chunk.type,
128
+ data: "data" in chunk ? chunk.data : void 0
129
+ }
130
+ ]
131
+ };
132
+ return [...result.slice(0, -1), updatedMessage];
133
+ }
105
134
  switch (chunk.type) {
106
135
  case "tripwire": {
107
136
  const newMessage = {
@@ -110,12 +139,17 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
110
139
  parts: [
111
140
  {
112
141
  type: "text",
113
- text: chunk.payload.tripwireReason
142
+ text: chunk.payload.reason
114
143
  }
115
144
  ],
116
145
  metadata: {
117
146
  ...metadata,
118
- status: "warning"
147
+ status: "tripwire",
148
+ tripwire: {
149
+ retry: chunk.payload.retry,
150
+ tripwirePayload: chunk.payload.metadata,
151
+ processorId: chunk.payload.processorId
152
+ }
119
153
  }
120
154
  };
121
155
  return [...result, newMessage];
@@ -259,17 +293,19 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
259
293
  if (!lastMessage || lastMessage.role !== "assistant") return result;
260
294
  const parts = [...lastMessage.parts];
261
295
  const toolPartIndex = parts.findIndex(
262
- (part) => part.type === "dynamic-tool" && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
296
+ (part) => (part.type === "dynamic-tool" || typeof part.type === "string" && part.type.startsWith("tool-")) && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
263
297
  );
264
298
  if (toolPartIndex !== -1) {
265
299
  const toolPart = parts[toolPartIndex];
266
- if (toolPart.type === "dynamic-tool") {
300
+ if (toolPart.type === "dynamic-tool" || typeof toolPart.type === "string" && toolPart.type.startsWith("tool-")) {
301
+ const toolName = "toolName" in toolPart && typeof toolPart.toolName === "string" ? toolPart.toolName : toolPart.type.startsWith("tool-") ? toolPart.type.substring(5) : "";
302
+ const toolCallId = toolPart.toolCallId;
267
303
  if (chunk.type === "tool-result" && chunk.payload.isError || chunk.type === "tool-error") {
268
304
  const error = chunk.type === "tool-error" ? chunk.payload.error : chunk.payload.result;
269
305
  parts[toolPartIndex] = {
270
306
  type: "dynamic-tool",
271
- toolName: toolPart.toolName,
272
- toolCallId: toolPart.toolCallId,
307
+ toolName,
308
+ toolCallId,
273
309
  state: "output-error",
274
310
  input: toolPart.input,
275
311
  errorText: String(error),
@@ -288,8 +324,8 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
288
324
  }
289
325
  parts[toolPartIndex] = {
290
326
  type: "dynamic-tool",
291
- toolName: toolPart.toolName,
292
- toolCallId: toolPart.toolCallId,
327
+ toolName,
328
+ toolCallId,
293
329
  state: "output-available",
294
330
  input: toolPart.input,
295
331
  output,
@@ -311,11 +347,14 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
311
347
  if (!lastMessage || lastMessage.role !== "assistant") return result;
312
348
  const parts = [...lastMessage.parts];
313
349
  const toolPartIndex = parts.findIndex(
314
- (part) => part.type === "dynamic-tool" && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
350
+ (part) => (part.type === "dynamic-tool" || typeof part.type === "string" && part.type.startsWith("tool-")) && "toolCallId" in part && part.toolCallId === chunk.payload.toolCallId
315
351
  );
316
352
  if (toolPartIndex !== -1) {
317
353
  const toolPart = parts[toolPartIndex];
318
- if (toolPart.type === "dynamic-tool") {
354
+ if (toolPart.type === "dynamic-tool" || typeof toolPart.type === "string" && toolPart.type.startsWith("tool-")) {
355
+ const toolName = "toolName" in toolPart && typeof toolPart.toolName === "string" ? toolPart.toolName : typeof toolPart.type === "string" && toolPart.type.startsWith("tool-") ? toolPart.type.substring(5) : "";
356
+ const toolCallId = toolPart.toolCallId;
357
+ const input = toolPart.input;
319
358
  if (chunk.payload.output?.type?.startsWith("workflow-")) {
320
359
  const existingWorkflowState = toolPart.output || {};
321
360
  const updatedWorkflowState = mapWorkflowStreamChunkToWatchResult(
@@ -323,7 +362,11 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
323
362
  chunk.payload.output
324
363
  );
325
364
  parts[toolPartIndex] = {
326
- ...toolPart,
365
+ type: "dynamic-tool",
366
+ toolName,
367
+ toolCallId,
368
+ state: "input-streaming",
369
+ input,
327
370
  output: updatedWorkflowState
328
371
  };
329
372
  } else if (chunk.payload.output?.from === "AGENT" || chunk.payload.output?.from === "USER" && chunk.payload.output?.payload?.output?.type?.startsWith("workflow-")) {
@@ -332,7 +375,11 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
332
375
  const currentOutput = toolPart.output || [];
333
376
  const existingOutput = Array.isArray(currentOutput) ? currentOutput : [];
334
377
  parts[toolPartIndex] = {
335
- ...toolPart,
378
+ type: "dynamic-tool",
379
+ toolName,
380
+ toolCallId,
381
+ state: "input-streaming",
382
+ input,
336
383
  output: [...existingOutput, chunk.payload.output]
337
384
  };
338
385
  }
@@ -428,11 +475,10 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
428
475
  const lastMessage = result[result.length - 1];
429
476
  if (!lastMessage || lastMessage.role !== "assistant") return result;
430
477
  const parts = lastMessage.parts.map((part) => {
431
- if (part.type === "text" && part.state === "streaming") {
432
- return { ...part, state: "done" };
433
- }
434
- if (part.type === "reasoning" && part.state === "streaming") {
435
- return { ...part, state: "done" };
478
+ if (typeof part === "object" && part !== null && "type" in part && "state" in part && part.state === "streaming") {
479
+ if (part.type === "text" || part.type === "reasoning") {
480
+ return { ...part, state: "done" };
481
+ }
436
482
  }
437
483
  return part;
438
484
  });
@@ -656,6 +702,29 @@ const toAssistantUIMessage = (message) => {
656
702
  }
657
703
  return baseToolCall;
658
704
  }
705
+ const requireApprovalMetadata = extendedMessage.metadata?.requireApprovalMetadata;
706
+ const partToolCallId = "toolCallId" in part && typeof part.toolCallId === "string" ? part.toolCallId : void 0;
707
+ const suspensionData = partToolCallId ? requireApprovalMetadata?.[partToolCallId] : void 0;
708
+ if (suspensionData) {
709
+ const toolName = "toolName" in part && typeof part.toolName === "string" ? part.toolName : part.type.startsWith("tool-") ? part.type.substring(5) : "";
710
+ return {
711
+ type: "tool-call",
712
+ toolCallId: partToolCallId,
713
+ toolName,
714
+ argsText: "input" in part ? JSON.stringify(part.input) : "{}",
715
+ args: "input" in part ? part.input : {},
716
+ metadata: extendedMessage.metadata
717
+ };
718
+ }
719
+ if (part.type.startsWith("data-")) {
720
+ return {
721
+ type: "data",
722
+ name: part.type.substring(5),
723
+ // Extract name from 'data-{name}'
724
+ data: part.data,
725
+ metadata: message.metadata
726
+ };
727
+ }
659
728
  return {
660
729
  type: "text",
661
730
  text: "",
@@ -697,7 +766,9 @@ const toAssistantUIMessage = (message) => {
697
766
 
698
767
  const resolveInitialMessages = (messages) => {
699
768
  return messages.map((message) => {
700
- const networkPart = message.parts.find((part) => part.type === "text" && part.text.includes('"isNetwork":true'));
769
+ const networkPart = message.parts.find(
770
+ (part) => typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string" && part.text.includes('"isNetwork":true')
771
+ );
701
772
  if (networkPart && networkPart.type === "text") {
702
773
  try {
703
774
  const json = JSON.parse(networkPart.text);
@@ -740,7 +811,6 @@ const resolveInitialMessages = (messages) => {
740
811
  childMessages,
741
812
  result: finalResult?.text || ""
742
813
  };
743
- console.log("json", json);
744
814
  const nextMessage = {
745
815
  role: "assistant",
746
816
  parts: [
@@ -768,6 +838,18 @@ const resolveInitialMessages = (messages) => {
768
838
  return message;
769
839
  }
770
840
  }
841
+ const extendedMessage = message;
842
+ const pendingToolApprovals = extendedMessage.metadata?.pendingToolApprovals;
843
+ if (pendingToolApprovals && typeof pendingToolApprovals === "object") {
844
+ return {
845
+ ...message,
846
+ metadata: {
847
+ ...message.metadata,
848
+ mode: "stream",
849
+ requireApprovalMetadata: pendingToolApprovals
850
+ }
851
+ };
852
+ }
771
853
  return message;
772
854
  });
773
855
  };
@@ -1216,22 +1298,35 @@ const fromCoreUserMessageToUIMessage = (coreUserMessage) => {
1216
1298
  };
1217
1299
  };
1218
1300
 
1219
- const useChat = ({ agentId, initializeMessages }) => {
1220
- const _currentRunId = react.useRef(void 0);
1301
+ const useChat = ({ agentId, resourceId, initializeMessages }) => {
1302
+ const extractRunIdFromMessages = (messages2) => {
1303
+ for (const message of messages2) {
1304
+ const pendingToolApprovals = message.metadata?.pendingToolApprovals;
1305
+ if (pendingToolApprovals && typeof pendingToolApprovals === "object") {
1306
+ const suspensionData = Object.values(pendingToolApprovals)[0];
1307
+ if (suspensionData?.runId) {
1308
+ return suspensionData.runId;
1309
+ }
1310
+ }
1311
+ }
1312
+ return void 0;
1313
+ };
1314
+ const initialMessages = initializeMessages?.() || [];
1315
+ const initialRunId = extractRunIdFromMessages(initialMessages);
1316
+ const _currentRunId = react.useRef(initialRunId);
1221
1317
  const _onChunk = react.useRef(void 0);
1222
- const [messages, setMessages] = react.useState(
1223
- () => resolveInitialMessages(initializeMessages?.() || [])
1224
- );
1318
+ const [messages, setMessages] = react.useState(() => resolveInitialMessages(initialMessages));
1225
1319
  const [toolCallApprovals, setToolCallApprovals] = react.useState({});
1226
1320
  const baseClient = useMastraClient();
1227
1321
  const [isRunning, setIsRunning] = react.useState(false);
1228
1322
  const generate = async ({
1229
1323
  coreUserMessages,
1230
- runtimeContext,
1324
+ requestContext,
1231
1325
  threadId,
1232
1326
  modelSettings,
1233
1327
  signal,
1234
- onFinish
1328
+ onFinish,
1329
+ tracingOptions
1235
1330
  }) => {
1236
1331
  const {
1237
1332
  frequencyPenalty,
@@ -1253,7 +1348,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1253
1348
  const agent = clientWithAbort.getAgent(agentId);
1254
1349
  const response = await agent.generate({
1255
1350
  messages: coreUserMessages,
1256
- runId: agentId,
1351
+ runId: uuid.v4(),
1257
1352
  maxSteps,
1258
1353
  modelSettings: {
1259
1354
  frequencyPenalty,
@@ -1265,9 +1360,10 @@ const useChat = ({ agentId, initializeMessages }) => {
1265
1360
  topP
1266
1361
  },
1267
1362
  instructions,
1268
- runtimeContext,
1269
- ...threadId ? { threadId, resourceId: agentId } : {},
1270
- providerOptions
1363
+ requestContext,
1364
+ ...threadId ? { threadId, resourceId: resourceId || agentId } : {},
1365
+ providerOptions,
1366
+ tracingOptions
1271
1367
  });
1272
1368
  setIsRunning(false);
1273
1369
  if (response && "uiMessages" in response.response && response.response.uiMessages) {
@@ -1281,7 +1377,15 @@ const useChat = ({ agentId, initializeMessages }) => {
1281
1377
  setMessages((prev) => [...prev, ...mastraUIMessages]);
1282
1378
  }
1283
1379
  };
1284
- const stream = async ({ coreUserMessages, runtimeContext, threadId, onChunk, modelSettings, signal }) => {
1380
+ const stream = async ({
1381
+ coreUserMessages,
1382
+ requestContext,
1383
+ threadId,
1384
+ onChunk,
1385
+ modelSettings,
1386
+ signal,
1387
+ tracingOptions
1388
+ }) => {
1285
1389
  const {
1286
1390
  frequencyPenalty,
1287
1391
  presencePenalty,
@@ -1301,7 +1405,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1301
1405
  abortSignal: signal
1302
1406
  });
1303
1407
  const agent = clientWithAbort.getAgent(agentId);
1304
- const runId = agentId;
1408
+ const runId = uuid.v4();
1305
1409
  const response = await agent.stream({
1306
1410
  messages: coreUserMessages,
1307
1411
  runId,
@@ -1316,10 +1420,11 @@ const useChat = ({ agentId, initializeMessages }) => {
1316
1420
  topP
1317
1421
  },
1318
1422
  instructions,
1319
- runtimeContext,
1320
- ...threadId ? { threadId, resourceId: agentId } : {},
1423
+ requestContext,
1424
+ ...threadId ? { threadId, resourceId: resourceId || agentId } : {},
1321
1425
  providerOptions,
1322
- requireToolApproval
1426
+ requireToolApproval,
1427
+ tracingOptions
1323
1428
  });
1324
1429
  _onChunk.current = onChunk;
1325
1430
  _currentRunId.current = runId;
@@ -1333,11 +1438,12 @@ const useChat = ({ agentId, initializeMessages }) => {
1333
1438
  };
1334
1439
  const network = async ({
1335
1440
  coreUserMessages,
1336
- runtimeContext,
1441
+ requestContext,
1337
1442
  threadId,
1338
1443
  onNetworkChunk,
1339
1444
  modelSettings,
1340
- signal
1445
+ signal,
1446
+ tracingOptions
1341
1447
  }) => {
1342
1448
  const { frequencyPenalty, presencePenalty, maxRetries, maxTokens, temperature, topK, topP, maxSteps } = modelSettings || {};
1343
1449
  setIsRunning(true);
@@ -1346,6 +1452,7 @@ const useChat = ({ agentId, initializeMessages }) => {
1346
1452
  abortSignal: signal
1347
1453
  });
1348
1454
  const agent = clientWithAbort.getAgent(agentId);
1455
+ const runId = uuid.v4();
1349
1456
  const response = await agent.network({
1350
1457
  messages: coreUserMessages,
1351
1458
  maxSteps,
@@ -1358,9 +1465,10 @@ const useChat = ({ agentId, initializeMessages }) => {
1358
1465
  topK,
1359
1466
  topP
1360
1467
  },
1361
- runId: agentId,
1362
- runtimeContext,
1363
- ...threadId ? { thread: threadId, resourceId: agentId } : {}
1468
+ runId,
1469
+ requestContext,
1470
+ ...threadId ? { thread: threadId, resourceId: resourceId || agentId } : {},
1471
+ tracingOptions
1364
1472
  });
1365
1473
  const transformer = new AISdkNetworkTransformer();
1366
1474
  await response.processDataStream({