@mastra/client-js 1.0.0-beta.13 → 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,102 @@
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
+
3
100
  ## 1.0.0-beta.13
4
101
 
5
102
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -3079,13 +3079,26 @@ var Workflow = class extends BaseResource {
3079
3079
  /**
3080
3080
  * Retrieves the execution result for a specific workflow run by its ID
3081
3081
  * @param runId - The ID of the workflow run to retrieve the execution result for
3082
- * @param requestContext - Optional request context to pass as query parameter
3082
+ * @param options - Optional configuration
3083
+ * @param options.requestContext - Optional request context to pass as query parameter
3084
+ * @param options.fields - Optional array of fields to return (e.g., ['status', 'result']). Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph. Omitting this returns all fields.
3085
+ * @param options.withNestedWorkflows - Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance when you don't need nested workflow details.
3083
3086
  * @returns Promise containing the workflow run execution result
3084
3087
  */
3085
- runExecutionResult(runId, requestContext) {
3086
- return this.request(
3087
- `/api/workflows/${this.workflowId}/runs/${runId}/execution-result${requestContextQueryString(requestContext)}`
3088
- );
3088
+ runExecutionResult(runId, options) {
3089
+ const searchParams = new URLSearchParams();
3090
+ if (options?.fields && options.fields.length > 0) {
3091
+ searchParams.set("fields", options.fields.join(","));
3092
+ }
3093
+ if (options?.withNestedWorkflows !== void 0) {
3094
+ searchParams.set("withNestedWorkflows", String(options.withNestedWorkflows));
3095
+ }
3096
+ const requestContextParam = base64RequestContext(parseClientRequestContext(options?.requestContext));
3097
+ if (requestContextParam) {
3098
+ searchParams.set("requestContext", requestContextParam);
3099
+ }
3100
+ const queryString = searchParams.size > 0 ? `?${searchParams.toString()}` : "";
3101
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result${queryString}`);
3089
3102
  }
3090
3103
  /**
3091
3104
  * Creates a new workflow run