@mastra/server 0.0.0-mcp-server-deploy-20250507160341 → 0.0.0-memory-system-message-error-20250813233316

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 (226) hide show
  1. package/LICENSE.md +11 -42
  2. package/README.md +48 -135
  3. package/dist/{chunk-5YGDYMRB.cjs → chunk-4CEZIJWJ.cjs} +16 -13
  4. package/dist/chunk-4CEZIJWJ.cjs.map +1 -0
  5. package/dist/chunk-4MQU6AJN.js +83 -0
  6. package/dist/chunk-4MQU6AJN.js.map +1 -0
  7. package/dist/{chunk-QN4KF3BH.cjs → chunk-4QSNRCOT.cjs} +4 -2
  8. package/dist/chunk-4QSNRCOT.cjs.map +1 -0
  9. package/dist/chunk-4US5W7PH.cjs +120 -0
  10. package/dist/chunk-4US5W7PH.cjs.map +1 -0
  11. package/dist/chunk-5AKR33BI.js +333 -0
  12. package/dist/chunk-5AKR33BI.js.map +1 -0
  13. package/dist/chunk-7FHF55WA.js +2041 -0
  14. package/dist/chunk-7FHF55WA.js.map +1 -0
  15. package/dist/{chunk-FV45V6WC.cjs → chunk-7NADHFD2.cjs} +3 -7
  16. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  17. package/dist/chunk-BED2O446.cjs +88 -0
  18. package/dist/chunk-BED2O446.cjs.map +1 -0
  19. package/dist/chunk-BUOJL3MN.js +529 -0
  20. package/dist/chunk-BUOJL3MN.js.map +1 -0
  21. package/dist/chunk-CY4TP3FK.js +16 -0
  22. package/dist/chunk-CY4TP3FK.js.map +1 -0
  23. package/dist/chunk-EBNIUZRY.cjs +344 -0
  24. package/dist/chunk-EBNIUZRY.cjs.map +1 -0
  25. package/dist/{chunk-4JINXASC.js → chunk-G7NVCO5M.js} +7 -4
  26. package/dist/chunk-G7NVCO5M.js.map +1 -0
  27. package/dist/chunk-GX25CWC7.cjs +588 -0
  28. package/dist/chunk-GX25CWC7.cjs.map +1 -0
  29. package/dist/{chunk-Q6SHQECN.js → chunk-HWHKM67I.js} +36 -10
  30. package/dist/chunk-HWHKM67I.js.map +1 -0
  31. package/dist/{chunk-AMVOS7YB.cjs → chunk-ILCWPBYQ.cjs} +14 -8
  32. package/dist/chunk-ILCWPBYQ.cjs.map +1 -0
  33. package/dist/chunk-JGVY3KWV.cjs +334 -0
  34. package/dist/chunk-JGVY3KWV.cjs.map +1 -0
  35. package/dist/chunk-JNWFG7JP.js +476 -0
  36. package/dist/chunk-JNWFG7JP.js.map +1 -0
  37. package/dist/chunk-KXNFZXLG.cjs +484 -0
  38. package/dist/chunk-KXNFZXLG.cjs.map +1 -0
  39. package/dist/chunk-L7YG7WQH.js +151 -0
  40. package/dist/chunk-L7YG7WQH.js.map +1 -0
  41. package/dist/chunk-LRUH33B4.cjs +2044 -0
  42. package/dist/chunk-LRUH33B4.cjs.map +1 -0
  43. package/dist/{chunk-TRDNDNGQ.js → chunk-MMROOK5J.js} +4 -7
  44. package/dist/chunk-MMROOK5J.js.map +1 -0
  45. package/dist/{chunk-M56ECCHK.cjs → chunk-NCS2OXX6.cjs} +22 -19
  46. package/dist/chunk-NCS2OXX6.cjs.map +1 -0
  47. package/dist/{chunk-D3G23FP3.cjs → chunk-O4I563YW.cjs} +26 -22
  48. package/dist/chunk-O4I563YW.cjs.map +1 -0
  49. package/dist/{chunk-L7XE5QTW.js → chunk-OW4FX5TS.js} +3 -1
  50. package/dist/chunk-OW4FX5TS.js.map +1 -0
  51. package/dist/chunk-PZ5AY32C.js +9 -0
  52. package/dist/chunk-PZ5AY32C.js.map +1 -0
  53. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  54. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  55. package/dist/chunk-RE4RPXT2.cjs +18 -0
  56. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  57. package/dist/chunk-RQQNZZAI.cjs +159 -0
  58. package/dist/chunk-RQQNZZAI.cjs.map +1 -0
  59. package/dist/chunk-S37KCGOR.cjs +546 -0
  60. package/dist/chunk-S37KCGOR.cjs.map +1 -0
  61. package/dist/{chunk-BPL2CBLV.js → chunk-SQ7KKIH3.js} +10 -4
  62. package/dist/chunk-SQ7KKIH3.js.map +1 -0
  63. package/dist/{chunk-3XTEV33Q.js → chunk-UVOSITKU.js} +61 -56
  64. package/dist/chunk-UVOSITKU.js.map +1 -0
  65. package/dist/{chunk-QJ3AHN64.js → chunk-Y3J45CVZ.js} +6 -3
  66. package/dist/chunk-Y3J45CVZ.js.map +1 -0
  67. package/dist/{chunk-5JNVY6DU.js → chunk-YS66MFDY.js} +9 -5
  68. package/dist/chunk-YS66MFDY.js.map +1 -0
  69. package/dist/chunk-ZKJZQN24.js +571 -0
  70. package/dist/chunk-ZKJZQN24.js.map +1 -0
  71. package/dist/index.cjs +2 -12
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +3 -1
  76. package/dist/index.js.map +1 -0
  77. package/dist/server/a2a/protocol.d.ts +8 -0
  78. package/dist/server/a2a/protocol.d.ts.map +1 -0
  79. package/dist/server/a2a/store.cjs +25 -0
  80. package/dist/server/a2a/store.cjs.map +1 -0
  81. package/dist/server/a2a/store.d.ts +14 -0
  82. package/dist/server/a2a/store.d.ts.map +1 -0
  83. package/dist/server/a2a/store.js +23 -0
  84. package/dist/server/a2a/store.js.map +1 -0
  85. package/dist/server/a2a/tasks.d.ts +20 -0
  86. package/dist/server/a2a/tasks.d.ts.map +1 -0
  87. package/dist/server/handlers/a2a.cjs +32 -0
  88. package/dist/server/handlers/a2a.cjs.map +1 -0
  89. package/dist/server/handlers/a2a.d.ts +68 -0
  90. package/dist/server/handlers/a2a.d.ts.map +1 -0
  91. package/dist/server/handlers/a2a.js +3 -0
  92. package/dist/server/handlers/a2a.js.map +1 -0
  93. package/dist/server/handlers/agents.cjs +21 -7
  94. package/dist/server/handlers/agents.cjs.map +1 -0
  95. package/dist/server/handlers/agents.d.ts +90 -6
  96. package/dist/server/handlers/agents.d.ts.map +1 -0
  97. package/dist/server/handlers/agents.js +3 -1
  98. package/dist/server/handlers/agents.js.map +1 -0
  99. package/dist/server/handlers/error.cjs +4 -2
  100. package/dist/server/handlers/error.cjs.map +1 -0
  101. package/dist/server/handlers/error.d.ts +2 -1
  102. package/dist/server/handlers/error.d.ts.map +1 -0
  103. package/dist/server/handlers/error.js +3 -1
  104. package/dist/server/handlers/error.js.map +1 -0
  105. package/dist/server/handlers/legacyWorkflows.cjs +48 -0
  106. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  107. package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
  108. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  109. package/dist/server/handlers/legacyWorkflows.js +3 -0
  110. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  111. package/dist/server/handlers/logs.cjs +6 -4
  112. package/dist/server/handlers/logs.cjs.map +1 -0
  113. package/dist/server/handlers/logs.d.ts +34 -3
  114. package/dist/server/handlers/logs.d.ts.map +1 -0
  115. package/dist/server/handlers/logs.js +3 -1
  116. package/dist/server/handlers/logs.js.map +1 -0
  117. package/dist/server/handlers/memory.cjs +39 -9
  118. package/dist/server/handlers/memory.cjs.map +1 -0
  119. package/dist/server/handlers/memory.d.ts +119 -8
  120. package/dist/server/handlers/memory.d.ts.map +1 -0
  121. package/dist/server/handlers/memory.js +3 -1
  122. package/dist/server/handlers/memory.js.map +1 -0
  123. package/dist/server/handlers/network.cjs +7 -5
  124. package/dist/server/handlers/network.cjs.map +1 -0
  125. package/dist/server/handlers/network.d.ts +50 -4
  126. package/dist/server/handlers/network.d.ts.map +1 -0
  127. package/dist/server/handlers/network.js +3 -1
  128. package/dist/server/handlers/network.js.map +1 -0
  129. package/dist/server/handlers/scores.cjs +32 -0
  130. package/dist/server/handlers/scores.cjs.map +1 -0
  131. package/dist/server/handlers/scores.d.ts +49 -0
  132. package/dist/server/handlers/scores.d.ts.map +1 -0
  133. package/dist/server/handlers/scores.js +3 -0
  134. package/dist/server/handlers/scores.js.map +1 -0
  135. package/dist/server/handlers/telemetry.cjs +5 -3
  136. package/dist/server/handlers/telemetry.cjs.map +1 -0
  137. package/dist/server/handlers/telemetry.d.ts +32 -2
  138. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  139. package/dist/server/handlers/telemetry.js +3 -1
  140. package/dist/server/handlers/telemetry.js.map +1 -0
  141. package/dist/server/handlers/tools.cjs +7 -5
  142. package/dist/server/handlers/tools.cjs.map +1 -0
  143. package/dist/server/handlers/tools.d.ts +21 -4
  144. package/dist/server/handlers/tools.d.ts.map +1 -0
  145. package/dist/server/handlers/tools.js +3 -1
  146. package/dist/server/handlers/tools.js.map +1 -0
  147. package/dist/server/handlers/utils.cjs +4 -2
  148. package/dist/server/handlers/utils.cjs.map +1 -0
  149. package/dist/server/handlers/utils.d.ts +2 -1
  150. package/dist/server/handlers/utils.d.ts.map +1 -0
  151. package/dist/server/handlers/utils.js +3 -1
  152. package/dist/server/handlers/utils.js.map +1 -0
  153. package/dist/server/handlers/vNextNetwork.cjs +220 -0
  154. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  155. package/dist/server/handlers/vNextNetwork.d.ts +179 -0
  156. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  157. package/dist/server/handlers/vNextNetwork.js +213 -0
  158. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  159. package/dist/server/handlers/vector.cjs +9 -7
  160. package/dist/server/handlers/vector.cjs.map +1 -0
  161. package/dist/server/handlers/vector.d.ts +51 -6
  162. package/dist/server/handlers/vector.d.ts.map +1 -0
  163. package/dist/server/handlers/vector.js +3 -1
  164. package/dist/server/handlers/vector.js.map +1 -0
  165. package/dist/server/handlers/voice.cjs +10 -4
  166. package/dist/server/handlers/voice.cjs.map +1 -0
  167. package/dist/server/handlers/voice.d.ts +39 -3
  168. package/dist/server/handlers/voice.d.ts.map +1 -0
  169. package/dist/server/handlers/voice.js +3 -1
  170. package/dist/server/handlers/voice.js.map +1 -0
  171. package/dist/server/handlers/workflows.cjs +35 -13
  172. package/dist/server/handlers/workflows.cjs.map +1 -0
  173. package/dist/server/handlers/workflows.d.ts +88 -10
  174. package/dist/server/handlers/workflows.d.ts.map +1 -0
  175. package/dist/server/handlers/workflows.js +3 -1
  176. package/dist/server/handlers/workflows.js.map +1 -0
  177. package/dist/server/handlers.cjs +42 -30
  178. package/dist/server/handlers.cjs.map +1 -0
  179. package/dist/server/handlers.d.ts +13 -10
  180. package/dist/server/handlers.d.ts.map +1 -0
  181. package/dist/server/handlers.js +14 -10
  182. package/dist/server/handlers.js.map +1 -0
  183. package/dist/server/http-exception.d.ts +87 -0
  184. package/dist/server/http-exception.d.ts.map +1 -0
  185. package/dist/server/types.d.ts +10 -0
  186. package/dist/server/types.d.ts.map +1 -0
  187. package/package.json +31 -18
  188. package/dist/_tsup-dts-rollup.d.cts +0 -748
  189. package/dist/_tsup-dts-rollup.d.ts +0 -748
  190. package/dist/chunk-2FJURXCL.cjs +0 -213
  191. package/dist/chunk-3AHQ5RGN.js +0 -11
  192. package/dist/chunk-3EJZQ6TQ.js +0 -49
  193. package/dist/chunk-4BIX6GMY.cjs +0 -189
  194. package/dist/chunk-55HTWX4C.cjs +0 -93
  195. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  196. package/dist/chunk-74DLDQTQ.cjs +0 -36
  197. package/dist/chunk-CHFORQ7J.cjs +0 -329
  198. package/dist/chunk-FOXHTOQZ.cjs +0 -324
  199. package/dist/chunk-HAA5T7JL.js +0 -33
  200. package/dist/chunk-IQTNZSFP.js +0 -312
  201. package/dist/chunk-OMN3UI6X.js +0 -5576
  202. package/dist/chunk-RBQASTUP.js +0 -203
  203. package/dist/chunk-SKBVVI24.cjs +0 -54
  204. package/dist/chunk-Y3SV5XK4.js +0 -181
  205. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  206. package/dist/index.d.cts +0 -2
  207. package/dist/server/handlers/agents.d.cts +0 -6
  208. package/dist/server/handlers/error.d.cts +0 -1
  209. package/dist/server/handlers/logs.d.cts +0 -3
  210. package/dist/server/handlers/mcp.cjs +0 -14
  211. package/dist/server/handlers/mcp.d.cts +0 -2
  212. package/dist/server/handlers/mcp.d.ts +0 -2
  213. package/dist/server/handlers/mcp.js +0 -1
  214. package/dist/server/handlers/memory.d.cts +0 -8
  215. package/dist/server/handlers/network.d.cts +0 -4
  216. package/dist/server/handlers/telemetry.d.cts +0 -2
  217. package/dist/server/handlers/tools.d.cts +0 -4
  218. package/dist/server/handlers/utils.d.cts +0 -1
  219. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  220. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  221. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  222. package/dist/server/handlers/vNextWorkflows.js +0 -1
  223. package/dist/server/handlers/vector.d.cts +0 -6
  224. package/dist/server/handlers/voice.d.cts +0 -3
  225. package/dist/server/handlers/workflows.d.cts +0 -10
  226. package/dist/server/handlers.d.cts +0 -10
@@ -1,203 +0,0 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
-
5
- // src/server/handlers/memory.ts
6
- var memory_exports = {};
7
- __export(memory_exports, {
8
- createThreadHandler: () => createThreadHandler,
9
- deleteThreadHandler: () => deleteThreadHandler,
10
- getMemoryStatusHandler: () => getMemoryStatusHandler,
11
- getMessagesHandler: () => getMessagesHandler,
12
- getThreadByIdHandler: () => getThreadByIdHandler,
13
- getThreadsHandler: () => getThreadsHandler,
14
- saveMessagesHandler: () => saveMessagesHandler,
15
- updateThreadHandler: () => updateThreadHandler
16
- });
17
- function getMemoryFromContext({
18
- mastra,
19
- agentId
20
- }) {
21
- const agent = agentId ? mastra.getAgent(agentId) : null;
22
- if (agentId && !agent) {
23
- throw new HTTPException(404, { message: "Agent not found" });
24
- }
25
- const memory = agent?.getMemory?.() || mastra.getMemory();
26
- return memory;
27
- }
28
- async function getMemoryStatusHandler({ mastra, agentId }) {
29
- try {
30
- const memory = getMemoryFromContext({ mastra, agentId });
31
- if (!memory) {
32
- return { result: false };
33
- }
34
- return { result: true };
35
- } catch (error) {
36
- return handleError(error, "Error getting memory status");
37
- }
38
- }
39
- async function getThreadsHandler({
40
- mastra,
41
- agentId,
42
- resourceId
43
- }) {
44
- try {
45
- const memory = getMemoryFromContext({ mastra, agentId });
46
- if (!memory) {
47
- throw new HTTPException(400, { message: "Memory is not initialized" });
48
- }
49
- validateBody({ resourceId });
50
- const threads = await memory.getThreadsByResourceId({ resourceId });
51
- return threads;
52
- } catch (error) {
53
- return handleError(error, "Error getting threads");
54
- }
55
- }
56
- async function getThreadByIdHandler({
57
- mastra,
58
- agentId,
59
- threadId
60
- }) {
61
- try {
62
- validateBody({ threadId });
63
- const memory = getMemoryFromContext({ mastra, agentId });
64
- if (!memory) {
65
- throw new HTTPException(400, { message: "Memory is not initialized" });
66
- }
67
- const thread = await memory.getThreadById({ threadId });
68
- if (!thread) {
69
- throw new HTTPException(404, { message: "Thread not found" });
70
- }
71
- return thread;
72
- } catch (error) {
73
- return handleError(error, "Error getting thread");
74
- }
75
- }
76
- async function saveMessagesHandler({
77
- mastra,
78
- agentId,
79
- body
80
- }) {
81
- try {
82
- const memory = getMemoryFromContext({ mastra, agentId });
83
- if (!memory) {
84
- throw new HTTPException(400, { message: "Memory is not initialized" });
85
- }
86
- if (!body?.messages) {
87
- throw new HTTPException(400, { message: "Messages are required" });
88
- }
89
- if (!Array.isArray(body.messages)) {
90
- throw new HTTPException(400, { message: "Messages should be an array" });
91
- }
92
- const processedMessages = body.messages.map((message) => ({
93
- ...message,
94
- id: memory.generateId(),
95
- createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
96
- }));
97
- const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
98
- return result;
99
- } catch (error) {
100
- return handleError(error, "Error saving messages");
101
- }
102
- }
103
- async function createThreadHandler({
104
- mastra,
105
- agentId,
106
- body
107
- }) {
108
- try {
109
- const memory = getMemoryFromContext({ mastra, agentId });
110
- if (!memory) {
111
- throw new HTTPException(400, { message: "Memory is not initialized" });
112
- }
113
- validateBody({ resourceId: body?.resourceId });
114
- const result = await memory.createThread({
115
- resourceId: body?.resourceId,
116
- title: body?.title,
117
- metadata: body?.metadata,
118
- threadId: body?.threadId
119
- });
120
- return result;
121
- } catch (error) {
122
- return handleError(error, "Error saving thread to memory");
123
- }
124
- }
125
- async function updateThreadHandler({
126
- mastra,
127
- agentId,
128
- threadId,
129
- body
130
- }) {
131
- try {
132
- const memory = getMemoryFromContext({ mastra, agentId });
133
- if (!body) {
134
- throw new HTTPException(400, { message: "Body is required" });
135
- }
136
- const { title, metadata, resourceId } = body;
137
- const updatedAt = /* @__PURE__ */ new Date();
138
- validateBody({ threadId });
139
- if (!memory) {
140
- throw new HTTPException(400, { message: "Memory is not initialized" });
141
- }
142
- const thread = await memory.getThreadById({ threadId });
143
- if (!thread) {
144
- throw new HTTPException(404, { message: "Thread not found" });
145
- }
146
- const updatedThread = {
147
- ...thread,
148
- title: title || thread.title,
149
- metadata: metadata || thread.metadata,
150
- resourceId: resourceId || thread.resourceId,
151
- createdAt: thread.createdAt,
152
- updatedAt
153
- };
154
- const result = await memory.saveThread({ thread: updatedThread });
155
- return result;
156
- } catch (error) {
157
- return handleError(error, "Error updating thread");
158
- }
159
- }
160
- async function deleteThreadHandler({
161
- mastra,
162
- agentId,
163
- threadId
164
- }) {
165
- try {
166
- validateBody({ threadId });
167
- const memory = getMemoryFromContext({ mastra, agentId });
168
- if (!memory) {
169
- throw new HTTPException(400, { message: "Memory is not initialized" });
170
- }
171
- const thread = await memory.getThreadById({ threadId });
172
- if (!thread) {
173
- throw new HTTPException(404, { message: "Thread not found" });
174
- }
175
- await memory.deleteThread(threadId);
176
- return { result: "Thread deleted" };
177
- } catch (error) {
178
- return handleError(error, "Error deleting thread");
179
- }
180
- }
181
- async function getMessagesHandler({
182
- mastra,
183
- agentId,
184
- threadId
185
- }) {
186
- try {
187
- validateBody({ threadId });
188
- const memory = getMemoryFromContext({ mastra, agentId });
189
- if (!memory) {
190
- throw new HTTPException(400, { message: "Memory is not initialized" });
191
- }
192
- const thread = await memory.getThreadById({ threadId });
193
- if (!thread) {
194
- throw new HTTPException(404, { message: "Thread not found" });
195
- }
196
- const result = await memory.query({ threadId });
197
- return result;
198
- } catch (error) {
199
- return handleError(error, "Error getting messages");
200
- }
201
- }
202
-
203
- export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, memory_exports, saveMessagesHandler, updateThreadHandler };
@@ -1,54 +0,0 @@
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({
15
- mastra,
16
- transportId
17
- }) {
18
- try {
19
- chunkQN4KF3BH_cjs.validateBody({ transportId });
20
- const logs = await mastra.getLogs(transportId);
21
- return logs;
22
- } catch (error) {
23
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting logs");
24
- }
25
- }
26
- async function getLogsByRunIdHandler({
27
- mastra,
28
- runId,
29
- transportId
30
- }) {
31
- try {
32
- chunkQN4KF3BH_cjs.validateBody({ runId, transportId });
33
- const logs = await mastra.getLogsByRunId({ runId, transportId });
34
- return logs;
35
- } catch (error) {
36
- return chunkZLBRQFDD_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 chunkZLBRQFDD_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;
@@ -1,181 +0,0 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { validateBody } from './chunk-L7XE5QTW.js';
3
- import { handleError } from './chunk-3AHQ5RGN.js';
4
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
5
-
6
- // src/server/handlers/agents.ts
7
- var agents_exports = {};
8
- __export(agents_exports, {
9
- generateHandler: () => generateHandler,
10
- getAgentByIdHandler: () => getAgentByIdHandler,
11
- getAgentsHandler: () => getAgentsHandler,
12
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
13
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
14
- streamGenerateHandler: () => streamGenerateHandler
15
- });
16
- async function getAgentsHandler({ mastra, runtimeContext }) {
17
- try {
18
- const agents = mastra.getAgents();
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()
40
- };
41
- })
42
- );
43
- const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
44
- acc[id] = rest;
45
- return acc;
46
- }, {});
47
- return serializedAgents;
48
- } catch (error) {
49
- return handleError(error, "Error getting agents");
50
- }
51
- }
52
- async function getAgentByIdHandler({
53
- mastra,
54
- runtimeContext,
55
- agentId
56
- }) {
57
- try {
58
- const agent = mastra.getAgent(agentId);
59
- if (!agent) {
60
- throw new HTTPException(404, { message: "Agent not found" });
61
- }
62
- const tools = await agent.getTools({ runtimeContext });
63
- const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
64
- const _tool = tool;
65
- acc[key] = {
66
- ..._tool,
67
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
68
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
69
- };
70
- return acc;
71
- }, {});
72
- const instructions = await agent.getInstructions({ runtimeContext });
73
- const llm = await agent.getLLM({ runtimeContext });
74
- return {
75
- name: agent.name,
76
- instructions,
77
- tools: serializedAgentTools,
78
- provider: llm?.getProvider(),
79
- modelId: llm?.getModelId()
80
- };
81
- } catch (error) {
82
- return handleError(error, "Error getting agent");
83
- }
84
- }
85
- async function getEvalsByAgentIdHandler({
86
- mastra,
87
- runtimeContext,
88
- agentId
89
- }) {
90
- try {
91
- const agent = mastra.getAgent(agentId);
92
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
93
- const instructions = await agent.getInstructions({ runtimeContext });
94
- return {
95
- id: agentId,
96
- name: agent.name,
97
- instructions,
98
- evals
99
- };
100
- } catch (error) {
101
- return handleError(error, "Error getting test evals");
102
- }
103
- }
104
- async function getLiveEvalsByAgentIdHandler({
105
- mastra,
106
- runtimeContext,
107
- agentId
108
- }) {
109
- try {
110
- const agent = mastra.getAgent(agentId);
111
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
112
- const instructions = await agent.getInstructions({ runtimeContext });
113
- return {
114
- id: agentId,
115
- name: agent.name,
116
- instructions,
117
- evals
118
- };
119
- } catch (error) {
120
- return handleError(error, "Error getting live evals");
121
- }
122
- }
123
- async function generateHandler({
124
- mastra,
125
- runtimeContext,
126
- agentId,
127
- body
128
- }) {
129
- try {
130
- const agent = mastra.getAgent(agentId);
131
- if (!agent) {
132
- throw new HTTPException(404, { message: "Agent not found" });
133
- }
134
- const { messages, resourceId, resourceid, ...rest } = body;
135
- const finalResourceId = resourceId ?? resourceid;
136
- validateBody({ messages });
137
- const result = await agent.generate(messages, {
138
- ...rest,
139
- // @ts-expect-error TODO fix types
140
- resourceId: finalResourceId,
141
- runtimeContext
142
- });
143
- return result;
144
- } catch (error) {
145
- return handleError(error, "Error generating from agent");
146
- }
147
- }
148
- async function streamGenerateHandler({
149
- mastra,
150
- runtimeContext,
151
- agentId,
152
- body
153
- }) {
154
- try {
155
- const agent = mastra.getAgent(agentId);
156
- if (!agent) {
157
- throw new HTTPException(404, { message: "Agent not found" });
158
- }
159
- const { messages, resourceId, resourceid, ...rest } = body;
160
- const finalResourceId = resourceId ?? resourceid;
161
- validateBody({ messages });
162
- const streamResult = await agent.stream(messages, {
163
- ...rest,
164
- // @ts-expect-error TODO fix types
165
- resourceId: finalResourceId,
166
- runtimeContext
167
- });
168
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
169
- sendUsage: true,
170
- sendReasoning: true,
171
- getErrorMessage: (error) => {
172
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
173
- }
174
- });
175
- return streamResponse;
176
- } catch (error) {
177
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
178
- }
179
- }
180
-
181
- export { agents_exports, generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
4
-
5
- // src/server/handlers/error.ts
6
- function handleError(error, defaultMessage) {
7
- const apiError = error;
8
- throw new chunkFV45V6WC_cjs.HTTPException(apiError.status || 500, {
9
- message: apiError.message || defaultMessage
10
- });
11
- }
12
-
13
- exports.handleError = handleError;
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
- export { getMcpServersHandler } from './_tsup-dts-rollup.cjs';
2
- export { getMcpServerHandler } from './_tsup-dts-rollup.cjs';
@@ -1,6 +0,0 @@
1
- export { getAgentsHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getAgentByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { getEvalsByAgentIdHandler } from '../../_tsup-dts-rollup.cjs';
4
- export { getLiveEvalsByAgentIdHandler } from '../../_tsup-dts-rollup.cjs';
5
- export { generateHandler } from '../../_tsup-dts-rollup.cjs';
6
- export { streamGenerateHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1 +0,0 @@
1
- export { handleError } from '../../_tsup-dts-rollup.cjs';
@@ -1,3 +0,0 @@
1
- export { getLogsHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getLogsByRunIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { getLogTransports } from '../../_tsup-dts-rollup.cjs';
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk74DLDQTQ_cjs = require('../../chunk-74DLDQTQ.cjs');
4
-
5
-
6
-
7
- Object.defineProperty(exports, "getMcpServerHandler", {
8
- enumerable: true,
9
- get: function () { return chunk74DLDQTQ_cjs.getMcpServerHandler; }
10
- });
11
- Object.defineProperty(exports, "getMcpServersHandler", {
12
- enumerable: true,
13
- get: function () { return chunk74DLDQTQ_cjs.getMcpServersHandler; }
14
- });
@@ -1,2 +0,0 @@
1
- export { getMcpServersHandler_alias_2 as getMcpServersHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getMcpServerHandler_alias_2 as getMcpServerHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,2 +0,0 @@
1
- export { getMcpServersHandler_alias_2 as getMcpServersHandler } from '../../_tsup-dts-rollup.js';
2
- export { getMcpServerHandler_alias_2 as getMcpServerHandler } from '../../_tsup-dts-rollup.js';
@@ -1 +0,0 @@
1
- export { getMcpServerHandler, getMcpServersHandler } from '../../chunk-HAA5T7JL.js';
@@ -1,8 +0,0 @@
1
- export { getMemoryStatusHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getThreadsHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { getThreadByIdHandler } from '../../_tsup-dts-rollup.cjs';
4
- export { saveMessagesHandler } from '../../_tsup-dts-rollup.cjs';
5
- export { createThreadHandler } from '../../_tsup-dts-rollup.cjs';
6
- export { updateThreadHandler } from '../../_tsup-dts-rollup.cjs';
7
- export { deleteThreadHandler } from '../../_tsup-dts-rollup.cjs';
8
- export { getMessagesHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,4 +0,0 @@
1
- export { getNetworksHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getNetworkByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { generateHandler_alias_1 as generateHandler } from '../../_tsup-dts-rollup.cjs';
4
- export { streamGenerateHandler_alias_1 as streamGenerateHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,2 +0,0 @@
1
- export { getTelemetryHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { storeTelemetryHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,4 +0,0 @@
1
- export { getToolsHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getToolByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { executeToolHandler } from '../../_tsup-dts-rollup.cjs';
4
- export { executeAgentToolHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1 +0,0 @@
1
- export { validateBody } from '../../_tsup-dts-rollup.cjs';
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkFOXHTOQZ_cjs = require('../../chunk-FOXHTOQZ.cjs');
4
-
5
-
6
-
7
- Object.defineProperty(exports, "createVNextWorkflowRunHandler", {
8
- enumerable: true,
9
- get: function () { return chunkFOXHTOQZ_cjs.createVNextWorkflowRunHandler; }
10
- });
11
- Object.defineProperty(exports, "getVNextWorkflowByIdHandler", {
12
- enumerable: true,
13
- get: function () { return chunkFOXHTOQZ_cjs.getVNextWorkflowByIdHandler; }
14
- });
15
- Object.defineProperty(exports, "getVNextWorkflowRunHandler", {
16
- enumerable: true,
17
- get: function () { return chunkFOXHTOQZ_cjs.getVNextWorkflowRunHandler; }
18
- });
19
- Object.defineProperty(exports, "getVNextWorkflowRunsHandler", {
20
- enumerable: true,
21
- get: function () { return chunkFOXHTOQZ_cjs.getVNextWorkflowRunsHandler; }
22
- });
23
- Object.defineProperty(exports, "getVNextWorkflowsHandler", {
24
- enumerable: true,
25
- get: function () { return chunkFOXHTOQZ_cjs.getVNextWorkflowsHandler; }
26
- });
27
- Object.defineProperty(exports, "resumeAsyncVNextWorkflowHandler", {
28
- enumerable: true,
29
- get: function () { return chunkFOXHTOQZ_cjs.resumeAsyncVNextWorkflowHandler; }
30
- });
31
- Object.defineProperty(exports, "resumeVNextWorkflowHandler", {
32
- enumerable: true,
33
- get: function () { return chunkFOXHTOQZ_cjs.resumeVNextWorkflowHandler; }
34
- });
35
- Object.defineProperty(exports, "startAsyncVNextWorkflowHandler", {
36
- enumerable: true,
37
- get: function () { return chunkFOXHTOQZ_cjs.startAsyncVNextWorkflowHandler; }
38
- });
39
- Object.defineProperty(exports, "startVNextWorkflowRunHandler", {
40
- enumerable: true,
41
- get: function () { return chunkFOXHTOQZ_cjs.startVNextWorkflowRunHandler; }
42
- });
43
- Object.defineProperty(exports, "watchVNextWorkflowHandler", {
44
- enumerable: true,
45
- get: function () { return chunkFOXHTOQZ_cjs.watchVNextWorkflowHandler; }
46
- });
@@ -1,10 +0,0 @@
1
- export { getVNextWorkflowsHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getVNextWorkflowByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { getVNextWorkflowRunHandler } 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';
@@ -1,10 +0,0 @@
1
- export { getVNextWorkflowsHandler } from '../../_tsup-dts-rollup.js';
2
- export { getVNextWorkflowByIdHandler } from '../../_tsup-dts-rollup.js';
3
- export { getVNextWorkflowRunHandler } 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';
@@ -1 +0,0 @@
1
- export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, watchVNextWorkflowHandler } from '../../chunk-IQTNZSFP.js';
@@ -1,6 +0,0 @@
1
- export { upsertVectors } from '../../_tsup-dts-rollup.cjs';
2
- export { createIndex } from '../../_tsup-dts-rollup.cjs';
3
- export { queryVectors } from '../../_tsup-dts-rollup.cjs';
4
- export { listIndexes } from '../../_tsup-dts-rollup.cjs';
5
- export { describeIndex } from '../../_tsup-dts-rollup.cjs';
6
- export { deleteIndex } from '../../_tsup-dts-rollup.cjs';
@@ -1,3 +0,0 @@
1
- export { getSpeakersHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { generateSpeechHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { transcribeSpeechHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,10 +0,0 @@
1
- export { getWorkflowsHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getWorkflowByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { startAsyncWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
4
- export { getWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
5
- export { createRunHandler } from '../../_tsup-dts-rollup.cjs';
6
- export { startWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
7
- export { watchWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
8
- export { resumeAsyncWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
9
- export { resumeWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
10
- export { getWorkflowRunsHandler } from '../../_tsup-dts-rollup.cjs';
@@ -1,10 +0,0 @@
1
- export { agents } from '../_tsup-dts-rollup.cjs';
2
- export { logs } from '../_tsup-dts-rollup.cjs';
3
- export { memory } from '../_tsup-dts-rollup.cjs';
4
- export { network } from '../_tsup-dts-rollup.cjs';
5
- export { telemetry } from '../_tsup-dts-rollup.cjs';
6
- export { tools } from '../_tsup-dts-rollup.cjs';
7
- export { workflows } from '../_tsup-dts-rollup.cjs';
8
- export { vNextWorkflows } from '../_tsup-dts-rollup.cjs';
9
- export { vector } from '../_tsup-dts-rollup.cjs';
10
- export { voice } from '../_tsup-dts-rollup.cjs';