@mastra/server 2.0.3 → 2.0.4-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 (69) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +152 -10
  2. package/dist/_tsup-dts-rollup.d.ts +152 -10
  3. package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
  4. package/dist/{chunk-3XTEV33Q.js → chunk-2KIW6AJK.js} +4 -3
  5. package/dist/{chunk-6Q7UXAYJ.cjs → chunk-3HQNCTZ2.cjs} +21 -20
  6. package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
  7. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  8. package/dist/chunk-5SN4U5AC.cjs +508 -0
  9. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  10. package/dist/chunk-75ZPJI57.cjs +9 -0
  11. package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
  12. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  13. package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
  14. package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
  15. package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
  16. package/dist/chunk-LIVAK2DM.js +2001 -0
  17. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  18. package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
  19. package/dist/chunk-MLKGABMK.js +7 -0
  20. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  21. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  22. package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
  23. package/dist/{chunk-M2RXDCPV.cjs → chunk-OHKAN72U.cjs} +76 -57
  24. package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
  25. package/dist/chunk-P6SCPDYW.js +500 -0
  26. package/dist/{chunk-GVBJ5I2S.js → chunk-Q6KMBIAN.js} +5 -4
  27. package/dist/{chunk-CHFORQ7J.cjs → chunk-RYUN5DF4.cjs} +45 -44
  28. package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
  29. package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
  30. package/dist/{chunk-OWNA6I2H.js → chunk-WVDUW4GI.js} +28 -9
  31. package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
  32. package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
  33. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  34. package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
  35. package/dist/server/handlers/a2a.cjs +30 -0
  36. package/dist/server/handlers/a2a.d.cts +6 -0
  37. package/dist/server/handlers/a2a.d.ts +6 -0
  38. package/dist/server/handlers/a2a.js +1 -0
  39. package/dist/server/handlers/agents.cjs +7 -7
  40. package/dist/server/handlers/agents.js +1 -1
  41. package/dist/server/handlers/error.cjs +2 -2
  42. package/dist/server/handlers/error.js +1 -1
  43. package/dist/server/handlers/logs.cjs +4 -4
  44. package/dist/server/handlers/logs.js +1 -1
  45. package/dist/server/handlers/memory.cjs +9 -9
  46. package/dist/server/handlers/memory.js +1 -1
  47. package/dist/server/handlers/network.cjs +5 -5
  48. package/dist/server/handlers/network.js +1 -1
  49. package/dist/server/handlers/telemetry.cjs +3 -3
  50. package/dist/server/handlers/telemetry.js +1 -1
  51. package/dist/server/handlers/tools.cjs +5 -5
  52. package/dist/server/handlers/tools.js +1 -1
  53. package/dist/server/handlers/utils.cjs +2 -2
  54. package/dist/server/handlers/utils.js +1 -1
  55. package/dist/server/handlers/vNextWorkflows.cjs +11 -11
  56. package/dist/server/handlers/vNextWorkflows.js +1 -1
  57. package/dist/server/handlers/vector.cjs +7 -7
  58. package/dist/server/handlers/vector.js +1 -1
  59. package/dist/server/handlers/voice.cjs +4 -4
  60. package/dist/server/handlers/voice.js +1 -1
  61. package/dist/server/handlers/workflows.cjs +11 -11
  62. package/dist/server/handlers/workflows.js +1 -1
  63. package/dist/server/handlers.cjs +28 -23
  64. package/dist/server/handlers.d.cts +1 -0
  65. package/dist/server/handlers.d.ts +1 -0
  66. package/dist/server/handlers.js +11 -10
  67. package/package.json +6 -4
  68. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  69. package/dist/chunk-OMN3UI6X.js +0 -5576
@@ -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,13 +15,13 @@ 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
26
  const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
26
27
  const attributes = attribute ? Object.fromEntries(
@@ -40,7 +41,7 @@ async function getTelemetryHandler({ mastra, body }) {
40
41
  });
41
42
  return traces;
42
43
  } catch (error2) {
43
- return chunkZLBRQFDD_cjs.handleError(error2, "Error getting telemetry");
44
+ return chunk64U3UDTH_cjs.handleError(error2, "Error getting telemetry");
44
45
  }
45
46
  }
46
47
  async function storeTelemetryHandler({ mastra, body }) {
@@ -48,7 +49,7 @@ async function storeTelemetryHandler({ mastra, body }) {
48
49
  const storage = mastra.getStorage();
49
50
  const logger = mastra.getLogger();
50
51
  if (!storage) {
51
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
52
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Storage is not initialized" });
52
53
  }
53
54
  const now = /* @__PURE__ */ new Date();
54
55
  const items = body?.resourceSpans?.[0]?.scopeSpans;
@@ -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 };
@@ -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,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,11 +29,11 @@ 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 }) {
@@ -44,7 +44,7 @@ async function getLogTransports({ mastra }) {
44
44
  transports: transports ? Object.keys(transports) : []
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,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.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');
8
+ var di = require('@mastra/core/di');
7
9
 
8
10
  // src/server/handlers/vNextWorkflows.ts
9
11
  var vNextWorkflows_exports = {};
10
- chunkFV45V6WC_cjs.__export(vNextWorkflows_exports, {
12
+ chunk75ZPJI57_cjs.__export(vNextWorkflows_exports, {
11
13
  createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
12
14
  getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
13
15
  getVNextWorkflowRunByIdHandler: () => getVNextWorkflowRunByIdHandler,
@@ -29,52 +31,54 @@ async function getVNextWorkflowsHandler({ mastra }) {
29
31
  acc2[key2] = {
30
32
  id: step.id,
31
33
  description: step.description,
32
- inputSchema: step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.inputSchema)) : void 0,
33
- outputSchema: step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.outputSchema)) : void 0,
34
- resumeSchema: step.resumeSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.resumeSchema)) : void 0,
35
- suspendSchema: step.suspendSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.suspendSchema)) : void 0
34
+ inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
35
+ outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
36
+ resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
37
+ suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
36
38
  };
37
39
  return acc2;
38
40
  }, {}),
39
41
  stepGraph: workflow.serializedStepGraph,
40
- inputSchema: workflow.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.inputSchema)) : void 0,
41
- outputSchema: workflow.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.outputSchema)) : void 0
42
+ inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
43
+ outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
42
44
  };
43
45
  return acc;
44
46
  }, {});
45
47
  return _workflows;
46
48
  } catch (error) {
47
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
49
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
48
50
  }
49
51
  }
50
52
  async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
51
53
  try {
52
54
  if (!workflowId) {
53
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
55
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
54
56
  }
55
57
  const workflow = mastra.vnext_getWorkflow(workflowId);
56
58
  if (!workflow) {
57
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
59
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
58
60
  }
59
61
  return {
60
62
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
61
63
  acc[key] = {
62
64
  id: step.id,
63
65
  description: step.description,
64
- inputSchema: step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.inputSchema)) : void 0,
65
- outputSchema: step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.outputSchema)) : void 0,
66
- resumeSchema: step.resumeSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.resumeSchema)) : void 0,
67
- suspendSchema: step.suspendSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.suspendSchema)) : void 0
66
+ inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
67
+ outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
68
+ resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
69
+ suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
68
70
  };
69
71
  return acc;
70
72
  }, {}),
71
73
  name: workflow.name,
72
74
  stepGraph: workflow.serializedStepGraph,
73
- inputSchema: workflow.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.inputSchema)) : void 0,
74
- outputSchema: workflow.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.outputSchema)) : void 0
75
+ // @ts-ignore - ignore infinite recursion
76
+ inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
77
+ // @ts-ignore - ignore infinite recursion
78
+ outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
75
79
  };
76
80
  } catch (error) {
77
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
81
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
78
82
  }
79
83
  }
80
84
  async function getVNextWorkflowRunByIdHandler({
@@ -84,22 +88,22 @@ async function getVNextWorkflowRunByIdHandler({
84
88
  }) {
85
89
  try {
86
90
  if (!workflowId) {
87
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
91
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
88
92
  }
89
93
  if (!runId) {
90
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
94
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
91
95
  }
92
96
  const workflow = mastra.vnext_getWorkflow(workflowId);
93
97
  if (!workflow) {
94
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
98
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
95
99
  }
96
100
  const run = await workflow.getWorkflowRunById(runId);
97
101
  if (!run) {
98
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
102
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
99
103
  }
100
104
  return run;
101
105
  } catch (error) {
102
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
106
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
103
107
  }
104
108
  }
105
109
  async function createVNextWorkflowRunHandler({
@@ -109,16 +113,16 @@ async function createVNextWorkflowRunHandler({
109
113
  }) {
110
114
  try {
111
115
  if (!workflowId) {
112
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
116
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
113
117
  }
114
118
  const workflow = mastra.vnext_getWorkflow(workflowId);
115
119
  if (!workflow) {
116
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
120
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
117
121
  }
118
122
  const run = workflow.createRun({ runId: prevRunId });
119
123
  return { runId: run.runId };
120
124
  } catch (error) {
121
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
125
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
122
126
  }
123
127
  }
124
128
  async function startAsyncVNextWorkflowHandler({
@@ -126,24 +130,29 @@ async function startAsyncVNextWorkflowHandler({
126
130
  runtimeContext,
127
131
  workflowId,
128
132
  runId,
129
- inputData
133
+ inputData,
134
+ runtimeContextFromRequest
130
135
  }) {
131
136
  try {
132
137
  if (!workflowId) {
133
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
138
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
134
139
  }
135
140
  const workflow = mastra.vnext_getWorkflow(workflowId);
136
141
  if (!workflow) {
137
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
142
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
138
143
  }
144
+ const finalRuntimeContext = new di.RuntimeContext([
145
+ ...Array.from(runtimeContext?.entries() ?? []),
146
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
147
+ ]);
139
148
  const _run = workflow.createRun({ runId });
140
149
  const result = await _run.start({
141
150
  inputData,
142
- runtimeContext
151
+ runtimeContext: finalRuntimeContext
143
152
  });
144
153
  return result;
145
154
  } catch (error) {
146
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
155
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
147
156
  }
148
157
  }
149
158
  async function startVNextWorkflowRunHandler({
@@ -151,28 +160,33 @@ async function startVNextWorkflowRunHandler({
151
160
  runtimeContext,
152
161
  workflowId,
153
162
  runId,
154
- inputData
163
+ inputData,
164
+ runtimeContextFromRequest
155
165
  }) {
156
166
  try {
157
167
  if (!workflowId) {
158
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
168
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
159
169
  }
160
170
  if (!runId) {
161
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
171
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
162
172
  }
163
173
  const workflow = mastra.vnext_getWorkflow(workflowId);
164
174
  const run = await workflow.getWorkflowRunById(runId);
165
175
  if (!run) {
166
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
176
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
167
177
  }
178
+ const finalRuntimeContext = new di.RuntimeContext([
179
+ ...Array.from(runtimeContext?.entries() ?? []),
180
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
181
+ ]);
168
182
  const _run = workflow.createRun({ runId });
169
183
  await _run.start({
170
184
  inputData,
171
- runtimeContext
185
+ runtimeContext: finalRuntimeContext
172
186
  });
173
187
  return { message: "Workflow run started" };
174
188
  } catch (e) {
175
- return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
189
+ return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
176
190
  }
177
191
  }
178
192
  async function watchVNextWorkflowHandler({
@@ -182,15 +196,15 @@ async function watchVNextWorkflowHandler({
182
196
  }) {
183
197
  try {
184
198
  if (!workflowId) {
185
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
199
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
186
200
  }
187
201
  if (!runId) {
188
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
202
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
189
203
  }
190
204
  const workflow = mastra.vnext_getWorkflow(workflowId);
191
205
  const run = await workflow.getWorkflowRunById(runId);
192
206
  if (!run) {
193
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
207
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
194
208
  }
195
209
  const _run = workflow.createRun({ runId });
196
210
  let unwatch;
@@ -218,7 +232,7 @@ async function watchVNextWorkflowHandler({
218
232
  });
219
233
  return stream;
220
234
  } catch (error) {
221
- return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
235
+ return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
222
236
  }
223
237
  }
224
238
  async function resumeAsyncVNextWorkflowHandler({
@@ -226,32 +240,37 @@ async function resumeAsyncVNextWorkflowHandler({
226
240
  workflowId,
227
241
  runId,
228
242
  body,
229
- runtimeContext
243
+ runtimeContext,
244
+ runtimeContextFromRequest
230
245
  }) {
231
246
  try {
232
247
  if (!workflowId) {
233
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
248
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
234
249
  }
235
250
  if (!runId) {
236
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
251
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
237
252
  }
238
253
  if (!body.step) {
239
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "step required to resume workflow" });
254
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
240
255
  }
241
256
  const workflow = mastra.vnext_getWorkflow(workflowId);
242
257
  const run = await workflow.getWorkflowRunById(runId);
243
258
  if (!run) {
244
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
259
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
245
260
  }
261
+ const finalRuntimeContext = new di.RuntimeContext([
262
+ ...Array.from(runtimeContext?.entries() ?? []),
263
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
264
+ ]);
246
265
  const _run = workflow.createRun({ runId });
247
266
  const result = await _run.resume({
248
267
  step: body.step,
249
268
  resumeData: body.resumeData,
250
- runtimeContext
269
+ runtimeContext: finalRuntimeContext
251
270
  });
252
271
  return result;
253
272
  } catch (error) {
254
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
273
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
255
274
  }
256
275
  }
257
276
  async function resumeVNextWorkflowHandler({
@@ -263,18 +282,18 @@ async function resumeVNextWorkflowHandler({
263
282
  }) {
264
283
  try {
265
284
  if (!workflowId) {
266
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
285
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
267
286
  }
268
287
  if (!runId) {
269
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
288
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
270
289
  }
271
290
  if (!body.step) {
272
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "step required to resume workflow" });
291
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
273
292
  }
274
293
  const workflow = mastra.vnext_getWorkflow(workflowId);
275
294
  const run = await workflow.getWorkflowRunById(runId);
276
295
  if (!run) {
277
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
296
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
278
297
  }
279
298
  const _run = workflow.createRun({ runId });
280
299
  await _run.resume({
@@ -284,7 +303,7 @@ async function resumeVNextWorkflowHandler({
284
303
  });
285
304
  return { message: "Workflow run resumed" };
286
305
  } catch (error) {
287
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
306
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
288
307
  }
289
308
  }
290
309
  async function getVNextWorkflowRunsHandler({
@@ -298,7 +317,7 @@ async function getVNextWorkflowRunsHandler({
298
317
  }) {
299
318
  try {
300
319
  if (!workflowId) {
301
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
320
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
302
321
  }
303
322
  const workflow = mastra.vnext_getWorkflow(workflowId);
304
323
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
@@ -307,7 +326,7 @@ async function getVNextWorkflowRunsHandler({
307
326
  };
308
327
  return workflowRuns;
309
328
  } catch (error) {
310
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
329
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
311
330
  }
312
331
  }
313
332
 
@@ -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 = {};