@mastra/server 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-fix-fetch-workflow-runs-20250624231457
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 +444 -108
- package/dist/_tsup-dts-rollup.d.ts +444 -108
- package/dist/chunk-4DTDPTQC.cjs +332 -0
- 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-AMVOS7YB.cjs → chunk-B4MQFJ7G.cjs} +12 -8
- package/dist/{chunk-BPL2CBLV.js → chunk-BFOA2QQY.js} +8 -4
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
- package/dist/{chunk-D3G23FP3.cjs → chunk-CPPYMJX5.cjs} +24 -22
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-GKM45O24.cjs +278 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/chunk-IMBY5XUG.cjs +86 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-MN6F4D5A.cjs +2004 -0
- package/dist/{chunk-3XTEV33Q.js → chunk-N2YBMSO2.js} +54 -51
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/chunk-OSZM4EAY.js +2001 -0
- package/dist/{chunk-Y3SV5XK4.js → chunk-PMUATKV2.js} +104 -15
- package/dist/chunk-QLG2PFHE.js +81 -0
- package/dist/{chunk-Q6SHQECN.js → chunk-R5VGYBV6.js} +34 -10
- package/dist/{chunk-2FJURXCL.cjs → chunk-RQ2Z56EC.cjs} +93 -55
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/{chunk-IQTNZSFP.js → chunk-SOBBILUG.js} +160 -51
- package/dist/chunk-TO5U6HW3.cjs +435 -0
- package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
- package/dist/chunk-WJY57THV.cjs +118 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-XR7VJOOP.js} +7 -5
- package/dist/{chunk-RBQASTUP.js → chunk-XUIJ7WRT.js} +63 -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/vNextNetwork.cjs +175 -0
- package/dist/server/handlers/vNextNetwork.d.cts +5 -0
- package/dist/server/handlers/vNextNetwork.d.ts +5 -0
- package/dist/server/handlers/vNextNetwork.js +169 -0
- 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 +21 -13
- package/dist/server/handlers/workflows.d.cts +4 -2
- package/dist/server/handlers/workflows.d.ts +4 -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 +13 -12
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-4BIX6GMY.cjs +0 -189
- package/dist/chunk-55HTWX4C.cjs +0 -93
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-CHFORQ7J.cjs +0 -329
- package/dist/chunk-FOXHTOQZ.cjs +0 -324
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-SKBVVI24.cjs +0 -54
- 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
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { stringify, esm_default } from './chunk-OSZM4EAY.js';
|
|
2
|
+
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
5
|
+
import { ReadableStream } from 'stream/web';
|
|
5
6
|
|
|
6
|
-
// src/server/handlers/
|
|
7
|
-
var
|
|
8
|
-
__export(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
// src/server/handlers/workflows.ts
|
|
8
|
+
var workflows_exports = {};
|
|
9
|
+
__export(workflows_exports, {
|
|
10
|
+
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
11
|
+
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
12
|
+
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
13
|
+
getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
|
|
14
|
+
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
15
|
+
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
16
|
+
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
17
|
+
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
18
|
+
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
19
|
+
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
20
|
+
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
21
|
+
watchWorkflowHandler: () => watchWorkflowHandler
|
|
19
22
|
});
|
|
20
|
-
async function
|
|
23
|
+
async function getWorkflowsHandler({ mastra }) {
|
|
21
24
|
try {
|
|
22
|
-
const workflows = mastra.
|
|
25
|
+
const workflows = mastra.getWorkflows({ serialized: false });
|
|
23
26
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
24
27
|
acc[key] = {
|
|
25
28
|
name: workflow.name,
|
|
29
|
+
description: workflow.description,
|
|
26
30
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
27
31
|
acc2[key2] = {
|
|
28
32
|
id: step.id,
|
|
@@ -45,12 +49,46 @@ async function getVNextWorkflowsHandler({ mastra }) {
|
|
|
45
49
|
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
46
50
|
}
|
|
47
51
|
}
|
|
48
|
-
async function
|
|
52
|
+
async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
53
|
+
const logger = mastra.getLogger();
|
|
54
|
+
if (!workflowId) {
|
|
55
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
56
|
+
}
|
|
57
|
+
let workflow;
|
|
58
|
+
try {
|
|
59
|
+
workflow = mastra.getWorkflow(workflowId);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
logger.debug("Error getting workflow, searching agents for workflow", error);
|
|
62
|
+
}
|
|
63
|
+
if (!workflow) {
|
|
64
|
+
logger.debug("Workflow not found, searching agents for workflow", { workflowId });
|
|
65
|
+
const agents = mastra.getAgents();
|
|
66
|
+
if (Object.keys(agents || {}).length) {
|
|
67
|
+
for (const [_, agent] of Object.entries(agents)) {
|
|
68
|
+
try {
|
|
69
|
+
const workflows = await agent.getWorkflows();
|
|
70
|
+
if (workflows[workflowId]) {
|
|
71
|
+
workflow = workflows[workflowId];
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
logger.debug("Error getting workflow from agent", error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!workflow) {
|
|
82
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
83
|
+
}
|
|
84
|
+
return { workflow };
|
|
85
|
+
}
|
|
86
|
+
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
49
87
|
try {
|
|
50
88
|
if (!workflowId) {
|
|
51
89
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
52
90
|
}
|
|
53
|
-
const workflow = mastra
|
|
91
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
54
92
|
if (!workflow) {
|
|
55
93
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
56
94
|
}
|
|
@@ -67,6 +105,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
67
105
|
return acc;
|
|
68
106
|
}, {}),
|
|
69
107
|
name: workflow.name,
|
|
108
|
+
description: workflow.description,
|
|
70
109
|
stepGraph: workflow.serializedStepGraph,
|
|
71
110
|
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
72
111
|
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
@@ -75,7 +114,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
75
114
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
76
115
|
}
|
|
77
116
|
}
|
|
78
|
-
async function
|
|
117
|
+
async function getWorkflowRunByIdHandler({
|
|
79
118
|
mastra,
|
|
80
119
|
workflowId,
|
|
81
120
|
runId
|
|
@@ -87,11 +126,11 @@ async function getVNextWorkflowRunHandler({
|
|
|
87
126
|
if (!runId) {
|
|
88
127
|
throw new HTTPException(400, { message: "Run ID is required" });
|
|
89
128
|
}
|
|
90
|
-
const workflow = mastra
|
|
129
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
91
130
|
if (!workflow) {
|
|
92
131
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
93
132
|
}
|
|
94
|
-
const run = await workflow.
|
|
133
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
95
134
|
if (!run) {
|
|
96
135
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
97
136
|
}
|
|
@@ -100,7 +139,34 @@ async function getVNextWorkflowRunHandler({
|
|
|
100
139
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
101
140
|
}
|
|
102
141
|
}
|
|
103
|
-
async function
|
|
142
|
+
async function getWorkflowRunExecutionResultHandler({
|
|
143
|
+
mastra,
|
|
144
|
+
workflowId,
|
|
145
|
+
runId
|
|
146
|
+
}) {
|
|
147
|
+
try {
|
|
148
|
+
if (!workflowId) {
|
|
149
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
150
|
+
}
|
|
151
|
+
if (!runId) {
|
|
152
|
+
throw new HTTPException(400, { message: "Run ID is required" });
|
|
153
|
+
}
|
|
154
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
155
|
+
if (!workflow) {
|
|
156
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
157
|
+
}
|
|
158
|
+
const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
|
|
159
|
+
if (!executionResult) {
|
|
160
|
+
throw new HTTPException(404, { message: "Workflow run execution result not found" });
|
|
161
|
+
}
|
|
162
|
+
return executionResult;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw new HTTPException(500, {
|
|
165
|
+
message: error?.message || "Error getting workflow run execution result"
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
async function createWorkflowRunHandler({
|
|
104
170
|
mastra,
|
|
105
171
|
workflowId,
|
|
106
172
|
runId: prevRunId
|
|
@@ -109,17 +175,17 @@ async function createVNextWorkflowRunHandler({
|
|
|
109
175
|
if (!workflowId) {
|
|
110
176
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
111
177
|
}
|
|
112
|
-
const workflow = mastra
|
|
178
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
113
179
|
if (!workflow) {
|
|
114
180
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
115
181
|
}
|
|
116
|
-
const run = workflow.
|
|
182
|
+
const run = await workflow.createRunAsync({ runId: prevRunId });
|
|
117
183
|
return { runId: run.runId };
|
|
118
184
|
} catch (error) {
|
|
119
185
|
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
120
186
|
}
|
|
121
187
|
}
|
|
122
|
-
async function
|
|
188
|
+
async function startAsyncWorkflowHandler({
|
|
123
189
|
mastra,
|
|
124
190
|
runtimeContext,
|
|
125
191
|
workflowId,
|
|
@@ -130,11 +196,11 @@ async function startAsyncVNextWorkflowHandler({
|
|
|
130
196
|
if (!workflowId) {
|
|
131
197
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
132
198
|
}
|
|
133
|
-
const workflow = mastra
|
|
199
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
134
200
|
if (!workflow) {
|
|
135
201
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
136
202
|
}
|
|
137
|
-
const _run = workflow.
|
|
203
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
138
204
|
const result = await _run.start({
|
|
139
205
|
inputData,
|
|
140
206
|
runtimeContext
|
|
@@ -144,7 +210,7 @@ async function startAsyncVNextWorkflowHandler({
|
|
|
144
210
|
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
145
211
|
}
|
|
146
212
|
}
|
|
147
|
-
async function
|
|
213
|
+
async function startWorkflowRunHandler({
|
|
148
214
|
mastra,
|
|
149
215
|
runtimeContext,
|
|
150
216
|
workflowId,
|
|
@@ -158,13 +224,16 @@ async function startVNextWorkflowRunHandler({
|
|
|
158
224
|
if (!runId) {
|
|
159
225
|
throw new HTTPException(400, { message: "runId required to start run" });
|
|
160
226
|
}
|
|
161
|
-
const workflow = mastra
|
|
162
|
-
|
|
227
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
228
|
+
if (!workflow) {
|
|
229
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
230
|
+
}
|
|
231
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
163
232
|
if (!run) {
|
|
164
233
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
165
234
|
}
|
|
166
|
-
const _run = workflow.
|
|
167
|
-
|
|
235
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
236
|
+
void _run.start({
|
|
168
237
|
inputData,
|
|
169
238
|
runtimeContext
|
|
170
239
|
});
|
|
@@ -173,7 +242,7 @@ async function startVNextWorkflowRunHandler({
|
|
|
173
242
|
return handleError(e, "Error starting workflow run");
|
|
174
243
|
}
|
|
175
244
|
}
|
|
176
|
-
async function
|
|
245
|
+
async function watchWorkflowHandler({
|
|
177
246
|
mastra,
|
|
178
247
|
workflowId,
|
|
179
248
|
runId
|
|
@@ -185,12 +254,15 @@ async function watchVNextWorkflowHandler({
|
|
|
185
254
|
if (!runId) {
|
|
186
255
|
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
187
256
|
}
|
|
188
|
-
const workflow = mastra
|
|
189
|
-
|
|
257
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
258
|
+
if (!workflow) {
|
|
259
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
260
|
+
}
|
|
261
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
190
262
|
if (!run) {
|
|
191
263
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
192
264
|
}
|
|
193
|
-
const _run = workflow.
|
|
265
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
194
266
|
let unwatch;
|
|
195
267
|
let asyncRef = null;
|
|
196
268
|
const stream = new ReadableStream({
|
|
@@ -219,7 +291,35 @@ async function watchVNextWorkflowHandler({
|
|
|
219
291
|
return handleError(error, "Error watching workflow");
|
|
220
292
|
}
|
|
221
293
|
}
|
|
222
|
-
async function
|
|
294
|
+
async function streamWorkflowHandler({
|
|
295
|
+
mastra,
|
|
296
|
+
runtimeContext,
|
|
297
|
+
workflowId,
|
|
298
|
+
runId,
|
|
299
|
+
inputData
|
|
300
|
+
}) {
|
|
301
|
+
try {
|
|
302
|
+
if (!workflowId) {
|
|
303
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
304
|
+
}
|
|
305
|
+
if (!runId) {
|
|
306
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
307
|
+
}
|
|
308
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
309
|
+
if (!workflow) {
|
|
310
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
311
|
+
}
|
|
312
|
+
const run = await workflow.createRunAsync({ runId });
|
|
313
|
+
const result = run.stream({
|
|
314
|
+
inputData,
|
|
315
|
+
runtimeContext
|
|
316
|
+
});
|
|
317
|
+
return result;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
return handleError(error, "Error executing workflow");
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async function resumeAsyncWorkflowHandler({
|
|
223
323
|
mastra,
|
|
224
324
|
workflowId,
|
|
225
325
|
runId,
|
|
@@ -236,12 +336,15 @@ async function resumeAsyncVNextWorkflowHandler({
|
|
|
236
336
|
if (!body.step) {
|
|
237
337
|
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
238
338
|
}
|
|
239
|
-
const workflow = mastra
|
|
240
|
-
|
|
339
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
340
|
+
if (!workflow) {
|
|
341
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
342
|
+
}
|
|
343
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
241
344
|
if (!run) {
|
|
242
345
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
243
346
|
}
|
|
244
|
-
const _run = workflow.
|
|
347
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
245
348
|
const result = await _run.resume({
|
|
246
349
|
step: body.step,
|
|
247
350
|
resumeData: body.resumeData,
|
|
@@ -252,7 +355,7 @@ async function resumeAsyncVNextWorkflowHandler({
|
|
|
252
355
|
return handleError(error, "Error resuming workflow step");
|
|
253
356
|
}
|
|
254
357
|
}
|
|
255
|
-
async function
|
|
358
|
+
async function resumeWorkflowHandler({
|
|
256
359
|
mastra,
|
|
257
360
|
workflowId,
|
|
258
361
|
runId,
|
|
@@ -269,13 +372,16 @@ async function resumeVNextWorkflowHandler({
|
|
|
269
372
|
if (!body.step) {
|
|
270
373
|
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
271
374
|
}
|
|
272
|
-
const workflow = mastra
|
|
273
|
-
|
|
375
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
376
|
+
if (!workflow) {
|
|
377
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
378
|
+
}
|
|
379
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
274
380
|
if (!run) {
|
|
275
381
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
276
382
|
}
|
|
277
|
-
const _run = workflow.
|
|
278
|
-
|
|
383
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
384
|
+
void _run.resume({
|
|
279
385
|
step: body.step,
|
|
280
386
|
resumeData: body.resumeData,
|
|
281
387
|
runtimeContext
|
|
@@ -285,7 +391,7 @@ async function resumeVNextWorkflowHandler({
|
|
|
285
391
|
return handleError(error, "Error resuming workflow");
|
|
286
392
|
}
|
|
287
393
|
}
|
|
288
|
-
async function
|
|
394
|
+
async function getWorkflowRunsHandler({
|
|
289
395
|
mastra,
|
|
290
396
|
workflowId,
|
|
291
397
|
fromDate,
|
|
@@ -298,7 +404,10 @@ async function getVNextWorkflowRunsHandler({
|
|
|
298
404
|
if (!workflowId) {
|
|
299
405
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
300
406
|
}
|
|
301
|
-
const workflow = mastra
|
|
407
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
408
|
+
if (!workflow) {
|
|
409
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
410
|
+
}
|
|
302
411
|
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
303
412
|
runs: [],
|
|
304
413
|
total: 0
|
|
@@ -309,4 +418,4 @@ async function getVNextWorkflowRunsHandler({
|
|
|
309
418
|
}
|
|
310
419
|
}
|
|
311
420
|
|
|
312
|
-
export {
|
|
421
|
+
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|