@mastra/server 0.0.0-ai-v5-20250626003446 → 0.0.0-ai-v5-20250718021026
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 +265 -22
- package/dist/_tsup-dts-rollup.d.ts +265 -22
- package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
- package/dist/{chunk-5BKZNI2F.cjs → chunk-34GEZJPU.cjs} +29 -23
- package/dist/{chunk-TGJMNUYJ.js → chunk-36BLNJHS.js} +108 -70
- package/dist/{chunk-XUTX4CAB.cjs → chunk-3TMDONWY.cjs} +154 -75
- package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
- package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
- package/dist/{chunk-P54JFWUD.js → chunk-BYCOGHDE.js} +3 -3
- package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
- package/dist/{chunk-I3FR2N5I.cjs → chunk-HAGPF7OS.cjs} +12 -12
- package/dist/{chunk-ASKESBJW.cjs → chunk-HISYIDYH.cjs} +107 -69
- package/dist/{chunk-NGURCFEJ.cjs → chunk-HRSAZUIK.cjs} +20 -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-BSUAZLUK.js → chunk-N6KVUULV.js} +110 -25
- package/dist/{chunk-2XXCPCYB.js → chunk-OKL5JVWU.js} +15 -9
- package/dist/{chunk-3CSC35VL.js → chunk-ORHUZSM2.js} +96 -19
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
- 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-WE32JG64.cjs → chunk-UCV4247U.cjs} +43 -43
- package/dist/chunk-VDTQM2M5.cjs +321 -0
- package/dist/{chunk-2HXKRRNS.js → chunk-WBRFIHSF.js} +4 -4
- package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
- package/dist/{chunk-CLYX4KLH.js → chunk-ZYAFP2AV.js} +8 -8
- 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 +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 +17 -9
- package/dist/server/handlers/memory.d.cts +2 -0
- package/dist/server/handlers/memory.d.ts +2 -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/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 +5 -5
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +21 -13
- package/dist/server/handlers/workflows.d.cts +2 -0
- package/dist/server/handlers/workflows.d.ts +2 -0
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +20 -20
- package/dist/server/handlers.js +10 -10
- package/package.json +9 -9
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-PADRC33G.cjs +0 -234
|
@@ -10,3 +10,5 @@ export { streamWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
|
10
10
|
export { resumeAsyncWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
11
11
|
export { resumeWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
12
12
|
export { getWorkflowRunsHandler } from '../../_tsup-dts-rollup.js';
|
|
13
|
+
export { cancelWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
|
|
14
|
+
export { sendWorkflowRunEventHandler } from '../../_tsup-dts-rollup.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler } from '../../chunk-
|
|
1
|
+
export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, sendWorkflowRunEventHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler } from '../../chunk-ORHUZSM2.js';
|
package/dist/server/handlers.cjs
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
3
|
+
var chunkHAGPF7OS_cjs = require('../chunk-HAGPF7OS.cjs');
|
|
4
|
+
var chunkG7KH752Y_cjs = require('../chunk-G7KH752Y.cjs');
|
|
5
|
+
var chunkHRSAZUIK_cjs = require('../chunk-HRSAZUIK.cjs');
|
|
6
|
+
var chunk7TP2LX5L_cjs = require('../chunk-7TP2LX5L.cjs');
|
|
7
|
+
var chunkRHSWAXKB_cjs = require('../chunk-RHSWAXKB.cjs');
|
|
8
|
+
var chunk3TMDONWY_cjs = require('../chunk-3TMDONWY.cjs');
|
|
9
9
|
var chunkT7WA465P_cjs = require('../chunk-T7WA465P.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
10
|
+
var chunk34GEZJPU_cjs = require('../chunk-34GEZJPU.cjs');
|
|
11
|
+
var chunkUCV4247U_cjs = require('../chunk-UCV4247U.cjs');
|
|
12
|
+
var chunkQGX47B5D_cjs = require('../chunk-QGX47B5D.cjs');
|
|
13
|
+
var chunkVDTQM2M5_cjs = require('../chunk-VDTQM2M5.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, "network", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkHAGPF7OS_cjs.network_exports; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "telemetry", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkG7KH752Y_cjs.telemetry_exports; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "tools", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkHRSAZUIK_cjs.tools_exports; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "vector", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunk7TP2LX5L_cjs.vector_exports; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "voice", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkRHSWAXKB_cjs.voice_exports; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "workflows", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunk3TMDONWY_cjs.workflows_exports; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "a2a", {
|
|
42
42
|
enumerable: true,
|
|
@@ -44,17 +44,17 @@ Object.defineProperty(exports, "a2a", {
|
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "agents", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunk34GEZJPU_cjs.agents_exports; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "legacyWorkflows", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkUCV4247U_cjs.legacyWorkflows_exports; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "logs", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkQGX47B5D_cjs.logs_exports; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "memory", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkVDTQM2M5_cjs.memory_exports; }
|
|
60
60
|
});
|
package/dist/server/handlers.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { network_exports as network } from '../chunk-
|
|
2
|
-
export { telemetry_exports as telemetry } from '../chunk-
|
|
3
|
-
export { tools_exports as tools } from '../chunk-
|
|
4
|
-
export { vector_exports as vector } from '../chunk-
|
|
5
|
-
export { voice_exports as voice } from '../chunk-
|
|
6
|
-
export { workflows_exports as workflows } from '../chunk-
|
|
1
|
+
export { network_exports as network } from '../chunk-BYCOGHDE.js';
|
|
2
|
+
export { telemetry_exports as telemetry } from '../chunk-RG473F6Y.js';
|
|
3
|
+
export { tools_exports as tools } from '../chunk-WBRFIHSF.js';
|
|
4
|
+
export { vector_exports as vector } from '../chunk-WNVFNNWN.js';
|
|
5
|
+
export { voice_exports as voice } from '../chunk-KHZKYUNR.js';
|
|
6
|
+
export { workflows_exports as workflows } from '../chunk-ORHUZSM2.js';
|
|
7
7
|
export { a2a_exports as a2a } from '../chunk-B36R2PHA.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-
|
|
8
|
+
export { agents_exports as agents } from '../chunk-OKL5JVWU.js';
|
|
9
|
+
export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-ZYAFP2AV.js';
|
|
10
|
+
export { logs_exports as logs } from '../chunk-4D66QEKC.js';
|
|
11
|
+
export { memory_exports as memory } from '../chunk-N6KVUULV.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/server",
|
|
3
|
-
"version": "0.0.0-ai-v5-
|
|
3
|
+
"version": "0.0.0-ai-v5-20250718021026",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -43,24 +43,24 @@
|
|
|
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-ai-v5-
|
|
49
|
+
"@mastra/core": "0.0.0-ai-v5-20250718021026"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@ai-sdk/openai": "2.0.0-beta.
|
|
52
|
+
"@ai-sdk/openai": "2.0.0-beta.6",
|
|
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.
|
|
60
|
-
"zod": "^3.25.
|
|
59
|
+
"vitest": "^3.2.4",
|
|
60
|
+
"zod": "^3.25.67",
|
|
61
61
|
"zod-to-json-schema": "^3.24.5",
|
|
62
|
-
"@internal/lint": "0.0.0-ai-v5-
|
|
63
|
-
"@mastra/core": "0.0.0-ai-v5-
|
|
62
|
+
"@internal/lint": "0.0.0-ai-v5-20250718021026",
|
|
63
|
+
"@mastra/core": "0.0.0-ai-v5-20250718021026"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"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-PADRC33G.cjs
DELETED
|
@@ -1,234 +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
|
-
function getMemoryFromContext({
|
|
21
|
-
mastra,
|
|
22
|
-
agentId
|
|
23
|
-
}) {
|
|
24
|
-
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
25
|
-
if (agentId && !agent) {
|
|
26
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
27
|
-
}
|
|
28
|
-
const memory = agent?.getMemory?.() || mastra.getMemory();
|
|
29
|
-
return memory;
|
|
30
|
-
}
|
|
31
|
-
async function getMemoryStatusHandler({ mastra, agentId }) {
|
|
32
|
-
try {
|
|
33
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
34
|
-
if (!memory) {
|
|
35
|
-
return { result: false };
|
|
36
|
-
}
|
|
37
|
-
return { result: true };
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function getThreadsHandler({
|
|
43
|
-
mastra,
|
|
44
|
-
agentId,
|
|
45
|
-
resourceId
|
|
46
|
-
}) {
|
|
47
|
-
try {
|
|
48
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
49
|
-
if (!memory) {
|
|
50
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
51
|
-
}
|
|
52
|
-
chunk57CJTIPW_cjs.validateBody({ resourceId });
|
|
53
|
-
const threads = await memory.getThreadsByResourceId({ resourceId });
|
|
54
|
-
return threads;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async function getThreadByIdHandler({
|
|
60
|
-
mastra,
|
|
61
|
-
agentId,
|
|
62
|
-
threadId
|
|
63
|
-
}) {
|
|
64
|
-
try {
|
|
65
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
66
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
67
|
-
if (!memory) {
|
|
68
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
69
|
-
}
|
|
70
|
-
const thread = await memory.getThreadById({ threadId });
|
|
71
|
-
if (!thread) {
|
|
72
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
73
|
-
}
|
|
74
|
-
return thread;
|
|
75
|
-
} catch (error) {
|
|
76
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async function saveMessagesHandler({
|
|
80
|
-
mastra,
|
|
81
|
-
agentId,
|
|
82
|
-
body
|
|
83
|
-
}) {
|
|
84
|
-
try {
|
|
85
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
86
|
-
if (!memory) {
|
|
87
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
88
|
-
}
|
|
89
|
-
if (!body?.messages) {
|
|
90
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
|
|
91
|
-
}
|
|
92
|
-
if (!Array.isArray(body.messages)) {
|
|
93
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
|
|
94
|
-
}
|
|
95
|
-
const processedMessages = body.messages.map((message) => ({
|
|
96
|
-
...message,
|
|
97
|
-
id: memory.generateId(),
|
|
98
|
-
createdAt: message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date()
|
|
99
|
-
}));
|
|
100
|
-
const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
|
|
101
|
-
return result;
|
|
102
|
-
} catch (error) {
|
|
103
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async function createThreadHandler({
|
|
107
|
-
mastra,
|
|
108
|
-
agentId,
|
|
109
|
-
body
|
|
110
|
-
}) {
|
|
111
|
-
try {
|
|
112
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
113
|
-
if (!memory) {
|
|
114
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
115
|
-
}
|
|
116
|
-
chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
|
|
117
|
-
const result = await memory.createThread({
|
|
118
|
-
resourceId: body?.resourceId,
|
|
119
|
-
title: body?.title,
|
|
120
|
-
metadata: body?.metadata,
|
|
121
|
-
threadId: body?.threadId
|
|
122
|
-
});
|
|
123
|
-
return result;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async function updateThreadHandler({
|
|
129
|
-
mastra,
|
|
130
|
-
agentId,
|
|
131
|
-
threadId,
|
|
132
|
-
body
|
|
133
|
-
}) {
|
|
134
|
-
try {
|
|
135
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
136
|
-
if (!body) {
|
|
137
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
|
|
138
|
-
}
|
|
139
|
-
const { title, metadata, resourceId } = body;
|
|
140
|
-
const updatedAt = /* @__PURE__ */ new Date();
|
|
141
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
142
|
-
if (!memory) {
|
|
143
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
144
|
-
}
|
|
145
|
-
const thread = await memory.getThreadById({ threadId });
|
|
146
|
-
if (!thread) {
|
|
147
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
148
|
-
}
|
|
149
|
-
const updatedThread = {
|
|
150
|
-
...thread,
|
|
151
|
-
title: title || thread.title,
|
|
152
|
-
metadata: metadata || thread.metadata,
|
|
153
|
-
resourceId: resourceId || thread.resourceId,
|
|
154
|
-
createdAt: thread.createdAt,
|
|
155
|
-
updatedAt
|
|
156
|
-
};
|
|
157
|
-
const result = await memory.saveThread({ thread: updatedThread });
|
|
158
|
-
return result;
|
|
159
|
-
} catch (error) {
|
|
160
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
async function deleteThreadHandler({
|
|
164
|
-
mastra,
|
|
165
|
-
agentId,
|
|
166
|
-
threadId
|
|
167
|
-
}) {
|
|
168
|
-
try {
|
|
169
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
170
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
171
|
-
if (!memory) {
|
|
172
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
173
|
-
}
|
|
174
|
-
const thread = await memory.getThreadById({ threadId });
|
|
175
|
-
if (!thread) {
|
|
176
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
177
|
-
}
|
|
178
|
-
await memory.deleteThread(threadId);
|
|
179
|
-
return { result: "Thread deleted" };
|
|
180
|
-
} catch (error) {
|
|
181
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
async function getMessagesHandler({
|
|
185
|
-
mastra,
|
|
186
|
-
agentId,
|
|
187
|
-
threadId,
|
|
188
|
-
limit,
|
|
189
|
-
format,
|
|
190
|
-
clientSdkCompat
|
|
191
|
-
}) {
|
|
192
|
-
if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
|
|
193
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
chunk57CJTIPW_cjs.validateBody({ threadId });
|
|
197
|
-
const memory = getMemoryFromContext({ mastra, agentId });
|
|
198
|
-
if (!memory) {
|
|
199
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
|
|
200
|
-
}
|
|
201
|
-
const thread = await memory.getThreadById({ threadId });
|
|
202
|
-
if (!thread) {
|
|
203
|
-
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
|
|
204
|
-
}
|
|
205
|
-
const result = await memory.query({
|
|
206
|
-
threadId,
|
|
207
|
-
...limit && { selectBy: { last: limit } }
|
|
208
|
-
});
|
|
209
|
-
let useV4Format = false;
|
|
210
|
-
if (format === "aiv4") {
|
|
211
|
-
useV4Format = true;
|
|
212
|
-
} else if (format === "aiv5") {
|
|
213
|
-
useV4Format = false;
|
|
214
|
-
} else {
|
|
215
|
-
useV4Format = clientSdkCompat === "v4" || mastra.getAiSdkCompatMode() === "v4";
|
|
216
|
-
}
|
|
217
|
-
if (useV4Format) {
|
|
218
|
-
return { messages: result.messages, uiMessages: result.uiMessagesV4 };
|
|
219
|
-
}
|
|
220
|
-
return { messages: result.messages, uiMessages: result.uiMessages };
|
|
221
|
-
} catch (error) {
|
|
222
|
-
return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
exports.createThreadHandler = createThreadHandler;
|
|
227
|
-
exports.deleteThreadHandler = deleteThreadHandler;
|
|
228
|
-
exports.getMemoryStatusHandler = getMemoryStatusHandler;
|
|
229
|
-
exports.getMessagesHandler = getMessagesHandler;
|
|
230
|
-
exports.getThreadByIdHandler = getThreadByIdHandler;
|
|
231
|
-
exports.getThreadsHandler = getThreadsHandler;
|
|
232
|
-
exports.memory_exports = memory_exports;
|
|
233
|
-
exports.saveMessagesHandler = saveMessagesHandler;
|
|
234
|
-
exports.updateThreadHandler = updateThreadHandler;
|