@mastra/server 0.0.0-revert-schema-20250416221206 → 0.0.0-separate-trace-data-from-component-20250501042644

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