@mastra/server 0.0.0-support-d1-client-20250701191943 → 0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806162745
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +11 -42
- package/dist/{chunk-BWHGBV3K.cjs → chunk-2XIJW7SV.cjs} +54 -22
- package/dist/chunk-2XIJW7SV.cjs.map +1 -0
- package/dist/{chunk-DPRB3R7Y.cjs → chunk-4CEZIJWJ.cjs} +16 -14
- package/dist/chunk-4CEZIJWJ.cjs.map +1 -0
- package/dist/{chunk-BOXE6WSV.js → chunk-4MQU6AJN.js} +5 -3
- package/dist/chunk-4MQU6AJN.js.map +1 -0
- package/dist/{chunk-57CJTIPW.cjs → chunk-4QSNRCOT.cjs} +4 -2
- package/dist/chunk-4QSNRCOT.cjs.map +1 -0
- package/dist/{chunk-L3N7ST2Z.cjs → chunk-4US5W7PH.cjs} +26 -24
- package/dist/chunk-4US5W7PH.cjs.map +1 -0
- package/dist/{chunk-MEGCYGBU.js → chunk-7FHF55WA.js} +39 -37
- package/dist/chunk-7FHF55WA.js.map +1 -0
- package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
- package/dist/chunk-7NADHFD2.cjs.map +1 -0
- package/dist/{chunk-CNVDCLSY.cjs → chunk-BED2O446.cjs} +11 -9
- package/dist/chunk-BED2O446.cjs.map +1 -0
- package/dist/{chunk-Z5TH5F35.js → chunk-BUOJL3MN.js} +66 -5
- package/dist/chunk-BUOJL3MN.js.map +1 -0
- package/dist/{chunk-QDOJJCS4.js → chunk-CY4TP3FK.js} +6 -2
- package/dist/chunk-CY4TP3FK.js.map +1 -0
- package/dist/{chunk-FVMGZKFD.js → chunk-G7NVCO5M.js} +5 -3
- package/dist/chunk-G7NVCO5M.js.map +1 -0
- package/dist/{chunk-SDPGVWQJ.cjs → chunk-GASWM5HJ.cjs} +4 -2
- package/dist/chunk-GASWM5HJ.cjs.map +1 -0
- package/dist/chunk-GX25CWC7.cjs +588 -0
- package/dist/chunk-GX25CWC7.cjs.map +1 -0
- package/dist/{chunk-G37NVEDX.js → chunk-HWHKM67I.js} +6 -4
- package/dist/chunk-HWHKM67I.js.map +1 -0
- package/dist/{chunk-ULFULEW4.cjs → chunk-ILCWPBYQ.cjs} +9 -7
- package/dist/chunk-ILCWPBYQ.cjs.map +1 -0
- package/dist/{chunk-TGZIR6AK.cjs → chunk-JGVY3KWV.cjs} +47 -45
- package/dist/chunk-JGVY3KWV.cjs.map +1 -0
- package/dist/{chunk-LI436ITD.cjs → chunk-LRUH33B4.cjs} +39 -37
- package/dist/chunk-LRUH33B4.cjs.map +1 -0
- package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
- package/dist/chunk-MMROOK5J.js.map +1 -0
- package/dist/{chunk-TVBPFPTN.cjs → chunk-NCS2OXX6.cjs} +20 -18
- package/dist/chunk-NCS2OXX6.cjs.map +1 -0
- package/dist/{chunk-FGGMQCPP.cjs → chunk-O4I563YW.cjs} +24 -22
- package/dist/chunk-O4I563YW.cjs.map +1 -0
- package/dist/{chunk-H5PTF3Y4.js → chunk-OW4FX5TS.js} +3 -1
- package/dist/chunk-OW4FX5TS.js.map +1 -0
- package/dist/{chunk-MLKGABMK.js → chunk-PZ5AY32C.js} +2 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/{chunk-75ZPJI57.cjs → chunk-Q7SFCCGT.cjs} +2 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-RE4RPXT2.cjs +18 -0
- package/dist/chunk-RE4RPXT2.cjs.map +1 -0
- package/dist/{chunk-7524QH7G.cjs → chunk-S37KCGOR.cjs} +140 -77
- package/dist/chunk-S37KCGOR.cjs.map +1 -0
- package/dist/{chunk-BP24Z4WG.js → chunk-SQ7KKIH3.js} +5 -3
- package/dist/chunk-SQ7KKIH3.js.map +1 -0
- package/dist/{chunk-GHC4YV6R.js → chunk-TRWPUPGD.js} +3 -1
- package/dist/chunk-TRWPUPGD.js.map +1 -0
- package/dist/chunk-TXAQU2XN.js +151 -0
- package/dist/chunk-TXAQU2XN.js.map +1 -0
- package/dist/{chunk-7GQJAMTA.js → chunk-UVOSITKU.js} +6 -4
- package/dist/chunk-UVOSITKU.js.map +1 -0
- package/dist/chunk-VIGPWTDA.cjs +159 -0
- package/dist/chunk-VIGPWTDA.cjs.map +1 -0
- package/dist/{chunk-4QBIUKVY.js → chunk-VOY6MGKA.js} +38 -7
- package/dist/chunk-VOY6MGKA.js.map +1 -0
- package/dist/{chunk-VMXLEF54.js → chunk-Y3J45CVZ.js} +6 -4
- package/dist/chunk-Y3J45CVZ.js.map +1 -0
- package/dist/{chunk-DFJUGWNU.js → chunk-YS66MFDY.js} +7 -5
- package/dist/chunk-YS66MFDY.js.map +1 -0
- package/dist/chunk-ZKJZQN24.js +571 -0
- package/dist/chunk-ZKJZQN24.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server/a2a/protocol.d.ts +8 -0
- package/dist/server/a2a/protocol.d.ts.map +1 -0
- package/dist/server/a2a/store.d.ts +14 -0
- package/dist/server/a2a/store.d.ts.map +1 -0
- package/dist/server/a2a/tasks.d.ts +20 -0
- package/dist/server/a2a/tasks.d.ts.map +1 -0
- package/dist/server/handlers/a2a.cjs +9 -7
- package/dist/server/handlers/a2a.cjs.map +1 -0
- package/dist/server/handlers/a2a.d.ts +66 -6
- package/dist/server/handlers/a2a.d.ts.map +1 -0
- package/dist/server/handlers/a2a.js +3 -1
- package/dist/server/handlers/a2a.js.map +1 -0
- package/dist/server/handlers/agents.cjs +13 -7
- package/dist/server/handlers/agents.cjs.map +1 -0
- package/dist/server/handlers/agents.d.ts +81 -6
- package/dist/server/handlers/agents.d.ts.map +1 -0
- package/dist/server/handlers/agents.js +3 -1
- package/dist/server/handlers/agents.js.map +1 -0
- package/dist/server/handlers/error.cjs +4 -2
- package/dist/server/handlers/error.cjs.map +1 -0
- package/dist/server/handlers/error.d.ts +2 -1
- package/dist/server/handlers/error.d.ts.map +1 -0
- package/dist/server/handlers/error.js +3 -1
- package/dist/server/handlers/error.js.map +1 -0
- package/dist/server/handlers/legacyWorkflows.cjs +13 -11
- package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
- package/dist/server/handlers/legacyWorkflows.js +3 -1
- package/dist/server/handlers/legacyWorkflows.js.map +1 -0
- package/dist/server/handlers/logs.cjs +6 -4
- package/dist/server/handlers/logs.cjs.map +1 -0
- package/dist/server/handlers/logs.d.ts +34 -3
- package/dist/server/handlers/logs.d.ts.map +1 -0
- package/dist/server/handlers/logs.js +3 -1
- package/dist/server/handlers/logs.js.map +1 -0
- package/dist/server/handlers/memory.cjs +39 -9
- package/dist/server/handlers/memory.cjs.map +1 -0
- package/dist/server/handlers/memory.d.ts +119 -8
- package/dist/server/handlers/memory.d.ts.map +1 -0
- package/dist/server/handlers/memory.js +3 -1
- package/dist/server/handlers/memory.js.map +1 -0
- package/dist/server/handlers/network.cjs +7 -5
- package/dist/server/handlers/network.cjs.map +1 -0
- package/dist/server/handlers/network.d.ts +50 -4
- package/dist/server/handlers/network.d.ts.map +1 -0
- package/dist/server/handlers/network.js +3 -1
- package/dist/server/handlers/network.js.map +1 -0
- package/dist/server/handlers/scores.cjs +32 -0
- package/dist/server/handlers/scores.cjs.map +1 -0
- package/dist/server/handlers/scores.d.ts +49 -0
- package/dist/server/handlers/scores.d.ts.map +1 -0
- package/dist/server/handlers/scores.js +3 -0
- package/dist/server/handlers/scores.js.map +1 -0
- package/dist/server/handlers/telemetry.cjs +5 -3
- package/dist/server/handlers/telemetry.cjs.map +1 -0
- package/dist/server/handlers/telemetry.d.ts +32 -2
- package/dist/server/handlers/telemetry.d.ts.map +1 -0
- package/dist/server/handlers/telemetry.js +3 -1
- package/dist/server/handlers/telemetry.js.map +1 -0
- package/dist/server/handlers/tools.cjs +7 -5
- package/dist/server/handlers/tools.cjs.map +1 -0
- package/dist/server/handlers/tools.d.ts +21 -4
- package/dist/server/handlers/tools.d.ts.map +1 -0
- package/dist/server/handlers/tools.js +3 -1
- package/dist/server/handlers/tools.js.map +1 -0
- package/dist/server/handlers/utils.cjs +4 -2
- package/dist/server/handlers/utils.cjs.map +1 -0
- package/dist/server/handlers/utils.d.ts +2 -1
- package/dist/server/handlers/utils.d.ts.map +1 -0
- package/dist/server/handlers/utils.js +3 -1
- package/dist/server/handlers/utils.js.map +1 -0
- package/dist/server/handlers/vNextNetwork.cjs +25 -23
- package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
- package/dist/server/handlers/vNextNetwork.d.ts +179 -6
- package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
- package/dist/server/handlers/vNextNetwork.js +6 -4
- package/dist/server/handlers/vNextNetwork.js.map +1 -0
- package/dist/server/handlers/vector.cjs +9 -7
- package/dist/server/handlers/vector.cjs.map +1 -0
- package/dist/server/handlers/vector.d.ts +51 -6
- package/dist/server/handlers/vector.d.ts.map +1 -0
- package/dist/server/handlers/vector.js +3 -1
- package/dist/server/handlers/vector.js.map +1 -0
- package/dist/server/handlers/voice.cjs +7 -5
- package/dist/server/handlers/voice.cjs.map +1 -0
- package/dist/server/handlers/voice.d.ts +39 -4
- package/dist/server/handlers/voice.d.ts.map +1 -0
- package/dist/server/handlers/voice.js +3 -1
- package/dist/server/handlers/voice.js.map +1 -0
- package/dist/server/handlers/workflows.cjs +24 -14
- package/dist/server/handlers/workflows.cjs.map +1 -0
- package/dist/server/handlers/workflows.d.ts +88 -13
- package/dist/server/handlers/workflows.d.ts.map +1 -0
- package/dist/server/handlers/workflows.js +3 -1
- package/dist/server/handlers/workflows.js.map +1 -0
- package/dist/server/handlers.cjs +32 -25
- package/dist/server/handlers.cjs.map +1 -0
- package/dist/server/handlers.d.ts +13 -11
- package/dist/server/handlers.d.ts.map +1 -0
- package/dist/server/handlers.js +14 -11
- package/dist/server/handlers.js.map +1 -0
- package/dist/server/http-exception.d.ts +87 -0
- package/dist/server/http-exception.d.ts.map +1 -0
- package/dist/server/types.d.ts +10 -0
- package/dist/server/types.d.ts.map +1 -0
- package/package.json +12 -10
- package/dist/_tsup-dts-rollup.d.cts +0 -1068
- package/dist/_tsup-dts-rollup.d.ts +0 -1068
- package/dist/chunk-3DKDT264.cjs +0 -251
- package/dist/chunk-LTJNMM2Y.js +0 -241
- package/dist/chunk-MTR2B27E.cjs +0 -14
- package/dist/index.d.cts +0 -1
- package/dist/server/handlers/a2a.d.cts +0 -6
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/telemetry.d.cts +0 -2
- package/dist/server/handlers/tools.d.cts +0 -4
- package/dist/server/handlers/utils.d.cts +0 -1
- package/dist/server/handlers/vNextNetwork.d.cts +0 -6
- package/dist/server/handlers/vector.d.cts +0 -6
- package/dist/server/handlers/voice.d.cts +0 -4
- package/dist/server/handlers/workflows.d.cts +0 -13
- package/dist/server/handlers.d.cts +0 -11
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkLRUH33B4_cjs = require('./chunk-LRUH33B4.cjs');
|
|
4
|
+
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
5
|
+
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
6
|
+
var chunkQ7SFCCGT_cjs = require('./chunk-Q7SFCCGT.cjs');
|
|
7
7
|
var web = require('stream/web');
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/workflows.ts
|
|
10
10
|
var workflows_exports = {};
|
|
11
|
-
|
|
11
|
+
chunkQ7SFCCGT_cjs.__export(workflows_exports, {
|
|
12
12
|
cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
|
|
13
13
|
createWorkflowRunHandler: () => createWorkflowRunHandler,
|
|
14
14
|
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
@@ -18,8 +18,10 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
|
|
|
18
18
|
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
19
19
|
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
20
20
|
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
21
|
+
sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
|
|
21
22
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
22
23
|
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
24
|
+
streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
|
|
23
25
|
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
24
26
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
25
27
|
});
|
|
@@ -29,10 +31,10 @@ function getSteps(steps, path) {
|
|
|
29
31
|
acc[fullKey] = {
|
|
30
32
|
id: step.id,
|
|
31
33
|
description: step.description,
|
|
32
|
-
inputSchema: step.inputSchema ?
|
|
33
|
-
outputSchema: step.outputSchema ?
|
|
34
|
-
resumeSchema: step.resumeSchema ?
|
|
35
|
-
suspendSchema: step.suspendSchema ?
|
|
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,
|
|
36
38
|
isWorkflow: step.component === "WORKFLOW"
|
|
37
39
|
};
|
|
38
40
|
if (step.component === "WORKFLOW" && step.steps) {
|
|
@@ -53,29 +55,29 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
53
55
|
acc2[key2] = {
|
|
54
56
|
id: step.id,
|
|
55
57
|
description: step.description,
|
|
56
|
-
inputSchema: step.inputSchema ?
|
|
57
|
-
outputSchema: step.outputSchema ?
|
|
58
|
-
resumeSchema: step.resumeSchema ?
|
|
59
|
-
suspendSchema: step.suspendSchema ?
|
|
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
|
|
60
62
|
};
|
|
61
63
|
return acc2;
|
|
62
64
|
}, {}),
|
|
63
65
|
allSteps: getSteps(workflow.steps) || {},
|
|
64
66
|
stepGraph: workflow.serializedStepGraph,
|
|
65
|
-
inputSchema: workflow.inputSchema ?
|
|
66
|
-
outputSchema: workflow.outputSchema ?
|
|
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
|
|
67
69
|
};
|
|
68
70
|
return acc;
|
|
69
71
|
}, {});
|
|
70
72
|
return _workflows;
|
|
71
73
|
} catch (error) {
|
|
72
|
-
return
|
|
74
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflows");
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
76
78
|
const logger = mastra.getLogger();
|
|
77
79
|
if (!workflowId) {
|
|
78
|
-
throw new
|
|
80
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
79
81
|
}
|
|
80
82
|
let workflow;
|
|
81
83
|
try {
|
|
@@ -102,28 +104,28 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
|
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
if (!workflow) {
|
|
105
|
-
throw new
|
|
107
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
106
108
|
}
|
|
107
109
|
return { workflow };
|
|
108
110
|
}
|
|
109
111
|
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
110
112
|
try {
|
|
111
113
|
if (!workflowId) {
|
|
112
|
-
throw new
|
|
114
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
113
115
|
}
|
|
114
116
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
115
117
|
if (!workflow) {
|
|
116
|
-
throw new
|
|
118
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
117
119
|
}
|
|
118
120
|
return {
|
|
119
121
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
120
122
|
acc[key] = {
|
|
121
123
|
id: step.id,
|
|
122
124
|
description: step.description,
|
|
123
|
-
inputSchema: step.inputSchema ?
|
|
124
|
-
outputSchema: step.outputSchema ?
|
|
125
|
-
resumeSchema: step.resumeSchema ?
|
|
126
|
-
suspendSchema: step.suspendSchema ?
|
|
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
|
|
127
129
|
};
|
|
128
130
|
return acc;
|
|
129
131
|
}, {}),
|
|
@@ -131,11 +133,11 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
131
133
|
name: workflow.name,
|
|
132
134
|
description: workflow.description,
|
|
133
135
|
stepGraph: workflow.serializedStepGraph,
|
|
134
|
-
inputSchema: workflow.inputSchema ?
|
|
135
|
-
outputSchema: workflow.outputSchema ?
|
|
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
|
|
136
138
|
};
|
|
137
139
|
} catch (error) {
|
|
138
|
-
return
|
|
140
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow");
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
async function getWorkflowRunByIdHandler({
|
|
@@ -145,22 +147,22 @@ async function getWorkflowRunByIdHandler({
|
|
|
145
147
|
}) {
|
|
146
148
|
try {
|
|
147
149
|
if (!workflowId) {
|
|
148
|
-
throw new
|
|
150
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
149
151
|
}
|
|
150
152
|
if (!runId) {
|
|
151
|
-
throw new
|
|
153
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
152
154
|
}
|
|
153
155
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
154
156
|
if (!workflow) {
|
|
155
|
-
throw new
|
|
157
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
156
158
|
}
|
|
157
159
|
const run = await workflow.getWorkflowRunById(runId);
|
|
158
160
|
if (!run) {
|
|
159
|
-
throw new
|
|
161
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
160
162
|
}
|
|
161
163
|
return run;
|
|
162
164
|
} catch (error) {
|
|
163
|
-
return
|
|
165
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow run");
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
async function getWorkflowRunExecutionResultHandler({
|
|
@@ -170,22 +172,22 @@ async function getWorkflowRunExecutionResultHandler({
|
|
|
170
172
|
}) {
|
|
171
173
|
try {
|
|
172
174
|
if (!workflowId) {
|
|
173
|
-
throw new
|
|
175
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
174
176
|
}
|
|
175
177
|
if (!runId) {
|
|
176
|
-
throw new
|
|
178
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
177
179
|
}
|
|
178
180
|
const workflow = mastra.getWorkflow(workflowId);
|
|
179
181
|
if (!workflow) {
|
|
180
|
-
throw new
|
|
182
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
181
183
|
}
|
|
182
184
|
const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
|
|
183
185
|
if (!executionResult) {
|
|
184
|
-
throw new
|
|
186
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
|
|
185
187
|
}
|
|
186
188
|
return executionResult;
|
|
187
189
|
} catch (error) {
|
|
188
|
-
return
|
|
190
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow run execution result");
|
|
189
191
|
}
|
|
190
192
|
}
|
|
191
193
|
async function createWorkflowRunHandler({
|
|
@@ -195,16 +197,16 @@ async function createWorkflowRunHandler({
|
|
|
195
197
|
}) {
|
|
196
198
|
try {
|
|
197
199
|
if (!workflowId) {
|
|
198
|
-
throw new
|
|
200
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
199
201
|
}
|
|
200
202
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
201
203
|
if (!workflow) {
|
|
202
|
-
throw new
|
|
204
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
203
205
|
}
|
|
204
206
|
const run = await workflow.createRunAsync({ runId: prevRunId });
|
|
205
207
|
return { runId: run.runId };
|
|
206
208
|
} catch (error) {
|
|
207
|
-
return
|
|
209
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error creating workflow run");
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
async function startAsyncWorkflowHandler({
|
|
@@ -216,11 +218,11 @@ async function startAsyncWorkflowHandler({
|
|
|
216
218
|
}) {
|
|
217
219
|
try {
|
|
218
220
|
if (!workflowId) {
|
|
219
|
-
throw new
|
|
221
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
220
222
|
}
|
|
221
223
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
222
224
|
if (!workflow) {
|
|
223
|
-
throw new
|
|
225
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
224
226
|
}
|
|
225
227
|
const _run = await workflow.createRunAsync({ runId });
|
|
226
228
|
const result = await _run.start({
|
|
@@ -229,7 +231,7 @@ async function startAsyncWorkflowHandler({
|
|
|
229
231
|
});
|
|
230
232
|
return result;
|
|
231
233
|
} catch (error) {
|
|
232
|
-
return
|
|
234
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error starting async workflow");
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
237
|
async function startWorkflowRunHandler({
|
|
@@ -241,18 +243,18 @@ async function startWorkflowRunHandler({
|
|
|
241
243
|
}) {
|
|
242
244
|
try {
|
|
243
245
|
if (!workflowId) {
|
|
244
|
-
throw new
|
|
246
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
245
247
|
}
|
|
246
248
|
if (!runId) {
|
|
247
|
-
throw new
|
|
249
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
248
250
|
}
|
|
249
251
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
250
252
|
if (!workflow) {
|
|
251
|
-
throw new
|
|
253
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
252
254
|
}
|
|
253
255
|
const run = await workflow.getWorkflowRunById(runId);
|
|
254
256
|
if (!run) {
|
|
255
|
-
throw new
|
|
257
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
256
258
|
}
|
|
257
259
|
const _run = await workflow.createRunAsync({ runId });
|
|
258
260
|
void _run.start({
|
|
@@ -261,7 +263,7 @@ async function startWorkflowRunHandler({
|
|
|
261
263
|
});
|
|
262
264
|
return { message: "Workflow run started" };
|
|
263
265
|
} catch (e) {
|
|
264
|
-
return
|
|
266
|
+
return chunkRE4RPXT2_cjs.handleError(e, "Error starting workflow run");
|
|
265
267
|
}
|
|
266
268
|
}
|
|
267
269
|
async function watchWorkflowHandler({
|
|
@@ -271,18 +273,18 @@ async function watchWorkflowHandler({
|
|
|
271
273
|
}) {
|
|
272
274
|
try {
|
|
273
275
|
if (!workflowId) {
|
|
274
|
-
throw new
|
|
276
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
275
277
|
}
|
|
276
278
|
if (!runId) {
|
|
277
|
-
throw new
|
|
279
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
278
280
|
}
|
|
279
281
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
280
282
|
if (!workflow) {
|
|
281
|
-
throw new
|
|
283
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
282
284
|
}
|
|
283
285
|
const run = await workflow.getWorkflowRunById(runId);
|
|
284
286
|
if (!run) {
|
|
285
|
-
throw new
|
|
287
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
286
288
|
}
|
|
287
289
|
const _run = await workflow.createRunAsync({ runId });
|
|
288
290
|
let unwatch;
|
|
@@ -310,7 +312,7 @@ async function watchWorkflowHandler({
|
|
|
310
312
|
});
|
|
311
313
|
return stream;
|
|
312
314
|
} catch (error) {
|
|
313
|
-
return
|
|
315
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error watching workflow");
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
318
|
async function streamWorkflowHandler({
|
|
@@ -322,14 +324,14 @@ async function streamWorkflowHandler({
|
|
|
322
324
|
}) {
|
|
323
325
|
try {
|
|
324
326
|
if (!workflowId) {
|
|
325
|
-
throw new
|
|
327
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
326
328
|
}
|
|
327
329
|
if (!runId) {
|
|
328
|
-
throw new
|
|
330
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
329
331
|
}
|
|
330
332
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
331
333
|
if (!workflow) {
|
|
332
|
-
throw new
|
|
334
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
333
335
|
}
|
|
334
336
|
const run = await workflow.createRunAsync({ runId });
|
|
335
337
|
const result = run.stream({
|
|
@@ -338,7 +340,35 @@ async function streamWorkflowHandler({
|
|
|
338
340
|
});
|
|
339
341
|
return result;
|
|
340
342
|
} catch (error) {
|
|
341
|
-
return
|
|
343
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error executing workflow");
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
async function streamVNextWorkflowHandler({
|
|
347
|
+
mastra,
|
|
348
|
+
runtimeContext,
|
|
349
|
+
workflowId,
|
|
350
|
+
runId,
|
|
351
|
+
inputData
|
|
352
|
+
}) {
|
|
353
|
+
try {
|
|
354
|
+
if (!workflowId) {
|
|
355
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
356
|
+
}
|
|
357
|
+
if (!runId) {
|
|
358
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to stream workflow" });
|
|
359
|
+
}
|
|
360
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
361
|
+
if (!workflow) {
|
|
362
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
363
|
+
}
|
|
364
|
+
const run = await workflow.createRunAsync({ runId });
|
|
365
|
+
const result = run.streamVNext({
|
|
366
|
+
inputData,
|
|
367
|
+
runtimeContext
|
|
368
|
+
});
|
|
369
|
+
return result;
|
|
370
|
+
} catch (error) {
|
|
371
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error streaming workflow");
|
|
342
372
|
}
|
|
343
373
|
}
|
|
344
374
|
async function resumeAsyncWorkflowHandler({
|
|
@@ -350,21 +380,21 @@ async function resumeAsyncWorkflowHandler({
|
|
|
350
380
|
}) {
|
|
351
381
|
try {
|
|
352
382
|
if (!workflowId) {
|
|
353
|
-
throw new
|
|
383
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
354
384
|
}
|
|
355
385
|
if (!runId) {
|
|
356
|
-
throw new
|
|
386
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
357
387
|
}
|
|
358
388
|
if (!body.step) {
|
|
359
|
-
throw new
|
|
389
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
360
390
|
}
|
|
361
391
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
362
392
|
if (!workflow) {
|
|
363
|
-
throw new
|
|
393
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
364
394
|
}
|
|
365
395
|
const run = await workflow.getWorkflowRunById(runId);
|
|
366
396
|
if (!run) {
|
|
367
|
-
throw new
|
|
397
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
368
398
|
}
|
|
369
399
|
const _run = await workflow.createRunAsync({ runId });
|
|
370
400
|
const result = await _run.resume({
|
|
@@ -374,7 +404,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
374
404
|
});
|
|
375
405
|
return result;
|
|
376
406
|
} catch (error) {
|
|
377
|
-
return
|
|
407
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow step");
|
|
378
408
|
}
|
|
379
409
|
}
|
|
380
410
|
async function resumeWorkflowHandler({
|
|
@@ -386,21 +416,21 @@ async function resumeWorkflowHandler({
|
|
|
386
416
|
}) {
|
|
387
417
|
try {
|
|
388
418
|
if (!workflowId) {
|
|
389
|
-
throw new
|
|
419
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
390
420
|
}
|
|
391
421
|
if (!runId) {
|
|
392
|
-
throw new
|
|
422
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
393
423
|
}
|
|
394
424
|
if (!body.step) {
|
|
395
|
-
throw new
|
|
425
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
396
426
|
}
|
|
397
427
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
398
428
|
if (!workflow) {
|
|
399
|
-
throw new
|
|
429
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
400
430
|
}
|
|
401
431
|
const run = await workflow.getWorkflowRunById(runId);
|
|
402
432
|
if (!run) {
|
|
403
|
-
throw new
|
|
433
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
404
434
|
}
|
|
405
435
|
const _run = await workflow.createRunAsync({ runId });
|
|
406
436
|
void _run.resume({
|
|
@@ -410,7 +440,7 @@ async function resumeWorkflowHandler({
|
|
|
410
440
|
});
|
|
411
441
|
return { message: "Workflow run resumed" };
|
|
412
442
|
} catch (error) {
|
|
413
|
-
return
|
|
443
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
|
|
414
444
|
}
|
|
415
445
|
}
|
|
416
446
|
async function getWorkflowRunsHandler({
|
|
@@ -424,11 +454,11 @@ async function getWorkflowRunsHandler({
|
|
|
424
454
|
}) {
|
|
425
455
|
try {
|
|
426
456
|
if (!workflowId) {
|
|
427
|
-
throw new
|
|
457
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
428
458
|
}
|
|
429
459
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
430
460
|
if (!workflow) {
|
|
431
|
-
throw new
|
|
461
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
432
462
|
}
|
|
433
463
|
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
434
464
|
runs: [],
|
|
@@ -436,7 +466,7 @@ async function getWorkflowRunsHandler({
|
|
|
436
466
|
};
|
|
437
467
|
return workflowRuns;
|
|
438
468
|
} catch (error) {
|
|
439
|
-
return
|
|
469
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow runs");
|
|
440
470
|
}
|
|
441
471
|
}
|
|
442
472
|
async function cancelWorkflowRunHandler({
|
|
@@ -446,24 +476,53 @@ async function cancelWorkflowRunHandler({
|
|
|
446
476
|
}) {
|
|
447
477
|
try {
|
|
448
478
|
if (!workflowId) {
|
|
449
|
-
throw new
|
|
479
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
450
480
|
}
|
|
451
481
|
if (!runId) {
|
|
452
|
-
throw new
|
|
482
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
|
|
453
483
|
}
|
|
454
484
|
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
455
485
|
if (!workflow) {
|
|
456
|
-
throw new
|
|
486
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
457
487
|
}
|
|
458
488
|
const run = await workflow.getWorkflowRunById(runId);
|
|
459
489
|
if (!run) {
|
|
460
|
-
throw new
|
|
490
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
461
491
|
}
|
|
462
492
|
const _run = await workflow.createRunAsync({ runId });
|
|
463
493
|
await _run.cancel();
|
|
464
494
|
return { message: "Workflow run cancelled" };
|
|
465
495
|
} catch (error) {
|
|
466
|
-
return
|
|
496
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error canceling workflow run");
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
async function sendWorkflowRunEventHandler({
|
|
500
|
+
mastra,
|
|
501
|
+
workflowId,
|
|
502
|
+
runId,
|
|
503
|
+
event,
|
|
504
|
+
data
|
|
505
|
+
}) {
|
|
506
|
+
try {
|
|
507
|
+
if (!workflowId) {
|
|
508
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
509
|
+
}
|
|
510
|
+
if (!runId) {
|
|
511
|
+
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
|
|
512
|
+
}
|
|
513
|
+
const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
|
|
514
|
+
if (!workflow) {
|
|
515
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
516
|
+
}
|
|
517
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
518
|
+
if (!run) {
|
|
519
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
520
|
+
}
|
|
521
|
+
const _run = await workflow.createRunAsync({ runId });
|
|
522
|
+
await _run.sendEvent(event, data);
|
|
523
|
+
return { message: "Workflow run event sent" };
|
|
524
|
+
} catch (error) {
|
|
525
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error sending workflow run event");
|
|
467
526
|
}
|
|
468
527
|
}
|
|
469
528
|
|
|
@@ -476,8 +535,12 @@ exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
|
476
535
|
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
477
536
|
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
478
537
|
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
538
|
+
exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
|
|
479
539
|
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
480
540
|
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
541
|
+
exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
|
|
481
542
|
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
482
543
|
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
483
544
|
exports.workflows_exports = workflows_exports;
|
|
545
|
+
//# sourceMappingURL=chunk-S37KCGOR.cjs.map
|
|
546
|
+
//# sourceMappingURL=chunk-S37KCGOR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","stringify","esm_default","acc","key","handleError","HTTPException","ReadableStream"],"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;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,0BAAA,EAAA,MAAA,0BAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,oBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAeA,SAAS,QAAA,CAAS,OAA0C,IAAA,EAAe;AACzE,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CAAE,MAAA,CAAY,CAAC,GAAA,EAAK,CAAC,GAAA,EAAK,IAAI,CAAA,KAAM;AAC7D,IAAA,MAAM,UAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,GAAK,GAAA;AAC1C,IAAA,GAAA,CAAI,OAAO,CAAA,GAAI;AAAA,MACb,IAAI,IAAA,CAAK,EAAA;AAAA,MACT,aAAa,IAAA,CAAK,WAAA;AAAA,MAClB,WAAA,EAAa,KAAK,WAAA,GAAcC,2BAAA,CAAUC,8BAAgB,IAAA,C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MAAM,GAAA,GAAM,MAAM,QAAA,CAAS,kBAAA,CAAmB,KAAK,CAAA;AAEnD,IAAA,IAAI,CAAC,GAAA,EAAK;AACR,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,IACpE;AAEA,IAAA,MAAM,OAAO,MAAM,QAAA,CAAS,cAAA,CAAe,EAAE,OAAO,CAAA;AAEpD,IAAA,MAAM,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,IAAI,CAAA;AAEhC,IAAA,OAAO,EAAE,SAAS,yBAAA,EAA0B;AAAA,EAC9C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,kCAAkC,CAAA;AAAA,EAC9D;AACF","file":"chunk-S37KCGOR.cjs","sourcesContent":["import { ReadableStream } from 'node:stream/web';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport type { Workflow, SerializedStepFlowEntry, WatchEvent, StepWithComponent } from '@mastra/core/workflows';\nimport { stringify } from 'superjson';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nfunction getSteps(steps: Record<string, StepWithComponent>, path?: string) {\n return Object.entries(steps).reduce<any>((acc, [key, step]) => {\n const fullKey = path ? `${path}.${key}` : key;\n acc[fullKey] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n isWorkflow: step.component === 'WORKFLOW',\n };\n\n if (step.component === 'WORKFLOW' && step.steps) {\n const nestedSteps = getSteps(step.steps, fullKey) || {};\n acc = { ...acc, ...nestedSteps };\n }\n\n return acc;\n }, {});\n}\n\nexport async function getWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<any>((acc, [key, workflow]) => {\n acc[key] = {\n name: workflow.name,\n description: workflow.description,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n acc[key] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n };\n return acc;\n }, {}),\n allSteps: getSteps(workflow.steps) || {},\n stepGraph: workflow.serializedStepGraph,\n inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : undefined,\n outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : undefined,\n };\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n}\n\ntype SerializedStep = {\n id: string;\n description: string;\n inputSchema: string | undefined;\n outputSchema: string | undefined;\n resumeSchema: string | undefined;\n suspendSchema: string | undefined;\n};\n\nasync function getWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n try {\n workflow = mastra.getWorkflow(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.getAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.getWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\nexport async function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<{\n steps: Record<string, SerializedStep>;\n allSteps: Record<string, SerializedStep>;\n name: string | undefined;\n description: string | undefined;\n stepGraph: SerializedStepFlowEntry[];\n inputSchema: string | undefined;\n outputSchema: string | undefined;\n}> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return {\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n acc[key] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n };\n return acc;\n }, {}),\n allSteps: getSteps(workflow.steps) || {},\n name: workflow.name,\n description: workflow.description,\n stepGraph: workflow.serializedStepGraph,\n inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : undefined,\n outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : undefined,\n };\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n}\n\nexport async function getWorkflowRunByIdHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n}\n\nexport async function getWorkflowRunExecutionResultHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const workflow = mastra.getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId);\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n}\n\nexport async function createWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId: prevRunId });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n}\n\nexport async function startAsyncWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.start({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n}\n\nexport async function startWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n void _run.start({\n inputData,\n runtimeContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream<string>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to watch workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = _run.watch(({ type, payload, eventTimestamp }) => {\n controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = payload.workflowState.status !== 'running';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n });\n },\n cancel() {\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function streamWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.streamVNext({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n}\n\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<WorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const workflowRuns = (await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n\nexport async function cancelWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n}\n\nexport async function sendWorkflowRunEventHandler({\n mastra,\n workflowId,\n runId,\n event,\n data,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n event: string;\n data: unknown;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to send workflow run event' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.sendEvent(event, data);\n\n return { message: 'Workflow run event sent' };\n } catch (error) {\n return handleError(error, 'Error sending workflow run event');\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { handleError } from './chunk-
|
|
2
|
-
import { HTTPException } from './chunk-
|
|
3
|
-
import { __export } from './chunk-
|
|
1
|
+
import { handleError } from './chunk-CY4TP3FK.js';
|
|
2
|
+
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
3
|
+
import { __export } from './chunk-PZ5AY32C.js';
|
|
4
4
|
|
|
5
5
|
// src/server/handlers/telemetry.ts
|
|
6
6
|
var telemetry_exports = {};
|
|
@@ -139,3 +139,5 @@ async function storeTelemetryHandler({ mastra, body }) {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
export { getTelemetryHandler, storeTelemetryHandler, telemetry_exports };
|
|
142
|
+
//# sourceMappingURL=chunk-SQ7KKIH3.js.map
|
|
143
|
+
//# sourceMappingURL=chunk-SQ7KKIH3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/telemetry.ts"],"names":["error","acc"],"mappings":";;;;;AAAA,IAAA,iBAAA,GAAA;AAAA,QAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,qBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAiBA,eAAsB,mBAAA,CAAoB,EAAE,MAAA,EAAQ,IAAA,EAAK,EAAqB;AAC5E,EAAA,IAAI;AACF,IAAA,MAAM,SAAA,GAAY,OAAO,YAAA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;AAAA,IACT,CAAA,EAAG,EAAE,CAAA;AAEL,IAAA,OAAO,QACJ,gBAAA,CAAiB;AAAA,MAChB,OAAA,EAAS;AAAA,KACV,CAAA,CACA,IAAA,CAAK,MAAM;AACV,MAAA,OAAO;AAAA,QACL,MAAA,EAAQ,SAAA;AAAA,QACR,OAAA,EAAS,4CAAA;AAAA,QACT,UAAA,EAAY,IAAA,CAAK,aAAA,EAAe,MAAA,IAAU;AAAA,OAC5C;AAAA,IACF,CAAC,CAAA,CACA,KAAA,CAAM,MAAM;AACX,MAAA,OAAO;AAAA,QACL,MAAA,EAAQ,OAAA;AAAA,QACR,OAAA,EAAS,0BAAA;AAAA;AAAA,QAET,OAAO,KAAA,CAAM;AAAA,OACf;AAAA,IACF,CAAC,CAAA;AAAA,EAGL,SAASD,MAAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA,CAAM,4BAA4BA,MAAK,CAAA;AAC/C,IAAA,OAAO;AAAA,MACL,MAAA,EAAQ,OAAA;AAAA,MACR,OAAA,EAAS,0BAAA;AAAA;AAAA,MAET,OAAOA,MAAAA,CAAM;AAAA,KACf;AAAA,EACF;AACF","file":"chunk-SQ7KKIH3.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\n\ninterface TelemetryContext extends Context {\n body?: {\n name?: string;\n scope?: string;\n page?: number;\n perPage?: number;\n attribute?: string | string[];\n fromDate?: Date;\n toDate?: Date;\n };\n}\n\nexport async function getTelemetryHandler({ mastra, body }: TelemetryContext) {\n try {\n const telemetry = mastra.getTelemetry();\n const storage = mastra.getStorage();\n\n if (!telemetry) {\n throw new HTTPException(400, { message: 'Telemetry is not initialized' });\n }\n\n if (!storage) {\n return [];\n }\n\n if (!body) {\n throw new HTTPException(400, { message: 'Body is required' });\n }\n\n const { name, scope, page, perPage, attribute, fromDate, toDate } = body;\n\n // Parse attribute query parameter if present\n const attributes = attribute\n ? Object.fromEntries(\n (Array.isArray(attribute) ? attribute : [attribute]).map(attr => {\n const [key, value] = attr.split(':');\n return [key, value];\n }),\n )\n : undefined;\n\n const traces = await storage.getTraces({\n name,\n scope,\n page: Number(page ?? 0),\n perPage: Number(perPage ?? 100),\n attributes,\n fromDate: fromDate ? new Date(fromDate) : undefined,\n toDate: toDate ? new Date(toDate) : undefined,\n });\n\n return traces;\n } catch (error) {\n return handleError(error, 'Error getting telemetry');\n }\n}\n\nexport async function storeTelemetryHandler({ mastra, body }: Context & { body: { resourceSpans: any[] } }) {\n try {\n const storage = mastra.getStorage();\n const logger = mastra.getLogger();\n\n if (!storage) {\n return {\n status: 'error',\n message: 'Storage is not initialized',\n };\n }\n\n const now = new Date();\n\n const items = body?.resourceSpans?.[0]?.scopeSpans;\n logger.debug('[Telemetry Handler] Received spans:', {\n totalSpans: items?.reduce((acc: number, scope: { spans: any[] }) => acc + scope.spans.length, 0) || 0,\n timestamp: now.toISOString(),\n });\n if (!items?.length) {\n return {\n status: 'success',\n message: 'No spans to process',\n traceCount: 0,\n };\n }\n\n const allSpans: any[] = items.reduce((acc: any, scopedSpans: any) => {\n const { scope, spans } = scopedSpans;\n for (const span of spans) {\n const {\n spanId,\n parentSpanId,\n traceId,\n name,\n kind,\n attributes,\n status,\n events,\n links,\n startTimeUnixNano,\n endTimeUnixNano,\n ...rest\n } = span;\n\n const startTime = Number(BigInt(startTimeUnixNano) / 1000n);\n const endTime = Number(BigInt(endTimeUnixNano) / 1000n);\n\n acc.push({\n id: spanId,\n parentSpanId,\n traceId,\n name,\n scope: scope.name,\n kind,\n status: JSON.stringify(status),\n events: JSON.stringify(events),\n links: JSON.stringify(links),\n attributes: JSON.stringify(\n attributes.reduce((acc: Record<string, any>, attr: any) => {\n const valueKey = Object.keys(attr.value)[0];\n if (valueKey) {\n acc[attr.key] = attr.value[valueKey];\n }\n return acc;\n }, {}),\n ),\n startTime,\n endTime,\n other: JSON.stringify(rest),\n createdAt: now,\n });\n }\n return acc;\n }, []);\n\n return storage\n .batchTraceInsert({\n records: allSpans,\n })\n .then(() => {\n return {\n status: 'success',\n message: 'Traces received and processed successfully',\n traceCount: body.resourceSpans?.length || 0,\n };\n })\n .catch(() => {\n return {\n status: 'error',\n message: 'Failed to process traces',\n // @ts-ignore\n error: error.message,\n };\n });\n\n // Return a simple response\n } catch (error) {\n console.error('Error processing traces:', error);\n return {\n status: 'error',\n message: 'Failed to process traces',\n // @ts-ignore\n error: error.message,\n };\n }\n}\n"]}
|