@mastra/server 0.0.0-message-ordering-20250415215612 → 0.0.0-pass-headers-for-create-mastra-client-20250529200245

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 (78) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +316 -59
  3. package/dist/_tsup-dts-rollup.d.ts +316 -59
  4. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  5. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  6. package/dist/chunk-5SN4U5AC.cjs +508 -0
  7. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/chunk-A3KDUGS7.cjs +239 -0
  10. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  11. package/dist/{chunk-YANVFOYA.js → chunk-C7564HUT.js} +56 -34
  12. package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
  13. package/dist/{chunk-3EJZQ6TQ.js → chunk-DQLE3DVM.js} +5 -5
  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-J3PKLB3A.js +231 -0
  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-SKBVVI24.cjs → chunk-NEOOQUKW.cjs} +11 -11
  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-DVPP5S6I.js → chunk-OR3CIE2H.js} +9 -6
  27. package/dist/chunk-P6SCPDYW.js +500 -0
  28. package/dist/{chunk-UV4WTEH4.js → chunk-TJKLBTFB.js} +20 -8
  29. package/dist/chunk-VPNDC2DI.cjs +148 -0
  30. package/dist/{chunk-OPP7H5TW.js → chunk-W7VCKPAD.js} +77 -62
  31. package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
  32. package/dist/{chunk-A7DF4ETD.cjs → chunk-YBVOQN4M.cjs} +22 -28
  33. package/dist/chunk-YIOVBYZH.cjs +332 -0
  34. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  35. package/dist/{chunk-PDC4ZBQW.cjs → chunk-ZE5AAC4I.cjs} +37 -25
  36. package/dist/server/handlers/a2a.cjs +30 -0
  37. package/dist/server/handlers/a2a.d.cts +6 -0
  38. package/dist/server/handlers/a2a.d.ts +6 -0
  39. package/dist/server/handlers/a2a.js +1 -0
  40. package/dist/server/handlers/agents.cjs +7 -7
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/error.cjs +2 -2
  43. package/dist/server/handlers/error.js +1 -1
  44. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  45. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  46. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.js +1 -0
  48. package/dist/server/handlers/logs.cjs +4 -4
  49. package/dist/server/handlers/logs.js +1 -1
  50. package/dist/server/handlers/memory.cjs +9 -9
  51. package/dist/server/handlers/memory.js +1 -1
  52. package/dist/server/handlers/network.cjs +5 -5
  53. package/dist/server/handlers/network.js +1 -1
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vector.cjs +7 -7
  61. package/dist/server/handlers/vector.js +1 -1
  62. package/dist/server/handlers/voice.cjs +4 -4
  63. package/dist/server/handlers/voice.js +1 -1
  64. package/dist/server/handlers/workflows.cjs +17 -13
  65. package/dist/server/handlers/workflows.d.cts +3 -2
  66. package/dist/server/handlers/workflows.d.ts +3 -2
  67. package/dist/server/handlers/workflows.js +1 -1
  68. package/dist/server/handlers.cjs +33 -23
  69. package/dist/server/handlers.d.cts +2 -0
  70. package/dist/server/handlers.d.ts +2 -0
  71. package/dist/server/handlers.js +11 -9
  72. package/package.json +8 -6
  73. package/dist/chunk-67WTHYAV.js +0 -156
  74. package/dist/chunk-B64YROKU.cjs +0 -317
  75. package/dist/chunk-JLDXUWK7.cjs +0 -126
  76. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  77. package/dist/chunk-VK6FX47H.js +0 -5576
  78. package/dist/chunk-Z46X3YCB.cjs +0 -164
@@ -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,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/logs.ts
8
8
  var logs_exports = {};
9
- chunkFV45V6WC_cjs.__export(logs_exports, {
9
+ chunk75ZPJI57_cjs.__export(logs_exports, {
10
10
  getLogTransports: () => getLogTransports,
11
11
  getLogsByRunIdHandler: () => getLogsByRunIdHandler,
12
12
  getLogsHandler: () => getLogsHandler
@@ -16,11 +16,11 @@ async function getLogsHandler({
16
16
  transportId
17
17
  }) {
18
18
  try {
19
- chunkQN4KF3BH_cjs.validateBody({ transportId });
19
+ chunk57CJTIPW_cjs.validateBody({ transportId });
20
20
  const logs = await mastra.getLogs(transportId);
21
21
  return logs;
22
22
  } catch (error) {
23
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs");
23
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting logs");
24
24
  }
25
25
  }
26
26
  async function getLogsByRunIdHandler({
@@ -29,22 +29,22 @@ async function getLogsByRunIdHandler({
29
29
  transportId
30
30
  }) {
31
31
  try {
32
- chunkQN4KF3BH_cjs.validateBody({ runId, transportId });
32
+ chunk57CJTIPW_cjs.validateBody({ runId, transportId });
33
33
  const logs = await mastra.getLogsByRunId({ runId, transportId });
34
34
  return logs;
35
35
  } catch (error) {
36
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs by run ID");
36
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting logs by run ID");
37
37
  }
38
38
  }
39
39
  async function getLogTransports({ mastra }) {
40
40
  try {
41
41
  const logger = mastra.getLogger();
42
- const transports = logger.transports;
42
+ const transports = logger.getTransports();
43
43
  return {
44
- transports: transports ? Object.keys(transports) : []
44
+ transports: transports ? [...transports.keys()] : []
45
45
  };
46
46
  } catch (error) {
47
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting log Transports");
47
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting log Transports");
48
48
  }
49
49
  }
50
50
 
@@ -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 {