@mastra/server 0.0.0-revert-schema-20250416221206 → 0.0.0-safe-stringify-telemetry-20251205024938
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/CHANGELOG.md +4368 -0
- package/LICENSE.md +11 -42
- package/README.md +45 -137
- package/dist/chunk-2PLXW4ZX.cjs +2777 -0
- package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
- package/dist/chunk-2S4IMB6E.cjs +130 -0
- package/dist/chunk-2S4IMB6E.cjs.map +1 -0
- package/dist/chunk-3SNGNFUJ.cjs +128 -0
- package/dist/chunk-3SNGNFUJ.cjs.map +1 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-4QCXUEAT.js} +11 -2
- package/dist/chunk-4QCXUEAT.js.map +1 -0
- package/dist/{chunk-WTHDCRMY.js → chunk-67GYDFSB.js} +33 -8
- package/dist/chunk-67GYDFSB.js.map +1 -0
- package/dist/chunk-6N3HC6O4.js +705 -0
- package/dist/chunk-6N3HC6O4.js.map +1 -0
- package/dist/{chunk-7IWQE76Z.cjs → chunk-6ZR275MD.cjs} +37 -11
- package/dist/chunk-6ZR275MD.cjs.map +1 -0
- package/dist/{chunk-FV45V6WC.cjs → chunk-7NADHFD2.cjs} +3 -7
- package/dist/chunk-7NADHFD2.cjs.map +1 -0
- package/dist/chunk-7RGKOGE4.cjs +485 -0
- package/dist/chunk-7RGKOGE4.cjs.map +1 -0
- package/dist/chunk-ABRFV4XP.js +83 -0
- package/dist/chunk-ABRFV4XP.js.map +1 -0
- package/dist/{chunk-UV4WTEH4.js → chunk-AHB4JCIQ.js} +55 -15
- package/dist/chunk-AHB4JCIQ.js.map +1 -0
- package/dist/chunk-AW5BU3RQ.js +192 -0
- package/dist/chunk-AW5BU3RQ.js.map +1 -0
- package/dist/chunk-BATEJLED.js +124 -0
- package/dist/chunk-BATEJLED.js.map +1 -0
- package/dist/chunk-CY4TP3FK.js +16 -0
- package/dist/chunk-CY4TP3FK.js.map +1 -0
- package/dist/chunk-CY6R3HLM.cjs +727 -0
- package/dist/chunk-CY6R3HLM.cjs.map +1 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-EP3JQDPD.cjs} +22 -19
- package/dist/chunk-EP3JQDPD.cjs.map +1 -0
- package/dist/chunk-G4PUALCE.cjs +28 -0
- package/dist/chunk-G4PUALCE.cjs.map +1 -0
- package/dist/chunk-G5O5SC7R.cjs +19565 -0
- package/dist/chunk-G5O5SC7R.cjs.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/chunk-I3C4ODGV.cjs +335 -0
- package/dist/chunk-I3C4ODGV.cjs.map +1 -0
- package/dist/chunk-IAE7SFBS.js +477 -0
- package/dist/chunk-IAE7SFBS.js.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/{chunk-OPP7H5TW.js → chunk-LLUOPR3J.js} +92 -74
- package/dist/chunk-LLUOPR3J.js.map +1 -0
- package/dist/chunk-LPM6BBAX.cjs +1043 -0
- package/dist/chunk-LPM6BBAX.cjs.map +1 -0
- package/dist/{chunk-TRDNDNGQ.js → chunk-MMROOK5J.js} +4 -7
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/{chunk-4JINXASC.js → chunk-MYR4PVGN.js} +7 -4
- package/dist/chunk-MYR4PVGN.js.map +1 -0
- package/dist/chunk-NT5XW5PI.cjs +596 -0
- package/dist/chunk-NT5XW5PI.cjs.map +1 -0
- package/dist/chunk-O7I5CWRX.cjs +44 -0
- package/dist/chunk-O7I5CWRX.cjs.map +1 -0
- package/dist/chunk-PBXWFGEH.js +579 -0
- package/dist/chunk-PBXWFGEH.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +39 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/chunk-QGNHNNJR.js +909 -0
- package/dist/chunk-QGNHNNJR.js.map +1 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-QQXMIP6C.js} +49 -22
- package/dist/chunk-QQXMIP6C.js.map +1 -0
- package/dist/chunk-QU6N55W6.cjs +256 -0
- package/dist/chunk-QU6N55W6.cjs.map +1 -0
- package/dist/chunk-RE4RPXT2.cjs +18 -0
- package/dist/chunk-RE4RPXT2.cjs.map +1 -0
- package/dist/chunk-RQK4FQUD.js +1012 -0
- package/dist/chunk-RQK4FQUD.js.map +1 -0
- package/dist/chunk-S6YZQY4V.cjs +938 -0
- package/dist/chunk-S6YZQY4V.cjs.map +1 -0
- package/dist/chunk-SHWNNZBL.js +254 -0
- package/dist/chunk-SHWNNZBL.js.map +1 -0
- package/dist/chunk-SPRRK3P7.cjs +200 -0
- package/dist/chunk-SPRRK3P7.cjs.map +1 -0
- package/dist/chunk-TOCYBDP2.js +46 -0
- package/dist/chunk-TOCYBDP2.js.map +1 -0
- package/dist/chunk-TRGAMKHX.cjs +167 -0
- package/dist/chunk-TRGAMKHX.cjs.map +1 -0
- package/dist/chunk-TRHCWKZ2.js +19529 -0
- package/dist/chunk-TRHCWKZ2.js.map +1 -0
- package/dist/chunk-VY4ENABS.cjs +135 -0
- package/dist/chunk-VY4ENABS.cjs.map +1 -0
- package/dist/chunk-X6C7BUWN.cjs +48 -0
- package/dist/chunk-X6C7BUWN.cjs.map +1 -0
- package/dist/chunk-XN74I6VW.cjs +88 -0
- package/dist/chunk-XN74I6VW.cjs.map +1 -0
- package/dist/chunk-YWOK4F5A.js +131 -0
- package/dist/chunk-YWOK4F5A.js.map +1 -0
- package/dist/chunk-ZULZ2752.js +2774 -0
- package/dist/chunk-ZULZ2752.js.map +1 -0
- package/dist/dist-4MVGNSRL.cjs +1150 -0
- package/dist/dist-4MVGNSRL.cjs.map +1 -0
- package/dist/dist-FZYCV3VB.cjs +940 -0
- package/dist/dist-FZYCV3VB.cjs.map +1 -0
- package/dist/dist-G2BYZJOC.cjs +928 -0
- package/dist/dist-G2BYZJOC.cjs.map +1 -0
- package/dist/dist-P4MXBQ3U.cjs +16 -0
- package/dist/dist-P4MXBQ3U.cjs.map +1 -0
- package/dist/dist-PQZUVLPC.js +937 -0
- package/dist/dist-PQZUVLPC.js.map +1 -0
- package/dist/dist-R7WYX6LC.js +925 -0
- package/dist/dist-R7WYX6LC.js.map +1 -0
- package/dist/dist-RFMYFILX.cjs +764 -0
- package/dist/dist-RFMYFILX.cjs.map +1 -0
- package/dist/dist-X7XR3M3Z.js +1147 -0
- package/dist/dist-X7XR3M3Z.js.map +1 -0
- package/dist/dist-XVBSOGFK.js +761 -0
- package/dist/dist-XVBSOGFK.js.map +1 -0
- package/dist/dist-YREX2TJT.js +3 -0
- package/dist/dist-YREX2TJT.js.map +1 -0
- package/dist/index.cjs +6 -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 +5 -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.cjs +25 -0
- package/dist/server/a2a/store.cjs.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/store.js +23 -0
- package/dist/server/a2a/store.js.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 +32 -0
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +68 -0
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -0
- package/dist/server/handlers/a2a.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +68 -0
- package/dist/server/handlers/agent-builder.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.d.ts +94 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -0
- package/dist/server/handlers/agent-builder.js +3 -0
- package/dist/server/handlers/agent-builder.js.map +1 -0
- package/dist/server/handlers/agents.cjs +65 -7
- package/dist/server/handlers/agents.cjs.map +1 -0
- package/dist/server/handlers/agents.d.ts +210 -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 +48 -0
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -0
- 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 +118 -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/observability.cjs +24 -0
- package/dist/server/handlers/observability.cjs.map +1 -0
- package/dist/server/handlers/observability.d.ts +49 -0
- package/dist/server/handlers/observability.d.ts.map +1 -0
- package/dist/server/handlers/observability.js +3 -0
- package/dist/server/handlers/observability.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 +152 -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 +9 -3
- package/dist/server/handlers/telemetry.cjs.map +1 -0
- package/dist/server/handlers/telemetry.d.ts +33 -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 +11 -5
- package/dist/server/handlers/tools.cjs.map +1 -0
- package/dist/server/handlers/tools.d.ts +25 -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 +8 -2
- package/dist/server/handlers/utils.cjs.map +1 -0
- package/dist/server/handlers/utils.d.ts +8 -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/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 +10 -4
- package/dist/server/handlers/voice.cjs.map +1 -0
- package/dist/server/handlers/voice.d.ts +41 -3
- 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 +83 -13
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +151 -10
- 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 +49 -27
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +14 -9
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +15 -9
- 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/dist/server/utils.d.ts +44 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/token-375W3LEI.cjs +64 -0
- package/dist/token-375W3LEI.cjs.map +1 -0
- package/dist/token-C3IMNCC4.js +62 -0
- package/dist/token-C3IMNCC4.js.map +1 -0
- package/dist/token-util-CV3RRG6K.cjs +9 -0
- package/dist/token-util-CV3RRG6K.cjs.map +1 -0
- package/dist/token-util-E5QO2RCL.js +7 -0
- package/dist/token-util-E5QO2RCL.js.map +1 -0
- package/package.json +50 -19
- package/dist/_tsup-dts-rollup.d.cts +0 -573
- package/dist/_tsup-dts-rollup.d.ts +0 -573
- package/dist/chunk-2FJURXCL.cjs +0 -213
- package/dist/chunk-3AHQ5RGN.js +0 -11
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-A7DF4ETD.cjs +0 -100
- package/dist/chunk-B64YROKU.cjs +0 -317
- package/dist/chunk-I6MBOQTH.js +0 -156
- package/dist/chunk-JLDXUWK7.cjs +0 -126
- package/dist/chunk-PDC4ZBQW.cjs +0 -126
- package/dist/chunk-QH6XWSXP.cjs +0 -5579
- package/dist/chunk-QN4KF3BH.cjs +0 -18
- package/dist/chunk-RBQASTUP.js +0 -203
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-UE27Q3XD.cjs +0 -164
- package/dist/chunk-VK6FX47H.js +0 -5576
- package/dist/chunk-YANVFOYA.js +0 -120
- package/dist/chunk-ZLBRQFDD.cjs +0 -13
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/network.cjs +0 -22
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/network.d.ts +0 -4
- package/dist/server/handlers/network.js +0 -1
- 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 -3
- package/dist/server/handlers/workflows.d.cts +0 -10
- package/dist/server/handlers.d.cts +0 -9
|
@@ -0,0 +1,938 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVY4ENABS_cjs = require('./chunk-VY4ENABS.cjs');
|
|
4
|
+
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
5
|
+
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
6
|
+
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
|
|
7
|
+
var web = require('stream/web');
|
|
8
|
+
|
|
9
|
+
// src/server/handlers/workflows.ts
|
|
10
|
+
var workflows_exports = {};
|
|
11
|
+
chunkO7I5CWRX_cjs.__export(workflows_exports, {
|
|
12
|
+
cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
|
|
13
|
+
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
14
|
+
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
15
|
+
getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
|
|
16
|
+
getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
|
|
17
|
+
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
18
|
+
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
19
|
+
observeStreamLegacyWorkflowHandler: () => observeStreamLegacyWorkflowHandler,
|
|
20
|
+
observeStreamVNextWorkflowHandler: () => observeStreamVNextWorkflowHandler,
|
|
21
|
+
observeStreamWorkflowHandler: () => observeStreamWorkflowHandler,
|
|
22
|
+
restartAllActiveWorkflowRunsAsyncHandler: () => restartAllActiveWorkflowRunsAsyncHandler,
|
|
23
|
+
restartAllActiveWorkflowRunsHandler: () => restartAllActiveWorkflowRunsHandler,
|
|
24
|
+
restartAsyncWorkflowHandler: () => restartAsyncWorkflowHandler,
|
|
25
|
+
restartWorkflowHandler: () => restartWorkflowHandler,
|
|
26
|
+
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
27
|
+
resumeStreamWorkflowHandler: () => resumeStreamWorkflowHandler,
|
|
28
|
+
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
29
|
+
sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
|
|
30
|
+
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
31
|
+
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
32
|
+
streamLegacyWorkflowHandler: () => streamLegacyWorkflowHandler,
|
|
33
|
+
streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
|
|
34
|
+
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
35
|
+
timeTravelAsyncWorkflowHandler: () => timeTravelAsyncWorkflowHandler,
|
|
36
|
+
timeTravelStreamWorkflowHandler: () => timeTravelStreamWorkflowHandler,
|
|
37
|
+
timeTravelWorkflowHandler: () => timeTravelWorkflowHandler,
|
|
38
|
+
watchWorkflowHandler: () => watchWorkflowHandler
|
|
39
|
+
});
|
|
40
|
+
async function getWorkflowsHandler({ mastra }) {
|
|
41
|
+
try {
|
|
42
|
+
const workflows = mastra.getWorkflows({ serialized: false });
|
|
43
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
44
|
+
acc[key] = chunkVY4ENABS_cjs.getWorkflowInfo(workflow);
|
|
45
|
+
return acc;
|
|
46
|
+
}, {});
|
|
47
|
+
return _workflows;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflows");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
53
|
+
const logger = mastra.getLogger();
|
|
54
|
+
if (!workflowId) {
|
|
55
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
56
|
+
}
|
|
57
|
+
let workflow;
|
|
58
|
+
workflow = chunkVY4ENABS_cjs.WorkflowRegistry.getWorkflow(workflowId);
|
|
59
|
+
if (!workflow) {
|
|
60
|
+
try {
|
|
61
|
+
workflow = mastra.getWorkflow(workflowId);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
logger.debug("Error getting workflow, searching agents for workflow", error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!workflow) {
|
|
67
|
+
logger.debug("Workflow not found, searching agents for workflow", { workflowId });
|
|
68
|
+
const agents = mastra.getAgents();
|
|
69
|
+
if (Object.keys(agents || {}).length) {
|
|
70
|
+
for (const [_, agent] of Object.entries(agents)) {
|
|
71
|
+
try {
|
|
72
|
+
const workflows = await agent.getWorkflows();
|
|
73
|
+
if (workflows[workflowId]) {
|
|
74
|
+
workflow = workflows[workflowId];
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
logger.debug("Error getting workflow from agent", error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!workflow) {
|
|
85
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
86
|
+
}
|
|
87
|
+
return { workflow };
|
|
88
|
+
}
|
|
89
|
+
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
90
|
+
try {
|
|
91
|
+
if (!workflowId) {
|
|
92
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
93
|
+
}
|
|
94
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
95
|
+
if (!workflow) {
|
|
96
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
97
|
+
}
|
|
98
|
+
return chunkVY4ENABS_cjs.getWorkflowInfo(workflow);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function getWorkflowRunByIdHandler({
|
|
104
|
+
mastra,
|
|
105
|
+
workflowId,
|
|
106
|
+
runId
|
|
107
|
+
}) {
|
|
108
|
+
try {
|
|
109
|
+
if (!workflowId) {
|
|
110
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
111
|
+
}
|
|
112
|
+
if (!runId) {
|
|
113
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
114
|
+
}
|
|
115
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
116
|
+
if (!workflow) {
|
|
117
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
118
|
+
}
|
|
119
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
120
|
+
if (!run) {
|
|
121
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
122
|
+
}
|
|
123
|
+
return run;
|
|
124
|
+
} catch (error) {
|
|
125
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow run");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function getWorkflowRunExecutionResultHandler({
|
|
129
|
+
mastra,
|
|
130
|
+
workflowId,
|
|
131
|
+
runId
|
|
132
|
+
}) {
|
|
133
|
+
try {
|
|
134
|
+
if (!workflowId) {
|
|
135
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
136
|
+
}
|
|
137
|
+
if (!runId) {
|
|
138
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
139
|
+
}
|
|
140
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
141
|
+
if (!workflow) {
|
|
142
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
143
|
+
}
|
|
144
|
+
const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
|
|
145
|
+
if (!executionResult) {
|
|
146
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
|
|
147
|
+
}
|
|
148
|
+
return executionResult;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow run execution result");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function createWorkflowRunHandler({
|
|
154
|
+
mastra,
|
|
155
|
+
workflowId,
|
|
156
|
+
runId: prevRunId
|
|
157
|
+
}) {
|
|
158
|
+
try {
|
|
159
|
+
if (!workflowId) {
|
|
160
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
161
|
+
}
|
|
162
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
163
|
+
if (!workflow) {
|
|
164
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
165
|
+
}
|
|
166
|
+
const run = await workflow.createRunAsync({ runId: prevRunId });
|
|
167
|
+
return { runId: run.runId };
|
|
168
|
+
} catch (error) {
|
|
169
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error creating workflow run");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function startAsyncWorkflowHandler({
|
|
173
|
+
mastra,
|
|
174
|
+
runtimeContext,
|
|
175
|
+
workflowId,
|
|
176
|
+
runId,
|
|
177
|
+
inputData,
|
|
178
|
+
tracingOptions
|
|
179
|
+
}) {
|
|
180
|
+
try {
|
|
181
|
+
if (!workflowId) {
|
|
182
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
183
|
+
}
|
|
184
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
185
|
+
if (!workflow) {
|
|
186
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
187
|
+
}
|
|
188
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
189
|
+
const result = await _run.start({
|
|
190
|
+
inputData,
|
|
191
|
+
runtimeContext,
|
|
192
|
+
tracingOptions
|
|
193
|
+
});
|
|
194
|
+
return result;
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error starting async workflow");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async function startWorkflowRunHandler({
|
|
200
|
+
mastra,
|
|
201
|
+
runtimeContext,
|
|
202
|
+
workflowId,
|
|
203
|
+
runId,
|
|
204
|
+
inputData,
|
|
205
|
+
tracingOptions
|
|
206
|
+
}) {
|
|
207
|
+
try {
|
|
208
|
+
if (!workflowId) {
|
|
209
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
210
|
+
}
|
|
211
|
+
if (!runId) {
|
|
212
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
213
|
+
}
|
|
214
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
215
|
+
if (!workflow) {
|
|
216
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
217
|
+
}
|
|
218
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
219
|
+
if (!run) {
|
|
220
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
221
|
+
}
|
|
222
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
223
|
+
void _run.start({
|
|
224
|
+
inputData,
|
|
225
|
+
runtimeContext,
|
|
226
|
+
tracingOptions
|
|
227
|
+
});
|
|
228
|
+
return { message: "Workflow run started" };
|
|
229
|
+
} catch (e) {
|
|
230
|
+
return chunkRE4RPXT2_cjs.handleError(e, "Error starting workflow run");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async function watchWorkflowHandler({
|
|
234
|
+
mastra,
|
|
235
|
+
workflowId,
|
|
236
|
+
runId,
|
|
237
|
+
eventType = "watch"
|
|
238
|
+
}) {
|
|
239
|
+
try {
|
|
240
|
+
if (!workflowId) {
|
|
241
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
242
|
+
}
|
|
243
|
+
if (!runId) {
|
|
244
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
245
|
+
}
|
|
246
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
247
|
+
if (!workflow) {
|
|
248
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
249
|
+
}
|
|
250
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
251
|
+
if (!run) {
|
|
252
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
253
|
+
}
|
|
254
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
255
|
+
let unwatch;
|
|
256
|
+
let asyncRef = null;
|
|
257
|
+
const stream = new web.ReadableStream({
|
|
258
|
+
start(controller) {
|
|
259
|
+
if (eventType === "watch") {
|
|
260
|
+
unwatch = _run.watch((event) => {
|
|
261
|
+
const { type, payload, eventTimestamp } = event;
|
|
262
|
+
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
263
|
+
if (asyncRef) {
|
|
264
|
+
clearImmediate(asyncRef);
|
|
265
|
+
asyncRef = null;
|
|
266
|
+
}
|
|
267
|
+
asyncRef = setImmediate(async () => {
|
|
268
|
+
const runDone = payload.workflowState?.status !== "running";
|
|
269
|
+
if (runDone) {
|
|
270
|
+
controller.close();
|
|
271
|
+
unwatch?.();
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}, eventType);
|
|
275
|
+
} else {
|
|
276
|
+
unwatch = _run.watch((event) => {
|
|
277
|
+
const { type, payload } = event;
|
|
278
|
+
controller.enqueue(JSON.stringify({ type, payload, runId }));
|
|
279
|
+
if (asyncRef) {
|
|
280
|
+
clearImmediate(asyncRef);
|
|
281
|
+
asyncRef = null;
|
|
282
|
+
}
|
|
283
|
+
asyncRef = setImmediate(async () => {
|
|
284
|
+
const runDone = type === "workflow-finish";
|
|
285
|
+
if (runDone) {
|
|
286
|
+
controller.close();
|
|
287
|
+
unwatch?.();
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}, eventType);
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
cancel() {
|
|
294
|
+
if (asyncRef) {
|
|
295
|
+
clearImmediate(asyncRef);
|
|
296
|
+
asyncRef = null;
|
|
297
|
+
}
|
|
298
|
+
unwatch?.();
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
return stream;
|
|
302
|
+
} catch (error) {
|
|
303
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error watching workflow");
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async function streamWorkflowHandler({
|
|
307
|
+
mastra,
|
|
308
|
+
runtimeContext,
|
|
309
|
+
workflowId,
|
|
310
|
+
runId,
|
|
311
|
+
inputData,
|
|
312
|
+
tracingOptions
|
|
313
|
+
}) {
|
|
314
|
+
return streamVNextWorkflowHandler({ mastra, workflowId, runId, inputData, runtimeContext, tracingOptions });
|
|
315
|
+
}
|
|
316
|
+
async function streamLegacyWorkflowHandler({
|
|
317
|
+
mastra,
|
|
318
|
+
runtimeContext,
|
|
319
|
+
workflowId,
|
|
320
|
+
runId,
|
|
321
|
+
inputData,
|
|
322
|
+
tracingOptions
|
|
323
|
+
}) {
|
|
324
|
+
try {
|
|
325
|
+
if (!workflowId) {
|
|
326
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
327
|
+
}
|
|
328
|
+
if (!runId) {
|
|
329
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
330
|
+
}
|
|
331
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
332
|
+
if (!workflow) {
|
|
333
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
334
|
+
}
|
|
335
|
+
const serverCache = mastra.getServerCache();
|
|
336
|
+
const run = await workflow.createRunAsync({ runId });
|
|
337
|
+
const result = run.streamLegacy({
|
|
338
|
+
inputData,
|
|
339
|
+
runtimeContext,
|
|
340
|
+
onChunk: async (chunk) => {
|
|
341
|
+
if (serverCache) {
|
|
342
|
+
const cacheKey = runId;
|
|
343
|
+
await serverCache.listPush(cacheKey, chunk);
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
tracingOptions
|
|
347
|
+
});
|
|
348
|
+
return result;
|
|
349
|
+
} catch (error) {
|
|
350
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error executing workflow");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async function observeStreamLegacyWorkflowHandler({
|
|
354
|
+
mastra,
|
|
355
|
+
workflowId,
|
|
356
|
+
runId
|
|
357
|
+
}) {
|
|
358
|
+
try {
|
|
359
|
+
if (!workflowId) {
|
|
360
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
361
|
+
}
|
|
362
|
+
if (!runId) {
|
|
363
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
|
|
364
|
+
}
|
|
365
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
366
|
+
if (!workflow) {
|
|
367
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
368
|
+
}
|
|
369
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
370
|
+
if (!run) {
|
|
371
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
372
|
+
}
|
|
373
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
374
|
+
const serverCache = mastra.getServerCache();
|
|
375
|
+
if (!serverCache) {
|
|
376
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Server cache not found" });
|
|
377
|
+
}
|
|
378
|
+
const transformStream = new web.TransformStream();
|
|
379
|
+
const writer = transformStream.writable.getWriter();
|
|
380
|
+
const cachedRunChunks = await serverCache.listFromTo(runId, 0);
|
|
381
|
+
for (const chunk of cachedRunChunks) {
|
|
382
|
+
await writer.write(chunk);
|
|
383
|
+
}
|
|
384
|
+
writer.releaseLock();
|
|
385
|
+
const result = _run.observeStreamLegacy();
|
|
386
|
+
return result.stream?.pipeThrough(transformStream);
|
|
387
|
+
} catch (error) {
|
|
388
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error observing workflow stream");
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
async function observeStreamWorkflowHandler({
|
|
392
|
+
mastra,
|
|
393
|
+
workflowId,
|
|
394
|
+
runId
|
|
395
|
+
}) {
|
|
396
|
+
return observeStreamVNextWorkflowHandler({ mastra, workflowId, runId });
|
|
397
|
+
}
|
|
398
|
+
async function streamVNextWorkflowHandler({
|
|
399
|
+
mastra,
|
|
400
|
+
runtimeContext,
|
|
401
|
+
workflowId,
|
|
402
|
+
runId,
|
|
403
|
+
inputData,
|
|
404
|
+
closeOnSuspend,
|
|
405
|
+
tracingOptions
|
|
406
|
+
}) {
|
|
407
|
+
try {
|
|
408
|
+
if (!workflowId) {
|
|
409
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
410
|
+
}
|
|
411
|
+
if (!runId) {
|
|
412
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to stream workflow" });
|
|
413
|
+
}
|
|
414
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
415
|
+
if (!workflow) {
|
|
416
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
417
|
+
}
|
|
418
|
+
const serverCache = mastra.getServerCache();
|
|
419
|
+
const run = await workflow.createRunAsync({ runId });
|
|
420
|
+
const result = run.stream({
|
|
421
|
+
inputData,
|
|
422
|
+
runtimeContext,
|
|
423
|
+
closeOnSuspend,
|
|
424
|
+
tracingOptions
|
|
425
|
+
});
|
|
426
|
+
return result.fullStream.pipeThrough(
|
|
427
|
+
new web.TransformStream({
|
|
428
|
+
transform(chunk, controller) {
|
|
429
|
+
if (serverCache) {
|
|
430
|
+
const cacheKey = runId;
|
|
431
|
+
serverCache.listPush(cacheKey, chunk).catch(() => {
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
controller.enqueue(chunk);
|
|
435
|
+
}
|
|
436
|
+
})
|
|
437
|
+
);
|
|
438
|
+
} catch (error) {
|
|
439
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error streaming workflow");
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async function observeStreamVNextWorkflowHandler({
|
|
443
|
+
mastra,
|
|
444
|
+
workflowId,
|
|
445
|
+
runId
|
|
446
|
+
}) {
|
|
447
|
+
try {
|
|
448
|
+
if (!workflowId) {
|
|
449
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
450
|
+
}
|
|
451
|
+
if (!runId) {
|
|
452
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
|
|
453
|
+
}
|
|
454
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
455
|
+
if (!workflow) {
|
|
456
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
457
|
+
}
|
|
458
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
459
|
+
if (!run) {
|
|
460
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
461
|
+
}
|
|
462
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
463
|
+
const serverCache = mastra.getServerCache();
|
|
464
|
+
if (!serverCache) {
|
|
465
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Server cache not found" });
|
|
466
|
+
}
|
|
467
|
+
const cachedRunChunks = await serverCache.listFromTo(runId, 0);
|
|
468
|
+
const combinedStream = new web.ReadableStream({
|
|
469
|
+
start(controller) {
|
|
470
|
+
const emitCachedChunks = async () => {
|
|
471
|
+
for (const chunk of cachedRunChunks) {
|
|
472
|
+
controller.enqueue(chunk);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
const liveStream = _run.observeStream();
|
|
476
|
+
const reader = liveStream.getReader();
|
|
477
|
+
const pump = async () => {
|
|
478
|
+
try {
|
|
479
|
+
while (true) {
|
|
480
|
+
const { done, value } = await reader.read();
|
|
481
|
+
if (done) {
|
|
482
|
+
controller.close();
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
controller.enqueue(value);
|
|
486
|
+
}
|
|
487
|
+
} catch (error) {
|
|
488
|
+
controller.error(error);
|
|
489
|
+
} finally {
|
|
490
|
+
reader.releaseLock();
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
void emitCachedChunks().then(() => {
|
|
494
|
+
void pump();
|
|
495
|
+
}).catch((error) => {
|
|
496
|
+
controller.error(error);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
return combinedStream;
|
|
501
|
+
} catch (error) {
|
|
502
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error observing workflow stream");
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
async function resumeAsyncWorkflowHandler({
|
|
506
|
+
mastra,
|
|
507
|
+
workflowId,
|
|
508
|
+
runId,
|
|
509
|
+
body,
|
|
510
|
+
runtimeContext,
|
|
511
|
+
tracingOptions
|
|
512
|
+
}) {
|
|
513
|
+
try {
|
|
514
|
+
if (!workflowId) {
|
|
515
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
516
|
+
}
|
|
517
|
+
if (!runId) {
|
|
518
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
519
|
+
}
|
|
520
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
521
|
+
if (!workflow) {
|
|
522
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
523
|
+
}
|
|
524
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
525
|
+
if (!run) {
|
|
526
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
527
|
+
}
|
|
528
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
529
|
+
const result = await _run.resume({
|
|
530
|
+
step: body.step,
|
|
531
|
+
resumeData: body.resumeData,
|
|
532
|
+
runtimeContext,
|
|
533
|
+
tracingOptions
|
|
534
|
+
});
|
|
535
|
+
return result;
|
|
536
|
+
} catch (error) {
|
|
537
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow step");
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
async function resumeWorkflowHandler({
|
|
541
|
+
mastra,
|
|
542
|
+
workflowId,
|
|
543
|
+
runId,
|
|
544
|
+
body,
|
|
545
|
+
runtimeContext,
|
|
546
|
+
tracingOptions
|
|
547
|
+
}) {
|
|
548
|
+
try {
|
|
549
|
+
if (!workflowId) {
|
|
550
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
551
|
+
}
|
|
552
|
+
if (!runId) {
|
|
553
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
554
|
+
}
|
|
555
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
556
|
+
if (!workflow) {
|
|
557
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
558
|
+
}
|
|
559
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
560
|
+
if (!run) {
|
|
561
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
562
|
+
}
|
|
563
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
564
|
+
void _run.resume({
|
|
565
|
+
step: body.step,
|
|
566
|
+
resumeData: body.resumeData,
|
|
567
|
+
runtimeContext,
|
|
568
|
+
tracingOptions
|
|
569
|
+
});
|
|
570
|
+
return { message: "Workflow run resumed" };
|
|
571
|
+
} catch (error) {
|
|
572
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
async function resumeStreamWorkflowHandler({
|
|
576
|
+
mastra,
|
|
577
|
+
workflowId,
|
|
578
|
+
runId,
|
|
579
|
+
body,
|
|
580
|
+
runtimeContext,
|
|
581
|
+
tracingOptions
|
|
582
|
+
}) {
|
|
583
|
+
try {
|
|
584
|
+
if (!workflowId) {
|
|
585
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
586
|
+
}
|
|
587
|
+
if (!runId) {
|
|
588
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
589
|
+
}
|
|
590
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
591
|
+
if (!workflow) {
|
|
592
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
593
|
+
}
|
|
594
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
595
|
+
if (!run) {
|
|
596
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
597
|
+
}
|
|
598
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
599
|
+
const serverCache = mastra.getServerCache();
|
|
600
|
+
const stream = _run.resumeStream({
|
|
601
|
+
step: body.step,
|
|
602
|
+
resumeData: body.resumeData,
|
|
603
|
+
runtimeContext,
|
|
604
|
+
tracingOptions
|
|
605
|
+
}).fullStream.pipeThrough(
|
|
606
|
+
new web.TransformStream({
|
|
607
|
+
transform(chunk, controller) {
|
|
608
|
+
if (serverCache) {
|
|
609
|
+
const cacheKey = runId;
|
|
610
|
+
serverCache.listPush(cacheKey, chunk).catch(() => {
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
controller.enqueue(chunk);
|
|
614
|
+
}
|
|
615
|
+
})
|
|
616
|
+
);
|
|
617
|
+
return stream;
|
|
618
|
+
} catch (error) {
|
|
619
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
async function getWorkflowRunsHandler({
|
|
623
|
+
mastra,
|
|
624
|
+
workflowId,
|
|
625
|
+
fromDate,
|
|
626
|
+
toDate,
|
|
627
|
+
limit,
|
|
628
|
+
offset,
|
|
629
|
+
resourceId
|
|
630
|
+
}) {
|
|
631
|
+
try {
|
|
632
|
+
if (!workflowId) {
|
|
633
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
634
|
+
}
|
|
635
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
636
|
+
if (!workflow) {
|
|
637
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
638
|
+
}
|
|
639
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
640
|
+
runs: [],
|
|
641
|
+
total: 0
|
|
642
|
+
};
|
|
643
|
+
return workflowRuns;
|
|
644
|
+
} catch (error) {
|
|
645
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow runs");
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
async function cancelWorkflowRunHandler({
|
|
649
|
+
mastra,
|
|
650
|
+
workflowId,
|
|
651
|
+
runId
|
|
652
|
+
}) {
|
|
653
|
+
try {
|
|
654
|
+
if (!workflowId) {
|
|
655
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
656
|
+
}
|
|
657
|
+
if (!runId) {
|
|
658
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
|
|
659
|
+
}
|
|
660
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
661
|
+
if (!workflow) {
|
|
662
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
663
|
+
}
|
|
664
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
665
|
+
if (!run) {
|
|
666
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
667
|
+
}
|
|
668
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
669
|
+
await _run.cancel();
|
|
670
|
+
return { message: "Workflow run cancelled" };
|
|
671
|
+
} catch (error) {
|
|
672
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error canceling workflow run");
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
async function sendWorkflowRunEventHandler({
|
|
676
|
+
mastra,
|
|
677
|
+
workflowId,
|
|
678
|
+
runId,
|
|
679
|
+
event,
|
|
680
|
+
data
|
|
681
|
+
}) {
|
|
682
|
+
try {
|
|
683
|
+
if (!workflowId) {
|
|
684
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
685
|
+
}
|
|
686
|
+
if (!runId) {
|
|
687
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
|
|
688
|
+
}
|
|
689
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
690
|
+
if (!workflow) {
|
|
691
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
692
|
+
}
|
|
693
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
694
|
+
if (!run) {
|
|
695
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
696
|
+
}
|
|
697
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
698
|
+
await _run.sendEvent(event, data);
|
|
699
|
+
return { message: "Workflow run event sent" };
|
|
700
|
+
} catch (error) {
|
|
701
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error sending workflow run event");
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
async function restartAsyncWorkflowHandler({
|
|
705
|
+
mastra,
|
|
706
|
+
workflowId,
|
|
707
|
+
runId,
|
|
708
|
+
runtimeContext,
|
|
709
|
+
tracingOptions
|
|
710
|
+
}) {
|
|
711
|
+
try {
|
|
712
|
+
if (!workflowId) {
|
|
713
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
714
|
+
}
|
|
715
|
+
if (!runId) {
|
|
716
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to restart workflow" });
|
|
717
|
+
}
|
|
718
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
719
|
+
if (!workflow) {
|
|
720
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
721
|
+
}
|
|
722
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
723
|
+
if (!run) {
|
|
724
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
725
|
+
}
|
|
726
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
727
|
+
const result = await _run.restart({
|
|
728
|
+
runtimeContext,
|
|
729
|
+
tracingOptions
|
|
730
|
+
});
|
|
731
|
+
return result;
|
|
732
|
+
} catch (error) {
|
|
733
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error restarting workflow");
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
async function restartWorkflowHandler({
|
|
737
|
+
mastra,
|
|
738
|
+
workflowId,
|
|
739
|
+
runId,
|
|
740
|
+
runtimeContext,
|
|
741
|
+
tracingOptions
|
|
742
|
+
}) {
|
|
743
|
+
try {
|
|
744
|
+
if (!workflowId) {
|
|
745
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
746
|
+
}
|
|
747
|
+
if (!runId) {
|
|
748
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to restart workflow" });
|
|
749
|
+
}
|
|
750
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
751
|
+
if (!workflow) {
|
|
752
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
753
|
+
}
|
|
754
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
755
|
+
if (!run) {
|
|
756
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
757
|
+
}
|
|
758
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
759
|
+
void _run.restart({
|
|
760
|
+
runtimeContext,
|
|
761
|
+
tracingOptions
|
|
762
|
+
});
|
|
763
|
+
return { message: "Workflow run restarted" };
|
|
764
|
+
} catch (error) {
|
|
765
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error restarting workflow");
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
async function restartAllActiveWorkflowRunsAsyncHandler({ mastra, workflowId }) {
|
|
769
|
+
try {
|
|
770
|
+
if (!workflowId) {
|
|
771
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
772
|
+
}
|
|
773
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
774
|
+
if (!workflow) {
|
|
775
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
776
|
+
}
|
|
777
|
+
await workflow.restartAllActiveWorkflowRuns();
|
|
778
|
+
return { message: "All active workflow runs restarted" };
|
|
779
|
+
} catch (error) {
|
|
780
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error restarting all active workflow runs");
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
async function restartAllActiveWorkflowRunsHandler({ mastra, workflowId }) {
|
|
784
|
+
try {
|
|
785
|
+
if (!workflowId) {
|
|
786
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
787
|
+
}
|
|
788
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
789
|
+
if (!workflow) {
|
|
790
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
791
|
+
}
|
|
792
|
+
void workflow.restartAllActiveWorkflowRuns();
|
|
793
|
+
return { message: "All active workflow runs restarted" };
|
|
794
|
+
} catch (error) {
|
|
795
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error restarting all active workflow runs");
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
async function timeTravelAsyncWorkflowHandler({
|
|
799
|
+
mastra,
|
|
800
|
+
workflowId,
|
|
801
|
+
runId,
|
|
802
|
+
body,
|
|
803
|
+
runtimeContext,
|
|
804
|
+
tracingOptions
|
|
805
|
+
}) {
|
|
806
|
+
try {
|
|
807
|
+
if (!workflowId) {
|
|
808
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
809
|
+
}
|
|
810
|
+
if (!runId) {
|
|
811
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to time travel workflow" });
|
|
812
|
+
}
|
|
813
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
814
|
+
if (!workflow) {
|
|
815
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
816
|
+
}
|
|
817
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
818
|
+
if (!run) {
|
|
819
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
820
|
+
}
|
|
821
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
822
|
+
const result = await _run.timeTravel({
|
|
823
|
+
...body,
|
|
824
|
+
runtimeContext,
|
|
825
|
+
tracingOptions
|
|
826
|
+
});
|
|
827
|
+
return result;
|
|
828
|
+
} catch (error) {
|
|
829
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error time traveling workflow");
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
async function timeTravelWorkflowHandler({
|
|
833
|
+
mastra,
|
|
834
|
+
workflowId,
|
|
835
|
+
runId,
|
|
836
|
+
body,
|
|
837
|
+
runtimeContext,
|
|
838
|
+
tracingOptions
|
|
839
|
+
}) {
|
|
840
|
+
try {
|
|
841
|
+
if (!workflowId) {
|
|
842
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
843
|
+
}
|
|
844
|
+
if (!runId) {
|
|
845
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to time travel workflow" });
|
|
846
|
+
}
|
|
847
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
848
|
+
if (!workflow) {
|
|
849
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
850
|
+
}
|
|
851
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
852
|
+
if (!run) {
|
|
853
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
854
|
+
}
|
|
855
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
856
|
+
void _run.timeTravel({
|
|
857
|
+
...body,
|
|
858
|
+
runtimeContext,
|
|
859
|
+
tracingOptions
|
|
860
|
+
});
|
|
861
|
+
return { message: "Workflow run time travel started" };
|
|
862
|
+
} catch (error) {
|
|
863
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error time traveling workflow");
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
async function timeTravelStreamWorkflowHandler({
|
|
867
|
+
mastra,
|
|
868
|
+
workflowId,
|
|
869
|
+
runId,
|
|
870
|
+
body,
|
|
871
|
+
runtimeContext,
|
|
872
|
+
tracingOptions
|
|
873
|
+
}) {
|
|
874
|
+
try {
|
|
875
|
+
if (!workflowId) {
|
|
876
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
877
|
+
}
|
|
878
|
+
if (!runId) {
|
|
879
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to time travel workflow" });
|
|
880
|
+
}
|
|
881
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
882
|
+
if (!workflow) {
|
|
883
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
884
|
+
}
|
|
885
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
886
|
+
if (!run) {
|
|
887
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
888
|
+
}
|
|
889
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
890
|
+
const serverCache = mastra.getServerCache();
|
|
891
|
+
const result = _run.timeTravelStream({ ...body, runtimeContext, tracingOptions });
|
|
892
|
+
return result.fullStream.pipeThrough(
|
|
893
|
+
new web.TransformStream({
|
|
894
|
+
transform(chunk, controller) {
|
|
895
|
+
if (serverCache) {
|
|
896
|
+
const cacheKey = runId;
|
|
897
|
+
serverCache.listPush(cacheKey, chunk).catch(() => {
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
controller.enqueue(chunk);
|
|
901
|
+
}
|
|
902
|
+
})
|
|
903
|
+
);
|
|
904
|
+
} catch (error) {
|
|
905
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
|
|
910
|
+
exports.createWorkflowRunHandler = createWorkflowRunHandler;
|
|
911
|
+
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
912
|
+
exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
913
|
+
exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
|
|
914
|
+
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
915
|
+
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
916
|
+
exports.observeStreamLegacyWorkflowHandler = observeStreamLegacyWorkflowHandler;
|
|
917
|
+
exports.observeStreamVNextWorkflowHandler = observeStreamVNextWorkflowHandler;
|
|
918
|
+
exports.observeStreamWorkflowHandler = observeStreamWorkflowHandler;
|
|
919
|
+
exports.restartAllActiveWorkflowRunsAsyncHandler = restartAllActiveWorkflowRunsAsyncHandler;
|
|
920
|
+
exports.restartAllActiveWorkflowRunsHandler = restartAllActiveWorkflowRunsHandler;
|
|
921
|
+
exports.restartAsyncWorkflowHandler = restartAsyncWorkflowHandler;
|
|
922
|
+
exports.restartWorkflowHandler = restartWorkflowHandler;
|
|
923
|
+
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
924
|
+
exports.resumeStreamWorkflowHandler = resumeStreamWorkflowHandler;
|
|
925
|
+
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
926
|
+
exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
|
|
927
|
+
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
928
|
+
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
929
|
+
exports.streamLegacyWorkflowHandler = streamLegacyWorkflowHandler;
|
|
930
|
+
exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
|
|
931
|
+
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
932
|
+
exports.timeTravelAsyncWorkflowHandler = timeTravelAsyncWorkflowHandler;
|
|
933
|
+
exports.timeTravelStreamWorkflowHandler = timeTravelStreamWorkflowHandler;
|
|
934
|
+
exports.timeTravelWorkflowHandler = timeTravelWorkflowHandler;
|
|
935
|
+
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
936
|
+
exports.workflows_exports = workflows_exports;
|
|
937
|
+
//# sourceMappingURL=chunk-S6YZQY4V.cjs.map
|
|
938
|
+
//# sourceMappingURL=chunk-S6YZQY4V.cjs.map
|