@mastra/deployer 0.15.3-alpha.5 → 0.15.3-alpha.7

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.
@@ -19,9 +19,8 @@ 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 { bodyLimit } from 'hono/body-limit';
23
- import { getAgentBuilderActionsHandler as getAgentBuilderActionsHandler$1, getAgentBuilderActionByIdHandler as getAgentBuilderActionByIdHandler$1, getAgentBuilderActionRunsHandler as getAgentBuilderActionRunsHandler$1, getAgentBuilderActionRunExecutionResultHandler as getAgentBuilderActionRunExecutionResultHandler$1, getAgentBuilderActionRunByIdHandler as getAgentBuilderActionRunByIdHandler$1, resumeAgentBuilderActionHandler as resumeAgentBuilderActionHandler$1, resumeAsyncAgentBuilderActionHandler as resumeAsyncAgentBuilderActionHandler$1, streamAgentBuilderActionHandler as streamAgentBuilderActionHandler$1, streamVNextAgentBuilderActionHandler as streamVNextAgentBuilderActionHandler$1, createAgentBuilderActionRunHandler as createAgentBuilderActionRunHandler$1, startAsyncAgentBuilderActionHandler as startAsyncAgentBuilderActionHandler$1, startAgentBuilderActionRunHandler as startAgentBuilderActionRunHandler$1, watchAgentBuilderActionHandler as watchAgentBuilderActionHandler$1, cancelAgentBuilderActionRunHandler as cancelAgentBuilderActionRunHandler$1, sendAgentBuilderActionRunEventHandler as sendAgentBuilderActionRunEventHandler$1 } from '@mastra/server/handlers/agent-builder';
24
22
  import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateLegacyHandler as generateLegacyHandler$1, generateHandler as generateHandler$1, generateVNextHandler as generateVNextHandler$1, streamVNextGenerateHandler as streamVNextGenerateHandler$1, streamGenerateLegacyHandler as streamGenerateLegacyHandler$1, streamGenerateHandler as streamGenerateHandler$1, streamVNextUIMessageHandler as streamVNextUIMessageHandler$1, updateAgentModelHandler as updateAgentModelHandler$1 } from '@mastra/server/handlers/agents';
23
+ import { bodyLimit } from 'hono/body-limit';
25
24
  import { Agent } from '@mastra/core/agent';
26
25
  import { z } from 'zod';
27
26
  import { getAgentToolHandler as getAgentToolHandler$1, executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
@@ -281,13 +280,13 @@ var Response2 = class _Response {
281
280
  });
282
281
  Object.setPrototypeOf(Response2, GlobalResponse);
283
282
  Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
284
- function writeFromReadableStream(stream7, writable) {
285
- if (stream7.locked) {
283
+ function writeFromReadableStream(stream6, writable) {
284
+ if (stream6.locked) {
286
285
  throw new TypeError("ReadableStream is locked.");
287
286
  } else if (writable.destroyed) {
288
287
  return;
289
288
  }
290
- const reader = stream7.getReader();
289
+ const reader = stream6.getReader();
291
290
  const handleError2 = () => {
292
291
  };
293
292
  writable.on("error", handleError2);
@@ -554,18 +553,18 @@ var ENCODINGS = {
554
553
  gzip: ".gz"
555
554
  };
556
555
  var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
557
- var createStreamBody = (stream7) => {
556
+ var createStreamBody = (stream6) => {
558
557
  const body = new ReadableStream({
559
558
  start(controller) {
560
- stream7.on("data", (chunk) => {
559
+ stream6.on("data", (chunk) => {
561
560
  controller.enqueue(chunk);
562
561
  });
563
- stream7.on("end", () => {
562
+ stream6.on("end", () => {
564
563
  controller.close();
565
564
  });
566
565
  },
567
566
  cancel() {
568
- stream7.destroy();
567
+ stream6.destroy();
569
568
  }
570
569
  });
571
570
  return body;
@@ -654,10 +653,10 @@ var serveStatic = (options = { root: "" }) => {
654
653
  end = size - 1;
655
654
  }
656
655
  const chunksize = end - start + 1;
657
- const stream7 = createReadStream(path, { start, end });
656
+ const stream6 = createReadStream(path, { start, end });
658
657
  c2.header("Content-Length", chunksize.toString());
659
658
  c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
660
- return c2.body(createStreamBody(stream7), 206);
659
+ return c2.body(createStreamBody(stream6), 206);
661
660
  };
662
661
  };
663
662
  var RENDER_TYPE = {
@@ -955,15 +954,15 @@ async function getAgentExecutionHandler(c2) {
955
954
  if (body.method === "message/stream") {
956
955
  return stream(
957
956
  c2,
958
- async (stream7) => {
957
+ async (stream6) => {
959
958
  try {
960
- stream7.onAbort(() => {
959
+ stream6.onAbort(() => {
961
960
  if (!result.locked) {
962
961
  return result.cancel();
963
962
  }
964
963
  });
965
964
  for await (const chunk of result) {
966
- await stream7.write(JSON.stringify(chunk) + "");
965
+ await stream6.write(JSON.stringify(chunk) + "");
967
966
  }
968
967
  } catch (err) {
969
968
  logger2.error("Error in message/stream stream: " + err?.message);
@@ -1188,7 +1187,7 @@ var authorizationMiddleware = async (c2, next) => {
1188
1187
  // src/server/handlers/client.ts
1189
1188
  var clients = /* @__PURE__ */ new Set();
1190
1189
  function handleClientsRefresh(c2) {
1191
- const stream7 = new ReadableStream({
1190
+ const stream6 = new ReadableStream({
1192
1191
  start(controller) {
1193
1192
  clients.add(controller);
1194
1193
  controller.enqueue("data: connected\n\n");
@@ -1197,7 +1196,7 @@ function handleClientsRefresh(c2) {
1197
1196
  });
1198
1197
  }
1199
1198
  });
1200
- return new Response(stream7, {
1199
+ return new Response(stream6, {
1201
1200
  headers: {
1202
1201
  "Content-Type": "text/event-stream",
1203
1202
  "Cache-Control": "no-cache",
@@ -1238,853 +1237,6 @@ function errorHandler(err, c2, isDev) {
1238
1237
  async function rootHandler(c2) {
1239
1238
  return c2.text("Hello to the Mastra API!");
1240
1239
  }
1241
- async function getAgentBuilderActionsHandler(c2) {
1242
- try {
1243
- const mastra = c2.get("mastra");
1244
- const actions = await getAgentBuilderActionsHandler$1({
1245
- mastra
1246
- });
1247
- return c2.json(actions);
1248
- } catch (error) {
1249
- return handleError(error, "Error getting agent builder actions");
1250
- }
1251
- }
1252
- async function getAgentBuilderActionByIdHandler(c2) {
1253
- try {
1254
- const mastra = c2.get("mastra");
1255
- const actionId = c2.req.param("actionId");
1256
- const action = await getAgentBuilderActionByIdHandler$1({
1257
- mastra,
1258
- actionId
1259
- });
1260
- return c2.json(action);
1261
- } catch (error) {
1262
- return handleError(error, "Error getting agent builder action by ID");
1263
- }
1264
- }
1265
- async function createAgentBuilderActionRunHandler(c2) {
1266
- try {
1267
- const mastra = c2.get("mastra");
1268
- const actionId = c2.req.param("actionId");
1269
- const runId = c2.req.query("runId");
1270
- const result = await createAgentBuilderActionRunHandler$1({
1271
- mastra,
1272
- actionId,
1273
- runId
1274
- });
1275
- return c2.json(result);
1276
- } catch (error) {
1277
- return handleError(error, "Error creating agent builder action run");
1278
- }
1279
- }
1280
- async function startAsyncAgentBuilderActionHandler(c2) {
1281
- try {
1282
- const mastra = c2.get("mastra");
1283
- const runtimeContext = c2.get("runtimeContext");
1284
- const actionId = c2.req.param("actionId");
1285
- const { inputData } = await c2.req.json();
1286
- const runId = c2.req.query("runId");
1287
- const result = await startAsyncAgentBuilderActionHandler$1({
1288
- mastra,
1289
- runtimeContext,
1290
- actionId,
1291
- runId,
1292
- inputData
1293
- });
1294
- return c2.json(result);
1295
- } catch (error) {
1296
- return handleError(error, "Error starting async agent builder action");
1297
- }
1298
- }
1299
- async function startAgentBuilderActionRunHandler(c2) {
1300
- try {
1301
- const mastra = c2.get("mastra");
1302
- const runtimeContext = c2.get("runtimeContext");
1303
- const actionId = c2.req.param("actionId");
1304
- const { inputData } = await c2.req.json();
1305
- const runId = c2.req.query("runId");
1306
- const result = await startAgentBuilderActionRunHandler$1({
1307
- mastra,
1308
- runtimeContext,
1309
- actionId,
1310
- runId,
1311
- inputData
1312
- });
1313
- return c2.json(result);
1314
- } catch (error) {
1315
- return handleError(error, "Error starting agent builder action run");
1316
- }
1317
- }
1318
- async function watchAgentBuilderActionHandler(c2) {
1319
- try {
1320
- const mastra = c2.get("mastra");
1321
- const logger2 = mastra.getLogger();
1322
- const actionId = c2.req.param("actionId");
1323
- const runId = c2.req.query("runId");
1324
- const eventType = c2.req.query("eventType");
1325
- if (!runId) {
1326
- throw new HTTPException(400, { message: "runId required to watch action" });
1327
- }
1328
- c2.header("Transfer-Encoding", "chunked");
1329
- return stream(c2, async (stream7) => {
1330
- try {
1331
- const result = await watchAgentBuilderActionHandler$1({
1332
- mastra,
1333
- actionId,
1334
- runId,
1335
- eventType
1336
- });
1337
- const reader = result.getReader();
1338
- stream7.onAbort(() => {
1339
- void reader.cancel("request aborted");
1340
- });
1341
- let chunkResult;
1342
- while ((chunkResult = await reader.read()) && !chunkResult.done) {
1343
- await stream7.write(JSON.stringify(chunkResult.value) + "");
1344
- }
1345
- } catch (err) {
1346
- logger2.error("Error in watch stream: " + (err?.message ?? "Unknown error"));
1347
- }
1348
- });
1349
- } catch (error) {
1350
- return handleError(error, "Error watching agent builder action");
1351
- }
1352
- }
1353
- async function streamAgentBuilderActionHandler(c2) {
1354
- try {
1355
- const mastra = c2.get("mastra");
1356
- const runtimeContext = c2.get("runtimeContext");
1357
- const logger2 = mastra.getLogger();
1358
- const actionId = c2.req.param("actionId");
1359
- const { inputData } = await c2.req.json();
1360
- const runId = c2.req.query("runId");
1361
- c2.header("Transfer-Encoding", "chunked");
1362
- return stream(
1363
- c2,
1364
- async (stream7) => {
1365
- try {
1366
- const result = await streamAgentBuilderActionHandler$1({
1367
- mastra,
1368
- actionId,
1369
- runId,
1370
- inputData,
1371
- runtimeContext
1372
- });
1373
- const reader = result.stream.getReader();
1374
- stream7.onAbort(() => {
1375
- void reader.cancel("request aborted");
1376
- });
1377
- let chunkResult;
1378
- while ((chunkResult = await reader.read()) && !chunkResult.done) {
1379
- await stream7.write(JSON.stringify(chunkResult.value) + "");
1380
- }
1381
- } catch (err) {
1382
- logger2.error("Error in action stream: " + (err?.message ?? "Unknown error"));
1383
- }
1384
- await stream7.close();
1385
- },
1386
- async (err) => {
1387
- logger2.error("Error in action stream: " + err?.message);
1388
- }
1389
- );
1390
- } catch (error) {
1391
- return handleError(error, "Error streaming agent builder action");
1392
- }
1393
- }
1394
- async function streamVNextAgentBuilderActionHandler(c2) {
1395
- try {
1396
- const mastra = c2.get("mastra");
1397
- const runtimeContext = c2.get("runtimeContext");
1398
- const logger2 = mastra.getLogger();
1399
- const actionId = c2.req.param("actionId");
1400
- const { inputData } = await c2.req.json();
1401
- const runId = c2.req.query("runId");
1402
- c2.header("Transfer-Encoding", "chunked");
1403
- return stream(
1404
- c2,
1405
- async (stream7) => {
1406
- try {
1407
- const result = await streamVNextAgentBuilderActionHandler$1({
1408
- mastra,
1409
- actionId,
1410
- runId,
1411
- inputData,
1412
- runtimeContext
1413
- });
1414
- const reader = result.getReader();
1415
- stream7.onAbort(() => {
1416
- void reader.cancel("request aborted");
1417
- });
1418
- let chunkResult;
1419
- while ((chunkResult = await reader.read()) && !chunkResult.done) {
1420
- await stream7.write(JSON.stringify(chunkResult.value) + "");
1421
- }
1422
- } catch (err) {
1423
- logger2.error("Error in action VNext stream: " + (err?.message ?? "Unknown error"));
1424
- }
1425
- },
1426
- async (err) => {
1427
- logger2.error("Error in action VNext stream: " + err?.message);
1428
- }
1429
- );
1430
- } catch (error) {
1431
- return handleError(error, "Error streaming VNext agent builder action");
1432
- }
1433
- }
1434
- async function resumeAsyncAgentBuilderActionHandler(c2) {
1435
- try {
1436
- const mastra = c2.get("mastra");
1437
- const runtimeContext = c2.get("runtimeContext");
1438
- const actionId = c2.req.param("actionId");
1439
- const runId = c2.req.query("runId");
1440
- const { step, resumeData } = await c2.req.json();
1441
- if (!runId) {
1442
- throw new HTTPException(400, { message: "runId required to resume action" });
1443
- }
1444
- const result = await resumeAsyncAgentBuilderActionHandler$1({
1445
- mastra,
1446
- runtimeContext,
1447
- actionId,
1448
- runId,
1449
- body: { step, resumeData }
1450
- });
1451
- return c2.json(result);
1452
- } catch (error) {
1453
- return handleError(error, "Error resuming async agent builder action");
1454
- }
1455
- }
1456
- async function resumeAgentBuilderActionHandler(c2) {
1457
- try {
1458
- const mastra = c2.get("mastra");
1459
- const runtimeContext = c2.get("runtimeContext");
1460
- const actionId = c2.req.param("actionId");
1461
- const runId = c2.req.query("runId");
1462
- const { step, resumeData } = await c2.req.json();
1463
- if (!runId) {
1464
- throw new HTTPException(400, { message: "runId required to resume action" });
1465
- }
1466
- await resumeAgentBuilderActionHandler$1({
1467
- mastra,
1468
- runtimeContext,
1469
- actionId,
1470
- runId,
1471
- body: { step, resumeData }
1472
- });
1473
- return c2.json({ message: "Action run resumed" });
1474
- } catch (error) {
1475
- return handleError(error, "Error resuming agent builder action");
1476
- }
1477
- }
1478
- async function getAgentBuilderActionRunsHandler(c2) {
1479
- try {
1480
- const mastra = c2.get("mastra");
1481
- const actionId = c2.req.param("actionId");
1482
- const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
1483
- const runs = await getAgentBuilderActionRunsHandler$1({
1484
- mastra,
1485
- actionId,
1486
- fromDate: fromDate ? new Date(fromDate) : void 0,
1487
- toDate: toDate ? new Date(toDate) : void 0,
1488
- limit: limit ? Number(limit) : void 0,
1489
- offset: offset ? Number(offset) : void 0,
1490
- resourceId
1491
- });
1492
- return c2.json(runs);
1493
- } catch (error) {
1494
- return handleError(error, "Error getting agent builder action runs");
1495
- }
1496
- }
1497
- async function getAgentBuilderActionRunByIdHandler(c2) {
1498
- try {
1499
- const mastra = c2.get("mastra");
1500
- const actionId = c2.req.param("actionId");
1501
- const runId = c2.req.param("runId");
1502
- const run = await getAgentBuilderActionRunByIdHandler$1({
1503
- mastra,
1504
- actionId,
1505
- runId
1506
- });
1507
- return c2.json(run);
1508
- } catch (error) {
1509
- return handleError(error, "Error getting agent builder action run by ID");
1510
- }
1511
- }
1512
- async function getAgentBuilderActionRunExecutionResultHandler(c2) {
1513
- try {
1514
- const mastra = c2.get("mastra");
1515
- const actionId = c2.req.param("actionId");
1516
- const runId = c2.req.param("runId");
1517
- const result = await getAgentBuilderActionRunExecutionResultHandler$1({
1518
- mastra,
1519
- actionId,
1520
- runId
1521
- });
1522
- return c2.json(result);
1523
- } catch (error) {
1524
- return handleError(error, "Error getting agent builder action run execution result");
1525
- }
1526
- }
1527
- async function cancelAgentBuilderActionRunHandler(c2) {
1528
- try {
1529
- const mastra = c2.get("mastra");
1530
- const actionId = c2.req.param("actionId");
1531
- const runId = c2.req.param("runId");
1532
- const result = await cancelAgentBuilderActionRunHandler$1({
1533
- mastra,
1534
- actionId,
1535
- runId
1536
- });
1537
- return c2.json(result);
1538
- } catch (error) {
1539
- return handleError(error, "Error cancelling agent builder action run");
1540
- }
1541
- }
1542
- async function sendAgentBuilderActionRunEventHandler(c2) {
1543
- try {
1544
- const mastra = c2.get("mastra");
1545
- const actionId = c2.req.param("actionId");
1546
- const runId = c2.req.param("runId");
1547
- const { event, data } = await c2.req.json();
1548
- const result = await sendAgentBuilderActionRunEventHandler$1({
1549
- mastra,
1550
- actionId,
1551
- runId,
1552
- event,
1553
- data
1554
- });
1555
- return c2.json(result);
1556
- } catch (error) {
1557
- return handleError(error, "Error sending agent builder action run event");
1558
- }
1559
- }
1560
-
1561
- // src/server/handlers/routes/agent-builder/router.ts
1562
- function agentBuilderRouter(bodyLimitOptions) {
1563
- const router = new Hono();
1564
- router.get(
1565
- "/",
1566
- w({
1567
- description: "Get all agent builder actions",
1568
- tags: ["agent-builder"],
1569
- responses: {
1570
- 200: {
1571
- description: "List of all agent builder actions"
1572
- }
1573
- }
1574
- }),
1575
- getAgentBuilderActionsHandler
1576
- );
1577
- router.get(
1578
- "/:actionId",
1579
- w({
1580
- description: "Get agent builder action by ID",
1581
- tags: ["agent-builder"],
1582
- parameters: [
1583
- {
1584
- name: "actionId",
1585
- in: "path",
1586
- required: true,
1587
- schema: { type: "string" }
1588
- }
1589
- ],
1590
- responses: {
1591
- 200: {
1592
- description: "Agent builder action details"
1593
- },
1594
- 404: {
1595
- description: "Agent builder action not found"
1596
- }
1597
- }
1598
- }),
1599
- getAgentBuilderActionByIdHandler
1600
- );
1601
- router.get(
1602
- "/:actionId/runs",
1603
- w({
1604
- description: "Get all runs for an agent builder action",
1605
- tags: ["agent-builder"],
1606
- parameters: [
1607
- {
1608
- name: "actionId",
1609
- in: "path",
1610
- required: true,
1611
- schema: { type: "string" }
1612
- },
1613
- { name: "fromDate", in: "query", required: false, schema: { type: "string", format: "date-time" } },
1614
- { name: "toDate", in: "query", required: false, schema: { type: "string", format: "date-time" } },
1615
- { name: "limit", in: "query", required: false, schema: { type: "number" } },
1616
- { name: "offset", in: "query", required: false, schema: { type: "number" } },
1617
- { name: "resourceId", in: "query", required: false, schema: { type: "string" } }
1618
- ],
1619
- responses: {
1620
- 200: {
1621
- description: "List of agent builder action runs from storage"
1622
- }
1623
- }
1624
- }),
1625
- getAgentBuilderActionRunsHandler
1626
- );
1627
- router.get(
1628
- "/:actionId/runs/:runId/execution-result",
1629
- w({
1630
- description: "Get execution result for an agent builder action run",
1631
- tags: ["agent-builder"],
1632
- parameters: [
1633
- {
1634
- name: "actionId",
1635
- in: "path",
1636
- required: true,
1637
- schema: { type: "string" }
1638
- },
1639
- {
1640
- name: "runId",
1641
- in: "path",
1642
- required: true,
1643
- schema: { type: "string" }
1644
- }
1645
- ],
1646
- responses: {
1647
- 200: {
1648
- description: "Agent builder action run execution result"
1649
- },
1650
- 404: {
1651
- description: "Agent builder action run execution result not found"
1652
- }
1653
- }
1654
- }),
1655
- getAgentBuilderActionRunExecutionResultHandler
1656
- );
1657
- router.get(
1658
- "/:actionId/runs/:runId",
1659
- w({
1660
- description: "Get agent builder action run by ID",
1661
- tags: ["agent-builder"],
1662
- parameters: [
1663
- {
1664
- name: "actionId",
1665
- in: "path",
1666
- required: true,
1667
- schema: { type: "string" }
1668
- },
1669
- {
1670
- name: "runId",
1671
- in: "path",
1672
- required: true,
1673
- schema: { type: "string" }
1674
- }
1675
- ],
1676
- responses: {
1677
- 200: {
1678
- description: "Agent builder action run by ID"
1679
- },
1680
- 404: {
1681
- description: "Agent builder action run not found"
1682
- }
1683
- }
1684
- }),
1685
- getAgentBuilderActionRunByIdHandler
1686
- );
1687
- router.post(
1688
- "/:actionId/resume",
1689
- w({
1690
- description: "Resume a suspended agent builder action step",
1691
- tags: ["agent-builder"],
1692
- parameters: [
1693
- {
1694
- name: "actionId",
1695
- in: "path",
1696
- required: true,
1697
- schema: { type: "string" }
1698
- },
1699
- {
1700
- name: "runId",
1701
- in: "query",
1702
- required: true,
1703
- schema: { type: "string" }
1704
- }
1705
- ],
1706
- requestBody: {
1707
- required: true,
1708
- content: {
1709
- "application/json": {
1710
- schema: {
1711
- type: "object",
1712
- properties: {
1713
- step: {
1714
- oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
1715
- },
1716
- resumeData: { type: "object" },
1717
- runtimeContext: {
1718
- type: "object",
1719
- description: "Runtime context for the agent builder action execution"
1720
- }
1721
- },
1722
- required: ["step"]
1723
- }
1724
- }
1725
- }
1726
- }
1727
- }),
1728
- resumeAgentBuilderActionHandler
1729
- );
1730
- router.post(
1731
- "/:actionId/resume-async",
1732
- bodyLimit(bodyLimitOptions),
1733
- w({
1734
- description: "Resume a suspended agent builder action step",
1735
- tags: ["agent-builder"],
1736
- parameters: [
1737
- {
1738
- name: "actionId",
1739
- in: "path",
1740
- required: true,
1741
- schema: { type: "string" }
1742
- },
1743
- {
1744
- name: "runId",
1745
- in: "query",
1746
- required: true,
1747
- schema: { type: "string" }
1748
- }
1749
- ],
1750
- requestBody: {
1751
- required: true,
1752
- content: {
1753
- "application/json": {
1754
- schema: {
1755
- type: "object",
1756
- properties: {
1757
- step: {
1758
- oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
1759
- },
1760
- resumeData: { type: "object" },
1761
- runtimeContext: {
1762
- type: "object",
1763
- description: "Runtime context for the agent builder action execution"
1764
- }
1765
- },
1766
- required: ["step"]
1767
- }
1768
- }
1769
- }
1770
- }
1771
- }),
1772
- resumeAsyncAgentBuilderActionHandler
1773
- );
1774
- router.post(
1775
- "/:actionId/stream",
1776
- w({
1777
- description: "Stream agent builder action in real-time",
1778
- parameters: [
1779
- {
1780
- name: "actionId",
1781
- in: "path",
1782
- required: true,
1783
- schema: { type: "string" }
1784
- },
1785
- {
1786
- name: "runId",
1787
- in: "query",
1788
- required: false,
1789
- schema: { type: "string" }
1790
- }
1791
- ],
1792
- requestBody: {
1793
- required: true,
1794
- content: {
1795
- "application/json": {
1796
- schema: {
1797
- type: "object",
1798
- properties: {
1799
- inputData: { type: "object" },
1800
- runtimeContext: {
1801
- type: "object",
1802
- description: "Runtime context for the agent builder action execution"
1803
- }
1804
- }
1805
- }
1806
- }
1807
- }
1808
- },
1809
- responses: {
1810
- 200: {
1811
- description: "agent builder action run started"
1812
- },
1813
- 404: {
1814
- description: "agent builder action not found"
1815
- }
1816
- },
1817
- tags: ["agent-builder"]
1818
- }),
1819
- streamAgentBuilderActionHandler
1820
- );
1821
- router.post(
1822
- "/:actionId/streamVNext",
1823
- w({
1824
- description: "Stream agent builder action in real-time using the VNext streaming API",
1825
- parameters: [
1826
- {
1827
- name: "actionId",
1828
- in: "path",
1829
- required: true,
1830
- schema: { type: "string" }
1831
- },
1832
- {
1833
- name: "runId",
1834
- in: "query",
1835
- required: false,
1836
- schema: { type: "string" }
1837
- }
1838
- ],
1839
- requestBody: {
1840
- required: true,
1841
- content: {
1842
- "application/json": {
1843
- schema: {
1844
- type: "object",
1845
- properties: {
1846
- inputData: { type: "object" },
1847
- runtimeContext: {
1848
- type: "object",
1849
- description: "Runtime context for the agent builder action execution"
1850
- }
1851
- }
1852
- }
1853
- }
1854
- }
1855
- },
1856
- responses: {
1857
- 200: {
1858
- description: "agent builder action run started"
1859
- },
1860
- 404: {
1861
- description: "agent builder action not found"
1862
- }
1863
- },
1864
- tags: ["agent-builder"]
1865
- }),
1866
- streamVNextAgentBuilderActionHandler
1867
- );
1868
- router.post(
1869
- "/:actionId/create-run",
1870
- bodyLimit(bodyLimitOptions),
1871
- w({
1872
- description: "Create a new agent builder action run",
1873
- tags: ["agent-builder"],
1874
- parameters: [
1875
- {
1876
- name: "actionId",
1877
- in: "path",
1878
- required: true,
1879
- schema: { type: "string" }
1880
- },
1881
- {
1882
- name: "runId",
1883
- in: "query",
1884
- required: false,
1885
- schema: { type: "string" }
1886
- }
1887
- ],
1888
- responses: {
1889
- 200: {
1890
- description: "New agent builder action run created"
1891
- }
1892
- }
1893
- }),
1894
- createAgentBuilderActionRunHandler
1895
- );
1896
- router.post(
1897
- "/:actionId/start-async",
1898
- bodyLimit(bodyLimitOptions),
1899
- w({
1900
- description: "Execute/Start an agent builder action",
1901
- tags: ["agent-builder"],
1902
- parameters: [
1903
- {
1904
- name: "actionId",
1905
- in: "path",
1906
- required: true,
1907
- schema: { type: "string" }
1908
- },
1909
- {
1910
- name: "runId",
1911
- in: "query",
1912
- required: false,
1913
- schema: { type: "string" }
1914
- }
1915
- ],
1916
- requestBody: {
1917
- required: true,
1918
- content: {
1919
- "application/json": {
1920
- schema: {
1921
- type: "object",
1922
- properties: {
1923
- inputData: { type: "object" },
1924
- runtimeContext: {
1925
- type: "object",
1926
- description: "Runtime context for the agent builder action execution"
1927
- }
1928
- }
1929
- }
1930
- }
1931
- }
1932
- },
1933
- responses: {
1934
- 200: {
1935
- description: "agent builder action execution result"
1936
- },
1937
- 404: {
1938
- description: "agent builder action not found"
1939
- }
1940
- }
1941
- }),
1942
- startAsyncAgentBuilderActionHandler
1943
- );
1944
- router.post(
1945
- "/:actionId/start",
1946
- w({
1947
- description: "Create and start a new agent builder action run",
1948
- tags: ["agent-builder"],
1949
- parameters: [
1950
- {
1951
- name: "actionId",
1952
- in: "path",
1953
- required: true,
1954
- schema: { type: "string" }
1955
- },
1956
- {
1957
- name: "runId",
1958
- in: "query",
1959
- required: true,
1960
- schema: { type: "string" }
1961
- }
1962
- ],
1963
- requestBody: {
1964
- required: true,
1965
- content: {
1966
- "application/json": {
1967
- schema: {
1968
- type: "object",
1969
- properties: {
1970
- inputData: { type: "object" },
1971
- runtimeContext: {
1972
- type: "object",
1973
- description: "Runtime context for the agent builder action execution"
1974
- }
1975
- }
1976
- }
1977
- }
1978
- }
1979
- },
1980
- responses: {
1981
- 200: {
1982
- description: "agent builder action run started"
1983
- },
1984
- 404: {
1985
- description: "agent builder action not found"
1986
- }
1987
- }
1988
- }),
1989
- startAgentBuilderActionRunHandler
1990
- );
1991
- router.get(
1992
- "/:actionId/watch",
1993
- w({
1994
- description: "Watch agent builder action transitions in real-time",
1995
- parameters: [
1996
- {
1997
- name: "actionId",
1998
- in: "path",
1999
- required: true,
2000
- schema: { type: "string" }
2001
- },
2002
- {
2003
- name: "runId",
2004
- in: "query",
2005
- required: false,
2006
- schema: { type: "string" }
2007
- },
2008
- {
2009
- name: "eventType",
2010
- in: "query",
2011
- required: false,
2012
- schema: { type: "string", enum: ["watch", "watch-v2"] }
2013
- }
2014
- ],
2015
- tags: ["agent-builder"],
2016
- responses: {
2017
- 200: {
2018
- description: "agent builder action transitions in real-time"
2019
- }
2020
- }
2021
- }),
2022
- watchAgentBuilderActionHandler
2023
- );
2024
- router.post(
2025
- "/:actionId/runs/:runId/cancel",
2026
- w({
2027
- description: "Cancel an agent builder action run",
2028
- parameters: [
2029
- {
2030
- name: "actionId",
2031
- in: "path",
2032
- required: true,
2033
- schema: { type: "string" }
2034
- },
2035
- {
2036
- name: "runId",
2037
- in: "path",
2038
- required: true,
2039
- schema: { type: "string" }
2040
- }
2041
- ],
2042
- tags: ["agent-builder"],
2043
- responses: {
2044
- 200: {
2045
- description: "agent builder action run cancelled"
2046
- }
2047
- }
2048
- }),
2049
- cancelAgentBuilderActionRunHandler
2050
- );
2051
- router.post(
2052
- "/:actionId/runs/:runId/send-event",
2053
- w({
2054
- description: "Send an event to an agent builder action run",
2055
- parameters: [
2056
- {
2057
- name: "actionId",
2058
- in: "path",
2059
- required: true,
2060
- schema: { type: "string" }
2061
- },
2062
- {
2063
- name: "runId",
2064
- in: "path",
2065
- required: true,
2066
- schema: { type: "string" }
2067
- }
2068
- ],
2069
- requestBody: {
2070
- required: true,
2071
- content: {
2072
- "application/json": {
2073
- schema: { type: "object", properties: { event: { type: "string" }, data: { type: "object" } } }
2074
- }
2075
- }
2076
- },
2077
- tags: ["agent-builder"],
2078
- responses: {
2079
- 200: {
2080
- description: "agent builder action run event sent"
2081
- }
2082
- }
2083
- }),
2084
- sendAgentBuilderActionRunEventHandler
2085
- );
2086
- return router;
2087
- }
2088
1240
  var AllowedProviderKeys = {
2089
1241
  openai: "OPENAI_API_KEY",
2090
1242
  xai: "XAI_API_KEY",
@@ -2286,7 +1438,7 @@ async function streamVNextGenerateHandler(c2) {
2286
1438
  c2.header("Transfer-Encoding", "chunked");
2287
1439
  return stream(
2288
1440
  c2,
2289
- async (stream7) => {
1441
+ async (stream6) => {
2290
1442
  try {
2291
1443
  const streamResponse = await streamVNextGenerateHandler$1({
2292
1444
  mastra,
@@ -2296,20 +1448,20 @@ async function streamVNextGenerateHandler(c2) {
2296
1448
  abortSignal: c2.req.raw.signal
2297
1449
  });
2298
1450
  const reader = streamResponse.fullStream.getReader();
2299
- stream7.onAbort(() => {
1451
+ stream6.onAbort(() => {
2300
1452
  void reader.cancel("request aborted");
2301
1453
  });
2302
1454
  let chunkResult;
2303
1455
  while ((chunkResult = await reader.read()) && !chunkResult.done) {
2304
- await stream7.write(`data: ${JSON.stringify(chunkResult.value)}
1456
+ await stream6.write(`data: ${JSON.stringify(chunkResult.value)}
2305
1457
 
2306
1458
  `);
2307
1459
  }
2308
- await stream7.write("data: [DONE]\n\n");
1460
+ await stream6.write("data: [DONE]\n\n");
2309
1461
  } catch (err) {
2310
1462
  logger2.error("Error in streamVNext generate: " + (err?.message ?? "Unknown error"));
2311
1463
  }
2312
- await stream7.close();
1464
+ await stream6.close();
2313
1465
  },
2314
1466
  async (err) => {
2315
1467
  logger2.error("Error in watch stream: " + err?.message);
@@ -8056,7 +7208,7 @@ async function streamGenerateVNextNetworkHandler(c2) {
8056
7208
  c2.header("Transfer-Encoding", "chunked");
8057
7209
  return stream(
8058
7210
  c2,
8059
- async (stream7) => {
7211
+ async (stream6) => {
8060
7212
  try {
8061
7213
  const result = await streamGenerateVNextNetworkHandler$1({
8062
7214
  mastra,
@@ -8065,12 +7217,12 @@ async function streamGenerateVNextNetworkHandler(c2) {
8065
7217
  body
8066
7218
  });
8067
7219
  const reader = result.stream.getReader();
8068
- stream7.onAbort(() => {
7220
+ stream6.onAbort(() => {
8069
7221
  void reader.cancel("request aborted");
8070
7222
  });
8071
7223
  let chunkResult;
8072
7224
  while ((chunkResult = await reader.read()) && !chunkResult.done) {
8073
- await stream7.write(JSON.stringify(chunkResult.value) + "");
7225
+ await stream6.write(JSON.stringify(chunkResult.value) + "");
8074
7226
  }
8075
7227
  } catch (err) {
8076
7228
  mastra.getLogger().error("Error in network stream: " + (err?.message ?? "Unknown error"));
@@ -8111,7 +7263,7 @@ async function loopStreamVNextNetworkHandler(c2) {
8111
7263
  c2.header("Transfer-Encoding", "chunked");
8112
7264
  return stream(
8113
7265
  c2,
8114
- async (stream7) => {
7266
+ async (stream6) => {
8115
7267
  try {
8116
7268
  const result = await loopStreamVNextNetworkHandler$1({
8117
7269
  mastra,
@@ -8120,12 +7272,12 @@ async function loopStreamVNextNetworkHandler(c2) {
8120
7272
  body
8121
7273
  });
8122
7274
  const reader = result.stream.getReader();
8123
- stream7.onAbort(() => {
7275
+ stream6.onAbort(() => {
8124
7276
  void reader.cancel("request aborted");
8125
7277
  });
8126
7278
  let chunkResult;
8127
7279
  while ((chunkResult = await reader.read()) && !chunkResult.done) {
8128
- await stream7.write(JSON.stringify(chunkResult.value) + "");
7280
+ await stream6.write(JSON.stringify(chunkResult.value) + "");
8129
7281
  }
8130
7282
  } catch (err) {
8131
7283
  mastra.getLogger().error("Error in network loop stream: " + (err?.message ?? "Unknown error"));
@@ -9511,7 +8663,7 @@ function watchWorkflowHandler(c2) {
9511
8663
  c2.header("Transfer-Encoding", "chunked");
9512
8664
  return stream(
9513
8665
  c2,
9514
- async (stream7) => {
8666
+ async (stream6) => {
9515
8667
  try {
9516
8668
  const result = await watchWorkflowHandler$1({
9517
8669
  mastra,
@@ -9519,12 +8671,12 @@ function watchWorkflowHandler(c2) {
9519
8671
  runId
9520
8672
  });
9521
8673
  const reader = result.getReader();
9522
- stream7.onAbort(() => {
8674
+ stream6.onAbort(() => {
9523
8675
  void reader.cancel("request aborted");
9524
8676
  });
9525
8677
  let chunkResult;
9526
8678
  while ((chunkResult = await reader.read()) && !chunkResult.done) {
9527
- await stream7.write(JSON.stringify(chunkResult.value) + "");
8679
+ await stream6.write(JSON.stringify(chunkResult.value) + "");
9528
8680
  }
9529
8681
  } catch (err) {
9530
8682
  logger2.error("Error in watch stream: " + (err?.message ?? "Unknown error"));
@@ -9549,7 +8701,7 @@ async function streamWorkflowHandler(c2) {
9549
8701
  c2.header("Transfer-Encoding", "chunked");
9550
8702
  return stream(
9551
8703
  c2,
9552
- async (stream7) => {
8704
+ async (stream6) => {
9553
8705
  try {
9554
8706
  const result = await streamWorkflowHandler$1({
9555
8707
  mastra,
@@ -9559,17 +8711,17 @@ async function streamWorkflowHandler(c2) {
9559
8711
  runtimeContext
9560
8712
  });
9561
8713
  const reader = result.stream.getReader();
9562
- stream7.onAbort(() => {
8714
+ stream6.onAbort(() => {
9563
8715
  void reader.cancel("request aborted");
9564
8716
  });
9565
8717
  let chunkResult;
9566
8718
  while ((chunkResult = await reader.read()) && !chunkResult.done) {
9567
- await stream7.write(JSON.stringify(chunkResult.value) + "");
8719
+ await stream6.write(JSON.stringify(chunkResult.value) + "");
9568
8720
  }
9569
8721
  } catch (err) {
9570
8722
  logger2.error("Error in workflow stream: " + (err?.message ?? "Unknown error"));
9571
8723
  }
9572
- await stream7.close();
8724
+ await stream6.close();
9573
8725
  },
9574
8726
  async (err) => {
9575
8727
  logger2.error("Error in workflow stream: " + err?.message);
@@ -9590,7 +8742,7 @@ async function streamVNextWorkflowHandler(c2) {
9590
8742
  c2.header("Transfer-Encoding", "chunked");
9591
8743
  return stream(
9592
8744
  c2,
9593
- async (stream7) => {
8745
+ async (stream6) => {
9594
8746
  try {
9595
8747
  const result = await streamVNextWorkflowHandler$1({
9596
8748
  mastra,
@@ -9600,12 +8752,12 @@ async function streamVNextWorkflowHandler(c2) {
9600
8752
  runtimeContext
9601
8753
  });
9602
8754
  const reader = result.getReader();
9603
- stream7.onAbort(() => {
8755
+ stream6.onAbort(() => {
9604
8756
  void reader.cancel("request aborted");
9605
8757
  });
9606
8758
  let chunkResult;
9607
8759
  while ((chunkResult = await reader.read()) && !chunkResult.done) {
9608
- await stream7.write(JSON.stringify(chunkResult.value) + "");
8760
+ await stream6.write(JSON.stringify(chunkResult.value) + "");
9609
8761
  }
9610
8762
  } catch (err) {
9611
8763
  logger2.error("Error in workflow VNext stream: " + (err?.message ?? "Unknown error"));
@@ -9833,20 +8985,20 @@ function watchLegacyWorkflowHandler(c2) {
9833
8985
  }
9834
8986
  return stream(
9835
8987
  c2,
9836
- async (stream7) => {
8988
+ async (stream6) => {
9837
8989
  try {
9838
8990
  const result = await watchLegacyWorkflowHandler$1({
9839
8991
  mastra,
9840
8992
  workflowId,
9841
8993
  runId
9842
8994
  });
9843
- stream7.onAbort(() => {
8995
+ stream6.onAbort(() => {
9844
8996
  if (!result.locked) {
9845
8997
  return result.cancel();
9846
8998
  }
9847
8999
  });
9848
9000
  for await (const chunk of result) {
9849
- await stream7.write(chunk.toString() + "");
9001
+ await stream6.write(chunk.toString() + "");
9850
9002
  }
9851
9003
  } catch (err) {
9852
9004
  console.log(err);
@@ -11146,7 +10298,6 @@ async function createHonoServer(mastra, options = {
11146
10298
  app.route("/api/workflows", workflowsRouter(bodyLimitOptions));
11147
10299
  app.route("/api/logs", logsRouter());
11148
10300
  app.route("/api/scores", scoresRouter(bodyLimitOptions));
11149
- app.route("/api/agent-builder", agentBuilderRouter(bodyLimitOptions));
11150
10301
  app.route("/api/tools", toolsRouter(bodyLimitOptions, options.tools));
11151
10302
  app.route("/api/vector", vectorRouter(bodyLimitOptions));
11152
10303
  if (options?.isDev || server?.build?.openAPIDocs || server?.build?.swaggerUI) {