@mastra/server 0.0.0-fix-multi-modal-for-cloud-20251028082043 → 0.0.0-fix-persist-session-cache-option-mcp-server-20251030171242

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 (114) hide show
  1. package/CHANGELOG.md +35 -3
  2. package/README.md +1 -1
  3. package/dist/{chunk-AHB4JCIQ.js → chunk-2XD2KQEK.js} +13 -13
  4. package/dist/chunk-2XD2KQEK.js.map +1 -0
  5. package/dist/{chunk-AW5BU3RQ.js → chunk-36CWLQQT.js} +19 -19
  6. package/dist/chunk-36CWLQQT.js.map +1 -0
  7. package/dist/{chunk-KDUHLUK4.cjs → chunk-4BKR6543.cjs} +128 -208
  8. package/dist/chunk-4BKR6543.cjs.map +1 -0
  9. package/dist/{chunk-7HCPO76Z.js → chunk-4YFT3JFJ.js} +107 -192
  10. package/dist/chunk-4YFT3JFJ.js.map +1 -0
  11. package/dist/{chunk-KSFLUEWV.js → chunk-6562SOHJ.js} +4 -4
  12. package/dist/{chunk-KSFLUEWV.js.map → chunk-6562SOHJ.js.map} +1 -1
  13. package/dist/{chunk-SPRRK3P7.cjs → chunk-6IGZKIRM.cjs} +19 -19
  14. package/dist/chunk-6IGZKIRM.cjs.map +1 -0
  15. package/dist/{chunk-QQXMIP6C.js → chunk-74ZF4DII.js} +10 -10
  16. package/dist/{chunk-QQXMIP6C.js.map → chunk-74ZF4DII.js.map} +1 -1
  17. package/dist/{chunk-ABRFV4XP.js → chunk-7KNKINQE.js} +11 -11
  18. package/dist/chunk-7KNKINQE.js.map +1 -0
  19. package/dist/{chunk-6VPAV4ZV.js → chunk-7MCHFMDF.js} +102 -129
  20. package/dist/chunk-7MCHFMDF.js.map +1 -0
  21. package/dist/{chunk-3SNGNFUJ.cjs → chunk-7YHMDEQ6.cjs} +10 -10
  22. package/dist/{chunk-3SNGNFUJ.cjs.map → chunk-7YHMDEQ6.cjs.map} +1 -1
  23. package/dist/{chunk-TRGAMKHX.cjs → chunk-BMOVKZO7.cjs} +19 -19
  24. package/dist/chunk-BMOVKZO7.cjs.map +1 -0
  25. package/dist/{chunk-OGK26QPW.js → chunk-CXVOX4WB.js} +41 -65
  26. package/dist/chunk-CXVOX4WB.js.map +1 -0
  27. package/dist/{chunk-LF2ZLOFP.js → chunk-GQRJOUV7.js} +64 -34
  28. package/dist/chunk-GQRJOUV7.js.map +1 -0
  29. package/dist/{chunk-YSHNCC6F.cjs → chunk-HLIRV42R.cjs} +109 -137
  30. package/dist/chunk-HLIRV42R.cjs.map +1 -0
  31. package/dist/{chunk-Y7SH5ZKM.cjs → chunk-LROVQBIB.cjs} +41 -66
  32. package/dist/chunk-LROVQBIB.cjs.map +1 -0
  33. package/dist/{chunk-GU4EWMZB.cjs → chunk-LZKJT7QP.cjs} +64 -34
  34. package/dist/chunk-LZKJT7QP.cjs.map +1 -0
  35. package/dist/{chunk-MN2TZQ7I.js → chunk-OEW3R7V4.js} +13 -13
  36. package/dist/chunk-OEW3R7V4.js.map +1 -0
  37. package/dist/{chunk-B7QWVGQQ.cjs → chunk-PUYDRTPG.cjs} +49 -58
  38. package/dist/chunk-PUYDRTPG.cjs.map +1 -0
  39. package/dist/{chunk-ZLBL4NQC.js → chunk-S4IOWSI3.js} +45 -54
  40. package/dist/chunk-S4IOWSI3.js.map +1 -0
  41. package/dist/{chunk-K5T5A3AL.cjs → chunk-SED4H2GJ.cjs} +14 -14
  42. package/dist/chunk-SED4H2GJ.cjs.map +1 -0
  43. package/dist/{chunk-XN74I6VW.cjs → chunk-WH5RPLO4.cjs} +13 -13
  44. package/dist/chunk-WH5RPLO4.cjs.map +1 -0
  45. package/dist/{chunk-CJFKRVED.cjs → chunk-YNGDJJOH.cjs} +14 -14
  46. package/dist/{chunk-CJFKRVED.cjs.map → chunk-YNGDJJOH.cjs.map} +1 -1
  47. package/dist/server/handlers/a2a.cjs +7 -7
  48. package/dist/server/handlers/a2a.d.ts +10 -10
  49. package/dist/server/handlers/a2a.d.ts.map +1 -1
  50. package/dist/server/handlers/a2a.js +1 -1
  51. package/dist/server/handlers/agent-builder.cjs +36 -16
  52. package/dist/server/handlers/agent-builder.d.ts +22 -6
  53. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  54. package/dist/server/handlers/agent-builder.js +1 -1
  55. package/dist/server/handlers/agents.cjs +25 -29
  56. package/dist/server/handlers/agents.d.ts +34 -47
  57. package/dist/server/handlers/agents.d.ts.map +1 -1
  58. package/dist/server/handlers/agents.js +1 -1
  59. package/dist/server/handlers/logs.cjs +7 -7
  60. package/dist/server/handlers/logs.d.ts +3 -3
  61. package/dist/server/handlers/logs.d.ts.map +1 -1
  62. package/dist/server/handlers/logs.js +1 -1
  63. package/dist/server/handlers/memory.cjs +17 -21
  64. package/dist/server/handlers/memory.d.ts +18 -21
  65. package/dist/server/handlers/memory.d.ts.map +1 -1
  66. package/dist/server/handlers/memory.js +1 -1
  67. package/dist/server/handlers/scores.cjs +10 -10
  68. package/dist/server/handlers/scores.d.ts +8 -8
  69. package/dist/server/handlers/scores.d.ts.map +1 -1
  70. package/dist/server/handlers/scores.js +1 -1
  71. package/dist/server/handlers/tools.cjs +7 -7
  72. package/dist/server/handlers/tools.d.ts +8 -8
  73. package/dist/server/handlers/tools.d.ts.map +1 -1
  74. package/dist/server/handlers/tools.js +1 -1
  75. package/dist/server/handlers/voice.cjs +5 -5
  76. package/dist/server/handlers/voice.d.ts +6 -6
  77. package/dist/server/handlers/voice.js +1 -1
  78. package/dist/server/handlers/workflows.cjs +23 -23
  79. package/dist/server/handlers/workflows.d.ts +19 -19
  80. package/dist/server/handlers/workflows.d.ts.map +1 -1
  81. package/dist/server/handlers/workflows.js +1 -1
  82. package/dist/server/handlers.cjs +19 -24
  83. package/dist/server/handlers.d.ts +0 -1
  84. package/dist/server/handlers.d.ts.map +1 -1
  85. package/dist/server/handlers.js +9 -10
  86. package/package.json +6 -6
  87. package/dist/chunk-6VPAV4ZV.js.map +0 -1
  88. package/dist/chunk-7HCPO76Z.js.map +0 -1
  89. package/dist/chunk-ABRFV4XP.js.map +0 -1
  90. package/dist/chunk-AHB4JCIQ.js.map +0 -1
  91. package/dist/chunk-AW5BU3RQ.js.map +0 -1
  92. package/dist/chunk-B7QWVGQQ.cjs.map +0 -1
  93. package/dist/chunk-GU4EWMZB.cjs.map +0 -1
  94. package/dist/chunk-I3C4ODGV.cjs +0 -335
  95. package/dist/chunk-I3C4ODGV.cjs.map +0 -1
  96. package/dist/chunk-K5T5A3AL.cjs.map +0 -1
  97. package/dist/chunk-KDUHLUK4.cjs.map +0 -1
  98. package/dist/chunk-LF2ZLOFP.js.map +0 -1
  99. package/dist/chunk-LLUOPR3J.js +0 -323
  100. package/dist/chunk-LLUOPR3J.js.map +0 -1
  101. package/dist/chunk-MN2TZQ7I.js.map +0 -1
  102. package/dist/chunk-OGK26QPW.js.map +0 -1
  103. package/dist/chunk-SPRRK3P7.cjs.map +0 -1
  104. package/dist/chunk-TRGAMKHX.cjs.map +0 -1
  105. package/dist/chunk-XN74I6VW.cjs.map +0 -1
  106. package/dist/chunk-Y7SH5ZKM.cjs.map +0 -1
  107. package/dist/chunk-YSHNCC6F.cjs.map +0 -1
  108. package/dist/chunk-ZLBL4NQC.js.map +0 -1
  109. package/dist/server/handlers/legacyWorkflows.cjs +0 -48
  110. package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
  111. package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
  112. package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
  113. package/dist/server/handlers/legacyWorkflows.js +0 -3
  114. package/dist/server/handlers/legacyWorkflows.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkCJFKRVED_cjs = require('./chunk-CJFKRVED.cjs');
3
+ var chunkYNGDJJOH_cjs = require('./chunk-YNGDJJOH.cjs');
4
4
  var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
5
5
  var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
6
6
  var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
@@ -14,8 +14,8 @@ chunkO7I5CWRX_cjs.__export(workflows_exports, {
14
14
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
15
15
  getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
16
16
  getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
17
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
18
- getWorkflowsHandler: () => getWorkflowsHandler,
17
+ listWorkflowRunsHandler: () => listWorkflowRunsHandler,
18
+ listWorkflowsHandler: () => listWorkflowsHandler,
19
19
  observeStreamLegacyWorkflowHandler: () => observeStreamLegacyWorkflowHandler,
20
20
  observeStreamVNextWorkflowHandler: () => observeStreamVNextWorkflowHandler,
21
21
  observeStreamWorkflowHandler: () => observeStreamWorkflowHandler,
@@ -30,11 +30,11 @@ chunkO7I5CWRX_cjs.__export(workflows_exports, {
30
30
  streamWorkflowHandler: () => streamWorkflowHandler,
31
31
  watchWorkflowHandler: () => watchWorkflowHandler
32
32
  });
33
- async function getWorkflowsHandler({ mastra }) {
33
+ async function listWorkflowsHandler({ mastra }) {
34
34
  try {
35
- const workflows = mastra.getWorkflows({ serialized: false });
35
+ const workflows = mastra.listWorkflows({ serialized: false });
36
36
  const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
37
- acc[key] = chunkCJFKRVED_cjs.getWorkflowInfo(workflow);
37
+ acc[key] = chunkYNGDJJOH_cjs.getWorkflowInfo(workflow);
38
38
  return acc;
39
39
  }, {});
40
40
  return _workflows;
@@ -42,13 +42,13 @@ async function getWorkflowsHandler({ mastra }) {
42
42
  return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflows");
43
43
  }
44
44
  }
45
- async function getWorkflowsFromSystem({ mastra, workflowId }) {
45
+ async function listWorkflowsFromSystem({ mastra, workflowId }) {
46
46
  const logger = mastra.getLogger();
47
47
  if (!workflowId) {
48
48
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
49
49
  }
50
50
  let workflow;
51
- workflow = chunkCJFKRVED_cjs.WorkflowRegistry.getWorkflow(workflowId);
51
+ workflow = chunkYNGDJJOH_cjs.WorkflowRegistry.getWorkflow(workflowId);
52
52
  if (!workflow) {
53
53
  try {
54
54
  workflow = mastra.getWorkflow(workflowId);
@@ -58,11 +58,11 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
58
58
  }
59
59
  if (!workflow) {
60
60
  logger.debug("Workflow not found, searching agents for workflow", { workflowId });
61
- const agents = mastra.getAgents();
61
+ const agents = mastra.listAgents();
62
62
  if (Object.keys(agents || {}).length) {
63
63
  for (const [_, agent] of Object.entries(agents)) {
64
64
  try {
65
- const workflows = await agent.getWorkflows();
65
+ const workflows = await agent.listWorkflows();
66
66
  if (workflows[workflowId]) {
67
67
  workflow = workflows[workflowId];
68
68
  break;
@@ -84,11 +84,11 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
84
84
  if (!workflowId) {
85
85
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
86
86
  }
87
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
87
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
88
88
  if (!workflow) {
89
89
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
90
90
  }
91
- return chunkCJFKRVED_cjs.getWorkflowInfo(workflow);
91
+ return chunkYNGDJJOH_cjs.getWorkflowInfo(workflow);
92
92
  } catch (error) {
93
93
  return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow");
94
94
  }
@@ -105,7 +105,7 @@ async function getWorkflowRunByIdHandler({
105
105
  if (!runId) {
106
106
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
107
107
  }
108
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
108
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
109
109
  if (!workflow) {
110
110
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
111
111
  }
@@ -152,7 +152,7 @@ async function createWorkflowRunHandler({
152
152
  if (!workflowId) {
153
153
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
154
154
  }
155
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
155
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
156
156
  if (!workflow) {
157
157
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
158
158
  }
@@ -164,7 +164,7 @@ async function createWorkflowRunHandler({
164
164
  }
165
165
  async function startAsyncWorkflowHandler({
166
166
  mastra,
167
- runtimeContext,
167
+ requestContext,
168
168
  workflowId,
169
169
  runId,
170
170
  inputData,
@@ -174,14 +174,14 @@ async function startAsyncWorkflowHandler({
174
174
  if (!workflowId) {
175
175
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
176
176
  }
177
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
177
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
178
178
  if (!workflow) {
179
179
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
180
180
  }
181
181
  const _run = await workflow.createRunAsync({ runId });
182
182
  const result = await _run.start({
183
183
  inputData,
184
- runtimeContext,
184
+ requestContext,
185
185
  tracingOptions
186
186
  });
187
187
  return result;
@@ -191,7 +191,7 @@ async function startAsyncWorkflowHandler({
191
191
  }
192
192
  async function startWorkflowRunHandler({
193
193
  mastra,
194
- runtimeContext,
194
+ requestContext,
195
195
  workflowId,
196
196
  runId,
197
197
  inputData,
@@ -204,7 +204,7 @@ async function startWorkflowRunHandler({
204
204
  if (!runId) {
205
205
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to start run" });
206
206
  }
207
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
207
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
208
208
  if (!workflow) {
209
209
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
210
210
  }
@@ -215,7 +215,7 @@ async function startWorkflowRunHandler({
215
215
  const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
216
216
  void _run.start({
217
217
  inputData,
218
- runtimeContext,
218
+ requestContext,
219
219
  tracingOptions
220
220
  });
221
221
  return { message: "Workflow run started" };
@@ -236,7 +236,7 @@ async function watchWorkflowHandler({
236
236
  if (!runId) {
237
237
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to watch workflow" });
238
238
  }
239
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
239
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
240
240
  if (!workflow) {
241
241
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
242
242
  }
@@ -298,17 +298,17 @@ async function watchWorkflowHandler({
298
298
  }
299
299
  async function streamWorkflowHandler({
300
300
  mastra,
301
- runtimeContext,
301
+ requestContext,
302
302
  workflowId,
303
303
  runId,
304
304
  inputData,
305
305
  tracingOptions
306
306
  }) {
307
- return streamVNextWorkflowHandler({ mastra, workflowId, runId, inputData, runtimeContext, tracingOptions });
307
+ return streamVNextWorkflowHandler({ mastra, workflowId, runId, inputData, requestContext, tracingOptions });
308
308
  }
309
309
  async function streamLegacyWorkflowHandler({
310
310
  mastra,
311
- runtimeContext,
311
+ requestContext,
312
312
  workflowId,
313
313
  runId,
314
314
  inputData,
@@ -321,7 +321,7 @@ async function streamLegacyWorkflowHandler({
321
321
  if (!runId) {
322
322
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
323
323
  }
324
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
324
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
325
325
  if (!workflow) {
326
326
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
327
327
  }
@@ -329,7 +329,7 @@ async function streamLegacyWorkflowHandler({
329
329
  const run = await workflow.createRunAsync({ runId });
330
330
  const result = run.streamLegacy({
331
331
  inputData,
332
- runtimeContext,
332
+ requestContext,
333
333
  onChunk: async (chunk) => {
334
334
  if (serverCache) {
335
335
  const cacheKey = runId;
@@ -355,7 +355,7 @@ async function observeStreamLegacyWorkflowHandler({
355
355
  if (!runId) {
356
356
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
357
357
  }
358
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
358
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
359
359
  if (!workflow) {
360
360
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
361
361
  }
@@ -390,7 +390,7 @@ async function observeStreamWorkflowHandler({
390
390
  }
391
391
  async function streamVNextWorkflowHandler({
392
392
  mastra,
393
- runtimeContext,
393
+ requestContext,
394
394
  workflowId,
395
395
  runId,
396
396
  inputData,
@@ -404,7 +404,7 @@ async function streamVNextWorkflowHandler({
404
404
  if (!runId) {
405
405
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to stream workflow" });
406
406
  }
407
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
407
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
408
408
  if (!workflow) {
409
409
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
410
410
  }
@@ -412,7 +412,7 @@ async function streamVNextWorkflowHandler({
412
412
  const run = await workflow.createRunAsync({ runId });
413
413
  const result = run.stream({
414
414
  inputData,
415
- runtimeContext,
415
+ requestContext,
416
416
  closeOnSuspend,
417
417
  tracingOptions
418
418
  });
@@ -444,7 +444,7 @@ async function observeStreamVNextWorkflowHandler({
444
444
  if (!runId) {
445
445
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
446
446
  }
447
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
447
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
448
448
  if (!workflow) {
449
449
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
450
450
  }
@@ -500,7 +500,7 @@ async function resumeAsyncWorkflowHandler({
500
500
  workflowId,
501
501
  runId,
502
502
  body,
503
- runtimeContext,
503
+ requestContext,
504
504
  tracingOptions
505
505
  }) {
506
506
  try {
@@ -510,10 +510,7 @@ async function resumeAsyncWorkflowHandler({
510
510
  if (!runId) {
511
511
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
512
512
  }
513
- if (!body.step) {
514
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
515
- }
516
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
513
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
517
514
  if (!workflow) {
518
515
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
519
516
  }
@@ -525,7 +522,7 @@ async function resumeAsyncWorkflowHandler({
525
522
  const result = await _run.resume({
526
523
  step: body.step,
527
524
  resumeData: body.resumeData,
528
- runtimeContext,
525
+ requestContext,
529
526
  tracingOptions
530
527
  });
531
528
  return result;
@@ -538,7 +535,7 @@ async function resumeWorkflowHandler({
538
535
  workflowId,
539
536
  runId,
540
537
  body,
541
- runtimeContext,
538
+ requestContext,
542
539
  tracingOptions
543
540
  }) {
544
541
  try {
@@ -548,10 +545,7 @@ async function resumeWorkflowHandler({
548
545
  if (!runId) {
549
546
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
550
547
  }
551
- if (!body.step) {
552
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
553
- }
554
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
548
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
555
549
  if (!workflow) {
556
550
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
557
551
  }
@@ -563,7 +557,7 @@ async function resumeWorkflowHandler({
563
557
  void _run.resume({
564
558
  step: body.step,
565
559
  resumeData: body.resumeData,
566
- runtimeContext,
560
+ requestContext,
567
561
  tracingOptions
568
562
  });
569
563
  return { message: "Workflow run resumed" };
@@ -576,7 +570,7 @@ async function resumeStreamWorkflowHandler({
576
570
  workflowId,
577
571
  runId,
578
572
  body,
579
- runtimeContext,
573
+ requestContext,
580
574
  tracingOptions
581
575
  }) {
582
576
  try {
@@ -586,10 +580,7 @@ async function resumeStreamWorkflowHandler({
586
580
  if (!runId) {
587
581
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
588
582
  }
589
- if (!body.step) {
590
- throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
591
- }
592
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
583
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
593
584
  if (!workflow) {
594
585
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
595
586
  }
@@ -602,7 +593,7 @@ async function resumeStreamWorkflowHandler({
602
593
  const stream = _run.resumeStream({
603
594
  step: body.step,
604
595
  resumeData: body.resumeData,
605
- runtimeContext,
596
+ requestContext,
606
597
  tracingOptions
607
598
  }).fullStream.pipeThrough(
608
599
  new web.TransformStream({
@@ -621,7 +612,7 @@ async function resumeStreamWorkflowHandler({
621
612
  return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
622
613
  }
623
614
  }
624
- async function getWorkflowRunsHandler({
615
+ async function listWorkflowRunsHandler({
625
616
  mastra,
626
617
  workflowId,
627
618
  fromDate,
@@ -634,11 +625,11 @@ async function getWorkflowRunsHandler({
634
625
  if (!workflowId) {
635
626
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
636
627
  }
637
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
628
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
638
629
  if (!workflow) {
639
630
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
640
631
  }
641
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
632
+ const workflowRuns = await workflow.listWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
642
633
  runs: [],
643
634
  total: 0
644
635
  };
@@ -659,7 +650,7 @@ async function cancelWorkflowRunHandler({
659
650
  if (!runId) {
660
651
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
661
652
  }
662
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
653
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
663
654
  if (!workflow) {
664
655
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
665
656
  }
@@ -688,7 +679,7 @@ async function sendWorkflowRunEventHandler({
688
679
  if (!runId) {
689
680
  throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
690
681
  }
691
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
682
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
692
683
  if (!workflow) {
693
684
  throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
694
685
  }
@@ -709,8 +700,8 @@ exports.createWorkflowRunHandler = createWorkflowRunHandler;
709
700
  exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
710
701
  exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
711
702
  exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
712
- exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
713
- exports.getWorkflowsHandler = getWorkflowsHandler;
703
+ exports.listWorkflowRunsHandler = listWorkflowRunsHandler;
704
+ exports.listWorkflowsHandler = listWorkflowsHandler;
714
705
  exports.observeStreamLegacyWorkflowHandler = observeStreamLegacyWorkflowHandler;
715
706
  exports.observeStreamVNextWorkflowHandler = observeStreamVNextWorkflowHandler;
716
707
  exports.observeStreamWorkflowHandler = observeStreamWorkflowHandler;
@@ -725,5 +716,5 @@ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
725
716
  exports.streamWorkflowHandler = streamWorkflowHandler;
726
717
  exports.watchWorkflowHandler = watchWorkflowHandler;
727
718
  exports.workflows_exports = workflows_exports;
728
- //# sourceMappingURL=chunk-B7QWVGQQ.cjs.map
729
- //# sourceMappingURL=chunk-B7QWVGQQ.cjs.map
719
+ //# sourceMappingURL=chunk-PUYDRTPG.cjs.map
720
+ //# sourceMappingURL=chunk-PUYDRTPG.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","getWorkflowInfo","handleError","HTTPException","WorkflowRegistry","ReadableStream","TransformStream"],"mappings":";;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,kCAAA,EAAA,MAAA,kCAAA;AAAA,EAAA,iCAAA,EAAA,MAAA,iCAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,uBAA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;AAEzE,IAAA,IAAI,CAAC,QAAA,EAAU;AACb,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,sBAAsB,CAAA;AAAA,IAChE;AAEA,IAAA,MAAM,GAAA,GAAM,MAAM,QAAA,CAAS,kBAAA,CAAmB,KAAK,CAAA;AAEnD,IAAA,IAAI,CAAC,GAAA,EAAK;AACR,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,IACpE;AAEA,IAAA,MAAM,IAAA,GAAO,MAAM,QAAA,CAAS,cAAA,CAAe,EAAE,KAAA,EAAO,UAAA,EAAY,GAAA,CAAI,UAAA,EAAY,CAAA;AAEhF,IAAA,MAAM,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,IAAI,CAAA;AAEhC,IAAA,OAAO,EAAE,SAAS,yBAAA,EAA0B;AAAA,EAC9C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,kCAAkC,CAAA;AAAA,EAC9D;AACF","file":"chunk-PUYDRTPG.cjs","sourcesContent":["import { ReadableStream, TransformStream } from 'node:stream/web';\nimport type { TracingOptions } from '@mastra/core/ai-tracing';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport type {\n Workflow,\n WatchEvent,\n WorkflowInfo,\n ChunkType,\n WorkflowStreamEvent,\n StreamEvent,\n} from '@mastra/core/workflows';\nimport { HTTPException } from '../http-exception';\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\nexport async function listWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.listWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\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.getWorkflow(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\nexport async function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowInfo> {\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 return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n}\n\nexport async function getWorkflowRunByIdHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>> {\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 const run = await workflow.getWorkflowRunById(runId);\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\nexport async function getWorkflowRunExecutionResultHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']> {\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 = mastra.getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId);\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n}\n\nexport async function createWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\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.createRunAsync({ runId: prevRunId });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n}\n\nexport async function startAsyncWorkflowHandler({\n mastra,\n requestContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\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.createRunAsync({ runId });\n const result = await _run.start({\n inputData,\n requestContext,\n tracingOptions,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n}\n\nexport async function startWorkflowRunHandler({\n mastra,\n requestContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\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.createRunAsync({ runId, resourceId: run.resourceId });\n void _run.start({\n inputData,\n requestContext,\n tracingOptions,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchWorkflowHandler({\n mastra,\n workflowId,\n runId,\n eventType = 'watch',\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n eventType?: 'watch' | 'watch-v2';\n}): Promise<ReadableStream<string>> {\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 watch 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.createRunAsync({ runId, resourceId: run.resourceId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n if (eventType === 'watch') {\n unwatch = _run.watch((event: WatchEvent) => {\n const { type, payload, eventTimestamp } = event;\n controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = (payload as WatchEvent['payload']).workflowState?.status !== 'running';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n }, eventType);\n } else {\n unwatch = _run.watch((event: WorkflowStreamEvent) => {\n const { type, payload } = event;\n controller.enqueue(JSON.stringify({ type, payload, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = type === 'workflow-finish';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n }, eventType);\n }\n },\n cancel() {\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function streamWorkflowHandler({\n mastra,\n requestContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\n return streamVNextWorkflowHandler({ mastra, workflowId, runId, inputData, requestContext, tracingOptions });\n}\n\nexport async function streamLegacyWorkflowHandler({\n mastra,\n requestContext,\n workflowId,\n runId,\n inputData,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\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.createRunAsync({ runId });\n const result = run.streamLegacy({\n inputData,\n requestContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n tracingOptions,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function observeStreamLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, '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.createRunAsync({ 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\nexport async function observeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n return observeStreamVNextWorkflowHandler({ mastra, workflowId, runId });\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n requestContext,\n workflowId,\n runId,\n inputData,\n closeOnSuspend,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n requestContext?: RequestContext;\n closeOnSuspend?: boolean;\n tracingOptions?: TracingOptions;\n}) {\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\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n requestContext,\n closeOnSuspend,\n tracingOptions,\n });\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\nexport async function observeStreamVNextWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, '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.createRunAsync({ 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\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n requestContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\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.createRunAsync({ runId, resourceId: run.resourceId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n requestContext,\n tracingOptions,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n requestContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\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.createRunAsync({ runId, resourceId: run.resourceId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n requestContext,\n tracingOptions,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function resumeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n requestContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n requestContext?: RequestContext;\n tracingOptions?: TracingOptions;\n}) {\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.createRunAsync({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const stream = _run\n .resumeStream({\n step: body.step,\n resumeData: body.resumeData,\n requestContext,\n tracingOptions,\n })\n .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\nexport async function listWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<WorkflowRuns> {\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 workflowRuns = (await workflow.listWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n\nexport async function cancelWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, '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.createRunAsync({ 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\nexport async function sendWorkflowRunEventHandler({\n mastra,\n workflowId,\n runId,\n event,\n data,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n event: string;\n data: unknown;\n}) {\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 send workflow run event' });\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.createRunAsync({ runId, resourceId: run.resourceId });\n\n await _run.sendEvent(event, data);\n\n return { message: 'Workflow run event sent' };\n } catch (error) {\n return handleError(error, 'Error sending workflow run event');\n }\n}\n"]}