@mastra/server 0.0.0-mcp-server-deploy-20250507160341 → 0.0.0-mcp-changeset-20250707162621
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/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +523 -193
- package/dist/_tsup-dts-rollup.d.ts +523 -193
- package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
- package/dist/{chunk-5YGDYMRB.cjs → chunk-2SLFAFTR.cjs} +14 -13
- package/dist/chunk-4D66QEKC.js +81 -0
- package/dist/{chunk-3XTEV33Q.js → chunk-5PQQ42EZ.js} +59 -56
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
- package/dist/chunk-B2PAS2IB.cjs +514 -0
- package/dist/{chunk-Y3SV5XK4.js → chunk-BK4XT6EG.js} +105 -16
- package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-QJ3AHN64.js → chunk-CRCR3ZUK.js} +4 -3
- package/dist/{chunk-2FJURXCL.cjs → chunk-DN7K6FJK.cjs} +93 -55
- package/dist/{chunk-D3G23FP3.cjs → chunk-FRVBFMO2.cjs} +24 -22
- package/dist/{chunk-AMVOS7YB.cjs → chunk-G7KH752Y.cjs} +12 -8
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-H7DMHBKY.js +498 -0
- package/dist/chunk-JMLYCXMK.cjs +332 -0
- package/dist/{chunk-Q6SHQECN.js → chunk-KHZKYUNR.js} +34 -10
- package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/chunk-LI436ITD.cjs +2042 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-LRCAAFUA.js} +7 -5
- package/dist/chunk-LZ3VJXSO.cjs +278 -0
- package/dist/chunk-MEGCYGBU.js +2039 -0
- package/dist/{chunk-RBQASTUP.js → chunk-MKLYEKEF.js} +63 -25
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/chunk-QGX47B5D.cjs +86 -0
- package/dist/{chunk-BPL2CBLV.js → chunk-RG473F6Y.js} +8 -4
- package/dist/chunk-RHSWAXKB.cjs +118 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
- package/dist/index.cjs +0 -12
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vNextNetwork.cjs +218 -0
- package/dist/server/handlers/vNextNetwork.d.cts +6 -0
- package/dist/server/handlers/vNextNetwork.d.ts +6 -0
- package/dist/server/handlers/vNextNetwork.js +211 -0
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -4
- package/dist/server/handlers/voice.d.cts +1 -0
- package/dist/server/handlers/voice.d.ts +1 -0
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +29 -13
- package/dist/server/handlers/workflows.d.cts +6 -2
- package/dist/server/handlers/workflows.d.ts +6 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +31 -26
- package/dist/server/handlers.d.cts +2 -1
- package/dist/server/handlers.d.ts +2 -1
- package/dist/server/handlers.js +11 -10
- package/package.json +14 -13
- package/dist/chunk-3AHQ5RGN.js +0 -11
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-4BIX6GMY.cjs +0 -189
- package/dist/chunk-55HTWX4C.cjs +0 -93
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-74DLDQTQ.cjs +0 -36
- package/dist/chunk-CHFORQ7J.cjs +0 -329
- package/dist/chunk-FOXHTOQZ.cjs +0 -324
- package/dist/chunk-HAA5T7JL.js +0 -33
- package/dist/chunk-IQTNZSFP.js +0 -312
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-ZLBRQFDD.cjs +0 -13
- package/dist/server/handlers/mcp.cjs +0 -14
- package/dist/server/handlers/mcp.d.cts +0 -2
- package/dist/server/handlers/mcp.d.ts +0 -2
- package/dist/server/handlers/mcp.js +0 -1
- package/dist/server/handlers/vNextWorkflows.cjs +0 -46
- package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
- package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
- package/dist/server/handlers/vNextWorkflows.js +0 -1
package/dist/chunk-74DLDQTQ.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
4
|
-
|
|
5
|
-
// src/server/handlers/mcp.ts
|
|
6
|
-
var getMcpServersHandler = async ({ mastra }) => {
|
|
7
|
-
const servers = mastra.getMCPServers();
|
|
8
|
-
return {
|
|
9
|
-
servers: servers.map((server) => ({
|
|
10
|
-
id: server.name,
|
|
11
|
-
name: server.name,
|
|
12
|
-
version: server.version,
|
|
13
|
-
tools: Object.keys(server.tools()).length
|
|
14
|
-
}))
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
var getMcpServerHandler = async ({ mastra, serverId }) => {
|
|
18
|
-
const server = mastra.getMCPServer(serverId);
|
|
19
|
-
if (!server) {
|
|
20
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: `MCP server '${serverId}' not found` });
|
|
21
|
-
}
|
|
22
|
-
const tools = server.tools();
|
|
23
|
-
return {
|
|
24
|
-
id: server.name,
|
|
25
|
-
name: server.name,
|
|
26
|
-
version: server.version,
|
|
27
|
-
tools: Object.entries(tools).map(([name, tool]) => ({
|
|
28
|
-
name,
|
|
29
|
-
description: tool.description,
|
|
30
|
-
parameters: tool.parameters
|
|
31
|
-
}))
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
exports.getMcpServerHandler = getMcpServerHandler;
|
|
36
|
-
exports.getMcpServersHandler = getMcpServersHandler;
|
package/dist/chunk-CHFORQ7J.cjs
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
|
|
4
|
-
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
5
|
-
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
6
|
-
var web = require('stream/web');
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/workflows.ts
|
|
9
|
-
var workflows_exports = {};
|
|
10
|
-
chunkFV45V6WC_cjs.__export(workflows_exports, {
|
|
11
|
-
createRunHandler: () => createRunHandler,
|
|
12
|
-
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
13
|
-
getWorkflowRunHandler: () => getWorkflowRunHandler,
|
|
14
|
-
getWorkflowRunsHandler: () => getWorkflowRunsHandler,
|
|
15
|
-
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
16
|
-
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
17
|
-
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
18
|
-
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
19
|
-
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
20
|
-
watchWorkflowHandler: () => watchWorkflowHandler
|
|
21
|
-
});
|
|
22
|
-
async function getWorkflowsHandler({ mastra }) {
|
|
23
|
-
try {
|
|
24
|
-
const workflows = mastra.getWorkflows({ serialized: false });
|
|
25
|
-
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
26
|
-
if (workflow.isNested) return acc;
|
|
27
|
-
acc[key] = {
|
|
28
|
-
stepGraph: workflow.stepGraph,
|
|
29
|
-
stepSubscriberGraph: workflow.stepSubscriberGraph,
|
|
30
|
-
serializedStepGraph: workflow.serializedStepGraph,
|
|
31
|
-
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
32
|
-
name: workflow.name,
|
|
33
|
-
triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
34
|
-
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
35
|
-
const _step = step;
|
|
36
|
-
acc2[key2] = {
|
|
37
|
-
id: _step.id,
|
|
38
|
-
description: _step.description,
|
|
39
|
-
workflowId: _step.workflowId,
|
|
40
|
-
inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
41
|
-
outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
|
|
42
|
-
};
|
|
43
|
-
return acc2;
|
|
44
|
-
}, {})
|
|
45
|
-
};
|
|
46
|
-
return acc;
|
|
47
|
-
}, {});
|
|
48
|
-
return _workflows;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
54
|
-
try {
|
|
55
|
-
if (!workflowId) {
|
|
56
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
57
|
-
}
|
|
58
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
59
|
-
if (!workflow) {
|
|
60
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
stepGraph: workflow.stepGraph,
|
|
64
|
-
stepSubscriberGraph: workflow.stepSubscriberGraph,
|
|
65
|
-
serializedStepGraph: workflow.serializedStepGraph,
|
|
66
|
-
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
67
|
-
name: workflow.name,
|
|
68
|
-
triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
69
|
-
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
70
|
-
const _step = step;
|
|
71
|
-
acc[key] = {
|
|
72
|
-
id: _step.id,
|
|
73
|
-
description: _step.description,
|
|
74
|
-
workflowId: _step.workflowId,
|
|
75
|
-
inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
76
|
-
outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
|
|
77
|
-
};
|
|
78
|
-
return acc;
|
|
79
|
-
}, {})
|
|
80
|
-
};
|
|
81
|
-
} catch (error) {
|
|
82
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async function startAsyncWorkflowHandler({
|
|
86
|
-
mastra,
|
|
87
|
-
runtimeContext,
|
|
88
|
-
workflowId,
|
|
89
|
-
runId,
|
|
90
|
-
triggerData
|
|
91
|
-
}) {
|
|
92
|
-
try {
|
|
93
|
-
if (!workflowId) {
|
|
94
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
95
|
-
}
|
|
96
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
97
|
-
if (!workflow) {
|
|
98
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
99
|
-
}
|
|
100
|
-
if (!runId) {
|
|
101
|
-
const { start } = workflow.createRun();
|
|
102
|
-
const result2 = await start({
|
|
103
|
-
triggerData,
|
|
104
|
-
runtimeContext
|
|
105
|
-
});
|
|
106
|
-
return result2;
|
|
107
|
-
}
|
|
108
|
-
const run = workflow.getRun(runId);
|
|
109
|
-
if (!run) {
|
|
110
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
111
|
-
}
|
|
112
|
-
const result = await run.start({
|
|
113
|
-
triggerData,
|
|
114
|
-
runtimeContext
|
|
115
|
-
});
|
|
116
|
-
return result;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async function getWorkflowRunHandler({
|
|
122
|
-
mastra,
|
|
123
|
-
workflowId,
|
|
124
|
-
runId
|
|
125
|
-
}) {
|
|
126
|
-
try {
|
|
127
|
-
if (!workflowId) {
|
|
128
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
129
|
-
}
|
|
130
|
-
if (!runId) {
|
|
131
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
132
|
-
}
|
|
133
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
134
|
-
if (!workflow) {
|
|
135
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
136
|
-
}
|
|
137
|
-
const run = workflow.getRun(runId);
|
|
138
|
-
if (!run) {
|
|
139
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
140
|
-
}
|
|
141
|
-
return run;
|
|
142
|
-
} catch (error) {
|
|
143
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
async function createRunHandler({
|
|
147
|
-
mastra,
|
|
148
|
-
workflowId,
|
|
149
|
-
runId: prevRunId
|
|
150
|
-
}) {
|
|
151
|
-
try {
|
|
152
|
-
if (!workflowId) {
|
|
153
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
154
|
-
}
|
|
155
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
156
|
-
if (!workflow) {
|
|
157
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
158
|
-
}
|
|
159
|
-
const { runId } = workflow.createRun({ runId: prevRunId });
|
|
160
|
-
return { runId };
|
|
161
|
-
} catch (error) {
|
|
162
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function startWorkflowRunHandler({
|
|
166
|
-
mastra,
|
|
167
|
-
runtimeContext,
|
|
168
|
-
workflowId,
|
|
169
|
-
runId,
|
|
170
|
-
triggerData
|
|
171
|
-
}) {
|
|
172
|
-
try {
|
|
173
|
-
if (!workflowId) {
|
|
174
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
175
|
-
}
|
|
176
|
-
if (!runId) {
|
|
177
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
178
|
-
}
|
|
179
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
180
|
-
const run = workflow.getRun(runId);
|
|
181
|
-
if (!run) {
|
|
182
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
183
|
-
}
|
|
184
|
-
await run.start({
|
|
185
|
-
triggerData,
|
|
186
|
-
runtimeContext
|
|
187
|
-
});
|
|
188
|
-
return { message: "Workflow run started" };
|
|
189
|
-
} catch (e) {
|
|
190
|
-
return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
async function watchWorkflowHandler({
|
|
194
|
-
mastra,
|
|
195
|
-
workflowId,
|
|
196
|
-
runId
|
|
197
|
-
}) {
|
|
198
|
-
try {
|
|
199
|
-
if (!workflowId) {
|
|
200
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
201
|
-
}
|
|
202
|
-
if (!runId) {
|
|
203
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
204
|
-
}
|
|
205
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
206
|
-
const run = workflow.getRun(runId);
|
|
207
|
-
if (!run) {
|
|
208
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
209
|
-
}
|
|
210
|
-
let unwatch;
|
|
211
|
-
let asyncRef = null;
|
|
212
|
-
const stream = new web.ReadableStream({
|
|
213
|
-
start(controller) {
|
|
214
|
-
unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
|
|
215
|
-
const activePathsObj = Object.fromEntries(activePaths);
|
|
216
|
-
controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
|
|
217
|
-
if (asyncRef) {
|
|
218
|
-
clearImmediate(asyncRef);
|
|
219
|
-
asyncRef = null;
|
|
220
|
-
}
|
|
221
|
-
asyncRef = setImmediate(() => {
|
|
222
|
-
if (!workflow.getRun(runId2)) {
|
|
223
|
-
controller.close();
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
cancel() {
|
|
229
|
-
unwatch?.();
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
return stream;
|
|
233
|
-
} catch (error) {
|
|
234
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
async function resumeAsyncWorkflowHandler({
|
|
238
|
-
mastra,
|
|
239
|
-
workflowId,
|
|
240
|
-
runId,
|
|
241
|
-
body,
|
|
242
|
-
runtimeContext
|
|
243
|
-
}) {
|
|
244
|
-
try {
|
|
245
|
-
if (!workflowId) {
|
|
246
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
247
|
-
}
|
|
248
|
-
if (!runId) {
|
|
249
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
250
|
-
}
|
|
251
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
252
|
-
const run = workflow.getRun(runId);
|
|
253
|
-
if (!run) {
|
|
254
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
255
|
-
}
|
|
256
|
-
const result = await run.resume({
|
|
257
|
-
stepId: body.stepId,
|
|
258
|
-
context: body.context,
|
|
259
|
-
runtimeContext
|
|
260
|
-
});
|
|
261
|
-
return result;
|
|
262
|
-
} catch (error) {
|
|
263
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
async function resumeWorkflowHandler({
|
|
267
|
-
mastra,
|
|
268
|
-
workflowId,
|
|
269
|
-
runId,
|
|
270
|
-
body,
|
|
271
|
-
runtimeContext
|
|
272
|
-
}) {
|
|
273
|
-
try {
|
|
274
|
-
if (!workflowId) {
|
|
275
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
276
|
-
}
|
|
277
|
-
if (!runId) {
|
|
278
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
279
|
-
}
|
|
280
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
281
|
-
const run = workflow.getRun(runId);
|
|
282
|
-
if (!run) {
|
|
283
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
284
|
-
}
|
|
285
|
-
await run.resume({
|
|
286
|
-
stepId: body.stepId,
|
|
287
|
-
context: body.context,
|
|
288
|
-
runtimeContext
|
|
289
|
-
});
|
|
290
|
-
return { message: "Workflow run resumed" };
|
|
291
|
-
} catch (error) {
|
|
292
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
async function getWorkflowRunsHandler({
|
|
296
|
-
mastra,
|
|
297
|
-
workflowId,
|
|
298
|
-
fromDate,
|
|
299
|
-
toDate,
|
|
300
|
-
limit,
|
|
301
|
-
offset,
|
|
302
|
-
resourceId
|
|
303
|
-
}) {
|
|
304
|
-
try {
|
|
305
|
-
if (!workflowId) {
|
|
306
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
307
|
-
}
|
|
308
|
-
const workflow = mastra.getWorkflow(workflowId);
|
|
309
|
-
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
310
|
-
runs: [],
|
|
311
|
-
total: 0
|
|
312
|
-
};
|
|
313
|
-
return workflowRuns;
|
|
314
|
-
} catch (error) {
|
|
315
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
exports.createRunHandler = createRunHandler;
|
|
320
|
-
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
321
|
-
exports.getWorkflowRunHandler = getWorkflowRunHandler;
|
|
322
|
-
exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
|
|
323
|
-
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
324
|
-
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
325
|
-
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
326
|
-
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
327
|
-
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
328
|
-
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
329
|
-
exports.workflows_exports = workflows_exports;
|
package/dist/chunk-FOXHTOQZ.cjs
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
|
|
4
|
-
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
5
|
-
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
6
|
-
var web = require('stream/web');
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/vNextWorkflows.ts
|
|
9
|
-
var vNextWorkflows_exports = {};
|
|
10
|
-
chunkFV45V6WC_cjs.__export(vNextWorkflows_exports, {
|
|
11
|
-
createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
|
|
12
|
-
getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
|
|
13
|
-
getVNextWorkflowRunHandler: () => getVNextWorkflowRunHandler,
|
|
14
|
-
getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
|
|
15
|
-
getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
|
|
16
|
-
resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
|
|
17
|
-
resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
|
|
18
|
-
startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
|
|
19
|
-
startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
|
|
20
|
-
watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
|
|
21
|
-
});
|
|
22
|
-
async function getVNextWorkflowsHandler({ mastra }) {
|
|
23
|
-
try {
|
|
24
|
-
const workflows = mastra.vnext_getWorkflows({ serialized: false });
|
|
25
|
-
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
26
|
-
acc[key] = {
|
|
27
|
-
name: workflow.name,
|
|
28
|
-
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
29
|
-
acc2[key2] = {
|
|
30
|
-
id: step.id,
|
|
31
|
-
description: step.description,
|
|
32
|
-
inputSchema: step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.inputSchema)) : void 0,
|
|
33
|
-
outputSchema: step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.outputSchema)) : void 0,
|
|
34
|
-
resumeSchema: step.resumeSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
35
|
-
suspendSchema: step.suspendSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.suspendSchema)) : void 0
|
|
36
|
-
};
|
|
37
|
-
return acc2;
|
|
38
|
-
}, {}),
|
|
39
|
-
stepGraph: workflow.serializedStepGraph,
|
|
40
|
-
inputSchema: workflow.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
41
|
-
outputSchema: workflow.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
42
|
-
};
|
|
43
|
-
return acc;
|
|
44
|
-
}, {});
|
|
45
|
-
return _workflows;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
51
|
-
try {
|
|
52
|
-
if (!workflowId) {
|
|
53
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
54
|
-
}
|
|
55
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
56
|
-
if (!workflow) {
|
|
57
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
61
|
-
acc[key] = {
|
|
62
|
-
id: step.id,
|
|
63
|
-
description: step.description,
|
|
64
|
-
inputSchema: step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.inputSchema)) : void 0,
|
|
65
|
-
outputSchema: step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.outputSchema)) : void 0,
|
|
66
|
-
resumeSchema: step.resumeSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
67
|
-
suspendSchema: step.suspendSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(step.suspendSchema)) : void 0
|
|
68
|
-
};
|
|
69
|
-
return acc;
|
|
70
|
-
}, {}),
|
|
71
|
-
name: workflow.name,
|
|
72
|
-
stepGraph: workflow.serializedStepGraph,
|
|
73
|
-
inputSchema: workflow.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
74
|
-
outputSchema: workflow.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
75
|
-
};
|
|
76
|
-
} catch (error) {
|
|
77
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
async function getVNextWorkflowRunHandler({
|
|
81
|
-
mastra,
|
|
82
|
-
workflowId,
|
|
83
|
-
runId
|
|
84
|
-
}) {
|
|
85
|
-
try {
|
|
86
|
-
if (!workflowId) {
|
|
87
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
88
|
-
}
|
|
89
|
-
if (!runId) {
|
|
90
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
91
|
-
}
|
|
92
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
93
|
-
if (!workflow) {
|
|
94
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
95
|
-
}
|
|
96
|
-
const run = await workflow.getWorkflowRun(runId);
|
|
97
|
-
if (!run) {
|
|
98
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
99
|
-
}
|
|
100
|
-
return run;
|
|
101
|
-
} catch (error) {
|
|
102
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function createVNextWorkflowRunHandler({
|
|
106
|
-
mastra,
|
|
107
|
-
workflowId,
|
|
108
|
-
runId: prevRunId
|
|
109
|
-
}) {
|
|
110
|
-
try {
|
|
111
|
-
if (!workflowId) {
|
|
112
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
113
|
-
}
|
|
114
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
115
|
-
if (!workflow) {
|
|
116
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
117
|
-
}
|
|
118
|
-
const run = workflow.createRun({ runId: prevRunId });
|
|
119
|
-
return { runId: run.runId };
|
|
120
|
-
} catch (error) {
|
|
121
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async function startAsyncVNextWorkflowHandler({
|
|
125
|
-
mastra,
|
|
126
|
-
runtimeContext,
|
|
127
|
-
workflowId,
|
|
128
|
-
runId,
|
|
129
|
-
inputData
|
|
130
|
-
}) {
|
|
131
|
-
try {
|
|
132
|
-
if (!workflowId) {
|
|
133
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
134
|
-
}
|
|
135
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
136
|
-
if (!workflow) {
|
|
137
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
138
|
-
}
|
|
139
|
-
const _run = workflow.createRun({ runId });
|
|
140
|
-
const result = await _run.start({
|
|
141
|
-
inputData,
|
|
142
|
-
runtimeContext
|
|
143
|
-
});
|
|
144
|
-
return result;
|
|
145
|
-
} catch (error) {
|
|
146
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async function startVNextWorkflowRunHandler({
|
|
150
|
-
mastra,
|
|
151
|
-
runtimeContext,
|
|
152
|
-
workflowId,
|
|
153
|
-
runId,
|
|
154
|
-
inputData
|
|
155
|
-
}) {
|
|
156
|
-
try {
|
|
157
|
-
if (!workflowId) {
|
|
158
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
159
|
-
}
|
|
160
|
-
if (!runId) {
|
|
161
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
162
|
-
}
|
|
163
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
164
|
-
const run = await workflow.getWorkflowRun(runId);
|
|
165
|
-
if (!run) {
|
|
166
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
167
|
-
}
|
|
168
|
-
const _run = workflow.createRun({ runId });
|
|
169
|
-
await _run.start({
|
|
170
|
-
inputData,
|
|
171
|
-
runtimeContext
|
|
172
|
-
});
|
|
173
|
-
return { message: "Workflow run started" };
|
|
174
|
-
} catch (e) {
|
|
175
|
-
return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
async function watchVNextWorkflowHandler({
|
|
179
|
-
mastra,
|
|
180
|
-
workflowId,
|
|
181
|
-
runId
|
|
182
|
-
}) {
|
|
183
|
-
try {
|
|
184
|
-
if (!workflowId) {
|
|
185
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
186
|
-
}
|
|
187
|
-
if (!runId) {
|
|
188
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
|
|
189
|
-
}
|
|
190
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
191
|
-
const run = await workflow.getWorkflowRun(runId);
|
|
192
|
-
if (!run) {
|
|
193
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
194
|
-
}
|
|
195
|
-
const _run = workflow.createRun({ runId });
|
|
196
|
-
let unwatch;
|
|
197
|
-
let asyncRef = null;
|
|
198
|
-
const stream = new web.ReadableStream({
|
|
199
|
-
start(controller) {
|
|
200
|
-
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
201
|
-
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
202
|
-
if (asyncRef) {
|
|
203
|
-
clearImmediate(asyncRef);
|
|
204
|
-
asyncRef = null;
|
|
205
|
-
}
|
|
206
|
-
asyncRef = setImmediate(async () => {
|
|
207
|
-
const runDone = payload.workflowState.status !== "running";
|
|
208
|
-
if (runDone) {
|
|
209
|
-
controller.close();
|
|
210
|
-
unwatch?.();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
},
|
|
215
|
-
cancel() {
|
|
216
|
-
unwatch?.();
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
return stream;
|
|
220
|
-
} catch (error) {
|
|
221
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
async function resumeAsyncVNextWorkflowHandler({
|
|
225
|
-
mastra,
|
|
226
|
-
workflowId,
|
|
227
|
-
runId,
|
|
228
|
-
body,
|
|
229
|
-
runtimeContext
|
|
230
|
-
}) {
|
|
231
|
-
try {
|
|
232
|
-
if (!workflowId) {
|
|
233
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
234
|
-
}
|
|
235
|
-
if (!runId) {
|
|
236
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
237
|
-
}
|
|
238
|
-
if (!body.step) {
|
|
239
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
240
|
-
}
|
|
241
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
242
|
-
const run = await workflow.getWorkflowRun(runId);
|
|
243
|
-
if (!run) {
|
|
244
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
245
|
-
}
|
|
246
|
-
const _run = workflow.createRun({ runId });
|
|
247
|
-
const result = await _run.resume({
|
|
248
|
-
step: body.step,
|
|
249
|
-
resumeData: body.resumeData,
|
|
250
|
-
runtimeContext
|
|
251
|
-
});
|
|
252
|
-
return result;
|
|
253
|
-
} catch (error) {
|
|
254
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
async function resumeVNextWorkflowHandler({
|
|
258
|
-
mastra,
|
|
259
|
-
workflowId,
|
|
260
|
-
runId,
|
|
261
|
-
body,
|
|
262
|
-
runtimeContext
|
|
263
|
-
}) {
|
|
264
|
-
try {
|
|
265
|
-
if (!workflowId) {
|
|
266
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
267
|
-
}
|
|
268
|
-
if (!runId) {
|
|
269
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
270
|
-
}
|
|
271
|
-
if (!body.step) {
|
|
272
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "step required to resume workflow" });
|
|
273
|
-
}
|
|
274
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
275
|
-
const run = await workflow.getWorkflowRun(runId);
|
|
276
|
-
if (!run) {
|
|
277
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
278
|
-
}
|
|
279
|
-
const _run = workflow.createRun({ runId });
|
|
280
|
-
await _run.resume({
|
|
281
|
-
step: body.step,
|
|
282
|
-
resumeData: body.resumeData,
|
|
283
|
-
runtimeContext
|
|
284
|
-
});
|
|
285
|
-
return { message: "Workflow run resumed" };
|
|
286
|
-
} catch (error) {
|
|
287
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
async function getVNextWorkflowRunsHandler({
|
|
291
|
-
mastra,
|
|
292
|
-
workflowId,
|
|
293
|
-
fromDate,
|
|
294
|
-
toDate,
|
|
295
|
-
limit,
|
|
296
|
-
offset,
|
|
297
|
-
resourceId
|
|
298
|
-
}) {
|
|
299
|
-
try {
|
|
300
|
-
if (!workflowId) {
|
|
301
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
302
|
-
}
|
|
303
|
-
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
304
|
-
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
305
|
-
runs: [],
|
|
306
|
-
total: 0
|
|
307
|
-
};
|
|
308
|
-
return workflowRuns;
|
|
309
|
-
} catch (error) {
|
|
310
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
exports.createVNextWorkflowRunHandler = createVNextWorkflowRunHandler;
|
|
315
|
-
exports.getVNextWorkflowByIdHandler = getVNextWorkflowByIdHandler;
|
|
316
|
-
exports.getVNextWorkflowRunHandler = getVNextWorkflowRunHandler;
|
|
317
|
-
exports.getVNextWorkflowRunsHandler = getVNextWorkflowRunsHandler;
|
|
318
|
-
exports.getVNextWorkflowsHandler = getVNextWorkflowsHandler;
|
|
319
|
-
exports.resumeAsyncVNextWorkflowHandler = resumeAsyncVNextWorkflowHandler;
|
|
320
|
-
exports.resumeVNextWorkflowHandler = resumeVNextWorkflowHandler;
|
|
321
|
-
exports.startAsyncVNextWorkflowHandler = startAsyncVNextWorkflowHandler;
|
|
322
|
-
exports.startVNextWorkflowRunHandler = startVNextWorkflowRunHandler;
|
|
323
|
-
exports.vNextWorkflows_exports = vNextWorkflows_exports;
|
|
324
|
-
exports.watchVNextWorkflowHandler = watchVNextWorkflowHandler;
|