@mastra/server 0.0.0-mcp-server-update-parse-20250421171139 → 0.0.0-mcp-server-deploy-20250507160341
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.
- package/dist/_tsup-dts-rollup.d.cts +217 -42
- package/dist/_tsup-dts-rollup.d.ts +217 -42
- package/dist/{chunk-4B7OUZXW.js → chunk-3XTEV33Q.js} +25 -13
- package/dist/{chunk-4WJ5GHRG.cjs → chunk-4BIX6GMY.cjs} +56 -31
- package/dist/{chunk-A7DF4ETD.cjs → chunk-55HTWX4C.cjs} +2 -9
- package/dist/{chunk-XISBMH56.js → chunk-5JNVY6DU.js} +4 -4
- package/dist/{chunk-JLDXUWK7.cjs → chunk-5YGDYMRB.cjs} +52 -31
- package/dist/chunk-74DLDQTQ.cjs +36 -0
- package/dist/{chunk-7IWQE76Z.cjs → chunk-AMVOS7YB.cjs} +4 -2
- package/dist/{chunk-WTHDCRMY.js → chunk-BPL2CBLV.js} +4 -2
- package/dist/{chunk-RNU4JMLM.cjs → chunk-CHFORQ7J.cjs} +25 -13
- package/dist/{chunk-HABV7TZK.cjs → chunk-D3G23FP3.cjs} +4 -4
- package/dist/chunk-FOXHTOQZ.cjs +324 -0
- package/dist/chunk-HAA5T7JL.js +33 -0
- package/dist/chunk-IQTNZSFP.js +312 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-Q6SHQECN.js} +2 -9
- package/dist/{chunk-YANVFOYA.js → chunk-QJ3AHN64.js} +52 -31
- package/dist/{chunk-TFFNX7FI.js → chunk-Y3SV5XK4.js} +56 -31
- package/dist/index.cjs +12 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/mcp.cjs +14 -0
- package/dist/server/handlers/mcp.d.cts +2 -0
- package/dist/server/handlers/mcp.d.ts +2 -0
- package/dist/server/handlers/mcp.js +1 -0
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/vNextWorkflows.cjs +46 -0
- package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
- package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
- package/dist/server/handlers/vNextWorkflows.js +1 -0
- package/dist/server/handlers/voice.cjs +4 -4
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +11 -11
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +20 -15
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +7 -6
- package/package.json +5 -5
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
'use strict';
|
|
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');
|
|
6
|
+
var web = require('stream/web');
|
|
7
|
+
|
|
8
|
+
// src/server/handlers/vNextWorkflows.ts
|
|
9
|
+
var vNextWorkflows_exports = {};
|
|
10
|
+
chunkFV45V6WC_cjs.__export(vNextWorkflows_exports, {
|
|
11
|
+
createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
|
|
12
|
+
getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
|
|
13
|
+
getVNextWorkflowRunHandler: () => getVNextWorkflowRunHandler,
|
|
14
|
+
getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
|
|
15
|
+
getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
|
|
16
|
+
resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
|
|
17
|
+
resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
|
|
18
|
+
startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
|
|
19
|
+
startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
|
|
20
|
+
watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
|
|
21
|
+
});
|
|
22
|
+
async function getVNextWorkflowsHandler({ mastra }) {
|
|
23
|
+
try {
|
|
24
|
+
const workflows = mastra.vnext_getWorkflows({ serialized: false });
|
|
25
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
26
|
+
acc[key] = {
|
|
27
|
+
name: workflow.name,
|
|
28
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
29
|
+
acc2[key2] = {
|
|
30
|
+
id: step.id,
|
|
31
|
+
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
|
|
36
|
+
};
|
|
37
|
+
return acc2;
|
|
38
|
+
}, {}),
|
|
39
|
+
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
|
+
};
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
45
|
+
return _workflows;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
51
|
+
try {
|
|
52
|
+
if (!workflowId) {
|
|
53
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
54
|
+
}
|
|
55
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
56
|
+
if (!workflow) {
|
|
57
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
61
|
+
acc[key] = {
|
|
62
|
+
id: step.id,
|
|
63
|
+
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
|
|
68
|
+
};
|
|
69
|
+
return acc;
|
|
70
|
+
}, {}),
|
|
71
|
+
name: workflow.name,
|
|
72
|
+
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
|
+
};
|
|
76
|
+
} catch (error) {
|
|
77
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function getVNextWorkflowRunHandler({
|
|
81
|
+
mastra,
|
|
82
|
+
workflowId,
|
|
83
|
+
runId
|
|
84
|
+
}) {
|
|
85
|
+
try {
|
|
86
|
+
if (!workflowId) {
|
|
87
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
88
|
+
}
|
|
89
|
+
if (!runId) {
|
|
90
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
91
|
+
}
|
|
92
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
93
|
+
if (!workflow) {
|
|
94
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
95
|
+
}
|
|
96
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
97
|
+
if (!run) {
|
|
98
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
99
|
+
}
|
|
100
|
+
return run;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function createVNextWorkflowRunHandler({
|
|
106
|
+
mastra,
|
|
107
|
+
workflowId,
|
|
108
|
+
runId: prevRunId
|
|
109
|
+
}) {
|
|
110
|
+
try {
|
|
111
|
+
if (!workflowId) {
|
|
112
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
113
|
+
}
|
|
114
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
115
|
+
if (!workflow) {
|
|
116
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
117
|
+
}
|
|
118
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
119
|
+
return { runId: run.runId };
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async function startAsyncVNextWorkflowHandler({
|
|
125
|
+
mastra,
|
|
126
|
+
runtimeContext,
|
|
127
|
+
workflowId,
|
|
128
|
+
runId,
|
|
129
|
+
inputData
|
|
130
|
+
}) {
|
|
131
|
+
try {
|
|
132
|
+
if (!workflowId) {
|
|
133
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
134
|
+
}
|
|
135
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
136
|
+
if (!workflow) {
|
|
137
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
138
|
+
}
|
|
139
|
+
const _run = workflow.createRun({ runId });
|
|
140
|
+
const result = await _run.start({
|
|
141
|
+
inputData,
|
|
142
|
+
runtimeContext
|
|
143
|
+
});
|
|
144
|
+
return result;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function startVNextWorkflowRunHandler({
|
|
150
|
+
mastra,
|
|
151
|
+
runtimeContext,
|
|
152
|
+
workflowId,
|
|
153
|
+
runId,
|
|
154
|
+
inputData
|
|
155
|
+
}) {
|
|
156
|
+
try {
|
|
157
|
+
if (!workflowId) {
|
|
158
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
159
|
+
}
|
|
160
|
+
if (!runId) {
|
|
161
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
162
|
+
}
|
|
163
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
164
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
165
|
+
if (!run) {
|
|
166
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
167
|
+
}
|
|
168
|
+
const _run = workflow.createRun({ runId });
|
|
169
|
+
await _run.start({
|
|
170
|
+
inputData,
|
|
171
|
+
runtimeContext
|
|
172
|
+
});
|
|
173
|
+
return { message: "Workflow run started" };
|
|
174
|
+
} catch (e) {
|
|
175
|
+
return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function watchVNextWorkflowHandler({
|
|
179
|
+
mastra,
|
|
180
|
+
workflowId,
|
|
181
|
+
runId
|
|
182
|
+
}) {
|
|
183
|
+
try {
|
|
184
|
+
if (!workflowId) {
|
|
185
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
186
|
+
}
|
|
187
|
+
if (!runId) {
|
|
188
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
189
|
+
}
|
|
190
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
191
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
192
|
+
if (!run) {
|
|
193
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
194
|
+
}
|
|
195
|
+
const _run = workflow.createRun({ runId });
|
|
196
|
+
let unwatch;
|
|
197
|
+
let asyncRef = null;
|
|
198
|
+
const stream = new web.ReadableStream({
|
|
199
|
+
start(controller) {
|
|
200
|
+
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
201
|
+
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
202
|
+
if (asyncRef) {
|
|
203
|
+
clearImmediate(asyncRef);
|
|
204
|
+
asyncRef = null;
|
|
205
|
+
}
|
|
206
|
+
asyncRef = setImmediate(async () => {
|
|
207
|
+
const runDone = payload.workflowState.status !== "running";
|
|
208
|
+
if (runDone) {
|
|
209
|
+
controller.close();
|
|
210
|
+
unwatch?.();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
cancel() {
|
|
216
|
+
unwatch?.();
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return stream;
|
|
220
|
+
} catch (error) {
|
|
221
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async function resumeAsyncVNextWorkflowHandler({
|
|
225
|
+
mastra,
|
|
226
|
+
workflowId,
|
|
227
|
+
runId,
|
|
228
|
+
body,
|
|
229
|
+
runtimeContext
|
|
230
|
+
}) {
|
|
231
|
+
try {
|
|
232
|
+
if (!workflowId) {
|
|
233
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
234
|
+
}
|
|
235
|
+
if (!runId) {
|
|
236
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
237
|
+
}
|
|
238
|
+
if (!body.step) {
|
|
239
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
240
|
+
}
|
|
241
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
242
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
243
|
+
if (!run) {
|
|
244
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
245
|
+
}
|
|
246
|
+
const _run = workflow.createRun({ runId });
|
|
247
|
+
const result = await _run.resume({
|
|
248
|
+
step: body.step,
|
|
249
|
+
resumeData: body.resumeData,
|
|
250
|
+
runtimeContext
|
|
251
|
+
});
|
|
252
|
+
return result;
|
|
253
|
+
} catch (error) {
|
|
254
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function resumeVNextWorkflowHandler({
|
|
258
|
+
mastra,
|
|
259
|
+
workflowId,
|
|
260
|
+
runId,
|
|
261
|
+
body,
|
|
262
|
+
runtimeContext
|
|
263
|
+
}) {
|
|
264
|
+
try {
|
|
265
|
+
if (!workflowId) {
|
|
266
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
267
|
+
}
|
|
268
|
+
if (!runId) {
|
|
269
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
270
|
+
}
|
|
271
|
+
if (!body.step) {
|
|
272
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
273
|
+
}
|
|
274
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
275
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
276
|
+
if (!run) {
|
|
277
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
278
|
+
}
|
|
279
|
+
const _run = workflow.createRun({ runId });
|
|
280
|
+
await _run.resume({
|
|
281
|
+
step: body.step,
|
|
282
|
+
resumeData: body.resumeData,
|
|
283
|
+
runtimeContext
|
|
284
|
+
});
|
|
285
|
+
return { message: "Workflow run resumed" };
|
|
286
|
+
} catch (error) {
|
|
287
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async function getVNextWorkflowRunsHandler({
|
|
291
|
+
mastra,
|
|
292
|
+
workflowId,
|
|
293
|
+
fromDate,
|
|
294
|
+
toDate,
|
|
295
|
+
limit,
|
|
296
|
+
offset,
|
|
297
|
+
resourceId
|
|
298
|
+
}) {
|
|
299
|
+
try {
|
|
300
|
+
if (!workflowId) {
|
|
301
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
302
|
+
}
|
|
303
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
304
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
305
|
+
runs: [],
|
|
306
|
+
total: 0
|
|
307
|
+
};
|
|
308
|
+
return workflowRuns;
|
|
309
|
+
} catch (error) {
|
|
310
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
exports.createVNextWorkflowRunHandler = createVNextWorkflowRunHandler;
|
|
315
|
+
exports.getVNextWorkflowByIdHandler = getVNextWorkflowByIdHandler;
|
|
316
|
+
exports.getVNextWorkflowRunHandler = getVNextWorkflowRunHandler;
|
|
317
|
+
exports.getVNextWorkflowRunsHandler = getVNextWorkflowRunsHandler;
|
|
318
|
+
exports.getVNextWorkflowsHandler = getVNextWorkflowsHandler;
|
|
319
|
+
exports.resumeAsyncVNextWorkflowHandler = resumeAsyncVNextWorkflowHandler;
|
|
320
|
+
exports.resumeVNextWorkflowHandler = resumeVNextWorkflowHandler;
|
|
321
|
+
exports.startAsyncVNextWorkflowHandler = startAsyncVNextWorkflowHandler;
|
|
322
|
+
exports.startVNextWorkflowRunHandler = startVNextWorkflowRunHandler;
|
|
323
|
+
exports.vNextWorkflows_exports = vNextWorkflows_exports;
|
|
324
|
+
exports.watchVNextWorkflowHandler = watchVNextWorkflowHandler;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HTTPException } from './chunk-TRDNDNGQ.js';
|
|
2
|
+
|
|
3
|
+
// src/server/handlers/mcp.ts
|
|
4
|
+
var getMcpServersHandler = async ({ mastra }) => {
|
|
5
|
+
const servers = mastra.getMCPServers();
|
|
6
|
+
return {
|
|
7
|
+
servers: servers.map((server) => ({
|
|
8
|
+
id: server.name,
|
|
9
|
+
name: server.name,
|
|
10
|
+
version: server.version,
|
|
11
|
+
tools: Object.keys(server.tools()).length
|
|
12
|
+
}))
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
var getMcpServerHandler = async ({ mastra, serverId }) => {
|
|
16
|
+
const server = mastra.getMCPServer(serverId);
|
|
17
|
+
if (!server) {
|
|
18
|
+
throw new HTTPException(404, { message: `MCP server '${serverId}' not found` });
|
|
19
|
+
}
|
|
20
|
+
const tools = server.tools();
|
|
21
|
+
return {
|
|
22
|
+
id: server.name,
|
|
23
|
+
name: server.name,
|
|
24
|
+
version: server.version,
|
|
25
|
+
tools: Object.entries(tools).map(([name, tool]) => ({
|
|
26
|
+
name,
|
|
27
|
+
description: tool.description,
|
|
28
|
+
parameters: tool.parameters
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { getMcpServerHandler, getMcpServersHandler };
|
|
@@ -0,0 +1,312 @@
|
|
|
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({
|
|
289
|
+
mastra,
|
|
290
|
+
workflowId,
|
|
291
|
+
fromDate,
|
|
292
|
+
toDate,
|
|
293
|
+
limit,
|
|
294
|
+
offset,
|
|
295
|
+
resourceId
|
|
296
|
+
}) {
|
|
297
|
+
try {
|
|
298
|
+
if (!workflowId) {
|
|
299
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
300
|
+
}
|
|
301
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
302
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
303
|
+
runs: [],
|
|
304
|
+
total: 0
|
|
305
|
+
};
|
|
306
|
+
return workflowRuns;
|
|
307
|
+
} catch (error) {
|
|
308
|
+
return handleError(error, "Error getting workflow runs");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };
|
|
@@ -38,9 +38,7 @@ async function generateSpeechHandler({
|
|
|
38
38
|
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
39
39
|
}
|
|
40
40
|
validateBody({
|
|
41
|
-
text:
|
|
42
|
-
speakerId: void 0,
|
|
43
|
-
...body
|
|
41
|
+
text: body?.text
|
|
44
42
|
});
|
|
45
43
|
const agent = mastra.getAgent(agentId);
|
|
46
44
|
if (!agent) {
|
|
@@ -53,12 +51,7 @@ async function generateSpeechHandler({
|
|
|
53
51
|
if (!audioStream) {
|
|
54
52
|
throw new HTTPException(500, { message: "Failed to generate speech" });
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
for await (const chunk of audioStream) {
|
|
58
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
59
|
-
}
|
|
60
|
-
const audioData = Buffer.concat(chunks);
|
|
61
|
-
return { audioData };
|
|
54
|
+
return audioStream;
|
|
62
55
|
} catch (error) {
|
|
63
56
|
return handleError(error, "Error generating speech");
|
|
64
57
|
}
|