@mastra/server 0.0.0-switch-to-core-20250424015131 → 0.0.0-vector-query-sources-20250516172905
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/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +258 -13
- package/dist/_tsup-dts-rollup.d.ts +258 -13
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/chunk-5SN4U5AC.cjs +508 -0
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-RE6YL32K.js → chunk-C7564HUT.js} +52 -30
- package/dist/chunk-D4IRYCUI.cjs +235 -0
- package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
- package/dist/{chunk-LFOBHRFO.js → chunk-EJO45KYT.js} +35 -20
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
- package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
- package/dist/{chunk-TZK63M5N.cjs → chunk-I2B73Y4I.cjs} +76 -61
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/{chunk-7IWQE76Z.cjs → chunk-MHKNLNAN.cjs} +13 -10
- package/dist/chunk-MIQYDLLM.js +329 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
- package/dist/{chunk-WTHDCRMY.js → chunk-OR3CIE2H.js} +7 -4
- package/dist/chunk-P6SCPDYW.js +500 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/chunk-UCTEMO2Q.cjs +341 -0
- package/dist/{chunk-FPIWDH5Y.cjs → chunk-VPNDC2DI.cjs} +62 -40
- package/dist/chunk-WUC6LSTW.js +227 -0
- package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
- package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
- package/dist/chunk-YWLUOY3D.cjs +2004 -0
- package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- 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/utils.cjs +2 -2
- package/dist/server/handlers/utils.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/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- 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 +31 -21
- package/dist/server/handlers.d.cts +2 -0
- package/dist/server/handlers.d.ts +2 -0
- package/dist/server/handlers.js +11 -9
- package/package.json +8 -6
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-HCOPJZ4A.cjs +0 -164
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-R4J7XQYU.js +0 -156
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
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');
|
|
7
|
+
var web = require('stream/web');
|
|
8
|
+
var di = require('@mastra/core/di');
|
|
9
|
+
|
|
10
|
+
// src/server/handlers/vNextWorkflows.ts
|
|
11
|
+
var vNextWorkflows_exports = {};
|
|
12
|
+
chunk75ZPJI57_cjs.__export(vNextWorkflows_exports, {
|
|
13
|
+
createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
|
|
14
|
+
getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
|
|
15
|
+
getVNextWorkflowRunByIdHandler: () => getVNextWorkflowRunByIdHandler,
|
|
16
|
+
getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
|
|
17
|
+
getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
|
|
18
|
+
resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
|
|
19
|
+
resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
|
|
20
|
+
startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
|
|
21
|
+
startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
|
|
22
|
+
watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
|
|
23
|
+
});
|
|
24
|
+
async function getVNextWorkflowsHandler({ mastra }) {
|
|
25
|
+
try {
|
|
26
|
+
const workflows = mastra.vnext_getWorkflows({ serialized: false });
|
|
27
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
28
|
+
acc[key] = {
|
|
29
|
+
name: workflow.name,
|
|
30
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
31
|
+
acc2[key2] = {
|
|
32
|
+
id: step.id,
|
|
33
|
+
description: step.description,
|
|
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
|
|
38
|
+
};
|
|
39
|
+
return acc2;
|
|
40
|
+
}, {}),
|
|
41
|
+
stepGraph: workflow.serializedStepGraph,
|
|
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
|
|
44
|
+
};
|
|
45
|
+
return acc;
|
|
46
|
+
}, {});
|
|
47
|
+
return _workflows;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
53
|
+
try {
|
|
54
|
+
if (!workflowId) {
|
|
55
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
56
|
+
}
|
|
57
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
58
|
+
if (!workflow) {
|
|
59
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
63
|
+
acc[key] = {
|
|
64
|
+
id: step.id,
|
|
65
|
+
description: step.description,
|
|
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
|
|
70
|
+
};
|
|
71
|
+
return acc;
|
|
72
|
+
}, {}),
|
|
73
|
+
name: workflow.name,
|
|
74
|
+
stepGraph: workflow.serializedStepGraph,
|
|
75
|
+
inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
76
|
+
outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function getVNextWorkflowRunByIdHandler({
|
|
83
|
+
mastra,
|
|
84
|
+
workflowId,
|
|
85
|
+
runId
|
|
86
|
+
}) {
|
|
87
|
+
try {
|
|
88
|
+
if (!workflowId) {
|
|
89
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
90
|
+
}
|
|
91
|
+
if (!runId) {
|
|
92
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
93
|
+
}
|
|
94
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
95
|
+
if (!workflow) {
|
|
96
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
97
|
+
}
|
|
98
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
99
|
+
if (!run) {
|
|
100
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
101
|
+
}
|
|
102
|
+
return run;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function createVNextWorkflowRunHandler({
|
|
108
|
+
mastra,
|
|
109
|
+
workflowId,
|
|
110
|
+
runId: prevRunId
|
|
111
|
+
}) {
|
|
112
|
+
try {
|
|
113
|
+
if (!workflowId) {
|
|
114
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
115
|
+
}
|
|
116
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
117
|
+
if (!workflow) {
|
|
118
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
119
|
+
}
|
|
120
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
121
|
+
return { runId: run.runId };
|
|
122
|
+
} catch (error) {
|
|
123
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function startAsyncVNextWorkflowHandler({
|
|
127
|
+
mastra,
|
|
128
|
+
runtimeContext,
|
|
129
|
+
workflowId,
|
|
130
|
+
runId,
|
|
131
|
+
inputData,
|
|
132
|
+
runtimeContextFromRequest
|
|
133
|
+
}) {
|
|
134
|
+
try {
|
|
135
|
+
if (!workflowId) {
|
|
136
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
137
|
+
}
|
|
138
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
139
|
+
if (!workflow) {
|
|
140
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
141
|
+
}
|
|
142
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
143
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
144
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
145
|
+
]);
|
|
146
|
+
const _run = workflow.createRun({ runId });
|
|
147
|
+
const result = await _run.start({
|
|
148
|
+
inputData,
|
|
149
|
+
runtimeContext: finalRuntimeContext
|
|
150
|
+
});
|
|
151
|
+
return result;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function startVNextWorkflowRunHandler({
|
|
157
|
+
mastra,
|
|
158
|
+
runtimeContext,
|
|
159
|
+
workflowId,
|
|
160
|
+
runId,
|
|
161
|
+
inputData,
|
|
162
|
+
runtimeContextFromRequest
|
|
163
|
+
}) {
|
|
164
|
+
try {
|
|
165
|
+
if (!workflowId) {
|
|
166
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
167
|
+
}
|
|
168
|
+
if (!runId) {
|
|
169
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
170
|
+
}
|
|
171
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
172
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
173
|
+
if (!run) {
|
|
174
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
175
|
+
}
|
|
176
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
177
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
178
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
179
|
+
]);
|
|
180
|
+
const _run = workflow.createRun({ runId });
|
|
181
|
+
void _run.start({
|
|
182
|
+
inputData,
|
|
183
|
+
runtimeContext: finalRuntimeContext
|
|
184
|
+
});
|
|
185
|
+
return { message: "Workflow run started" };
|
|
186
|
+
} catch (e) {
|
|
187
|
+
return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async function watchVNextWorkflowHandler({
|
|
191
|
+
mastra,
|
|
192
|
+
workflowId,
|
|
193
|
+
runId
|
|
194
|
+
}) {
|
|
195
|
+
try {
|
|
196
|
+
if (!workflowId) {
|
|
197
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
198
|
+
}
|
|
199
|
+
if (!runId) {
|
|
200
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
201
|
+
}
|
|
202
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
203
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
204
|
+
if (!run) {
|
|
205
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
206
|
+
}
|
|
207
|
+
const _run = workflow.createRun({ runId });
|
|
208
|
+
let unwatch;
|
|
209
|
+
let asyncRef = null;
|
|
210
|
+
const stream = new web.ReadableStream({
|
|
211
|
+
start(controller) {
|
|
212
|
+
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
213
|
+
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
214
|
+
if (asyncRef) {
|
|
215
|
+
clearImmediate(asyncRef);
|
|
216
|
+
asyncRef = null;
|
|
217
|
+
}
|
|
218
|
+
asyncRef = setImmediate(async () => {
|
|
219
|
+
const runDone = payload.workflowState.status !== "running";
|
|
220
|
+
if (runDone) {
|
|
221
|
+
controller.close();
|
|
222
|
+
unwatch?.();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
cancel() {
|
|
228
|
+
unwatch?.();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return stream;
|
|
232
|
+
} catch (error) {
|
|
233
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async function resumeAsyncVNextWorkflowHandler({
|
|
237
|
+
mastra,
|
|
238
|
+
workflowId,
|
|
239
|
+
runId,
|
|
240
|
+
body,
|
|
241
|
+
runtimeContext,
|
|
242
|
+
runtimeContextFromRequest
|
|
243
|
+
}) {
|
|
244
|
+
try {
|
|
245
|
+
if (!workflowId) {
|
|
246
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
247
|
+
}
|
|
248
|
+
if (!runId) {
|
|
249
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
250
|
+
}
|
|
251
|
+
if (!body.step) {
|
|
252
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
253
|
+
}
|
|
254
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
255
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
256
|
+
if (!run) {
|
|
257
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
258
|
+
}
|
|
259
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
260
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
261
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
262
|
+
]);
|
|
263
|
+
const _run = workflow.createRun({ runId });
|
|
264
|
+
const result = await _run.resume({
|
|
265
|
+
step: body.step,
|
|
266
|
+
resumeData: body.resumeData,
|
|
267
|
+
runtimeContext: finalRuntimeContext
|
|
268
|
+
});
|
|
269
|
+
return result;
|
|
270
|
+
} catch (error) {
|
|
271
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function resumeVNextWorkflowHandler({
|
|
275
|
+
mastra,
|
|
276
|
+
workflowId,
|
|
277
|
+
runId,
|
|
278
|
+
body,
|
|
279
|
+
runtimeContext
|
|
280
|
+
}) {
|
|
281
|
+
try {
|
|
282
|
+
if (!workflowId) {
|
|
283
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
284
|
+
}
|
|
285
|
+
if (!runId) {
|
|
286
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
287
|
+
}
|
|
288
|
+
if (!body.step) {
|
|
289
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
290
|
+
}
|
|
291
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
292
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
293
|
+
if (!run) {
|
|
294
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
295
|
+
}
|
|
296
|
+
const _run = workflow.createRun({ runId });
|
|
297
|
+
void _run.resume({
|
|
298
|
+
step: body.step,
|
|
299
|
+
resumeData: body.resumeData,
|
|
300
|
+
runtimeContext
|
|
301
|
+
});
|
|
302
|
+
return { message: "Workflow run resumed" };
|
|
303
|
+
} catch (error) {
|
|
304
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async function getVNextWorkflowRunsHandler({
|
|
308
|
+
mastra,
|
|
309
|
+
workflowId,
|
|
310
|
+
fromDate,
|
|
311
|
+
toDate,
|
|
312
|
+
limit,
|
|
313
|
+
offset,
|
|
314
|
+
resourceId
|
|
315
|
+
}) {
|
|
316
|
+
try {
|
|
317
|
+
if (!workflowId) {
|
|
318
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
319
|
+
}
|
|
320
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
321
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
322
|
+
runs: [],
|
|
323
|
+
total: 0
|
|
324
|
+
};
|
|
325
|
+
return workflowRuns;
|
|
326
|
+
} catch (error) {
|
|
327
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
exports.createVNextWorkflowRunHandler = createVNextWorkflowRunHandler;
|
|
332
|
+
exports.getVNextWorkflowByIdHandler = getVNextWorkflowByIdHandler;
|
|
333
|
+
exports.getVNextWorkflowRunByIdHandler = getVNextWorkflowRunByIdHandler;
|
|
334
|
+
exports.getVNextWorkflowRunsHandler = getVNextWorkflowRunsHandler;
|
|
335
|
+
exports.getVNextWorkflowsHandler = getVNextWorkflowsHandler;
|
|
336
|
+
exports.resumeAsyncVNextWorkflowHandler = resumeAsyncVNextWorkflowHandler;
|
|
337
|
+
exports.resumeVNextWorkflowHandler = resumeVNextWorkflowHandler;
|
|
338
|
+
exports.startAsyncVNextWorkflowHandler = startAsyncVNextWorkflowHandler;
|
|
339
|
+
exports.startVNextWorkflowRunHandler = startVNextWorkflowRunHandler;
|
|
340
|
+
exports.vNextWorkflows_exports = vNextWorkflows_exports;
|
|
341
|
+
exports.watchVNextWorkflowHandler = watchVNextWorkflowHandler;
|
|
@@ -1,44 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.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
|
|
|
7
8
|
// src/server/handlers/network.ts
|
|
8
9
|
var network_exports = {};
|
|
9
|
-
|
|
10
|
+
chunk75ZPJI57_cjs.__export(network_exports, {
|
|
10
11
|
generateHandler: () => generateHandler,
|
|
11
12
|
getNetworkByIdHandler: () => getNetworkByIdHandler,
|
|
12
13
|
getNetworksHandler: () => getNetworksHandler,
|
|
13
14
|
streamGenerateHandler: () => streamGenerateHandler
|
|
14
15
|
});
|
|
15
|
-
async function getNetworksHandler({
|
|
16
|
+
async function getNetworksHandler({
|
|
17
|
+
mastra,
|
|
18
|
+
runtimeContext
|
|
19
|
+
}) {
|
|
16
20
|
try {
|
|
17
21
|
const networks = mastra.getNetworks();
|
|
18
|
-
const serializedNetworks =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
const serializedNetworks = await Promise.all(
|
|
23
|
+
networks.map(async (network) => {
|
|
24
|
+
const routingAgent = network.getRoutingAgent();
|
|
25
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
26
|
+
const agents = network.getAgents();
|
|
27
|
+
return {
|
|
28
|
+
id: network.formatAgentId(routingAgent.name),
|
|
29
|
+
name: routingAgent.name,
|
|
30
|
+
instructions: routingAgent.instructions,
|
|
31
|
+
agents: await Promise.all(
|
|
32
|
+
agents.map(async (agent) => {
|
|
33
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
34
|
+
return {
|
|
35
|
+
name: agent.name,
|
|
36
|
+
provider: llm?.getProvider(),
|
|
37
|
+
modelId: llm?.getModelId()
|
|
38
|
+
};
|
|
39
|
+
})
|
|
40
|
+
),
|
|
41
|
+
routingModel: {
|
|
42
|
+
provider: routingLLM?.getProvider(),
|
|
43
|
+
modelId: routingLLM?.getModelId()
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
);
|
|
36
48
|
return serializedNetworks;
|
|
37
49
|
} catch (error) {
|
|
38
|
-
return
|
|
50
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting networks");
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
|
-
async function getNetworkByIdHandler({
|
|
53
|
+
async function getNetworkByIdHandler({
|
|
54
|
+
mastra,
|
|
55
|
+
networkId,
|
|
56
|
+
runtimeContext
|
|
57
|
+
}) {
|
|
42
58
|
try {
|
|
43
59
|
const networks = mastra.getNetworks();
|
|
44
60
|
const network = networks.find((network2) => {
|
|
@@ -46,27 +62,33 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
46
62
|
return network2.formatAgentId(routingAgent2.name) === networkId;
|
|
47
63
|
});
|
|
48
64
|
if (!network) {
|
|
49
|
-
throw new
|
|
65
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
50
66
|
}
|
|
51
67
|
const routingAgent = network.getRoutingAgent();
|
|
68
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
52
69
|
const agents = network.getAgents();
|
|
53
70
|
const serializedNetwork = {
|
|
54
71
|
id: network.formatAgentId(routingAgent.name),
|
|
55
72
|
name: routingAgent.name,
|
|
56
73
|
instructions: routingAgent.instructions,
|
|
57
|
-
agents:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
agents: await Promise.all(
|
|
75
|
+
agents.map(async (agent) => {
|
|
76
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
77
|
+
return {
|
|
78
|
+
name: agent.name,
|
|
79
|
+
provider: llm?.getProvider(),
|
|
80
|
+
modelId: llm?.getModelId()
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
),
|
|
62
84
|
routingModel: {
|
|
63
|
-
provider:
|
|
64
|
-
modelId:
|
|
85
|
+
provider: routingLLM?.getProvider(),
|
|
86
|
+
modelId: routingLLM?.getModelId()
|
|
65
87
|
}
|
|
66
88
|
};
|
|
67
89
|
return serializedNetwork;
|
|
68
90
|
} catch (error) {
|
|
69
|
-
return
|
|
91
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting network by ID");
|
|
70
92
|
}
|
|
71
93
|
}
|
|
72
94
|
async function generateHandler({
|
|
@@ -78,14 +100,14 @@ async function generateHandler({
|
|
|
78
100
|
try {
|
|
79
101
|
const network = mastra.getNetwork(networkId);
|
|
80
102
|
if (!network) {
|
|
81
|
-
throw new
|
|
103
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
82
104
|
}
|
|
83
|
-
|
|
105
|
+
chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
|
|
84
106
|
const { messages, ...rest } = body;
|
|
85
107
|
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
86
108
|
return result;
|
|
87
109
|
} catch (error) {
|
|
88
|
-
return
|
|
110
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error generating from network");
|
|
89
111
|
}
|
|
90
112
|
}
|
|
91
113
|
async function streamGenerateHandler({
|
|
@@ -97,9 +119,9 @@ async function streamGenerateHandler({
|
|
|
97
119
|
try {
|
|
98
120
|
const network = mastra.getNetwork(networkId);
|
|
99
121
|
if (!network) {
|
|
100
|
-
throw new
|
|
122
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
101
123
|
}
|
|
102
|
-
|
|
124
|
+
chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
|
|
103
125
|
const { messages, output, ...rest } = body;
|
|
104
126
|
const streamResult = await network.stream(messages, {
|
|
105
127
|
output,
|
|
@@ -115,7 +137,7 @@ async function streamGenerateHandler({
|
|
|
115
137
|
});
|
|
116
138
|
return streamResponse;
|
|
117
139
|
} catch (error) {
|
|
118
|
-
return
|
|
140
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error streaming from network");
|
|
119
141
|
}
|
|
120
142
|
}
|
|
121
143
|
|