@mastra/server 1.0.0-beta.19 → 1.0.0-beta.20

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/{chunk-MZXGNP3J.cjs → chunk-3PZVR6W3.cjs} +70 -106
  3. package/dist/chunk-3PZVR6W3.cjs.map +1 -0
  4. package/dist/{chunk-K73YS7YB.cjs → chunk-AQI6GLTN.cjs} +74 -74
  5. package/dist/{chunk-K73YS7YB.cjs.map → chunk-AQI6GLTN.cjs.map} +1 -1
  6. package/dist/{chunk-3XI22UQR.cjs → chunk-GWLR6K3H.cjs} +7 -3
  7. package/dist/chunk-GWLR6K3H.cjs.map +1 -0
  8. package/dist/{chunk-E646Y4FQ.js → chunk-H66LLFDL.js} +3 -3
  9. package/dist/chunk-H66LLFDL.js.map +1 -0
  10. package/dist/{chunk-7ZYZHQRF.cjs → chunk-IMPZBQ5U.cjs} +350 -216
  11. package/dist/chunk-IMPZBQ5U.cjs.map +1 -0
  12. package/dist/{chunk-MXJEVTGK.js → chunk-J6DCK7KG.js} +5 -11
  13. package/dist/chunk-J6DCK7KG.js.map +1 -0
  14. package/dist/{chunk-OCJ3BRZM.js → chunk-JQPDZZLI.js} +178 -51
  15. package/dist/chunk-JQPDZZLI.js.map +1 -0
  16. package/dist/{chunk-5ZYHM57F.cjs → chunk-KXYDJIKD.cjs} +177 -49
  17. package/dist/chunk-KXYDJIKD.cjs.map +1 -0
  18. package/dist/{chunk-SV4AUWGY.js → chunk-LOA7RQYO.js} +3 -3
  19. package/dist/{chunk-SV4AUWGY.js.map → chunk-LOA7RQYO.js.map} +1 -1
  20. package/dist/{chunk-AWK2DVRO.js → chunk-OKURLPIJ.js} +275 -138
  21. package/dist/chunk-OKURLPIJ.js.map +1 -0
  22. package/dist/{chunk-E4ZPLXZT.js → chunk-Q4BOUQ2O.js} +66 -100
  23. package/dist/chunk-Q4BOUQ2O.js.map +1 -0
  24. package/dist/{chunk-WBLT2HL3.js → chunk-QKXZF7YS.js} +7 -3
  25. package/dist/chunk-QKXZF7YS.js.map +1 -0
  26. package/dist/{chunk-BVIEHV3I.cjs → chunk-T3ZHTCEI.cjs} +2 -2
  27. package/dist/{chunk-BVIEHV3I.cjs.map → chunk-T3ZHTCEI.cjs.map} +1 -1
  28. package/dist/{chunk-BMLUV4BH.cjs → chunk-VX3VN7FN.cjs} +3 -3
  29. package/dist/chunk-VX3VN7FN.cjs.map +1 -0
  30. package/dist/{chunk-VYNS3ZKV.cjs → chunk-Y3VSCOCE.cjs} +7 -13
  31. package/dist/chunk-Y3VSCOCE.cjs.map +1 -0
  32. package/dist/{chunk-T2AYFHKB.js → chunk-ZRBZESWG.js} +2 -2
  33. package/dist/{chunk-T2AYFHKB.js.map → chunk-ZRBZESWG.js.map} +1 -1
  34. package/dist/{dist-AF7EUPXA.cjs → dist-7NTDEVLP.cjs} +28 -28
  35. package/dist/{dist-AF7EUPXA.cjs.map → dist-7NTDEVLP.cjs.map} +1 -1
  36. package/dist/{dist-4CMHRWC4.js → dist-B5GMANA6.js} +3 -3
  37. package/dist/{dist-4CMHRWC4.js.map → dist-B5GMANA6.js.map} +1 -1
  38. package/dist/dist-EDO7GEGI.js +3 -0
  39. package/dist/{dist-MEN73GGI.js.map → dist-EDO7GEGI.js.map} +1 -1
  40. package/dist/{dist-Q2ST4SUQ.cjs → dist-OF24ZMHH.cjs} +30 -30
  41. package/dist/{dist-Q2ST4SUQ.cjs.map → dist-OF24ZMHH.cjs.map} +1 -1
  42. package/dist/{dist-Y5SYUVLY.cjs → dist-P6YSNLL3.cjs} +20 -20
  43. package/dist/{dist-Y5SYUVLY.cjs.map → dist-P6YSNLL3.cjs.map} +1 -1
  44. package/dist/{dist-AEJONJSS.js → dist-SMBO5KVB.js} +3 -3
  45. package/dist/{dist-AEJONJSS.js.map → dist-SMBO5KVB.js.map} +1 -1
  46. package/dist/{dist-TE7XRSWH.js → dist-THPMW5QR.js} +3 -3
  47. package/dist/{dist-TE7XRSWH.js.map → dist-THPMW5QR.js.map} +1 -1
  48. package/dist/{dist-NVXXJWBO.cjs → dist-VZTG56X2.cjs} +26 -26
  49. package/dist/{dist-NVXXJWBO.cjs.map → dist-VZTG56X2.cjs.map} +1 -1
  50. package/dist/dist-ZLC23RVC.cjs +16 -0
  51. package/dist/{dist-2J26LQO2.cjs.map → dist-ZLC23RVC.cjs.map} +1 -1
  52. package/dist/{dist-VPYZNWNG.js → dist-ZOZ6MHJH.js} +3 -3
  53. package/dist/{dist-VPYZNWNG.js.map → dist-ZOZ6MHJH.js.map} +1 -1
  54. package/dist/docs/README.md +31 -0
  55. package/dist/docs/SKILL.md +32 -0
  56. package/dist/docs/SOURCE_MAP.json +6 -0
  57. package/dist/docs/server/01-custom-adapters.md +377 -0
  58. package/dist/docs/server/02-reference.md +828 -0
  59. package/dist/server/handlers/a2a.cjs +9 -9
  60. package/dist/server/handlers/a2a.js +1 -1
  61. package/dist/server/handlers/agent-builder.cjs +16 -28
  62. package/dist/server/handlers/agent-builder.d.ts +51 -85
  63. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  64. package/dist/server/handlers/agent-builder.js +1 -1
  65. package/dist/server/handlers/agents.cjs +24 -24
  66. package/dist/server/handlers/agents.d.ts.map +1 -1
  67. package/dist/server/handlers/agents.js +1 -1
  68. package/dist/server/handlers/memory.cjs +28 -24
  69. package/dist/server/handlers/memory.d.ts +114 -30
  70. package/dist/server/handlers/memory.d.ts.map +1 -1
  71. package/dist/server/handlers/memory.js +1 -1
  72. package/dist/server/handlers/observability.d.ts +17 -17
  73. package/dist/server/handlers/observability.d.ts.map +1 -1
  74. package/dist/server/handlers/workflows.cjs +24 -36
  75. package/dist/server/handlers/workflows.d.ts +61 -108
  76. package/dist/server/handlers/workflows.d.ts.map +1 -1
  77. package/dist/server/handlers/workflows.js +1 -1
  78. package/dist/server/handlers.cjs +10 -10
  79. package/dist/server/handlers.js +5 -5
  80. package/dist/server/schemas/agent-builder.d.ts +1 -1
  81. package/dist/server/schemas/agent-builder.d.ts.map +1 -1
  82. package/dist/server/schemas/memory.d.ts +161 -31
  83. package/dist/server/schemas/memory.d.ts.map +1 -1
  84. package/dist/server/schemas/workflows.d.ts +214 -34
  85. package/dist/server/schemas/workflows.d.ts.map +1 -1
  86. package/dist/server/server-adapter/index.cjs +102 -94
  87. package/dist/server/server-adapter/index.cjs.map +1 -1
  88. package/dist/server/server-adapter/index.d.ts +24 -6
  89. package/dist/server/server-adapter/index.d.ts.map +1 -1
  90. package/dist/server/server-adapter/index.js +20 -13
  91. package/dist/server/server-adapter/index.js.map +1 -1
  92. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
  93. package/dist/server/server-adapter/routes/memory.d.ts.map +1 -1
  94. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  95. package/dist/server/utils.d.ts.map +1 -1
  96. package/package.json +10 -9
  97. package/dist/chunk-3XI22UQR.cjs.map +0 -1
  98. package/dist/chunk-5ZYHM57F.cjs.map +0 -1
  99. package/dist/chunk-7ZYZHQRF.cjs.map +0 -1
  100. package/dist/chunk-AWK2DVRO.js.map +0 -1
  101. package/dist/chunk-BMLUV4BH.cjs.map +0 -1
  102. package/dist/chunk-E4ZPLXZT.js.map +0 -1
  103. package/dist/chunk-E646Y4FQ.js.map +0 -1
  104. package/dist/chunk-MXJEVTGK.js.map +0 -1
  105. package/dist/chunk-MZXGNP3J.cjs.map +0 -1
  106. package/dist/chunk-OCJ3BRZM.js.map +0 -1
  107. package/dist/chunk-VYNS3ZKV.cjs.map +0 -1
  108. package/dist/chunk-WBLT2HL3.js.map +0 -1
  109. package/dist/dist-2J26LQO2.cjs +0 -16
  110. package/dist/dist-MEN73GGI.js +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,109 @@
1
1
  # @mastra/server
2
2
 
3
+ ## 1.0.0-beta.20
4
+
5
+ ### Minor Changes
6
+
7
+ - Unified `getWorkflowRunById` and `getWorkflowRunExecutionResult` into a single API that returns `WorkflowState` with both metadata and execution state. ([#11429](https://github.com/mastra-ai/mastra/pull/11429))
8
+
9
+ **What changed:**
10
+ - `getWorkflowRunById` now returns a unified `WorkflowState` object containing metadata (runId, workflowName, resourceId, createdAt, updatedAt) along with processed execution state (status, result, error, payload, steps)
11
+ - Added optional `fields` parameter to request only specific fields for better performance
12
+ - Added optional `withNestedWorkflows` parameter to control nested workflow step inclusion
13
+ - Removed `getWorkflowRunExecutionResult` - use `getWorkflowRunById` instead (breaking change)
14
+ - Removed `/execution-result` API endpoints from server (breaking change)
15
+ - Removed `runExecutionResult()` method from client SDK (breaking change)
16
+ - Removed `GetWorkflowRunExecutionResultResponse` type from client SDK (breaking change)
17
+
18
+ **Before:**
19
+
20
+ ```typescript
21
+ // Had to call two different methods for different data
22
+ const run = await workflow.getWorkflowRunById(runId); // Returns raw WorkflowRun with snapshot
23
+ const result = await workflow.getWorkflowRunExecutionResult(runId); // Returns processed execution state
24
+ ```
25
+
26
+ **After:**
27
+
28
+ ```typescript
29
+ // Single method returns everything
30
+ const run = await workflow.getWorkflowRunById(runId);
31
+ // Returns: { runId, workflowName, resourceId, createdAt, updatedAt, status, result, error, payload, steps }
32
+
33
+ // Request only specific fields for better performance (avoids expensive step fetching)
34
+ const status = await workflow.getWorkflowRunById(runId, { fields: ['status'] });
35
+
36
+ // Skip nested workflow steps for faster response
37
+ const run = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
38
+ ```
39
+
40
+ **Why:** The previous API required calling two separate methods to get complete workflow run information. This unification simplifies the API surface and gives users control over performance - fetching all steps (especially nested workflows) can be expensive, so the `fields` and `withNestedWorkflows` options let users request only what they need.
41
+
42
+ ### Patch Changes
43
+
44
+ - Add embedded documentation support for Mastra packages ([#11472](https://github.com/mastra-ai/mastra/pull/11472))
45
+
46
+ Mastra packages now include embedded documentation in the published npm package under `dist/docs/`. This enables coding agents and AI assistants to understand and use the framework by reading documentation directly from `node_modules`.
47
+
48
+ Each package includes:
49
+ - **SKILL.md** - Entry point explaining the package's purpose and capabilities
50
+ - **SOURCE_MAP.json** - Machine-readable index mapping exports to types and implementation files
51
+ - **Topic folders** - Conceptual documentation organized by feature area
52
+
53
+ Documentation is driven by the `packages` frontmatter field in MDX files, which maps docs to their corresponding packages. CI validation ensures all docs include this field.
54
+
55
+ - Remove `streamVNext`, `resumeStreamVNext`, and `observeStreamVNext` methods, call `stream`, `resumeStream` and `observeStream` directly ([#11499](https://github.com/mastra-ai/mastra/pull/11499))
56
+
57
+ ```diff
58
+ + const run = await workflow.createRun({ runId: '123' });
59
+ - const stream = await run.streamVNext({ inputData: { ... } });
60
+ + const stream = await run.stream({ inputData: { ... } });
61
+ ```
62
+
63
+ - Fixed inconsistent query parameter handling across server adapters. ([#11429](https://github.com/mastra-ai/mastra/pull/11429))
64
+
65
+ **What changed:** Query parameters are now processed consistently across all server adapters (Express, Hono, Fastify, Koa). Added internal helper `normalizeQueryParams` and `ParsedRequestParams` type to `@mastra/server` for adapter implementations.
66
+
67
+ **Why:** Different HTTP frameworks handle query parameters differently - some return single strings while others return arrays for repeated params like `?tag=a&tag=b`. This caused type inconsistencies that could lead to validation failures in certain adapters.
68
+
69
+ **User impact:** None for typical usage - HTTP endpoints and client SDK behavior are unchanged. If you extend server adapter classes and override `getParams` or `parseQueryParams`, update your implementation to use `Record<string, string | string[]>` for query parameters.
70
+
71
+ - Add initial state input to workflow form in studio ([#11560](https://github.com/mastra-ai/mastra/pull/11560))
72
+
73
+ - Adds thread cloning to create independent copies of conversations that can diverge. ([#11517](https://github.com/mastra-ai/mastra/pull/11517))
74
+
75
+ ```typescript
76
+ // Clone a thread
77
+ const { thread, clonedMessages } = await memory.cloneThread({
78
+ sourceThreadId: 'thread-123',
79
+ title: 'My Clone',
80
+ options: {
81
+ messageLimit: 10, // optional: only copy last N messages
82
+ },
83
+ });
84
+
85
+ // Check if a thread is a clone
86
+ if (memory.isClone(thread)) {
87
+ const source = await memory.getSourceThread(thread.id);
88
+ }
89
+
90
+ // List all clones of a thread
91
+ const clones = await memory.listClones('thread-123');
92
+ ```
93
+
94
+ Includes:
95
+ - Storage implementations for InMemory, PostgreSQL, LibSQL, Upstash
96
+ - API endpoint: `POST /api/memory/threads/:threadId/clone`
97
+ - Embeddings created for cloned messages (semantic recall)
98
+ - Clone button in playground UI Memory tab
99
+
100
+ - Make agentId optional for memory read operations (getThread, listThreads, listMessages) ([#11540](https://github.com/mastra-ai/mastra/pull/11540))
101
+
102
+ When workflows use multiple agents sharing the same threadId/resourceId, users can now retrieve threads and messages without specifying an agentId. The server falls back to using storage directly when agentId is not provided.
103
+
104
+ - Updated dependencies [[`d2d3e22`](https://github.com/mastra-ai/mastra/commit/d2d3e22a419ee243f8812a84e3453dd44365ecb0), [`bc72b52`](https://github.com/mastra-ai/mastra/commit/bc72b529ee4478fe89ecd85a8be47ce0127b82a0), [`05b8bee`](https://github.com/mastra-ai/mastra/commit/05b8bee9e50e6c2a4a2bf210eca25ee212ca24fa), [`c042bd0`](https://github.com/mastra-ai/mastra/commit/c042bd0b743e0e86199d0cb83344ca7690e34a9c), [`940a2b2`](https://github.com/mastra-ai/mastra/commit/940a2b27480626ed7e74f55806dcd2181c1dd0c2), [`e0941c3`](https://github.com/mastra-ai/mastra/commit/e0941c3d7fc75695d5d258e7008fd5d6e650800c), [`0c0580a`](https://github.com/mastra-ai/mastra/commit/0c0580a42f697cd2a7d5973f25bfe7da9055038a), [`28f5f89`](https://github.com/mastra-ai/mastra/commit/28f5f89705f2409921e3c45178796c0e0d0bbb64), [`e601b27`](https://github.com/mastra-ai/mastra/commit/e601b272c70f3a5ecca610373aa6223012704892), [`3d3366f`](https://github.com/mastra-ai/mastra/commit/3d3366f31683e7137d126a3a57174a222c5801fb), [`5a4953f`](https://github.com/mastra-ai/mastra/commit/5a4953f7d25bb15ca31ed16038092a39cb3f98b3), [`eb9e522`](https://github.com/mastra-ai/mastra/commit/eb9e522ce3070a405e5b949b7bf5609ca51d7fe2), [`20e6f19`](https://github.com/mastra-ai/mastra/commit/20e6f1971d51d3ff6dd7accad8aaaae826d540ed), [`4f0b3c6`](https://github.com/mastra-ai/mastra/commit/4f0b3c66f196c06448487f680ccbb614d281e2f7), [`74c4f22`](https://github.com/mastra-ai/mastra/commit/74c4f22ed4c71e72598eacc346ba95cdbc00294f), [`81b6a8f`](https://github.com/mastra-ai/mastra/commit/81b6a8ff79f49a7549d15d66624ac1a0b8f5f971), [`e4d366a`](https://github.com/mastra-ai/mastra/commit/e4d366aeb500371dd4210d6aa8361a4c21d87034), [`a4f010b`](https://github.com/mastra-ai/mastra/commit/a4f010b22e4355a5fdee70a1fe0f6e4a692cc29e), [`73b0bb3`](https://github.com/mastra-ai/mastra/commit/73b0bb394dba7c9482eb467a97ab283dbc0ef4db), [`5627a8c`](https://github.com/mastra-ai/mastra/commit/5627a8c6dc11fe3711b3fa7a6ffd6eb34100a306), [`3ff45d1`](https://github.com/mastra-ai/mastra/commit/3ff45d10e0c80c5335a957ab563da72feb623520), [`251df45`](https://github.com/mastra-ai/mastra/commit/251df4531407dfa46d805feb40ff3fb49769f455), [`f894d14`](https://github.com/mastra-ai/mastra/commit/f894d148946629af7b1f452d65a9cf864cec3765), [`c2b9547`](https://github.com/mastra-ai/mastra/commit/c2b9547bf435f56339f23625a743b2147ab1c7a6), [`580b592`](https://github.com/mastra-ai/mastra/commit/580b5927afc82fe460dfdf9a38a902511b6b7e7f), [`58e3931`](https://github.com/mastra-ai/mastra/commit/58e3931af9baa5921688566210f00fb0c10479fa), [`08bb631`](https://github.com/mastra-ai/mastra/commit/08bb631ae2b14684b2678e3549d0b399a6f0561e), [`4fba91b`](https://github.com/mastra-ai/mastra/commit/4fba91bec7c95911dc28e369437596b152b04cd0), [`12b0cc4`](https://github.com/mastra-ai/mastra/commit/12b0cc4077d886b1a552637dedb70a7ade93528c)]:
105
+ - @mastra/core@1.0.0-beta.20
106
+
3
107
  ## 1.0.0-beta.19
4
108
 
5
109
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk3XI22UQR_cjs = require('./chunk-3XI22UQR.cjs');
3
+ var chunkGWLR6K3H_cjs = require('./chunk-GWLR6K3H.cjs');
4
4
  var chunkR25YJP3Y_cjs = require('./chunk-R25YJP3Y.cjs');
5
5
  var chunkMCYD5LW7_cjs = require('./chunk-MCYD5LW7.cjs');
6
6
  var chunkUKRDDBXY_cjs = require('./chunk-UKRDDBXY.cjs');
@@ -22,11 +22,9 @@ chunkO7I5CWRX_cjs.__export(workflows_exports, {
22
22
  DELETE_WORKFLOW_RUN_BY_ID_ROUTE: () => DELETE_WORKFLOW_RUN_BY_ID_ROUTE,
23
23
  GET_WORKFLOW_BY_ID_ROUTE: () => GET_WORKFLOW_BY_ID_ROUTE,
24
24
  GET_WORKFLOW_RUN_BY_ID_ROUTE: () => GET_WORKFLOW_RUN_BY_ID_ROUTE,
25
- GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE: () => GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE,
26
25
  LIST_WORKFLOWS_ROUTE: () => LIST_WORKFLOWS_ROUTE,
27
26
  LIST_WORKFLOW_RUNS_ROUTE: () => LIST_WORKFLOW_RUNS_ROUTE,
28
27
  OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE: () => OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE,
29
- OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE: () => OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE,
30
28
  OBSERVE_STREAM_WORKFLOW_ROUTE: () => OBSERVE_STREAM_WORKFLOW_ROUTE,
31
29
  RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE: () => RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE,
32
30
  RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE: () => RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE,
@@ -38,7 +36,6 @@ chunkO7I5CWRX_cjs.__export(workflows_exports, {
38
36
  START_ASYNC_WORKFLOW_ROUTE: () => START_ASYNC_WORKFLOW_ROUTE,
39
37
  START_WORKFLOW_RUN_ROUTE: () => START_WORKFLOW_RUN_ROUTE,
40
38
  STREAM_LEGACY_WORKFLOW_ROUTE: () => STREAM_LEGACY_WORKFLOW_ROUTE,
41
- STREAM_VNEXT_WORKFLOW_ROUTE: () => STREAM_VNEXT_WORKFLOW_ROUTE,
42
39
  STREAM_WORKFLOW_ROUTE: () => STREAM_WORKFLOW_ROUTE,
43
40
  TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE: () => TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE,
44
41
  TIME_TRAVEL_STREAM_WORKFLOW_ROUTE: () => TIME_TRAVEL_STREAM_WORKFLOW_ROUTE,
@@ -64,7 +61,14 @@ var workflowRunPathParams = workflowIdPathParams.extend({
64
61
  });
65
62
  var serializedStepSchema = z__default.default.object({
66
63
  id: z__default.default.string(),
67
- description: z__default.default.string().optional()
64
+ description: z__default.default.string().optional(),
65
+ stateSchema: z__default.default.string().optional(),
66
+ inputSchema: z__default.default.string().optional(),
67
+ outputSchema: z__default.default.string().optional(),
68
+ resumeSchema: z__default.default.string().optional(),
69
+ suspendSchema: z__default.default.string().optional(),
70
+ component: z__default.default.string().optional(),
71
+ isWorkflow: z__default.default.boolean().optional()
68
72
  });
69
73
  var serializedStepFlowEntrySchema = z__default.default.object({
70
74
  type: z__default.default.enum(["step", "sleep", "sleepUntil", "waitForEvent", "parallel", "conditional", "loop", "foreach"])
@@ -77,6 +81,7 @@ var workflowInfoSchema = z__default.default.object({
77
81
  stepGraph: z__default.default.array(serializedStepFlowEntrySchema),
78
82
  inputSchema: z__default.default.string().optional(),
79
83
  outputSchema: z__default.default.string().optional(),
84
+ stateSchema: z__default.default.string().optional(),
80
85
  options: z__default.default.object({}).optional(),
81
86
  isProcessorWorkflow: z__default.default.boolean().optional()
82
87
  });
@@ -93,7 +98,6 @@ var workflowRunsResponseSchema = z__default.default.object({
93
98
  runs: z__default.default.array(workflowRunSchema),
94
99
  total: z__default.default.number()
95
100
  });
96
- var workflowRunResponseSchema = workflowRunSchema;
97
101
  var listWorkflowRunsQuerySchema = chunkMCYD5LW7_cjs.createCombinedPaginationSchema().extend({
98
102
  fromDate: z__default.default.coerce.date().optional(),
99
103
  toDate: z__default.default.coerce.date().optional(),
@@ -140,38 +144,55 @@ z__default.default.object({
140
144
  event: z__default.default.string(),
141
145
  data: z__default.default.unknown()
142
146
  });
143
- var workflowExecutionResultQuerySchema = z__default.default.object({
144
- fields: z__default.default.string().optional().refine(
145
- (value) => {
146
- if (!value) return true;
147
- const validFields = /* @__PURE__ */ new Set([
148
- "status",
149
- "result",
150
- "error",
151
- "payload",
152
- "steps",
153
- "activeStepsPath",
154
- "serializedStepGraph"
155
- ]);
156
- const requestedFields = value.split(",").map((f) => f.trim());
157
- return requestedFields.every((field) => validFields.has(field));
158
- },
159
- {
160
- message: "Invalid field name. Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph"
161
- }
162
- ).describe(
163
- "Comma-separated list of fields to return. Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph. If not provided, returns all fields."
164
- ),
165
- withNestedWorkflows: z__default.default.enum(["true", "false"]).optional().describe(
166
- "Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance."
167
- )
168
- });
147
+ var VALID_WORKFLOW_RESULT_FIELDS = /* @__PURE__ */ new Set([
148
+ "result",
149
+ "error",
150
+ "payload",
151
+ "steps",
152
+ "activeStepsPath",
153
+ "serializedStepGraph"
154
+ ]);
155
+ var WORKFLOW_RESULT_FIELDS_ERROR = "Invalid field name. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph";
156
+ var createFieldsValidator = (description) => z__default.default.string().optional().refine(
157
+ (value) => {
158
+ if (!value) return true;
159
+ const requestedFields = value.split(",").map((f) => f.trim());
160
+ return requestedFields.every((field) => VALID_WORKFLOW_RESULT_FIELDS.has(field));
161
+ },
162
+ { message: WORKFLOW_RESULT_FIELDS_ERROR }
163
+ ).describe(description);
164
+ var withNestedWorkflowsField = z__default.default.enum(["true", "false"]).optional().describe("Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance.");
169
165
  var workflowExecutionResultSchema = z__default.default.object({
170
166
  status: workflowRunStatusSchema.optional(),
171
167
  result: z__default.default.unknown().optional(),
172
168
  error: z__default.default.unknown().optional(),
173
169
  payload: z__default.default.unknown().optional(),
170
+ initialState: z__default.default.unknown().optional(),
171
+ steps: z__default.default.record(z__default.default.string(), z__default.default.any()).optional(),
172
+ activeStepsPath: z__default.default.record(z__default.default.string(), z__default.default.array(z__default.default.number())).optional(),
173
+ serializedStepGraph: z__default.default.array(serializedStepFlowEntrySchema).optional()
174
+ });
175
+ var workflowRunResultQuerySchema = z__default.default.object({
176
+ fields: createFieldsValidator(
177
+ "Comma-separated list of fields to return. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included."
178
+ ),
179
+ withNestedWorkflows: withNestedWorkflowsField
180
+ });
181
+ var workflowRunResultSchema = z__default.default.object({
182
+ // Metadata - always present
183
+ runId: z__default.default.string(),
184
+ workflowName: z__default.default.string(),
185
+ resourceId: z__default.default.string().optional(),
186
+ createdAt: z__default.default.date(),
187
+ updatedAt: z__default.default.date(),
188
+ // Execution state
189
+ status: workflowRunStatusSchema,
190
+ initialState: z__default.default.record(z__default.default.string(), z__default.default.any()).optional(),
191
+ result: z__default.default.unknown().optional(),
192
+ error: z__default.default.unknown().optional(),
193
+ payload: z__default.default.unknown().optional(),
174
194
  steps: z__default.default.record(z__default.default.string(), z__default.default.any()).optional(),
195
+ // Optional detailed fields
175
196
  activeStepsPath: z__default.default.record(z__default.default.string(), z__default.default.array(z__default.default.number())).optional(),
176
197
  serializedStepGraph: z__default.default.array(serializedStepFlowEntrySchema).optional()
177
198
  });
@@ -191,7 +212,7 @@ async function listWorkflowsFromSystem({ mastra, workflowId }) {
191
212
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
192
213
  }
193
214
  let workflow;
194
- workflow = chunk3XI22UQR_cjs.WorkflowRegistry.getWorkflow(workflowId);
215
+ workflow = chunkGWLR6K3H_cjs.WorkflowRegistry.getWorkflow(workflowId);
195
216
  if (!workflow) {
196
217
  try {
197
218
  workflow = mastra.getWorkflowById(workflowId);
@@ -238,7 +259,7 @@ var LIST_WORKFLOWS_ROUTE = chunkUKRDDBXY_cjs.createRoute({
238
259
  const workflows = mastra.listWorkflows({ serialized: false });
239
260
  const isPartial = partial === "true";
240
261
  const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
241
- acc[key] = chunk3XI22UQR_cjs.getWorkflowInfo(workflow, isPartial);
262
+ acc[key] = chunkGWLR6K3H_cjs.getWorkflowInfo(workflow, isPartial);
242
263
  return acc;
243
264
  }, {});
244
265
  return _workflows;
@@ -262,7 +283,7 @@ var GET_WORKFLOW_BY_ID_ROUTE = chunkUKRDDBXY_cjs.createRoute({
262
283
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
263
284
  }
264
285
  const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
265
- return chunk3XI22UQR_cjs.getWorkflowInfo(workflow);
286
+ return chunkGWLR6K3H_cjs.getWorkflowInfo(workflow);
266
287
  } catch (error) {
267
288
  return chunkSUKFO7UM_cjs.handleError(error, "Error getting workflow");
268
289
  }
@@ -323,11 +344,12 @@ var GET_WORKFLOW_RUN_BY_ID_ROUTE = chunkUKRDDBXY_cjs.createRoute({
323
344
  path: "/api/workflows/:workflowId/runs/:runId",
324
345
  responseType: "json",
325
346
  pathParamSchema: workflowRunPathParams,
326
- responseSchema: workflowRunResponseSchema,
347
+ queryParamSchema: workflowRunResultQuerySchema,
348
+ responseSchema: workflowRunResultSchema,
327
349
  summary: "Get workflow run by ID",
328
- description: "Returns details for a specific workflow run",
350
+ description: "Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result,metadata)",
329
351
  tags: ["Workflows"],
330
- handler: async ({ mastra, workflowId, runId }) => {
352
+ handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows }) => {
331
353
  try {
332
354
  if (!workflowId) {
333
355
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
@@ -339,7 +361,12 @@ var GET_WORKFLOW_RUN_BY_ID_ROUTE = chunkUKRDDBXY_cjs.createRoute({
339
361
  if (!workflow) {
340
362
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
341
363
  }
342
- const run = await workflow.getWorkflowRunById(runId);
364
+ const fieldList = fields ? fields.split(",").map((f) => f.trim()) : void 0;
365
+ const run = await workflow.getWorkflowRunById(runId, {
366
+ withNestedWorkflows: withNestedWorkflows !== "false",
367
+ // Default to true unless explicitly 'false'
368
+ fields: fieldList
369
+ });
343
370
  if (!run) {
344
371
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
345
372
  }
@@ -446,18 +473,6 @@ var STREAM_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
446
473
  }
447
474
  }
448
475
  });
449
- var STREAM_VNEXT_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
450
- method: "POST",
451
- path: "/api/workflows/:workflowId/streamVNext",
452
- responseType: "stream",
453
- pathParamSchema: workflowIdPathParams,
454
- queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
455
- bodySchema: streamWorkflowBodySchema,
456
- summary: "Stream workflow execution (v2)",
457
- description: "Executes a workflow using the v2 streaming API and streams the results in real-time",
458
- tags: ["Workflows"],
459
- handler: STREAM_WORKFLOW_ROUTE.handler
460
- });
461
476
  var RESUME_STREAM_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
462
477
  method: "POST",
463
478
  path: "/api/workflows/:workflowId/resume-stream",
@@ -505,43 +520,6 @@ var RESUME_STREAM_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
505
520
  }
506
521
  }
507
522
  });
508
- var GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = chunkUKRDDBXY_cjs.createRoute({
509
- method: "GET",
510
- path: "/api/workflows/:workflowId/runs/:runId/execution-result",
511
- responseType: "json",
512
- pathParamSchema: workflowRunPathParams,
513
- queryParamSchema: workflowExecutionResultQuerySchema,
514
- responseSchema: workflowExecutionResultSchema,
515
- summary: "Get workflow execution result",
516
- description: "Returns the final execution result of a completed workflow run. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result)",
517
- tags: ["Workflows"],
518
- handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows }) => {
519
- try {
520
- if (!workflowId) {
521
- throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
522
- }
523
- if (!runId) {
524
- throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Run ID is required" });
525
- }
526
- const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
527
- if (!workflow) {
528
- throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
529
- }
530
- const fieldList = fields ? fields.split(",").map((f) => f.trim()) : void 0;
531
- const executionResult = await workflow.getWorkflowRunExecutionResult(runId, {
532
- withNestedWorkflows: withNestedWorkflows !== "false",
533
- // Default to true unless explicitly 'false'
534
- fields: fieldList
535
- });
536
- if (!executionResult) {
537
- throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
538
- }
539
- return executionResult;
540
- } catch (error) {
541
- return chunkSUKFO7UM_cjs.handleError(error, "Error getting workflow run execution result");
542
- }
543
- }
544
- });
545
523
  var START_ASYNC_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
546
524
  method: "POST",
547
525
  path: "/api/workflows/:workflowId/start-async",
@@ -677,18 +655,6 @@ var OBSERVE_STREAM_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
677
655
  }
678
656
  }
679
657
  });
680
- var OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
681
- method: "POST",
682
- path: "/api/workflows/:workflowId/observe-streamVNext",
683
- responseType: "stream",
684
- pathParamSchema: workflowIdPathParams,
685
- queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
686
- responseSchema: chunkR25YJP3Y_cjs.streamResponseSchema,
687
- summary: "Observe workflow stream (v2)",
688
- description: "Observes and streams updates from an already running workflow execution using v2 streaming API",
689
- tags: ["Workflows"],
690
- handler: OBSERVE_STREAM_WORKFLOW_ROUTE.handler
691
- });
692
658
  var RESUME_ASYNC_WORKFLOW_ROUTE = chunkUKRDDBXY_cjs.createRoute({
693
659
  method: "POST",
694
660
  path: "/api/workflows/:workflowId/resume-async",
@@ -1115,11 +1081,9 @@ exports.CREATE_WORKFLOW_RUN_ROUTE = CREATE_WORKFLOW_RUN_ROUTE;
1115
1081
  exports.DELETE_WORKFLOW_RUN_BY_ID_ROUTE = DELETE_WORKFLOW_RUN_BY_ID_ROUTE;
1116
1082
  exports.GET_WORKFLOW_BY_ID_ROUTE = GET_WORKFLOW_BY_ID_ROUTE;
1117
1083
  exports.GET_WORKFLOW_RUN_BY_ID_ROUTE = GET_WORKFLOW_RUN_BY_ID_ROUTE;
1118
- exports.GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE;
1119
1084
  exports.LIST_WORKFLOWS_ROUTE = LIST_WORKFLOWS_ROUTE;
1120
1085
  exports.LIST_WORKFLOW_RUNS_ROUTE = LIST_WORKFLOW_RUNS_ROUTE;
1121
1086
  exports.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE;
1122
- exports.OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE = OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE;
1123
1087
  exports.OBSERVE_STREAM_WORKFLOW_ROUTE = OBSERVE_STREAM_WORKFLOW_ROUTE;
1124
1088
  exports.RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE;
1125
1089
  exports.RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE;
@@ -1131,7 +1095,6 @@ exports.RESUME_WORKFLOW_ROUTE = RESUME_WORKFLOW_ROUTE;
1131
1095
  exports.START_ASYNC_WORKFLOW_ROUTE = START_ASYNC_WORKFLOW_ROUTE;
1132
1096
  exports.START_WORKFLOW_RUN_ROUTE = START_WORKFLOW_RUN_ROUTE;
1133
1097
  exports.STREAM_LEGACY_WORKFLOW_ROUTE = STREAM_LEGACY_WORKFLOW_ROUTE;
1134
- exports.STREAM_VNEXT_WORKFLOW_ROUTE = STREAM_VNEXT_WORKFLOW_ROUTE;
1135
1098
  exports.STREAM_WORKFLOW_ROUTE = STREAM_WORKFLOW_ROUTE;
1136
1099
  exports.TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE;
1137
1100
  exports.TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = TIME_TRAVEL_STREAM_WORKFLOW_ROUTE;
@@ -1146,8 +1109,9 @@ exports.streamWorkflowBodySchema = streamWorkflowBodySchema;
1146
1109
  exports.workflowControlResponseSchema = workflowControlResponseSchema;
1147
1110
  exports.workflowExecutionResultSchema = workflowExecutionResultSchema;
1148
1111
  exports.workflowInfoSchema = workflowInfoSchema;
1149
- exports.workflowRunResponseSchema = workflowRunResponseSchema;
1112
+ exports.workflowRunResultQuerySchema = workflowRunResultQuerySchema;
1113
+ exports.workflowRunResultSchema = workflowRunResultSchema;
1150
1114
  exports.workflowRunsResponseSchema = workflowRunsResponseSchema;
1151
1115
  exports.workflows_exports = workflows_exports;
1152
- //# sourceMappingURL=chunk-MZXGNP3J.cjs.map
1153
- //# sourceMappingURL=chunk-MZXGNP3J.cjs.map
1116
+ //# sourceMappingURL=chunk-3PZVR6W3.cjs.map
1117
+ //# sourceMappingURL=chunk-3PZVR6W3.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/workflows.ts","../src/server/schemas/workflows.ts"],"names":["__export","z","createCombinedPaginationSchema","tracingOptionsSchema","messageResponseSchema","HTTPException","WorkflowRegistry","createRoute","getWorkflowInfo","handleError","optionalRunIdSchema","runIdSchema","TransformStream","streamResponseSchema","ReadableStream"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,+BAAA,EAAA,MAAA,+BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,4CAAA,EAAA,MAAA,4CAAA;AAAA,EAAA,sCAAA,EAAA,MAAA,sCAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA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AM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,MACpE;AAEA,MAAA,MAAM,eAAA,GAAkB,IAAIO,mBAAA,EAA0C;AAEtE,MAAA,MAAM,MAAA,GAAS,eAAA,CAAgB,QAAA,CAAS,SAAA,EAAU;AAElD,MAAA,MAAM,eAAA,GAAkB,MAAM,WAAA,CAAY,UAAA,CAAW,OAAO,CAAC,CAAA;AAE7D,MAAA,KAAA,MAAW,SAAS,eAAA,EAAiB;AACnC,QAAA,MAAM,MAAA,CAAO,MAAM,KAAY,CAAA;AAAA,MACjC;AAEA,MAAA,MAAA,CAAO,WAAA,EAAY;AAEnB,MAAA,MAAM,MAAA,GAAS,KAAK,mBAAA,EAAoB;AACxC,MAAA,OAAO,MAAA,CAAO,MAAA,EAAQ,WAAA,CAAY,eAAe,CAAA;AAAA,IACnD,SAAS,KAAA,EAAO;AACd,MAAA,OAAOH,6BAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-3PZVR6W3.cjs","sourcesContent":["import { ReadableStream, TransformStream } from 'node:stream/web';\nimport type { WorkflowInfo, ChunkType, StreamEvent, WorkflowStateField } from '@mastra/core/workflows';\nimport { z } from 'zod';\nimport { HTTPException } from '../http-exception';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport {\n createWorkflowRunBodySchema,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n listWorkflowsResponseSchema,\n restartBodySchema,\n timeTravelBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamWorkflowBodySchema,\n workflowControlResponseSchema,\n workflowExecutionResultSchema,\n workflowIdPathParams,\n workflowInfoSchema,\n workflowRunPathParams,\n workflowRunsResponseSchema,\n workflowRunResultQuerySchema,\n workflowRunResultSchema,\n} from '../schemas/workflows';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nasync function listWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n try {\n workflow = mastra.getWorkflowById(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.listAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.listWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_WORKFLOWS_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows',\n responseType: 'json',\n queryParamSchema: z.object({\n partial: z.string().optional(),\n }),\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List all workflows',\n description: 'Returns a list of all available workflows in the system',\n tags: ['Workflows'],\n handler: async ({ mastra, partial }) => {\n try {\n const workflows = mastra.listWorkflows({ serialized: false });\n const isPartial = partial === 'true';\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow, isPartial);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n },\n});\n\nexport const GET_WORKFLOW_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get workflow by ID',\n description: 'Returns details for a specific workflow',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n },\n});\n\nexport const LIST_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId/runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List workflow runs',\n description: 'Returns a paginated list of execution runs for the specified workflow',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, fromDate, toDate, page, perPage, limit, offset, resourceId, status }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // If page/perPage provided, use directly; otherwise convert from limit/offset\n let finalPage = page;\n let finalPerPage = perPage;\n\n if (finalPerPage === undefined && limit !== undefined) {\n finalPerPage = limit;\n }\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n if (\n finalPerPage !== undefined &&\n (typeof finalPerPage !== 'number' || !Number.isInteger(finalPerPage) || finalPerPage <= 0)\n ) {\n throw new HTTPException(400, { message: 'perPage must be a positive integer' });\n }\n if (finalPage !== undefined && (!Number.isInteger(finalPage) || finalPage < 0)) {\n throw new HTTPException(400, { message: 'page must be a non-negative integer' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const workflowRuns = (await workflow.listWorkflowRuns({\n fromDate: fromDate ? (typeof fromDate === 'string' ? new Date(fromDate) : fromDate) : undefined,\n toDate: toDate ? (typeof toDate === 'string' ? new Date(toDate) : toDate) : undefined,\n perPage: finalPerPage,\n page: finalPage,\n resourceId,\n status,\n })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\n});\n\nexport const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get workflow run by ID',\n description:\n 'Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result,metadata)',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Parse fields parameter (comma-separated string)\n const fieldList = fields ? (fields.split(',').map((f: string) => f.trim()) as WorkflowStateField[]) : undefined;\n\n const run = await workflow.getWorkflowRunById(runId, {\n withNestedWorkflows: withNestedWorkflows !== 'false', // Default to true unless explicitly 'false'\n fields: fieldList,\n });\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n },\n});\n\nexport const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'DELETE',\n path: '/api/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Delete workflow run by ID',\n description: 'Deletes a specific workflow run by ID',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.deleteWorkflowRunById(runId);\n\n return { message: 'Workflow run deleted' };\n } catch (error) {\n return handleError(error, 'Error deleting workflow run');\n }\n },\n});\n\nexport const CREATE_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/create-run',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: createWorkflowRunBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create workflow run',\n description: 'Creates a new workflow execution instance with an optional custom run ID',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, resourceId, disableScorers }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRun({ runId, resourceId, disableScorers });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n },\n});\n\nexport const STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n summary: 'Stream workflow execution',\n description: 'Executes a workflow and streams the results in real-time',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, resourceId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId });\n const result = run.stream(params);\n return result.fullStream.pipeThrough(\n new TransformStream<ChunkType, ChunkType>({\n transform(chunk, controller) {\n if (serverCache) {\n const cacheKey = runId;\n serverCache.listPush(cacheKey, chunk).catch(() => {});\n }\n controller.enqueue(chunk);\n },\n }),\n );\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n },\n});\n\nexport const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/resume-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume workflow stream',\n description: 'Resumes a suspended workflow execution and continues streaming results',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const stream = _run.resumeStream(params).fullStream.pipeThrough(\n new TransformStream<ChunkType, ChunkType>({\n transform(chunk, controller) {\n if (serverCache) {\n const cacheKey = runId;\n serverCache.listPush(cacheKey, chunk).catch(() => {});\n }\n\n controller.enqueue(chunk);\n },\n }),\n );\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const START_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/start-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start workflow asynchronously',\n description: 'Starts a workflow execution asynchronously without streaming results',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRun({ runId });\n const result = await _run.start(params);\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n },\n});\n\nexport const START_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/start',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific workflow run',\n description: 'Starts execution of a specific workflow run by ID',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n void _run.start({\n ...params,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n },\n});\n\nexport const OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/observe',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream',\n description: 'Observes and streams updates from an already running workflow execution',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks first\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n // Create a readable stream that first emits cached chunks, then the live stream\n const combinedStream = new ReadableStream<ChunkType>({\n start(controller) {\n // First, emit all cached chunks\n const emitCachedChunks = async () => {\n for (const chunk of cachedRunChunks) {\n controller.enqueue(chunk as ChunkType);\n }\n };\n\n // Then, pipe the live stream\n const liveStream = _run.observeStream();\n const reader = liveStream.getReader();\n\n const pump = async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n break;\n }\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n } finally {\n reader.releaseLock();\n }\n };\n\n // Start with cached chunks, then live stream\n void emitCachedChunks()\n .then(() => {\n void pump();\n })\n .catch(error => {\n controller.error(error);\n });\n },\n });\n\n return combinedStream;\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/resume-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume workflow asynchronously',\n description: 'Resumes a suspended workflow execution asynchronously without streaming',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resume(params);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\nexport const RESUME_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/resume',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume workflow',\n description: 'Resumes a suspended workflow execution from a specific step',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.resume(params);\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Restart workflow asynchronously',\n description: 'Restarts an active workflow execution asynchronously',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.restart(params);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart workflow',\n description: 'Restarts an active workflow execution',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart(params);\n\n return { message: 'Workflow run restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart-all-active-workflow-runs-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs asynchronously',\n description: 'Restarts all active workflow runs asynchronously',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart-all-active-workflow-runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs',\n description: 'Restarts all active workflow runs',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n void workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/time-travel-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Time travel workflow asynchronously',\n description: 'Time travels a workflow run asynchronously without streaming',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.timeTravel(params);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/time-travel',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Time travel workflow',\n description: 'Time travels a workflow run, starting from a specific step',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.timeTravel(params);\n\n return { message: 'Workflow run time travel started' };\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/time-travel-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n summary: 'Time travel workflow stream',\n description: 'Time travels a workflow run, starting from a specific step, and streams the results in real-time',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId });\n const result = run.timeTravelStream(params);\n return result.fullStream.pipeThrough(\n new TransformStream<ChunkType, ChunkType>({\n transform(chunk, controller) {\n if (serverCache) {\n const cacheKey = runId;\n serverCache.listPush(cacheKey, chunk).catch(() => {});\n }\n controller.enqueue(chunk);\n },\n }),\n );\n } catch (error) {\n return handleError(error, 'Error time traveling workflow stream');\n }\n },\n});\n\nexport const CANCEL_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel workflow run',\n description: 'Cancels an in-progress workflow execution',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream workflow with legacy format',\n description: 'Legacy endpoint for streaming workflow execution. Use /api/workflows/:workflowId/stream instead.',\n tags: ['Workflows', 'Legacy'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId });\n const result = run.streamLegacy({\n ...params,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return result.stream;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe workflow stream with legacy format',\n description: 'Legacy endpoint for observing workflow stream. Use /api/workflows/:workflowId/observe instead.',\n tags: ['Workflows', 'Legacy'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n const transformStream = new TransformStream<StreamEvent, StreamEvent>();\n\n const writer = transformStream.writable.getWriter();\n\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n for (const chunk of cachedRunChunks) {\n await writer.write(chunk as any);\n }\n\n writer.releaseLock();\n\n const result = _run.observeStreamLegacy();\n return result.stream?.pipeThrough(transformStream);\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n","import z from 'zod';\nimport { createCombinedPaginationSchema, tracingOptionsSchema, messageResponseSchema } from './common';\n\nexport const workflowRunStatusSchema = z.enum([\n 'running',\n 'waiting',\n 'suspended',\n 'success',\n 'failed',\n 'canceled',\n 'pending',\n 'bailed',\n 'tripwire',\n 'paused',\n]);\n\n// Path parameter schemas\nexport const workflowIdPathParams = z.object({\n workflowId: z.string().describe('Unique identifier for the workflow'),\n});\n\nexport const workflowRunPathParams = workflowIdPathParams.extend({\n runId: z.string().describe('Unique identifier for the workflow run'),\n});\n\n/**\n * Schema for serialized step\n * Uses passthrough() to allow step-specific fields\n */\nconst serializedStepSchema = z.object({\n id: z.string(),\n description: z.string().optional(),\n stateSchema: z.string().optional(),\n inputSchema: z.string().optional(),\n outputSchema: z.string().optional(),\n resumeSchema: z.string().optional(),\n suspendSchema: z.string().optional(),\n component: z.string().optional(),\n isWorkflow: z.boolean().optional(),\n});\n\n/**\n * Schema for serialized step flow entry\n * Represents different step flow types in the workflow graph\n */\nconst serializedStepFlowEntrySchema = z.object({\n type: z.enum(['step', 'sleep', 'sleepUntil', 'waitForEvent', 'parallel', 'conditional', 'loop', 'foreach']),\n});\n\n/**\n * Schema for workflow information\n * Returned by getWorkflowByIdHandler and listWorkflowsHandler\n */\nexport const workflowInfoSchema = z.object({\n steps: z.record(z.string(), serializedStepSchema),\n allSteps: z.record(z.string(), serializedStepSchema),\n name: z.string().optional(),\n description: z.string().optional(),\n stepGraph: z.array(serializedStepFlowEntrySchema),\n inputSchema: z.string().optional(),\n outputSchema: z.string().optional(),\n stateSchema: z.string().optional(),\n options: z.object({}).optional(),\n isProcessorWorkflow: z.boolean().optional(),\n});\n\n/**\n * Schema for list workflows endpoint response\n * Returns a record of workflow ID to workflow info\n */\nexport const listWorkflowsResponseSchema = z.record(z.string(), workflowInfoSchema);\n\n/**\n * Schema for workflow run object\n */\nconst workflowRunSchema = z.object({\n workflowName: z.string(),\n runId: z.string(),\n snapshot: z.union([z.object({}), z.string()]),\n createdAt: z.date(),\n updatedAt: z.date(),\n resourceId: z.string().optional(),\n});\n\n/**\n * Schema for workflow runs response (paginated)\n * Includes runs array and total count\n */\nexport const workflowRunsResponseSchema = z.object({\n runs: z.array(workflowRunSchema),\n total: z.number(),\n});\n\n/**\n * Schema for query parameters when listing workflow runs\n * Supports both page/perPage and limit/offset for backwards compatibility\n * If page/perPage provided, use directly; otherwise convert from limit/offset\n */\nexport const listWorkflowRunsQuerySchema = createCombinedPaginationSchema().extend({\n fromDate: z.coerce.date().optional(),\n toDate: z.coerce.date().optional(),\n resourceId: z.string().optional(),\n status: workflowRunStatusSchema.optional(),\n});\n\n/**\n * Base schema for workflow execution with input data and tracing\n */\nconst workflowExecutionBodySchema = z.object({\n resourceId: z.string().optional(),\n inputData: z.unknown().optional(),\n initialState: z.unknown().optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n perStep: z.boolean().optional(),\n});\n\n/**\n * Schema for legacy stream workflow body (no closeOnSuspend support)\n * Used by /stream-legacy endpoints\n */\nexport const streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;\n\n/**\n * Schema for stream workflow body\n * Used by both /stream and /streamVNext endpoints\n */\nexport const streamWorkflowBodySchema = workflowExecutionBodySchema.extend({\n closeOnSuspend: z.boolean().optional(),\n});\n\n/**\n * Schema for resume workflow body\n * Used by resume-stream, resume-async and resume endpoints\n */\nexport const resumeBodySchema = z.object({\n step: z.union([z.string(), z.array(z.string())]).optional(), // Optional - workflow can auto-resume all suspended steps\n resumeData: z.unknown().optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n perStep: z.boolean().optional(),\n});\n\n/**\n * Schema for restart workflow body\n * Used by restart-async and restart endpoints\n */\nexport const restartBodySchema = z.object({\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n});\n\n/**\n * Schema for time travel workflow body\n * Used by time-travel-stream, time-travel-async and time-travel endpoints\n */\nexport const timeTravelBodySchema = z.object({\n inputData: z.unknown().optional(),\n resumeData: z.unknown().optional(),\n initialState: z.unknown().optional(),\n step: z.union([z.string(), z.array(z.string())]),\n context: z.record(z.string(), z.any()).optional(),\n nestedStepsContext: z.record(z.string(), z.record(z.string(), z.any())).optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n perStep: z.boolean().optional(),\n});\n\n/**\n * Schema for start async workflow body\n */\nexport const startAsyncWorkflowBodySchema = workflowExecutionBodySchema;\n\n/**\n * Schema for send workflow run event body\n */\nexport const sendWorkflowRunEventBodySchema = z.object({\n event: z.string(),\n data: z.unknown(),\n});\n\n// Shared field validation for workflow result queries\nconst VALID_WORKFLOW_RESULT_FIELDS = new Set([\n 'result',\n 'error',\n 'payload',\n 'steps',\n 'activeStepsPath',\n 'serializedStepGraph',\n]);\n\nconst WORKFLOW_RESULT_FIELDS_ERROR =\n 'Invalid field name. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph';\n\nconst createFieldsValidator = (description: string) =>\n z\n .string()\n .optional()\n .refine(\n value => {\n if (!value) return true;\n const requestedFields = value.split(',').map(f => f.trim());\n return requestedFields.every(field => VALID_WORKFLOW_RESULT_FIELDS.has(field));\n },\n { message: WORKFLOW_RESULT_FIELDS_ERROR },\n )\n .describe(description);\n\nconst withNestedWorkflowsField = z\n .enum(['true', 'false'])\n .optional()\n .describe('Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance.');\n\n/**\n * Schema for workflow execution result\n * All fields are optional since field filtering allows requesting specific fields only\n */\nexport const workflowExecutionResultSchema = z.object({\n status: workflowRunStatusSchema.optional(),\n result: z.unknown().optional(),\n error: z.unknown().optional(),\n payload: z.unknown().optional(),\n initialState: z.unknown().optional(),\n steps: z.record(z.string(), z.any()).optional(),\n activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),\n serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional(),\n});\n\n/**\n * Schema for query parameters when getting a unified workflow run result\n */\nexport const workflowRunResultQuerySchema = z.object({\n fields: createFieldsValidator(\n 'Comma-separated list of fields to return. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included.',\n ),\n withNestedWorkflows: withNestedWorkflowsField,\n});\n\n/**\n * Schema for unified workflow run result response\n * Combines metadata and processed execution state\n */\nexport const workflowRunResultSchema = z.object({\n // Metadata - always present\n runId: z.string(),\n workflowName: z.string(),\n resourceId: z.string().optional(),\n createdAt: z.date(),\n updatedAt: z.date(),\n\n // Execution state\n status: workflowRunStatusSchema,\n initialState: z.record(z.string(), z.any()).optional(),\n result: z.unknown().optional(),\n error: z.unknown().optional(),\n payload: z.unknown().optional(),\n steps: z.record(z.string(), z.any()).optional(),\n\n // Optional detailed fields\n activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),\n serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional(),\n});\n\n/**\n * Response schema for workflow control operations\n */\nexport const workflowControlResponseSchema = messageResponseSchema;\n\n/**\n * Response schema for create workflow run operation\n * Returns only the runId after creating a run\n */\nexport const createWorkflowRunResponseSchema = z.object({\n runId: z.string(),\n});\n\n/**\n * Schema for create workflow run body\n * Used by /create-run endpoint\n */\nexport const createWorkflowRunBodySchema = z.object({\n resourceId: z.string().optional(),\n disableScorers: z.boolean().optional(),\n});\n"]}