@mastra/deployer 0.3.5-alpha.0 → 0.10.0
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/_tsup-dts-rollup.d.cts +46 -22
- package/dist/_tsup-dts-rollup.d.ts +46 -22
- package/dist/server/index.cjs +499 -397
- package/dist/server/index.js +500 -398
- package/dist/templates/instrumentation-template.js +5 -2
- package/package.json +8 -5
package/dist/server/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var httpException = require('hono/http-exception');
|
|
|
21
21
|
var a2a = require('@mastra/server/handlers/a2a');
|
|
22
22
|
var streaming = require('hono/streaming');
|
|
23
23
|
var agents = require('@mastra/server/handlers/agents');
|
|
24
|
+
var legacyWorkflows = require('@mastra/server/handlers/legacyWorkflows');
|
|
24
25
|
var logs = require('@mastra/server/handlers/logs');
|
|
25
26
|
var util = require('util');
|
|
26
27
|
var buffer = require('buffer');
|
|
@@ -31,7 +32,6 @@ var zod = require('zod');
|
|
|
31
32
|
var telemetry = require('@mastra/server/handlers/telemetry');
|
|
32
33
|
var tools = require('@mastra/server/handlers/tools');
|
|
33
34
|
var vector = require('@mastra/server/handlers/vector');
|
|
34
|
-
var vNextWorkflows = require('@mastra/server/handlers/vNextWorkflows');
|
|
35
35
|
var voice = require('@mastra/server/handlers/voice');
|
|
36
36
|
var workflows = require('@mastra/server/handlers/workflows');
|
|
37
37
|
|
|
@@ -1044,6 +1044,187 @@ async function setAgentInstructionsHandler(c2) {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
1047
|
+
// src/server/handlers/auth/defaults.ts
|
|
1048
|
+
var defaultAuthConfig = {
|
|
1049
|
+
public: [
|
|
1050
|
+
"/",
|
|
1051
|
+
"/refresh-events",
|
|
1052
|
+
"/__refresh",
|
|
1053
|
+
"/assets/*",
|
|
1054
|
+
"/auth/*",
|
|
1055
|
+
"/openapi.json",
|
|
1056
|
+
"/swagger-ui",
|
|
1057
|
+
["/api/agents", "GET"],
|
|
1058
|
+
["/a2a/*", ["GET"]]
|
|
1059
|
+
],
|
|
1060
|
+
// Simple rule system
|
|
1061
|
+
rules: [
|
|
1062
|
+
// Admin users can do anything
|
|
1063
|
+
{
|
|
1064
|
+
condition: (user) => {
|
|
1065
|
+
if (typeof user === "object" && user !== null) {
|
|
1066
|
+
if ("isAdmin" in user) {
|
|
1067
|
+
return !!user.isAdmin;
|
|
1068
|
+
}
|
|
1069
|
+
if ("role" in user) {
|
|
1070
|
+
return user.role === "admin";
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
return false;
|
|
1074
|
+
},
|
|
1075
|
+
allow: true
|
|
1076
|
+
}
|
|
1077
|
+
]
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
// src/server/handlers/auth/helpers.ts
|
|
1081
|
+
var canAccessPublicly = (path, method, authConfig) => {
|
|
1082
|
+
const publicAccess = [...defaultAuthConfig.public || [], ...authConfig.public || []];
|
|
1083
|
+
for (const patternPathOrMethod of publicAccess) {
|
|
1084
|
+
if (patternPathOrMethod instanceof RegExp) {
|
|
1085
|
+
if (patternPathOrMethod.test(path)) {
|
|
1086
|
+
return true;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
if (typeof patternPathOrMethod === "string" && pathMatchesPattern(path, patternPathOrMethod)) {
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {
|
|
1093
|
+
const [pattern, methodOrMethods] = patternPathOrMethod;
|
|
1094
|
+
if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {
|
|
1095
|
+
return true;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return false;
|
|
1100
|
+
};
|
|
1101
|
+
var pathMatchesPattern = (path, pattern) => {
|
|
1102
|
+
if (pattern.endsWith("*")) {
|
|
1103
|
+
const prefix = pattern.slice(0, -1);
|
|
1104
|
+
return path.startsWith(prefix);
|
|
1105
|
+
}
|
|
1106
|
+
return path === pattern;
|
|
1107
|
+
};
|
|
1108
|
+
var pathMatchesRule = (path, rulePath) => {
|
|
1109
|
+
if (!rulePath) return true;
|
|
1110
|
+
if (typeof rulePath === "string") {
|
|
1111
|
+
return pathMatchesPattern(path, rulePath);
|
|
1112
|
+
}
|
|
1113
|
+
if (rulePath instanceof RegExp) {
|
|
1114
|
+
console.log("rulePath", rulePath, path, rulePath.test(path));
|
|
1115
|
+
return rulePath.test(path);
|
|
1116
|
+
}
|
|
1117
|
+
if (Array.isArray(rulePath)) {
|
|
1118
|
+
return rulePath.some((p2) => pathMatchesPattern(path, p2));
|
|
1119
|
+
}
|
|
1120
|
+
return false;
|
|
1121
|
+
};
|
|
1122
|
+
var matchesOrIncludes = (values, value) => {
|
|
1123
|
+
if (typeof values === "string") {
|
|
1124
|
+
return values === value;
|
|
1125
|
+
}
|
|
1126
|
+
if (Array.isArray(values)) {
|
|
1127
|
+
return values.includes(value);
|
|
1128
|
+
}
|
|
1129
|
+
return false;
|
|
1130
|
+
};
|
|
1131
|
+
var checkRules = async (rules, path, method, user) => {
|
|
1132
|
+
for (const i2 in rules || []) {
|
|
1133
|
+
const rule = rules?.[i2];
|
|
1134
|
+
if (!pathMatchesRule(path, rule.path)) {
|
|
1135
|
+
continue;
|
|
1136
|
+
}
|
|
1137
|
+
if (rule.methods && !matchesOrIncludes(rule.methods, method)) {
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
const condition = rule.condition;
|
|
1141
|
+
if (typeof condition === "function") {
|
|
1142
|
+
const allowed = await Promise.resolve().then(() => condition(user)).catch(() => false);
|
|
1143
|
+
if (allowed) {
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
} else if (rule.allow) {
|
|
1147
|
+
return true;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return false;
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
// src/server/handlers/auth/index.ts
|
|
1154
|
+
var authenticationMiddleware = async (c2, next) => {
|
|
1155
|
+
const mastra = c2.get("mastra");
|
|
1156
|
+
const authConfig = mastra.getServer()?.experimental_auth;
|
|
1157
|
+
if (!authConfig) {
|
|
1158
|
+
return next();
|
|
1159
|
+
}
|
|
1160
|
+
if (canAccessPublicly(c2.req.path, c2.req.method, authConfig)) {
|
|
1161
|
+
return next();
|
|
1162
|
+
}
|
|
1163
|
+
const authHeader = c2.req.header("Authorization");
|
|
1164
|
+
let token = authHeader ? authHeader.replace("Bearer ", "") : null;
|
|
1165
|
+
if (!token && c2.req.query("apiKey")) {
|
|
1166
|
+
token = c2.req.query("apiKey") || null;
|
|
1167
|
+
}
|
|
1168
|
+
if (!token) {
|
|
1169
|
+
return c2.json({ error: "Authentication required" }, 401);
|
|
1170
|
+
}
|
|
1171
|
+
try {
|
|
1172
|
+
let user;
|
|
1173
|
+
if (typeof authConfig.authenticateToken === "function") {
|
|
1174
|
+
user = await authConfig.authenticateToken(token, c2.req);
|
|
1175
|
+
} else {
|
|
1176
|
+
throw new Error("No token verification method configured");
|
|
1177
|
+
}
|
|
1178
|
+
if (!user) {
|
|
1179
|
+
return c2.json({ error: "Invalid or expired token" }, 401);
|
|
1180
|
+
}
|
|
1181
|
+
c2.get("runtimeContext").set("user", user);
|
|
1182
|
+
return next();
|
|
1183
|
+
} catch (err) {
|
|
1184
|
+
console.error(err);
|
|
1185
|
+
return c2.json({ error: "Invalid or expired token" }, 401);
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
var authorizationMiddleware = async (c2, next) => {
|
|
1189
|
+
const mastra = c2.get("mastra");
|
|
1190
|
+
const authConfig = mastra.getServer()?.experimental_auth;
|
|
1191
|
+
if (!authConfig) {
|
|
1192
|
+
return next();
|
|
1193
|
+
}
|
|
1194
|
+
const path = c2.req.path;
|
|
1195
|
+
const method = c2.req.method;
|
|
1196
|
+
if (canAccessPublicly(path, method, authConfig)) {
|
|
1197
|
+
return next();
|
|
1198
|
+
}
|
|
1199
|
+
const user = c2.get("runtimeContext").get("user");
|
|
1200
|
+
if (typeof authConfig.authorize === "function") {
|
|
1201
|
+
try {
|
|
1202
|
+
const isAuthorized = await authConfig.authorize(path, method, user, c2);
|
|
1203
|
+
if (isAuthorized) {
|
|
1204
|
+
return next();
|
|
1205
|
+
}
|
|
1206
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1207
|
+
} catch (err) {
|
|
1208
|
+
console.error(err);
|
|
1209
|
+
return c2.json({ error: "Authorization error" }, 500);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
if (authConfig.rules && authConfig.rules.length > 0) {
|
|
1213
|
+
const isAuthorized = await checkRules(authConfig.rules, path, method, user);
|
|
1214
|
+
if (isAuthorized) {
|
|
1215
|
+
return next();
|
|
1216
|
+
}
|
|
1217
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1218
|
+
}
|
|
1219
|
+
if (defaultAuthConfig.rules && defaultAuthConfig.rules.length > 0) {
|
|
1220
|
+
const isAuthorized = await checkRules(defaultAuthConfig.rules, path, method, user);
|
|
1221
|
+
if (isAuthorized) {
|
|
1222
|
+
return next();
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1047
1228
|
// src/server/handlers/client.ts
|
|
1048
1229
|
var clients = /* @__PURE__ */ new Set();
|
|
1049
1230
|
function handleClientsRefresh(c2) {
|
|
@@ -1075,6 +1256,184 @@ function handleTriggerClientsRefresh(c2) {
|
|
|
1075
1256
|
});
|
|
1076
1257
|
return c2.json({ success: true, clients: clients.size });
|
|
1077
1258
|
}
|
|
1259
|
+
async function getLegacyWorkflowsHandler(c2) {
|
|
1260
|
+
try {
|
|
1261
|
+
const mastra = c2.get("mastra");
|
|
1262
|
+
const workflows = await legacyWorkflows.getLegacyWorkflowsHandler({
|
|
1263
|
+
mastra
|
|
1264
|
+
});
|
|
1265
|
+
return c2.json(workflows);
|
|
1266
|
+
} catch (error) {
|
|
1267
|
+
return handleError(error, "Error getting workflows");
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
async function getLegacyWorkflowByIdHandler(c2) {
|
|
1271
|
+
try {
|
|
1272
|
+
const mastra = c2.get("mastra");
|
|
1273
|
+
const workflowId = c2.req.param("workflowId");
|
|
1274
|
+
const workflow = await legacyWorkflows.getLegacyWorkflowByIdHandler({
|
|
1275
|
+
mastra,
|
|
1276
|
+
workflowId
|
|
1277
|
+
});
|
|
1278
|
+
return c2.json(workflow);
|
|
1279
|
+
} catch (error) {
|
|
1280
|
+
return handleError(error, "Error getting workflow");
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
async function startAsyncLegacyWorkflowHandler(c2) {
|
|
1284
|
+
try {
|
|
1285
|
+
const mastra = c2.get("mastra");
|
|
1286
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1287
|
+
const workflowId = c2.req.param("workflowId");
|
|
1288
|
+
const triggerData = await c2.req.json();
|
|
1289
|
+
const runId = c2.req.query("runId");
|
|
1290
|
+
const result = await legacyWorkflows.startAsyncLegacyWorkflowHandler({
|
|
1291
|
+
mastra,
|
|
1292
|
+
runtimeContext,
|
|
1293
|
+
workflowId,
|
|
1294
|
+
runId,
|
|
1295
|
+
triggerData
|
|
1296
|
+
});
|
|
1297
|
+
return c2.json(result);
|
|
1298
|
+
} catch (error) {
|
|
1299
|
+
return handleError(error, "Error executing workflow");
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
async function createLegacyWorkflowRunHandler(c2) {
|
|
1303
|
+
try {
|
|
1304
|
+
const mastra = c2.get("mastra");
|
|
1305
|
+
const workflowId = c2.req.param("workflowId");
|
|
1306
|
+
const prevRunId = c2.req.query("runId");
|
|
1307
|
+
const result = await legacyWorkflows.createLegacyWorkflowRunHandler({
|
|
1308
|
+
mastra,
|
|
1309
|
+
workflowId,
|
|
1310
|
+
runId: prevRunId
|
|
1311
|
+
});
|
|
1312
|
+
return c2.json(result);
|
|
1313
|
+
} catch (e2) {
|
|
1314
|
+
return handleError(e2, "Error creating run");
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
async function startLegacyWorkflowRunHandler(c2) {
|
|
1318
|
+
try {
|
|
1319
|
+
const mastra = c2.get("mastra");
|
|
1320
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1321
|
+
const workflowId = c2.req.param("workflowId");
|
|
1322
|
+
const triggerData = await c2.req.json();
|
|
1323
|
+
const runId = c2.req.query("runId");
|
|
1324
|
+
await legacyWorkflows.startLegacyWorkflowRunHandler({
|
|
1325
|
+
mastra,
|
|
1326
|
+
runtimeContext,
|
|
1327
|
+
workflowId,
|
|
1328
|
+
runId,
|
|
1329
|
+
triggerData
|
|
1330
|
+
});
|
|
1331
|
+
return c2.json({ message: "Workflow run started" });
|
|
1332
|
+
} catch (e2) {
|
|
1333
|
+
return handleError(e2, "Error starting workflow run");
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
function watchLegacyWorkflowHandler(c2) {
|
|
1337
|
+
try {
|
|
1338
|
+
const mastra = c2.get("mastra");
|
|
1339
|
+
const logger2 = mastra.getLogger();
|
|
1340
|
+
const workflowId = c2.req.param("workflowId");
|
|
1341
|
+
const runId = c2.req.query("runId");
|
|
1342
|
+
if (!runId) {
|
|
1343
|
+
throw new httpException.HTTPException(400, { message: "runId required to watch workflow" });
|
|
1344
|
+
}
|
|
1345
|
+
return streaming.stream(
|
|
1346
|
+
c2,
|
|
1347
|
+
async (stream4) => {
|
|
1348
|
+
try {
|
|
1349
|
+
const result = await legacyWorkflows.watchLegacyWorkflowHandler({
|
|
1350
|
+
mastra,
|
|
1351
|
+
workflowId,
|
|
1352
|
+
runId
|
|
1353
|
+
});
|
|
1354
|
+
stream4.onAbort(() => {
|
|
1355
|
+
if (!result.locked) {
|
|
1356
|
+
return result.cancel();
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
for await (const chunk of result) {
|
|
1360
|
+
await stream4.write(chunk.toString() + "");
|
|
1361
|
+
}
|
|
1362
|
+
} catch (err) {
|
|
1363
|
+
console.log(err);
|
|
1364
|
+
}
|
|
1365
|
+
},
|
|
1366
|
+
async (err) => {
|
|
1367
|
+
logger2.error("Error in watch stream: " + err?.message);
|
|
1368
|
+
}
|
|
1369
|
+
);
|
|
1370
|
+
} catch (error) {
|
|
1371
|
+
return handleError(error, "Error watching workflow");
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
async function resumeAsyncLegacyWorkflowHandler(c2) {
|
|
1375
|
+
try {
|
|
1376
|
+
const mastra = c2.get("mastra");
|
|
1377
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1378
|
+
const workflowId = c2.req.param("workflowId");
|
|
1379
|
+
const runId = c2.req.query("runId");
|
|
1380
|
+
const { stepId, context } = await c2.req.json();
|
|
1381
|
+
if (!runId) {
|
|
1382
|
+
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
1383
|
+
}
|
|
1384
|
+
const result = await legacyWorkflows.resumeAsyncLegacyWorkflowHandler({
|
|
1385
|
+
mastra,
|
|
1386
|
+
runtimeContext,
|
|
1387
|
+
workflowId,
|
|
1388
|
+
runId,
|
|
1389
|
+
body: { stepId, context }
|
|
1390
|
+
});
|
|
1391
|
+
return c2.json(result);
|
|
1392
|
+
} catch (error) {
|
|
1393
|
+
return handleError(error, "Error resuming workflow step");
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
async function resumeLegacyWorkflowHandler(c2) {
|
|
1397
|
+
try {
|
|
1398
|
+
const mastra = c2.get("mastra");
|
|
1399
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1400
|
+
const workflowId = c2.req.param("workflowId");
|
|
1401
|
+
const runId = c2.req.query("runId");
|
|
1402
|
+
const { stepId, context } = await c2.req.json();
|
|
1403
|
+
if (!runId) {
|
|
1404
|
+
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
1405
|
+
}
|
|
1406
|
+
await legacyWorkflows.resumeLegacyWorkflowHandler({
|
|
1407
|
+
mastra,
|
|
1408
|
+
runtimeContext,
|
|
1409
|
+
workflowId,
|
|
1410
|
+
runId,
|
|
1411
|
+
body: { stepId, context }
|
|
1412
|
+
});
|
|
1413
|
+
return c2.json({ message: "Workflow run resumed" });
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
return handleError(error, "Error resuming workflow");
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
async function getLegacyWorkflowRunsHandler(c2) {
|
|
1419
|
+
try {
|
|
1420
|
+
const mastra = c2.get("mastra");
|
|
1421
|
+
const workflowId = c2.req.param("workflowId");
|
|
1422
|
+
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
1423
|
+
const workflowRuns = await legacyWorkflows.getLegacyWorkflowRunsHandler({
|
|
1424
|
+
mastra,
|
|
1425
|
+
workflowId,
|
|
1426
|
+
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
1427
|
+
toDate: toDate ? new Date(toDate) : void 0,
|
|
1428
|
+
limit: limit ? Number(limit) : void 0,
|
|
1429
|
+
offset: offset ? Number(offset) : void 0,
|
|
1430
|
+
resourceId
|
|
1431
|
+
});
|
|
1432
|
+
return c2.json(workflowRuns);
|
|
1433
|
+
} catch (error) {
|
|
1434
|
+
return handleError(error, "Error getting workflow runs");
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1078
1437
|
async function getLogsHandler(c2) {
|
|
1079
1438
|
try {
|
|
1080
1439
|
const mastra = c2.get("mastra");
|
|
@@ -3665,217 +4024,37 @@ async function deleteIndex(c2) {
|
|
|
3665
4024
|
return handleError(error, "Error deleting index");
|
|
3666
4025
|
}
|
|
3667
4026
|
}
|
|
3668
|
-
async function
|
|
4027
|
+
async function getSpeakersHandler(c2) {
|
|
3669
4028
|
try {
|
|
3670
4029
|
const mastra = c2.get("mastra");
|
|
3671
|
-
const
|
|
3672
|
-
|
|
4030
|
+
const agentId = c2.req.param("agentId");
|
|
4031
|
+
const speakers = await voice.getSpeakersHandler({
|
|
4032
|
+
mastra,
|
|
4033
|
+
agentId
|
|
3673
4034
|
});
|
|
3674
|
-
return c2.json(
|
|
4035
|
+
return c2.json(speakers);
|
|
3675
4036
|
} catch (error) {
|
|
3676
|
-
return handleError(error, "Error getting
|
|
4037
|
+
return handleError(error, "Error getting speakers");
|
|
3677
4038
|
}
|
|
3678
4039
|
}
|
|
3679
|
-
async function
|
|
4040
|
+
async function speakHandler(c2) {
|
|
3680
4041
|
try {
|
|
3681
4042
|
const mastra = c2.get("mastra");
|
|
3682
|
-
const
|
|
3683
|
-
const
|
|
4043
|
+
const agentId = c2.req.param("agentId");
|
|
4044
|
+
const { input, options } = await c2.req.json();
|
|
4045
|
+
const audioStream = await voice.generateSpeechHandler({
|
|
3684
4046
|
mastra,
|
|
3685
|
-
|
|
4047
|
+
agentId,
|
|
4048
|
+
body: { text: input, speakerId: options?.speakerId }
|
|
3686
4049
|
});
|
|
3687
|
-
|
|
4050
|
+
c2.header("Content-Type", `audio/${options?.filetype ?? "mp3"}`);
|
|
4051
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4052
|
+
return c2.body(audioStream);
|
|
3688
4053
|
} catch (error) {
|
|
3689
|
-
return handleError(error, "Error
|
|
4054
|
+
return handleError(error, "Error generating speech");
|
|
3690
4055
|
}
|
|
3691
4056
|
}
|
|
3692
|
-
async function
|
|
3693
|
-
try {
|
|
3694
|
-
const mastra = c2.get("mastra");
|
|
3695
|
-
const workflowId = c2.req.param("workflowId");
|
|
3696
|
-
const prevRunId = c2.req.query("runId");
|
|
3697
|
-
const result = await vNextWorkflows.createVNextWorkflowRunHandler({
|
|
3698
|
-
mastra,
|
|
3699
|
-
workflowId,
|
|
3700
|
-
runId: prevRunId
|
|
3701
|
-
});
|
|
3702
|
-
return c2.json(result);
|
|
3703
|
-
} catch (e2) {
|
|
3704
|
-
return handleError(e2, "Error creating run");
|
|
3705
|
-
}
|
|
3706
|
-
}
|
|
3707
|
-
async function startAsyncVNextWorkflowHandler(c2) {
|
|
3708
|
-
try {
|
|
3709
|
-
const mastra = c2.get("mastra");
|
|
3710
|
-
const workflowId = c2.req.param("workflowId");
|
|
3711
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3712
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3713
|
-
const runId = c2.req.query("runId");
|
|
3714
|
-
const result = await vNextWorkflows.startAsyncVNextWorkflowHandler({
|
|
3715
|
-
mastra,
|
|
3716
|
-
runtimeContext,
|
|
3717
|
-
runtimeContextFromRequest,
|
|
3718
|
-
workflowId,
|
|
3719
|
-
runId,
|
|
3720
|
-
inputData
|
|
3721
|
-
});
|
|
3722
|
-
return c2.json(result);
|
|
3723
|
-
} catch (error) {
|
|
3724
|
-
return handleError(error, "Error executing workflow");
|
|
3725
|
-
}
|
|
3726
|
-
}
|
|
3727
|
-
async function startVNextWorkflowRunHandler(c2) {
|
|
3728
|
-
try {
|
|
3729
|
-
const mastra = c2.get("mastra");
|
|
3730
|
-
const workflowId = c2.req.param("workflowId");
|
|
3731
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3732
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3733
|
-
const runId = c2.req.query("runId");
|
|
3734
|
-
await vNextWorkflows.startVNextWorkflowRunHandler({
|
|
3735
|
-
mastra,
|
|
3736
|
-
runtimeContext,
|
|
3737
|
-
runtimeContextFromRequest,
|
|
3738
|
-
workflowId,
|
|
3739
|
-
runId,
|
|
3740
|
-
inputData
|
|
3741
|
-
});
|
|
3742
|
-
return c2.json({ message: "Workflow run started" });
|
|
3743
|
-
} catch (e2) {
|
|
3744
|
-
return handleError(e2, "Error starting workflow run");
|
|
3745
|
-
}
|
|
3746
|
-
}
|
|
3747
|
-
function watchVNextWorkflowHandler(c2) {
|
|
3748
|
-
try {
|
|
3749
|
-
const mastra = c2.get("mastra");
|
|
3750
|
-
const logger2 = mastra.getLogger();
|
|
3751
|
-
const workflowId = c2.req.param("workflowId");
|
|
3752
|
-
const runId = c2.req.query("runId");
|
|
3753
|
-
if (!runId) {
|
|
3754
|
-
throw new httpException.HTTPException(400, { message: "runId required to watch workflow" });
|
|
3755
|
-
}
|
|
3756
|
-
return streaming.stream(
|
|
3757
|
-
c2,
|
|
3758
|
-
async (stream4) => {
|
|
3759
|
-
try {
|
|
3760
|
-
const result = await vNextWorkflows.watchVNextWorkflowHandler({
|
|
3761
|
-
mastra,
|
|
3762
|
-
workflowId,
|
|
3763
|
-
runId
|
|
3764
|
-
});
|
|
3765
|
-
stream4.onAbort(() => {
|
|
3766
|
-
if (!result.locked) {
|
|
3767
|
-
return result.cancel();
|
|
3768
|
-
}
|
|
3769
|
-
});
|
|
3770
|
-
for await (const chunk of result) {
|
|
3771
|
-
await stream4.write(chunk.toString() + "");
|
|
3772
|
-
}
|
|
3773
|
-
} catch (err) {
|
|
3774
|
-
console.log(err);
|
|
3775
|
-
}
|
|
3776
|
-
},
|
|
3777
|
-
async (err) => {
|
|
3778
|
-
logger2.error("Error in watch stream: " + err?.message);
|
|
3779
|
-
}
|
|
3780
|
-
);
|
|
3781
|
-
} catch (error) {
|
|
3782
|
-
return handleError(error, "Error watching workflow");
|
|
3783
|
-
}
|
|
3784
|
-
}
|
|
3785
|
-
async function resumeAsyncVNextWorkflowHandler(c2) {
|
|
3786
|
-
try {
|
|
3787
|
-
const mastra = c2.get("mastra");
|
|
3788
|
-
const workflowId = c2.req.param("workflowId");
|
|
3789
|
-
const runId = c2.req.query("runId");
|
|
3790
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3791
|
-
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3792
|
-
if (!runId) {
|
|
3793
|
-
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
3794
|
-
}
|
|
3795
|
-
const result = await vNextWorkflows.resumeAsyncVNextWorkflowHandler({
|
|
3796
|
-
mastra,
|
|
3797
|
-
runtimeContext,
|
|
3798
|
-
runtimeContextFromRequest,
|
|
3799
|
-
workflowId,
|
|
3800
|
-
runId,
|
|
3801
|
-
body: { step, resumeData }
|
|
3802
|
-
});
|
|
3803
|
-
return c2.json(result);
|
|
3804
|
-
} catch (error) {
|
|
3805
|
-
return handleError(error, "Error resuming workflow step");
|
|
3806
|
-
}
|
|
3807
|
-
}
|
|
3808
|
-
async function resumeVNextWorkflowHandler(c2) {
|
|
3809
|
-
try {
|
|
3810
|
-
const mastra = c2.get("mastra");
|
|
3811
|
-
const workflowId = c2.req.param("workflowId");
|
|
3812
|
-
const runId = c2.req.query("runId");
|
|
3813
|
-
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
3814
|
-
if (!runId) {
|
|
3815
|
-
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
3816
|
-
}
|
|
3817
|
-
await vNextWorkflows.resumeVNextWorkflowHandler({
|
|
3818
|
-
mastra,
|
|
3819
|
-
runtimeContext,
|
|
3820
|
-
workflowId,
|
|
3821
|
-
runId,
|
|
3822
|
-
body: { step, resumeData }
|
|
3823
|
-
});
|
|
3824
|
-
return c2.json({ message: "Workflow run resumed" });
|
|
3825
|
-
} catch (error) {
|
|
3826
|
-
return handleError(error, "Error resuming workflow");
|
|
3827
|
-
}
|
|
3828
|
-
}
|
|
3829
|
-
async function getVNextWorkflowRunsHandler(c2) {
|
|
3830
|
-
try {
|
|
3831
|
-
const mastra = c2.get("mastra");
|
|
3832
|
-
const workflowId = c2.req.param("workflowId");
|
|
3833
|
-
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
3834
|
-
const workflowRuns = await vNextWorkflows.getVNextWorkflowRunsHandler({
|
|
3835
|
-
mastra,
|
|
3836
|
-
workflowId,
|
|
3837
|
-
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
3838
|
-
toDate: toDate ? new Date(toDate) : void 0,
|
|
3839
|
-
limit: limit ? Number(limit) : void 0,
|
|
3840
|
-
offset: offset ? Number(offset) : void 0,
|
|
3841
|
-
resourceId
|
|
3842
|
-
});
|
|
3843
|
-
return c2.json(workflowRuns);
|
|
3844
|
-
} catch (error) {
|
|
3845
|
-
return handleError(error, "Error getting workflow runs");
|
|
3846
|
-
}
|
|
3847
|
-
}
|
|
3848
|
-
async function getSpeakersHandler(c2) {
|
|
3849
|
-
try {
|
|
3850
|
-
const mastra = c2.get("mastra");
|
|
3851
|
-
const agentId = c2.req.param("agentId");
|
|
3852
|
-
const speakers = await voice.getSpeakersHandler({
|
|
3853
|
-
mastra,
|
|
3854
|
-
agentId
|
|
3855
|
-
});
|
|
3856
|
-
return c2.json(speakers);
|
|
3857
|
-
} catch (error) {
|
|
3858
|
-
return handleError(error, "Error getting speakers");
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
async function speakHandler(c2) {
|
|
3862
|
-
try {
|
|
3863
|
-
const mastra = c2.get("mastra");
|
|
3864
|
-
const agentId = c2.req.param("agentId");
|
|
3865
|
-
const { input, options } = await c2.req.json();
|
|
3866
|
-
const audioStream = await voice.generateSpeechHandler({
|
|
3867
|
-
mastra,
|
|
3868
|
-
agentId,
|
|
3869
|
-
body: { text: input, speakerId: options?.speakerId }
|
|
3870
|
-
});
|
|
3871
|
-
c2.header("Content-Type", `audio/${options?.filetype ?? "mp3"}`);
|
|
3872
|
-
c2.header("Transfer-Encoding", "chunked");
|
|
3873
|
-
return c2.body(audioStream);
|
|
3874
|
-
} catch (error) {
|
|
3875
|
-
return handleError(error, "Error generating speech");
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
3878
|
-
async function listenHandler(c2) {
|
|
4057
|
+
async function listenHandler(c2) {
|
|
3879
4058
|
try {
|
|
3880
4059
|
const mastra = c2.get("mastra");
|
|
3881
4060
|
const agentId = c2.req.param("agentId");
|
|
@@ -3928,53 +4107,55 @@ async function getWorkflowByIdHandler(c2) {
|
|
|
3928
4107
|
return handleError(error, "Error getting workflow");
|
|
3929
4108
|
}
|
|
3930
4109
|
}
|
|
3931
|
-
async function
|
|
4110
|
+
async function createWorkflowRunHandler(c2) {
|
|
3932
4111
|
try {
|
|
3933
4112
|
const mastra = c2.get("mastra");
|
|
3934
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3935
4113
|
const workflowId = c2.req.param("workflowId");
|
|
3936
|
-
const
|
|
3937
|
-
const
|
|
3938
|
-
const result = await workflows.startAsyncWorkflowHandler({
|
|
4114
|
+
const prevRunId = c2.req.query("runId");
|
|
4115
|
+
const result = await workflows.createWorkflowRunHandler({
|
|
3939
4116
|
mastra,
|
|
3940
|
-
runtimeContext,
|
|
3941
4117
|
workflowId,
|
|
3942
|
-
runId
|
|
3943
|
-
triggerData
|
|
4118
|
+
runId: prevRunId
|
|
3944
4119
|
});
|
|
3945
4120
|
return c2.json(result);
|
|
3946
|
-
} catch (
|
|
3947
|
-
return handleError(
|
|
4121
|
+
} catch (e2) {
|
|
4122
|
+
return handleError(e2, "Error creating run");
|
|
3948
4123
|
}
|
|
3949
4124
|
}
|
|
3950
|
-
async function
|
|
4125
|
+
async function startAsyncWorkflowHandler(c2) {
|
|
3951
4126
|
try {
|
|
3952
4127
|
const mastra = c2.get("mastra");
|
|
3953
4128
|
const workflowId = c2.req.param("workflowId");
|
|
3954
|
-
const
|
|
3955
|
-
const
|
|
4129
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4130
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
4131
|
+
const runId = c2.req.query("runId");
|
|
4132
|
+
const result = await workflows.startAsyncWorkflowHandler({
|
|
3956
4133
|
mastra,
|
|
4134
|
+
runtimeContext,
|
|
4135
|
+
runtimeContextFromRequest,
|
|
3957
4136
|
workflowId,
|
|
3958
|
-
runId
|
|
4137
|
+
runId,
|
|
4138
|
+
inputData
|
|
3959
4139
|
});
|
|
3960
4140
|
return c2.json(result);
|
|
3961
|
-
} catch (
|
|
3962
|
-
return handleError(
|
|
4141
|
+
} catch (error) {
|
|
4142
|
+
return handleError(error, "Error executing workflow");
|
|
3963
4143
|
}
|
|
3964
4144
|
}
|
|
3965
4145
|
async function startWorkflowRunHandler(c2) {
|
|
3966
4146
|
try {
|
|
3967
4147
|
const mastra = c2.get("mastra");
|
|
3968
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3969
4148
|
const workflowId = c2.req.param("workflowId");
|
|
3970
|
-
const
|
|
4149
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4150
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3971
4151
|
const runId = c2.req.query("runId");
|
|
3972
4152
|
await workflows.startWorkflowRunHandler({
|
|
3973
4153
|
mastra,
|
|
3974
4154
|
runtimeContext,
|
|
4155
|
+
runtimeContextFromRequest,
|
|
3975
4156
|
workflowId,
|
|
3976
4157
|
runId,
|
|
3977
|
-
|
|
4158
|
+
inputData
|
|
3978
4159
|
});
|
|
3979
4160
|
return c2.json({ message: "Workflow run started" });
|
|
3980
4161
|
} catch (e2) {
|
|
@@ -4022,19 +4203,20 @@ function watchWorkflowHandler(c2) {
|
|
|
4022
4203
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
4023
4204
|
try {
|
|
4024
4205
|
const mastra = c2.get("mastra");
|
|
4025
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
4026
4206
|
const workflowId = c2.req.param("workflowId");
|
|
4027
4207
|
const runId = c2.req.query("runId");
|
|
4028
|
-
const
|
|
4208
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4209
|
+
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
4029
4210
|
if (!runId) {
|
|
4030
4211
|
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
4031
4212
|
}
|
|
4032
4213
|
const result = await workflows.resumeAsyncWorkflowHandler({
|
|
4033
4214
|
mastra,
|
|
4034
4215
|
runtimeContext,
|
|
4216
|
+
runtimeContextFromRequest,
|
|
4035
4217
|
workflowId,
|
|
4036
4218
|
runId,
|
|
4037
|
-
body: {
|
|
4219
|
+
body: { step, resumeData }
|
|
4038
4220
|
});
|
|
4039
4221
|
return c2.json(result);
|
|
4040
4222
|
} catch (error) {
|
|
@@ -4044,10 +4226,9 @@ async function resumeAsyncWorkflowHandler(c2) {
|
|
|
4044
4226
|
async function resumeWorkflowHandler(c2) {
|
|
4045
4227
|
try {
|
|
4046
4228
|
const mastra = c2.get("mastra");
|
|
4047
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
4048
4229
|
const workflowId = c2.req.param("workflowId");
|
|
4049
4230
|
const runId = c2.req.query("runId");
|
|
4050
|
-
const {
|
|
4231
|
+
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
4051
4232
|
if (!runId) {
|
|
4052
4233
|
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
4053
4234
|
}
|
|
@@ -4056,7 +4237,7 @@ async function resumeWorkflowHandler(c2) {
|
|
|
4056
4237
|
runtimeContext,
|
|
4057
4238
|
workflowId,
|
|
4058
4239
|
runId,
|
|
4059
|
-
body: {
|
|
4240
|
+
body: { step, resumeData }
|
|
4060
4241
|
});
|
|
4061
4242
|
return c2.json({ message: "Workflow run resumed" });
|
|
4062
4243
|
} catch (error) {
|
|
@@ -4273,6 +4454,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
4273
4454
|
};
|
|
4274
4455
|
app.use("*", timeout.timeout(server?.timeout ?? 3 * 60 * 1e3), cors.cors(corsConfig));
|
|
4275
4456
|
}
|
|
4457
|
+
app.use("*", authenticationMiddleware);
|
|
4458
|
+
app.use("*", authorizationMiddleware);
|
|
4276
4459
|
const bodyLimitOptions = {
|
|
4277
4460
|
maxSize: server?.bodySizeLimit ?? 4.5 * 1024 * 1024,
|
|
4278
4461
|
// 4.5 MB,
|
|
@@ -5840,23 +6023,23 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5840
6023
|
storeTelemetryHandler
|
|
5841
6024
|
);
|
|
5842
6025
|
app.get(
|
|
5843
|
-
"/api/workflows/
|
|
6026
|
+
"/api/workflows/legacy",
|
|
5844
6027
|
h({
|
|
5845
|
-
description: "Get all
|
|
5846
|
-
tags: ["
|
|
6028
|
+
description: "Get all legacy workflows",
|
|
6029
|
+
tags: ["legacyWorkflows"],
|
|
5847
6030
|
responses: {
|
|
5848
6031
|
200: {
|
|
5849
|
-
description: "List of all
|
|
6032
|
+
description: "List of all legacy workflows"
|
|
5850
6033
|
}
|
|
5851
6034
|
}
|
|
5852
6035
|
}),
|
|
5853
|
-
|
|
6036
|
+
getLegacyWorkflowsHandler
|
|
5854
6037
|
);
|
|
5855
6038
|
app.get(
|
|
5856
|
-
"/api/workflows/
|
|
6039
|
+
"/api/workflows/legacy/:workflowId",
|
|
5857
6040
|
h({
|
|
5858
|
-
description: "Get
|
|
5859
|
-
tags: ["
|
|
6041
|
+
description: "Get legacy workflow by ID",
|
|
6042
|
+
tags: ["legacyWorkflows"],
|
|
5860
6043
|
parameters: [
|
|
5861
6044
|
{
|
|
5862
6045
|
name: "workflowId",
|
|
@@ -5867,20 +6050,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5867
6050
|
],
|
|
5868
6051
|
responses: {
|
|
5869
6052
|
200: {
|
|
5870
|
-
description: "
|
|
6053
|
+
description: "Legacy Workflow details"
|
|
5871
6054
|
},
|
|
5872
6055
|
404: {
|
|
5873
|
-
description: "
|
|
6056
|
+
description: "Legacy Workflow not found"
|
|
5874
6057
|
}
|
|
5875
6058
|
}
|
|
5876
6059
|
}),
|
|
5877
|
-
|
|
6060
|
+
getLegacyWorkflowByIdHandler
|
|
5878
6061
|
);
|
|
5879
6062
|
app.get(
|
|
5880
|
-
"/api/workflows/
|
|
6063
|
+
"/api/workflows/legacy/:workflowId/runs",
|
|
5881
6064
|
h({
|
|
5882
|
-
description: "Get all runs for a
|
|
5883
|
-
tags: ["
|
|
6065
|
+
description: "Get all runs for a legacy workflow",
|
|
6066
|
+
tags: ["legacyWorkflows"],
|
|
5884
6067
|
parameters: [
|
|
5885
6068
|
{
|
|
5886
6069
|
name: "workflowId",
|
|
@@ -5896,17 +6079,17 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5896
6079
|
],
|
|
5897
6080
|
responses: {
|
|
5898
6081
|
200: {
|
|
5899
|
-
description: "List of
|
|
6082
|
+
description: "List of legacy workflow runs from storage"
|
|
5900
6083
|
}
|
|
5901
6084
|
}
|
|
5902
6085
|
}),
|
|
5903
|
-
|
|
6086
|
+
getLegacyWorkflowRunsHandler
|
|
5904
6087
|
);
|
|
5905
6088
|
app.post(
|
|
5906
|
-
"/api/workflows/
|
|
6089
|
+
"/api/workflows/legacy/:workflowId/resume",
|
|
5907
6090
|
h({
|
|
5908
|
-
description: "Resume a suspended
|
|
5909
|
-
tags: ["
|
|
6091
|
+
description: "Resume a suspended legacy workflow step",
|
|
6092
|
+
tags: ["legacyWorkflows"],
|
|
5910
6093
|
parameters: [
|
|
5911
6094
|
{
|
|
5912
6095
|
name: "workflowId",
|
|
@@ -5928,29 +6111,22 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5928
6111
|
schema: {
|
|
5929
6112
|
type: "object",
|
|
5930
6113
|
properties: {
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
resumeData: { type: "object" },
|
|
5935
|
-
runtimeContext: {
|
|
5936
|
-
type: "object",
|
|
5937
|
-
description: "Runtime context for the workflow execution"
|
|
5938
|
-
}
|
|
5939
|
-
},
|
|
5940
|
-
required: ["step"]
|
|
6114
|
+
stepId: { type: "string" },
|
|
6115
|
+
context: { type: "object" }
|
|
6116
|
+
}
|
|
5941
6117
|
}
|
|
5942
6118
|
}
|
|
5943
6119
|
}
|
|
5944
6120
|
}
|
|
5945
6121
|
}),
|
|
5946
|
-
|
|
6122
|
+
resumeLegacyWorkflowHandler
|
|
5947
6123
|
);
|
|
5948
6124
|
app.post(
|
|
5949
|
-
"/api/workflows/
|
|
6125
|
+
"/api/workflows/legacy/:workflowId/resume-async",
|
|
5950
6126
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5951
6127
|
h({
|
|
5952
|
-
description: "Resume a suspended
|
|
5953
|
-
tags: ["
|
|
6128
|
+
description: "Resume a suspended legacy workflow step",
|
|
6129
|
+
tags: ["legacyWorkflows"],
|
|
5954
6130
|
parameters: [
|
|
5955
6131
|
{
|
|
5956
6132
|
name: "workflowId",
|
|
@@ -5972,29 +6148,21 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5972
6148
|
schema: {
|
|
5973
6149
|
type: "object",
|
|
5974
6150
|
properties: {
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
resumeData: { type: "object" },
|
|
5979
|
-
runtimeContext: {
|
|
5980
|
-
type: "object",
|
|
5981
|
-
description: "Runtime context for the workflow execution"
|
|
5982
|
-
}
|
|
5983
|
-
},
|
|
5984
|
-
required: ["step"]
|
|
6151
|
+
stepId: { type: "string" },
|
|
6152
|
+
context: { type: "object" }
|
|
6153
|
+
}
|
|
5985
6154
|
}
|
|
5986
6155
|
}
|
|
5987
6156
|
}
|
|
5988
6157
|
}
|
|
5989
6158
|
}),
|
|
5990
|
-
|
|
6159
|
+
resumeAsyncLegacyWorkflowHandler
|
|
5991
6160
|
);
|
|
5992
6161
|
app.post(
|
|
5993
|
-
"/api/workflows/
|
|
5994
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6162
|
+
"/api/workflows/legacy/:workflowId/create-run",
|
|
5995
6163
|
h({
|
|
5996
|
-
description: "Create a new
|
|
5997
|
-
tags: ["
|
|
6164
|
+
description: "Create a new legacy workflow run",
|
|
6165
|
+
tags: ["legacyWorkflows"],
|
|
5998
6166
|
parameters: [
|
|
5999
6167
|
{
|
|
6000
6168
|
name: "workflowId",
|
|
@@ -6011,18 +6179,18 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6011
6179
|
],
|
|
6012
6180
|
responses: {
|
|
6013
6181
|
200: {
|
|
6014
|
-
description: "New
|
|
6182
|
+
description: "New legacy workflow run created"
|
|
6015
6183
|
}
|
|
6016
6184
|
}
|
|
6017
6185
|
}),
|
|
6018
|
-
|
|
6186
|
+
createLegacyWorkflowRunHandler
|
|
6019
6187
|
);
|
|
6020
6188
|
app.post(
|
|
6021
|
-
"/api/workflows/
|
|
6189
|
+
"/api/workflows/legacy/:workflowId/start-async",
|
|
6022
6190
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6023
6191
|
h({
|
|
6024
|
-
description: "Execute/Start a
|
|
6025
|
-
tags: ["
|
|
6192
|
+
description: "Execute/Start a legacy workflow",
|
|
6193
|
+
tags: ["legacyWorkflows"],
|
|
6026
6194
|
parameters: [
|
|
6027
6195
|
{
|
|
6028
6196
|
name: "workflowId",
|
|
@@ -6044,11 +6212,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6044
6212
|
schema: {
|
|
6045
6213
|
type: "object",
|
|
6046
6214
|
properties: {
|
|
6047
|
-
|
|
6048
|
-
runtimeContext: {
|
|
6049
|
-
type: "object",
|
|
6050
|
-
description: "Runtime context for the workflow execution"
|
|
6051
|
-
}
|
|
6215
|
+
input: { type: "object" }
|
|
6052
6216
|
}
|
|
6053
6217
|
}
|
|
6054
6218
|
}
|
|
@@ -6056,20 +6220,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6056
6220
|
},
|
|
6057
6221
|
responses: {
|
|
6058
6222
|
200: {
|
|
6059
|
-
description: "
|
|
6223
|
+
description: "Legacy Workflow execution result"
|
|
6060
6224
|
},
|
|
6061
6225
|
404: {
|
|
6062
|
-
description: "
|
|
6226
|
+
description: "Legacy Workflow not found"
|
|
6063
6227
|
}
|
|
6064
6228
|
}
|
|
6065
6229
|
}),
|
|
6066
|
-
|
|
6230
|
+
startAsyncLegacyWorkflowHandler
|
|
6067
6231
|
);
|
|
6068
6232
|
app.post(
|
|
6069
|
-
"/api/workflows/
|
|
6233
|
+
"/api/workflows/legacy/:workflowId/start",
|
|
6070
6234
|
h({
|
|
6071
|
-
description: "Create and start a new
|
|
6072
|
-
tags: ["
|
|
6235
|
+
description: "Create and start a new legacy workflow run",
|
|
6236
|
+
tags: ["legacyWorkflows"],
|
|
6073
6237
|
parameters: [
|
|
6074
6238
|
{
|
|
6075
6239
|
name: "workflowId",
|
|
@@ -6091,11 +6255,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6091
6255
|
schema: {
|
|
6092
6256
|
type: "object",
|
|
6093
6257
|
properties: {
|
|
6094
|
-
|
|
6095
|
-
runtimeContext: {
|
|
6096
|
-
type: "object",
|
|
6097
|
-
description: "Runtime context for the workflow execution"
|
|
6098
|
-
}
|
|
6258
|
+
input: { type: "object" }
|
|
6099
6259
|
}
|
|
6100
6260
|
}
|
|
6101
6261
|
}
|
|
@@ -6103,19 +6263,19 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6103
6263
|
},
|
|
6104
6264
|
responses: {
|
|
6105
6265
|
200: {
|
|
6106
|
-
description: "
|
|
6266
|
+
description: "Legacy Workflow run started"
|
|
6107
6267
|
},
|
|
6108
6268
|
404: {
|
|
6109
|
-
description: "
|
|
6269
|
+
description: "Legacy Workflow not found"
|
|
6110
6270
|
}
|
|
6111
6271
|
}
|
|
6112
6272
|
}),
|
|
6113
|
-
|
|
6273
|
+
startLegacyWorkflowRunHandler
|
|
6114
6274
|
);
|
|
6115
6275
|
app.get(
|
|
6116
|
-
"/api/workflows/
|
|
6276
|
+
"/api/workflows/legacy/:workflowId/watch",
|
|
6117
6277
|
h({
|
|
6118
|
-
description: "Watch
|
|
6278
|
+
description: "Watch legacy workflow transitions in real-time",
|
|
6119
6279
|
parameters: [
|
|
6120
6280
|
{
|
|
6121
6281
|
name: "workflowId",
|
|
@@ -6130,14 +6290,14 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6130
6290
|
schema: { type: "string" }
|
|
6131
6291
|
}
|
|
6132
6292
|
],
|
|
6133
|
-
tags: ["
|
|
6293
|
+
tags: ["legacyWorkflows"],
|
|
6134
6294
|
responses: {
|
|
6135
6295
|
200: {
|
|
6136
|
-
description: "
|
|
6296
|
+
description: "Legacy Workflow transitions in real-time"
|
|
6137
6297
|
}
|
|
6138
6298
|
}
|
|
6139
6299
|
}),
|
|
6140
|
-
|
|
6300
|
+
watchLegacyWorkflowHandler
|
|
6141
6301
|
);
|
|
6142
6302
|
app.get(
|
|
6143
6303
|
"/api/workflows",
|
|
@@ -6228,9 +6388,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6228
6388
|
schema: {
|
|
6229
6389
|
type: "object",
|
|
6230
6390
|
properties: {
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6391
|
+
step: {
|
|
6392
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
6393
|
+
},
|
|
6394
|
+
resumeData: { type: "object" },
|
|
6395
|
+
runtimeContext: {
|
|
6396
|
+
type: "object",
|
|
6397
|
+
description: "Runtime context for the workflow execution"
|
|
6398
|
+
}
|
|
6399
|
+
},
|
|
6400
|
+
required: ["step"]
|
|
6234
6401
|
}
|
|
6235
6402
|
}
|
|
6236
6403
|
}
|
|
@@ -6238,43 +6405,6 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6238
6405
|
}),
|
|
6239
6406
|
resumeWorkflowHandler
|
|
6240
6407
|
);
|
|
6241
|
-
app.post(
|
|
6242
|
-
"/api/workflows/:workflowId/resumeAsync",
|
|
6243
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6244
|
-
h({
|
|
6245
|
-
description: "@deprecated Use /api/workflows/:workflowId/resume-async instead",
|
|
6246
|
-
tags: ["workflows"],
|
|
6247
|
-
parameters: [
|
|
6248
|
-
{
|
|
6249
|
-
name: "workflowId",
|
|
6250
|
-
in: "path",
|
|
6251
|
-
required: true,
|
|
6252
|
-
schema: { type: "string" }
|
|
6253
|
-
},
|
|
6254
|
-
{
|
|
6255
|
-
name: "runId",
|
|
6256
|
-
in: "query",
|
|
6257
|
-
required: true,
|
|
6258
|
-
schema: { type: "string" }
|
|
6259
|
-
}
|
|
6260
|
-
],
|
|
6261
|
-
requestBody: {
|
|
6262
|
-
required: true,
|
|
6263
|
-
content: {
|
|
6264
|
-
"application/json": {
|
|
6265
|
-
schema: {
|
|
6266
|
-
type: "object",
|
|
6267
|
-
properties: {
|
|
6268
|
-
stepId: { type: "string" },
|
|
6269
|
-
context: { type: "object" }
|
|
6270
|
-
}
|
|
6271
|
-
}
|
|
6272
|
-
}
|
|
6273
|
-
}
|
|
6274
|
-
}
|
|
6275
|
-
}),
|
|
6276
|
-
resumeAsyncWorkflowHandler
|
|
6277
|
-
);
|
|
6278
6408
|
app.post(
|
|
6279
6409
|
"/api/workflows/:workflowId/resume-async",
|
|
6280
6410
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
@@ -6302,9 +6432,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6302
6432
|
schema: {
|
|
6303
6433
|
type: "object",
|
|
6304
6434
|
properties: {
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6435
|
+
step: {
|
|
6436
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
6437
|
+
},
|
|
6438
|
+
resumeData: { type: "object" },
|
|
6439
|
+
runtimeContext: {
|
|
6440
|
+
type: "object",
|
|
6441
|
+
description: "Runtime context for the workflow execution"
|
|
6442
|
+
}
|
|
6443
|
+
},
|
|
6444
|
+
required: ["step"]
|
|
6308
6445
|
}
|
|
6309
6446
|
}
|
|
6310
6447
|
}
|
|
@@ -6313,7 +6450,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6313
6450
|
resumeAsyncWorkflowHandler
|
|
6314
6451
|
);
|
|
6315
6452
|
app.post(
|
|
6316
|
-
"/api/workflows/:workflowId/
|
|
6453
|
+
"/api/workflows/:workflowId/create-run",
|
|
6454
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6317
6455
|
h({
|
|
6318
6456
|
description: "Create a new workflow run",
|
|
6319
6457
|
tags: ["workflows"],
|
|
@@ -6337,51 +6475,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6337
6475
|
}
|
|
6338
6476
|
}
|
|
6339
6477
|
}),
|
|
6340
|
-
|
|
6341
|
-
);
|
|
6342
|
-
app.post(
|
|
6343
|
-
"/api/workflows/:workflowId/startAsync",
|
|
6344
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6345
|
-
h({
|
|
6346
|
-
description: "@deprecated Use /api/workflows/:workflowId/start-async instead",
|
|
6347
|
-
tags: ["workflows"],
|
|
6348
|
-
parameters: [
|
|
6349
|
-
{
|
|
6350
|
-
name: "workflowId",
|
|
6351
|
-
in: "path",
|
|
6352
|
-
required: true,
|
|
6353
|
-
schema: { type: "string" }
|
|
6354
|
-
},
|
|
6355
|
-
{
|
|
6356
|
-
name: "runId",
|
|
6357
|
-
in: "query",
|
|
6358
|
-
required: false,
|
|
6359
|
-
schema: { type: "string" }
|
|
6360
|
-
}
|
|
6361
|
-
],
|
|
6362
|
-
requestBody: {
|
|
6363
|
-
required: true,
|
|
6364
|
-
content: {
|
|
6365
|
-
"application/json": {
|
|
6366
|
-
schema: {
|
|
6367
|
-
type: "object",
|
|
6368
|
-
properties: {
|
|
6369
|
-
input: { type: "object" }
|
|
6370
|
-
}
|
|
6371
|
-
}
|
|
6372
|
-
}
|
|
6373
|
-
}
|
|
6374
|
-
},
|
|
6375
|
-
responses: {
|
|
6376
|
-
200: {
|
|
6377
|
-
description: "Workflow execution result"
|
|
6378
|
-
},
|
|
6379
|
-
404: {
|
|
6380
|
-
description: "Workflow not found"
|
|
6381
|
-
}
|
|
6382
|
-
}
|
|
6383
|
-
}),
|
|
6384
|
-
startAsyncWorkflowHandler
|
|
6478
|
+
createWorkflowRunHandler
|
|
6385
6479
|
);
|
|
6386
6480
|
app.post(
|
|
6387
6481
|
"/api/workflows/:workflowId/start-async",
|
|
@@ -6410,7 +6504,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6410
6504
|
schema: {
|
|
6411
6505
|
type: "object",
|
|
6412
6506
|
properties: {
|
|
6413
|
-
|
|
6507
|
+
inputData: { type: "object" },
|
|
6508
|
+
runtimeContext: {
|
|
6509
|
+
type: "object",
|
|
6510
|
+
description: "Runtime context for the workflow execution"
|
|
6511
|
+
}
|
|
6414
6512
|
}
|
|
6415
6513
|
}
|
|
6416
6514
|
}
|
|
@@ -6418,10 +6516,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6418
6516
|
},
|
|
6419
6517
|
responses: {
|
|
6420
6518
|
200: {
|
|
6421
|
-
description: "
|
|
6519
|
+
description: "workflow execution result"
|
|
6422
6520
|
},
|
|
6423
6521
|
404: {
|
|
6424
|
-
description: "
|
|
6522
|
+
description: "workflow not found"
|
|
6425
6523
|
}
|
|
6426
6524
|
}
|
|
6427
6525
|
}),
|
|
@@ -6453,7 +6551,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6453
6551
|
schema: {
|
|
6454
6552
|
type: "object",
|
|
6455
6553
|
properties: {
|
|
6456
|
-
|
|
6554
|
+
inputData: { type: "object" },
|
|
6555
|
+
runtimeContext: {
|
|
6556
|
+
type: "object",
|
|
6557
|
+
description: "Runtime context for the workflow execution"
|
|
6558
|
+
}
|
|
6457
6559
|
}
|
|
6458
6560
|
}
|
|
6459
6561
|
}
|
|
@@ -6461,10 +6563,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6461
6563
|
},
|
|
6462
6564
|
responses: {
|
|
6463
6565
|
200: {
|
|
6464
|
-
description: "
|
|
6566
|
+
description: "workflow run started"
|
|
6465
6567
|
},
|
|
6466
6568
|
404: {
|
|
6467
|
-
description: "
|
|
6569
|
+
description: "workflow not found"
|
|
6468
6570
|
}
|
|
6469
6571
|
}
|
|
6470
6572
|
}),
|
|
@@ -6491,7 +6593,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6491
6593
|
tags: ["workflows"],
|
|
6492
6594
|
responses: {
|
|
6493
6595
|
200: {
|
|
6494
|
-
description: "
|
|
6596
|
+
description: "workflow transitions in real-time"
|
|
6495
6597
|
}
|
|
6496
6598
|
}
|
|
6497
6599
|
}),
|