@mastra/server 0.10.13 → 0.10.14
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 +1078 -0
- package/dist/_tsup-dts-rollup.d.ts +1078 -0
- package/dist/chunk-2KZFMI6P.cjs +37 -0
- package/dist/chunk-2SLFAFTR.cjs +148 -0
- package/dist/chunk-4D66QEKC.js +81 -0
- package/dist/chunk-5PQQ42EZ.js +320 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-7TP2LX5L.cjs +129 -0
- package/dist/chunk-B2PAS2IB.cjs +514 -0
- package/dist/chunk-BK4XT6EG.js +270 -0
- package/dist/chunk-CCGRCYWJ.cjs +18 -0
- package/dist/chunk-CRCR3ZUK.js +142 -0
- package/dist/chunk-DN7K6FJK.cjs +251 -0
- package/dist/chunk-FRVBFMO2.cjs +128 -0
- package/dist/chunk-G7KH752Y.cjs +145 -0
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-H7DMHBKY.js +498 -0
- package/dist/chunk-JMLYCXMK.cjs +332 -0
- package/dist/chunk-KHZKYUNR.js +112 -0
- package/dist/chunk-LCM566I4.js +35 -0
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/chunk-LI436ITD.cjs +2042 -0
- package/dist/chunk-LRCAAFUA.js +122 -0
- package/dist/chunk-LZ3VJXSO.cjs +278 -0
- package/dist/chunk-MEGCYGBU.js +2039 -0
- package/dist/chunk-MKLYEKEF.js +241 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/chunk-QGX47B5D.cjs +86 -0
- package/dist/chunk-RG473F6Y.js +141 -0
- package/dist/chunk-RHSWAXKB.cjs +118 -0
- package/dist/chunk-RSEO4XPX.js +16 -0
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/chunk-WNVFNNWN.js +121 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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 +30 -0
- package/dist/server/handlers/agents.d.cts +6 -0
- package/dist/server/handlers/agents.d.ts +6 -0
- package/dist/server/handlers/agents.js +1 -0
- package/dist/server/handlers/error.cjs +10 -0
- package/dist/server/handlers/error.d.cts +1 -0
- package/dist/server/handlers/error.d.ts +1 -0
- package/dist/server/handlers/error.js +1 -0
- package/dist/server/handlers/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- package/dist/server/handlers/logs.cjs +18 -0
- package/dist/server/handlers/logs.d.cts +3 -0
- package/dist/server/handlers/logs.d.ts +3 -0
- package/dist/server/handlers/logs.js +1 -0
- package/dist/server/handlers/memory.cjs +38 -0
- package/dist/server/handlers/memory.d.cts +8 -0
- package/dist/server/handlers/memory.d.ts +8 -0
- package/dist/server/handlers/memory.js +1 -0
- package/dist/server/handlers/network.cjs +22 -0
- package/dist/server/handlers/network.d.cts +4 -0
- package/dist/server/handlers/network.d.ts +4 -0
- package/dist/server/handlers/network.js +1 -0
- package/dist/server/handlers/telemetry.cjs +14 -0
- package/dist/server/handlers/telemetry.d.cts +2 -0
- package/dist/server/handlers/telemetry.d.ts +2 -0
- package/dist/server/handlers/telemetry.js +1 -0
- package/dist/server/handlers/tools.cjs +22 -0
- package/dist/server/handlers/tools.d.cts +4 -0
- package/dist/server/handlers/tools.d.ts +4 -0
- package/dist/server/handlers/tools.js +1 -0
- package/dist/server/handlers/utils.cjs +10 -0
- package/dist/server/handlers/utils.d.cts +1 -0
- package/dist/server/handlers/utils.d.ts +1 -0
- package/dist/server/handlers/utils.js +1 -0
- package/dist/server/handlers/vNextNetwork.cjs +218 -0
- package/dist/server/handlers/vNextNetwork.d.cts +6 -0
- package/dist/server/handlers/vNextNetwork.d.ts +6 -0
- package/dist/server/handlers/vNextNetwork.js +211 -0
- package/dist/server/handlers/vector.cjs +30 -0
- package/dist/server/handlers/vector.d.cts +6 -0
- package/dist/server/handlers/vector.d.ts +6 -0
- package/dist/server/handlers/vector.js +1 -0
- package/dist/server/handlers/voice.cjs +22 -0
- package/dist/server/handlers/voice.d.cts +4 -0
- package/dist/server/handlers/voice.d.ts +4 -0
- package/dist/server/handlers/voice.js +1 -0
- package/dist/server/handlers/workflows.cjs +62 -0
- package/dist/server/handlers/workflows.d.cts +14 -0
- package/dist/server/handlers/workflows.d.ts +14 -0
- package/dist/server/handlers/workflows.js +1 -0
- package/dist/server/handlers.cjs +60 -0
- package/dist/server/handlers.d.cts +11 -0
- package/dist/server/handlers.d.ts +11 -0
- package/dist/server/handlers.js +11 -0
- package/package.json +2 -2
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
|
|
4
|
+
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
5
|
+
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
6
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
|
+
var web = require('stream/web');
|
|
8
|
+
|
|
9
|
+
// src/server/handlers/legacyWorkflows.ts
|
|
10
|
+
var legacyWorkflows_exports = {};
|
|
11
|
+
chunk75ZPJI57_cjs.__export(legacyWorkflows_exports, {
|
|
12
|
+
createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
|
|
13
|
+
getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
|
|
14
|
+
getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
|
|
15
|
+
getLegacyWorkflowRunsHandler: () => getLegacyWorkflowRunsHandler,
|
|
16
|
+
getLegacyWorkflowsHandler: () => getLegacyWorkflowsHandler,
|
|
17
|
+
resumeAsyncLegacyWorkflowHandler: () => resumeAsyncLegacyWorkflowHandler,
|
|
18
|
+
resumeLegacyWorkflowHandler: () => resumeLegacyWorkflowHandler,
|
|
19
|
+
startAsyncLegacyWorkflowHandler: () => startAsyncLegacyWorkflowHandler,
|
|
20
|
+
startLegacyWorkflowRunHandler: () => startLegacyWorkflowRunHandler,
|
|
21
|
+
watchLegacyWorkflowHandler: () => watchLegacyWorkflowHandler
|
|
22
|
+
});
|
|
23
|
+
async function getLegacyWorkflowsHandler({ mastra }) {
|
|
24
|
+
try {
|
|
25
|
+
const workflows = mastra.legacy_getWorkflows({ serialized: false });
|
|
26
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
27
|
+
if (workflow.isNested) return acc;
|
|
28
|
+
acc[key] = {
|
|
29
|
+
stepGraph: workflow.stepGraph,
|
|
30
|
+
stepSubscriberGraph: workflow.stepSubscriberGraph,
|
|
31
|
+
serializedStepGraph: workflow.serializedStepGraph,
|
|
32
|
+
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
33
|
+
name: workflow.name,
|
|
34
|
+
triggerSchema: workflow.triggerSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
35
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
36
|
+
const _step = step;
|
|
37
|
+
acc2[key2] = {
|
|
38
|
+
id: _step.id,
|
|
39
|
+
description: _step.description,
|
|
40
|
+
workflowId: _step.workflowId,
|
|
41
|
+
inputSchema: _step.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
42
|
+
outputSchema: _step.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_step.outputSchema)) : void 0
|
|
43
|
+
};
|
|
44
|
+
return acc2;
|
|
45
|
+
}, {})
|
|
46
|
+
};
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
return _workflows;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return chunkPZQDCRPV_cjs.handleError(error, "error getting workflows");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
|
|
55
|
+
try {
|
|
56
|
+
if (!workflowId) {
|
|
57
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
58
|
+
}
|
|
59
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
60
|
+
if (!workflow) {
|
|
61
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
stepGraph: workflow.stepGraph,
|
|
65
|
+
stepSubscriberGraph: workflow.stepSubscriberGraph,
|
|
66
|
+
serializedStepGraph: workflow.serializedStepGraph,
|
|
67
|
+
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
68
|
+
name: workflow.name,
|
|
69
|
+
triggerSchema: workflow.triggerSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
70
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
71
|
+
const _step = step;
|
|
72
|
+
acc[key] = {
|
|
73
|
+
id: _step.id,
|
|
74
|
+
description: _step.description,
|
|
75
|
+
workflowId: _step.workflowId,
|
|
76
|
+
inputSchema: _step.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
77
|
+
outputSchema: _step.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_step.outputSchema)) : void 0
|
|
78
|
+
};
|
|
79
|
+
return acc;
|
|
80
|
+
}, {})
|
|
81
|
+
};
|
|
82
|
+
} catch (error) {
|
|
83
|
+
return chunkPZQDCRPV_cjs.handleError(error, "error getting workflow by id");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function startAsyncLegacyWorkflowHandler({
|
|
87
|
+
mastra,
|
|
88
|
+
runtimeContext,
|
|
89
|
+
workflowId,
|
|
90
|
+
runId,
|
|
91
|
+
triggerData
|
|
92
|
+
}) {
|
|
93
|
+
try {
|
|
94
|
+
if (!workflowId) {
|
|
95
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
96
|
+
}
|
|
97
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
98
|
+
if (!workflow) {
|
|
99
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
100
|
+
}
|
|
101
|
+
if (!runId) {
|
|
102
|
+
const newRun = workflow.createRun();
|
|
103
|
+
const result2 = await newRun.start({
|
|
104
|
+
triggerData,
|
|
105
|
+
runtimeContext
|
|
106
|
+
});
|
|
107
|
+
return result2;
|
|
108
|
+
}
|
|
109
|
+
const run = workflow.getMemoryRun(runId);
|
|
110
|
+
if (!run) {
|
|
111
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
112
|
+
}
|
|
113
|
+
const result = await run.start({
|
|
114
|
+
triggerData,
|
|
115
|
+
runtimeContext
|
|
116
|
+
});
|
|
117
|
+
return result;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
return chunkPZQDCRPV_cjs.handleError(error, "error starting workflow");
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function getLegacyWorkflowRunHandler({
|
|
123
|
+
mastra,
|
|
124
|
+
workflowId,
|
|
125
|
+
runId
|
|
126
|
+
}) {
|
|
127
|
+
try {
|
|
128
|
+
if (!workflowId) {
|
|
129
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
130
|
+
}
|
|
131
|
+
if (!runId) {
|
|
132
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
133
|
+
}
|
|
134
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
135
|
+
if (!workflow) {
|
|
136
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
137
|
+
}
|
|
138
|
+
const run = await workflow.getRun(runId);
|
|
139
|
+
if (!run) {
|
|
140
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
141
|
+
}
|
|
142
|
+
return run;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return chunkPZQDCRPV_cjs.handleError(error, "error getting workflow run");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function createLegacyWorkflowRunHandler({
|
|
148
|
+
mastra,
|
|
149
|
+
workflowId,
|
|
150
|
+
runId: prevRunId
|
|
151
|
+
}) {
|
|
152
|
+
try {
|
|
153
|
+
if (!workflowId) {
|
|
154
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
155
|
+
}
|
|
156
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
157
|
+
if (!workflow) {
|
|
158
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
159
|
+
}
|
|
160
|
+
const newRun = workflow.createRun({ runId: prevRunId });
|
|
161
|
+
return { runId: newRun.runId };
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return chunkPZQDCRPV_cjs.handleError(error, "error creating workflow run");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function startLegacyWorkflowRunHandler({
|
|
167
|
+
mastra,
|
|
168
|
+
runtimeContext,
|
|
169
|
+
workflowId,
|
|
170
|
+
runId,
|
|
171
|
+
triggerData
|
|
172
|
+
}) {
|
|
173
|
+
try {
|
|
174
|
+
if (!workflowId) {
|
|
175
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
176
|
+
}
|
|
177
|
+
if (!runId) {
|
|
178
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
179
|
+
}
|
|
180
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
181
|
+
const run = workflow.getMemoryRun(runId);
|
|
182
|
+
if (!run) {
|
|
183
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
184
|
+
}
|
|
185
|
+
void run.start({
|
|
186
|
+
triggerData,
|
|
187
|
+
runtimeContext
|
|
188
|
+
});
|
|
189
|
+
return { message: "Workflow run started" };
|
|
190
|
+
} catch (e) {
|
|
191
|
+
return chunkPZQDCRPV_cjs.handleError(e, "Error starting workflow run");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function watchLegacyWorkflowHandler({
|
|
195
|
+
mastra,
|
|
196
|
+
workflowId,
|
|
197
|
+
runId
|
|
198
|
+
}) {
|
|
199
|
+
try {
|
|
200
|
+
if (!workflowId) {
|
|
201
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
202
|
+
}
|
|
203
|
+
if (!runId) {
|
|
204
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
205
|
+
}
|
|
206
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
207
|
+
const run = workflow.getMemoryRun(runId);
|
|
208
|
+
if (!run) {
|
|
209
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
210
|
+
}
|
|
211
|
+
let unwatch;
|
|
212
|
+
let asyncRef = null;
|
|
213
|
+
const stream = new web.ReadableStream({
|
|
214
|
+
start(controller) {
|
|
215
|
+
unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
|
|
216
|
+
const activePathsObj = Object.fromEntries(activePaths);
|
|
217
|
+
controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
|
|
218
|
+
if (asyncRef) {
|
|
219
|
+
clearImmediate(asyncRef);
|
|
220
|
+
asyncRef = null;
|
|
221
|
+
}
|
|
222
|
+
asyncRef = setImmediate(() => {
|
|
223
|
+
const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
|
|
224
|
+
if (runDone) {
|
|
225
|
+
controller.close();
|
|
226
|
+
unwatch?.();
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
cancel() {
|
|
232
|
+
unwatch?.();
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return stream;
|
|
236
|
+
} catch (error) {
|
|
237
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error watching workflow");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
async function resumeAsyncLegacyWorkflowHandler({
|
|
241
|
+
mastra,
|
|
242
|
+
workflowId,
|
|
243
|
+
runId,
|
|
244
|
+
body,
|
|
245
|
+
runtimeContext
|
|
246
|
+
}) {
|
|
247
|
+
try {
|
|
248
|
+
if (!workflowId) {
|
|
249
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
250
|
+
}
|
|
251
|
+
if (!runId) {
|
|
252
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
253
|
+
}
|
|
254
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
255
|
+
const run = workflow.getMemoryRun(runId);
|
|
256
|
+
if (!run) {
|
|
257
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
258
|
+
}
|
|
259
|
+
const result = await run.resume({
|
|
260
|
+
stepId: body.stepId,
|
|
261
|
+
context: body.context,
|
|
262
|
+
runtimeContext
|
|
263
|
+
});
|
|
264
|
+
return result;
|
|
265
|
+
} catch (error) {
|
|
266
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow step");
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
async function resumeLegacyWorkflowHandler({
|
|
270
|
+
mastra,
|
|
271
|
+
workflowId,
|
|
272
|
+
runId,
|
|
273
|
+
body,
|
|
274
|
+
runtimeContext
|
|
275
|
+
}) {
|
|
276
|
+
try {
|
|
277
|
+
if (!workflowId) {
|
|
278
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
279
|
+
}
|
|
280
|
+
if (!runId) {
|
|
281
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
282
|
+
}
|
|
283
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
284
|
+
const run = workflow.getMemoryRun(runId);
|
|
285
|
+
if (!run) {
|
|
286
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
287
|
+
}
|
|
288
|
+
void run.resume({
|
|
289
|
+
stepId: body.stepId,
|
|
290
|
+
context: body.context,
|
|
291
|
+
runtimeContext
|
|
292
|
+
});
|
|
293
|
+
return { message: "Workflow run resumed" };
|
|
294
|
+
} catch (error) {
|
|
295
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async function getLegacyWorkflowRunsHandler({
|
|
299
|
+
mastra,
|
|
300
|
+
workflowId,
|
|
301
|
+
fromDate,
|
|
302
|
+
toDate,
|
|
303
|
+
limit,
|
|
304
|
+
offset,
|
|
305
|
+
resourceId
|
|
306
|
+
}) {
|
|
307
|
+
try {
|
|
308
|
+
if (!workflowId) {
|
|
309
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
310
|
+
}
|
|
311
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
312
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
313
|
+
runs: [],
|
|
314
|
+
total: 0
|
|
315
|
+
};
|
|
316
|
+
return workflowRuns;
|
|
317
|
+
} catch (error) {
|
|
318
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow runs");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
exports.createLegacyWorkflowRunHandler = createLegacyWorkflowRunHandler;
|
|
323
|
+
exports.getLegacyWorkflowByIdHandler = getLegacyWorkflowByIdHandler;
|
|
324
|
+
exports.getLegacyWorkflowRunHandler = getLegacyWorkflowRunHandler;
|
|
325
|
+
exports.getLegacyWorkflowRunsHandler = getLegacyWorkflowRunsHandler;
|
|
326
|
+
exports.getLegacyWorkflowsHandler = getLegacyWorkflowsHandler;
|
|
327
|
+
exports.legacyWorkflows_exports = legacyWorkflows_exports;
|
|
328
|
+
exports.resumeAsyncLegacyWorkflowHandler = resumeAsyncLegacyWorkflowHandler;
|
|
329
|
+
exports.resumeLegacyWorkflowHandler = resumeLegacyWorkflowHandler;
|
|
330
|
+
exports.startAsyncLegacyWorkflowHandler = startAsyncLegacyWorkflowHandler;
|
|
331
|
+
exports.startLegacyWorkflowRunHandler = startLegacyWorkflowRunHandler;
|
|
332
|
+
exports.watchLegacyWorkflowHandler = watchLegacyWorkflowHandler;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { validateBody } from './chunk-RSEO4XPX.js';
|
|
2
|
+
import { handleError } from './chunk-LF7P5PLR.js';
|
|
3
|
+
import { HTTPException } from './chunk-LCM566I4.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
|
|
7
|
+
// src/server/handlers/voice.ts
|
|
8
|
+
var voice_exports = {};
|
|
9
|
+
__export(voice_exports, {
|
|
10
|
+
generateSpeechHandler: () => generateSpeechHandler,
|
|
11
|
+
getListenerHandler: () => getListenerHandler,
|
|
12
|
+
getSpeakersHandler: () => getSpeakersHandler,
|
|
13
|
+
transcribeSpeechHandler: () => transcribeSpeechHandler
|
|
14
|
+
});
|
|
15
|
+
async function getSpeakersHandler({ mastra, agentId }) {
|
|
16
|
+
try {
|
|
17
|
+
if (!agentId) {
|
|
18
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
19
|
+
}
|
|
20
|
+
const agent = mastra.getAgent(agentId);
|
|
21
|
+
if (!agent) {
|
|
22
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
23
|
+
}
|
|
24
|
+
const voice = await agent.getVoice();
|
|
25
|
+
if (!voice) {
|
|
26
|
+
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
27
|
+
}
|
|
28
|
+
const speakers = await voice.getSpeakers();
|
|
29
|
+
return speakers;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return handleError(error, "Error getting speakers");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function generateSpeechHandler({
|
|
35
|
+
mastra,
|
|
36
|
+
agentId,
|
|
37
|
+
body
|
|
38
|
+
}) {
|
|
39
|
+
try {
|
|
40
|
+
if (!agentId) {
|
|
41
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
42
|
+
}
|
|
43
|
+
validateBody({
|
|
44
|
+
text: body?.text
|
|
45
|
+
});
|
|
46
|
+
const agent = mastra.getAgent(agentId);
|
|
47
|
+
if (!agent) {
|
|
48
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
49
|
+
}
|
|
50
|
+
const voice = await agent.getVoice();
|
|
51
|
+
if (!voice) {
|
|
52
|
+
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
53
|
+
}
|
|
54
|
+
const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
|
|
55
|
+
if (!audioStream) {
|
|
56
|
+
throw new HTTPException(500, { message: "Failed to generate speech" });
|
|
57
|
+
}
|
|
58
|
+
return audioStream;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return handleError(error, "Error generating speech");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function transcribeSpeechHandler({
|
|
64
|
+
mastra,
|
|
65
|
+
agentId,
|
|
66
|
+
body
|
|
67
|
+
}) {
|
|
68
|
+
try {
|
|
69
|
+
if (!agentId) {
|
|
70
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
71
|
+
}
|
|
72
|
+
if (!body?.audioData) {
|
|
73
|
+
throw new HTTPException(400, { message: "Audio data is required" });
|
|
74
|
+
}
|
|
75
|
+
const agent = mastra.getAgent(agentId);
|
|
76
|
+
if (!agent) {
|
|
77
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
78
|
+
}
|
|
79
|
+
const voice = await agent.getVoice();
|
|
80
|
+
if (!voice) {
|
|
81
|
+
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
82
|
+
}
|
|
83
|
+
const audioStream = new Readable();
|
|
84
|
+
audioStream.push(body.audioData);
|
|
85
|
+
audioStream.push(null);
|
|
86
|
+
const text = await voice.listen(audioStream, body.options);
|
|
87
|
+
return { text };
|
|
88
|
+
} catch (error) {
|
|
89
|
+
return handleError(error, "Error transcribing speech");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function getListenerHandler({ mastra, agentId }) {
|
|
93
|
+
try {
|
|
94
|
+
if (!agentId) {
|
|
95
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
96
|
+
}
|
|
97
|
+
const agent = mastra.getAgent(agentId);
|
|
98
|
+
if (!agent) {
|
|
99
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
100
|
+
}
|
|
101
|
+
const voice = await agent.getVoice();
|
|
102
|
+
if (!voice) {
|
|
103
|
+
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
104
|
+
}
|
|
105
|
+
const listeners = await voice.getListener();
|
|
106
|
+
return listeners;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return handleError(error, "Error getting listeners");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/server/http-exception.ts
|
|
2
|
+
var HTTPException = class extends Error {
|
|
3
|
+
res;
|
|
4
|
+
status;
|
|
5
|
+
/**
|
|
6
|
+
* Creates an instance of `HTTPException`.
|
|
7
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
8
|
+
* @param options - Additional options for the exception.
|
|
9
|
+
*/
|
|
10
|
+
constructor(status = 500, options) {
|
|
11
|
+
super(options?.message, { cause: options?.cause });
|
|
12
|
+
this.res = options?.res;
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.stack = options?.stack || this.stack;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the response object associated with the exception.
|
|
18
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
19
|
+
* @returns The response object.
|
|
20
|
+
*/
|
|
21
|
+
getResponse() {
|
|
22
|
+
if (this.res) {
|
|
23
|
+
const newResponse = new Response(this.res.body, {
|
|
24
|
+
status: this.status,
|
|
25
|
+
headers: this.res.headers
|
|
26
|
+
});
|
|
27
|
+
return newResponse;
|
|
28
|
+
}
|
|
29
|
+
return new Response(this.message, {
|
|
30
|
+
status: this.status
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { HTTPException };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HTTPException } from './chunk-LCM566I4.js';
|
|
2
|
+
|
|
3
|
+
// src/server/handlers/error.ts
|
|
4
|
+
function handleError(error, defaultMessage) {
|
|
5
|
+
const apiError = error;
|
|
6
|
+
const apiErrorStatus = apiError.status || apiError.details?.status || 500;
|
|
7
|
+
throw new HTTPException(apiErrorStatus, {
|
|
8
|
+
message: apiError.message || defaultMessage,
|
|
9
|
+
stack: apiError.stack,
|
|
10
|
+
cause: apiError.cause
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { handleError };
|