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