@mastra/server 0.0.0-vnext-inngest-20250508122351 → 0.0.0-vnextAgentNetwork-20250527091247
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/dist/_tsup-dts-rollup.d.cts +251 -93
- package/dist/_tsup-dts-rollup.d.ts +251 -93
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/chunk-5SN4U5AC.cjs +508 -0
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-SKBVVI24.cjs → chunk-7DLZLWJV.cjs} +12 -11
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
- package/dist/{chunk-6Q7UXAYJ.cjs → chunk-D4IRYCUI.cjs} +57 -20
- package/dist/{chunk-RBQASTUP.js → chunk-DJJIUEL2.js} +13 -5
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
- package/dist/{chunk-OWNA6I2H.js → chunk-KUNQFY2W.js} +98 -45
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-MMO2HDM6.cjs +378 -0
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
- package/dist/chunk-P6SCPDYW.js +500 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
- package/dist/{chunk-3XTEV33Q.js → chunk-W7VCKPAD.js} +53 -50
- package/dist/{chunk-3EJZQ6TQ.js → chunk-WFBJJNCK.js} +6 -5
- package/dist/{chunk-GVBJ5I2S.js → chunk-WUC6LSTW.js} +41 -4
- package/dist/{chunk-2FJURXCL.cjs → chunk-Y7UWRW5X.cjs} +43 -35
- package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
- package/dist/chunk-YIOVBYZH.cjs +332 -0
- package/dist/chunk-YWLUOY3D.cjs +2004 -0
- package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +4 -4
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +17 -13
- package/dist/server/handlers/workflows.d.cts +3 -2
- package/dist/server/handlers/workflows.d.ts +3 -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 +6 -4
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-CHFORQ7J.cjs +0 -329
- package/dist/chunk-M2RXDCPV.cjs +0 -324
- package/dist/chunk-OMN3UI6X.js +0 -5576
- 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,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
4
|
+
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
5
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
5
6
|
|
|
6
7
|
// src/server/handlers/vector.ts
|
|
7
8
|
var vector_exports = {};
|
|
8
|
-
|
|
9
|
+
chunk75ZPJI57_cjs.__export(vector_exports, {
|
|
9
10
|
createIndex: () => createIndex,
|
|
10
11
|
deleteIndex: () => deleteIndex,
|
|
11
12
|
describeIndex: () => describeIndex,
|
|
@@ -15,24 +16,24 @@ chunkFV45V6WC_cjs.__export(vector_exports, {
|
|
|
15
16
|
});
|
|
16
17
|
function getVector(mastra, vectorName) {
|
|
17
18
|
if (!vectorName) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Vector name is required" });
|
|
19
20
|
}
|
|
20
21
|
const vector = mastra.getVector(vectorName);
|
|
21
22
|
if (!vector) {
|
|
22
|
-
throw new
|
|
23
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
|
|
23
24
|
}
|
|
24
25
|
return vector;
|
|
25
26
|
}
|
|
26
27
|
async function upsertVectors({ mastra, vectorName, index }) {
|
|
27
28
|
try {
|
|
28
29
|
if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
|
|
29
|
-
throw new
|
|
30
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
|
|
30
31
|
}
|
|
31
32
|
const vector = getVector(mastra, vectorName);
|
|
32
33
|
const result = await vector.upsert(index);
|
|
33
34
|
return { ids: result };
|
|
34
35
|
} catch (error) {
|
|
35
|
-
return
|
|
36
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error upserting vectors");
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
async function createIndex({
|
|
@@ -43,18 +44,18 @@ async function createIndex({
|
|
|
43
44
|
try {
|
|
44
45
|
const { indexName, dimension, metric } = index;
|
|
45
46
|
if (!indexName || typeof dimension !== "number" || dimension <= 0) {
|
|
46
|
-
throw new
|
|
47
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, {
|
|
47
48
|
message: "Invalid request index, indexName and positive dimension number are required."
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
|
|
51
|
-
throw new
|
|
52
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
|
|
52
53
|
}
|
|
53
54
|
const vector = getVector(mastra, vectorName);
|
|
54
55
|
await vector.createIndex({ indexName, dimension, metric });
|
|
55
56
|
return { success: true };
|
|
56
57
|
} catch (error) {
|
|
57
|
-
return
|
|
58
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error creating index");
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
async function queryVectors({
|
|
@@ -64,13 +65,13 @@ async function queryVectors({
|
|
|
64
65
|
}) {
|
|
65
66
|
try {
|
|
66
67
|
if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
|
|
67
|
-
throw new
|
|
68
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
|
|
68
69
|
}
|
|
69
70
|
const vector = getVector(mastra, vectorName);
|
|
70
71
|
const results = await vector.query(query);
|
|
71
72
|
return results;
|
|
72
73
|
} catch (error) {
|
|
73
|
-
return
|
|
74
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error querying vectors");
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
async function listIndexes({ mastra, vectorName }) {
|
|
@@ -79,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
|
|
|
79
80
|
const indexes = await vector.listIndexes();
|
|
80
81
|
return indexes.filter(Boolean);
|
|
81
82
|
} catch (error) {
|
|
82
|
-
return
|
|
83
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error listing indexes");
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
async function describeIndex({
|
|
@@ -89,17 +90,17 @@ async function describeIndex({
|
|
|
89
90
|
}) {
|
|
90
91
|
try {
|
|
91
92
|
if (!indexName) {
|
|
92
|
-
throw new
|
|
93
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
|
|
93
94
|
}
|
|
94
95
|
const vector = getVector(mastra, vectorName);
|
|
95
|
-
const stats = await vector.describeIndex(indexName);
|
|
96
|
+
const stats = await vector.describeIndex({ indexName });
|
|
96
97
|
return {
|
|
97
98
|
dimension: stats.dimension,
|
|
98
99
|
count: stats.count,
|
|
99
100
|
metric: stats.metric?.toLowerCase()
|
|
100
101
|
};
|
|
101
102
|
} catch (error) {
|
|
102
|
-
return
|
|
103
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error describing index");
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
async function deleteIndex({
|
|
@@ -109,13 +110,13 @@ async function deleteIndex({
|
|
|
109
110
|
}) {
|
|
110
111
|
try {
|
|
111
112
|
if (!indexName) {
|
|
112
|
-
throw new
|
|
113
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Index name is required" });
|
|
113
114
|
}
|
|
114
115
|
const vector = getVector(mastra, vectorName);
|
|
115
|
-
await vector.deleteIndex(indexName);
|
|
116
|
+
await vector.deleteIndex({ indexName });
|
|
116
117
|
return { success: true };
|
|
117
118
|
} catch (error) {
|
|
118
|
-
return
|
|
119
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error deleting index");
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -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-M5ABIP7D.js';
|
|
3
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
4
5
|
|
|
5
6
|
// src/server/handlers/network.ts
|
|
6
7
|
var network_exports = {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
|
|
4
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
5
|
+
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
6
|
+
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
7
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
8
|
var runtimeContext = require('@mastra/core/runtime-context');
|
|
8
9
|
|
|
9
10
|
// src/server/handlers/agents.ts
|
|
10
11
|
var agents_exports = {};
|
|
11
|
-
|
|
12
|
+
chunk75ZPJI57_cjs.__export(agents_exports, {
|
|
12
13
|
generateHandler: () => generateHandler,
|
|
13
14
|
getAgentByIdHandler: () => getAgentByIdHandler,
|
|
14
15
|
getAgentsHandler: () => getAgentsHandler,
|
|
@@ -28,16 +29,34 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
28
29
|
const _tool = tool;
|
|
29
30
|
acc[key] = {
|
|
30
31
|
..._tool,
|
|
31
|
-
inputSchema: _tool.inputSchema ?
|
|
32
|
-
outputSchema: _tool.outputSchema ?
|
|
32
|
+
inputSchema: _tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
33
|
+
outputSchema: _tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
33
34
|
};
|
|
34
35
|
return acc;
|
|
35
36
|
}, {});
|
|
37
|
+
let serializedAgentWorkflows = {};
|
|
38
|
+
if ("getWorkflows" in agent) {
|
|
39
|
+
const logger = mastra.getLogger();
|
|
40
|
+
try {
|
|
41
|
+
const workflows = await agent.getWorkflows({ runtimeContext });
|
|
42
|
+
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
43
|
+
return {
|
|
44
|
+
...acc,
|
|
45
|
+
[key]: {
|
|
46
|
+
name: workflow.name
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, {});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
36
54
|
return {
|
|
37
55
|
id,
|
|
38
56
|
name: agent.name,
|
|
39
57
|
instructions,
|
|
40
58
|
tools: serializedAgentTools,
|
|
59
|
+
workflows: serializedAgentWorkflows,
|
|
41
60
|
provider: llm?.getProvider(),
|
|
42
61
|
modelId: llm?.getModelId()
|
|
43
62
|
};
|
|
@@ -49,7 +68,7 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
49
68
|
}, {});
|
|
50
69
|
return serializedAgents;
|
|
51
70
|
} catch (error) {
|
|
52
|
-
return
|
|
71
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting agents");
|
|
53
72
|
}
|
|
54
73
|
}
|
|
55
74
|
async function getAgentByIdHandler({
|
|
@@ -60,29 +79,47 @@ async function getAgentByIdHandler({
|
|
|
60
79
|
try {
|
|
61
80
|
const agent = mastra.getAgent(agentId);
|
|
62
81
|
if (!agent) {
|
|
63
|
-
throw new
|
|
82
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
64
83
|
}
|
|
65
84
|
const tools = await agent.getTools({ runtimeContext });
|
|
66
85
|
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
67
86
|
const _tool = tool;
|
|
68
87
|
acc[key] = {
|
|
69
88
|
..._tool,
|
|
70
|
-
inputSchema: _tool.inputSchema ?
|
|
71
|
-
outputSchema: _tool.outputSchema ?
|
|
89
|
+
inputSchema: _tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
90
|
+
outputSchema: _tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
72
91
|
};
|
|
73
92
|
return acc;
|
|
74
93
|
}, {});
|
|
94
|
+
let serializedAgentWorkflows = {};
|
|
95
|
+
if ("getWorkflows" in agent) {
|
|
96
|
+
const logger = mastra.getLogger();
|
|
97
|
+
try {
|
|
98
|
+
const workflows = await agent.getWorkflows({ runtimeContext });
|
|
99
|
+
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
100
|
+
return {
|
|
101
|
+
...acc,
|
|
102
|
+
[key]: {
|
|
103
|
+
name: workflow.name
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, {});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
75
111
|
const instructions = await agent.getInstructions({ runtimeContext });
|
|
76
112
|
const llm = await agent.getLLM({ runtimeContext });
|
|
77
113
|
return {
|
|
78
114
|
name: agent.name,
|
|
79
115
|
instructions,
|
|
80
116
|
tools: serializedAgentTools,
|
|
117
|
+
workflows: serializedAgentWorkflows,
|
|
81
118
|
provider: llm?.getProvider(),
|
|
82
119
|
modelId: llm?.getModelId()
|
|
83
120
|
};
|
|
84
121
|
} catch (error) {
|
|
85
|
-
return
|
|
122
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting agent");
|
|
86
123
|
}
|
|
87
124
|
}
|
|
88
125
|
async function getEvalsByAgentIdHandler({
|
|
@@ -101,7 +138,7 @@ async function getEvalsByAgentIdHandler({
|
|
|
101
138
|
evals
|
|
102
139
|
};
|
|
103
140
|
} catch (error) {
|
|
104
|
-
return
|
|
141
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting test evals");
|
|
105
142
|
}
|
|
106
143
|
}
|
|
107
144
|
async function getLiveEvalsByAgentIdHandler({
|
|
@@ -120,7 +157,7 @@ async function getLiveEvalsByAgentIdHandler({
|
|
|
120
157
|
evals
|
|
121
158
|
};
|
|
122
159
|
} catch (error) {
|
|
123
|
-
return
|
|
160
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting live evals");
|
|
124
161
|
}
|
|
125
162
|
}
|
|
126
163
|
async function generateHandler({
|
|
@@ -132,7 +169,7 @@ async function generateHandler({
|
|
|
132
169
|
try {
|
|
133
170
|
const agent = mastra.getAgent(agentId);
|
|
134
171
|
if (!agent) {
|
|
135
|
-
throw new
|
|
172
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
136
173
|
}
|
|
137
174
|
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
138
175
|
const finalResourceId = resourceId ?? resourceid;
|
|
@@ -140,7 +177,7 @@ async function generateHandler({
|
|
|
140
177
|
...Array.from(runtimeContext$1.entries()),
|
|
141
178
|
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
142
179
|
]);
|
|
143
|
-
|
|
180
|
+
chunk57CJTIPW_cjs.validateBody({ messages });
|
|
144
181
|
const result = await agent.generate(messages, {
|
|
145
182
|
...rest,
|
|
146
183
|
// @ts-expect-error TODO fix types
|
|
@@ -149,7 +186,7 @@ async function generateHandler({
|
|
|
149
186
|
});
|
|
150
187
|
return result;
|
|
151
188
|
} catch (error) {
|
|
152
|
-
return
|
|
189
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error generating from agent");
|
|
153
190
|
}
|
|
154
191
|
}
|
|
155
192
|
async function streamGenerateHandler({
|
|
@@ -161,7 +198,7 @@ async function streamGenerateHandler({
|
|
|
161
198
|
try {
|
|
162
199
|
const agent = mastra.getAgent(agentId);
|
|
163
200
|
if (!agent) {
|
|
164
|
-
throw new
|
|
201
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
165
202
|
}
|
|
166
203
|
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
167
204
|
const finalResourceId = resourceId ?? resourceid;
|
|
@@ -169,7 +206,7 @@ async function streamGenerateHandler({
|
|
|
169
206
|
...Array.from(runtimeContext$1.entries()),
|
|
170
207
|
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
171
208
|
]);
|
|
172
|
-
|
|
209
|
+
chunk57CJTIPW_cjs.validateBody({ messages });
|
|
173
210
|
const streamResult = await agent.stream(messages, {
|
|
174
211
|
...rest,
|
|
175
212
|
// @ts-expect-error TODO fix types
|
|
@@ -185,7 +222,7 @@ async function streamGenerateHandler({
|
|
|
185
222
|
});
|
|
186
223
|
return streamResponse;
|
|
187
224
|
} catch (error) {
|
|
188
|
-
throw new
|
|
225
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
|
|
189
226
|
}
|
|
190
227
|
}
|
|
191
228
|
|
|
@@ -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-M5ABIP7D.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 = {};
|
|
@@ -181,8 +182,12 @@ async function deleteThreadHandler({
|
|
|
181
182
|
async function getMessagesHandler({
|
|
182
183
|
mastra,
|
|
183
184
|
agentId,
|
|
184
|
-
threadId
|
|
185
|
+
threadId,
|
|
186
|
+
limit
|
|
185
187
|
}) {
|
|
188
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
|
|
189
|
+
throw new HTTPException(400, { message: "Invalid limit: must be a positive integer" });
|
|
190
|
+
}
|
|
186
191
|
try {
|
|
187
192
|
validateBody({ threadId });
|
|
188
193
|
const memory = getMemoryFromContext({ mastra, agentId });
|
|
@@ -193,7 +198,10 @@ async function getMessagesHandler({
|
|
|
193
198
|
if (!thread) {
|
|
194
199
|
throw new HTTPException(404, { message: "Thread not found" });
|
|
195
200
|
}
|
|
196
|
-
const result = await memory.query({
|
|
201
|
+
const result = await memory.query({
|
|
202
|
+
threadId,
|
|
203
|
+
...limit && { selectBy: { last: limit } }
|
|
204
|
+
});
|
|
197
205
|
return result;
|
|
198
206
|
} catch (error) {
|
|
199
207
|
return handleError(error, "Error getting messages");
|
|
@@ -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-M5ABIP7D.js';
|
|
3
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
4
5
|
import { Readable } from 'stream';
|
|
5
6
|
|
|
6
7
|
// src/server/handlers/voice.ts
|