@mastra/server 0.0.0-revert-schema-20250416221206 → 0.0.0-separate-trace-data-from-component-20250501042644
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/dist/_tsup-dts-rollup.d.cts +111 -30
- package/dist/_tsup-dts-rollup.d.ts +111 -30
- package/dist/{chunk-UE27Q3XD.cjs → chunk-4BIX6GMY.cjs} +59 -34
- package/dist/{chunk-A7DF4ETD.cjs → chunk-55HTWX4C.cjs} +2 -9
- package/dist/{chunk-UV4WTEH4.js → chunk-5JNVY6DU.js} +5 -5
- package/dist/{chunk-QH6XWSXP.cjs → chunk-5SWCVTNL.cjs} +38 -38
- package/dist/{chunk-JLDXUWK7.cjs → chunk-5YGDYMRB.cjs} +52 -31
- package/dist/chunk-AELYAUEE.cjs +316 -0
- package/dist/{chunk-PDC4ZBQW.cjs → chunk-D3G23FP3.cjs} +9 -9
- package/dist/{chunk-B64YROKU.cjs → chunk-EVCC233P.cjs} +22 -18
- package/dist/chunk-JPB6RPGB.js +304 -0
- package/dist/{chunk-OPP7H5TW.js → chunk-M3YJLWTU.js} +16 -12
- package/dist/{chunk-VK6FX47H.js → chunk-OMN3UI6X.js} +38 -38
- package/dist/{chunk-3RVHWGWO.js → chunk-Q6SHQECN.js} +2 -9
- package/dist/{chunk-YANVFOYA.js → chunk-QJ3AHN64.js} +52 -31
- package/dist/{chunk-I6MBOQTH.js → chunk-Y3SV5XK4.js} +57 -32
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/vNextWorkflows.cjs +46 -0
- package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
- package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
- package/dist/server/handlers/vNextWorkflows.js +1 -0
- package/dist/server/handlers/voice.cjs +4 -4
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +11 -11
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +15 -10
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +6 -5
- package/package.json +5 -5
|
@@ -12,33 +12,48 @@ chunkFV45V6WC_cjs.__export(network_exports, {
|
|
|
12
12
|
getNetworksHandler: () => getNetworksHandler,
|
|
13
13
|
streamGenerateHandler: () => streamGenerateHandler
|
|
14
14
|
});
|
|
15
|
-
async function getNetworksHandler({
|
|
15
|
+
async function getNetworksHandler({
|
|
16
|
+
mastra,
|
|
17
|
+
runtimeContext
|
|
18
|
+
}) {
|
|
16
19
|
try {
|
|
17
20
|
const networks = mastra.getNetworks();
|
|
18
|
-
const serializedNetworks =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
const serializedNetworks = await Promise.all(
|
|
22
|
+
networks.map(async (network) => {
|
|
23
|
+
const routingAgent = network.getRoutingAgent();
|
|
24
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
25
|
+
const agents = network.getAgents();
|
|
26
|
+
return {
|
|
27
|
+
id: network.formatAgentId(routingAgent.name),
|
|
28
|
+
name: routingAgent.name,
|
|
29
|
+
instructions: routingAgent.instructions,
|
|
30
|
+
agents: await Promise.all(
|
|
31
|
+
agents.map(async (agent) => {
|
|
32
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
33
|
+
return {
|
|
34
|
+
name: agent.name,
|
|
35
|
+
provider: llm?.getProvider(),
|
|
36
|
+
modelId: llm?.getModelId()
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
),
|
|
40
|
+
routingModel: {
|
|
41
|
+
provider: routingLLM?.getProvider(),
|
|
42
|
+
modelId: routingLLM?.getModelId()
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
);
|
|
36
47
|
return serializedNetworks;
|
|
37
48
|
} catch (error) {
|
|
38
49
|
return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
|
-
async function getNetworkByIdHandler({
|
|
52
|
+
async function getNetworkByIdHandler({
|
|
53
|
+
mastra,
|
|
54
|
+
networkId,
|
|
55
|
+
runtimeContext
|
|
56
|
+
}) {
|
|
42
57
|
try {
|
|
43
58
|
const networks = mastra.getNetworks();
|
|
44
59
|
const network = networks.find((network2) => {
|
|
@@ -49,19 +64,25 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
49
64
|
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
|
|
50
65
|
}
|
|
51
66
|
const routingAgent = network.getRoutingAgent();
|
|
67
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
52
68
|
const agents = network.getAgents();
|
|
53
69
|
const serializedNetwork = {
|
|
54
70
|
id: network.formatAgentId(routingAgent.name),
|
|
55
71
|
name: routingAgent.name,
|
|
56
72
|
instructions: routingAgent.instructions,
|
|
57
|
-
agents:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
agents: await Promise.all(
|
|
74
|
+
agents.map(async (agent) => {
|
|
75
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
76
|
+
return {
|
|
77
|
+
name: agent.name,
|
|
78
|
+
provider: llm?.getProvider(),
|
|
79
|
+
modelId: llm?.getModelId()
|
|
80
|
+
};
|
|
81
|
+
})
|
|
82
|
+
),
|
|
62
83
|
routingModel: {
|
|
63
|
-
provider:
|
|
64
|
-
modelId:
|
|
84
|
+
provider: routingLLM?.getProvider(),
|
|
85
|
+
modelId: routingLLM?.getModelId()
|
|
65
86
|
}
|
|
66
87
|
};
|
|
67
88
|
return serializedNetwork;
|
|
@@ -71,7 +92,7 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
71
92
|
}
|
|
72
93
|
async function generateHandler({
|
|
73
94
|
mastra,
|
|
74
|
-
|
|
95
|
+
runtimeContext,
|
|
75
96
|
networkId,
|
|
76
97
|
body
|
|
77
98
|
}) {
|
|
@@ -82,7 +103,7 @@ async function generateHandler({
|
|
|
82
103
|
}
|
|
83
104
|
chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
|
|
84
105
|
const { messages, ...rest } = body;
|
|
85
|
-
const result = await network.generate(messages, { ...rest,
|
|
106
|
+
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
86
107
|
return result;
|
|
87
108
|
} catch (error) {
|
|
88
109
|
return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
|
|
@@ -92,7 +113,7 @@ async function streamGenerateHandler({
|
|
|
92
113
|
mastra,
|
|
93
114
|
networkId,
|
|
94
115
|
body,
|
|
95
|
-
|
|
116
|
+
runtimeContext
|
|
96
117
|
}) {
|
|
97
118
|
try {
|
|
98
119
|
const network = mastra.getNetwork(networkId);
|
|
@@ -104,7 +125,7 @@ async function streamGenerateHandler({
|
|
|
104
125
|
const streamResult = await network.stream(messages, {
|
|
105
126
|
output,
|
|
106
127
|
...rest,
|
|
107
|
-
|
|
128
|
+
runtimeContext
|
|
108
129
|
});
|
|
109
130
|
const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
110
131
|
sendUsage: true,
|
|
@@ -0,0 +1,316 @@
|
|
|
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({ mastra, workflowId }) {
|
|
291
|
+
try {
|
|
292
|
+
if (!workflowId) {
|
|
293
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
294
|
+
}
|
|
295
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
296
|
+
const workflowRuns = await workflow.getWorkflowRuns() || {
|
|
297
|
+
runs: [],
|
|
298
|
+
total: 0
|
|
299
|
+
};
|
|
300
|
+
return workflowRuns;
|
|
301
|
+
} catch (error) {
|
|
302
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
exports.createVNextWorkflowRunHandler = createVNextWorkflowRunHandler;
|
|
307
|
+
exports.getVNextWorkflowByIdHandler = getVNextWorkflowByIdHandler;
|
|
308
|
+
exports.getVNextWorkflowRunHandler = getVNextWorkflowRunHandler;
|
|
309
|
+
exports.getVNextWorkflowRunsHandler = getVNextWorkflowRunsHandler;
|
|
310
|
+
exports.getVNextWorkflowsHandler = getVNextWorkflowsHandler;
|
|
311
|
+
exports.resumeAsyncVNextWorkflowHandler = resumeAsyncVNextWorkflowHandler;
|
|
312
|
+
exports.resumeVNextWorkflowHandler = resumeVNextWorkflowHandler;
|
|
313
|
+
exports.startAsyncVNextWorkflowHandler = startAsyncVNextWorkflowHandler;
|
|
314
|
+
exports.startVNextWorkflowRunHandler = startVNextWorkflowRunHandler;
|
|
315
|
+
exports.vNextWorkflows_exports = vNextWorkflows_exports;
|
|
316
|
+
exports.watchVNextWorkflowHandler = watchVNextWorkflowHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
|
|
4
4
|
var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
|
|
5
5
|
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
6
6
|
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
@@ -24,8 +24,8 @@ async function getToolsHandler({ tools }) {
|
|
|
24
24
|
const tool = _tool;
|
|
25
25
|
acc[id] = {
|
|
26
26
|
...tool,
|
|
27
|
-
inputSchema: tool.inputSchema ?
|
|
28
|
-
outputSchema: tool.outputSchema ?
|
|
27
|
+
inputSchema: tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.inputSchema)) : void 0,
|
|
28
|
+
outputSchema: tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.outputSchema)) : void 0
|
|
29
29
|
};
|
|
30
30
|
return acc;
|
|
31
31
|
},
|
|
@@ -44,8 +44,8 @@ async function getToolByIdHandler({ tools, toolId }) {
|
|
|
44
44
|
}
|
|
45
45
|
const serializedTool = {
|
|
46
46
|
...tool,
|
|
47
|
-
inputSchema: tool.inputSchema ?
|
|
48
|
-
outputSchema: tool.outputSchema ?
|
|
47
|
+
inputSchema: tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.inputSchema)) : void 0,
|
|
48
|
+
outputSchema: tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.outputSchema)) : void 0
|
|
49
49
|
};
|
|
50
50
|
return serializedTool;
|
|
51
51
|
} catch (error) {
|
|
@@ -58,7 +58,7 @@ function executeToolHandler(tools$1) {
|
|
|
58
58
|
runId,
|
|
59
59
|
toolId,
|
|
60
60
|
data,
|
|
61
|
-
|
|
61
|
+
runtimeContext
|
|
62
62
|
}) => {
|
|
63
63
|
try {
|
|
64
64
|
if (!toolId) {
|
|
@@ -80,7 +80,7 @@ function executeToolHandler(tools$1) {
|
|
|
80
80
|
context: data,
|
|
81
81
|
mastra,
|
|
82
82
|
runId,
|
|
83
|
-
|
|
83
|
+
runtimeContext
|
|
84
84
|
});
|
|
85
85
|
return result;
|
|
86
86
|
} catch (error) {
|
|
@@ -93,7 +93,7 @@ async function executeAgentToolHandler({
|
|
|
93
93
|
agentId,
|
|
94
94
|
toolId,
|
|
95
95
|
data,
|
|
96
|
-
|
|
96
|
+
runtimeContext
|
|
97
97
|
}) {
|
|
98
98
|
try {
|
|
99
99
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
@@ -109,7 +109,7 @@ async function executeAgentToolHandler({
|
|
|
109
109
|
}
|
|
110
110
|
const result = await tool.execute({
|
|
111
111
|
context: data,
|
|
112
|
-
|
|
112
|
+
runtimeContext,
|
|
113
113
|
mastra,
|
|
114
114
|
runId: agentId
|
|
115
115
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
|
|
4
4
|
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
5
5
|
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
6
6
|
var web = require('stream/web');
|
|
@@ -30,13 +30,15 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
30
30
|
serializedStepGraph: workflow.serializedStepGraph,
|
|
31
31
|
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
32
32
|
name: workflow.name,
|
|
33
|
-
triggerSchema: workflow.triggerSchema ?
|
|
33
|
+
triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
34
34
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
35
35
|
const _step = step;
|
|
36
36
|
acc2[key2] = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
40
42
|
};
|
|
41
43
|
return acc2;
|
|
42
44
|
}, {})
|
|
@@ -63,13 +65,15 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
63
65
|
serializedStepGraph: workflow.serializedStepGraph,
|
|
64
66
|
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
65
67
|
name: workflow.name,
|
|
66
|
-
triggerSchema: workflow.triggerSchema ?
|
|
68
|
+
triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
67
69
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
68
70
|
const _step = step;
|
|
69
71
|
acc[key] = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
73
77
|
};
|
|
74
78
|
return acc;
|
|
75
79
|
}, {})
|
|
@@ -80,7 +84,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
80
84
|
}
|
|
81
85
|
async function startAsyncWorkflowHandler({
|
|
82
86
|
mastra,
|
|
83
|
-
|
|
87
|
+
runtimeContext,
|
|
84
88
|
workflowId,
|
|
85
89
|
runId,
|
|
86
90
|
triggerData
|
|
@@ -97,7 +101,7 @@ async function startAsyncWorkflowHandler({
|
|
|
97
101
|
const { start } = workflow.createRun();
|
|
98
102
|
const result2 = await start({
|
|
99
103
|
triggerData,
|
|
100
|
-
|
|
104
|
+
runtimeContext
|
|
101
105
|
});
|
|
102
106
|
return result2;
|
|
103
107
|
}
|
|
@@ -107,7 +111,7 @@ async function startAsyncWorkflowHandler({
|
|
|
107
111
|
}
|
|
108
112
|
const result = await run.start({
|
|
109
113
|
triggerData,
|
|
110
|
-
|
|
114
|
+
runtimeContext
|
|
111
115
|
});
|
|
112
116
|
return result;
|
|
113
117
|
} catch (error) {
|
|
@@ -160,7 +164,7 @@ async function createRunHandler({
|
|
|
160
164
|
}
|
|
161
165
|
async function startWorkflowRunHandler({
|
|
162
166
|
mastra,
|
|
163
|
-
|
|
167
|
+
runtimeContext,
|
|
164
168
|
workflowId,
|
|
165
169
|
runId,
|
|
166
170
|
triggerData
|
|
@@ -179,7 +183,7 @@ async function startWorkflowRunHandler({
|
|
|
179
183
|
}
|
|
180
184
|
await run.start({
|
|
181
185
|
triggerData,
|
|
182
|
-
|
|
186
|
+
runtimeContext
|
|
183
187
|
});
|
|
184
188
|
return { message: "Workflow run started" };
|
|
185
189
|
} catch (e) {
|
|
@@ -235,7 +239,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
235
239
|
workflowId,
|
|
236
240
|
runId,
|
|
237
241
|
body,
|
|
238
|
-
|
|
242
|
+
runtimeContext
|
|
239
243
|
}) {
|
|
240
244
|
try {
|
|
241
245
|
if (!workflowId) {
|
|
@@ -252,7 +256,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
252
256
|
const result = await run.resume({
|
|
253
257
|
stepId: body.stepId,
|
|
254
258
|
context: body.context,
|
|
255
|
-
|
|
259
|
+
runtimeContext
|
|
256
260
|
});
|
|
257
261
|
return result;
|
|
258
262
|
} catch (error) {
|
|
@@ -264,7 +268,7 @@ async function resumeWorkflowHandler({
|
|
|
264
268
|
workflowId,
|
|
265
269
|
runId,
|
|
266
270
|
body,
|
|
267
|
-
|
|
271
|
+
runtimeContext
|
|
268
272
|
}) {
|
|
269
273
|
try {
|
|
270
274
|
if (!workflowId) {
|
|
@@ -281,7 +285,7 @@ async function resumeWorkflowHandler({
|
|
|
281
285
|
await run.resume({
|
|
282
286
|
stepId: body.stepId,
|
|
283
287
|
context: body.context,
|
|
284
|
-
|
|
288
|
+
runtimeContext
|
|
285
289
|
});
|
|
286
290
|
return { message: "Workflow run resumed" };
|
|
287
291
|
} catch (error) {
|