@mastra/server 0.0.0-fix-memory-xxhash-20250409202110 → 0.0.0-generate-message-id-20250512171942

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 (75) hide show
  1. package/{LICENSE → LICENSE.md} +3 -1
  2. package/README.md +48 -135
  3. package/dist/_tsup-dts-rollup.d.cts +282 -34
  4. package/dist/_tsup-dts-rollup.d.ts +282 -34
  5. package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
  6. package/dist/chunk-3HQNCTZ2.cjs +199 -0
  7. package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
  8. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  9. package/dist/chunk-5SN4U5AC.cjs +508 -0
  10. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  11. package/dist/chunk-75ZPJI57.cjs +9 -0
  12. package/dist/{chunk-2YONKUWB.js → chunk-C7564HUT.js} +58 -33
  13. package/dist/{chunk-ILW7XYNJ.js → chunk-EJO45KYT.js} +51 -27
  14. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  15. package/dist/{chunk-3RVHWGWO.js → chunk-HFWCEP5S.js} +6 -12
  16. package/dist/{chunk-2JQC6JWP.js → chunk-HWZVAG3H.js} +7 -4
  17. package/dist/{chunk-X37I6GZT.cjs → chunk-I2B73Y4I.cjs} +92 -68
  18. package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
  19. package/dist/chunk-LIVAK2DM.js +2001 -0
  20. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  21. package/dist/{chunk-CWSDZEZG.cjs → chunk-MHKNLNAN.cjs} +15 -12
  22. package/dist/chunk-MIQYDLLM.js +329 -0
  23. package/dist/chunk-MLKGABMK.js +7 -0
  24. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  25. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  26. package/dist/{chunk-VB7KH62D.cjs → chunk-OGCNNUHF.cjs} +13 -10
  27. package/dist/{chunk-DVPP5S6I.js → chunk-OR3CIE2H.js} +9 -6
  28. package/dist/chunk-P6SCPDYW.js +500 -0
  29. package/dist/{chunk-BMA2ORRT.js → chunk-Q6KMBIAN.js} +76 -37
  30. package/dist/{chunk-YNSGUC2O.js → chunk-TJKLBTFB.js} +23 -7
  31. package/dist/chunk-UCTEMO2Q.cjs +341 -0
  32. package/dist/chunk-VPNDC2DI.cjs +148 -0
  33. package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
  34. package/dist/{chunk-A7DF4ETD.cjs → chunk-YBVOQN4M.cjs} +22 -28
  35. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  36. package/dist/{chunk-4C3EPMMF.cjs → chunk-ZE5AAC4I.cjs} +40 -24
  37. package/dist/server/handlers/a2a.cjs +30 -0
  38. package/dist/server/handlers/a2a.d.cts +6 -0
  39. package/dist/server/handlers/a2a.d.ts +6 -0
  40. package/dist/server/handlers/a2a.js +1 -0
  41. package/dist/server/handlers/agents.cjs +7 -7
  42. package/dist/server/handlers/agents.js +1 -1
  43. package/dist/server/handlers/error.cjs +2 -2
  44. package/dist/server/handlers/error.js +1 -1
  45. package/dist/server/handlers/logs.cjs +4 -4
  46. package/dist/server/handlers/logs.js +1 -1
  47. package/dist/server/handlers/memory.cjs +9 -9
  48. package/dist/server/handlers/memory.js +1 -1
  49. package/dist/server/handlers/network.cjs +5 -5
  50. package/dist/server/handlers/network.js +1 -1
  51. package/dist/server/handlers/telemetry.cjs +3 -3
  52. package/dist/server/handlers/telemetry.js +1 -1
  53. package/dist/server/handlers/tools.cjs +5 -5
  54. package/dist/server/handlers/tools.js +1 -1
  55. package/dist/server/handlers/utils.cjs +2 -2
  56. package/dist/server/handlers/utils.js +1 -1
  57. package/dist/server/handlers/vNextWorkflows.cjs +46 -0
  58. package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
  59. package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
  60. package/dist/server/handlers/vNextWorkflows.js +1 -0
  61. package/dist/server/handlers/vector.cjs +7 -7
  62. package/dist/server/handlers/vector.js +1 -1
  63. package/dist/server/handlers/voice.cjs +4 -4
  64. package/dist/server/handlers/voice.js +1 -1
  65. package/dist/server/handlers/workflows.cjs +11 -11
  66. package/dist/server/handlers/workflows.js +1 -1
  67. package/dist/server/handlers.cjs +31 -21
  68. package/dist/server/handlers.d.cts +2 -0
  69. package/dist/server/handlers.d.ts +2 -0
  70. package/dist/server/handlers.js +11 -9
  71. package/package.json +9 -7
  72. package/dist/chunk-5JOF627H.cjs +0 -123
  73. package/dist/chunk-GV52BII2.cjs +0 -160
  74. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  75. package/dist/chunk-VK6FX47H.js +0 -5576
@@ -1,6 +1,7 @@
1
- import { stringify, esm_default } from './chunk-VK6FX47H.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { stringify, esm_default } from './chunk-LIVAK2DM.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
4
5
  import { ReadableStream } from 'node:stream/web';
5
6
 
6
7
  // src/server/handlers/workflows.ts
@@ -32,7 +33,9 @@ async function getWorkflowsHandler({ mastra }) {
32
33
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
33
34
  const _step = step;
34
35
  acc2[key2] = {
35
- ..._step,
36
+ id: _step.id,
37
+ description: _step.description,
38
+ workflowId: _step.workflowId,
36
39
  inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
37
40
  outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
38
41
  };
@@ -65,7 +68,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
65
68
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
66
69
  const _step = step;
67
70
  acc[key] = {
68
- ..._step,
71
+ id: _step.id,
72
+ description: _step.description,
73
+ workflowId: _step.workflowId,
69
74
  inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
70
75
  outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
71
76
  };
@@ -78,6 +83,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
78
83
  }
79
84
  async function startAsyncWorkflowHandler({
80
85
  mastra,
86
+ runtimeContext,
81
87
  workflowId,
82
88
  runId,
83
89
  triggerData
@@ -91,18 +97,20 @@ async function startAsyncWorkflowHandler({
91
97
  throw new HTTPException(404, { message: "Workflow not found" });
92
98
  }
93
99
  if (!runId) {
94
- const { start } = workflow.createRun();
95
- const result2 = await start({
96
- triggerData
100
+ const newRun = workflow.createRun();
101
+ const result2 = await newRun.start({
102
+ triggerData,
103
+ runtimeContext
97
104
  });
98
105
  return result2;
99
106
  }
100
- const run = workflow.getRun(runId);
107
+ const run = workflow.getMemoryRun(runId);
101
108
  if (!run) {
102
109
  throw new HTTPException(404, { message: "Workflow run not found" });
103
110
  }
104
111
  const result = await run.start({
105
- triggerData
112
+ triggerData,
113
+ runtimeContext
106
114
  });
107
115
  return result;
108
116
  } catch (error) {
@@ -125,7 +133,7 @@ async function getWorkflowRunHandler({
125
133
  if (!workflow) {
126
134
  throw new HTTPException(404, { message: "Workflow not found" });
127
135
  }
128
- const run = workflow.getRun(runId);
136
+ const run = await workflow.getRun(runId);
129
137
  if (!run) {
130
138
  throw new HTTPException(404, { message: "Workflow run not found" });
131
139
  }
@@ -147,14 +155,15 @@ async function createRunHandler({
147
155
  if (!workflow) {
148
156
  throw new HTTPException(404, { message: "Workflow not found" });
149
157
  }
150
- const { runId } = workflow.createRun({ runId: prevRunId });
151
- return { runId };
158
+ const newRun = workflow.createRun({ runId: prevRunId });
159
+ return { runId: newRun.runId };
152
160
  } catch (error) {
153
161
  throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
154
162
  }
155
163
  }
156
164
  async function startWorkflowRunHandler({
157
165
  mastra,
166
+ runtimeContext,
158
167
  workflowId,
159
168
  runId,
160
169
  triggerData
@@ -167,12 +176,13 @@ async function startWorkflowRunHandler({
167
176
  throw new HTTPException(400, { message: "runId required to start run" });
168
177
  }
169
178
  const workflow = mastra.getWorkflow(workflowId);
170
- const run = workflow.getRun(runId);
179
+ const run = workflow.getMemoryRun(runId);
171
180
  if (!run) {
172
181
  throw new HTTPException(404, { message: "Workflow run not found" });
173
182
  }
174
- await run.start({
175
- triggerData
183
+ void run.start({
184
+ triggerData,
185
+ runtimeContext
176
186
  });
177
187
  return { message: "Workflow run started" };
178
188
  } catch (e) {
@@ -192,7 +202,7 @@ async function watchWorkflowHandler({
192
202
  throw new HTTPException(400, { message: "runId required to watch workflow" });
193
203
  }
194
204
  const workflow = mastra.getWorkflow(workflowId);
195
- const run = workflow.getRun(runId);
205
+ const run = workflow.getMemoryRun(runId);
196
206
  if (!run) {
197
207
  throw new HTTPException(404, { message: "Workflow run not found" });
198
208
  }
@@ -208,8 +218,10 @@ async function watchWorkflowHandler({
208
218
  asyncRef = null;
209
219
  }
210
220
  asyncRef = setImmediate(() => {
211
- if (!workflow.getRun(runId2)) {
221
+ const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
222
+ if (runDone) {
212
223
  controller.close();
224
+ unwatch?.();
213
225
  }
214
226
  });
215
227
  });
@@ -227,7 +239,8 @@ async function resumeAsyncWorkflowHandler({
227
239
  mastra,
228
240
  workflowId,
229
241
  runId,
230
- body
242
+ body,
243
+ runtimeContext
231
244
  }) {
232
245
  try {
233
246
  if (!workflowId) {
@@ -237,13 +250,14 @@ async function resumeAsyncWorkflowHandler({
237
250
  throw new HTTPException(400, { message: "runId required to resume workflow" });
238
251
  }
239
252
  const workflow = mastra.getWorkflow(workflowId);
240
- const run = workflow.getRun(runId);
253
+ const run = workflow.getMemoryRun(runId);
241
254
  if (!run) {
242
255
  throw new HTTPException(404, { message: "Workflow run not found" });
243
256
  }
244
257
  const result = await run.resume({
245
258
  stepId: body.stepId,
246
- context: body.context
259
+ context: body.context,
260
+ runtimeContext
247
261
  });
248
262
  return result;
249
263
  } catch (error) {
@@ -254,7 +268,8 @@ async function resumeWorkflowHandler({
254
268
  mastra,
255
269
  workflowId,
256
270
  runId,
257
- body
271
+ body,
272
+ runtimeContext
258
273
  }) {
259
274
  try {
260
275
  if (!workflowId) {
@@ -264,26 +279,35 @@ async function resumeWorkflowHandler({
264
279
  throw new HTTPException(400, { message: "runId required to resume workflow" });
265
280
  }
266
281
  const workflow = mastra.getWorkflow(workflowId);
267
- const run = workflow.getRun(runId);
282
+ const run = workflow.getMemoryRun(runId);
268
283
  if (!run) {
269
284
  throw new HTTPException(404, { message: "Workflow run not found" });
270
285
  }
271
- await run.resume({
286
+ void run.resume({
272
287
  stepId: body.stepId,
273
- context: body.context
288
+ context: body.context,
289
+ runtimeContext
274
290
  });
275
291
  return { message: "Workflow run resumed" };
276
292
  } catch (error) {
277
293
  return handleError(error, "Error resuming workflow");
278
294
  }
279
295
  }
280
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
296
+ async function getWorkflowRunsHandler({
297
+ mastra,
298
+ workflowId,
299
+ fromDate,
300
+ toDate,
301
+ limit,
302
+ offset,
303
+ resourceId
304
+ }) {
281
305
  try {
282
306
  if (!workflowId) {
283
307
  throw new HTTPException(400, { message: "Workflow ID is required" });
284
308
  }
285
309
  const workflow = mastra.getWorkflow(workflowId);
286
- const workflowRuns = await workflow.getWorkflowRuns() || {
310
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
287
311
  runs: [],
288
312
  total: 0
289
313
  };
@@ -1,4 +1,4 @@
1
- import { HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { HTTPException } from './chunk-NYN7KFXL.js';
2
2
 
3
3
  // src/server/handlers/utils.ts
4
4
  function validateBody(body) {
@@ -1,6 +1,7 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { validateBody } from './chunk-H5PTF3Y4.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
4
5
  import { Readable } from 'stream';
5
6
 
6
7
  // src/server/handlers/voice.ts
@@ -38,9 +39,7 @@ async function generateSpeechHandler({
38
39
  throw new HTTPException(400, { message: "Agent ID is required" });
39
40
  }
40
41
  validateBody({
41
- text: void 0,
42
- speakerId: void 0,
43
- ...body
42
+ text: body?.text
44
43
  });
45
44
  const agent = mastra.getAgent(agentId);
46
45
  if (!agent) {
@@ -53,12 +52,7 @@ async function generateSpeechHandler({
53
52
  if (!audioStream) {
54
53
  throw new HTTPException(500, { message: "Failed to generate speech" });
55
54
  }
56
- const chunks = [];
57
- for await (const chunk of audioStream) {
58
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
59
- }
60
- const audioData = Buffer.concat(chunks);
61
- return { audioData };
55
+ return audioStream;
62
56
  } catch (error) {
63
57
  return handleError(error, "Error generating speech");
64
58
  }
@@ -1,6 +1,6 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export } from './chunk-TRDNDNGQ.js';
1
+ import { validateBody } from './chunk-H5PTF3Y4.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { __export } from './chunk-MLKGABMK.js';
4
4
 
5
5
  // src/server/handlers/logs.ts
6
6
  var logs_exports = {};
@@ -9,7 +9,10 @@ __export(logs_exports, {
9
9
  getLogsByRunIdHandler: () => getLogsByRunIdHandler,
10
10
  getLogsHandler: () => getLogsHandler
11
11
  });
12
- async function getLogsHandler({ mastra, transportId }) {
12
+ async function getLogsHandler({
13
+ mastra,
14
+ transportId
15
+ }) {
13
16
  try {
14
17
  validateBody({ transportId });
15
18
  const logs = await mastra.getLogs(transportId);
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunkQH6XWSXP_cjs = require('./chunk-QH6XWSXP.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
7
  var web = require('stream/web');
7
8
 
8
9
  // src/server/handlers/workflows.ts
9
10
  var workflows_exports = {};
10
- chunkFV45V6WC_cjs.__export(workflows_exports, {
11
+ chunk75ZPJI57_cjs.__export(workflows_exports, {
11
12
  createRunHandler: () => createRunHandler,
12
13
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
14
  getWorkflowRunHandler: () => getWorkflowRunHandler,
@@ -30,13 +31,15 @@ async function getWorkflowsHandler({ mastra }) {
30
31
  serializedStepGraph: workflow.serializedStepGraph,
31
32
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
32
33
  name: workflow.name,
33
- triggerSchema: workflow.triggerSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
+ triggerSchema: workflow.triggerSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
35
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
35
36
  const _step = step;
36
37
  acc2[key2] = {
37
- ..._step,
38
- inputSchema: _step.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.inputSchema)) : void 0,
39
- outputSchema: _step.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.outputSchema)) : void 0
38
+ id: _step.id,
39
+ description: _step.description,
40
+ workflowId: _step.workflowId,
41
+ inputSchema: _step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.inputSchema)) : void 0,
42
+ outputSchema: _step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.outputSchema)) : void 0
40
43
  };
41
44
  return acc2;
42
45
  }, {})
@@ -45,17 +48,17 @@ async function getWorkflowsHandler({ mastra }) {
45
48
  }, {});
46
49
  return _workflows;
47
50
  } catch (error) {
48
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
51
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
49
52
  }
50
53
  }
51
54
  async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
55
  try {
53
56
  if (!workflowId) {
54
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
57
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
55
58
  }
56
59
  const workflow = mastra.getWorkflow(workflowId);
57
60
  if (!workflow) {
58
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
61
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
59
62
  }
60
63
  return {
61
64
  stepGraph: workflow.stepGraph,
@@ -63,52 +66,57 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
63
66
  serializedStepGraph: workflow.serializedStepGraph,
64
67
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
65
68
  name: workflow.name,
66
- triggerSchema: workflow.triggerSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(workflow.triggerSchema)) : void 0,
69
+ triggerSchema: workflow.triggerSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.triggerSchema)) : void 0,
67
70
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
68
71
  const _step = step;
69
72
  acc[key] = {
70
- ..._step,
71
- inputSchema: _step.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.inputSchema)) : void 0,
72
- outputSchema: _step.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.outputSchema)) : void 0
73
+ id: _step.id,
74
+ description: _step.description,
75
+ workflowId: _step.workflowId,
76
+ inputSchema: _step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.inputSchema)) : void 0,
77
+ outputSchema: _step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.outputSchema)) : void 0
73
78
  };
74
79
  return acc;
75
80
  }, {})
76
81
  };
77
82
  } catch (error) {
78
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
83
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
79
84
  }
80
85
  }
81
86
  async function startAsyncWorkflowHandler({
82
87
  mastra,
88
+ runtimeContext,
83
89
  workflowId,
84
90
  runId,
85
91
  triggerData
86
92
  }) {
87
93
  try {
88
94
  if (!workflowId) {
89
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
95
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
90
96
  }
91
97
  const workflow = mastra.getWorkflow(workflowId);
92
98
  if (!workflow) {
93
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
99
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
94
100
  }
95
101
  if (!runId) {
96
- const { start } = workflow.createRun();
97
- const result2 = await start({
98
- triggerData
102
+ const newRun = workflow.createRun();
103
+ const result2 = await newRun.start({
104
+ triggerData,
105
+ runtimeContext
99
106
  });
100
107
  return result2;
101
108
  }
102
- const run = workflow.getRun(runId);
109
+ const run = workflow.getMemoryRun(runId);
103
110
  if (!run) {
104
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
111
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
105
112
  }
106
113
  const result = await run.start({
107
- triggerData
114
+ triggerData,
115
+ runtimeContext
108
116
  });
109
117
  return result;
110
118
  } catch (error) {
111
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
119
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
112
120
  }
113
121
  }
114
122
  async function getWorkflowRunHandler({
@@ -118,22 +126,22 @@ async function getWorkflowRunHandler({
118
126
  }) {
119
127
  try {
120
128
  if (!workflowId) {
121
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
129
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
122
130
  }
123
131
  if (!runId) {
124
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
132
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
125
133
  }
126
134
  const workflow = mastra.getWorkflow(workflowId);
127
135
  if (!workflow) {
128
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
136
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
129
137
  }
130
- const run = workflow.getRun(runId);
138
+ const run = await workflow.getRun(runId);
131
139
  if (!run) {
132
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
140
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
133
141
  }
134
142
  return run;
135
143
  } catch (error) {
136
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
144
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
137
145
  }
138
146
  }
139
147
  async function createRunHandler({
@@ -143,42 +151,44 @@ async function createRunHandler({
143
151
  }) {
144
152
  try {
145
153
  if (!workflowId) {
146
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
154
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
147
155
  }
148
156
  const workflow = mastra.getWorkflow(workflowId);
149
157
  if (!workflow) {
150
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
158
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
151
159
  }
152
- const { runId } = workflow.createRun({ runId: prevRunId });
153
- return { runId };
160
+ const newRun = workflow.createRun({ runId: prevRunId });
161
+ return { runId: newRun.runId };
154
162
  } catch (error) {
155
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
163
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
156
164
  }
157
165
  }
158
166
  async function startWorkflowRunHandler({
159
167
  mastra,
168
+ runtimeContext,
160
169
  workflowId,
161
170
  runId,
162
171
  triggerData
163
172
  }) {
164
173
  try {
165
174
  if (!workflowId) {
166
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
175
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
167
176
  }
168
177
  if (!runId) {
169
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
178
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
170
179
  }
171
180
  const workflow = mastra.getWorkflow(workflowId);
172
- const run = workflow.getRun(runId);
181
+ const run = workflow.getMemoryRun(runId);
173
182
  if (!run) {
174
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
183
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
175
184
  }
176
- await run.start({
177
- triggerData
185
+ void run.start({
186
+ triggerData,
187
+ runtimeContext
178
188
  });
179
189
  return { message: "Workflow run started" };
180
190
  } catch (e) {
181
- return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
191
+ return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
182
192
  }
183
193
  }
184
194
  async function watchWorkflowHandler({
@@ -188,15 +198,15 @@ async function watchWorkflowHandler({
188
198
  }) {
189
199
  try {
190
200
  if (!workflowId) {
191
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
201
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
192
202
  }
193
203
  if (!runId) {
194
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
204
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
195
205
  }
196
206
  const workflow = mastra.getWorkflow(workflowId);
197
- const run = workflow.getRun(runId);
207
+ const run = workflow.getMemoryRun(runId);
198
208
  if (!run) {
199
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
209
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
200
210
  }
201
211
  let unwatch;
202
212
  let asyncRef = null;
@@ -210,8 +220,10 @@ async function watchWorkflowHandler({
210
220
  asyncRef = null;
211
221
  }
212
222
  asyncRef = setImmediate(() => {
213
- if (!workflow.getRun(runId2)) {
223
+ const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
224
+ if (runDone) {
214
225
  controller.close();
226
+ unwatch?.();
215
227
  }
216
228
  });
217
229
  });
@@ -222,76 +234,88 @@ async function watchWorkflowHandler({
222
234
  });
223
235
  return stream;
224
236
  } catch (error) {
225
- return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
237
+ return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
226
238
  }
227
239
  }
228
240
  async function resumeAsyncWorkflowHandler({
229
241
  mastra,
230
242
  workflowId,
231
243
  runId,
232
- body
244
+ body,
245
+ runtimeContext
233
246
  }) {
234
247
  try {
235
248
  if (!workflowId) {
236
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
249
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
237
250
  }
238
251
  if (!runId) {
239
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
252
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
240
253
  }
241
254
  const workflow = mastra.getWorkflow(workflowId);
242
- const run = workflow.getRun(runId);
255
+ const run = workflow.getMemoryRun(runId);
243
256
  if (!run) {
244
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
257
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
245
258
  }
246
259
  const result = await run.resume({
247
260
  stepId: body.stepId,
248
- context: body.context
261
+ context: body.context,
262
+ runtimeContext
249
263
  });
250
264
  return result;
251
265
  } catch (error) {
252
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
266
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
253
267
  }
254
268
  }
255
269
  async function resumeWorkflowHandler({
256
270
  mastra,
257
271
  workflowId,
258
272
  runId,
259
- body
273
+ body,
274
+ runtimeContext
260
275
  }) {
261
276
  try {
262
277
  if (!workflowId) {
263
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
278
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
264
279
  }
265
280
  if (!runId) {
266
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
281
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
267
282
  }
268
283
  const workflow = mastra.getWorkflow(workflowId);
269
- const run = workflow.getRun(runId);
284
+ const run = workflow.getMemoryRun(runId);
270
285
  if (!run) {
271
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
286
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
272
287
  }
273
- await run.resume({
288
+ void run.resume({
274
289
  stepId: body.stepId,
275
- context: body.context
290
+ context: body.context,
291
+ runtimeContext
276
292
  });
277
293
  return { message: "Workflow run resumed" };
278
294
  } catch (error) {
279
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
295
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
280
296
  }
281
297
  }
282
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
298
+ async function getWorkflowRunsHandler({
299
+ mastra,
300
+ workflowId,
301
+ fromDate,
302
+ toDate,
303
+ limit,
304
+ offset,
305
+ resourceId
306
+ }) {
283
307
  try {
284
308
  if (!workflowId) {
285
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
309
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
286
310
  }
287
311
  const workflow = mastra.getWorkflow(workflowId);
288
- const workflowRuns = await workflow.getWorkflowRuns() || {
312
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
289
313
  runs: [],
290
314
  total: 0
291
315
  };
292
316
  return workflowRuns;
293
317
  } catch (error) {
294
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
318
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
295
319
  }
296
320
  }
297
321
 
@@ -1,5 +1,6 @@
1
- import { handleError } from './chunk-3AHQ5RGN.js';
2
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { handleError } from './chunk-M5ABIP7D.js';
2
+ import { HTTPException } from './chunk-NYN7KFXL.js';
3
+ import { __export } from './chunk-MLKGABMK.js';
3
4
 
4
5
  // src/server/handlers/vector.ts
5
6
  var vector_exports = {};