@mastra/server 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-unified-sidebar-20251010130811

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 (280) hide show
  1. package/CHANGELOG.md +3987 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +0 -5
  4. package/dist/chunk-2PLXW4ZX.cjs +2777 -0
  5. package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
  6. package/dist/chunk-2S4IMB6E.cjs +130 -0
  7. package/dist/chunk-2S4IMB6E.cjs.map +1 -0
  8. package/dist/chunk-3LTO44EP.cjs +570 -0
  9. package/dist/chunk-3LTO44EP.cjs.map +1 -0
  10. package/dist/chunk-3SNGNFUJ.cjs +128 -0
  11. package/dist/chunk-3SNGNFUJ.cjs.map +1 -0
  12. package/dist/{chunk-RSEO4XPX.js → chunk-4QCXUEAT.js} +11 -2
  13. package/dist/chunk-4QCXUEAT.js.map +1 -0
  14. package/dist/chunk-5BNQIYQN.js +189 -0
  15. package/dist/chunk-5BNQIYQN.js.map +1 -0
  16. package/dist/{chunk-RG473F6Y.js → chunk-67GYDFSB.js} +24 -5
  17. package/dist/chunk-67GYDFSB.js.map +1 -0
  18. package/dist/{chunk-G7KH752Y.cjs → chunk-6ZR275MD.cjs} +28 -8
  19. package/dist/chunk-6ZR275MD.cjs.map +1 -0
  20. package/dist/chunk-7HDOBOGG.cjs +17517 -0
  21. package/dist/chunk-7HDOBOGG.cjs.map +1 -0
  22. package/dist/{chunk-2KZFMI6P.cjs → chunk-7NADHFD2.cjs} +2 -0
  23. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  24. package/dist/{chunk-4D66QEKC.js → chunk-ABRFV4XP.js} +5 -3
  25. package/dist/chunk-ABRFV4XP.js.map +1 -0
  26. package/dist/{chunk-LRCAAFUA.js → chunk-AHB4JCIQ.js} +50 -12
  27. package/dist/chunk-AHB4JCIQ.js.map +1 -0
  28. package/dist/chunk-BATEJLED.js +124 -0
  29. package/dist/chunk-BATEJLED.js.map +1 -0
  30. package/dist/chunk-BZLZFHAT.cjs +682 -0
  31. package/dist/chunk-BZLZFHAT.cjs.map +1 -0
  32. package/dist/{chunk-LF7P5PLR.js → chunk-CY4TP3FK.js} +3 -1
  33. package/dist/chunk-CY4TP3FK.js.map +1 -0
  34. package/dist/{chunk-H7DMHBKY.js → chunk-DB63UMTV.js} +249 -87
  35. package/dist/chunk-DB63UMTV.js.map +1 -0
  36. package/dist/{chunk-7TP2LX5L.cjs → chunk-EP3JQDPD.cjs} +20 -18
  37. package/dist/chunk-EP3JQDPD.cjs.map +1 -0
  38. package/dist/chunk-FWO7VQDC.js +17481 -0
  39. package/dist/chunk-FWO7VQDC.js.map +1 -0
  40. package/dist/chunk-FZNS32WJ.js +46 -0
  41. package/dist/chunk-FZNS32WJ.js.map +1 -0
  42. package/dist/chunk-G4PUALCE.cjs +28 -0
  43. package/dist/chunk-G4PUALCE.cjs.map +1 -0
  44. package/dist/chunk-GU4EWMZB.cjs +769 -0
  45. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  46. package/dist/{chunk-GHC4YV6R.js → chunk-HPXAM2PG.js} +109 -136
  47. package/dist/chunk-HPXAM2PG.js.map +1 -0
  48. package/dist/{chunk-JMLYCXMK.cjs → chunk-I3C4ODGV.cjs} +48 -45
  49. package/dist/chunk-I3C4ODGV.cjs.map +1 -0
  50. package/dist/chunk-JSLAYFEW.js +662 -0
  51. package/dist/chunk-JSLAYFEW.js.map +1 -0
  52. package/dist/chunk-LF2ZLOFP.js +767 -0
  53. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  54. package/dist/{chunk-5PQQ42EZ.js → chunk-LLUOPR3J.js} +13 -10
  55. package/dist/chunk-LLUOPR3J.js.map +1 -0
  56. package/dist/chunk-LNT5N7XW.cjs +197 -0
  57. package/dist/chunk-LNT5N7XW.cjs.map +1 -0
  58. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  59. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  60. package/dist/{chunk-LCM566I4.js → chunk-MMROOK5J.js} +2 -0
  61. package/dist/chunk-MMROOK5J.js.map +1 -0
  62. package/dist/chunk-MQDBNHBT.cjs +680 -0
  63. package/dist/chunk-MQDBNHBT.cjs.map +1 -0
  64. package/dist/{chunk-WNVFNNWN.js → chunk-MYR4PVGN.js} +5 -3
  65. package/dist/chunk-MYR4PVGN.js.map +1 -0
  66. package/dist/chunk-O7I5CWRX.cjs +44 -0
  67. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  68. package/dist/chunk-OEOGYAQC.js +553 -0
  69. package/dist/chunk-OEOGYAQC.js.map +1 -0
  70. package/dist/chunk-OYL5TBJW.cjs +48 -0
  71. package/dist/chunk-OYL5TBJW.cjs.map +1 -0
  72. package/dist/chunk-PR4QN5HX.js +39 -0
  73. package/dist/chunk-PR4QN5HX.js.map +1 -0
  74. package/dist/{chunk-KHZKYUNR.js → chunk-QQXMIP6C.js} +23 -13
  75. package/dist/chunk-QQXMIP6C.js.map +1 -0
  76. package/dist/{chunk-PZQDCRPV.cjs → chunk-RE4RPXT2.cjs} +4 -2
  77. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  78. package/dist/chunk-RQK4FQUD.js +1012 -0
  79. package/dist/chunk-RQK4FQUD.js.map +1 -0
  80. package/dist/chunk-SIW6CYO3.js +254 -0
  81. package/dist/chunk-SIW6CYO3.js.map +1 -0
  82. package/dist/{chunk-SDPGVWQJ.cjs → chunk-TOP25AIO.cjs} +110 -137
  83. package/dist/chunk-TOP25AIO.cjs.map +1 -0
  84. package/dist/chunk-TRGAMKHX.cjs +167 -0
  85. package/dist/chunk-TRGAMKHX.cjs.map +1 -0
  86. package/dist/chunk-VY4ENABS.cjs +135 -0
  87. package/dist/chunk-VY4ENABS.cjs.map +1 -0
  88. package/dist/{chunk-QGX47B5D.cjs → chunk-XN74I6VW.cjs} +11 -9
  89. package/dist/chunk-XN74I6VW.cjs.map +1 -0
  90. package/dist/chunk-XVPBGW6Y.cjs +256 -0
  91. package/dist/chunk-XVPBGW6Y.cjs.map +1 -0
  92. package/dist/chunk-YWOK4F5A.js +131 -0
  93. package/dist/chunk-YWOK4F5A.js.map +1 -0
  94. package/dist/chunk-ZULZ2752.js +2774 -0
  95. package/dist/chunk-ZULZ2752.js.map +1 -0
  96. package/dist/dist-4MVGNSRL.cjs +1150 -0
  97. package/dist/dist-4MVGNSRL.cjs.map +1 -0
  98. package/dist/dist-FZYCV3VB.cjs +940 -0
  99. package/dist/dist-FZYCV3VB.cjs.map +1 -0
  100. package/dist/dist-G2BYZJOC.cjs +928 -0
  101. package/dist/dist-G2BYZJOC.cjs.map +1 -0
  102. package/dist/dist-P4MXBQ3U.cjs +16 -0
  103. package/dist/dist-P4MXBQ3U.cjs.map +1 -0
  104. package/dist/dist-PQZUVLPC.js +937 -0
  105. package/dist/dist-PQZUVLPC.js.map +1 -0
  106. package/dist/dist-R7WYX6LC.js +925 -0
  107. package/dist/dist-R7WYX6LC.js.map +1 -0
  108. package/dist/dist-RFMYFILX.cjs +764 -0
  109. package/dist/dist-RFMYFILX.cjs.map +1 -0
  110. package/dist/dist-X7XR3M3Z.js +1147 -0
  111. package/dist/dist-X7XR3M3Z.js.map +1 -0
  112. package/dist/dist-XVBSOGFK.js +761 -0
  113. package/dist/dist-XVBSOGFK.js.map +1 -0
  114. package/dist/dist-YREX2TJT.js +3 -0
  115. package/dist/dist-YREX2TJT.js.map +1 -0
  116. package/dist/index.cjs +6 -0
  117. package/dist/index.cjs.map +1 -0
  118. package/dist/index.d.ts +1 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +5 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/server/a2a/protocol.d.ts +8 -0
  123. package/dist/server/a2a/protocol.d.ts.map +1 -0
  124. package/dist/server/a2a/store.cjs +25 -0
  125. package/dist/server/a2a/store.cjs.map +1 -0
  126. package/dist/server/a2a/store.d.ts +14 -0
  127. package/dist/server/a2a/store.d.ts.map +1 -0
  128. package/dist/server/a2a/store.js +23 -0
  129. package/dist/server/a2a/store.js.map +1 -0
  130. package/dist/server/a2a/tasks.d.ts +20 -0
  131. package/dist/server/a2a/tasks.d.ts.map +1 -0
  132. package/dist/server/handlers/a2a.cjs +13 -11
  133. package/dist/server/handlers/a2a.cjs.map +1 -0
  134. package/dist/server/handlers/a2a.d.ts +68 -6
  135. package/dist/server/handlers/a2a.d.ts.map +1 -0
  136. package/dist/server/handlers/a2a.js +3 -1
  137. package/dist/server/handlers/a2a.js.map +1 -0
  138. package/dist/server/handlers/agent-builder.cjs +68 -0
  139. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  140. package/dist/server/handlers/agent-builder.d.ts +94 -0
  141. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  142. package/dist/server/handlers/agent-builder.js +3 -0
  143. package/dist/server/handlers/agent-builder.js.map +1 -0
  144. package/dist/server/handlers/agents.cjs +57 -7
  145. package/dist/server/handlers/agents.cjs.map +1 -0
  146. package/dist/server/handlers/agents.d.ts +204 -6
  147. package/dist/server/handlers/agents.d.ts.map +1 -0
  148. package/dist/server/handlers/agents.js +3 -1
  149. package/dist/server/handlers/agents.js.map +1 -0
  150. package/dist/server/handlers/error.cjs +4 -2
  151. package/dist/server/handlers/error.cjs.map +1 -0
  152. package/dist/server/handlers/error.d.ts +2 -1
  153. package/dist/server/handlers/error.d.ts.map +1 -0
  154. package/dist/server/handlers/error.js +3 -1
  155. package/dist/server/handlers/error.js.map +1 -0
  156. package/dist/server/handlers/legacyWorkflows.cjs +13 -11
  157. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  158. package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
  159. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  160. package/dist/server/handlers/legacyWorkflows.js +3 -1
  161. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  162. package/dist/server/handlers/logs.cjs +6 -4
  163. package/dist/server/handlers/logs.cjs.map +1 -0
  164. package/dist/server/handlers/logs.d.ts +34 -3
  165. package/dist/server/handlers/logs.d.ts.map +1 -0
  166. package/dist/server/handlers/logs.js +3 -1
  167. package/dist/server/handlers/logs.js.map +1 -0
  168. package/dist/server/handlers/memory.cjs +39 -9
  169. package/dist/server/handlers/memory.cjs.map +1 -0
  170. package/dist/server/handlers/memory.d.ts +118 -8
  171. package/dist/server/handlers/memory.d.ts.map +1 -0
  172. package/dist/server/handlers/memory.js +3 -1
  173. package/dist/server/handlers/memory.js.map +1 -0
  174. package/dist/server/handlers/observability.cjs +24 -0
  175. package/dist/server/handlers/observability.cjs.map +1 -0
  176. package/dist/server/handlers/observability.d.ts +49 -0
  177. package/dist/server/handlers/observability.d.ts.map +1 -0
  178. package/dist/server/handlers/observability.js +3 -0
  179. package/dist/server/handlers/observability.js.map +1 -0
  180. package/dist/server/handlers/scores.cjs +32 -0
  181. package/dist/server/handlers/scores.cjs.map +1 -0
  182. package/dist/server/handlers/scores.d.ts +251 -0
  183. package/dist/server/handlers/scores.d.ts.map +1 -0
  184. package/dist/server/handlers/scores.js +3 -0
  185. package/dist/server/handlers/scores.js.map +1 -0
  186. package/dist/server/handlers/telemetry.cjs +9 -3
  187. package/dist/server/handlers/telemetry.cjs.map +1 -0
  188. package/dist/server/handlers/telemetry.d.ts +33 -2
  189. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  190. package/dist/server/handlers/telemetry.js +3 -1
  191. package/dist/server/handlers/telemetry.js.map +1 -0
  192. package/dist/server/handlers/tools.cjs +11 -5
  193. package/dist/server/handlers/tools.cjs.map +1 -0
  194. package/dist/server/handlers/tools.d.ts +25 -4
  195. package/dist/server/handlers/tools.d.ts.map +1 -0
  196. package/dist/server/handlers/tools.js +3 -1
  197. package/dist/server/handlers/tools.js.map +1 -0
  198. package/dist/server/handlers/utils.cjs +8 -2
  199. package/dist/server/handlers/utils.cjs.map +1 -0
  200. package/dist/server/handlers/utils.d.ts +8 -1
  201. package/dist/server/handlers/utils.d.ts.map +1 -0
  202. package/dist/server/handlers/utils.js +3 -1
  203. package/dist/server/handlers/utils.js.map +1 -0
  204. package/dist/server/handlers/vector.cjs +9 -7
  205. package/dist/server/handlers/vector.cjs.map +1 -0
  206. package/dist/server/handlers/vector.d.ts +51 -6
  207. package/dist/server/handlers/vector.d.ts.map +1 -0
  208. package/dist/server/handlers/vector.js +3 -1
  209. package/dist/server/handlers/vector.js.map +1 -0
  210. package/dist/server/handlers/voice.cjs +7 -5
  211. package/dist/server/handlers/voice.cjs.map +1 -0
  212. package/dist/server/handlers/voice.d.ts +41 -4
  213. package/dist/server/handlers/voice.d.ts.map +1 -0
  214. package/dist/server/handlers/voice.js +3 -1
  215. package/dist/server/handlers/voice.js.map +1 -0
  216. package/dist/server/handlers/workflows.cjs +33 -15
  217. package/dist/server/handlers/workflows.cjs.map +1 -0
  218. package/dist/server/handlers/workflows.d.ts +91 -14
  219. package/dist/server/handlers/workflows.d.ts.map +1 -0
  220. package/dist/server/handlers/workflows.js +3 -1
  221. package/dist/server/handlers/workflows.js.map +1 -0
  222. package/dist/server/handlers.cjs +44 -32
  223. package/dist/server/handlers.cjs.map +1 -0
  224. package/dist/server/handlers.d.ts +14 -11
  225. package/dist/server/handlers.d.ts.map +1 -0
  226. package/dist/server/handlers.js +15 -11
  227. package/dist/server/handlers.js.map +1 -0
  228. package/dist/server/http-exception.d.ts +87 -0
  229. package/dist/server/http-exception.d.ts.map +1 -0
  230. package/dist/server/types.d.ts +10 -0
  231. package/dist/server/types.d.ts.map +1 -0
  232. package/dist/server/utils.d.ts +44 -0
  233. package/dist/server/utils.d.ts.map +1 -0
  234. package/dist/token-53CFGXUO.cjs +64 -0
  235. package/dist/token-53CFGXUO.cjs.map +1 -0
  236. package/dist/token-WAEKDUVY.js +62 -0
  237. package/dist/token-WAEKDUVY.js.map +1 -0
  238. package/dist/token-util-LY37VCIN.js +7 -0
  239. package/dist/token-util-LY37VCIN.js.map +1 -0
  240. package/dist/token-util-S4A355II.cjs +9 -0
  241. package/dist/token-util-S4A355II.cjs.map +1 -0
  242. package/package.json +38 -15
  243. package/dist/_tsup-dts-rollup.d.cts +0 -1078
  244. package/dist/_tsup-dts-rollup.d.ts +0 -1078
  245. package/dist/chunk-2SLFAFTR.cjs +0 -148
  246. package/dist/chunk-75ZPJI57.cjs +0 -9
  247. package/dist/chunk-B2PAS2IB.cjs +0 -514
  248. package/dist/chunk-BK4XT6EG.js +0 -270
  249. package/dist/chunk-CCGRCYWJ.cjs +0 -18
  250. package/dist/chunk-CRCR3ZUK.js +0 -142
  251. package/dist/chunk-DN7K6FJK.cjs +0 -251
  252. package/dist/chunk-FRVBFMO2.cjs +0 -128
  253. package/dist/chunk-LI436ITD.cjs +0 -2042
  254. package/dist/chunk-LZ3VJXSO.cjs +0 -278
  255. package/dist/chunk-MEGCYGBU.js +0 -2039
  256. package/dist/chunk-MKLYEKEF.js +0 -241
  257. package/dist/chunk-MLKGABMK.js +0 -7
  258. package/dist/chunk-RHSWAXKB.cjs +0 -118
  259. package/dist/index.d.cts +0 -1
  260. package/dist/server/handlers/a2a.d.cts +0 -6
  261. package/dist/server/handlers/agents.d.cts +0 -6
  262. package/dist/server/handlers/error.d.cts +0 -1
  263. package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
  264. package/dist/server/handlers/logs.d.cts +0 -3
  265. package/dist/server/handlers/memory.d.cts +0 -8
  266. package/dist/server/handlers/network.cjs +0 -22
  267. package/dist/server/handlers/network.d.cts +0 -4
  268. package/dist/server/handlers/network.d.ts +0 -4
  269. package/dist/server/handlers/network.js +0 -1
  270. package/dist/server/handlers/telemetry.d.cts +0 -2
  271. package/dist/server/handlers/tools.d.cts +0 -4
  272. package/dist/server/handlers/utils.d.cts +0 -1
  273. package/dist/server/handlers/vNextNetwork.cjs +0 -218
  274. package/dist/server/handlers/vNextNetwork.d.cts +0 -6
  275. package/dist/server/handlers/vNextNetwork.d.ts +0 -6
  276. package/dist/server/handlers/vNextNetwork.js +0 -211
  277. package/dist/server/handlers/vector.d.cts +0 -6
  278. package/dist/server/handlers/voice.d.cts +0 -4
  279. package/dist/server/handlers/workflows.d.cts +0 -14
  280. package/dist/server/handlers.d.cts +0 -11
@@ -1,241 +0,0 @@
1
- import { validateBody } from './chunk-RSEO4XPX.js';
2
- import { handleError } from './chunk-LF7P5PLR.js';
3
- import { HTTPException } from './chunk-LCM566I4.js';
4
- import { __export } from './chunk-MLKGABMK.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
- async function getMemoryFromContext({
19
- mastra,
20
- agentId,
21
- networkId,
22
- runtimeContext
23
- }) {
24
- const agent = agentId ? mastra.getAgent(agentId) : null;
25
- if (agentId && !agent) {
26
- throw new HTTPException(404, { message: "Agent not found" });
27
- }
28
- const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
29
- if (networkId && !network) {
30
- throw new HTTPException(404, { message: "Network not found" });
31
- }
32
- if (agent) {
33
- return agent?.getMemory() || mastra.getMemory();
34
- }
35
- if (network) {
36
- return await network?.getMemory({ runtimeContext }) || mastra.getMemory();
37
- }
38
- return mastra.getMemory();
39
- }
40
- async function getMemoryStatusHandler({
41
- mastra,
42
- agentId,
43
- networkId,
44
- runtimeContext
45
- }) {
46
- try {
47
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
48
- if (!memory) {
49
- return { result: false };
50
- }
51
- return { result: true };
52
- } catch (error) {
53
- return handleError(error, "Error getting memory status");
54
- }
55
- }
56
- async function getThreadsHandler({
57
- mastra,
58
- agentId,
59
- resourceId,
60
- networkId,
61
- runtimeContext
62
- }) {
63
- try {
64
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
65
- if (!memory) {
66
- throw new HTTPException(400, { message: "Memory is not initialized" });
67
- }
68
- validateBody({ resourceId });
69
- const threads = await memory.getThreadsByResourceId({ resourceId });
70
- return threads;
71
- } catch (error) {
72
- return handleError(error, "Error getting threads");
73
- }
74
- }
75
- async function getThreadByIdHandler({
76
- mastra,
77
- agentId,
78
- threadId,
79
- networkId,
80
- runtimeContext
81
- }) {
82
- try {
83
- validateBody({ threadId });
84
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
85
- if (!memory) {
86
- throw new HTTPException(400, { message: "Memory is not initialized" });
87
- }
88
- const thread = await memory.getThreadById({ threadId });
89
- if (!thread) {
90
- throw new HTTPException(404, { message: "Thread not found" });
91
- }
92
- return thread;
93
- } catch (error) {
94
- return handleError(error, "Error getting thread");
95
- }
96
- }
97
- async function saveMessagesHandler({
98
- mastra,
99
- agentId,
100
- body,
101
- networkId,
102
- runtimeContext
103
- }) {
104
- try {
105
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
106
- if (!memory) {
107
- throw new HTTPException(400, { message: "Memory is not initialized" });
108
- }
109
- if (!body?.messages) {
110
- throw new HTTPException(400, { message: "Messages are required" });
111
- }
112
- if (!Array.isArray(body.messages)) {
113
- throw new HTTPException(400, { message: "Messages should be an array" });
114
- }
115
- const processedMessages = body.messages.map((message) => ({
116
- ...message,
117
- id: memory.generateId(),
118
- createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
119
- }));
120
- const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
121
- return result;
122
- } catch (error) {
123
- return handleError(error, "Error saving messages");
124
- }
125
- }
126
- async function createThreadHandler({
127
- mastra,
128
- agentId,
129
- body,
130
- networkId,
131
- runtimeContext
132
- }) {
133
- try {
134
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
135
- if (!memory) {
136
- throw new HTTPException(400, { message: "Memory is not initialized" });
137
- }
138
- validateBody({ resourceId: body?.resourceId });
139
- const result = await memory.createThread({
140
- resourceId: body?.resourceId,
141
- title: body?.title,
142
- metadata: body?.metadata,
143
- threadId: body?.threadId
144
- });
145
- return result;
146
- } catch (error) {
147
- return handleError(error, "Error saving thread to memory");
148
- }
149
- }
150
- async function updateThreadHandler({
151
- mastra,
152
- agentId,
153
- threadId,
154
- body,
155
- networkId,
156
- runtimeContext
157
- }) {
158
- try {
159
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
160
- if (!body) {
161
- throw new HTTPException(400, { message: "Body is required" });
162
- }
163
- const { title, metadata, resourceId } = body;
164
- const updatedAt = /* @__PURE__ */ new Date();
165
- validateBody({ threadId });
166
- if (!memory) {
167
- throw new HTTPException(400, { message: "Memory is not initialized" });
168
- }
169
- const thread = await memory.getThreadById({ threadId });
170
- if (!thread) {
171
- throw new HTTPException(404, { message: "Thread not found" });
172
- }
173
- const updatedThread = {
174
- ...thread,
175
- title: title || thread.title,
176
- metadata: metadata || thread.metadata,
177
- resourceId: resourceId || thread.resourceId,
178
- createdAt: thread.createdAt,
179
- updatedAt
180
- };
181
- const result = await memory.saveThread({ thread: updatedThread });
182
- return result;
183
- } catch (error) {
184
- return handleError(error, "Error updating thread");
185
- }
186
- }
187
- async function deleteThreadHandler({
188
- mastra,
189
- agentId,
190
- threadId,
191
- networkId,
192
- runtimeContext
193
- }) {
194
- try {
195
- validateBody({ threadId });
196
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
197
- if (!memory) {
198
- throw new HTTPException(400, { message: "Memory is not initialized" });
199
- }
200
- const thread = await memory.getThreadById({ threadId });
201
- if (!thread) {
202
- throw new HTTPException(404, { message: "Thread not found" });
203
- }
204
- await memory.deleteThread(threadId);
205
- return { result: "Thread deleted" };
206
- } catch (error) {
207
- return handleError(error, "Error deleting thread");
208
- }
209
- }
210
- async function getMessagesHandler({
211
- mastra,
212
- agentId,
213
- threadId,
214
- limit,
215
- networkId,
216
- runtimeContext
217
- }) {
218
- if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
219
- throw new HTTPException(400, { message: "Invalid limit: must be a positive integer" });
220
- }
221
- try {
222
- validateBody({ threadId });
223
- const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
224
- if (!memory) {
225
- throw new HTTPException(400, { message: "Memory is not initialized" });
226
- }
227
- const thread = await memory.getThreadById({ threadId });
228
- if (!thread) {
229
- throw new HTTPException(404, { message: "Thread not found" });
230
- }
231
- const result = await memory.query({
232
- threadId,
233
- ...limit && { selectBy: { last: limit } }
234
- });
235
- return { messages: result.messages, uiMessages: result.uiMessages };
236
- } catch (error) {
237
- return handleError(error, "Error getting messages");
238
- }
239
- }
240
-
241
- export { createThreadHandler, deleteThreadHandler, getMemoryStatusHandler, getMessagesHandler, getThreadByIdHandler, getThreadsHandler, memory_exports, saveMessagesHandler, updateThreadHandler };
@@ -1,7 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
- export { __export };
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
- var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
- var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
- var stream = require('stream');
8
-
9
- // src/server/handlers/voice.ts
10
- var voice_exports = {};
11
- chunk75ZPJI57_cjs.__export(voice_exports, {
12
- generateSpeechHandler: () => generateSpeechHandler,
13
- getListenerHandler: () => getListenerHandler,
14
- getSpeakersHandler: () => getSpeakersHandler,
15
- transcribeSpeechHandler: () => transcribeSpeechHandler
16
- });
17
- async function getSpeakersHandler({ mastra, agentId }) {
18
- try {
19
- if (!agentId) {
20
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
21
- }
22
- const agent = mastra.getAgent(agentId);
23
- if (!agent) {
24
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
25
- }
26
- const voice = await agent.getVoice();
27
- if (!voice) {
28
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
29
- }
30
- const speakers = await voice.getSpeakers();
31
- return speakers;
32
- } catch (error) {
33
- return chunkPZQDCRPV_cjs.handleError(error, "Error getting speakers");
34
- }
35
- }
36
- async function generateSpeechHandler({
37
- mastra,
38
- agentId,
39
- body
40
- }) {
41
- try {
42
- if (!agentId) {
43
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
44
- }
45
- chunkCCGRCYWJ_cjs.validateBody({
46
- text: body?.text
47
- });
48
- const agent = mastra.getAgent(agentId);
49
- if (!agent) {
50
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
51
- }
52
- const voice = await agent.getVoice();
53
- if (!voice) {
54
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
55
- }
56
- const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
57
- if (!audioStream) {
58
- throw new chunk2KZFMI6P_cjs.HTTPException(500, { message: "Failed to generate speech" });
59
- }
60
- return audioStream;
61
- } catch (error) {
62
- return chunkPZQDCRPV_cjs.handleError(error, "Error generating speech");
63
- }
64
- }
65
- async function transcribeSpeechHandler({
66
- mastra,
67
- agentId,
68
- body
69
- }) {
70
- try {
71
- if (!agentId) {
72
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
73
- }
74
- if (!body?.audioData) {
75
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Audio data is required" });
76
- }
77
- const agent = mastra.getAgent(agentId);
78
- if (!agent) {
79
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
80
- }
81
- const voice = await agent.getVoice();
82
- if (!voice) {
83
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
84
- }
85
- const audioStream = new stream.Readable();
86
- audioStream.push(body.audioData);
87
- audioStream.push(null);
88
- const text = await voice.listen(audioStream, body.options);
89
- return { text };
90
- } catch (error) {
91
- return chunkPZQDCRPV_cjs.handleError(error, "Error transcribing speech");
92
- }
93
- }
94
- async function getListenerHandler({ mastra, agentId }) {
95
- try {
96
- if (!agentId) {
97
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
98
- }
99
- const agent = mastra.getAgent(agentId);
100
- if (!agent) {
101
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
102
- }
103
- const voice = await agent.getVoice();
104
- if (!voice) {
105
- throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
106
- }
107
- const listeners = await voice.getListener();
108
- return listeners;
109
- } catch (error) {
110
- return chunkPZQDCRPV_cjs.handleError(error, "Error getting listeners");
111
- }
112
- }
113
-
114
- exports.generateSpeechHandler = generateSpeechHandler;
115
- exports.getListenerHandler = getListenerHandler;
116
- exports.getSpeakersHandler = getSpeakersHandler;
117
- exports.transcribeSpeechHandler = transcribeSpeechHandler;
118
- exports.voice_exports = voice_exports;
package/dist/index.d.cts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export { getAgentCardByIdHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { handleTaskSend } from '../../_tsup-dts-rollup.cjs';
3
- export { handleTaskGet } from '../../_tsup-dts-rollup.cjs';
4
- export { handleTaskSendSubscribe } from '../../_tsup-dts-rollup.cjs';
5
- export { handleTaskCancel } from '../../_tsup-dts-rollup.cjs';
6
- export { getAgentExecutionHandler } 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,10 +0,0 @@
1
- export { getLegacyWorkflowsHandler } from '../../_tsup-dts-rollup.cjs';
2
- export { getLegacyWorkflowByIdHandler } from '../../_tsup-dts-rollup.cjs';
3
- export { startAsyncLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
4
- export { getLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
5
- export { createLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
6
- export { startLegacyWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
7
- export { watchLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
8
- export { resumeAsyncLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
9
- export { resumeLegacyWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
10
- export { getLegacyWorkflowRunsHandler } 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,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,22 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk2SLFAFTR_cjs = require('../../chunk-2SLFAFTR.cjs');
4
-
5
-
6
-
7
- Object.defineProperty(exports, "generateHandler", {
8
- enumerable: true,
9
- get: function () { return chunk2SLFAFTR_cjs.generateHandler; }
10
- });
11
- Object.defineProperty(exports, "getNetworkByIdHandler", {
12
- enumerable: true,
13
- get: function () { return chunk2SLFAFTR_cjs.getNetworkByIdHandler; }
14
- });
15
- Object.defineProperty(exports, "getNetworksHandler", {
16
- enumerable: true,
17
- get: function () { return chunk2SLFAFTR_cjs.getNetworksHandler; }
18
- });
19
- Object.defineProperty(exports, "streamGenerateHandler", {
20
- enumerable: true,
21
- get: function () { return chunk2SLFAFTR_cjs.streamGenerateHandler; }
22
- });
@@ -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,4 +0,0 @@
1
- export { getNetworksHandler } from '../../_tsup-dts-rollup.js';
2
- export { getNetworkByIdHandler } from '../../_tsup-dts-rollup.js';
3
- export { generateHandler_alias_1 as generateHandler } from '../../_tsup-dts-rollup.js';
4
- export { streamGenerateHandler_alias_1 as streamGenerateHandler } from '../../_tsup-dts-rollup.js';
@@ -1 +0,0 @@
1
- export { generateHandler, getNetworkByIdHandler, getNetworksHandler, streamGenerateHandler } from '../../chunk-CRCR3ZUK.js';
@@ -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,218 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkLI436ITD_cjs = require('../../chunk-LI436ITD.cjs');
4
- var chunkCCGRCYWJ_cjs = require('../../chunk-CCGRCYWJ.cjs');
5
- var chunkPZQDCRPV_cjs = require('../../chunk-PZQDCRPV.cjs');
6
- var chunk2KZFMI6P_cjs = require('../../chunk-2KZFMI6P.cjs');
7
-
8
- // src/server/handlers/vNextNetwork.ts
9
- async function getVNextNetworksHandler({
10
- mastra,
11
- runtimeContext
12
- }) {
13
- try {
14
- const networks = mastra.vnext_getNetworks();
15
- const serializedNetworks = await Promise.all(
16
- networks.map(async (network) => {
17
- const routingAgent = await network.getRoutingAgent({ runtimeContext });
18
- const routingLLM = await routingAgent.getLLM({ runtimeContext });
19
- const agents = await network.getAgents({ runtimeContext });
20
- const workflows = await network.getWorkflows({ runtimeContext });
21
- const tools = await network.getTools({ runtimeContext });
22
- const networkInstruction = await network.getInstructions({ runtimeContext });
23
- return {
24
- id: network.id,
25
- name: network.name,
26
- instructions: networkInstruction,
27
- tools: await Promise.all(
28
- Object.values(tools).map(async (tool) => {
29
- return {
30
- id: tool.id,
31
- description: tool.description
32
- };
33
- })
34
- ),
35
- agents: await Promise.all(
36
- Object.values(agents).map(async (agent) => {
37
- const llm = await agent.getLLM({ runtimeContext });
38
- return {
39
- name: agent.name,
40
- provider: llm?.getProvider(),
41
- modelId: llm?.getModelId()
42
- };
43
- })
44
- ),
45
- workflows: await Promise.all(
46
- Object.values(workflows).map(async (workflow) => {
47
- return {
48
- name: workflow.name,
49
- description: workflow.description,
50
- inputSchema: workflow.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.inputSchema)) : void 0,
51
- outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
52
- };
53
- })
54
- ),
55
- routingModel: {
56
- provider: routingLLM?.getProvider(),
57
- modelId: routingLLM?.getModelId()
58
- }
59
- };
60
- })
61
- );
62
- return serializedNetworks;
63
- } catch (error) {
64
- return chunkPZQDCRPV_cjs.handleError(error, "Error getting networks");
65
- }
66
- }
67
- async function getVNextNetworkByIdHandler({
68
- mastra,
69
- networkId,
70
- runtimeContext
71
- }) {
72
- try {
73
- const network = mastra.vnext_getNetwork(networkId);
74
- if (!network) {
75
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
76
- }
77
- const routingAgent = await network.getRoutingAgent({ runtimeContext });
78
- const routingLLM = await routingAgent.getLLM({ runtimeContext });
79
- const agents = await network.getAgents({ runtimeContext });
80
- const workflows = await network.getWorkflows({ runtimeContext });
81
- const tools = await network.getTools({ runtimeContext });
82
- const networkInstruction = await network.getInstructions({ runtimeContext });
83
- const serializedNetwork = {
84
- id: network.id,
85
- name: network.name,
86
- instructions: networkInstruction,
87
- agents: await Promise.all(
88
- Object.values(agents).map(async (agent) => {
89
- const llm = await agent.getLLM({ runtimeContext });
90
- return {
91
- name: agent.name,
92
- provider: llm?.getProvider(),
93
- modelId: llm?.getModelId()
94
- };
95
- })
96
- ),
97
- workflows: await Promise.all(
98
- Object.values(workflows).map(async (workflow) => {
99
- return {
100
- name: workflow.name,
101
- description: workflow.description,
102
- inputSchema: workflow.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.inputSchema)) : void 0,
103
- outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
104
- };
105
- })
106
- ),
107
- tools: await Promise.all(
108
- Object.values(tools).map(async (tool) => {
109
- return {
110
- id: tool.id,
111
- description: tool.description
112
- };
113
- })
114
- ),
115
- routingModel: {
116
- provider: routingLLM?.getProvider(),
117
- modelId: routingLLM?.getModelId()
118
- }
119
- };
120
- return serializedNetwork;
121
- } catch (error) {
122
- return chunkPZQDCRPV_cjs.handleError(error, "Error getting network by ID");
123
- }
124
- }
125
- async function generateVNextNetworkHandler({
126
- mastra,
127
- runtimeContext,
128
- networkId,
129
- body
130
- }) {
131
- try {
132
- const network = mastra.vnext_getNetwork(networkId);
133
- if (!network) {
134
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
135
- }
136
- chunkCCGRCYWJ_cjs.validateBody({ message: body.message });
137
- const { message, threadId, resourceId } = body;
138
- const result = await network.generate(message, { runtimeContext, threadId, resourceId });
139
- return result;
140
- } catch (error) {
141
- return chunkPZQDCRPV_cjs.handleError(error, "Error generating from network");
142
- }
143
- }
144
- async function streamGenerateVNextNetworkHandler({
145
- mastra,
146
- networkId,
147
- body,
148
- runtimeContext
149
- }) {
150
- try {
151
- const network = mastra.vnext_getNetwork(networkId);
152
- if (!network) {
153
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
154
- }
155
- chunkCCGRCYWJ_cjs.validateBody({ message: body.message });
156
- const { message, threadId, resourceId } = body;
157
- const streamResult = await network.stream(message, {
158
- runtimeContext,
159
- threadId,
160
- resourceId
161
- });
162
- return streamResult;
163
- } catch (error) {
164
- return chunkPZQDCRPV_cjs.handleError(error, "Error streaming from network");
165
- }
166
- }
167
- async function loopVNextNetworkHandler({
168
- mastra,
169
- networkId,
170
- body,
171
- runtimeContext
172
- }) {
173
- try {
174
- const network = mastra.vnext_getNetwork(networkId);
175
- if (!network) {
176
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
177
- }
178
- chunkCCGRCYWJ_cjs.validateBody({ message: body.message });
179
- const { message } = body;
180
- const result = await network.loop(message, {
181
- runtimeContext
182
- });
183
- return result;
184
- } catch (error) {
185
- return chunkPZQDCRPV_cjs.handleError(error, "Error looping network");
186
- }
187
- }
188
- async function loopStreamVNextNetworkHandler({
189
- mastra,
190
- networkId,
191
- body,
192
- runtimeContext
193
- }) {
194
- try {
195
- const network = mastra.vnext_getNetwork(networkId);
196
- if (!network) {
197
- throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
198
- }
199
- chunkCCGRCYWJ_cjs.validateBody({ message: body.message });
200
- const { message, threadId, resourceId, maxIterations } = body;
201
- const result = await network.loopStream(message, {
202
- runtimeContext,
203
- threadId,
204
- resourceId,
205
- maxIterations
206
- });
207
- return result;
208
- } catch (error) {
209
- return chunkPZQDCRPV_cjs.handleError(error, "Error streaming network loop");
210
- }
211
- }
212
-
213
- exports.generateVNextNetworkHandler = generateVNextNetworkHandler;
214
- exports.getVNextNetworkByIdHandler = getVNextNetworkByIdHandler;
215
- exports.getVNextNetworksHandler = getVNextNetworksHandler;
216
- exports.loopStreamVNextNetworkHandler = loopStreamVNextNetworkHandler;
217
- exports.loopVNextNetworkHandler = loopVNextNetworkHandler;
218
- exports.streamGenerateVNextNetworkHandler = streamGenerateVNextNetworkHandler;