@mastra/server 0.0.0-a2a-20250421213654

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.
Files changed (97) hide show
  1. package/LICENSE.md +46 -0
  2. package/README.md +159 -0
  3. package/dist/_tsup-dts-rollup.d.cts +897 -0
  4. package/dist/_tsup-dts-rollup.d.ts +897 -0
  5. package/dist/chunk-3KWAWPRU.cjs +127 -0
  6. package/dist/chunk-4VNS5WPM.js +37 -0
  7. package/dist/chunk-57CJTIPW.cjs +18 -0
  8. package/dist/chunk-5SWCVTNL.cjs +5579 -0
  9. package/dist/chunk-64U3UDTH.cjs +13 -0
  10. package/dist/chunk-6QEBCWQG.js +136 -0
  11. package/dist/chunk-75KYFUMD.cjs +165 -0
  12. package/dist/chunk-B2TWGIVC.cjs +101 -0
  13. package/dist/chunk-CVPOREIE.cjs +42 -0
  14. package/dist/chunk-CZOSYERC.js +312 -0
  15. package/dist/chunk-FFRES7WX.js +157 -0
  16. package/dist/chunk-H5PTF3Y4.js +16 -0
  17. package/dist/chunk-IDPBXKRV.js +121 -0
  18. package/dist/chunk-J2MCTUD4.js +121 -0
  19. package/dist/chunk-JQCFFVSK.cjs +127 -0
  20. package/dist/chunk-LGJ46RCS.js +96 -0
  21. package/dist/chunk-LTP7PHVE.cjs +321 -0
  22. package/dist/chunk-M5ABIP7D.js +11 -0
  23. package/dist/chunk-NJF275KR.js +49 -0
  24. package/dist/chunk-NYN7KFXL.js +34 -0
  25. package/dist/chunk-O7X557PN.cjs +140 -0
  26. package/dist/chunk-OCWPVYNI.cjs +36 -0
  27. package/dist/chunk-OMN3UI6X.js +5576 -0
  28. package/dist/chunk-P7UZNROR.js +306 -0
  29. package/dist/chunk-PJHJORJL.js +204 -0
  30. package/dist/chunk-RXH2S65Z.cjs +54 -0
  31. package/dist/chunk-UVVUDJBW.cjs +214 -0
  32. package/dist/chunk-Y7WN2UYV.cjs +318 -0
  33. package/dist/chunk-YB2FGKQ5.js +121 -0
  34. package/dist/chunk-ZCRMOXNW.cjs +129 -0
  35. package/dist/index.cjs +2 -0
  36. package/dist/index.d.cts +1 -0
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +1 -0
  39. package/dist/magic-string.es-5UDOWOAZ.js +1294 -0
  40. package/dist/magic-string.es-IL2775P6.cjs +1300 -0
  41. package/dist/server/handlers/a2a.cjs +34 -0
  42. package/dist/server/handlers/a2a.d.cts +7 -0
  43. package/dist/server/handlers/a2a.d.ts +7 -0
  44. package/dist/server/handlers/a2a.js +1 -0
  45. package/dist/server/handlers/agents.cjs +30 -0
  46. package/dist/server/handlers/agents.d.cts +6 -0
  47. package/dist/server/handlers/agents.d.ts +6 -0
  48. package/dist/server/handlers/agents.js +1 -0
  49. package/dist/server/handlers/error.cjs +10 -0
  50. package/dist/server/handlers/error.d.cts +1 -0
  51. package/dist/server/handlers/error.d.ts +1 -0
  52. package/dist/server/handlers/error.js +1 -0
  53. package/dist/server/handlers/logs.cjs +18 -0
  54. package/dist/server/handlers/logs.d.cts +3 -0
  55. package/dist/server/handlers/logs.d.ts +3 -0
  56. package/dist/server/handlers/logs.js +1 -0
  57. package/dist/server/handlers/memory.cjs +38 -0
  58. package/dist/server/handlers/memory.d.cts +8 -0
  59. package/dist/server/handlers/memory.d.ts +8 -0
  60. package/dist/server/handlers/memory.js +1 -0
  61. package/dist/server/handlers/network.cjs +22 -0
  62. package/dist/server/handlers/network.d.cts +4 -0
  63. package/dist/server/handlers/network.d.ts +4 -0
  64. package/dist/server/handlers/network.js +1 -0
  65. package/dist/server/handlers/telemetry.cjs +14 -0
  66. package/dist/server/handlers/telemetry.d.cts +2 -0
  67. package/dist/server/handlers/telemetry.d.ts +2 -0
  68. package/dist/server/handlers/telemetry.js +1 -0
  69. package/dist/server/handlers/test-utils.cjs +16209 -0
  70. package/dist/server/handlers/test-utils.d.cts +1 -0
  71. package/dist/server/handlers/test-utils.d.ts +1 -0
  72. package/dist/server/handlers/test-utils.js +16207 -0
  73. package/dist/server/handlers/tools.cjs +22 -0
  74. package/dist/server/handlers/tools.d.cts +4 -0
  75. package/dist/server/handlers/tools.d.ts +4 -0
  76. package/dist/server/handlers/tools.js +1 -0
  77. package/dist/server/handlers/utils.cjs +10 -0
  78. package/dist/server/handlers/utils.d.cts +1 -0
  79. package/dist/server/handlers/utils.d.ts +1 -0
  80. package/dist/server/handlers/utils.js +1 -0
  81. package/dist/server/handlers/vector.cjs +30 -0
  82. package/dist/server/handlers/vector.d.cts +6 -0
  83. package/dist/server/handlers/vector.d.ts +6 -0
  84. package/dist/server/handlers/vector.js +1 -0
  85. package/dist/server/handlers/voice.cjs +18 -0
  86. package/dist/server/handlers/voice.d.cts +3 -0
  87. package/dist/server/handlers/voice.d.ts +3 -0
  88. package/dist/server/handlers/voice.js +1 -0
  89. package/dist/server/handlers/workflows.cjs +46 -0
  90. package/dist/server/handlers/workflows.d.cts +10 -0
  91. package/dist/server/handlers/workflows.d.ts +10 -0
  92. package/dist/server/handlers/workflows.js +1 -0
  93. package/dist/server/handlers.cjs +55 -0
  94. package/dist/server/handlers.d.cts +10 -0
  95. package/dist/server/handlers.d.ts +10 -0
  96. package/dist/server/handlers.js +10 -0
  97. package/package.json +71 -0
@@ -0,0 +1,306 @@
1
+ import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-4VNS5WPM.js';
5
+ import { ReadableStream } from 'node:stream/web';
6
+
7
+ // src/server/handlers/workflows.ts
8
+ var workflows_exports = {};
9
+ __export(workflows_exports, {
10
+ createRunHandler: () => createRunHandler,
11
+ getWorkflowByIdHandler: () => getWorkflowByIdHandler,
12
+ getWorkflowRunHandler: () => getWorkflowRunHandler,
13
+ getWorkflowRunsHandler: () => getWorkflowRunsHandler,
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
+ if (workflow.isNested) return acc;
26
+ acc[key] = {
27
+ stepGraph: workflow.stepGraph,
28
+ stepSubscriberGraph: workflow.stepSubscriberGraph,
29
+ serializedStepGraph: workflow.serializedStepGraph,
30
+ serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
31
+ name: workflow.name,
32
+ triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
33
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
34
+ const _step = step;
35
+ acc2[key2] = {
36
+ ..._step,
37
+ inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
38
+ outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
39
+ };
40
+ return acc2;
41
+ }, {})
42
+ };
43
+ return acc;
44
+ }, {});
45
+ return _workflows;
46
+ } catch (error) {
47
+ throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
48
+ }
49
+ }
50
+ async function getWorkflowByIdHandler({ mastra, workflowId }) {
51
+ try {
52
+ if (!workflowId) {
53
+ throw new HTTPException(400, { message: "Workflow ID is required" });
54
+ }
55
+ const workflow = mastra.getWorkflow(workflowId);
56
+ if (!workflow) {
57
+ throw new HTTPException(404, { message: "Workflow not found" });
58
+ }
59
+ return {
60
+ stepGraph: workflow.stepGraph,
61
+ stepSubscriberGraph: workflow.stepSubscriberGraph,
62
+ serializedStepGraph: workflow.serializedStepGraph,
63
+ serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
64
+ name: workflow.name,
65
+ triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
66
+ steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
67
+ const _step = step;
68
+ acc[key] = {
69
+ ..._step,
70
+ inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
71
+ outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
72
+ };
73
+ return acc;
74
+ }, {})
75
+ };
76
+ } catch (error) {
77
+ throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
78
+ }
79
+ }
80
+ async function startAsyncWorkflowHandler({
81
+ mastra,
82
+ container,
83
+ workflowId,
84
+ runId,
85
+ triggerData
86
+ }) {
87
+ try {
88
+ if (!workflowId) {
89
+ throw new HTTPException(400, { message: "Workflow ID is required" });
90
+ }
91
+ const workflow = mastra.getWorkflow(workflowId);
92
+ if (!workflow) {
93
+ throw new HTTPException(404, { message: "Workflow not found" });
94
+ }
95
+ if (!runId) {
96
+ const { start } = workflow.createRun();
97
+ const result2 = await start({
98
+ triggerData,
99
+ container
100
+ });
101
+ return result2;
102
+ }
103
+ const run = workflow.getRun(runId);
104
+ if (!run) {
105
+ throw new HTTPException(404, { message: "Workflow run not found" });
106
+ }
107
+ const result = await run.start({
108
+ triggerData,
109
+ container
110
+ });
111
+ return result;
112
+ } catch (error) {
113
+ throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
114
+ }
115
+ }
116
+ async function getWorkflowRunHandler({
117
+ mastra,
118
+ workflowId,
119
+ runId
120
+ }) {
121
+ try {
122
+ if (!workflowId) {
123
+ throw new HTTPException(400, { message: "Workflow ID is required" });
124
+ }
125
+ if (!runId) {
126
+ throw new HTTPException(400, { message: "Run ID is required" });
127
+ }
128
+ const workflow = mastra.getWorkflow(workflowId);
129
+ if (!workflow) {
130
+ throw new HTTPException(404, { message: "Workflow not found" });
131
+ }
132
+ const run = workflow.getRun(runId);
133
+ if (!run) {
134
+ throw new HTTPException(404, { message: "Workflow run not found" });
135
+ }
136
+ return run;
137
+ } catch (error) {
138
+ throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
139
+ }
140
+ }
141
+ async function createRunHandler({
142
+ mastra,
143
+ workflowId,
144
+ runId: prevRunId
145
+ }) {
146
+ try {
147
+ if (!workflowId) {
148
+ throw new HTTPException(400, { message: "Workflow ID is required" });
149
+ }
150
+ const workflow = mastra.getWorkflow(workflowId);
151
+ if (!workflow) {
152
+ throw new HTTPException(404, { message: "Workflow not found" });
153
+ }
154
+ const { runId } = workflow.createRun({ runId: prevRunId });
155
+ return { runId };
156
+ } catch (error) {
157
+ throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
158
+ }
159
+ }
160
+ async function startWorkflowRunHandler({
161
+ mastra,
162
+ container,
163
+ workflowId,
164
+ runId,
165
+ triggerData
166
+ }) {
167
+ try {
168
+ if (!workflowId) {
169
+ throw new HTTPException(400, { message: "Workflow ID is required" });
170
+ }
171
+ if (!runId) {
172
+ throw new HTTPException(400, { message: "runId required to start run" });
173
+ }
174
+ const workflow = mastra.getWorkflow(workflowId);
175
+ const run = workflow.getRun(runId);
176
+ if (!run) {
177
+ throw new HTTPException(404, { message: "Workflow run not found" });
178
+ }
179
+ await run.start({
180
+ triggerData,
181
+ container
182
+ });
183
+ return { message: "Workflow run started" };
184
+ } catch (e) {
185
+ return handleError(e, "Error starting workflow run");
186
+ }
187
+ }
188
+ async function watchWorkflowHandler({
189
+ mastra,
190
+ workflowId,
191
+ runId
192
+ }) {
193
+ try {
194
+ if (!workflowId) {
195
+ throw new HTTPException(400, { message: "Workflow ID is required" });
196
+ }
197
+ if (!runId) {
198
+ throw new HTTPException(400, { message: "runId required to watch workflow" });
199
+ }
200
+ const workflow = mastra.getWorkflow(workflowId);
201
+ const run = workflow.getRun(runId);
202
+ if (!run) {
203
+ throw new HTTPException(404, { message: "Workflow run not found" });
204
+ }
205
+ let unwatch;
206
+ let asyncRef = null;
207
+ const stream = new ReadableStream({
208
+ start(controller) {
209
+ unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
210
+ const activePathsObj = Object.fromEntries(activePaths);
211
+ controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
212
+ if (asyncRef) {
213
+ clearImmediate(asyncRef);
214
+ asyncRef = null;
215
+ }
216
+ asyncRef = setImmediate(() => {
217
+ if (!workflow.getRun(runId2)) {
218
+ controller.close();
219
+ }
220
+ });
221
+ });
222
+ },
223
+ cancel() {
224
+ unwatch?.();
225
+ }
226
+ });
227
+ return stream;
228
+ } catch (error) {
229
+ return handleError(error, "Error watching workflow");
230
+ }
231
+ }
232
+ async function resumeAsyncWorkflowHandler({
233
+ mastra,
234
+ workflowId,
235
+ runId,
236
+ body,
237
+ container
238
+ }) {
239
+ try {
240
+ if (!workflowId) {
241
+ throw new HTTPException(400, { message: "Workflow ID is required" });
242
+ }
243
+ if (!runId) {
244
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
245
+ }
246
+ const workflow = mastra.getWorkflow(workflowId);
247
+ const run = workflow.getRun(runId);
248
+ if (!run) {
249
+ throw new HTTPException(404, { message: "Workflow run not found" });
250
+ }
251
+ const result = await run.resume({
252
+ stepId: body.stepId,
253
+ context: body.context,
254
+ container
255
+ });
256
+ return result;
257
+ } catch (error) {
258
+ return handleError(error, "Error resuming workflow step");
259
+ }
260
+ }
261
+ async function resumeWorkflowHandler({
262
+ mastra,
263
+ workflowId,
264
+ runId,
265
+ body,
266
+ container
267
+ }) {
268
+ try {
269
+ if (!workflowId) {
270
+ throw new HTTPException(400, { message: "Workflow ID is required" });
271
+ }
272
+ if (!runId) {
273
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
274
+ }
275
+ const workflow = mastra.getWorkflow(workflowId);
276
+ const run = workflow.getRun(runId);
277
+ if (!run) {
278
+ throw new HTTPException(404, { message: "Workflow run not found" });
279
+ }
280
+ await run.resume({
281
+ stepId: body.stepId,
282
+ context: body.context,
283
+ container
284
+ });
285
+ return { message: "Workflow run resumed" };
286
+ } catch (error) {
287
+ return handleError(error, "Error resuming workflow");
288
+ }
289
+ }
290
+ async function getWorkflowRunsHandler({ mastra, workflowId }) {
291
+ try {
292
+ if (!workflowId) {
293
+ throw new HTTPException(400, { message: "Workflow ID is required" });
294
+ }
295
+ const workflow = mastra.getWorkflow(workflowId);
296
+ const workflowRuns = await workflow.getWorkflowRuns() || {
297
+ runs: [],
298
+ total: 0
299
+ };
300
+ return workflowRuns;
301
+ } catch (error) {
302
+ return handleError(error, "Error getting workflow runs");
303
+ }
304
+ }
305
+
306
+ export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, workflows_exports };
@@ -0,0 +1,204 @@
1
+ import { validateBody } from './chunk-H5PTF3Y4.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-4VNS5WPM.js';
5
+
6
+ // src/server/handlers/memory.ts
7
+ var memory_exports = {};
8
+ __export(memory_exports, {
9
+ createThreadHandler: () => createThreadHandler,
10
+ deleteThreadHandler: () => deleteThreadHandler,
11
+ getMemoryStatusHandler: () => getMemoryStatusHandler,
12
+ getMessagesHandler: () => getMessagesHandler,
13
+ getThreadByIdHandler: () => getThreadByIdHandler,
14
+ getThreadsHandler: () => getThreadsHandler,
15
+ saveMessagesHandler: () => saveMessagesHandler,
16
+ updateThreadHandler: () => updateThreadHandler
17
+ });
18
+ function getMemoryFromContext({
19
+ mastra,
20
+ agentId
21
+ }) {
22
+ const agent = agentId ? mastra.getAgent(agentId) : null;
23
+ if (agentId && !agent) {
24
+ throw new HTTPException(404, { message: "Agent not found" });
25
+ }
26
+ const memory = agent?.getMemory?.() || mastra.getMemory();
27
+ return memory;
28
+ }
29
+ async function getMemoryStatusHandler({ mastra, agentId }) {
30
+ try {
31
+ const memory = getMemoryFromContext({ mastra, agentId });
32
+ if (!memory) {
33
+ return { result: false };
34
+ }
35
+ return { result: true };
36
+ } catch (error) {
37
+ return handleError(error, "Error getting memory status");
38
+ }
39
+ }
40
+ async function getThreadsHandler({
41
+ mastra,
42
+ agentId,
43
+ resourceId
44
+ }) {
45
+ try {
46
+ const memory = getMemoryFromContext({ mastra, agentId });
47
+ if (!memory) {
48
+ throw new HTTPException(400, { message: "Memory is not initialized" });
49
+ }
50
+ validateBody({ resourceId });
51
+ const threads = await memory.getThreadsByResourceId({ resourceId });
52
+ return threads;
53
+ } catch (error) {
54
+ return handleError(error, "Error getting threads");
55
+ }
56
+ }
57
+ async function getThreadByIdHandler({
58
+ mastra,
59
+ agentId,
60
+ threadId
61
+ }) {
62
+ try {
63
+ validateBody({ threadId });
64
+ const memory = getMemoryFromContext({ mastra, agentId });
65
+ if (!memory) {
66
+ throw new HTTPException(400, { message: "Memory is not initialized" });
67
+ }
68
+ const thread = await memory.getThreadById({ threadId });
69
+ if (!thread) {
70
+ throw new HTTPException(404, { message: "Thread not found" });
71
+ }
72
+ return thread;
73
+ } catch (error) {
74
+ return handleError(error, "Error getting thread");
75
+ }
76
+ }
77
+ async function saveMessagesHandler({
78
+ mastra,
79
+ agentId,
80
+ body
81
+ }) {
82
+ try {
83
+ const memory = getMemoryFromContext({ mastra, agentId });
84
+ if (!memory) {
85
+ throw new HTTPException(400, { message: "Memory is not initialized" });
86
+ }
87
+ if (!body?.messages) {
88
+ throw new HTTPException(400, { message: "Messages are required" });
89
+ }
90
+ if (!Array.isArray(body.messages)) {
91
+ throw new HTTPException(400, { message: "Messages should be an array" });
92
+ }
93
+ const processedMessages = body.messages.map((message) => ({
94
+ ...message,
95
+ id: memory.generateId(),
96
+ createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
97
+ }));
98
+ const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
99
+ return result;
100
+ } catch (error) {
101
+ return handleError(error, "Error saving messages");
102
+ }
103
+ }
104
+ async function createThreadHandler({
105
+ mastra,
106
+ agentId,
107
+ body
108
+ }) {
109
+ try {
110
+ const memory = getMemoryFromContext({ mastra, agentId });
111
+ if (!memory) {
112
+ throw new HTTPException(400, { message: "Memory is not initialized" });
113
+ }
114
+ validateBody({ resourceId: body?.resourceId });
115
+ const result = await memory.createThread({
116
+ resourceId: body?.resourceId,
117
+ title: body?.title,
118
+ metadata: body?.metadata,
119
+ threadId: body?.threadId
120
+ });
121
+ return result;
122
+ } catch (error) {
123
+ return handleError(error, "Error saving thread to memory");
124
+ }
125
+ }
126
+ async function updateThreadHandler({
127
+ mastra,
128
+ agentId,
129
+ threadId,
130
+ body
131
+ }) {
132
+ try {
133
+ const memory = getMemoryFromContext({ mastra, agentId });
134
+ if (!body) {
135
+ throw new HTTPException(400, { message: "Body is required" });
136
+ }
137
+ const { title, metadata, resourceId } = body;
138
+ const updatedAt = /* @__PURE__ */ new Date();
139
+ validateBody({ threadId });
140
+ if (!memory) {
141
+ throw new HTTPException(400, { message: "Memory is not initialized" });
142
+ }
143
+ const thread = await memory.getThreadById({ threadId });
144
+ if (!thread) {
145
+ throw new HTTPException(404, { message: "Thread not found" });
146
+ }
147
+ const updatedThread = {
148
+ ...thread,
149
+ title: title || thread.title,
150
+ metadata: metadata || thread.metadata,
151
+ resourceId: resourceId || thread.resourceId,
152
+ createdAt: thread.createdAt,
153
+ updatedAt
154
+ };
155
+ const result = await memory.saveThread({ thread: updatedThread });
156
+ return result;
157
+ } catch (error) {
158
+ return handleError(error, "Error updating thread");
159
+ }
160
+ }
161
+ async function deleteThreadHandler({
162
+ mastra,
163
+ agentId,
164
+ threadId
165
+ }) {
166
+ try {
167
+ validateBody({ threadId });
168
+ const memory = getMemoryFromContext({ mastra, agentId });
169
+ if (!memory) {
170
+ throw new HTTPException(400, { message: "Memory is not initialized" });
171
+ }
172
+ const thread = await memory.getThreadById({ threadId });
173
+ if (!thread) {
174
+ throw new HTTPException(404, { message: "Thread not found" });
175
+ }
176
+ await memory.deleteThread(threadId);
177
+ return { result: "Thread deleted" };
178
+ } catch (error) {
179
+ return handleError(error, "Error deleting thread");
180
+ }
181
+ }
182
+ async function getMessagesHandler({
183
+ mastra,
184
+ agentId,
185
+ threadId
186
+ }) {
187
+ try {
188
+ validateBody({ threadId });
189
+ const memory = getMemoryFromContext({ mastra, agentId });
190
+ if (!memory) {
191
+ throw new HTTPException(400, { message: "Memory is not initialized" });
192
+ }
193
+ const thread = await memory.getThreadById({ threadId });
194
+ if (!thread) {
195
+ throw new HTTPException(404, { message: "Thread not found" });
196
+ }
197
+ const result = await memory.query({ threadId });
198
+ return result;
199
+ } catch (error) {
200
+ return handleError(error, "Error getting messages");
201
+ }
202
+ }
203
+
204
+ export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, memory_exports, saveMessagesHandler, updateThreadHandler };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkCVPOREIE_cjs = require('./chunk-CVPOREIE.cjs');
6
+
7
+ // src/server/handlers/logs.ts
8
+ var logs_exports = {};
9
+ chunkCVPOREIE_cjs.__export(logs_exports, {
10
+ getLogTransports: () => getLogTransports,
11
+ getLogsByRunIdHandler: () => getLogsByRunIdHandler,
12
+ getLogsHandler: () => getLogsHandler
13
+ });
14
+ async function getLogsHandler({
15
+ mastra,
16
+ transportId
17
+ }) {
18
+ try {
19
+ chunk57CJTIPW_cjs.validateBody({ transportId });
20
+ const logs = await mastra.getLogs(transportId);
21
+ return logs;
22
+ } catch (error) {
23
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting logs");
24
+ }
25
+ }
26
+ async function getLogsByRunIdHandler({
27
+ mastra,
28
+ runId,
29
+ transportId
30
+ }) {
31
+ try {
32
+ chunk57CJTIPW_cjs.validateBody({ runId, transportId });
33
+ const logs = await mastra.getLogsByRunId({ runId, transportId });
34
+ return logs;
35
+ } catch (error) {
36
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting logs by run ID");
37
+ }
38
+ }
39
+ async function getLogTransports({ mastra }) {
40
+ try {
41
+ const logger = mastra.getLogger();
42
+ const transports = logger.transports;
43
+ return {
44
+ transports: transports ? Object.keys(transports) : []
45
+ };
46
+ } catch (error) {
47
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting log Transports");
48
+ }
49
+ }
50
+
51
+ exports.getLogTransports = getLogTransports;
52
+ exports.getLogsByRunIdHandler = getLogsByRunIdHandler;
53
+ exports.getLogsHandler = getLogsHandler;
54
+ exports.logs_exports = logs_exports;