@mastra/server 0.0.0-ai-v5-20250626003446 → 0.0.0-ai-v5-20250718021026
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/LICENSE.md +11 -42
- package/dist/_tsup-dts-rollup.d.cts +265 -22
- package/dist/_tsup-dts-rollup.d.ts +265 -22
- package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
- package/dist/{chunk-5BKZNI2F.cjs → chunk-34GEZJPU.cjs} +29 -23
- package/dist/{chunk-TGJMNUYJ.js → chunk-36BLNJHS.js} +108 -70
- package/dist/{chunk-XUTX4CAB.cjs → chunk-3TMDONWY.cjs} +154 -75
- package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
- package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
- package/dist/{chunk-P54JFWUD.js → chunk-BYCOGHDE.js} +3 -3
- package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
- package/dist/{chunk-I3FR2N5I.cjs → chunk-HAGPF7OS.cjs} +12 -12
- package/dist/{chunk-ASKESBJW.cjs → chunk-HISYIDYH.cjs} +107 -69
- package/dist/{chunk-NGURCFEJ.cjs → chunk-HRSAZUIK.cjs} +20 -20
- package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
- package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/{chunk-BSUAZLUK.js → chunk-N6KVUULV.js} +110 -25
- package/dist/{chunk-2XXCPCYB.js → chunk-OKL5JVWU.js} +15 -9
- package/dist/{chunk-3CSC35VL.js → chunk-ORHUZSM2.js} +96 -19
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
- package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
- package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
- package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/{chunk-WE32JG64.cjs → chunk-UCV4247U.cjs} +43 -43
- package/dist/chunk-VDTQM2M5.cjs +321 -0
- package/dist/{chunk-2HXKRRNS.js → chunk-WBRFIHSF.js} +4 -4
- package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
- package/dist/{chunk-CLYX4KLH.js → chunk-ZYAFP2AV.js} +8 -8
- 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/legacyWorkflows.cjs +11 -11
- package/dist/server/handlers/legacyWorkflows.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 +17 -9
- package/dist/server/handlers/memory.d.cts +2 -0
- package/dist/server/handlers/memory.d.ts +2 -0
- 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/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 +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +21 -13
- package/dist/server/handlers/workflows.d.cts +2 -0
- package/dist/server/handlers/workflows.d.ts +2 -0
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +20 -20
- package/dist/server/handlers.js +10 -10
- package/package.json +9 -9
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-PADRC33G.cjs +0 -234
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkHISYIDYH_cjs = require('./chunk-HISYIDYH.cjs');
|
|
4
|
+
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
5
|
+
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
6
6
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
7
|
var web = require('stream/web');
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/workflows.ts
|
|
10
10
|
var workflows_exports = {};
|
|
11
11
|
chunk75ZPJI57_cjs.__export(workflows_exports, {
|
|
12
|
+
cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
|
|
12
13
|
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
13
14
|
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
14
15
|
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
@@ -17,11 +18,31 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
|
|
|
17
18
|
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
18
19
|
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
19
20
|
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
21
|
+
sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
|
|
20
22
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
21
23
|
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
22
24
|
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
23
25
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
24
26
|
});
|
|
27
|
+
function getSteps(steps, path) {
|
|
28
|
+
return Object.entries(steps).reduce((acc, [key, step]) => {
|
|
29
|
+
const fullKey = path ? `${path}.${key}` : key;
|
|
30
|
+
acc[fullKey] = {
|
|
31
|
+
id: step.id,
|
|
32
|
+
description: step.description,
|
|
33
|
+
inputSchema: step.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.inputSchema)) : void 0,
|
|
34
|
+
outputSchema: step.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.outputSchema)) : void 0,
|
|
35
|
+
resumeSchema: step.resumeSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
36
|
+
suspendSchema: step.suspendSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.suspendSchema)) : void 0,
|
|
37
|
+
isWorkflow: step.component === "WORKFLOW"
|
|
38
|
+
};
|
|
39
|
+
if (step.component === "WORKFLOW" && step.steps) {
|
|
40
|
+
const nestedSteps = getSteps(step.steps, fullKey) || {};
|
|
41
|
+
acc = { ...acc, ...nestedSteps };
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, {});
|
|
45
|
+
}
|
|
25
46
|
async function getWorkflowsHandler({ mastra }) {
|
|
26
47
|
try {
|
|
27
48
|
const workflows = mastra.getWorkflows({ serialized: false });
|
|
@@ -33,28 +54,29 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
33
54
|
acc2[key2] = {
|
|
34
55
|
id: step.id,
|
|
35
56
|
description: step.description,
|
|
36
|
-
inputSchema: step.inputSchema ?
|
|
37
|
-
outputSchema: step.outputSchema ?
|
|
38
|
-
resumeSchema: step.resumeSchema ?
|
|
39
|
-
suspendSchema: step.suspendSchema ?
|
|
57
|
+
inputSchema: step.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.inputSchema)) : void 0,
|
|
58
|
+
outputSchema: step.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.outputSchema)) : void 0,
|
|
59
|
+
resumeSchema: step.resumeSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
60
|
+
suspendSchema: step.suspendSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.suspendSchema)) : void 0
|
|
40
61
|
};
|
|
41
62
|
return acc2;
|
|
42
63
|
}, {}),
|
|
64
|
+
allSteps: getSteps(workflow.steps) || {},
|
|
43
65
|
stepGraph: workflow.serializedStepGraph,
|
|
44
|
-
inputSchema: workflow.inputSchema ?
|
|
45
|
-
outputSchema: workflow.outputSchema ?
|
|
66
|
+
inputSchema: workflow.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
67
|
+
outputSchema: workflow.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
46
68
|
};
|
|
47
69
|
return acc;
|
|
48
70
|
}, {});
|
|
49
71
|
return _workflows;
|
|
50
72
|
} catch (error) {
|
|
51
|
-
|
|
73
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflows");
|
|
52
74
|
}
|
|
53
75
|
}
|
|
54
76
|
async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
55
77
|
const logger = mastra.getLogger();
|
|
56
78
|
if (!workflowId) {
|
|
57
|
-
throw new
|
|
79
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
58
80
|
}
|
|
59
81
|
let workflow;
|
|
60
82
|
try {
|
|
@@ -81,39 +103,40 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
|
81
103
|
}
|
|
82
104
|
}
|
|
83
105
|
if (!workflow) {
|
|
84
|
-
throw new
|
|
106
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
85
107
|
}
|
|
86
108
|
return { workflow };
|
|
87
109
|
}
|
|
88
110
|
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
89
111
|
try {
|
|
90
112
|
if (!workflowId) {
|
|
91
|
-
throw new
|
|
113
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
92
114
|
}
|
|
93
115
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
94
116
|
if (!workflow) {
|
|
95
|
-
throw new
|
|
117
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
96
118
|
}
|
|
97
119
|
return {
|
|
98
120
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
99
121
|
acc[key] = {
|
|
100
122
|
id: step.id,
|
|
101
123
|
description: step.description,
|
|
102
|
-
inputSchema: step.inputSchema ?
|
|
103
|
-
outputSchema: step.outputSchema ?
|
|
104
|
-
resumeSchema: step.resumeSchema ?
|
|
105
|
-
suspendSchema: step.suspendSchema ?
|
|
124
|
+
inputSchema: step.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.inputSchema)) : void 0,
|
|
125
|
+
outputSchema: step.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.outputSchema)) : void 0,
|
|
126
|
+
resumeSchema: step.resumeSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
127
|
+
suspendSchema: step.suspendSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(step.suspendSchema)) : void 0
|
|
106
128
|
};
|
|
107
129
|
return acc;
|
|
108
130
|
}, {}),
|
|
131
|
+
allSteps: getSteps(workflow.steps) || {},
|
|
109
132
|
name: workflow.name,
|
|
110
133
|
description: workflow.description,
|
|
111
134
|
stepGraph: workflow.serializedStepGraph,
|
|
112
|
-
inputSchema: workflow.inputSchema ?
|
|
113
|
-
outputSchema: workflow.outputSchema ?
|
|
135
|
+
inputSchema: workflow.inputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
136
|
+
outputSchema: workflow.outputSchema ? chunkHISYIDYH_cjs.stringify(chunkHISYIDYH_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
114
137
|
};
|
|
115
138
|
} catch (error) {
|
|
116
|
-
|
|
139
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow");
|
|
117
140
|
}
|
|
118
141
|
}
|
|
119
142
|
async function getWorkflowRunByIdHandler({
|
|
@@ -123,22 +146,22 @@ async function getWorkflowRunByIdHandler({
|
|
|
123
146
|
}) {
|
|
124
147
|
try {
|
|
125
148
|
if (!workflowId) {
|
|
126
|
-
throw new
|
|
149
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
127
150
|
}
|
|
128
151
|
if (!runId) {
|
|
129
|
-
throw new
|
|
152
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
130
153
|
}
|
|
131
154
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
132
155
|
if (!workflow) {
|
|
133
|
-
throw new
|
|
156
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
134
157
|
}
|
|
135
158
|
const run = await workflow.getWorkflowRunById(runId);
|
|
136
159
|
if (!run) {
|
|
137
|
-
throw new
|
|
160
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
138
161
|
}
|
|
139
162
|
return run;
|
|
140
163
|
} catch (error) {
|
|
141
|
-
|
|
164
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow run");
|
|
142
165
|
}
|
|
143
166
|
}
|
|
144
167
|
async function getWorkflowRunExecutionResultHandler({
|
|
@@ -148,24 +171,22 @@ async function getWorkflowRunExecutionResultHandler({
|
|
|
148
171
|
}) {
|
|
149
172
|
try {
|
|
150
173
|
if (!workflowId) {
|
|
151
|
-
throw new
|
|
174
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
152
175
|
}
|
|
153
176
|
if (!runId) {
|
|
154
|
-
throw new
|
|
177
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
155
178
|
}
|
|
156
179
|
const workflow = mastra.getWorkflow(workflowId);
|
|
157
180
|
if (!workflow) {
|
|
158
|
-
throw new
|
|
181
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
159
182
|
}
|
|
160
183
|
const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
|
|
161
184
|
if (!executionResult) {
|
|
162
|
-
throw new
|
|
185
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
|
|
163
186
|
}
|
|
164
187
|
return executionResult;
|
|
165
188
|
} catch (error) {
|
|
166
|
-
|
|
167
|
-
message: error?.message || "Error getting workflow run execution result"
|
|
168
|
-
});
|
|
189
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow run execution result");
|
|
169
190
|
}
|
|
170
191
|
}
|
|
171
192
|
async function createWorkflowRunHandler({
|
|
@@ -175,16 +196,16 @@ async function createWorkflowRunHandler({
|
|
|
175
196
|
}) {
|
|
176
197
|
try {
|
|
177
198
|
if (!workflowId) {
|
|
178
|
-
throw new
|
|
199
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
179
200
|
}
|
|
180
201
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
181
202
|
if (!workflow) {
|
|
182
|
-
throw new
|
|
203
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
183
204
|
}
|
|
184
|
-
const run = workflow.
|
|
205
|
+
const run = await workflow.createRunAsync({ runId: prevRunId });
|
|
185
206
|
return { runId: run.runId };
|
|
186
207
|
} catch (error) {
|
|
187
|
-
|
|
208
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error creating workflow run");
|
|
188
209
|
}
|
|
189
210
|
}
|
|
190
211
|
async function startAsyncWorkflowHandler({
|
|
@@ -196,20 +217,20 @@ async function startAsyncWorkflowHandler({
|
|
|
196
217
|
}) {
|
|
197
218
|
try {
|
|
198
219
|
if (!workflowId) {
|
|
199
|
-
throw new
|
|
220
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
200
221
|
}
|
|
201
222
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
202
223
|
if (!workflow) {
|
|
203
|
-
throw new
|
|
224
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
204
225
|
}
|
|
205
|
-
const _run = workflow.
|
|
226
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
206
227
|
const result = await _run.start({
|
|
207
228
|
inputData,
|
|
208
229
|
runtimeContext
|
|
209
230
|
});
|
|
210
231
|
return result;
|
|
211
232
|
} catch (error) {
|
|
212
|
-
|
|
233
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error starting async workflow");
|
|
213
234
|
}
|
|
214
235
|
}
|
|
215
236
|
async function startWorkflowRunHandler({
|
|
@@ -221,27 +242,27 @@ async function startWorkflowRunHandler({
|
|
|
221
242
|
}) {
|
|
222
243
|
try {
|
|
223
244
|
if (!workflowId) {
|
|
224
|
-
throw new
|
|
245
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
225
246
|
}
|
|
226
247
|
if (!runId) {
|
|
227
|
-
throw new
|
|
248
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
228
249
|
}
|
|
229
250
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
230
251
|
if (!workflow) {
|
|
231
|
-
throw new
|
|
252
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
232
253
|
}
|
|
233
254
|
const run = await workflow.getWorkflowRunById(runId);
|
|
234
255
|
if (!run) {
|
|
235
|
-
throw new
|
|
256
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
236
257
|
}
|
|
237
|
-
const _run = workflow.
|
|
258
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
238
259
|
void _run.start({
|
|
239
260
|
inputData,
|
|
240
261
|
runtimeContext
|
|
241
262
|
});
|
|
242
263
|
return { message: "Workflow run started" };
|
|
243
264
|
} catch (e) {
|
|
244
|
-
return
|
|
265
|
+
return chunkPZQDCRPV_cjs.handleError(e, "Error starting workflow run");
|
|
245
266
|
}
|
|
246
267
|
}
|
|
247
268
|
async function watchWorkflowHandler({
|
|
@@ -251,20 +272,20 @@ async function watchWorkflowHandler({
|
|
|
251
272
|
}) {
|
|
252
273
|
try {
|
|
253
274
|
if (!workflowId) {
|
|
254
|
-
throw new
|
|
275
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
255
276
|
}
|
|
256
277
|
if (!runId) {
|
|
257
|
-
throw new
|
|
278
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
258
279
|
}
|
|
259
280
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
260
281
|
if (!workflow) {
|
|
261
|
-
throw new
|
|
282
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
262
283
|
}
|
|
263
284
|
const run = await workflow.getWorkflowRunById(runId);
|
|
264
285
|
if (!run) {
|
|
265
|
-
throw new
|
|
286
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
266
287
|
}
|
|
267
|
-
const _run = workflow.
|
|
288
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
268
289
|
let unwatch;
|
|
269
290
|
let asyncRef = null;
|
|
270
291
|
const stream = new web.ReadableStream({
|
|
@@ -290,7 +311,7 @@ async function watchWorkflowHandler({
|
|
|
290
311
|
});
|
|
291
312
|
return stream;
|
|
292
313
|
} catch (error) {
|
|
293
|
-
return
|
|
314
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error watching workflow");
|
|
294
315
|
}
|
|
295
316
|
}
|
|
296
317
|
async function streamWorkflowHandler({
|
|
@@ -302,23 +323,23 @@ async function streamWorkflowHandler({
|
|
|
302
323
|
}) {
|
|
303
324
|
try {
|
|
304
325
|
if (!workflowId) {
|
|
305
|
-
throw new
|
|
326
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
306
327
|
}
|
|
307
328
|
if (!runId) {
|
|
308
|
-
throw new
|
|
329
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
309
330
|
}
|
|
310
331
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
311
332
|
if (!workflow) {
|
|
312
|
-
throw new
|
|
333
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
313
334
|
}
|
|
314
|
-
const run = workflow.
|
|
335
|
+
const run = await workflow.createRunAsync({ runId });
|
|
315
336
|
const result = run.stream({
|
|
316
337
|
inputData,
|
|
317
338
|
runtimeContext
|
|
318
339
|
});
|
|
319
340
|
return result;
|
|
320
341
|
} catch (error) {
|
|
321
|
-
return
|
|
342
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error executing workflow");
|
|
322
343
|
}
|
|
323
344
|
}
|
|
324
345
|
async function resumeAsyncWorkflowHandler({
|
|
@@ -330,23 +351,23 @@ async function resumeAsyncWorkflowHandler({
|
|
|
330
351
|
}) {
|
|
331
352
|
try {
|
|
332
353
|
if (!workflowId) {
|
|
333
|
-
throw new
|
|
354
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
334
355
|
}
|
|
335
356
|
if (!runId) {
|
|
336
|
-
throw new
|
|
357
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
337
358
|
}
|
|
338
359
|
if (!body.step) {
|
|
339
|
-
throw new
|
|
360
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
340
361
|
}
|
|
341
362
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
342
363
|
if (!workflow) {
|
|
343
|
-
throw new
|
|
364
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
344
365
|
}
|
|
345
366
|
const run = await workflow.getWorkflowRunById(runId);
|
|
346
367
|
if (!run) {
|
|
347
|
-
throw new
|
|
368
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
348
369
|
}
|
|
349
|
-
const _run = workflow.
|
|
370
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
350
371
|
const result = await _run.resume({
|
|
351
372
|
step: body.step,
|
|
352
373
|
resumeData: body.resumeData,
|
|
@@ -354,7 +375,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
354
375
|
});
|
|
355
376
|
return result;
|
|
356
377
|
} catch (error) {
|
|
357
|
-
return
|
|
378
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow step");
|
|
358
379
|
}
|
|
359
380
|
}
|
|
360
381
|
async function resumeWorkflowHandler({
|
|
@@ -366,23 +387,23 @@ async function resumeWorkflowHandler({
|
|
|
366
387
|
}) {
|
|
367
388
|
try {
|
|
368
389
|
if (!workflowId) {
|
|
369
|
-
throw new
|
|
390
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
370
391
|
}
|
|
371
392
|
if (!runId) {
|
|
372
|
-
throw new
|
|
393
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
373
394
|
}
|
|
374
395
|
if (!body.step) {
|
|
375
|
-
throw new
|
|
396
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
376
397
|
}
|
|
377
398
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
378
399
|
if (!workflow) {
|
|
379
|
-
throw new
|
|
400
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
380
401
|
}
|
|
381
402
|
const run = await workflow.getWorkflowRunById(runId);
|
|
382
403
|
if (!run) {
|
|
383
|
-
throw new
|
|
404
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
384
405
|
}
|
|
385
|
-
const _run = workflow.
|
|
406
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
386
407
|
void _run.resume({
|
|
387
408
|
step: body.step,
|
|
388
409
|
resumeData: body.resumeData,
|
|
@@ -390,7 +411,7 @@ async function resumeWorkflowHandler({
|
|
|
390
411
|
});
|
|
391
412
|
return { message: "Workflow run resumed" };
|
|
392
413
|
} catch (error) {
|
|
393
|
-
return
|
|
414
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow");
|
|
394
415
|
}
|
|
395
416
|
}
|
|
396
417
|
async function getWorkflowRunsHandler({
|
|
@@ -404,11 +425,11 @@ async function getWorkflowRunsHandler({
|
|
|
404
425
|
}) {
|
|
405
426
|
try {
|
|
406
427
|
if (!workflowId) {
|
|
407
|
-
throw new
|
|
428
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
408
429
|
}
|
|
409
430
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
410
431
|
if (!workflow) {
|
|
411
|
-
throw new
|
|
432
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
412
433
|
}
|
|
413
434
|
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
414
435
|
runs: [],
|
|
@@ -416,10 +437,67 @@ async function getWorkflowRunsHandler({
|
|
|
416
437
|
};
|
|
417
438
|
return workflowRuns;
|
|
418
439
|
} catch (error) {
|
|
419
|
-
return
|
|
440
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow runs");
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
async function cancelWorkflowRunHandler({
|
|
444
|
+
mastra,
|
|
445
|
+
workflowId,
|
|
446
|
+
runId
|
|
447
|
+
}) {
|
|
448
|
+
try {
|
|
449
|
+
if (!workflowId) {
|
|
450
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
451
|
+
}
|
|
452
|
+
if (!runId) {
|
|
453
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
|
|
454
|
+
}
|
|
455
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
456
|
+
if (!workflow) {
|
|
457
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
458
|
+
}
|
|
459
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
460
|
+
if (!run) {
|
|
461
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
462
|
+
}
|
|
463
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
464
|
+
await _run.cancel();
|
|
465
|
+
return { message: "Workflow run cancelled" };
|
|
466
|
+
} catch (error) {
|
|
467
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error canceling workflow run");
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
async function sendWorkflowRunEventHandler({
|
|
471
|
+
mastra,
|
|
472
|
+
workflowId,
|
|
473
|
+
runId,
|
|
474
|
+
event,
|
|
475
|
+
data
|
|
476
|
+
}) {
|
|
477
|
+
try {
|
|
478
|
+
if (!workflowId) {
|
|
479
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
480
|
+
}
|
|
481
|
+
if (!runId) {
|
|
482
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
|
|
483
|
+
}
|
|
484
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
485
|
+
if (!workflow) {
|
|
486
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
487
|
+
}
|
|
488
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
489
|
+
if (!run) {
|
|
490
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
491
|
+
}
|
|
492
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
493
|
+
await _run.sendEvent(event, data);
|
|
494
|
+
return { message: "Workflow run event sent" };
|
|
495
|
+
} catch (error) {
|
|
496
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error sending workflow run event");
|
|
420
497
|
}
|
|
421
498
|
}
|
|
422
499
|
|
|
500
|
+
exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
|
|
423
501
|
exports.createWorkflowRunHandler = createWorkflowRunHandler;
|
|
424
502
|
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
425
503
|
exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
@@ -428,6 +506,7 @@ exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
|
428
506
|
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
429
507
|
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
430
508
|
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
509
|
+
exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
|
|
431
510
|
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
432
511
|
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
433
512
|
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { validateBody } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
1
|
+
import { validateBody } from './chunk-RSEO4XPX.js';
|
|
2
|
+
import { handleError } from './chunk-LF7P5PLR.js';
|
|
3
3
|
import { __export } from './chunk-MLKGABMK.js';
|
|
4
4
|
|
|
5
5
|
// src/server/handlers/logs.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
4
|
+
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
5
5
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
6
|
|
|
7
7
|
// src/server/handlers/vector.ts
|
|
@@ -16,24 +16,24 @@ chunk75ZPJI57_cjs.__export(vector_exports, {
|
|
|
16
16
|
});
|
|
17
17
|
function getVector(mastra, vectorName) {
|
|
18
18
|
if (!vectorName) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Vector name is required" });
|
|
20
20
|
}
|
|
21
21
|
const vector = mastra.getVector(vectorName);
|
|
22
22
|
if (!vector) {
|
|
23
|
-
throw new
|
|
23
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
|
|
24
24
|
}
|
|
25
25
|
return vector;
|
|
26
26
|
}
|
|
27
27
|
async function upsertVectors({ mastra, vectorName, index }) {
|
|
28
28
|
try {
|
|
29
29
|
if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
|
|
30
|
-
throw new
|
|
30
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
|
|
31
31
|
}
|
|
32
32
|
const vector = getVector(mastra, vectorName);
|
|
33
33
|
const result = await vector.upsert(index);
|
|
34
34
|
return { ids: result };
|
|
35
35
|
} catch (error) {
|
|
36
|
-
return
|
|
36
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error upserting vectors");
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
async function createIndex({
|
|
@@ -44,18 +44,18 @@ async function createIndex({
|
|
|
44
44
|
try {
|
|
45
45
|
const { indexName, dimension, metric } = index;
|
|
46
46
|
if (!indexName || typeof dimension !== "number" || dimension <= 0) {
|
|
47
|
-
throw new
|
|
47
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, {
|
|
48
48
|
message: "Invalid request index, indexName and positive dimension number are required."
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
|
|
52
|
-
throw new
|
|
52
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
|
|
53
53
|
}
|
|
54
54
|
const vector = getVector(mastra, vectorName);
|
|
55
55
|
await vector.createIndex({ indexName, dimension, metric });
|
|
56
56
|
return { success: true };
|
|
57
57
|
} catch (error) {
|
|
58
|
-
return
|
|
58
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error creating index");
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
async function queryVectors({
|
|
@@ -65,13 +65,13 @@ async function queryVectors({
|
|
|
65
65
|
}) {
|
|
66
66
|
try {
|
|
67
67
|
if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
|
|
68
|
-
throw new
|
|
68
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
|
|
69
69
|
}
|
|
70
70
|
const vector = getVector(mastra, vectorName);
|
|
71
71
|
const results = await vector.query(query);
|
|
72
72
|
return results;
|
|
73
73
|
} catch (error) {
|
|
74
|
-
return
|
|
74
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error querying vectors");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
async function listIndexes({ mastra, vectorName }) {
|
|
@@ -80,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
|
|
|
80
80
|
const indexes = await vector.listIndexes();
|
|
81
81
|
return indexes.filter(Boolean);
|
|
82
82
|
} catch (error) {
|
|
83
|
-
return
|
|
83
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error listing indexes");
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
async function describeIndex({
|
|
@@ -90,7 +90,7 @@ async function describeIndex({
|
|
|
90
90
|
}) {
|
|
91
91
|
try {
|
|
92
92
|
if (!indexName) {
|
|
93
|
-
throw new
|
|
93
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
|
|
94
94
|
}
|
|
95
95
|
const vector = getVector(mastra, vectorName);
|
|
96
96
|
const stats = await vector.describeIndex({ indexName });
|
|
@@ -100,7 +100,7 @@ async function describeIndex({
|
|
|
100
100
|
metric: stats.metric?.toLowerCase()
|
|
101
101
|
};
|
|
102
102
|
} catch (error) {
|
|
103
|
-
return
|
|
103
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error describing index");
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
async function deleteIndex({
|
|
@@ -110,13 +110,13 @@ async function deleteIndex({
|
|
|
110
110
|
}) {
|
|
111
111
|
try {
|
|
112
112
|
if (!indexName) {
|
|
113
|
-
throw new
|
|
113
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
|
|
114
114
|
}
|
|
115
115
|
const vector = getVector(mastra, vectorName);
|
|
116
116
|
await vector.deleteIndex({ indexName });
|
|
117
117
|
return { success: true };
|
|
118
118
|
} catch (error) {
|
|
119
|
-
return
|
|
119
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error deleting index");
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { validateBody } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import { HTTPException } from './chunk-
|
|
1
|
+
import { validateBody } from './chunk-RSEO4XPX.js';
|
|
2
|
+
import { handleError } from './chunk-LF7P5PLR.js';
|
|
3
|
+
import { HTTPException } from './chunk-LCM566I4.js';
|
|
4
4
|
import { __export } from './chunk-MLKGABMK.js';
|
|
5
5
|
import { createV4CompatibleResponse } from '@mastra/core/agent';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
4
4
|
|
|
5
5
|
// src/server/handlers/utils.ts
|
|
6
6
|
function validateBody(body) {
|
|
@@ -11,7 +11,7 @@ function validateBody(body) {
|
|
|
11
11
|
return acc;
|
|
12
12
|
}, {});
|
|
13
13
|
if (Object.keys(errorResponse).length > 0) {
|
|
14
|
-
throw new
|
|
14
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|