@mastra/server 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-transpile-packages-20250724123433
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 +390 -45
- package/dist/_tsup-dts-rollup.d.ts +390 -45
- package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
- package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
- package/dist/chunk-4D66QEKC.js +81 -0
- package/dist/{chunk-W7VCKPAD.js → chunk-5PQQ42EZ.js} +9 -9
- package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
- package/dist/chunk-B2PAS2IB.cjs +514 -0
- package/dist/{chunk-J3PKLB3A.js → chunk-BK4XT6EG.js} +56 -17
- package/dist/chunk-CBFTEHOO.cjs +157 -0
- package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
- package/dist/{chunk-ZE5AAC4I.cjs → chunk-FRVBFMO2.cjs} +26 -36
- package/dist/{chunk-DJJIUEL2.js → chunk-G4L7OMCA.js} +135 -26
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
- package/dist/{chunk-KUNQFY2W.js → chunk-H7DMHBKY.js} +190 -57
- package/dist/{chunk-YIOVBYZH.cjs → chunk-JMLYCXMK.cjs} +43 -43
- package/dist/{chunk-CP55EVBK.js → chunk-KHZKYUNR.js} +15 -11
- package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/{chunk-YWLUOY3D.cjs → chunk-LI436ITD.cjs} +107 -69
- package/dist/{chunk-TJKLBTFB.js → chunk-LRCAAFUA.js} +10 -20
- package/dist/{chunk-A3KDUGS7.cjs → chunk-LZ3VJXSO.cjs} +70 -31
- package/dist/{chunk-LIVAK2DM.js → chunk-MEGCYGBU.js} +108 -70
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/chunk-QGX47B5D.cjs +86 -0
- package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
- package/dist/{chunk-CMMOIUFC.cjs → chunk-RHSWAXKB.cjs} +34 -30
- package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/chunk-VULESSU5.js +149 -0
- package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
- package/dist/chunk-Z75RYULP.cjs +333 -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 +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 +21 -9
- package/dist/server/handlers/memory.d.cts +3 -0
- package/dist/server/handlers/memory.d.ts +3 -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 +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 +24 -12
- 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 +15 -15
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-DQLE3DVM.js +0 -49
- package/dist/chunk-M5ABIP7D.js +0 -11
- package/dist/chunk-MMO2HDM6.cjs +0 -378
- package/dist/chunk-NEOOQUKW.cjs +0 -54
- package/dist/chunk-Y7UWRW5X.cjs +0 -221
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
|
|
4
|
+
var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
|
|
5
|
+
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
6
|
+
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
7
7
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
8
8
|
var runtimeContext = require('@mastra/core/runtime-context');
|
|
9
9
|
|
|
@@ -25,12 +25,14 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
25
25
|
const instructions = await agent.getInstructions({ runtimeContext });
|
|
26
26
|
const tools = await agent.getTools({ runtimeContext });
|
|
27
27
|
const llm = await agent.getLLM({ runtimeContext });
|
|
28
|
+
const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
|
|
29
|
+
const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
|
|
28
30
|
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
29
31
|
const _tool = tool;
|
|
30
32
|
acc[key] = {
|
|
31
33
|
..._tool,
|
|
32
|
-
inputSchema: _tool.inputSchema ?
|
|
33
|
-
outputSchema: _tool.outputSchema ?
|
|
34
|
+
inputSchema: _tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
35
|
+
outputSchema: _tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
34
36
|
};
|
|
35
37
|
return acc;
|
|
36
38
|
}, {});
|
|
@@ -59,8 +61,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
59
61
|
workflows: serializedAgentWorkflows,
|
|
60
62
|
provider: llm?.getProvider(),
|
|
61
63
|
modelId: llm?.getModelId(),
|
|
62
|
-
defaultGenerateOptions
|
|
63
|
-
defaultStreamOptions
|
|
64
|
+
defaultGenerateOptions,
|
|
65
|
+
defaultStreamOptions
|
|
64
66
|
};
|
|
65
67
|
})
|
|
66
68
|
);
|
|
@@ -70,26 +72,27 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
70
72
|
}, {});
|
|
71
73
|
return serializedAgents;
|
|
72
74
|
} catch (error) {
|
|
73
|
-
return
|
|
75
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting agents");
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
async function getAgentByIdHandler({
|
|
77
79
|
mastra,
|
|
78
80
|
runtimeContext,
|
|
79
|
-
agentId
|
|
81
|
+
agentId,
|
|
82
|
+
isPlayground = false
|
|
80
83
|
}) {
|
|
81
84
|
try {
|
|
82
85
|
const agent = mastra.getAgent(agentId);
|
|
83
86
|
if (!agent) {
|
|
84
|
-
throw new
|
|
87
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
|
|
85
88
|
}
|
|
86
89
|
const tools = await agent.getTools({ runtimeContext });
|
|
87
90
|
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
88
91
|
const _tool = tool;
|
|
89
92
|
acc[key] = {
|
|
90
93
|
..._tool,
|
|
91
|
-
inputSchema: _tool.inputSchema ?
|
|
92
|
-
outputSchema: _tool.outputSchema ?
|
|
94
|
+
inputSchema: _tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
95
|
+
outputSchema: _tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
93
96
|
};
|
|
94
97
|
return acc;
|
|
95
98
|
}, {});
|
|
@@ -102,7 +105,16 @@ async function getAgentByIdHandler({
|
|
|
102
105
|
return {
|
|
103
106
|
...acc,
|
|
104
107
|
[key]: {
|
|
105
|
-
name: workflow.name
|
|
108
|
+
name: workflow.name,
|
|
109
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
110
|
+
return {
|
|
111
|
+
...acc2,
|
|
112
|
+
[key2]: {
|
|
113
|
+
id: step.id,
|
|
114
|
+
description: step.description
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}, {})
|
|
106
118
|
}
|
|
107
119
|
};
|
|
108
120
|
}, {});
|
|
@@ -110,8 +122,24 @@ async function getAgentByIdHandler({
|
|
|
110
122
|
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
111
123
|
}
|
|
112
124
|
}
|
|
113
|
-
|
|
125
|
+
let proxyRuntimeContext = runtimeContext;
|
|
126
|
+
if (isPlayground) {
|
|
127
|
+
proxyRuntimeContext = new Proxy(runtimeContext, {
|
|
128
|
+
get(target, prop) {
|
|
129
|
+
if (prop === "get") {
|
|
130
|
+
return function(key) {
|
|
131
|
+
const value = target.get(key);
|
|
132
|
+
return value ?? `<${key}>`;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return Reflect.get(target, prop);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
|
|
114
140
|
const llm = await agent.getLLM({ runtimeContext });
|
|
141
|
+
const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
|
|
142
|
+
const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
|
|
115
143
|
return {
|
|
116
144
|
name: agent.name,
|
|
117
145
|
instructions,
|
|
@@ -119,11 +147,11 @@ async function getAgentByIdHandler({
|
|
|
119
147
|
workflows: serializedAgentWorkflows,
|
|
120
148
|
provider: llm?.getProvider(),
|
|
121
149
|
modelId: llm?.getModelId(),
|
|
122
|
-
defaultGenerateOptions
|
|
123
|
-
defaultStreamOptions
|
|
150
|
+
defaultGenerateOptions,
|
|
151
|
+
defaultStreamOptions
|
|
124
152
|
};
|
|
125
153
|
} catch (error) {
|
|
126
|
-
return
|
|
154
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting agent");
|
|
127
155
|
}
|
|
128
156
|
}
|
|
129
157
|
async function getEvalsByAgentIdHandler({
|
|
@@ -142,7 +170,7 @@ async function getEvalsByAgentIdHandler({
|
|
|
142
170
|
evals
|
|
143
171
|
};
|
|
144
172
|
} catch (error) {
|
|
145
|
-
return
|
|
173
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting test evals");
|
|
146
174
|
}
|
|
147
175
|
}
|
|
148
176
|
async function getLiveEvalsByAgentIdHandler({
|
|
@@ -161,19 +189,20 @@ async function getLiveEvalsByAgentIdHandler({
|
|
|
161
189
|
evals
|
|
162
190
|
};
|
|
163
191
|
} catch (error) {
|
|
164
|
-
return
|
|
192
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting live evals");
|
|
165
193
|
}
|
|
166
194
|
}
|
|
167
195
|
async function generateHandler({
|
|
168
196
|
mastra,
|
|
169
197
|
runtimeContext: runtimeContext$1,
|
|
170
198
|
agentId,
|
|
171
|
-
body
|
|
199
|
+
body,
|
|
200
|
+
abortSignal
|
|
172
201
|
}) {
|
|
173
202
|
try {
|
|
174
203
|
const agent = mastra.getAgent(agentId);
|
|
175
204
|
if (!agent) {
|
|
176
|
-
throw new
|
|
205
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
|
|
177
206
|
}
|
|
178
207
|
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
179
208
|
const finalResourceId = resourceId ?? resourceid;
|
|
@@ -181,28 +210,30 @@ async function generateHandler({
|
|
|
181
210
|
...Array.from(runtimeContext$1.entries()),
|
|
182
211
|
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
183
212
|
]);
|
|
184
|
-
|
|
213
|
+
chunkCCGRCYWJ_cjs.validateBody({ messages });
|
|
185
214
|
const result = await agent.generate(messages, {
|
|
186
215
|
...rest,
|
|
187
216
|
// @ts-expect-error TODO fix types
|
|
188
217
|
resourceId: finalResourceId,
|
|
189
|
-
runtimeContext: finalRuntimeContext
|
|
218
|
+
runtimeContext: finalRuntimeContext,
|
|
219
|
+
signal: abortSignal
|
|
190
220
|
});
|
|
191
221
|
return result;
|
|
192
222
|
} catch (error) {
|
|
193
|
-
return
|
|
223
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error generating from agent");
|
|
194
224
|
}
|
|
195
225
|
}
|
|
196
226
|
async function streamGenerateHandler({
|
|
197
227
|
mastra,
|
|
198
228
|
runtimeContext: runtimeContext$1,
|
|
199
229
|
agentId,
|
|
200
|
-
body
|
|
230
|
+
body,
|
|
231
|
+
abortSignal
|
|
201
232
|
}) {
|
|
202
233
|
try {
|
|
203
234
|
const agent = mastra.getAgent(agentId);
|
|
204
235
|
if (!agent) {
|
|
205
|
-
throw new
|
|
236
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
|
|
206
237
|
}
|
|
207
238
|
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
208
239
|
const finalResourceId = resourceId ?? resourceid;
|
|
@@ -210,23 +241,31 @@ async function streamGenerateHandler({
|
|
|
210
241
|
...Array.from(runtimeContext$1.entries()),
|
|
211
242
|
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
212
243
|
]);
|
|
213
|
-
|
|
244
|
+
chunkCCGRCYWJ_cjs.validateBody({ messages });
|
|
214
245
|
const streamResult = await agent.stream(messages, {
|
|
215
246
|
...rest,
|
|
216
247
|
// @ts-expect-error TODO fix types
|
|
217
248
|
resourceId: finalResourceId,
|
|
218
|
-
runtimeContext: finalRuntimeContext
|
|
249
|
+
runtimeContext: finalRuntimeContext,
|
|
250
|
+
signal: abortSignal
|
|
219
251
|
});
|
|
220
|
-
const streamResponse = rest.output ? streamResult.toTextStreamResponse(
|
|
252
|
+
const streamResponse = rest.output ? streamResult.toTextStreamResponse({
|
|
253
|
+
headers: {
|
|
254
|
+
"Transfer-Encoding": "chunked"
|
|
255
|
+
}
|
|
256
|
+
}) : streamResult.toDataStreamResponse({
|
|
221
257
|
sendUsage: true,
|
|
222
258
|
sendReasoning: true,
|
|
223
259
|
getErrorMessage: (error) => {
|
|
224
260
|
return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
|
|
261
|
+
},
|
|
262
|
+
headers: {
|
|
263
|
+
"Transfer-Encoding": "chunked"
|
|
225
264
|
}
|
|
226
265
|
});
|
|
227
266
|
return streamResponse;
|
|
228
267
|
} catch (error) {
|
|
229
|
-
|
|
268
|
+
return chunkPZQDCRPV_cjs.handleError(error, "error streaming agent response");
|
|
230
269
|
}
|
|
231
270
|
}
|
|
232
271
|
|