@mastra/deployer 0.3.4 → 0.4.0-alpha.1
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 +179 -23
- package/dist/_tsup-dts-rollup.d.ts +179 -23
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/index.cjs +6 -6
- package/dist/build/index.js +2 -2
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-FA7LXQU6.cjs → chunk-BQAYAQTU.cjs} +4 -4
- package/dist/{chunk-QJQ2V3Z2.js → chunk-EHPJDSR3.js} +11 -1
- package/dist/{chunk-6J52IX4J.cjs → chunk-HHZDRBPV.cjs} +11 -1
- package/dist/{chunk-ABTWXYGO.js → chunk-U5VNUAES.js} +1 -1
- package/dist/{chunk-KCX3UGHY.cjs → chunk-WHD7NHLX.cjs} +2 -2
- package/dist/{chunk-37LFSIVL.js → chunk-YU2QBGOU.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/server/index.cjs +791 -395
- package/dist/server/index.js +792 -396
- 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");
|
|
@@ -2984,7 +3343,7 @@ var getMcpServerMessageHandler = async (c2) => {
|
|
|
2984
3343
|
try {
|
|
2985
3344
|
await server.startHTTP({
|
|
2986
3345
|
url: new URL(c2.req.url),
|
|
2987
|
-
httpPath: `/api/
|
|
3346
|
+
httpPath: `/api/mcp/${serverId}/mcp`,
|
|
2988
3347
|
req,
|
|
2989
3348
|
res,
|
|
2990
3349
|
options: {
|
|
@@ -3005,8 +3364,8 @@ var getMcpServerSseHandler = async (c2) => {
|
|
|
3005
3364
|
return c2.json({ error: `MCP server '${serverId}' not found` }, 404);
|
|
3006
3365
|
}
|
|
3007
3366
|
const requestUrl = new URL(c2.req.url);
|
|
3008
|
-
const sseConnectionPath = `/api/
|
|
3009
|
-
const sseMessagePath = `/api/
|
|
3367
|
+
const sseConnectionPath = `/api/mcp/${serverId}/sse`;
|
|
3368
|
+
const sseMessagePath = `/api/mcp/${serverId}/messages`;
|
|
3010
3369
|
try {
|
|
3011
3370
|
return await server.startHonoSSE({
|
|
3012
3371
|
url: requestUrl,
|
|
@@ -3019,17 +3378,159 @@ var getMcpServerSseHandler = async (c2) => {
|
|
|
3019
3378
|
return handleError(error, "Error handling MCP SSE request");
|
|
3020
3379
|
}
|
|
3021
3380
|
};
|
|
3022
|
-
async
|
|
3381
|
+
var listMcpRegistryServersHandler = async (c2) => {
|
|
3382
|
+
const mastra = getMastra(c2);
|
|
3383
|
+
if (!mastra || typeof mastra.getMCPServers !== "function") {
|
|
3384
|
+
c2.get("logger")?.error("Mastra instance or getMCPServers method not available in listMcpRegistryServersHandler");
|
|
3385
|
+
return c2.json({ error: "Mastra instance or getMCPServers method not available" }, 500);
|
|
3386
|
+
}
|
|
3387
|
+
const mcpServersMap = mastra.getMCPServers();
|
|
3388
|
+
if (!mcpServersMap) {
|
|
3389
|
+
c2.get("logger")?.warn("getMCPServers returned undefined or null in listMcpRegistryServersHandler");
|
|
3390
|
+
return c2.json({ servers: [], next: null, total_count: 0 });
|
|
3391
|
+
}
|
|
3392
|
+
const allServersArray = Array.from(
|
|
3393
|
+
mcpServersMap instanceof Map ? mcpServersMap.values() : Object.values(mcpServersMap)
|
|
3394
|
+
);
|
|
3395
|
+
const limit = parseInt(c2.req.query("limit") || "50", 10);
|
|
3396
|
+
const offset = parseInt(c2.req.query("offset") || "0", 10);
|
|
3397
|
+
const paginatedServers = allServersArray.slice(offset, offset + limit);
|
|
3398
|
+
const serverInfos = paginatedServers.map((server) => server.getServerInfo());
|
|
3399
|
+
const total_count = allServersArray.length;
|
|
3400
|
+
let next = null;
|
|
3401
|
+
if (offset + limit < total_count) {
|
|
3402
|
+
const nextOffset = offset + limit;
|
|
3403
|
+
const currentUrl = new URL(c2.req.url);
|
|
3404
|
+
currentUrl.searchParams.set("offset", nextOffset.toString());
|
|
3405
|
+
currentUrl.searchParams.set("limit", limit.toString());
|
|
3406
|
+
next = currentUrl.toString();
|
|
3407
|
+
}
|
|
3408
|
+
return c2.json({
|
|
3409
|
+
servers: serverInfos,
|
|
3410
|
+
next,
|
|
3411
|
+
total_count
|
|
3412
|
+
});
|
|
3413
|
+
};
|
|
3414
|
+
var getMcpRegistryServerDetailHandler = async (c2) => {
|
|
3415
|
+
const mastra = getMastra(c2);
|
|
3416
|
+
const serverId = c2.req.param("id");
|
|
3417
|
+
const requestedVersion = c2.req.query("version");
|
|
3418
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3419
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in getMcpRegistryServerDetailHandler");
|
|
3420
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3421
|
+
}
|
|
3422
|
+
const server = mastra.getMCPServer(serverId);
|
|
3423
|
+
if (!server) {
|
|
3424
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3425
|
+
}
|
|
3426
|
+
const serverDetailInfo = server.getServerDetail();
|
|
3427
|
+
if (requestedVersion && serverDetailInfo.version_detail.version !== requestedVersion) {
|
|
3428
|
+
c2.get("logger")?.info(
|
|
3429
|
+
`MCP server with ID '${serverId}' found, but version '${serverDetailInfo.version_detail.version}' does not match requested version '${requestedVersion}'.`
|
|
3430
|
+
);
|
|
3431
|
+
return c2.json(
|
|
3432
|
+
{
|
|
3433
|
+
error: `MCP server with ID '${serverId}' found, but not version '${requestedVersion}'. Available version is '${serverDetailInfo.version_detail.version}'.`
|
|
3434
|
+
},
|
|
3435
|
+
404
|
|
3436
|
+
// Return 404 as the specific version is not found
|
|
3437
|
+
);
|
|
3438
|
+
}
|
|
3439
|
+
return c2.json(serverDetailInfo);
|
|
3440
|
+
};
|
|
3441
|
+
var listMcpServerToolsHandler = async (c2) => {
|
|
3442
|
+
const mastra = getMastra(c2);
|
|
3443
|
+
const serverId = c2.req.param("serverId");
|
|
3444
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3445
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in listMcpServerToolsHandler");
|
|
3446
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3447
|
+
}
|
|
3448
|
+
const server = mastra.getMCPServer(serverId);
|
|
3449
|
+
if (!server) {
|
|
3450
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3451
|
+
}
|
|
3452
|
+
if (typeof server.getToolListInfo !== "function") {
|
|
3453
|
+
c2.get("logger")?.error(`MCPServer with ID '${serverId}' does not support getToolListInfo.`);
|
|
3454
|
+
return c2.json({ error: `Server '${serverId}' cannot list tools in this way.` }, 501);
|
|
3455
|
+
}
|
|
3023
3456
|
try {
|
|
3024
|
-
const
|
|
3025
|
-
|
|
3026
|
-
const result = await memory.getMemoryStatusHandler({
|
|
3027
|
-
mastra,
|
|
3028
|
-
agentId
|
|
3029
|
-
});
|
|
3030
|
-
return c2.json(result);
|
|
3457
|
+
const toolListInfo = server.getToolListInfo();
|
|
3458
|
+
return c2.json(toolListInfo);
|
|
3031
3459
|
} catch (error) {
|
|
3032
|
-
|
|
3460
|
+
c2.get("logger")?.error(`Error in listMcpServerToolsHandler for serverId '${serverId}':`, { error: error.message });
|
|
3461
|
+
return handleError(error, `Error listing tools for MCP server '${serverId}'`);
|
|
3462
|
+
}
|
|
3463
|
+
};
|
|
3464
|
+
var getMcpServerToolDetailHandler = async (c2) => {
|
|
3465
|
+
const mastra = getMastra(c2);
|
|
3466
|
+
const serverId = c2.req.param("serverId");
|
|
3467
|
+
const toolId = c2.req.param("toolId");
|
|
3468
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3469
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in getMcpServerToolDetailHandler");
|
|
3470
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3471
|
+
}
|
|
3472
|
+
const server = mastra.getMCPServer(serverId);
|
|
3473
|
+
if (!server) {
|
|
3474
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3475
|
+
}
|
|
3476
|
+
if (typeof server.getToolInfo !== "function") {
|
|
3477
|
+
c2.get("logger")?.error(`MCPServer with ID '${serverId}' does not support getToolInfo.`);
|
|
3478
|
+
return c2.json({ error: `Server '${serverId}' cannot provide tool details in this way.` }, 501);
|
|
3479
|
+
}
|
|
3480
|
+
try {
|
|
3481
|
+
const toolInfo = server.getToolInfo(toolId);
|
|
3482
|
+
if (!toolInfo) {
|
|
3483
|
+
return c2.json({ error: `Tool with ID '${toolId}' not found on MCP server '${serverId}'` }, 404);
|
|
3484
|
+
}
|
|
3485
|
+
return c2.json(toolInfo);
|
|
3486
|
+
} catch (error) {
|
|
3487
|
+
c2.get("logger")?.error(`Error in getMcpServerToolDetailHandler for serverId '${serverId}', toolId '${toolId}':`, {
|
|
3488
|
+
error: error.message
|
|
3489
|
+
});
|
|
3490
|
+
return handleError(error, `Error getting tool '${toolId}' details for MCP server '${serverId}'`);
|
|
3491
|
+
}
|
|
3492
|
+
};
|
|
3493
|
+
var executeMcpServerToolHandler = async (c2) => {
|
|
3494
|
+
const mastra = getMastra(c2);
|
|
3495
|
+
const serverId = c2.req.param("serverId");
|
|
3496
|
+
const toolId = c2.req.param("toolId");
|
|
3497
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3498
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in executeMcpServerToolHandler");
|
|
3499
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3500
|
+
}
|
|
3501
|
+
const server = mastra.getMCPServer(serverId);
|
|
3502
|
+
if (!server) {
|
|
3503
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3504
|
+
}
|
|
3505
|
+
if (typeof server.executeTool !== "function") {
|
|
3506
|
+
c2.get("logger")?.error(`MCPServer with ID '${serverId}' does not support executeTool.`);
|
|
3507
|
+
return c2.json({ error: `Server '${serverId}' cannot execute tools in this way.` }, 501);
|
|
3508
|
+
}
|
|
3509
|
+
try {
|
|
3510
|
+
const body = await c2.req.json();
|
|
3511
|
+
const args = body?.data;
|
|
3512
|
+
const runtimeContext = body?.runtimeContext;
|
|
3513
|
+
const result = await server.executeTool(toolId, args, runtimeContext);
|
|
3514
|
+
return c2.json({ result });
|
|
3515
|
+
} catch (error) {
|
|
3516
|
+
c2.get("logger")?.error(`Error executing tool '${toolId}' on server '${serverId}':`, { error: error.message });
|
|
3517
|
+
if (error.name === "ZodError") {
|
|
3518
|
+
return c2.json({ error: "Invalid tool arguments", details: error.errors }, 400);
|
|
3519
|
+
}
|
|
3520
|
+
return handleError(error, `Error executing tool '${toolId}' on MCP server '${serverId}'`);
|
|
3521
|
+
}
|
|
3522
|
+
};
|
|
3523
|
+
async function getMemoryStatusHandler(c2) {
|
|
3524
|
+
try {
|
|
3525
|
+
const mastra = c2.get("mastra");
|
|
3526
|
+
const agentId = c2.req.query("agentId");
|
|
3527
|
+
const result = await memory.getMemoryStatusHandler({
|
|
3528
|
+
mastra,
|
|
3529
|
+
agentId
|
|
3530
|
+
});
|
|
3531
|
+
return c2.json(result);
|
|
3532
|
+
} catch (error) {
|
|
3533
|
+
return handleError(error, "Error getting memory status");
|
|
3033
3534
|
}
|
|
3034
3535
|
}
|
|
3035
3536
|
async function getThreadsHandler(c2) {
|
|
@@ -3523,186 +4024,6 @@ async function deleteIndex(c2) {
|
|
|
3523
4024
|
return handleError(error, "Error deleting index");
|
|
3524
4025
|
}
|
|
3525
4026
|
}
|
|
3526
|
-
async function getVNextWorkflowsHandler(c2) {
|
|
3527
|
-
try {
|
|
3528
|
-
const mastra = c2.get("mastra");
|
|
3529
|
-
const workflows = await vNextWorkflows.getVNextWorkflowsHandler({
|
|
3530
|
-
mastra
|
|
3531
|
-
});
|
|
3532
|
-
return c2.json(workflows);
|
|
3533
|
-
} catch (error) {
|
|
3534
|
-
return handleError(error, "Error getting workflows");
|
|
3535
|
-
}
|
|
3536
|
-
}
|
|
3537
|
-
async function getVNextWorkflowByIdHandler(c2) {
|
|
3538
|
-
try {
|
|
3539
|
-
const mastra = c2.get("mastra");
|
|
3540
|
-
const workflowId = c2.req.param("workflowId");
|
|
3541
|
-
const workflow = await vNextWorkflows.getVNextWorkflowByIdHandler({
|
|
3542
|
-
mastra,
|
|
3543
|
-
workflowId
|
|
3544
|
-
});
|
|
3545
|
-
return c2.json(workflow);
|
|
3546
|
-
} catch (error) {
|
|
3547
|
-
return handleError(error, "Error getting workflow");
|
|
3548
|
-
}
|
|
3549
|
-
}
|
|
3550
|
-
async function createVNextWorkflowRunHandler(c2) {
|
|
3551
|
-
try {
|
|
3552
|
-
const mastra = c2.get("mastra");
|
|
3553
|
-
const workflowId = c2.req.param("workflowId");
|
|
3554
|
-
const prevRunId = c2.req.query("runId");
|
|
3555
|
-
const result = await vNextWorkflows.createVNextWorkflowRunHandler({
|
|
3556
|
-
mastra,
|
|
3557
|
-
workflowId,
|
|
3558
|
-
runId: prevRunId
|
|
3559
|
-
});
|
|
3560
|
-
return c2.json(result);
|
|
3561
|
-
} catch (e2) {
|
|
3562
|
-
return handleError(e2, "Error creating run");
|
|
3563
|
-
}
|
|
3564
|
-
}
|
|
3565
|
-
async function startAsyncVNextWorkflowHandler(c2) {
|
|
3566
|
-
try {
|
|
3567
|
-
const mastra = c2.get("mastra");
|
|
3568
|
-
const workflowId = c2.req.param("workflowId");
|
|
3569
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3570
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3571
|
-
const runId = c2.req.query("runId");
|
|
3572
|
-
const result = await vNextWorkflows.startAsyncVNextWorkflowHandler({
|
|
3573
|
-
mastra,
|
|
3574
|
-
runtimeContext,
|
|
3575
|
-
runtimeContextFromRequest,
|
|
3576
|
-
workflowId,
|
|
3577
|
-
runId,
|
|
3578
|
-
inputData
|
|
3579
|
-
});
|
|
3580
|
-
return c2.json(result);
|
|
3581
|
-
} catch (error) {
|
|
3582
|
-
return handleError(error, "Error executing workflow");
|
|
3583
|
-
}
|
|
3584
|
-
}
|
|
3585
|
-
async function startVNextWorkflowRunHandler(c2) {
|
|
3586
|
-
try {
|
|
3587
|
-
const mastra = c2.get("mastra");
|
|
3588
|
-
const workflowId = c2.req.param("workflowId");
|
|
3589
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3590
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3591
|
-
const runId = c2.req.query("runId");
|
|
3592
|
-
await vNextWorkflows.startVNextWorkflowRunHandler({
|
|
3593
|
-
mastra,
|
|
3594
|
-
runtimeContext,
|
|
3595
|
-
runtimeContextFromRequest,
|
|
3596
|
-
workflowId,
|
|
3597
|
-
runId,
|
|
3598
|
-
inputData
|
|
3599
|
-
});
|
|
3600
|
-
return c2.json({ message: "Workflow run started" });
|
|
3601
|
-
} catch (e2) {
|
|
3602
|
-
return handleError(e2, "Error starting workflow run");
|
|
3603
|
-
}
|
|
3604
|
-
}
|
|
3605
|
-
function watchVNextWorkflowHandler(c2) {
|
|
3606
|
-
try {
|
|
3607
|
-
const mastra = c2.get("mastra");
|
|
3608
|
-
const logger2 = mastra.getLogger();
|
|
3609
|
-
const workflowId = c2.req.param("workflowId");
|
|
3610
|
-
const runId = c2.req.query("runId");
|
|
3611
|
-
if (!runId) {
|
|
3612
|
-
throw new httpException.HTTPException(400, { message: "runId required to watch workflow" });
|
|
3613
|
-
}
|
|
3614
|
-
return streaming.stream(
|
|
3615
|
-
c2,
|
|
3616
|
-
async (stream4) => {
|
|
3617
|
-
try {
|
|
3618
|
-
const result = await vNextWorkflows.watchVNextWorkflowHandler({
|
|
3619
|
-
mastra,
|
|
3620
|
-
workflowId,
|
|
3621
|
-
runId
|
|
3622
|
-
});
|
|
3623
|
-
stream4.onAbort(() => {
|
|
3624
|
-
if (!result.locked) {
|
|
3625
|
-
return result.cancel();
|
|
3626
|
-
}
|
|
3627
|
-
});
|
|
3628
|
-
for await (const chunk of result) {
|
|
3629
|
-
await stream4.write(chunk.toString() + "");
|
|
3630
|
-
}
|
|
3631
|
-
} catch (err) {
|
|
3632
|
-
console.log(err);
|
|
3633
|
-
}
|
|
3634
|
-
},
|
|
3635
|
-
async (err) => {
|
|
3636
|
-
logger2.error("Error in watch stream: " + err?.message);
|
|
3637
|
-
}
|
|
3638
|
-
);
|
|
3639
|
-
} catch (error) {
|
|
3640
|
-
return handleError(error, "Error watching workflow");
|
|
3641
|
-
}
|
|
3642
|
-
}
|
|
3643
|
-
async function resumeAsyncVNextWorkflowHandler(c2) {
|
|
3644
|
-
try {
|
|
3645
|
-
const mastra = c2.get("mastra");
|
|
3646
|
-
const workflowId = c2.req.param("workflowId");
|
|
3647
|
-
const runId = c2.req.query("runId");
|
|
3648
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3649
|
-
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3650
|
-
if (!runId) {
|
|
3651
|
-
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
3652
|
-
}
|
|
3653
|
-
const result = await vNextWorkflows.resumeAsyncVNextWorkflowHandler({
|
|
3654
|
-
mastra,
|
|
3655
|
-
runtimeContext,
|
|
3656
|
-
runtimeContextFromRequest,
|
|
3657
|
-
workflowId,
|
|
3658
|
-
runId,
|
|
3659
|
-
body: { step, resumeData }
|
|
3660
|
-
});
|
|
3661
|
-
return c2.json(result);
|
|
3662
|
-
} catch (error) {
|
|
3663
|
-
return handleError(error, "Error resuming workflow step");
|
|
3664
|
-
}
|
|
3665
|
-
}
|
|
3666
|
-
async function resumeVNextWorkflowHandler(c2) {
|
|
3667
|
-
try {
|
|
3668
|
-
const mastra = c2.get("mastra");
|
|
3669
|
-
const workflowId = c2.req.param("workflowId");
|
|
3670
|
-
const runId = c2.req.query("runId");
|
|
3671
|
-
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
3672
|
-
if (!runId) {
|
|
3673
|
-
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
3674
|
-
}
|
|
3675
|
-
await vNextWorkflows.resumeVNextWorkflowHandler({
|
|
3676
|
-
mastra,
|
|
3677
|
-
runtimeContext,
|
|
3678
|
-
workflowId,
|
|
3679
|
-
runId,
|
|
3680
|
-
body: { step, resumeData }
|
|
3681
|
-
});
|
|
3682
|
-
return c2.json({ message: "Workflow run resumed" });
|
|
3683
|
-
} catch (error) {
|
|
3684
|
-
return handleError(error, "Error resuming workflow");
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
async function getVNextWorkflowRunsHandler(c2) {
|
|
3688
|
-
try {
|
|
3689
|
-
const mastra = c2.get("mastra");
|
|
3690
|
-
const workflowId = c2.req.param("workflowId");
|
|
3691
|
-
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
3692
|
-
const workflowRuns = await vNextWorkflows.getVNextWorkflowRunsHandler({
|
|
3693
|
-
mastra,
|
|
3694
|
-
workflowId,
|
|
3695
|
-
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
3696
|
-
toDate: toDate ? new Date(toDate) : void 0,
|
|
3697
|
-
limit: limit ? Number(limit) : void 0,
|
|
3698
|
-
offset: offset ? Number(offset) : void 0,
|
|
3699
|
-
resourceId
|
|
3700
|
-
});
|
|
3701
|
-
return c2.json(workflowRuns);
|
|
3702
|
-
} catch (error) {
|
|
3703
|
-
return handleError(error, "Error getting workflow runs");
|
|
3704
|
-
}
|
|
3705
|
-
}
|
|
3706
4027
|
async function getSpeakersHandler(c2) {
|
|
3707
4028
|
try {
|
|
3708
4029
|
const mastra = c2.get("mastra");
|
|
@@ -3786,53 +4107,55 @@ async function getWorkflowByIdHandler(c2) {
|
|
|
3786
4107
|
return handleError(error, "Error getting workflow");
|
|
3787
4108
|
}
|
|
3788
4109
|
}
|
|
3789
|
-
async function
|
|
4110
|
+
async function createWorkflowRunHandler(c2) {
|
|
3790
4111
|
try {
|
|
3791
4112
|
const mastra = c2.get("mastra");
|
|
3792
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3793
4113
|
const workflowId = c2.req.param("workflowId");
|
|
3794
|
-
const
|
|
3795
|
-
const
|
|
3796
|
-
const result = await workflows.startAsyncWorkflowHandler({
|
|
4114
|
+
const prevRunId = c2.req.query("runId");
|
|
4115
|
+
const result = await workflows.createWorkflowRunHandler({
|
|
3797
4116
|
mastra,
|
|
3798
|
-
runtimeContext,
|
|
3799
4117
|
workflowId,
|
|
3800
|
-
runId
|
|
3801
|
-
triggerData
|
|
4118
|
+
runId: prevRunId
|
|
3802
4119
|
});
|
|
3803
4120
|
return c2.json(result);
|
|
3804
|
-
} catch (
|
|
3805
|
-
return handleError(
|
|
4121
|
+
} catch (e2) {
|
|
4122
|
+
return handleError(e2, "Error creating run");
|
|
3806
4123
|
}
|
|
3807
4124
|
}
|
|
3808
|
-
async function
|
|
4125
|
+
async function startAsyncWorkflowHandler(c2) {
|
|
3809
4126
|
try {
|
|
3810
4127
|
const mastra = c2.get("mastra");
|
|
3811
4128
|
const workflowId = c2.req.param("workflowId");
|
|
3812
|
-
const
|
|
3813
|
-
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({
|
|
3814
4133
|
mastra,
|
|
4134
|
+
runtimeContext,
|
|
4135
|
+
runtimeContextFromRequest,
|
|
3815
4136
|
workflowId,
|
|
3816
|
-
runId
|
|
4137
|
+
runId,
|
|
4138
|
+
inputData
|
|
3817
4139
|
});
|
|
3818
4140
|
return c2.json(result);
|
|
3819
|
-
} catch (
|
|
3820
|
-
return handleError(
|
|
4141
|
+
} catch (error) {
|
|
4142
|
+
return handleError(error, "Error executing workflow");
|
|
3821
4143
|
}
|
|
3822
4144
|
}
|
|
3823
4145
|
async function startWorkflowRunHandler(c2) {
|
|
3824
4146
|
try {
|
|
3825
4147
|
const mastra = c2.get("mastra");
|
|
3826
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3827
4148
|
const workflowId = c2.req.param("workflowId");
|
|
3828
|
-
const
|
|
4149
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4150
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3829
4151
|
const runId = c2.req.query("runId");
|
|
3830
4152
|
await workflows.startWorkflowRunHandler({
|
|
3831
4153
|
mastra,
|
|
3832
4154
|
runtimeContext,
|
|
4155
|
+
runtimeContextFromRequest,
|
|
3833
4156
|
workflowId,
|
|
3834
4157
|
runId,
|
|
3835
|
-
|
|
4158
|
+
inputData
|
|
3836
4159
|
});
|
|
3837
4160
|
return c2.json({ message: "Workflow run started" });
|
|
3838
4161
|
} catch (e2) {
|
|
@@ -3880,19 +4203,20 @@ function watchWorkflowHandler(c2) {
|
|
|
3880
4203
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
3881
4204
|
try {
|
|
3882
4205
|
const mastra = c2.get("mastra");
|
|
3883
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3884
4206
|
const workflowId = c2.req.param("workflowId");
|
|
3885
4207
|
const runId = c2.req.query("runId");
|
|
3886
|
-
const
|
|
4208
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4209
|
+
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3887
4210
|
if (!runId) {
|
|
3888
4211
|
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
3889
4212
|
}
|
|
3890
4213
|
const result = await workflows.resumeAsyncWorkflowHandler({
|
|
3891
4214
|
mastra,
|
|
3892
4215
|
runtimeContext,
|
|
4216
|
+
runtimeContextFromRequest,
|
|
3893
4217
|
workflowId,
|
|
3894
4218
|
runId,
|
|
3895
|
-
body: {
|
|
4219
|
+
body: { step, resumeData }
|
|
3896
4220
|
});
|
|
3897
4221
|
return c2.json(result);
|
|
3898
4222
|
} catch (error) {
|
|
@@ -3902,10 +4226,9 @@ async function resumeAsyncWorkflowHandler(c2) {
|
|
|
3902
4226
|
async function resumeWorkflowHandler(c2) {
|
|
3903
4227
|
try {
|
|
3904
4228
|
const mastra = c2.get("mastra");
|
|
3905
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3906
4229
|
const workflowId = c2.req.param("workflowId");
|
|
3907
4230
|
const runId = c2.req.query("runId");
|
|
3908
|
-
const {
|
|
4231
|
+
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
3909
4232
|
if (!runId) {
|
|
3910
4233
|
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
3911
4234
|
}
|
|
@@ -3914,7 +4237,7 @@ async function resumeWorkflowHandler(c2) {
|
|
|
3914
4237
|
runtimeContext,
|
|
3915
4238
|
workflowId,
|
|
3916
4239
|
runId,
|
|
3917
|
-
body: {
|
|
4240
|
+
body: { step, resumeData }
|
|
3918
4241
|
});
|
|
3919
4242
|
return c2.json({ message: "Workflow run resumed" });
|
|
3920
4243
|
} catch (error) {
|
|
@@ -4131,6 +4454,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
4131
4454
|
};
|
|
4132
4455
|
app.use("*", timeout.timeout(server?.timeout ?? 3 * 60 * 1e3), cors.cors(corsConfig));
|
|
4133
4456
|
}
|
|
4457
|
+
app.use("*", authenticationMiddleware);
|
|
4458
|
+
app.use("*", authorizationMiddleware);
|
|
4134
4459
|
const bodyLimitOptions = {
|
|
4135
4460
|
maxSize: server?.bodySizeLimit ?? 4.5 * 1024 * 1024,
|
|
4136
4461
|
// 4.5 MB,
|
|
@@ -5176,7 +5501,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5176
5501
|
executeAgentToolHandler
|
|
5177
5502
|
);
|
|
5178
5503
|
app.post(
|
|
5179
|
-
"/api/
|
|
5504
|
+
"/api/mcp/:serverId/mcp",
|
|
5180
5505
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5181
5506
|
h({
|
|
5182
5507
|
description: "Send a message to an MCP server using Streamable HTTP",
|
|
@@ -5203,8 +5528,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5203
5528
|
}),
|
|
5204
5529
|
getMcpServerMessageHandler
|
|
5205
5530
|
);
|
|
5206
|
-
const mcpSseBasePath = "/api/
|
|
5207
|
-
const mcpSseMessagePath = "/api/
|
|
5531
|
+
const mcpSseBasePath = "/api/mcp/:serverId/sse";
|
|
5532
|
+
const mcpSseMessagePath = "/api/mcp/:serverId/messages";
|
|
5208
5533
|
app.get(
|
|
5209
5534
|
mcpSseBasePath,
|
|
5210
5535
|
h({
|
|
@@ -5262,6 +5587,158 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5262
5587
|
}),
|
|
5263
5588
|
getMcpServerSseHandler
|
|
5264
5589
|
);
|
|
5590
|
+
app.get(
|
|
5591
|
+
"/api/mcp/v0/servers",
|
|
5592
|
+
h({
|
|
5593
|
+
description: "List all available MCP server instances with basic information.",
|
|
5594
|
+
tags: ["mcp"],
|
|
5595
|
+
parameters: [
|
|
5596
|
+
{
|
|
5597
|
+
name: "limit",
|
|
5598
|
+
in: "query",
|
|
5599
|
+
description: "Number of results per page.",
|
|
5600
|
+
required: false,
|
|
5601
|
+
schema: { type: "integer", default: 50, minimum: 1, maximum: 5e3 }
|
|
5602
|
+
},
|
|
5603
|
+
{
|
|
5604
|
+
name: "offset",
|
|
5605
|
+
in: "query",
|
|
5606
|
+
description: "Number of results to skip for pagination.",
|
|
5607
|
+
required: false,
|
|
5608
|
+
schema: { type: "integer", default: 0, minimum: 0 }
|
|
5609
|
+
}
|
|
5610
|
+
],
|
|
5611
|
+
responses: {
|
|
5612
|
+
200: {
|
|
5613
|
+
description: "A list of MCP server instances.",
|
|
5614
|
+
content: {
|
|
5615
|
+
"application/json": {
|
|
5616
|
+
schema: {
|
|
5617
|
+
type: "object",
|
|
5618
|
+
properties: {
|
|
5619
|
+
servers: { type: "array", items: { $ref: "#/components/schemas/ServerInfo" } },
|
|
5620
|
+
next: { type: "string", format: "uri", nullable: true },
|
|
5621
|
+
total_count: { type: "integer" }
|
|
5622
|
+
}
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
}
|
|
5628
|
+
}),
|
|
5629
|
+
listMcpRegistryServersHandler
|
|
5630
|
+
);
|
|
5631
|
+
app.get(
|
|
5632
|
+
"/api/mcp/v0/servers/:id",
|
|
5633
|
+
h({
|
|
5634
|
+
description: "Get detailed information about a specific MCP server instance.",
|
|
5635
|
+
tags: ["mcp"],
|
|
5636
|
+
parameters: [
|
|
5637
|
+
{
|
|
5638
|
+
name: "id",
|
|
5639
|
+
in: "path",
|
|
5640
|
+
required: true,
|
|
5641
|
+
description: "Unique ID of the MCP server instance.",
|
|
5642
|
+
schema: { type: "string" }
|
|
5643
|
+
},
|
|
5644
|
+
{
|
|
5645
|
+
name: "version",
|
|
5646
|
+
in: "query",
|
|
5647
|
+
required: false,
|
|
5648
|
+
description: "Desired MCP server version (currently informational, server returns its actual version).",
|
|
5649
|
+
schema: { type: "string" }
|
|
5650
|
+
}
|
|
5651
|
+
],
|
|
5652
|
+
responses: {
|
|
5653
|
+
200: {
|
|
5654
|
+
description: "Detailed information about the MCP server instance.",
|
|
5655
|
+
content: {
|
|
5656
|
+
"application/json": { schema: { $ref: "#/components/schemas/ServerDetailInfo" } }
|
|
5657
|
+
}
|
|
5658
|
+
},
|
|
5659
|
+
404: {
|
|
5660
|
+
description: "MCP server instance not found.",
|
|
5661
|
+
content: { "application/json": { schema: { type: "object", properties: { error: { type: "string" } } } } }
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
}),
|
|
5665
|
+
getMcpRegistryServerDetailHandler
|
|
5666
|
+
);
|
|
5667
|
+
app.get(
|
|
5668
|
+
"/api/mcp/:serverId/tools",
|
|
5669
|
+
h({
|
|
5670
|
+
description: "List all tools available on a specific MCP server instance.",
|
|
5671
|
+
tags: ["mcp"],
|
|
5672
|
+
parameters: [
|
|
5673
|
+
{
|
|
5674
|
+
name: "serverId",
|
|
5675
|
+
in: "path",
|
|
5676
|
+
required: true,
|
|
5677
|
+
description: "Unique ID of the MCP server instance.",
|
|
5678
|
+
schema: { type: "string" }
|
|
5679
|
+
}
|
|
5680
|
+
],
|
|
5681
|
+
responses: {
|
|
5682
|
+
200: { description: "A list of tools for the MCP server." },
|
|
5683
|
+
// Define schema if you have one for McpServerToolListResponse
|
|
5684
|
+
404: { description: "MCP server instance not found." },
|
|
5685
|
+
501: { description: "Server does not support listing tools." }
|
|
5686
|
+
}
|
|
5687
|
+
}),
|
|
5688
|
+
listMcpServerToolsHandler
|
|
5689
|
+
);
|
|
5690
|
+
app.get(
|
|
5691
|
+
"/api/mcp/:serverId/tools/:toolId",
|
|
5692
|
+
h({
|
|
5693
|
+
description: "Get details for a specific tool on an MCP server.",
|
|
5694
|
+
tags: ["mcp"],
|
|
5695
|
+
parameters: [
|
|
5696
|
+
{ name: "serverId", in: "path", required: true, schema: { type: "string" } },
|
|
5697
|
+
{ name: "toolId", in: "path", required: true, schema: { type: "string" } }
|
|
5698
|
+
],
|
|
5699
|
+
responses: {
|
|
5700
|
+
200: { description: "Details of the specified tool." },
|
|
5701
|
+
// Define schema for McpToolInfo
|
|
5702
|
+
404: { description: "MCP server or tool not found." },
|
|
5703
|
+
501: { description: "Server does not support getting tool details." }
|
|
5704
|
+
}
|
|
5705
|
+
}),
|
|
5706
|
+
getMcpServerToolDetailHandler
|
|
5707
|
+
);
|
|
5708
|
+
app.post(
|
|
5709
|
+
"/api/mcp/:serverId/tools/:toolId/execute",
|
|
5710
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5711
|
+
h({
|
|
5712
|
+
description: "Execute a specific tool on an MCP server.",
|
|
5713
|
+
tags: ["mcp"],
|
|
5714
|
+
parameters: [
|
|
5715
|
+
{ name: "serverId", in: "path", required: true, schema: { type: "string" } },
|
|
5716
|
+
{ name: "toolId", in: "path", required: true, schema: { type: "string" } }
|
|
5717
|
+
],
|
|
5718
|
+
requestBody: {
|
|
5719
|
+
required: true,
|
|
5720
|
+
content: {
|
|
5721
|
+
"application/json": {
|
|
5722
|
+
schema: {
|
|
5723
|
+
type: "object",
|
|
5724
|
+
properties: {
|
|
5725
|
+
data: { type: "object" },
|
|
5726
|
+
runtimeContext: { type: "object" }
|
|
5727
|
+
}
|
|
5728
|
+
}
|
|
5729
|
+
}
|
|
5730
|
+
}
|
|
5731
|
+
// Simplified schema
|
|
5732
|
+
},
|
|
5733
|
+
responses: {
|
|
5734
|
+
200: { description: "Result of the tool execution." },
|
|
5735
|
+
400: { description: "Invalid tool arguments." },
|
|
5736
|
+
404: { description: "MCP server or tool not found." },
|
|
5737
|
+
501: { description: "Server does not support tool execution." }
|
|
5738
|
+
}
|
|
5739
|
+
}),
|
|
5740
|
+
executeMcpServerToolHandler
|
|
5741
|
+
);
|
|
5265
5742
|
app.get(
|
|
5266
5743
|
"/api/memory/status",
|
|
5267
5744
|
h({
|
|
@@ -5546,23 +6023,23 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5546
6023
|
storeTelemetryHandler
|
|
5547
6024
|
);
|
|
5548
6025
|
app.get(
|
|
5549
|
-
"/api/workflows/
|
|
6026
|
+
"/api/workflows/legacy",
|
|
5550
6027
|
h({
|
|
5551
|
-
description: "Get all
|
|
5552
|
-
tags: ["
|
|
6028
|
+
description: "Get all legacy workflows",
|
|
6029
|
+
tags: ["legacyWorkflows"],
|
|
5553
6030
|
responses: {
|
|
5554
6031
|
200: {
|
|
5555
|
-
description: "List of all
|
|
6032
|
+
description: "List of all legacy workflows"
|
|
5556
6033
|
}
|
|
5557
6034
|
}
|
|
5558
6035
|
}),
|
|
5559
|
-
|
|
6036
|
+
getLegacyWorkflowsHandler
|
|
5560
6037
|
);
|
|
5561
6038
|
app.get(
|
|
5562
|
-
"/api/workflows/
|
|
6039
|
+
"/api/workflows/legacy/:workflowId",
|
|
5563
6040
|
h({
|
|
5564
|
-
description: "Get
|
|
5565
|
-
tags: ["
|
|
6041
|
+
description: "Get legacy workflow by ID",
|
|
6042
|
+
tags: ["legacyWorkflows"],
|
|
5566
6043
|
parameters: [
|
|
5567
6044
|
{
|
|
5568
6045
|
name: "workflowId",
|
|
@@ -5573,20 +6050,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5573
6050
|
],
|
|
5574
6051
|
responses: {
|
|
5575
6052
|
200: {
|
|
5576
|
-
description: "
|
|
6053
|
+
description: "Legacy Workflow details"
|
|
5577
6054
|
},
|
|
5578
6055
|
404: {
|
|
5579
|
-
description: "
|
|
6056
|
+
description: "Legacy Workflow not found"
|
|
5580
6057
|
}
|
|
5581
6058
|
}
|
|
5582
6059
|
}),
|
|
5583
|
-
|
|
6060
|
+
getLegacyWorkflowByIdHandler
|
|
5584
6061
|
);
|
|
5585
6062
|
app.get(
|
|
5586
|
-
"/api/workflows/
|
|
6063
|
+
"/api/workflows/legacy/:workflowId/runs",
|
|
5587
6064
|
h({
|
|
5588
|
-
description: "Get all runs for a
|
|
5589
|
-
tags: ["
|
|
6065
|
+
description: "Get all runs for a legacy workflow",
|
|
6066
|
+
tags: ["legacyWorkflows"],
|
|
5590
6067
|
parameters: [
|
|
5591
6068
|
{
|
|
5592
6069
|
name: "workflowId",
|
|
@@ -5602,17 +6079,17 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5602
6079
|
],
|
|
5603
6080
|
responses: {
|
|
5604
6081
|
200: {
|
|
5605
|
-
description: "List of
|
|
6082
|
+
description: "List of legacy workflow runs from storage"
|
|
5606
6083
|
}
|
|
5607
6084
|
}
|
|
5608
6085
|
}),
|
|
5609
|
-
|
|
6086
|
+
getLegacyWorkflowRunsHandler
|
|
5610
6087
|
);
|
|
5611
6088
|
app.post(
|
|
5612
|
-
"/api/workflows/
|
|
6089
|
+
"/api/workflows/legacy/:workflowId/resume",
|
|
5613
6090
|
h({
|
|
5614
|
-
description: "Resume a suspended
|
|
5615
|
-
tags: ["
|
|
6091
|
+
description: "Resume a suspended legacy workflow step",
|
|
6092
|
+
tags: ["legacyWorkflows"],
|
|
5616
6093
|
parameters: [
|
|
5617
6094
|
{
|
|
5618
6095
|
name: "workflowId",
|
|
@@ -5634,29 +6111,22 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5634
6111
|
schema: {
|
|
5635
6112
|
type: "object",
|
|
5636
6113
|
properties: {
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
resumeData: { type: "object" },
|
|
5641
|
-
runtimeContext: {
|
|
5642
|
-
type: "object",
|
|
5643
|
-
description: "Runtime context for the workflow execution"
|
|
5644
|
-
}
|
|
5645
|
-
},
|
|
5646
|
-
required: ["step"]
|
|
6114
|
+
stepId: { type: "string" },
|
|
6115
|
+
context: { type: "object" }
|
|
6116
|
+
}
|
|
5647
6117
|
}
|
|
5648
6118
|
}
|
|
5649
6119
|
}
|
|
5650
6120
|
}
|
|
5651
6121
|
}),
|
|
5652
|
-
|
|
6122
|
+
resumeLegacyWorkflowHandler
|
|
5653
6123
|
);
|
|
5654
6124
|
app.post(
|
|
5655
|
-
"/api/workflows/
|
|
6125
|
+
"/api/workflows/legacy/:workflowId/resume-async",
|
|
5656
6126
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5657
6127
|
h({
|
|
5658
|
-
description: "Resume a suspended
|
|
5659
|
-
tags: ["
|
|
6128
|
+
description: "Resume a suspended legacy workflow step",
|
|
6129
|
+
tags: ["legacyWorkflows"],
|
|
5660
6130
|
parameters: [
|
|
5661
6131
|
{
|
|
5662
6132
|
name: "workflowId",
|
|
@@ -5678,29 +6148,21 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5678
6148
|
schema: {
|
|
5679
6149
|
type: "object",
|
|
5680
6150
|
properties: {
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
resumeData: { type: "object" },
|
|
5685
|
-
runtimeContext: {
|
|
5686
|
-
type: "object",
|
|
5687
|
-
description: "Runtime context for the workflow execution"
|
|
5688
|
-
}
|
|
5689
|
-
},
|
|
5690
|
-
required: ["step"]
|
|
6151
|
+
stepId: { type: "string" },
|
|
6152
|
+
context: { type: "object" }
|
|
6153
|
+
}
|
|
5691
6154
|
}
|
|
5692
6155
|
}
|
|
5693
6156
|
}
|
|
5694
6157
|
}
|
|
5695
6158
|
}),
|
|
5696
|
-
|
|
6159
|
+
resumeAsyncLegacyWorkflowHandler
|
|
5697
6160
|
);
|
|
5698
6161
|
app.post(
|
|
5699
|
-
"/api/workflows/
|
|
5700
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6162
|
+
"/api/workflows/legacy/:workflowId/create-run",
|
|
5701
6163
|
h({
|
|
5702
|
-
description: "Create a new
|
|
5703
|
-
tags: ["
|
|
6164
|
+
description: "Create a new legacy workflow run",
|
|
6165
|
+
tags: ["legacyWorkflows"],
|
|
5704
6166
|
parameters: [
|
|
5705
6167
|
{
|
|
5706
6168
|
name: "workflowId",
|
|
@@ -5717,18 +6179,18 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5717
6179
|
],
|
|
5718
6180
|
responses: {
|
|
5719
6181
|
200: {
|
|
5720
|
-
description: "New
|
|
6182
|
+
description: "New legacy workflow run created"
|
|
5721
6183
|
}
|
|
5722
6184
|
}
|
|
5723
6185
|
}),
|
|
5724
|
-
|
|
6186
|
+
createLegacyWorkflowRunHandler
|
|
5725
6187
|
);
|
|
5726
6188
|
app.post(
|
|
5727
|
-
"/api/workflows/
|
|
6189
|
+
"/api/workflows/legacy/:workflowId/start-async",
|
|
5728
6190
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5729
6191
|
h({
|
|
5730
|
-
description: "Execute/Start a
|
|
5731
|
-
tags: ["
|
|
6192
|
+
description: "Execute/Start a legacy workflow",
|
|
6193
|
+
tags: ["legacyWorkflows"],
|
|
5732
6194
|
parameters: [
|
|
5733
6195
|
{
|
|
5734
6196
|
name: "workflowId",
|
|
@@ -5750,11 +6212,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5750
6212
|
schema: {
|
|
5751
6213
|
type: "object",
|
|
5752
6214
|
properties: {
|
|
5753
|
-
|
|
5754
|
-
runtimeContext: {
|
|
5755
|
-
type: "object",
|
|
5756
|
-
description: "Runtime context for the workflow execution"
|
|
5757
|
-
}
|
|
6215
|
+
input: { type: "object" }
|
|
5758
6216
|
}
|
|
5759
6217
|
}
|
|
5760
6218
|
}
|
|
@@ -5762,20 +6220,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5762
6220
|
},
|
|
5763
6221
|
responses: {
|
|
5764
6222
|
200: {
|
|
5765
|
-
description: "
|
|
6223
|
+
description: "Legacy Workflow execution result"
|
|
5766
6224
|
},
|
|
5767
6225
|
404: {
|
|
5768
|
-
description: "
|
|
6226
|
+
description: "Legacy Workflow not found"
|
|
5769
6227
|
}
|
|
5770
6228
|
}
|
|
5771
6229
|
}),
|
|
5772
|
-
|
|
6230
|
+
startAsyncLegacyWorkflowHandler
|
|
5773
6231
|
);
|
|
5774
6232
|
app.post(
|
|
5775
|
-
"/api/workflows/
|
|
6233
|
+
"/api/workflows/legacy/:workflowId/start",
|
|
5776
6234
|
h({
|
|
5777
|
-
description: "Create and start a new
|
|
5778
|
-
tags: ["
|
|
6235
|
+
description: "Create and start a new legacy workflow run",
|
|
6236
|
+
tags: ["legacyWorkflows"],
|
|
5779
6237
|
parameters: [
|
|
5780
6238
|
{
|
|
5781
6239
|
name: "workflowId",
|
|
@@ -5797,11 +6255,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5797
6255
|
schema: {
|
|
5798
6256
|
type: "object",
|
|
5799
6257
|
properties: {
|
|
5800
|
-
|
|
5801
|
-
runtimeContext: {
|
|
5802
|
-
type: "object",
|
|
5803
|
-
description: "Runtime context for the workflow execution"
|
|
5804
|
-
}
|
|
6258
|
+
input: { type: "object" }
|
|
5805
6259
|
}
|
|
5806
6260
|
}
|
|
5807
6261
|
}
|
|
@@ -5809,19 +6263,19 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5809
6263
|
},
|
|
5810
6264
|
responses: {
|
|
5811
6265
|
200: {
|
|
5812
|
-
description: "
|
|
6266
|
+
description: "Legacy Workflow run started"
|
|
5813
6267
|
},
|
|
5814
6268
|
404: {
|
|
5815
|
-
description: "
|
|
6269
|
+
description: "Legacy Workflow not found"
|
|
5816
6270
|
}
|
|
5817
6271
|
}
|
|
5818
6272
|
}),
|
|
5819
|
-
|
|
6273
|
+
startLegacyWorkflowRunHandler
|
|
5820
6274
|
);
|
|
5821
6275
|
app.get(
|
|
5822
|
-
"/api/workflows/
|
|
6276
|
+
"/api/workflows/legacy/:workflowId/watch",
|
|
5823
6277
|
h({
|
|
5824
|
-
description: "Watch
|
|
6278
|
+
description: "Watch legacy workflow transitions in real-time",
|
|
5825
6279
|
parameters: [
|
|
5826
6280
|
{
|
|
5827
6281
|
name: "workflowId",
|
|
@@ -5836,14 +6290,14 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5836
6290
|
schema: { type: "string" }
|
|
5837
6291
|
}
|
|
5838
6292
|
],
|
|
5839
|
-
tags: ["
|
|
6293
|
+
tags: ["legacyWorkflows"],
|
|
5840
6294
|
responses: {
|
|
5841
6295
|
200: {
|
|
5842
|
-
description: "
|
|
6296
|
+
description: "Legacy Workflow transitions in real-time"
|
|
5843
6297
|
}
|
|
5844
6298
|
}
|
|
5845
6299
|
}),
|
|
5846
|
-
|
|
6300
|
+
watchLegacyWorkflowHandler
|
|
5847
6301
|
);
|
|
5848
6302
|
app.get(
|
|
5849
6303
|
"/api/workflows",
|
|
@@ -5934,9 +6388,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5934
6388
|
schema: {
|
|
5935
6389
|
type: "object",
|
|
5936
6390
|
properties: {
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
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"]
|
|
5940
6401
|
}
|
|
5941
6402
|
}
|
|
5942
6403
|
}
|
|
@@ -5944,43 +6405,6 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5944
6405
|
}),
|
|
5945
6406
|
resumeWorkflowHandler
|
|
5946
6407
|
);
|
|
5947
|
-
app.post(
|
|
5948
|
-
"/api/workflows/:workflowId/resumeAsync",
|
|
5949
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5950
|
-
h({
|
|
5951
|
-
description: "@deprecated Use /api/workflows/:workflowId/resume-async instead",
|
|
5952
|
-
tags: ["workflows"],
|
|
5953
|
-
parameters: [
|
|
5954
|
-
{
|
|
5955
|
-
name: "workflowId",
|
|
5956
|
-
in: "path",
|
|
5957
|
-
required: true,
|
|
5958
|
-
schema: { type: "string" }
|
|
5959
|
-
},
|
|
5960
|
-
{
|
|
5961
|
-
name: "runId",
|
|
5962
|
-
in: "query",
|
|
5963
|
-
required: true,
|
|
5964
|
-
schema: { type: "string" }
|
|
5965
|
-
}
|
|
5966
|
-
],
|
|
5967
|
-
requestBody: {
|
|
5968
|
-
required: true,
|
|
5969
|
-
content: {
|
|
5970
|
-
"application/json": {
|
|
5971
|
-
schema: {
|
|
5972
|
-
type: "object",
|
|
5973
|
-
properties: {
|
|
5974
|
-
stepId: { type: "string" },
|
|
5975
|
-
context: { type: "object" }
|
|
5976
|
-
}
|
|
5977
|
-
}
|
|
5978
|
-
}
|
|
5979
|
-
}
|
|
5980
|
-
}
|
|
5981
|
-
}),
|
|
5982
|
-
resumeAsyncWorkflowHandler
|
|
5983
|
-
);
|
|
5984
6408
|
app.post(
|
|
5985
6409
|
"/api/workflows/:workflowId/resume-async",
|
|
5986
6410
|
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
@@ -6008,9 +6432,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6008
6432
|
schema: {
|
|
6009
6433
|
type: "object",
|
|
6010
6434
|
properties: {
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
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"]
|
|
6014
6445
|
}
|
|
6015
6446
|
}
|
|
6016
6447
|
}
|
|
@@ -6019,7 +6450,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6019
6450
|
resumeAsyncWorkflowHandler
|
|
6020
6451
|
);
|
|
6021
6452
|
app.post(
|
|
6022
|
-
"/api/workflows/:workflowId/
|
|
6453
|
+
"/api/workflows/:workflowId/create-run",
|
|
6454
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6023
6455
|
h({
|
|
6024
6456
|
description: "Create a new workflow run",
|
|
6025
6457
|
tags: ["workflows"],
|
|
@@ -6043,51 +6475,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6043
6475
|
}
|
|
6044
6476
|
}
|
|
6045
6477
|
}),
|
|
6046
|
-
|
|
6047
|
-
);
|
|
6048
|
-
app.post(
|
|
6049
|
-
"/api/workflows/:workflowId/startAsync",
|
|
6050
|
-
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6051
|
-
h({
|
|
6052
|
-
description: "@deprecated Use /api/workflows/:workflowId/start-async instead",
|
|
6053
|
-
tags: ["workflows"],
|
|
6054
|
-
parameters: [
|
|
6055
|
-
{
|
|
6056
|
-
name: "workflowId",
|
|
6057
|
-
in: "path",
|
|
6058
|
-
required: true,
|
|
6059
|
-
schema: { type: "string" }
|
|
6060
|
-
},
|
|
6061
|
-
{
|
|
6062
|
-
name: "runId",
|
|
6063
|
-
in: "query",
|
|
6064
|
-
required: false,
|
|
6065
|
-
schema: { type: "string" }
|
|
6066
|
-
}
|
|
6067
|
-
],
|
|
6068
|
-
requestBody: {
|
|
6069
|
-
required: true,
|
|
6070
|
-
content: {
|
|
6071
|
-
"application/json": {
|
|
6072
|
-
schema: {
|
|
6073
|
-
type: "object",
|
|
6074
|
-
properties: {
|
|
6075
|
-
input: { type: "object" }
|
|
6076
|
-
}
|
|
6077
|
-
}
|
|
6078
|
-
}
|
|
6079
|
-
}
|
|
6080
|
-
},
|
|
6081
|
-
responses: {
|
|
6082
|
-
200: {
|
|
6083
|
-
description: "Workflow execution result"
|
|
6084
|
-
},
|
|
6085
|
-
404: {
|
|
6086
|
-
description: "Workflow not found"
|
|
6087
|
-
}
|
|
6088
|
-
}
|
|
6089
|
-
}),
|
|
6090
|
-
startAsyncWorkflowHandler
|
|
6478
|
+
createWorkflowRunHandler
|
|
6091
6479
|
);
|
|
6092
6480
|
app.post(
|
|
6093
6481
|
"/api/workflows/:workflowId/start-async",
|
|
@@ -6116,7 +6504,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6116
6504
|
schema: {
|
|
6117
6505
|
type: "object",
|
|
6118
6506
|
properties: {
|
|
6119
|
-
|
|
6507
|
+
inputData: { type: "object" },
|
|
6508
|
+
runtimeContext: {
|
|
6509
|
+
type: "object",
|
|
6510
|
+
description: "Runtime context for the workflow execution"
|
|
6511
|
+
}
|
|
6120
6512
|
}
|
|
6121
6513
|
}
|
|
6122
6514
|
}
|
|
@@ -6124,10 +6516,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6124
6516
|
},
|
|
6125
6517
|
responses: {
|
|
6126
6518
|
200: {
|
|
6127
|
-
description: "
|
|
6519
|
+
description: "workflow execution result"
|
|
6128
6520
|
},
|
|
6129
6521
|
404: {
|
|
6130
|
-
description: "
|
|
6522
|
+
description: "workflow not found"
|
|
6131
6523
|
}
|
|
6132
6524
|
}
|
|
6133
6525
|
}),
|
|
@@ -6159,7 +6551,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6159
6551
|
schema: {
|
|
6160
6552
|
type: "object",
|
|
6161
6553
|
properties: {
|
|
6162
|
-
|
|
6554
|
+
inputData: { type: "object" },
|
|
6555
|
+
runtimeContext: {
|
|
6556
|
+
type: "object",
|
|
6557
|
+
description: "Runtime context for the workflow execution"
|
|
6558
|
+
}
|
|
6163
6559
|
}
|
|
6164
6560
|
}
|
|
6165
6561
|
}
|
|
@@ -6167,10 +6563,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6167
6563
|
},
|
|
6168
6564
|
responses: {
|
|
6169
6565
|
200: {
|
|
6170
|
-
description: "
|
|
6566
|
+
description: "workflow run started"
|
|
6171
6567
|
},
|
|
6172
6568
|
404: {
|
|
6173
|
-
description: "
|
|
6569
|
+
description: "workflow not found"
|
|
6174
6570
|
}
|
|
6175
6571
|
}
|
|
6176
6572
|
}),
|
|
@@ -6197,7 +6593,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6197
6593
|
tags: ["workflows"],
|
|
6198
6594
|
responses: {
|
|
6199
6595
|
200: {
|
|
6200
|
-
description: "
|
|
6596
|
+
description: "workflow transitions in real-time"
|
|
6201
6597
|
}
|
|
6202
6598
|
}
|
|
6203
6599
|
}),
|
|
@@ -6615,7 +7011,7 @@ async function createNodeServer(mastra, options = {}) {
|
|
|
6615
7011
|
{
|
|
6616
7012
|
fetch: app.fetch,
|
|
6617
7013
|
port,
|
|
6618
|
-
hostname: serverOptions?.host
|
|
7014
|
+
hostname: serverOptions?.host
|
|
6619
7015
|
},
|
|
6620
7016
|
() => {
|
|
6621
7017
|
const logger2 = mastra.getLogger();
|