@mastra/server 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnext-20251104230439

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 (269) hide show
  1. package/CHANGELOG.md +4403 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +1 -6
  4. package/dist/chunk-2PLXW4ZX.cjs +2777 -0
  5. package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
  6. package/dist/chunk-46Z2KDQL.js +124 -0
  7. package/dist/chunk-46Z2KDQL.js.map +1 -0
  8. package/dist/{chunk-FV45V6WC.cjs → chunk-64ITUOXI.cjs} +3 -7
  9. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  10. package/dist/{chunk-TRDNDNGQ.js → chunk-6QWQZI4Q.js} +4 -7
  11. package/dist/chunk-6QWQZI4Q.js.map +1 -0
  12. package/dist/chunk-73PAWDM5.js +83 -0
  13. package/dist/chunk-73PAWDM5.js.map +1 -0
  14. package/dist/chunk-AEVI2HIU.cjs +651 -0
  15. package/dist/chunk-AEVI2HIU.cjs.map +1 -0
  16. package/dist/chunk-ALOLTNSO.js +477 -0
  17. package/dist/chunk-ALOLTNSO.js.map +1 -0
  18. package/dist/chunk-B6NK4KI5.cjs +128 -0
  19. package/dist/chunk-B6NK4KI5.cjs.map +1 -0
  20. package/dist/chunk-BANGX6SC.cjs +200 -0
  21. package/dist/chunk-BANGX6SC.cjs.map +1 -0
  22. package/dist/chunk-BHQH5QXD.cjs +172 -0
  23. package/dist/chunk-BHQH5QXD.cjs.map +1 -0
  24. package/dist/chunk-BTWIR2B7.cjs +28 -0
  25. package/dist/chunk-BTWIR2B7.cjs.map +1 -0
  26. package/dist/chunk-DNUO33HF.js +129 -0
  27. package/dist/chunk-DNUO33HF.js.map +1 -0
  28. package/dist/chunk-FKZVCLOY.js +527 -0
  29. package/dist/chunk-FKZVCLOY.js.map +1 -0
  30. package/dist/chunk-GTZOYEAU.cjs +130 -0
  31. package/dist/chunk-GTZOYEAU.cjs.map +1 -0
  32. package/dist/chunk-GU4EWMZB.cjs +769 -0
  33. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  34. package/dist/chunk-IGOWG5V5.js +192 -0
  35. package/dist/chunk-IGOWG5V5.js.map +1 -0
  36. package/dist/chunk-JIIVA4BA.cjs +23087 -0
  37. package/dist/chunk-JIIVA4BA.cjs.map +1 -0
  38. package/dist/chunk-JO2AZFJN.js +165 -0
  39. package/dist/chunk-JO2AZFJN.js.map +1 -0
  40. package/dist/chunk-JZ65BJ6H.cjs +678 -0
  41. package/dist/chunk-JZ65BJ6H.cjs.map +1 -0
  42. package/dist/chunk-KCP6I5F3.js +23047 -0
  43. package/dist/chunk-KCP6I5F3.js.map +1 -0
  44. package/dist/{chunk-4JINXASC.js → chunk-KWH5QBXP.js} +7 -4
  45. package/dist/chunk-KWH5QBXP.js.map +1 -0
  46. package/dist/chunk-LF2ZLOFP.js +767 -0
  47. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  48. package/dist/{chunk-Q6SHQECN.js → chunk-LPCK5MAF.js} +47 -13
  49. package/dist/chunk-LPCK5MAF.js.map +1 -0
  50. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  51. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  52. package/dist/chunk-LWLSQ2W4.cjs +133 -0
  53. package/dist/chunk-LWLSQ2W4.cjs.map +1 -0
  54. package/dist/chunk-O7I5CWRX.cjs +44 -0
  55. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  56. package/dist/chunk-PPMIB3FQ.cjs +88 -0
  57. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  58. package/dist/chunk-PR4QN5HX.js +39 -0
  59. package/dist/chunk-PR4QN5HX.js.map +1 -0
  60. package/dist/chunk-QFGNUBOA.cjs +543 -0
  61. package/dist/chunk-QFGNUBOA.cjs.map +1 -0
  62. package/dist/chunk-QU6N55W6.cjs +256 -0
  63. package/dist/chunk-QU6N55W6.cjs.map +1 -0
  64. package/dist/chunk-R6OQFR47.js +630 -0
  65. package/dist/chunk-R6OQFR47.js.map +1 -0
  66. package/dist/chunk-RQK4FQUD.js +1012 -0
  67. package/dist/chunk-RQK4FQUD.js.map +1 -0
  68. package/dist/{chunk-M56ECCHK.cjs → chunk-S54HNARD.cjs} +22 -19
  69. package/dist/chunk-S54HNARD.cjs.map +1 -0
  70. package/dist/chunk-SHWNNZBL.js +254 -0
  71. package/dist/chunk-SHWNNZBL.js.map +1 -0
  72. package/dist/{chunk-L7XE5QTW.js → chunk-SZIFSF4T.js} +11 -2
  73. package/dist/chunk-SZIFSF4T.js.map +1 -0
  74. package/dist/chunk-TOCYBDP2.js +46 -0
  75. package/dist/chunk-TOCYBDP2.js.map +1 -0
  76. package/dist/chunk-UXGQZUYZ.js +16 -0
  77. package/dist/chunk-UXGQZUYZ.js.map +1 -0
  78. package/dist/chunk-V5WWQN7P.cjs +18 -0
  79. package/dist/chunk-V5WWQN7P.cjs.map +1 -0
  80. package/dist/chunk-VYR3SAFM.js +658 -0
  81. package/dist/chunk-VYR3SAFM.js.map +1 -0
  82. package/dist/chunk-X6C7BUWN.cjs +48 -0
  83. package/dist/chunk-X6C7BUWN.cjs.map +1 -0
  84. package/dist/chunk-XXGID4PQ.cjs +485 -0
  85. package/dist/chunk-XXGID4PQ.cjs.map +1 -0
  86. package/dist/chunk-ZULZ2752.js +2774 -0
  87. package/dist/chunk-ZULZ2752.js.map +1 -0
  88. package/dist/dist-4MVGNSRL.cjs +1150 -0
  89. package/dist/dist-4MVGNSRL.cjs.map +1 -0
  90. package/dist/dist-FZYCV3VB.cjs +940 -0
  91. package/dist/dist-FZYCV3VB.cjs.map +1 -0
  92. package/dist/dist-G2BYZJOC.cjs +928 -0
  93. package/dist/dist-G2BYZJOC.cjs.map +1 -0
  94. package/dist/dist-P4MXBQ3U.cjs +16 -0
  95. package/dist/dist-P4MXBQ3U.cjs.map +1 -0
  96. package/dist/dist-PQZUVLPC.js +937 -0
  97. package/dist/dist-PQZUVLPC.js.map +1 -0
  98. package/dist/dist-R7WYX6LC.js +925 -0
  99. package/dist/dist-R7WYX6LC.js.map +1 -0
  100. package/dist/dist-RFMYFILX.cjs +764 -0
  101. package/dist/dist-RFMYFILX.cjs.map +1 -0
  102. package/dist/dist-X7XR3M3Z.js +1147 -0
  103. package/dist/dist-X7XR3M3Z.js.map +1 -0
  104. package/dist/dist-XVBSOGFK.js +761 -0
  105. package/dist/dist-XVBSOGFK.js.map +1 -0
  106. package/dist/dist-YREX2TJT.js +3 -0
  107. package/dist/dist-YREX2TJT.js.map +1 -0
  108. package/dist/index.cjs +6 -0
  109. package/dist/index.cjs.map +1 -0
  110. package/dist/index.d.ts +1 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +5 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/server/a2a/protocol.d.ts +8 -0
  115. package/dist/server/a2a/protocol.d.ts.map +1 -0
  116. package/dist/server/a2a/store.cjs +25 -0
  117. package/dist/server/a2a/store.cjs.map +1 -0
  118. package/dist/server/a2a/store.d.ts +14 -0
  119. package/dist/server/a2a/store.d.ts.map +1 -0
  120. package/dist/server/a2a/store.js +23 -0
  121. package/dist/server/a2a/store.js.map +1 -0
  122. package/dist/server/a2a/tasks.d.ts +20 -0
  123. package/dist/server/a2a/tasks.d.ts.map +1 -0
  124. package/dist/server/handlers/a2a.cjs +32 -0
  125. package/dist/server/handlers/a2a.cjs.map +1 -0
  126. package/dist/server/handlers/a2a.d.ts +68 -0
  127. package/dist/server/handlers/a2a.d.ts.map +1 -0
  128. package/dist/server/handlers/a2a.js +3 -0
  129. package/dist/server/handlers/a2a.js.map +1 -0
  130. package/dist/server/handlers/agent-builder.cjs +84 -0
  131. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  132. package/dist/server/handlers/agent-builder.d.ts +91 -0
  133. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  134. package/dist/server/handlers/agent-builder.js +3 -0
  135. package/dist/server/handlers/agent-builder.js.map +1 -0
  136. package/dist/server/handlers/agents.cjs +60 -10
  137. package/dist/server/handlers/agents.cjs.map +1 -0
  138. package/dist/server/handlers/agents.d.ts +194 -6
  139. package/dist/server/handlers/agents.d.ts.map +1 -0
  140. package/dist/server/handlers/agents.js +3 -1
  141. package/dist/server/handlers/agents.js.map +1 -0
  142. package/dist/server/handlers/error.cjs +4 -2
  143. package/dist/server/handlers/error.cjs.map +1 -0
  144. package/dist/server/handlers/error.d.ts +2 -1
  145. package/dist/server/handlers/error.d.ts.map +1 -0
  146. package/dist/server/handlers/error.js +3 -1
  147. package/dist/server/handlers/error.js.map +1 -0
  148. package/dist/server/handlers/logs.cjs +9 -7
  149. package/dist/server/handlers/logs.cjs.map +1 -0
  150. package/dist/server/handlers/logs.d.ts +34 -3
  151. package/dist/server/handlers/logs.d.ts.map +1 -0
  152. package/dist/server/handlers/logs.js +3 -1
  153. package/dist/server/handlers/logs.js.map +1 -0
  154. package/dist/server/handlers/memory.cjs +36 -10
  155. package/dist/server/handlers/memory.cjs.map +1 -0
  156. package/dist/server/handlers/memory.d.ts +116 -8
  157. package/dist/server/handlers/memory.d.ts.map +1 -0
  158. package/dist/server/handlers/memory.js +3 -1
  159. package/dist/server/handlers/memory.js.map +1 -0
  160. package/dist/server/handlers/observability.cjs +24 -0
  161. package/dist/server/handlers/observability.cjs.map +1 -0
  162. package/dist/server/handlers/observability.d.ts +49 -0
  163. package/dist/server/handlers/observability.d.ts.map +1 -0
  164. package/dist/server/handlers/observability.js +3 -0
  165. package/dist/server/handlers/observability.js.map +1 -0
  166. package/dist/server/handlers/scores.cjs +32 -0
  167. package/dist/server/handlers/scores.cjs.map +1 -0
  168. package/dist/server/handlers/scores.d.ts +152 -0
  169. package/dist/server/handlers/scores.d.ts.map +1 -0
  170. package/dist/server/handlers/scores.js +3 -0
  171. package/dist/server/handlers/scores.js.map +1 -0
  172. package/dist/server/handlers/tools.cjs +12 -6
  173. package/dist/server/handlers/tools.cjs.map +1 -0
  174. package/dist/server/handlers/tools.d.ts +25 -4
  175. package/dist/server/handlers/tools.d.ts.map +1 -0
  176. package/dist/server/handlers/tools.js +3 -1
  177. package/dist/server/handlers/tools.js.map +1 -0
  178. package/dist/server/handlers/utils.cjs +8 -2
  179. package/dist/server/handlers/utils.cjs.map +1 -0
  180. package/dist/server/handlers/utils.d.ts +8 -1
  181. package/dist/server/handlers/utils.d.ts.map +1 -0
  182. package/dist/server/handlers/utils.js +3 -1
  183. package/dist/server/handlers/utils.js.map +1 -0
  184. package/dist/server/handlers/vector.cjs +9 -7
  185. package/dist/server/handlers/vector.cjs.map +1 -0
  186. package/dist/server/handlers/vector.d.ts +51 -6
  187. package/dist/server/handlers/vector.d.ts.map +1 -0
  188. package/dist/server/handlers/vector.js +3 -1
  189. package/dist/server/handlers/vector.js.map +1 -0
  190. package/dist/server/handlers/voice.cjs +10 -4
  191. package/dist/server/handlers/voice.cjs.map +1 -0
  192. package/dist/server/handlers/voice.d.ts +41 -3
  193. package/dist/server/handlers/voice.d.ts.map +1 -0
  194. package/dist/server/handlers/voice.js +3 -1
  195. package/dist/server/handlers/voice.js.map +1 -0
  196. package/dist/server/handlers/workflows.cjs +54 -16
  197. package/dist/server/handlers/workflows.cjs.map +1 -0
  198. package/dist/server/handlers/workflows.d.ts +94 -10
  199. package/dist/server/handlers/workflows.d.ts.map +1 -0
  200. package/dist/server/handlers/workflows.js +3 -1
  201. package/dist/server/handlers/workflows.js.map +1 -0
  202. package/dist/server/handlers.cjs +37 -30
  203. package/dist/server/handlers.cjs.map +1 -0
  204. package/dist/server/handlers.d.ts +12 -10
  205. package/dist/server/handlers.d.ts.map +1 -0
  206. package/dist/server/handlers.js +13 -10
  207. package/dist/server/handlers.js.map +1 -0
  208. package/dist/server/http-exception.d.ts +82 -0
  209. package/dist/server/http-exception.d.ts.map +1 -0
  210. package/dist/server/types.d.ts +10 -0
  211. package/dist/server/types.d.ts.map +1 -0
  212. package/dist/server/utils.d.ts +44 -0
  213. package/dist/server/utils.d.ts.map +1 -0
  214. package/dist/token-375W3LEI.cjs +64 -0
  215. package/dist/token-375W3LEI.cjs.map +1 -0
  216. package/dist/token-C3IMNCC4.js +62 -0
  217. package/dist/token-C3IMNCC4.js.map +1 -0
  218. package/dist/token-util-CV3RRG6K.cjs +9 -0
  219. package/dist/token-util-CV3RRG6K.cjs.map +1 -0
  220. package/dist/token-util-E5QO2RCL.js +7 -0
  221. package/dist/token-util-E5QO2RCL.js.map +1 -0
  222. package/package.json +43 -19
  223. package/dist/_tsup-dts-rollup.d.cts +0 -670
  224. package/dist/_tsup-dts-rollup.d.ts +0 -670
  225. package/dist/chunk-2FJURXCL.cjs +0 -213
  226. package/dist/chunk-3AHQ5RGN.js +0 -11
  227. package/dist/chunk-3EJZQ6TQ.js +0 -49
  228. package/dist/chunk-3XTEV33Q.js +0 -317
  229. package/dist/chunk-55HTWX4C.cjs +0 -93
  230. package/dist/chunk-5JNVY6DU.js +0 -120
  231. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  232. package/dist/chunk-5YGDYMRB.cjs +0 -147
  233. package/dist/chunk-6Q7UXAYJ.cjs +0 -198
  234. package/dist/chunk-AMVOS7YB.cjs +0 -141
  235. package/dist/chunk-BPL2CBLV.js +0 -137
  236. package/dist/chunk-CHFORQ7J.cjs +0 -329
  237. package/dist/chunk-D3G23FP3.cjs +0 -126
  238. package/dist/chunk-GVBJ5I2S.js +0 -190
  239. package/dist/chunk-M2RXDCPV.cjs +0 -324
  240. package/dist/chunk-OMN3UI6X.js +0 -5576
  241. package/dist/chunk-OWNA6I2H.js +0 -312
  242. package/dist/chunk-QJ3AHN64.js +0 -141
  243. package/dist/chunk-QN4KF3BH.cjs +0 -18
  244. package/dist/chunk-RBQASTUP.js +0 -203
  245. package/dist/chunk-SKBVVI24.cjs +0 -54
  246. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  247. package/dist/index.d.cts +0 -1
  248. package/dist/server/handlers/agents.d.cts +0 -6
  249. package/dist/server/handlers/error.d.cts +0 -1
  250. package/dist/server/handlers/logs.d.cts +0 -3
  251. package/dist/server/handlers/memory.d.cts +0 -8
  252. package/dist/server/handlers/network.cjs +0 -22
  253. package/dist/server/handlers/network.d.cts +0 -4
  254. package/dist/server/handlers/network.d.ts +0 -4
  255. package/dist/server/handlers/network.js +0 -1
  256. package/dist/server/handlers/telemetry.cjs +0 -14
  257. package/dist/server/handlers/telemetry.d.cts +0 -2
  258. package/dist/server/handlers/telemetry.d.ts +0 -2
  259. package/dist/server/handlers/telemetry.js +0 -1
  260. package/dist/server/handlers/tools.d.cts +0 -4
  261. package/dist/server/handlers/utils.d.cts +0 -1
  262. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  263. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  264. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  265. package/dist/server/handlers/vNextWorkflows.js +0 -1
  266. package/dist/server/handlers/vector.d.cts +0 -6
  267. package/dist/server/handlers/voice.d.cts +0 -3
  268. package/dist/server/handlers/workflows.d.cts +0 -10
  269. package/dist/server/handlers.d.cts +0 -10
@@ -1,213 +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/memory.ts
8
- var memory_exports = {};
9
- chunkFV45V6WC_cjs.__export(memory_exports, {
10
- createThreadHandler: () => createThreadHandler,
11
- deleteThreadHandler: () => deleteThreadHandler,
12
- getMemoryStatusHandler: () => getMemoryStatusHandler,
13
- getMessagesHandler: () => getMessagesHandler,
14
- getThreadByIdHandler: () => getThreadByIdHandler,
15
- getThreadsHandler: () => getThreadsHandler,
16
- saveMessagesHandler: () => saveMessagesHandler,
17
- updateThreadHandler: () => updateThreadHandler
18
- });
19
- function getMemoryFromContext({
20
- mastra,
21
- agentId
22
- }) {
23
- const agent = agentId ? mastra.getAgent(agentId) : null;
24
- if (agentId && !agent) {
25
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
26
- }
27
- const memory = agent?.getMemory?.() || mastra.getMemory();
28
- return memory;
29
- }
30
- async function getMemoryStatusHandler({ mastra, agentId }) {
31
- try {
32
- const memory = getMemoryFromContext({ mastra, agentId });
33
- if (!memory) {
34
- return { result: false };
35
- }
36
- return { result: true };
37
- } catch (error) {
38
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting memory status");
39
- }
40
- }
41
- async function getThreadsHandler({
42
- mastra,
43
- agentId,
44
- resourceId
45
- }) {
46
- try {
47
- const memory = getMemoryFromContext({ mastra, agentId });
48
- if (!memory) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
50
- }
51
- chunkQN4KF3BH_cjs.validateBody({ resourceId });
52
- const threads = await memory.getThreadsByResourceId({ resourceId });
53
- return threads;
54
- } catch (error) {
55
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting threads");
56
- }
57
- }
58
- async function getThreadByIdHandler({
59
- mastra,
60
- agentId,
61
- threadId
62
- }) {
63
- try {
64
- chunkQN4KF3BH_cjs.validateBody({ threadId });
65
- const memory = getMemoryFromContext({ mastra, agentId });
66
- if (!memory) {
67
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
68
- }
69
- const thread = await memory.getThreadById({ threadId });
70
- if (!thread) {
71
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
72
- }
73
- return thread;
74
- } catch (error) {
75
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting thread");
76
- }
77
- }
78
- async function saveMessagesHandler({
79
- mastra,
80
- agentId,
81
- body
82
- }) {
83
- try {
84
- const memory = getMemoryFromContext({ mastra, agentId });
85
- if (!memory) {
86
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
87
- }
88
- if (!body?.messages) {
89
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Messages are required" });
90
- }
91
- if (!Array.isArray(body.messages)) {
92
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Messages should be an array" });
93
- }
94
- const processedMessages = body.messages.map((message) => ({
95
- ...message,
96
- id: memory.generateId(),
97
- createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
98
- }));
99
- const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
100
- return result;
101
- } catch (error) {
102
- return chunkZLBRQFDD_cjs.handleError(error, "Error saving messages");
103
- }
104
- }
105
- async function createThreadHandler({
106
- mastra,
107
- agentId,
108
- body
109
- }) {
110
- try {
111
- const memory = getMemoryFromContext({ mastra, agentId });
112
- if (!memory) {
113
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
114
- }
115
- chunkQN4KF3BH_cjs.validateBody({ resourceId: body?.resourceId });
116
- const result = await memory.createThread({
117
- resourceId: body?.resourceId,
118
- title: body?.title,
119
- metadata: body?.metadata,
120
- threadId: body?.threadId
121
- });
122
- return result;
123
- } catch (error) {
124
- return chunkZLBRQFDD_cjs.handleError(error, "Error saving thread to memory");
125
- }
126
- }
127
- async function updateThreadHandler({
128
- mastra,
129
- agentId,
130
- threadId,
131
- body
132
- }) {
133
- try {
134
- const memory = getMemoryFromContext({ mastra, agentId });
135
- if (!body) {
136
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Body is required" });
137
- }
138
- const { title, metadata, resourceId } = body;
139
- const updatedAt = /* @__PURE__ */ new Date();
140
- chunkQN4KF3BH_cjs.validateBody({ threadId });
141
- if (!memory) {
142
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
143
- }
144
- const thread = await memory.getThreadById({ threadId });
145
- if (!thread) {
146
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
147
- }
148
- const updatedThread = {
149
- ...thread,
150
- title: title || thread.title,
151
- metadata: metadata || thread.metadata,
152
- resourceId: resourceId || thread.resourceId,
153
- createdAt: thread.createdAt,
154
- updatedAt
155
- };
156
- const result = await memory.saveThread({ thread: updatedThread });
157
- return result;
158
- } catch (error) {
159
- return chunkZLBRQFDD_cjs.handleError(error, "Error updating thread");
160
- }
161
- }
162
- async function deleteThreadHandler({
163
- mastra,
164
- agentId,
165
- threadId
166
- }) {
167
- try {
168
- chunkQN4KF3BH_cjs.validateBody({ threadId });
169
- const memory = getMemoryFromContext({ mastra, agentId });
170
- if (!memory) {
171
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
172
- }
173
- const thread = await memory.getThreadById({ threadId });
174
- if (!thread) {
175
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
176
- }
177
- await memory.deleteThread(threadId);
178
- return { result: "Thread deleted" };
179
- } catch (error) {
180
- return chunkZLBRQFDD_cjs.handleError(error, "Error deleting thread");
181
- }
182
- }
183
- async function getMessagesHandler({
184
- mastra,
185
- agentId,
186
- threadId
187
- }) {
188
- try {
189
- chunkQN4KF3BH_cjs.validateBody({ threadId });
190
- const memory = getMemoryFromContext({ mastra, agentId });
191
- if (!memory) {
192
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Memory is not initialized" });
193
- }
194
- const thread = await memory.getThreadById({ threadId });
195
- if (!thread) {
196
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Thread not found" });
197
- }
198
- const result = await memory.query({ threadId });
199
- return result;
200
- } catch (error) {
201
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting messages");
202
- }
203
- }
204
-
205
- exports.createThreadHandler = createThreadHandler;
206
- exports.deleteThreadHandler = deleteThreadHandler;
207
- exports.getMemoryStatusHandler = getMemoryStatusHandler;
208
- exports.getMessagesHandler = getMessagesHandler;
209
- exports.getThreadByIdHandler = getThreadByIdHandler;
210
- exports.getThreadsHandler = getThreadsHandler;
211
- exports.memory_exports = memory_exports;
212
- exports.saveMessagesHandler = saveMessagesHandler;
213
- exports.updateThreadHandler = updateThreadHandler;
@@ -1,11 +0,0 @@
1
- import { HTTPException } from './chunk-TRDNDNGQ.js';
2
-
3
- // src/server/handlers/error.ts
4
- function handleError(error, defaultMessage) {
5
- const apiError = error;
6
- throw new HTTPException(apiError.status || 500, {
7
- message: apiError.message || defaultMessage
8
- });
9
- }
10
-
11
- export { handleError };
@@ -1,49 +0,0 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export } from './chunk-TRDNDNGQ.js';
4
-
5
- // src/server/handlers/logs.ts
6
- var logs_exports = {};
7
- __export(logs_exports, {
8
- getLogTransports: () => getLogTransports,
9
- getLogsByRunIdHandler: () => getLogsByRunIdHandler,
10
- getLogsHandler: () => getLogsHandler
11
- });
12
- async function getLogsHandler({
13
- mastra,
14
- transportId
15
- }) {
16
- try {
17
- validateBody({ transportId });
18
- const logs = await mastra.getLogs(transportId);
19
- return logs;
20
- } catch (error) {
21
- return handleError(error, "Error getting logs");
22
- }
23
- }
24
- async function getLogsByRunIdHandler({
25
- mastra,
26
- runId,
27
- transportId
28
- }) {
29
- try {
30
- validateBody({ runId, transportId });
31
- const logs = await mastra.getLogsByRunId({ runId, transportId });
32
- return logs;
33
- } catch (error) {
34
- return handleError(error, "Error getting logs by run ID");
35
- }
36
- }
37
- async function getLogTransports({ mastra }) {
38
- try {
39
- const logger = mastra.getLogger();
40
- const transports = logger.transports;
41
- return {
42
- transports: transports ? Object.keys(transports) : []
43
- };
44
- } catch (error) {
45
- return handleError(error, "Error getting log Transports");
46
- }
47
- }
48
-
49
- export { getLogTransports, getLogsByRunIdHandler, getLogsHandler, logs_exports };
@@ -1,317 +0,0 @@
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/workflows.ts
7
- var workflows_exports = {};
8
- __export(workflows_exports, {
9
- createRunHandler: () => createRunHandler,
10
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
11
- getWorkflowRunHandler: () => getWorkflowRunHandler,
12
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
13
- getWorkflowsHandler: () => getWorkflowsHandler,
14
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
15
- resumeWorkflowHandler: () => resumeWorkflowHandler,
16
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
17
- startWorkflowRunHandler: () => startWorkflowRunHandler,
18
- watchWorkflowHandler: () => watchWorkflowHandler
19
- });
20
- async function getWorkflowsHandler({ mastra }) {
21
- try {
22
- const workflows = mastra.getWorkflows({ serialized: false });
23
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
24
- if (workflow.isNested) return acc;
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 ? stringify(esm_default(workflow.triggerSchema)) : void 0,
32
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
33
- const _step = step;
34
- acc2[key2] = {
35
- id: _step.id,
36
- description: _step.description,
37
- workflowId: _step.workflowId,
38
- inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
39
- outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
40
- };
41
- return acc2;
42
- }, {})
43
- };
44
- return acc;
45
- }, {});
46
- return _workflows;
47
- } catch (error) {
48
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
49
- }
50
- }
51
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
- try {
53
- if (!workflowId) {
54
- throw new HTTPException(400, { message: "Workflow ID is required" });
55
- }
56
- const workflow = mastra.getWorkflow(workflowId);
57
- if (!workflow) {
58
- throw new HTTPException(404, { message: "Workflow not found" });
59
- }
60
- return {
61
- stepGraph: workflow.stepGraph,
62
- stepSubscriberGraph: workflow.stepSubscriberGraph,
63
- serializedStepGraph: workflow.serializedStepGraph,
64
- serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
65
- name: workflow.name,
66
- triggerSchema: workflow.triggerSchema ? stringify(esm_default(workflow.triggerSchema)) : void 0,
67
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
68
- const _step = step;
69
- acc[key] = {
70
- id: _step.id,
71
- description: _step.description,
72
- workflowId: _step.workflowId,
73
- inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
74
- outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
75
- };
76
- return acc;
77
- }, {})
78
- };
79
- } catch (error) {
80
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
81
- }
82
- }
83
- async function startAsyncWorkflowHandler({
84
- mastra,
85
- runtimeContext,
86
- workflowId,
87
- runId,
88
- triggerData
89
- }) {
90
- try {
91
- if (!workflowId) {
92
- throw new HTTPException(400, { message: "Workflow ID is required" });
93
- }
94
- const workflow = mastra.getWorkflow(workflowId);
95
- if (!workflow) {
96
- throw new HTTPException(404, { message: "Workflow not found" });
97
- }
98
- if (!runId) {
99
- const { start } = workflow.createRun();
100
- const result2 = await start({
101
- triggerData,
102
- runtimeContext
103
- });
104
- return result2;
105
- }
106
- const run = workflow.getRun(runId);
107
- if (!run) {
108
- throw new HTTPException(404, { message: "Workflow run not found" });
109
- }
110
- const result = await run.start({
111
- triggerData,
112
- runtimeContext
113
- });
114
- return result;
115
- } catch (error) {
116
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
117
- }
118
- }
119
- async function getWorkflowRunHandler({
120
- mastra,
121
- workflowId,
122
- runId
123
- }) {
124
- try {
125
- if (!workflowId) {
126
- throw new HTTPException(400, { message: "Workflow ID is required" });
127
- }
128
- if (!runId) {
129
- throw new HTTPException(400, { message: "Run ID is required" });
130
- }
131
- const workflow = mastra.getWorkflow(workflowId);
132
- if (!workflow) {
133
- throw new HTTPException(404, { message: "Workflow not found" });
134
- }
135
- const run = workflow.getRun(runId);
136
- if (!run) {
137
- throw new HTTPException(404, { message: "Workflow run not found" });
138
- }
139
- return run;
140
- } catch (error) {
141
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
142
- }
143
- }
144
- async function createRunHandler({
145
- mastra,
146
- workflowId,
147
- runId: prevRunId
148
- }) {
149
- try {
150
- if (!workflowId) {
151
- throw new HTTPException(400, { message: "Workflow ID is required" });
152
- }
153
- const workflow = mastra.getWorkflow(workflowId);
154
- if (!workflow) {
155
- throw new HTTPException(404, { message: "Workflow not found" });
156
- }
157
- const { runId } = workflow.createRun({ runId: prevRunId });
158
- return { runId };
159
- } catch (error) {
160
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
161
- }
162
- }
163
- async function startWorkflowRunHandler({
164
- mastra,
165
- runtimeContext,
166
- workflowId,
167
- runId,
168
- triggerData
169
- }) {
170
- try {
171
- if (!workflowId) {
172
- throw new HTTPException(400, { message: "Workflow ID is required" });
173
- }
174
- if (!runId) {
175
- throw new HTTPException(400, { message: "runId required to start run" });
176
- }
177
- const workflow = mastra.getWorkflow(workflowId);
178
- const run = workflow.getRun(runId);
179
- if (!run) {
180
- throw new HTTPException(404, { message: "Workflow run not found" });
181
- }
182
- await run.start({
183
- triggerData,
184
- runtimeContext
185
- });
186
- return { message: "Workflow run started" };
187
- } catch (e) {
188
- return handleError(e, "Error starting workflow run");
189
- }
190
- }
191
- async function watchWorkflowHandler({
192
- mastra,
193
- workflowId,
194
- runId
195
- }) {
196
- try {
197
- if (!workflowId) {
198
- throw new HTTPException(400, { message: "Workflow ID is required" });
199
- }
200
- if (!runId) {
201
- throw new HTTPException(400, { message: "runId required to watch workflow" });
202
- }
203
- const workflow = mastra.getWorkflow(workflowId);
204
- const run = workflow.getRun(runId);
205
- if (!run) {
206
- throw new HTTPException(404, { message: "Workflow run not found" });
207
- }
208
- let unwatch;
209
- let asyncRef = null;
210
- const stream = new ReadableStream({
211
- start(controller) {
212
- unwatch = run.watch(({ activePaths, runId: runId2, timestamp, results }) => {
213
- const activePathsObj = Object.fromEntries(activePaths);
214
- controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId: runId2, timestamp, results }));
215
- if (asyncRef) {
216
- clearImmediate(asyncRef);
217
- asyncRef = null;
218
- }
219
- asyncRef = setImmediate(() => {
220
- if (!workflow.getRun(runId2)) {
221
- controller.close();
222
- }
223
- });
224
- });
225
- },
226
- cancel() {
227
- unwatch?.();
228
- }
229
- });
230
- return stream;
231
- } catch (error) {
232
- return handleError(error, "Error watching workflow");
233
- }
234
- }
235
- async function resumeAsyncWorkflowHandler({
236
- mastra,
237
- workflowId,
238
- runId,
239
- body,
240
- runtimeContext
241
- }) {
242
- try {
243
- if (!workflowId) {
244
- throw new HTTPException(400, { message: "Workflow ID is required" });
245
- }
246
- if (!runId) {
247
- throw new HTTPException(400, { message: "runId required to resume workflow" });
248
- }
249
- const workflow = mastra.getWorkflow(workflowId);
250
- const run = workflow.getRun(runId);
251
- if (!run) {
252
- throw new HTTPException(404, { message: "Workflow run not found" });
253
- }
254
- const result = await run.resume({
255
- stepId: body.stepId,
256
- context: body.context,
257
- runtimeContext
258
- });
259
- return result;
260
- } catch (error) {
261
- return handleError(error, "Error resuming workflow step");
262
- }
263
- }
264
- async function resumeWorkflowHandler({
265
- mastra,
266
- workflowId,
267
- runId,
268
- body,
269
- runtimeContext
270
- }) {
271
- try {
272
- if (!workflowId) {
273
- throw new HTTPException(400, { message: "Workflow ID is required" });
274
- }
275
- if (!runId) {
276
- throw new HTTPException(400, { message: "runId required to resume workflow" });
277
- }
278
- const workflow = mastra.getWorkflow(workflowId);
279
- const run = workflow.getRun(runId);
280
- if (!run) {
281
- throw new HTTPException(404, { message: "Workflow run not found" });
282
- }
283
- await run.resume({
284
- stepId: body.stepId,
285
- context: body.context,
286
- runtimeContext
287
- });
288
- return { message: "Workflow run resumed" };
289
- } catch (error) {
290
- return handleError(error, "Error resuming workflow");
291
- }
292
- }
293
- async function getWorkflowRunsHandler({
294
- mastra,
295
- workflowId,
296
- fromDate,
297
- toDate,
298
- limit,
299
- offset,
300
- resourceId
301
- }) {
302
- try {
303
- if (!workflowId) {
304
- throw new HTTPException(400, { message: "Workflow ID is required" });
305
- }
306
- const workflow = mastra.getWorkflow(workflowId);
307
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
308
- runs: [],
309
- total: 0
310
- };
311
- return workflowRuns;
312
- } catch (error) {
313
- return handleError(error, "Error getting workflow runs");
314
- }
315
- }
316
-
317
- export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, workflows_exports };
@@ -1,93 +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
- var stream = require('stream');
7
-
8
- // src/server/handlers/voice.ts
9
- var voice_exports = {};
10
- chunkFV45V6WC_cjs.__export(voice_exports, {
11
- generateSpeechHandler: () => generateSpeechHandler,
12
- getSpeakersHandler: () => getSpeakersHandler,
13
- transcribeSpeechHandler: () => transcribeSpeechHandler
14
- });
15
- async function getSpeakersHandler({ mastra, agentId }) {
16
- try {
17
- if (!agentId) {
18
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
19
- }
20
- const agent = mastra.getAgent(agentId);
21
- if (!agent) {
22
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
23
- }
24
- if (!agent.voice) {
25
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
26
- }
27
- const speakers = await agent.voice.getSpeakers();
28
- return speakers;
29
- } catch (error) {
30
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting speakers");
31
- }
32
- }
33
- async function generateSpeechHandler({
34
- mastra,
35
- agentId,
36
- body
37
- }) {
38
- try {
39
- if (!agentId) {
40
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
41
- }
42
- chunkQN4KF3BH_cjs.validateBody({
43
- text: body?.text
44
- });
45
- const agent = mastra.getAgent(agentId);
46
- if (!agent) {
47
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
48
- }
49
- if (!agent.voice) {
50
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
51
- }
52
- const audioStream = await agent.voice.speak(body.text, { speaker: body.speakerId });
53
- if (!audioStream) {
54
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: "Failed to generate speech" });
55
- }
56
- return audioStream;
57
- } catch (error) {
58
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating speech");
59
- }
60
- }
61
- async function transcribeSpeechHandler({
62
- mastra,
63
- agentId,
64
- body
65
- }) {
66
- try {
67
- if (!agentId) {
68
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
69
- }
70
- if (!body?.audioData) {
71
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Audio data is required" });
72
- }
73
- const agent = mastra.getAgent(agentId);
74
- if (!agent) {
75
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
76
- }
77
- if (!agent.voice) {
78
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
79
- }
80
- const audioStream = new stream.Readable();
81
- audioStream.push(body.audioData);
82
- audioStream.push(null);
83
- const text = await agent.voice.listen(audioStream, body.options);
84
- return { text };
85
- } catch (error) {
86
- return chunkZLBRQFDD_cjs.handleError(error, "Error transcribing speech");
87
- }
88
- }
89
-
90
- exports.generateSpeechHandler = generateSpeechHandler;
91
- exports.getSpeakersHandler = getSpeakersHandler;
92
- exports.transcribeSpeechHandler = transcribeSpeechHandler;
93
- exports.voice_exports = voice_exports;