@mastra/server 0.0.0-update-scorers-api-20250801170445 → 0.0.0-usechat-duplicate-20251016110554
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 +4048 -0
- package/README.md +0 -5
- 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-X5SDJOY6.cjs → chunk-3LTO44EP.cjs} +66 -53
- package/dist/chunk-3LTO44EP.cjs.map +1 -0
- package/dist/{chunk-4US5W7PH.cjs → chunk-3SNGNFUJ.cjs} +23 -15
- package/dist/chunk-3SNGNFUJ.cjs.map +1 -0
- package/dist/{chunk-OW4FX5TS.js → chunk-4QCXUEAT.js} +10 -3
- package/dist/chunk-4QCXUEAT.js.map +1 -0
- package/dist/{chunk-SQ7KKIH3.js → chunk-67GYDFSB.js} +22 -5
- package/dist/chunk-67GYDFSB.js.map +1 -0
- package/dist/{chunk-ILCWPBYQ.cjs → chunk-6ZR275MD.cjs} +23 -5
- package/dist/chunk-6ZR275MD.cjs.map +1 -0
- package/dist/chunk-7HDOBOGG.cjs +17517 -0
- package/dist/chunk-7HDOBOGG.cjs.map +1 -0
- package/dist/{chunk-4MQU6AJN.js → chunk-ABRFV4XP.js} +4 -4
- package/dist/{chunk-4MQU6AJN.js.map → chunk-ABRFV4XP.js.map} +1 -1
- package/dist/{chunk-YS66MFDY.js → chunk-AHB4JCIQ.js} +48 -12
- package/dist/chunk-AHB4JCIQ.js.map +1 -0
- package/dist/{chunk-TXAQU2XN.js → chunk-AW5BU3RQ.js} +63 -22
- 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-BZLZFHAT.cjs +682 -0
- package/dist/chunk-BZLZFHAT.cjs.map +1 -0
- package/dist/{chunk-BUOJL3MN.js → chunk-DB63UMTV.js} +220 -89
- package/dist/chunk-DB63UMTV.js.map +1 -0
- package/dist/{chunk-NCS2OXX6.cjs → chunk-EP3JQDPD.cjs} +4 -4
- package/dist/{chunk-NCS2OXX6.cjs.map → chunk-EP3JQDPD.cjs.map} +1 -1
- package/dist/chunk-FWO7VQDC.js +17481 -0
- package/dist/chunk-FWO7VQDC.js.map +1 -0
- package/dist/chunk-FZNS32WJ.js +46 -0
- package/dist/chunk-FZNS32WJ.js.map +1 -0
- package/dist/{chunk-4QSNRCOT.cjs → chunk-G4PUALCE.cjs} +10 -2
- package/dist/chunk-G4PUALCE.cjs.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/{chunk-TRWPUPGD.js → chunk-HPXAM2PG.js} +109 -138
- package/dist/chunk-HPXAM2PG.js.map +1 -0
- package/dist/{chunk-JGVY3KWV.cjs → chunk-I3C4ODGV.cjs} +12 -11
- package/dist/chunk-I3C4ODGV.cjs.map +1 -0
- package/dist/chunk-JSLAYFEW.js +662 -0
- package/dist/chunk-JSLAYFEW.js.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/{chunk-UVOSITKU.js → chunk-LLUOPR3J.js} +11 -10
- 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-S37KCGOR.cjs → chunk-MQDBNHBT.cjs} +222 -88
- package/dist/chunk-MQDBNHBT.cjs.map +1 -0
- package/dist/{chunk-G7NVCO5M.js → chunk-MYR4PVGN.js} +3 -3
- package/dist/{chunk-G7NVCO5M.js.map → chunk-MYR4PVGN.js.map} +1 -1
- package/dist/chunk-O7I5CWRX.cjs +44 -0
- package/dist/{chunk-Q7SFCCGT.cjs.map → chunk-O7I5CWRX.cjs.map} +1 -1
- package/dist/{chunk-HXIOPAHT.js → chunk-OEOGYAQC.js} +54 -42
- package/dist/chunk-OEOGYAQC.js.map +1 -0
- package/dist/chunk-OYL5TBJW.cjs +48 -0
- package/dist/chunk-OYL5TBJW.cjs.map +1 -0
- package/dist/chunk-PR4QN5HX.js +39 -0
- package/dist/{chunk-PZ5AY32C.js.map → chunk-PR4QN5HX.js.map} +1 -1
- package/dist/{chunk-HWHKM67I.js → chunk-QQXMIP6C.js} +21 -13
- package/dist/chunk-QQXMIP6C.js.map +1 -0
- package/dist/chunk-RQK4FQUD.js +1012 -0
- package/dist/chunk-RQK4FQUD.js.map +1 -0
- package/dist/chunk-SIW6CYO3.js +254 -0
- package/dist/chunk-SIW6CYO3.js.map +1 -0
- package/dist/{chunk-VIGPWTDA.cjs → chunk-SPRRK3P7.cjs} +64 -23
- package/dist/chunk-SPRRK3P7.cjs.map +1 -0
- package/dist/{chunk-GASWM5HJ.cjs → chunk-TOP25AIO.cjs} +110 -139
- package/dist/chunk-TOP25AIO.cjs.map +1 -0
- package/dist/{chunk-O4I563YW.cjs → chunk-TRGAMKHX.cjs} +50 -13
- package/dist/chunk-TRGAMKHX.cjs.map +1 -0
- package/dist/chunk-VY4ENABS.cjs +135 -0
- package/dist/chunk-VY4ENABS.cjs.map +1 -0
- package/dist/{chunk-BED2O446.cjs → chunk-XN74I6VW.cjs} +7 -7
- package/dist/{chunk-BED2O446.cjs.map → chunk-XN74I6VW.cjs.map} +1 -1
- package/dist/chunk-XVPBGW6Y.cjs +256 -0
- package/dist/chunk-XVPBGW6Y.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 +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/server/a2a/store.cjs +25 -0
- package/dist/server/a2a/store.cjs.map +1 -0
- package/dist/server/a2a/store.d.ts +3 -3
- package/dist/server/a2a/store.d.ts.map +1 -1
- package/dist/server/a2a/store.js +23 -0
- package/dist/server/a2a/store.js.map +1 -0
- package/dist/server/a2a/tasks.d.ts +7 -7
- package/dist/server/a2a/tasks.d.ts.map +1 -1
- package/dist/server/handlers/a2a.cjs +11 -11
- package/dist/server/handlers/a2a.d.ts +17 -15
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- 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 +53 -9
- package/dist/server/handlers/agents.d.ts +156 -33
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +11 -11
- package/dist/server/handlers/legacyWorkflows.d.ts +1 -1
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -1
- package/dist/server/handlers/legacyWorkflows.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +19 -15
- package/dist/server/handlers/memory.d.ts +24 -19
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- 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 +7 -7
- package/dist/server/handlers/scores.d.ts +110 -7
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/telemetry.cjs +7 -3
- package/dist/server/handlers/telemetry.d.ts +2 -1
- package/dist/server/handlers/telemetry.d.ts.map +1 -1
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +9 -5
- package/dist/server/handlers/tools.d.ts +5 -1
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +6 -2
- package/dist/server/handlers/utils.d.ts +6 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.d.ts +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.d.ts +7 -5
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +28 -16
- package/dist/server/handlers/workflows.d.ts +37 -34
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +38 -33
- package/dist/server/handlers.d.ts +13 -12
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +13 -12
- package/dist/server/utils.d.ts +44 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/token-53CFGXUO.cjs +64 -0
- package/dist/token-53CFGXUO.cjs.map +1 -0
- package/dist/token-WAEKDUVY.js +62 -0
- package/dist/token-WAEKDUVY.js.map +1 -0
- package/dist/token-util-LY37VCIN.js +7 -0
- package/dist/token-util-LY37VCIN.js.map +1 -0
- package/dist/token-util-S4A355II.cjs +9 -0
- package/dist/token-util-S4A355II.cjs.map +1 -0
- package/package.json +36 -14
- package/dist/chunk-2XIJW7SV.cjs +0 -310
- package/dist/chunk-2XIJW7SV.cjs.map +0 -1
- package/dist/chunk-4CEZIJWJ.cjs +0 -150
- package/dist/chunk-4CEZIJWJ.cjs.map +0 -1
- package/dist/chunk-4QSNRCOT.cjs.map +0 -1
- package/dist/chunk-4US5W7PH.cjs.map +0 -1
- package/dist/chunk-7FHF55WA.js +0 -2041
- package/dist/chunk-7FHF55WA.js.map +0 -1
- package/dist/chunk-BUOJL3MN.js.map +0 -1
- package/dist/chunk-GASWM5HJ.cjs.map +0 -1
- package/dist/chunk-HWHKM67I.js.map +0 -1
- package/dist/chunk-HXIOPAHT.js.map +0 -1
- package/dist/chunk-ILCWPBYQ.cjs.map +0 -1
- package/dist/chunk-JGVY3KWV.cjs.map +0 -1
- package/dist/chunk-LRUH33B4.cjs +0 -2044
- package/dist/chunk-LRUH33B4.cjs.map +0 -1
- package/dist/chunk-O4I563YW.cjs.map +0 -1
- package/dist/chunk-OW4FX5TS.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-Q7SFCCGT.cjs +0 -11
- package/dist/chunk-S37KCGOR.cjs.map +0 -1
- package/dist/chunk-SQ7KKIH3.js.map +0 -1
- package/dist/chunk-TRWPUPGD.js.map +0 -1
- package/dist/chunk-TXAQU2XN.js.map +0 -1
- package/dist/chunk-UVOSITKU.js.map +0 -1
- package/dist/chunk-VIGPWTDA.cjs.map +0 -1
- package/dist/chunk-VOY6MGKA.js +0 -301
- package/dist/chunk-VOY6MGKA.js.map +0 -1
- package/dist/chunk-X5SDJOY6.cjs.map +0 -1
- package/dist/chunk-Y3J45CVZ.js +0 -144
- package/dist/chunk-Y3J45CVZ.js.map +0 -1
- package/dist/chunk-YS66MFDY.js.map +0 -1
- package/dist/server/handlers/network.cjs +0 -24
- package/dist/server/handlers/network.cjs.map +0 -1
- package/dist/server/handlers/network.d.ts +0 -50
- package/dist/server/handlers/network.d.ts.map +0 -1
- package/dist/server/handlers/network.js +0 -3
- package/dist/server/handlers/network.js.map +0 -1
- package/dist/server/handlers/vNextNetwork.cjs +0 -220
- package/dist/server/handlers/vNextNetwork.cjs.map +0 -1
- package/dist/server/handlers/vNextNetwork.d.ts +0 -179
- package/dist/server/handlers/vNextNetwork.d.ts.map +0 -1
- package/dist/server/handlers/vNextNetwork.js +0 -213
- package/dist/server/handlers/vNextNetwork.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVY4ENABS_cjs = require('./chunk-VY4ENABS.cjs');
|
|
4
4
|
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
5
5
|
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
|
|
7
7
|
var web = require('stream/web');
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/workflows.ts
|
|
10
10
|
var workflows_exports = {};
|
|
11
|
-
|
|
11
|
+
chunkO7I5CWRX_cjs.__export(workflows_exports, {
|
|
12
12
|
cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
|
|
13
13
|
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
14
14
|
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
@@ -16,7 +16,10 @@ chunkQ7SFCCGT_cjs.__export(workflows_exports, {
|
|
|
16
16
|
getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
|
|
17
17
|
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
18
18
|
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
19
|
+
observeStreamVNextWorkflowHandler: () => observeStreamVNextWorkflowHandler,
|
|
20
|
+
observeStreamWorkflowHandler: () => observeStreamWorkflowHandler,
|
|
19
21
|
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
22
|
+
resumeStreamWorkflowHandler: () => resumeStreamWorkflowHandler,
|
|
20
23
|
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
21
24
|
sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
|
|
22
25
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
@@ -25,48 +28,11 @@ chunkQ7SFCCGT_cjs.__export(workflows_exports, {
|
|
|
25
28
|
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
26
29
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
27
30
|
});
|
|
28
|
-
function getSteps(steps, path) {
|
|
29
|
-
return Object.entries(steps).reduce((acc, [key, step]) => {
|
|
30
|
-
const fullKey = path ? `${path}.${key}` : key;
|
|
31
|
-
acc[fullKey] = {
|
|
32
|
-
id: step.id,
|
|
33
|
-
description: step.description,
|
|
34
|
-
inputSchema: step.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.inputSchema)) : void 0,
|
|
35
|
-
outputSchema: step.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.outputSchema)) : void 0,
|
|
36
|
-
resumeSchema: step.resumeSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
37
|
-
suspendSchema: step.suspendSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.suspendSchema)) : void 0,
|
|
38
|
-
isWorkflow: step.component === "WORKFLOW"
|
|
39
|
-
};
|
|
40
|
-
if (step.component === "WORKFLOW" && step.steps) {
|
|
41
|
-
const nestedSteps = getSteps(step.steps, fullKey) || {};
|
|
42
|
-
acc = { ...acc, ...nestedSteps };
|
|
43
|
-
}
|
|
44
|
-
return acc;
|
|
45
|
-
}, {});
|
|
46
|
-
}
|
|
47
31
|
async function getWorkflowsHandler({ mastra }) {
|
|
48
32
|
try {
|
|
49
33
|
const workflows = mastra.getWorkflows({ serialized: false });
|
|
50
34
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
51
|
-
acc[key] =
|
|
52
|
-
name: workflow.name,
|
|
53
|
-
description: workflow.description,
|
|
54
|
-
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
55
|
-
acc2[key2] = {
|
|
56
|
-
id: step.id,
|
|
57
|
-
description: step.description,
|
|
58
|
-
inputSchema: step.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.inputSchema)) : void 0,
|
|
59
|
-
outputSchema: step.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.outputSchema)) : void 0,
|
|
60
|
-
resumeSchema: step.resumeSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
61
|
-
suspendSchema: step.suspendSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.suspendSchema)) : void 0
|
|
62
|
-
};
|
|
63
|
-
return acc2;
|
|
64
|
-
}, {}),
|
|
65
|
-
allSteps: getSteps(workflow.steps) || {},
|
|
66
|
-
stepGraph: workflow.serializedStepGraph,
|
|
67
|
-
inputSchema: workflow.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
68
|
-
outputSchema: workflow.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
69
|
-
};
|
|
35
|
+
acc[key] = chunkVY4ENABS_cjs.getWorkflowInfo(workflow);
|
|
70
36
|
return acc;
|
|
71
37
|
}, {});
|
|
72
38
|
return _workflows;
|
|
@@ -80,10 +46,13 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
|
80
46
|
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
81
47
|
}
|
|
82
48
|
let workflow;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
49
|
+
workflow = chunkVY4ENABS_cjs.WorkflowRegistry.getWorkflow(workflowId);
|
|
50
|
+
if (!workflow) {
|
|
51
|
+
try {
|
|
52
|
+
workflow = mastra.getWorkflow(workflowId);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
logger.debug("Error getting workflow, searching agents for workflow", error);
|
|
55
|
+
}
|
|
87
56
|
}
|
|
88
57
|
if (!workflow) {
|
|
89
58
|
logger.debug("Workflow not found, searching agents for workflow", { workflowId });
|
|
@@ -117,25 +86,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
117
86
|
if (!workflow) {
|
|
118
87
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
119
88
|
}
|
|
120
|
-
return
|
|
121
|
-
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
122
|
-
acc[key] = {
|
|
123
|
-
id: step.id,
|
|
124
|
-
description: step.description,
|
|
125
|
-
inputSchema: step.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.inputSchema)) : void 0,
|
|
126
|
-
outputSchema: step.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.outputSchema)) : void 0,
|
|
127
|
-
resumeSchema: step.resumeSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
128
|
-
suspendSchema: step.suspendSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(step.suspendSchema)) : void 0
|
|
129
|
-
};
|
|
130
|
-
return acc;
|
|
131
|
-
}, {}),
|
|
132
|
-
allSteps: getSteps(workflow.steps) || {},
|
|
133
|
-
name: workflow.name,
|
|
134
|
-
description: workflow.description,
|
|
135
|
-
stepGraph: workflow.serializedStepGraph,
|
|
136
|
-
inputSchema: workflow.inputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
137
|
-
outputSchema: workflow.outputSchema ? chunkLRUH33B4_cjs.stringify(chunkLRUH33B4_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
138
|
-
};
|
|
89
|
+
return chunkVY4ENABS_cjs.getWorkflowInfo(workflow);
|
|
139
90
|
} catch (error) {
|
|
140
91
|
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow");
|
|
141
92
|
}
|
|
@@ -214,7 +165,8 @@ async function startAsyncWorkflowHandler({
|
|
|
214
165
|
runtimeContext,
|
|
215
166
|
workflowId,
|
|
216
167
|
runId,
|
|
217
|
-
inputData
|
|
168
|
+
inputData,
|
|
169
|
+
tracingOptions
|
|
218
170
|
}) {
|
|
219
171
|
try {
|
|
220
172
|
if (!workflowId) {
|
|
@@ -227,7 +179,8 @@ async function startAsyncWorkflowHandler({
|
|
|
227
179
|
const _run = await workflow.createRunAsync({ runId });
|
|
228
180
|
const result = await _run.start({
|
|
229
181
|
inputData,
|
|
230
|
-
runtimeContext
|
|
182
|
+
runtimeContext,
|
|
183
|
+
tracingOptions
|
|
231
184
|
});
|
|
232
185
|
return result;
|
|
233
186
|
} catch (error) {
|
|
@@ -239,7 +192,8 @@ async function startWorkflowRunHandler({
|
|
|
239
192
|
runtimeContext,
|
|
240
193
|
workflowId,
|
|
241
194
|
runId,
|
|
242
|
-
inputData
|
|
195
|
+
inputData,
|
|
196
|
+
tracingOptions
|
|
243
197
|
}) {
|
|
244
198
|
try {
|
|
245
199
|
if (!workflowId) {
|
|
@@ -256,10 +210,11 @@ async function startWorkflowRunHandler({
|
|
|
256
210
|
if (!run) {
|
|
257
211
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
258
212
|
}
|
|
259
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
213
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
260
214
|
void _run.start({
|
|
261
215
|
inputData,
|
|
262
|
-
runtimeContext
|
|
216
|
+
runtimeContext,
|
|
217
|
+
tracingOptions
|
|
263
218
|
});
|
|
264
219
|
return { message: "Workflow run started" };
|
|
265
220
|
} catch (e) {
|
|
@@ -269,7 +224,8 @@ async function startWorkflowRunHandler({
|
|
|
269
224
|
async function watchWorkflowHandler({
|
|
270
225
|
mastra,
|
|
271
226
|
workflowId,
|
|
272
|
-
runId
|
|
227
|
+
runId,
|
|
228
|
+
eventType = "watch"
|
|
273
229
|
}) {
|
|
274
230
|
try {
|
|
275
231
|
if (!workflowId) {
|
|
@@ -286,27 +242,32 @@ async function watchWorkflowHandler({
|
|
|
286
242
|
if (!run) {
|
|
287
243
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
288
244
|
}
|
|
289
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
245
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
290
246
|
let unwatch;
|
|
291
247
|
let asyncRef = null;
|
|
292
248
|
const stream = new web.ReadableStream({
|
|
293
249
|
start(controller) {
|
|
294
|
-
unwatch = _run.watch((
|
|
250
|
+
unwatch = _run.watch((event) => {
|
|
251
|
+
const { type, payload, eventTimestamp } = event;
|
|
295
252
|
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
296
253
|
if (asyncRef) {
|
|
297
254
|
clearImmediate(asyncRef);
|
|
298
255
|
asyncRef = null;
|
|
299
256
|
}
|
|
300
257
|
asyncRef = setImmediate(async () => {
|
|
301
|
-
const runDone = payload.workflowState.status !== "running";
|
|
258
|
+
const runDone = eventType === "watch" ? payload.workflowState.status !== "running" : type === "finish";
|
|
302
259
|
if (runDone) {
|
|
303
260
|
controller.close();
|
|
304
261
|
unwatch?.();
|
|
305
262
|
}
|
|
306
263
|
});
|
|
307
|
-
});
|
|
264
|
+
}, eventType);
|
|
308
265
|
},
|
|
309
266
|
cancel() {
|
|
267
|
+
if (asyncRef) {
|
|
268
|
+
clearImmediate(asyncRef);
|
|
269
|
+
asyncRef = null;
|
|
270
|
+
}
|
|
310
271
|
unwatch?.();
|
|
311
272
|
}
|
|
312
273
|
});
|
|
@@ -320,7 +281,8 @@ async function streamWorkflowHandler({
|
|
|
320
281
|
runtimeContext,
|
|
321
282
|
workflowId,
|
|
322
283
|
runId,
|
|
323
|
-
inputData
|
|
284
|
+
inputData,
|
|
285
|
+
tracingOptions
|
|
324
286
|
}) {
|
|
325
287
|
try {
|
|
326
288
|
if (!workflowId) {
|
|
@@ -333,22 +295,70 @@ async function streamWorkflowHandler({
|
|
|
333
295
|
if (!workflow) {
|
|
334
296
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
335
297
|
}
|
|
298
|
+
const serverCache = mastra.getServerCache();
|
|
336
299
|
const run = await workflow.createRunAsync({ runId });
|
|
337
300
|
const result = run.stream({
|
|
338
301
|
inputData,
|
|
339
|
-
runtimeContext
|
|
302
|
+
runtimeContext,
|
|
303
|
+
onChunk: async (chunk) => {
|
|
304
|
+
if (serverCache) {
|
|
305
|
+
const cacheKey = runId;
|
|
306
|
+
await serverCache.listPush(cacheKey, chunk);
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
tracingOptions
|
|
340
310
|
});
|
|
341
311
|
return result;
|
|
342
312
|
} catch (error) {
|
|
343
313
|
return chunkRE4RPXT2_cjs.handleError(error, "Error executing workflow");
|
|
344
314
|
}
|
|
345
315
|
}
|
|
316
|
+
async function observeStreamWorkflowHandler({
|
|
317
|
+
mastra,
|
|
318
|
+
workflowId,
|
|
319
|
+
runId
|
|
320
|
+
}) {
|
|
321
|
+
try {
|
|
322
|
+
if (!workflowId) {
|
|
323
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
324
|
+
}
|
|
325
|
+
if (!runId) {
|
|
326
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
|
|
327
|
+
}
|
|
328
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
329
|
+
if (!workflow) {
|
|
330
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
331
|
+
}
|
|
332
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
333
|
+
if (!run) {
|
|
334
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
335
|
+
}
|
|
336
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
337
|
+
const serverCache = mastra.getServerCache();
|
|
338
|
+
if (!serverCache) {
|
|
339
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Server cache not found" });
|
|
340
|
+
}
|
|
341
|
+
const transformStream = new web.TransformStream();
|
|
342
|
+
const writer = transformStream.writable.getWriter();
|
|
343
|
+
const cachedRunChunks = await serverCache.listFromTo(runId, 0);
|
|
344
|
+
for (const chunk of cachedRunChunks) {
|
|
345
|
+
await writer.write(chunk);
|
|
346
|
+
}
|
|
347
|
+
writer.releaseLock();
|
|
348
|
+
const result = _run.observeStream();
|
|
349
|
+
return result.stream?.pipeThrough(transformStream);
|
|
350
|
+
} catch (error) {
|
|
351
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error observing workflow stream");
|
|
352
|
+
}
|
|
353
|
+
}
|
|
346
354
|
async function streamVNextWorkflowHandler({
|
|
347
355
|
mastra,
|
|
348
356
|
runtimeContext,
|
|
349
357
|
workflowId,
|
|
350
358
|
runId,
|
|
351
|
-
inputData
|
|
359
|
+
inputData,
|
|
360
|
+
closeOnSuspend,
|
|
361
|
+
tracingOptions
|
|
352
362
|
}) {
|
|
353
363
|
try {
|
|
354
364
|
if (!workflowId) {
|
|
@@ -361,22 +371,95 @@ async function streamVNextWorkflowHandler({
|
|
|
361
371
|
if (!workflow) {
|
|
362
372
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
363
373
|
}
|
|
374
|
+
const serverCache = mastra.getServerCache();
|
|
364
375
|
const run = await workflow.createRunAsync({ runId });
|
|
365
376
|
const result = run.streamVNext({
|
|
366
377
|
inputData,
|
|
367
|
-
runtimeContext
|
|
378
|
+
runtimeContext,
|
|
379
|
+
closeOnSuspend,
|
|
380
|
+
onChunk: async (chunk) => {
|
|
381
|
+
if (serverCache) {
|
|
382
|
+
const cacheKey = runId;
|
|
383
|
+
await serverCache.listPush(cacheKey, chunk);
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
tracingOptions
|
|
368
387
|
});
|
|
369
388
|
return result;
|
|
370
389
|
} catch (error) {
|
|
371
390
|
return chunkRE4RPXT2_cjs.handleError(error, "Error streaming workflow");
|
|
372
391
|
}
|
|
373
392
|
}
|
|
393
|
+
async function observeStreamVNextWorkflowHandler({
|
|
394
|
+
mastra,
|
|
395
|
+
workflowId,
|
|
396
|
+
runId
|
|
397
|
+
}) {
|
|
398
|
+
try {
|
|
399
|
+
if (!workflowId) {
|
|
400
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
401
|
+
}
|
|
402
|
+
if (!runId) {
|
|
403
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
|
|
404
|
+
}
|
|
405
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
406
|
+
if (!workflow) {
|
|
407
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
408
|
+
}
|
|
409
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
410
|
+
if (!run) {
|
|
411
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
412
|
+
}
|
|
413
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
414
|
+
const serverCache = mastra.getServerCache();
|
|
415
|
+
if (!serverCache) {
|
|
416
|
+
throw new chunk7NADHFD2_cjs.HTTPException(500, { message: "Server cache not found" });
|
|
417
|
+
}
|
|
418
|
+
const cachedRunChunks = await serverCache.listFromTo(runId, 0);
|
|
419
|
+
const combinedStream = new web.ReadableStream({
|
|
420
|
+
start(controller) {
|
|
421
|
+
const emitCachedChunks = async () => {
|
|
422
|
+
for (const chunk of cachedRunChunks) {
|
|
423
|
+
controller.enqueue(chunk);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const liveStream = _run.observeStreamVNext();
|
|
427
|
+
const reader = liveStream.getReader();
|
|
428
|
+
const pump = async () => {
|
|
429
|
+
try {
|
|
430
|
+
while (true) {
|
|
431
|
+
const { done, value } = await reader.read();
|
|
432
|
+
if (done) {
|
|
433
|
+
controller.close();
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
controller.enqueue(value);
|
|
437
|
+
}
|
|
438
|
+
} catch (error) {
|
|
439
|
+
controller.error(error);
|
|
440
|
+
} finally {
|
|
441
|
+
reader.releaseLock();
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
void emitCachedChunks().then(() => {
|
|
445
|
+
void pump();
|
|
446
|
+
}).catch((error) => {
|
|
447
|
+
controller.error(error);
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
return combinedStream;
|
|
452
|
+
} catch (error) {
|
|
453
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error observing workflow stream");
|
|
454
|
+
}
|
|
455
|
+
}
|
|
374
456
|
async function resumeAsyncWorkflowHandler({
|
|
375
457
|
mastra,
|
|
376
458
|
workflowId,
|
|
377
459
|
runId,
|
|
378
460
|
body,
|
|
379
|
-
runtimeContext
|
|
461
|
+
runtimeContext,
|
|
462
|
+
tracingOptions
|
|
380
463
|
}) {
|
|
381
464
|
try {
|
|
382
465
|
if (!workflowId) {
|
|
@@ -396,11 +479,12 @@ async function resumeAsyncWorkflowHandler({
|
|
|
396
479
|
if (!run) {
|
|
397
480
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
398
481
|
}
|
|
399
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
482
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
400
483
|
const result = await _run.resume({
|
|
401
484
|
step: body.step,
|
|
402
485
|
resumeData: body.resumeData,
|
|
403
|
-
runtimeContext
|
|
486
|
+
runtimeContext,
|
|
487
|
+
tracingOptions
|
|
404
488
|
});
|
|
405
489
|
return result;
|
|
406
490
|
} catch (error) {
|
|
@@ -412,7 +496,8 @@ async function resumeWorkflowHandler({
|
|
|
412
496
|
workflowId,
|
|
413
497
|
runId,
|
|
414
498
|
body,
|
|
415
|
-
runtimeContext
|
|
499
|
+
runtimeContext,
|
|
500
|
+
tracingOptions
|
|
416
501
|
}) {
|
|
417
502
|
try {
|
|
418
503
|
if (!workflowId) {
|
|
@@ -432,17 +517,63 @@ async function resumeWorkflowHandler({
|
|
|
432
517
|
if (!run) {
|
|
433
518
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
434
519
|
}
|
|
435
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
520
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
436
521
|
void _run.resume({
|
|
437
522
|
step: body.step,
|
|
438
523
|
resumeData: body.resumeData,
|
|
439
|
-
runtimeContext
|
|
524
|
+
runtimeContext,
|
|
525
|
+
tracingOptions
|
|
440
526
|
});
|
|
441
527
|
return { message: "Workflow run resumed" };
|
|
442
528
|
} catch (error) {
|
|
443
529
|
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
|
|
444
530
|
}
|
|
445
531
|
}
|
|
532
|
+
async function resumeStreamWorkflowHandler({
|
|
533
|
+
mastra,
|
|
534
|
+
workflowId,
|
|
535
|
+
runId,
|
|
536
|
+
body,
|
|
537
|
+
runtimeContext,
|
|
538
|
+
tracingOptions
|
|
539
|
+
}) {
|
|
540
|
+
try {
|
|
541
|
+
if (!workflowId) {
|
|
542
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
543
|
+
}
|
|
544
|
+
if (!runId) {
|
|
545
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
546
|
+
}
|
|
547
|
+
if (!body.step) {
|
|
548
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
549
|
+
}
|
|
550
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
551
|
+
if (!workflow) {
|
|
552
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
553
|
+
}
|
|
554
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
555
|
+
if (!run) {
|
|
556
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
557
|
+
}
|
|
558
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
559
|
+
const serverCache = mastra.getServerCache();
|
|
560
|
+
const stream = _run.resumeStreamVNext({
|
|
561
|
+
step: body.step,
|
|
562
|
+
resumeData: body.resumeData,
|
|
563
|
+
runtimeContext,
|
|
564
|
+
tracingOptions,
|
|
565
|
+
onChunk: async (chunk) => {
|
|
566
|
+
if (serverCache) {
|
|
567
|
+
const cacheKey = runId;
|
|
568
|
+
await serverCache.listPush(cacheKey, chunk);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
return stream;
|
|
573
|
+
} catch (error) {
|
|
574
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
|
|
575
|
+
}
|
|
576
|
+
}
|
|
446
577
|
async function getWorkflowRunsHandler({
|
|
447
578
|
mastra,
|
|
448
579
|
workflowId,
|
|
@@ -489,7 +620,7 @@ async function cancelWorkflowRunHandler({
|
|
|
489
620
|
if (!run) {
|
|
490
621
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
491
622
|
}
|
|
492
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
623
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
493
624
|
await _run.cancel();
|
|
494
625
|
return { message: "Workflow run cancelled" };
|
|
495
626
|
} catch (error) {
|
|
@@ -518,7 +649,7 @@ async function sendWorkflowRunEventHandler({
|
|
|
518
649
|
if (!run) {
|
|
519
650
|
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
520
651
|
}
|
|
521
|
-
const _run = await workflow.createRunAsync({ runId });
|
|
652
|
+
const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
|
|
522
653
|
await _run.sendEvent(event, data);
|
|
523
654
|
return { message: "Workflow run event sent" };
|
|
524
655
|
} catch (error) {
|
|
@@ -533,7 +664,10 @@ exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
|
|
|
533
664
|
exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
|
|
534
665
|
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
535
666
|
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
667
|
+
exports.observeStreamVNextWorkflowHandler = observeStreamVNextWorkflowHandler;
|
|
668
|
+
exports.observeStreamWorkflowHandler = observeStreamWorkflowHandler;
|
|
536
669
|
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
670
|
+
exports.resumeStreamWorkflowHandler = resumeStreamWorkflowHandler;
|
|
537
671
|
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
538
672
|
exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
|
|
539
673
|
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
@@ -542,5 +676,5 @@ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
|
|
|
542
676
|
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
543
677
|
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
544
678
|
exports.workflows_exports = workflows_exports;
|
|
545
|
-
//# sourceMappingURL=chunk-
|
|
546
|
-
//# sourceMappingURL=chunk-
|
|
679
|
+
//# sourceMappingURL=chunk-MQDBNHBT.cjs.map
|
|
680
|
+
//# sourceMappingURL=chunk-MQDBNHBT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","getWorkflowInfo","handleError","HTTPException","WorkflowRegistry","ReadableStream","TransformStream"],"mappings":";;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAA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chunk-MQDBNHBT.cjs","sourcesContent":["import { ReadableStream, TransformStream } from 'node:stream/web';\nimport type { TracingOptions } from '@mastra/core/ai-tracing';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport type { Workflow, WatchEvent, WorkflowInfo, StreamEvent, ChunkType } from '@mastra/core/workflows';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nexport async function getWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\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 // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n try {\n workflow = mastra.getWorkflow(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\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<WorkflowInfo> {\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 getWorkflowInfo(workflow);\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 tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 tracingOptions,\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 tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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, resourceId: run.resourceId });\n void _run.start({\n inputData,\n runtimeContext,\n tracingOptions,\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 eventType = 'watch',\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n eventType?: 'watch' | 'watch-v2';\n}): 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, resourceId: run.resourceId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = _run.watch((event: any) => {\n const { type, payload, eventTimestamp } = event;\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 = eventType === 'watch' ? payload.workflowState.status !== 'running' : type === 'finish';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n }, eventType);\n },\n cancel() {\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\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 tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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 serverCache = mastra.getServerCache();\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n runtimeContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n tracingOptions,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function observeStreamWorkflowHandler({\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 observe workflow stream' });\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, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n const transformStream = new TransformStream<StreamEvent, StreamEvent>();\n\n const writer = transformStream.writable.getWriter();\n\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n for (const chunk of cachedRunChunks) {\n await writer.write(chunk as any);\n }\n\n writer.releaseLock();\n\n const result = _run.observeStream();\n return result.stream?.pipeThrough(transformStream);\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n closeOnSuspend,\n tracingOptions,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n closeOnSuspend?: boolean;\n tracingOptions?: TracingOptions;\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 serverCache = mastra.getServerCache();\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.streamVNext({\n inputData,\n runtimeContext,\n closeOnSuspend,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n tracingOptions,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n}\n\nexport async function observeStreamVNextWorkflowHandler({\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 observe workflow stream' });\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, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks first\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n // Create a readable stream that first emits cached chunks, then the live stream\n const combinedStream = new ReadableStream<ChunkType>({\n start(controller) {\n // First, emit all cached chunks\n const emitCachedChunks = async () => {\n for (const chunk of cachedRunChunks) {\n controller.enqueue(chunk as ChunkType);\n }\n };\n\n // Then, pipe the live stream\n const liveStream = _run.observeStreamVNext();\n const reader = liveStream.getReader();\n\n const pump = async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n break;\n }\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n } finally {\n reader.releaseLock();\n }\n };\n\n // Start with cached chunks, then live stream\n void emitCachedChunks()\n .then(() => {\n void pump();\n })\n .catch(error => {\n controller.error(error);\n });\n },\n });\n\n return combinedStream;\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n}\n\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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, resourceId: run.resourceId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n tracingOptions,\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 tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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, resourceId: run.resourceId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n tracingOptions,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function resumeStreamWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n tracingOptions,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n tracingOptions?: TracingOptions;\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, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const stream = _run.resumeStreamVNext({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n tracingOptions,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return stream;\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, resourceId: run.resourceId });\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, resourceId: run.resourceId });\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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { handleError } from './chunk-CY4TP3FK.js';
|
|
2
2
|
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
3
|
-
import { __export } from './chunk-
|
|
3
|
+
import { __export } from './chunk-PR4QN5HX.js';
|
|
4
4
|
|
|
5
5
|
// src/server/handlers/vector.ts
|
|
6
6
|
var vector_exports = {};
|
|
@@ -119,5 +119,5 @@ async function deleteIndex({
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export { createIndex, deleteIndex, describeIndex, listIndexes, queryVectors, upsertVectors, vector_exports };
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-MYR4PVGN.js.map
|
|
123
|
+
//# sourceMappingURL=chunk-MYR4PVGN.js.map
|