@mastra/server 0.24.0-alpha.0 → 1.0.0-beta.0
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/CHANGELOG.md +309 -48
- package/README.md +1 -1
- package/dist/{chunk-OQPXME7E.js → chunk-2IS5WICF.js} +4569 -1062
- package/dist/chunk-2IS5WICF.js.map +1 -0
- package/dist/{chunk-SPRRK3P7.cjs → chunk-2YZH5PH6.cjs} +47 -47
- package/dist/chunk-2YZH5PH6.cjs.map +1 -0
- package/dist/{chunk-BATEJLED.js → chunk-3AMNUUZF.js} +20 -20
- package/dist/chunk-3AMNUUZF.js.map +1 -0
- package/dist/{chunk-AW5BU3RQ.js → chunk-3F52QCI4.js} +40 -40
- package/dist/chunk-3F52QCI4.js.map +1 -0
- package/dist/{chunk-PBXWFGEH.js → chunk-4JF5WXPL.js} +130 -207
- package/dist/chunk-4JF5WXPL.js.map +1 -0
- package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
- package/dist/chunk-64ITUOXI.cjs.map +1 -0
- package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
- package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
- package/dist/{chunk-ABRFV4XP.js → chunk-73PAWDM5.js} +13 -13
- package/dist/chunk-73PAWDM5.js.map +1 -0
- package/dist/{chunk-2S4IMB6E.cjs → chunk-A24TSVEZ.cjs} +39 -39
- package/dist/chunk-A24TSVEZ.cjs.map +1 -0
- package/dist/{chunk-NT5XW5PI.cjs → chunk-A2NPD5N6.cjs} +176 -255
- package/dist/chunk-A2NPD5N6.cjs.map +1 -0
- package/dist/{chunk-QQXMIP6C.js → chunk-B3Z6J745.js} +17 -17
- package/dist/chunk-B3Z6J745.js.map +1 -0
- package/dist/{chunk-G4PUALCE.cjs → chunk-BTWIR2B7.cjs} +4 -4
- package/dist/{chunk-G4PUALCE.cjs.map → chunk-BTWIR2B7.cjs.map} +1 -1
- package/dist/{chunk-YWOK4F5A.js → chunk-D7T74TVR.js} +4 -6
- package/dist/chunk-D7T74TVR.js.map +1 -0
- package/dist/{chunk-IJSDPAUY.cjs → chunk-EHACNWDL.cjs} +156 -202
- package/dist/chunk-EHACNWDL.cjs.map +1 -0
- package/dist/{chunk-HPXAM2PG.js → chunk-FPBYKMIS.js} +13 -13
- package/dist/chunk-FPBYKMIS.js.map +1 -0
- package/dist/{chunk-3SNGNFUJ.cjs → chunk-GLAZTMX3.cjs} +37 -37
- package/dist/chunk-GLAZTMX3.cjs.map +1 -0
- package/dist/{chunk-TEOUDAN5.cjs → chunk-ID6JYDNL.cjs} +4590 -1080
- package/dist/chunk-ID6JYDNL.cjs.map +1 -0
- package/dist/{chunk-TRGAMKHX.cjs → chunk-KF3RI45U.cjs} +46 -41
- package/dist/chunk-KF3RI45U.cjs.map +1 -0
- package/dist/{chunk-TOP25AIO.cjs → chunk-KJIDZQRA.cjs} +14 -14
- package/dist/chunk-KJIDZQRA.cjs.map +1 -0
- package/dist/{chunk-MYR4PVGN.js → chunk-KWH5QBXP.js} +4 -4
- package/dist/{chunk-MYR4PVGN.js.map → chunk-KWH5QBXP.js.map} +1 -1
- package/dist/{chunk-AHB4JCIQ.js → chunk-ND5OKOMT.js} +31 -26
- package/dist/chunk-ND5OKOMT.js.map +1 -0
- package/dist/{chunk-XN74I6VW.cjs → chunk-PPMIB3FQ.cjs} +20 -20
- package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
- package/dist/{chunk-EP3JQDPD.cjs → chunk-S54HNARD.cjs} +18 -18
- package/dist/{chunk-EP3JQDPD.cjs.map → chunk-S54HNARD.cjs.map} +1 -1
- package/dist/{chunk-4QCXUEAT.js → chunk-SZIFSF4T.js} +3 -3
- package/dist/{chunk-4QCXUEAT.js.map → chunk-SZIFSF4T.js.map} +1 -1
- package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
- package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
- package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
- package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
- package/dist/{chunk-VY4ENABS.cjs → chunk-W2KMU354.cjs} +4 -6
- package/dist/chunk-W2KMU354.cjs.map +1 -0
- package/dist/{chunk-H33KYEMY.cjs → chunk-X3MICMI2.cjs} +140 -240
- package/dist/chunk-X3MICMI2.cjs.map +1 -0
- package/dist/{chunk-Y4VKB6KC.js → chunk-Z2O5YVHY.js} +121 -165
- package/dist/chunk-Z2O5YVHY.js.map +1 -0
- package/dist/{chunk-PY2K7VNW.js → chunk-ZJ6KEY6H.js} +67 -165
- package/dist/chunk-ZJ6KEY6H.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.d.ts +10 -10
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +31 -19
- package/dist/server/handlers/agent-builder.d.ts +38 -47
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +22 -30
- package/dist/server/handlers/agents.d.ts +36 -55
- package/dist/server/handlers/agents.d.ts.map +1 -1
- 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/logs.cjs +7 -7
- package/dist/server/handlers/logs.d.ts +3 -3
- package/dist/server/handlers/logs.d.ts.map +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +17 -25
- package/dist/server/handlers/memory.d.ts +28 -34
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +8 -8
- package/dist/server/handlers/observability.d.ts +12 -12
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +11 -11
- package/dist/server/handlers/scores.d.ts +24 -24
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/tools.cjs +7 -7
- package/dist/server/handlers/tools.d.ts +8 -8
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +3 -3
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.d.ts +6 -6
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +21 -29
- package/dist/server/handlers/workflows.d.ts +27 -36
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +26 -36
- package/dist/server/handlers.d.ts +0 -2
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +11 -13
- package/dist/server/http-exception.d.ts +0 -5
- package/dist/server/http-exception.d.ts.map +1 -1
- package/dist/server/utils.d.ts +3 -2
- package/dist/server/utils.d.ts.map +1 -1
- package/package.json +9 -13
- package/dist/chunk-2S4IMB6E.cjs.map +0 -1
- package/dist/chunk-3SNGNFUJ.cjs.map +0 -1
- package/dist/chunk-67GYDFSB.js +0 -160
- package/dist/chunk-67GYDFSB.js.map +0 -1
- package/dist/chunk-6ZR275MD.cjs +0 -165
- package/dist/chunk-6ZR275MD.cjs.map +0 -1
- package/dist/chunk-ABRFV4XP.js.map +0 -1
- package/dist/chunk-AHB4JCIQ.js.map +0 -1
- package/dist/chunk-AW5BU3RQ.js.map +0 -1
- package/dist/chunk-BATEJLED.js.map +0 -1
- package/dist/chunk-H33KYEMY.cjs.map +0 -1
- package/dist/chunk-HPXAM2PG.js.map +0 -1
- package/dist/chunk-I3C4ODGV.cjs +0 -335
- package/dist/chunk-I3C4ODGV.cjs.map +0 -1
- package/dist/chunk-IJSDPAUY.cjs.map +0 -1
- package/dist/chunk-LLUOPR3J.js +0 -323
- package/dist/chunk-LLUOPR3J.js.map +0 -1
- package/dist/chunk-MMROOK5J.js.map +0 -1
- package/dist/chunk-NT5XW5PI.cjs.map +0 -1
- package/dist/chunk-OQPXME7E.js.map +0 -1
- package/dist/chunk-PBXWFGEH.js.map +0 -1
- package/dist/chunk-PY2K7VNW.js.map +0 -1
- package/dist/chunk-QQXMIP6C.js.map +0 -1
- package/dist/chunk-SPRRK3P7.cjs.map +0 -1
- package/dist/chunk-TEOUDAN5.cjs.map +0 -1
- package/dist/chunk-TOP25AIO.cjs.map +0 -1
- package/dist/chunk-TRGAMKHX.cjs.map +0 -1
- package/dist/chunk-VY4ENABS.cjs.map +0 -1
- package/dist/chunk-XN74I6VW.cjs.map +0 -1
- package/dist/chunk-Y4VKB6KC.js.map +0 -1
- package/dist/chunk-YWOK4F5A.js.map +0 -1
- package/dist/server/handlers/legacyWorkflows.cjs +0 -48
- package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
- package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
- package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
- package/dist/server/handlers/legacyWorkflows.js +0 -3
- package/dist/server/handlers/legacyWorkflows.js.map +0 -1
- package/dist/server/handlers/telemetry.cjs +0 -20
- package/dist/server/handlers/telemetry.cjs.map +0 -1
- package/dist/server/handlers/telemetry.d.ts +0 -33
- package/dist/server/handlers/telemetry.d.ts.map +0 -1
- package/dist/server/handlers/telemetry.js +0 -3
- package/dist/server/handlers/telemetry.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkBTWIR2B7_cjs = require('./chunk-BTWIR2B7.cjs');
|
|
4
|
+
var chunkV5WWQN7P_cjs = require('./chunk-V5WWQN7P.cjs');
|
|
5
|
+
var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
|
|
6
6
|
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
|
|
7
|
-
var agent = require('@mastra/core/agent');
|
|
8
7
|
var di = require('@mastra/core/di');
|
|
9
8
|
var utils = require('@mastra/core/utils');
|
|
10
9
|
|
|
@@ -16,12 +15,10 @@ chunkO7I5CWRX_cjs.__export(memory_exports, {
|
|
|
16
15
|
deleteThreadHandler: () => deleteThreadHandler,
|
|
17
16
|
getMemoryConfigHandler: () => getMemoryConfigHandler,
|
|
18
17
|
getMemoryStatusHandler: () => getMemoryStatusHandler,
|
|
19
|
-
getMessagesHandler: () => getMessagesHandler,
|
|
20
|
-
getMessagesPaginatedHandler: () => getMessagesPaginatedHandler,
|
|
21
18
|
getThreadByIdHandler: () => getThreadByIdHandler,
|
|
22
|
-
getThreadsHandler: () => getThreadsHandler,
|
|
23
|
-
getThreadsPaginatedHandler: () => getThreadsPaginatedHandler,
|
|
24
19
|
getWorkingMemoryHandler: () => getWorkingMemoryHandler,
|
|
20
|
+
listMessagesHandler: () => listMessagesHandler,
|
|
21
|
+
listThreadsHandler: () => listThreadsHandler,
|
|
25
22
|
saveMessagesHandler: () => saveMessagesHandler,
|
|
26
23
|
searchMemoryHandler: () => searchMemoryHandler,
|
|
27
24
|
updateThreadHandler: () => updateThreadHandler,
|
|
@@ -30,20 +27,20 @@ chunkO7I5CWRX_cjs.__export(memory_exports, {
|
|
|
30
27
|
async function getMemoryFromContext({
|
|
31
28
|
mastra,
|
|
32
29
|
agentId,
|
|
33
|
-
|
|
30
|
+
requestContext
|
|
34
31
|
}) {
|
|
35
32
|
const logger = mastra.getLogger();
|
|
36
33
|
let agent;
|
|
37
34
|
if (agentId) {
|
|
38
35
|
try {
|
|
39
|
-
agent = mastra.
|
|
36
|
+
agent = mastra.getAgentById(agentId);
|
|
40
37
|
} catch (error) {
|
|
41
38
|
logger.debug("Error getting agent from mastra, searching agents for agent", error);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
if (agentId && !agent) {
|
|
45
42
|
logger.debug("Agent not found, searching agents for agent", { agentId });
|
|
46
|
-
const agents = mastra.
|
|
43
|
+
const agents = mastra.listAgents();
|
|
47
44
|
if (Object.keys(agents || {}).length) {
|
|
48
45
|
for (const [_, ag] of Object.entries(agents)) {
|
|
49
46
|
try {
|
|
@@ -58,140 +55,113 @@ async function getMemoryFromContext({
|
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
if (!agent) {
|
|
61
|
-
throw new
|
|
58
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
if (agent) {
|
|
65
62
|
return await agent?.getMemory({
|
|
66
|
-
|
|
67
|
-
})
|
|
63
|
+
requestContext: requestContext ?? new di.RequestContext()
|
|
64
|
+
});
|
|
68
65
|
}
|
|
69
|
-
return mastra.getMemory();
|
|
70
66
|
}
|
|
71
67
|
async function getMemoryStatusHandler({
|
|
72
68
|
mastra,
|
|
73
69
|
agentId,
|
|
74
|
-
|
|
70
|
+
requestContext
|
|
75
71
|
}) {
|
|
76
72
|
try {
|
|
77
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
73
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
78
74
|
if (!memory) {
|
|
79
75
|
return { result: false };
|
|
80
76
|
}
|
|
81
77
|
return { result: true };
|
|
82
78
|
} catch (error) {
|
|
83
|
-
return
|
|
79
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error getting memory status");
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
82
|
async function getMemoryConfigHandler({
|
|
87
83
|
mastra,
|
|
88
84
|
agentId,
|
|
89
|
-
|
|
85
|
+
requestContext
|
|
90
86
|
}) {
|
|
91
87
|
try {
|
|
92
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
88
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
93
89
|
if (!memory) {
|
|
94
|
-
throw new
|
|
90
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
95
91
|
}
|
|
96
92
|
const config = memory.getMergedThreadConfig({});
|
|
97
93
|
return { config };
|
|
98
94
|
} catch (error) {
|
|
99
|
-
return
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async function getThreadsHandler({
|
|
103
|
-
mastra,
|
|
104
|
-
agentId,
|
|
105
|
-
resourceId,
|
|
106
|
-
runtimeContext,
|
|
107
|
-
orderBy,
|
|
108
|
-
sortDirection
|
|
109
|
-
}) {
|
|
110
|
-
try {
|
|
111
|
-
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
112
|
-
if (!memory) {
|
|
113
|
-
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
114
|
-
}
|
|
115
|
-
chunkG4PUALCE_cjs.validateBody({ resourceId });
|
|
116
|
-
const threads = await memory.getThreadsByResourceId({
|
|
117
|
-
resourceId,
|
|
118
|
-
orderBy,
|
|
119
|
-
sortDirection
|
|
120
|
-
});
|
|
121
|
-
return threads;
|
|
122
|
-
} catch (error) {
|
|
123
|
-
return chunkRE4RPXT2_cjs.handleError(error, "Error getting threads");
|
|
95
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error getting memory configuration");
|
|
124
96
|
}
|
|
125
97
|
}
|
|
126
|
-
async function
|
|
98
|
+
async function listThreadsHandler({
|
|
127
99
|
mastra,
|
|
128
100
|
agentId,
|
|
129
101
|
resourceId,
|
|
130
|
-
|
|
102
|
+
requestContext,
|
|
131
103
|
page,
|
|
132
104
|
perPage,
|
|
133
|
-
orderBy
|
|
134
|
-
sortDirection
|
|
105
|
+
orderBy
|
|
135
106
|
}) {
|
|
136
107
|
try {
|
|
137
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
108
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
138
109
|
if (!memory) {
|
|
139
|
-
throw new
|
|
110
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
140
111
|
}
|
|
141
|
-
|
|
142
|
-
const result = await memory.
|
|
112
|
+
chunkBTWIR2B7_cjs.validateBody({ resourceId });
|
|
113
|
+
const result = await memory.listThreadsByResourceId({
|
|
143
114
|
resourceId,
|
|
144
115
|
page,
|
|
145
116
|
perPage,
|
|
146
|
-
orderBy
|
|
147
|
-
sortDirection
|
|
117
|
+
orderBy
|
|
148
118
|
});
|
|
149
119
|
return result;
|
|
150
120
|
} catch (error) {
|
|
151
|
-
return
|
|
121
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error listing threads");
|
|
152
122
|
}
|
|
153
123
|
}
|
|
154
124
|
async function getThreadByIdHandler({
|
|
155
125
|
mastra,
|
|
156
126
|
agentId,
|
|
157
127
|
threadId,
|
|
158
|
-
|
|
128
|
+
requestContext
|
|
159
129
|
}) {
|
|
160
130
|
try {
|
|
161
|
-
|
|
162
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
131
|
+
chunkBTWIR2B7_cjs.validateBody({ threadId });
|
|
132
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
163
133
|
if (!memory) {
|
|
164
|
-
throw new
|
|
134
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
165
135
|
}
|
|
166
136
|
const thread = await memory.getThreadById({ threadId });
|
|
167
137
|
if (!thread) {
|
|
168
|
-
throw new
|
|
138
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
169
139
|
}
|
|
170
140
|
return thread;
|
|
171
141
|
} catch (error) {
|
|
172
|
-
return
|
|
142
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error getting thread");
|
|
173
143
|
}
|
|
174
144
|
}
|
|
175
145
|
async function saveMessagesHandler({
|
|
176
146
|
mastra,
|
|
177
147
|
agentId,
|
|
178
148
|
body,
|
|
179
|
-
|
|
149
|
+
requestContext
|
|
180
150
|
}) {
|
|
181
151
|
try {
|
|
182
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
152
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
183
153
|
if (!memory) {
|
|
184
|
-
throw new
|
|
154
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
185
155
|
}
|
|
186
156
|
if (!body?.messages) {
|
|
187
|
-
throw new
|
|
157
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
188
158
|
}
|
|
189
159
|
if (!Array.isArray(body.messages)) {
|
|
190
|
-
throw new
|
|
160
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
191
161
|
}
|
|
192
162
|
const invalidMessages = body.messages.filter((message) => !message.threadId || !message.resourceId);
|
|
193
163
|
if (invalidMessages.length > 0) {
|
|
194
|
-
throw new
|
|
164
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, {
|
|
195
165
|
message: `All messages must have threadId and resourceId fields. Found ${invalidMessages.length} invalid message(s).`
|
|
196
166
|
});
|
|
197
167
|
}
|
|
@@ -203,21 +173,21 @@ async function saveMessagesHandler({
|
|
|
203
173
|
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
204
174
|
return result;
|
|
205
175
|
} catch (error) {
|
|
206
|
-
return
|
|
176
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error saving messages");
|
|
207
177
|
}
|
|
208
178
|
}
|
|
209
179
|
async function createThreadHandler({
|
|
210
180
|
mastra,
|
|
211
181
|
agentId,
|
|
212
182
|
body,
|
|
213
|
-
|
|
183
|
+
requestContext
|
|
214
184
|
}) {
|
|
215
185
|
try {
|
|
216
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
186
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
217
187
|
if (!memory) {
|
|
218
|
-
throw new
|
|
188
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
219
189
|
}
|
|
220
|
-
|
|
190
|
+
chunkBTWIR2B7_cjs.validateBody({ resourceId: body?.resourceId });
|
|
221
191
|
const result = await memory.createThread({
|
|
222
192
|
resourceId: body?.resourceId,
|
|
223
193
|
title: body?.title,
|
|
@@ -226,7 +196,7 @@ async function createThreadHandler({
|
|
|
226
196
|
});
|
|
227
197
|
return result;
|
|
228
198
|
} catch (error) {
|
|
229
|
-
return
|
|
199
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error saving thread to memory");
|
|
230
200
|
}
|
|
231
201
|
}
|
|
232
202
|
async function updateThreadHandler({
|
|
@@ -234,22 +204,22 @@ async function updateThreadHandler({
|
|
|
234
204
|
agentId,
|
|
235
205
|
threadId,
|
|
236
206
|
body,
|
|
237
|
-
|
|
207
|
+
requestContext
|
|
238
208
|
}) {
|
|
239
209
|
try {
|
|
240
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
210
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
241
211
|
if (!body) {
|
|
242
|
-
throw new
|
|
212
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Body is required" });
|
|
243
213
|
}
|
|
244
214
|
const { title, metadata, resourceId } = body;
|
|
245
215
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
246
|
-
|
|
216
|
+
chunkBTWIR2B7_cjs.validateBody({ threadId });
|
|
247
217
|
if (!memory) {
|
|
248
|
-
throw new
|
|
218
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
249
219
|
}
|
|
250
220
|
const thread = await memory.getThreadById({ threadId });
|
|
251
221
|
if (!thread) {
|
|
252
|
-
throw new
|
|
222
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
253
223
|
}
|
|
254
224
|
const updatedThread = {
|
|
255
225
|
...thread,
|
|
@@ -262,82 +232,68 @@ async function updateThreadHandler({
|
|
|
262
232
|
const result = await memory.saveThread({ thread: updatedThread });
|
|
263
233
|
return result;
|
|
264
234
|
} catch (error) {
|
|
265
|
-
return
|
|
235
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error updating thread");
|
|
266
236
|
}
|
|
267
237
|
}
|
|
268
238
|
async function deleteThreadHandler({
|
|
269
239
|
mastra,
|
|
270
240
|
agentId,
|
|
271
241
|
threadId,
|
|
272
|
-
|
|
242
|
+
requestContext
|
|
273
243
|
}) {
|
|
274
244
|
try {
|
|
275
|
-
|
|
276
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
245
|
+
chunkBTWIR2B7_cjs.validateBody({ threadId });
|
|
246
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
277
247
|
if (!memory) {
|
|
278
|
-
throw new
|
|
248
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
279
249
|
}
|
|
280
250
|
const thread = await memory.getThreadById({ threadId });
|
|
281
251
|
if (!thread) {
|
|
282
|
-
throw new
|
|
252
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
283
253
|
}
|
|
284
254
|
await memory.deleteThread(threadId);
|
|
285
255
|
return { result: "Thread deleted" };
|
|
286
256
|
} catch (error) {
|
|
287
|
-
return
|
|
257
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error deleting thread");
|
|
288
258
|
}
|
|
289
259
|
}
|
|
290
|
-
async function
|
|
291
|
-
mastra,
|
|
292
|
-
threadId,
|
|
293
|
-
resourceId,
|
|
294
|
-
selectBy,
|
|
295
|
-
format
|
|
296
|
-
}) {
|
|
297
|
-
try {
|
|
298
|
-
chunkG4PUALCE_cjs.validateBody({ threadId });
|
|
299
|
-
const storage = mastra.getStorage();
|
|
300
|
-
if (!storage) {
|
|
301
|
-
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Storage is not initialized" });
|
|
302
|
-
}
|
|
303
|
-
const thread = await storage.getThreadById({ threadId });
|
|
304
|
-
if (!thread) {
|
|
305
|
-
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Thread not found" });
|
|
306
|
-
}
|
|
307
|
-
const result = await storage.getMessagesPaginated({ threadId, resourceId, selectBy, format });
|
|
308
|
-
return result;
|
|
309
|
-
} catch (error) {
|
|
310
|
-
return chunkRE4RPXT2_cjs.handleError(error, "Error getting messages");
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async function getMessagesHandler({
|
|
260
|
+
async function listMessagesHandler({
|
|
314
261
|
mastra,
|
|
315
262
|
agentId,
|
|
316
263
|
threadId,
|
|
317
|
-
|
|
318
|
-
|
|
264
|
+
resourceId,
|
|
265
|
+
perPage,
|
|
266
|
+
page,
|
|
267
|
+
orderBy,
|
|
268
|
+
include,
|
|
269
|
+
filter,
|
|
270
|
+
requestContext
|
|
319
271
|
}) {
|
|
320
|
-
if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
|
|
321
|
-
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
|
|
322
|
-
}
|
|
323
272
|
try {
|
|
324
|
-
|
|
325
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
273
|
+
chunkBTWIR2B7_cjs.validateBody({ threadId });
|
|
274
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
326
275
|
if (!memory) {
|
|
327
|
-
throw new
|
|
276
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
277
|
+
}
|
|
278
|
+
if (!threadId) {
|
|
279
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "No threadId found" });
|
|
328
280
|
}
|
|
329
281
|
const thread = await memory.getThreadById({ threadId });
|
|
330
282
|
if (!thread) {
|
|
331
|
-
throw new
|
|
283
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
332
284
|
}
|
|
333
|
-
const result = await memory.
|
|
285
|
+
const result = await memory.recall({
|
|
334
286
|
threadId,
|
|
335
|
-
|
|
287
|
+
resourceId,
|
|
288
|
+
perPage,
|
|
289
|
+
page,
|
|
290
|
+
orderBy,
|
|
291
|
+
include,
|
|
292
|
+
filter
|
|
336
293
|
});
|
|
337
|
-
|
|
338
|
-
return { messages: result.messages, uiMessages, legacyMessages: result.uiMessages };
|
|
294
|
+
return result;
|
|
339
295
|
} catch (error) {
|
|
340
|
-
return
|
|
296
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error getting messages");
|
|
341
297
|
}
|
|
342
298
|
}
|
|
343
299
|
async function getWorkingMemoryHandler({
|
|
@@ -345,14 +301,14 @@ async function getWorkingMemoryHandler({
|
|
|
345
301
|
agentId,
|
|
346
302
|
threadId,
|
|
347
303
|
resourceId,
|
|
348
|
-
|
|
304
|
+
requestContext,
|
|
349
305
|
memoryConfig
|
|
350
306
|
}) {
|
|
351
307
|
try {
|
|
352
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
353
|
-
|
|
308
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
309
|
+
chunkBTWIR2B7_cjs.validateBody({ threadId });
|
|
354
310
|
if (!memory) {
|
|
355
|
-
throw new
|
|
311
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
356
312
|
}
|
|
357
313
|
const thread = await memory.getThreadById({ threadId });
|
|
358
314
|
const threadExists = !!thread;
|
|
@@ -360,10 +316,10 @@ async function getWorkingMemoryHandler({
|
|
|
360
316
|
const workingMemoryTemplate = template?.format === "json" ? { ...template, content: JSON.stringify(utils.generateEmptyFromSchema(template.content)) } : template;
|
|
361
317
|
const workingMemory = await memory.getWorkingMemory({ threadId, resourceId, memoryConfig });
|
|
362
318
|
const config = memory.getMergedThreadConfig(memoryConfig || {});
|
|
363
|
-
const source = config.workingMemory?.scope
|
|
319
|
+
const source = config.workingMemory?.scope !== "thread" && resourceId ? "resource" : "thread";
|
|
364
320
|
return { workingMemory, source, workingMemoryTemplate, threadExists };
|
|
365
321
|
} catch (error) {
|
|
366
|
-
return
|
|
322
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error getting working memory");
|
|
367
323
|
}
|
|
368
324
|
}
|
|
369
325
|
async function updateWorkingMemoryHandler({
|
|
@@ -371,38 +327,38 @@ async function updateWorkingMemoryHandler({
|
|
|
371
327
|
agentId,
|
|
372
328
|
threadId,
|
|
373
329
|
body,
|
|
374
|
-
|
|
330
|
+
requestContext
|
|
375
331
|
}) {
|
|
376
332
|
try {
|
|
377
|
-
|
|
378
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
333
|
+
chunkBTWIR2B7_cjs.validateBody({ threadId });
|
|
334
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
379
335
|
const { resourceId, memoryConfig, workingMemory } = body;
|
|
380
336
|
if (!memory) {
|
|
381
|
-
throw new
|
|
337
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
382
338
|
}
|
|
383
339
|
const thread = await memory.getThreadById({ threadId });
|
|
384
340
|
if (!thread) {
|
|
385
|
-
throw new
|
|
341
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
386
342
|
}
|
|
387
343
|
await memory.updateWorkingMemory({ threadId, resourceId, workingMemory, memoryConfig });
|
|
388
344
|
return { success: true };
|
|
389
345
|
} catch (error) {
|
|
390
|
-
return
|
|
346
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error updating working memory");
|
|
391
347
|
}
|
|
392
348
|
}
|
|
393
349
|
async function deleteMessagesHandler({
|
|
394
350
|
mastra,
|
|
395
351
|
agentId,
|
|
396
352
|
messageIds,
|
|
397
|
-
|
|
353
|
+
requestContext
|
|
398
354
|
}) {
|
|
399
355
|
try {
|
|
400
356
|
if (messageIds === void 0 || messageIds === null) {
|
|
401
|
-
throw new
|
|
357
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "messageIds is required" });
|
|
402
358
|
}
|
|
403
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
359
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
404
360
|
if (!memory) {
|
|
405
|
-
throw new
|
|
361
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
406
362
|
}
|
|
407
363
|
await memory.deleteMessages(messageIds);
|
|
408
364
|
let count = 1;
|
|
@@ -411,7 +367,7 @@ async function deleteMessagesHandler({
|
|
|
411
367
|
}
|
|
412
368
|
return { success: true, message: `${count} message${count === 1 ? "" : "s"} deleted successfully` };
|
|
413
369
|
} catch (error) {
|
|
414
|
-
return
|
|
370
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error deleting messages");
|
|
415
371
|
}
|
|
416
372
|
}
|
|
417
373
|
async function searchMemoryHandler({
|
|
@@ -421,29 +377,28 @@ async function searchMemoryHandler({
|
|
|
421
377
|
resourceId,
|
|
422
378
|
threadId,
|
|
423
379
|
limit = 20,
|
|
424
|
-
|
|
380
|
+
requestContext,
|
|
425
381
|
memoryConfig
|
|
426
382
|
}) {
|
|
427
383
|
try {
|
|
428
|
-
|
|
429
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
384
|
+
chunkBTWIR2B7_cjs.validateBody({ searchQuery, resourceId });
|
|
385
|
+
const memory = await getMemoryFromContext({ mastra, agentId, requestContext });
|
|
430
386
|
if (!memory) {
|
|
431
|
-
throw new
|
|
387
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
432
388
|
}
|
|
433
389
|
const config = memory.getMergedThreadConfig(memoryConfig || {});
|
|
434
390
|
const hasSemanticRecall = !!config?.semanticRecall;
|
|
435
|
-
const resourceScope = typeof config?.semanticRecall === "object"
|
|
391
|
+
const resourceScope = typeof config?.semanticRecall === "object" ? config?.semanticRecall?.scope !== "thread" : true;
|
|
436
392
|
if (threadId && !resourceScope) {
|
|
437
393
|
const thread = await memory.getThreadById({ threadId });
|
|
438
394
|
if (!thread) {
|
|
439
|
-
throw new
|
|
395
|
+
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
440
396
|
}
|
|
441
397
|
if (thread.resourceId !== resourceId) {
|
|
442
|
-
throw new
|
|
398
|
+
throw new chunk64ITUOXI_cjs.HTTPException(403, { message: "Thread does not belong to the specified resource" });
|
|
443
399
|
}
|
|
444
400
|
}
|
|
445
401
|
const searchResults = [];
|
|
446
|
-
const messageMap = /* @__PURE__ */ new Map();
|
|
447
402
|
if (threadId && !resourceScope) {
|
|
448
403
|
const thread = await memory.getThreadById({ threadId });
|
|
449
404
|
if (!thread) {
|
|
@@ -451,117 +406,85 @@ async function searchMemoryHandler({
|
|
|
451
406
|
results: [],
|
|
452
407
|
count: 0,
|
|
453
408
|
query: searchQuery,
|
|
454
|
-
searchScope: "thread",
|
|
409
|
+
searchScope: resourceScope ? "resource" : "thread",
|
|
455
410
|
searchType: hasSemanticRecall ? "semantic" : "text"
|
|
456
411
|
};
|
|
457
412
|
}
|
|
458
413
|
}
|
|
459
|
-
if (!threadId
|
|
460
|
-
const threads = await memory.
|
|
414
|
+
if (!threadId) {
|
|
415
|
+
const { threads } = await memory.listThreadsByResourceId({
|
|
416
|
+
resourceId,
|
|
417
|
+
page: 0,
|
|
418
|
+
perPage: 1,
|
|
419
|
+
orderBy: { field: "updatedAt", direction: "DESC" }
|
|
420
|
+
});
|
|
461
421
|
if (threads.length === 0) {
|
|
462
422
|
return {
|
|
463
423
|
results: [],
|
|
464
424
|
count: 0,
|
|
465
425
|
query: searchQuery,
|
|
466
|
-
searchScope: "resource",
|
|
426
|
+
searchScope: resourceScope ? "resource" : "thread",
|
|
467
427
|
searchType: hasSemanticRecall ? "semantic" : "text"
|
|
468
428
|
};
|
|
469
429
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
430
|
+
threadId = threads[0].id;
|
|
431
|
+
}
|
|
432
|
+
const beforeRange = typeof config.semanticRecall === `boolean` ? 2 : typeof config.semanticRecall?.messageRange === `number` ? config.semanticRecall.messageRange : config.semanticRecall?.messageRange.before || 2;
|
|
433
|
+
const afterRange = typeof config.semanticRecall === `boolean` ? 2 : typeof config.semanticRecall?.messageRange === `number` ? config.semanticRecall.messageRange : config.semanticRecall?.messageRange.after || 2;
|
|
434
|
+
if (resourceScope && config.semanticRecall) {
|
|
435
|
+
config.semanticRecall = typeof config.semanticRecall === `boolean` ? (
|
|
436
|
+
// make message range 0 so we can highlight the matches in search, message range will include other messages, not the matching ones
|
|
437
|
+
// and we add prev/next messages in a special section on each message anyway
|
|
438
|
+
{ messageRange: 0, topK: 2, scope: "resource" }
|
|
439
|
+
) : { ...config.semanticRecall, messageRange: 0 };
|
|
440
|
+
}
|
|
441
|
+
const threadConfig = memory.getMergedThreadConfig(config || {});
|
|
442
|
+
if (!threadConfig.lastMessages && !threadConfig.semanticRecall) {
|
|
443
|
+
return { results: [], count: 0, query: searchQuery };
|
|
444
|
+
}
|
|
445
|
+
const result = await memory.recall({
|
|
446
|
+
threadId,
|
|
447
|
+
resourceId,
|
|
448
|
+
perPage: threadConfig.lastMessages,
|
|
449
|
+
threadConfig: config,
|
|
450
|
+
vectorSearchString: threadConfig.semanticRecall && searchQuery ? searchQuery : void 0
|
|
451
|
+
});
|
|
452
|
+
const threadIds = Array.from(
|
|
453
|
+
new Set(result.messages.map((m) => m.threadId || threadId).filter(Boolean))
|
|
454
|
+
);
|
|
455
|
+
const fetched = await Promise.all(threadIds.map((id) => memory.getThreadById({ threadId: id })));
|
|
456
|
+
const threadMap = new Map(fetched.filter(Boolean).map((t) => [t.id, t]));
|
|
457
|
+
for (const msg of result.messages) {
|
|
458
|
+
const content = typeof msg.content.content === `string` ? msg.content.content : msg.content.parts?.map((p) => p.type === "text" ? p.text : "").join(" ") || "";
|
|
459
|
+
const msgThreadId = msg.threadId || threadId;
|
|
460
|
+
const thread = threadMap.get(msgThreadId);
|
|
461
|
+
const threadMessages = (await memory.recall({ threadId: msgThreadId })).messages;
|
|
462
|
+
const messageIndex = threadMessages.findIndex((m) => m.id === msg.id);
|
|
463
|
+
const searchResult = {
|
|
464
|
+
id: msg.id,
|
|
465
|
+
role: msg.role,
|
|
466
|
+
content,
|
|
467
|
+
createdAt: msg.createdAt,
|
|
468
|
+
threadId: msgThreadId,
|
|
469
|
+
threadTitle: thread?.title || msgThreadId
|
|
470
|
+
};
|
|
471
|
+
if (messageIndex !== -1) {
|
|
472
|
+
searchResult.context = {
|
|
473
|
+
before: threadMessages.slice(Math.max(0, messageIndex - beforeRange), messageIndex).map((m) => ({
|
|
474
|
+
id: m.id,
|
|
475
|
+
role: m.role,
|
|
476
|
+
content: m.content,
|
|
477
|
+
createdAt: m.createdAt || /* @__PURE__ */ new Date()
|
|
478
|
+
})),
|
|
479
|
+
after: threadMessages.slice(messageIndex + 1, messageIndex + afterRange + 1).map((m) => ({
|
|
480
|
+
id: m.id,
|
|
481
|
+
role: m.role,
|
|
482
|
+
content: m.content,
|
|
483
|
+
createdAt: m.createdAt || /* @__PURE__ */ new Date()
|
|
484
|
+
}))
|
|
522
485
|
};
|
|
523
486
|
}
|
|
524
|
-
|
|
525
|
-
threadId,
|
|
526
|
-
resourceId,
|
|
527
|
-
vectorMessageSearch: searchQuery,
|
|
528
|
-
config
|
|
529
|
-
});
|
|
530
|
-
const threadMessages = (await memory.query({ threadId })).uiMessages;
|
|
531
|
-
result.messagesV2.forEach((msg) => {
|
|
532
|
-
if (messageMap.has(msg.id)) return;
|
|
533
|
-
messageMap.set(msg.id, true);
|
|
534
|
-
const content = msg.content.content || msg.content.parts?.map((p) => p.type === "text" ? p.text : "").join(" ") || "";
|
|
535
|
-
if (!hasSemanticRecall && !content.toLowerCase().includes(searchQuery.toLowerCase())) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
const messageIndex = threadMessages.findIndex((m) => m.id === msg.id);
|
|
539
|
-
const searchResult = {
|
|
540
|
-
id: msg.id,
|
|
541
|
-
role: msg.role,
|
|
542
|
-
content,
|
|
543
|
-
createdAt: msg.createdAt,
|
|
544
|
-
threadId,
|
|
545
|
-
threadTitle: thread?.title || threadId
|
|
546
|
-
};
|
|
547
|
-
if (messageIndex !== -1) {
|
|
548
|
-
searchResult.context = {
|
|
549
|
-
before: threadMessages.slice(Math.max(0, messageIndex - 2), messageIndex).map((m) => ({
|
|
550
|
-
id: m.id,
|
|
551
|
-
role: m.role,
|
|
552
|
-
content: m.content,
|
|
553
|
-
createdAt: m.createdAt || /* @__PURE__ */ new Date()
|
|
554
|
-
})),
|
|
555
|
-
after: threadMessages.slice(messageIndex + 1, messageIndex + 3).map((m) => ({
|
|
556
|
-
id: m.id,
|
|
557
|
-
role: m.role,
|
|
558
|
-
content: m.content,
|
|
559
|
-
createdAt: m.createdAt || /* @__PURE__ */ new Date()
|
|
560
|
-
}))
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
searchResults.push(searchResult);
|
|
564
|
-
});
|
|
487
|
+
searchResults.push(searchResult);
|
|
565
488
|
}
|
|
566
489
|
const sortedResults = searchResults.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()).slice(0, limit);
|
|
567
490
|
return {
|
|
@@ -572,7 +495,7 @@ async function searchMemoryHandler({
|
|
|
572
495
|
searchType: hasSemanticRecall ? "semantic" : "text"
|
|
573
496
|
};
|
|
574
497
|
} catch (error) {
|
|
575
|
-
return
|
|
498
|
+
return chunkV5WWQN7P_cjs.handleError(error, "Error searching memory");
|
|
576
499
|
}
|
|
577
500
|
}
|
|
578
501
|
|
|
@@ -581,16 +504,14 @@ exports.deleteMessagesHandler = deleteMessagesHandler;
|
|
|
581
504
|
exports.deleteThreadHandler = deleteThreadHandler;
|
|
582
505
|
exports.getMemoryConfigHandler = getMemoryConfigHandler;
|
|
583
506
|
exports.getMemoryStatusHandler = getMemoryStatusHandler;
|
|
584
|
-
exports.getMessagesHandler = getMessagesHandler;
|
|
585
|
-
exports.getMessagesPaginatedHandler = getMessagesPaginatedHandler;
|
|
586
507
|
exports.getThreadByIdHandler = getThreadByIdHandler;
|
|
587
|
-
exports.getThreadsHandler = getThreadsHandler;
|
|
588
|
-
exports.getThreadsPaginatedHandler = getThreadsPaginatedHandler;
|
|
589
508
|
exports.getWorkingMemoryHandler = getWorkingMemoryHandler;
|
|
509
|
+
exports.listMessagesHandler = listMessagesHandler;
|
|
510
|
+
exports.listThreadsHandler = listThreadsHandler;
|
|
590
511
|
exports.memory_exports = memory_exports;
|
|
591
512
|
exports.saveMessagesHandler = saveMessagesHandler;
|
|
592
513
|
exports.searchMemoryHandler = searchMemoryHandler;
|
|
593
514
|
exports.updateThreadHandler = updateThreadHandler;
|
|
594
515
|
exports.updateWorkingMemoryHandler = updateWorkingMemoryHandler;
|
|
595
|
-
//# sourceMappingURL=chunk-
|
|
596
|
-
//# sourceMappingURL=chunk-
|
|
516
|
+
//# sourceMappingURL=chunk-A2NPD5N6.cjs.map
|
|
517
|
+
//# sourceMappingURL=chunk-A2NPD5N6.cjs.map
|