@mastra/client-js 1.0.0-beta.11 → 1.0.0-beta.14

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,184 @@
1
1
  # @mastra/client-js
2
2
 
3
+ ## 1.0.0-beta.14
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: Add field filtering and nested workflow control to workflow execution result endpoint ([#11246](https://github.com/mastra-ai/mastra/pull/11246))
8
+
9
+ Adds two optional query parameters to `/api/workflows/:workflowId/runs/:runId/execution-result` endpoint:
10
+ - `fields`: Request only specific fields (e.g., `status`, `result`, `error`)
11
+ - `withNestedWorkflows`: Control whether to fetch nested workflow data
12
+
13
+ This significantly reduces response payload size and improves response times for large workflows.
14
+
15
+ ## Server Endpoint Usage
16
+
17
+ ```http
18
+ # Get only status (minimal payload - fastest)
19
+ GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status
20
+
21
+ # Get status and result
22
+ GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status,result
23
+
24
+ # Get all fields but without nested workflow data (faster)
25
+ GET /api/workflows/:workflowId/runs/:runId/execution-result?withNestedWorkflows=false
26
+
27
+ # Get only specific fields without nested workflow data
28
+ GET /api/workflows/:workflowId/runs/:runId/execution-result?fields=status,steps&withNestedWorkflows=false
29
+
30
+ # Get full data (default behavior)
31
+ GET /api/workflows/:workflowId/runs/:runId/execution-result
32
+ ```
33
+
34
+ ## Client SDK Usage
35
+
36
+ ```typescript
37
+ import { MastraClient } from '@mastra/client-js';
38
+
39
+ const client = new MastraClient({ baseUrl: 'http://localhost:4111' });
40
+ const workflow = client.getWorkflow('myWorkflow');
41
+
42
+ // Get only status (minimal payload - fastest)
43
+ const statusOnly = await workflow.runExecutionResult(runId, {
44
+ fields: ['status'],
45
+ });
46
+ console.log(statusOnly.status); // 'success' | 'failed' | 'running' | etc.
47
+
48
+ // Get status and result
49
+ const statusAndResult = await workflow.runExecutionResult(runId, {
50
+ fields: ['status', 'result'],
51
+ });
52
+
53
+ // Get all fields but without nested workflow data (faster)
54
+ const resultWithoutNested = await workflow.runExecutionResult(runId, {
55
+ withNestedWorkflows: false,
56
+ });
57
+
58
+ // Get specific fields without nested workflow data
59
+ const optimized = await workflow.runExecutionResult(runId, {
60
+ fields: ['status', 'steps'],
61
+ withNestedWorkflows: false,
62
+ });
63
+
64
+ // Get full execution result (default behavior)
65
+ const fullResult = await workflow.runExecutionResult(runId);
66
+ ```
67
+
68
+ ## Core API Changes
69
+
70
+ The `Workflow.getWorkflowRunExecutionResult` method now accepts an options object:
71
+
72
+ ```typescript
73
+ await workflow.getWorkflowRunExecutionResult(runId, {
74
+ withNestedWorkflows: false, // default: true, set to false to skip nested workflow data
75
+ fields: ['status', 'result'], // optional field filtering
76
+ });
77
+ ```
78
+
79
+ ## Inngest Compatibility
80
+
81
+ The `@mastra/inngest` package has been updated to use the new options object API. This is a non-breaking internal change - no action required from inngest workflow users.
82
+
83
+ ## Performance Impact
84
+
85
+ For workflows with large step outputs:
86
+ - Requesting only `status`: ~99% reduction in payload size
87
+ - Requesting `status,result,error`: ~95% reduction in payload size
88
+ - Using `withNestedWorkflows=false`: Avoids expensive nested workflow data fetching
89
+ - Combining both: Maximum performance optimization
90
+
91
+ - Fix delayed promises rejecting when stream suspends on tool-call-approval ([#11278](https://github.com/mastra-ai/mastra/pull/11278))
92
+
93
+ When a stream ends in suspended state (e.g., requiring tool approval), the delayed promises like `toolResults`, `toolCalls`, `text`, etc. now resolve with partial results instead of rejecting with an error. This allows consumers to access data that was produced before the suspension.
94
+
95
+ Also improves generic type inference for `LLMStepResult` and related types throughout the streaming infrastructure.
96
+
97
+ - Updated dependencies [[`4f94ed8`](https://github.com/mastra-ai/mastra/commit/4f94ed8177abfde3ec536e3574883e075423350c), [`ac3cc23`](https://github.com/mastra-ai/mastra/commit/ac3cc2397d1966bc0fc2736a223abc449d3c7719), [`a86f4df`](https://github.com/mastra-ai/mastra/commit/a86f4df0407311e0d2ea49b9a541f0938810d6a9), [`029540c`](https://github.com/mastra-ai/mastra/commit/029540ca1e582fc2dd8d288ecd4a9b0f31a954ef), [`66741d1`](https://github.com/mastra-ai/mastra/commit/66741d1a99c4f42cf23a16109939e8348ac6852e), [`01b20fe`](https://github.com/mastra-ai/mastra/commit/01b20fefb7c67c2b7d79417598ef4e60256d1225), [`0dbf199`](https://github.com/mastra-ai/mastra/commit/0dbf199110f22192ce5c95b1c8148d4872b4d119), [`a7ce182`](https://github.com/mastra-ai/mastra/commit/a7ce1822a8785ce45d62dd5c911af465e144f7d7)]:
98
+ - @mastra/core@1.0.0-beta.14
99
+
100
+ ## 1.0.0-beta.13
101
+
102
+ ### Patch Changes
103
+
104
+ - Updated dependencies [[`919a22b`](https://github.com/mastra-ai/mastra/commit/919a22b25876f9ed5891efe5facbe682c30ff497)]:
105
+ - @mastra/core@1.0.0-beta.13
106
+
107
+ ## 1.0.0-beta.12
108
+
109
+ ### Patch Changes
110
+
111
+ - Embed AI types to fix peerdeps mismatches ([`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808))
112
+
113
+ - Add resourceId to workflow routes ([#11166](https://github.com/mastra-ai/mastra/pull/11166))
114
+
115
+ - Add `Run` instance to client-js. `workflow.createRun` returns the `Run` instance which can be used for the different run methods. ([#11207](https://github.com/mastra-ai/mastra/pull/11207))
116
+ With this change, run methods cannot be called directly on workflow instance anymore
117
+
118
+ ```diff
119
+ - const result = await workflow.stream({ runId: '123', inputData: { ... } });
120
+ + const run = await workflow.createRun({ runId: '123' });
121
+ + const stream = await run.stream({ inputData: { ... } });
122
+ ```
123
+
124
+ - Deserialize workflow errors on the client side ([#10992](https://github.com/mastra-ai/mastra/pull/10992))
125
+
126
+ When workflows fail, the server sends error data as JSON over HTTP. This change deserializes those errors back to proper `Error` instances on the client.
127
+
128
+ **Before:**
129
+
130
+ ```typescript
131
+ const result = await workflow.startAsync({ input });
132
+ if (result.status === 'failed') {
133
+ // result.error was a plain object, couldn't use instanceof
134
+ console.log(result.error.message); // TypeScript error
135
+ }
136
+ ```
137
+
138
+ **After:**
139
+
140
+ ```typescript
141
+ const result = await workflow.startAsync({ input });
142
+ if (result.status === 'failed') {
143
+ // result.error is now a proper Error instance
144
+ if (result.error instanceof MyCustomError) {
145
+ console.log(result.error.statusCode); // Works!
146
+ }
147
+ }
148
+ ```
149
+
150
+ This enables proper error handling and type checking in client applications, allowing developers to implement error-specific recovery logic based on custom error types and properties.
151
+
152
+ Features:
153
+ - `instanceof Error` checks
154
+ - Access to `error.message`, `error.name`, `error.stack`
155
+ - Preservation of custom error properties (e.g., `statusCode`, `responseHeaders`)
156
+ - Nested error tracking via `error.cause`
157
+
158
+ Affected methods:
159
+ - `startAsync()`
160
+ - `resumeAsync()`
161
+ - `restartAsync()`
162
+ - `timeTravelAsync()`
163
+
164
+ - Add missing status parameter to workflow.runs() method ([#11095](https://github.com/mastra-ai/mastra/pull/11095))
165
+
166
+ The `status` parameter was supported by the server API but was missing from the TypeScript types in @mastra/client-js.
167
+
168
+ Now you can filter workflow runs by status:
169
+
170
+ ```typescript
171
+ // Get only running workflows
172
+ const runningRuns = await workflow.runs({ status: 'running' });
173
+
174
+ // Get completed workflows
175
+ const completedRuns = await workflow.runs({ status: 'success' });
176
+ ```
177
+
178
+ - Updated dependencies [[`d5ed981`](https://github.com/mastra-ai/mastra/commit/d5ed981c8701c1b8a27a5f35a9a2f7d9244e695f), [`9650cce`](https://github.com/mastra-ai/mastra/commit/9650cce52a1d917ff9114653398e2a0f5c3ba808), [`932d63d`](https://github.com/mastra-ai/mastra/commit/932d63dd51be9c8bf1e00e3671fe65606c6fb9cd), [`b760b73`](https://github.com/mastra-ai/mastra/commit/b760b731aca7c8a3f041f61d57a7f125ae9cb215), [`695a621`](https://github.com/mastra-ai/mastra/commit/695a621528bdabeb87f83c2277cf2bb084c7f2b4), [`2b459f4`](https://github.com/mastra-ai/mastra/commit/2b459f466fd91688eeb2a44801dc23f7f8a887ab), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`24b76d8`](https://github.com/mastra-ai/mastra/commit/24b76d8e17656269c8ed09a0c038adb9cc2ae95a), [`243a823`](https://github.com/mastra-ai/mastra/commit/243a8239c5906f5c94e4f78b54676793f7510ae3), [`486352b`](https://github.com/mastra-ai/mastra/commit/486352b66c746602b68a95839f830de14c7fb8c0), [`c61fac3`](https://github.com/mastra-ai/mastra/commit/c61fac3add96f0dcce0208c07415279e2537eb62), [`6f14f70`](https://github.com/mastra-ai/mastra/commit/6f14f706ccaaf81b69544b6c1b75ab66a41e5317), [`09e4bae`](https://github.com/mastra-ai/mastra/commit/09e4bae18dd5357d2ae078a4a95a2af32168ab08), [`4524734`](https://github.com/mastra-ai/mastra/commit/45247343e384717a7c8404296275c56201d6470f), [`2a53598`](https://github.com/mastra-ai/mastra/commit/2a53598c6d8cfeb904a7fc74e57e526d751c8fa6), [`c7cd3c7`](https://github.com/mastra-ai/mastra/commit/c7cd3c7a187d7aaf79e2ca139de328bf609a14b4), [`847c212`](https://github.com/mastra-ai/mastra/commit/847c212caba7df0d6f2fc756b494ac3c75c3720d), [`6f941c4`](https://github.com/mastra-ai/mastra/commit/6f941c438ca5f578619788acc7608fc2e23bd176)]:
179
+ - @mastra/core@1.0.0-beta.12
180
+ - @mastra/schema-compat@1.0.0-beta.3
181
+
3
182
  ## 1.0.0-beta.11
4
183
 
5
184
  ### Patch Changes