@mastra/server 0.0.0-llamaindex-switch-core-20250424001624 → 0.0.0-main-test-20251105183450

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 (263) hide show
  1. package/CHANGELOG.md +4494 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +45 -137
  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-A5SOZY5R.js +502 -0
  15. package/dist/chunk-A5SOZY5R.js.map +1 -0
  16. package/dist/chunk-AEVI2HIU.cjs +651 -0
  17. package/dist/chunk-AEVI2HIU.cjs.map +1 -0
  18. package/dist/chunk-ALOLTNSO.js +477 -0
  19. package/dist/chunk-ALOLTNSO.js.map +1 -0
  20. package/dist/chunk-B6NK4KI5.cjs +128 -0
  21. package/dist/chunk-B6NK4KI5.cjs.map +1 -0
  22. package/dist/chunk-BANGX6SC.cjs +200 -0
  23. package/dist/chunk-BANGX6SC.cjs.map +1 -0
  24. package/dist/chunk-BHQH5QXD.cjs +172 -0
  25. package/dist/chunk-BHQH5QXD.cjs.map +1 -0
  26. package/dist/chunk-BTWIR2B7.cjs +28 -0
  27. package/dist/chunk-BTWIR2B7.cjs.map +1 -0
  28. package/dist/chunk-DNUO33HF.js +129 -0
  29. package/dist/chunk-DNUO33HF.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-JO2AZFJN.js +165 -0
  37. package/dist/chunk-JO2AZFJN.js.map +1 -0
  38. package/dist/chunk-JZ65BJ6H.cjs +678 -0
  39. package/dist/chunk-JZ65BJ6H.cjs.map +1 -0
  40. package/dist/{chunk-4JINXASC.js → chunk-KWH5QBXP.js} +7 -4
  41. package/dist/chunk-KWH5QBXP.js.map +1 -0
  42. package/dist/chunk-LF2ZLOFP.js +767 -0
  43. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  44. package/dist/{chunk-Q6SHQECN.js → chunk-LPCK5MAF.js} +47 -13
  45. package/dist/chunk-LPCK5MAF.js.map +1 -0
  46. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  47. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  48. package/dist/chunk-LWLSQ2W4.cjs +133 -0
  49. package/dist/chunk-LWLSQ2W4.cjs.map +1 -0
  50. package/dist/chunk-MMQIJZ2Q.cjs +23079 -0
  51. package/dist/chunk-MMQIJZ2Q.cjs.map +1 -0
  52. package/dist/chunk-O7I5CWRX.cjs +44 -0
  53. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  54. package/dist/chunk-PPMIB3FQ.cjs +88 -0
  55. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  56. package/dist/chunk-PR4QN5HX.js +39 -0
  57. package/dist/chunk-PR4QN5HX.js.map +1 -0
  58. package/dist/chunk-QU6N55W6.cjs +256 -0
  59. package/dist/chunk-QU6N55W6.cjs.map +1 -0
  60. package/dist/chunk-R6OQFR47.js +630 -0
  61. package/dist/chunk-R6OQFR47.js.map +1 -0
  62. package/dist/chunk-RQK4FQUD.js +1012 -0
  63. package/dist/chunk-RQK4FQUD.js.map +1 -0
  64. package/dist/{chunk-M56ECCHK.cjs → chunk-S54HNARD.cjs} +22 -19
  65. package/dist/chunk-S54HNARD.cjs.map +1 -0
  66. package/dist/chunk-SHWNNZBL.js +254 -0
  67. package/dist/chunk-SHWNNZBL.js.map +1 -0
  68. package/dist/chunk-SIPNICB3.cjs +517 -0
  69. package/dist/chunk-SIPNICB3.cjs.map +1 -0
  70. package/dist/{chunk-L7XE5QTW.js → chunk-SZIFSF4T.js} +11 -2
  71. package/dist/chunk-SZIFSF4T.js.map +1 -0
  72. package/dist/chunk-TOCYBDP2.js +46 -0
  73. package/dist/chunk-TOCYBDP2.js.map +1 -0
  74. package/dist/chunk-UU7MMOP5.js +23039 -0
  75. package/dist/chunk-UU7MMOP5.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 +34 -12
  155. package/dist/server/handlers/memory.cjs.map +1 -0
  156. package/dist/server/handlers/memory.d.ts +112 -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 +38 -26
  203. package/dist/server/handlers.cjs.map +1 -0
  204. package/dist/server/handlers.d.ts +12 -9
  205. package/dist/server/handlers.d.ts.map +1 -0
  206. package/dist/server/handlers.js +13 -9
  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 +46 -19
  223. package/dist/_tsup-dts-rollup.d.cts +0 -571
  224. package/dist/_tsup-dts-rollup.d.ts +0 -571
  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-55HTWX4C.cjs +0 -93
  229. package/dist/chunk-5JNVY6DU.js +0 -120
  230. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  231. package/dist/chunk-7IWQE76Z.cjs +0 -139
  232. package/dist/chunk-D3G23FP3.cjs +0 -126
  233. package/dist/chunk-FPIWDH5Y.cjs +0 -126
  234. package/dist/chunk-HCOPJZ4A.cjs +0 -164
  235. package/dist/chunk-LFOBHRFO.js +0 -305
  236. package/dist/chunk-OMN3UI6X.js +0 -5576
  237. package/dist/chunk-QN4KF3BH.cjs +0 -18
  238. package/dist/chunk-R4J7XQYU.js +0 -156
  239. package/dist/chunk-RBQASTUP.js +0 -203
  240. package/dist/chunk-RE6YL32K.js +0 -120
  241. package/dist/chunk-SKBVVI24.cjs +0 -54
  242. package/dist/chunk-TZK63M5N.cjs +0 -317
  243. package/dist/chunk-WTHDCRMY.js +0 -135
  244. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  245. package/dist/index.d.cts +0 -1
  246. package/dist/server/handlers/agents.d.cts +0 -6
  247. package/dist/server/handlers/error.d.cts +0 -1
  248. package/dist/server/handlers/logs.d.cts +0 -3
  249. package/dist/server/handlers/memory.d.cts +0 -8
  250. package/dist/server/handlers/network.cjs +0 -22
  251. package/dist/server/handlers/network.d.cts +0 -4
  252. package/dist/server/handlers/network.d.ts +0 -4
  253. package/dist/server/handlers/network.js +0 -1
  254. package/dist/server/handlers/telemetry.cjs +0 -14
  255. package/dist/server/handlers/telemetry.d.cts +0 -2
  256. package/dist/server/handlers/telemetry.d.ts +0 -2
  257. package/dist/server/handlers/telemetry.js +0 -1
  258. package/dist/server/handlers/tools.d.cts +0 -4
  259. package/dist/server/handlers/utils.d.cts +0 -1
  260. package/dist/server/handlers/vector.d.cts +0 -6
  261. package/dist/server/handlers/voice.d.cts +0 -3
  262. package/dist/server/handlers/workflows.d.cts +0 -10
  263. package/dist/server/handlers.d.cts +0 -9
@@ -1,139 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
4
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
5
-
6
- // src/server/handlers/telemetry.ts
7
- var telemetry_exports = {};
8
- chunkFV45V6WC_cjs.__export(telemetry_exports, {
9
- getTelemetryHandler: () => getTelemetryHandler,
10
- storeTelemetryHandler: () => storeTelemetryHandler
11
- });
12
- async function getTelemetryHandler({ mastra, body }) {
13
- try {
14
- const telemetry = mastra.getTelemetry();
15
- const storage = mastra.getStorage();
16
- if (!telemetry) {
17
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
- }
19
- if (!storage) {
20
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
21
- }
22
- if (!body) {
23
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Body is required" });
24
- }
25
- const { name, scope, page, perPage, attribute } = body;
26
- const attributes = attribute ? Object.fromEntries(
27
- (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
28
- const [key, value] = attr.split(":");
29
- return [key, value];
30
- })
31
- ) : void 0;
32
- const traces = await storage.getTraces({
33
- name,
34
- scope,
35
- page: Number(page ?? 0),
36
- perPage: Number(perPage ?? 100),
37
- attributes
38
- });
39
- return traces;
40
- } catch (error2) {
41
- return chunkZLBRQFDD_cjs.handleError(error2, "Error getting telemetry");
42
- }
43
- }
44
- async function storeTelemetryHandler({ mastra, body }) {
45
- try {
46
- const storage = mastra.getStorage();
47
- const logger = mastra.getLogger();
48
- if (!storage) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
50
- }
51
- const now = /* @__PURE__ */ new Date();
52
- const items = body?.resourceSpans?.[0]?.scopeSpans;
53
- logger.debug("[Telemetry Handler] Received spans:", {
54
- totalSpans: items?.reduce((acc, scope) => acc + scope.spans.length, 0) || 0,
55
- timestamp: now.toISOString()
56
- });
57
- if (!items?.length) {
58
- return {
59
- status: "success",
60
- message: "No spans to process",
61
- traceCount: 0
62
- };
63
- }
64
- const allSpans = items.reduce((acc, scopedSpans) => {
65
- const { scope, spans } = scopedSpans;
66
- for (const span of spans) {
67
- const {
68
- spanId,
69
- parentSpanId,
70
- traceId,
71
- name,
72
- kind,
73
- attributes,
74
- status,
75
- events,
76
- links,
77
- startTimeUnixNano,
78
- endTimeUnixNano,
79
- ...rest
80
- } = span;
81
- const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
82
- const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
83
- acc.push({
84
- id: spanId,
85
- parentSpanId,
86
- traceId,
87
- name,
88
- scope: scope.name,
89
- kind,
90
- status: JSON.stringify(status),
91
- events: JSON.stringify(events),
92
- links: JSON.stringify(links),
93
- attributes: JSON.stringify(
94
- attributes.reduce((acc2, attr) => {
95
- const valueKey = Object.keys(attr.value)[0];
96
- if (valueKey) {
97
- acc2[attr.key] = attr.value[valueKey];
98
- }
99
- return acc2;
100
- }, {})
101
- ),
102
- startTime,
103
- endTime,
104
- other: JSON.stringify(rest),
105
- createdAt: now
106
- });
107
- }
108
- return acc;
109
- }, []);
110
- return storage.batchTraceInsert({
111
- records: allSpans
112
- }).then(() => {
113
- return {
114
- status: "success",
115
- message: "Traces received and processed successfully",
116
- traceCount: body.resourceSpans?.length || 0
117
- };
118
- }).catch(() => {
119
- return {
120
- status: "error",
121
- message: "Failed to process traces",
122
- // @ts-ignore
123
- error: error.message
124
- };
125
- });
126
- } catch (error2) {
127
- console.error("Error processing traces:", error2);
128
- return {
129
- status: "error",
130
- message: "Failed to process traces",
131
- // @ts-ignore
132
- error: error2.message
133
- };
134
- }
135
- }
136
-
137
- exports.getTelemetryHandler = getTelemetryHandler;
138
- exports.storeTelemetryHandler = storeTelemetryHandler;
139
- exports.telemetry_exports = telemetry_exports;
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
5
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
6
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
7
- var tools = require('@mastra/core/tools');
8
-
9
- // src/server/handlers/tools.ts
10
- var tools_exports = {};
11
- chunkFV45V6WC_cjs.__export(tools_exports, {
12
- executeAgentToolHandler: () => executeAgentToolHandler,
13
- executeToolHandler: () => executeToolHandler,
14
- getToolByIdHandler: () => getToolByIdHandler,
15
- getToolsHandler: () => getToolsHandler
16
- });
17
- async function getToolsHandler({ tools }) {
18
- try {
19
- if (!tools) {
20
- return {};
21
- }
22
- const serializedTools = Object.entries(tools).reduce(
23
- (acc, [id, _tool]) => {
24
- const tool = _tool;
25
- acc[id] = {
26
- ...tool,
27
- inputSchema: tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.inputSchema)) : void 0,
28
- outputSchema: tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.outputSchema)) : void 0
29
- };
30
- return acc;
31
- },
32
- {}
33
- );
34
- return serializedTools;
35
- } catch (error) {
36
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting tools");
37
- }
38
- }
39
- async function getToolByIdHandler({ tools, toolId }) {
40
- try {
41
- const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
42
- if (!tool) {
43
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
44
- }
45
- const serializedTool = {
46
- ...tool,
47
- inputSchema: tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.inputSchema)) : void 0,
48
- outputSchema: tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.outputSchema)) : void 0
49
- };
50
- return serializedTool;
51
- } catch (error) {
52
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting tool");
53
- }
54
- }
55
- function executeToolHandler(tools$1) {
56
- return async ({
57
- mastra,
58
- runId,
59
- toolId,
60
- data,
61
- runtimeContext
62
- }) => {
63
- try {
64
- if (!toolId) {
65
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool ID is required" });
66
- }
67
- const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
68
- if (!tool) {
69
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
70
- }
71
- if (!tool?.execute) {
72
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool is not executable" });
73
- }
74
- chunkQN4KF3BH_cjs.validateBody({ data });
75
- if (tools.isVercelTool(tool)) {
76
- const result2 = await tool.execute(data);
77
- return result2;
78
- }
79
- const result = await tool.execute({
80
- context: data,
81
- mastra,
82
- runId,
83
- runtimeContext
84
- });
85
- return result;
86
- } catch (error) {
87
- return chunkZLBRQFDD_cjs.handleError(error, "Error executing tool");
88
- }
89
- };
90
- }
91
- async function executeAgentToolHandler({
92
- mastra,
93
- agentId,
94
- toolId,
95
- data,
96
- runtimeContext
97
- }) {
98
- try {
99
- const agent = agentId ? mastra.getAgent(agentId) : null;
100
- if (!agent) {
101
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
102
- }
103
- const tool = Object.values(agent?.tools || {}).find((tool2) => tool2.id === toolId);
104
- if (!tool) {
105
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
106
- }
107
- if (!tool?.execute) {
108
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool is not executable" });
109
- }
110
- const result = await tool.execute({
111
- context: data,
112
- runtimeContext,
113
- mastra,
114
- runId: agentId
115
- });
116
- return result;
117
- } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error executing tool");
119
- }
120
- }
121
-
122
- exports.executeAgentToolHandler = executeAgentToolHandler;
123
- exports.executeToolHandler = executeToolHandler;
124
- exports.getToolByIdHandler = getToolByIdHandler;
125
- exports.getToolsHandler = getToolsHandler;
126
- exports.tools_exports = tools_exports;
@@ -1,126 +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/network.ts
8
- var network_exports = {};
9
- chunkFV45V6WC_cjs.__export(network_exports, {
10
- generateHandler: () => generateHandler,
11
- getNetworkByIdHandler: () => getNetworkByIdHandler,
12
- getNetworksHandler: () => getNetworksHandler,
13
- streamGenerateHandler: () => streamGenerateHandler
14
- });
15
- async function getNetworksHandler({ mastra }) {
16
- try {
17
- const networks = mastra.getNetworks();
18
- const serializedNetworks = networks.map((network) => {
19
- const routingAgent = network.getRoutingAgent();
20
- const agents = network.getAgents();
21
- return {
22
- id: network.formatAgentId(routingAgent.name),
23
- name: routingAgent.name,
24
- instructions: routingAgent.instructions,
25
- agents: agents.map((agent) => ({
26
- name: agent.name,
27
- provider: agent.llm?.getProvider(),
28
- modelId: agent.llm?.getModelId()
29
- })),
30
- routingModel: {
31
- provider: routingAgent.llm?.getProvider(),
32
- modelId: routingAgent.llm?.getModelId()
33
- }
34
- };
35
- });
36
- return serializedNetworks;
37
- } catch (error) {
38
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
39
- }
40
- }
41
- async function getNetworkByIdHandler({ mastra, networkId }) {
42
- try {
43
- const networks = mastra.getNetworks();
44
- const network = networks.find((network2) => {
45
- const routingAgent2 = network2.getRoutingAgent();
46
- return network2.formatAgentId(routingAgent2.name) === networkId;
47
- });
48
- if (!network) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
50
- }
51
- const routingAgent = network.getRoutingAgent();
52
- const agents = network.getAgents();
53
- const serializedNetwork = {
54
- id: network.formatAgentId(routingAgent.name),
55
- name: routingAgent.name,
56
- instructions: routingAgent.instructions,
57
- agents: agents.map((agent) => ({
58
- name: agent.name,
59
- provider: agent.llm?.getProvider(),
60
- modelId: agent.llm?.getModelId()
61
- })),
62
- routingModel: {
63
- provider: routingAgent.llm?.getProvider(),
64
- modelId: routingAgent.llm?.getModelId()
65
- }
66
- };
67
- return serializedNetwork;
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting network by ID");
70
- }
71
- }
72
- async function generateHandler({
73
- mastra,
74
- runtimeContext,
75
- networkId,
76
- body
77
- }) {
78
- try {
79
- const network = mastra.getNetwork(networkId);
80
- if (!network) {
81
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
82
- }
83
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
84
- const { messages, ...rest } = body;
85
- const result = await network.generate(messages, { ...rest, runtimeContext });
86
- return result;
87
- } catch (error) {
88
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
89
- }
90
- }
91
- async function streamGenerateHandler({
92
- mastra,
93
- networkId,
94
- body,
95
- runtimeContext
96
- }) {
97
- try {
98
- const network = mastra.getNetwork(networkId);
99
- if (!network) {
100
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
101
- }
102
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
103
- const { messages, output, ...rest } = body;
104
- const streamResult = await network.stream(messages, {
105
- output,
106
- ...rest,
107
- runtimeContext
108
- });
109
- const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
110
- sendUsage: true,
111
- sendReasoning: true,
112
- getErrorMessage: (error) => {
113
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
114
- }
115
- });
116
- return streamResponse;
117
- } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error streaming from network");
119
- }
120
- }
121
-
122
- exports.generateHandler = generateHandler;
123
- exports.getNetworkByIdHandler = getNetworkByIdHandler;
124
- exports.getNetworksHandler = getNetworksHandler;
125
- exports.network_exports = network_exports;
126
- exports.streamGenerateHandler = streamGenerateHandler;
@@ -1,164 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
5
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
6
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
7
-
8
- // src/server/handlers/agents.ts
9
- var agents_exports = {};
10
- chunkFV45V6WC_cjs.__export(agents_exports, {
11
- generateHandler: () => generateHandler,
12
- getAgentByIdHandler: () => getAgentByIdHandler,
13
- getAgentsHandler: () => getAgentsHandler,
14
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
15
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
16
- streamGenerateHandler: () => streamGenerateHandler
17
- });
18
- async function getAgentsHandler({ mastra }) {
19
- try {
20
- const agents = mastra.getAgents();
21
- const serializedAgents = Object.entries(agents).reduce((acc, [_id, _agent]) => {
22
- const agent = _agent;
23
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc2, [key, tool]) => {
24
- const _tool = tool;
25
- acc2[key] = {
26
- ..._tool,
27
- inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
28
- outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
29
- };
30
- return acc2;
31
- }, {});
32
- acc[_id] = {
33
- name: agent.name,
34
- instructions: agent.instructions,
35
- tools: serializedAgentTools,
36
- provider: agent.llm?.getProvider(),
37
- modelId: agent.llm?.getModelId()
38
- };
39
- return acc;
40
- }, {});
41
- return serializedAgents;
42
- } catch (error) {
43
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agents");
44
- }
45
- }
46
- async function getAgentByIdHandler({ mastra, agentId }) {
47
- try {
48
- const agent = mastra.getAgent(agentId);
49
- if (!agent) {
50
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
51
- }
52
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
53
- const _tool = tool;
54
- acc[key] = {
55
- ..._tool,
56
- inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
57
- outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
58
- };
59
- return acc;
60
- }, {});
61
- return {
62
- name: agent.name,
63
- instructions: agent.instructions,
64
- tools: serializedAgentTools,
65
- provider: agent.llm?.getProvider(),
66
- modelId: agent.llm?.getModelId()
67
- };
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agent");
70
- }
71
- }
72
- async function getEvalsByAgentIdHandler({ mastra, agentId }) {
73
- try {
74
- const agent = mastra.getAgent(agentId);
75
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
76
- return {
77
- id: agentId,
78
- name: agent.name,
79
- instructions: agent.instructions,
80
- evals
81
- };
82
- } catch (error) {
83
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting test evals");
84
- }
85
- }
86
- async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
87
- try {
88
- const agent = mastra.getAgent(agentId);
89
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
90
- return {
91
- id: agentId,
92
- name: agent.name,
93
- instructions: agent.instructions,
94
- evals
95
- };
96
- } catch (error) {
97
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting live evals");
98
- }
99
- }
100
- async function generateHandler({
101
- mastra,
102
- runtimeContext,
103
- agentId,
104
- body
105
- }) {
106
- try {
107
- const agent = mastra.getAgent(agentId);
108
- if (!agent) {
109
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
110
- }
111
- const { messages, resourceId, resourceid, ...rest } = body;
112
- const finalResourceId = resourceId ?? resourceid;
113
- chunkQN4KF3BH_cjs.validateBody({ messages });
114
- const result = await agent.generate(messages, {
115
- ...rest,
116
- // @ts-expect-error TODO fix types
117
- resourceId: finalResourceId,
118
- runtimeContext
119
- });
120
- return result;
121
- } catch (error) {
122
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from agent");
123
- }
124
- }
125
- async function streamGenerateHandler({
126
- mastra,
127
- runtimeContext,
128
- agentId,
129
- body
130
- }) {
131
- try {
132
- const agent = mastra.getAgent(agentId);
133
- if (!agent) {
134
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
135
- }
136
- const { messages, resourceId, resourceid, ...rest } = body;
137
- const finalResourceId = resourceId ?? resourceid;
138
- chunkQN4KF3BH_cjs.validateBody({ messages });
139
- const streamResult = await agent.stream(messages, {
140
- ...rest,
141
- // @ts-expect-error TODO fix types
142
- resourceId: finalResourceId,
143
- runtimeContext
144
- });
145
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
146
- sendUsage: true,
147
- sendReasoning: true,
148
- getErrorMessage: (error) => {
149
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
150
- }
151
- });
152
- return streamResponse;
153
- } catch (error) {
154
- throw new chunkFV45V6WC_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
155
- }
156
- }
157
-
158
- exports.agents_exports = agents_exports;
159
- exports.generateHandler = generateHandler;
160
- exports.getAgentByIdHandler = getAgentByIdHandler;
161
- exports.getAgentsHandler = getAgentsHandler;
162
- exports.getEvalsByAgentIdHandler = getEvalsByAgentIdHandler;
163
- exports.getLiveEvalsByAgentIdHandler = getLiveEvalsByAgentIdHandler;
164
- exports.streamGenerateHandler = streamGenerateHandler;