@mastra/server 0.0.0-tool-call-parts-20250630193309 → 0.0.0-transpile-packages-20250730132657

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 (78) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +212 -23
  3. package/dist/_tsup-dts-rollup.d.ts +212 -23
  4. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  5. package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
  6. package/dist/{chunk-MEGCYGBU.js → chunk-36BLNJHS.js} +37 -37
  7. package/dist/chunk-424T5F2J.cjs +157 -0
  8. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  9. package/dist/{chunk-L3VURYKY.cjs → chunk-6KP2OBYA.cjs} +177 -68
  10. package/dist/chunk-6T5JUKOQ.js +149 -0
  11. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  12. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  13. package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
  14. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  15. package/dist/{chunk-LI436ITD.cjs → chunk-HISYIDYH.cjs} +37 -37
  16. package/dist/{chunk-Z3PTO2AK.cjs → chunk-HRSAZUIK.cjs} +20 -20
  17. package/dist/{chunk-EP3XVEVC.cjs → chunk-I5JKUCGE.cjs} +50 -20
  18. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  19. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  20. package/dist/chunk-LF7P5PLR.js +14 -0
  21. package/dist/chunk-PZQDCRPV.cjs +16 -0
  22. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  23. package/dist/chunk-R3I7AJVL.js +507 -0
  24. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  25. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  26. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  27. package/dist/{chunk-72LOJGUV.js → chunk-T7HAZC2E.js} +118 -12
  28. package/dist/chunk-TTPJHP42.cjs +522 -0
  29. package/dist/{chunk-NGHSYB5B.cjs → chunk-UCV4247U.cjs} +43 -43
  30. package/dist/{chunk-2BCWG3EZ.js → chunk-VTTN2FW3.js} +36 -7
  31. package/dist/{chunk-EWLR2PNT.js → chunk-WBRFIHSF.js} +4 -4
  32. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  33. package/dist/{chunk-E2LP4J6K.js → chunk-ZYAFP2AV.js} +8 -8
  34. package/dist/server/handlers/agents.cjs +11 -7
  35. package/dist/server/handlers/agents.d.cts +1 -0
  36. package/dist/server/handlers/agents.d.ts +1 -0
  37. package/dist/server/handlers/agents.js +1 -1
  38. package/dist/server/handlers/error.cjs +2 -2
  39. package/dist/server/handlers/error.js +1 -1
  40. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  41. package/dist/server/handlers/legacyWorkflows.js +1 -1
  42. package/dist/server/handlers/logs.cjs +4 -4
  43. package/dist/server/handlers/logs.js +1 -1
  44. package/dist/server/handlers/memory.cjs +29 -9
  45. package/dist/server/handlers/memory.d.cts +5 -0
  46. package/dist/server/handlers/memory.d.ts +5 -0
  47. package/dist/server/handlers/memory.js +1 -1
  48. package/dist/server/handlers/network.cjs +5 -5
  49. package/dist/server/handlers/network.js +1 -1
  50. package/dist/server/handlers/scores.cjs +30 -0
  51. package/dist/server/handlers/scores.d.cts +6 -0
  52. package/dist/server/handlers/scores.d.ts +6 -0
  53. package/dist/server/handlers/scores.js +1 -0
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vNextNetwork.cjs +23 -23
  61. package/dist/server/handlers/vNextNetwork.js +4 -4
  62. package/dist/server/handlers/vector.cjs +7 -7
  63. package/dist/server/handlers/vector.js +1 -1
  64. package/dist/server/handlers/voice.cjs +5 -5
  65. package/dist/server/handlers/voice.js +1 -1
  66. package/dist/server/handlers/workflows.cjs +25 -13
  67. package/dist/server/handlers/workflows.d.cts +3 -0
  68. package/dist/server/handlers/workflows.d.ts +3 -0
  69. package/dist/server/handlers/workflows.js +1 -1
  70. package/dist/server/handlers.cjs +28 -23
  71. package/dist/server/handlers.d.cts +3 -2
  72. package/dist/server/handlers.d.ts +3 -2
  73. package/dist/server/handlers.js +11 -10
  74. package/package.json +8 -7
  75. package/dist/chunk-64U3UDTH.cjs +0 -13
  76. package/dist/chunk-M5ABIP7D.js +0 -11
  77. package/dist/chunk-RQ2Z56EC.cjs +0 -251
  78. package/dist/chunk-XUIJ7WRT.js +0 -241
@@ -1,241 +0,0 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.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 };