@mastra/server 0.0.0-separate-trace-data-from-component-20250501141108 → 0.0.0-taofeeqInngest-20250603090617
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 +282 -92
- package/dist/_tsup-dts-rollup.d.ts +282 -92
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-4BIX6GMY.cjs → chunk-A3KDUGS7.cjs} +78 -28
- package/dist/{chunk-7IWQE76Z.cjs → chunk-B4MQFJ7G.cjs} +16 -10
- package/dist/{chunk-WTHDCRMY.js → chunk-BFOA2QQY.js} +12 -6
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
- package/dist/{chunk-55HTWX4C.cjs → chunk-CMMOIUFC.cjs} +40 -19
- package/dist/{chunk-Q6SHQECN.js → chunk-CP55EVBK.js} +24 -4
- package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
- package/dist/{chunk-3EJZQ6TQ.js → chunk-DQLE3DVM.js} +5 -5
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-Y3SV5XK4.js → chunk-J3PKLB3A.js} +60 -10
- package/dist/{chunk-JPB6RPGB.js → chunk-KUNQFY2W.js} +112 -51
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-MMO2HDM6.cjs +378 -0
- package/dist/{chunk-SKBVVI24.cjs → chunk-NEOOQUKW.cjs} +11 -11
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
- package/dist/{chunk-M3YJLWTU.js → chunk-W7VCKPAD.js} +62 -51
- package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
- package/dist/chunk-YIOVBYZH.cjs +332 -0
- 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/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 +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/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -4
- package/dist/server/handlers/voice.d.cts +1 -0
- package/dist/server/handlers/voice.d.ts +1 -0
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +17 -13
- package/dist/server/handlers/workflows.d.cts +3 -2
- package/dist/server/handlers/workflows.d.ts +3 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +32 -27
- package/dist/server/handlers.d.cts +2 -1
- package/dist/server/handlers.d.ts +2 -1
- package/dist/server/handlers.js +11 -10
- package/package.json +7 -5
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-AELYAUEE.cjs +0 -316
- package/dist/chunk-EVCC233P.cjs +0 -321
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/server/handlers/vNextWorkflows.cjs +0 -46
- package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
- package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
- package/dist/server/handlers/vNextWorkflows.js +0 -1
|
@@ -0,0 +1,378 @@
|
|
|
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/workflows.ts
|
|
11
|
+
var workflows_exports = {};
|
|
12
|
+
chunk75ZPJI57_cjs.__export(workflows_exports, {
|
|
13
|
+
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
14
|
+
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
15
|
+
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
16
|
+
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
17
|
+
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
18
|
+
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
19
|
+
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
20
|
+
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
21
|
+
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
22
|
+
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
23
|
+
watchWorkflowHandler: () => watchWorkflowHandler
|
|
24
|
+
});
|
|
25
|
+
async function getWorkflowsHandler({ mastra }) {
|
|
26
|
+
try {
|
|
27
|
+
const workflows = mastra.getWorkflows({ serialized: false });
|
|
28
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
29
|
+
acc[key] = {
|
|
30
|
+
name: workflow.name,
|
|
31
|
+
description: workflow.description,
|
|
32
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
33
|
+
acc2[key2] = {
|
|
34
|
+
id: step.id,
|
|
35
|
+
description: step.description,
|
|
36
|
+
inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
|
|
37
|
+
outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
|
|
38
|
+
resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
39
|
+
suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
|
|
40
|
+
};
|
|
41
|
+
return acc2;
|
|
42
|
+
}, {}),
|
|
43
|
+
stepGraph: workflow.serializedStepGraph,
|
|
44
|
+
inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
45
|
+
outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
46
|
+
};
|
|
47
|
+
return acc;
|
|
48
|
+
}, {});
|
|
49
|
+
return _workflows;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
55
|
+
try {
|
|
56
|
+
if (!workflowId) {
|
|
57
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
58
|
+
}
|
|
59
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
60
|
+
if (!workflow) {
|
|
61
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
65
|
+
acc[key] = {
|
|
66
|
+
id: step.id,
|
|
67
|
+
description: step.description,
|
|
68
|
+
inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
|
|
69
|
+
outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
|
|
70
|
+
resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
71
|
+
suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
|
|
72
|
+
};
|
|
73
|
+
return acc;
|
|
74
|
+
}, {}),
|
|
75
|
+
name: workflow.name,
|
|
76
|
+
description: workflow.description,
|
|
77
|
+
stepGraph: workflow.serializedStepGraph,
|
|
78
|
+
inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
79
|
+
outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
80
|
+
};
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function getWorkflowRunByIdHandler({
|
|
86
|
+
mastra,
|
|
87
|
+
workflowId,
|
|
88
|
+
runId
|
|
89
|
+
}) {
|
|
90
|
+
try {
|
|
91
|
+
if (!workflowId) {
|
|
92
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
93
|
+
}
|
|
94
|
+
if (!runId) {
|
|
95
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
96
|
+
}
|
|
97
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
98
|
+
if (!workflow) {
|
|
99
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
100
|
+
}
|
|
101
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
102
|
+
if (!run) {
|
|
103
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
104
|
+
}
|
|
105
|
+
return run;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function createWorkflowRunHandler({
|
|
111
|
+
mastra,
|
|
112
|
+
workflowId,
|
|
113
|
+
runId: prevRunId
|
|
114
|
+
}) {
|
|
115
|
+
try {
|
|
116
|
+
if (!workflowId) {
|
|
117
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
118
|
+
}
|
|
119
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
120
|
+
if (!workflow) {
|
|
121
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
122
|
+
}
|
|
123
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
124
|
+
return { runId: run.runId };
|
|
125
|
+
} catch (error) {
|
|
126
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function startAsyncWorkflowHandler({
|
|
130
|
+
mastra,
|
|
131
|
+
runtimeContext,
|
|
132
|
+
workflowId,
|
|
133
|
+
runId,
|
|
134
|
+
inputData,
|
|
135
|
+
runtimeContextFromRequest
|
|
136
|
+
}) {
|
|
137
|
+
try {
|
|
138
|
+
if (!workflowId) {
|
|
139
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
140
|
+
}
|
|
141
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
142
|
+
if (!workflow) {
|
|
143
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
144
|
+
}
|
|
145
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
146
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
147
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
148
|
+
]);
|
|
149
|
+
const _run = workflow.createRun({ runId });
|
|
150
|
+
const result = await _run.start({
|
|
151
|
+
inputData,
|
|
152
|
+
runtimeContext: finalRuntimeContext
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async function startWorkflowRunHandler({
|
|
160
|
+
mastra,
|
|
161
|
+
runtimeContext,
|
|
162
|
+
workflowId,
|
|
163
|
+
runId,
|
|
164
|
+
inputData,
|
|
165
|
+
runtimeContextFromRequest
|
|
166
|
+
}) {
|
|
167
|
+
try {
|
|
168
|
+
if (!workflowId) {
|
|
169
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
170
|
+
}
|
|
171
|
+
if (!runId) {
|
|
172
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
173
|
+
}
|
|
174
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
175
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
176
|
+
if (!run) {
|
|
177
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
178
|
+
}
|
|
179
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
180
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
181
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
182
|
+
]);
|
|
183
|
+
const _run = workflow.createRun({ runId });
|
|
184
|
+
void _run.start({
|
|
185
|
+
inputData,
|
|
186
|
+
runtimeContext: finalRuntimeContext
|
|
187
|
+
});
|
|
188
|
+
return { message: "Workflow run started" };
|
|
189
|
+
} catch (e) {
|
|
190
|
+
return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function watchWorkflowHandler({
|
|
194
|
+
mastra,
|
|
195
|
+
workflowId,
|
|
196
|
+
runId
|
|
197
|
+
}) {
|
|
198
|
+
try {
|
|
199
|
+
if (!workflowId) {
|
|
200
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
201
|
+
}
|
|
202
|
+
if (!runId) {
|
|
203
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
204
|
+
}
|
|
205
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
206
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
207
|
+
if (!run) {
|
|
208
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
209
|
+
}
|
|
210
|
+
const _run = workflow.createRun({ runId });
|
|
211
|
+
let unwatch;
|
|
212
|
+
let asyncRef = null;
|
|
213
|
+
const stream = new web.ReadableStream({
|
|
214
|
+
start(controller) {
|
|
215
|
+
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
216
|
+
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
217
|
+
if (asyncRef) {
|
|
218
|
+
clearImmediate(asyncRef);
|
|
219
|
+
asyncRef = null;
|
|
220
|
+
}
|
|
221
|
+
asyncRef = setImmediate(async () => {
|
|
222
|
+
const runDone = payload.workflowState.status !== "running";
|
|
223
|
+
if (runDone) {
|
|
224
|
+
controller.close();
|
|
225
|
+
unwatch?.();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
cancel() {
|
|
231
|
+
unwatch?.();
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
return stream;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function streamWorkflowHandler({
|
|
240
|
+
mastra,
|
|
241
|
+
runtimeContext,
|
|
242
|
+
workflowId,
|
|
243
|
+
runId,
|
|
244
|
+
inputData,
|
|
245
|
+
runtimeContextFromRequest
|
|
246
|
+
}) {
|
|
247
|
+
try {
|
|
248
|
+
if (!workflowId) {
|
|
249
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
250
|
+
}
|
|
251
|
+
if (!runId) {
|
|
252
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
253
|
+
}
|
|
254
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
255
|
+
if (!workflow) {
|
|
256
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
257
|
+
}
|
|
258
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
259
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
260
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
261
|
+
]);
|
|
262
|
+
const run = workflow.createRun({ runId });
|
|
263
|
+
const result = run.stream({
|
|
264
|
+
inputData,
|
|
265
|
+
runtimeContext: finalRuntimeContext
|
|
266
|
+
});
|
|
267
|
+
return result;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error executing workflow");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function resumeAsyncWorkflowHandler({
|
|
273
|
+
mastra,
|
|
274
|
+
workflowId,
|
|
275
|
+
runId,
|
|
276
|
+
body,
|
|
277
|
+
runtimeContext,
|
|
278
|
+
runtimeContextFromRequest
|
|
279
|
+
}) {
|
|
280
|
+
try {
|
|
281
|
+
if (!workflowId) {
|
|
282
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
283
|
+
}
|
|
284
|
+
if (!runId) {
|
|
285
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
286
|
+
}
|
|
287
|
+
if (!body.step) {
|
|
288
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
289
|
+
}
|
|
290
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
291
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
292
|
+
if (!run) {
|
|
293
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
294
|
+
}
|
|
295
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
296
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
297
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
298
|
+
]);
|
|
299
|
+
const _run = workflow.createRun({ runId });
|
|
300
|
+
const result = await _run.resume({
|
|
301
|
+
step: body.step,
|
|
302
|
+
resumeData: body.resumeData,
|
|
303
|
+
runtimeContext: finalRuntimeContext
|
|
304
|
+
});
|
|
305
|
+
return result;
|
|
306
|
+
} catch (error) {
|
|
307
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
async function resumeWorkflowHandler({
|
|
311
|
+
mastra,
|
|
312
|
+
workflowId,
|
|
313
|
+
runId,
|
|
314
|
+
body,
|
|
315
|
+
runtimeContext
|
|
316
|
+
}) {
|
|
317
|
+
try {
|
|
318
|
+
if (!workflowId) {
|
|
319
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
320
|
+
}
|
|
321
|
+
if (!runId) {
|
|
322
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
323
|
+
}
|
|
324
|
+
if (!body.step) {
|
|
325
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
326
|
+
}
|
|
327
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
328
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
329
|
+
if (!run) {
|
|
330
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
331
|
+
}
|
|
332
|
+
const _run = workflow.createRun({ runId });
|
|
333
|
+
void _run.resume({
|
|
334
|
+
step: body.step,
|
|
335
|
+
resumeData: body.resumeData,
|
|
336
|
+
runtimeContext
|
|
337
|
+
});
|
|
338
|
+
return { message: "Workflow run resumed" };
|
|
339
|
+
} catch (error) {
|
|
340
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async function getWorkflowRunsHandler({
|
|
344
|
+
mastra,
|
|
345
|
+
workflowId,
|
|
346
|
+
fromDate,
|
|
347
|
+
toDate,
|
|
348
|
+
limit,
|
|
349
|
+
offset,
|
|
350
|
+
resourceId
|
|
351
|
+
}) {
|
|
352
|
+
try {
|
|
353
|
+
if (!workflowId) {
|
|
354
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
355
|
+
}
|
|
356
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
357
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
358
|
+
runs: [],
|
|
359
|
+
total: 0
|
|
360
|
+
};
|
|
361
|
+
return workflowRuns;
|
|
362
|
+
} catch (error) {
|
|
363
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
exports.createWorkflowRunHandler = createWorkflowRunHandler;
|
|
368
|
+
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
369
|
+
exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
370
|
+
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
371
|
+
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
372
|
+
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
373
|
+
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
374
|
+
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
375
|
+
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
376
|
+
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
377
|
+
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
378
|
+
exports.workflows_exports = workflows_exports;
|
|
@@ -1,12 +1,12 @@
|
|
|
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 chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
6
|
|
|
7
7
|
// src/server/handlers/logs.ts
|
|
8
8
|
var logs_exports = {};
|
|
9
|
-
|
|
9
|
+
chunk75ZPJI57_cjs.__export(logs_exports, {
|
|
10
10
|
getLogTransports: () => getLogTransports,
|
|
11
11
|
getLogsByRunIdHandler: () => getLogsByRunIdHandler,
|
|
12
12
|
getLogsHandler: () => getLogsHandler
|
|
@@ -16,11 +16,11 @@ async function getLogsHandler({
|
|
|
16
16
|
transportId
|
|
17
17
|
}) {
|
|
18
18
|
try {
|
|
19
|
-
|
|
19
|
+
chunk57CJTIPW_cjs.validateBody({ transportId });
|
|
20
20
|
const logs = await mastra.getLogs(transportId);
|
|
21
21
|
return logs;
|
|
22
22
|
} catch (error) {
|
|
23
|
-
return
|
|
23
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting logs");
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
async function getLogsByRunIdHandler({
|
|
@@ -29,22 +29,22 @@ async function getLogsByRunIdHandler({
|
|
|
29
29
|
transportId
|
|
30
30
|
}) {
|
|
31
31
|
try {
|
|
32
|
-
|
|
32
|
+
chunk57CJTIPW_cjs.validateBody({ runId, transportId });
|
|
33
33
|
const logs = await mastra.getLogsByRunId({ runId, transportId });
|
|
34
34
|
return logs;
|
|
35
35
|
} catch (error) {
|
|
36
|
-
return
|
|
36
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting logs by run ID");
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
async function getLogTransports({ mastra }) {
|
|
40
40
|
try {
|
|
41
41
|
const logger = mastra.getLogger();
|
|
42
|
-
const transports = logger.
|
|
42
|
+
const transports = logger.getTransports();
|
|
43
43
|
return {
|
|
44
|
-
transports: transports ?
|
|
44
|
+
transports: transports ? [...transports.keys()] : []
|
|
45
45
|
};
|
|
46
46
|
} catch (error) {
|
|
47
|
-
return
|
|
47
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting log Transports");
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/server/http-exception.ts
|
|
8
2
|
var HTTPException = class extends Error {
|
|
9
3
|
res;
|
|
@@ -37,4 +31,4 @@ var HTTPException = class extends Error {
|
|
|
37
31
|
}
|
|
38
32
|
};
|
|
39
33
|
|
|
40
|
-
export { HTTPException
|
|
34
|
+
export { HTTPException };
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __export = (target, all) => {
|
|
5
|
-
for (var name in all)
|
|
6
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
// src/server/http-exception.ts
|
|
10
4
|
var HTTPException = class extends Error {
|
|
11
5
|
res;
|
|
@@ -40,4 +34,3 @@ var HTTPException = class extends Error {
|
|
|
40
34
|
};
|
|
41
35
|
|
|
42
36
|
exports.HTTPException = HTTPException;
|
|
43
|
-
exports.__export = __export;
|