@mastra/server 0.0.0-working-memory-per-user-20250620161509 → 0.0.0-zod-v4-compat-part-2-20250820135355
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/{chunk-VPNDC2DI.cjs → chunk-4CEZIJWJ.cjs} +16 -14
- package/dist/chunk-4CEZIJWJ.cjs.map +1 -0
- package/dist/{chunk-QLG2PFHE.js → chunk-4MQU6AJN.js} +5 -3
- package/dist/chunk-4MQU6AJN.js.map +1 -0
- package/dist/{chunk-57CJTIPW.cjs → chunk-4QSNRCOT.cjs} +4 -2
- package/dist/chunk-4QSNRCOT.cjs.map +1 -0
- package/dist/{chunk-WJY57THV.cjs → chunk-4US5W7PH.cjs} +26 -24
- package/dist/chunk-4US5W7PH.cjs.map +1 -0
- package/dist/chunk-57W7TS7P.cjs +547 -0
- package/dist/chunk-57W7TS7P.cjs.map +1 -0
- package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
- package/dist/chunk-7NADHFD2.cjs.map +1 -0
- package/dist/{chunk-IMBY5XUG.cjs → chunk-BED2O446.cjs} +11 -9
- package/dist/chunk-BED2O446.cjs.map +1 -0
- package/dist/chunk-CY4TP3FK.js +16 -0
- package/dist/chunk-CY4TP3FK.js.map +1 -0
- package/dist/{chunk-55DOQLP6.js → chunk-G7NVCO5M.js} +5 -3
- package/dist/chunk-G7NVCO5M.js.map +1 -0
- package/dist/{chunk-SDPGVWQJ.cjs → chunk-GASWM5HJ.cjs} +4 -2
- package/dist/chunk-GASWM5HJ.cjs.map +1 -0
- package/dist/{chunk-5UV7XQ4G.js → chunk-GBL4JYW7.js} +52 -16
- package/dist/chunk-GBL4JYW7.js.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/chunk-GX25CWC7.cjs +588 -0
- package/dist/chunk-GX25CWC7.cjs.map +1 -0
- package/dist/{chunk-N2YBMSO2.js → chunk-HNYYFKON.js} +18 -15
- package/dist/chunk-HNYYFKON.js.map +1 -0
- package/dist/{chunk-R5VGYBV6.js → chunk-HWHKM67I.js} +6 -4
- package/dist/chunk-HWHKM67I.js.map +1 -0
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-ILCWPBYQ.cjs} +9 -7
- package/dist/chunk-ILCWPBYQ.cjs.map +1 -0
- package/dist/{chunk-2GOU7Q4O.js → chunk-ITZX6VPI.js} +146 -73
- package/dist/chunk-ITZX6VPI.js.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/{chunk-BNEY4P4P.cjs → chunk-NCS2OXX6.cjs} +20 -18
- package/dist/chunk-NCS2OXX6.cjs.map +1 -0
- package/dist/{chunk-H5PTF3Y4.js → chunk-OW4FX5TS.js} +3 -1
- package/dist/chunk-OW4FX5TS.js.map +1 -0
- package/dist/{chunk-MLKGABMK.js → chunk-PZ5AY32C.js} +2 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{chunk-75ZPJI57.cjs → chunk-Q7SFCCGT.cjs} +2 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-RE4RPXT2.cjs +18 -0
- package/dist/chunk-RE4RPXT2.cjs.map +1 -0
- package/dist/{chunk-CPPYMJX5.cjs → chunk-RTI33BGT.cjs} +25 -22
- package/dist/chunk-RTI33BGT.cjs.map +1 -0
- package/dist/{chunk-E5IRS3XH.cjs → chunk-SKWJUK3M.cjs} +63 -26
- package/dist/chunk-SKWJUK3M.cjs.map +1 -0
- package/dist/{chunk-4DTDPTQC.cjs → chunk-SOIOAAJ4.cjs} +48 -45
- package/dist/chunk-SOIOAAJ4.cjs.map +1 -0
- package/dist/{chunk-BFOA2QQY.js → chunk-SQ7KKIH3.js} +5 -3
- package/dist/chunk-SQ7KKIH3.js.map +1 -0
- package/dist/{chunk-GHC4YV6R.js → chunk-TRWPUPGD.js} +3 -1
- package/dist/chunk-TRWPUPGD.js.map +1 -0
- package/dist/chunk-TXAQU2XN.js +151 -0
- package/dist/chunk-TXAQU2XN.js.map +1 -0
- package/dist/chunk-VIGPWTDA.cjs +159 -0
- package/dist/chunk-VIGPWTDA.cjs.map +1 -0
- package/dist/{chunk-XR7VJOOP.js → chunk-WHQZT6R2.js} +12 -9
- package/dist/chunk-WHQZT6R2.js.map +1 -0
- package/dist/{chunk-C7564HUT.js → chunk-Y3J45CVZ.js} +6 -4
- package/dist/chunk-Y3J45CVZ.js.map +1 -0
- package/dist/chunk-ZKJZQN24.js +571 -0
- package/dist/chunk-ZKJZQN24.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server/a2a/protocol.d.ts +8 -0
- package/dist/server/a2a/protocol.d.ts.map +1 -0
- package/dist/server/a2a/store.d.ts +14 -0
- package/dist/server/a2a/store.d.ts.map +1 -0
- package/dist/server/a2a/tasks.d.ts +20 -0
- package/dist/server/a2a/tasks.d.ts.map +1 -0
- package/dist/server/handlers/a2a.cjs +9 -7
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +66 -6
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -1
- package/dist/server/handlers/a2a.js.map +1 -0
- package/dist/server/handlers/agents.cjs +13 -7
- package/dist/server/handlers/agents.cjs.map +1 -0
- package/dist/server/handlers/agents.d.ts +81 -6
- package/dist/server/handlers/agents.d.ts.map +1 -0
- package/dist/server/handlers/agents.js +3 -1
- package/dist/server/handlers/agents.js.map +1 -0
- package/dist/server/handlers/error.cjs +4 -2
- package/dist/server/handlers/error.cjs.map +1 -0
- package/dist/server/handlers/error.d.ts +2 -1
- package/dist/server/handlers/error.d.ts.map +1 -0
- package/dist/server/handlers/error.js +3 -1
- package/dist/server/handlers/error.js.map +1 -0
- package/dist/server/handlers/legacyWorkflows.cjs +13 -11
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -1
- package/dist/server/handlers/legacyWorkflows.js.map +1 -0
- package/dist/server/handlers/logs.cjs +6 -4
- package/dist/server/handlers/logs.cjs.map +1 -0
- package/dist/server/handlers/logs.d.ts +34 -3
- package/dist/server/handlers/logs.d.ts.map +1 -0
- package/dist/server/handlers/logs.js +3 -1
- package/dist/server/handlers/logs.js.map +1 -0
- package/dist/server/handlers/memory.cjs +39 -9
- package/dist/server/handlers/memory.cjs.map +1 -0
- package/dist/server/handlers/memory.d.ts +119 -8
- package/dist/server/handlers/memory.d.ts.map +1 -0
- package/dist/server/handlers/memory.js +3 -1
- package/dist/server/handlers/memory.js.map +1 -0
- package/dist/server/handlers/network.cjs +7 -5
- package/dist/server/handlers/network.cjs.map +1 -0
- package/dist/server/handlers/network.d.ts +50 -4
- package/dist/server/handlers/network.d.ts.map +1 -0
- package/dist/server/handlers/network.js +3 -1
- package/dist/server/handlers/network.js.map +1 -0
- package/dist/server/handlers/scores.cjs +32 -0
- package/dist/server/handlers/scores.cjs.map +1 -0
- package/dist/server/handlers/scores.d.ts +49 -0
- package/dist/server/handlers/scores.d.ts.map +1 -0
- package/dist/server/handlers/scores.js +3 -0
- package/dist/server/handlers/scores.js.map +1 -0
- package/dist/server/handlers/telemetry.cjs +5 -3
- package/dist/server/handlers/telemetry.cjs.map +1 -0
- package/dist/server/handlers/telemetry.d.ts +32 -2
- package/dist/server/handlers/telemetry.d.ts.map +1 -0
- package/dist/server/handlers/telemetry.js +3 -1
- package/dist/server/handlers/telemetry.js.map +1 -0
- package/dist/server/handlers/tools.cjs +7 -5
- package/dist/server/handlers/tools.cjs.map +1 -0
- package/dist/server/handlers/tools.d.ts +21 -4
- package/dist/server/handlers/tools.d.ts.map +1 -0
- package/dist/server/handlers/tools.js +3 -1
- package/dist/server/handlers/tools.js.map +1 -0
- package/dist/server/handlers/utils.cjs +4 -2
- package/dist/server/handlers/utils.cjs.map +1 -0
- package/dist/server/handlers/utils.d.ts +2 -1
- package/dist/server/handlers/utils.d.ts.map +1 -0
- package/dist/server/handlers/utils.js +3 -1
- package/dist/server/handlers/utils.js.map +1 -0
- package/dist/server/handlers/vNextNetwork.cjs +220 -0
- package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
- package/dist/server/handlers/vNextNetwork.d.ts +179 -0
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
- package/dist/server/handlers/vNextNetwork.js +213 -0
- package/dist/server/handlers/vNextNetwork.js.map +1 -0
- package/dist/server/handlers/vector.cjs +9 -7
- package/dist/server/handlers/vector.cjs.map +1 -0
- package/dist/server/handlers/vector.d.ts +51 -6
- package/dist/server/handlers/vector.d.ts.map +1 -0
- package/dist/server/handlers/vector.js +3 -1
- package/dist/server/handlers/vector.js.map +1 -0
- package/dist/server/handlers/voice.cjs +7 -5
- package/dist/server/handlers/voice.cjs.map +1 -0
- package/dist/server/handlers/voice.d.ts +39 -4
- package/dist/server/handlers/voice.d.ts.map +1 -0
- package/dist/server/handlers/voice.js +3 -1
- package/dist/server/handlers/voice.js.map +1 -0
- package/dist/server/handlers/workflows.cjs +27 -13
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +88 -12
- package/dist/server/handlers/workflows.d.ts.map +1 -0
- package/dist/server/handlers/workflows.js +3 -1
- package/dist/server/handlers/workflows.js.map +1 -0
- package/dist/server/handlers.cjs +32 -25
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +13 -11
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +14 -11
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/http-exception.d.ts +87 -0
- package/dist/server/http-exception.d.ts.map +1 -0
- package/dist/server/types.d.ts +10 -0
- package/dist/server/types.d.ts.map +1 -0
- package/package.json +11 -11
- package/dist/_tsup-dts-rollup.d.cts +0 -864
- package/dist/_tsup-dts-rollup.d.ts +0 -864
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-6TJSHFCJ.cjs +0 -221
- package/dist/chunk-7TB34RLZ.cjs +0 -471
- package/dist/chunk-I7KJZNX5.js +0 -211
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-MN6F4D5A.cjs +0 -2004
- package/dist/chunk-OSZM4EAY.js +0 -2001
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/a2a.d.cts +0 -6
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/telemetry.d.cts +0 -2
- package/dist/server/handlers/tools.d.cts +0 -4
- package/dist/server/handlers/utils.d.cts +0 -1
- package/dist/server/handlers/vector.d.cts +0 -6
- package/dist/server/handlers/voice.d.cts +0 -4
- package/dist/server/handlers/workflows.d.cts +0 -12
- package/dist/server/handlers.d.cts +0 -11
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { stringify
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import { HTTPException } from './chunk-
|
|
4
|
-
import { __export } from './chunk-
|
|
1
|
+
import { stringify } from './chunk-LF2ZLOFP.js';
|
|
2
|
+
import { handleError } from './chunk-CY4TP3FK.js';
|
|
3
|
+
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
4
|
+
import { __export } from './chunk-PZ5AY32C.js';
|
|
5
5
|
import { ReadableStream } from 'stream/web';
|
|
6
|
-
import {
|
|
6
|
+
import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
|
|
7
7
|
|
|
8
8
|
// src/server/handlers/workflows.ts
|
|
9
9
|
var workflows_exports = {};
|
|
10
10
|
__export(workflows_exports, {
|
|
11
|
+
cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
|
|
11
12
|
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
12
13
|
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
13
14
|
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
@@ -16,11 +17,32 @@ __export(workflows_exports, {
|
|
|
16
17
|
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
17
18
|
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
18
19
|
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
20
|
+
sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
|
|
19
21
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
20
22
|
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
23
|
+
streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
|
|
21
24
|
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
22
25
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
23
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 ? stringify(zodToJsonSchema(step.inputSchema)) : void 0,
|
|
34
|
+
outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : void 0,
|
|
35
|
+
resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
36
|
+
suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(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
|
+
}
|
|
24
46
|
async function getWorkflowsHandler({ mastra }) {
|
|
25
47
|
try {
|
|
26
48
|
const workflows = mastra.getWorkflows({ serialized: false });
|
|
@@ -32,22 +54,23 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
32
54
|
acc2[key2] = {
|
|
33
55
|
id: step.id,
|
|
34
56
|
description: step.description,
|
|
35
|
-
inputSchema: step.inputSchema ? stringify(
|
|
36
|
-
outputSchema: step.outputSchema ? stringify(
|
|
37
|
-
resumeSchema: step.resumeSchema ? stringify(
|
|
38
|
-
suspendSchema: step.suspendSchema ? stringify(
|
|
57
|
+
inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : void 0,
|
|
58
|
+
outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : void 0,
|
|
59
|
+
resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
60
|
+
suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : void 0
|
|
39
61
|
};
|
|
40
62
|
return acc2;
|
|
41
63
|
}, {}),
|
|
64
|
+
allSteps: getSteps(workflow.steps) || {},
|
|
42
65
|
stepGraph: workflow.serializedStepGraph,
|
|
43
|
-
inputSchema: workflow.inputSchema ? stringify(
|
|
44
|
-
outputSchema: workflow.outputSchema ? stringify(
|
|
66
|
+
inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : void 0,
|
|
67
|
+
outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : void 0
|
|
45
68
|
};
|
|
46
69
|
return acc;
|
|
47
70
|
}, {});
|
|
48
71
|
return _workflows;
|
|
49
72
|
} catch (error) {
|
|
50
|
-
|
|
73
|
+
return handleError(error, "Error getting workflows");
|
|
51
74
|
}
|
|
52
75
|
}
|
|
53
76
|
async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
@@ -98,21 +121,22 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
98
121
|
acc[key] = {
|
|
99
122
|
id: step.id,
|
|
100
123
|
description: step.description,
|
|
101
|
-
inputSchema: step.inputSchema ? stringify(
|
|
102
|
-
outputSchema: step.outputSchema ? stringify(
|
|
103
|
-
resumeSchema: step.resumeSchema ? stringify(
|
|
104
|
-
suspendSchema: step.suspendSchema ? stringify(
|
|
124
|
+
inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : void 0,
|
|
125
|
+
outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : void 0,
|
|
126
|
+
resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
127
|
+
suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : void 0
|
|
105
128
|
};
|
|
106
129
|
return acc;
|
|
107
130
|
}, {}),
|
|
131
|
+
allSteps: getSteps(workflow.steps) || {},
|
|
108
132
|
name: workflow.name,
|
|
109
133
|
description: workflow.description,
|
|
110
134
|
stepGraph: workflow.serializedStepGraph,
|
|
111
|
-
inputSchema: workflow.inputSchema ? stringify(
|
|
112
|
-
outputSchema: workflow.outputSchema ? stringify(
|
|
135
|
+
inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : void 0,
|
|
136
|
+
outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : void 0
|
|
113
137
|
};
|
|
114
138
|
} catch (error) {
|
|
115
|
-
|
|
139
|
+
return handleError(error, "Error getting workflow");
|
|
116
140
|
}
|
|
117
141
|
}
|
|
118
142
|
async function getWorkflowRunByIdHandler({
|
|
@@ -137,7 +161,7 @@ async function getWorkflowRunByIdHandler({
|
|
|
137
161
|
}
|
|
138
162
|
return run;
|
|
139
163
|
} catch (error) {
|
|
140
|
-
|
|
164
|
+
return handleError(error, "Error getting workflow run");
|
|
141
165
|
}
|
|
142
166
|
}
|
|
143
167
|
async function getWorkflowRunExecutionResultHandler({
|
|
@@ -162,9 +186,7 @@ async function getWorkflowRunExecutionResultHandler({
|
|
|
162
186
|
}
|
|
163
187
|
return executionResult;
|
|
164
188
|
} catch (error) {
|
|
165
|
-
|
|
166
|
-
message: error?.message || "Error getting workflow run execution result"
|
|
167
|
-
});
|
|
189
|
+
return handleError(error, "Error getting workflow run execution result");
|
|
168
190
|
}
|
|
169
191
|
}
|
|
170
192
|
async function createWorkflowRunHandler({
|
|
@@ -180,15 +202,15 @@ async function createWorkflowRunHandler({
|
|
|
180
202
|
if (!workflow) {
|
|
181
203
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
182
204
|
}
|
|
183
|
-
const run = workflow.
|
|
205
|
+
const run = await workflow.createRunAsync({ runId: prevRunId });
|
|
184
206
|
return { runId: run.runId };
|
|
185
207
|
} catch (error) {
|
|
186
|
-
|
|
208
|
+
return handleError(error, "Error creating workflow run");
|
|
187
209
|
}
|
|
188
210
|
}
|
|
189
211
|
async function startAsyncWorkflowHandler({
|
|
190
212
|
mastra,
|
|
191
|
-
runtimeContext
|
|
213
|
+
runtimeContext,
|
|
192
214
|
workflowId,
|
|
193
215
|
runId,
|
|
194
216
|
inputData
|
|
@@ -201,26 +223,19 @@ async function startAsyncWorkflowHandler({
|
|
|
201
223
|
if (!workflow) {
|
|
202
224
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
203
225
|
}
|
|
204
|
-
|
|
205
|
-
if (payloadRuntimeContext) {
|
|
206
|
-
runtimeContext = new RuntimeContext();
|
|
207
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
208
|
-
runtimeContext.set(key, value);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
const _run = workflow.createRun({ runId });
|
|
226
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
212
227
|
const result = await _run.start({
|
|
213
228
|
inputData,
|
|
214
229
|
runtimeContext
|
|
215
230
|
});
|
|
216
231
|
return result;
|
|
217
232
|
} catch (error) {
|
|
218
|
-
|
|
233
|
+
return handleError(error, "Error starting async workflow");
|
|
219
234
|
}
|
|
220
235
|
}
|
|
221
236
|
async function startWorkflowRunHandler({
|
|
222
237
|
mastra,
|
|
223
|
-
runtimeContext
|
|
238
|
+
runtimeContext,
|
|
224
239
|
workflowId,
|
|
225
240
|
runId,
|
|
226
241
|
inputData
|
|
@@ -240,14 +255,7 @@ async function startWorkflowRunHandler({
|
|
|
240
255
|
if (!run) {
|
|
241
256
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
242
257
|
}
|
|
243
|
-
|
|
244
|
-
if (payloadRuntimeContext) {
|
|
245
|
-
runtimeContext = new RuntimeContext();
|
|
246
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
247
|
-
runtimeContext.set(key, value);
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
const _run = workflow.createRun({ runId });
|
|
258
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
251
259
|
void _run.start({
|
|
252
260
|
inputData,
|
|
253
261
|
runtimeContext
|
|
@@ -277,7 +285,7 @@ async function watchWorkflowHandler({
|
|
|
277
285
|
if (!run) {
|
|
278
286
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
279
287
|
}
|
|
280
|
-
const _run = workflow.
|
|
288
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
281
289
|
let unwatch;
|
|
282
290
|
let asyncRef = null;
|
|
283
291
|
const stream = new ReadableStream({
|
|
@@ -308,7 +316,7 @@ async function watchWorkflowHandler({
|
|
|
308
316
|
}
|
|
309
317
|
async function streamWorkflowHandler({
|
|
310
318
|
mastra,
|
|
311
|
-
runtimeContext
|
|
319
|
+
runtimeContext,
|
|
312
320
|
workflowId,
|
|
313
321
|
runId,
|
|
314
322
|
inputData
|
|
@@ -324,14 +332,7 @@ async function streamWorkflowHandler({
|
|
|
324
332
|
if (!workflow) {
|
|
325
333
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
326
334
|
}
|
|
327
|
-
|
|
328
|
-
if (payloadRuntimeContext) {
|
|
329
|
-
runtimeContext = new RuntimeContext();
|
|
330
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
331
|
-
runtimeContext.set(key, value);
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
const run = workflow.createRun({ runId });
|
|
335
|
+
const run = await workflow.createRunAsync({ runId });
|
|
335
336
|
const result = run.stream({
|
|
336
337
|
inputData,
|
|
337
338
|
runtimeContext
|
|
@@ -341,12 +342,40 @@ async function streamWorkflowHandler({
|
|
|
341
342
|
return handleError(error, "Error executing workflow");
|
|
342
343
|
}
|
|
343
344
|
}
|
|
345
|
+
async function streamVNextWorkflowHandler({
|
|
346
|
+
mastra,
|
|
347
|
+
runtimeContext,
|
|
348
|
+
workflowId,
|
|
349
|
+
runId,
|
|
350
|
+
inputData
|
|
351
|
+
}) {
|
|
352
|
+
try {
|
|
353
|
+
if (!workflowId) {
|
|
354
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
355
|
+
}
|
|
356
|
+
if (!runId) {
|
|
357
|
+
throw new HTTPException(400, { message: "runId required to stream workflow" });
|
|
358
|
+
}
|
|
359
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
360
|
+
if (!workflow) {
|
|
361
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
362
|
+
}
|
|
363
|
+
const run = await workflow.createRunAsync({ runId });
|
|
364
|
+
const result = run.streamVNext({
|
|
365
|
+
inputData,
|
|
366
|
+
runtimeContext
|
|
367
|
+
});
|
|
368
|
+
return result;
|
|
369
|
+
} catch (error) {
|
|
370
|
+
return handleError(error, "Error streaming workflow");
|
|
371
|
+
}
|
|
372
|
+
}
|
|
344
373
|
async function resumeAsyncWorkflowHandler({
|
|
345
374
|
mastra,
|
|
346
375
|
workflowId,
|
|
347
376
|
runId,
|
|
348
377
|
body,
|
|
349
|
-
runtimeContext
|
|
378
|
+
runtimeContext
|
|
350
379
|
}) {
|
|
351
380
|
try {
|
|
352
381
|
if (!workflowId) {
|
|
@@ -366,14 +395,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
366
395
|
if (!run) {
|
|
367
396
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
368
397
|
}
|
|
369
|
-
|
|
370
|
-
if (payloadRuntimeContext) {
|
|
371
|
-
runtimeContext = new RuntimeContext();
|
|
372
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
373
|
-
runtimeContext.set(key, value);
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
const _run = workflow.createRun({ runId });
|
|
398
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
377
399
|
const result = await _run.resume({
|
|
378
400
|
step: body.step,
|
|
379
401
|
resumeData: body.resumeData,
|
|
@@ -389,7 +411,7 @@ async function resumeWorkflowHandler({
|
|
|
389
411
|
workflowId,
|
|
390
412
|
runId,
|
|
391
413
|
body,
|
|
392
|
-
runtimeContext
|
|
414
|
+
runtimeContext
|
|
393
415
|
}) {
|
|
394
416
|
try {
|
|
395
417
|
if (!workflowId) {
|
|
@@ -409,14 +431,7 @@ async function resumeWorkflowHandler({
|
|
|
409
431
|
if (!run) {
|
|
410
432
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
411
433
|
}
|
|
412
|
-
|
|
413
|
-
if (payloadRuntimeContext) {
|
|
414
|
-
runtimeContext = new RuntimeContext();
|
|
415
|
-
Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
|
|
416
|
-
runtimeContext.set(key, value);
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
const _run = workflow.createRun({ runId });
|
|
434
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
420
435
|
void _run.resume({
|
|
421
436
|
step: body.step,
|
|
422
437
|
resumeData: body.resumeData,
|
|
@@ -453,5 +468,63 @@ async function getWorkflowRunsHandler({
|
|
|
453
468
|
return handleError(error, "Error getting workflow runs");
|
|
454
469
|
}
|
|
455
470
|
}
|
|
471
|
+
async function cancelWorkflowRunHandler({
|
|
472
|
+
mastra,
|
|
473
|
+
workflowId,
|
|
474
|
+
runId
|
|
475
|
+
}) {
|
|
476
|
+
try {
|
|
477
|
+
if (!workflowId) {
|
|
478
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
479
|
+
}
|
|
480
|
+
if (!runId) {
|
|
481
|
+
throw new HTTPException(400, { message: "runId required to cancel workflow run" });
|
|
482
|
+
}
|
|
483
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
484
|
+
if (!workflow) {
|
|
485
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
486
|
+
}
|
|
487
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
488
|
+
if (!run) {
|
|
489
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
490
|
+
}
|
|
491
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
492
|
+
await _run.cancel();
|
|
493
|
+
return { message: "Workflow run cancelled" };
|
|
494
|
+
} catch (error) {
|
|
495
|
+
return handleError(error, "Error canceling workflow run");
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
async function sendWorkflowRunEventHandler({
|
|
499
|
+
mastra,
|
|
500
|
+
workflowId,
|
|
501
|
+
runId,
|
|
502
|
+
event,
|
|
503
|
+
data
|
|
504
|
+
}) {
|
|
505
|
+
try {
|
|
506
|
+
if (!workflowId) {
|
|
507
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
508
|
+
}
|
|
509
|
+
if (!runId) {
|
|
510
|
+
throw new HTTPException(400, { message: "runId required to send workflow run event" });
|
|
511
|
+
}
|
|
512
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
513
|
+
if (!workflow) {
|
|
514
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
515
|
+
}
|
|
516
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
517
|
+
if (!run) {
|
|
518
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
519
|
+
}
|
|
520
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
521
|
+
await _run.sendEvent(event, data);
|
|
522
|
+
return { message: "Workflow run event sent" };
|
|
523
|
+
} catch (error) {
|
|
524
|
+
return handleError(error, "Error sending workflow run event");
|
|
525
|
+
}
|
|
526
|
+
}
|
|
456
527
|
|
|
457
|
-
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|
|
528
|
+
export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, sendWorkflowRunEventHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamVNextWorkflowHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|
|
529
|
+
//# sourceMappingURL=chunk-ITZX6VPI.js.map
|
|
530
|
+
//# sourceMappingURL=chunk-ITZX6VPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["acc","key"],"mappings":";;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAA,QAA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0B;AAAA,EAC9C,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,kCAAkC,CAAA;AAAA,EAC9D;AACF","file":"chunk-ITZX6VPI.js","sourcesContent":["import { ReadableStream } from 'node:stream/web';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport type { Workflow, SerializedStepFlowEntry, WatchEvent, StepWithComponent } from '@mastra/core/workflows';\nimport { stringify } from 'superjson';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nfunction getSteps(steps: Record<string, StepWithComponent>, path?: string) {\n return Object.entries(steps).reduce<any>((acc, [key, step]) => {\n const fullKey = path ? `${path}.${key}` : key;\n acc[fullKey] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n isWorkflow: step.component === 'WORKFLOW',\n };\n\n if (step.component === 'WORKFLOW' && step.steps) {\n const nestedSteps = getSteps(step.steps, fullKey) || {};\n acc = { ...acc, ...nestedSteps };\n }\n\n return acc;\n }, {});\n}\n\nexport async function getWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<any>((acc, [key, workflow]) => {\n acc[key] = {\n name: workflow.name,\n description: workflow.description,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n acc[key] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n };\n return acc;\n }, {}),\n allSteps: getSteps(workflow.steps) || {},\n stepGraph: workflow.serializedStepGraph,\n inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : undefined,\n outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : undefined,\n };\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n}\n\ntype SerializedStep = {\n id: string;\n description: string;\n inputSchema: string | undefined;\n outputSchema: string | undefined;\n resumeSchema: string | undefined;\n suspendSchema: string | undefined;\n};\n\nasync function getWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n try {\n workflow = mastra.getWorkflow(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.getAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.getWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\nexport async function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<{\n steps: Record<string, SerializedStep>;\n allSteps: Record<string, SerializedStep>;\n name: string | undefined;\n description: string | undefined;\n stepGraph: SerializedStepFlowEntry[];\n inputSchema: string | undefined;\n outputSchema: string | undefined;\n}> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return {\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n acc[key] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n };\n return acc;\n }, {}),\n allSteps: getSteps(workflow.steps) || {},\n name: workflow.name,\n description: workflow.description,\n stepGraph: workflow.serializedStepGraph,\n inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : undefined,\n outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : undefined,\n };\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n}\n\nexport async function getWorkflowRunByIdHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n}\n\nexport async function getWorkflowRunExecutionResultHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const workflow = mastra.getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId);\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n}\n\nexport async function createWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId: prevRunId });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n}\n\nexport async function startAsyncWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.start({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n}\n\nexport async function startWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n void _run.start({\n inputData,\n runtimeContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream<string>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to watch workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = _run.watch(({ type, payload, eventTimestamp }) => {\n controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = payload.workflowState.status !== 'running';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n });\n },\n cancel() {\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function streamWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.streamVNext({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n}\n\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<WorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const workflowRuns = (await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n\nexport async function cancelWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n}\n\nexport async function sendWorkflowRunEventHandler({\n mastra,\n workflowId,\n runId,\n event,\n data,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n event: string;\n data: unknown;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to send workflow run event' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.sendEvent(event, data);\n\n return { message: 'Workflow run event sent' };\n } catch (error) {\n return handleError(error, 'Error sending workflow run event');\n }\n}\n"]}
|