@mastra/deployer 0.3.5-alpha.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.cts +46 -22
- package/dist/_tsup-dts-rollup.d.ts +46 -22
- package/dist/server/index.cjs +499 -397
- package/dist/server/index.js +500 -398
- package/dist/templates/instrumentation-template.js +5 -2
- package/package.json +8 -5
package/dist/server/index.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");
|
|
@@ -3659,217 +4018,37 @@ async function deleteIndex(c2) {
|
|
|
3659
4018
|
return handleError(error, "Error deleting index");
|
|
3660
4019
|
}
|
|
3661
4020
|
}
|
|
3662
|
-
async function
|
|
4021
|
+
async function getSpeakersHandler(c2) {
|
|
3663
4022
|
try {
|
|
3664
4023
|
const mastra = c2.get("mastra");
|
|
3665
|
-
const
|
|
3666
|
-
|
|
4024
|
+
const agentId = c2.req.param("agentId");
|
|
4025
|
+
const speakers = await getSpeakersHandler$1({
|
|
4026
|
+
mastra,
|
|
4027
|
+
agentId
|
|
3667
4028
|
});
|
|
3668
|
-
return c2.json(
|
|
4029
|
+
return c2.json(speakers);
|
|
3669
4030
|
} catch (error) {
|
|
3670
|
-
return handleError(error, "Error getting
|
|
4031
|
+
return handleError(error, "Error getting speakers");
|
|
3671
4032
|
}
|
|
3672
4033
|
}
|
|
3673
|
-
async function
|
|
4034
|
+
async function speakHandler(c2) {
|
|
3674
4035
|
try {
|
|
3675
4036
|
const mastra = c2.get("mastra");
|
|
3676
|
-
const
|
|
3677
|
-
const
|
|
4037
|
+
const agentId = c2.req.param("agentId");
|
|
4038
|
+
const { input, options } = await c2.req.json();
|
|
4039
|
+
const audioStream = await generateSpeechHandler({
|
|
3678
4040
|
mastra,
|
|
3679
|
-
|
|
4041
|
+
agentId,
|
|
4042
|
+
body: { text: input, speakerId: options?.speakerId }
|
|
3680
4043
|
});
|
|
3681
|
-
|
|
4044
|
+
c2.header("Content-Type", `audio/${options?.filetype ?? "mp3"}`);
|
|
4045
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4046
|
+
return c2.body(audioStream);
|
|
3682
4047
|
} catch (error) {
|
|
3683
|
-
return handleError(error, "Error
|
|
4048
|
+
return handleError(error, "Error generating speech");
|
|
3684
4049
|
}
|
|
3685
4050
|
}
|
|
3686
|
-
async function
|
|
3687
|
-
try {
|
|
3688
|
-
const mastra = c2.get("mastra");
|
|
3689
|
-
const workflowId = c2.req.param("workflowId");
|
|
3690
|
-
const prevRunId = c2.req.query("runId");
|
|
3691
|
-
const result = await createVNextWorkflowRunHandler$1({
|
|
3692
|
-
mastra,
|
|
3693
|
-
workflowId,
|
|
3694
|
-
runId: prevRunId
|
|
3695
|
-
});
|
|
3696
|
-
return c2.json(result);
|
|
3697
|
-
} catch (e2) {
|
|
3698
|
-
return handleError(e2, "Error creating run");
|
|
3699
|
-
}
|
|
3700
|
-
}
|
|
3701
|
-
async function startAsyncVNextWorkflowHandler(c2) {
|
|
3702
|
-
try {
|
|
3703
|
-
const mastra = c2.get("mastra");
|
|
3704
|
-
const workflowId = c2.req.param("workflowId");
|
|
3705
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3706
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3707
|
-
const runId = c2.req.query("runId");
|
|
3708
|
-
const result = await startAsyncVNextWorkflowHandler$1({
|
|
3709
|
-
mastra,
|
|
3710
|
-
runtimeContext,
|
|
3711
|
-
runtimeContextFromRequest,
|
|
3712
|
-
workflowId,
|
|
3713
|
-
runId,
|
|
3714
|
-
inputData
|
|
3715
|
-
});
|
|
3716
|
-
return c2.json(result);
|
|
3717
|
-
} catch (error) {
|
|
3718
|
-
return handleError(error, "Error executing workflow");
|
|
3719
|
-
}
|
|
3720
|
-
}
|
|
3721
|
-
async function startVNextWorkflowRunHandler(c2) {
|
|
3722
|
-
try {
|
|
3723
|
-
const mastra = c2.get("mastra");
|
|
3724
|
-
const workflowId = c2.req.param("workflowId");
|
|
3725
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3726
|
-
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3727
|
-
const runId = c2.req.query("runId");
|
|
3728
|
-
await startVNextWorkflowRunHandler$1({
|
|
3729
|
-
mastra,
|
|
3730
|
-
runtimeContext,
|
|
3731
|
-
runtimeContextFromRequest,
|
|
3732
|
-
workflowId,
|
|
3733
|
-
runId,
|
|
3734
|
-
inputData
|
|
3735
|
-
});
|
|
3736
|
-
return c2.json({ message: "Workflow run started" });
|
|
3737
|
-
} catch (e2) {
|
|
3738
|
-
return handleError(e2, "Error starting workflow run");
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
function watchVNextWorkflowHandler(c2) {
|
|
3742
|
-
try {
|
|
3743
|
-
const mastra = c2.get("mastra");
|
|
3744
|
-
const logger2 = mastra.getLogger();
|
|
3745
|
-
const workflowId = c2.req.param("workflowId");
|
|
3746
|
-
const runId = c2.req.query("runId");
|
|
3747
|
-
if (!runId) {
|
|
3748
|
-
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
3749
|
-
}
|
|
3750
|
-
return stream(
|
|
3751
|
-
c2,
|
|
3752
|
-
async (stream4) => {
|
|
3753
|
-
try {
|
|
3754
|
-
const result = await watchVNextWorkflowHandler$1({
|
|
3755
|
-
mastra,
|
|
3756
|
-
workflowId,
|
|
3757
|
-
runId
|
|
3758
|
-
});
|
|
3759
|
-
stream4.onAbort(() => {
|
|
3760
|
-
if (!result.locked) {
|
|
3761
|
-
return result.cancel();
|
|
3762
|
-
}
|
|
3763
|
-
});
|
|
3764
|
-
for await (const chunk of result) {
|
|
3765
|
-
await stream4.write(chunk.toString() + "");
|
|
3766
|
-
}
|
|
3767
|
-
} catch (err) {
|
|
3768
|
-
console.log(err);
|
|
3769
|
-
}
|
|
3770
|
-
},
|
|
3771
|
-
async (err) => {
|
|
3772
|
-
logger2.error("Error in watch stream: " + err?.message);
|
|
3773
|
-
}
|
|
3774
|
-
);
|
|
3775
|
-
} catch (error) {
|
|
3776
|
-
return handleError(error, "Error watching workflow");
|
|
3777
|
-
}
|
|
3778
|
-
}
|
|
3779
|
-
async function resumeAsyncVNextWorkflowHandler(c2) {
|
|
3780
|
-
try {
|
|
3781
|
-
const mastra = c2.get("mastra");
|
|
3782
|
-
const workflowId = c2.req.param("workflowId");
|
|
3783
|
-
const runId = c2.req.query("runId");
|
|
3784
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3785
|
-
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3786
|
-
if (!runId) {
|
|
3787
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
3788
|
-
}
|
|
3789
|
-
const result = await resumeAsyncVNextWorkflowHandler$1({
|
|
3790
|
-
mastra,
|
|
3791
|
-
runtimeContext,
|
|
3792
|
-
runtimeContextFromRequest,
|
|
3793
|
-
workflowId,
|
|
3794
|
-
runId,
|
|
3795
|
-
body: { step, resumeData }
|
|
3796
|
-
});
|
|
3797
|
-
return c2.json(result);
|
|
3798
|
-
} catch (error) {
|
|
3799
|
-
return handleError(error, "Error resuming workflow step");
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
async function resumeVNextWorkflowHandler(c2) {
|
|
3803
|
-
try {
|
|
3804
|
-
const mastra = c2.get("mastra");
|
|
3805
|
-
const workflowId = c2.req.param("workflowId");
|
|
3806
|
-
const runId = c2.req.query("runId");
|
|
3807
|
-
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
3808
|
-
if (!runId) {
|
|
3809
|
-
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
3810
|
-
}
|
|
3811
|
-
await resumeVNextWorkflowHandler$1({
|
|
3812
|
-
mastra,
|
|
3813
|
-
runtimeContext,
|
|
3814
|
-
workflowId,
|
|
3815
|
-
runId,
|
|
3816
|
-
body: { step, resumeData }
|
|
3817
|
-
});
|
|
3818
|
-
return c2.json({ message: "Workflow run resumed" });
|
|
3819
|
-
} catch (error) {
|
|
3820
|
-
return handleError(error, "Error resuming workflow");
|
|
3821
|
-
}
|
|
3822
|
-
}
|
|
3823
|
-
async function getVNextWorkflowRunsHandler(c2) {
|
|
3824
|
-
try {
|
|
3825
|
-
const mastra = c2.get("mastra");
|
|
3826
|
-
const workflowId = c2.req.param("workflowId");
|
|
3827
|
-
const { fromDate, toDate, limit, offset, resourceId } = c2.req.query();
|
|
3828
|
-
const workflowRuns = await getVNextWorkflowRunsHandler$1({
|
|
3829
|
-
mastra,
|
|
3830
|
-
workflowId,
|
|
3831
|
-
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
3832
|
-
toDate: toDate ? new Date(toDate) : void 0,
|
|
3833
|
-
limit: limit ? Number(limit) : void 0,
|
|
3834
|
-
offset: offset ? Number(offset) : void 0,
|
|
3835
|
-
resourceId
|
|
3836
|
-
});
|
|
3837
|
-
return c2.json(workflowRuns);
|
|
3838
|
-
} catch (error) {
|
|
3839
|
-
return handleError(error, "Error getting workflow runs");
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
async function getSpeakersHandler(c2) {
|
|
3843
|
-
try {
|
|
3844
|
-
const mastra = c2.get("mastra");
|
|
3845
|
-
const agentId = c2.req.param("agentId");
|
|
3846
|
-
const speakers = await getSpeakersHandler$1({
|
|
3847
|
-
mastra,
|
|
3848
|
-
agentId
|
|
3849
|
-
});
|
|
3850
|
-
return c2.json(speakers);
|
|
3851
|
-
} catch (error) {
|
|
3852
|
-
return handleError(error, "Error getting speakers");
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
async function speakHandler(c2) {
|
|
3856
|
-
try {
|
|
3857
|
-
const mastra = c2.get("mastra");
|
|
3858
|
-
const agentId = c2.req.param("agentId");
|
|
3859
|
-
const { input, options } = await c2.req.json();
|
|
3860
|
-
const audioStream = await generateSpeechHandler({
|
|
3861
|
-
mastra,
|
|
3862
|
-
agentId,
|
|
3863
|
-
body: { text: input, speakerId: options?.speakerId }
|
|
3864
|
-
});
|
|
3865
|
-
c2.header("Content-Type", `audio/${options?.filetype ?? "mp3"}`);
|
|
3866
|
-
c2.header("Transfer-Encoding", "chunked");
|
|
3867
|
-
return c2.body(audioStream);
|
|
3868
|
-
} catch (error) {
|
|
3869
|
-
return handleError(error, "Error generating speech");
|
|
3870
|
-
}
|
|
3871
|
-
}
|
|
3872
|
-
async function listenHandler(c2) {
|
|
4051
|
+
async function listenHandler(c2) {
|
|
3873
4052
|
try {
|
|
3874
4053
|
const mastra = c2.get("mastra");
|
|
3875
4054
|
const agentId = c2.req.param("agentId");
|
|
@@ -3922,53 +4101,55 @@ async function getWorkflowByIdHandler(c2) {
|
|
|
3922
4101
|
return handleError(error, "Error getting workflow");
|
|
3923
4102
|
}
|
|
3924
4103
|
}
|
|
3925
|
-
async function
|
|
4104
|
+
async function createWorkflowRunHandler(c2) {
|
|
3926
4105
|
try {
|
|
3927
4106
|
const mastra = c2.get("mastra");
|
|
3928
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3929
4107
|
const workflowId = c2.req.param("workflowId");
|
|
3930
|
-
const
|
|
3931
|
-
const
|
|
3932
|
-
const result = await startAsyncWorkflowHandler$1({
|
|
4108
|
+
const prevRunId = c2.req.query("runId");
|
|
4109
|
+
const result = await createWorkflowRunHandler$1({
|
|
3933
4110
|
mastra,
|
|
3934
|
-
runtimeContext,
|
|
3935
4111
|
workflowId,
|
|
3936
|
-
runId
|
|
3937
|
-
triggerData
|
|
4112
|
+
runId: prevRunId
|
|
3938
4113
|
});
|
|
3939
4114
|
return c2.json(result);
|
|
3940
|
-
} catch (
|
|
3941
|
-
return handleError(
|
|
4115
|
+
} catch (e2) {
|
|
4116
|
+
return handleError(e2, "Error creating run");
|
|
3942
4117
|
}
|
|
3943
4118
|
}
|
|
3944
|
-
async function
|
|
4119
|
+
async function startAsyncWorkflowHandler(c2) {
|
|
3945
4120
|
try {
|
|
3946
4121
|
const mastra = c2.get("mastra");
|
|
3947
4122
|
const workflowId = c2.req.param("workflowId");
|
|
3948
|
-
const
|
|
3949
|
-
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({
|
|
3950
4127
|
mastra,
|
|
4128
|
+
runtimeContext,
|
|
4129
|
+
runtimeContextFromRequest,
|
|
3951
4130
|
workflowId,
|
|
3952
|
-
runId
|
|
4131
|
+
runId,
|
|
4132
|
+
inputData
|
|
3953
4133
|
});
|
|
3954
4134
|
return c2.json(result);
|
|
3955
|
-
} catch (
|
|
3956
|
-
return handleError(
|
|
4135
|
+
} catch (error) {
|
|
4136
|
+
return handleError(error, "Error executing workflow");
|
|
3957
4137
|
}
|
|
3958
4138
|
}
|
|
3959
4139
|
async function startWorkflowRunHandler(c2) {
|
|
3960
4140
|
try {
|
|
3961
4141
|
const mastra = c2.get("mastra");
|
|
3962
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
3963
4142
|
const workflowId = c2.req.param("workflowId");
|
|
3964
|
-
const
|
|
4143
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4144
|
+
const { inputData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
3965
4145
|
const runId = c2.req.query("runId");
|
|
3966
4146
|
await startWorkflowRunHandler$1({
|
|
3967
4147
|
mastra,
|
|
3968
4148
|
runtimeContext,
|
|
4149
|
+
runtimeContextFromRequest,
|
|
3969
4150
|
workflowId,
|
|
3970
4151
|
runId,
|
|
3971
|
-
|
|
4152
|
+
inputData
|
|
3972
4153
|
});
|
|
3973
4154
|
return c2.json({ message: "Workflow run started" });
|
|
3974
4155
|
} catch (e2) {
|
|
@@ -4016,19 +4197,20 @@ function watchWorkflowHandler(c2) {
|
|
|
4016
4197
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
4017
4198
|
try {
|
|
4018
4199
|
const mastra = c2.get("mastra");
|
|
4019
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
4020
4200
|
const workflowId = c2.req.param("workflowId");
|
|
4021
4201
|
const runId = c2.req.query("runId");
|
|
4022
|
-
const
|
|
4202
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4203
|
+
const { step, resumeData, runtimeContext: runtimeContextFromRequest } = await c2.req.json();
|
|
4023
4204
|
if (!runId) {
|
|
4024
4205
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
4025
4206
|
}
|
|
4026
4207
|
const result = await resumeAsyncWorkflowHandler$1({
|
|
4027
4208
|
mastra,
|
|
4028
4209
|
runtimeContext,
|
|
4210
|
+
runtimeContextFromRequest,
|
|
4029
4211
|
workflowId,
|
|
4030
4212
|
runId,
|
|
4031
|
-
body: {
|
|
4213
|
+
body: { step, resumeData }
|
|
4032
4214
|
});
|
|
4033
4215
|
return c2.json(result);
|
|
4034
4216
|
} catch (error) {
|
|
@@ -4038,10 +4220,9 @@ async function resumeAsyncWorkflowHandler(c2) {
|
|
|
4038
4220
|
async function resumeWorkflowHandler(c2) {
|
|
4039
4221
|
try {
|
|
4040
4222
|
const mastra = c2.get("mastra");
|
|
4041
|
-
const runtimeContext = c2.get("runtimeContext");
|
|
4042
4223
|
const workflowId = c2.req.param("workflowId");
|
|
4043
4224
|
const runId = c2.req.query("runId");
|
|
4044
|
-
const {
|
|
4225
|
+
const { step, resumeData, runtimeContext } = await c2.req.json();
|
|
4045
4226
|
if (!runId) {
|
|
4046
4227
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
4047
4228
|
}
|
|
@@ -4050,7 +4231,7 @@ async function resumeWorkflowHandler(c2) {
|
|
|
4050
4231
|
runtimeContext,
|
|
4051
4232
|
workflowId,
|
|
4052
4233
|
runId,
|
|
4053
|
-
body: {
|
|
4234
|
+
body: { step, resumeData }
|
|
4054
4235
|
});
|
|
4055
4236
|
return c2.json({ message: "Workflow run resumed" });
|
|
4056
4237
|
} catch (error) {
|
|
@@ -4267,6 +4448,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
4267
4448
|
};
|
|
4268
4449
|
app.use("*", timeout(server?.timeout ?? 3 * 60 * 1e3), cors(corsConfig));
|
|
4269
4450
|
}
|
|
4451
|
+
app.use("*", authenticationMiddleware);
|
|
4452
|
+
app.use("*", authorizationMiddleware);
|
|
4270
4453
|
const bodyLimitOptions = {
|
|
4271
4454
|
maxSize: server?.bodySizeLimit ?? 4.5 * 1024 * 1024,
|
|
4272
4455
|
// 4.5 MB,
|
|
@@ -5834,23 +6017,23 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5834
6017
|
storeTelemetryHandler
|
|
5835
6018
|
);
|
|
5836
6019
|
app.get(
|
|
5837
|
-
"/api/workflows/
|
|
6020
|
+
"/api/workflows/legacy",
|
|
5838
6021
|
h({
|
|
5839
|
-
description: "Get all
|
|
5840
|
-
tags: ["
|
|
6022
|
+
description: "Get all legacy workflows",
|
|
6023
|
+
tags: ["legacyWorkflows"],
|
|
5841
6024
|
responses: {
|
|
5842
6025
|
200: {
|
|
5843
|
-
description: "List of all
|
|
6026
|
+
description: "List of all legacy workflows"
|
|
5844
6027
|
}
|
|
5845
6028
|
}
|
|
5846
6029
|
}),
|
|
5847
|
-
|
|
6030
|
+
getLegacyWorkflowsHandler
|
|
5848
6031
|
);
|
|
5849
6032
|
app.get(
|
|
5850
|
-
"/api/workflows/
|
|
6033
|
+
"/api/workflows/legacy/:workflowId",
|
|
5851
6034
|
h({
|
|
5852
|
-
description: "Get
|
|
5853
|
-
tags: ["
|
|
6035
|
+
description: "Get legacy workflow by ID",
|
|
6036
|
+
tags: ["legacyWorkflows"],
|
|
5854
6037
|
parameters: [
|
|
5855
6038
|
{
|
|
5856
6039
|
name: "workflowId",
|
|
@@ -5861,20 +6044,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5861
6044
|
],
|
|
5862
6045
|
responses: {
|
|
5863
6046
|
200: {
|
|
5864
|
-
description: "
|
|
6047
|
+
description: "Legacy Workflow details"
|
|
5865
6048
|
},
|
|
5866
6049
|
404: {
|
|
5867
|
-
description: "
|
|
6050
|
+
description: "Legacy Workflow not found"
|
|
5868
6051
|
}
|
|
5869
6052
|
}
|
|
5870
6053
|
}),
|
|
5871
|
-
|
|
6054
|
+
getLegacyWorkflowByIdHandler
|
|
5872
6055
|
);
|
|
5873
6056
|
app.get(
|
|
5874
|
-
"/api/workflows/
|
|
6057
|
+
"/api/workflows/legacy/:workflowId/runs",
|
|
5875
6058
|
h({
|
|
5876
|
-
description: "Get all runs for a
|
|
5877
|
-
tags: ["
|
|
6059
|
+
description: "Get all runs for a legacy workflow",
|
|
6060
|
+
tags: ["legacyWorkflows"],
|
|
5878
6061
|
parameters: [
|
|
5879
6062
|
{
|
|
5880
6063
|
name: "workflowId",
|
|
@@ -5890,17 +6073,17 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5890
6073
|
],
|
|
5891
6074
|
responses: {
|
|
5892
6075
|
200: {
|
|
5893
|
-
description: "List of
|
|
6076
|
+
description: "List of legacy workflow runs from storage"
|
|
5894
6077
|
}
|
|
5895
6078
|
}
|
|
5896
6079
|
}),
|
|
5897
|
-
|
|
6080
|
+
getLegacyWorkflowRunsHandler
|
|
5898
6081
|
);
|
|
5899
6082
|
app.post(
|
|
5900
|
-
"/api/workflows/
|
|
6083
|
+
"/api/workflows/legacy/:workflowId/resume",
|
|
5901
6084
|
h({
|
|
5902
|
-
description: "Resume a suspended
|
|
5903
|
-
tags: ["
|
|
6085
|
+
description: "Resume a suspended legacy workflow step",
|
|
6086
|
+
tags: ["legacyWorkflows"],
|
|
5904
6087
|
parameters: [
|
|
5905
6088
|
{
|
|
5906
6089
|
name: "workflowId",
|
|
@@ -5922,29 +6105,22 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5922
6105
|
schema: {
|
|
5923
6106
|
type: "object",
|
|
5924
6107
|
properties: {
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
resumeData: { type: "object" },
|
|
5929
|
-
runtimeContext: {
|
|
5930
|
-
type: "object",
|
|
5931
|
-
description: "Runtime context for the workflow execution"
|
|
5932
|
-
}
|
|
5933
|
-
},
|
|
5934
|
-
required: ["step"]
|
|
6108
|
+
stepId: { type: "string" },
|
|
6109
|
+
context: { type: "object" }
|
|
6110
|
+
}
|
|
5935
6111
|
}
|
|
5936
6112
|
}
|
|
5937
6113
|
}
|
|
5938
6114
|
}
|
|
5939
6115
|
}),
|
|
5940
|
-
|
|
6116
|
+
resumeLegacyWorkflowHandler
|
|
5941
6117
|
);
|
|
5942
6118
|
app.post(
|
|
5943
|
-
"/api/workflows/
|
|
6119
|
+
"/api/workflows/legacy/:workflowId/resume-async",
|
|
5944
6120
|
bodyLimit(bodyLimitOptions),
|
|
5945
6121
|
h({
|
|
5946
|
-
description: "Resume a suspended
|
|
5947
|
-
tags: ["
|
|
6122
|
+
description: "Resume a suspended legacy workflow step",
|
|
6123
|
+
tags: ["legacyWorkflows"],
|
|
5948
6124
|
parameters: [
|
|
5949
6125
|
{
|
|
5950
6126
|
name: "workflowId",
|
|
@@ -5966,29 +6142,21 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
5966
6142
|
schema: {
|
|
5967
6143
|
type: "object",
|
|
5968
6144
|
properties: {
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
resumeData: { type: "object" },
|
|
5973
|
-
runtimeContext: {
|
|
5974
|
-
type: "object",
|
|
5975
|
-
description: "Runtime context for the workflow execution"
|
|
5976
|
-
}
|
|
5977
|
-
},
|
|
5978
|
-
required: ["step"]
|
|
6145
|
+
stepId: { type: "string" },
|
|
6146
|
+
context: { type: "object" }
|
|
6147
|
+
}
|
|
5979
6148
|
}
|
|
5980
6149
|
}
|
|
5981
6150
|
}
|
|
5982
6151
|
}
|
|
5983
6152
|
}),
|
|
5984
|
-
|
|
6153
|
+
resumeAsyncLegacyWorkflowHandler
|
|
5985
6154
|
);
|
|
5986
6155
|
app.post(
|
|
5987
|
-
"/api/workflows/
|
|
5988
|
-
bodyLimit(bodyLimitOptions),
|
|
6156
|
+
"/api/workflows/legacy/:workflowId/create-run",
|
|
5989
6157
|
h({
|
|
5990
|
-
description: "Create a new
|
|
5991
|
-
tags: ["
|
|
6158
|
+
description: "Create a new legacy workflow run",
|
|
6159
|
+
tags: ["legacyWorkflows"],
|
|
5992
6160
|
parameters: [
|
|
5993
6161
|
{
|
|
5994
6162
|
name: "workflowId",
|
|
@@ -6005,18 +6173,18 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6005
6173
|
],
|
|
6006
6174
|
responses: {
|
|
6007
6175
|
200: {
|
|
6008
|
-
description: "New
|
|
6176
|
+
description: "New legacy workflow run created"
|
|
6009
6177
|
}
|
|
6010
6178
|
}
|
|
6011
6179
|
}),
|
|
6012
|
-
|
|
6180
|
+
createLegacyWorkflowRunHandler
|
|
6013
6181
|
);
|
|
6014
6182
|
app.post(
|
|
6015
|
-
"/api/workflows/
|
|
6183
|
+
"/api/workflows/legacy/:workflowId/start-async",
|
|
6016
6184
|
bodyLimit(bodyLimitOptions),
|
|
6017
6185
|
h({
|
|
6018
|
-
description: "Execute/Start a
|
|
6019
|
-
tags: ["
|
|
6186
|
+
description: "Execute/Start a legacy workflow",
|
|
6187
|
+
tags: ["legacyWorkflows"],
|
|
6020
6188
|
parameters: [
|
|
6021
6189
|
{
|
|
6022
6190
|
name: "workflowId",
|
|
@@ -6038,11 +6206,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6038
6206
|
schema: {
|
|
6039
6207
|
type: "object",
|
|
6040
6208
|
properties: {
|
|
6041
|
-
|
|
6042
|
-
runtimeContext: {
|
|
6043
|
-
type: "object",
|
|
6044
|
-
description: "Runtime context for the workflow execution"
|
|
6045
|
-
}
|
|
6209
|
+
input: { type: "object" }
|
|
6046
6210
|
}
|
|
6047
6211
|
}
|
|
6048
6212
|
}
|
|
@@ -6050,20 +6214,20 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6050
6214
|
},
|
|
6051
6215
|
responses: {
|
|
6052
6216
|
200: {
|
|
6053
|
-
description: "
|
|
6217
|
+
description: "Legacy Workflow execution result"
|
|
6054
6218
|
},
|
|
6055
6219
|
404: {
|
|
6056
|
-
description: "
|
|
6220
|
+
description: "Legacy Workflow not found"
|
|
6057
6221
|
}
|
|
6058
6222
|
}
|
|
6059
6223
|
}),
|
|
6060
|
-
|
|
6224
|
+
startAsyncLegacyWorkflowHandler
|
|
6061
6225
|
);
|
|
6062
6226
|
app.post(
|
|
6063
|
-
"/api/workflows/
|
|
6227
|
+
"/api/workflows/legacy/:workflowId/start",
|
|
6064
6228
|
h({
|
|
6065
|
-
description: "Create and start a new
|
|
6066
|
-
tags: ["
|
|
6229
|
+
description: "Create and start a new legacy workflow run",
|
|
6230
|
+
tags: ["legacyWorkflows"],
|
|
6067
6231
|
parameters: [
|
|
6068
6232
|
{
|
|
6069
6233
|
name: "workflowId",
|
|
@@ -6085,11 +6249,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6085
6249
|
schema: {
|
|
6086
6250
|
type: "object",
|
|
6087
6251
|
properties: {
|
|
6088
|
-
|
|
6089
|
-
runtimeContext: {
|
|
6090
|
-
type: "object",
|
|
6091
|
-
description: "Runtime context for the workflow execution"
|
|
6092
|
-
}
|
|
6252
|
+
input: { type: "object" }
|
|
6093
6253
|
}
|
|
6094
6254
|
}
|
|
6095
6255
|
}
|
|
@@ -6097,19 +6257,19 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6097
6257
|
},
|
|
6098
6258
|
responses: {
|
|
6099
6259
|
200: {
|
|
6100
|
-
description: "
|
|
6260
|
+
description: "Legacy Workflow run started"
|
|
6101
6261
|
},
|
|
6102
6262
|
404: {
|
|
6103
|
-
description: "
|
|
6263
|
+
description: "Legacy Workflow not found"
|
|
6104
6264
|
}
|
|
6105
6265
|
}
|
|
6106
6266
|
}),
|
|
6107
|
-
|
|
6267
|
+
startLegacyWorkflowRunHandler
|
|
6108
6268
|
);
|
|
6109
6269
|
app.get(
|
|
6110
|
-
"/api/workflows/
|
|
6270
|
+
"/api/workflows/legacy/:workflowId/watch",
|
|
6111
6271
|
h({
|
|
6112
|
-
description: "Watch
|
|
6272
|
+
description: "Watch legacy workflow transitions in real-time",
|
|
6113
6273
|
parameters: [
|
|
6114
6274
|
{
|
|
6115
6275
|
name: "workflowId",
|
|
@@ -6124,14 +6284,14 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6124
6284
|
schema: { type: "string" }
|
|
6125
6285
|
}
|
|
6126
6286
|
],
|
|
6127
|
-
tags: ["
|
|
6287
|
+
tags: ["legacyWorkflows"],
|
|
6128
6288
|
responses: {
|
|
6129
6289
|
200: {
|
|
6130
|
-
description: "
|
|
6290
|
+
description: "Legacy Workflow transitions in real-time"
|
|
6131
6291
|
}
|
|
6132
6292
|
}
|
|
6133
6293
|
}),
|
|
6134
|
-
|
|
6294
|
+
watchLegacyWorkflowHandler
|
|
6135
6295
|
);
|
|
6136
6296
|
app.get(
|
|
6137
6297
|
"/api/workflows",
|
|
@@ -6222,9 +6382,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6222
6382
|
schema: {
|
|
6223
6383
|
type: "object",
|
|
6224
6384
|
properties: {
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
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"]
|
|
6228
6395
|
}
|
|
6229
6396
|
}
|
|
6230
6397
|
}
|
|
@@ -6232,43 +6399,6 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6232
6399
|
}),
|
|
6233
6400
|
resumeWorkflowHandler
|
|
6234
6401
|
);
|
|
6235
|
-
app.post(
|
|
6236
|
-
"/api/workflows/:workflowId/resumeAsync",
|
|
6237
|
-
bodyLimit(bodyLimitOptions),
|
|
6238
|
-
h({
|
|
6239
|
-
description: "@deprecated Use /api/workflows/:workflowId/resume-async instead",
|
|
6240
|
-
tags: ["workflows"],
|
|
6241
|
-
parameters: [
|
|
6242
|
-
{
|
|
6243
|
-
name: "workflowId",
|
|
6244
|
-
in: "path",
|
|
6245
|
-
required: true,
|
|
6246
|
-
schema: { type: "string" }
|
|
6247
|
-
},
|
|
6248
|
-
{
|
|
6249
|
-
name: "runId",
|
|
6250
|
-
in: "query",
|
|
6251
|
-
required: true,
|
|
6252
|
-
schema: { type: "string" }
|
|
6253
|
-
}
|
|
6254
|
-
],
|
|
6255
|
-
requestBody: {
|
|
6256
|
-
required: true,
|
|
6257
|
-
content: {
|
|
6258
|
-
"application/json": {
|
|
6259
|
-
schema: {
|
|
6260
|
-
type: "object",
|
|
6261
|
-
properties: {
|
|
6262
|
-
stepId: { type: "string" },
|
|
6263
|
-
context: { type: "object" }
|
|
6264
|
-
}
|
|
6265
|
-
}
|
|
6266
|
-
}
|
|
6267
|
-
}
|
|
6268
|
-
}
|
|
6269
|
-
}),
|
|
6270
|
-
resumeAsyncWorkflowHandler
|
|
6271
|
-
);
|
|
6272
6402
|
app.post(
|
|
6273
6403
|
"/api/workflows/:workflowId/resume-async",
|
|
6274
6404
|
bodyLimit(bodyLimitOptions),
|
|
@@ -6296,9 +6426,16 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6296
6426
|
schema: {
|
|
6297
6427
|
type: "object",
|
|
6298
6428
|
properties: {
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
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"]
|
|
6302
6439
|
}
|
|
6303
6440
|
}
|
|
6304
6441
|
}
|
|
@@ -6307,7 +6444,8 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6307
6444
|
resumeAsyncWorkflowHandler
|
|
6308
6445
|
);
|
|
6309
6446
|
app.post(
|
|
6310
|
-
"/api/workflows/:workflowId/
|
|
6447
|
+
"/api/workflows/:workflowId/create-run",
|
|
6448
|
+
bodyLimit(bodyLimitOptions),
|
|
6311
6449
|
h({
|
|
6312
6450
|
description: "Create a new workflow run",
|
|
6313
6451
|
tags: ["workflows"],
|
|
@@ -6331,51 +6469,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6331
6469
|
}
|
|
6332
6470
|
}
|
|
6333
6471
|
}),
|
|
6334
|
-
|
|
6335
|
-
);
|
|
6336
|
-
app.post(
|
|
6337
|
-
"/api/workflows/:workflowId/startAsync",
|
|
6338
|
-
bodyLimit(bodyLimitOptions),
|
|
6339
|
-
h({
|
|
6340
|
-
description: "@deprecated Use /api/workflows/:workflowId/start-async instead",
|
|
6341
|
-
tags: ["workflows"],
|
|
6342
|
-
parameters: [
|
|
6343
|
-
{
|
|
6344
|
-
name: "workflowId",
|
|
6345
|
-
in: "path",
|
|
6346
|
-
required: true,
|
|
6347
|
-
schema: { type: "string" }
|
|
6348
|
-
},
|
|
6349
|
-
{
|
|
6350
|
-
name: "runId",
|
|
6351
|
-
in: "query",
|
|
6352
|
-
required: false,
|
|
6353
|
-
schema: { type: "string" }
|
|
6354
|
-
}
|
|
6355
|
-
],
|
|
6356
|
-
requestBody: {
|
|
6357
|
-
required: true,
|
|
6358
|
-
content: {
|
|
6359
|
-
"application/json": {
|
|
6360
|
-
schema: {
|
|
6361
|
-
type: "object",
|
|
6362
|
-
properties: {
|
|
6363
|
-
input: { type: "object" }
|
|
6364
|
-
}
|
|
6365
|
-
}
|
|
6366
|
-
}
|
|
6367
|
-
}
|
|
6368
|
-
},
|
|
6369
|
-
responses: {
|
|
6370
|
-
200: {
|
|
6371
|
-
description: "Workflow execution result"
|
|
6372
|
-
},
|
|
6373
|
-
404: {
|
|
6374
|
-
description: "Workflow not found"
|
|
6375
|
-
}
|
|
6376
|
-
}
|
|
6377
|
-
}),
|
|
6378
|
-
startAsyncWorkflowHandler
|
|
6472
|
+
createWorkflowRunHandler
|
|
6379
6473
|
);
|
|
6380
6474
|
app.post(
|
|
6381
6475
|
"/api/workflows/:workflowId/start-async",
|
|
@@ -6404,7 +6498,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6404
6498
|
schema: {
|
|
6405
6499
|
type: "object",
|
|
6406
6500
|
properties: {
|
|
6407
|
-
|
|
6501
|
+
inputData: { type: "object" },
|
|
6502
|
+
runtimeContext: {
|
|
6503
|
+
type: "object",
|
|
6504
|
+
description: "Runtime context for the workflow execution"
|
|
6505
|
+
}
|
|
6408
6506
|
}
|
|
6409
6507
|
}
|
|
6410
6508
|
}
|
|
@@ -6412,10 +6510,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6412
6510
|
},
|
|
6413
6511
|
responses: {
|
|
6414
6512
|
200: {
|
|
6415
|
-
description: "
|
|
6513
|
+
description: "workflow execution result"
|
|
6416
6514
|
},
|
|
6417
6515
|
404: {
|
|
6418
|
-
description: "
|
|
6516
|
+
description: "workflow not found"
|
|
6419
6517
|
}
|
|
6420
6518
|
}
|
|
6421
6519
|
}),
|
|
@@ -6447,7 +6545,11 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6447
6545
|
schema: {
|
|
6448
6546
|
type: "object",
|
|
6449
6547
|
properties: {
|
|
6450
|
-
|
|
6548
|
+
inputData: { type: "object" },
|
|
6549
|
+
runtimeContext: {
|
|
6550
|
+
type: "object",
|
|
6551
|
+
description: "Runtime context for the workflow execution"
|
|
6552
|
+
}
|
|
6451
6553
|
}
|
|
6452
6554
|
}
|
|
6453
6555
|
}
|
|
@@ -6455,10 +6557,10 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6455
6557
|
},
|
|
6456
6558
|
responses: {
|
|
6457
6559
|
200: {
|
|
6458
|
-
description: "
|
|
6560
|
+
description: "workflow run started"
|
|
6459
6561
|
},
|
|
6460
6562
|
404: {
|
|
6461
|
-
description: "
|
|
6563
|
+
description: "workflow not found"
|
|
6462
6564
|
}
|
|
6463
6565
|
}
|
|
6464
6566
|
}),
|
|
@@ -6485,7 +6587,7 @@ async function createHonoServer(mastra, options = {}) {
|
|
|
6485
6587
|
tags: ["workflows"],
|
|
6486
6588
|
responses: {
|
|
6487
6589
|
200: {
|
|
6488
|
-
description: "
|
|
6590
|
+
description: "workflow transitions in real-time"
|
|
6489
6591
|
}
|
|
6490
6592
|
}
|
|
6491
6593
|
}),
|