@mastra/deployer 0.14.0-alpha.3 → 0.14.0-alpha.5
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/build/analyze.cjs +3 -3
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/babel/remove-all-options-bundler.d.ts +2 -1
- package/dist/build/babel/remove-all-options-bundler.d.ts.map +1 -1
- package/dist/build/babel/remove-all-options-deployer.d.ts +5 -0
- package/dist/build/babel/remove-all-options-deployer.d.ts.map +1 -0
- package/dist/build/babel/remove-all-options-except.d.ts +2 -1
- package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
- package/dist/build/babel/remove-all-options-server.d.ts +2 -1
- package/dist/build/babel/remove-all-options-server.d.ts.map +1 -1
- package/dist/build/babel/remove-all-options-telemetry.d.ts +1 -1
- package/dist/build/babel/remove-all-options-telemetry.d.ts.map +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/bundlerOptions.d.ts +3 -2
- package/dist/build/bundlerOptions.d.ts.map +1 -1
- package/dist/build/customInstrumentation.d.ts.map +1 -1
- package/dist/build/deployer.d.ts +4 -3
- package/dist/build/deployer.d.ts.map +1 -1
- package/dist/build/index.cjs +12 -12
- package/dist/build/index.js +4 -4
- package/dist/build/plugins/esbuild.d.ts +3 -0
- package/dist/build/plugins/esbuild.d.ts.map +1 -0
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/build/serverOptions.d.ts +3 -2
- package/dist/build/serverOptions.d.ts.map +1 -1
- package/dist/build/shared/extract-mastra-option.d.ts +15 -0
- package/dist/build/shared/extract-mastra-option.d.ts.map +1 -0
- package/dist/build/telemetry.d.ts +3 -11
- package/dist/build/telemetry.d.ts.map +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-SA7YCRKF.js → chunk-3ZVEABRA.js} +21 -100
- package/dist/chunk-3ZVEABRA.js.map +1 -0
- package/dist/{chunk-3RRMEPHU.js → chunk-4HS72TCL.js} +13 -24
- package/dist/chunk-4HS72TCL.js.map +1 -0
- package/dist/{chunk-J42QUFVB.cjs → chunk-FIOHFXQ4.cjs} +8 -14
- package/dist/chunk-FIOHFXQ4.cjs.map +1 -0
- package/dist/{chunk-MRJUFOEN.cjs → chunk-G4TSJE4W.cjs} +47 -52
- package/dist/chunk-G4TSJE4W.cjs.map +1 -0
- package/dist/{chunk-4CTQZBDI.js → chunk-GXPWEOOA.js} +43 -47
- package/dist/chunk-GXPWEOOA.js.map +1 -0
- package/dist/chunk-HHNOUMJH.js +26 -0
- package/dist/chunk-HHNOUMJH.js.map +1 -0
- package/dist/{chunk-VAE7BL7I.cjs → chunk-LG5W6D2R.cjs} +19 -10
- package/dist/chunk-LG5W6D2R.cjs.map +1 -0
- package/dist/{chunk-OOVC5E4J.js → chunk-NOI4CTSN.js} +18 -10
- package/dist/chunk-NOI4CTSN.js.map +1 -0
- package/dist/{chunk-N66CXJKO.js → chunk-SBEJU32H.js} +4 -9
- package/dist/chunk-SBEJU32H.js.map +1 -0
- package/dist/chunk-UD4WRJI3.cjs +28 -0
- package/dist/chunk-UD4WRJI3.cjs.map +1 -0
- package/dist/{chunk-PBN66NLE.cjs → chunk-UYBVYWPG.cjs} +24 -124
- package/dist/chunk-UYBVYWPG.cjs.map +1 -0
- package/dist/{chunk-PO2BAZ5A.cjs → chunk-V7XDPQFQ.cjs} +19 -31
- package/dist/chunk-V7XDPQFQ.cjs.map +1 -0
- package/dist/index.cjs +20 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -129
- package/dist/index.js.map +1 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts +12 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/scores/handlers.d.ts +50 -0
- package/dist/server/handlers/routes/scores/handlers.d.ts.map +1 -1
- package/dist/server/index.cjs +228 -5
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +229 -6
- package/dist/server/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-3RRMEPHU.js.map +0 -1
- package/dist/chunk-4CTQZBDI.js.map +0 -1
- package/dist/chunk-EFPKWUPY.js +0 -107
- package/dist/chunk-EFPKWUPY.js.map +0 -1
- package/dist/chunk-J42QUFVB.cjs.map +0 -1
- package/dist/chunk-MRJUFOEN.cjs.map +0 -1
- package/dist/chunk-N66CXJKO.js.map +0 -1
- package/dist/chunk-OOVC5E4J.js.map +0 -1
- package/dist/chunk-PBN66NLE.cjs.map +0 -1
- package/dist/chunk-PO2BAZ5A.cjs.map +0 -1
- package/dist/chunk-SA7YCRKF.js.map +0 -1
- package/dist/chunk-VAE7BL7I.cjs.map +0 -1
- package/dist/chunk-ZGXUX6Z6.cjs +0 -133
- package/dist/chunk-ZGXUX6Z6.cjs.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { timeout } from 'hono/timeout';
|
|
|
19
19
|
import { HTTPException } from 'hono/http-exception';
|
|
20
20
|
import { getAgentCardByIdHandler as getAgentCardByIdHandler$1, getAgentExecutionHandler as getAgentExecutionHandler$1 } from '@mastra/server/handlers/a2a';
|
|
21
21
|
import { stream } from 'hono/streaming';
|
|
22
|
-
import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateHandler as generateHandler$1,
|
|
22
|
+
import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateHandler as generateHandler$1, generateVNextHandler as generateVNextHandler$1, streamVNextGenerateHandler as streamVNextGenerateHandler$1, streamGenerateHandler as streamGenerateHandler$1, streamVNextUIMessageHandler as streamVNextUIMessageHandler$1, updateAgentModelHandler as updateAgentModelHandler$1 } from '@mastra/server/handlers/agents';
|
|
23
23
|
import { bodyLimit } from 'hono/body-limit';
|
|
24
24
|
import { Agent } from '@mastra/core/agent';
|
|
25
25
|
import { z } from 'zod';
|
|
@@ -1244,6 +1244,56 @@ var AllowedProviderKeys = {
|
|
|
1244
1244
|
};
|
|
1245
1245
|
|
|
1246
1246
|
// src/server/handlers/routes/agents/handlers.ts
|
|
1247
|
+
var vNextBodyOptions = {
|
|
1248
|
+
messages: {
|
|
1249
|
+
type: "array",
|
|
1250
|
+
items: { type: "object" }
|
|
1251
|
+
},
|
|
1252
|
+
threadId: { type: "string" },
|
|
1253
|
+
resourceId: { type: "string", description: "The resource ID for the conversation" },
|
|
1254
|
+
runId: { type: "string" },
|
|
1255
|
+
output: { type: "object" },
|
|
1256
|
+
instructions: { type: "string", description: "Optional instructions to override the agent's default instructions" },
|
|
1257
|
+
context: {
|
|
1258
|
+
type: "array",
|
|
1259
|
+
items: { type: "object" },
|
|
1260
|
+
description: "Additional context messages to include"
|
|
1261
|
+
},
|
|
1262
|
+
memory: {
|
|
1263
|
+
type: "object",
|
|
1264
|
+
properties: {
|
|
1265
|
+
threadId: { type: "string" },
|
|
1266
|
+
resourceId: { type: "string", description: "The resource ID for the conversation" },
|
|
1267
|
+
options: { type: "object", description: "Memory configuration options" }
|
|
1268
|
+
},
|
|
1269
|
+
description: "Memory options for the conversation"
|
|
1270
|
+
},
|
|
1271
|
+
savePerStep: { type: "boolean", description: "Whether to save messages incrementally on step finish" },
|
|
1272
|
+
format: { type: "string", enum: ["mastra", "aisdk"], description: "Response format" },
|
|
1273
|
+
toolChoice: {
|
|
1274
|
+
oneOf: [
|
|
1275
|
+
{ type: "string", enum: ["auto", "none", "required"] },
|
|
1276
|
+
{ type: "object", properties: { type: { type: "string" }, toolName: { type: "string" } } }
|
|
1277
|
+
],
|
|
1278
|
+
description: "Controls how tools are selected during generation"
|
|
1279
|
+
},
|
|
1280
|
+
modelSettings: {
|
|
1281
|
+
type: "object",
|
|
1282
|
+
properties: {
|
|
1283
|
+
maxTokens: { type: "number", description: "Maximum number of tokens to generate" },
|
|
1284
|
+
temperature: { type: "number", minimum: 0, maximum: 1, description: "Temperature setting for randomness (0-1)" },
|
|
1285
|
+
topP: { type: "number", minimum: 0, maximum: 1, description: "Nucleus sampling (0-1)" },
|
|
1286
|
+
topK: { type: "number", description: "Only sample from the top K options for each subsequent token" },
|
|
1287
|
+
presencePenalty: { type: "number", minimum: -1, maximum: 1, description: "Presence penalty (-1 to 1)" },
|
|
1288
|
+
frequencyPenalty: { type: "number", minimum: -1, maximum: 1, description: "Frequency penalty (-1 to 1)" },
|
|
1289
|
+
stopSequences: { type: "array", items: { type: "string" }, description: "Stop sequences for text generation" },
|
|
1290
|
+
seed: { type: "number", description: "Seed for deterministic results" },
|
|
1291
|
+
maxRetries: { type: "number", description: "Maximum number of retries" },
|
|
1292
|
+
headers: { type: "object", description: "Additional HTTP headers" }
|
|
1293
|
+
},
|
|
1294
|
+
description: "Model settings for generation"
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1247
1297
|
async function getAgentsHandler(c2) {
|
|
1248
1298
|
const serializedAgents = await getAgentsHandler$1({
|
|
1249
1299
|
mastra: c2.get("mastra"),
|
|
@@ -1304,6 +1354,24 @@ async function generateHandler(c2) {
|
|
|
1304
1354
|
return handleError(error, "Error generating from agent");
|
|
1305
1355
|
}
|
|
1306
1356
|
}
|
|
1357
|
+
async function generateVNextHandler(c2) {
|
|
1358
|
+
try {
|
|
1359
|
+
const mastra = c2.get("mastra");
|
|
1360
|
+
const agentId = c2.req.param("agentId");
|
|
1361
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1362
|
+
const body = await c2.req.json();
|
|
1363
|
+
const result = await generateVNextHandler$1({
|
|
1364
|
+
mastra,
|
|
1365
|
+
agentId,
|
|
1366
|
+
runtimeContext,
|
|
1367
|
+
body,
|
|
1368
|
+
abortSignal: c2.req.raw.signal
|
|
1369
|
+
});
|
|
1370
|
+
return c2.json(result);
|
|
1371
|
+
} catch (error) {
|
|
1372
|
+
return handleError(error, "Error generating vnext from agent");
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1307
1375
|
async function streamGenerateHandler(c2) {
|
|
1308
1376
|
try {
|
|
1309
1377
|
const mastra = c2.get("mastra");
|
|
@@ -1334,21 +1402,24 @@ async function streamVNextGenerateHandler(c2) {
|
|
|
1334
1402
|
c2,
|
|
1335
1403
|
async (stream6) => {
|
|
1336
1404
|
try {
|
|
1337
|
-
const
|
|
1405
|
+
const streamResponse = await streamVNextGenerateHandler$1({
|
|
1338
1406
|
mastra,
|
|
1339
1407
|
agentId,
|
|
1340
1408
|
runtimeContext,
|
|
1341
1409
|
body,
|
|
1342
1410
|
abortSignal: c2.req.raw.signal
|
|
1343
1411
|
});
|
|
1344
|
-
const reader =
|
|
1412
|
+
const reader = streamResponse.fullStream.getReader();
|
|
1345
1413
|
stream6.onAbort(() => {
|
|
1346
1414
|
void reader.cancel("request aborted");
|
|
1347
1415
|
});
|
|
1348
1416
|
let chunkResult;
|
|
1349
1417
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
1350
|
-
await stream6.write(JSON.stringify(chunkResult.value)
|
|
1418
|
+
await stream6.write(`data: ${JSON.stringify(chunkResult.value)}
|
|
1419
|
+
|
|
1420
|
+
`);
|
|
1351
1421
|
}
|
|
1422
|
+
await stream6.write("data: [DONE]\n\n");
|
|
1352
1423
|
} catch (err) {
|
|
1353
1424
|
logger2.error("Error in streamVNext generate: " + (err?.message ?? "Unknown error"));
|
|
1354
1425
|
}
|
|
@@ -1362,6 +1433,24 @@ async function streamVNextGenerateHandler(c2) {
|
|
|
1362
1433
|
return handleError(error, "Error streaming from agent");
|
|
1363
1434
|
}
|
|
1364
1435
|
}
|
|
1436
|
+
async function streamVNextUIMessageHandler(c2) {
|
|
1437
|
+
try {
|
|
1438
|
+
const mastra = c2.get("mastra");
|
|
1439
|
+
const agentId = c2.req.param("agentId");
|
|
1440
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1441
|
+
const body = await c2.req.json();
|
|
1442
|
+
const streamResponse = await streamVNextUIMessageHandler$1({
|
|
1443
|
+
mastra,
|
|
1444
|
+
agentId,
|
|
1445
|
+
runtimeContext,
|
|
1446
|
+
body,
|
|
1447
|
+
abortSignal: c2.req.raw.signal
|
|
1448
|
+
});
|
|
1449
|
+
return streamResponse;
|
|
1450
|
+
} catch (error) {
|
|
1451
|
+
return handleError(error, "Error streaming ui message from agent");
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1365
1454
|
async function setAgentInstructionsHandler(c2) {
|
|
1366
1455
|
try {
|
|
1367
1456
|
const isPlayground = c2.get("playground") === true;
|
|
@@ -1404,6 +1493,18 @@ async function updateAgentModelHandler(c2) {
|
|
|
1404
1493
|
return handleError(error, "Error updating agent model");
|
|
1405
1494
|
}
|
|
1406
1495
|
}
|
|
1496
|
+
async function deprecatedStreamVNextHandler(c2) {
|
|
1497
|
+
return c2.json(
|
|
1498
|
+
{
|
|
1499
|
+
error: "This endpoint is deprecated",
|
|
1500
|
+
message: "The /streamVNext endpoint has been deprecated. Please use an alternative streaming endpoint.",
|
|
1501
|
+
deprecated_endpoint: "/api/agents/:agentId/streamVNext",
|
|
1502
|
+
replacement_endpoint: "/api/agents/:agentId/stream/vnext"
|
|
1503
|
+
},
|
|
1504
|
+
410
|
|
1505
|
+
// 410 Gone status code for deprecated endpoints
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1407
1508
|
async function getModelProvidersHandler(c2) {
|
|
1408
1509
|
const isPlayground = c2.get("playground") === true;
|
|
1409
1510
|
if (!isPlayground) {
|
|
@@ -1795,6 +1896,80 @@ function agentsRouter(bodyLimitOptions) {
|
|
|
1795
1896
|
}),
|
|
1796
1897
|
generateHandler
|
|
1797
1898
|
);
|
|
1899
|
+
router.post(
|
|
1900
|
+
"/:agentId/generate/vnext",
|
|
1901
|
+
bodyLimit(bodyLimitOptions),
|
|
1902
|
+
w({
|
|
1903
|
+
description: "Generate a response from an agent",
|
|
1904
|
+
tags: ["agents"],
|
|
1905
|
+
parameters: [
|
|
1906
|
+
{
|
|
1907
|
+
name: "agentId",
|
|
1908
|
+
in: "path",
|
|
1909
|
+
required: true,
|
|
1910
|
+
schema: { type: "string" }
|
|
1911
|
+
}
|
|
1912
|
+
],
|
|
1913
|
+
requestBody: {
|
|
1914
|
+
required: true,
|
|
1915
|
+
content: {
|
|
1916
|
+
"application/json": {
|
|
1917
|
+
schema: {
|
|
1918
|
+
type: "object",
|
|
1919
|
+
properties: vNextBodyOptions,
|
|
1920
|
+
required: ["messages"]
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
},
|
|
1925
|
+
responses: {
|
|
1926
|
+
200: {
|
|
1927
|
+
description: "Generated response"
|
|
1928
|
+
},
|
|
1929
|
+
404: {
|
|
1930
|
+
description: "Agent not found"
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
}),
|
|
1934
|
+
generateVNextHandler
|
|
1935
|
+
);
|
|
1936
|
+
router.post(
|
|
1937
|
+
"/:agentId/stream/vnext",
|
|
1938
|
+
bodyLimit(bodyLimitOptions),
|
|
1939
|
+
w({
|
|
1940
|
+
description: "Generate a response from an agent",
|
|
1941
|
+
tags: ["agents"],
|
|
1942
|
+
parameters: [
|
|
1943
|
+
{
|
|
1944
|
+
name: "agentId",
|
|
1945
|
+
in: "path",
|
|
1946
|
+
required: true,
|
|
1947
|
+
schema: { type: "string" }
|
|
1948
|
+
}
|
|
1949
|
+
],
|
|
1950
|
+
requestBody: {
|
|
1951
|
+
required: true,
|
|
1952
|
+
content: {
|
|
1953
|
+
"application/json": {
|
|
1954
|
+
schema: {
|
|
1955
|
+
type: "object",
|
|
1956
|
+
properties: vNextBodyOptions,
|
|
1957
|
+
required: ["messages"]
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
},
|
|
1962
|
+
responses: {
|
|
1963
|
+
200: {
|
|
1964
|
+
description: "Generated response"
|
|
1965
|
+
},
|
|
1966
|
+
404: {
|
|
1967
|
+
description: "Agent not found"
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
}),
|
|
1971
|
+
streamVNextGenerateHandler
|
|
1972
|
+
);
|
|
1798
1973
|
router.post(
|
|
1799
1974
|
"/:agentId/stream",
|
|
1800
1975
|
bodyLimit(bodyLimitOptions),
|
|
@@ -1850,8 +2025,9 @@ function agentsRouter(bodyLimitOptions) {
|
|
|
1850
2025
|
"/:agentId/streamVNext",
|
|
1851
2026
|
bodyLimit(bodyLimitOptions),
|
|
1852
2027
|
w({
|
|
1853
|
-
description: "
|
|
2028
|
+
description: "[DEPRECATED] This endpoint is deprecated. Please use /stream instead.",
|
|
1854
2029
|
tags: ["agents"],
|
|
2030
|
+
deprecated: true,
|
|
1855
2031
|
parameters: [
|
|
1856
2032
|
{
|
|
1857
2033
|
name: "agentId",
|
|
@@ -1900,6 +2076,53 @@ function agentsRouter(bodyLimitOptions) {
|
|
|
1900
2076
|
}
|
|
1901
2077
|
}
|
|
1902
2078
|
},
|
|
2079
|
+
responses: {
|
|
2080
|
+
410: {
|
|
2081
|
+
description: "Endpoint deprecated",
|
|
2082
|
+
content: {
|
|
2083
|
+
"application/json": {
|
|
2084
|
+
schema: {
|
|
2085
|
+
type: "object",
|
|
2086
|
+
properties: {
|
|
2087
|
+
error: { type: "string" },
|
|
2088
|
+
message: { type: "string" },
|
|
2089
|
+
deprecated_endpoint: { type: "string" },
|
|
2090
|
+
replacement_endpoint: { type: "string" }
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
}),
|
|
2098
|
+
deprecatedStreamVNextHandler
|
|
2099
|
+
);
|
|
2100
|
+
router.post(
|
|
2101
|
+
"/:agentId/stream/vnext/ui",
|
|
2102
|
+
bodyLimit(bodyLimitOptions),
|
|
2103
|
+
w({
|
|
2104
|
+
description: "Stream a response from an agent",
|
|
2105
|
+
tags: ["agents"],
|
|
2106
|
+
parameters: [
|
|
2107
|
+
{
|
|
2108
|
+
name: "agentId",
|
|
2109
|
+
in: "path",
|
|
2110
|
+
required: true,
|
|
2111
|
+
schema: { type: "string" }
|
|
2112
|
+
}
|
|
2113
|
+
],
|
|
2114
|
+
requestBody: {
|
|
2115
|
+
required: true,
|
|
2116
|
+
content: {
|
|
2117
|
+
"application/json": {
|
|
2118
|
+
schema: {
|
|
2119
|
+
type: "object",
|
|
2120
|
+
properties: vNextBodyOptions,
|
|
2121
|
+
required: ["messages"]
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
},
|
|
1903
2126
|
responses: {
|
|
1904
2127
|
200: {
|
|
1905
2128
|
description: "Streamed response"
|
|
@@ -1909,7 +2132,7 @@ function agentsRouter(bodyLimitOptions) {
|
|
|
1909
2132
|
}
|
|
1910
2133
|
}
|
|
1911
2134
|
}),
|
|
1912
|
-
|
|
2135
|
+
streamVNextUIMessageHandler
|
|
1913
2136
|
);
|
|
1914
2137
|
router.post(
|
|
1915
2138
|
"/:agentId/model",
|