@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.
- package/LICENSE.md +11 -42
- package/dist/_tsup-dts-rollup.d.cts +212 -23
- package/dist/_tsup-dts-rollup.d.ts +212 -23
- package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
- package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
- package/dist/{chunk-MEGCYGBU.js → chunk-36BLNJHS.js} +37 -37
- package/dist/chunk-424T5F2J.cjs +157 -0
- package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
- package/dist/{chunk-L3VURYKY.cjs → chunk-6KP2OBYA.cjs} +177 -68
- package/dist/chunk-6T5JUKOQ.js +149 -0
- package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
- package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
- package/dist/{chunk-LI436ITD.cjs → chunk-HISYIDYH.cjs} +37 -37
- package/dist/{chunk-Z3PTO2AK.cjs → chunk-HRSAZUIK.cjs} +20 -20
- package/dist/{chunk-EP3XVEVC.cjs → chunk-I5JKUCGE.cjs} +50 -20
- package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
- package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
- package/dist/chunk-R3I7AJVL.js +507 -0
- package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
- package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
- package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/{chunk-72LOJGUV.js → chunk-T7HAZC2E.js} +118 -12
- package/dist/chunk-TTPJHP42.cjs +522 -0
- package/dist/{chunk-NGHSYB5B.cjs → chunk-UCV4247U.cjs} +43 -43
- package/dist/{chunk-2BCWG3EZ.js → chunk-VTTN2FW3.js} +36 -7
- package/dist/{chunk-EWLR2PNT.js → chunk-WBRFIHSF.js} +4 -4
- package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
- package/dist/{chunk-E2LP4J6K.js → chunk-ZYAFP2AV.js} +8 -8
- package/dist/server/handlers/agents.cjs +11 -7
- package/dist/server/handlers/agents.d.cts +1 -0
- package/dist/server/handlers/agents.d.ts +1 -0
- 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 +11 -11
- package/dist/server/handlers/legacyWorkflows.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +29 -9
- package/dist/server/handlers/memory.d.cts +5 -0
- package/dist/server/handlers/memory.d.ts +5 -0
- 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/scores.cjs +30 -0
- package/dist/server/handlers/scores.d.cts +6 -0
- package/dist/server/handlers/scores.d.ts +6 -0
- package/dist/server/handlers/scores.js +1 -0
- 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 +23 -23
- package/dist/server/handlers/vNextNetwork.js +4 -4
- 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.js +1 -1
- package/dist/server/handlers/workflows.cjs +25 -13
- package/dist/server/handlers/workflows.d.cts +3 -0
- package/dist/server/handlers/workflows.d.ts +3 -0
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +28 -23
- package/dist/server/handlers.d.cts +3 -2
- package/dist/server/handlers.d.ts +3 -2
- package/dist/server/handlers.js +11 -10
- package/package.json +8 -7
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-RQ2Z56EC.cjs +0 -251
- package/dist/chunk-XUIJ7WRT.js +0 -241
package/dist/server/handlers.cjs
CHANGED
|
@@ -1,42 +1,47 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
3
|
+
var chunk6KP2OBYA_cjs = require('../chunk-6KP2OBYA.cjs');
|
|
4
|
+
var chunk2SLFAFTR_cjs = require('../chunk-2SLFAFTR.cjs');
|
|
5
|
+
var chunk424T5F2J_cjs = require('../chunk-424T5F2J.cjs');
|
|
6
|
+
var chunkG7KH752Y_cjs = require('../chunk-G7KH752Y.cjs');
|
|
7
|
+
var chunkHRSAZUIK_cjs = require('../chunk-HRSAZUIK.cjs');
|
|
8
|
+
var chunk7TP2LX5L_cjs = require('../chunk-7TP2LX5L.cjs');
|
|
9
|
+
var chunkRHSWAXKB_cjs = require('../chunk-RHSWAXKB.cjs');
|
|
9
10
|
var chunkSDPGVWQJ_cjs = require('../chunk-SDPGVWQJ.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
11
|
+
var chunkI5JKUCGE_cjs = require('../chunk-I5JKUCGE.cjs');
|
|
12
|
+
var chunkUCV4247U_cjs = require('../chunk-UCV4247U.cjs');
|
|
13
|
+
var chunkQGX47B5D_cjs = require('../chunk-QGX47B5D.cjs');
|
|
14
|
+
var chunkTTPJHP42_cjs = require('../chunk-TTPJHP42.cjs');
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
Object.defineProperty(exports, "workflows", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunk6KP2OBYA_cjs.workflows_exports; }
|
|
21
|
+
});
|
|
17
22
|
Object.defineProperty(exports, "network", {
|
|
18
23
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunk2SLFAFTR_cjs.network_exports; }
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "scores", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return chunk424T5F2J_cjs.scores_exports; }
|
|
20
29
|
});
|
|
21
30
|
Object.defineProperty(exports, "telemetry", {
|
|
22
31
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunkG7KH752Y_cjs.telemetry_exports; }
|
|
24
33
|
});
|
|
25
34
|
Object.defineProperty(exports, "tools", {
|
|
26
35
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunkHRSAZUIK_cjs.tools_exports; }
|
|
28
37
|
});
|
|
29
38
|
Object.defineProperty(exports, "vector", {
|
|
30
39
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunk7TP2LX5L_cjs.vector_exports; }
|
|
32
41
|
});
|
|
33
42
|
Object.defineProperty(exports, "voice", {
|
|
34
43
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "workflows", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () { return chunkL3VURYKY_cjs.workflows_exports; }
|
|
44
|
+
get: function () { return chunkRHSWAXKB_cjs.voice_exports; }
|
|
40
45
|
});
|
|
41
46
|
Object.defineProperty(exports, "a2a", {
|
|
42
47
|
enumerable: true,
|
|
@@ -44,17 +49,17 @@ Object.defineProperty(exports, "a2a", {
|
|
|
44
49
|
});
|
|
45
50
|
Object.defineProperty(exports, "agents", {
|
|
46
51
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
52
|
+
get: function () { return chunkI5JKUCGE_cjs.agents_exports; }
|
|
48
53
|
});
|
|
49
54
|
Object.defineProperty(exports, "legacyWorkflows", {
|
|
50
55
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
56
|
+
get: function () { return chunkUCV4247U_cjs.legacyWorkflows_exports; }
|
|
52
57
|
});
|
|
53
58
|
Object.defineProperty(exports, "logs", {
|
|
54
59
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
60
|
+
get: function () { return chunkQGX47B5D_cjs.logs_exports; }
|
|
56
61
|
});
|
|
57
62
|
Object.defineProperty(exports, "memory", {
|
|
58
63
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
64
|
+
get: function () { return chunkTTPJHP42_cjs.memory_exports; }
|
|
60
65
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { agents } from '../_tsup-dts-rollup.cjs';
|
|
2
2
|
export { a2a } from '../_tsup-dts-rollup.cjs';
|
|
3
|
+
export { legacyWorkflows } from '../_tsup-dts-rollup.cjs';
|
|
3
4
|
export { logs } from '../_tsup-dts-rollup.cjs';
|
|
4
5
|
export { memory } from '../_tsup-dts-rollup.cjs';
|
|
5
6
|
export { network } from '../_tsup-dts-rollup.cjs';
|
|
7
|
+
export { scores } from '../_tsup-dts-rollup.cjs';
|
|
6
8
|
export { telemetry } from '../_tsup-dts-rollup.cjs';
|
|
7
9
|
export { tools } from '../_tsup-dts-rollup.cjs';
|
|
8
|
-
export { legacyWorkflows } from '../_tsup-dts-rollup.cjs';
|
|
9
|
-
export { workflows } from '../_tsup-dts-rollup.cjs';
|
|
10
10
|
export { vector } from '../_tsup-dts-rollup.cjs';
|
|
11
11
|
export { voice } from '../_tsup-dts-rollup.cjs';
|
|
12
|
+
export { workflows } from '../_tsup-dts-rollup.cjs';
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { agents } from '../_tsup-dts-rollup.js';
|
|
2
2
|
export { a2a } from '../_tsup-dts-rollup.js';
|
|
3
|
+
export { legacyWorkflows } from '../_tsup-dts-rollup.js';
|
|
3
4
|
export { logs } from '../_tsup-dts-rollup.js';
|
|
4
5
|
export { memory } from '../_tsup-dts-rollup.js';
|
|
5
6
|
export { network } from '../_tsup-dts-rollup.js';
|
|
7
|
+
export { scores } from '../_tsup-dts-rollup.js';
|
|
6
8
|
export { telemetry } from '../_tsup-dts-rollup.js';
|
|
7
9
|
export { tools } from '../_tsup-dts-rollup.js';
|
|
8
|
-
export { legacyWorkflows } from '../_tsup-dts-rollup.js';
|
|
9
|
-
export { workflows } from '../_tsup-dts-rollup.js';
|
|
10
10
|
export { vector } from '../_tsup-dts-rollup.js';
|
|
11
11
|
export { voice } from '../_tsup-dts-rollup.js';
|
|
12
|
+
export { workflows } from '../_tsup-dts-rollup.js';
|
package/dist/server/handlers.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
export { workflows_exports as workflows } from '../chunk-T7HAZC2E.js';
|
|
2
|
+
export { network_exports as network } from '../chunk-CRCR3ZUK.js';
|
|
3
|
+
export { scores_exports as scores } from '../chunk-6T5JUKOQ.js';
|
|
4
|
+
export { telemetry_exports as telemetry } from '../chunk-RG473F6Y.js';
|
|
5
|
+
export { tools_exports as tools } from '../chunk-WBRFIHSF.js';
|
|
6
|
+
export { vector_exports as vector } from '../chunk-WNVFNNWN.js';
|
|
7
|
+
export { voice_exports as voice } from '../chunk-KHZKYUNR.js';
|
|
7
8
|
export { a2a_exports as a2a } from '../chunk-GHC4YV6R.js';
|
|
8
|
-
export { agents_exports as agents } from '../chunk-
|
|
9
|
-
export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-
|
|
10
|
-
export { logs_exports as logs } from '../chunk-
|
|
11
|
-
export { memory_exports as memory } from '../chunk-
|
|
9
|
+
export { agents_exports as agents } from '../chunk-VTTN2FW3.js';
|
|
10
|
+
export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-ZYAFP2AV.js';
|
|
11
|
+
export { logs_exports as logs } from '../chunk-4D66QEKC.js';
|
|
12
|
+
export { memory_exports as memory } from '../chunk-R3I7AJVL.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/server",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-transpile-packages-20250730132657",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -43,24 +43,25 @@
|
|
|
43
43
|
},
|
|
44
44
|
"keywords": [],
|
|
45
45
|
"author": "",
|
|
46
|
-
"license": "
|
|
46
|
+
"license": "Apache-2.0",
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"zod": "^3.0.0",
|
|
49
|
-
"@mastra/core": "0.0.0-
|
|
49
|
+
"@mastra/core": "0.0.0-transpile-packages-20250730132657"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@ai-sdk/openai": "^1.3.22",
|
|
53
53
|
"@microsoft/api-extractor": "^7.52.8",
|
|
54
54
|
"@types/node": "^20.19.0",
|
|
55
|
-
"eslint": "^9.
|
|
55
|
+
"eslint": "^9.30.1",
|
|
56
56
|
"superjson": "^2.2.2",
|
|
57
57
|
"tsup": "^8.5.0",
|
|
58
58
|
"typescript": "^5.8.3",
|
|
59
|
-
"vitest": "^2.
|
|
59
|
+
"vitest": "^3.2.4",
|
|
60
60
|
"zod": "^3.25.67",
|
|
61
61
|
"zod-to-json-schema": "^3.24.5",
|
|
62
|
-
"@internal/lint": "0.0.0-
|
|
63
|
-
"@
|
|
62
|
+
"@internal/lint": "0.0.0-transpile-packages-20250730132657",
|
|
63
|
+
"@internal/storage-test-utils": "0.0.19",
|
|
64
|
+
"@mastra/core": "0.0.0-transpile-packages-20250730132657"
|
|
64
65
|
},
|
|
65
66
|
"scripts": {
|
|
66
67
|
"build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",
|
package/dist/chunk-64U3UDTH.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
4
|
-
|
|
5
|
-
// src/server/handlers/error.ts
|
|
6
|
-
function handleError(error, defaultMessage) {
|
|
7
|
-
const apiError = error;
|
|
8
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(apiError.status || 500, {
|
|
9
|
-
message: apiError.message || defaultMessage
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
exports.handleError = handleError;
|
package/dist/chunk-M5ABIP7D.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
2
|
-
|
|
3
|
-
// src/server/handlers/error.ts
|
|
4
|
-
function handleError(error, defaultMessage) {
|
|
5
|
-
const apiError = error;
|
|
6
|
-
throw new HTTPException(apiError.status || 500, {
|
|
7
|
-
message: apiError.message || defaultMessage
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { handleError };
|
package/dist/chunk-RQ2Z56EC.cjs
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
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');
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/memory.ts
|
|
9
|
-
var memory_exports = {};
|
|
10
|
-
chunk75ZPJI57_cjs.__export(memory_exports, {
|
|
11
|
-
createThreadHandler: () => createThreadHandler,
|
|
12
|
-
deleteThreadHandler: () => deleteThreadHandler,
|
|
13
|
-
getMemoryStatusHandler: () => getMemoryStatusHandler,
|
|
14
|
-
getMessagesHandler: () => getMessagesHandler,
|
|
15
|
-
getThreadByIdHandler: () => getThreadByIdHandler,
|
|
16
|
-
getThreadsHandler: () => getThreadsHandler,
|
|
17
|
-
saveMessagesHandler: () => saveMessagesHandler,
|
|
18
|
-
updateThreadHandler: () => updateThreadHandler
|
|
19
|
-
});
|
|
20
|
-
async function getMemoryFromContext({
|
|
21
|
-
mastra,
|
|
22
|
-
agentId,
|
|
23
|
-
networkId,
|
|
24
|
-
runtimeContext
|
|
25
|
-
}) {
|
|
26
|
-
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
27
|
-
if (agentId && !agent) {
|
|
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();
|
|
39
|
-
}
|
|
40
|
-
return mastra.getMemory();
|
|
41
|
-
}
|
|
42
|
-
async function getMemoryStatusHandler({
|
|
43
|
-
mastra,
|
|
44
|
-
agentId,
|
|
45
|
-
networkId,
|
|
46
|
-
runtimeContext
|
|
47
|
-
}) {
|
|
48
|
-
try {
|
|
49
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
50
|
-
if (!memory) {
|
|
51
|
-
return { result: false };
|
|
52
|
-
}
|
|
53
|
-
return { result: true };
|
|
54
|
-
} catch (error) {
|
|
55
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
async function getThreadsHandler({
|
|
59
|
-
mastra,
|
|
60
|
-
agentId,
|
|
61
|
-
resourceId,
|
|
62
|
-
networkId,
|
|
63
|
-
runtimeContext
|
|
64
|
-
}) {
|
|
65
|
-
try {
|
|
66
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
67
|
-
if (!memory) {
|
|
68
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
69
|
-
}
|
|
70
|
-
chunk57CJTIPW_cjs.validateBody({ resourceId });
|
|
71
|
-
const threads = await memory.getThreadsByResourceId({ resourceId });
|
|
72
|
-
return threads;
|
|
73
|
-
} catch (error) {
|
|
74
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
async function getThreadByIdHandler({
|
|
78
|
-
mastra,
|
|
79
|
-
agentId,
|
|
80
|
-
threadId,
|
|
81
|
-
networkId,
|
|
82
|
-
runtimeContext
|
|
83
|
-
}) {
|
|
84
|
-
try {
|
|
85
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
86
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
87
|
-
if (!memory) {
|
|
88
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
89
|
-
}
|
|
90
|
-
const thread = await memory.getThreadById({ threadId });
|
|
91
|
-
if (!thread) {
|
|
92
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
93
|
-
}
|
|
94
|
-
return thread;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async function saveMessagesHandler({
|
|
100
|
-
mastra,
|
|
101
|
-
agentId,
|
|
102
|
-
body,
|
|
103
|
-
networkId,
|
|
104
|
-
runtimeContext
|
|
105
|
-
}) {
|
|
106
|
-
try {
|
|
107
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
108
|
-
if (!memory) {
|
|
109
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
110
|
-
}
|
|
111
|
-
if (!body?.messages) {
|
|
112
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
113
|
-
}
|
|
114
|
-
if (!Array.isArray(body.messages)) {
|
|
115
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
116
|
-
}
|
|
117
|
-
const processedMessages = body.messages.map((message) => ({
|
|
118
|
-
...message,
|
|
119
|
-
id: memory.generateId(),
|
|
120
|
-
createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
|
|
121
|
-
}));
|
|
122
|
-
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
123
|
-
return result;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function createThreadHandler({
|
|
129
|
-
mastra,
|
|
130
|
-
agentId,
|
|
131
|
-
body,
|
|
132
|
-
networkId,
|
|
133
|
-
runtimeContext
|
|
134
|
-
}) {
|
|
135
|
-
try {
|
|
136
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
137
|
-
if (!memory) {
|
|
138
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
139
|
-
}
|
|
140
|
-
chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
|
|
141
|
-
const result = await memory.createThread({
|
|
142
|
-
resourceId: body?.resourceId,
|
|
143
|
-
title: body?.title,
|
|
144
|
-
metadata: body?.metadata,
|
|
145
|
-
threadId: body?.threadId
|
|
146
|
-
});
|
|
147
|
-
return result;
|
|
148
|
-
} catch (error) {
|
|
149
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async function updateThreadHandler({
|
|
153
|
-
mastra,
|
|
154
|
-
agentId,
|
|
155
|
-
threadId,
|
|
156
|
-
body,
|
|
157
|
-
networkId,
|
|
158
|
-
runtimeContext
|
|
159
|
-
}) {
|
|
160
|
-
try {
|
|
161
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
162
|
-
if (!body) {
|
|
163
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
|
|
164
|
-
}
|
|
165
|
-
const { title, metadata, resourceId } = body;
|
|
166
|
-
const updatedAt = /* @__PURE__ */ new Date();
|
|
167
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
168
|
-
if (!memory) {
|
|
169
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
170
|
-
}
|
|
171
|
-
const thread = await memory.getThreadById({ threadId });
|
|
172
|
-
if (!thread) {
|
|
173
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
174
|
-
}
|
|
175
|
-
const updatedThread = {
|
|
176
|
-
...thread,
|
|
177
|
-
title: title || thread.title,
|
|
178
|
-
metadata: metadata || thread.metadata,
|
|
179
|
-
resourceId: resourceId || thread.resourceId,
|
|
180
|
-
createdAt: thread.createdAt,
|
|
181
|
-
updatedAt
|
|
182
|
-
};
|
|
183
|
-
const result = await memory.saveThread({ thread: updatedThread });
|
|
184
|
-
return result;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
async function deleteThreadHandler({
|
|
190
|
-
mastra,
|
|
191
|
-
agentId,
|
|
192
|
-
threadId,
|
|
193
|
-
networkId,
|
|
194
|
-
runtimeContext
|
|
195
|
-
}) {
|
|
196
|
-
try {
|
|
197
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
198
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
199
|
-
if (!memory) {
|
|
200
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
201
|
-
}
|
|
202
|
-
const thread = await memory.getThreadById({ threadId });
|
|
203
|
-
if (!thread) {
|
|
204
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
205
|
-
}
|
|
206
|
-
await memory.deleteThread(threadId);
|
|
207
|
-
return { result: "Thread deleted" };
|
|
208
|
-
} catch (error) {
|
|
209
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
async function getMessagesHandler({
|
|
213
|
-
mastra,
|
|
214
|
-
agentId,
|
|
215
|
-
threadId,
|
|
216
|
-
limit,
|
|
217
|
-
networkId,
|
|
218
|
-
runtimeContext
|
|
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
|
-
}
|
|
223
|
-
try {
|
|
224
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
225
|
-
const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
|
|
226
|
-
if (!memory) {
|
|
227
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
228
|
-
}
|
|
229
|
-
const thread = await memory.getThreadById({ threadId });
|
|
230
|
-
if (!thread) {
|
|
231
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
232
|
-
}
|
|
233
|
-
const result = await memory.query({
|
|
234
|
-
threadId,
|
|
235
|
-
...limit && { selectBy: { last: limit } }
|
|
236
|
-
});
|
|
237
|
-
return { messages: result.messages, uiMessages: result.uiMessages };
|
|
238
|
-
} catch (error) {
|
|
239
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
exports.createThreadHandler = createThreadHandler;
|
|
244
|
-
exports.deleteThreadHandler = deleteThreadHandler;
|
|
245
|
-
exports.getMemoryStatusHandler = getMemoryStatusHandler;
|
|
246
|
-
exports.getMessagesHandler = getMessagesHandler;
|
|
247
|
-
exports.getThreadByIdHandler = getThreadByIdHandler;
|
|
248
|
-
exports.getThreadsHandler = getThreadsHandler;
|
|
249
|
-
exports.memory_exports = memory_exports;
|
|
250
|
-
exports.saveMessagesHandler = saveMessagesHandler;
|
|
251
|
-
exports.updateThreadHandler = updateThreadHandler;
|