@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,308 +0,0 @@
1
- 'use strict';
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');
6
- var web = require('stream/web');
7
-
8
- // src/server/handlers/workflows.ts
9
- var workflows_exports = {};
10
- chunkFV45V6WC_cjs.__export(workflows_exports, {
11
- createRunHandler: () => createRunHandler,
12
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
- getWorkflowRunHandler: () => getWorkflowRunHandler,
14
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
15
- getWorkflowsHandler: () => getWorkflowsHandler,
16
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
17
- resumeWorkflowHandler: () => resumeWorkflowHandler,
18
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
19
- startWorkflowRunHandler: () => startWorkflowRunHandler,
20
- watchWorkflowHandler: () => watchWorkflowHandler
21
- });
22
- async function getWorkflowsHandler({ mastra }) {
23
- try {
24
- const workflows = mastra.getWorkflows({ serialized: false });
25
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
26
- if (workflow.isNested) return acc;
27
- acc[key] = {
28
- stepGraph: workflow.stepGraph,
29
- stepSubscriberGraph: workflow.stepSubscriberGraph,
30
- serializedStepGraph: workflow.serializedStepGraph,
31
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
32
- name: workflow.name,
33
- triggerSchema: workflow.triggerSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
35
- const _step = step;
36
- 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
40
- };
41
- return acc2;
42
- }, {})
43
- };
44
- return acc;
45
- }, {});
46
- return _workflows;
47
- } catch (error) {
48
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
49
- }
50
- }
51
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
- try {
53
- if (!workflowId) {
54
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
55
- }
56
- const workflow = mastra.getWorkflow(workflowId);
57
- if (!workflow) {
58
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
59
- }
60
- return {
61
- stepGraph: workflow.stepGraph,
62
- stepSubscriberGraph: workflow.stepSubscriberGraph,
63
- serializedStepGraph: workflow.serializedStepGraph,
64
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
65
- name: workflow.name,
66
- triggerSchema: workflow.triggerSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(workflow.triggerSchema)) : void 0,
67
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
68
- const _step = step;
69
- 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
- };
74
- return acc;
75
- }, {})
76
- };
77
- } catch (error) {
78
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
79
- }
80
- }
81
- async function startAsyncWorkflowHandler({
82
- mastra,
83
- workflowId,
84
- runId,
85
- triggerData
86
- }) {
87
- try {
88
- if (!workflowId) {
89
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
90
- }
91
- const workflow = mastra.getWorkflow(workflowId);
92
- if (!workflow) {
93
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
94
- }
95
- if (!runId) {
96
- const { start } = workflow.createRun();
97
- const result2 = await start({
98
- triggerData
99
- });
100
- return result2;
101
- }
102
- const run = workflow.getRun(runId);
103
- if (!run) {
104
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
105
- }
106
- const result = await run.start({
107
- triggerData
108
- });
109
- return result;
110
- } catch (error) {
111
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
112
- }
113
- }
114
- async function getWorkflowRunHandler({
115
- mastra,
116
- workflowId,
117
- runId
118
- }) {
119
- try {
120
- if (!workflowId) {
121
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
122
- }
123
- if (!runId) {
124
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
125
- }
126
- const workflow = mastra.getWorkflow(workflowId);
127
- if (!workflow) {
128
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
129
- }
130
- const run = workflow.getRun(runId);
131
- if (!run) {
132
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
133
- }
134
- return run;
135
- } catch (error) {
136
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
137
- }
138
- }
139
- async function createRunHandler({
140
- mastra,
141
- workflowId,
142
- runId: prevRunId
143
- }) {
144
- try {
145
- if (!workflowId) {
146
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
147
- }
148
- const workflow = mastra.getWorkflow(workflowId);
149
- if (!workflow) {
150
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
151
- }
152
- const { runId } = workflow.createRun({ runId: prevRunId });
153
- return { runId };
154
- } catch (error) {
155
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
156
- }
157
- }
158
- async function startWorkflowRunHandler({
159
- mastra,
160
- workflowId,
161
- runId,
162
- triggerData
163
- }) {
164
- try {
165
- if (!workflowId) {
166
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
167
- }
168
- if (!runId) {
169
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
170
- }
171
- const workflow = mastra.getWorkflow(workflowId);
172
- const run = workflow.getRun(runId);
173
- if (!run) {
174
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
175
- }
176
- await run.start({
177
- triggerData
178
- });
179
- return { message: "Workflow run started" };
180
- } catch (e) {
181
- return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
182
- }
183
- }
184
- async function watchWorkflowHandler({
185
- mastra,
186
- workflowId,
187
- runId
188
- }) {
189
- try {
190
- if (!workflowId) {
191
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
192
- }
193
- if (!runId) {
194
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
195
- }
196
- const workflow = mastra.getWorkflow(workflowId);
197
- const run = workflow.getRun(runId);
198
- if (!run) {
199
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
200
- }
201
- let unwatch;
202
- let asyncRef = null;
203
- const stream = new web.ReadableStream({
204
- start(controller) {
205
- unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
206
- const activePathsObj = Object.fromEntries(activePaths);
207
- controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
208
- if (asyncRef) {
209
- clearImmediate(asyncRef);
210
- asyncRef = null;
211
- }
212
- asyncRef = setImmediate(() => {
213
- if (!workflow.getRun(runId2)) {
214
- controller.close();
215
- }
216
- });
217
- });
218
- },
219
- cancel() {
220
- unwatch?.();
221
- }
222
- });
223
- return stream;
224
- } catch (error) {
225
- return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
226
- }
227
- }
228
- async function resumeAsyncWorkflowHandler({
229
- mastra,
230
- workflowId,
231
- runId,
232
- body
233
- }) {
234
- try {
235
- if (!workflowId) {
236
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
237
- }
238
- if (!runId) {
239
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
240
- }
241
- const workflow = mastra.getWorkflow(workflowId);
242
- const run = workflow.getRun(runId);
243
- if (!run) {
244
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
245
- }
246
- const result = await run.resume({
247
- stepId: body.stepId,
248
- context: body.context
249
- });
250
- return result;
251
- } catch (error) {
252
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
253
- }
254
- }
255
- async function resumeWorkflowHandler({
256
- mastra,
257
- workflowId,
258
- runId,
259
- body
260
- }) {
261
- try {
262
- if (!workflowId) {
263
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
264
- }
265
- if (!runId) {
266
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
267
- }
268
- const workflow = mastra.getWorkflow(workflowId);
269
- const run = workflow.getRun(runId);
270
- if (!run) {
271
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
272
- }
273
- await run.resume({
274
- stepId: body.stepId,
275
- context: body.context
276
- });
277
- return { message: "Workflow run resumed" };
278
- } catch (error) {
279
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
280
- }
281
- }
282
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
283
- try {
284
- if (!workflowId) {
285
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
286
- }
287
- const workflow = mastra.getWorkflow(workflowId);
288
- const workflowRuns = await workflow.getWorkflowRuns() || {
289
- runs: [],
290
- total: 0
291
- };
292
- return workflowRuns;
293
- } catch (error) {
294
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
295
- }
296
- }
297
-
298
- exports.createRunHandler = createRunHandler;
299
- exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
300
- exports.getWorkflowRunHandler = getWorkflowRunHandler;
301
- exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
302
- exports.getWorkflowsHandler = getWorkflowsHandler;
303
- exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
304
- exports.resumeWorkflowHandler = resumeWorkflowHandler;
305
- exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
306
- exports.startWorkflowRunHandler = startWorkflowRunHandler;
307
- exports.watchWorkflowHandler = watchWorkflowHandler;
308
- exports.workflows_exports = workflows_exports;