@mastra/server 0.0.0-switch-to-core-20250424015131 → 0.0.0-vnext-inngest-20250506123700
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 +104 -7
- package/dist/_tsup-dts-rollup.d.ts +104 -7
- package/dist/{chunk-LFOBHRFO.js → chunk-3XTEV33Q.js} +16 -4
- package/dist/{chunk-HCOPJZ4A.cjs → chunk-4BIX6GMY.cjs} +52 -27
- package/dist/{chunk-FPIWDH5Y.cjs → chunk-5YGDYMRB.cjs} +48 -27
- package/dist/{chunk-7IWQE76Z.cjs → chunk-AMVOS7YB.cjs} +4 -2
- package/dist/{chunk-WTHDCRMY.js → chunk-BPL2CBLV.js} +4 -2
- package/dist/{chunk-TZK63M5N.cjs → chunk-CHFORQ7J.cjs} +16 -4
- package/dist/chunk-M2RXDCPV.cjs +324 -0
- package/dist/chunk-OWNA6I2H.js +312 -0
- package/dist/{chunk-RE6YL32K.js → chunk-QJ3AHN64.js} +48 -27
- package/dist/{chunk-R4J7XQYU.js → chunk-Y3SV5XK4.js} +52 -27
- 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/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/workflows.cjs +11 -11
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +13 -8
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +5 -4
- package/package.json +5 -5
|
@@ -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 };
|
|
@@ -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;
|
|
@@ -13,27 +13,35 @@ __export(agents_exports, {
|
|
|
13
13
|
getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
|
|
14
14
|
streamGenerateHandler: () => streamGenerateHandler
|
|
15
15
|
});
|
|
16
|
-
async function getAgentsHandler({ mastra }) {
|
|
16
|
+
async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
17
17
|
try {
|
|
18
18
|
const agents = mastra.getAgents();
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const serializedAgentsMap = await Promise.all(
|
|
20
|
+
Object.entries(agents).map(async ([id, agent]) => {
|
|
21
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
22
|
+
const tools = await agent.getTools({ runtimeContext });
|
|
23
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
24
|
+
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
25
|
+
const _tool = tool;
|
|
26
|
+
acc[key] = {
|
|
27
|
+
..._tool,
|
|
28
|
+
inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
|
|
29
|
+
outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
|
|
30
|
+
};
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
return {
|
|
34
|
+
id,
|
|
35
|
+
name: agent.name,
|
|
36
|
+
instructions,
|
|
37
|
+
tools: serializedAgentTools,
|
|
38
|
+
provider: llm?.getProvider(),
|
|
39
|
+
modelId: llm?.getModelId()
|
|
27
40
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
instructions: agent.instructions,
|
|
33
|
-
tools: serializedAgentTools,
|
|
34
|
-
provider: agent.llm?.getProvider(),
|
|
35
|
-
modelId: agent.llm?.getModelId()
|
|
36
|
-
};
|
|
41
|
+
})
|
|
42
|
+
);
|
|
43
|
+
const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
|
|
44
|
+
acc[id] = rest;
|
|
37
45
|
return acc;
|
|
38
46
|
}, {});
|
|
39
47
|
return serializedAgents;
|
|
@@ -41,13 +49,18 @@ async function getAgentsHandler({ mastra }) {
|
|
|
41
49
|
return handleError(error, "Error getting agents");
|
|
42
50
|
}
|
|
43
51
|
}
|
|
44
|
-
async function getAgentByIdHandler({
|
|
52
|
+
async function getAgentByIdHandler({
|
|
53
|
+
mastra,
|
|
54
|
+
runtimeContext,
|
|
55
|
+
agentId
|
|
56
|
+
}) {
|
|
45
57
|
try {
|
|
46
58
|
const agent = mastra.getAgent(agentId);
|
|
47
59
|
if (!agent) {
|
|
48
60
|
throw new HTTPException(404, { message: "Agent not found" });
|
|
49
61
|
}
|
|
50
|
-
const
|
|
62
|
+
const tools = await agent.getTools({ runtimeContext });
|
|
63
|
+
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
51
64
|
const _tool = tool;
|
|
52
65
|
acc[key] = {
|
|
53
66
|
..._tool,
|
|
@@ -56,39 +69,51 @@ async function getAgentByIdHandler({ mastra, agentId }) {
|
|
|
56
69
|
};
|
|
57
70
|
return acc;
|
|
58
71
|
}, {});
|
|
72
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
73
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
59
74
|
return {
|
|
60
75
|
name: agent.name,
|
|
61
|
-
instructions
|
|
76
|
+
instructions,
|
|
62
77
|
tools: serializedAgentTools,
|
|
63
|
-
provider:
|
|
64
|
-
modelId:
|
|
78
|
+
provider: llm?.getProvider(),
|
|
79
|
+
modelId: llm?.getModelId()
|
|
65
80
|
};
|
|
66
81
|
} catch (error) {
|
|
67
82
|
return handleError(error, "Error getting agent");
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
|
-
async function getEvalsByAgentIdHandler({
|
|
85
|
+
async function getEvalsByAgentIdHandler({
|
|
86
|
+
mastra,
|
|
87
|
+
runtimeContext,
|
|
88
|
+
agentId
|
|
89
|
+
}) {
|
|
71
90
|
try {
|
|
72
91
|
const agent = mastra.getAgent(agentId);
|
|
73
92
|
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
|
|
93
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
74
94
|
return {
|
|
75
95
|
id: agentId,
|
|
76
96
|
name: agent.name,
|
|
77
|
-
instructions
|
|
97
|
+
instructions,
|
|
78
98
|
evals
|
|
79
99
|
};
|
|
80
100
|
} catch (error) {
|
|
81
101
|
return handleError(error, "Error getting test evals");
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
|
-
async function getLiveEvalsByAgentIdHandler({
|
|
104
|
+
async function getLiveEvalsByAgentIdHandler({
|
|
105
|
+
mastra,
|
|
106
|
+
runtimeContext,
|
|
107
|
+
agentId
|
|
108
|
+
}) {
|
|
85
109
|
try {
|
|
86
110
|
const agent = mastra.getAgent(agentId);
|
|
87
111
|
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
|
|
112
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
88
113
|
return {
|
|
89
114
|
id: agentId,
|
|
90
115
|
name: agent.name,
|
|
91
|
-
instructions
|
|
116
|
+
instructions,
|
|
92
117
|
evals
|
|
93
118
|
};
|
|
94
119
|
} catch (error) {
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4BIX6GMY_cjs = require('../../chunk-4BIX6GMY.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 chunk4BIX6GMY_cjs.generateHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "getAgentByIdHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk4BIX6GMY_cjs.getAgentByIdHandler; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getAgentsHandler", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk4BIX6GMY_cjs.getAgentsHandler; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getEvalsByAgentIdHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk4BIX6GMY_cjs.getEvalsByAgentIdHandler; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "getLiveEvalsByAgentIdHandler", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk4BIX6GMY_cjs.getLiveEvalsByAgentIdHandler; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "streamGenerateHandler", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk4BIX6GMY_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-Y3SV5XK4.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';
|