@mastra/server 0.0.0-declaration-maps-20250730185206 → 0.0.0-dynamic-model-router-20251009204130
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 +3969 -0
- package/README.md +0 -5
- package/dist/chunk-2PLXW4ZX.cjs +2777 -0
- package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
- package/dist/chunk-2S4IMB6E.cjs +130 -0
- package/dist/chunk-2S4IMB6E.cjs.map +1 -0
- package/dist/chunk-3Q7FKRVX.cjs +682 -0
- package/dist/chunk-3Q7FKRVX.cjs.map +1 -0
- package/dist/{chunk-4US5W7PH.cjs → chunk-3SNGNFUJ.cjs} +23 -15
- package/dist/chunk-3SNGNFUJ.cjs.map +1 -0
- package/dist/{chunk-OW4FX5TS.js → chunk-4QCXUEAT.js} +10 -3
- package/dist/chunk-4QCXUEAT.js.map +1 -0
- package/dist/{chunk-TXAQU2XN.js → chunk-5BNQIYQN.js} +60 -22
- package/dist/chunk-5BNQIYQN.js.map +1 -0
- package/dist/{chunk-SQ7KKIH3.js → chunk-67GYDFSB.js} +22 -5
- package/dist/chunk-67GYDFSB.js.map +1 -0
- package/dist/{chunk-ILCWPBYQ.cjs → chunk-6ZR275MD.cjs} +23 -5
- package/dist/chunk-6ZR275MD.cjs.map +1 -0
- package/dist/{chunk-4MQU6AJN.js → chunk-ABRFV4XP.js} +4 -4
- package/dist/{chunk-4MQU6AJN.js.map → chunk-ABRFV4XP.js.map} +1 -1
- package/dist/{chunk-YS66MFDY.js → chunk-AHB4JCIQ.js} +48 -12
- package/dist/chunk-AHB4JCIQ.js.map +1 -0
- package/dist/chunk-BATEJLED.js +124 -0
- package/dist/chunk-BATEJLED.js.map +1 -0
- package/dist/{chunk-BUOJL3MN.js → chunk-DB63UMTV.js} +220 -89
- package/dist/chunk-DB63UMTV.js.map +1 -0
- package/dist/{chunk-NCS2OXX6.cjs → chunk-EP3JQDPD.cjs} +4 -4
- package/dist/{chunk-NCS2OXX6.cjs.map → chunk-EP3JQDPD.cjs.map} +1 -1
- package/dist/chunk-FZNS32WJ.js +46 -0
- package/dist/chunk-FZNS32WJ.js.map +1 -0
- package/dist/{chunk-4QSNRCOT.cjs → chunk-G4PUALCE.cjs} +10 -2
- package/dist/chunk-G4PUALCE.cjs.map +1 -0
- package/dist/chunk-GU4EWMZB.cjs +769 -0
- package/dist/chunk-GU4EWMZB.cjs.map +1 -0
- package/dist/chunk-HKW2536J.js +17477 -0
- package/dist/chunk-HKW2536J.js.map +1 -0
- package/dist/{chunk-TRWPUPGD.js → chunk-HPXAM2PG.js} +109 -138
- package/dist/chunk-HPXAM2PG.js.map +1 -0
- package/dist/{chunk-JGVY3KWV.cjs → chunk-I3C4ODGV.cjs} +12 -11
- package/dist/chunk-I3C4ODGV.cjs.map +1 -0
- package/dist/chunk-KJJA7GPJ.cjs +17513 -0
- package/dist/chunk-KJJA7GPJ.cjs.map +1 -0
- package/dist/chunk-LF2ZLOFP.js +767 -0
- package/dist/chunk-LF2ZLOFP.js.map +1 -0
- package/dist/{chunk-UVOSITKU.js → chunk-LLUOPR3J.js} +11 -10
- package/dist/chunk-LLUOPR3J.js.map +1 -0
- package/dist/{chunk-VIGPWTDA.cjs → chunk-LNT5N7XW.cjs} +61 -23
- package/dist/chunk-LNT5N7XW.cjs.map +1 -0
- package/dist/chunk-LPM6BBAX.cjs +1043 -0
- package/dist/chunk-LPM6BBAX.cjs.map +1 -0
- package/dist/chunk-LV66LYKV.js +662 -0
- package/dist/chunk-LV66LYKV.js.map +1 -0
- package/dist/{chunk-S37KCGOR.cjs → chunk-MQDBNHBT.cjs} +222 -88
- package/dist/chunk-MQDBNHBT.cjs.map +1 -0
- package/dist/{chunk-G7NVCO5M.js → chunk-MYR4PVGN.js} +3 -3
- package/dist/{chunk-G7NVCO5M.js.map → chunk-MYR4PVGN.js.map} +1 -1
- package/dist/chunk-O7I5CWRX.cjs +44 -0
- package/dist/{chunk-Q7SFCCGT.cjs.map → chunk-O7I5CWRX.cjs.map} +1 -1
- package/dist/chunk-OYL5TBJW.cjs +48 -0
- package/dist/chunk-OYL5TBJW.cjs.map +1 -0
- package/dist/chunk-PR4QN5HX.js +39 -0
- package/dist/{chunk-PZ5AY32C.js.map → chunk-PR4QN5HX.js.map} +1 -1
- package/dist/{chunk-HWHKM67I.js → chunk-QQXMIP6C.js} +21 -13
- package/dist/chunk-QQXMIP6C.js.map +1 -0
- package/dist/chunk-RQK4FQUD.js +1012 -0
- package/dist/chunk-RQK4FQUD.js.map +1 -0
- package/dist/chunk-SIW6CYO3.js +254 -0
- package/dist/chunk-SIW6CYO3.js.map +1 -0
- package/dist/{chunk-GASWM5HJ.cjs → chunk-TOP25AIO.cjs} +110 -139
- package/dist/chunk-TOP25AIO.cjs.map +1 -0
- package/dist/{chunk-O4I563YW.cjs → chunk-TRGAMKHX.cjs} +50 -13
- package/dist/chunk-TRGAMKHX.cjs.map +1 -0
- package/dist/chunk-VY4ENABS.cjs +135 -0
- package/dist/chunk-VY4ENABS.cjs.map +1 -0
- package/dist/{chunk-HXIOPAHT.js → chunk-WHABYJRY.js} +51 -41
- package/dist/chunk-WHABYJRY.js.map +1 -0
- package/dist/{chunk-BED2O446.cjs → chunk-XN74I6VW.cjs} +7 -7
- package/dist/{chunk-BED2O446.cjs.map → chunk-XN74I6VW.cjs.map} +1 -1
- package/dist/chunk-XVPBGW6Y.cjs +256 -0
- package/dist/chunk-XVPBGW6Y.cjs.map +1 -0
- package/dist/{chunk-X5SDJOY6.cjs → chunk-YJU744I4.cjs} +63 -52
- package/dist/chunk-YJU744I4.cjs.map +1 -0
- package/dist/chunk-YWOK4F5A.js +131 -0
- package/dist/chunk-YWOK4F5A.js.map +1 -0
- package/dist/chunk-ZULZ2752.js +2774 -0
- package/dist/chunk-ZULZ2752.js.map +1 -0
- package/dist/dist-4MVGNSRL.cjs +1150 -0
- package/dist/dist-4MVGNSRL.cjs.map +1 -0
- package/dist/dist-FZYCV3VB.cjs +940 -0
- package/dist/dist-FZYCV3VB.cjs.map +1 -0
- package/dist/dist-G2BYZJOC.cjs +928 -0
- package/dist/dist-G2BYZJOC.cjs.map +1 -0
- package/dist/dist-P4MXBQ3U.cjs +16 -0
- package/dist/dist-P4MXBQ3U.cjs.map +1 -0
- package/dist/dist-PQZUVLPC.js +937 -0
- package/dist/dist-PQZUVLPC.js.map +1 -0
- package/dist/dist-R7WYX6LC.js +925 -0
- package/dist/dist-R7WYX6LC.js.map +1 -0
- package/dist/dist-RFMYFILX.cjs +764 -0
- package/dist/dist-RFMYFILX.cjs.map +1 -0
- package/dist/dist-X7XR3M3Z.js +1147 -0
- package/dist/dist-X7XR3M3Z.js.map +1 -0
- package/dist/dist-XVBSOGFK.js +761 -0
- package/dist/dist-XVBSOGFK.js.map +1 -0
- package/dist/dist-YREX2TJT.js +3 -0
- package/dist/dist-YREX2TJT.js.map +1 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/server/a2a/store.cjs +25 -0
- package/dist/server/a2a/store.cjs.map +1 -0
- package/dist/server/a2a/store.d.ts +3 -3
- package/dist/server/a2a/store.d.ts.map +1 -1
- package/dist/server/a2a/store.js +23 -0
- package/dist/server/a2a/store.js.map +1 -0
- package/dist/server/a2a/tasks.d.ts +7 -7
- package/dist/server/a2a/tasks.d.ts.map +1 -1
- package/dist/server/handlers/a2a.cjs +11 -11
- package/dist/server/handlers/a2a.d.ts +17 -15
- 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 +68 -0
- package/dist/server/handlers/agent-builder.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.d.ts +94 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -0
- package/dist/server/handlers/agent-builder.js +3 -0
- package/dist/server/handlers/agent-builder.js.map +1 -0
- package/dist/server/handlers/agents.cjs +53 -9
- package/dist/server/handlers/agents.d.ts +154 -31
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +11 -11
- package/dist/server/handlers/legacyWorkflows.d.ts +1 -1
- package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -1
- 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 +19 -15
- package/dist/server/handlers/memory.d.ts +22 -18
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +24 -0
- package/dist/server/handlers/observability.cjs.map +1 -0
- package/dist/server/handlers/observability.d.ts +49 -0
- package/dist/server/handlers/observability.d.ts.map +1 -0
- package/dist/server/handlers/observability.js +3 -0
- package/dist/server/handlers/observability.js.map +1 -0
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.d.ts +209 -7
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/telemetry.cjs +7 -3
- package/dist/server/handlers/telemetry.d.ts +2 -1
- package/dist/server/handlers/telemetry.d.ts.map +1 -1
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +9 -5
- package/dist/server/handlers/tools.d.ts +5 -1
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +6 -2
- package/dist/server/handlers/utils.d.ts +6 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.d.ts +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.d.ts +7 -5
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +28 -16
- package/dist/server/handlers/workflows.d.ts +37 -34
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +38 -33
- package/dist/server/handlers.d.ts +13 -12
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +13 -12
- package/dist/server/utils.d.ts +44 -0
- package/dist/server/utils.d.ts.map +1 -0
- package/dist/token-53CFGXUO.cjs +64 -0
- package/dist/token-53CFGXUO.cjs.map +1 -0
- package/dist/token-WAEKDUVY.js +62 -0
- package/dist/token-WAEKDUVY.js.map +1 -0
- package/dist/token-util-LY37VCIN.js +7 -0
- package/dist/token-util-LY37VCIN.js.map +1 -0
- package/dist/token-util-S4A355II.cjs +9 -0
- package/dist/token-util-S4A355II.cjs.map +1 -0
- package/package.json +36 -14
- package/dist/chunk-2XIJW7SV.cjs +0 -310
- package/dist/chunk-2XIJW7SV.cjs.map +0 -1
- package/dist/chunk-4CEZIJWJ.cjs +0 -150
- package/dist/chunk-4CEZIJWJ.cjs.map +0 -1
- package/dist/chunk-4QSNRCOT.cjs.map +0 -1
- package/dist/chunk-4US5W7PH.cjs.map +0 -1
- package/dist/chunk-7FHF55WA.js +0 -2041
- package/dist/chunk-7FHF55WA.js.map +0 -1
- package/dist/chunk-BUOJL3MN.js.map +0 -1
- package/dist/chunk-GASWM5HJ.cjs.map +0 -1
- package/dist/chunk-HWHKM67I.js.map +0 -1
- package/dist/chunk-HXIOPAHT.js.map +0 -1
- package/dist/chunk-ILCWPBYQ.cjs.map +0 -1
- package/dist/chunk-JGVY3KWV.cjs.map +0 -1
- package/dist/chunk-LRUH33B4.cjs +0 -2044
- package/dist/chunk-LRUH33B4.cjs.map +0 -1
- package/dist/chunk-O4I563YW.cjs.map +0 -1
- package/dist/chunk-OW4FX5TS.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-Q7SFCCGT.cjs +0 -11
- package/dist/chunk-S37KCGOR.cjs.map +0 -1
- package/dist/chunk-SQ7KKIH3.js.map +0 -1
- package/dist/chunk-TRWPUPGD.js.map +0 -1
- package/dist/chunk-TXAQU2XN.js.map +0 -1
- package/dist/chunk-UVOSITKU.js.map +0 -1
- package/dist/chunk-VIGPWTDA.cjs.map +0 -1
- package/dist/chunk-VOY6MGKA.js +0 -301
- package/dist/chunk-VOY6MGKA.js.map +0 -1
- package/dist/chunk-X5SDJOY6.cjs.map +0 -1
- package/dist/chunk-Y3J45CVZ.js +0 -144
- package/dist/chunk-Y3J45CVZ.js.map +0 -1
- package/dist/chunk-YS66MFDY.js.map +0 -1
- package/dist/server/handlers/network.cjs +0 -24
- package/dist/server/handlers/network.cjs.map +0 -1
- package/dist/server/handlers/network.d.ts +0 -50
- package/dist/server/handlers/network.d.ts.map +0 -1
- package/dist/server/handlers/network.js +0 -3
- package/dist/server/handlers/network.js.map +0 -1
- package/dist/server/handlers/vNextNetwork.cjs +0 -220
- package/dist/server/handlers/vNextNetwork.cjs.map +0 -1
- package/dist/server/handlers/vNextNetwork.d.ts +0 -179
- package/dist/server/handlers/vNextNetwork.d.ts.map +0 -1
- package/dist/server/handlers/vNextNetwork.js +0 -213
- package/dist/server/handlers/vNextNetwork.js.map +0 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkG4PUALCE_cjs = require('./chunk-G4PUALCE.cjs');
|
|
4
|
+
var chunkGU4EWMZB_cjs = require('./chunk-GU4EWMZB.cjs');
|
|
5
5
|
var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
|
|
6
6
|
var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
|
|
8
8
|
var tools = require('@mastra/core/tools');
|
|
9
|
+
var zodToJson = require('@mastra/core/utils/zod-to-json');
|
|
9
10
|
|
|
10
11
|
// src/server/handlers/tools.ts
|
|
11
12
|
var tools_exports = {};
|
|
12
|
-
|
|
13
|
+
chunkO7I5CWRX_cjs.__export(tools_exports, {
|
|
13
14
|
executeAgentToolHandler: () => executeAgentToolHandler,
|
|
14
15
|
executeToolHandler: () => executeToolHandler,
|
|
16
|
+
getAgentToolHandler: () => getAgentToolHandler,
|
|
15
17
|
getToolByIdHandler: () => getToolByIdHandler,
|
|
16
18
|
getToolsHandler: () => getToolsHandler
|
|
17
19
|
});
|
|
@@ -25,8 +27,8 @@ async function getToolsHandler({ tools }) {
|
|
|
25
27
|
const tool = _tool;
|
|
26
28
|
acc[id] = {
|
|
27
29
|
...tool,
|
|
28
|
-
inputSchema: tool.inputSchema ?
|
|
29
|
-
outputSchema: tool.outputSchema ?
|
|
30
|
+
inputSchema: tool.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(tool.inputSchema)) : void 0,
|
|
31
|
+
outputSchema: tool.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(tool.outputSchema)) : void 0
|
|
30
32
|
};
|
|
31
33
|
return acc;
|
|
32
34
|
},
|
|
@@ -45,8 +47,8 @@ async function getToolByIdHandler({ tools, toolId }) {
|
|
|
45
47
|
}
|
|
46
48
|
const serializedTool = {
|
|
47
49
|
...tool,
|
|
48
|
-
inputSchema: tool.inputSchema ?
|
|
49
|
-
outputSchema: tool.outputSchema ?
|
|
50
|
+
inputSchema: tool.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(tool.inputSchema)) : void 0,
|
|
51
|
+
outputSchema: tool.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(tool.outputSchema)) : void 0
|
|
50
52
|
};
|
|
51
53
|
return serializedTool;
|
|
52
54
|
} catch (error) {
|
|
@@ -72,7 +74,7 @@ function executeToolHandler(tools$1) {
|
|
|
72
74
|
if (!tool?.execute) {
|
|
73
75
|
throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Tool is not executable" });
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
chunkG4PUALCE_cjs.validateBody({ data });
|
|
76
78
|
if (tools.isVercelTool(tool)) {
|
|
77
79
|
const result2 = await tool.execute(data);
|
|
78
80
|
return result2;
|
|
@@ -81,7 +83,11 @@ function executeToolHandler(tools$1) {
|
|
|
81
83
|
context: data,
|
|
82
84
|
mastra,
|
|
83
85
|
runId,
|
|
84
|
-
runtimeContext
|
|
86
|
+
runtimeContext,
|
|
87
|
+
// TODO: Pass proper tracing context when server API supports tracing
|
|
88
|
+
tracingContext: { currentSpan: void 0 },
|
|
89
|
+
suspend: async () => {
|
|
90
|
+
}
|
|
85
91
|
});
|
|
86
92
|
return result;
|
|
87
93
|
} catch (error) {
|
|
@@ -89,6 +95,32 @@ function executeToolHandler(tools$1) {
|
|
|
89
95
|
}
|
|
90
96
|
};
|
|
91
97
|
}
|
|
98
|
+
async function getAgentToolHandler({
|
|
99
|
+
mastra,
|
|
100
|
+
agentId,
|
|
101
|
+
toolId,
|
|
102
|
+
runtimeContext
|
|
103
|
+
}) {
|
|
104
|
+
try {
|
|
105
|
+
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
106
|
+
if (!agent) {
|
|
107
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Agent not found" });
|
|
108
|
+
}
|
|
109
|
+
const agentTools = await agent.getTools({ runtimeContext });
|
|
110
|
+
const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
|
|
111
|
+
if (!tool) {
|
|
112
|
+
throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Tool not found" });
|
|
113
|
+
}
|
|
114
|
+
const serializedTool = {
|
|
115
|
+
...tool,
|
|
116
|
+
inputSchema: tool.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(tool.inputSchema)) : void 0,
|
|
117
|
+
outputSchema: tool.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(tool.outputSchema)) : void 0
|
|
118
|
+
};
|
|
119
|
+
return serializedTool;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return chunkRE4RPXT2_cjs.handleError(error, "Error getting agent tool");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
92
124
|
async function executeAgentToolHandler({
|
|
93
125
|
mastra,
|
|
94
126
|
agentId,
|
|
@@ -113,7 +145,11 @@ async function executeAgentToolHandler({
|
|
|
113
145
|
context: data,
|
|
114
146
|
runtimeContext,
|
|
115
147
|
mastra,
|
|
116
|
-
runId: agentId
|
|
148
|
+
runId: agentId,
|
|
149
|
+
// TODO: Pass proper tracing context when server API supports tracing
|
|
150
|
+
tracingContext: { currentSpan: void 0 },
|
|
151
|
+
suspend: async () => {
|
|
152
|
+
}
|
|
117
153
|
});
|
|
118
154
|
return result;
|
|
119
155
|
} catch (error) {
|
|
@@ -123,8 +159,9 @@ async function executeAgentToolHandler({
|
|
|
123
159
|
|
|
124
160
|
exports.executeAgentToolHandler = executeAgentToolHandler;
|
|
125
161
|
exports.executeToolHandler = executeToolHandler;
|
|
162
|
+
exports.getAgentToolHandler = getAgentToolHandler;
|
|
126
163
|
exports.getToolByIdHandler = getToolByIdHandler;
|
|
127
164
|
exports.getToolsHandler = getToolsHandler;
|
|
128
165
|
exports.tools_exports = tools_exports;
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
166
|
+
//# sourceMappingURL=chunk-TRGAMKHX.cjs.map
|
|
167
|
+
//# sourceMappingURL=chunk-TRGAMKHX.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/tools.ts"],"names":["__export","stringify","zodToJsonSchema","handleError","tool","HTTPException","tools","validateBody","isVercelTool","result"],"mappings":";;;;;;;;;;;AAAA,IAAA,aAAA,GA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AA,EAAS,kBAAkB,CAAA;AAAA,IAC5D;AAEA,IAAA,IAAI,CAAC,MAAM,OAAA,EAAS;AAClB,MAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,IACpE;AAOA,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,OAAA,CAAQ;AAAA,MAChC,OAAA,EAAS,IAAA;AAAA,MACT,cAAA;AAAA,MACA,MAAA;AAAA,MACA,KAAA,EAAO,OAAA;AAAA;AAAA,MAEP,cAAA,EAAgB,EAAE,WAAA,EAAa,MAAA,EAAU;AAAA,MACzC,SAAS,YAAY;AAAA,MAAC;AAAA,KACvB,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAOF,6BAAA,CAAY,OAAO,sBAAsB,CAAA;AAAA,EAClD;AACF","file":"chunk-TRGAMKHX.cjs","sourcesContent":["import type { RuntimeContext } from '@mastra/core/di';\nimport type { ToolAction, VercelTool } from '@mastra/core/tools';\nimport { isVercelTool } from '@mastra/core/tools';\nimport { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport { stringify } from 'superjson';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface ToolsContext extends Context {\n tools?: Record<string, ToolAction | VercelTool>;\n toolId?: string;\n runId?: string;\n}\n\n// Tool handlers\nexport async function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>) {\n try {\n if (!tools) {\n return {};\n }\n\n const serializedTools = Object.entries(tools).reduce(\n (acc, [id, _tool]) => {\n const tool = _tool as any;\n acc[id] = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n return acc;\n },\n {} as Record<string, any>,\n );\n\n return serializedTools;\n } catch (error) {\n return handleError(error, 'Error getting tools');\n }\n}\n\nexport async function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>) {\n try {\n const tool = Object.values(tools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const serializedTool = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n\n return serializedTool;\n } catch (error) {\n return handleError(error, 'Error getting tool');\n }\n}\n\nexport function executeToolHandler(tools: ToolsContext['tools']) {\n return async ({\n mastra,\n runId,\n toolId,\n data,\n runtimeContext,\n }: Pick<ToolsContext, 'mastra' | 'toolId' | 'runId'> & {\n data?: unknown;\n runtimeContext: RuntimeContext;\n }) => {\n try {\n if (!toolId) {\n throw new HTTPException(400, { message: 'Tool ID is required' });\n }\n\n const tool = Object.values(tools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n if (!tool?.execute) {\n throw new HTTPException(400, { message: 'Tool is not executable' });\n }\n\n validateBody({ data });\n\n if (isVercelTool(tool)) {\n const result = await (tool as any).execute(data);\n return result;\n }\n\n const result = await tool.execute({\n context: data!,\n mastra,\n runId,\n runtimeContext,\n // TODO: Pass proper tracing context when server API supports tracing\n tracingContext: { currentSpan: undefined },\n suspend: async () => {},\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error executing tool');\n }\n };\n}\n\nexport async function getAgentToolHandler({\n mastra,\n agentId,\n toolId,\n runtimeContext,\n}: Pick<ToolsContext, 'mastra' | 'toolId'> & {\n agentId?: string;\n runtimeContext: RuntimeContext;\n}) {\n try {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const agentTools = await agent.getTools({ runtimeContext });\n\n const tool = Object.values(agentTools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const serializedTool = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n\n return serializedTool;\n } catch (error) {\n return handleError(error, 'Error getting agent tool');\n }\n}\n\nexport async function executeAgentToolHandler({\n mastra,\n agentId,\n toolId,\n data,\n runtimeContext,\n}: Pick<ToolsContext, 'mastra' | 'toolId'> & {\n agentId?: string;\n data: any;\n runtimeContext: RuntimeContext;\n}) {\n try {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (!agent) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const agentTools = await agent.getTools({ runtimeContext });\n\n const tool = Object.values(agentTools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n if (!tool?.execute) {\n throw new HTTPException(400, { message: 'Tool is not executable' });\n }\n\n // if (isVercelTool(tool)) {\n // const result = await (tool as any).execute(data);\n // return result;\n // }\n\n const result = await tool.execute({\n context: data,\n runtimeContext,\n mastra,\n runId: agentId,\n // TODO: Pass proper tracing context when server API supports tracing\n tracingContext: { currentSpan: undefined },\n suspend: async () => {},\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing tool');\n }\n}\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkGU4EWMZB_cjs = require('./chunk-GU4EWMZB.cjs');
|
|
4
|
+
var zodToJson = require('@mastra/core/utils/zod-to-json');
|
|
5
|
+
|
|
6
|
+
function getSteps(steps, path) {
|
|
7
|
+
return Object.entries(steps).reduce((acc, [key, step]) => {
|
|
8
|
+
const fullKey = path ? `${path}.${key}` : key;
|
|
9
|
+
acc[fullKey] = {
|
|
10
|
+
id: step.id,
|
|
11
|
+
description: step.description,
|
|
12
|
+
inputSchema: step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.inputSchema)) : void 0,
|
|
13
|
+
outputSchema: step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.outputSchema)) : void 0,
|
|
14
|
+
resumeSchema: step.resumeSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
15
|
+
suspendSchema: step.suspendSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.suspendSchema)) : void 0,
|
|
16
|
+
isWorkflow: step.component === "WORKFLOW",
|
|
17
|
+
component: step.component
|
|
18
|
+
};
|
|
19
|
+
if (step.component === "WORKFLOW" && step.steps) {
|
|
20
|
+
const nestedSteps = getSteps(step.steps, fullKey) || {};
|
|
21
|
+
acc = { ...acc, ...nestedSteps };
|
|
22
|
+
}
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
}
|
|
26
|
+
function getWorkflowInfo(workflow) {
|
|
27
|
+
return {
|
|
28
|
+
name: workflow.name,
|
|
29
|
+
description: workflow.description,
|
|
30
|
+
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
31
|
+
acc[key] = {
|
|
32
|
+
id: step.id,
|
|
33
|
+
description: step.description,
|
|
34
|
+
inputSchema: step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.inputSchema)) : void 0,
|
|
35
|
+
outputSchema: step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.outputSchema)) : void 0,
|
|
36
|
+
resumeSchema: step.resumeSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.resumeSchema)) : void 0,
|
|
37
|
+
suspendSchema: step.suspendSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.suspendSchema)) : void 0,
|
|
38
|
+
component: step.component
|
|
39
|
+
};
|
|
40
|
+
return acc;
|
|
41
|
+
}, {}),
|
|
42
|
+
allSteps: getSteps(workflow.steps) || {},
|
|
43
|
+
stepGraph: workflow.serializedStepGraph,
|
|
44
|
+
inputSchema: workflow.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.inputSchema)) : void 0,
|
|
45
|
+
outputSchema: workflow.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.outputSchema)) : void 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var WorkflowRegistry = class {
|
|
49
|
+
static additionalWorkflows = {};
|
|
50
|
+
/**
|
|
51
|
+
* Register a workflow temporarily
|
|
52
|
+
*/
|
|
53
|
+
static registerTemporaryWorkflow(id, workflow) {
|
|
54
|
+
this.additionalWorkflows[id] = workflow;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Register all workflows from map
|
|
58
|
+
*/
|
|
59
|
+
static registerTemporaryWorkflows(workflows, mastra) {
|
|
60
|
+
for (const [id, workflow] of Object.entries(workflows)) {
|
|
61
|
+
if (mastra) {
|
|
62
|
+
workflow.__registerMastra(mastra);
|
|
63
|
+
workflow.__registerPrimitives({
|
|
64
|
+
logger: mastra.getLogger(),
|
|
65
|
+
telemetry: mastra.getTelemetry(),
|
|
66
|
+
storage: mastra.getStorage(),
|
|
67
|
+
memory: mastra.getMemory(),
|
|
68
|
+
agents: mastra.getAgents(),
|
|
69
|
+
tts: mastra.getTTS(),
|
|
70
|
+
vectors: mastra.getVectors()
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
this.additionalWorkflows[id] = workflow;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get a workflow by ID from the registry (returns undefined if not found)
|
|
78
|
+
*/
|
|
79
|
+
static getWorkflow(workflowId) {
|
|
80
|
+
return this.additionalWorkflows[workflowId];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get all workflows from the registry
|
|
84
|
+
*/
|
|
85
|
+
static getAllWorkflows() {
|
|
86
|
+
return { ...this.additionalWorkflows };
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Clean up a temporary workflow
|
|
90
|
+
*/
|
|
91
|
+
static cleanupTemporaryWorkflow(workflowId) {
|
|
92
|
+
delete this.additionalWorkflows[workflowId];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Clean up all registered workflows
|
|
96
|
+
*/
|
|
97
|
+
static cleanup() {
|
|
98
|
+
this.additionalWorkflows = {};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Check if a workflow ID is a valid agent-builder workflow
|
|
102
|
+
*/
|
|
103
|
+
static isAgentBuilderWorkflow(workflowId) {
|
|
104
|
+
return workflowId in this.additionalWorkflows;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get all registered temporary workflow IDs (for debugging)
|
|
108
|
+
*/
|
|
109
|
+
static getRegisteredWorkflowIds() {
|
|
110
|
+
return Object.keys(this.additionalWorkflows);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
function convertInstructionsToString(message) {
|
|
114
|
+
if (!message) {
|
|
115
|
+
return "";
|
|
116
|
+
}
|
|
117
|
+
if (typeof message === "string") {
|
|
118
|
+
return message;
|
|
119
|
+
}
|
|
120
|
+
if (Array.isArray(message)) {
|
|
121
|
+
return message.map((m) => {
|
|
122
|
+
if (typeof m === "string") {
|
|
123
|
+
return m;
|
|
124
|
+
}
|
|
125
|
+
return typeof m.content === "string" ? m.content : "";
|
|
126
|
+
}).filter((content) => content).join("\n");
|
|
127
|
+
}
|
|
128
|
+
return typeof message.content === "string" ? message.content : "";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports.WorkflowRegistry = WorkflowRegistry;
|
|
132
|
+
exports.convertInstructionsToString = convertInstructionsToString;
|
|
133
|
+
exports.getWorkflowInfo = getWorkflowInfo;
|
|
134
|
+
//# sourceMappingURL=chunk-VY4ENABS.cjs.map
|
|
135
|
+
//# sourceMappingURL=chunk-VY4ENABS.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/utils.ts"],"names":["stringify","zodToJsonSchema"],"mappings":";;;;;AAKA,SAAS,QAAA,CAAS,OAA0C,IAAA,EAAe;AACzE,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CAAE,MAAA,CAAY,CAAC,GAAA,EAAK,CAAC,GAAA,EAAK,IAAI,CAAA,KAAM;AAC7D,IAAA,MAAM,UAAU,IAAA,GAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA,GAAK,GAAA;AAC1C,IAAA,GAAA,CAAI,OAAO,CAAA,GAAI;AAAA,MACb,IAAI,IAAA,CAAK,EAAA;AAAA,MACT,aAAa,IAAA,CAAK,WAAA;AAAA,MAClB,WAAA,EAAa,KAAK,WAAA,GAAcA,2BAAA,CAAUC,0BAAgB,IAAA,CAAK,WAAW,CAAC,CAAA,GAAI,MAAA;AAAA,MAC/E,YAAA,EAAc,KAAK,YAAA,GAAeD,2BAAA,CAAUC,0BAAgB,IAAA,CAAK,YAAY,CAAC,CAAA,GAAI,MAAA;AAAA,MAClF,YAAA,EAAc,KAAK,YAAA,GAAeD,2BAAA,CAAUC,0BAAgB,IAAA,CAAK,YAAY,CAAC,CAAA,GAAI,MAAA;AAAA,MAClF,aAAA,EAAe,KAAK,aAAA,GAAgBD,2BAAA,CAAUC,0BAAgB,IAAA,CAAK,aAAa,CAAC,CAAA,GAAI,MAAA;AAAA,MACrF,UAAA,EAAY,KAAK,SAAA,KAAc,UAAA;AAAA,MAC/B,WAAW,IAAA,CAAK;AAAA,KAClB;AAEA,IAAA,IAAI,IAAA,CAAK,SAAA,KAAc,UAAA,IAAc,IAAA,CAAK,KAAA,EAAO;AAC/C,MAAA,MAAM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,OAAA,GAAU,EAAA;AACjE","file":"chunk-VY4ENABS.cjs","sourcesContent":["import type { SystemMessage } from '@mastra/core';\nimport { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport type { StepWithComponent, Workflow, WorkflowInfo } from '@mastra/core/workflows';\nimport { stringify } from 'superjson';\n\nfunction getSteps(steps: Record<string, StepWithComponent>, path?: string) {\n return Object.entries(steps).reduce<any>((acc, [key, step]) => {\n const fullKey = path ? `${path}.${key}` : key;\n acc[fullKey] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n isWorkflow: step.component === 'WORKFLOW',\n component: step.component,\n };\n\n if (step.component === 'WORKFLOW' && step.steps) {\n const nestedSteps = getSteps(step.steps, fullKey) || {};\n acc = { ...acc, ...nestedSteps };\n }\n\n return acc;\n }, {});\n}\n\nexport function getWorkflowInfo(workflow: Workflow): WorkflowInfo {\n return {\n name: workflow.name,\n description: workflow.description,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n acc[key] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n component: step.component,\n };\n return acc;\n }, {}),\n allSteps: getSteps(workflow.steps) || {},\n stepGraph: workflow.serializedStepGraph,\n inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : undefined,\n outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : undefined,\n };\n}\n\n/**\n * Workflow Registry for temporarily registering additional workflows\n * that are not part of the user's Mastra instance (e.g., internal template workflows)\n */\nexport class WorkflowRegistry {\n private static additionalWorkflows: Record<string, Workflow> = {};\n\n /**\n * Register a workflow temporarily\n */\n static registerTemporaryWorkflow(id: string, workflow: Workflow): void {\n this.additionalWorkflows[id] = workflow;\n }\n\n /**\n * Register all workflows from map\n */\n static registerTemporaryWorkflows(workflows: Record<string, Workflow>, mastra?: any): void {\n for (const [id, workflow] of Object.entries(workflows)) {\n // Register Mastra instance with the workflow if provided\n if (mastra) {\n workflow.__registerMastra(mastra);\n workflow.__registerPrimitives({\n logger: mastra.getLogger(),\n telemetry: mastra.getTelemetry(),\n storage: mastra.getStorage(),\n memory: mastra.getMemory(),\n agents: mastra.getAgents(),\n tts: mastra.getTTS(),\n vectors: mastra.getVectors(),\n });\n }\n this.additionalWorkflows[id] = workflow;\n }\n }\n\n /**\n * Get a workflow by ID from the registry (returns undefined if not found)\n */\n static getWorkflow(workflowId: string): Workflow | undefined {\n return this.additionalWorkflows[workflowId];\n }\n\n /**\n * Get all workflows from the registry\n */\n static getAllWorkflows(): Record<string, Workflow> {\n return { ...this.additionalWorkflows };\n }\n\n /**\n * Clean up a temporary workflow\n */\n static cleanupTemporaryWorkflow(workflowId: string): void {\n delete this.additionalWorkflows[workflowId];\n }\n /**\n * Clean up all registered workflows\n */\n static cleanup(): void {\n // Clear all workflows (since we register all agent-builder workflows each time)\n this.additionalWorkflows = {};\n }\n\n /**\n * Check if a workflow ID is a valid agent-builder workflow\n */\n static isAgentBuilderWorkflow(workflowId: string): boolean {\n return workflowId in this.additionalWorkflows;\n }\n\n /**\n * Get all registered temporary workflow IDs (for debugging)\n */\n static getRegisteredWorkflowIds(): string[] {\n return Object.keys(this.additionalWorkflows);\n }\n}\n\nexport function convertInstructionsToString(message: SystemMessage): string {\n if (!message) {\n return '';\n }\n\n if (typeof message === 'string') {\n return message;\n }\n\n if (Array.isArray(message)) {\n return message\n .map(m => {\n if (typeof m === 'string') {\n return m;\n }\n // Safely extract content from message objects\n return typeof m.content === 'string' ? m.content : '';\n })\n .filter(content => content) // Remove empty strings\n .join('\\n');\n }\n\n // Handle single message object - safely extract content\n return typeof message.content === 'string' ? message.content : '';\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { validateBody } from './chunk-
|
|
1
|
+
import { validateBody } from './chunk-4QCXUEAT.js';
|
|
2
2
|
import { handleError } from './chunk-CY4TP3FK.js';
|
|
3
3
|
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
4
|
-
import { __export } from './chunk-
|
|
5
|
-
import { generateEmptyFromSchema } from '@mastra/core';
|
|
4
|
+
import { __export } from './chunk-PR4QN5HX.js';
|
|
5
|
+
import { generateEmptyFromSchema } from '@mastra/core/utils';
|
|
6
6
|
|
|
7
7
|
// src/server/handlers/memory.ts
|
|
8
8
|
var memory_exports = {};
|
|
@@ -16,6 +16,7 @@ __export(memory_exports, {
|
|
|
16
16
|
getMessagesPaginatedHandler: () => getMessagesPaginatedHandler,
|
|
17
17
|
getThreadByIdHandler: () => getThreadByIdHandler,
|
|
18
18
|
getThreadsHandler: () => getThreadsHandler,
|
|
19
|
+
getThreadsPaginatedHandler: () => getThreadsPaginatedHandler,
|
|
19
20
|
getWorkingMemoryHandler: () => getWorkingMemoryHandler,
|
|
20
21
|
saveMessagesHandler: () => saveMessagesHandler,
|
|
21
22
|
searchMemoryHandler: () => searchMemoryHandler,
|
|
@@ -25,33 +26,26 @@ __export(memory_exports, {
|
|
|
25
26
|
async function getMemoryFromContext({
|
|
26
27
|
mastra,
|
|
27
28
|
agentId,
|
|
28
|
-
networkId,
|
|
29
29
|
runtimeContext
|
|
30
30
|
}) {
|
|
31
31
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
32
32
|
if (agentId && !agent) {
|
|
33
33
|
throw new HTTPException(404, { message: "Agent not found" });
|
|
34
34
|
}
|
|
35
|
-
const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
|
|
36
|
-
if (networkId && !network) {
|
|
37
|
-
throw new HTTPException(404, { message: "Network not found" });
|
|
38
|
-
}
|
|
39
35
|
if (agent) {
|
|
40
|
-
return await agent?.getMemory(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return await network?.getMemory({ runtimeContext }) || mastra.getMemory();
|
|
36
|
+
return await agent?.getMemory({
|
|
37
|
+
runtimeContext
|
|
38
|
+
}) || mastra.getMemory();
|
|
44
39
|
}
|
|
45
40
|
return mastra.getMemory();
|
|
46
41
|
}
|
|
47
42
|
async function getMemoryStatusHandler({
|
|
48
43
|
mastra,
|
|
49
44
|
agentId,
|
|
50
|
-
networkId,
|
|
51
45
|
runtimeContext
|
|
52
46
|
}) {
|
|
53
47
|
try {
|
|
54
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
48
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
55
49
|
if (!memory) {
|
|
56
50
|
return { result: false };
|
|
57
51
|
}
|
|
@@ -63,11 +57,10 @@ async function getMemoryStatusHandler({
|
|
|
63
57
|
async function getMemoryConfigHandler({
|
|
64
58
|
mastra,
|
|
65
59
|
agentId,
|
|
66
|
-
networkId,
|
|
67
60
|
runtimeContext
|
|
68
61
|
}) {
|
|
69
62
|
try {
|
|
70
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
63
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
71
64
|
if (!memory) {
|
|
72
65
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
73
66
|
}
|
|
@@ -81,13 +74,12 @@ async function getThreadsHandler({
|
|
|
81
74
|
mastra,
|
|
82
75
|
agentId,
|
|
83
76
|
resourceId,
|
|
84
|
-
networkId,
|
|
85
77
|
runtimeContext,
|
|
86
78
|
orderBy,
|
|
87
79
|
sortDirection
|
|
88
80
|
}) {
|
|
89
81
|
try {
|
|
90
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
82
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
91
83
|
if (!memory) {
|
|
92
84
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
93
85
|
}
|
|
@@ -102,16 +94,43 @@ async function getThreadsHandler({
|
|
|
102
94
|
return handleError(error, "Error getting threads");
|
|
103
95
|
}
|
|
104
96
|
}
|
|
97
|
+
async function getThreadsPaginatedHandler({
|
|
98
|
+
mastra,
|
|
99
|
+
agentId,
|
|
100
|
+
resourceId,
|
|
101
|
+
runtimeContext,
|
|
102
|
+
page,
|
|
103
|
+
perPage,
|
|
104
|
+
orderBy,
|
|
105
|
+
sortDirection
|
|
106
|
+
}) {
|
|
107
|
+
try {
|
|
108
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
109
|
+
if (!memory) {
|
|
110
|
+
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
111
|
+
}
|
|
112
|
+
validateBody({ resourceId });
|
|
113
|
+
const result = await memory.getThreadsByResourceIdPaginated({
|
|
114
|
+
resourceId,
|
|
115
|
+
page,
|
|
116
|
+
perPage,
|
|
117
|
+
orderBy,
|
|
118
|
+
sortDirection
|
|
119
|
+
});
|
|
120
|
+
return result;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
return handleError(error, "Error getting paginated threads");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
105
125
|
async function getThreadByIdHandler({
|
|
106
126
|
mastra,
|
|
107
127
|
agentId,
|
|
108
128
|
threadId,
|
|
109
|
-
networkId,
|
|
110
129
|
runtimeContext
|
|
111
130
|
}) {
|
|
112
131
|
try {
|
|
113
132
|
validateBody({ threadId });
|
|
114
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
133
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
115
134
|
if (!memory) {
|
|
116
135
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
117
136
|
}
|
|
@@ -128,11 +147,10 @@ async function saveMessagesHandler({
|
|
|
128
147
|
mastra,
|
|
129
148
|
agentId,
|
|
130
149
|
body,
|
|
131
|
-
networkId,
|
|
132
150
|
runtimeContext
|
|
133
151
|
}) {
|
|
134
152
|
try {
|
|
135
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
153
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
136
154
|
if (!memory) {
|
|
137
155
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
138
156
|
}
|
|
@@ -163,11 +181,10 @@ async function createThreadHandler({
|
|
|
163
181
|
mastra,
|
|
164
182
|
agentId,
|
|
165
183
|
body,
|
|
166
|
-
networkId,
|
|
167
184
|
runtimeContext
|
|
168
185
|
}) {
|
|
169
186
|
try {
|
|
170
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
187
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
171
188
|
if (!memory) {
|
|
172
189
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
173
190
|
}
|
|
@@ -188,11 +205,10 @@ async function updateThreadHandler({
|
|
|
188
205
|
agentId,
|
|
189
206
|
threadId,
|
|
190
207
|
body,
|
|
191
|
-
networkId,
|
|
192
208
|
runtimeContext
|
|
193
209
|
}) {
|
|
194
210
|
try {
|
|
195
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
211
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
196
212
|
if (!body) {
|
|
197
213
|
throw new HTTPException(400, { message: "Body is required" });
|
|
198
214
|
}
|
|
@@ -224,12 +240,11 @@ async function deleteThreadHandler({
|
|
|
224
240
|
mastra,
|
|
225
241
|
agentId,
|
|
226
242
|
threadId,
|
|
227
|
-
networkId,
|
|
228
243
|
runtimeContext
|
|
229
244
|
}) {
|
|
230
245
|
try {
|
|
231
246
|
validateBody({ threadId });
|
|
232
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
247
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
233
248
|
if (!memory) {
|
|
234
249
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
235
250
|
}
|
|
@@ -271,7 +286,6 @@ async function getMessagesHandler({
|
|
|
271
286
|
agentId,
|
|
272
287
|
threadId,
|
|
273
288
|
limit,
|
|
274
|
-
networkId,
|
|
275
289
|
runtimeContext
|
|
276
290
|
}) {
|
|
277
291
|
if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
|
|
@@ -279,7 +293,7 @@ async function getMessagesHandler({
|
|
|
279
293
|
}
|
|
280
294
|
try {
|
|
281
295
|
validateBody({ threadId });
|
|
282
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
296
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
283
297
|
if (!memory) {
|
|
284
298
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
285
299
|
}
|
|
@@ -301,12 +315,11 @@ async function getWorkingMemoryHandler({
|
|
|
301
315
|
agentId,
|
|
302
316
|
threadId,
|
|
303
317
|
resourceId,
|
|
304
|
-
networkId,
|
|
305
318
|
runtimeContext,
|
|
306
319
|
memoryConfig
|
|
307
320
|
}) {
|
|
308
321
|
try {
|
|
309
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
322
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
310
323
|
validateBody({ threadId });
|
|
311
324
|
if (!memory) {
|
|
312
325
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
@@ -328,12 +341,11 @@ async function updateWorkingMemoryHandler({
|
|
|
328
341
|
agentId,
|
|
329
342
|
threadId,
|
|
330
343
|
body,
|
|
331
|
-
networkId,
|
|
332
344
|
runtimeContext
|
|
333
345
|
}) {
|
|
334
346
|
try {
|
|
335
347
|
validateBody({ threadId });
|
|
336
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
348
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
337
349
|
const { resourceId, memoryConfig, workingMemory } = body;
|
|
338
350
|
if (!memory) {
|
|
339
351
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
@@ -352,14 +364,13 @@ async function deleteMessagesHandler({
|
|
|
352
364
|
mastra,
|
|
353
365
|
agentId,
|
|
354
366
|
messageIds,
|
|
355
|
-
networkId,
|
|
356
367
|
runtimeContext
|
|
357
368
|
}) {
|
|
358
369
|
try {
|
|
359
370
|
if (messageIds === void 0 || messageIds === null) {
|
|
360
371
|
throw new HTTPException(400, { message: "messageIds is required" });
|
|
361
372
|
}
|
|
362
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
373
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
363
374
|
if (!memory) {
|
|
364
375
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
365
376
|
}
|
|
@@ -380,13 +391,12 @@ async function searchMemoryHandler({
|
|
|
380
391
|
resourceId,
|
|
381
392
|
threadId,
|
|
382
393
|
limit = 20,
|
|
383
|
-
networkId,
|
|
384
394
|
runtimeContext,
|
|
385
395
|
memoryConfig
|
|
386
396
|
}) {
|
|
387
397
|
try {
|
|
388
398
|
validateBody({ searchQuery, resourceId });
|
|
389
|
-
const memory = await getMemoryFromContext({ mastra, agentId,
|
|
399
|
+
const memory = await getMemoryFromContext({ mastra, agentId, runtimeContext });
|
|
390
400
|
if (!memory) {
|
|
391
401
|
throw new HTTPException(400, { message: "Memory is not initialized" });
|
|
392
402
|
}
|
|
@@ -536,6 +546,6 @@ async function searchMemoryHandler({
|
|
|
536
546
|
}
|
|
537
547
|
}
|
|
538
548
|
|
|
539
|
-
export { createThreadHandler, deleteMessagesHandler, deleteThreadHandler, getMemoryConfigHandler, getMemoryStatusHandler, getMessagesHandler, getMessagesPaginatedHandler, getThreadByIdHandler, getThreadsHandler, getWorkingMemoryHandler, memory_exports, saveMessagesHandler, searchMemoryHandler, updateThreadHandler, updateWorkingMemoryHandler };
|
|
540
|
-
//# sourceMappingURL=chunk-
|
|
541
|
-
//# sourceMappingURL=chunk-
|
|
549
|
+
export { createThreadHandler, deleteMessagesHandler, deleteThreadHandler, getMemoryConfigHandler, getMemoryStatusHandler, getMessagesHandler, getMessagesPaginatedHandler, getThreadByIdHandler, getThreadsHandler, getThreadsPaginatedHandler, getWorkingMemoryHandler, memory_exports, saveMessagesHandler, searchMemoryHandler, updateThreadHandler, updateWorkingMemoryHandler };
|
|
550
|
+
//# sourceMappingURL=chunk-WHABYJRY.js.map
|
|
551
|
+
//# sourceMappingURL=chunk-WHABYJRY.js.map
|