@mastra/server 0.0.0-commonjs-20250414101718 → 0.0.0-custom-instrumentation-20250626084921
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.
- package/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +544 -62
- package/dist/_tsup-dts-rollup.d.ts +544 -62
- package/dist/chunk-4DTDPTQC.cjs +332 -0
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-CWSDZEZG.cjs → chunk-B4MQFJ7G.cjs} +18 -12
- package/dist/{chunk-DVPP5S6I.js → chunk-BFOA2QQY.js} +14 -8
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-YANVFOYA.js → chunk-C7564HUT.js} +56 -34
- package/dist/{chunk-4C3EPMMF.cjs → chunk-CPPYMJX5.cjs} +31 -25
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-GKM45O24.cjs +278 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/chunk-IMBY5XUG.cjs +86 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-MN6F4D5A.cjs +2004 -0
- package/dist/{chunk-OPP7H5TW.js → chunk-N2YBMSO2.js} +78 -63
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/chunk-OSZM4EAY.js +2001 -0
- package/dist/chunk-PMUATKV2.js +270 -0
- package/dist/chunk-QLG2PFHE.js +81 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-R5VGYBV6.js} +36 -19
- package/dist/{chunk-2FJURXCL.cjs → chunk-RQ2Z56EC.cjs} +93 -55
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/chunk-SOBBILUG.js +421 -0
- package/dist/chunk-TO5U6HW3.cjs +435 -0
- package/dist/chunk-VPNDC2DI.cjs +148 -0
- package/dist/chunk-WJY57THV.cjs +118 -0
- package/dist/{chunk-YNSGUC2O.js → chunk-XR7VJOOP.js} +14 -8
- package/dist/{chunk-RBQASTUP.js → chunk-XUIJ7WRT.js} +63 -25
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vNextNetwork.cjs +200 -0
- package/dist/server/handlers/vNextNetwork.d.cts +6 -0
- package/dist/server/handlers/vNextNetwork.d.ts +6 -0
- package/dist/server/handlers/vNextNetwork.js +193 -0
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -4
- package/dist/server/handlers/voice.d.cts +1 -0
- package/dist/server/handlers/voice.d.ts +1 -0
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +21 -13
- package/dist/server/handlers/workflows.d.cts +4 -2
- package/dist/server/handlers/workflows.d.ts +4 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +33 -23
- package/dist/server/handlers.d.cts +2 -0
- package/dist/server/handlers.d.ts +2 -0
- package/dist/server/handlers.js +11 -9
- package/package.json +13 -12
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-67WTHYAV.js +0 -156
- package/dist/chunk-A7DF4ETD.cjs +0 -100
- package/dist/chunk-B64YROKU.cjs +0 -317
- package/dist/chunk-JLDXUWK7.cjs +0 -126
- package/dist/chunk-QH6XWSXP.cjs +0 -5579
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-VK6FX47H.js +0 -5576
- package/dist/chunk-Z46X3YCB.cjs +0 -164
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
4
|
+
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
5
|
+
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/memory.ts
|
|
8
9
|
var memory_exports = {};
|
|
9
|
-
|
|
10
|
+
chunk75ZPJI57_cjs.__export(memory_exports, {
|
|
10
11
|
createThreadHandler: () => createThreadHandler,
|
|
11
12
|
deleteThreadHandler: () => deleteThreadHandler,
|
|
12
13
|
getMemoryStatusHandler: () => getMemoryStatusHandler,
|
|
@@ -16,80 +17,102 @@ chunkFV45V6WC_cjs.__export(memory_exports, {
|
|
|
16
17
|
saveMessagesHandler: () => saveMessagesHandler,
|
|
17
18
|
updateThreadHandler: () => updateThreadHandler
|
|
18
19
|
});
|
|
19
|
-
function getMemoryFromContext({
|
|
20
|
+
async function getMemoryFromContext({
|
|
20
21
|
mastra,
|
|
21
|
-
agentId
|
|
22
|
+
agentId,
|
|
23
|
+
networkId,
|
|
24
|
+
runtimeContext
|
|
22
25
|
}) {
|
|
23
26
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
24
27
|
if (agentId && !agent) {
|
|
25
|
-
throw new
|
|
28
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
29
|
+
}
|
|
30
|
+
const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
|
|
31
|
+
if (networkId && !network) {
|
|
32
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
33
|
+
}
|
|
34
|
+
if (agent) {
|
|
35
|
+
return agent?.getMemory() || mastra.getMemory();
|
|
36
|
+
}
|
|
37
|
+
if (network) {
|
|
38
|
+
return await network?.getMemory({ runtimeContext }) || mastra.getMemory();
|
|
26
39
|
}
|
|
27
|
-
|
|
28
|
-
return memory;
|
|
40
|
+
return mastra.getMemory();
|
|
29
41
|
}
|
|
30
|
-
async function getMemoryStatusHandler({
|
|
42
|
+
async function getMemoryStatusHandler({
|
|
43
|
+
mastra,
|
|
44
|
+
agentId,
|
|
45
|
+
networkId,
|
|
46
|
+
runtimeContext
|
|
47
|
+
}) {
|
|
31
48
|
try {
|
|
32
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
49
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
33
50
|
if (!memory) {
|
|
34
51
|
return { result: false };
|
|
35
52
|
}
|
|
36
53
|
return { result: true };
|
|
37
54
|
} catch (error) {
|
|
38
|
-
return
|
|
55
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
async function getThreadsHandler({
|
|
42
59
|
mastra,
|
|
43
60
|
agentId,
|
|
44
|
-
resourceId
|
|
61
|
+
resourceId,
|
|
62
|
+
networkId,
|
|
63
|
+
runtimeContext
|
|
45
64
|
}) {
|
|
46
65
|
try {
|
|
47
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
66
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
48
67
|
if (!memory) {
|
|
49
|
-
throw new
|
|
68
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
50
69
|
}
|
|
51
|
-
|
|
70
|
+
chunk57CJTIPW_cjs.validateBody({ resourceId });
|
|
52
71
|
const threads = await memory.getThreadsByResourceId({ resourceId });
|
|
53
72
|
return threads;
|
|
54
73
|
} catch (error) {
|
|
55
|
-
return
|
|
74
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
|
|
56
75
|
}
|
|
57
76
|
}
|
|
58
77
|
async function getThreadByIdHandler({
|
|
59
78
|
mastra,
|
|
60
79
|
agentId,
|
|
61
|
-
threadId
|
|
80
|
+
threadId,
|
|
81
|
+
networkId,
|
|
82
|
+
runtimeContext
|
|
62
83
|
}) {
|
|
63
84
|
try {
|
|
64
|
-
|
|
65
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
85
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
86
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
66
87
|
if (!memory) {
|
|
67
|
-
throw new
|
|
88
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
68
89
|
}
|
|
69
90
|
const thread = await memory.getThreadById({ threadId });
|
|
70
91
|
if (!thread) {
|
|
71
|
-
throw new
|
|
92
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
72
93
|
}
|
|
73
94
|
return thread;
|
|
74
95
|
} catch (error) {
|
|
75
|
-
return
|
|
96
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
|
|
76
97
|
}
|
|
77
98
|
}
|
|
78
99
|
async function saveMessagesHandler({
|
|
79
100
|
mastra,
|
|
80
101
|
agentId,
|
|
81
|
-
body
|
|
102
|
+
body,
|
|
103
|
+
networkId,
|
|
104
|
+
runtimeContext
|
|
82
105
|
}) {
|
|
83
106
|
try {
|
|
84
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
107
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
85
108
|
if (!memory) {
|
|
86
|
-
throw new
|
|
109
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
87
110
|
}
|
|
88
111
|
if (!body?.messages) {
|
|
89
|
-
throw new
|
|
112
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
90
113
|
}
|
|
91
114
|
if (!Array.isArray(body.messages)) {
|
|
92
|
-
throw new
|
|
115
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
93
116
|
}
|
|
94
117
|
const processedMessages = body.messages.map((message) => ({
|
|
95
118
|
...message,
|
|
@@ -99,20 +122,22 @@ async function saveMessagesHandler({
|
|
|
99
122
|
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
100
123
|
return result;
|
|
101
124
|
} catch (error) {
|
|
102
|
-
return
|
|
125
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
|
|
103
126
|
}
|
|
104
127
|
}
|
|
105
128
|
async function createThreadHandler({
|
|
106
129
|
mastra,
|
|
107
130
|
agentId,
|
|
108
|
-
body
|
|
131
|
+
body,
|
|
132
|
+
networkId,
|
|
133
|
+
runtimeContext
|
|
109
134
|
}) {
|
|
110
135
|
try {
|
|
111
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
136
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
112
137
|
if (!memory) {
|
|
113
|
-
throw new
|
|
138
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
114
139
|
}
|
|
115
|
-
|
|
140
|
+
chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
|
|
116
141
|
const result = await memory.createThread({
|
|
117
142
|
resourceId: body?.resourceId,
|
|
118
143
|
title: body?.title,
|
|
@@ -121,29 +146,31 @@ async function createThreadHandler({
|
|
|
121
146
|
});
|
|
122
147
|
return result;
|
|
123
148
|
} catch (error) {
|
|
124
|
-
return
|
|
149
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
|
|
125
150
|
}
|
|
126
151
|
}
|
|
127
152
|
async function updateThreadHandler({
|
|
128
153
|
mastra,
|
|
129
154
|
agentId,
|
|
130
155
|
threadId,
|
|
131
|
-
body
|
|
156
|
+
body,
|
|
157
|
+
networkId,
|
|
158
|
+
runtimeContext
|
|
132
159
|
}) {
|
|
133
160
|
try {
|
|
134
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
161
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
135
162
|
if (!body) {
|
|
136
|
-
throw new
|
|
163
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
|
|
137
164
|
}
|
|
138
165
|
const { title, metadata, resourceId } = body;
|
|
139
166
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
140
|
-
|
|
167
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
141
168
|
if (!memory) {
|
|
142
|
-
throw new
|
|
169
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
143
170
|
}
|
|
144
171
|
const thread = await memory.getThreadById({ threadId });
|
|
145
172
|
if (!thread) {
|
|
146
|
-
throw new
|
|
173
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
147
174
|
}
|
|
148
175
|
const updatedThread = {
|
|
149
176
|
...thread,
|
|
@@ -156,49 +183,60 @@ async function updateThreadHandler({
|
|
|
156
183
|
const result = await memory.saveThread({ thread: updatedThread });
|
|
157
184
|
return result;
|
|
158
185
|
} catch (error) {
|
|
159
|
-
return
|
|
186
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
|
|
160
187
|
}
|
|
161
188
|
}
|
|
162
189
|
async function deleteThreadHandler({
|
|
163
190
|
mastra,
|
|
164
191
|
agentId,
|
|
165
|
-
threadId
|
|
192
|
+
threadId,
|
|
193
|
+
networkId,
|
|
194
|
+
runtimeContext
|
|
166
195
|
}) {
|
|
167
196
|
try {
|
|
168
|
-
|
|
169
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
197
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
198
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
170
199
|
if (!memory) {
|
|
171
|
-
throw new
|
|
200
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
172
201
|
}
|
|
173
202
|
const thread = await memory.getThreadById({ threadId });
|
|
174
203
|
if (!thread) {
|
|
175
|
-
throw new
|
|
204
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
176
205
|
}
|
|
177
206
|
await memory.deleteThread(threadId);
|
|
178
207
|
return { result: "Thread deleted" };
|
|
179
208
|
} catch (error) {
|
|
180
|
-
return
|
|
209
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
|
|
181
210
|
}
|
|
182
211
|
}
|
|
183
212
|
async function getMessagesHandler({
|
|
184
213
|
mastra,
|
|
185
214
|
agentId,
|
|
186
|
-
threadId
|
|
215
|
+
threadId,
|
|
216
|
+
limit,
|
|
217
|
+
networkId,
|
|
218
|
+
runtimeContext
|
|
187
219
|
}) {
|
|
220
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
|
|
221
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
|
|
222
|
+
}
|
|
188
223
|
try {
|
|
189
|
-
|
|
190
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
224
|
+
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
225
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
191
226
|
if (!memory) {
|
|
192
|
-
throw new
|
|
227
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
193
228
|
}
|
|
194
229
|
const thread = await memory.getThreadById({ threadId });
|
|
195
230
|
if (!thread) {
|
|
196
|
-
throw new
|
|
231
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
197
232
|
}
|
|
198
|
-
const result = await memory.query({
|
|
199
|
-
|
|
233
|
+
const result = await memory.query({
|
|
234
|
+
threadId,
|
|
235
|
+
...limit && { selectBy: { last: limit } }
|
|
236
|
+
});
|
|
237
|
+
return { messages: result.messages, uiMessages: result.uiMessages };
|
|
200
238
|
} catch (error) {
|
|
201
|
-
return
|
|
239
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
|
|
202
240
|
}
|
|
203
241
|
}
|
|
204
242
|
|