@mastra/server 0.0.0-generate-message-id-20250512171942 → 0.0.0-inject-middleware-20250528213451
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 +114 -96
- package/dist/_tsup-dts-rollup.d.ts +114 -96
- package/dist/{chunk-IU5VO2I2.js → chunk-55DOQLP6.js} +2 -2
- package/dist/{chunk-3HQNCTZ2.cjs → chunk-A3KDUGS7.cjs} +42 -2
- package/dist/{chunk-4YZ3U35L.cjs → chunk-BNEY4P4P.cjs} +2 -2
- package/dist/{chunk-X3ZDCS52.js → chunk-DJJIUEL2.js} +9 -2
- package/dist/{chunk-HWZVAG3H.js → chunk-DQLE3DVM.js} +2 -2
- package/dist/{chunk-Q6KMBIAN.js → chunk-J3PKLB3A.js} +42 -2
- package/dist/{chunk-MIQYDLLM.js → chunk-KUNQFY2W.js} +70 -34
- package/dist/{chunk-UCTEMO2Q.cjs → chunk-MMO2HDM6.cjs} +81 -44
- package/dist/{chunk-OGCNNUHF.cjs → chunk-NEOOQUKW.cjs} +2 -2
- package/dist/{chunk-EJO45KYT.js → chunk-W7VCKPAD.js} +34 -34
- package/dist/{chunk-24EGIVT7.cjs → chunk-Y7UWRW5X.cjs} +9 -2
- package/dist/{chunk-I2B73Y4I.cjs → chunk-YIOVBYZH.cjs} +44 -44
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.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/vector.cjs +7 -7
- package/dist/server/handlers/vector.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 +20 -20
- package/dist/server/handlers.d.cts +1 -1
- package/dist/server/handlers.d.ts +1 -1
- package/dist/server/handlers.js +7 -7
- package/package.json +5 -5
- 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
|
@@ -5,26 +5,28 @@ import { __export } from './chunk-MLKGABMK.js';
|
|
|
5
5
|
import { ReadableStream } from 'node:stream/web';
|
|
6
6
|
import { RuntimeContext } from '@mastra/core/di';
|
|
7
7
|
|
|
8
|
-
// src/server/handlers/
|
|
9
|
-
var
|
|
10
|
-
__export(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
// src/server/handlers/workflows.ts
|
|
9
|
+
var workflows_exports = {};
|
|
10
|
+
__export(workflows_exports, {
|
|
11
|
+
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
12
|
+
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
13
|
+
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
14
|
+
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
15
|
+
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
16
|
+
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
17
|
+
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
18
|
+
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
19
|
+
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
20
|
+
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
21
|
+
watchWorkflowHandler: () => watchWorkflowHandler
|
|
21
22
|
});
|
|
22
|
-
async function
|
|
23
|
+
async function getWorkflowsHandler({ mastra }) {
|
|
23
24
|
try {
|
|
24
|
-
const workflows = mastra.
|
|
25
|
+
const workflows = mastra.getWorkflows({ serialized: false });
|
|
25
26
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
26
27
|
acc[key] = {
|
|
27
28
|
name: workflow.name,
|
|
29
|
+
description: workflow.description,
|
|
28
30
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
29
31
|
acc2[key2] = {
|
|
30
32
|
id: step.id,
|
|
@@ -47,12 +49,12 @@ async function getVNextWorkflowsHandler({ mastra }) {
|
|
|
47
49
|
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
async function
|
|
52
|
+
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
51
53
|
try {
|
|
52
54
|
if (!workflowId) {
|
|
53
55
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
54
56
|
}
|
|
55
|
-
const workflow = mastra.
|
|
57
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
56
58
|
if (!workflow) {
|
|
57
59
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
58
60
|
}
|
|
@@ -69,6 +71,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
69
71
|
return acc;
|
|
70
72
|
}, {}),
|
|
71
73
|
name: workflow.name,
|
|
74
|
+
description: workflow.description,
|
|
72
75
|
stepGraph: workflow.serializedStepGraph,
|
|
73
76
|
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
74
77
|
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
@@ -77,7 +80,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
77
80
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
async function
|
|
83
|
+
async function getWorkflowRunByIdHandler({
|
|
81
84
|
mastra,
|
|
82
85
|
workflowId,
|
|
83
86
|
runId
|
|
@@ -89,7 +92,7 @@ async function getVNextWorkflowRunByIdHandler({
|
|
|
89
92
|
if (!runId) {
|
|
90
93
|
throw new HTTPException(400, { message: "Run ID is required" });
|
|
91
94
|
}
|
|
92
|
-
const workflow = mastra.
|
|
95
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
93
96
|
if (!workflow) {
|
|
94
97
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
95
98
|
}
|
|
@@ -102,7 +105,7 @@ async function getVNextWorkflowRunByIdHandler({
|
|
|
102
105
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
103
106
|
}
|
|
104
107
|
}
|
|
105
|
-
async function
|
|
108
|
+
async function createWorkflowRunHandler({
|
|
106
109
|
mastra,
|
|
107
110
|
workflowId,
|
|
108
111
|
runId: prevRunId
|
|
@@ -111,7 +114,7 @@ async function createVNextWorkflowRunHandler({
|
|
|
111
114
|
if (!workflowId) {
|
|
112
115
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
113
116
|
}
|
|
114
|
-
const workflow = mastra.
|
|
117
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
115
118
|
if (!workflow) {
|
|
116
119
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
117
120
|
}
|
|
@@ -121,7 +124,7 @@ async function createVNextWorkflowRunHandler({
|
|
|
121
124
|
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
|
-
async function
|
|
127
|
+
async function startAsyncWorkflowHandler({
|
|
125
128
|
mastra,
|
|
126
129
|
runtimeContext,
|
|
127
130
|
workflowId,
|
|
@@ -133,7 +136,7 @@ async function startAsyncVNextWorkflowHandler({
|
|
|
133
136
|
if (!workflowId) {
|
|
134
137
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
135
138
|
}
|
|
136
|
-
const workflow = mastra.
|
|
139
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
137
140
|
if (!workflow) {
|
|
138
141
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
139
142
|
}
|
|
@@ -151,7 +154,7 @@ async function startAsyncVNextWorkflowHandler({
|
|
|
151
154
|
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
|
-
async function
|
|
157
|
+
async function startWorkflowRunHandler({
|
|
155
158
|
mastra,
|
|
156
159
|
runtimeContext,
|
|
157
160
|
workflowId,
|
|
@@ -166,7 +169,7 @@ async function startVNextWorkflowRunHandler({
|
|
|
166
169
|
if (!runId) {
|
|
167
170
|
throw new HTTPException(400, { message: "runId required to start run" });
|
|
168
171
|
}
|
|
169
|
-
const workflow = mastra.
|
|
172
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
170
173
|
const run = await workflow.getWorkflowRunById(runId);
|
|
171
174
|
if (!run) {
|
|
172
175
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -185,7 +188,7 @@ async function startVNextWorkflowRunHandler({
|
|
|
185
188
|
return handleError(e, "Error starting workflow run");
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
|
-
async function
|
|
191
|
+
async function watchWorkflowHandler({
|
|
189
192
|
mastra,
|
|
190
193
|
workflowId,
|
|
191
194
|
runId
|
|
@@ -197,7 +200,7 @@ async function watchVNextWorkflowHandler({
|
|
|
197
200
|
if (!runId) {
|
|
198
201
|
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
199
202
|
}
|
|
200
|
-
const workflow = mastra.
|
|
203
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
201
204
|
const run = await workflow.getWorkflowRunById(runId);
|
|
202
205
|
if (!run) {
|
|
203
206
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -231,7 +234,40 @@ async function watchVNextWorkflowHandler({
|
|
|
231
234
|
return handleError(error, "Error watching workflow");
|
|
232
235
|
}
|
|
233
236
|
}
|
|
234
|
-
|
|
237
|
+
function streamWorkflowHandler({
|
|
238
|
+
mastra,
|
|
239
|
+
runtimeContext,
|
|
240
|
+
workflowId,
|
|
241
|
+
runId,
|
|
242
|
+
inputData,
|
|
243
|
+
runtimeContextFromRequest
|
|
244
|
+
}) {
|
|
245
|
+
try {
|
|
246
|
+
if (!workflowId) {
|
|
247
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
248
|
+
}
|
|
249
|
+
if (!runId) {
|
|
250
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
251
|
+
}
|
|
252
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
253
|
+
if (!workflow) {
|
|
254
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
255
|
+
}
|
|
256
|
+
const finalRuntimeContext = new RuntimeContext([
|
|
257
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
258
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
259
|
+
]);
|
|
260
|
+
const run = workflow.createRun({ runId });
|
|
261
|
+
const result = run.stream({
|
|
262
|
+
inputData,
|
|
263
|
+
runtimeContext: finalRuntimeContext
|
|
264
|
+
});
|
|
265
|
+
return result;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return handleError(error, "Error executing workflow");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function resumeAsyncWorkflowHandler({
|
|
235
271
|
mastra,
|
|
236
272
|
workflowId,
|
|
237
273
|
runId,
|
|
@@ -249,7 +285,7 @@ async function resumeAsyncVNextWorkflowHandler({
|
|
|
249
285
|
if (!body.step) {
|
|
250
286
|
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
251
287
|
}
|
|
252
|
-
const workflow = mastra.
|
|
288
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
253
289
|
const run = await workflow.getWorkflowRunById(runId);
|
|
254
290
|
if (!run) {
|
|
255
291
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -269,7 +305,7 @@ async function resumeAsyncVNextWorkflowHandler({
|
|
|
269
305
|
return handleError(error, "Error resuming workflow step");
|
|
270
306
|
}
|
|
271
307
|
}
|
|
272
|
-
async function
|
|
308
|
+
async function resumeWorkflowHandler({
|
|
273
309
|
mastra,
|
|
274
310
|
workflowId,
|
|
275
311
|
runId,
|
|
@@ -286,7 +322,7 @@ async function resumeVNextWorkflowHandler({
|
|
|
286
322
|
if (!body.step) {
|
|
287
323
|
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
288
324
|
}
|
|
289
|
-
const workflow = mastra.
|
|
325
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
290
326
|
const run = await workflow.getWorkflowRunById(runId);
|
|
291
327
|
if (!run) {
|
|
292
328
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -302,7 +338,7 @@ async function resumeVNextWorkflowHandler({
|
|
|
302
338
|
return handleError(error, "Error resuming workflow");
|
|
303
339
|
}
|
|
304
340
|
}
|
|
305
|
-
async function
|
|
341
|
+
async function getWorkflowRunsHandler({
|
|
306
342
|
mastra,
|
|
307
343
|
workflowId,
|
|
308
344
|
fromDate,
|
|
@@ -315,7 +351,7 @@ async function getVNextWorkflowRunsHandler({
|
|
|
315
351
|
if (!workflowId) {
|
|
316
352
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
317
353
|
}
|
|
318
|
-
const workflow = mastra.
|
|
354
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
319
355
|
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
320
356
|
runs: [],
|
|
321
357
|
total: 0
|
|
@@ -326,4 +362,4 @@ async function getVNextWorkflowRunsHandler({
|
|
|
326
362
|
}
|
|
327
363
|
}
|
|
328
364
|
|
|
329
|
-
export {
|
|
365
|
+
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|
|
@@ -7,26 +7,28 @@ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
|
7
7
|
var web = require('stream/web');
|
|
8
8
|
var di = require('@mastra/core/di');
|
|
9
9
|
|
|
10
|
-
// src/server/handlers/
|
|
11
|
-
var
|
|
12
|
-
chunk75ZPJI57_cjs.__export(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
23
24
|
});
|
|
24
|
-
async function
|
|
25
|
+
async function getWorkflowsHandler({ mastra }) {
|
|
25
26
|
try {
|
|
26
|
-
const workflows = mastra.
|
|
27
|
+
const workflows = mastra.getWorkflows({ serialized: false });
|
|
27
28
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
28
29
|
acc[key] = {
|
|
29
30
|
name: workflow.name,
|
|
31
|
+
description: workflow.description,
|
|
30
32
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
31
33
|
acc2[key2] = {
|
|
32
34
|
id: step.id,
|
|
@@ -49,12 +51,12 @@ async function getVNextWorkflowsHandler({ mastra }) {
|
|
|
49
51
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
|
-
async function
|
|
54
|
+
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
53
55
|
try {
|
|
54
56
|
if (!workflowId) {
|
|
55
57
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
56
58
|
}
|
|
57
|
-
const workflow = mastra.
|
|
59
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
58
60
|
if (!workflow) {
|
|
59
61
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
60
62
|
}
|
|
@@ -71,6 +73,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
71
73
|
return acc;
|
|
72
74
|
}, {}),
|
|
73
75
|
name: workflow.name,
|
|
76
|
+
description: workflow.description,
|
|
74
77
|
stepGraph: workflow.serializedStepGraph,
|
|
75
78
|
inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
76
79
|
outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
@@ -79,7 +82,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
79
82
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
async function
|
|
85
|
+
async function getWorkflowRunByIdHandler({
|
|
83
86
|
mastra,
|
|
84
87
|
workflowId,
|
|
85
88
|
runId
|
|
@@ -91,7 +94,7 @@ async function getVNextWorkflowRunByIdHandler({
|
|
|
91
94
|
if (!runId) {
|
|
92
95
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
93
96
|
}
|
|
94
|
-
const workflow = mastra.
|
|
97
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
95
98
|
if (!workflow) {
|
|
96
99
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
97
100
|
}
|
|
@@ -104,7 +107,7 @@ async function getVNextWorkflowRunByIdHandler({
|
|
|
104
107
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
async function
|
|
110
|
+
async function createWorkflowRunHandler({
|
|
108
111
|
mastra,
|
|
109
112
|
workflowId,
|
|
110
113
|
runId: prevRunId
|
|
@@ -113,7 +116,7 @@ async function createVNextWorkflowRunHandler({
|
|
|
113
116
|
if (!workflowId) {
|
|
114
117
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
115
118
|
}
|
|
116
|
-
const workflow = mastra.
|
|
119
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
117
120
|
if (!workflow) {
|
|
118
121
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
119
122
|
}
|
|
@@ -123,7 +126,7 @@ async function createVNextWorkflowRunHandler({
|
|
|
123
126
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
async function
|
|
129
|
+
async function startAsyncWorkflowHandler({
|
|
127
130
|
mastra,
|
|
128
131
|
runtimeContext,
|
|
129
132
|
workflowId,
|
|
@@ -135,7 +138,7 @@ async function startAsyncVNextWorkflowHandler({
|
|
|
135
138
|
if (!workflowId) {
|
|
136
139
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
137
140
|
}
|
|
138
|
-
const workflow = mastra.
|
|
141
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
139
142
|
if (!workflow) {
|
|
140
143
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
141
144
|
}
|
|
@@ -153,7 +156,7 @@ async function startAsyncVNextWorkflowHandler({
|
|
|
153
156
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
|
-
async function
|
|
159
|
+
async function startWorkflowRunHandler({
|
|
157
160
|
mastra,
|
|
158
161
|
runtimeContext,
|
|
159
162
|
workflowId,
|
|
@@ -168,7 +171,7 @@ async function startVNextWorkflowRunHandler({
|
|
|
168
171
|
if (!runId) {
|
|
169
172
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
170
173
|
}
|
|
171
|
-
const workflow = mastra.
|
|
174
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
172
175
|
const run = await workflow.getWorkflowRunById(runId);
|
|
173
176
|
if (!run) {
|
|
174
177
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -187,7 +190,7 @@ async function startVNextWorkflowRunHandler({
|
|
|
187
190
|
return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
|
-
async function
|
|
193
|
+
async function watchWorkflowHandler({
|
|
191
194
|
mastra,
|
|
192
195
|
workflowId,
|
|
193
196
|
runId
|
|
@@ -199,7 +202,7 @@ async function watchVNextWorkflowHandler({
|
|
|
199
202
|
if (!runId) {
|
|
200
203
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
201
204
|
}
|
|
202
|
-
const workflow = mastra.
|
|
205
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
203
206
|
const run = await workflow.getWorkflowRunById(runId);
|
|
204
207
|
if (!run) {
|
|
205
208
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -233,7 +236,40 @@ async function watchVNextWorkflowHandler({
|
|
|
233
236
|
return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
|
-
|
|
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({
|
|
237
273
|
mastra,
|
|
238
274
|
workflowId,
|
|
239
275
|
runId,
|
|
@@ -251,7 +287,7 @@ async function resumeAsyncVNextWorkflowHandler({
|
|
|
251
287
|
if (!body.step) {
|
|
252
288
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
253
289
|
}
|
|
254
|
-
const workflow = mastra.
|
|
290
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
255
291
|
const run = await workflow.getWorkflowRunById(runId);
|
|
256
292
|
if (!run) {
|
|
257
293
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -271,7 +307,7 @@ async function resumeAsyncVNextWorkflowHandler({
|
|
|
271
307
|
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
|
|
272
308
|
}
|
|
273
309
|
}
|
|
274
|
-
async function
|
|
310
|
+
async function resumeWorkflowHandler({
|
|
275
311
|
mastra,
|
|
276
312
|
workflowId,
|
|
277
313
|
runId,
|
|
@@ -288,7 +324,7 @@ async function resumeVNextWorkflowHandler({
|
|
|
288
324
|
if (!body.step) {
|
|
289
325
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
290
326
|
}
|
|
291
|
-
const workflow = mastra.
|
|
327
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
292
328
|
const run = await workflow.getWorkflowRunById(runId);
|
|
293
329
|
if (!run) {
|
|
294
330
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
@@ -304,7 +340,7 @@ async function resumeVNextWorkflowHandler({
|
|
|
304
340
|
return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
|
|
305
341
|
}
|
|
306
342
|
}
|
|
307
|
-
async function
|
|
343
|
+
async function getWorkflowRunsHandler({
|
|
308
344
|
mastra,
|
|
309
345
|
workflowId,
|
|
310
346
|
fromDate,
|
|
@@ -317,7 +353,7 @@ async function getVNextWorkflowRunsHandler({
|
|
|
317
353
|
if (!workflowId) {
|
|
318
354
|
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
319
355
|
}
|
|
320
|
-
const workflow = mastra.
|
|
356
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
321
357
|
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
322
358
|
runs: [],
|
|
323
359
|
total: 0
|
|
@@ -328,14 +364,15 @@ async function getVNextWorkflowRunsHandler({
|
|
|
328
364
|
}
|
|
329
365
|
}
|
|
330
366
|
|
|
331
|
-
exports.
|
|
332
|
-
exports.
|
|
333
|
-
exports.
|
|
334
|
-
exports.
|
|
335
|
-
exports.
|
|
336
|
-
exports.
|
|
337
|
-
exports.
|
|
338
|
-
exports.
|
|
339
|
-
exports.
|
|
340
|
-
exports.
|
|
341
|
-
exports.
|
|
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;
|
|
@@ -39,9 +39,9 @@ async function getLogsByRunIdHandler({
|
|
|
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
47
|
return chunk64U3UDTH_cjs.handleError(error, "Error getting log Transports");
|