@mastra/react 0.1.0-beta.9 → 0.1.0

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,4 +1,687 @@
1
- # @mastra/react-hooks
1
+ # @mastra/react
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added human-in-the-loop (HITL) tool approval support for `generate()` method. ([#12056](https://github.com/mastra-ai/mastra/pull/12056))
8
+
9
+ **Why:** This provides parity between `stream()` and `generate()` for tool approval flows, allowing non-streaming use cases to leverage `requireToolApproval` without needing to switch to streaming.
10
+
11
+ Previously, tool approval with `requireToolApproval` only worked with `stream()`. Now you can use the same approval flow with `generate()` for non-streaming use cases.
12
+
13
+ **Using tool approval with generate()**
14
+
15
+ ```typescript
16
+ const output = await agent.generate('Find user John', {
17
+ requireToolApproval: true,
18
+ });
19
+
20
+ // Check if a tool is waiting for approval
21
+ if (output.finishReason === 'suspended') {
22
+ console.log('Tool requires approval:', output.suspendPayload.toolName);
23
+
24
+ // Approve the tool call
25
+ const result = await agent.approveToolCallGenerate({
26
+ runId: output.runId,
27
+ toolCallId: output.suspendPayload.toolCallId,
28
+ });
29
+
30
+ console.log(result.text);
31
+ }
32
+ ```
33
+
34
+ **Declining a tool call**
35
+
36
+ ```typescript
37
+ if (output.finishReason === 'suspended') {
38
+ const result = await agent.declineToolCallGenerate({
39
+ runId: output.runId,
40
+ toolCallId: output.suspendPayload.toolCallId,
41
+ });
42
+ }
43
+ ```
44
+
45
+ **New methods added:**
46
+ - `agent.approveToolCallGenerate({ runId, toolCallId })` - Approves a pending tool call and returns the complete result
47
+ - `agent.declineToolCallGenerate({ runId, toolCallId })` - Declines a pending tool call and returns the complete result
48
+
49
+ **Server routes added:**
50
+ - `POST /api/agents/:agentId/approve-tool-call-generate`
51
+ - `POST /api/agents/:agentId/decline-tool-call-generate`
52
+
53
+ The playground UI now also supports tool approval when using generate mode.
54
+
55
+ - Bump minimum required Node.js version to 22.13.0 ([#9706](https://github.com/mastra-ai/mastra/pull/9706))
56
+
57
+ - **Fixed:** Align `Agent.network` with core and update `@mastra/react` network usage. ([#12015](https://github.com/mastra-ai/mastra/pull/12015))
58
+
59
+ - Rename RuntimeContext to RequestContext ([#9511](https://github.com/mastra-ai/mastra/pull/9511))
60
+
61
+ - Unified observability schema with entity-based span identification ([#11132](https://github.com/mastra-ai/mastra/pull/11132))
62
+
63
+ ## What changed
64
+
65
+ Spans now use a unified identification model with `entityId`, `entityType`, and `entityName` instead of separate `agentId`, `toolId`, `workflowId` fields.
66
+
67
+ **Before:**
68
+
69
+ ```typescript
70
+ // Old span structure
71
+ span.agentId; // 'my-agent'
72
+ span.toolId; // undefined
73
+ span.workflowId; // undefined
74
+ ```
75
+
76
+ **After:**
77
+
78
+ ```typescript
79
+ // New span structure
80
+ span.entityType; // EntityType.AGENT
81
+ span.entityId; // 'my-agent'
82
+ span.entityName; // 'My Agent'
83
+ ```
84
+
85
+ ## New `listTraces()` API
86
+
87
+ Query traces with filtering, pagination, and sorting:
88
+
89
+ ```typescript
90
+ const { spans, pagination } = await storage.listTraces({
91
+ filters: {
92
+ entityType: EntityType.AGENT,
93
+ entityId: 'my-agent',
94
+ userId: 'user-123',
95
+ environment: 'production',
96
+ status: TraceStatus.SUCCESS,
97
+ startedAt: { start: new Date('2024-01-01'), end: new Date('2024-01-31') },
98
+ },
99
+ pagination: { page: 0, perPage: 50 },
100
+ orderBy: { field: 'startedAt', direction: 'DESC' },
101
+ });
102
+ ```
103
+
104
+ **Available filters:** date ranges (`startedAt`, `endedAt`), entity (`entityType`, `entityId`, `entityName`), identity (`userId`, `organizationId`), correlation IDs (`runId`, `sessionId`, `threadId`), deployment (`environment`, `source`, `serviceName`), `tags`, `metadata`, and `status`.
105
+
106
+ ## New retrieval methods
107
+ - `getSpan({ traceId, spanId })` - Get a single span
108
+ - `getRootSpan({ traceId })` - Get the root span of a trace
109
+ - `getTrace({ traceId })` - Get all spans for a trace
110
+
111
+ ## Backward compatibility
112
+
113
+ The legacy `getTraces()` method continues to work. When you pass `name: "agent run: my-agent"`, it automatically transforms to `entityId: "my-agent", entityType: AGENT`.
114
+
115
+ ## Migration
116
+
117
+ **Automatic:** SQL-based stores (PostgreSQL, LibSQL, MSSQL) automatically add new columns to existing `spans` tables on initialization. Existing data is preserved with new columns set to `NULL`.
118
+
119
+ **No action required:** Your existing code continues to work. Adopt the new fields and `listTraces()` API at your convenience.
120
+
121
+ - Renamed `MastraMessageV2` to `MastraDBMessage` ([#9255](https://github.com/mastra-ai/mastra/pull/9255))
122
+ 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
123
+
124
+ - 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))
125
+
126
+ ### Patch Changes
127
+
128
+ - Remove redundant toolCalls from network agent finalResult ([#11189](https://github.com/mastra-ai/mastra/pull/11189))
129
+
130
+ The network agent's `finalResult` was storing `toolCalls` separately even though all tool call information is already present in the `messages` array (as `tool-call` and `tool-result` type messages). This caused significant token waste since the routing agent reads this data from memory on every iteration.
131
+
132
+ **Before:** `finalResult: { text, toolCalls, messages }`
133
+ **After:** `finalResult: { text, messages }`
134
+
135
+ +**Migration:** If you were accessing `finalResult.toolCalls`, retrieve tool calls from `finalResult.messages` by filtering for messages with `type: 'tool-call'`.
136
+
137
+ Updated `@mastra/react` to extract tool calls directly from the `messages` array instead of the removed `toolCalls` field when resolving initial messages from memory.
138
+
139
+ Fixes #11059
140
+
141
+ - Auto resume suspended tools if `autoResumeSuspendedTools: true` ([#11157](https://github.com/mastra-ai/mastra/pull/11157))
142
+
143
+ The flag can be added to `defaultAgentOptions` when creating the agent or to options in `agent.stream` or `agent.generate`
144
+
145
+ ```typescript
146
+ const agent = new Agent({
147
+ //...agent information,
148
+ defaultAgentOptions: {
149
+ autoResumeSuspendedTools: true,
150
+ },
151
+ });
152
+ ```
153
+
154
+ - Removes the deprecated `threadId` and `resourceId` options from `AgentExecutionOptions`. These have been deprecated for months in favour of the `memory` option. ([#11897](https://github.com/mastra-ai/mastra/pull/11897))
155
+
156
+ ### Breaking Changes
157
+
158
+ #### `@mastra/core`
159
+
160
+ The `threadId` and `resourceId` options have been removed from `agent.generate()` and `agent.stream()`. Use the `memory` option instead:
161
+
162
+ ```ts
163
+ // Before
164
+ await agent.stream('Hello', {
165
+ threadId: 'thread-123',
166
+ resourceId: 'user-456',
167
+ });
168
+
169
+ // After
170
+ await agent.stream('Hello', {
171
+ memory: {
172
+ thread: 'thread-123',
173
+ resource: 'user-456',
174
+ },
175
+ });
176
+ ```
177
+
178
+ #### `@mastra/server`
179
+
180
+ The `threadId`, `resourceId`, and `resourceid` fields have been removed from the main agent execution body schema. The server now expects the `memory` option format in request bodies. Legacy routes (`/api/agents/:agentId/generate-legacy` and `/api/agents/:agentId/stream-legacy`) continue to support the deprecated fields.
181
+
182
+ #### `@mastra/react`
183
+
184
+ The `useChat` hook now internally converts `threadId` to the `memory` option format when making API calls. No changes needed in component code - the hook handles the conversion automatically.
185
+
186
+ #### `@mastra/client-js`
187
+
188
+ When using the client SDK agent methods, use the `memory` option instead of `threadId`/`resourceId`:
189
+
190
+ ```ts
191
+ const agent = client.getAgent('my-agent');
192
+
193
+ // Before
194
+ await agent.generate([...], {
195
+ threadId: 'thread-123',
196
+ resourceId: 'user-456',
197
+ });
198
+
199
+ // After
200
+ await agent.generate([...], {
201
+ memory: {
202
+ thread: 'thread-123',
203
+ resource: 'user-456',
204
+ },
205
+ });
206
+ ```
207
+
208
+ - Adjust the types to accept tracingOptions ([#10742](https://github.com/mastra-ai/mastra/pull/10742))
209
+
210
+ - Add human-in-the-loop (HITL) support to agent networks ([#11678](https://github.com/mastra-ai/mastra/pull/11678))
211
+ - Add suspend/resume capabilities to agent network
212
+ - Enable auto-resume for suspended network execution via `autoResumeSuspendedTools`
213
+
214
+ `agent.resumeNetwork`, `agent.approveNetworkToolCall`, `agent.declineNetworkToolCall`
215
+
216
+ - Fix TypeScript errors during build declaration generation ([#11682](https://github.com/mastra-ai/mastra/pull/11682))
217
+
218
+ Updated test file `toUIMessage.test.ts` to match current `@mastra/core` types:
219
+ - Changed `error` property from string to `Error` object (per `StepFailure` type)
220
+ - Added missing `resumeSchema` property to `tool-call-approval` payloads (per `ToolCallApprovalPayload` type)
221
+ - Added `zod` as peer/dev dependency for test type support
222
+
223
+ - Fix text parts incorrectly merging across tool calls ([#11783](https://github.com/mastra-ai/mastra/pull/11783))
224
+
225
+ Previously, when an agent produced text before and after a tool call (e.g., "Let me search for that" → tool call → "Here's what I found"), the text parts would be merged into a single part, losing the separation. This fix introduces a `textId` property to track separate text streams, ensuring each text stream maintains its own text part in the UI message.
226
+
227
+ Fixes #11577
228
+
229
+ - Configurable resourceId in react useChat ([#10461](https://github.com/mastra-ai/mastra/pull/10461))
230
+
231
+ - Add tool call approval ([#8649](https://github.com/mastra-ai/mastra/pull/8649))
232
+
233
+ - 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. ([#10369](https://github.com/mastra-ai/mastra/pull/10369))
234
+
235
+ **Backend changes (@mastra/core):**
236
+ - Add assistant messages to messageList immediately after LLM execution
237
+ - Flush messages synchronously before suspension to persist state
238
+ - Create thread if it doesn't exist before flushing
239
+ - Add metadata helpers to persist and remove tool approval state
240
+ - Pass saveQueueManager and memory context through workflow for immediate persistence
241
+
242
+ **Frontend changes (@mastra/react):**
243
+ - Extract runId from pending approvals to enable resumption after refresh
244
+ - Convert `pendingToolApprovals` (DB format) to `requireApprovalMetadata` (runtime format)
245
+ - Handle both `dynamic-tool` and `tool-{NAME}` part types for approval state
246
+ - Change runId from hardcoded `agentId` to unique `uuid()`
247
+
248
+ **UI changes (@mastra/playground-ui):**
249
+ - Handle tool calls awaiting approval in message initialization
250
+ - Convert approval metadata format when loading initial messages
251
+
252
+ Fixes #9745, #9906
253
+
254
+ - Fixed compatibility with updated `@mastra/client-js` generate and stream API signatures ([#12011](https://github.com/mastra-ai/mastra/pull/12011))
255
+
256
+ - Fixed agent network not returning text response when routing agent handles requests without delegation. ([#11497](https://github.com/mastra-ai/mastra/pull/11497))
257
+
258
+ **What changed:**
259
+ - Agent networks now correctly stream text responses when the routing agent decides to handle a request itself instead of delegating to sub-agents, workflows, or tools
260
+ - Added fallback in transformers to ensure text is always returned even if core events are missing
261
+
262
+ **Why this matters:**
263
+ Previously, when using `toAISdkV5Stream` or `networkRoute()` outside of the Mastra Studio UI, no text content was returned when the routing agent handled requests directly. This fix ensures consistent behavior across all API routes.
264
+
265
+ Fixes #11219
266
+
267
+ - Fix multi modal in react sdk ([#9373](https://github.com/mastra-ai/mastra/pull/9373))
268
+
269
+ - Display network completion validation results and scorer feedback in the Playground when viewing agent network runs, letting users see pass/fail status and actionable feedback from completion scorers ([#11562](https://github.com/mastra-ai/mastra/pull/11562))
270
+
271
+ - 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))
272
+
273
+ When a workflow contains an agent step that triggers a tripwire, the workflow returns with `status: 'tripwire'` and includes tripwire details:
274
+
275
+ ```typescript
276
+ const run = await workflow.createRun();
277
+ const result = await run.start({ inputData: { message: 'Hello' } });
278
+
279
+ if (result.status === 'tripwire') {
280
+ console.log('Workflow terminated by tripwire:', result.tripwire?.reason);
281
+ console.log('Processor ID:', result.tripwire?.processorId);
282
+ console.log('Retry requested:', result.tripwire?.retry);
283
+ }
284
+ ```
285
+
286
+ Adds new UI state for tripwire in agent chat and workflow UI.
287
+
288
+ 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).
289
+
290
+ - - Add persistence for custom data chunks (`data-*` parts) emitted via `writer.custom()` in tools ([#10884](https://github.com/mastra-ai/mastra/pull/10884))
291
+ - Data chunks are now saved to message storage so they survive page refreshes
292
+ - Update `@assistant-ui/react` to v0.11.47 with native `DataMessagePart` support
293
+ - Convert `data-*` parts to `DataMessagePart` format (`{ type: 'data', name: string, data: T }`)
294
+ - Update related `@assistant-ui/*` packages for compatibility
295
+ - Updated dependencies [[`6edf340`](https://github.com/mastra-ai/mastra/commit/6edf3402f6a46ee8def2f42a2287785251fbffd6), [`bc72b52`](https://github.com/mastra-ai/mastra/commit/bc72b529ee4478fe89ecd85a8be47ce0127b82a0), [`ed3e3dd`](https://github.com/mastra-ai/mastra/commit/ed3e3ddec69d564fe2b125e083437f76331f1283), [`c042bd0`](https://github.com/mastra-ai/mastra/commit/c042bd0b743e0e86199d0cb83344ca7690e34a9c), [`3852192`](https://github.com/mastra-ai/mastra/commit/3852192c81b2a4f1f883f17d80ce50e0c60dba55), [`fec5129`](https://github.com/mastra-ai/mastra/commit/fec5129de7fc64423ea03661a56cef31dc747a0d), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`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), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`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), [`9d5059e`](https://github.com/mastra-ai/mastra/commit/9d5059eae810829935fb08e81a9bb7ecd5b144a7), [`e1b7118`](https://github.com/mastra-ai/mastra/commit/e1b7118f42ca0a97247afc75e57dcd5fdf987752), [`461e448`](https://github.com/mastra-ai/mastra/commit/461e448852fe999506a6046d50b1efc27d8aa378), [`441c7b6`](https://github.com/mastra-ai/mastra/commit/441c7b6665915cfa7fd625fded8c0f518530bf10), [`b7de533`](https://github.com/mastra-ai/mastra/commit/b7de53361667eb51fefd89fcaed924f3c57cee8d), [`ef756c6`](https://github.com/mastra-ai/mastra/commit/ef756c65f82d16531c43f49a27290a416611e526), [`1b85674`](https://github.com/mastra-ai/mastra/commit/1b85674123708d9b85834dccc9eae601a9d0891c), [`5a1ede1`](https://github.com/mastra-ai/mastra/commit/5a1ede1f7ab527b9ead11f7eee2f73e67aeca9e4), [`47b1c16`](https://github.com/mastra-ai/mastra/commit/47b1c16a01c7ffb6765fe1e499b49092f8b7eba3), [`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), [`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac), [`66741d1`](https://github.com/mastra-ai/mastra/commit/66741d1a99c4f42cf23a16109939e8348ac6852e), [`610a70b`](https://github.com/mastra-ai/mastra/commit/610a70bdad282079f0c630e0d7bb284578f20151), [`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), [`d90ea65`](https://github.com/mastra-ai/mastra/commit/d90ea6536f7aa51c6545a4e9215b55858e98e16d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`eb09742`](https://github.com/mastra-ai/mastra/commit/eb09742197f66c4c38154c3beec78313e69760b2), [`e4d366a`](https://github.com/mastra-ai/mastra/commit/e4d366aeb500371dd4210d6aa8361a4c21d87034), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`d171e55`](https://github.com/mastra-ai/mastra/commit/d171e559ead9f52ec728d424844c8f7b164c4510), [`632fdb8`](https://github.com/mastra-ai/mastra/commit/632fdb8b3cd9ff6f90399256d526db439fc1758b), [`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), [`9312dcd`](https://github.com/mastra-ai/mastra/commit/9312dcd1c6f5b321929e7d382e763d95fdc030f5), [`184f01d`](https://github.com/mastra-ai/mastra/commit/184f01d1f534ec0be9703d3996f2e088b4a560eb), [`363284b`](https://github.com/mastra-ai/mastra/commit/363284bb974e850f06f40f89a28c79d9f432d7e4), [`83d5942`](https://github.com/mastra-ai/mastra/commit/83d5942669ce7bba4a6ca4fd4da697a10eb5ebdc), [`58e3931`](https://github.com/mastra-ai/mastra/commit/58e3931af9baa5921688566210f00fb0c10479fa), [`439eaf7`](https://github.com/mastra-ai/mastra/commit/439eaf75447809b05e326666675a4dcbf9c334ce), [`b7959e6`](https://github.com/mastra-ai/mastra/commit/b7959e6e25a46b480f9ea2217c4c6c588c423791), [`a7ce182`](https://github.com/mastra-ai/mastra/commit/a7ce1822a8785ce45d62dd5c911af465e144f7d7), [`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), [`08bb631`](https://github.com/mastra-ai/mastra/commit/08bb631ae2b14684b2678e3549d0b399a6f0561e), [`a0c8c1b`](https://github.com/mastra-ai/mastra/commit/a0c8c1b87d4fee252aebda73e8637fbe01d761c9), [`6cbb549`](https://github.com/mastra-ai/mastra/commit/6cbb549475201a2fbf158f0fd7323f6495f46d08), [`c218bd3`](https://github.com/mastra-ai/mastra/commit/c218bd3759e32423735b04843a09404572631014), [`e1bb9c9`](https://github.com/mastra-ai/mastra/commit/e1bb9c94b4eb68b019ae275981be3feb769b5365), [`106c960`](https://github.com/mastra-ai/mastra/commit/106c960df5d110ec15ac8f45de8858597fb90ad5)]:
296
+ - @mastra/client-js@1.0.0
297
+
298
+ ## 0.1.0-beta.27
299
+
300
+ ### Patch Changes
301
+
302
+ - Updated dependencies:
303
+ - @mastra/client-js@1.0.0-beta.27
304
+
305
+ ## 0.1.0-beta.26
306
+
307
+ ### Patch Changes
308
+
309
+ - Updated dependencies [[`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac)]:
310
+ - @mastra/client-js@1.0.0-beta.26
311
+
312
+ ## 0.1.0-beta.25
313
+
314
+ ### Minor Changes
315
+
316
+ - Added human-in-the-loop (HITL) tool approval support for `generate()` method. ([#12056](https://github.com/mastra-ai/mastra/pull/12056))
317
+
318
+ **Why:** This provides parity between `stream()` and `generate()` for tool approval flows, allowing non-streaming use cases to leverage `requireToolApproval` without needing to switch to streaming.
319
+
320
+ Previously, tool approval with `requireToolApproval` only worked with `stream()`. Now you can use the same approval flow with `generate()` for non-streaming use cases.
321
+
322
+ **Using tool approval with generate()**
323
+
324
+ ```typescript
325
+ const output = await agent.generate('Find user John', {
326
+ requireToolApproval: true,
327
+ });
328
+
329
+ // Check if a tool is waiting for approval
330
+ if (output.finishReason === 'suspended') {
331
+ console.log('Tool requires approval:', output.suspendPayload.toolName);
332
+
333
+ // Approve the tool call
334
+ const result = await agent.approveToolCallGenerate({
335
+ runId: output.runId,
336
+ toolCallId: output.suspendPayload.toolCallId,
337
+ });
338
+
339
+ console.log(result.text);
340
+ }
341
+ ```
342
+
343
+ **Declining a tool call**
344
+
345
+ ```typescript
346
+ if (output.finishReason === 'suspended') {
347
+ const result = await agent.declineToolCallGenerate({
348
+ runId: output.runId,
349
+ toolCallId: output.suspendPayload.toolCallId,
350
+ });
351
+ }
352
+ ```
353
+
354
+ **New methods added:**
355
+ - `agent.approveToolCallGenerate({ runId, toolCallId })` - Approves a pending tool call and returns the complete result
356
+ - `agent.declineToolCallGenerate({ runId, toolCallId })` - Declines a pending tool call and returns the complete result
357
+
358
+ **Server routes added:**
359
+ - `POST /api/agents/:agentId/approve-tool-call-generate`
360
+ - `POST /api/agents/:agentId/decline-tool-call-generate`
361
+
362
+ The playground UI now also supports tool approval when using generate mode.
363
+
364
+ ### Patch Changes
365
+
366
+ - Updated dependencies [[`ed3e3dd`](https://github.com/mastra-ai/mastra/commit/ed3e3ddec69d564fe2b125e083437f76331f1283), [`47b1c16`](https://github.com/mastra-ai/mastra/commit/47b1c16a01c7ffb6765fe1e499b49092f8b7eba3), [`9312dcd`](https://github.com/mastra-ai/mastra/commit/9312dcd1c6f5b321929e7d382e763d95fdc030f5)]:
367
+ - @mastra/client-js@1.0.0-beta.25
368
+
369
+ ## 0.1.0-beta.23
370
+
371
+ ### Major Changes
372
+
373
+ - **Fixed:** Align `Agent.network` with core and update `@mastra/react` network usage. ([#12015](https://github.com/mastra-ai/mastra/pull/12015))
374
+
375
+ ### Patch Changes
376
+
377
+ - Fixed compatibility with updated `@mastra/client-js` generate and stream API signatures ([#12011](https://github.com/mastra-ai/mastra/pull/12011))
378
+
379
+ - Updated dependencies [[`461e448`](https://github.com/mastra-ai/mastra/commit/461e448852fe999506a6046d50b1efc27d8aa378)]:
380
+ - @mastra/client-js@1.0.0-beta.24
381
+
382
+ ## 0.1.0-beta.23
383
+
384
+ ### Patch Changes
385
+
386
+ - Updated dependencies:
387
+ - @mastra/client-js@1.0.0-beta.23
388
+
389
+ ## 0.1.0-beta.22
390
+
391
+ ### Patch Changes
392
+
393
+ - Removes the deprecated `threadId` and `resourceId` options from `AgentExecutionOptions`. These have been deprecated for months in favour of the `memory` option. ([#11897](https://github.com/mastra-ai/mastra/pull/11897))
394
+
395
+ ### Breaking Changes
396
+
397
+ #### `@mastra/core`
398
+
399
+ The `threadId` and `resourceId` options have been removed from `agent.generate()` and `agent.stream()`. Use the `memory` option instead:
400
+
401
+ ```ts
402
+ // Before
403
+ await agent.stream('Hello', {
404
+ threadId: 'thread-123',
405
+ resourceId: 'user-456',
406
+ });
407
+
408
+ // After
409
+ await agent.stream('Hello', {
410
+ memory: {
411
+ thread: 'thread-123',
412
+ resource: 'user-456',
413
+ },
414
+ });
415
+ ```
416
+
417
+ #### `@mastra/server`
418
+
419
+ The `threadId`, `resourceId`, and `resourceid` fields have been removed from the main agent execution body schema. The server now expects the `memory` option format in request bodies. Legacy routes (`/api/agents/:agentId/generate-legacy` and `/api/agents/:agentId/stream-legacy`) continue to support the deprecated fields.
420
+
421
+ #### `@mastra/react`
422
+
423
+ The `useChat` hook now internally converts `threadId` to the `memory` option format when making API calls. No changes needed in component code - the hook handles the conversion automatically.
424
+
425
+ #### `@mastra/client-js`
426
+
427
+ When using the client SDK agent methods, use the `memory` option instead of `threadId`/`resourceId`:
428
+
429
+ ```ts
430
+ const agent = client.getAgent('my-agent');
431
+
432
+ // Before
433
+ await agent.generate({
434
+ messages: [...],
435
+ threadId: 'thread-123',
436
+ resourceId: 'user-456',
437
+ });
438
+
439
+ // After
440
+ await agent.generate({
441
+ messages: [...],
442
+ memory: {
443
+ thread: 'thread-123',
444
+ resource: 'user-456',
445
+ },
446
+ });
447
+ ```
448
+
449
+ - Add human-in-the-loop (HITL) support to agent networks ([#11678](https://github.com/mastra-ai/mastra/pull/11678))
450
+ - Add suspend/resume capabilities to agent network
451
+ - Enable auto-resume for suspended network execution via `autoResumeSuspendedTools`
452
+
453
+ `agent.resumeNetwork`, `agent.approveNetworkToolCall`, `agent.declineNetworkToolCall`
454
+
455
+ - Fix text parts incorrectly merging across tool calls ([#11783](https://github.com/mastra-ai/mastra/pull/11783))
456
+
457
+ Previously, when an agent produced text before and after a tool call (e.g., "Let me search for that" → tool call → "Here's what I found"), the text parts would be merged into a single part, losing the separation. This fix introduces a `textId` property to track separate text streams, ensuring each text stream maintains its own text part in the UI message.
458
+
459
+ Fixes #11577
460
+
461
+ - Updated dependencies [[`9d5059e`](https://github.com/mastra-ai/mastra/commit/9d5059eae810829935fb08e81a9bb7ecd5b144a7), [`ef756c6`](https://github.com/mastra-ai/mastra/commit/ef756c65f82d16531c43f49a27290a416611e526), [`610a70b`](https://github.com/mastra-ai/mastra/commit/610a70bdad282079f0c630e0d7bb284578f20151)]:
462
+ - @mastra/client-js@1.0.0-beta.22
463
+
464
+ ## 0.1.0-beta.21
465
+
466
+ ### Patch Changes
467
+
468
+ - Updated dependencies:
469
+ - @mastra/client-js@1.0.0-beta.21
470
+
471
+ ## 0.1.0-beta.20
472
+
473
+ ### Patch Changes
474
+
475
+ - Fix TypeScript errors during build declaration generation ([#11682](https://github.com/mastra-ai/mastra/pull/11682))
476
+
477
+ Updated test file `toUIMessage.test.ts` to match current `@mastra/core` types:
478
+ - Changed `error` property from string to `Error` object (per `StepFailure` type)
479
+ - Added missing `resumeSchema` property to `tool-call-approval` payloads (per `ToolCallApprovalPayload` type)
480
+ - Added `zod` as peer/dev dependency for test type support
481
+
482
+ - Fixed agent network not returning text response when routing agent handles requests without delegation. ([#11497](https://github.com/mastra-ai/mastra/pull/11497))
483
+
484
+ **What changed:**
485
+ - Agent networks now correctly stream text responses when the routing agent decides to handle a request itself instead of delegating to sub-agents, workflows, or tools
486
+ - Added fallback in transformers to ensure text is always returned even if core events are missing
487
+
488
+ **Why this matters:**
489
+ Previously, when using `toAISdkV5Stream` or `networkRoute()` outside of the Mastra Studio UI, no text content was returned when the routing agent handled requests directly. This fix ensures consistent behavior across all API routes.
490
+
491
+ Fixes #11219
492
+
493
+ - Display network completion validation results and scorer feedback in the Playground when viewing agent network runs, letting users see pass/fail status and actionable feedback from completion scorers ([#11562](https://github.com/mastra-ai/mastra/pull/11562))
494
+
495
+ - Updated dependencies [[`bc72b52`](https://github.com/mastra-ai/mastra/commit/bc72b529ee4478fe89ecd85a8be47ce0127b82a0), [`c042bd0`](https://github.com/mastra-ai/mastra/commit/c042bd0b743e0e86199d0cb83344ca7690e34a9c), [`e4d366a`](https://github.com/mastra-ai/mastra/commit/e4d366aeb500371dd4210d6aa8361a4c21d87034), [`58e3931`](https://github.com/mastra-ai/mastra/commit/58e3931af9baa5921688566210f00fb0c10479fa), [`08bb631`](https://github.com/mastra-ai/mastra/commit/08bb631ae2b14684b2678e3549d0b399a6f0561e), [`106c960`](https://github.com/mastra-ai/mastra/commit/106c960df5d110ec15ac8f45de8858597fb90ad5)]:
496
+ - @mastra/client-js@1.0.0-beta.20
497
+
498
+ ## 0.1.0-beta.19
499
+
500
+ ### Patch Changes
501
+
502
+ - Updated dependencies:
503
+ - @mastra/client-js@1.0.0-beta.19
504
+
505
+ ## 0.1.0-beta.18
506
+
507
+ ### Patch Changes
508
+
509
+ - Updated dependencies:
510
+ - @mastra/client-js@1.0.0-beta.18
511
+
512
+ ## 0.1.0-beta.17
513
+
514
+ ### Patch Changes
515
+
516
+ - Updated dependencies:
517
+ - @mastra/client-js@1.0.0-beta.17
518
+
519
+ ## 0.1.0-beta.16
520
+
521
+ ### Patch Changes
522
+
523
+ - Updated dependencies [[`6cbb549`](https://github.com/mastra-ai/mastra/commit/6cbb549475201a2fbf158f0fd7323f6495f46d08)]:
524
+ - @mastra/client-js@1.0.0-beta.16
525
+
526
+ ## 0.1.0-beta.15
527
+
528
+ ### Minor Changes
529
+
530
+ - Unified observability schema with entity-based span identification ([#11132](https://github.com/mastra-ai/mastra/pull/11132))
531
+
532
+ ## What changed
533
+
534
+ Spans now use a unified identification model with `entityId`, `entityType`, and `entityName` instead of separate `agentId`, `toolId`, `workflowId` fields.
535
+
536
+ **Before:**
537
+
538
+ ```typescript
539
+ // Old span structure
540
+ span.agentId; // 'my-agent'
541
+ span.toolId; // undefined
542
+ span.workflowId; // undefined
543
+ ```
544
+
545
+ **After:**
546
+
547
+ ```typescript
548
+ // New span structure
549
+ span.entityType; // EntityType.AGENT
550
+ span.entityId; // 'my-agent'
551
+ span.entityName; // 'My Agent'
552
+ ```
553
+
554
+ ## New `listTraces()` API
555
+
556
+ Query traces with filtering, pagination, and sorting:
557
+
558
+ ```typescript
559
+ const { spans, pagination } = await storage.listTraces({
560
+ filters: {
561
+ entityType: EntityType.AGENT,
562
+ entityId: 'my-agent',
563
+ userId: 'user-123',
564
+ environment: 'production',
565
+ status: TraceStatus.SUCCESS,
566
+ startedAt: { start: new Date('2024-01-01'), end: new Date('2024-01-31') },
567
+ },
568
+ pagination: { page: 0, perPage: 50 },
569
+ orderBy: { field: 'startedAt', direction: 'DESC' },
570
+ });
571
+ ```
572
+
573
+ **Available filters:** date ranges (`startedAt`, `endedAt`), entity (`entityType`, `entityId`, `entityName`), identity (`userId`, `organizationId`), correlation IDs (`runId`, `sessionId`, `threadId`), deployment (`environment`, `source`, `serviceName`), `tags`, `metadata`, and `status`.
574
+
575
+ ## New retrieval methods
576
+ - `getSpan({ traceId, spanId })` - Get a single span
577
+ - `getRootSpan({ traceId })` - Get the root span of a trace
578
+ - `getTrace({ traceId })` - Get all spans for a trace
579
+
580
+ ## Backward compatibility
581
+
582
+ The legacy `getTraces()` method continues to work. When you pass `name: "agent run: my-agent"`, it automatically transforms to `entityId: "my-agent", entityType: AGENT`.
583
+
584
+ ## Migration
585
+
586
+ **Automatic:** SQL-based stores (PostgreSQL, LibSQL, MSSQL) automatically add new columns to existing `spans` tables on initialization. Existing data is preserved with new columns set to `NULL`.
587
+
588
+ **No action required:** Your existing code continues to work. Adopt the new fields and `listTraces()` API at your convenience.
589
+
590
+ ### Patch Changes
591
+
592
+ - Updated dependencies [[`d90ea65`](https://github.com/mastra-ai/mastra/commit/d90ea6536f7aa51c6545a4e9215b55858e98e16d), [`d171e55`](https://github.com/mastra-ai/mastra/commit/d171e559ead9f52ec728d424844c8f7b164c4510), [`632fdb8`](https://github.com/mastra-ai/mastra/commit/632fdb8b3cd9ff6f90399256d526db439fc1758b), [`184f01d`](https://github.com/mastra-ai/mastra/commit/184f01d1f534ec0be9703d3996f2e088b4a560eb)]:
593
+ - @mastra/client-js@1.0.0-beta.15
594
+
595
+ ## 0.1.0-beta.14
596
+
597
+ ### Patch Changes
598
+
599
+ - Updated dependencies [[`66741d1`](https://github.com/mastra-ai/mastra/commit/66741d1a99c4f42cf23a16109939e8348ac6852e), [`a7ce182`](https://github.com/mastra-ai/mastra/commit/a7ce1822a8785ce45d62dd5c911af465e144f7d7)]:
600
+ - @mastra/client-js@1.0.0-beta.14
601
+
602
+ ## 0.1.0-beta.13
603
+
604
+ ### Patch Changes
605
+
606
+ - Updated dependencies:
607
+ - @mastra/client-js@1.0.0-beta.13
608
+
609
+ ## 0.1.0-beta.12
610
+
611
+ ### Patch Changes
612
+
613
+ - Remove redundant toolCalls from network agent finalResult ([#11189](https://github.com/mastra-ai/mastra/pull/11189))
614
+
615
+ The network agent's `finalResult` was storing `toolCalls` separately even though all tool call information is already present in the `messages` array (as `tool-call` and `tool-result` type messages). This caused significant token waste since the routing agent reads this data from memory on every iteration.
616
+
617
+ **Before:** `finalResult: { text, toolCalls, messages }`
618
+ **After:** `finalResult: { text, messages }`
619
+
620
+ +**Migration:** If you were accessing `finalResult.toolCalls`, retrieve tool calls from `finalResult.messages` by filtering for messages with `type: 'tool-call'`.
621
+
622
+ Updated `@mastra/react` to extract tool calls directly from the `messages` array instead of the removed `toolCalls` field when resolving initial messages from memory.
623
+
624
+ Fixes #11059
625
+
626
+ - Auto resume suspended tools if `autoResumeSuspendedTools: true` ([#11157](https://github.com/mastra-ai/mastra/pull/11157))
627
+
628
+ The flag can be added to `defaultAgentOptions` when creating the agent or to options in `agent.stream` or `agent.generate`
629
+
630
+ ```typescript
631
+ const agent = new Agent({
632
+ //...agent information,
633
+ defaultAgentOptions: {
634
+ autoResumeSuspendedTools: true,
635
+ },
636
+ });
637
+ ```
638
+
639
+ - Updated dependencies [[`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`1b85674`](https://github.com/mastra-ai/mastra/commit/1b85674123708d9b85834dccc9eae601a9d0891c), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`439eaf7`](https://github.com/mastra-ai/mastra/commit/439eaf75447809b05e326666675a4dcbf9c334ce)]:
640
+ - @mastra/client-js@1.0.0-beta.12
641
+
642
+ ## 0.1.0-beta.11
643
+
644
+ ### Patch Changes
645
+
646
+ - 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))
647
+
648
+ When a workflow contains an agent step that triggers a tripwire, the workflow returns with `status: 'tripwire'` and includes tripwire details:
649
+
650
+ ```typescript showLineNumbers copy
651
+ const run = await workflow.createRun();
652
+ const result = await run.start({ inputData: { message: 'Hello' } });
653
+
654
+ if (result.status === 'tripwire') {
655
+ console.log('Workflow terminated by tripwire:', result.tripwire?.reason);
656
+ console.log('Processor ID:', result.tripwire?.processorId);
657
+ console.log('Retry requested:', result.tripwire?.retry);
658
+ }
659
+ ```
660
+
661
+ Adds new UI state for tripwire in agent chat and workflow UI.
662
+
663
+ 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).
664
+
665
+ - Updated dependencies [[`3bf6c5f`](https://github.com/mastra-ai/mastra/commit/3bf6c5f104c25226cd84e0c77f9dec15f2cac2db)]:
666
+ - @mastra/client-js@1.0.0-beta.11
667
+
668
+ ## 0.1.0-beta.10
669
+
670
+ ### Minor Changes
671
+
672
+ - 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))
673
+
674
+ ### Patch Changes
675
+
676
+ - fix: persist data-\* chunks from writer.custom() to memory storage ([#10884](https://github.com/mastra-ai/mastra/pull/10884))
677
+ - Add persistence for custom data chunks (`data-*` parts) emitted via `writer.custom()` in tools
678
+ - Data chunks are now saved to message storage so they survive page refreshes
679
+ - Update `@assistant-ui/react` to v0.11.47 with native `DataMessagePart` support
680
+ - Convert `data-*` parts to `DataMessagePart` format (`{ type: 'data', name: string, data: T }`)
681
+ - Update related `@assistant-ui/*` packages for compatibility
682
+
683
+ - Updated dependencies [[`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d)]:
684
+ - @mastra/client-js@1.0.0-beta.10
2
685
 
3
686
  ## 0.1.0-beta.9
4
687