@mastra/server 0.0.0-message-ordering-20250415215612 → 0.0.0-pg-pool-options-20250428183821

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 (39) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +99 -24
  2. package/dist/_tsup-dts-rollup.d.ts +99 -24
  3. package/dist/{chunk-A7DF4ETD.cjs → chunk-55HTWX4C.cjs} +2 -9
  4. package/dist/{chunk-UV4WTEH4.js → chunk-5JNVY6DU.js} +5 -5
  5. package/dist/{chunk-QH6XWSXP.cjs → chunk-5SWCVTNL.cjs} +38 -38
  6. package/dist/{chunk-CWSDZEZG.cjs → chunk-7IWQE76Z.cjs} +2 -2
  7. package/dist/{chunk-PDC4ZBQW.cjs → chunk-D3G23FP3.cjs} +9 -9
  8. package/dist/{chunk-JLDXUWK7.cjs → chunk-FPIWDH5Y.cjs} +4 -4
  9. package/dist/{chunk-Z46X3YCB.cjs → chunk-HCOPJZ4A.cjs} +11 -11
  10. package/dist/chunk-L5JIIJGO.js +300 -0
  11. package/dist/{chunk-OPP7H5TW.js → chunk-LFOBHRFO.js} +10 -10
  12. package/dist/{chunk-VK6FX47H.js → chunk-OMN3UI6X.js} +38 -38
  13. package/dist/{chunk-3RVHWGWO.js → chunk-Q6SHQECN.js} +2 -9
  14. package/dist/{chunk-67WTHYAV.js → chunk-R4J7XQYU.js} +7 -7
  15. package/dist/{chunk-YANVFOYA.js → chunk-RE6YL32K.js} +4 -4
  16. package/dist/{chunk-B64YROKU.cjs → chunk-TZK63M5N.cjs} +16 -16
  17. package/dist/{chunk-DVPP5S6I.js → chunk-WTHDCRMY.js} +2 -2
  18. package/dist/chunk-YN63BKGG.cjs +312 -0
  19. package/dist/server/handlers/agents.cjs +7 -7
  20. package/dist/server/handlers/agents.js +1 -1
  21. package/dist/server/handlers/network.cjs +5 -5
  22. package/dist/server/handlers/network.js +1 -1
  23. package/dist/server/handlers/telemetry.cjs +3 -3
  24. package/dist/server/handlers/telemetry.js +1 -1
  25. package/dist/server/handlers/tools.cjs +5 -5
  26. package/dist/server/handlers/tools.js +1 -1
  27. package/dist/server/handlers/vNextWorkflows.cjs +46 -0
  28. package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
  29. package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
  30. package/dist/server/handlers/vNextWorkflows.js +1 -0
  31. package/dist/server/handlers/voice.cjs +4 -4
  32. package/dist/server/handlers/voice.js +1 -1
  33. package/dist/server/handlers/workflows.cjs +11 -11
  34. package/dist/server/handlers/workflows.js +1 -1
  35. package/dist/server/handlers.cjs +17 -12
  36. package/dist/server/handlers.d.cts +1 -0
  37. package/dist/server/handlers.d.ts +1 -0
  38. package/dist/server/handlers.js +7 -6
  39. package/package.json +3 -3
@@ -0,0 +1,300 @@
1
+ import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
+ import { handleError } from './chunk-3AHQ5RGN.js';
3
+ import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
+ import { ReadableStream } from 'node:stream/web';
5
+
6
+ // src/server/handlers/vNextWorkflows.ts
7
+ var vNextWorkflows_exports = {};
8
+ __export(vNextWorkflows_exports, {
9
+ createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
10
+ getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
11
+ getVNextWorkflowRunHandler: () => getVNextWorkflowRunHandler,
12
+ getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
13
+ getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
14
+ resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
15
+ resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
16
+ startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
17
+ startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
18
+ watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
19
+ });
20
+ async function getVNextWorkflowsHandler({ mastra }) {
21
+ try {
22
+ const workflows = mastra.vnext_getWorkflows({ serialized: false });
23
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
24
+ acc[key] = {
25
+ name: workflow.name,
26
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
27
+ acc2[key2] = {
28
+ ...step,
29
+ inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
30
+ outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
31
+ resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0
32
+ };
33
+ return acc2;
34
+ }, {}),
35
+ stepGraph: workflow.stepGraph,
36
+ inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
37
+ outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
38
+ };
39
+ return acc;
40
+ }, {});
41
+ return _workflows;
42
+ } catch (error) {
43
+ throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
44
+ }
45
+ }
46
+ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
47
+ try {
48
+ if (!workflowId) {
49
+ throw new HTTPException(400, { message: "Workflow ID is required" });
50
+ }
51
+ const workflow = mastra.vnext_getWorkflow(workflowId);
52
+ if (!workflow) {
53
+ throw new HTTPException(404, { message: "Workflow not found" });
54
+ }
55
+ return {
56
+ steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
57
+ acc[key] = {
58
+ ...step,
59
+ inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
60
+ outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
61
+ resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0
62
+ };
63
+ return acc;
64
+ }, {}),
65
+ name: workflow.name,
66
+ stepGraph: workflow.stepGraph,
67
+ inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
68
+ outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
69
+ };
70
+ } catch (error) {
71
+ throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
72
+ }
73
+ }
74
+ async function getVNextWorkflowRunHandler({
75
+ mastra,
76
+ workflowId,
77
+ runId
78
+ }) {
79
+ try {
80
+ if (!workflowId) {
81
+ throw new HTTPException(400, { message: "Workflow ID is required" });
82
+ }
83
+ if (!runId) {
84
+ throw new HTTPException(400, { message: "Run ID is required" });
85
+ }
86
+ const workflow = mastra.vnext_getWorkflow(workflowId);
87
+ if (!workflow) {
88
+ throw new HTTPException(404, { message: "Workflow not found" });
89
+ }
90
+ const run = await workflow.getWorkflowRun(runId);
91
+ if (!run) {
92
+ throw new HTTPException(404, { message: "Workflow run not found" });
93
+ }
94
+ return run;
95
+ } catch (error) {
96
+ throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
97
+ }
98
+ }
99
+ async function createVNextWorkflowRunHandler({
100
+ mastra,
101
+ workflowId,
102
+ runId: prevRunId
103
+ }) {
104
+ try {
105
+ if (!workflowId) {
106
+ throw new HTTPException(400, { message: "Workflow ID is required" });
107
+ }
108
+ const workflow = mastra.vnext_getWorkflow(workflowId);
109
+ if (!workflow) {
110
+ throw new HTTPException(404, { message: "Workflow not found" });
111
+ }
112
+ const run = workflow.createRun({ runId: prevRunId });
113
+ return { runId: run.runId };
114
+ } catch (error) {
115
+ throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
116
+ }
117
+ }
118
+ async function startAsyncVNextWorkflowHandler({
119
+ mastra,
120
+ runtimeContext,
121
+ workflowId,
122
+ runId,
123
+ inputData
124
+ }) {
125
+ try {
126
+ if (!workflowId) {
127
+ throw new HTTPException(400, { message: "Workflow ID is required" });
128
+ }
129
+ const workflow = mastra.vnext_getWorkflow(workflowId);
130
+ if (!workflow) {
131
+ throw new HTTPException(404, { message: "Workflow not found" });
132
+ }
133
+ const _run = workflow.createRun({ runId });
134
+ const result = await _run.start({
135
+ inputData,
136
+ runtimeContext
137
+ });
138
+ return result;
139
+ } catch (error) {
140
+ throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
141
+ }
142
+ }
143
+ async function startVNextWorkflowRunHandler({
144
+ mastra,
145
+ runtimeContext,
146
+ workflowId,
147
+ runId,
148
+ inputData
149
+ }) {
150
+ try {
151
+ if (!workflowId) {
152
+ throw new HTTPException(400, { message: "Workflow ID is required" });
153
+ }
154
+ if (!runId) {
155
+ throw new HTTPException(400, { message: "runId required to start run" });
156
+ }
157
+ const workflow = mastra.vnext_getWorkflow(workflowId);
158
+ const run = await workflow.getWorkflowRun(runId);
159
+ if (!run) {
160
+ throw new HTTPException(404, { message: "Workflow run not found" });
161
+ }
162
+ const _run = workflow.createRun({ runId });
163
+ await _run.start({
164
+ inputData,
165
+ runtimeContext
166
+ });
167
+ return { message: "Workflow run started" };
168
+ } catch (e) {
169
+ return handleError(e, "Error starting workflow run");
170
+ }
171
+ }
172
+ async function watchVNextWorkflowHandler({
173
+ mastra,
174
+ workflowId,
175
+ runId
176
+ }) {
177
+ try {
178
+ if (!workflowId) {
179
+ throw new HTTPException(400, { message: "Workflow ID is required" });
180
+ }
181
+ if (!runId) {
182
+ throw new HTTPException(400, { message: "runId required to watch workflow" });
183
+ }
184
+ const workflow = mastra.vnext_getWorkflow(workflowId);
185
+ const run = await workflow.getWorkflowRun(runId);
186
+ if (!run) {
187
+ throw new HTTPException(404, { message: "Workflow run not found" });
188
+ }
189
+ const _run = workflow.createRun({ runId });
190
+ let unwatch;
191
+ let asyncRef = null;
192
+ const stream = new ReadableStream({
193
+ start(controller) {
194
+ unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
195
+ controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
196
+ if (asyncRef) {
197
+ clearImmediate(asyncRef);
198
+ asyncRef = null;
199
+ }
200
+ asyncRef = setImmediate(async () => {
201
+ const runDone = payload.workflowState.status !== "running";
202
+ if (runDone) {
203
+ controller.close();
204
+ unwatch?.();
205
+ }
206
+ });
207
+ });
208
+ },
209
+ cancel() {
210
+ unwatch?.();
211
+ }
212
+ });
213
+ return stream;
214
+ } catch (error) {
215
+ return handleError(error, "Error watching workflow");
216
+ }
217
+ }
218
+ async function resumeAsyncVNextWorkflowHandler({
219
+ mastra,
220
+ workflowId,
221
+ runId,
222
+ body,
223
+ runtimeContext
224
+ }) {
225
+ try {
226
+ if (!workflowId) {
227
+ throw new HTTPException(400, { message: "Workflow ID is required" });
228
+ }
229
+ if (!runId) {
230
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
231
+ }
232
+ if (!body.step) {
233
+ throw new HTTPException(400, { message: "step required to resume workflow" });
234
+ }
235
+ const workflow = mastra.vnext_getWorkflow(workflowId);
236
+ const run = await workflow.getWorkflowRun(runId);
237
+ if (!run) {
238
+ throw new HTTPException(404, { message: "Workflow run not found" });
239
+ }
240
+ const _run = workflow.createRun({ runId });
241
+ const result = await _run.resume({
242
+ step: body.step,
243
+ resumeData: body.resumeData,
244
+ runtimeContext
245
+ });
246
+ return result;
247
+ } catch (error) {
248
+ return handleError(error, "Error resuming workflow step");
249
+ }
250
+ }
251
+ async function resumeVNextWorkflowHandler({
252
+ mastra,
253
+ workflowId,
254
+ runId,
255
+ body,
256
+ runtimeContext
257
+ }) {
258
+ try {
259
+ if (!workflowId) {
260
+ throw new HTTPException(400, { message: "Workflow ID is required" });
261
+ }
262
+ if (!runId) {
263
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
264
+ }
265
+ if (!body.step) {
266
+ throw new HTTPException(400, { message: "step required to resume workflow" });
267
+ }
268
+ const workflow = mastra.vnext_getWorkflow(workflowId);
269
+ const run = await workflow.getWorkflowRun(runId);
270
+ if (!run) {
271
+ throw new HTTPException(404, { message: "Workflow run not found" });
272
+ }
273
+ const _run = workflow.createRun({ runId });
274
+ await _run.resume({
275
+ step: body.step,
276
+ resumeData: body.resumeData,
277
+ runtimeContext
278
+ });
279
+ return { message: "Workflow run resumed" };
280
+ } catch (error) {
281
+ return handleError(error, "Error resuming workflow");
282
+ }
283
+ }
284
+ async function getVNextWorkflowRunsHandler({ mastra, workflowId }) {
285
+ try {
286
+ if (!workflowId) {
287
+ throw new HTTPException(400, { message: "Workflow ID is required" });
288
+ }
289
+ const workflow = mastra.vnext_getWorkflow(workflowId);
290
+ const workflowRuns = await workflow.getWorkflowRuns() || {
291
+ runs: [],
292
+ total: 0
293
+ };
294
+ return workflowRuns;
295
+ } catch (error) {
296
+ return handleError(error, "Error getting workflow runs");
297
+ }
298
+ }
299
+
300
+ export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };
@@ -1,4 +1,4 @@
1
- import { stringify, esm_default } from './chunk-VK6FX47H.js';
1
+ import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
2
  import { handleError } from './chunk-3AHQ5RGN.js';
3
3
  import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
4
  import { ReadableStream } from 'node:stream/web';
@@ -78,7 +78,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
78
78
  }
79
79
  async function startAsyncWorkflowHandler({
80
80
  mastra,
81
- container,
81
+ runtimeContext,
82
82
  workflowId,
83
83
  runId,
84
84
  triggerData
@@ -95,7 +95,7 @@ async function startAsyncWorkflowHandler({
95
95
  const { start } = workflow.createRun();
96
96
  const result2 = await start({
97
97
  triggerData,
98
- container
98
+ runtimeContext
99
99
  });
100
100
  return result2;
101
101
  }
@@ -105,7 +105,7 @@ async function startAsyncWorkflowHandler({
105
105
  }
106
106
  const result = await run.start({
107
107
  triggerData,
108
- container
108
+ runtimeContext
109
109
  });
110
110
  return result;
111
111
  } catch (error) {
@@ -158,7 +158,7 @@ async function createRunHandler({
158
158
  }
159
159
  async function startWorkflowRunHandler({
160
160
  mastra,
161
- container,
161
+ runtimeContext,
162
162
  workflowId,
163
163
  runId,
164
164
  triggerData
@@ -177,7 +177,7 @@ async function startWorkflowRunHandler({
177
177
  }
178
178
  await run.start({
179
179
  triggerData,
180
- container
180
+ runtimeContext
181
181
  });
182
182
  return { message: "Workflow run started" };
183
183
  } catch (e) {
@@ -233,7 +233,7 @@ async function resumeAsyncWorkflowHandler({
233
233
  workflowId,
234
234
  runId,
235
235
  body,
236
- container
236
+ runtimeContext
237
237
  }) {
238
238
  try {
239
239
  if (!workflowId) {
@@ -250,7 +250,7 @@ async function resumeAsyncWorkflowHandler({
250
250
  const result = await run.resume({
251
251
  stepId: body.stepId,
252
252
  context: body.context,
253
- container
253
+ runtimeContext
254
254
  });
255
255
  return result;
256
256
  } catch (error) {
@@ -262,7 +262,7 @@ async function resumeWorkflowHandler({
262
262
  workflowId,
263
263
  runId,
264
264
  body,
265
- container
265
+ runtimeContext
266
266
  }) {
267
267
  try {
268
268
  if (!workflowId) {
@@ -279,7 +279,7 @@ async function resumeWorkflowHandler({
279
279
  await run.resume({
280
280
  stepId: body.stepId,
281
281
  context: body.context,
282
- container
282
+ runtimeContext
283
283
  });
284
284
  return { message: "Workflow run resumed" };
285
285
  } catch (error) {