@mastra/server 0.0.0-message-ordering-20250415215612 → 0.0.0-redis-cloud-transporter-20250508191651
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 +128 -31
- package/dist/_tsup-dts-rollup.d.ts +128 -31
- package/dist/{chunk-OPP7H5TW.js → chunk-3XTEV33Q.js} +26 -14
- 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-Z46X3YCB.cjs → chunk-6Q7UXAYJ.cjs} +72 -38
- package/dist/{chunk-CWSDZEZG.cjs → chunk-AMVOS7YB.cjs} +6 -4
- package/dist/{chunk-DVPP5S6I.js → chunk-BPL2CBLV.js} +6 -4
- package/dist/{chunk-B64YROKU.cjs → chunk-CHFORQ7J.cjs} +32 -20
- package/dist/{chunk-PDC4ZBQW.cjs → chunk-D3G23FP3.cjs} +9 -9
- package/dist/{chunk-67WTHYAV.js → chunk-GVBJ5I2S.js} +70 -36
- package/dist/chunk-M2RXDCPV.cjs +324 -0
- package/dist/{chunk-VK6FX47H.js → chunk-OMN3UI6X.js} +38 -38
- package/dist/chunk-OWNA6I2H.js +312 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-Q6SHQECN.js} +2 -9
- package/dist/{chunk-YANVFOYA.js → chunk-QJ3AHN64.js} +52 -31
- 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/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/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 +17 -12
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +7 -6
- package/package.json +6 -6
|
@@ -0,0 +1,312 @@
|
|
|
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
|
+
getVNextWorkflowRunByIdHandler: () => getVNextWorkflowRunByIdHandler,
|
|
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
|
+
id: step.id,
|
|
29
|
+
description: step.description,
|
|
30
|
+
inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
|
|
31
|
+
outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
|
|
32
|
+
resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
|
|
33
|
+
suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
|
|
34
|
+
};
|
|
35
|
+
return acc2;
|
|
36
|
+
}, {}),
|
|
37
|
+
stepGraph: workflow.serializedStepGraph,
|
|
38
|
+
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
39
|
+
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
40
|
+
};
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
return _workflows;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
|
|
49
|
+
try {
|
|
50
|
+
if (!workflowId) {
|
|
51
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
52
|
+
}
|
|
53
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
54
|
+
if (!workflow) {
|
|
55
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
59
|
+
acc[key] = {
|
|
60
|
+
id: step.id,
|
|
61
|
+
description: step.description,
|
|
62
|
+
inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
|
|
63
|
+
outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
|
|
64
|
+
resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
|
|
65
|
+
suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
|
|
66
|
+
};
|
|
67
|
+
return acc;
|
|
68
|
+
}, {}),
|
|
69
|
+
name: workflow.name,
|
|
70
|
+
stepGraph: workflow.serializedStepGraph,
|
|
71
|
+
inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
|
|
72
|
+
outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
|
|
73
|
+
};
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function getVNextWorkflowRunByIdHandler({
|
|
79
|
+
mastra,
|
|
80
|
+
workflowId,
|
|
81
|
+
runId
|
|
82
|
+
}) {
|
|
83
|
+
try {
|
|
84
|
+
if (!workflowId) {
|
|
85
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
86
|
+
}
|
|
87
|
+
if (!runId) {
|
|
88
|
+
throw new HTTPException(400, { message: "Run ID is required" });
|
|
89
|
+
}
|
|
90
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
91
|
+
if (!workflow) {
|
|
92
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
93
|
+
}
|
|
94
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
95
|
+
if (!run) {
|
|
96
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
97
|
+
}
|
|
98
|
+
return run;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function createVNextWorkflowRunHandler({
|
|
104
|
+
mastra,
|
|
105
|
+
workflowId,
|
|
106
|
+
runId: prevRunId
|
|
107
|
+
}) {
|
|
108
|
+
try {
|
|
109
|
+
if (!workflowId) {
|
|
110
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
111
|
+
}
|
|
112
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
113
|
+
if (!workflow) {
|
|
114
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
115
|
+
}
|
|
116
|
+
const run = workflow.createRun({ runId: prevRunId });
|
|
117
|
+
return { runId: run.runId };
|
|
118
|
+
} catch (error) {
|
|
119
|
+
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function startAsyncVNextWorkflowHandler({
|
|
123
|
+
mastra,
|
|
124
|
+
runtimeContext,
|
|
125
|
+
workflowId,
|
|
126
|
+
runId,
|
|
127
|
+
inputData
|
|
128
|
+
}) {
|
|
129
|
+
try {
|
|
130
|
+
if (!workflowId) {
|
|
131
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
132
|
+
}
|
|
133
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
134
|
+
if (!workflow) {
|
|
135
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
136
|
+
}
|
|
137
|
+
const _run = workflow.createRun({ runId });
|
|
138
|
+
const result = await _run.start({
|
|
139
|
+
inputData,
|
|
140
|
+
runtimeContext
|
|
141
|
+
});
|
|
142
|
+
return result;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function startVNextWorkflowRunHandler({
|
|
148
|
+
mastra,
|
|
149
|
+
runtimeContext,
|
|
150
|
+
workflowId,
|
|
151
|
+
runId,
|
|
152
|
+
inputData
|
|
153
|
+
}) {
|
|
154
|
+
try {
|
|
155
|
+
if (!workflowId) {
|
|
156
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
157
|
+
}
|
|
158
|
+
if (!runId) {
|
|
159
|
+
throw new HTTPException(400, { message: "runId required to start run" });
|
|
160
|
+
}
|
|
161
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
162
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
163
|
+
if (!run) {
|
|
164
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
165
|
+
}
|
|
166
|
+
const _run = workflow.createRun({ runId });
|
|
167
|
+
await _run.start({
|
|
168
|
+
inputData,
|
|
169
|
+
runtimeContext
|
|
170
|
+
});
|
|
171
|
+
return { message: "Workflow run started" };
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return handleError(e, "Error starting workflow run");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async function watchVNextWorkflowHandler({
|
|
177
|
+
mastra,
|
|
178
|
+
workflowId,
|
|
179
|
+
runId
|
|
180
|
+
}) {
|
|
181
|
+
try {
|
|
182
|
+
if (!workflowId) {
|
|
183
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
184
|
+
}
|
|
185
|
+
if (!runId) {
|
|
186
|
+
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
187
|
+
}
|
|
188
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
189
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
190
|
+
if (!run) {
|
|
191
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
192
|
+
}
|
|
193
|
+
const _run = workflow.createRun({ runId });
|
|
194
|
+
let unwatch;
|
|
195
|
+
let asyncRef = null;
|
|
196
|
+
const stream = new ReadableStream({
|
|
197
|
+
start(controller) {
|
|
198
|
+
unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
|
|
199
|
+
controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
|
|
200
|
+
if (asyncRef) {
|
|
201
|
+
clearImmediate(asyncRef);
|
|
202
|
+
asyncRef = null;
|
|
203
|
+
}
|
|
204
|
+
asyncRef = setImmediate(async () => {
|
|
205
|
+
const runDone = payload.workflowState.status !== "running";
|
|
206
|
+
if (runDone) {
|
|
207
|
+
controller.close();
|
|
208
|
+
unwatch?.();
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
cancel() {
|
|
214
|
+
unwatch?.();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return stream;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
return handleError(error, "Error watching workflow");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function resumeAsyncVNextWorkflowHandler({
|
|
223
|
+
mastra,
|
|
224
|
+
workflowId,
|
|
225
|
+
runId,
|
|
226
|
+
body,
|
|
227
|
+
runtimeContext
|
|
228
|
+
}) {
|
|
229
|
+
try {
|
|
230
|
+
if (!workflowId) {
|
|
231
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
232
|
+
}
|
|
233
|
+
if (!runId) {
|
|
234
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
235
|
+
}
|
|
236
|
+
if (!body.step) {
|
|
237
|
+
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
238
|
+
}
|
|
239
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
240
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
241
|
+
if (!run) {
|
|
242
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
243
|
+
}
|
|
244
|
+
const _run = workflow.createRun({ runId });
|
|
245
|
+
const result = await _run.resume({
|
|
246
|
+
step: body.step,
|
|
247
|
+
resumeData: body.resumeData,
|
|
248
|
+
runtimeContext
|
|
249
|
+
});
|
|
250
|
+
return result;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
return handleError(error, "Error resuming workflow step");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function resumeVNextWorkflowHandler({
|
|
256
|
+
mastra,
|
|
257
|
+
workflowId,
|
|
258
|
+
runId,
|
|
259
|
+
body,
|
|
260
|
+
runtimeContext
|
|
261
|
+
}) {
|
|
262
|
+
try {
|
|
263
|
+
if (!workflowId) {
|
|
264
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
265
|
+
}
|
|
266
|
+
if (!runId) {
|
|
267
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
268
|
+
}
|
|
269
|
+
if (!body.step) {
|
|
270
|
+
throw new HTTPException(400, { message: "step required to resume workflow" });
|
|
271
|
+
}
|
|
272
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
273
|
+
const run = await workflow.getWorkflowRunById(runId);
|
|
274
|
+
if (!run) {
|
|
275
|
+
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
276
|
+
}
|
|
277
|
+
const _run = workflow.createRun({ runId });
|
|
278
|
+
await _run.resume({
|
|
279
|
+
step: body.step,
|
|
280
|
+
resumeData: body.resumeData,
|
|
281
|
+
runtimeContext
|
|
282
|
+
});
|
|
283
|
+
return { message: "Workflow run resumed" };
|
|
284
|
+
} catch (error) {
|
|
285
|
+
return handleError(error, "Error resuming workflow");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
async function getVNextWorkflowRunsHandler({
|
|
289
|
+
mastra,
|
|
290
|
+
workflowId,
|
|
291
|
+
fromDate,
|
|
292
|
+
toDate,
|
|
293
|
+
limit,
|
|
294
|
+
offset,
|
|
295
|
+
resourceId
|
|
296
|
+
}) {
|
|
297
|
+
try {
|
|
298
|
+
if (!workflowId) {
|
|
299
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
300
|
+
}
|
|
301
|
+
const workflow = mastra.vnext_getWorkflow(workflowId);
|
|
302
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
303
|
+
runs: [],
|
|
304
|
+
total: 0
|
|
305
|
+
};
|
|
306
|
+
return workflowRuns;
|
|
307
|
+
} catch (error) {
|
|
308
|
+
return handleError(error, "Error getting workflow runs");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunByIdHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };
|
|
@@ -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
|
}
|
|
@@ -10,33 +10,48 @@ __export(network_exports, {
|
|
|
10
10
|
getNetworksHandler: () => getNetworksHandler,
|
|
11
11
|
streamGenerateHandler: () => streamGenerateHandler
|
|
12
12
|
});
|
|
13
|
-
async function getNetworksHandler({
|
|
13
|
+
async function getNetworksHandler({
|
|
14
|
+
mastra,
|
|
15
|
+
runtimeContext
|
|
16
|
+
}) {
|
|
14
17
|
try {
|
|
15
18
|
const networks = mastra.getNetworks();
|
|
16
|
-
const serializedNetworks =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const serializedNetworks = await Promise.all(
|
|
20
|
+
networks.map(async (network) => {
|
|
21
|
+
const routingAgent = network.getRoutingAgent();
|
|
22
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
23
|
+
const agents = network.getAgents();
|
|
24
|
+
return {
|
|
25
|
+
id: network.formatAgentId(routingAgent.name),
|
|
26
|
+
name: routingAgent.name,
|
|
27
|
+
instructions: routingAgent.instructions,
|
|
28
|
+
agents: await Promise.all(
|
|
29
|
+
agents.map(async (agent) => {
|
|
30
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
31
|
+
return {
|
|
32
|
+
name: agent.name,
|
|
33
|
+
provider: llm?.getProvider(),
|
|
34
|
+
modelId: llm?.getModelId()
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
),
|
|
38
|
+
routingModel: {
|
|
39
|
+
provider: routingLLM?.getProvider(),
|
|
40
|
+
modelId: routingLLM?.getModelId()
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
})
|
|
44
|
+
);
|
|
34
45
|
return serializedNetworks;
|
|
35
46
|
} catch (error) {
|
|
36
47
|
return handleError(error, "Error getting networks");
|
|
37
48
|
}
|
|
38
49
|
}
|
|
39
|
-
async function getNetworkByIdHandler({
|
|
50
|
+
async function getNetworkByIdHandler({
|
|
51
|
+
mastra,
|
|
52
|
+
networkId,
|
|
53
|
+
runtimeContext
|
|
54
|
+
}) {
|
|
40
55
|
try {
|
|
41
56
|
const networks = mastra.getNetworks();
|
|
42
57
|
const network = networks.find((network2) => {
|
|
@@ -47,19 +62,25 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
47
62
|
throw new HTTPException(404, { message: "Network not found" });
|
|
48
63
|
}
|
|
49
64
|
const routingAgent = network.getRoutingAgent();
|
|
65
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
50
66
|
const agents = network.getAgents();
|
|
51
67
|
const serializedNetwork = {
|
|
52
68
|
id: network.formatAgentId(routingAgent.name),
|
|
53
69
|
name: routingAgent.name,
|
|
54
70
|
instructions: routingAgent.instructions,
|
|
55
|
-
agents:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
agents: await Promise.all(
|
|
72
|
+
agents.map(async (agent) => {
|
|
73
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
74
|
+
return {
|
|
75
|
+
name: agent.name,
|
|
76
|
+
provider: llm?.getProvider(),
|
|
77
|
+
modelId: llm?.getModelId()
|
|
78
|
+
};
|
|
79
|
+
})
|
|
80
|
+
),
|
|
60
81
|
routingModel: {
|
|
61
|
-
provider:
|
|
62
|
-
modelId:
|
|
82
|
+
provider: routingLLM?.getProvider(),
|
|
83
|
+
modelId: routingLLM?.getModelId()
|
|
63
84
|
}
|
|
64
85
|
};
|
|
65
86
|
return serializedNetwork;
|
|
@@ -69,7 +90,7 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
69
90
|
}
|
|
70
91
|
async function generateHandler({
|
|
71
92
|
mastra,
|
|
72
|
-
|
|
93
|
+
runtimeContext,
|
|
73
94
|
networkId,
|
|
74
95
|
body
|
|
75
96
|
}) {
|
|
@@ -80,7 +101,7 @@ async function generateHandler({
|
|
|
80
101
|
}
|
|
81
102
|
validateBody({ messages: body.messages });
|
|
82
103
|
const { messages, ...rest } = body;
|
|
83
|
-
const result = await network.generate(messages, { ...rest,
|
|
104
|
+
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
84
105
|
return result;
|
|
85
106
|
} catch (error) {
|
|
86
107
|
return handleError(error, "Error generating from network");
|
|
@@ -90,7 +111,7 @@ async function streamGenerateHandler({
|
|
|
90
111
|
mastra,
|
|
91
112
|
networkId,
|
|
92
113
|
body,
|
|
93
|
-
|
|
114
|
+
runtimeContext
|
|
94
115
|
}) {
|
|
95
116
|
try {
|
|
96
117
|
const network = mastra.getNetwork(networkId);
|
|
@@ -102,7 +123,7 @@ async function streamGenerateHandler({
|
|
|
102
123
|
const streamResult = await network.stream(messages, {
|
|
103
124
|
output,
|
|
104
125
|
...rest,
|
|
105
|
-
|
|
126
|
+
runtimeContext
|
|
106
127
|
});
|
|
107
128
|
const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
108
129
|
sendUsage: true,
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6Q7UXAYJ_cjs = require('../../chunk-6Q7UXAYJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "generateHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk6Q7UXAYJ_cjs.generateHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "getAgentByIdHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk6Q7UXAYJ_cjs.getAgentByIdHandler; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getAgentsHandler", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk6Q7UXAYJ_cjs.getAgentsHandler; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getEvalsByAgentIdHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk6Q7UXAYJ_cjs.getEvalsByAgentIdHandler; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "getLiveEvalsByAgentIdHandler", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk6Q7UXAYJ_cjs.getLiveEvalsByAgentIdHandler; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "streamGenerateHandler", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk6Q7UXAYJ_cjs.streamGenerateHandler; }
|
|
30
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-
|
|
1
|
+
export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-GVBJ5I2S.js';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5YGDYMRB_cjs = require('../../chunk-5YGDYMRB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "generateHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk5YGDYMRB_cjs.generateHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "getNetworkByIdHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk5YGDYMRB_cjs.getNetworkByIdHandler; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getNetworksHandler", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk5YGDYMRB_cjs.getNetworksHandler; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "streamGenerateHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk5YGDYMRB_cjs.streamGenerateHandler; }
|
|
22
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { generateHandler, getNetworkByIdHandler, getNetworksHandler, streamGenerateHandler } from '../../chunk-
|
|
1
|
+
export { generateHandler, getNetworkByIdHandler, getNetworksHandler, streamGenerateHandler } from '../../chunk-QJ3AHN64.js';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAMVOS7YB_cjs = require('../../chunk-AMVOS7YB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "getTelemetryHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkAMVOS7YB_cjs.getTelemetryHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "storeTelemetryHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkAMVOS7YB_cjs.storeTelemetryHandler; }
|
|
14
14
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getTelemetryHandler, storeTelemetryHandler } from '../../chunk-
|
|
1
|
+
export { getTelemetryHandler, storeTelemetryHandler } from '../../chunk-BPL2CBLV.js';
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkD3G23FP3_cjs = require('../../chunk-D3G23FP3.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "executeAgentToolHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkD3G23FP3_cjs.executeAgentToolHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "executeToolHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkD3G23FP3_cjs.executeToolHandler; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getToolByIdHandler", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkD3G23FP3_cjs.getToolByIdHandler; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getToolsHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkD3G23FP3_cjs.getToolsHandler; }
|
|
22
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { executeAgentToolHandler, executeToolHandler, getToolByIdHandler, getToolsHandler } from '../../chunk-
|
|
1
|
+
export { executeAgentToolHandler, executeToolHandler, getToolByIdHandler, getToolsHandler } from '../../chunk-5JNVY6DU.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkM2RXDCPV_cjs = require('../../chunk-M2RXDCPV.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "createVNextWorkflowRunHandler", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkM2RXDCPV_cjs.createVNextWorkflowRunHandler; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "getVNextWorkflowByIdHandler", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkM2RXDCPV_cjs.getVNextWorkflowByIdHandler; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "getVNextWorkflowRunByIdHandler", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkM2RXDCPV_cjs.getVNextWorkflowRunByIdHandler; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getVNextWorkflowRunsHandler", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkM2RXDCPV_cjs.getVNextWorkflowRunsHandler; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "getVNextWorkflowsHandler", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkM2RXDCPV_cjs.getVNextWorkflowsHandler; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "resumeAsyncVNextWorkflowHandler", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkM2RXDCPV_cjs.resumeAsyncVNextWorkflowHandler; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "resumeVNextWorkflowHandler", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkM2RXDCPV_cjs.resumeVNextWorkflowHandler; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "startAsyncVNextWorkflowHandler", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkM2RXDCPV_cjs.startAsyncVNextWorkflowHandler; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "startVNextWorkflowRunHandler", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkM2RXDCPV_cjs.startVNextWorkflowRunHandler; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "watchVNextWorkflowHandler", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkM2RXDCPV_cjs.watchVNextWorkflowHandler; }
|
|
46
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { getVNextWorkflowsHandler } from '../../_tsup-dts-rollup.cjs';
|
|
2
|
+
export { getVNextWorkflowByIdHandler } from '../../_tsup-dts-rollup.cjs';
|
|
3
|
+
export { getVNextWorkflowRunByIdHandler } from '../../_tsup-dts-rollup.cjs';
|
|
4
|
+
export { createVNextWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
|
|
5
|
+
export { startAsyncVNextWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
6
|
+
export { startVNextWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
|
|
7
|
+
export { watchVNextWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
8
|
+
export { resumeAsyncVNextWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
9
|
+
export { resumeVNextWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
10
|
+
export { getVNextWorkflowRunsHandler } from '../../_tsup-dts-rollup.cjs';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { getVNextWorkflowsHandler } from '../../_tsup-dts-rollup.js';
|
|
2
|
+
export { getVNextWorkflowByIdHandler } from '../../_tsup-dts-rollup.js';
|
|
3
|
+
export { getVNextWorkflowRunByIdHandler } from '../../_tsup-dts-rollup.js';
|
|
4
|
+
export { createVNextWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
|
|
5
|
+
export { startAsyncVNextWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
6
|
+
export { startVNextWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
|
|
7
|
+
export { watchVNextWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
8
|
+
export { resumeAsyncVNextWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
9
|
+
export { resumeVNextWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
10
|
+
export { getVNextWorkflowRunsHandler } from '../../_tsup-dts-rollup.js';
|