@mastra/server 1.29.1 → 1.30.0-alpha.1

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 (159) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/dist/{chunk-LWK57QIA.cjs → chunk-2CFH32YO.cjs} +5 -5
  3. package/dist/{chunk-LWK57QIA.cjs.map → chunk-2CFH32YO.cjs.map} +1 -1
  4. package/dist/{chunk-HU57X24H.js → chunk-2HVAN7FF.js} +25 -10
  5. package/dist/chunk-2HVAN7FF.js.map +1 -0
  6. package/dist/{chunk-E6E2VFIT.js → chunk-2PF5ZR2Q.js} +9 -9
  7. package/dist/{chunk-E6E2VFIT.js.map → chunk-2PF5ZR2Q.js.map} +1 -1
  8. package/dist/{chunk-HYI4ZAV7.js → chunk-43CWQ4M3.js} +8 -3
  9. package/dist/chunk-43CWQ4M3.js.map +1 -0
  10. package/dist/{chunk-JJT4GBDZ.js → chunk-4BSJHDYP.js} +3 -3
  11. package/dist/{chunk-JJT4GBDZ.js.map → chunk-4BSJHDYP.js.map} +1 -1
  12. package/dist/{chunk-X2XQFFXR.js → chunk-4GOK3PCO.js} +5 -5
  13. package/dist/{chunk-X2XQFFXR.js.map → chunk-4GOK3PCO.js.map} +1 -1
  14. package/dist/{chunk-4Y5P2GYV.js → chunk-4J4K36CU.js} +3 -3
  15. package/dist/{chunk-4Y5P2GYV.js.map → chunk-4J4K36CU.js.map} +1 -1
  16. package/dist/{chunk-RQXUPTUI.js → chunk-5OOYXBPG.js} +7 -3
  17. package/dist/chunk-5OOYXBPG.js.map +1 -0
  18. package/dist/{chunk-IO7PPBD4.js → chunk-DBPJYWAH.js} +47 -86
  19. package/dist/chunk-DBPJYWAH.js.map +1 -0
  20. package/dist/{chunk-H4HRQ7ZN.cjs → chunk-DZZBC6UV.cjs} +169 -32
  21. package/dist/chunk-DZZBC6UV.cjs.map +1 -0
  22. package/dist/{chunk-I3BHHWHT.cjs → chunk-EFW6MWXU.cjs} +4 -2
  23. package/dist/chunk-EFW6MWXU.cjs.map +1 -0
  24. package/dist/{chunk-2Z5KJJDZ.js → chunk-EPM6ILRW.js} +14 -3
  25. package/dist/chunk-EPM6ILRW.js.map +1 -0
  26. package/dist/{chunk-HWK6K3DW.cjs → chunk-EQR4MMSL.cjs} +7 -7
  27. package/dist/{chunk-HWK6K3DW.cjs.map → chunk-EQR4MMSL.cjs.map} +1 -1
  28. package/dist/{chunk-VFHNACRY.js → chunk-FN4GIXQQ.js} +5 -5
  29. package/dist/{chunk-VFHNACRY.js.map → chunk-FN4GIXQQ.js.map} +1 -1
  30. package/dist/{chunk-YO7N5VOP.js → chunk-GEXJ4LPZ.js} +3 -3
  31. package/dist/{chunk-YO7N5VOP.js.map → chunk-GEXJ4LPZ.js.map} +1 -1
  32. package/dist/{chunk-XT6GKIYW.cjs → chunk-GUWIV3ZN.cjs} +9 -2
  33. package/dist/chunk-GUWIV3ZN.cjs.map +1 -0
  34. package/dist/{chunk-PSQNWPPT.cjs → chunk-H6NJWTER.cjs} +4 -4
  35. package/dist/{chunk-PSQNWPPT.cjs.map → chunk-H6NJWTER.cjs.map} +1 -1
  36. package/dist/{chunk-KBD6NZE2.cjs → chunk-HR4M27JP.cjs} +77 -77
  37. package/dist/{chunk-KBD6NZE2.cjs.map → chunk-HR4M27JP.cjs.map} +1 -1
  38. package/dist/{chunk-VLNRGJEM.js → chunk-JZNOIGOQ.js} +3 -3
  39. package/dist/{chunk-VLNRGJEM.js.map → chunk-JZNOIGOQ.js.map} +1 -1
  40. package/dist/{chunk-VR623NIZ.cjs → chunk-KI7TGMMV.cjs} +276 -160
  41. package/dist/chunk-KI7TGMMV.cjs.map +1 -0
  42. package/dist/{chunk-P7QF3UG4.js → chunk-KJLIMNMI.js} +3 -3
  43. package/dist/{chunk-P7QF3UG4.js.map → chunk-KJLIMNMI.js.map} +1 -1
  44. package/dist/{chunk-WC4RIS4D.js → chunk-KW2MZGRE.js} +3 -3
  45. package/dist/{chunk-WC4RIS4D.js.map → chunk-KW2MZGRE.js.map} +1 -1
  46. package/dist/{chunk-IA7PNRIA.cjs → chunk-LI3EL57Z.cjs} +11 -11
  47. package/dist/{chunk-IA7PNRIA.cjs.map → chunk-LI3EL57Z.cjs.map} +1 -1
  48. package/dist/{chunk-33WVA4ZN.cjs → chunk-LKS22ETT.cjs} +19 -19
  49. package/dist/{chunk-33WVA4ZN.cjs.map → chunk-LKS22ETT.cjs.map} +1 -1
  50. package/dist/{chunk-NO3V76EI.cjs → chunk-LY6Q36YN.cjs} +17 -17
  51. package/dist/{chunk-NO3V76EI.cjs.map → chunk-LY6Q36YN.cjs.map} +1 -1
  52. package/dist/{chunk-UOWUXTUO.cjs → chunk-NGYGE7QW.cjs} +27 -27
  53. package/dist/{chunk-UOWUXTUO.cjs.map → chunk-NGYGE7QW.cjs.map} +1 -1
  54. package/dist/{chunk-JVQ5EXNJ.js → chunk-OJRAH5VV.js} +4 -3
  55. package/dist/chunk-OJRAH5VV.js.map +1 -0
  56. package/dist/{chunk-JOC7WKJ2.cjs → chunk-ONPPBXWB.cjs} +48 -48
  57. package/dist/{chunk-JOC7WKJ2.cjs.map → chunk-ONPPBXWB.cjs.map} +1 -1
  58. package/dist/{chunk-QP5DRBMC.js → chunk-QL62CV5V.js} +5 -5
  59. package/dist/{chunk-QP5DRBMC.js.map → chunk-QL62CV5V.js.map} +1 -1
  60. package/dist/{chunk-53QVLUCB.cjs → chunk-RPMBPQNO.cjs} +25 -10
  61. package/dist/chunk-RPMBPQNO.cjs.map +1 -0
  62. package/dist/{chunk-3DKWFTZU.js → chunk-RTD3NZ4G.js} +166 -29
  63. package/dist/chunk-RTD3NZ4G.js.map +1 -0
  64. package/dist/{chunk-RPOKTN4O.cjs → chunk-SEAOI56Z.cjs} +7 -7
  65. package/dist/{chunk-RPOKTN4O.cjs.map → chunk-SEAOI56Z.cjs.map} +1 -1
  66. package/dist/{chunk-K33KUMJY.js → chunk-SSMLJV2K.js} +5 -5
  67. package/dist/{chunk-K33KUMJY.js.map → chunk-SSMLJV2K.js.map} +1 -1
  68. package/dist/{chunk-DIX6JWN4.cjs → chunk-TF7NSMHW.cjs} +7 -2
  69. package/dist/chunk-TF7NSMHW.cjs.map +1 -0
  70. package/dist/{chunk-B7SBAXEP.cjs → chunk-TKHLXCSZ.cjs} +7 -7
  71. package/dist/{chunk-B7SBAXEP.cjs.map → chunk-TKHLXCSZ.cjs.map} +1 -1
  72. package/dist/{chunk-JGHGC64S.cjs → chunk-UQLJDNXU.cjs} +4 -4
  73. package/dist/{chunk-JGHGC64S.cjs.map → chunk-UQLJDNXU.cjs.map} +1 -1
  74. package/dist/{chunk-YGQNINW7.js → chunk-UZRD3SEA.js} +146 -31
  75. package/dist/chunk-UZRD3SEA.js.map +1 -0
  76. package/dist/{chunk-O76KG2FC.js → chunk-VZNOKYP5.js} +3 -3
  77. package/dist/{chunk-O76KG2FC.js.map → chunk-VZNOKYP5.js.map} +1 -1
  78. package/dist/{chunk-5BXP7S4P.cjs → chunk-XG2VRXG5.cjs} +15 -4
  79. package/dist/chunk-XG2VRXG5.cjs.map +1 -0
  80. package/dist/{chunk-R4DZSQYI.cjs → chunk-Y2SA2JZT.cjs} +138 -177
  81. package/dist/chunk-Y2SA2JZT.cjs.map +1 -0
  82. package/dist/docs/SKILL.md +1 -1
  83. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  84. package/dist/{observational-memory-YYO73QMY-JNLMPY5B.js → observational-memory-ZS2HJPUO-2ZBP2HCP.js} +3 -3
  85. package/dist/{observational-memory-YYO73QMY-JNLMPY5B.js.map → observational-memory-ZS2HJPUO-2ZBP2HCP.js.map} +1 -1
  86. package/dist/{observational-memory-YYO73QMY-CHIPDTZY.cjs → observational-memory-ZS2HJPUO-472SI4TK.cjs} +26 -26
  87. package/dist/{observational-memory-YYO73QMY-CHIPDTZY.cjs.map → observational-memory-ZS2HJPUO-472SI4TK.cjs.map} +1 -1
  88. package/dist/server/auth/helpers.d.ts.map +1 -1
  89. package/dist/server/auth/index.cjs +14 -14
  90. package/dist/server/auth/index.js +1 -1
  91. package/dist/server/constants.d.ts +1 -0
  92. package/dist/server/constants.d.ts.map +1 -1
  93. package/dist/server/handlers/a2a.cjs +10 -10
  94. package/dist/server/handlers/a2a.d.ts +17 -3
  95. package/dist/server/handlers/a2a.d.ts.map +1 -1
  96. package/dist/server/handlers/a2a.js +1 -1
  97. package/dist/server/handlers/agent-builder.cjs +16 -16
  98. package/dist/server/handlers/agent-builder.js +1 -1
  99. package/dist/server/handlers/agents.cjs +41 -37
  100. package/dist/server/handlers/agents.d.ts +14 -2
  101. package/dist/server/handlers/agents.d.ts.map +1 -1
  102. package/dist/server/handlers/agents.js +1 -1
  103. package/dist/server/handlers/auth.cjs +11 -11
  104. package/dist/server/handlers/auth.js +1 -1
  105. package/dist/server/handlers/conversations.cjs +5 -5
  106. package/dist/server/handlers/conversations.js +1 -1
  107. package/dist/server/handlers/logs.cjs +4 -4
  108. package/dist/server/handlers/logs.js +1 -1
  109. package/dist/server/handlers/memory.cjs +27 -27
  110. package/dist/server/handlers/memory.js +1 -1
  111. package/dist/server/handlers/responses.cjs +4 -4
  112. package/dist/server/handlers/responses.js +1 -1
  113. package/dist/server/handlers/responses.storage.cjs +8 -8
  114. package/dist/server/handlers/responses.storage.js +1 -1
  115. package/dist/server/handlers/scores.cjs +7 -7
  116. package/dist/server/handlers/scores.js +1 -1
  117. package/dist/server/handlers/tools.cjs +6 -6
  118. package/dist/server/handlers/tools.js +1 -1
  119. package/dist/server/handlers/utils.cjs +9 -9
  120. package/dist/server/handlers/utils.js +1 -1
  121. package/dist/server/handlers/voice.cjs +8 -8
  122. package/dist/server/handlers/voice.js +1 -1
  123. package/dist/server/handlers/workflows.cjs +24 -24
  124. package/dist/server/handlers/workflows.d.ts +2 -0
  125. package/dist/server/handlers/workflows.d.ts.map +1 -1
  126. package/dist/server/handlers/workflows.js +1 -1
  127. package/dist/server/handlers.cjs +22 -22
  128. package/dist/server/handlers.js +11 -11
  129. package/dist/server/schemas/agents.d.ts +12 -0
  130. package/dist/server/schemas/agents.d.ts.map +1 -1
  131. package/dist/server/schemas/index.cjs +69 -61
  132. package/dist/server/schemas/index.js +3 -3
  133. package/dist/server/schemas/workflows.d.ts +8 -0
  134. package/dist/server/schemas/workflows.d.ts.map +1 -1
  135. package/dist/server/server-adapter/index.cjs +136 -131
  136. package/dist/server/server-adapter/index.cjs.map +1 -1
  137. package/dist/server/server-adapter/index.d.ts.map +1 -1
  138. package/dist/server/server-adapter/index.js +19 -14
  139. package/dist/server/server-adapter/index.js.map +1 -1
  140. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
  141. package/dist/server/server-adapter/routes/workflows.d.ts +2 -0
  142. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  143. package/package.json +4 -4
  144. package/dist/chunk-2Z5KJJDZ.js.map +0 -1
  145. package/dist/chunk-3DKWFTZU.js.map +0 -1
  146. package/dist/chunk-53QVLUCB.cjs.map +0 -1
  147. package/dist/chunk-5BXP7S4P.cjs.map +0 -1
  148. package/dist/chunk-DIX6JWN4.cjs.map +0 -1
  149. package/dist/chunk-H4HRQ7ZN.cjs.map +0 -1
  150. package/dist/chunk-HU57X24H.js.map +0 -1
  151. package/dist/chunk-HYI4ZAV7.js.map +0 -1
  152. package/dist/chunk-I3BHHWHT.cjs.map +0 -1
  153. package/dist/chunk-IO7PPBD4.js.map +0 -1
  154. package/dist/chunk-JVQ5EXNJ.js.map +0 -1
  155. package/dist/chunk-R4DZSQYI.cjs.map +0 -1
  156. package/dist/chunk-RQXUPTUI.js.map +0 -1
  157. package/dist/chunk-VR623NIZ.cjs.map +0 -1
  158. package/dist/chunk-XT6GKIYW.cjs.map +0 -1
  159. package/dist/chunk-YGQNINW7.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkDIX6JWN4_cjs = require('./chunk-DIX6JWN4.cjs');
4
- var chunkXT6GKIYW_cjs = require('./chunk-XT6GKIYW.cjs');
3
+ var chunkTF7NSMHW_cjs = require('./chunk-TF7NSMHW.cjs');
4
+ var chunkGUWIV3ZN_cjs = require('./chunk-GUWIV3ZN.cjs');
5
5
  var chunkYJQYJ5WD_cjs = require('./chunk-YJQYJ5WD.cjs');
6
- var chunkLWK57QIA_cjs = require('./chunk-LWK57QIA.cjs');
6
+ var chunk2CFH32YO_cjs = require('./chunk-2CFH32YO.cjs');
7
7
  var chunkDIG2K5CV_cjs = require('./chunk-DIG2K5CV.cjs');
8
8
  var chunk5UKYK7YK_cjs = require('./chunk-5UKYK7YK.cjs');
9
9
  var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
10
10
  var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
11
11
  var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
12
- var web = require('stream/web');
12
+ var stream = require('@mastra/core/stream');
13
13
  var v4 = require('zod/v4');
14
14
 
15
15
  // src/server/handlers/workflows.ts
@@ -82,7 +82,7 @@ var LIST_WORKFLOWS_ROUTE = chunk5UKYK7YK_cjs.createRoute({
82
82
  queryParamSchema: v4.z.object({
83
83
  partial: v4.z.string().optional()
84
84
  }),
85
- responseSchema: chunkDIX6JWN4_cjs.listWorkflowsResponseSchema,
85
+ responseSchema: chunkTF7NSMHW_cjs.listWorkflowsResponseSchema,
86
86
  summary: "List all workflows",
87
87
  description: "Returns a list of all available workflows in the system",
88
88
  tags: ["Workflows"],
@@ -105,8 +105,8 @@ var GET_WORKFLOW_BY_ID_ROUTE = chunk5UKYK7YK_cjs.createRoute({
105
105
  method: "GET",
106
106
  path: "/workflows/:workflowId",
107
107
  responseType: "json",
108
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
109
- responseSchema: chunkDIX6JWN4_cjs.workflowInfoSchema,
108
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
109
+ responseSchema: chunkTF7NSMHW_cjs.workflowInfoSchema,
110
110
  summary: "Get workflow by ID",
111
111
  description: "Returns details for a specific workflow",
112
112
  tags: ["Workflows"],
@@ -127,9 +127,9 @@ var LIST_WORKFLOW_RUNS_ROUTE = chunk5UKYK7YK_cjs.createRoute({
127
127
  method: "GET",
128
128
  path: "/workflows/:workflowId/runs",
129
129
  responseType: "json",
130
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
131
- queryParamSchema: chunkDIX6JWN4_cjs.listWorkflowRunsQuerySchema,
132
- responseSchema: chunkDIX6JWN4_cjs.workflowRunsResponseSchema,
130
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
131
+ queryParamSchema: chunkTF7NSMHW_cjs.listWorkflowRunsQuerySchema,
132
+ responseSchema: chunkTF7NSMHW_cjs.workflowRunsResponseSchema,
133
133
  summary: "List workflow runs",
134
134
  description: "Returns a paginated list of execution runs for the specified workflow",
135
135
  tags: ["Workflows"],
@@ -148,7 +148,7 @@ var LIST_WORKFLOW_RUNS_ROUTE = chunk5UKYK7YK_cjs.createRoute({
148
148
  requestContext
149
149
  }) => {
150
150
  try {
151
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, resourceId);
151
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, resourceId);
152
152
  if (!workflowId) {
153
153
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
154
154
  }
@@ -191,16 +191,16 @@ var GET_WORKFLOW_RUN_BY_ID_ROUTE = chunk5UKYK7YK_cjs.createRoute({
191
191
  method: "GET",
192
192
  path: "/workflows/:workflowId/runs/:runId",
193
193
  responseType: "json",
194
- pathParamSchema: chunkDIX6JWN4_cjs.workflowRunPathParams,
195
- queryParamSchema: chunkDIX6JWN4_cjs.workflowRunResultQuerySchema,
196
- responseSchema: chunkDIX6JWN4_cjs.workflowRunResultSchema,
194
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowRunPathParams,
195
+ queryParamSchema: chunkTF7NSMHW_cjs.workflowRunResultQuerySchema,
196
+ responseSchema: chunkTF7NSMHW_cjs.workflowRunResultSchema,
197
197
  summary: "Get workflow run by ID",
198
198
  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)",
199
199
  tags: ["Workflows"],
200
200
  requiresAuth: true,
201
201
  handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows, requestContext }) => {
202
202
  try {
203
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
203
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
204
204
  if (!workflowId) {
205
205
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
206
206
  }
@@ -220,7 +220,7 @@ var GET_WORKFLOW_RUN_BY_ID_ROUTE = chunk5UKYK7YK_cjs.createRoute({
220
220
  if (!run) {
221
221
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
222
222
  }
223
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
223
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
224
224
  return run;
225
225
  } catch (error) {
226
226
  return chunkB34S64RC_cjs.handleError(error, "Error getting workflow run");
@@ -231,15 +231,15 @@ var DELETE_WORKFLOW_RUN_BY_ID_ROUTE = chunk5UKYK7YK_cjs.createRoute({
231
231
  method: "DELETE",
232
232
  path: "/workflows/:workflowId/runs/:runId",
233
233
  responseType: "json",
234
- pathParamSchema: chunkDIX6JWN4_cjs.workflowRunPathParams,
235
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
234
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowRunPathParams,
235
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
236
236
  summary: "Delete workflow run by ID",
237
237
  description: "Deletes a specific workflow run by ID",
238
238
  tags: ["Workflows"],
239
239
  requiresAuth: true,
240
240
  handler: async ({ mastra, workflowId, runId, requestContext }) => {
241
241
  try {
242
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
242
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
243
243
  if (!workflowId) {
244
244
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
245
245
  }
@@ -254,7 +254,7 @@ var DELETE_WORKFLOW_RUN_BY_ID_ROUTE = chunk5UKYK7YK_cjs.createRoute({
254
254
  if (!run) {
255
255
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
256
256
  }
257
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
257
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
258
258
  await workflow.deleteWorkflowRunById(runId);
259
259
  return { message: "Workflow run deleted" };
260
260
  } catch (error) {
@@ -266,17 +266,17 @@ var CREATE_WORKFLOW_RUN_ROUTE = chunk5UKYK7YK_cjs.createRoute({
266
266
  method: "POST",
267
267
  path: "/workflows/:workflowId/create-run",
268
268
  responseType: "json",
269
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
269
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
270
270
  queryParamSchema: chunkDIG2K5CV_cjs.optionalRunIdSchema,
271
- bodySchema: chunkDIX6JWN4_cjs.createWorkflowRunBodySchema,
272
- responseSchema: chunkDIX6JWN4_cjs.createWorkflowRunResponseSchema,
271
+ bodySchema: chunkTF7NSMHW_cjs.createWorkflowRunBodySchema,
272
+ responseSchema: chunkTF7NSMHW_cjs.createWorkflowRunResponseSchema,
273
273
  summary: "Create workflow run",
274
274
  description: "Creates a new workflow execution instance with an optional custom run ID",
275
275
  tags: ["Workflows"],
276
276
  requiresAuth: true,
277
277
  handler: async ({ mastra, workflowId, runId, resourceId, disableScorers, requestContext }) => {
278
278
  try {
279
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, resourceId);
279
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, resourceId);
280
280
  if (!workflowId) {
281
281
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
282
282
  }
@@ -295,16 +295,16 @@ var STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
295
295
  method: "POST",
296
296
  path: "/workflows/:workflowId/stream",
297
297
  responseType: "stream",
298
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
298
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
299
299
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
300
- bodySchema: chunkDIX6JWN4_cjs.streamWorkflowBodySchema,
300
+ bodySchema: chunkTF7NSMHW_cjs.streamWorkflowBodySchema,
301
301
  summary: "Stream workflow execution",
302
302
  description: "Executes a workflow and streams the results in real-time",
303
303
  tags: ["Workflows"],
304
304
  requiresAuth: true,
305
305
  handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {
306
306
  try {
307
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, resourceId);
307
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, resourceId);
308
308
  if (!workflowId) {
309
309
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
310
310
  }
@@ -318,18 +318,14 @@ var STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
318
318
  const serverCache = mastra.getServerCache();
319
319
  const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });
320
320
  const result = run.stream({ ...params, requestContext });
321
- return result.fullStream.pipeThrough(
322
- new web.TransformStream({
323
- transform(chunk, controller) {
324
- if (serverCache) {
325
- const cacheKey = runId;
326
- serverCache.listPush(cacheKey, chunk).catch(() => {
327
- });
328
- }
329
- controller.enqueue(chunk);
330
- }
331
- })
332
- );
321
+ if (serverCache) {
322
+ const { transform } = stream.createCachingTransformStream({
323
+ cache: serverCache,
324
+ cacheKey: runId
325
+ });
326
+ return result.fullStream.pipeThrough(transform);
327
+ }
328
+ return result.fullStream;
333
329
  } catch (error) {
334
330
  return chunkB34S64RC_cjs.handleError(error, "Error streaming workflow");
335
331
  }
@@ -339,17 +335,17 @@ var RESUME_STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
339
335
  method: "POST",
340
336
  path: "/workflows/:workflowId/resume-stream",
341
337
  responseType: "stream",
342
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
338
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
343
339
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
344
- bodySchema: chunkDIX6JWN4_cjs.resumeBodySchema,
345
- responseSchema: chunkXT6GKIYW_cjs.streamResponseSchema,
340
+ bodySchema: chunkTF7NSMHW_cjs.resumeBodySchema,
341
+ responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
346
342
  summary: "Resume workflow stream",
347
343
  description: "Resumes a suspended workflow execution and continues streaming results",
348
344
  tags: ["Workflows"],
349
345
  requiresAuth: true,
350
346
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
351
347
  try {
352
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
348
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
353
349
  if (!workflowId) {
354
350
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
355
351
  }
@@ -364,22 +360,18 @@ var RESUME_STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
364
360
  if (!run) {
365
361
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
366
362
  }
367
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
363
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
368
364
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
369
365
  const serverCache = mastra.getServerCache();
370
- const stream = _run.resumeStream({ ...params, requestContext }).fullStream.pipeThrough(
371
- new web.TransformStream({
372
- transform(chunk, controller) {
373
- if (serverCache) {
374
- const cacheKey = runId;
375
- serverCache.listPush(cacheKey, chunk).catch(() => {
376
- });
377
- }
378
- controller.enqueue(chunk);
379
- }
380
- })
381
- );
382
- return stream;
366
+ const resumeResult = _run.resumeStream({ ...params, requestContext });
367
+ if (serverCache) {
368
+ const { transform } = stream.createCachingTransformStream({
369
+ cache: serverCache,
370
+ cacheKey: runId
371
+ });
372
+ return resumeResult.fullStream.pipeThrough(transform);
373
+ }
374
+ return resumeResult.fullStream;
383
375
  } catch (error) {
384
376
  return chunkB34S64RC_cjs.handleError(error, "Error resuming workflow");
385
377
  }
@@ -389,17 +381,17 @@ var START_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
389
381
  method: "POST",
390
382
  path: "/workflows/:workflowId/start-async",
391
383
  responseType: "json",
392
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
384
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
393
385
  queryParamSchema: chunkDIG2K5CV_cjs.optionalRunIdSchema,
394
- bodySchema: chunkDIX6JWN4_cjs.startAsyncWorkflowBodySchema,
395
- responseSchema: chunkDIX6JWN4_cjs.workflowExecutionResultSchema,
386
+ bodySchema: chunkTF7NSMHW_cjs.startAsyncWorkflowBodySchema,
387
+ responseSchema: chunkTF7NSMHW_cjs.workflowExecutionResultSchema,
396
388
  summary: "Start workflow asynchronously",
397
389
  description: "Starts a workflow execution asynchronously without streaming results",
398
390
  tags: ["Workflows"],
399
391
  requiresAuth: true,
400
392
  handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {
401
393
  try {
402
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, resourceId);
394
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, resourceId);
403
395
  if (!workflowId) {
404
396
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
405
397
  }
@@ -419,17 +411,17 @@ var START_WORKFLOW_RUN_ROUTE = chunk5UKYK7YK_cjs.createRoute({
419
411
  method: "POST",
420
412
  path: "/workflows/:workflowId/start",
421
413
  responseType: "json",
422
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
414
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
423
415
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
424
- bodySchema: chunkDIX6JWN4_cjs.startAsyncWorkflowBodySchema,
425
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
416
+ bodySchema: chunkTF7NSMHW_cjs.startAsyncWorkflowBodySchema,
417
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
426
418
  summary: "Start specific workflow run",
427
419
  description: "Starts execution of a specific workflow run by ID",
428
420
  tags: ["Workflows"],
429
421
  requiresAuth: true,
430
422
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
431
423
  try {
432
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
424
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
433
425
  if (!workflowId) {
434
426
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
435
427
  }
@@ -444,7 +436,7 @@ var START_WORKFLOW_RUN_ROUTE = chunk5UKYK7YK_cjs.createRoute({
444
436
  if (!run) {
445
437
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
446
438
  }
447
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
439
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
448
440
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
449
441
  void _run.start({
450
442
  ...params,
@@ -460,16 +452,16 @@ var OBSERVE_STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
460
452
  method: "POST",
461
453
  path: "/workflows/:workflowId/observe",
462
454
  responseType: "stream",
463
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
464
- queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
465
- responseSchema: chunkXT6GKIYW_cjs.streamResponseSchema,
455
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
456
+ queryParamSchema: chunkTF7NSMHW_cjs.observeWorkflowQuerySchema,
457
+ responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
466
458
  summary: "Observe workflow stream",
467
- description: "Observes and streams updates from an already running workflow execution",
459
+ description: "Observes and streams updates from an already running workflow execution. Supports position-based resume with offset for efficient reconnection.",
468
460
  tags: ["Workflows"],
469
461
  requiresAuth: true,
470
- handler: async ({ mastra, workflowId, runId, requestContext }) => {
462
+ handler: async ({ mastra, workflowId, runId, offset, requestContext }) => {
471
463
  try {
472
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
464
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
473
465
  if (!workflowId) {
474
466
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
475
467
  }
@@ -484,46 +476,19 @@ var OBSERVE_STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
484
476
  if (!run) {
485
477
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
486
478
  }
487
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
479
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
488
480
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
489
481
  const serverCache = mastra.getServerCache();
490
482
  if (!serverCache) {
491
483
  throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Server cache not found" });
492
484
  }
493
- const cachedRunChunks = await serverCache.listFromTo(runId, 0);
494
- const combinedStream = new web.ReadableStream({
495
- start(controller) {
496
- const emitCachedChunks = async () => {
497
- for (const chunk of cachedRunChunks) {
498
- controller.enqueue(chunk);
499
- }
500
- };
501
- const liveStream = _run.observeStream();
502
- const reader = liveStream.getReader();
503
- const pump = async () => {
504
- try {
505
- while (true) {
506
- const { done, value } = await reader.read();
507
- if (done) {
508
- controller.close();
509
- break;
510
- }
511
- controller.enqueue(value);
512
- }
513
- } catch (error) {
514
- controller.error(error);
515
- } finally {
516
- reader.releaseLock();
517
- }
518
- };
519
- void emitCachedChunks().then(() => {
520
- void pump();
521
- }).catch((error) => {
522
- controller.error(error);
523
- });
524
- }
485
+ const startIndex = offset ?? 0;
486
+ const cachedRunChunks = await serverCache.listFromTo(runId, startIndex);
487
+ const liveStream = _run.observeStream();
488
+ return stream.createReplayStream({
489
+ history: cachedRunChunks,
490
+ liveSource: liveStream
525
491
  });
526
- return combinedStream;
527
492
  } catch (error) {
528
493
  return chunkB34S64RC_cjs.handleError(error, "Error observing workflow stream");
529
494
  }
@@ -533,17 +498,17 @@ var RESUME_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
533
498
  method: "POST",
534
499
  path: "/workflows/:workflowId/resume-async",
535
500
  responseType: "json",
536
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
501
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
537
502
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
538
- bodySchema: chunkDIX6JWN4_cjs.resumeBodySchema,
539
- responseSchema: chunkDIX6JWN4_cjs.workflowExecutionResultSchema,
503
+ bodySchema: chunkTF7NSMHW_cjs.resumeBodySchema,
504
+ responseSchema: chunkTF7NSMHW_cjs.workflowExecutionResultSchema,
540
505
  summary: "Resume workflow asynchronously",
541
506
  description: "Resumes a suspended workflow execution asynchronously without streaming",
542
507
  tags: ["Workflows"],
543
508
  requiresAuth: true,
544
509
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
545
510
  try {
546
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
511
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
547
512
  if (!workflowId) {
548
513
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
549
514
  }
@@ -558,7 +523,7 @@ var RESUME_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
558
523
  if (!run) {
559
524
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
560
525
  }
561
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
526
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
562
527
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
563
528
  const result = await _run.resume({ ...params, requestContext });
564
529
  return result;
@@ -571,17 +536,17 @@ var RESUME_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
571
536
  method: "POST",
572
537
  path: "/workflows/:workflowId/resume",
573
538
  responseType: "json",
574
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
539
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
575
540
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
576
- bodySchema: chunkDIX6JWN4_cjs.resumeBodySchema,
577
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
541
+ bodySchema: chunkTF7NSMHW_cjs.resumeBodySchema,
542
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
578
543
  summary: "Resume workflow",
579
544
  description: "Resumes a suspended workflow execution from a specific step",
580
545
  tags: ["Workflows"],
581
546
  requiresAuth: true,
582
547
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
583
548
  try {
584
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
549
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
585
550
  if (!workflowId) {
586
551
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
587
552
  }
@@ -596,7 +561,7 @@ var RESUME_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
596
561
  if (!run) {
597
562
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
598
563
  }
599
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
564
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
600
565
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
601
566
  void _run.resume({ ...params, requestContext });
602
567
  return { message: "Workflow run resumed" };
@@ -609,17 +574,17 @@ var RESTART_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
609
574
  method: "POST",
610
575
  path: "/workflows/:workflowId/restart-async",
611
576
  responseType: "json",
612
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
577
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
613
578
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
614
- bodySchema: chunkDIX6JWN4_cjs.restartBodySchema,
615
- responseSchema: chunkDIX6JWN4_cjs.workflowExecutionResultSchema,
579
+ bodySchema: chunkTF7NSMHW_cjs.restartBodySchema,
580
+ responseSchema: chunkTF7NSMHW_cjs.workflowExecutionResultSchema,
616
581
  summary: "Restart workflow asynchronously",
617
582
  description: "Restarts an active workflow execution asynchronously",
618
583
  tags: ["Workflows"],
619
584
  requiresAuth: true,
620
585
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
621
586
  try {
622
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
587
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
623
588
  if (!workflowId) {
624
589
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
625
590
  }
@@ -634,7 +599,7 @@ var RESTART_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
634
599
  if (!run) {
635
600
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
636
601
  }
637
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
602
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
638
603
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
639
604
  const result = await _run.restart({ ...params, requestContext });
640
605
  return result;
@@ -647,17 +612,17 @@ var RESTART_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
647
612
  method: "POST",
648
613
  path: "/workflows/:workflowId/restart",
649
614
  responseType: "json",
650
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
615
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
651
616
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
652
- bodySchema: chunkDIX6JWN4_cjs.restartBodySchema,
653
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
617
+ bodySchema: chunkTF7NSMHW_cjs.restartBodySchema,
618
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
654
619
  summary: "Restart workflow",
655
620
  description: "Restarts an active workflow execution",
656
621
  tags: ["Workflows"],
657
622
  requiresAuth: true,
658
623
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
659
624
  try {
660
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
625
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
661
626
  if (!workflowId) {
662
627
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
663
628
  }
@@ -672,7 +637,7 @@ var RESTART_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
672
637
  if (!run) {
673
638
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
674
639
  }
675
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
640
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
676
641
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
677
642
  void _run.restart({ ...params, requestContext });
678
643
  return { message: "Workflow run restarted" };
@@ -685,8 +650,8 @@ var RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = chunk5UKYK7YK_cjs.createRoute
685
650
  method: "POST",
686
651
  path: "/workflows/:workflowId/restart-all-active-workflow-runs-async",
687
652
  responseType: "json",
688
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
689
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
653
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
654
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
690
655
  summary: "Restart all active workflow runs asynchronously",
691
656
  description: "Restarts all active workflow runs asynchronously",
692
657
  tags: ["Workflows"],
@@ -711,8 +676,8 @@ var RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = chunk5UKYK7YK_cjs.createRoute({
711
676
  method: "POST",
712
677
  path: "/workflows/:workflowId/restart-all-active-workflow-runs",
713
678
  responseType: "json",
714
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
715
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
679
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
680
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
716
681
  summary: "Restart all active workflow runs",
717
682
  description: "Restarts all active workflow runs",
718
683
  tags: ["Workflows"],
@@ -737,17 +702,17 @@ var TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
737
702
  method: "POST",
738
703
  path: "/workflows/:workflowId/time-travel-async",
739
704
  responseType: "json",
740
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
705
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
741
706
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
742
- bodySchema: chunkDIX6JWN4_cjs.timeTravelBodySchema,
743
- responseSchema: chunkDIX6JWN4_cjs.workflowExecutionResultSchema,
707
+ bodySchema: chunkTF7NSMHW_cjs.timeTravelBodySchema,
708
+ responseSchema: chunkTF7NSMHW_cjs.workflowExecutionResultSchema,
744
709
  summary: "Time travel workflow asynchronously",
745
710
  description: "Time travels a workflow run asynchronously without streaming",
746
711
  tags: ["Workflows"],
747
712
  requiresAuth: true,
748
713
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
749
714
  try {
750
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
715
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
751
716
  if (!workflowId) {
752
717
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
753
718
  }
@@ -762,7 +727,7 @@ var TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
762
727
  if (!run) {
763
728
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
764
729
  }
765
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
730
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
766
731
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
767
732
  const result = await _run.timeTravel({ ...params, requestContext });
768
733
  return result;
@@ -775,17 +740,17 @@ var TIME_TRAVEL_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
775
740
  method: "POST",
776
741
  path: "/workflows/:workflowId/time-travel",
777
742
  responseType: "json",
778
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
743
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
779
744
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
780
- bodySchema: chunkDIX6JWN4_cjs.timeTravelBodySchema,
781
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
745
+ bodySchema: chunkTF7NSMHW_cjs.timeTravelBodySchema,
746
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
782
747
  summary: "Time travel workflow",
783
748
  description: "Time travels a workflow run, starting from a specific step",
784
749
  tags: ["Workflows"],
785
750
  requiresAuth: true,
786
751
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
787
752
  try {
788
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
753
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
789
754
  if (!workflowId) {
790
755
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
791
756
  }
@@ -800,7 +765,7 @@ var TIME_TRAVEL_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
800
765
  if (!run) {
801
766
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
802
767
  }
803
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
768
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
804
769
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
805
770
  void _run.timeTravel({ ...params, requestContext });
806
771
  return { message: "Workflow run time travel started" };
@@ -813,16 +778,16 @@ var TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
813
778
  method: "POST",
814
779
  path: "/workflows/:workflowId/time-travel-stream",
815
780
  responseType: "stream",
816
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
781
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
817
782
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
818
- bodySchema: chunkDIX6JWN4_cjs.timeTravelBodySchema,
783
+ bodySchema: chunkTF7NSMHW_cjs.timeTravelBodySchema,
819
784
  summary: "Time travel workflow stream",
820
785
  description: "Time travels a workflow run, starting from a specific step, and streams the results in real-time",
821
786
  tags: ["Workflows"],
822
787
  requiresAuth: true,
823
788
  handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
824
789
  try {
825
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
790
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
826
791
  if (!workflowId) {
827
792
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
828
793
  }
@@ -837,22 +802,18 @@ var TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
837
802
  if (!existingRun) {
838
803
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
839
804
  }
840
- await chunkLWK57QIA_cjs.validateRunOwnership(existingRun, effectiveResourceId);
805
+ await chunk2CFH32YO_cjs.validateRunOwnership(existingRun, effectiveResourceId);
841
806
  const serverCache = mastra.getServerCache();
842
807
  const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });
843
808
  const result = run.timeTravelStream({ ...params, requestContext });
844
- return result.fullStream.pipeThrough(
845
- new web.TransformStream({
846
- transform(chunk, controller) {
847
- if (serverCache) {
848
- const cacheKey = runId;
849
- serverCache.listPush(cacheKey, chunk).catch(() => {
850
- });
851
- }
852
- controller.enqueue(chunk);
853
- }
854
- })
855
- );
809
+ if (serverCache) {
810
+ const { transform } = stream.createCachingTransformStream({
811
+ cache: serverCache,
812
+ cacheKey: runId
813
+ });
814
+ return result.fullStream.pipeThrough(transform);
815
+ }
816
+ return result.fullStream;
856
817
  } catch (error) {
857
818
  return chunkB34S64RC_cjs.handleError(error, "Error time traveling workflow stream");
858
819
  }
@@ -862,15 +823,15 @@ var CANCEL_WORKFLOW_RUN_ROUTE = chunk5UKYK7YK_cjs.createRoute({
862
823
  method: "POST",
863
824
  path: "/workflows/:workflowId/runs/:runId/cancel",
864
825
  responseType: "json",
865
- pathParamSchema: chunkDIX6JWN4_cjs.workflowRunPathParams,
866
- responseSchema: chunkDIX6JWN4_cjs.workflowControlResponseSchema,
826
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowRunPathParams,
827
+ responseSchema: chunkTF7NSMHW_cjs.workflowControlResponseSchema,
867
828
  summary: "Cancel workflow run",
868
829
  description: "Cancels an in-progress workflow execution",
869
830
  tags: ["Workflows"],
870
831
  requiresAuth: true,
871
832
  handler: async ({ mastra, workflowId, runId, requestContext }) => {
872
833
  try {
873
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
834
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
874
835
  if (!workflowId) {
875
836
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
876
837
  }
@@ -885,7 +846,7 @@ var CANCEL_WORKFLOW_RUN_ROUTE = chunk5UKYK7YK_cjs.createRoute({
885
846
  if (!run) {
886
847
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
887
848
  }
888
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
849
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
889
850
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
890
851
  await _run.cancel();
891
852
  return { message: "Workflow run cancelled" };
@@ -898,17 +859,17 @@ var STREAM_LEGACY_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
898
859
  method: "POST",
899
860
  path: "/workflows/:workflowId/stream-legacy",
900
861
  responseType: "stream",
901
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
862
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
902
863
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
903
- bodySchema: chunkDIX6JWN4_cjs.streamWorkflowBodySchema,
904
- responseSchema: chunkXT6GKIYW_cjs.streamResponseSchema,
864
+ bodySchema: chunkTF7NSMHW_cjs.streamWorkflowBodySchema,
865
+ responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
905
866
  summary: "[DEPRECATED] Stream workflow with legacy format",
906
867
  description: "Legacy endpoint for streaming workflow execution. Use /workflows/:workflowId/stream instead.",
907
868
  tags: ["Workflows", "Legacy"],
908
869
  requiresAuth: true,
909
870
  handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {
910
871
  try {
911
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, resourceId);
872
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, resourceId);
912
873
  if (!workflowId) {
913
874
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
914
875
  }
@@ -941,16 +902,16 @@ var OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
941
902
  method: "POST",
942
903
  path: "/workflows/:workflowId/observe-stream-legacy",
943
904
  responseType: "stream",
944
- pathParamSchema: chunkDIX6JWN4_cjs.workflowIdPathParams,
905
+ pathParamSchema: chunkTF7NSMHW_cjs.workflowIdPathParams,
945
906
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
946
- responseSchema: chunkXT6GKIYW_cjs.streamResponseSchema,
907
+ responseSchema: chunkGUWIV3ZN_cjs.streamResponseSchema,
947
908
  summary: "[DEPRECATED] Observe workflow stream with legacy format",
948
909
  description: "Legacy endpoint for observing workflow stream. Use /workflows/:workflowId/observe instead.",
949
910
  tags: ["Workflows", "Legacy"],
950
911
  requiresAuth: true,
951
912
  handler: async ({ mastra, workflowId, runId, requestContext }) => {
952
913
  try {
953
- const effectiveResourceId = chunkLWK57QIA_cjs.getEffectiveResourceId(requestContext, void 0);
914
+ const effectiveResourceId = chunk2CFH32YO_cjs.getEffectiveResourceId(requestContext, void 0);
954
915
  if (!workflowId) {
955
916
  throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
956
917
  }
@@ -965,21 +926,21 @@ var OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = chunk5UKYK7YK_cjs.createRoute({
965
926
  if (!run) {
966
927
  throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
967
928
  }
968
- await chunkLWK57QIA_cjs.validateRunOwnership(run, effectiveResourceId);
929
+ await chunk2CFH32YO_cjs.validateRunOwnership(run, effectiveResourceId);
969
930
  const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
970
931
  const serverCache = mastra.getServerCache();
971
932
  if (!serverCache) {
972
933
  throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Server cache not found" });
973
934
  }
974
- const transformStream = new web.TransformStream();
975
- const writer = transformStream.writable.getWriter();
976
935
  const cachedRunChunks = await serverCache.listFromTo(runId, 0);
977
- for (const chunk of cachedRunChunks) {
978
- await writer.write(chunk);
979
- }
980
- writer.releaseLock();
981
936
  const result = _run.observeStreamLegacy();
982
- return result.stream?.pipeThrough(transformStream);
937
+ if (!result.stream) {
938
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Failed to create observe stream" });
939
+ }
940
+ return stream.createReplayStream({
941
+ history: cachedRunChunks,
942
+ liveSource: result.stream
943
+ });
983
944
  } catch (error) {
984
945
  return chunkB34S64RC_cjs.handleError(error, "Error observing workflow stream");
985
946
  }
@@ -1010,5 +971,5 @@ exports.TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE;
1010
971
  exports.TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = TIME_TRAVEL_STREAM_WORKFLOW_ROUTE;
1011
972
  exports.TIME_TRAVEL_WORKFLOW_ROUTE = TIME_TRAVEL_WORKFLOW_ROUTE;
1012
973
  exports.workflows_exports = workflows_exports;
1013
- //# sourceMappingURL=chunk-R4DZSQYI.cjs.map
1014
- //# sourceMappingURL=chunk-R4DZSQYI.cjs.map
974
+ //# sourceMappingURL=chunk-Y2SA2JZT.cjs.map
975
+ //# sourceMappingURL=chunk-Y2SA2JZT.cjs.map