@mastra/server 0.0.0-extend-clickhouse-20250418135620 → 0.0.0-feat-tool-input-validation-20250731232758

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 (102) hide show
  1. package/LICENSE.md +11 -42
  2. package/README.md +48 -135
  3. package/dist/_tsup-dts-rollup.d.cts +763 -76
  4. package/dist/_tsup-dts-rollup.d.ts +763 -76
  5. package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
  6. package/dist/chunk-2SLFAFTR.cjs +148 -0
  7. package/dist/chunk-36BLNJHS.js +2039 -0
  8. package/dist/chunk-424T5F2J.cjs +157 -0
  9. package/dist/chunk-4D66QEKC.js +81 -0
  10. package/dist/chunk-6KP2OBYA.cjs +544 -0
  11. package/dist/chunk-6T5JUKOQ.js +149 -0
  12. package/dist/chunk-75ZPJI57.cjs +9 -0
  13. package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
  14. package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  15. package/dist/{chunk-YANVFOYA.js → chunk-CRCR3ZUK.js} +56 -34
  16. package/dist/{chunk-7IWQE76Z.cjs → chunk-G7KH752Y.cjs} +16 -10
  17. package/dist/chunk-GHC4YV6R.js +504 -0
  18. package/dist/chunk-HISYIDYH.cjs +2042 -0
  19. package/dist/{chunk-HABV7TZK.cjs → chunk-HRSAZUIK.cjs} +28 -26
  20. package/dist/chunk-I5JKUCGE.cjs +308 -0
  21. package/dist/{chunk-3RVHWGWO.js → chunk-KHZKYUNR.js} +36 -19
  22. package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
  23. package/dist/chunk-LF7P5PLR.js +14 -0
  24. package/dist/chunk-MLKGABMK.js +7 -0
  25. package/dist/chunk-PIAJQ75M.js +539 -0
  26. package/dist/chunk-PZQDCRPV.cjs +16 -0
  27. package/dist/chunk-QGX47B5D.cjs +86 -0
  28. package/dist/{chunk-WTHDCRMY.js → chunk-RG473F6Y.js} +12 -6
  29. package/dist/chunk-RHSWAXKB.cjs +118 -0
  30. package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
  31. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  32. package/dist/chunk-T7HAZC2E.js +527 -0
  33. package/dist/chunk-UCV4247U.cjs +332 -0
  34. package/dist/chunk-UEVYOKAH.cjs +555 -0
  35. package/dist/chunk-VTTN2FW3.js +299 -0
  36. package/dist/{chunk-XISBMH56.js → chunk-WBRFIHSF.js} +11 -9
  37. package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
  38. package/dist/{chunk-4B7OUZXW.js → chunk-ZYAFP2AV.js} +83 -68
  39. package/dist/server/handlers/a2a.cjs +30 -0
  40. package/dist/server/handlers/a2a.d.cts +6 -0
  41. package/dist/server/handlers/a2a.d.ts +6 -0
  42. package/dist/server/handlers/a2a.js +1 -0
  43. package/dist/server/handlers/agents.cjs +11 -7
  44. package/dist/server/handlers/agents.d.cts +1 -0
  45. package/dist/server/handlers/agents.d.ts +1 -0
  46. package/dist/server/handlers/agents.js +1 -1
  47. package/dist/server/handlers/error.cjs +2 -2
  48. package/dist/server/handlers/error.js +1 -1
  49. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  50. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  51. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  52. package/dist/server/handlers/legacyWorkflows.js +1 -0
  53. package/dist/server/handlers/logs.cjs +4 -4
  54. package/dist/server/handlers/logs.js +1 -1
  55. package/dist/server/handlers/memory.cjs +33 -9
  56. package/dist/server/handlers/memory.d.cts +6 -0
  57. package/dist/server/handlers/memory.d.ts +6 -0
  58. package/dist/server/handlers/memory.js +1 -1
  59. package/dist/server/handlers/network.cjs +5 -5
  60. package/dist/server/handlers/network.js +1 -1
  61. package/dist/server/handlers/scores.cjs +30 -0
  62. package/dist/server/handlers/scores.d.cts +6 -0
  63. package/dist/server/handlers/scores.d.ts +6 -0
  64. package/dist/server/handlers/scores.js +1 -0
  65. package/dist/server/handlers/telemetry.cjs +3 -3
  66. package/dist/server/handlers/telemetry.js +1 -1
  67. package/dist/server/handlers/tools.cjs +5 -5
  68. package/dist/server/handlers/tools.js +1 -1
  69. package/dist/server/handlers/utils.cjs +2 -2
  70. package/dist/server/handlers/utils.js +1 -1
  71. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  72. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  73. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  74. package/dist/server/handlers/vNextNetwork.js +211 -0
  75. package/dist/server/handlers/vector.cjs +7 -7
  76. package/dist/server/handlers/vector.js +1 -1
  77. package/dist/server/handlers/voice.cjs +8 -4
  78. package/dist/server/handlers/voice.d.cts +1 -0
  79. package/dist/server/handlers/voice.d.ts +1 -0
  80. package/dist/server/handlers/voice.js +1 -1
  81. package/dist/server/handlers/workflows.cjs +33 -13
  82. package/dist/server/handlers/workflows.d.cts +7 -2
  83. package/dist/server/handlers/workflows.d.ts +7 -2
  84. package/dist/server/handlers/workflows.js +1 -1
  85. package/dist/server/handlers.cjs +40 -25
  86. package/dist/server/handlers.d.cts +4 -1
  87. package/dist/server/handlers.d.ts +4 -1
  88. package/dist/server/handlers.js +12 -9
  89. package/package.json +17 -15
  90. package/dist/chunk-2FJURXCL.cjs +0 -213
  91. package/dist/chunk-3AHQ5RGN.js +0 -11
  92. package/dist/chunk-3EJZQ6TQ.js +0 -49
  93. package/dist/chunk-4WJ5GHRG.cjs +0 -164
  94. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  95. package/dist/chunk-A7DF4ETD.cjs +0 -100
  96. package/dist/chunk-JLDXUWK7.cjs +0 -126
  97. package/dist/chunk-OMN3UI6X.js +0 -5576
  98. package/dist/chunk-RBQASTUP.js +0 -203
  99. package/dist/chunk-RNU4JMLM.cjs +0 -317
  100. package/dist/chunk-SKBVVI24.cjs +0 -54
  101. package/dist/chunk-TFFNX7FI.js +0 -156
  102. package/dist/chunk-ZLBRQFDD.cjs +0 -13
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
5
+
6
+ // src/server/handlers/scores.ts
7
+ var scores_exports = {};
8
+ chunk75ZPJI57_cjs.__export(scores_exports, {
9
+ getScorerHandler: () => getScorerHandler,
10
+ getScorersHandler: () => getScorersHandler,
11
+ getScoresByEntityIdHandler: () => getScoresByEntityIdHandler,
12
+ getScoresByRunIdHandler: () => getScoresByRunIdHandler,
13
+ getScoresByScorerIdHandler: () => getScoresByScorerIdHandler,
14
+ saveScoreHandler: () => saveScoreHandler
15
+ });
16
+ async function getScorersFromSystem({
17
+ mastra,
18
+ runtimeContext
19
+ }) {
20
+ const agents = mastra.getAgents();
21
+ const workflows = mastra.getWorkflows();
22
+ const scorersMap = /* @__PURE__ */ new Map();
23
+ for (const [agentId, agent] of Object.entries(agents)) {
24
+ const scorers = await agent.getScorers({
25
+ runtimeContext
26
+ }) || {};
27
+ if (Object.keys(scorers).length > 0) {
28
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
29
+ if (scorersMap.has(scorerId)) {
30
+ scorersMap.get(scorerId)?.agentIds.push(agentId);
31
+ } else {
32
+ scorersMap.set(scorerId, {
33
+ workflowIds: [],
34
+ ...scorer,
35
+ agentIds: [agent.name]
36
+ });
37
+ }
38
+ }
39
+ }
40
+ }
41
+ for (const [workflowId, workflow] of Object.entries(workflows)) {
42
+ const scorers = await workflow.getScorers({
43
+ runtimeContext
44
+ }) || {};
45
+ if (Object.keys(scorers).length > 0) {
46
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
47
+ if (scorersMap.has(scorerId)) {
48
+ scorersMap.get(scorerId)?.workflowIds.push(workflowId);
49
+ } else {
50
+ scorersMap.set(scorerId, {
51
+ agentIds: [],
52
+ ...scorer,
53
+ workflowIds: [workflowId]
54
+ });
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return Object.fromEntries(scorersMap.entries());
60
+ }
61
+ async function getScorersHandler({ mastra, runtimeContext }) {
62
+ const scorers = await getScorersFromSystem({
63
+ mastra,
64
+ runtimeContext
65
+ });
66
+ return scorers;
67
+ }
68
+ async function getScorerHandler({
69
+ mastra,
70
+ scorerId,
71
+ runtimeContext
72
+ }) {
73
+ const scorers = await getScorersFromSystem({
74
+ mastra,
75
+ runtimeContext
76
+ });
77
+ const scorer = scorers[scorerId];
78
+ if (!scorer) {
79
+ return null;
80
+ }
81
+ return scorer;
82
+ }
83
+ async function getScoresByRunIdHandler({
84
+ mastra,
85
+ runId,
86
+ pagination
87
+ }) {
88
+ try {
89
+ const scores = await mastra.getStorage()?.getScoresByRunId?.({
90
+ runId,
91
+ pagination
92
+ }) || [];
93
+ return scores;
94
+ } catch (error) {
95
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by run id");
96
+ }
97
+ }
98
+ async function getScoresByScorerIdHandler({
99
+ mastra,
100
+ scorerId,
101
+ pagination,
102
+ entityId,
103
+ entityType
104
+ }) {
105
+ try {
106
+ const scores = await mastra.getStorage()?.getScoresByScorerId?.({
107
+ scorerId,
108
+ pagination,
109
+ entityId,
110
+ entityType
111
+ }) || [];
112
+ return scores;
113
+ } catch (error) {
114
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by scorer id");
115
+ }
116
+ }
117
+ async function getScoresByEntityIdHandler({
118
+ mastra,
119
+ entityId,
120
+ entityType,
121
+ pagination
122
+ }) {
123
+ try {
124
+ let entityIdToUse = entityId;
125
+ if (entityType === "AGENT") {
126
+ const agent = mastra.getAgentById(entityId);
127
+ entityIdToUse = agent.id;
128
+ } else if (entityType === "WORKFLOW") {
129
+ const workflow = mastra.getWorkflowById(entityId);
130
+ entityIdToUse = workflow.id;
131
+ }
132
+ const scores = await mastra.getStorage()?.getScoresByEntityId?.({
133
+ entityId: entityIdToUse,
134
+ entityType,
135
+ pagination
136
+ }) || [];
137
+ return scores;
138
+ } catch (error) {
139
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by entity id");
140
+ }
141
+ }
142
+ async function saveScoreHandler({ mastra, score }) {
143
+ try {
144
+ const scores = await mastra.getStorage()?.saveScore?.(score) || [];
145
+ return scores;
146
+ } catch (error) {
147
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving score");
148
+ }
149
+ }
150
+
151
+ exports.getScorerHandler = getScorerHandler;
152
+ exports.getScorersHandler = getScorersHandler;
153
+ exports.getScoresByEntityIdHandler = getScoresByEntityIdHandler;
154
+ exports.getScoresByRunIdHandler = getScoresByRunIdHandler;
155
+ exports.getScoresByScorerIdHandler = getScoresByScorerIdHandler;
156
+ exports.saveScoreHandler = saveScoreHandler;
157
+ exports.scores_exports = scores_exports;
@@ -0,0 +1,81 @@
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { __export } from './chunk-MLKGABMK.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
+ params
16
+ }) {
17
+ try {
18
+ validateBody({ transportId });
19
+ const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
20
+ const filters = _filters ? Object.fromEntries(
21
+ (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
22
+ const [key, value] = attr.split(":");
23
+ return [key, value];
24
+ })
25
+ ) : void 0;
26
+ const logs = await mastra.getLogs(transportId, {
27
+ fromDate,
28
+ toDate,
29
+ logLevel,
30
+ filters,
31
+ page: page ? Number(page) : void 0,
32
+ perPage: perPage ? Number(perPage) : void 0
33
+ });
34
+ return logs;
35
+ } catch (error) {
36
+ return handleError(error, "Error getting logs");
37
+ }
38
+ }
39
+ async function getLogsByRunIdHandler({
40
+ mastra,
41
+ runId,
42
+ transportId,
43
+ params
44
+ }) {
45
+ try {
46
+ validateBody({ runId, transportId });
47
+ const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
48
+ const filters = _filters ? Object.fromEntries(
49
+ (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
50
+ const [key, value] = attr.split(":");
51
+ return [key, value];
52
+ })
53
+ ) : void 0;
54
+ const logs = await mastra.getLogsByRunId({
55
+ runId,
56
+ transportId,
57
+ fromDate,
58
+ toDate,
59
+ logLevel,
60
+ filters,
61
+ page: page ? Number(page) : void 0,
62
+ perPage: perPage ? Number(perPage) : void 0
63
+ });
64
+ return logs;
65
+ } catch (error) {
66
+ return handleError(error, "Error getting logs by run ID");
67
+ }
68
+ }
69
+ async function getLogTransports({ mastra }) {
70
+ try {
71
+ const logger = mastra.getLogger();
72
+ const transports = logger.getTransports();
73
+ return {
74
+ transports: transports ? [...transports.keys()] : []
75
+ };
76
+ } catch (error) {
77
+ return handleError(error, "Error getting log Transports");
78
+ }
79
+ }
80
+
81
+ export { getLogTransports, getLogsByRunIdHandler, getLogsHandler, logs_exports };