@mastra/deployer 0.10.7-alpha.0 → 0.10.7-alpha.2
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 +10 -0
- package/dist/_tsup-dts-rollup.d.ts +10 -0
- package/dist/server/index.cjs +597 -37
- package/dist/server/index.js +597 -37
- package/dist/templates/instrumentation-template.js +1 -0
- package/package.json +8 -8
package/dist/server/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ var zod = require('zod');
|
|
|
32
32
|
var telemetry = require('@mastra/server/handlers/telemetry');
|
|
33
33
|
var tools = require('@mastra/server/handlers/tools');
|
|
34
34
|
var vector = require('@mastra/server/handlers/vector');
|
|
35
|
+
var vNextNetwork = require('@mastra/server/handlers/vNextNetwork');
|
|
35
36
|
var voice = require('@mastra/server/handlers/voice');
|
|
36
37
|
var workflows = require('@mastra/server/handlers/workflows');
|
|
37
38
|
|
|
@@ -263,14 +264,14 @@ var Response2 = class _Response {
|
|
|
263
264
|
});
|
|
264
265
|
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
265
266
|
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
266
|
-
function writeFromReadableStream(
|
|
267
|
-
if (
|
|
267
|
+
function writeFromReadableStream(stream5, writable) {
|
|
268
|
+
if (stream5.locked) {
|
|
268
269
|
throw new TypeError("ReadableStream is locked.");
|
|
269
270
|
} else if (writable.destroyed) {
|
|
270
|
-
|
|
271
|
+
stream5.cancel();
|
|
271
272
|
return;
|
|
272
273
|
}
|
|
273
|
-
const reader =
|
|
274
|
+
const reader = stream5.getReader();
|
|
274
275
|
writable.on("close", cancel);
|
|
275
276
|
writable.on("error", cancel);
|
|
276
277
|
reader.read().then(flow, cancel);
|
|
@@ -505,18 +506,18 @@ var ENCODINGS = {
|
|
|
505
506
|
gzip: ".gz"
|
|
506
507
|
};
|
|
507
508
|
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
508
|
-
var createStreamBody = (
|
|
509
|
+
var createStreamBody = (stream5) => {
|
|
509
510
|
const body = new ReadableStream({
|
|
510
511
|
start(controller) {
|
|
511
|
-
|
|
512
|
+
stream5.on("data", (chunk) => {
|
|
512
513
|
controller.enqueue(chunk);
|
|
513
514
|
});
|
|
514
|
-
|
|
515
|
+
stream5.on("end", () => {
|
|
515
516
|
controller.close();
|
|
516
517
|
});
|
|
517
518
|
},
|
|
518
519
|
cancel() {
|
|
519
|
-
|
|
520
|
+
stream5.destroy();
|
|
520
521
|
}
|
|
521
522
|
});
|
|
522
523
|
return body;
|
|
@@ -612,10 +613,10 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
612
613
|
end = size - 1;
|
|
613
614
|
}
|
|
614
615
|
const chunksize = end - start + 1;
|
|
615
|
-
const
|
|
616
|
+
const stream5 = fs.createReadStream(path, { start, end });
|
|
616
617
|
c2.header("Content-Length", chunksize.toString());
|
|
617
618
|
c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
618
|
-
return c2.body(createStreamBody(
|
|
619
|
+
return c2.body(createStreamBody(stream5), 206);
|
|
619
620
|
};
|
|
620
621
|
};
|
|
621
622
|
var RENDER_TYPE = {
|
|
@@ -736,7 +737,7 @@ var middleware = (options) => async (c2) => {
|
|
|
736
737
|
);
|
|
737
738
|
};
|
|
738
739
|
|
|
739
|
-
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.
|
|
740
|
+
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.8.1_openapi-types@12.1.3_zod@3.25.67/node_modules/hono-openapi/utils.js
|
|
740
741
|
var e = Symbol("openapi");
|
|
741
742
|
var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
|
|
742
743
|
var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
|
|
@@ -911,15 +912,15 @@ async function getAgentExecutionHandler(c2) {
|
|
|
911
912
|
if (body.method === "tasks/sendSubscribe") {
|
|
912
913
|
return streaming.stream(
|
|
913
914
|
c2,
|
|
914
|
-
async (
|
|
915
|
+
async (stream5) => {
|
|
915
916
|
try {
|
|
916
|
-
|
|
917
|
+
stream5.onAbort(() => {
|
|
917
918
|
if (!result.locked) {
|
|
918
919
|
return result.cancel();
|
|
919
920
|
}
|
|
920
921
|
});
|
|
921
922
|
for await (const chunk of result) {
|
|
922
|
-
await
|
|
923
|
+
await stream5.write(JSON.stringify(chunk) + "");
|
|
923
924
|
}
|
|
924
925
|
} catch (err) {
|
|
925
926
|
logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
|
|
@@ -1250,7 +1251,7 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1250
1251
|
// src/server/handlers/client.ts
|
|
1251
1252
|
var clients = /* @__PURE__ */ new Set();
|
|
1252
1253
|
function handleClientsRefresh(c2) {
|
|
1253
|
-
const
|
|
1254
|
+
const stream5 = new ReadableStream({
|
|
1254
1255
|
start(controller) {
|
|
1255
1256
|
clients.add(controller);
|
|
1256
1257
|
controller.enqueue("data: connected\n\n");
|
|
@@ -1259,7 +1260,7 @@ function handleClientsRefresh(c2) {
|
|
|
1259
1260
|
});
|
|
1260
1261
|
}
|
|
1261
1262
|
});
|
|
1262
|
-
return new Response(
|
|
1263
|
+
return new Response(stream5, {
|
|
1263
1264
|
headers: {
|
|
1264
1265
|
"Content-Type": "text/event-stream",
|
|
1265
1266
|
"Cache-Control": "no-cache",
|
|
@@ -1366,20 +1367,20 @@ function watchLegacyWorkflowHandler(c2) {
|
|
|
1366
1367
|
}
|
|
1367
1368
|
return streaming.stream(
|
|
1368
1369
|
c2,
|
|
1369
|
-
async (
|
|
1370
|
+
async (stream5) => {
|
|
1370
1371
|
try {
|
|
1371
1372
|
const result = await legacyWorkflows.watchLegacyWorkflowHandler({
|
|
1372
1373
|
mastra,
|
|
1373
1374
|
workflowId,
|
|
1374
1375
|
runId
|
|
1375
1376
|
});
|
|
1376
|
-
|
|
1377
|
+
stream5.onAbort(() => {
|
|
1377
1378
|
if (!result.locked) {
|
|
1378
1379
|
return result.cancel();
|
|
1379
1380
|
}
|
|
1380
1381
|
});
|
|
1381
1382
|
for await (const chunk of result) {
|
|
1382
|
-
await
|
|
1383
|
+
await stream5.write(chunk.toString() + "");
|
|
1383
1384
|
}
|
|
1384
1385
|
} catch (err) {
|
|
1385
1386
|
console.log(err);
|
|
@@ -3577,9 +3578,11 @@ async function getMemoryStatusHandler(c2) {
|
|
|
3577
3578
|
try {
|
|
3578
3579
|
const mastra = c2.get("mastra");
|
|
3579
3580
|
const agentId = c2.req.query("agentId");
|
|
3581
|
+
const networkId = c2.req.query("networkId");
|
|
3580
3582
|
const result = await memory.getMemoryStatusHandler({
|
|
3581
3583
|
mastra,
|
|
3582
|
-
agentId
|
|
3584
|
+
agentId,
|
|
3585
|
+
networkId
|
|
3583
3586
|
});
|
|
3584
3587
|
return c2.json(result);
|
|
3585
3588
|
} catch (error) {
|
|
@@ -3591,10 +3594,12 @@ async function getThreadsHandler(c2) {
|
|
|
3591
3594
|
const mastra = c2.get("mastra");
|
|
3592
3595
|
const agentId = c2.req.query("agentId");
|
|
3593
3596
|
const resourceId = c2.req.query("resourceid");
|
|
3597
|
+
const networkId = c2.req.query("networkId");
|
|
3594
3598
|
const result = await memory.getThreadsHandler({
|
|
3595
3599
|
mastra,
|
|
3596
3600
|
agentId,
|
|
3597
|
-
resourceId
|
|
3601
|
+
resourceId,
|
|
3602
|
+
networkId
|
|
3598
3603
|
});
|
|
3599
3604
|
return c2.json(result);
|
|
3600
3605
|
} catch (error) {
|
|
@@ -3606,10 +3611,12 @@ async function getThreadByIdHandler(c2) {
|
|
|
3606
3611
|
const mastra = c2.get("mastra");
|
|
3607
3612
|
const agentId = c2.req.query("agentId");
|
|
3608
3613
|
const threadId = c2.req.param("threadId");
|
|
3614
|
+
const networkId = c2.req.query("networkId");
|
|
3609
3615
|
const result = await memory.getThreadByIdHandler({
|
|
3610
3616
|
mastra,
|
|
3611
3617
|
agentId,
|
|
3612
|
-
threadId
|
|
3618
|
+
threadId,
|
|
3619
|
+
networkId
|
|
3613
3620
|
});
|
|
3614
3621
|
return c2.json(result);
|
|
3615
3622
|
} catch (error) {
|
|
@@ -3620,11 +3627,13 @@ async function saveMessagesHandler(c2) {
|
|
|
3620
3627
|
try {
|
|
3621
3628
|
const mastra = c2.get("mastra");
|
|
3622
3629
|
const agentId = c2.req.query("agentId");
|
|
3630
|
+
const networkId = c2.req.query("networkId");
|
|
3623
3631
|
const body = await c2.req.json();
|
|
3624
3632
|
const result = await memory.saveMessagesHandler({
|
|
3625
3633
|
mastra,
|
|
3626
3634
|
agentId,
|
|
3627
|
-
body
|
|
3635
|
+
body,
|
|
3636
|
+
networkId
|
|
3628
3637
|
});
|
|
3629
3638
|
return c2.json(result);
|
|
3630
3639
|
} catch (error) {
|
|
@@ -3635,11 +3644,13 @@ async function createThreadHandler(c2) {
|
|
|
3635
3644
|
try {
|
|
3636
3645
|
const mastra = c2.get("mastra");
|
|
3637
3646
|
const agentId = c2.req.query("agentId");
|
|
3647
|
+
const networkId = c2.req.query("networkId");
|
|
3638
3648
|
const body = await c2.req.json();
|
|
3639
3649
|
const result = await memory.createThreadHandler({
|
|
3640
3650
|
mastra,
|
|
3641
3651
|
agentId,
|
|
3642
|
-
body
|
|
3652
|
+
body,
|
|
3653
|
+
networkId
|
|
3643
3654
|
});
|
|
3644
3655
|
return c2.json(result);
|
|
3645
3656
|
} catch (error) {
|
|
@@ -3651,12 +3662,14 @@ async function updateThreadHandler(c2) {
|
|
|
3651
3662
|
const mastra = c2.get("mastra");
|
|
3652
3663
|
const agentId = c2.req.query("agentId");
|
|
3653
3664
|
const threadId = c2.req.param("threadId");
|
|
3665
|
+
const networkId = c2.req.query("networkId");
|
|
3654
3666
|
const body = await c2.req.json();
|
|
3655
3667
|
const result = await memory.updateThreadHandler({
|
|
3656
3668
|
mastra,
|
|
3657
3669
|
agentId,
|
|
3658
3670
|
threadId,
|
|
3659
|
-
body
|
|
3671
|
+
body,
|
|
3672
|
+
networkId
|
|
3660
3673
|
});
|
|
3661
3674
|
return c2.json(result);
|
|
3662
3675
|
} catch (error) {
|
|
@@ -3668,10 +3681,12 @@ async function deleteThreadHandler(c2) {
|
|
|
3668
3681
|
const mastra = c2.get("mastra");
|
|
3669
3682
|
const agentId = c2.req.query("agentId");
|
|
3670
3683
|
const threadId = c2.req.param("threadId");
|
|
3684
|
+
const networkId = c2.req.query("networkId");
|
|
3671
3685
|
const result = await memory.deleteThreadHandler({
|
|
3672
3686
|
mastra,
|
|
3673
3687
|
agentId,
|
|
3674
|
-
threadId
|
|
3688
|
+
threadId,
|
|
3689
|
+
networkId
|
|
3675
3690
|
});
|
|
3676
3691
|
return c2.json(result);
|
|
3677
3692
|
} catch (error) {
|
|
@@ -3682,6 +3697,7 @@ async function getMessagesHandler(c2) {
|
|
|
3682
3697
|
try {
|
|
3683
3698
|
const mastra = c2.get("mastra");
|
|
3684
3699
|
const agentId = c2.req.query("agentId");
|
|
3700
|
+
const networkId = c2.req.query("networkId");
|
|
3685
3701
|
const threadId = c2.req.param("threadId");
|
|
3686
3702
|
const rawLimit = c2.req.query("limit");
|
|
3687
3703
|
let limit = void 0;
|
|
@@ -3695,6 +3711,7 @@ async function getMessagesHandler(c2) {
|
|
|
3695
3711
|
mastra,
|
|
3696
3712
|
agentId,
|
|
3697
3713
|
threadId,
|
|
3714
|
+
networkId,
|
|
3698
3715
|
limit
|
|
3699
3716
|
});
|
|
3700
3717
|
return c2.json(result);
|
|
@@ -4075,6 +4092,106 @@ async function deleteIndex(c2) {
|
|
|
4075
4092
|
return handleError(error, "Error deleting index");
|
|
4076
4093
|
}
|
|
4077
4094
|
}
|
|
4095
|
+
async function getVNextNetworksHandler(c2) {
|
|
4096
|
+
try {
|
|
4097
|
+
const mastra = c2.get("mastra");
|
|
4098
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4099
|
+
const networks = await vNextNetwork.getVNextNetworksHandler({
|
|
4100
|
+
mastra,
|
|
4101
|
+
runtimeContext
|
|
4102
|
+
});
|
|
4103
|
+
return c2.json(networks);
|
|
4104
|
+
} catch (error) {
|
|
4105
|
+
return handleError(error, "Error getting networks");
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
async function getVNextNetworkByIdHandler(c2) {
|
|
4109
|
+
try {
|
|
4110
|
+
const mastra = c2.get("mastra");
|
|
4111
|
+
const networkId = c2.req.param("networkId");
|
|
4112
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4113
|
+
const network = await vNextNetwork.getVNextNetworkByIdHandler({
|
|
4114
|
+
mastra,
|
|
4115
|
+
networkId,
|
|
4116
|
+
runtimeContext
|
|
4117
|
+
});
|
|
4118
|
+
return c2.json(network);
|
|
4119
|
+
} catch (error) {
|
|
4120
|
+
return handleError(error, "Error getting network by ID");
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
async function generateVNextNetworkHandler(c2) {
|
|
4124
|
+
try {
|
|
4125
|
+
const mastra = c2.get("mastra");
|
|
4126
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4127
|
+
const networkId = c2.req.param("networkId");
|
|
4128
|
+
const body = await c2.req.json();
|
|
4129
|
+
const result = await vNextNetwork.generateVNextNetworkHandler({
|
|
4130
|
+
mastra,
|
|
4131
|
+
runtimeContext,
|
|
4132
|
+
networkId,
|
|
4133
|
+
body
|
|
4134
|
+
});
|
|
4135
|
+
return c2.json(result);
|
|
4136
|
+
} catch (error) {
|
|
4137
|
+
return handleError(error, "Error generating from network");
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
async function streamGenerateVNextNetworkHandler(c2) {
|
|
4141
|
+
try {
|
|
4142
|
+
const mastra = c2.get("mastra");
|
|
4143
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4144
|
+
const logger2 = mastra.getLogger();
|
|
4145
|
+
const networkId = c2.req.param("networkId");
|
|
4146
|
+
const body = await c2.req.json();
|
|
4147
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4148
|
+
return streaming.stream(
|
|
4149
|
+
c2,
|
|
4150
|
+
async (stream5) => {
|
|
4151
|
+
try {
|
|
4152
|
+
const result = await vNextNetwork.streamGenerateVNextNetworkHandler({
|
|
4153
|
+
mastra,
|
|
4154
|
+
runtimeContext,
|
|
4155
|
+
networkId,
|
|
4156
|
+
body
|
|
4157
|
+
});
|
|
4158
|
+
const reader = result.stream.getReader();
|
|
4159
|
+
stream5.onAbort(() => {
|
|
4160
|
+
void reader.cancel("request aborted");
|
|
4161
|
+
});
|
|
4162
|
+
let chunkResult;
|
|
4163
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4164
|
+
await stream5.write(JSON.stringify(chunkResult.value) + "");
|
|
4165
|
+
}
|
|
4166
|
+
} catch (err) {
|
|
4167
|
+
mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
4168
|
+
}
|
|
4169
|
+
},
|
|
4170
|
+
async (err) => {
|
|
4171
|
+
logger2.error("Error in watch stream: " + err?.message);
|
|
4172
|
+
}
|
|
4173
|
+
);
|
|
4174
|
+
} catch (error) {
|
|
4175
|
+
return handleError(error, "Error streaming from network");
|
|
4176
|
+
}
|
|
4177
|
+
}
|
|
4178
|
+
async function loopVNextNetworkHandler(c2) {
|
|
4179
|
+
try {
|
|
4180
|
+
const mastra = c2.get("mastra");
|
|
4181
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4182
|
+
const networkId = c2.req.param("networkId");
|
|
4183
|
+
const body = await c2.req.json();
|
|
4184
|
+
const result = await vNextNetwork.loopVNextNetworkHandler({
|
|
4185
|
+
mastra,
|
|
4186
|
+
runtimeContext,
|
|
4187
|
+
networkId,
|
|
4188
|
+
body
|
|
4189
|
+
});
|
|
4190
|
+
return c2.json(result);
|
|
4191
|
+
} catch (error) {
|
|
4192
|
+
return handleError(error, "Error looping from network");
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4078
4195
|
async function getSpeakersHandler(c2) {
|
|
4079
4196
|
try {
|
|
4080
4197
|
const mastra = c2.get("mastra");
|
|
@@ -4189,8 +4306,9 @@ async function createWorkflowRunHandler(c2) {
|
|
|
4189
4306
|
async function startAsyncWorkflowHandler(c2) {
|
|
4190
4307
|
try {
|
|
4191
4308
|
const mastra = c2.get("mastra");
|
|
4309
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4192
4310
|
const workflowId = c2.req.param("workflowId");
|
|
4193
|
-
const { inputData
|
|
4311
|
+
const { inputData } = await c2.req.json();
|
|
4194
4312
|
const runId = c2.req.query("runId");
|
|
4195
4313
|
const result = await workflows.startAsyncWorkflowHandler({
|
|
4196
4314
|
mastra,
|
|
@@ -4207,8 +4325,9 @@ async function startAsyncWorkflowHandler(c2) {
|
|
|
4207
4325
|
async function startWorkflowRunHandler(c2) {
|
|
4208
4326
|
try {
|
|
4209
4327
|
const mastra = c2.get("mastra");
|
|
4328
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4210
4329
|
const workflowId = c2.req.param("workflowId");
|
|
4211
|
-
const { inputData
|
|
4330
|
+
const { inputData } = await c2.req.json();
|
|
4212
4331
|
const runId = c2.req.query("runId");
|
|
4213
4332
|
await workflows.startWorkflowRunHandler({
|
|
4214
4333
|
mastra,
|
|
@@ -4231,9 +4350,10 @@ function watchWorkflowHandler(c2) {
|
|
|
4231
4350
|
if (!runId) {
|
|
4232
4351
|
throw new httpException.HTTPException(400, { message: "runId required to watch workflow" });
|
|
4233
4352
|
}
|
|
4353
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4234
4354
|
return streaming.stream(
|
|
4235
4355
|
c2,
|
|
4236
|
-
async (
|
|
4356
|
+
async (stream5) => {
|
|
4237
4357
|
try {
|
|
4238
4358
|
const result = await workflows.watchWorkflowHandler({
|
|
4239
4359
|
mastra,
|
|
@@ -4241,12 +4361,12 @@ function watchWorkflowHandler(c2) {
|
|
|
4241
4361
|
runId
|
|
4242
4362
|
});
|
|
4243
4363
|
const reader = result.getReader();
|
|
4244
|
-
|
|
4364
|
+
stream5.onAbort(() => {
|
|
4245
4365
|
void reader.cancel("request aborted");
|
|
4246
4366
|
});
|
|
4247
4367
|
let chunkResult;
|
|
4248
4368
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4249
|
-
await
|
|
4369
|
+
await stream5.write(JSON.stringify(chunkResult.value) + "");
|
|
4250
4370
|
}
|
|
4251
4371
|
} catch (err) {
|
|
4252
4372
|
mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
@@ -4263,13 +4383,15 @@ function watchWorkflowHandler(c2) {
|
|
|
4263
4383
|
async function streamWorkflowHandler(c2) {
|
|
4264
4384
|
try {
|
|
4265
4385
|
const mastra = c2.get("mastra");
|
|
4386
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4266
4387
|
const logger2 = mastra.getLogger();
|
|
4267
4388
|
const workflowId = c2.req.param("workflowId");
|
|
4268
|
-
const { inputData
|
|
4389
|
+
const { inputData } = await c2.req.json();
|
|
4269
4390
|
const runId = c2.req.query("runId");
|
|
4391
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4270
4392
|
return streaming.stream(
|
|
4271
4393
|
c2,
|
|
4272
|
-
async (
|
|
4394
|
+
async (stream5) => {
|
|
4273
4395
|
try {
|
|
4274
4396
|
const result = await workflows.streamWorkflowHandler({
|
|
4275
4397
|
mastra,
|
|
@@ -4279,12 +4401,12 @@ async function streamWorkflowHandler(c2) {
|
|
|
4279
4401
|
runtimeContext
|
|
4280
4402
|
});
|
|
4281
4403
|
const reader = result.stream.getReader();
|
|
4282
|
-
|
|
4404
|
+
stream5.onAbort(() => {
|
|
4283
4405
|
void reader.cancel("request aborted");
|
|
4284
4406
|
});
|
|
4285
4407
|
let chunkResult;
|
|
4286
4408
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4287
|
-
await
|
|
4409
|
+
await stream5.write(JSON.stringify(chunkResult.value) + "");
|
|
4288
4410
|
}
|
|
4289
4411
|
} catch (err) {
|
|
4290
4412
|
console.log(err);
|
|
@@ -4301,9 +4423,10 @@ async function streamWorkflowHandler(c2) {
|
|
|
4301
4423
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
4302
4424
|
try {
|
|
4303
4425
|
const mastra = c2.get("mastra");
|
|
4426
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4304
4427
|
const workflowId = c2.req.param("workflowId");
|
|
4305
4428
|
const runId = c2.req.query("runId");
|
|
4306
|
-
const { step, resumeData
|
|
4429
|
+
const { step, resumeData } = await c2.req.json();
|
|
4307
4430
|
if (!runId) {
|
|
4308
4431
|
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
4309
4432
|
}
|
|
@@ -4322,9 +4445,10 @@ async function resumeAsyncWorkflowHandler(c2) {
|
|
|
4322
4445
|
async function resumeWorkflowHandler(c2) {
|
|
4323
4446
|
try {
|
|
4324
4447
|
const mastra = c2.get("mastra");
|
|
4448
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4325
4449
|
const workflowId = c2.req.param("workflowId");
|
|
4326
4450
|
const runId = c2.req.query("runId");
|
|
4327
|
-
const { step, resumeData
|
|
4451
|
+
const { step, resumeData } = await c2.req.json();
|
|
4328
4452
|
if (!runId) {
|
|
4329
4453
|
throw new httpException.HTTPException(400, { message: "runId required to resume workflow" });
|
|
4330
4454
|
}
|
|
@@ -4799,6 +4923,185 @@ ${err.stack.split("\n").slice(1).join("\n")}
|
|
|
4799
4923
|
}),
|
|
4800
4924
|
getAgentsHandler
|
|
4801
4925
|
);
|
|
4926
|
+
app.get(
|
|
4927
|
+
"/api/networks/v-next",
|
|
4928
|
+
w({
|
|
4929
|
+
description: "Get all available v-next networks",
|
|
4930
|
+
tags: ["vNextNetworks"],
|
|
4931
|
+
responses: {
|
|
4932
|
+
200: {
|
|
4933
|
+
description: "List of all v-next networks"
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4936
|
+
}),
|
|
4937
|
+
getVNextNetworksHandler
|
|
4938
|
+
);
|
|
4939
|
+
app.get(
|
|
4940
|
+
"/api/networks/v-next/:networkId",
|
|
4941
|
+
w({
|
|
4942
|
+
description: "Get v-next network by ID",
|
|
4943
|
+
tags: ["vNextNetworks"],
|
|
4944
|
+
parameters: [
|
|
4945
|
+
{
|
|
4946
|
+
name: "networkId",
|
|
4947
|
+
in: "path",
|
|
4948
|
+
required: true,
|
|
4949
|
+
schema: { type: "string" }
|
|
4950
|
+
}
|
|
4951
|
+
],
|
|
4952
|
+
responses: {
|
|
4953
|
+
200: {
|
|
4954
|
+
description: "v-next Network details"
|
|
4955
|
+
},
|
|
4956
|
+
404: {
|
|
4957
|
+
description: "v-next Network not found"
|
|
4958
|
+
}
|
|
4959
|
+
}
|
|
4960
|
+
}),
|
|
4961
|
+
getVNextNetworkByIdHandler
|
|
4962
|
+
);
|
|
4963
|
+
app.post(
|
|
4964
|
+
"/api/networks/v-next/:networkId/generate",
|
|
4965
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
4966
|
+
w({
|
|
4967
|
+
description: "Generate a response from a v-next network",
|
|
4968
|
+
tags: ["vNextNetworks"],
|
|
4969
|
+
parameters: [
|
|
4970
|
+
{
|
|
4971
|
+
name: "networkId",
|
|
4972
|
+
in: "path",
|
|
4973
|
+
required: true,
|
|
4974
|
+
schema: { type: "string" }
|
|
4975
|
+
}
|
|
4976
|
+
],
|
|
4977
|
+
requestBody: {
|
|
4978
|
+
required: true,
|
|
4979
|
+
content: {
|
|
4980
|
+
"application/json": {
|
|
4981
|
+
schema: {
|
|
4982
|
+
type: "object",
|
|
4983
|
+
properties: {
|
|
4984
|
+
message: {
|
|
4985
|
+
type: "string",
|
|
4986
|
+
description: "Message for the v-next network"
|
|
4987
|
+
},
|
|
4988
|
+
threadId: {
|
|
4989
|
+
type: "string",
|
|
4990
|
+
description: "Thread Id of the conversation"
|
|
4991
|
+
},
|
|
4992
|
+
resourceId: {
|
|
4993
|
+
type: "string",
|
|
4994
|
+
description: "Resource Id of the conversation"
|
|
4995
|
+
}
|
|
4996
|
+
},
|
|
4997
|
+
required: ["message"]
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
5000
|
+
}
|
|
5001
|
+
},
|
|
5002
|
+
responses: {
|
|
5003
|
+
200: {
|
|
5004
|
+
description: "Generated response"
|
|
5005
|
+
},
|
|
5006
|
+
404: {
|
|
5007
|
+
description: "v-next Network not found"
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
}),
|
|
5011
|
+
generateVNextNetworkHandler
|
|
5012
|
+
);
|
|
5013
|
+
app.post(
|
|
5014
|
+
"/api/networks/v-next/:networkId/loop",
|
|
5015
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5016
|
+
w({
|
|
5017
|
+
description: "Loop a v-next network",
|
|
5018
|
+
tags: ["vNextNetworks"],
|
|
5019
|
+
parameters: [
|
|
5020
|
+
{
|
|
5021
|
+
name: "networkId",
|
|
5022
|
+
in: "path",
|
|
5023
|
+
required: true,
|
|
5024
|
+
schema: { type: "string" }
|
|
5025
|
+
}
|
|
5026
|
+
],
|
|
5027
|
+
requestBody: {
|
|
5028
|
+
required: true,
|
|
5029
|
+
content: {
|
|
5030
|
+
"application/json": {
|
|
5031
|
+
schema: {
|
|
5032
|
+
type: "object",
|
|
5033
|
+
properties: {
|
|
5034
|
+
message: {
|
|
5035
|
+
type: "string",
|
|
5036
|
+
description: "Message for the v-next network"
|
|
5037
|
+
}
|
|
5038
|
+
},
|
|
5039
|
+
required: ["message"]
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
},
|
|
5044
|
+
responses: {
|
|
5045
|
+
200: {
|
|
5046
|
+
description: "Looped response"
|
|
5047
|
+
},
|
|
5048
|
+
404: {
|
|
5049
|
+
description: "v-next Network not found"
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
}),
|
|
5053
|
+
loopVNextNetworkHandler
|
|
5054
|
+
);
|
|
5055
|
+
app.post(
|
|
5056
|
+
"/api/networks/v-next/:networkId/stream",
|
|
5057
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
5058
|
+
w({
|
|
5059
|
+
description: "Generate a response from a v-next network",
|
|
5060
|
+
tags: ["vNextNetworks"],
|
|
5061
|
+
parameters: [
|
|
5062
|
+
{
|
|
5063
|
+
name: "networkId",
|
|
5064
|
+
in: "path",
|
|
5065
|
+
required: true,
|
|
5066
|
+
schema: { type: "string" }
|
|
5067
|
+
}
|
|
5068
|
+
],
|
|
5069
|
+
requestBody: {
|
|
5070
|
+
required: true,
|
|
5071
|
+
content: {
|
|
5072
|
+
"application/json": {
|
|
5073
|
+
schema: {
|
|
5074
|
+
type: "object",
|
|
5075
|
+
properties: {
|
|
5076
|
+
message: {
|
|
5077
|
+
type: "string",
|
|
5078
|
+
description: "Message for the v-next network"
|
|
5079
|
+
},
|
|
5080
|
+
threadId: {
|
|
5081
|
+
type: "string",
|
|
5082
|
+
description: "Thread Id of the conversation"
|
|
5083
|
+
},
|
|
5084
|
+
resourceId: {
|
|
5085
|
+
type: "string",
|
|
5086
|
+
description: "Resource Id of the conversation"
|
|
5087
|
+
}
|
|
5088
|
+
},
|
|
5089
|
+
required: ["message"]
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
}
|
|
5093
|
+
},
|
|
5094
|
+
responses: {
|
|
5095
|
+
200: {
|
|
5096
|
+
description: "Generated response"
|
|
5097
|
+
},
|
|
5098
|
+
404: {
|
|
5099
|
+
description: "v-next Network not found"
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
}),
|
|
5103
|
+
streamGenerateVNextNetworkHandler
|
|
5104
|
+
);
|
|
4802
5105
|
app.get(
|
|
4803
5106
|
"/api/networks",
|
|
4804
5107
|
w({
|
|
@@ -6077,6 +6380,263 @@ ${err.stack.split("\n").slice(1).join("\n")}
|
|
|
6077
6380
|
}),
|
|
6078
6381
|
executeMcpServerToolHandler
|
|
6079
6382
|
);
|
|
6383
|
+
app.get(
|
|
6384
|
+
"/api/memory/network/status",
|
|
6385
|
+
w({
|
|
6386
|
+
description: "Get network memory status",
|
|
6387
|
+
tags: ["networkMemory"],
|
|
6388
|
+
parameters: [
|
|
6389
|
+
{
|
|
6390
|
+
name: "networkId",
|
|
6391
|
+
in: "query",
|
|
6392
|
+
required: true,
|
|
6393
|
+
schema: { type: "string" }
|
|
6394
|
+
}
|
|
6395
|
+
],
|
|
6396
|
+
responses: {
|
|
6397
|
+
200: {
|
|
6398
|
+
description: "Memory status"
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
}),
|
|
6402
|
+
getMemoryStatusHandler
|
|
6403
|
+
);
|
|
6404
|
+
app.get(
|
|
6405
|
+
"/api/memory/network/threads",
|
|
6406
|
+
w({
|
|
6407
|
+
description: "Get all threads",
|
|
6408
|
+
tags: ["networkMemory"],
|
|
6409
|
+
parameters: [
|
|
6410
|
+
{
|
|
6411
|
+
name: "resourceid",
|
|
6412
|
+
in: "query",
|
|
6413
|
+
required: true,
|
|
6414
|
+
schema: { type: "string" }
|
|
6415
|
+
},
|
|
6416
|
+
{
|
|
6417
|
+
name: "networkId",
|
|
6418
|
+
in: "query",
|
|
6419
|
+
required: true,
|
|
6420
|
+
schema: { type: "string" }
|
|
6421
|
+
}
|
|
6422
|
+
],
|
|
6423
|
+
responses: {
|
|
6424
|
+
200: {
|
|
6425
|
+
description: "List of all threads"
|
|
6426
|
+
}
|
|
6427
|
+
}
|
|
6428
|
+
}),
|
|
6429
|
+
getThreadsHandler
|
|
6430
|
+
);
|
|
6431
|
+
app.get(
|
|
6432
|
+
"/api/memory/network/threads/:threadId",
|
|
6433
|
+
w({
|
|
6434
|
+
description: "Get thread by ID",
|
|
6435
|
+
tags: ["networkMemory"],
|
|
6436
|
+
parameters: [
|
|
6437
|
+
{
|
|
6438
|
+
name: "threadId",
|
|
6439
|
+
in: "path",
|
|
6440
|
+
required: true,
|
|
6441
|
+
schema: { type: "string" }
|
|
6442
|
+
},
|
|
6443
|
+
{
|
|
6444
|
+
name: "networkId",
|
|
6445
|
+
in: "query",
|
|
6446
|
+
required: true,
|
|
6447
|
+
schema: { type: "string" }
|
|
6448
|
+
}
|
|
6449
|
+
],
|
|
6450
|
+
responses: {
|
|
6451
|
+
200: {
|
|
6452
|
+
description: "Thread details"
|
|
6453
|
+
},
|
|
6454
|
+
404: {
|
|
6455
|
+
description: "Thread not found"
|
|
6456
|
+
}
|
|
6457
|
+
}
|
|
6458
|
+
}),
|
|
6459
|
+
getThreadByIdHandler
|
|
6460
|
+
);
|
|
6461
|
+
app.get(
|
|
6462
|
+
"/api/memory/network/threads/:threadId/messages",
|
|
6463
|
+
w({
|
|
6464
|
+
description: "Get messages for a thread",
|
|
6465
|
+
tags: ["networkMemory"],
|
|
6466
|
+
parameters: [
|
|
6467
|
+
{
|
|
6468
|
+
name: "threadId",
|
|
6469
|
+
in: "path",
|
|
6470
|
+
required: true,
|
|
6471
|
+
schema: { type: "string" }
|
|
6472
|
+
},
|
|
6473
|
+
{
|
|
6474
|
+
name: "networkId",
|
|
6475
|
+
in: "query",
|
|
6476
|
+
required: true,
|
|
6477
|
+
schema: { type: "string" }
|
|
6478
|
+
},
|
|
6479
|
+
{
|
|
6480
|
+
name: "limit",
|
|
6481
|
+
in: "query",
|
|
6482
|
+
required: false,
|
|
6483
|
+
schema: { type: "number" },
|
|
6484
|
+
description: "Limit the number of messages to retrieve (default: 40)"
|
|
6485
|
+
}
|
|
6486
|
+
],
|
|
6487
|
+
responses: {
|
|
6488
|
+
200: {
|
|
6489
|
+
description: "List of messages"
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
}),
|
|
6493
|
+
getMessagesHandler
|
|
6494
|
+
);
|
|
6495
|
+
app.post(
|
|
6496
|
+
"/api/memory/network/threads",
|
|
6497
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6498
|
+
w({
|
|
6499
|
+
description: "Create a new thread",
|
|
6500
|
+
tags: ["networkMemory"],
|
|
6501
|
+
parameters: [
|
|
6502
|
+
{
|
|
6503
|
+
name: "networkId",
|
|
6504
|
+
in: "query",
|
|
6505
|
+
required: true,
|
|
6506
|
+
schema: { type: "string" }
|
|
6507
|
+
}
|
|
6508
|
+
],
|
|
6509
|
+
requestBody: {
|
|
6510
|
+
required: true,
|
|
6511
|
+
content: {
|
|
6512
|
+
"application/json": {
|
|
6513
|
+
schema: {
|
|
6514
|
+
type: "object",
|
|
6515
|
+
properties: {
|
|
6516
|
+
title: { type: "string" },
|
|
6517
|
+
metadata: { type: "object" },
|
|
6518
|
+
resourceId: { type: "string" },
|
|
6519
|
+
threadId: { type: "string" }
|
|
6520
|
+
}
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
}
|
|
6524
|
+
},
|
|
6525
|
+
responses: {
|
|
6526
|
+
200: {
|
|
6527
|
+
description: "Created thread"
|
|
6528
|
+
}
|
|
6529
|
+
}
|
|
6530
|
+
}),
|
|
6531
|
+
createThreadHandler
|
|
6532
|
+
);
|
|
6533
|
+
app.patch(
|
|
6534
|
+
"/api/memory/network/threads/:threadId",
|
|
6535
|
+
w({
|
|
6536
|
+
description: "Update a thread",
|
|
6537
|
+
tags: ["networkMemory"],
|
|
6538
|
+
parameters: [
|
|
6539
|
+
{
|
|
6540
|
+
name: "threadId",
|
|
6541
|
+
in: "path",
|
|
6542
|
+
required: true,
|
|
6543
|
+
schema: { type: "string" }
|
|
6544
|
+
},
|
|
6545
|
+
{
|
|
6546
|
+
name: "networkId",
|
|
6547
|
+
in: "query",
|
|
6548
|
+
required: true,
|
|
6549
|
+
schema: { type: "string" }
|
|
6550
|
+
}
|
|
6551
|
+
],
|
|
6552
|
+
requestBody: {
|
|
6553
|
+
required: true,
|
|
6554
|
+
content: {
|
|
6555
|
+
"application/json": {
|
|
6556
|
+
schema: { type: "object" }
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6559
|
+
},
|
|
6560
|
+
responses: {
|
|
6561
|
+
200: {
|
|
6562
|
+
description: "Updated thread"
|
|
6563
|
+
},
|
|
6564
|
+
404: {
|
|
6565
|
+
description: "Thread not found"
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6568
|
+
}),
|
|
6569
|
+
updateThreadHandler
|
|
6570
|
+
);
|
|
6571
|
+
app.delete(
|
|
6572
|
+
"/api/memory/network/threads/:threadId",
|
|
6573
|
+
w({
|
|
6574
|
+
description: "Delete a thread",
|
|
6575
|
+
tags: ["networkMemory"],
|
|
6576
|
+
parameters: [
|
|
6577
|
+
{
|
|
6578
|
+
name: "threadId",
|
|
6579
|
+
in: "path",
|
|
6580
|
+
required: true,
|
|
6581
|
+
schema: { type: "string" }
|
|
6582
|
+
},
|
|
6583
|
+
{
|
|
6584
|
+
name: "networkId",
|
|
6585
|
+
in: "query",
|
|
6586
|
+
required: true,
|
|
6587
|
+
schema: { type: "string" }
|
|
6588
|
+
}
|
|
6589
|
+
],
|
|
6590
|
+
responses: {
|
|
6591
|
+
200: {
|
|
6592
|
+
description: "Thread deleted"
|
|
6593
|
+
},
|
|
6594
|
+
404: {
|
|
6595
|
+
description: "Thread not found"
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
}),
|
|
6599
|
+
deleteThreadHandler
|
|
6600
|
+
);
|
|
6601
|
+
app.post(
|
|
6602
|
+
"/api/memory/network/save-messages",
|
|
6603
|
+
bodyLimit.bodyLimit(bodyLimitOptions),
|
|
6604
|
+
w({
|
|
6605
|
+
description: "Save messages",
|
|
6606
|
+
tags: ["networkMemory"],
|
|
6607
|
+
parameters: [
|
|
6608
|
+
{
|
|
6609
|
+
name: "networkId",
|
|
6610
|
+
in: "query",
|
|
6611
|
+
required: true,
|
|
6612
|
+
schema: { type: "string" }
|
|
6613
|
+
}
|
|
6614
|
+
],
|
|
6615
|
+
requestBody: {
|
|
6616
|
+
required: true,
|
|
6617
|
+
content: {
|
|
6618
|
+
"application/json": {
|
|
6619
|
+
schema: {
|
|
6620
|
+
type: "object",
|
|
6621
|
+
properties: {
|
|
6622
|
+
messages: {
|
|
6623
|
+
type: "array",
|
|
6624
|
+
items: { type: "object" }
|
|
6625
|
+
}
|
|
6626
|
+
},
|
|
6627
|
+
required: ["messages"]
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
}
|
|
6631
|
+
},
|
|
6632
|
+
responses: {
|
|
6633
|
+
200: {
|
|
6634
|
+
description: "Messages saved"
|
|
6635
|
+
}
|
|
6636
|
+
}
|
|
6637
|
+
}),
|
|
6638
|
+
saveMessagesHandler
|
|
6639
|
+
);
|
|
6080
6640
|
app.get(
|
|
6081
6641
|
"/api/memory/status",
|
|
6082
6642
|
w({
|