@mastra/server 0.0.1-alpha.0
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/LICENSE +44 -0
- package/README.md +159 -0
- package/dist/_tsup-dts-rollup.d.cts +592 -0
- package/dist/_tsup-dts-rollup.d.ts +592 -0
- package/dist/chunk-2FJURXCL.cjs +213 -0
- package/dist/chunk-2JQC6JWP.js +46 -0
- package/dist/chunk-2YONKUWB.js +117 -0
- package/dist/chunk-3AHQ5RGN.js +11 -0
- package/dist/chunk-3RVHWGWO.js +95 -0
- package/dist/chunk-4C3EPMMF.cjs +122 -0
- package/dist/chunk-4JINXASC.js +120 -0
- package/dist/chunk-5JOF627H.cjs +123 -0
- package/dist/chunk-5MCUD7TP.js +142 -0
- package/dist/chunk-5WF7YIIE.cjs +150 -0
- package/dist/chunk-A4DCRMIV.js +125 -0
- package/dist/chunk-A7DF4ETD.cjs +100 -0
- package/dist/chunk-FV45V6WC.cjs +43 -0
- package/dist/chunk-L7XE5QTW.js +16 -0
- package/dist/chunk-M56ECCHK.cjs +128 -0
- package/dist/chunk-QH6XWSXP.cjs +5579 -0
- package/dist/chunk-QN4KF3BH.cjs +18 -0
- package/dist/chunk-RBQASTUP.js +203 -0
- package/dist/chunk-S6GTZWMY.js +275 -0
- package/dist/chunk-SKKC3EDG.cjs +286 -0
- package/dist/chunk-TRDNDNGQ.js +40 -0
- package/dist/chunk-VB7KH62D.cjs +51 -0
- package/dist/chunk-VK6FX47H.js +5576 -0
- package/dist/chunk-YCJ2OJTL.cjs +129 -0
- package/dist/chunk-YNSGUC2O.js +116 -0
- package/dist/chunk-ZLBRQFDD.cjs +13 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server/handlers/agents.cjs +30 -0
- package/dist/server/handlers/agents.d.cts +6 -0
- package/dist/server/handlers/agents.d.ts +6 -0
- package/dist/server/handlers/agents.js +1 -0
- package/dist/server/handlers/error.cjs +10 -0
- package/dist/server/handlers/error.d.cts +1 -0
- package/dist/server/handlers/error.d.ts +1 -0
- package/dist/server/handlers/error.js +1 -0
- package/dist/server/handlers/logs.cjs +18 -0
- package/dist/server/handlers/logs.d.cts +3 -0
- package/dist/server/handlers/logs.d.ts +3 -0
- package/dist/server/handlers/logs.js +1 -0
- package/dist/server/handlers/memory.cjs +38 -0
- package/dist/server/handlers/memory.d.cts +8 -0
- package/dist/server/handlers/memory.d.ts +8 -0
- package/dist/server/handlers/memory.js +1 -0
- package/dist/server/handlers/network.cjs +22 -0
- package/dist/server/handlers/network.d.cts +4 -0
- package/dist/server/handlers/network.d.ts +4 -0
- package/dist/server/handlers/network.js +1 -0
- package/dist/server/handlers/telemetry.cjs +14 -0
- package/dist/server/handlers/telemetry.d.cts +2 -0
- package/dist/server/handlers/telemetry.d.ts +2 -0
- package/dist/server/handlers/telemetry.js +1 -0
- package/dist/server/handlers/tools.cjs +22 -0
- package/dist/server/handlers/tools.d.cts +4 -0
- package/dist/server/handlers/tools.d.ts +4 -0
- package/dist/server/handlers/tools.js +1 -0
- package/dist/server/handlers/utils.cjs +10 -0
- package/dist/server/handlers/utils.d.cts +1 -0
- package/dist/server/handlers/utils.d.ts +1 -0
- package/dist/server/handlers/utils.js +1 -0
- package/dist/server/handlers/vector.cjs +30 -0
- package/dist/server/handlers/vector.d.cts +6 -0
- package/dist/server/handlers/vector.d.ts +6 -0
- package/dist/server/handlers/vector.js +1 -0
- package/dist/server/handlers/voice.cjs +18 -0
- package/dist/server/handlers/voice.d.cts +3 -0
- package/dist/server/handlers/voice.d.ts +3 -0
- package/dist/server/handlers/voice.js +1 -0
- package/dist/server/handlers/workflows.cjs +42 -0
- package/dist/server/handlers/workflows.d.cts +9 -0
- package/dist/server/handlers/workflows.d.ts +9 -0
- package/dist/server/handlers/workflows.js +1 -0
- package/dist/server/handlers.cjs +50 -0
- package/dist/server/handlers.d.cts +9 -0
- package/dist/server/handlers.d.ts +9 -0
- package/dist/server/handlers.js +9 -0
- package/package.json +71 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQH6XWSXP_cjs = require('./chunk-QH6XWSXP.cjs');
|
|
4
|
+
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
5
|
+
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
6
|
+
var web = require('stream/web');
|
|
7
|
+
|
|
8
|
+
// src/server/handlers/workflows.ts
|
|
9
|
+
var workflows_exports = {};
|
|
10
|
+
chunkFV45V6WC_cjs.__export(workflows_exports, {
|
|
11
|
+
createRunHandler: () => createRunHandler,
|
|
12
|
+
getWorkflowByIdHandler: () => getWorkflowByIdHandler,
|
|
13
|
+
getWorkflowRunHandler: () => getWorkflowRunHandler,
|
|
14
|
+
getWorkflowsHandler: () => getWorkflowsHandler,
|
|
15
|
+
resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
|
|
16
|
+
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
17
|
+
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
18
|
+
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
19
|
+
watchWorkflowHandler: () => watchWorkflowHandler
|
|
20
|
+
});
|
|
21
|
+
async function getWorkflowsHandler({ mastra }) {
|
|
22
|
+
try {
|
|
23
|
+
const workflows = mastra.getWorkflows({ serialized: false });
|
|
24
|
+
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
25
|
+
acc[key] = {
|
|
26
|
+
stepGraph: workflow.stepGraph,
|
|
27
|
+
stepSubscriberGraph: workflow.stepSubscriberGraph,
|
|
28
|
+
serializedStepGraph: workflow.serializedStepGraph,
|
|
29
|
+
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
30
|
+
name: workflow.name,
|
|
31
|
+
triggerSchema: workflow.triggerSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
32
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
33
|
+
const _step = step;
|
|
34
|
+
acc2[key2] = {
|
|
35
|
+
..._step,
|
|
36
|
+
inputSchema: _step.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
37
|
+
outputSchema: _step.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.outputSchema)) : void 0
|
|
38
|
+
};
|
|
39
|
+
return acc2;
|
|
40
|
+
}, {})
|
|
41
|
+
};
|
|
42
|
+
return acc;
|
|
43
|
+
}, {});
|
|
44
|
+
return _workflows;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
50
|
+
try {
|
|
51
|
+
if (!workflowId) {
|
|
52
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
53
|
+
}
|
|
54
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
55
|
+
if (!workflow) {
|
|
56
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
stepGraph: workflow.stepGraph,
|
|
60
|
+
stepSubscriberGraph: workflow.stepSubscriberGraph,
|
|
61
|
+
serializedStepGraph: workflow.serializedStepGraph,
|
|
62
|
+
serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
|
|
63
|
+
name: workflow.name,
|
|
64
|
+
triggerSchema: workflow.triggerSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(workflow.triggerSchema)) : void 0,
|
|
65
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
66
|
+
const _step = step;
|
|
67
|
+
acc[key] = {
|
|
68
|
+
..._step,
|
|
69
|
+
inputSchema: _step.inputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
70
|
+
outputSchema: _step.outputSchema ? chunkQH6XWSXP_cjs.stringify(chunkQH6XWSXP_cjs.esm_default(_step.outputSchema)) : void 0
|
|
71
|
+
};
|
|
72
|
+
return acc;
|
|
73
|
+
}, {})
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function startAsyncWorkflowHandler({
|
|
80
|
+
mastra,
|
|
81
|
+
workflowId,
|
|
82
|
+
runId,
|
|
83
|
+
triggerData
|
|
84
|
+
}) {
|
|
85
|
+
try {
|
|
86
|
+
if (!workflowId) {
|
|
87
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
88
|
+
}
|
|
89
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
90
|
+
if (!runId) {
|
|
91
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
92
|
+
}
|
|
93
|
+
if (!workflow) {
|
|
94
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
95
|
+
}
|
|
96
|
+
const run = workflow.getRun(runId);
|
|
97
|
+
if (!run) {
|
|
98
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
99
|
+
}
|
|
100
|
+
const result = await run.start({
|
|
101
|
+
triggerData
|
|
102
|
+
});
|
|
103
|
+
return result;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function getWorkflowRunHandler({
|
|
109
|
+
mastra,
|
|
110
|
+
workflowId,
|
|
111
|
+
runId
|
|
112
|
+
}) {
|
|
113
|
+
try {
|
|
114
|
+
if (!workflowId) {
|
|
115
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
116
|
+
}
|
|
117
|
+
if (!runId) {
|
|
118
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
|
|
119
|
+
}
|
|
120
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
121
|
+
if (!workflow) {
|
|
122
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
123
|
+
}
|
|
124
|
+
const run = workflow.getRun(runId);
|
|
125
|
+
if (!run) {
|
|
126
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
127
|
+
}
|
|
128
|
+
return run;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async function createRunHandler({
|
|
134
|
+
mastra,
|
|
135
|
+
workflowId,
|
|
136
|
+
runId: prevRunId
|
|
137
|
+
}) {
|
|
138
|
+
try {
|
|
139
|
+
if (!workflowId) {
|
|
140
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
141
|
+
}
|
|
142
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
143
|
+
if (!workflow) {
|
|
144
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
145
|
+
}
|
|
146
|
+
const { runId } = workflow.createRun({ runId: prevRunId });
|
|
147
|
+
return { runId };
|
|
148
|
+
} catch (error) {
|
|
149
|
+
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function startWorkflowRunHandler({
|
|
153
|
+
mastra,
|
|
154
|
+
workflowId,
|
|
155
|
+
runId,
|
|
156
|
+
triggerData
|
|
157
|
+
}) {
|
|
158
|
+
try {
|
|
159
|
+
if (!workflowId) {
|
|
160
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
161
|
+
}
|
|
162
|
+
if (!runId) {
|
|
163
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
|
|
164
|
+
}
|
|
165
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
166
|
+
const run = workflow.getRun(runId);
|
|
167
|
+
if (!run) {
|
|
168
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
169
|
+
}
|
|
170
|
+
await run.start({
|
|
171
|
+
triggerData
|
|
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 watchWorkflowHandler({
|
|
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.getWorkflow(workflowId);
|
|
191
|
+
const run = workflow.getRun(runId);
|
|
192
|
+
if (!run) {
|
|
193
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
194
|
+
}
|
|
195
|
+
let unwatch;
|
|
196
|
+
let asyncRef = null;
|
|
197
|
+
const stream = new web.ReadableStream({
|
|
198
|
+
start(controller) {
|
|
199
|
+
unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
|
|
200
|
+
const activePathsObj = Object.fromEntries(activePaths);
|
|
201
|
+
controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
|
|
202
|
+
if (asyncRef) {
|
|
203
|
+
clearImmediate(asyncRef);
|
|
204
|
+
asyncRef = null;
|
|
205
|
+
}
|
|
206
|
+
asyncRef = setImmediate(() => {
|
|
207
|
+
if (!workflow.getRun(runId2)) {
|
|
208
|
+
controller.close();
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
cancel() {
|
|
214
|
+
unwatch?.();
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return stream;
|
|
218
|
+
} catch (error) {
|
|
219
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function resumeAsyncWorkflowHandler({
|
|
223
|
+
mastra,
|
|
224
|
+
workflowId,
|
|
225
|
+
runId,
|
|
226
|
+
body
|
|
227
|
+
}) {
|
|
228
|
+
try {
|
|
229
|
+
if (!workflowId) {
|
|
230
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
231
|
+
}
|
|
232
|
+
if (!runId) {
|
|
233
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
234
|
+
}
|
|
235
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
236
|
+
const run = workflow.getRun(runId);
|
|
237
|
+
if (!run) {
|
|
238
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
239
|
+
}
|
|
240
|
+
const result = await run.resume({
|
|
241
|
+
stepId: body.stepId,
|
|
242
|
+
context: body.context
|
|
243
|
+
});
|
|
244
|
+
return result;
|
|
245
|
+
} catch (error) {
|
|
246
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
async function resumeWorkflowHandler({
|
|
250
|
+
mastra,
|
|
251
|
+
workflowId,
|
|
252
|
+
runId,
|
|
253
|
+
body
|
|
254
|
+
}) {
|
|
255
|
+
try {
|
|
256
|
+
if (!workflowId) {
|
|
257
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
258
|
+
}
|
|
259
|
+
if (!runId) {
|
|
260
|
+
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
261
|
+
}
|
|
262
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
263
|
+
const run = workflow.getRun(runId);
|
|
264
|
+
if (!run) {
|
|
265
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
266
|
+
}
|
|
267
|
+
await run.resume({
|
|
268
|
+
stepId: body.stepId,
|
|
269
|
+
context: body.context
|
|
270
|
+
});
|
|
271
|
+
return { message: "Workflow run resumed" };
|
|
272
|
+
} catch (error) {
|
|
273
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
exports.createRunHandler = createRunHandler;
|
|
278
|
+
exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
|
|
279
|
+
exports.getWorkflowRunHandler = getWorkflowRunHandler;
|
|
280
|
+
exports.getWorkflowsHandler = getWorkflowsHandler;
|
|
281
|
+
exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
282
|
+
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
283
|
+
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
284
|
+
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
285
|
+
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
286
|
+
exports.workflows_exports = workflows_exports;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/server/http-exception.ts
|
|
8
|
+
var HTTPException = class extends Error {
|
|
9
|
+
res;
|
|
10
|
+
status;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of `HTTPException`.
|
|
13
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
14
|
+
* @param options - Additional options for the exception.
|
|
15
|
+
*/
|
|
16
|
+
constructor(status = 500, options) {
|
|
17
|
+
super(options?.message, { cause: options?.cause });
|
|
18
|
+
this.res = options?.res;
|
|
19
|
+
this.status = status;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the response object associated with the exception.
|
|
23
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
24
|
+
* @returns The response object.
|
|
25
|
+
*/
|
|
26
|
+
getResponse() {
|
|
27
|
+
if (this.res) {
|
|
28
|
+
const newResponse = new Response(this.res.body, {
|
|
29
|
+
status: this.status,
|
|
30
|
+
headers: this.res.headers
|
|
31
|
+
});
|
|
32
|
+
return newResponse;
|
|
33
|
+
}
|
|
34
|
+
return new Response(this.message, {
|
|
35
|
+
status: this.status
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { HTTPException, __export };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
|
|
4
|
+
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
5
|
+
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
6
|
+
|
|
7
|
+
// src/server/handlers/logs.ts
|
|
8
|
+
var logs_exports = {};
|
|
9
|
+
chunkFV45V6WC_cjs.__export(logs_exports, {
|
|
10
|
+
getLogTransports: () => getLogTransports,
|
|
11
|
+
getLogsByRunIdHandler: () => getLogsByRunIdHandler,
|
|
12
|
+
getLogsHandler: () => getLogsHandler
|
|
13
|
+
});
|
|
14
|
+
async function getLogsHandler({ mastra, transportId }) {
|
|
15
|
+
try {
|
|
16
|
+
chunkQN4KF3BH_cjs.validateBody({ transportId });
|
|
17
|
+
const logs = await mastra.getLogs(transportId);
|
|
18
|
+
return logs;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async function getLogsByRunIdHandler({
|
|
24
|
+
mastra,
|
|
25
|
+
runId,
|
|
26
|
+
transportId
|
|
27
|
+
}) {
|
|
28
|
+
try {
|
|
29
|
+
chunkQN4KF3BH_cjs.validateBody({ runId, transportId });
|
|
30
|
+
const logs = await mastra.getLogsByRunId({ runId, transportId });
|
|
31
|
+
return logs;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs by run ID");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function getLogTransports({ mastra }) {
|
|
37
|
+
try {
|
|
38
|
+
const logger = mastra.getLogger();
|
|
39
|
+
const transports = logger.transports;
|
|
40
|
+
return {
|
|
41
|
+
transports: transports ? Object.keys(transports) : []
|
|
42
|
+
};
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return chunkZLBRQFDD_cjs.handleError(error, "Error getting log Transports");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.getLogTransports = getLogTransports;
|
|
49
|
+
exports.getLogsByRunIdHandler = getLogsByRunIdHandler;
|
|
50
|
+
exports.getLogsHandler = getLogsHandler;
|
|
51
|
+
exports.logs_exports = logs_exports;
|