@mastra/server 0.0.1-alpha.6 → 0.10.1-alpha.0

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 (79) hide show
  1. package/{LICENSE → LICENSE.md} +3 -1
  2. package/README.md +48 -135
  3. package/dist/_tsup-dts-rollup.d.cts +316 -52
  4. package/dist/_tsup-dts-rollup.d.ts +316 -52
  5. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  6. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  7. package/dist/chunk-5SN4U5AC.cjs +508 -0
  8. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  9. package/dist/chunk-75ZPJI57.cjs +9 -0
  10. package/dist/{chunk-VB7KH62D.cjs → chunk-7DLZLWJV.cjs} +16 -12
  11. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  12. package/dist/{chunk-2YONKUWB.js → chunk-C7564HUT.js} +58 -33
  13. package/dist/chunk-D4IRYCUI.cjs +235 -0
  14. package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
  15. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  16. package/dist/{chunk-3RVHWGWO.js → chunk-HFWCEP5S.js} +6 -12
  17. package/dist/chunk-KUNQFY2W.js +365 -0
  18. package/dist/chunk-LIVAK2DM.js +2001 -0
  19. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  20. package/dist/{chunk-CWSDZEZG.cjs → chunk-MHKNLNAN.cjs} +15 -12
  21. package/dist/chunk-MLKGABMK.js +7 -0
  22. package/dist/chunk-MMO2HDM6.cjs +378 -0
  23. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  24. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  25. package/dist/{chunk-DVPP5S6I.js → chunk-OR3CIE2H.js} +9 -6
  26. package/dist/chunk-P6SCPDYW.js +500 -0
  27. package/dist/{chunk-YNSGUC2O.js → chunk-TJKLBTFB.js} +23 -7
  28. package/dist/chunk-VPNDC2DI.cjs +148 -0
  29. package/dist/{chunk-ILW7XYNJ.js → chunk-W7VCKPAD.js} +84 -60
  30. package/dist/{chunk-2JQC6JWP.js → chunk-WFBJJNCK.js} +10 -6
  31. package/dist/chunk-WUC6LSTW.js +227 -0
  32. package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
  33. package/dist/{chunk-A7DF4ETD.cjs → chunk-YBVOQN4M.cjs} +22 -28
  34. package/dist/chunk-YIOVBYZH.cjs +332 -0
  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/legacyWorkflows.cjs +46 -0
  46. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  48. package/dist/server/handlers/legacyWorkflows.js +1 -0
  49. package/dist/server/handlers/logs.cjs +4 -4
  50. package/dist/server/handlers/logs.js +1 -1
  51. package/dist/server/handlers/memory.cjs +9 -9
  52. package/dist/server/handlers/memory.js +1 -1
  53. package/dist/server/handlers/network.cjs +5 -5
  54. package/dist/server/handlers/network.js +1 -1
  55. package/dist/server/handlers/telemetry.cjs +3 -3
  56. package/dist/server/handlers/telemetry.js +1 -1
  57. package/dist/server/handlers/tools.cjs +5 -5
  58. package/dist/server/handlers/tools.js +1 -1
  59. package/dist/server/handlers/utils.cjs +2 -2
  60. package/dist/server/handlers/utils.js +1 -1
  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 +17 -13
  66. package/dist/server/handlers/workflows.d.cts +3 -2
  67. package/dist/server/handlers/workflows.d.ts +3 -2
  68. package/dist/server/handlers/workflows.js +1 -1
  69. package/dist/server/handlers.cjs +33 -23
  70. package/dist/server/handlers.d.cts +2 -0
  71. package/dist/server/handlers.d.ts +2 -0
  72. package/dist/server/handlers.js +11 -9
  73. package/package.json +9 -7
  74. package/dist/chunk-5JOF627H.cjs +0 -123
  75. package/dist/chunk-BMA2ORRT.js +0 -152
  76. package/dist/chunk-GV52BII2.cjs +0 -160
  77. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  78. package/dist/chunk-VK6FX47H.js +0 -5576
  79. package/dist/chunk-X37I6GZT.cjs +0 -308
@@ -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/error.ts
4
4
  function handleError(error, defaultMessage) {
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
4
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
5
6
 
6
7
  // src/server/handlers/telemetry.ts
7
8
  var telemetry_exports = {};
8
- chunkFV45V6WC_cjs.__export(telemetry_exports, {
9
+ chunk75ZPJI57_cjs.__export(telemetry_exports, {
9
10
  getTelemetryHandler: () => getTelemetryHandler,
10
11
  storeTelemetryHandler: () => storeTelemetryHandler
11
12
  });
@@ -14,31 +15,33 @@ async function getTelemetryHandler({ mastra, body }) {
14
15
  const telemetry = mastra.getTelemetry();
15
16
  const storage = mastra.getStorage();
16
17
  if (!telemetry) {
17
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
19
  }
19
20
  if (!storage) {
20
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
21
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Storage is not initialized" });
21
22
  }
22
23
  if (!body) {
23
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Body is required" });
24
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
24
25
  }
25
- const { name, scope, page, perPage, attribute } = body;
26
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
26
27
  const attributes = attribute ? Object.fromEntries(
27
28
  (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
28
29
  const [key, value] = attr.split(":");
29
30
  return [key, value];
30
31
  })
31
32
  ) : void 0;
32
- const traces = await storage.__getTraces({
33
+ const traces = await storage.getTraces({
33
34
  name,
34
35
  scope,
35
36
  page: Number(page ?? 0),
36
37
  perPage: Number(perPage ?? 100),
37
- attributes
38
+ attributes,
39
+ fromDate: fromDate ? new Date(fromDate) : void 0,
40
+ toDate: toDate ? new Date(toDate) : void 0
38
41
  });
39
42
  return traces;
40
43
  } catch (error2) {
41
- return chunkZLBRQFDD_cjs.handleError(error2, "Error getting telemetry");
44
+ return chunk64U3UDTH_cjs.handleError(error2, "Error getting telemetry");
42
45
  }
43
46
  }
44
47
  async function storeTelemetryHandler({ mastra, body }) {
@@ -46,7 +49,7 @@ async function storeTelemetryHandler({ mastra, body }) {
46
49
  const storage = mastra.getStorage();
47
50
  const logger = mastra.getLogger();
48
51
  if (!storage) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
52
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Storage is not initialized" });
50
53
  }
51
54
  const now = /* @__PURE__ */ new Date();
52
55
  const items = body?.resourceSpans?.[0]?.scopeSpans;
@@ -107,7 +110,7 @@ async function storeTelemetryHandler({ mastra, body }) {
107
110
  }
108
111
  return acc;
109
112
  }, []);
110
- return storage.__batchTraceInsert({
113
+ return storage.batchTraceInsert({
111
114
  records: allSpans
112
115
  }).then(() => {
113
116
  return {
@@ -0,0 +1,7 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export { __export };
@@ -0,0 +1,378 @@
1
+ 'use strict';
2
+
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');
7
+ var web = require('stream/web');
8
+ var di = require('@mastra/core/di');
9
+
10
+ // src/server/handlers/workflows.ts
11
+ var workflows_exports = {};
12
+ chunk75ZPJI57_cjs.__export(workflows_exports, {
13
+ createWorkflowRunHandler: () => createWorkflowRunHandler,
14
+ getWorkflowByIdHandler: () => getWorkflowByIdHandler,
15
+ getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
16
+ getWorkflowRunsHandler: () => getWorkflowRunsHandler,
17
+ getWorkflowsHandler: () => getWorkflowsHandler,
18
+ resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
19
+ resumeWorkflowHandler: () => resumeWorkflowHandler,
20
+ startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
21
+ startWorkflowRunHandler: () => startWorkflowRunHandler,
22
+ streamWorkflowHandler: () => streamWorkflowHandler,
23
+ watchWorkflowHandler: () => watchWorkflowHandler
24
+ });
25
+ async function getWorkflowsHandler({ mastra }) {
26
+ try {
27
+ const workflows = mastra.getWorkflows({ serialized: false });
28
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
29
+ acc[key] = {
30
+ name: workflow.name,
31
+ description: workflow.description,
32
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
33
+ acc2[key2] = {
34
+ id: step.id,
35
+ description: step.description,
36
+ inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
37
+ outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
38
+ resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
39
+ suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
40
+ };
41
+ return acc2;
42
+ }, {}),
43
+ stepGraph: workflow.serializedStepGraph,
44
+ inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
45
+ outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
46
+ };
47
+ return acc;
48
+ }, {});
49
+ return _workflows;
50
+ } catch (error) {
51
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
52
+ }
53
+ }
54
+ async function getWorkflowByIdHandler({ mastra, workflowId }) {
55
+ try {
56
+ if (!workflowId) {
57
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
58
+ }
59
+ const workflow = mastra.getWorkflow(workflowId);
60
+ if (!workflow) {
61
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
62
+ }
63
+ return {
64
+ steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
65
+ acc[key] = {
66
+ id: step.id,
67
+ description: step.description,
68
+ inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
69
+ outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
70
+ resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
71
+ suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
72
+ };
73
+ return acc;
74
+ }, {}),
75
+ name: workflow.name,
76
+ description: workflow.description,
77
+ stepGraph: workflow.serializedStepGraph,
78
+ inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
79
+ outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
80
+ };
81
+ } catch (error) {
82
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
83
+ }
84
+ }
85
+ async function getWorkflowRunByIdHandler({
86
+ mastra,
87
+ workflowId,
88
+ runId
89
+ }) {
90
+ try {
91
+ if (!workflowId) {
92
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
93
+ }
94
+ if (!runId) {
95
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
96
+ }
97
+ const workflow = mastra.getWorkflow(workflowId);
98
+ if (!workflow) {
99
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
100
+ }
101
+ const run = await workflow.getWorkflowRunById(runId);
102
+ if (!run) {
103
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
104
+ }
105
+ return run;
106
+ } catch (error) {
107
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
108
+ }
109
+ }
110
+ async function createWorkflowRunHandler({
111
+ mastra,
112
+ workflowId,
113
+ runId: prevRunId
114
+ }) {
115
+ try {
116
+ if (!workflowId) {
117
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
118
+ }
119
+ const workflow = mastra.getWorkflow(workflowId);
120
+ if (!workflow) {
121
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
122
+ }
123
+ const run = workflow.createRun({ runId: prevRunId });
124
+ return { runId: run.runId };
125
+ } catch (error) {
126
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
127
+ }
128
+ }
129
+ async function startAsyncWorkflowHandler({
130
+ mastra,
131
+ runtimeContext,
132
+ workflowId,
133
+ runId,
134
+ inputData,
135
+ runtimeContextFromRequest
136
+ }) {
137
+ try {
138
+ if (!workflowId) {
139
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
140
+ }
141
+ const workflow = mastra.getWorkflow(workflowId);
142
+ if (!workflow) {
143
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
144
+ }
145
+ const finalRuntimeContext = new di.RuntimeContext([
146
+ ...Array.from(runtimeContext?.entries() ?? []),
147
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
148
+ ]);
149
+ const _run = workflow.createRun({ runId });
150
+ const result = await _run.start({
151
+ inputData,
152
+ runtimeContext: finalRuntimeContext
153
+ });
154
+ return result;
155
+ } catch (error) {
156
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
157
+ }
158
+ }
159
+ async function startWorkflowRunHandler({
160
+ mastra,
161
+ runtimeContext,
162
+ workflowId,
163
+ runId,
164
+ inputData,
165
+ runtimeContextFromRequest
166
+ }) {
167
+ try {
168
+ if (!workflowId) {
169
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
170
+ }
171
+ if (!runId) {
172
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
173
+ }
174
+ const workflow = mastra.getWorkflow(workflowId);
175
+ const run = await workflow.getWorkflowRunById(runId);
176
+ if (!run) {
177
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
178
+ }
179
+ const finalRuntimeContext = new di.RuntimeContext([
180
+ ...Array.from(runtimeContext?.entries() ?? []),
181
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
182
+ ]);
183
+ const _run = workflow.createRun({ runId });
184
+ void _run.start({
185
+ inputData,
186
+ runtimeContext: finalRuntimeContext
187
+ });
188
+ return { message: "Workflow run started" };
189
+ } catch (e) {
190
+ return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
191
+ }
192
+ }
193
+ async function watchWorkflowHandler({
194
+ mastra,
195
+ workflowId,
196
+ runId
197
+ }) {
198
+ try {
199
+ if (!workflowId) {
200
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
201
+ }
202
+ if (!runId) {
203
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
204
+ }
205
+ const workflow = mastra.getWorkflow(workflowId);
206
+ const run = await workflow.getWorkflowRunById(runId);
207
+ if (!run) {
208
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
209
+ }
210
+ const _run = workflow.createRun({ runId });
211
+ let unwatch;
212
+ let asyncRef = null;
213
+ const stream = new web.ReadableStream({
214
+ start(controller) {
215
+ unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
216
+ controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
217
+ if (asyncRef) {
218
+ clearImmediate(asyncRef);
219
+ asyncRef = null;
220
+ }
221
+ asyncRef = setImmediate(async () => {
222
+ const runDone = payload.workflowState.status !== "running";
223
+ if (runDone) {
224
+ controller.close();
225
+ unwatch?.();
226
+ }
227
+ });
228
+ });
229
+ },
230
+ cancel() {
231
+ unwatch?.();
232
+ }
233
+ });
234
+ return stream;
235
+ } catch (error) {
236
+ return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
237
+ }
238
+ }
239
+ function streamWorkflowHandler({
240
+ mastra,
241
+ runtimeContext,
242
+ workflowId,
243
+ runId,
244
+ inputData,
245
+ runtimeContextFromRequest
246
+ }) {
247
+ try {
248
+ if (!workflowId) {
249
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
250
+ }
251
+ if (!runId) {
252
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
253
+ }
254
+ const workflow = mastra.getWorkflow(workflowId);
255
+ if (!workflow) {
256
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
257
+ }
258
+ const finalRuntimeContext = new di.RuntimeContext([
259
+ ...Array.from(runtimeContext?.entries() ?? []),
260
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
261
+ ]);
262
+ const run = workflow.createRun({ runId });
263
+ const result = run.stream({
264
+ inputData,
265
+ runtimeContext: finalRuntimeContext
266
+ });
267
+ return result;
268
+ } catch (error) {
269
+ return chunk64U3UDTH_cjs.handleError(error, "Error executing workflow");
270
+ }
271
+ }
272
+ async function resumeAsyncWorkflowHandler({
273
+ mastra,
274
+ workflowId,
275
+ runId,
276
+ body,
277
+ runtimeContext,
278
+ runtimeContextFromRequest
279
+ }) {
280
+ try {
281
+ if (!workflowId) {
282
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
283
+ }
284
+ if (!runId) {
285
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
286
+ }
287
+ if (!body.step) {
288
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
289
+ }
290
+ const workflow = mastra.getWorkflow(workflowId);
291
+ const run = await workflow.getWorkflowRunById(runId);
292
+ if (!run) {
293
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
294
+ }
295
+ const finalRuntimeContext = new di.RuntimeContext([
296
+ ...Array.from(runtimeContext?.entries() ?? []),
297
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
298
+ ]);
299
+ const _run = workflow.createRun({ runId });
300
+ const result = await _run.resume({
301
+ step: body.step,
302
+ resumeData: body.resumeData,
303
+ runtimeContext: finalRuntimeContext
304
+ });
305
+ return result;
306
+ } catch (error) {
307
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
308
+ }
309
+ }
310
+ async function resumeWorkflowHandler({
311
+ mastra,
312
+ workflowId,
313
+ runId,
314
+ body,
315
+ runtimeContext
316
+ }) {
317
+ try {
318
+ if (!workflowId) {
319
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
320
+ }
321
+ if (!runId) {
322
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
323
+ }
324
+ if (!body.step) {
325
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
326
+ }
327
+ const workflow = mastra.getWorkflow(workflowId);
328
+ const run = await workflow.getWorkflowRunById(runId);
329
+ if (!run) {
330
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
331
+ }
332
+ const _run = workflow.createRun({ runId });
333
+ void _run.resume({
334
+ step: body.step,
335
+ resumeData: body.resumeData,
336
+ runtimeContext
337
+ });
338
+ return { message: "Workflow run resumed" };
339
+ } catch (error) {
340
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
341
+ }
342
+ }
343
+ async function getWorkflowRunsHandler({
344
+ mastra,
345
+ workflowId,
346
+ fromDate,
347
+ toDate,
348
+ limit,
349
+ offset,
350
+ resourceId
351
+ }) {
352
+ try {
353
+ if (!workflowId) {
354
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
355
+ }
356
+ const workflow = mastra.getWorkflow(workflowId);
357
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
358
+ runs: [],
359
+ total: 0
360
+ };
361
+ return workflowRuns;
362
+ } catch (error) {
363
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
364
+ }
365
+ }
366
+
367
+ exports.createWorkflowRunHandler = createWorkflowRunHandler;
368
+ exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
369
+ exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
370
+ exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
371
+ exports.getWorkflowsHandler = getWorkflowsHandler;
372
+ exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
373
+ exports.resumeWorkflowHandler = resumeWorkflowHandler;
374
+ exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
375
+ exports.startWorkflowRunHandler = startWorkflowRunHandler;
376
+ exports.streamWorkflowHandler = streamWorkflowHandler;
377
+ exports.watchWorkflowHandler = watchWorkflowHandler;
378
+ exports.workflows_exports = workflows_exports;
@@ -1,9 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
1
  // src/server/http-exception.ts
8
2
  var HTTPException = class extends Error {
9
3
  res;
@@ -37,4 +31,4 @@ var HTTPException = class extends Error {
37
31
  }
38
32
  };
39
33
 
40
- export { HTTPException, __export };
34
+ export { HTTPException };
@@ -1,11 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var __defProp = Object.defineProperty;
4
- var __export = (target, all) => {
5
- for (var name in all)
6
- __defProp(target, name, { get: all[name], enumerable: true });
7
- };
8
-
9
3
  // src/server/http-exception.ts
10
4
  var HTTPException = class extends Error {
11
5
  res;
@@ -40,4 +34,3 @@ var HTTPException = class extends Error {
40
34
  };
41
35
 
42
36
  exports.HTTPException = HTTPException;
43
- exports.__export = __export;
@@ -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/telemetry.ts
5
6
  var telemetry_exports = {};
@@ -20,19 +21,21 @@ async function getTelemetryHandler({ mastra, body }) {
20
21
  if (!body) {
21
22
  throw new HTTPException(400, { message: "Body is required" });
22
23
  }
23
- const { name, scope, page, perPage, attribute } = body;
24
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
24
25
  const attributes = attribute ? Object.fromEntries(
25
26
  (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
26
27
  const [key, value] = attr.split(":");
27
28
  return [key, value];
28
29
  })
29
30
  ) : void 0;
30
- const traces = await storage.__getTraces({
31
+ const traces = await storage.getTraces({
31
32
  name,
32
33
  scope,
33
34
  page: Number(page ?? 0),
34
35
  perPage: Number(perPage ?? 100),
35
- attributes
36
+ attributes,
37
+ fromDate: fromDate ? new Date(fromDate) : void 0,
38
+ toDate: toDate ? new Date(toDate) : void 0
36
39
  });
37
40
  return traces;
38
41
  } catch (error2) {
@@ -105,7 +108,7 @@ async function storeTelemetryHandler({ mastra, body }) {
105
108
  }
106
109
  return acc;
107
110
  }, []);
108
- return storage.__batchTraceInsert({
111
+ return storage.batchTraceInsert({
109
112
  records: allSpans
110
113
  }).then(() => {
111
114
  return {