@mastra/server 0.0.0-mcp-server-update-parse-20250421171139 → 0.0.0-pg-pool-options-20250428183821
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 +99 -24
- package/dist/_tsup-dts-rollup.d.ts +99 -24
- package/dist/{chunk-A7DF4ETD.cjs → chunk-55HTWX4C.cjs} +2 -9
- package/dist/{chunk-XISBMH56.js → chunk-5JNVY6DU.js} +4 -4
- package/dist/{chunk-HABV7TZK.cjs → chunk-D3G23FP3.cjs} +4 -4
- package/dist/{chunk-JLDXUWK7.cjs → chunk-FPIWDH5Y.cjs} +4 -4
- package/dist/{chunk-4WJ5GHRG.cjs → chunk-HCOPJZ4A.cjs} +4 -4
- package/dist/chunk-L5JIIJGO.js +300 -0
- package/dist/{chunk-4B7OUZXW.js → chunk-LFOBHRFO.js} +9 -9
- package/dist/{chunk-3RVHWGWO.js → chunk-Q6SHQECN.js} +2 -9
- package/dist/{chunk-TFFNX7FI.js → chunk-R4J7XQYU.js} +4 -4
- package/dist/{chunk-YANVFOYA.js → chunk-RE6YL32K.js} +4 -4
- package/dist/{chunk-RNU4JMLM.cjs → chunk-TZK63M5N.cjs} +9 -9
- package/dist/chunk-YN63BKGG.cjs +312 -0
- 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 +4 -4
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { stringify, esm_default } from './chunk-OMN3UI6X.js';
|
|
2
|
+
import { handleError } from './chunk-3AHQ5RGN.js';
|
|
3
|
+
import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
|
|
4
|
+
import { ReadableStream } from 'node:stream/web';
|
|
5
|
+
|
|
6
|
+
// src/server/handlers/vNextWorkflows.ts
|
|
7
|
+
var vNextWorkflows_exports = {};
|
|
8
|
+
__export(vNextWorkflows_exports, {
|
|
9
|
+
createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
|
|
10
|
+
getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
|
|
11
|
+
getVNextWorkflowRunHandler: () => getVNextWorkflowRunHandler,
|
|
12
|
+
getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
|
|
13
|
+
getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
|
|
14
|
+
resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
|
|
15
|
+
resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
|
|
16
|
+
startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
|
|
17
|
+
startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
|
|
18
|
+
watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
|
|
19
|
+
});
|
|
20
|
+
async function getVNextWorkflowsHandler({ mastra }) {
|
|
21
|
+
try {
|
|
22
|
+
const workflows = mastra.vnext_getWorkflows({ serialized: false });
|
|
23
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
24
|
+
acc[key] = {
|
|
25
|
+
name: workflow.name,
|
|
26
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
27
|
+
acc2[key2] = {
|
|
28
|
+
...step,
|
|
29
|
+
inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
|
|
30
|
+
outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
|
|
31
|
+
resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0
|
|
32
|
+
};
|
|
33
|
+
return acc2;
|
|
34
|
+
}, {}),
|
|
35
|
+
stepGraph: workflow.stepGraph,
|
|
36
|
+
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
37
|
+
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
38
|
+
};
|
|
39
|
+
return acc;
|
|
40
|
+
}, {});
|
|
41
|
+
return _workflows;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
47
|
+
try {
|
|
48
|
+
if (!workflowId) {
|
|
49
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
50
|
+
}
|
|
51
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
52
|
+
if (!workflow) {
|
|
53
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
57
|
+
acc[key] = {
|
|
58
|
+
...step,
|
|
59
|
+
inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
|
|
60
|
+
outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
|
|
61
|
+
resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0
|
|
62
|
+
};
|
|
63
|
+
return acc;
|
|
64
|
+
}, {}),
|
|
65
|
+
name: workflow.name,
|
|
66
|
+
stepGraph: workflow.stepGraph,
|
|
67
|
+
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
68
|
+
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function getVNextWorkflowRunHandler({
|
|
75
|
+
mastra,
|
|
76
|
+
workflowId,
|
|
77
|
+
runId
|
|
78
|
+
}) {
|
|
79
|
+
try {
|
|
80
|
+
if (!workflowId) {
|
|
81
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
82
|
+
}
|
|
83
|
+
if (!runId) {
|
|
84
|
+
throw new HTTPException(400, { message: "Run ID is required" });
|
|
85
|
+
}
|
|
86
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
87
|
+
if (!workflow) {
|
|
88
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
89
|
+
}
|
|
90
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
91
|
+
if (!run) {
|
|
92
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
93
|
+
}
|
|
94
|
+
return run;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function createVNextWorkflowRunHandler({
|
|
100
|
+
mastra,
|
|
101
|
+
workflowId,
|
|
102
|
+
runId: prevRunId
|
|
103
|
+
}) {
|
|
104
|
+
try {
|
|
105
|
+
if (!workflowId) {
|
|
106
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
107
|
+
}
|
|
108
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
109
|
+
if (!workflow) {
|
|
110
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
111
|
+
}
|
|
112
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
113
|
+
return { runId: run.runId };
|
|
114
|
+
} catch (error) {
|
|
115
|
+
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function startAsyncVNextWorkflowHandler({
|
|
119
|
+
mastra,
|
|
120
|
+
runtimeContext,
|
|
121
|
+
workflowId,
|
|
122
|
+
runId,
|
|
123
|
+
inputData
|
|
124
|
+
}) {
|
|
125
|
+
try {
|
|
126
|
+
if (!workflowId) {
|
|
127
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
128
|
+
}
|
|
129
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
130
|
+
if (!workflow) {
|
|
131
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
132
|
+
}
|
|
133
|
+
const _run = workflow.createRun({ runId });
|
|
134
|
+
const result = await _run.start({
|
|
135
|
+
inputData,
|
|
136
|
+
runtimeContext
|
|
137
|
+
});
|
|
138
|
+
return result;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async function startVNextWorkflowRunHandler({
|
|
144
|
+
mastra,
|
|
145
|
+
runtimeContext,
|
|
146
|
+
workflowId,
|
|
147
|
+
runId,
|
|
148
|
+
inputData
|
|
149
|
+
}) {
|
|
150
|
+
try {
|
|
151
|
+
if (!workflowId) {
|
|
152
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
153
|
+
}
|
|
154
|
+
if (!runId) {
|
|
155
|
+
throw new HTTPException(400, { message: "runId required to start run" });
|
|
156
|
+
}
|
|
157
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
158
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
159
|
+
if (!run) {
|
|
160
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
161
|
+
}
|
|
162
|
+
const _run = workflow.createRun({ runId });
|
|
163
|
+
await _run.start({
|
|
164
|
+
inputData,
|
|
165
|
+
runtimeContext
|
|
166
|
+
});
|
|
167
|
+
return { message: "Workflow run started" };
|
|
168
|
+
} catch (e) {
|
|
169
|
+
return handleError(e, "Error starting workflow run");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function watchVNextWorkflowHandler({
|
|
173
|
+
mastra,
|
|
174
|
+
workflowId,
|
|
175
|
+
runId
|
|
176
|
+
}) {
|
|
177
|
+
try {
|
|
178
|
+
if (!workflowId) {
|
|
179
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
180
|
+
}
|
|
181
|
+
if (!runId) {
|
|
182
|
+
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
183
|
+
}
|
|
184
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
185
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
186
|
+
if (!run) {
|
|
187
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
188
|
+
}
|
|
189
|
+
const _run = workflow.createRun({ runId });
|
|
190
|
+
let unwatch;
|
|
191
|
+
let asyncRef = null;
|
|
192
|
+
const stream = new ReadableStream({
|
|
193
|
+
start(controller) {
|
|
194
|
+
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
195
|
+
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
196
|
+
if (asyncRef) {
|
|
197
|
+
clearImmediate(asyncRef);
|
|
198
|
+
asyncRef = null;
|
|
199
|
+
}
|
|
200
|
+
asyncRef = setImmediate(async () => {
|
|
201
|
+
const runDone = payload.workflowState.status !== "running";
|
|
202
|
+
if (runDone) {
|
|
203
|
+
controller.close();
|
|
204
|
+
unwatch?.();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
cancel() {
|
|
210
|
+
unwatch?.();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return stream;
|
|
214
|
+
} catch (error) {
|
|
215
|
+
return handleError(error, "Error watching workflow");
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
async function resumeAsyncVNextWorkflowHandler({
|
|
219
|
+
mastra,
|
|
220
|
+
workflowId,
|
|
221
|
+
runId,
|
|
222
|
+
body,
|
|
223
|
+
runtimeContext
|
|
224
|
+
}) {
|
|
225
|
+
try {
|
|
226
|
+
if (!workflowId) {
|
|
227
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
228
|
+
}
|
|
229
|
+
if (!runId) {
|
|
230
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
231
|
+
}
|
|
232
|
+
if (!body.step) {
|
|
233
|
+
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
234
|
+
}
|
|
235
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
236
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
237
|
+
if (!run) {
|
|
238
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
239
|
+
}
|
|
240
|
+
const _run = workflow.createRun({ runId });
|
|
241
|
+
const result = await _run.resume({
|
|
242
|
+
step: body.step,
|
|
243
|
+
resumeData: body.resumeData,
|
|
244
|
+
runtimeContext
|
|
245
|
+
});
|
|
246
|
+
return result;
|
|
247
|
+
} catch (error) {
|
|
248
|
+
return handleError(error, "Error resuming workflow step");
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async function resumeVNextWorkflowHandler({
|
|
252
|
+
mastra,
|
|
253
|
+
workflowId,
|
|
254
|
+
runId,
|
|
255
|
+
body,
|
|
256
|
+
runtimeContext
|
|
257
|
+
}) {
|
|
258
|
+
try {
|
|
259
|
+
if (!workflowId) {
|
|
260
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
261
|
+
}
|
|
262
|
+
if (!runId) {
|
|
263
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
264
|
+
}
|
|
265
|
+
if (!body.step) {
|
|
266
|
+
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
267
|
+
}
|
|
268
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
269
|
+
const run = await workflow.getWorkflowRun(runId);
|
|
270
|
+
if (!run) {
|
|
271
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
272
|
+
}
|
|
273
|
+
const _run = workflow.createRun({ runId });
|
|
274
|
+
await _run.resume({
|
|
275
|
+
step: body.step,
|
|
276
|
+
resumeData: body.resumeData,
|
|
277
|
+
runtimeContext
|
|
278
|
+
});
|
|
279
|
+
return { message: "Workflow run resumed" };
|
|
280
|
+
} catch (error) {
|
|
281
|
+
return handleError(error, "Error resuming workflow");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
async function getVNextWorkflowRunsHandler({ mastra, workflowId }) {
|
|
285
|
+
try {
|
|
286
|
+
if (!workflowId) {
|
|
287
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
288
|
+
}
|
|
289
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
290
|
+
const workflowRuns = await workflow.getWorkflowRuns() || {
|
|
291
|
+
runs: [],
|
|
292
|
+
total: 0
|
|
293
|
+
};
|
|
294
|
+
return workflowRuns;
|
|
295
|
+
} catch (error) {
|
|
296
|
+
return handleError(error, "Error getting workflow runs");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };
|
|
@@ -78,7 +78,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
78
78
|
}
|
|
79
79
|
async function startAsyncWorkflowHandler({
|
|
80
80
|
mastra,
|
|
81
|
-
|
|
81
|
+
runtimeContext,
|
|
82
82
|
workflowId,
|
|
83
83
|
runId,
|
|
84
84
|
triggerData
|
|
@@ -95,7 +95,7 @@ async function startAsyncWorkflowHandler({
|
|
|
95
95
|
const { start } = workflow.createRun();
|
|
96
96
|
const result2 = await start({
|
|
97
97
|
triggerData,
|
|
98
|
-
|
|
98
|
+
runtimeContext
|
|
99
99
|
});
|
|
100
100
|
return result2;
|
|
101
101
|
}
|
|
@@ -105,7 +105,7 @@ async function startAsyncWorkflowHandler({
|
|
|
105
105
|
}
|
|
106
106
|
const result = await run.start({
|
|
107
107
|
triggerData,
|
|
108
|
-
|
|
108
|
+
runtimeContext
|
|
109
109
|
});
|
|
110
110
|
return result;
|
|
111
111
|
} catch (error) {
|
|
@@ -158,7 +158,7 @@ async function createRunHandler({
|
|
|
158
158
|
}
|
|
159
159
|
async function startWorkflowRunHandler({
|
|
160
160
|
mastra,
|
|
161
|
-
|
|
161
|
+
runtimeContext,
|
|
162
162
|
workflowId,
|
|
163
163
|
runId,
|
|
164
164
|
triggerData
|
|
@@ -177,7 +177,7 @@ async function startWorkflowRunHandler({
|
|
|
177
177
|
}
|
|
178
178
|
await run.start({
|
|
179
179
|
triggerData,
|
|
180
|
-
|
|
180
|
+
runtimeContext
|
|
181
181
|
});
|
|
182
182
|
return { message: "Workflow run started" };
|
|
183
183
|
} catch (e) {
|
|
@@ -233,7 +233,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
233
233
|
workflowId,
|
|
234
234
|
runId,
|
|
235
235
|
body,
|
|
236
|
-
|
|
236
|
+
runtimeContext
|
|
237
237
|
}) {
|
|
238
238
|
try {
|
|
239
239
|
if (!workflowId) {
|
|
@@ -250,7 +250,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
250
250
|
const result = await run.resume({
|
|
251
251
|
stepId: body.stepId,
|
|
252
252
|
context: body.context,
|
|
253
|
-
|
|
253
|
+
runtimeContext
|
|
254
254
|
});
|
|
255
255
|
return result;
|
|
256
256
|
} catch (error) {
|
|
@@ -262,7 +262,7 @@ async function resumeWorkflowHandler({
|
|
|
262
262
|
workflowId,
|
|
263
263
|
runId,
|
|
264
264
|
body,
|
|
265
|
-
|
|
265
|
+
runtimeContext
|
|
266
266
|
}) {
|
|
267
267
|
try {
|
|
268
268
|
if (!workflowId) {
|
|
@@ -279,7 +279,7 @@ async function resumeWorkflowHandler({
|
|
|
279
279
|
await run.resume({
|
|
280
280
|
stepId: body.stepId,
|
|
281
281
|
context: body.context,
|
|
282
|
-
|
|
282
|
+
runtimeContext
|
|
283
283
|
});
|
|
284
284
|
return { message: "Workflow run resumed" };
|
|
285
285
|
} catch (error) {
|
|
@@ -38,9 +38,7 @@ async function generateSpeechHandler({
|
|
|
38
38
|
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
39
39
|
}
|
|
40
40
|
validateBody({
|
|
41
|
-
text:
|
|
42
|
-
speakerId: void 0,
|
|
43
|
-
...body
|
|
41
|
+
text: body?.text
|
|
44
42
|
});
|
|
45
43
|
const agent = mastra.getAgent(agentId);
|
|
46
44
|
if (!agent) {
|
|
@@ -53,12 +51,7 @@ async function generateSpeechHandler({
|
|
|
53
51
|
if (!audioStream) {
|
|
54
52
|
throw new HTTPException(500, { message: "Failed to generate speech" });
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
for await (const chunk of audioStream) {
|
|
58
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
59
|
-
}
|
|
60
|
-
const audioData = Buffer.concat(chunks);
|
|
61
|
-
return { audioData };
|
|
54
|
+
return audioStream;
|
|
62
55
|
} catch (error) {
|
|
63
56
|
return handleError(error, "Error generating speech");
|
|
64
57
|
}
|
|
@@ -97,7 +97,7 @@ async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
|
|
|
97
97
|
}
|
|
98
98
|
async function generateHandler({
|
|
99
99
|
mastra,
|
|
100
|
-
|
|
100
|
+
runtimeContext,
|
|
101
101
|
agentId,
|
|
102
102
|
body
|
|
103
103
|
}) {
|
|
@@ -113,7 +113,7 @@ async function generateHandler({
|
|
|
113
113
|
...rest,
|
|
114
114
|
// @ts-expect-error TODO fix types
|
|
115
115
|
resourceId: finalResourceId,
|
|
116
|
-
|
|
116
|
+
runtimeContext
|
|
117
117
|
});
|
|
118
118
|
return result;
|
|
119
119
|
} catch (error) {
|
|
@@ -122,7 +122,7 @@ async function generateHandler({
|
|
|
122
122
|
}
|
|
123
123
|
async function streamGenerateHandler({
|
|
124
124
|
mastra,
|
|
125
|
-
|
|
125
|
+
runtimeContext,
|
|
126
126
|
agentId,
|
|
127
127
|
body
|
|
128
128
|
}) {
|
|
@@ -138,7 +138,7 @@ async function streamGenerateHandler({
|
|
|
138
138
|
...rest,
|
|
139
139
|
// @ts-expect-error TODO fix types
|
|
140
140
|
resourceId: finalResourceId,
|
|
141
|
-
|
|
141
|
+
runtimeContext
|
|
142
142
|
});
|
|
143
143
|
const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
144
144
|
sendUsage: true,
|
|
@@ -69,7 +69,7 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
69
69
|
}
|
|
70
70
|
async function generateHandler({
|
|
71
71
|
mastra,
|
|
72
|
-
|
|
72
|
+
runtimeContext,
|
|
73
73
|
networkId,
|
|
74
74
|
body
|
|
75
75
|
}) {
|
|
@@ -80,7 +80,7 @@ async function generateHandler({
|
|
|
80
80
|
}
|
|
81
81
|
validateBody({ messages: body.messages });
|
|
82
82
|
const { messages, ...rest } = body;
|
|
83
|
-
const result = await network.generate(messages, { ...rest,
|
|
83
|
+
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
84
84
|
return result;
|
|
85
85
|
} catch (error) {
|
|
86
86
|
return handleError(error, "Error generating from network");
|
|
@@ -90,7 +90,7 @@ async function streamGenerateHandler({
|
|
|
90
90
|
mastra,
|
|
91
91
|
networkId,
|
|
92
92
|
body,
|
|
93
|
-
|
|
93
|
+
runtimeContext
|
|
94
94
|
}) {
|
|
95
95
|
try {
|
|
96
96
|
const network = mastra.getNetwork(networkId);
|
|
@@ -102,7 +102,7 @@ async function streamGenerateHandler({
|
|
|
102
102
|
const streamResult = await network.stream(messages, {
|
|
103
103
|
output,
|
|
104
104
|
...rest,
|
|
105
|
-
|
|
105
|
+
runtimeContext
|
|
106
106
|
});
|
|
107
107
|
const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
108
108
|
sendUsage: true,
|
|
@@ -80,7 +80,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
80
80
|
}
|
|
81
81
|
async function startAsyncWorkflowHandler({
|
|
82
82
|
mastra,
|
|
83
|
-
|
|
83
|
+
runtimeContext,
|
|
84
84
|
workflowId,
|
|
85
85
|
runId,
|
|
86
86
|
triggerData
|
|
@@ -97,7 +97,7 @@ async function startAsyncWorkflowHandler({
|
|
|
97
97
|
const { start } = workflow.createRun();
|
|
98
98
|
const result2 = await start({
|
|
99
99
|
triggerData,
|
|
100
|
-
|
|
100
|
+
runtimeContext
|
|
101
101
|
});
|
|
102
102
|
return result2;
|
|
103
103
|
}
|
|
@@ -107,7 +107,7 @@ async function startAsyncWorkflowHandler({
|
|
|
107
107
|
}
|
|
108
108
|
const result = await run.start({
|
|
109
109
|
triggerData,
|
|
110
|
-
|
|
110
|
+
runtimeContext
|
|
111
111
|
});
|
|
112
112
|
return result;
|
|
113
113
|
} catch (error) {
|
|
@@ -160,7 +160,7 @@ async function createRunHandler({
|
|
|
160
160
|
}
|
|
161
161
|
async function startWorkflowRunHandler({
|
|
162
162
|
mastra,
|
|
163
|
-
|
|
163
|
+
runtimeContext,
|
|
164
164
|
workflowId,
|
|
165
165
|
runId,
|
|
166
166
|
triggerData
|
|
@@ -179,7 +179,7 @@ async function startWorkflowRunHandler({
|
|
|
179
179
|
}
|
|
180
180
|
await run.start({
|
|
181
181
|
triggerData,
|
|
182
|
-
|
|
182
|
+
runtimeContext
|
|
183
183
|
});
|
|
184
184
|
return { message: "Workflow run started" };
|
|
185
185
|
} catch (e) {
|
|
@@ -235,7 +235,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
235
235
|
workflowId,
|
|
236
236
|
runId,
|
|
237
237
|
body,
|
|
238
|
-
|
|
238
|
+
runtimeContext
|
|
239
239
|
}) {
|
|
240
240
|
try {
|
|
241
241
|
if (!workflowId) {
|
|
@@ -252,7 +252,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
252
252
|
const result = await run.resume({
|
|
253
253
|
stepId: body.stepId,
|
|
254
254
|
context: body.context,
|
|
255
|
-
|
|
255
|
+
runtimeContext
|
|
256
256
|
});
|
|
257
257
|
return result;
|
|
258
258
|
} catch (error) {
|
|
@@ -264,7 +264,7 @@ async function resumeWorkflowHandler({
|
|
|
264
264
|
workflowId,
|
|
265
265
|
runId,
|
|
266
266
|
body,
|
|
267
|
-
|
|
267
|
+
runtimeContext
|
|
268
268
|
}) {
|
|
269
269
|
try {
|
|
270
270
|
if (!workflowId) {
|
|
@@ -281,7 +281,7 @@ async function resumeWorkflowHandler({
|
|
|
281
281
|
await run.resume({
|
|
282
282
|
stepId: body.stepId,
|
|
283
283
|
context: body.context,
|
|
284
|
-
|
|
284
|
+
runtimeContext
|
|
285
285
|
});
|
|
286
286
|
return { message: "Workflow run resumed" };
|
|
287
287
|
} catch (error) {
|