@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.js
CHANGED
|
@@ -19,6 +19,7 @@ import { HTTPException } from 'hono/http-exception';
|
|
|
19
19
|
import { getAgentCardByIdHandler as getAgentCardByIdHandler$1, getAgentExecutionHandler as getAgentExecutionHandler$1 } from '@mastra/server/handlers/a2a';
|
|
20
20
|
import { stream } from 'hono/streaming';
|
|
21
21
|
import { getAgentsHandler as getAgentsHandler$1, getAgentByIdHandler as getAgentByIdHandler$1, getEvalsByAgentIdHandler as getEvalsByAgentIdHandler$1, getLiveEvalsByAgentIdHandler as getLiveEvalsByAgentIdHandler$1, generateHandler as generateHandler$2, streamGenerateHandler as streamGenerateHandler$2 } from '@mastra/server/handlers/agents';
|
|
22
|
+
import { getLegacyWorkflowsHandler as getLegacyWorkflowsHandler$1, getLegacyWorkflowByIdHandler as getLegacyWorkflowByIdHandler$1, getLegacyWorkflowRunsHandler as getLegacyWorkflowRunsHandler$1, resumeLegacyWorkflowHandler as resumeLegacyWorkflowHandler$1, resumeAsyncLegacyWorkflowHandler as resumeAsyncLegacyWorkflowHandler$1, createLegacyWorkflowRunHandler as createLegacyWorkflowRunHandler$1, startAsyncLegacyWorkflowHandler as startAsyncLegacyWorkflowHandler$1, startLegacyWorkflowRunHandler as startLegacyWorkflowRunHandler$1, watchLegacyWorkflowHandler as watchLegacyWorkflowHandler$1 } from '@mastra/server/handlers/legacyWorkflows';
|
|
22
23
|
import { getLogsHandler as getLogsHandler$1, getLogTransports as getLogTransports$1, getLogsByRunIdHandler as getLogsByRunIdHandler$1 } from '@mastra/server/handlers/logs';
|
|
23
24
|
import { Writable, Readable as Readable$1 } from 'node:stream';
|
|
24
25
|
import util from 'node:util';
|
|
@@ -30,9 +31,8 @@ import { z } from 'zod';
|
|
|
30
31
|
import { getTelemetryHandler as getTelemetryHandler$1, storeTelemetryHandler as storeTelemetryHandler$1 } from '@mastra/server/handlers/telemetry';
|
|
31
32
|
import { executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
|
|
32
33
|
import { upsertVectors as upsertVectors$1, createIndex as createIndex$1, queryVectors as queryVectors$1, listIndexes as listIndexes$1, describeIndex as describeIndex$1, deleteIndex as deleteIndex$1 } from '@mastra/server/handlers/vector';
|
|
33
|
-
import { getVNextWorkflowsHandler as getVNextWorkflowsHandler$1, getVNextWorkflowByIdHandler as getVNextWorkflowByIdHandler$1, getVNextWorkflowRunsHandler as getVNextWorkflowRunsHandler$1, resumeVNextWorkflowHandler as resumeVNextWorkflowHandler$1, resumeAsyncVNextWorkflowHandler as resumeAsyncVNextWorkflowHandler$1, createVNextWorkflowRunHandler as createVNextWorkflowRunHandler$1, startAsyncVNextWorkflowHandler as startAsyncVNextWorkflowHandler$1, startVNextWorkflowRunHandler as startVNextWorkflowRunHandler$1, watchVNextWorkflowHandler as watchVNextWorkflowHandler$1 } from '@mastra/server/handlers/vNextWorkflows';
|
|
34
34
|
import { getSpeakersHandler as getSpeakersHandler$1, generateSpeechHandler, transcribeSpeechHandler } from '@mastra/server/handlers/voice';
|
|
35
|
-
import { getWorkflowsHandler as getWorkflowsHandler$1, getWorkflowByIdHandler as getWorkflowByIdHandler$1, getWorkflowRunsHandler as getWorkflowRunsHandler$1, resumeWorkflowHandler as resumeWorkflowHandler$1, resumeAsyncWorkflowHandler as resumeAsyncWorkflowHandler$1,
|
|
35
|
+
import { getWorkflowsHandler as getWorkflowsHandler$1, getWorkflowByIdHandler as getWorkflowByIdHandler$1, getWorkflowRunsHandler as getWorkflowRunsHandler$1, resumeWorkflowHandler as resumeWorkflowHandler$1, resumeAsyncWorkflowHandler as resumeAsyncWorkflowHandler$1, createWorkflowRunHandler as createWorkflowRunHandler$1, startAsyncWorkflowHandler as startAsyncWorkflowHandler$1, startWorkflowRunHandler as startWorkflowRunHandler$1, watchWorkflowHandler as watchWorkflowHandler$1 } from '@mastra/server/handlers/workflows';
|
|
36
36
|
|
|
37
37
|
// src/server/index.ts
|
|
38
38
|
var RequestError = class extends Error {
|
|
@@ -1038,6 +1038,187 @@ async function setAgentInstructionsHandler(c2) {
|
|
|
1038
1038
|
}
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
|
+
// src/server/handlers/auth/defaults.ts
|
|
1042
|
+
var defaultAuthConfig = {
|
|
1043
|
+
public: [
|
|
1044
|
+
"/",
|
|
1045
|
+
"/refresh-events",
|
|
1046
|
+
"/__refresh",
|
|
1047
|
+
"/assets/*",
|
|
1048
|
+
"/auth/*",
|
|
1049
|
+
"/openapi.json",
|
|
1050
|
+
"/swagger-ui",
|
|
1051
|
+
["/api/agents", "GET"],
|
|
1052
|
+
["/a2a/*", ["GET"]]
|
|
1053
|
+
],
|
|
1054
|
+
// Simple rule system
|
|
1055
|
+
rules: [
|
|
1056
|
+
// Admin users can do anything
|
|
1057
|
+
{
|
|
1058
|
+
condition: (user) => {
|
|
1059
|
+
if (typeof user === "object" && user !== null) {
|
|
1060
|
+
if ("isAdmin" in user) {
|
|
1061
|
+
return !!user.isAdmin;
|
|
1062
|
+
}
|
|
1063
|
+
if ("role" in user) {
|
|
1064
|
+
return user.role === "admin";
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
return false;
|
|
1068
|
+
},
|
|
1069
|
+
allow: true
|
|
1070
|
+
}
|
|
1071
|
+
]
|
|
1072
|
+
};
|
|
1073
|
+
|
|
1074
|
+
// src/server/handlers/auth/helpers.ts
|
|
1075
|
+
var canAccessPublicly = (path, method, authConfig) => {
|
|
1076
|
+
const publicAccess = [...defaultAuthConfig.public || [], ...authConfig.public || []];
|
|
1077
|
+
for (const patternPathOrMethod of publicAccess) {
|
|
1078
|
+
if (patternPathOrMethod instanceof RegExp) {
|
|
1079
|
+
if (patternPathOrMethod.test(path)) {
|
|
1080
|
+
return true;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
if (typeof patternPathOrMethod === "string" && pathMatchesPattern(path, patternPathOrMethod)) {
|
|
1084
|
+
return true;
|
|
1085
|
+
}
|
|
1086
|
+
if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {
|
|
1087
|
+
const [pattern, methodOrMethods] = patternPathOrMethod;
|
|
1088
|
+
if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {
|
|
1089
|
+
return true;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return false;
|
|
1094
|
+
};
|
|
1095
|
+
var pathMatchesPattern = (path, pattern) => {
|
|
1096
|
+
if (pattern.endsWith("*")) {
|
|
1097
|
+
const prefix = pattern.slice(0, -1);
|
|
1098
|
+
return path.startsWith(prefix);
|
|
1099
|
+
}
|
|
1100
|
+
return path === pattern;
|
|
1101
|
+
};
|
|
1102
|
+
var pathMatchesRule = (path, rulePath) => {
|
|
1103
|
+
if (!rulePath) return true;
|
|
1104
|
+
if (typeof rulePath === "string") {
|
|
1105
|
+
return pathMatchesPattern(path, rulePath);
|
|
1106
|
+
}
|
|
1107
|
+
if (rulePath instanceof RegExp) {
|
|
1108
|
+
console.log("rulePath", rulePath, path, rulePath.test(path));
|
|
1109
|
+
return rulePath.test(path);
|
|
1110
|
+
}
|
|
1111
|
+
if (Array.isArray(rulePath)) {
|
|
1112
|
+
return rulePath.some((p2) => pathMatchesPattern(path, p2));
|
|
1113
|
+
}
|
|
1114
|
+
return false;
|
|
1115
|
+
};
|
|
1116
|
+
var matchesOrIncludes = (values, value) => {
|
|
1117
|
+
if (typeof values === "string") {
|
|
1118
|
+
return values === value;
|
|
1119
|
+
}
|
|
1120
|
+
if (Array.isArray(values)) {
|
|
1121
|
+
return values.includes(value);
|
|
1122
|
+
}
|
|
1123
|
+
return false;
|
|
1124
|
+
};
|
|
1125
|
+
var checkRules = async (rules, path, method, user) => {
|
|
1126
|
+
for (const i2 in rules || []) {
|
|
1127
|
+
const rule = rules?.[i2];
|
|
1128
|
+
if (!pathMatchesRule(path, rule.path)) {
|
|
1129
|
+
continue;
|
|
1130
|
+
}
|
|
1131
|
+
if (rule.methods && !matchesOrIncludes(rule.methods, method)) {
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
const condition = rule.condition;
|
|
1135
|
+
if (typeof condition === "function") {
|
|
1136
|
+
const allowed = await Promise.resolve().then(() => condition(user)).catch(() => false);
|
|
1137
|
+
if (allowed) {
|
|
1138
|
+
return true;
|
|
1139
|
+
}
|
|
1140
|
+
} else if (rule.allow) {
|
|
1141
|
+
return true;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
return false;
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
// src/server/handlers/auth/index.ts
|
|
1148
|
+
var authenticationMiddleware = async (c2, next) => {
|
|
1149
|
+
const mastra = c2.get("mastra");
|
|
1150
|
+
const authConfig = mastra.getServer()?.experimental_auth;
|
|
1151
|
+
if (!authConfig) {
|
|
1152
|
+
return next();
|
|
1153
|
+
}
|
|
1154
|
+
if (canAccessPublicly(c2.req.path, c2.req.method, authConfig)) {
|
|
1155
|
+
return next();
|
|
1156
|
+
}
|
|
1157
|
+
const authHeader = c2.req.header("Authorization");
|
|
1158
|
+
let token = authHeader ? authHeader.replace("Bearer ", "") : null;
|
|
1159
|
+
if (!token && c2.req.query("apiKey")) {
|
|
1160
|
+
token = c2.req.query("apiKey") || null;
|
|
1161
|
+
}
|
|
1162
|
+
if (!token) {
|
|
1163
|
+
return c2.json({ error: "Authentication required" }, 401);
|
|
1164
|
+
}
|
|
1165
|
+
try {
|
|
1166
|
+
let user;
|
|
1167
|
+
if (typeof authConfig.authenticateToken === "function") {
|
|
1168
|
+
user = await authConfig.authenticateToken(token, c2.req);
|
|
1169
|
+
} else {
|
|
1170
|
+
throw new Error("No token verification method configured");
|
|
1171
|
+
}
|
|
1172
|
+
if (!user) {
|
|
1173
|
+
return c2.json({ error: "Invalid or expired token" }, 401);
|
|
1174
|
+
}
|
|
1175
|
+
c2.get("runtimeContext").set("user", user);
|
|
1176
|
+
return next();
|
|
1177
|
+
} catch (err) {
|
|
1178
|
+
console.error(err);
|
|
1179
|
+
return c2.json({ error: "Invalid or expired token" }, 401);
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
var authorizationMiddleware = async (c2, next) => {
|
|
1183
|
+
const mastra = c2.get("mastra");
|
|
1184
|
+
const authConfig = mastra.getServer()?.experimental_auth;
|
|
1185
|
+
if (!authConfig) {
|
|
1186
|
+
return next();
|
|
1187
|
+
}
|
|
1188
|
+
const path = c2.req.path;
|
|
1189
|
+
const method = c2.req.method;
|
|
1190
|
+
if (canAccessPublicly(path, method, authConfig)) {
|
|
1191
|
+
return next();
|
|
1192
|
+
}
|
|
1193
|
+
const user = c2.get("runtimeContext").get("user");
|
|
1194
|
+
if (typeof authConfig.authorize === "function") {
|
|
1195
|
+
try {
|
|
1196
|
+
const isAuthorized = await authConfig.authorize(path, method, user, c2);
|
|
1197
|
+
if (isAuthorized) {
|
|
1198
|
+
return next();
|
|
1199
|
+
}
|
|
1200
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1201
|
+
} catch (err) {
|
|
1202
|
+
console.error(err);
|
|
1203
|
+
return c2.json({ error: "Authorization error" }, 500);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
if (authConfig.rules && authConfig.rules.length > 0) {
|
|
1207
|
+
const isAuthorized = await checkRules(authConfig.rules, path, method, user);
|
|
1208
|
+
if (isAuthorized) {
|
|
1209
|
+
return next();
|
|
1210
|
+
}
|
|
1211
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1212
|
+
}
|
|
1213
|
+
if (defaultAuthConfig.rules && defaultAuthConfig.rules.length > 0) {
|
|
1214
|
+
const isAuthorized = await checkRules(defaultAuthConfig.rules, path, method, user);
|
|
1215
|
+
if (isAuthorized) {
|
|
1216
|
+
return next();
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
return c2.json({ error: "Access denied" }, 403);
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1041
1222
|
// src/server/handlers/client.ts
|
|
1042
1223
|
var clients = /* @__PURE__ */ new Set();
|
|
1043
1224
|
function handleClientsRefresh(c2) {
|
|
@@ -1069,6 +1250,184 @@ function handleTriggerClientsRefresh(c2) {
|
|
|
1069
1250
|
});
|
|
1070
1251
|
return c2.json({ success: true, clients: clients.size });
|
|
1071
1252
|
}
|
|
1253
|
+
async function getLegacyWorkflowsHandler(c2) {
|
|
1254
|
+
try {
|
|
1255
|
+
const mastra = c2.get("mastra");
|
|
1256
|
+
const workflows = await getLegacyWorkflowsHandler$1({
|
|
1257
|
+
mastra
|
|
1258
|
+
});
|
|
1259
|
+
return c2.json(workflows);
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
return handleError(error, "Error getting workflows");
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
async function getLegacyWorkflowByIdHandler(c2) {
|
|
1265
|
+
try {
|
|
1266
|
+
const mastra = c2.get("mastra");
|
|
1267
|
+
const workflowId = c2.req.param("workflowId");
|
|
1268
|
+
const workflow = await getLegacyWorkflowByIdHandler$1({
|
|
1269
|
+
mastra,
|
|
1270
|
+
workflowId
|
|
1271
|
+
});
|
|
1272
|
+
return c2.json(workflow);
|
|
1273
|
+
} catch (error) {
|
|
1274
|
+
return handleError(error, "Error getting workflow");
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
async function startAsyncLegacyWorkflowHandler(c2) {
|
|
1278
|
+
try {
|
|
1279
|
+
const mastra = c2.get("mastra");
|
|
1280
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1281
|
+
const workflowId = c2.req.param("workflowId");
|
|
1282
|
+
const triggerData = await c2.req.json();
|
|
1283
|
+
const runId = c2.req.query("runId");
|
|
1284
|
+
const result = await startAsyncLegacyWorkflowHandler$1({
|
|
1285
|
+
mastra,
|
|
1286
|
+
runtimeContext,
|
|
1287
|
+
workflowId,
|
|
1288
|
+
runId,
|
|
1289
|
+
triggerData
|
|
1290
|
+
});
|
|
1291
|
+
return c2.json(result);
|
|
1292
|
+
} catch (error) {
|
|
1293
|
+
return handleError(error, "Error executing workflow");
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
async function createLegacyWorkflowRunHandler(c2) {
|
|
1297
|
+
try {
|
|
1298
|
+
const mastra = c2.get("mastra");
|
|
1299
|
+
const workflowId = c2.req.param("workflowId");
|
|
1300
|
+
const prevRunId = c2.req.query("runId");
|
|
1301
|
+
const result = await createLegacyWorkflowRunHandler$1({
|
|
1302
|
+
mastra,
|
|
1303
|
+
workflowId,
|
|
1304
|
+
runId: prevRunId
|
|
1305
|
+
});
|
|
1306
|
+
return c2.json(result);
|
|
1307
|
+
} catch (e2) {
|
|
1308
|
+
return handleError(e2, "Error creating run");
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
async function startLegacyWorkflowRunHandler(c2) {
|
|
1312
|
+
try {
|
|
1313
|
+
const mastra = c2.get("mastra");
|
|
1314
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1315
|
+
const workflowId = c2.req.param("workflowId");
|
|
1316
|
+
const triggerData = await c2.req.json();
|
|
1317
|
+
const runId = c2.req.query("runId");
|
|
1318
|
+
await startLegacyWorkflowRunHandler$1({
|
|
1319
|
+
mastra,
|
|
1320
|
+
runtimeContext,
|
|
1321
|
+
workflowId,
|
|
1322
|
+
runId,
|
|
1323
|
+
triggerData
|
|
1324
|
+
});
|
|
1325
|
+
return c2.json({ message: "Workflow run started" });
|
|
1326
|
+
} catch (e2) {
|
|
1327
|
+
return handleError(e2, "Error starting workflow run");
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
function watchLegacyWorkflowHandler(c2) {
|
|
1331
|
+
try {
|
|
1332
|
+
const mastra = c2.get("mastra");
|
|
1333
|
+
const logger2 = mastra.getLogger();
|
|
1334
|
+
const workflowId = c2.req.param("workflowId");
|
|
1335
|
+
const runId = c2.req.query("runId");
|
|
1336
|
+
if (!runId) {
|
|
1337
|
+
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
1338
|
+
}
|
|
1339
|
+
return stream(
|
|
1340
|
+
c2,
|
|
1341
|
+
async (stream4) => {
|
|
1342
|
+
try {
|
|
1343
|
+
const result = await watchLegacyWorkflowHandler$1({
|
|
1344
|
+
mastra,
|
|
1345
|
+
workflowId,
|
|
1346
|
+
runId
|
|
1347
|
+
});
|
|
1348
|
+
stream4.onAbort(() => {
|
|
1349
|
+
if (!result.locked) {
|
|
1350
|
+
return result.cancel();
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
for await (const chunk of result) {
|
|
1354
|
+
await stream4.write(chunk.toString() + "");
|
|
1355
|
+
}
|
|
1356
|
+
} catch (err) {
|
|
1357
|
+
console.log(err);
|
|
1358
|
+
}
|
|
1359
|
+
},
|
|
1360
|
+
async (err) => {
|
|
1361
|
+
logger2.error("Error in watch stream: " + err?.message);
|
|
1362
|
+
}
|
|
1363
|
+
);
|
|
1364
|
+
} catch (error) {
|
|
1365
|
+
return handleError(error, "Error watching workflow");
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
async function resumeAsyncLegacyWorkflowHandler(c2) {
|
|
1369
|
+
try {
|
|
1370
|
+
const mastra = c2.get("mastra");
|
|
1371
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1372
|
+
const workflowId = c2.req.param("workflowId");
|
|
1373
|
+
const runId = c2.req.query("runId");
|
|
1374
|
+
const { stepId, context } = await c2.req.json();
|
|
1375
|
+
if (!runId) {
|
|
1376
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
1377
|
+
}
|
|
1378
|
+
const result = await resumeAsyncLegacyWorkflowHandler$1({
|
|
1379
|
+
mastra,
|
|
1380
|
+
runtimeContext,
|
|
1381
|
+
workflowId,
|
|
1382
|
+
runId,
|
|
1383
|
+
body: { stepId, context }
|
|
1384
|
+
});
|
|
1385
|
+
return c2.json(result);
|
|
1386
|
+
} catch (error) {
|
|
1387
|
+
return handleError(error, "Error resuming workflow step");
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
async function resumeLegacyWorkflowHandler(c2) {
|
|
1391
|
+
try {
|
|
1392
|
+
const mastra = c2.get("mastra");
|
|
1393
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
1394
|
+
const workflowId = c2.req.param("workflowId");
|
|
1395
|
+
const runId = c2.req.query("runId");
|
|
1396
|
+
const { stepId, context } = await c2.req.json();
|
|
1397
|
+
if (!runId) {
|
|
1398
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
1399
|
+
}
|
|
1400
|
+
await resumeLegacyWorkflowHandler$1({
|
|
1401
|
+
mastra,
|
|
1402
|
+
runtimeContext,
|
|
1403
|
+
workflowId,
|
|
1404
|
+
runId,
|
|
1405
|
+
body: { stepId, context }
|
|
1406
|
+
});
|
|
1407
|
+
return c2.json({ message: "Workflow run resumed" });
|
|
1408
|
+
} catch (error) {
|
|
1409
|
+
return handleError(error, "Error resuming workflow");
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
async function getLegacyWorkflowRunsHandler(c2) {
|
|
1413
|
+
try {
|
|
1414
|
+
const mastra = c2.get("mastra");
|
|
1415
|
+
const workflowId = c2.req.param("workflowId");
|
|
1416
|
+
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
1417
|
+
const workflowRuns = await getLegacyWorkflowRunsHandler$1({
|
|
1418
|
+
mastra,
|
|
1419
|
+
workflowId,
|
|
1420
|
+
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
1421
|
+
toDate: toDate ? new Date(toDate) : void 0,
|
|
1422
|
+
limit: limit ? Number(limit) : void 0,
|
|
1423
|
+
offset: offset ? Number(offset) : void 0,
|
|
1424
|
+
resourceId
|
|
1425
|
+
});
|
|
1426
|
+
return c2.json(workflowRuns);
|
|
1427
|
+
} catch (error) {
|
|
1428
|
+
return handleError(error, "Error getting workflow runs");
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1072
1431
|
async function getLogsHandler(c2) {
|
|
1073
1432
|
try {
|
|
1074
1433
|
const mastra = c2.get("mastra");
|
|
@@ -2978,7 +3337,7 @@ var getMcpServerMessageHandler = async (c2) => {
|
|
|
2978
3337
|
try {
|
|
2979
3338
|
await server.startHTTP({
|
|
2980
3339
|
url: new URL(c2.req.url),
|
|
2981
|
-
httpPath: `/api/
|
|
3340
|
+
httpPath: `/api/mcp/${serverId}/mcp`,
|
|
2982
3341
|
req,
|
|
2983
3342
|
res,
|
|
2984
3343
|
options: {
|
|
@@ -2999,8 +3358,8 @@ var getMcpServerSseHandler = async (c2) => {
|
|
|
2999
3358
|
return c2.json({ error: `MCP server '${serverId}' not found` }, 404);
|
|
3000
3359
|
}
|
|
3001
3360
|
const requestUrl = new URL(c2.req.url);
|
|
3002
|
-
const sseConnectionPath = `/api/
|
|
3003
|
-
const sseMessagePath = `/api/
|
|
3361
|
+
const sseConnectionPath = `/api/mcp/${serverId}/sse`;
|
|
3362
|
+
const sseMessagePath = `/api/mcp/${serverId}/messages`;
|
|
3004
3363
|
try {
|
|
3005
3364
|
return await server.startHonoSSE({
|
|
3006
3365
|
url: requestUrl,
|
|
@@ -3013,17 +3372,159 @@ var getMcpServerSseHandler = async (c2) => {
|
|
|
3013
3372
|
return handleError(error, "Error handling MCP SSE request");
|
|
3014
3373
|
}
|
|
3015
3374
|
};
|
|
3016
|
-
async
|
|
3375
|
+
var listMcpRegistryServersHandler = async (c2) => {
|
|
3376
|
+
const mastra = getMastra(c2);
|
|
3377
|
+
if (!mastra || typeof mastra.getMCPServers !== "function") {
|
|
3378
|
+
c2.get("logger")?.error("Mastra instance or getMCPServers method not available in listMcpRegistryServersHandler");
|
|
3379
|
+
return c2.json({ error: "Mastra instance or getMCPServers method not available" }, 500);
|
|
3380
|
+
}
|
|
3381
|
+
const mcpServersMap = mastra.getMCPServers();
|
|
3382
|
+
if (!mcpServersMap) {
|
|
3383
|
+
c2.get("logger")?.warn("getMCPServers returned undefined or null in listMcpRegistryServersHandler");
|
|
3384
|
+
return c2.json({ servers: [], next: null, total_count: 0 });
|
|
3385
|
+
}
|
|
3386
|
+
const allServersArray = Array.from(
|
|
3387
|
+
mcpServersMap instanceof Map ? mcpServersMap.values() : Object.values(mcpServersMap)
|
|
3388
|
+
);
|
|
3389
|
+
const limit = parseInt(c2.req.query("limit") || "50", 10);
|
|
3390
|
+
const offset = parseInt(c2.req.query("offset") || "0", 10);
|
|
3391
|
+
const paginatedServers = allServersArray.slice(offset, offset + limit);
|
|
3392
|
+
const serverInfos = paginatedServers.map((server) => server.getServerInfo());
|
|
3393
|
+
const total_count = allServersArray.length;
|
|
3394
|
+
let next = null;
|
|
3395
|
+
if (offset + limit < total_count) {
|
|
3396
|
+
const nextOffset = offset + limit;
|
|
3397
|
+
const currentUrl = new URL(c2.req.url);
|
|
3398
|
+
currentUrl.searchParams.set("offset", nextOffset.toString());
|
|
3399
|
+
currentUrl.searchParams.set("limit", limit.toString());
|
|
3400
|
+
next = currentUrl.toString();
|
|
3401
|
+
}
|
|
3402
|
+
return c2.json({
|
|
3403
|
+
servers: serverInfos,
|
|
3404
|
+
next,
|
|
3405
|
+
total_count
|
|
3406
|
+
});
|
|
3407
|
+
};
|
|
3408
|
+
var getMcpRegistryServerDetailHandler = async (c2) => {
|
|
3409
|
+
const mastra = getMastra(c2);
|
|
3410
|
+
const serverId = c2.req.param("id");
|
|
3411
|
+
const requestedVersion = c2.req.query("version");
|
|
3412
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3413
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in getMcpRegistryServerDetailHandler");
|
|
3414
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3415
|
+
}
|
|
3416
|
+
const server = mastra.getMCPServer(serverId);
|
|
3417
|
+
if (!server) {
|
|
3418
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3419
|
+
}
|
|
3420
|
+
const serverDetailInfo = server.getServerDetail();
|
|
3421
|
+
if (requestedVersion && serverDetailInfo.version_detail.version !== requestedVersion) {
|
|
3422
|
+
c2.get("logger")?.info(
|
|
3423
|
+
`MCP server with ID '${serverId}' found, but version '${serverDetailInfo.version_detail.version}' does not match requested version '${requestedVersion}'.`
|
|
3424
|
+
);
|
|
3425
|
+
return c2.json(
|
|
3426
|
+
{
|
|
3427
|
+
error: `MCP server with ID '${serverId}' found, but not version '${requestedVersion}'. Available version is '${serverDetailInfo.version_detail.version}'.`
|
|
3428
|
+
},
|
|
3429
|
+
404
|
|
3430
|
+
// Return 404 as the specific version is not found
|
|
3431
|
+
);
|
|
3432
|
+
}
|
|
3433
|
+
return c2.json(serverDetailInfo);
|
|
3434
|
+
};
|
|
3435
|
+
var listMcpServerToolsHandler = async (c2) => {
|
|
3436
|
+
const mastra = getMastra(c2);
|
|
3437
|
+
const serverId = c2.req.param("serverId");
|
|
3438
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3439
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in listMcpServerToolsHandler");
|
|
3440
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3441
|
+
}
|
|
3442
|
+
const server = mastra.getMCPServer(serverId);
|
|
3443
|
+
if (!server) {
|
|
3444
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3445
|
+
}
|
|
3446
|
+
if (typeof server.getToolListInfo !== "function") {
|
|
3447
|
+
c2.get("logger")?.error(`MCPServer with ID '${serverId}' does not support getToolListInfo.`);
|
|
3448
|
+
return c2.json({ error: `Server '${serverId}' cannot list tools in this way.` }, 501);
|
|
3449
|
+
}
|
|
3017
3450
|
try {
|
|
3018
|
-
const
|
|
3019
|
-
|
|
3020
|
-
const result = await getMemoryStatusHandler$1({
|
|
3021
|
-
mastra,
|
|
3022
|
-
agentId
|
|
3023
|
-
});
|
|
3024
|
-
return c2.json(result);
|
|
3451
|
+
const toolListInfo = server.getToolListInfo();
|
|
3452
|
+
return c2.json(toolListInfo);
|
|
3025
3453
|
} catch (error) {
|
|
3026
|
-
|
|
3454
|
+
c2.get("logger")?.error(`Error in listMcpServerToolsHandler for serverId '${serverId}':`, { error: error.message });
|
|
3455
|
+
return handleError(error, `Error listing tools for MCP server '${serverId}'`);
|
|
3456
|
+
}
|
|
3457
|
+
};
|
|
3458
|
+
var getMcpServerToolDetailHandler = async (c2) => {
|
|
3459
|
+
const mastra = getMastra(c2);
|
|
3460
|
+
const serverId = c2.req.param("serverId");
|
|
3461
|
+
const toolId = c2.req.param("toolId");
|
|
3462
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3463
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in getMcpServerToolDetailHandler");
|
|
3464
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3465
|
+
}
|
|
3466
|
+
const server = mastra.getMCPServer(serverId);
|
|
3467
|
+
if (!server) {
|
|
3468
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3469
|
+
}
|
|
3470
|
+
if (typeof server.getToolInfo !== "function") {
|
|
3471
|
+
c2.get("logger")?.error(`MCPServer with ID '${serverId}' does not support getToolInfo.`);
|
|
3472
|
+
return c2.json({ error: `Server '${serverId}' cannot provide tool details in this way.` }, 501);
|
|
3473
|
+
}
|
|
3474
|
+
try {
|
|
3475
|
+
const toolInfo = server.getToolInfo(toolId);
|
|
3476
|
+
if (!toolInfo) {
|
|
3477
|
+
return c2.json({ error: `Tool with ID '${toolId}' not found on MCP server '${serverId}'` }, 404);
|
|
3478
|
+
}
|
|
3479
|
+
return c2.json(toolInfo);
|
|
3480
|
+
} catch (error) {
|
|
3481
|
+
c2.get("logger")?.error(`Error in getMcpServerToolDetailHandler for serverId '${serverId}', toolId '${toolId}':`, {
|
|
3482
|
+
error: error.message
|
|
3483
|
+
});
|
|
3484
|
+
return handleError(error, `Error getting tool '${toolId}' details for MCP server '${serverId}'`);
|
|
3485
|
+
}
|
|
3486
|
+
};
|
|
3487
|
+
var executeMcpServerToolHandler = async (c2) => {
|
|
3488
|
+
const mastra = getMastra(c2);
|
|
3489
|
+
const serverId = c2.req.param("serverId");
|
|
3490
|
+
const toolId = c2.req.param("toolId");
|
|
3491
|
+
if (!mastra || typeof mastra.getMCPServer !== "function") {
|
|
3492
|
+
c2.get("logger")?.error("Mastra instance or getMCPServer method not available in executeMcpServerToolHandler");
|
|
3493
|
+
return c2.json({ error: "Mastra instance or getMCPServer method not available" }, 500);
|
|
3494
|
+
}
|
|
3495
|
+
const server = mastra.getMCPServer(serverId);
|
|
3496
|
+
if (!server) {
|
|
3497
|
+
return c2.json({ error: `MCP server with ID '${serverId}' not found` }, 404);
|
|
3498
|
+
}
|
|
3499
|
+
if (typeof server.executeTool !== "function") {
|
|
3500
|
+
c2.get("logger")?.error(`MCPServer with ID '${serverId}' does not support executeTool.`);
|
|
3501
|
+
return c2.json({ error: `Server '${serverId}' cannot execute tools in this way.` }, 501);
|
|
3502
|
+
}
|
|
3503
|
+
try {
|
|
3504
|
+
const body = await c2.req.json();
|
|
3505
|
+
const args = body?.data;
|
|
3506
|
+
const runtimeContext = body?.runtimeContext;
|
|
3507
|
+
const result = await server.executeTool(toolId, args, runtimeContext);
|
|
3508
|
+
return c2.json({ result });
|
|
3509
|
+
} catch (error) {
|
|
3510
|
+
c2.get("logger")?.error(`Error executing tool '${toolId}' on server '${serverId}':`, { error: error.message });
|
|
3511
|
+
if (error.name === "ZodError") {
|
|
3512
|
+
return c2.json({ error: "Invalid tool arguments", details: error.errors }, 400);
|
|
3513
|
+
}
|
|
3514
|
+
return handleError(error, `Error executing tool '${toolId}' on MCP server '${serverId}'`);
|
|
3515
|
+
}
|
|
3516
|
+
};
|
|
3517
|
+
async function getMemoryStatusHandler(c2) {
|
|
3518
|
+
try {
|
|
3519
|
+
const mastra = c2.get("mastra");
|
|
3520
|
+
const agentId = c2.req.query("agentId");
|
|
3521
|
+
const result = await getMemoryStatusHandler$1({
|
|
3522
|
+
mastra,
|
|
3523
|
+
agentId
|
|
3524
|
+
});
|
|
3525
|
+
return c2.json(result);
|
|
3526
|
+
} catch (error) {
|
|
3527
|
+
return handleError(error, "Error getting memory status");
|
|
3027
3528
|
}
|
|
3028
3529
|
}
|
|
3029
3530
|
async function getThreadsHandler(c2) {
|
|
@@ -3517,186 +4018,6 @@ async function deleteIndex(c2) {
|
|
|
3517
4018
|
return handleError(error, "Error deleting index");
|
|
3518
4019
|
}
|
|
3519
4020
|
}
|
|
3520
|
-
async function getVNextWorkflowsHandler(c2) {
|
|
3521
|
-
try {
|
|
3522
|
-
const mastra = c2.get("mastra");
|
|
3523
|
-
const workflows = await getVNextWorkflowsHandler$1({
|
|
3524
|
-
mastra
|
|
3525
|
-
});
|
|
3526
|
-
return c2.json(workflows);
|
|
3527
|
-
} catch (error) {
|
|
3528
|
-
return handleError(error, "Error getting workflows");
|
|
3529
|
-
}
|
|
3530
|
-
}
|
|
3531
|
-
async function getVNextWorkflowByIdHandler(c2) {
|
|
3532
|
-
try {
|
|
3533
|
-
const mastra = c2.get("mastra");
|
|
3534
|
-
const workflowId = c2.req.param("workflowId");
|
|
3535
|
-
const workflow = await getVNextWorkflowByIdHandler$1({
|
|
3536
|
-
mastra,
|
|
3537
|
-
workflowId
|
|
3538
|
-
});
|
|
3539
|
-
return c2.json(workflow);
|
|
3540
|
-
} catch (error) {
|
|
3541
|
-
return handleError(error, "Error getting workflow");
|
|
3542
|
-
}
|
|
3543
|
-
}
|
|
3544
|
-
async function createVNextWorkflowRunHandler(c2) {
|
|
3545
|
-
try {
|
|
3546
|
-
const mastra = c2.get("mastra");
|
|
3547
|
-
const workflowId = c2.req.param("workflowId");
|
|
3548
|
-
const prevRunId = c2.req.query("runId");
|
|
3549
|
-
const result = await createVNextWorkflowRunHandler$1({
|
|
3550
|
-
mastra,
|
|
3551
|
-
workflowId,
|
|
3552
|
-
runId: prevRunId
|
|
3553
|
-
});
|
|
3554
|
-
return c2.json(result);
|
|
3555
|
-
} catch (e2) {
|
|
3556
|
-
return handleError(e2, "Error creating run");
|
|
3557
|
-
}
|
|
3558
|
-
}
|
|
3559
|
-
async function startAsyncVNextWorkflowHandler(c2) {
|
|
3560
|
-
try {
|
|
3561
|
-
const mastra = c2.get("mastra");
|
|
3562
|
-
const workflowId = c2.req.param("workflowId");
|
|
3563
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3564
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3565
|
-
const runId = c2.req.query("runId");
|
|
3566
|
-
const result = await startAsyncVNextWorkflowHandler$1({
|
|
3567
|
-
mastra,
|
|
3568
|
-
runtimeContext,
|
|
3569
|
-
runtimeContextFromRequest,
|
|
3570
|
-
workflowId,
|
|
3571
|
-
runId,
|
|
3572
|
-
inputData
|
|
3573
|
-
});
|
|
3574
|
-
return c2.json(result);
|
|
3575
|
-
} catch (error) {
|
|
3576
|
-
return handleError(error, "Error executing workflow");
|
|
3577
|
-
}
|
|
3578
|
-
}
|
|
3579
|
-
async function startVNextWorkflowRunHandler(c2) {
|
|
3580
|
-
try {
|
|
3581
|
-
const mastra = c2.get("mastra");
|
|
3582
|
-
const workflowId = c2.req.param("workflowId");
|
|
3583
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3584
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3585
|
-
const runId = c2.req.query("runId");
|
|
3586
|
-
await startVNextWorkflowRunHandler$1({
|
|
3587
|
-
mastra,
|
|
3588
|
-
runtimeContext,
|
|
3589
|
-
runtimeContextFromRequest,
|
|
3590
|
-
workflowId,
|
|
3591
|
-
runId,
|
|
3592
|
-
inputData
|
|
3593
|
-
});
|
|
3594
|
-
return c2.json({ message: "Workflow run started" });
|
|
3595
|
-
} catch (e2) {
|
|
3596
|
-
return handleError(e2, "Error starting workflow run");
|
|
3597
|
-
}
|
|
3598
|
-
}
|
|
3599
|
-
function watchVNextWorkflowHandler(c2) {
|
|
3600
|
-
try {
|
|
3601
|
-
const mastra = c2.get("mastra");
|
|
3602
|
-
const logger2 = mastra.getLogger();
|
|
3603
|
-
const workflowId = c2.req.param("workflowId");
|
|
3604
|
-
const runId = c2.req.query("runId");
|
|
3605
|
-
if (!runId) {
|
|
3606
|
-
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
3607
|
-
}
|
|
3608
|
-
return stream(
|
|
3609
|
-
c2,
|
|
3610
|
-
async (stream4) => {
|
|
3611
|
-
try {
|
|
3612
|
-
const result = await watchVNextWorkflowHandler$1({
|
|
3613
|
-
mastra,
|
|
3614
|
-
workflowId,
|
|
3615
|
-
runId
|
|
3616
|
-
});
|
|
3617
|
-
stream4.onAbort(() => {
|
|
3618
|
-
if (!result.locked) {
|
|
3619
|
-
return result.cancel();
|
|
3620
|
-
}
|
|
3621
|
-
});
|
|
3622
|
-
for await (const chunk of result) {
|
|
3623
|
-
await stream4.write(chunk.toString() + "");
|
|
3624
|
-
}
|
|
3625
|
-
} catch (err) {
|
|
3626
|
-
console.log(err);
|
|
3627
|
-
}
|
|
3628
|
-
},
|
|
3629
|
-
async (err) => {
|
|
3630
|
-
logger2.error("Error in watch stream: " + err?.message);
|
|
3631
|
-
}
|
|
3632
|
-
);
|
|
3633
|
-
} catch (error) {
|
|
3634
|
-
return handleError(error, "Error watching workflow");
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
async function resumeAsyncVNextWorkflowHandler(c2) {
|
|
3638
|
-
try {
|
|
3639
|
-
const mastra = c2.get("mastra");
|
|
3640
|
-
const workflowId = c2.req.param("workflowId");
|
|
3641
|
-
const runId = c2.req.query("runId");
|
|
3642
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3643
|
-
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3644
|
-
if (!runId) {
|
|
3645
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
3646
|
-
}
|
|
3647
|
-
const result = await resumeAsyncVNextWorkflowHandler$1({
|
|
3648
|
-
mastra,
|
|
3649
|
-
runtimeContext,
|
|
3650
|
-
runtimeContextFromRequest,
|
|
3651
|
-
workflowId,
|
|
3652
|
-
runId,
|
|
3653
|
-
body: { step, resumeData }
|
|
3654
|
-
});
|
|
3655
|
-
return c2.json(result);
|
|
3656
|
-
} catch (error) {
|
|
3657
|
-
return handleError(error, "Error resuming workflow step");
|
|
3658
|
-
}
|
|
3659
|
-
}
|
|
3660
|
-
async function resumeVNextWorkflowHandler(c2) {
|
|
3661
|
-
try {
|
|
3662
|
-
const mastra = c2.get("mastra");
|
|
3663
|
-
const workflowId = c2.req.param("workflowId");
|
|
3664
|
-
const runId = c2.req.query("runId");
|
|
3665
|
-
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
3666
|
-
if (!runId) {
|
|
3667
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
3668
|
-
}
|
|
3669
|
-
await resumeVNextWorkflowHandler$1({
|
|
3670
|
-
mastra,
|
|
3671
|
-
runtimeContext,
|
|
3672
|
-
workflowId,
|
|
3673
|
-
runId,
|
|
3674
|
-
body: { step, resumeData }
|
|
3675
|
-
});
|
|
3676
|
-
return c2.json({ message: "Workflow run resumed" });
|
|
3677
|
-
} catch (error) {
|
|
3678
|
-
return handleError(error, "Error resuming workflow");
|
|
3679
|
-
}
|
|
3680
|
-
}
|
|
3681
|
-
async function getVNextWorkflowRunsHandler(c2) {
|
|
3682
|
-
try {
|
|
3683
|
-
const mastra = c2.get("mastra");
|
|
3684
|
-
const workflowId = c2.req.param("workflowId");
|
|
3685
|
-
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
3686
|
-
const workflowRuns = await getVNextWorkflowRunsHandler$1({
|
|
3687
|
-
mastra,
|
|
3688
|
-
workflowId,
|
|
3689
|
-
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
3690
|
-
toDate: toDate ? new Date(toDate) : void 0,
|
|
3691
|
-
limit: limit ? Number(limit) : void 0,
|
|
3692
|
-
offset: offset ? Number(offset) : void 0,
|
|
3693
|
-
resourceId
|
|
3694
|
-
});
|
|
3695
|
-
return c2.json(workflowRuns);
|
|
3696
|
-
} catch (error) {
|
|
3697
|
-
return handleError(error, "Error getting workflow runs");
|
|
3698
|
-
}
|
|
3699
|
-
}
|
|
3700
4021
|
async function getSpeakersHandler(c2) {
|
|
3701
4022
|
try {
|
|
3702
4023
|
const mastra = c2.get("mastra");
|
|
@@ -3780,53 +4101,55 @@ async function getWorkflowByIdHandler(c2) {
|
|
|
3780
4101
|
return handleError(error, "Error getting workflow");
|
|
3781
4102
|
}
|
|
3782
4103
|
}
|
|
3783
|
-
async function
|
|
4104
|
+
async function createWorkflowRunHandler(c2) {
|
|
3784
4105
|
try {
|
|
3785
4106
|
const mastra = c2.get("mastra");
|
|
3786
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3787
4107
|
const workflowId = c2.req.param("workflowId");
|
|
3788
|
-
const
|
|
3789
|
-
const
|
|
3790
|
-
const result = await startAsyncWorkflowHandler$1({
|
|
4108
|
+
const prevRunId = c2.req.query("runId");
|
|
4109
|
+
const result = await createWorkflowRunHandler$1({
|
|
3791
4110
|
mastra,
|
|
3792
|
-
runtimeContext,
|
|
3793
4111
|
workflowId,
|
|
3794
|
-
runId
|
|
3795
|
-
triggerData
|
|
4112
|
+
runId: prevRunId
|
|
3796
4113
|
});
|
|
3797
4114
|
return c2.json(result);
|
|
3798
|
-
} catch (
|
|
3799
|
-
return handleError(
|
|
4115
|
+
} catch (e2) {
|
|
4116
|
+
return handleError(e2, "Error creating run");
|
|
3800
4117
|
}
|
|
3801
4118
|
}
|
|
3802
|
-
async function
|
|
4119
|
+
async function startAsyncWorkflowHandler(c2) {
|
|
3803
4120
|
try {
|
|
3804
4121
|
const mastra = c2.get("mastra");
|
|
3805
4122
|
const workflowId = c2.req.param("workflowId");
|
|
3806
|
-
const
|
|
3807
|
-
const
|
|
4123
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4124
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
4125
|
+
const runId = c2.req.query("runId");
|
|
4126
|
+
const result = await startAsyncWorkflowHandler$1({
|
|
3808
4127
|
mastra,
|
|
4128
|
+
runtimeContext,
|
|
4129
|
+
runtimeContextFromRequest,
|
|
3809
4130
|
workflowId,
|
|
3810
|
-
runId
|
|
4131
|
+
runId,
|
|
4132
|
+
inputData
|
|
3811
4133
|
});
|
|
3812
4134
|
return c2.json(result);
|
|
3813
|
-
} catch (
|
|
3814
|
-
return handleError(
|
|
4135
|
+
} catch (error) {
|
|
4136
|
+
return handleError(error, "Error executing workflow");
|
|
3815
4137
|
}
|
|
3816
4138
|
}
|
|
3817
4139
|
async function startWorkflowRunHandler(c2) {
|
|
3818
4140
|
try {
|
|
3819
4141
|
const mastra = c2.get("mastra");
|
|
3820
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3821
4142
|
const workflowId = c2.req.param("workflowId");
|
|
3822
|
-
const
|
|
4143
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4144
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3823
4145
|
const runId = c2.req.query("runId");
|
|
3824
4146
|
await startWorkflowRunHandler$1({
|
|
3825
4147
|
mastra,
|
|
3826
4148
|
runtimeContext,
|
|
4149
|
+
runtimeContextFromRequest,
|
|
3827
4150
|
workflowId,
|
|
3828
4151
|
runId,
|
|
3829
|
-
|
|
4152
|
+
inputData
|
|
3830
4153
|
});
|
|
3831
4154
|
return c2.json({ message: "Workflow run started" });
|
|
3832
4155
|
} catch (e2) {
|
|
@@ -3874,19 +4197,20 @@ function watchWorkflowHandler(c2) {
|
|
|
3874
4197
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
3875
4198
|
try {
|
|
3876
4199
|
const mastra = c2.get("mastra");
|
|
3877
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3878
4200
|
const workflowId = c2.req.param("workflowId");
|
|
3879
4201
|
const runId = c2.req.query("runId");
|
|
3880
|
-
const
|
|
4202
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4203
|
+
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3881
4204
|
if (!runId) {
|
|
3882
4205
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
3883
4206
|
}
|
|
3884
4207
|
const result = await resumeAsyncWorkflowHandler$1({
|
|
3885
4208
|
mastra,
|
|
3886
4209
|
runtimeContext,
|
|
4210
|
+
runtimeContextFromRequest,
|
|
3887
4211
|
workflowId,
|
|
3888
4212
|
runId,
|
|
3889
|
-
body: {
|
|
4213
|
+
body: { step, resumeData }
|
|
3890
4214
|
});
|
|
3891
4215
|
return c2.json(result);
|
|
3892
4216
|
} catch (error) {
|
|
@@ -3896,10 +4220,9 @@ async function resumeAsyncWorkflowHandler(c2) {
|
|
|
3896
4220
|
async function resumeWorkflowHandler(c2) {
|
|
3897
4221
|
try {
|
|
3898
4222
|
const mastra = c2.get("mastra");
|
|
3899
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3900
4223
|
const workflowId = c2.req.param("workflowId");
|
|
3901
4224
|
const runId = c2.req.query("runId");
|
|
3902
|
-
const {
|
|
4225
|
+
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
3903
4226
|
if (!runId) {
|
|
3904
4227
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
3905
4228
|
}
|
|
@@ -3908,7 +4231,7 @@ async function resumeWorkflowHandler(c2) {
|
|
|
3908
4231
|
runtimeContext,
|
|
3909
4232
|
workflowId,
|
|
3910
4233
|
runId,
|
|
3911
|
-
body: {
|
|
4234
|
+
body: { step, resumeData }
|
|
3912
4235
|
});
|
|
3913
4236
|
return c2.json({ message: "Workflow run resumed" });
|
|
3914
4237
|
} catch (error) {
|
|
@@ -4125,6 +4448,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
4125
4448
|
};
|
|
4126
4449
|
app.use("*", timeout(server?.timeout ?? 3 * 60 * 1e3), cors(corsConfig));
|
|
4127
4450
|
}
|
|
4451
|
+
app.use("*", authenticationMiddleware);
|
|
4452
|
+
app.use("*", authorizationMiddleware);
|
|
4128
4453
|
const bodyLimitOptions = {
|
|
4129
4454
|
maxSize: server?.bodySizeLimit ?? 4.5 * 1024 * 1024,
|
|
4130
4455
|
// 4.5 MB,
|
|
@@ -5170,7 +5495,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5170
5495
|
executeAgentToolHandler
|
|
5171
5496
|
);
|
|
5172
5497
|
app.post(
|
|
5173
|
-
"/api/
|
|
5498
|
+
"/api/mcp/:serverId/mcp",
|
|
5174
5499
|
bodyLimit(bodyLimitOptions),
|
|
5175
5500
|
h({
|
|
5176
5501
|
description: "Send a message to an MCP server using Streamable HTTP",
|
|
@@ -5197,8 +5522,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5197
5522
|
}),
|
|
5198
5523
|
getMcpServerMessageHandler
|
|
5199
5524
|
);
|
|
5200
|
-
const mcpSseBasePath = "/api/
|
|
5201
|
-
const mcpSseMessagePath = "/api/
|
|
5525
|
+
const mcpSseBasePath = "/api/mcp/:serverId/sse";
|
|
5526
|
+
const mcpSseMessagePath = "/api/mcp/:serverId/messages";
|
|
5202
5527
|
app.get(
|
|
5203
5528
|
mcpSseBasePath,
|
|
5204
5529
|
h({
|
|
@@ -5256,6 +5581,158 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5256
5581
|
}),
|
|
5257
5582
|
getMcpServerSseHandler
|
|
5258
5583
|
);
|
|
5584
|
+
app.get(
|
|
5585
|
+
"/api/mcp/v0/servers",
|
|
5586
|
+
h({
|
|
5587
|
+
description: "List all available MCP server instances with basic information.",
|
|
5588
|
+
tags: ["mcp"],
|
|
5589
|
+
parameters: [
|
|
5590
|
+
{
|
|
5591
|
+
name: "limit",
|
|
5592
|
+
in: "query",
|
|
5593
|
+
description: "Number of results per page.",
|
|
5594
|
+
required: false,
|
|
5595
|
+
schema: { type: "integer", default: 50, minimum: 1, maximum: 5e3 }
|
|
5596
|
+
},
|
|
5597
|
+
{
|
|
5598
|
+
name: "offset",
|
|
5599
|
+
in: "query",
|
|
5600
|
+
description: "Number of results to skip for pagination.",
|
|
5601
|
+
required: false,
|
|
5602
|
+
schema: { type: "integer", default: 0, minimum: 0 }
|
|
5603
|
+
}
|
|
5604
|
+
],
|
|
5605
|
+
responses: {
|
|
5606
|
+
200: {
|
|
5607
|
+
description: "A list of MCP server instances.",
|
|
5608
|
+
content: {
|
|
5609
|
+
"application/json": {
|
|
5610
|
+
schema: {
|
|
5611
|
+
type: "object",
|
|
5612
|
+
properties: {
|
|
5613
|
+
servers: { type: "array", items: { $ref: "#/components/schemas/ServerInfo" } },
|
|
5614
|
+
next: { type: "string", format: "uri", nullable: true },
|
|
5615
|
+
total_count: { type: "integer" }
|
|
5616
|
+
}
|
|
5617
|
+
}
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5622
|
+
}),
|
|
5623
|
+
listMcpRegistryServersHandler
|
|
5624
|
+
);
|
|
5625
|
+
app.get(
|
|
5626
|
+
"/api/mcp/v0/servers/:id",
|
|
5627
|
+
h({
|
|
5628
|
+
description: "Get detailed information about a specific MCP server instance.",
|
|
5629
|
+
tags: ["mcp"],
|
|
5630
|
+
parameters: [
|
|
5631
|
+
{
|
|
5632
|
+
name: "id",
|
|
5633
|
+
in: "path",
|
|
5634
|
+
required: true,
|
|
5635
|
+
description: "Unique ID of the MCP server instance.",
|
|
5636
|
+
schema: { type: "string" }
|
|
5637
|
+
},
|
|
5638
|
+
{
|
|
5639
|
+
name: "version",
|
|
5640
|
+
in: "query",
|
|
5641
|
+
required: false,
|
|
5642
|
+
description: "Desired MCP server version (currently informational, server returns its actual version).",
|
|
5643
|
+
schema: { type: "string" }
|
|
5644
|
+
}
|
|
5645
|
+
],
|
|
5646
|
+
responses: {
|
|
5647
|
+
200: {
|
|
5648
|
+
description: "Detailed information about the MCP server instance.",
|
|
5649
|
+
content: {
|
|
5650
|
+
"application/json": { schema: { $ref: "#/components/schemas/ServerDetailInfo" } }
|
|
5651
|
+
}
|
|
5652
|
+
},
|
|
5653
|
+
404: {
|
|
5654
|
+
description: "MCP server instance not found.",
|
|
5655
|
+
content: { "application/json": { schema: { type: "object", properties: { error: { type: "string" } } } } }
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5658
|
+
}),
|
|
5659
|
+
getMcpRegistryServerDetailHandler
|
|
5660
|
+
);
|
|
5661
|
+
app.get(
|
|
5662
|
+
"/api/mcp/:serverId/tools",
|
|
5663
|
+
h({
|
|
5664
|
+
description: "List all tools available on a specific MCP server instance.",
|
|
5665
|
+
tags: ["mcp"],
|
|
5666
|
+
parameters: [
|
|
5667
|
+
{
|
|
5668
|
+
name: "serverId",
|
|
5669
|
+
in: "path",
|
|
5670
|
+
required: true,
|
|
5671
|
+
description: "Unique ID of the MCP server instance.",
|
|
5672
|
+
schema: { type: "string" }
|
|
5673
|
+
}
|
|
5674
|
+
],
|
|
5675
|
+
responses: {
|
|
5676
|
+
200: { description: "A list of tools for the MCP server." },
|
|
5677
|
+
// Define schema if you have one for McpServerToolListResponse
|
|
5678
|
+
404: { description: "MCP server instance not found." },
|
|
5679
|
+
501: { description: "Server does not support listing tools." }
|
|
5680
|
+
}
|
|
5681
|
+
}),
|
|
5682
|
+
listMcpServerToolsHandler
|
|
5683
|
+
);
|
|
5684
|
+
app.get(
|
|
5685
|
+
"/api/mcp/:serverId/tools/:toolId",
|
|
5686
|
+
h({
|
|
5687
|
+
description: "Get details for a specific tool on an MCP server.",
|
|
5688
|
+
tags: ["mcp"],
|
|
5689
|
+
parameters: [
|
|
5690
|
+
{ name: "serverId", in: "path", required: true, schema: { type: "string" } },
|
|
5691
|
+
{ name: "toolId", in: "path", required: true, schema: { type: "string" } }
|
|
5692
|
+
],
|
|
5693
|
+
responses: {
|
|
5694
|
+
200: { description: "Details of the specified tool." },
|
|
5695
|
+
// Define schema for McpToolInfo
|
|
5696
|
+
404: { description: "MCP server or tool not found." },
|
|
5697
|
+
501: { description: "Server does not support getting tool details." }
|
|
5698
|
+
}
|
|
5699
|
+
}),
|
|
5700
|
+
getMcpServerToolDetailHandler
|
|
5701
|
+
);
|
|
5702
|
+
app.post(
|
|
5703
|
+
"/api/mcp/:serverId/tools/:toolId/execute",
|
|
5704
|
+
bodyLimit(bodyLimitOptions),
|
|
5705
|
+
h({
|
|
5706
|
+
description: "Execute a specific tool on an MCP server.",
|
|
5707
|
+
tags: ["mcp"],
|
|
5708
|
+
parameters: [
|
|
5709
|
+
{ name: "serverId", in: "path", required: true, schema: { type: "string" } },
|
|
5710
|
+
{ name: "toolId", in: "path", required: true, schema: { type: "string" } }
|
|
5711
|
+
],
|
|
5712
|
+
requestBody: {
|
|
5713
|
+
required: true,
|
|
5714
|
+
content: {
|
|
5715
|
+
"application/json": {
|
|
5716
|
+
schema: {
|
|
5717
|
+
type: "object",
|
|
5718
|
+
properties: {
|
|
5719
|
+
data: { type: "object" },
|
|
5720
|
+
runtimeContext: { type: "object" }
|
|
5721
|
+
}
|
|
5722
|
+
}
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
// Simplified schema
|
|
5726
|
+
},
|
|
5727
|
+
responses: {
|
|
5728
|
+
200: { description: "Result of the tool execution." },
|
|
5729
|
+
400: { description: "Invalid tool arguments." },
|
|
5730
|
+
404: { description: "MCP server or tool not found." },
|
|
5731
|
+
501: { description: "Server does not support tool execution." }
|
|
5732
|
+
}
|
|
5733
|
+
}),
|
|
5734
|
+
executeMcpServerToolHandler
|
|
5735
|
+
);
|
|
5259
5736
|
app.get(
|
|
5260
5737
|
"/api/memory/status",
|
|
5261
5738
|
h({
|
|
@@ -5540,23 +6017,23 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5540
6017
|
storeTelemetryHandler
|
|
5541
6018
|
);
|
|
5542
6019
|
app.get(
|
|
5543
|
-
"/api/workflows/
|
|
6020
|
+
"/api/workflows/legacy",
|
|
5544
6021
|
h({
|
|
5545
|
-
description: "Get all
|
|
5546
|
-
tags: ["
|
|
6022
|
+
description: "Get all legacy workflows",
|
|
6023
|
+
tags: ["legacyWorkflows"],
|
|
5547
6024
|
responses: {
|
|
5548
6025
|
200: {
|
|
5549
|
-
description: "List of all
|
|
6026
|
+
description: "List of all legacy workflows"
|
|
5550
6027
|
}
|
|
5551
6028
|
}
|
|
5552
6029
|
}),
|
|
5553
|
-
|
|
6030
|
+
getLegacyWorkflowsHandler
|
|
5554
6031
|
);
|
|
5555
6032
|
app.get(
|
|
5556
|
-
"/api/workflows/
|
|
6033
|
+
"/api/workflows/legacy/:workflowId",
|
|
5557
6034
|
h({
|
|
5558
|
-
description: "Get
|
|
5559
|
-
tags: ["
|
|
6035
|
+
description: "Get legacy workflow by ID",
|
|
6036
|
+
tags: ["legacyWorkflows"],
|
|
5560
6037
|
parameters: [
|
|
5561
6038
|
{
|
|
5562
6039
|
name: "workflowId",
|
|
@@ -5567,20 +6044,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5567
6044
|
],
|
|
5568
6045
|
responses: {
|
|
5569
6046
|
200: {
|
|
5570
|
-
description: "
|
|
6047
|
+
description: "Legacy Workflow details"
|
|
5571
6048
|
},
|
|
5572
6049
|
404: {
|
|
5573
|
-
description: "
|
|
6050
|
+
description: "Legacy Workflow not found"
|
|
5574
6051
|
}
|
|
5575
6052
|
}
|
|
5576
6053
|
}),
|
|
5577
|
-
|
|
6054
|
+
getLegacyWorkflowByIdHandler
|
|
5578
6055
|
);
|
|
5579
6056
|
app.get(
|
|
5580
|
-
"/api/workflows/
|
|
6057
|
+
"/api/workflows/legacy/:workflowId/runs",
|
|
5581
6058
|
h({
|
|
5582
|
-
description: "Get all runs for a
|
|
5583
|
-
tags: ["
|
|
6059
|
+
description: "Get all runs for a legacy workflow",
|
|
6060
|
+
tags: ["legacyWorkflows"],
|
|
5584
6061
|
parameters: [
|
|
5585
6062
|
{
|
|
5586
6063
|
name: "workflowId",
|
|
@@ -5596,17 +6073,17 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5596
6073
|
],
|
|
5597
6074
|
responses: {
|
|
5598
6075
|
200: {
|
|
5599
|
-
description: "List of
|
|
6076
|
+
description: "List of legacy workflow runs from storage"
|
|
5600
6077
|
}
|
|
5601
6078
|
}
|
|
5602
6079
|
}),
|
|
5603
|
-
|
|
6080
|
+
getLegacyWorkflowRunsHandler
|
|
5604
6081
|
);
|
|
5605
6082
|
app.post(
|
|
5606
|
-
"/api/workflows/
|
|
6083
|
+
"/api/workflows/legacy/:workflowId/resume",
|
|
5607
6084
|
h({
|
|
5608
|
-
description: "Resume a suspended
|
|
5609
|
-
tags: ["
|
|
6085
|
+
description: "Resume a suspended legacy workflow step",
|
|
6086
|
+
tags: ["legacyWorkflows"],
|
|
5610
6087
|
parameters: [
|
|
5611
6088
|
{
|
|
5612
6089
|
name: "workflowId",
|
|
@@ -5628,29 +6105,22 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5628
6105
|
schema: {
|
|
5629
6106
|
type: "object",
|
|
5630
6107
|
properties: {
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
resumeData: { type: "object" },
|
|
5635
|
-
runtimeContext: {
|
|
5636
|
-
type: "object",
|
|
5637
|
-
description: "Runtime context for the workflow execution"
|
|
5638
|
-
}
|
|
5639
|
-
},
|
|
5640
|
-
required: ["step"]
|
|
6108
|
+
stepId: { type: "string" },
|
|
6109
|
+
context: { type: "object" }
|
|
6110
|
+
}
|
|
5641
6111
|
}
|
|
5642
6112
|
}
|
|
5643
6113
|
}
|
|
5644
6114
|
}
|
|
5645
6115
|
}),
|
|
5646
|
-
|
|
6116
|
+
resumeLegacyWorkflowHandler
|
|
5647
6117
|
);
|
|
5648
6118
|
app.post(
|
|
5649
|
-
"/api/workflows/
|
|
6119
|
+
"/api/workflows/legacy/:workflowId/resume-async",
|
|
5650
6120
|
bodyLimit(bodyLimitOptions),
|
|
5651
6121
|
h({
|
|
5652
|
-
description: "Resume a suspended
|
|
5653
|
-
tags: ["
|
|
6122
|
+
description: "Resume a suspended legacy workflow step",
|
|
6123
|
+
tags: ["legacyWorkflows"],
|
|
5654
6124
|
parameters: [
|
|
5655
6125
|
{
|
|
5656
6126
|
name: "workflowId",
|
|
@@ -5672,29 +6142,21 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5672
6142
|
schema: {
|
|
5673
6143
|
type: "object",
|
|
5674
6144
|
properties: {
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
resumeData: { type: "object" },
|
|
5679
|
-
runtimeContext: {
|
|
5680
|
-
type: "object",
|
|
5681
|
-
description: "Runtime context for the workflow execution"
|
|
5682
|
-
}
|
|
5683
|
-
},
|
|
5684
|
-
required: ["step"]
|
|
6145
|
+
stepId: { type: "string" },
|
|
6146
|
+
context: { type: "object" }
|
|
6147
|
+
}
|
|
5685
6148
|
}
|
|
5686
6149
|
}
|
|
5687
6150
|
}
|
|
5688
6151
|
}
|
|
5689
6152
|
}),
|
|
5690
|
-
|
|
6153
|
+
resumeAsyncLegacyWorkflowHandler
|
|
5691
6154
|
);
|
|
5692
6155
|
app.post(
|
|
5693
|
-
"/api/workflows/
|
|
5694
|
-
bodyLimit(bodyLimitOptions),
|
|
6156
|
+
"/api/workflows/legacy/:workflowId/create-run",
|
|
5695
6157
|
h({
|
|
5696
|
-
description: "Create a new
|
|
5697
|
-
tags: ["
|
|
6158
|
+
description: "Create a new legacy workflow run",
|
|
6159
|
+
tags: ["legacyWorkflows"],
|
|
5698
6160
|
parameters: [
|
|
5699
6161
|
{
|
|
5700
6162
|
name: "workflowId",
|
|
@@ -5711,18 +6173,18 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5711
6173
|
],
|
|
5712
6174
|
responses: {
|
|
5713
6175
|
200: {
|
|
5714
|
-
description: "New
|
|
6176
|
+
description: "New legacy workflow run created"
|
|
5715
6177
|
}
|
|
5716
6178
|
}
|
|
5717
6179
|
}),
|
|
5718
|
-
|
|
6180
|
+
createLegacyWorkflowRunHandler
|
|
5719
6181
|
);
|
|
5720
6182
|
app.post(
|
|
5721
|
-
"/api/workflows/
|
|
6183
|
+
"/api/workflows/legacy/:workflowId/start-async",
|
|
5722
6184
|
bodyLimit(bodyLimitOptions),
|
|
5723
6185
|
h({
|
|
5724
|
-
description: "Execute/Start a
|
|
5725
|
-
tags: ["
|
|
6186
|
+
description: "Execute/Start a legacy workflow",
|
|
6187
|
+
tags: ["legacyWorkflows"],
|
|
5726
6188
|
parameters: [
|
|
5727
6189
|
{
|
|
5728
6190
|
name: "workflowId",
|
|
@@ -5744,11 +6206,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5744
6206
|
schema: {
|
|
5745
6207
|
type: "object",
|
|
5746
6208
|
properties: {
|
|
5747
|
-
|
|
5748
|
-
runtimeContext: {
|
|
5749
|
-
type: "object",
|
|
5750
|
-
description: "Runtime context for the workflow execution"
|
|
5751
|
-
}
|
|
6209
|
+
input: { type: "object" }
|
|
5752
6210
|
}
|
|
5753
6211
|
}
|
|
5754
6212
|
}
|
|
@@ -5756,20 +6214,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5756
6214
|
},
|
|
5757
6215
|
responses: {
|
|
5758
6216
|
200: {
|
|
5759
|
-
description: "
|
|
6217
|
+
description: "Legacy Workflow execution result"
|
|
5760
6218
|
},
|
|
5761
6219
|
404: {
|
|
5762
|
-
description: "
|
|
6220
|
+
description: "Legacy Workflow not found"
|
|
5763
6221
|
}
|
|
5764
6222
|
}
|
|
5765
6223
|
}),
|
|
5766
|
-
|
|
6224
|
+
startAsyncLegacyWorkflowHandler
|
|
5767
6225
|
);
|
|
5768
6226
|
app.post(
|
|
5769
|
-
"/api/workflows/
|
|
6227
|
+
"/api/workflows/legacy/:workflowId/start",
|
|
5770
6228
|
h({
|
|
5771
|
-
description: "Create and start a new
|
|
5772
|
-
tags: ["
|
|
6229
|
+
description: "Create and start a new legacy workflow run",
|
|
6230
|
+
tags: ["legacyWorkflows"],
|
|
5773
6231
|
parameters: [
|
|
5774
6232
|
{
|
|
5775
6233
|
name: "workflowId",
|
|
@@ -5791,11 +6249,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5791
6249
|
schema: {
|
|
5792
6250
|
type: "object",
|
|
5793
6251
|
properties: {
|
|
5794
|
-
|
|
5795
|
-
runtimeContext: {
|
|
5796
|
-
type: "object",
|
|
5797
|
-
description: "Runtime context for the workflow execution"
|
|
5798
|
-
}
|
|
6252
|
+
input: { type: "object" }
|
|
5799
6253
|
}
|
|
5800
6254
|
}
|
|
5801
6255
|
}
|
|
@@ -5803,19 +6257,19 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5803
6257
|
},
|
|
5804
6258
|
responses: {
|
|
5805
6259
|
200: {
|
|
5806
|
-
description: "
|
|
6260
|
+
description: "Legacy Workflow run started"
|
|
5807
6261
|
},
|
|
5808
6262
|
404: {
|
|
5809
|
-
description: "
|
|
6263
|
+
description: "Legacy Workflow not found"
|
|
5810
6264
|
}
|
|
5811
6265
|
}
|
|
5812
6266
|
}),
|
|
5813
|
-
|
|
6267
|
+
startLegacyWorkflowRunHandler
|
|
5814
6268
|
);
|
|
5815
6269
|
app.get(
|
|
5816
|
-
"/api/workflows/
|
|
6270
|
+
"/api/workflows/legacy/:workflowId/watch",
|
|
5817
6271
|
h({
|
|
5818
|
-
description: "Watch
|
|
6272
|
+
description: "Watch legacy workflow transitions in real-time",
|
|
5819
6273
|
parameters: [
|
|
5820
6274
|
{
|
|
5821
6275
|
name: "workflowId",
|
|
@@ -5830,14 +6284,14 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5830
6284
|
schema: { type: "string" }
|
|
5831
6285
|
}
|
|
5832
6286
|
],
|
|
5833
|
-
tags: ["
|
|
6287
|
+
tags: ["legacyWorkflows"],
|
|
5834
6288
|
responses: {
|
|
5835
6289
|
200: {
|
|
5836
|
-
description: "
|
|
6290
|
+
description: "Legacy Workflow transitions in real-time"
|
|
5837
6291
|
}
|
|
5838
6292
|
}
|
|
5839
6293
|
}),
|
|
5840
|
-
|
|
6294
|
+
watchLegacyWorkflowHandler
|
|
5841
6295
|
);
|
|
5842
6296
|
app.get(
|
|
5843
6297
|
"/api/workflows",
|
|
@@ -5928,9 +6382,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5928
6382
|
schema: {
|
|
5929
6383
|
type: "object",
|
|
5930
6384
|
properties: {
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
6385
|
+
step: {
|
|
6386
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
6387
|
+
},
|
|
6388
|
+
resumeData: { type: "object" },
|
|
6389
|
+
runtimeContext: {
|
|
6390
|
+
type: "object",
|
|
6391
|
+
description: "Runtime context for the workflow execution"
|
|
6392
|
+
}
|
|
6393
|
+
},
|
|
6394
|
+
required: ["step"]
|
|
5934
6395
|
}
|
|
5935
6396
|
}
|
|
5936
6397
|
}
|
|
@@ -5938,43 +6399,6 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5938
6399
|
}),
|
|
5939
6400
|
resumeWorkflowHandler
|
|
5940
6401
|
);
|
|
5941
|
-
app.post(
|
|
5942
|
-
"/api/workflows/:workflowId/resumeAsync",
|
|
5943
|
-
bodyLimit(bodyLimitOptions),
|
|
5944
|
-
h({
|
|
5945
|
-
description: "@deprecated Use /api/workflows/:workflowId/resume-async instead",
|
|
5946
|
-
tags: ["workflows"],
|
|
5947
|
-
parameters: [
|
|
5948
|
-
{
|
|
5949
|
-
name: "workflowId",
|
|
5950
|
-
in: "path",
|
|
5951
|
-
required: true,
|
|
5952
|
-
schema: { type: "string" }
|
|
5953
|
-
},
|
|
5954
|
-
{
|
|
5955
|
-
name: "runId",
|
|
5956
|
-
in: "query",
|
|
5957
|
-
required: true,
|
|
5958
|
-
schema: { type: "string" }
|
|
5959
|
-
}
|
|
5960
|
-
],
|
|
5961
|
-
requestBody: {
|
|
5962
|
-
required: true,
|
|
5963
|
-
content: {
|
|
5964
|
-
"application/json": {
|
|
5965
|
-
schema: {
|
|
5966
|
-
type: "object",
|
|
5967
|
-
properties: {
|
|
5968
|
-
stepId: { type: "string" },
|
|
5969
|
-
context: { type: "object" }
|
|
5970
|
-
}
|
|
5971
|
-
}
|
|
5972
|
-
}
|
|
5973
|
-
}
|
|
5974
|
-
}
|
|
5975
|
-
}),
|
|
5976
|
-
resumeAsyncWorkflowHandler
|
|
5977
|
-
);
|
|
5978
6402
|
app.post(
|
|
5979
6403
|
"/api/workflows/:workflowId/resume-async",
|
|
5980
6404
|
bodyLimit(bodyLimitOptions),
|
|
@@ -6002,9 +6426,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6002
6426
|
schema: {
|
|
6003
6427
|
type: "object",
|
|
6004
6428
|
properties: {
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6429
|
+
step: {
|
|
6430
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
6431
|
+
},
|
|
6432
|
+
resumeData: { type: "object" },
|
|
6433
|
+
runtimeContext: {
|
|
6434
|
+
type: "object",
|
|
6435
|
+
description: "Runtime context for the workflow execution"
|
|
6436
|
+
}
|
|
6437
|
+
},
|
|
6438
|
+
required: ["step"]
|
|
6008
6439
|
}
|
|
6009
6440
|
}
|
|
6010
6441
|
}
|
|
@@ -6013,7 +6444,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6013
6444
|
resumeAsyncWorkflowHandler
|
|
6014
6445
|
);
|
|
6015
6446
|
app.post(
|
|
6016
|
-
"/api/workflows/:workflowId/
|
|
6447
|
+
"/api/workflows/:workflowId/create-run",
|
|
6448
|
+
bodyLimit(bodyLimitOptions),
|
|
6017
6449
|
h({
|
|
6018
6450
|
description: "Create a new workflow run",
|
|
6019
6451
|
tags: ["workflows"],
|
|
@@ -6037,51 +6469,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6037
6469
|
}
|
|
6038
6470
|
}
|
|
6039
6471
|
}),
|
|
6040
|
-
|
|
6041
|
-
);
|
|
6042
|
-
app.post(
|
|
6043
|
-
"/api/workflows/:workflowId/startAsync",
|
|
6044
|
-
bodyLimit(bodyLimitOptions),
|
|
6045
|
-
h({
|
|
6046
|
-
description: "@deprecated Use /api/workflows/:workflowId/start-async instead",
|
|
6047
|
-
tags: ["workflows"],
|
|
6048
|
-
parameters: [
|
|
6049
|
-
{
|
|
6050
|
-
name: "workflowId",
|
|
6051
|
-
in: "path",
|
|
6052
|
-
required: true,
|
|
6053
|
-
schema: { type: "string" }
|
|
6054
|
-
},
|
|
6055
|
-
{
|
|
6056
|
-
name: "runId",
|
|
6057
|
-
in: "query",
|
|
6058
|
-
required: false,
|
|
6059
|
-
schema: { type: "string" }
|
|
6060
|
-
}
|
|
6061
|
-
],
|
|
6062
|
-
requestBody: {
|
|
6063
|
-
required: true,
|
|
6064
|
-
content: {
|
|
6065
|
-
"application/json": {
|
|
6066
|
-
schema: {
|
|
6067
|
-
type: "object",
|
|
6068
|
-
properties: {
|
|
6069
|
-
input: { type: "object" }
|
|
6070
|
-
}
|
|
6071
|
-
}
|
|
6072
|
-
}
|
|
6073
|
-
}
|
|
6074
|
-
},
|
|
6075
|
-
responses: {
|
|
6076
|
-
200: {
|
|
6077
|
-
description: "Workflow execution result"
|
|
6078
|
-
},
|
|
6079
|
-
404: {
|
|
6080
|
-
description: "Workflow not found"
|
|
6081
|
-
}
|
|
6082
|
-
}
|
|
6083
|
-
}),
|
|
6084
|
-
startAsyncWorkflowHandler
|
|
6472
|
+
createWorkflowRunHandler
|
|
6085
6473
|
);
|
|
6086
6474
|
app.post(
|
|
6087
6475
|
"/api/workflows/:workflowId/start-async",
|
|
@@ -6110,7 +6498,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6110
6498
|
schema: {
|
|
6111
6499
|
type: "object",
|
|
6112
6500
|
properties: {
|
|
6113
|
-
|
|
6501
|
+
inputData: { type: "object" },
|
|
6502
|
+
runtimeContext: {
|
|
6503
|
+
type: "object",
|
|
6504
|
+
description: "Runtime context for the workflow execution"
|
|
6505
|
+
}
|
|
6114
6506
|
}
|
|
6115
6507
|
}
|
|
6116
6508
|
}
|
|
@@ -6118,10 +6510,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6118
6510
|
},
|
|
6119
6511
|
responses: {
|
|
6120
6512
|
200: {
|
|
6121
|
-
description: "
|
|
6513
|
+
description: "workflow execution result"
|
|
6122
6514
|
},
|
|
6123
6515
|
404: {
|
|
6124
|
-
description: "
|
|
6516
|
+
description: "workflow not found"
|
|
6125
6517
|
}
|
|
6126
6518
|
}
|
|
6127
6519
|
}),
|
|
@@ -6153,7 +6545,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6153
6545
|
schema: {
|
|
6154
6546
|
type: "object",
|
|
6155
6547
|
properties: {
|
|
6156
|
-
|
|
6548
|
+
inputData: { type: "object" },
|
|
6549
|
+
runtimeContext: {
|
|
6550
|
+
type: "object",
|
|
6551
|
+
description: "Runtime context for the workflow execution"
|
|
6552
|
+
}
|
|
6157
6553
|
}
|
|
6158
6554
|
}
|
|
6159
6555
|
}
|
|
@@ -6161,10 +6557,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6161
6557
|
},
|
|
6162
6558
|
responses: {
|
|
6163
6559
|
200: {
|
|
6164
|
-
description: "
|
|
6560
|
+
description: "workflow run started"
|
|
6165
6561
|
},
|
|
6166
6562
|
404: {
|
|
6167
|
-
description: "
|
|
6563
|
+
description: "workflow not found"
|
|
6168
6564
|
}
|
|
6169
6565
|
}
|
|
6170
6566
|
}),
|
|
@@ -6191,7 +6587,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6191
6587
|
tags: ["workflows"],
|
|
6192
6588
|
responses: {
|
|
6193
6589
|
200: {
|
|
6194
|
-
description: "
|
|
6590
|
+
description: "workflow transitions in real-time"
|
|
6195
6591
|
}
|
|
6196
6592
|
}
|
|
6197
6593
|
}),
|
|
@@ -6609,7 +7005,7 @@ async function createNodeServer(mastra, options = {}) {
|
|
|
6609
7005
|
{
|
|
6610
7006
|
fetch: app.fetch,
|
|
6611
7007
|
port,
|
|
6612
|
-
hostname: serverOptions?.host
|
|
7008
|
+
hostname: serverOptions?.host
|
|
6613
7009
|
},
|
|
6614
7010
|
() => {
|
|
6615
7011
|
const logger2 = mastra.getLogger();
|