@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.
- package/CHANGELOG.md +20 -0
- package/dist/server/index.cjs +39 -888
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +39 -888
- package/dist/server/index.js.map +1 -1
- package/package.json +6 -6
package/dist/server/index.cjs
CHANGED
|
@@ -21,9 +21,8 @@ var timeout = require('hono/timeout');
|
|
|
21
21
|
var httpException = require('hono/http-exception');
|
|
22
22
|
var a2a = require('@mastra/server/handlers/a2a');
|
|
23
23
|
var streaming = require('hono/streaming');
|
|
24
|
-
var bodyLimit = require('hono/body-limit');
|
|
25
|
-
var agentBuilder = require('@mastra/server/handlers/agent-builder');
|
|
26
24
|
var agents = require('@mastra/server/handlers/agents');
|
|
25
|
+
var bodyLimit = require('hono/body-limit');
|
|
27
26
|
var agent = require('@mastra/core/agent');
|
|
28
27
|
var zod = require('zod');
|
|
29
28
|
var tools$1 = require('@mastra/server/handlers/tools');
|
|
@@ -288,13 +287,13 @@ var Response2 = class _Response {
|
|
|
288
287
|
});
|
|
289
288
|
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
290
289
|
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
291
|
-
function writeFromReadableStream(
|
|
292
|
-
if (
|
|
290
|
+
function writeFromReadableStream(stream6, writable) {
|
|
291
|
+
if (stream6.locked) {
|
|
293
292
|
throw new TypeError("ReadableStream is locked.");
|
|
294
293
|
} else if (writable.destroyed) {
|
|
295
294
|
return;
|
|
296
295
|
}
|
|
297
|
-
const reader =
|
|
296
|
+
const reader = stream6.getReader();
|
|
298
297
|
const handleError2 = () => {
|
|
299
298
|
};
|
|
300
299
|
writable.on("error", handleError2);
|
|
@@ -561,18 +560,18 @@ var ENCODINGS = {
|
|
|
561
560
|
gzip: ".gz"
|
|
562
561
|
};
|
|
563
562
|
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
564
|
-
var createStreamBody = (
|
|
563
|
+
var createStreamBody = (stream6) => {
|
|
565
564
|
const body = new ReadableStream({
|
|
566
565
|
start(controller) {
|
|
567
|
-
|
|
566
|
+
stream6.on("data", (chunk) => {
|
|
568
567
|
controller.enqueue(chunk);
|
|
569
568
|
});
|
|
570
|
-
|
|
569
|
+
stream6.on("end", () => {
|
|
571
570
|
controller.close();
|
|
572
571
|
});
|
|
573
572
|
},
|
|
574
573
|
cancel() {
|
|
575
|
-
|
|
574
|
+
stream6.destroy();
|
|
576
575
|
}
|
|
577
576
|
});
|
|
578
577
|
return body;
|
|
@@ -661,10 +660,10 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
661
660
|
end = size - 1;
|
|
662
661
|
}
|
|
663
662
|
const chunksize = end - start + 1;
|
|
664
|
-
const
|
|
663
|
+
const stream6 = fs.createReadStream(path$1, { start, end });
|
|
665
664
|
c2.header("Content-Length", chunksize.toString());
|
|
666
665
|
c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
667
|
-
return c2.body(createStreamBody(
|
|
666
|
+
return c2.body(createStreamBody(stream6), 206);
|
|
668
667
|
};
|
|
669
668
|
};
|
|
670
669
|
var RENDER_TYPE = {
|
|
@@ -962,15 +961,15 @@ async function getAgentExecutionHandler(c2) {
|
|
|
962
961
|
if (body.method === "message/stream") {
|
|
963
962
|
return streaming.stream(
|
|
964
963
|
c2,
|
|
965
|
-
async (
|
|
964
|
+
async (stream6) => {
|
|
966
965
|
try {
|
|
967
|
-
|
|
966
|
+
stream6.onAbort(() => {
|
|
968
967
|
if (!result.locked) {
|
|
969
968
|
return result.cancel();
|
|
970
969
|
}
|
|
971
970
|
});
|
|
972
971
|
for await (const chunk of result) {
|
|
973
|
-
await
|
|
972
|
+
await stream6.write(JSON.stringify(chunk) + "");
|
|
974
973
|
}
|
|
975
974
|
} catch (err) {
|
|
976
975
|
logger2.error("Error in message/stream stream: " + err?.message);
|
|
@@ -1195,7 +1194,7 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1195
1194
|
// src/server/handlers/client.ts
|
|
1196
1195
|
var clients = /* @__PURE__ */ new Set();
|
|
1197
1196
|
function handleClientsRefresh(c2) {
|
|
1198
|
-
const
|
|
1197
|
+
const stream6 = new ReadableStream({
|
|
1199
1198
|
start(controller) {
|
|
1200
1199
|
clients.add(controller);
|
|
1201
1200
|
controller.enqueue("data: connected\n\n");
|
|
@@ -1204,7 +1203,7 @@ function handleClientsRefresh(c2) {
|
|
|
1204
1203
|
});
|
|
1205
1204
|
}
|
|
1206
1205
|
});
|
|
1207
|
-
return new Response(
|
|
1206
|
+
return new Response(stream6, {
|
|
1208
1207
|
headers: {
|
|
1209
1208
|
"Content-Type": "text/event-stream",
|
|
1210
1209
|
"Cache-Control": "no-cache",
|
|
@@ -1245,853 +1244,6 @@ function errorHandler(err, c2, isDev) {
|
|
|
1245
1244
|
async function rootHandler(c2) {
|
|
1246
1245
|
return c2.text("Hello to the Mastra API!");
|
|
1247
1246
|
}
|
|
1248
|
-
async function getAgentBuilderActionsHandler(c2) {
|
|
1249
|
-
try {
|
|
1250
|
-
const mastra = c2.get("mastra");
|
|
1251
|
-
const actions = await agentBuilder.getAgentBuilderActionsHandler({
|
|
1252
|
-
mastra
|
|
1253
|
-
});
|
|
1254
|
-
return c2.json(actions);
|
|
1255
|
-
} catch (error) {
|
|
1256
|
-
return handleError(error, "Error getting agent builder actions");
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
async function getAgentBuilderActionByIdHandler(c2) {
|
|
1260
|
-
try {
|
|
1261
|
-
const mastra = c2.get("mastra");
|
|
1262
|
-
const actionId = c2.req.param("actionId");
|
|
1263
|
-
const action = await agentBuilder.getAgentBuilderActionByIdHandler({
|
|
1264
|
-
mastra,
|
|
1265
|
-
actionId
|
|
1266
|
-
});
|
|
1267
|
-
return c2.json(action);
|
|
1268
|
-
} catch (error) {
|
|
1269
|
-
return handleError(error, "Error getting agent builder action by ID");
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
async function createAgentBuilderActionRunHandler(c2) {
|
|
1273
|
-
try {
|
|
1274
|
-
const mastra = c2.get("mastra");
|
|
1275
|
-
const actionId = c2.req.param("actionId");
|
|
1276
|
-
const runId = c2.req.query("runId");
|
|
1277
|
-
const result = await agentBuilder.createAgentBuilderActionRunHandler({
|
|
1278
|
-
mastra,
|
|
1279
|
-
actionId,
|
|
1280
|
-
runId
|
|
1281
|
-
});
|
|
1282
|
-
return c2.json(result);
|
|
1283
|
-
} catch (error) {
|
|
1284
|
-
return handleError(error, "Error creating agent builder action run");
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
async function startAsyncAgentBuilderActionHandler(c2) {
|
|
1288
|
-
try {
|
|
1289
|
-
const mastra = c2.get("mastra");
|
|
1290
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
1291
|
-
const actionId = c2.req.param("actionId");
|
|
1292
|
-
const { inputData } = await c2.req.json();
|
|
1293
|
-
const runId = c2.req.query("runId");
|
|
1294
|
-
const result = await agentBuilder.startAsyncAgentBuilderActionHandler({
|
|
1295
|
-
mastra,
|
|
1296
|
-
runtimeContext,
|
|
1297
|
-
actionId,
|
|
1298
|
-
runId,
|
|
1299
|
-
inputData
|
|
1300
|
-
});
|
|
1301
|
-
return c2.json(result);
|
|
1302
|
-
} catch (error) {
|
|
1303
|
-
return handleError(error, "Error starting async agent builder action");
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
async function startAgentBuilderActionRunHandler(c2) {
|
|
1307
|
-
try {
|
|
1308
|
-
const mastra = c2.get("mastra");
|
|
1309
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
1310
|
-
const actionId = c2.req.param("actionId");
|
|
1311
|
-
const { inputData } = await c2.req.json();
|
|
1312
|
-
const runId = c2.req.query("runId");
|
|
1313
|
-
const result = await agentBuilder.startAgentBuilderActionRunHandler({
|
|
1314
|
-
mastra,
|
|
1315
|
-
runtimeContext,
|
|
1316
|
-
actionId,
|
|
1317
|
-
runId,
|
|
1318
|
-
inputData
|
|
1319
|
-
});
|
|
1320
|
-
return c2.json(result);
|
|
1321
|
-
} catch (error) {
|
|
1322
|
-
return handleError(error, "Error starting agent builder action run");
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
async function watchAgentBuilderActionHandler(c2) {
|
|
1326
|
-
try {
|
|
1327
|
-
const mastra = c2.get("mastra");
|
|
1328
|
-
const logger2 = mastra.getLogger();
|
|
1329
|
-
const actionId = c2.req.param("actionId");
|
|
1330
|
-
const runId = c2.req.query("runId");
|
|
1331
|
-
const eventType = c2.req.query("eventType");
|
|
1332
|
-
if (!runId) {
|
|
1333
|
-
throw new httpException.HTTPException(400, { message: "runId required to watch action" });
|
|
1334
|
-
}
|
|
1335
|
-
c2.header("Transfer-Encoding", "chunked");
|
|
1336
|
-
return streaming.stream(c2, async (stream7) => {
|
|
1337
|
-
try {
|
|
1338
|
-
const result = await agentBuilder.watchAgentBuilderActionHandler({
|
|
1339
|
-
mastra,
|
|
1340
|
-
actionId,
|
|
1341
|
-
runId,
|
|
1342
|
-
eventType
|
|
1343
|
-
});
|
|
1344
|
-
const reader = result.getReader();
|
|
1345
|
-
stream7.onAbort(() => {
|
|
1346
|
-
void reader.cancel("request aborted");
|
|
1347
|
-
});
|
|
1348
|
-
let chunkResult;
|
|
1349
|
-
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
1350
|
-
await stream7.write(JSON.stringify(chunkResult.value) + "");
|
|
1351
|
-
}
|
|
1352
|
-
} catch (err) {
|
|
1353
|
-
logger2.error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
1354
|
-
}
|
|
1355
|
-
});
|
|
1356
|
-
} catch (error) {
|
|
1357
|
-
return handleError(error, "Error watching agent builder action");
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
async function streamAgentBuilderActionHandler(c2) {
|
|
1361
|
-
try {
|
|
1362
|
-
const mastra = c2.get("mastra");
|
|
1363
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
1364
|
-
const logger2 = mastra.getLogger();
|
|
1365
|
-
const actionId = c2.req.param("actionId");
|
|
1366
|
-
const { inputData } = await c2.req.json();
|
|
1367
|
-
const runId = c2.req.query("runId");
|
|
1368
|
-
c2.header("Transfer-Encoding", "chunked");
|
|
1369
|
-
return streaming.stream(
|
|
1370
|
-
c2,
|
|
1371
|
-
async (stream7) => {
|
|
1372
|
-
try {
|
|
1373
|
-
const result = await agentBuilder.streamAgentBuilderActionHandler({
|
|
1374
|
-
mastra,
|
|
1375
|
-
actionId,
|
|
1376
|
-
runId,
|
|
1377
|
-
inputData,
|
|
1378
|
-
runtimeContext
|
|
1379
|
-
});
|
|
1380
|
-
const reader = result.stream.getReader();
|
|
1381
|
-
stream7.onAbort(() => {
|
|
1382
|
-
void reader.cancel("request aborted");
|
|
1383
|
-
});
|
|
1384
|
-
let chunkResult;
|
|
1385
|
-
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
1386
|
-
await stream7.write(JSON.stringify(chunkResult.value) + "");
|
|
1387
|
-
}
|
|
1388
|
-
} catch (err) {
|
|
1389
|
-
logger2.error("Error in action stream: " + (err?.message ?? "Unknown error"));
|
|
1390
|
-
}
|
|
1391
|
-
await stream7.close();
|
|
1392
|
-
},
|
|
1393
|
-
async (err) => {
|
|
1394
|
-
logger2.error("Error in action stream: " + err?.message);
|
|
1395
|
-
}
|
|
1396
|
-
);
|
|
1397
|
-
} catch (error) {
|
|
1398
|
-
return handleError(error, "Error streaming agent builder action");
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
async function streamVNextAgentBuilderActionHandler(c2) {
|
|
1402
|
-
try {
|
|
1403
|
-
const mastra = c2.get("mastra");
|
|
1404
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
1405
|
-
const logger2 = mastra.getLogger();
|
|
1406
|
-
const actionId = c2.req.param("actionId");
|
|
1407
|
-
const { inputData } = await c2.req.json();
|
|
1408
|
-
const runId = c2.req.query("runId");
|
|
1409
|
-
c2.header("Transfer-Encoding", "chunked");
|
|
1410
|
-
return streaming.stream(
|
|
1411
|
-
c2,
|
|
1412
|
-
async (stream7) => {
|
|
1413
|
-
try {
|
|
1414
|
-
const result = await agentBuilder.streamVNextAgentBuilderActionHandler({
|
|
1415
|
-
mastra,
|
|
1416
|
-
actionId,
|
|
1417
|
-
runId,
|
|
1418
|
-
inputData,
|
|
1419
|
-
runtimeContext
|
|
1420
|
-
});
|
|
1421
|
-
const reader = result.getReader();
|
|
1422
|
-
stream7.onAbort(() => {
|
|
1423
|
-
void reader.cancel("request aborted");
|
|
1424
|
-
});
|
|
1425
|
-
let chunkResult;
|
|
1426
|
-
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
1427
|
-
await stream7.write(JSON.stringify(chunkResult.value) + "");
|
|
1428
|
-
}
|
|
1429
|
-
} catch (err) {
|
|
1430
|
-
logger2.error("Error in action VNext stream: " + (err?.message ?? "Unknown error"));
|
|
1431
|
-
}
|
|
1432
|
-
},
|
|
1433
|
-
async (err) => {
|
|
1434
|
-
logger2.error("Error in action VNext stream: " + err?.message);
|
|
1435
|
-
}
|
|
1436
|
-
);
|
|
1437
|
-
} catch (error) {
|
|
1438
|
-
return handleError(error, "Error streaming VNext agent builder action");
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
async function resumeAsyncAgentBuilderActionHandler(c2) {
|
|
1442
|
-
try {
|
|
1443
|
-
const mastra = c2.get("mastra");
|
|
1444
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
1445
|
-
const actionId = c2.req.param("actionId");
|
|
1446
|
-
const runId = c2.req.query("runId");
|
|
1447
|
-
const { step, resumeData } = await c2.req.json();
|
|
1448
|
-
if (!runId) {
|
|
1449
|
-
throw new httpException.HTTPException(400, { message: "runId required to resume action" });
|
|
1450
|
-
}
|
|
1451
|
-
const result = await agentBuilder.resumeAsyncAgentBuilderActionHandler({
|
|
1452
|
-
mastra,
|
|
1453
|
-
runtimeContext,
|
|
1454
|
-
actionId,
|
|
1455
|
-
runId,
|
|
1456
|
-
body: { step, resumeData }
|
|
1457
|
-
});
|
|
1458
|
-
return c2.json(result);
|
|
1459
|
-
} catch (error) {
|
|
1460
|
-
return handleError(error, "Error resuming async agent builder action");
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
async function resumeAgentBuilderActionHandler(c2) {
|
|
1464
|
-
try {
|
|
1465
|
-
const mastra = c2.get("mastra");
|
|
1466
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
1467
|
-
const actionId = c2.req.param("actionId");
|
|
1468
|
-
const runId = c2.req.query("runId");
|
|
1469
|
-
const { step, resumeData } = await c2.req.json();
|
|
1470
|
-
if (!runId) {
|
|
1471
|
-
throw new httpException.HTTPException(400, { message: "runId required to resume action" });
|
|
1472
|
-
}
|
|
1473
|
-
await agentBuilder.resumeAgentBuilderActionHandler({
|
|
1474
|
-
mastra,
|
|
1475
|
-
runtimeContext,
|
|
1476
|
-
actionId,
|
|
1477
|
-
runId,
|
|
1478
|
-
body: { step, resumeData }
|
|
1479
|
-
});
|
|
1480
|
-
return c2.json({ message: "Action run resumed" });
|
|
1481
|
-
} catch (error) {
|
|
1482
|
-
return handleError(error, "Error resuming agent builder action");
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
async function getAgentBuilderActionRunsHandler(c2) {
|
|
1486
|
-
try {
|
|
1487
|
-
const mastra = c2.get("mastra");
|
|
1488
|
-
const actionId = c2.req.param("actionId");
|
|
1489
|
-
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
1490
|
-
const runs = await agentBuilder.getAgentBuilderActionRunsHandler({
|
|
1491
|
-
mastra,
|
|
1492
|
-
actionId,
|
|
1493
|
-
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
1494
|
-
toDate: toDate ? new Date(toDate) : void 0,
|
|
1495
|
-
limit: limit ? Number(limit) : void 0,
|
|
1496
|
-
offset: offset ? Number(offset) : void 0,
|
|
1497
|
-
resourceId
|
|
1498
|
-
});
|
|
1499
|
-
return c2.json(runs);
|
|
1500
|
-
} catch (error) {
|
|
1501
|
-
return handleError(error, "Error getting agent builder action runs");
|
|
1502
|
-
}
|
|
1503
|
-
}
|
|
1504
|
-
async function getAgentBuilderActionRunByIdHandler(c2) {
|
|
1505
|
-
try {
|
|
1506
|
-
const mastra = c2.get("mastra");
|
|
1507
|
-
const actionId = c2.req.param("actionId");
|
|
1508
|
-
const runId = c2.req.param("runId");
|
|
1509
|
-
const run = await agentBuilder.getAgentBuilderActionRunByIdHandler({
|
|
1510
|
-
mastra,
|
|
1511
|
-
actionId,
|
|
1512
|
-
runId
|
|
1513
|
-
});
|
|
1514
|
-
return c2.json(run);
|
|
1515
|
-
} catch (error) {
|
|
1516
|
-
return handleError(error, "Error getting agent builder action run by ID");
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
async function getAgentBuilderActionRunExecutionResultHandler(c2) {
|
|
1520
|
-
try {
|
|
1521
|
-
const mastra = c2.get("mastra");
|
|
1522
|
-
const actionId = c2.req.param("actionId");
|
|
1523
|
-
const runId = c2.req.param("runId");
|
|
1524
|
-
const result = await agentBuilder.getAgentBuilderActionRunExecutionResultHandler({
|
|
1525
|
-
mastra,
|
|
1526
|
-
actionId,
|
|
1527
|
-
runId
|
|
1528
|
-
});
|
|
1529
|
-
return c2.json(result);
|
|
1530
|
-
} catch (error) {
|
|
1531
|
-
return handleError(error, "Error getting agent builder action run execution result");
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
async function cancelAgentBuilderActionRunHandler(c2) {
|
|
1535
|
-
try {
|
|
1536
|
-
const mastra = c2.get("mastra");
|
|
1537
|
-
const actionId = c2.req.param("actionId");
|
|
1538
|
-
const runId = c2.req.param("runId");
|
|
1539
|
-
const result = await agentBuilder.cancelAgentBuilderActionRunHandler({
|
|
1540
|
-
mastra,
|
|
1541
|
-
actionId,
|
|
1542
|
-
runId
|
|
1543
|
-
});
|
|
1544
|
-
return c2.json(result);
|
|
1545
|
-
} catch (error) {
|
|
1546
|
-
return handleError(error, "Error cancelling agent builder action run");
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
async function sendAgentBuilderActionRunEventHandler(c2) {
|
|
1550
|
-
try {
|
|
1551
|
-
const mastra = c2.get("mastra");
|
|
1552
|
-
const actionId = c2.req.param("actionId");
|
|
1553
|
-
const runId = c2.req.param("runId");
|
|
1554
|
-
const { event, data } = await c2.req.json();
|
|
1555
|
-
const result = await agentBuilder.sendAgentBuilderActionRunEventHandler({
|
|
1556
|
-
mastra,
|
|
1557
|
-
actionId,
|
|
1558
|
-
runId,
|
|
1559
|
-
event,
|
|
1560
|
-
data
|
|
1561
|
-
});
|
|
1562
|
-
return c2.json(result);
|
|
1563
|
-
} catch (error) {
|
|
1564
|
-
return handleError(error, "Error sending agent builder action run event");
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
// src/server/handlers/routes/agent-builder/router.ts
|
|
1569
|
-
function agentBuilderRouter(bodyLimitOptions) {
|
|
1570
|
-
const router = new hono.Hono();
|
|
1571
|
-
router.get(
|
|
1572
|
-
"/",
|
|
1573
|
-
w({
|
|
1574
|
-
description: "Get all agent builder actions",
|
|
1575
|
-
tags: ["agent-builder"],
|
|
1576
|
-
responses: {
|
|
1577
|
-
200: {
|
|
1578
|
-
description: "List of all agent builder actions"
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
}),
|
|
1582
|
-
getAgentBuilderActionsHandler
|
|
1583
|
-
);
|
|
1584
|
-
router.get(
|
|
1585
|
-
"/:actionId",
|
|
1586
|
-
w({
|
|
1587
|
-
description: "Get agent builder action by ID",
|
|
1588
|
-
tags: ["agent-builder"],
|
|
1589
|
-
parameters: [
|
|
1590
|
-
{
|
|
1591
|
-
name: "actionId",
|
|
1592
|
-
in: "path",
|
|
1593
|
-
required: true,
|
|
1594
|
-
schema: { type: "string" }
|
|
1595
|
-
}
|
|
1596
|
-
],
|
|
1597
|
-
responses: {
|
|
1598
|
-
200: {
|
|
1599
|
-
description: "Agent builder action details"
|
|
1600
|
-
},
|
|
1601
|
-
404: {
|
|
1602
|
-
description: "Agent builder action not found"
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
}),
|
|
1606
|
-
getAgentBuilderActionByIdHandler
|
|
1607
|
-
);
|
|
1608
|
-
router.get(
|
|
1609
|
-
"/:actionId/runs",
|
|
1610
|
-
w({
|
|
1611
|
-
description: "Get all runs for an agent builder action",
|
|
1612
|
-
tags: ["agent-builder"],
|
|
1613
|
-
parameters: [
|
|
1614
|
-
{
|
|
1615
|
-
name: "actionId",
|
|
1616
|
-
in: "path",
|
|
1617
|
-
required: true,
|
|
1618
|
-
schema: { type: "string" }
|
|
1619
|
-
},
|
|
1620
|
-
{ name: "fromDate", in: "query", required: false, schema: { type: "string", format: "date-time" } },
|
|
1621
|
-
{ name: "toDate", in: "query", required: false, schema: { type: "string", format: "date-time" } },
|
|
1622
|
-
{ name: "limit", in: "query", required: false, schema: { type: "number" } },
|
|
1623
|
-
{ name: "offset", in: "query", required: false, schema: { type: "number" } },
|
|
1624
|
-
{ name: "resourceId", in: "query", required: false, schema: { type: "string" } }
|
|
1625
|
-
],
|
|
1626
|
-
responses: {
|
|
1627
|
-
200: {
|
|
1628
|
-
description: "List of agent builder action runs from storage"
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
}),
|
|
1632
|
-
getAgentBuilderActionRunsHandler
|
|
1633
|
-
);
|
|
1634
|
-
router.get(
|
|
1635
|
-
"/:actionId/runs/:runId/execution-result",
|
|
1636
|
-
w({
|
|
1637
|
-
description: "Get execution result for an agent builder action run",
|
|
1638
|
-
tags: ["agent-builder"],
|
|
1639
|
-
parameters: [
|
|
1640
|
-
{
|
|
1641
|
-
name: "actionId",
|
|
1642
|
-
in: "path",
|
|
1643
|
-
required: true,
|
|
1644
|
-
schema: { type: "string" }
|
|
1645
|
-
},
|
|
1646
|
-
{
|
|
1647
|
-
name: "runId",
|
|
1648
|
-
in: "path",
|
|
1649
|
-
required: true,
|
|
1650
|
-
schema: { type: "string" }
|
|
1651
|
-
}
|
|
1652
|
-
],
|
|
1653
|
-
responses: {
|
|
1654
|
-
200: {
|
|
1655
|
-
description: "Agent builder action run execution result"
|
|
1656
|
-
},
|
|
1657
|
-
404: {
|
|
1658
|
-
description: "Agent builder action run execution result not found"
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
}),
|
|
1662
|
-
getAgentBuilderActionRunExecutionResultHandler
|
|
1663
|
-
);
|
|
1664
|
-
router.get(
|
|
1665
|
-
"/:actionId/runs/:runId",
|
|
1666
|
-
w({
|
|
1667
|
-
description: "Get agent builder action run by ID",
|
|
1668
|
-
tags: ["agent-builder"],
|
|
1669
|
-
parameters: [
|
|
1670
|
-
{
|
|
1671
|
-
name: "actionId",
|
|
1672
|
-
in: "path",
|
|
1673
|
-
required: true,
|
|
1674
|
-
schema: { type: "string" }
|
|
1675
|
-
},
|
|
1676
|
-
{
|
|
1677
|
-
name: "runId",
|
|
1678
|
-
in: "path",
|
|
1679
|
-
required: true,
|
|
1680
|
-
schema: { type: "string" }
|
|
1681
|
-
}
|
|
1682
|
-
],
|
|
1683
|
-
responses: {
|
|
1684
|
-
200: {
|
|
1685
|
-
description: "Agent builder action run by ID"
|
|
1686
|
-
},
|
|
1687
|
-
404: {
|
|
1688
|
-
description: "Agent builder action run not found"
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
}),
|
|
1692
|
-
getAgentBuilderActionRunByIdHandler
|
|
1693
|
-
);
|
|
1694
|
-
router.post(
|
|
1695
|
-
"/:actionId/resume",
|
|
1696
|
-
w({
|
|
1697
|
-
description: "Resume a suspended agent builder action step",
|
|
1698
|
-
tags: ["agent-builder"],
|
|
1699
|
-
parameters: [
|
|
1700
|
-
{
|
|
1701
|
-
name: "actionId",
|
|
1702
|
-
in: "path",
|
|
1703
|
-
required: true,
|
|
1704
|
-
schema: { type: "string" }
|
|
1705
|
-
},
|
|
1706
|
-
{
|
|
1707
|
-
name: "runId",
|
|
1708
|
-
in: "query",
|
|
1709
|
-
required: true,
|
|
1710
|
-
schema: { type: "string" }
|
|
1711
|
-
}
|
|
1712
|
-
],
|
|
1713
|
-
requestBody: {
|
|
1714
|
-
required: true,
|
|
1715
|
-
content: {
|
|
1716
|
-
"application/json": {
|
|
1717
|
-
schema: {
|
|
1718
|
-
type: "object",
|
|
1719
|
-
properties: {
|
|
1720
|
-
step: {
|
|
1721
|
-
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
1722
|
-
},
|
|
1723
|
-
resumeData: { type: "object" },
|
|
1724
|
-
runtimeContext: {
|
|
1725
|
-
type: "object",
|
|
1726
|
-
description: "Runtime context for the agent builder action execution"
|
|
1727
|
-
}
|
|
1728
|
-
},
|
|
1729
|
-
required: ["step"]
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
}),
|
|
1735
|
-
resumeAgentBuilderActionHandler
|
|
1736
|
-
);
|
|
1737
|
-
router.post(
|
|
1738
|
-
"/:actionId/resume-async",
|
|
1739
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
1740
|
-
w({
|
|
1741
|
-
description: "Resume a suspended agent builder action step",
|
|
1742
|
-
tags: ["agent-builder"],
|
|
1743
|
-
parameters: [
|
|
1744
|
-
{
|
|
1745
|
-
name: "actionId",
|
|
1746
|
-
in: "path",
|
|
1747
|
-
required: true,
|
|
1748
|
-
schema: { type: "string" }
|
|
1749
|
-
},
|
|
1750
|
-
{
|
|
1751
|
-
name: "runId",
|
|
1752
|
-
in: "query",
|
|
1753
|
-
required: true,
|
|
1754
|
-
schema: { type: "string" }
|
|
1755
|
-
}
|
|
1756
|
-
],
|
|
1757
|
-
requestBody: {
|
|
1758
|
-
required: true,
|
|
1759
|
-
content: {
|
|
1760
|
-
"application/json": {
|
|
1761
|
-
schema: {
|
|
1762
|
-
type: "object",
|
|
1763
|
-
properties: {
|
|
1764
|
-
step: {
|
|
1765
|
-
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
1766
|
-
},
|
|
1767
|
-
resumeData: { type: "object" },
|
|
1768
|
-
runtimeContext: {
|
|
1769
|
-
type: "object",
|
|
1770
|
-
description: "Runtime context for the agent builder action execution"
|
|
1771
|
-
}
|
|
1772
|
-
},
|
|
1773
|
-
required: ["step"]
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
}),
|
|
1779
|
-
resumeAsyncAgentBuilderActionHandler
|
|
1780
|
-
);
|
|
1781
|
-
router.post(
|
|
1782
|
-
"/:actionId/stream",
|
|
1783
|
-
w({
|
|
1784
|
-
description: "Stream agent builder action in real-time",
|
|
1785
|
-
parameters: [
|
|
1786
|
-
{
|
|
1787
|
-
name: "actionId",
|
|
1788
|
-
in: "path",
|
|
1789
|
-
required: true,
|
|
1790
|
-
schema: { type: "string" }
|
|
1791
|
-
},
|
|
1792
|
-
{
|
|
1793
|
-
name: "runId",
|
|
1794
|
-
in: "query",
|
|
1795
|
-
required: false,
|
|
1796
|
-
schema: { type: "string" }
|
|
1797
|
-
}
|
|
1798
|
-
],
|
|
1799
|
-
requestBody: {
|
|
1800
|
-
required: true,
|
|
1801
|
-
content: {
|
|
1802
|
-
"application/json": {
|
|
1803
|
-
schema: {
|
|
1804
|
-
type: "object",
|
|
1805
|
-
properties: {
|
|
1806
|
-
inputData: { type: "object" },
|
|
1807
|
-
runtimeContext: {
|
|
1808
|
-
type: "object",
|
|
1809
|
-
description: "Runtime context for the agent builder action execution"
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
},
|
|
1816
|
-
responses: {
|
|
1817
|
-
200: {
|
|
1818
|
-
description: "agent builder action run started"
|
|
1819
|
-
},
|
|
1820
|
-
404: {
|
|
1821
|
-
description: "agent builder action not found"
|
|
1822
|
-
}
|
|
1823
|
-
},
|
|
1824
|
-
tags: ["agent-builder"]
|
|
1825
|
-
}),
|
|
1826
|
-
streamAgentBuilderActionHandler
|
|
1827
|
-
);
|
|
1828
|
-
router.post(
|
|
1829
|
-
"/:actionId/streamVNext",
|
|
1830
|
-
w({
|
|
1831
|
-
description: "Stream agent builder action in real-time using the VNext streaming API",
|
|
1832
|
-
parameters: [
|
|
1833
|
-
{
|
|
1834
|
-
name: "actionId",
|
|
1835
|
-
in: "path",
|
|
1836
|
-
required: true,
|
|
1837
|
-
schema: { type: "string" }
|
|
1838
|
-
},
|
|
1839
|
-
{
|
|
1840
|
-
name: "runId",
|
|
1841
|
-
in: "query",
|
|
1842
|
-
required: false,
|
|
1843
|
-
schema: { type: "string" }
|
|
1844
|
-
}
|
|
1845
|
-
],
|
|
1846
|
-
requestBody: {
|
|
1847
|
-
required: true,
|
|
1848
|
-
content: {
|
|
1849
|
-
"application/json": {
|
|
1850
|
-
schema: {
|
|
1851
|
-
type: "object",
|
|
1852
|
-
properties: {
|
|
1853
|
-
inputData: { type: "object" },
|
|
1854
|
-
runtimeContext: {
|
|
1855
|
-
type: "object",
|
|
1856
|
-
description: "Runtime context for the agent builder action execution"
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
},
|
|
1863
|
-
responses: {
|
|
1864
|
-
200: {
|
|
1865
|
-
description: "agent builder action run started"
|
|
1866
|
-
},
|
|
1867
|
-
404: {
|
|
1868
|
-
description: "agent builder action not found"
|
|
1869
|
-
}
|
|
1870
|
-
},
|
|
1871
|
-
tags: ["agent-builder"]
|
|
1872
|
-
}),
|
|
1873
|
-
streamVNextAgentBuilderActionHandler
|
|
1874
|
-
);
|
|
1875
|
-
router.post(
|
|
1876
|
-
"/:actionId/create-run",
|
|
1877
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
1878
|
-
w({
|
|
1879
|
-
description: "Create a new agent builder action run",
|
|
1880
|
-
tags: ["agent-builder"],
|
|
1881
|
-
parameters: [
|
|
1882
|
-
{
|
|
1883
|
-
name: "actionId",
|
|
1884
|
-
in: "path",
|
|
1885
|
-
required: true,
|
|
1886
|
-
schema: { type: "string" }
|
|
1887
|
-
},
|
|
1888
|
-
{
|
|
1889
|
-
name: "runId",
|
|
1890
|
-
in: "query",
|
|
1891
|
-
required: false,
|
|
1892
|
-
schema: { type: "string" }
|
|
1893
|
-
}
|
|
1894
|
-
],
|
|
1895
|
-
responses: {
|
|
1896
|
-
200: {
|
|
1897
|
-
description: "New agent builder action run created"
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
}),
|
|
1901
|
-
createAgentBuilderActionRunHandler
|
|
1902
|
-
);
|
|
1903
|
-
router.post(
|
|
1904
|
-
"/:actionId/start-async",
|
|
1905
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
1906
|
-
w({
|
|
1907
|
-
description: "Execute/Start an agent builder action",
|
|
1908
|
-
tags: ["agent-builder"],
|
|
1909
|
-
parameters: [
|
|
1910
|
-
{
|
|
1911
|
-
name: "actionId",
|
|
1912
|
-
in: "path",
|
|
1913
|
-
required: true,
|
|
1914
|
-
schema: { type: "string" }
|
|
1915
|
-
},
|
|
1916
|
-
{
|
|
1917
|
-
name: "runId",
|
|
1918
|
-
in: "query",
|
|
1919
|
-
required: false,
|
|
1920
|
-
schema: { type: "string" }
|
|
1921
|
-
}
|
|
1922
|
-
],
|
|
1923
|
-
requestBody: {
|
|
1924
|
-
required: true,
|
|
1925
|
-
content: {
|
|
1926
|
-
"application/json": {
|
|
1927
|
-
schema: {
|
|
1928
|
-
type: "object",
|
|
1929
|
-
properties: {
|
|
1930
|
-
inputData: { type: "object" },
|
|
1931
|
-
runtimeContext: {
|
|
1932
|
-
type: "object",
|
|
1933
|
-
description: "Runtime context for the agent builder action execution"
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
},
|
|
1940
|
-
responses: {
|
|
1941
|
-
200: {
|
|
1942
|
-
description: "agent builder action execution result"
|
|
1943
|
-
},
|
|
1944
|
-
404: {
|
|
1945
|
-
description: "agent builder action not found"
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
}),
|
|
1949
|
-
startAsyncAgentBuilderActionHandler
|
|
1950
|
-
);
|
|
1951
|
-
router.post(
|
|
1952
|
-
"/:actionId/start",
|
|
1953
|
-
w({
|
|
1954
|
-
description: "Create and start a new agent builder action run",
|
|
1955
|
-
tags: ["agent-builder"],
|
|
1956
|
-
parameters: [
|
|
1957
|
-
{
|
|
1958
|
-
name: "actionId",
|
|
1959
|
-
in: "path",
|
|
1960
|
-
required: true,
|
|
1961
|
-
schema: { type: "string" }
|
|
1962
|
-
},
|
|
1963
|
-
{
|
|
1964
|
-
name: "runId",
|
|
1965
|
-
in: "query",
|
|
1966
|
-
required: true,
|
|
1967
|
-
schema: { type: "string" }
|
|
1968
|
-
}
|
|
1969
|
-
],
|
|
1970
|
-
requestBody: {
|
|
1971
|
-
required: true,
|
|
1972
|
-
content: {
|
|
1973
|
-
"application/json": {
|
|
1974
|
-
schema: {
|
|
1975
|
-
type: "object",
|
|
1976
|
-
properties: {
|
|
1977
|
-
inputData: { type: "object" },
|
|
1978
|
-
runtimeContext: {
|
|
1979
|
-
type: "object",
|
|
1980
|
-
description: "Runtime context for the agent builder action execution"
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
},
|
|
1987
|
-
responses: {
|
|
1988
|
-
200: {
|
|
1989
|
-
description: "agent builder action run started"
|
|
1990
|
-
},
|
|
1991
|
-
404: {
|
|
1992
|
-
description: "agent builder action not found"
|
|
1993
|
-
}
|
|
1994
|
-
}
|
|
1995
|
-
}),
|
|
1996
|
-
startAgentBuilderActionRunHandler
|
|
1997
|
-
);
|
|
1998
|
-
router.get(
|
|
1999
|
-
"/:actionId/watch",
|
|
2000
|
-
w({
|
|
2001
|
-
description: "Watch agent builder action transitions in real-time",
|
|
2002
|
-
parameters: [
|
|
2003
|
-
{
|
|
2004
|
-
name: "actionId",
|
|
2005
|
-
in: "path",
|
|
2006
|
-
required: true,
|
|
2007
|
-
schema: { type: "string" }
|
|
2008
|
-
},
|
|
2009
|
-
{
|
|
2010
|
-
name: "runId",
|
|
2011
|
-
in: "query",
|
|
2012
|
-
required: false,
|
|
2013
|
-
schema: { type: "string" }
|
|
2014
|
-
},
|
|
2015
|
-
{
|
|
2016
|
-
name: "eventType",
|
|
2017
|
-
in: "query",
|
|
2018
|
-
required: false,
|
|
2019
|
-
schema: { type: "string", enum: ["watch", "watch-v2"] }
|
|
2020
|
-
}
|
|
2021
|
-
],
|
|
2022
|
-
tags: ["agent-builder"],
|
|
2023
|
-
responses: {
|
|
2024
|
-
200: {
|
|
2025
|
-
description: "agent builder action transitions in real-time"
|
|
2026
|
-
}
|
|
2027
|
-
}
|
|
2028
|
-
}),
|
|
2029
|
-
watchAgentBuilderActionHandler
|
|
2030
|
-
);
|
|
2031
|
-
router.post(
|
|
2032
|
-
"/:actionId/runs/:runId/cancel",
|
|
2033
|
-
w({
|
|
2034
|
-
description: "Cancel an agent builder action run",
|
|
2035
|
-
parameters: [
|
|
2036
|
-
{
|
|
2037
|
-
name: "actionId",
|
|
2038
|
-
in: "path",
|
|
2039
|
-
required: true,
|
|
2040
|
-
schema: { type: "string" }
|
|
2041
|
-
},
|
|
2042
|
-
{
|
|
2043
|
-
name: "runId",
|
|
2044
|
-
in: "path",
|
|
2045
|
-
required: true,
|
|
2046
|
-
schema: { type: "string" }
|
|
2047
|
-
}
|
|
2048
|
-
],
|
|
2049
|
-
tags: ["agent-builder"],
|
|
2050
|
-
responses: {
|
|
2051
|
-
200: {
|
|
2052
|
-
description: "agent builder action run cancelled"
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
}),
|
|
2056
|
-
cancelAgentBuilderActionRunHandler
|
|
2057
|
-
);
|
|
2058
|
-
router.post(
|
|
2059
|
-
"/:actionId/runs/:runId/send-event",
|
|
2060
|
-
w({
|
|
2061
|
-
description: "Send an event to an agent builder action run",
|
|
2062
|
-
parameters: [
|
|
2063
|
-
{
|
|
2064
|
-
name: "actionId",
|
|
2065
|
-
in: "path",
|
|
2066
|
-
required: true,
|
|
2067
|
-
schema: { type: "string" }
|
|
2068
|
-
},
|
|
2069
|
-
{
|
|
2070
|
-
name: "runId",
|
|
2071
|
-
in: "path",
|
|
2072
|
-
required: true,
|
|
2073
|
-
schema: { type: "string" }
|
|
2074
|
-
}
|
|
2075
|
-
],
|
|
2076
|
-
requestBody: {
|
|
2077
|
-
required: true,
|
|
2078
|
-
content: {
|
|
2079
|
-
"application/json": {
|
|
2080
|
-
schema: { type: "object", properties: { event: { type: "string" }, data: { type: "object" } } }
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
},
|
|
2084
|
-
tags: ["agent-builder"],
|
|
2085
|
-
responses: {
|
|
2086
|
-
200: {
|
|
2087
|
-
description: "agent builder action run event sent"
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
}),
|
|
2091
|
-
sendAgentBuilderActionRunEventHandler
|
|
2092
|
-
);
|
|
2093
|
-
return router;
|
|
2094
|
-
}
|
|
2095
1247
|
var AllowedProviderKeys = {
|
|
2096
1248
|
openai: "OPENAI_API_KEY",
|
|
2097
1249
|
xai: "XAI_API_KEY",
|
|
@@ -2293,7 +1445,7 @@ async function streamVNextGenerateHandler(c2) {
|
|
|
2293
1445
|
c2.header("Transfer-Encoding", "chunked");
|
|
2294
1446
|
return streaming.stream(
|
|
2295
1447
|
c2,
|
|
2296
|
-
async (
|
|
1448
|
+
async (stream6) => {
|
|
2297
1449
|
try {
|
|
2298
1450
|
const streamResponse = await agents.streamVNextGenerateHandler({
|
|
2299
1451
|
mastra,
|
|
@@ -2303,20 +1455,20 @@ async function streamVNextGenerateHandler(c2) {
|
|
|
2303
1455
|
abortSignal: c2.req.raw.signal
|
|
2304
1456
|
});
|
|
2305
1457
|
const reader = streamResponse.fullStream.getReader();
|
|
2306
|
-
|
|
1458
|
+
stream6.onAbort(() => {
|
|
2307
1459
|
void reader.cancel("request aborted");
|
|
2308
1460
|
});
|
|
2309
1461
|
let chunkResult;
|
|
2310
1462
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
2311
|
-
await
|
|
1463
|
+
await stream6.write(`data: ${JSON.stringify(chunkResult.value)}
|
|
2312
1464
|
|
|
2313
1465
|
`);
|
|
2314
1466
|
}
|
|
2315
|
-
await
|
|
1467
|
+
await stream6.write("data: [DONE]\n\n");
|
|
2316
1468
|
} catch (err) {
|
|
2317
1469
|
logger2.error("Error in streamVNext generate: " + (err?.message ?? "Unknown error"));
|
|
2318
1470
|
}
|
|
2319
|
-
await
|
|
1471
|
+
await stream6.close();
|
|
2320
1472
|
},
|
|
2321
1473
|
async (err) => {
|
|
2322
1474
|
logger2.error("Error in watch stream: " + err?.message);
|
|
@@ -8063,7 +7215,7 @@ async function streamGenerateVNextNetworkHandler(c2) {
|
|
|
8063
7215
|
c2.header("Transfer-Encoding", "chunked");
|
|
8064
7216
|
return streaming.stream(
|
|
8065
7217
|
c2,
|
|
8066
|
-
async (
|
|
7218
|
+
async (stream6) => {
|
|
8067
7219
|
try {
|
|
8068
7220
|
const result = await vNextNetwork.streamGenerateVNextNetworkHandler({
|
|
8069
7221
|
mastra,
|
|
@@ -8072,12 +7224,12 @@ async function streamGenerateVNextNetworkHandler(c2) {
|
|
|
8072
7224
|
body
|
|
8073
7225
|
});
|
|
8074
7226
|
const reader = result.stream.getReader();
|
|
8075
|
-
|
|
7227
|
+
stream6.onAbort(() => {
|
|
8076
7228
|
void reader.cancel("request aborted");
|
|
8077
7229
|
});
|
|
8078
7230
|
let chunkResult;
|
|
8079
7231
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
8080
|
-
await
|
|
7232
|
+
await stream6.write(JSON.stringify(chunkResult.value) + "");
|
|
8081
7233
|
}
|
|
8082
7234
|
} catch (err) {
|
|
8083
7235
|
mastra.getLogger().error("Error in network stream: " + (err?.message ?? "Unknown error"));
|
|
@@ -8118,7 +7270,7 @@ async function loopStreamVNextNetworkHandler(c2) {
|
|
|
8118
7270
|
c2.header("Transfer-Encoding", "chunked");
|
|
8119
7271
|
return streaming.stream(
|
|
8120
7272
|
c2,
|
|
8121
|
-
async (
|
|
7273
|
+
async (stream6) => {
|
|
8122
7274
|
try {
|
|
8123
7275
|
const result = await vNextNetwork.loopStreamVNextNetworkHandler({
|
|
8124
7276
|
mastra,
|
|
@@ -8127,12 +7279,12 @@ async function loopStreamVNextNetworkHandler(c2) {
|
|
|
8127
7279
|
body
|
|
8128
7280
|
});
|
|
8129
7281
|
const reader = result.stream.getReader();
|
|
8130
|
-
|
|
7282
|
+
stream6.onAbort(() => {
|
|
8131
7283
|
void reader.cancel("request aborted");
|
|
8132
7284
|
});
|
|
8133
7285
|
let chunkResult;
|
|
8134
7286
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
8135
|
-
await
|
|
7287
|
+
await stream6.write(JSON.stringify(chunkResult.value) + "");
|
|
8136
7288
|
}
|
|
8137
7289
|
} catch (err) {
|
|
8138
7290
|
mastra.getLogger().error("Error in network loop stream: " + (err?.message ?? "Unknown error"));
|
|
@@ -9518,7 +8670,7 @@ function watchWorkflowHandler(c2) {
|
|
|
9518
8670
|
c2.header("Transfer-Encoding", "chunked");
|
|
9519
8671
|
return streaming.stream(
|
|
9520
8672
|
c2,
|
|
9521
|
-
async (
|
|
8673
|
+
async (stream6) => {
|
|
9522
8674
|
try {
|
|
9523
8675
|
const result = await workflows.watchWorkflowHandler({
|
|
9524
8676
|
mastra,
|
|
@@ -9526,12 +8678,12 @@ function watchWorkflowHandler(c2) {
|
|
|
9526
8678
|
runId
|
|
9527
8679
|
});
|
|
9528
8680
|
const reader = result.getReader();
|
|
9529
|
-
|
|
8681
|
+
stream6.onAbort(() => {
|
|
9530
8682
|
void reader.cancel("request aborted");
|
|
9531
8683
|
});
|
|
9532
8684
|
let chunkResult;
|
|
9533
8685
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
9534
|
-
await
|
|
8686
|
+
await stream6.write(JSON.stringify(chunkResult.value) + "");
|
|
9535
8687
|
}
|
|
9536
8688
|
} catch (err) {
|
|
9537
8689
|
logger2.error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
@@ -9556,7 +8708,7 @@ async function streamWorkflowHandler(c2) {
|
|
|
9556
8708
|
c2.header("Transfer-Encoding", "chunked");
|
|
9557
8709
|
return streaming.stream(
|
|
9558
8710
|
c2,
|
|
9559
|
-
async (
|
|
8711
|
+
async (stream6) => {
|
|
9560
8712
|
try {
|
|
9561
8713
|
const result = await workflows.streamWorkflowHandler({
|
|
9562
8714
|
mastra,
|
|
@@ -9566,17 +8718,17 @@ async function streamWorkflowHandler(c2) {
|
|
|
9566
8718
|
runtimeContext
|
|
9567
8719
|
});
|
|
9568
8720
|
const reader = result.stream.getReader();
|
|
9569
|
-
|
|
8721
|
+
stream6.onAbort(() => {
|
|
9570
8722
|
void reader.cancel("request aborted");
|
|
9571
8723
|
});
|
|
9572
8724
|
let chunkResult;
|
|
9573
8725
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
9574
|
-
await
|
|
8726
|
+
await stream6.write(JSON.stringify(chunkResult.value) + "");
|
|
9575
8727
|
}
|
|
9576
8728
|
} catch (err) {
|
|
9577
8729
|
logger2.error("Error in workflow stream: " + (err?.message ?? "Unknown error"));
|
|
9578
8730
|
}
|
|
9579
|
-
await
|
|
8731
|
+
await stream6.close();
|
|
9580
8732
|
},
|
|
9581
8733
|
async (err) => {
|
|
9582
8734
|
logger2.error("Error in workflow stream: " + err?.message);
|
|
@@ -9597,7 +8749,7 @@ async function streamVNextWorkflowHandler(c2) {
|
|
|
9597
8749
|
c2.header("Transfer-Encoding", "chunked");
|
|
9598
8750
|
return streaming.stream(
|
|
9599
8751
|
c2,
|
|
9600
|
-
async (
|
|
8752
|
+
async (stream6) => {
|
|
9601
8753
|
try {
|
|
9602
8754
|
const result = await workflows.streamVNextWorkflowHandler({
|
|
9603
8755
|
mastra,
|
|
@@ -9607,12 +8759,12 @@ async function streamVNextWorkflowHandler(c2) {
|
|
|
9607
8759
|
runtimeContext
|
|
9608
8760
|
});
|
|
9609
8761
|
const reader = result.getReader();
|
|
9610
|
-
|
|
8762
|
+
stream6.onAbort(() => {
|
|
9611
8763
|
void reader.cancel("request aborted");
|
|
9612
8764
|
});
|
|
9613
8765
|
let chunkResult;
|
|
9614
8766
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
9615
|
-
await
|
|
8767
|
+
await stream6.write(JSON.stringify(chunkResult.value) + "");
|
|
9616
8768
|
}
|
|
9617
8769
|
} catch (err) {
|
|
9618
8770
|
logger2.error("Error in workflow VNext stream: " + (err?.message ?? "Unknown error"));
|
|
@@ -9840,20 +8992,20 @@ function watchLegacyWorkflowHandler(c2) {
|
|
|
9840
8992
|
}
|
|
9841
8993
|
return streaming.stream(
|
|
9842
8994
|
c2,
|
|
9843
|
-
async (
|
|
8995
|
+
async (stream6) => {
|
|
9844
8996
|
try {
|
|
9845
8997
|
const result = await legacyWorkflows.watchLegacyWorkflowHandler({
|
|
9846
8998
|
mastra,
|
|
9847
8999
|
workflowId,
|
|
9848
9000
|
runId
|
|
9849
9001
|
});
|
|
9850
|
-
|
|
9002
|
+
stream6.onAbort(() => {
|
|
9851
9003
|
if (!result.locked) {
|
|
9852
9004
|
return result.cancel();
|
|
9853
9005
|
}
|
|
9854
9006
|
});
|
|
9855
9007
|
for await (const chunk of result) {
|
|
9856
|
-
await
|
|
9008
|
+
await stream6.write(chunk.toString() + "");
|
|
9857
9009
|
}
|
|
9858
9010
|
} catch (err) {
|
|
9859
9011
|
console.log(err);
|
|
@@ -11153,7 +10305,6 @@ async function createHonoServer(mastra, options = {
|
|
|
11153
10305
|
app.route("/api/workflows", workflowsRouter(bodyLimitOptions));
|
|
11154
10306
|
app.route("/api/logs", logsRouter());
|
|
11155
10307
|
app.route("/api/scores", scoresRouter(bodyLimitOptions));
|
|
11156
|
-
app.route("/api/agent-builder", agentBuilderRouter(bodyLimitOptions));
|
|
11157
10308
|
app.route("/api/tools", toolsRouter(bodyLimitOptions, options.tools));
|
|
11158
10309
|
app.route("/api/vector", vectorRouter(bodyLimitOptions));
|
|
11159
10310
|
if (options?.isDev || server?.build?.openAPIDocs || server?.build?.swaggerUI) {
|