@mastra/server 0.0.0-separate-trace-data-from-component-20250501042644 → 0.0.0-support-d1-client-20250701191943
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 +517 -103
- package/dist/_tsup-dts-rollup.d.ts +517 -103
- package/dist/{chunk-2FJURXCL.cjs → chunk-3DKDT264.cjs} +93 -55
- package/dist/{chunk-Y3SV5XK4.js → chunk-4QBIUKVY.js} +105 -16
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/chunk-7524QH7G.cjs +483 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M3YJLWTU.js → chunk-7GQJAMTA.js} +68 -57
- package/dist/chunk-BOXE6WSV.js +81 -0
- package/dist/{chunk-WTHDCRMY.js → chunk-BP24Z4WG.js} +12 -6
- package/dist/chunk-BWHGBV3K.cjs +278 -0
- package/dist/chunk-CNVDCLSY.cjs +86 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-DFJUGWNU.js} +7 -5
- package/dist/{chunk-5YGDYMRB.cjs → chunk-DPRB3R7Y.cjs} +14 -13
- package/dist/{chunk-D3G23FP3.cjs → chunk-FGGMQCPP.cjs} +24 -22
- package/dist/{chunk-4JINXASC.js → chunk-FVMGZKFD.js} +5 -4
- package/dist/{chunk-Q6SHQECN.js → chunk-G37NVEDX.js} +34 -10
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/chunk-L3N7ST2Z.cjs +118 -0
- package/dist/chunk-LI436ITD.cjs +2042 -0
- package/dist/{chunk-RBQASTUP.js → chunk-LTJNMM2Y.js} +63 -25
- package/dist/chunk-MEGCYGBU.js +2039 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-MTR2B27E.cjs} +3 -2
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/{chunk-3AHQ5RGN.js → chunk-QDOJJCS4.js} +3 -2
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/chunk-TGZIR6AK.cjs +332 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-TVBPFPTN.cjs} +20 -19
- package/dist/{chunk-7IWQE76Z.cjs → chunk-ULFULEW4.cjs} +16 -10
- package/dist/{chunk-QJ3AHN64.js → chunk-VMXLEF54.js} +4 -3
- package/dist/chunk-Z5TH5F35.js +468 -0
- 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 +218 -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 +211 -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 +25 -13
- package/dist/server/handlers/workflows.d.cts +5 -2
- package/dist/server/handlers/workflows.d.ts +5 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +32 -27
- package/dist/server/handlers.d.cts +2 -1
- package/dist/server/handlers.d.ts +2 -1
- package/dist/server/handlers.js +11 -10
- package/package.json +14 -13
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-4BIX6GMY.cjs +0 -189
- package/dist/chunk-55HTWX4C.cjs +0 -93
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-AELYAUEE.cjs +0 -316
- package/dist/chunk-EVCC233P.cjs +0 -321
- package/dist/chunk-JPB6RPGB.js +0 -304
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/server/handlers/vNextWorkflows.cjs +0 -46
- package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
- package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
- package/dist/server/handlers/vNextWorkflows.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { validateBody } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
1
|
+
import { validateBody } from './chunk-H5PTF3Y4.js';
|
|
2
|
+
import { handleError } from './chunk-QDOJJCS4.js';
|
|
3
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
4
5
|
|
|
5
6
|
// src/server/handlers/memory.ts
|
|
6
7
|
var memory_exports = {};
|
|
@@ -14,20 +15,36 @@ __export(memory_exports, {
|
|
|
14
15
|
saveMessagesHandler: () => saveMessagesHandler,
|
|
15
16
|
updateThreadHandler: () => updateThreadHandler
|
|
16
17
|
});
|
|
17
|
-
function getMemoryFromContext({
|
|
18
|
+
async function getMemoryFromContext({
|
|
18
19
|
mastra,
|
|
19
|
-
agentId
|
|
20
|
+
agentId,
|
|
21
|
+
networkId,
|
|
22
|
+
runtimeContext
|
|
20
23
|
}) {
|
|
21
24
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
22
25
|
if (agentId && !agent) {
|
|
23
26
|
throw new HTTPException(404, { message: "Agent not found" });
|
|
24
27
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
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();
|
|
27
39
|
}
|
|
28
|
-
async function getMemoryStatusHandler({
|
|
40
|
+
async function getMemoryStatusHandler({
|
|
41
|
+
mastra,
|
|
42
|
+
agentId,
|
|
43
|
+
networkId,
|
|
44
|
+
runtimeContext
|
|
45
|
+
}) {
|
|
29
46
|
try {
|
|
30
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
47
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
31
48
|
if (!memory) {
|
|
32
49
|
return { result: false };
|
|
33
50
|
}
|
|
@@ -39,10 +56,12 @@ async function getMemoryStatusHandler({ mastra, agentId }) {
|
|
|
39
56
|
async function getThreadsHandler({
|
|
40
57
|
mastra,
|
|
41
58
|
agentId,
|
|
42
|
-
resourceId
|
|
59
|
+
resourceId,
|
|
60
|
+
networkId,
|
|
61
|
+
runtimeContext
|
|
43
62
|
}) {
|
|
44
63
|
try {
|
|
45
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
64
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
46
65
|
if (!memory) {
|
|
47
66
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
48
67
|
}
|
|
@@ -56,11 +75,13 @@ async function getThreadsHandler({
|
|
|
56
75
|
async function getThreadByIdHandler({
|
|
57
76
|
mastra,
|
|
58
77
|
agentId,
|
|
59
|
-
threadId
|
|
78
|
+
threadId,
|
|
79
|
+
networkId,
|
|
80
|
+
runtimeContext
|
|
60
81
|
}) {
|
|
61
82
|
try {
|
|
62
83
|
validateBody({ threadId });
|
|
63
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
84
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
64
85
|
if (!memory) {
|
|
65
86
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
66
87
|
}
|
|
@@ -76,10 +97,12 @@ async function getThreadByIdHandler({
|
|
|
76
97
|
async function saveMessagesHandler({
|
|
77
98
|
mastra,
|
|
78
99
|
agentId,
|
|
79
|
-
body
|
|
100
|
+
body,
|
|
101
|
+
networkId,
|
|
102
|
+
runtimeContext
|
|
80
103
|
}) {
|
|
81
104
|
try {
|
|
82
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
105
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
83
106
|
if (!memory) {
|
|
84
107
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
85
108
|
}
|
|
@@ -103,10 +126,12 @@ async function saveMessagesHandler({
|
|
|
103
126
|
async function createThreadHandler({
|
|
104
127
|
mastra,
|
|
105
128
|
agentId,
|
|
106
|
-
body
|
|
129
|
+
body,
|
|
130
|
+
networkId,
|
|
131
|
+
runtimeContext
|
|
107
132
|
}) {
|
|
108
133
|
try {
|
|
109
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
134
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
110
135
|
if (!memory) {
|
|
111
136
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
112
137
|
}
|
|
@@ -126,10 +151,12 @@ async function updateThreadHandler({
|
|
|
126
151
|
mastra,
|
|
127
152
|
agentId,
|
|
128
153
|
threadId,
|
|
129
|
-
body
|
|
154
|
+
body,
|
|
155
|
+
networkId,
|
|
156
|
+
runtimeContext
|
|
130
157
|
}) {
|
|
131
158
|
try {
|
|
132
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
159
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
133
160
|
if (!body) {
|
|
134
161
|
throw new HTTPException(400, { message: "Body is required" });
|
|
135
162
|
}
|
|
@@ -160,11 +187,13 @@ async function updateThreadHandler({
|
|
|
160
187
|
async function deleteThreadHandler({
|
|
161
188
|
mastra,
|
|
162
189
|
agentId,
|
|
163
|
-
threadId
|
|
190
|
+
threadId,
|
|
191
|
+
networkId,
|
|
192
|
+
runtimeContext
|
|
164
193
|
}) {
|
|
165
194
|
try {
|
|
166
195
|
validateBody({ threadId });
|
|
167
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
196
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
168
197
|
if (!memory) {
|
|
169
198
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
170
199
|
}
|
|
@@ -181,11 +210,17 @@ async function deleteThreadHandler({
|
|
|
181
210
|
async function getMessagesHandler({
|
|
182
211
|
mastra,
|
|
183
212
|
agentId,
|
|
184
|
-
threadId
|
|
213
|
+
threadId,
|
|
214
|
+
limit,
|
|
215
|
+
networkId,
|
|
216
|
+
runtimeContext
|
|
185
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
|
+
}
|
|
186
221
|
try {
|
|
187
222
|
validateBody({ threadId });
|
|
188
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
223
|
+
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
189
224
|
if (!memory) {
|
|
190
225
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
191
226
|
}
|
|
@@ -193,8 +228,11 @@ async function getMessagesHandler({
|
|
|
193
228
|
if (!thread) {
|
|
194
229
|
throw new HTTPException(404, { message: "Thread not found" });
|
|
195
230
|
}
|
|
196
|
-
const result = await memory.query({
|
|
197
|
-
|
|
231
|
+
const result = await memory.query({
|
|
232
|
+
threadId,
|
|
233
|
+
...limit && { selectBy: { last: limit } }
|
|
234
|
+
});
|
|
235
|
+
return { messages: result.messages, uiMessages: result.uiMessages };
|
|
198
236
|
} catch (error) {
|
|
199
237
|
return handleError(error, "Error getting messages");
|
|
200
238
|
}
|