@mastra/deployer 0.10.7-alpha.1 → 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.js
CHANGED
|
@@ -30,6 +30,7 @@ import { z } from 'zod';
|
|
|
30
30
|
import { getTelemetryHandler as getTelemetryHandler$1, storeTelemetryHandler as storeTelemetryHandler$1 } from '@mastra/server/handlers/telemetry';
|
|
31
31
|
import { executeAgentToolHandler as executeAgentToolHandler$1, getToolsHandler as getToolsHandler$1, getToolByIdHandler as getToolByIdHandler$1, executeToolHandler as executeToolHandler$1 } from '@mastra/server/handlers/tools';
|
|
32
32
|
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 { getVNextNetworksHandler as getVNextNetworksHandler$1, getVNextNetworkByIdHandler as getVNextNetworkByIdHandler$1, generateVNextNetworkHandler as generateVNextNetworkHandler$1, loopVNextNetworkHandler as loopVNextNetworkHandler$1, streamGenerateVNextNetworkHandler as streamGenerateVNextNetworkHandler$1 } from '@mastra/server/handlers/vNextNetwork';
|
|
33
34
|
import { getSpeakersHandler as getSpeakersHandler$1, generateSpeechHandler, getListenerHandler as getListenerHandler$1, transcribeSpeechHandler } from '@mastra/server/handlers/voice';
|
|
34
35
|
import { getWorkflowsHandler as getWorkflowsHandler$1, getWorkflowByIdHandler as getWorkflowByIdHandler$1, getWorkflowRunsHandler as getWorkflowRunsHandler$1, getWorkflowRunExecutionResultHandler as getWorkflowRunExecutionResultHandler$1, getWorkflowRunByIdHandler as getWorkflowRunByIdHandler$1, resumeWorkflowHandler as resumeWorkflowHandler$1, resumeAsyncWorkflowHandler as resumeAsyncWorkflowHandler$1, streamWorkflowHandler as streamWorkflowHandler$1, createWorkflowRunHandler as createWorkflowRunHandler$1, startAsyncWorkflowHandler as startAsyncWorkflowHandler$1, startWorkflowRunHandler as startWorkflowRunHandler$1, watchWorkflowHandler as watchWorkflowHandler$1 } from '@mastra/server/handlers/workflows';
|
|
35
36
|
|
|
@@ -256,14 +257,14 @@ var Response2 = class _Response {
|
|
|
256
257
|
});
|
|
257
258
|
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
258
259
|
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
259
|
-
function writeFromReadableStream(
|
|
260
|
-
if (
|
|
260
|
+
function writeFromReadableStream(stream5, writable) {
|
|
261
|
+
if (stream5.locked) {
|
|
261
262
|
throw new TypeError("ReadableStream is locked.");
|
|
262
263
|
} else if (writable.destroyed) {
|
|
263
|
-
|
|
264
|
+
stream5.cancel();
|
|
264
265
|
return;
|
|
265
266
|
}
|
|
266
|
-
const reader =
|
|
267
|
+
const reader = stream5.getReader();
|
|
267
268
|
writable.on("close", cancel);
|
|
268
269
|
writable.on("error", cancel);
|
|
269
270
|
reader.read().then(flow, cancel);
|
|
@@ -498,18 +499,18 @@ var ENCODINGS = {
|
|
|
498
499
|
gzip: ".gz"
|
|
499
500
|
};
|
|
500
501
|
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
501
|
-
var createStreamBody = (
|
|
502
|
+
var createStreamBody = (stream5) => {
|
|
502
503
|
const body = new ReadableStream({
|
|
503
504
|
start(controller) {
|
|
504
|
-
|
|
505
|
+
stream5.on("data", (chunk) => {
|
|
505
506
|
controller.enqueue(chunk);
|
|
506
507
|
});
|
|
507
|
-
|
|
508
|
+
stream5.on("end", () => {
|
|
508
509
|
controller.close();
|
|
509
510
|
});
|
|
510
511
|
},
|
|
511
512
|
cancel() {
|
|
512
|
-
|
|
513
|
+
stream5.destroy();
|
|
513
514
|
}
|
|
514
515
|
});
|
|
515
516
|
return body;
|
|
@@ -605,10 +606,10 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
605
606
|
end = size - 1;
|
|
606
607
|
}
|
|
607
608
|
const chunksize = end - start + 1;
|
|
608
|
-
const
|
|
609
|
+
const stream5 = createReadStream(path, { start, end });
|
|
609
610
|
c2.header("Content-Length", chunksize.toString());
|
|
610
611
|
c2.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
611
|
-
return c2.body(createStreamBody(
|
|
612
|
+
return c2.body(createStreamBody(stream5), 206);
|
|
612
613
|
};
|
|
613
614
|
};
|
|
614
615
|
var RENDER_TYPE = {
|
|
@@ -729,7 +730,7 @@ var middleware = (options) => async (c2) => {
|
|
|
729
730
|
);
|
|
730
731
|
};
|
|
731
732
|
|
|
732
|
-
// ../../node_modules/.pnpm/hono-openapi@0.4.8_hono@4.
|
|
733
|
+
// ../../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
|
|
733
734
|
var e = Symbol("openapi");
|
|
734
735
|
var n = ["GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"];
|
|
735
736
|
var s2 = (e2) => e2.charAt(0).toUpperCase() + e2.slice(1);
|
|
@@ -904,15 +905,15 @@ async function getAgentExecutionHandler(c2) {
|
|
|
904
905
|
if (body.method === "tasks/sendSubscribe") {
|
|
905
906
|
return stream(
|
|
906
907
|
c2,
|
|
907
|
-
async (
|
|
908
|
+
async (stream5) => {
|
|
908
909
|
try {
|
|
909
|
-
|
|
910
|
+
stream5.onAbort(() => {
|
|
910
911
|
if (!result.locked) {
|
|
911
912
|
return result.cancel();
|
|
912
913
|
}
|
|
913
914
|
});
|
|
914
915
|
for await (const chunk of result) {
|
|
915
|
-
await
|
|
916
|
+
await stream5.write(JSON.stringify(chunk) + "");
|
|
916
917
|
}
|
|
917
918
|
} catch (err) {
|
|
918
919
|
logger2.error("Error in tasks/sendSubscribe stream: " + err?.message);
|
|
@@ -1243,7 +1244,7 @@ var authorizationMiddleware = async (c2, next) => {
|
|
|
1243
1244
|
// src/server/handlers/client.ts
|
|
1244
1245
|
var clients = /* @__PURE__ */ new Set();
|
|
1245
1246
|
function handleClientsRefresh(c2) {
|
|
1246
|
-
const
|
|
1247
|
+
const stream5 = new ReadableStream({
|
|
1247
1248
|
start(controller) {
|
|
1248
1249
|
clients.add(controller);
|
|
1249
1250
|
controller.enqueue("data: connected\n\n");
|
|
@@ -1252,7 +1253,7 @@ function handleClientsRefresh(c2) {
|
|
|
1252
1253
|
});
|
|
1253
1254
|
}
|
|
1254
1255
|
});
|
|
1255
|
-
return new Response(
|
|
1256
|
+
return new Response(stream5, {
|
|
1256
1257
|
headers: {
|
|
1257
1258
|
"Content-Type": "text/event-stream",
|
|
1258
1259
|
"Cache-Control": "no-cache",
|
|
@@ -1359,20 +1360,20 @@ function watchLegacyWorkflowHandler(c2) {
|
|
|
1359
1360
|
}
|
|
1360
1361
|
return stream(
|
|
1361
1362
|
c2,
|
|
1362
|
-
async (
|
|
1363
|
+
async (stream5) => {
|
|
1363
1364
|
try {
|
|
1364
1365
|
const result = await watchLegacyWorkflowHandler$1({
|
|
1365
1366
|
mastra,
|
|
1366
1367
|
workflowId,
|
|
1367
1368
|
runId
|
|
1368
1369
|
});
|
|
1369
|
-
|
|
1370
|
+
stream5.onAbort(() => {
|
|
1370
1371
|
if (!result.locked) {
|
|
1371
1372
|
return result.cancel();
|
|
1372
1373
|
}
|
|
1373
1374
|
});
|
|
1374
1375
|
for await (const chunk of result) {
|
|
1375
|
-
await
|
|
1376
|
+
await stream5.write(chunk.toString() + "");
|
|
1376
1377
|
}
|
|
1377
1378
|
} catch (err) {
|
|
1378
1379
|
console.log(err);
|
|
@@ -3570,9 +3571,11 @@ async function getMemoryStatusHandler(c2) {
|
|
|
3570
3571
|
try {
|
|
3571
3572
|
const mastra = c2.get("mastra");
|
|
3572
3573
|
const agentId = c2.req.query("agentId");
|
|
3574
|
+
const networkId = c2.req.query("networkId");
|
|
3573
3575
|
const result = await getMemoryStatusHandler$1({
|
|
3574
3576
|
mastra,
|
|
3575
|
-
agentId
|
|
3577
|
+
agentId,
|
|
3578
|
+
networkId
|
|
3576
3579
|
});
|
|
3577
3580
|
return c2.json(result);
|
|
3578
3581
|
} catch (error) {
|
|
@@ -3584,10 +3587,12 @@ async function getThreadsHandler(c2) {
|
|
|
3584
3587
|
const mastra = c2.get("mastra");
|
|
3585
3588
|
const agentId = c2.req.query("agentId");
|
|
3586
3589
|
const resourceId = c2.req.query("resourceid");
|
|
3590
|
+
const networkId = c2.req.query("networkId");
|
|
3587
3591
|
const result = await getThreadsHandler$1({
|
|
3588
3592
|
mastra,
|
|
3589
3593
|
agentId,
|
|
3590
|
-
resourceId
|
|
3594
|
+
resourceId,
|
|
3595
|
+
networkId
|
|
3591
3596
|
});
|
|
3592
3597
|
return c2.json(result);
|
|
3593
3598
|
} catch (error) {
|
|
@@ -3599,10 +3604,12 @@ async function getThreadByIdHandler(c2) {
|
|
|
3599
3604
|
const mastra = c2.get("mastra");
|
|
3600
3605
|
const agentId = c2.req.query("agentId");
|
|
3601
3606
|
const threadId = c2.req.param("threadId");
|
|
3607
|
+
const networkId = c2.req.query("networkId");
|
|
3602
3608
|
const result = await getThreadByIdHandler$1({
|
|
3603
3609
|
mastra,
|
|
3604
3610
|
agentId,
|
|
3605
|
-
threadId
|
|
3611
|
+
threadId,
|
|
3612
|
+
networkId
|
|
3606
3613
|
});
|
|
3607
3614
|
return c2.json(result);
|
|
3608
3615
|
} catch (error) {
|
|
@@ -3613,11 +3620,13 @@ async function saveMessagesHandler(c2) {
|
|
|
3613
3620
|
try {
|
|
3614
3621
|
const mastra = c2.get("mastra");
|
|
3615
3622
|
const agentId = c2.req.query("agentId");
|
|
3623
|
+
const networkId = c2.req.query("networkId");
|
|
3616
3624
|
const body = await c2.req.json();
|
|
3617
3625
|
const result = await saveMessagesHandler$1({
|
|
3618
3626
|
mastra,
|
|
3619
3627
|
agentId,
|
|
3620
|
-
body
|
|
3628
|
+
body,
|
|
3629
|
+
networkId
|
|
3621
3630
|
});
|
|
3622
3631
|
return c2.json(result);
|
|
3623
3632
|
} catch (error) {
|
|
@@ -3628,11 +3637,13 @@ async function createThreadHandler(c2) {
|
|
|
3628
3637
|
try {
|
|
3629
3638
|
const mastra = c2.get("mastra");
|
|
3630
3639
|
const agentId = c2.req.query("agentId");
|
|
3640
|
+
const networkId = c2.req.query("networkId");
|
|
3631
3641
|
const body = await c2.req.json();
|
|
3632
3642
|
const result = await createThreadHandler$1({
|
|
3633
3643
|
mastra,
|
|
3634
3644
|
agentId,
|
|
3635
|
-
body
|
|
3645
|
+
body,
|
|
3646
|
+
networkId
|
|
3636
3647
|
});
|
|
3637
3648
|
return c2.json(result);
|
|
3638
3649
|
} catch (error) {
|
|
@@ -3644,12 +3655,14 @@ async function updateThreadHandler(c2) {
|
|
|
3644
3655
|
const mastra = c2.get("mastra");
|
|
3645
3656
|
const agentId = c2.req.query("agentId");
|
|
3646
3657
|
const threadId = c2.req.param("threadId");
|
|
3658
|
+
const networkId = c2.req.query("networkId");
|
|
3647
3659
|
const body = await c2.req.json();
|
|
3648
3660
|
const result = await updateThreadHandler$1({
|
|
3649
3661
|
mastra,
|
|
3650
3662
|
agentId,
|
|
3651
3663
|
threadId,
|
|
3652
|
-
body
|
|
3664
|
+
body,
|
|
3665
|
+
networkId
|
|
3653
3666
|
});
|
|
3654
3667
|
return c2.json(result);
|
|
3655
3668
|
} catch (error) {
|
|
@@ -3661,10 +3674,12 @@ async function deleteThreadHandler(c2) {
|
|
|
3661
3674
|
const mastra = c2.get("mastra");
|
|
3662
3675
|
const agentId = c2.req.query("agentId");
|
|
3663
3676
|
const threadId = c2.req.param("threadId");
|
|
3677
|
+
const networkId = c2.req.query("networkId");
|
|
3664
3678
|
const result = await deleteThreadHandler$1({
|
|
3665
3679
|
mastra,
|
|
3666
3680
|
agentId,
|
|
3667
|
-
threadId
|
|
3681
|
+
threadId,
|
|
3682
|
+
networkId
|
|
3668
3683
|
});
|
|
3669
3684
|
return c2.json(result);
|
|
3670
3685
|
} catch (error) {
|
|
@@ -3675,6 +3690,7 @@ async function getMessagesHandler(c2) {
|
|
|
3675
3690
|
try {
|
|
3676
3691
|
const mastra = c2.get("mastra");
|
|
3677
3692
|
const agentId = c2.req.query("agentId");
|
|
3693
|
+
const networkId = c2.req.query("networkId");
|
|
3678
3694
|
const threadId = c2.req.param("threadId");
|
|
3679
3695
|
const rawLimit = c2.req.query("limit");
|
|
3680
3696
|
let limit = void 0;
|
|
@@ -3688,6 +3704,7 @@ async function getMessagesHandler(c2) {
|
|
|
3688
3704
|
mastra,
|
|
3689
3705
|
agentId,
|
|
3690
3706
|
threadId,
|
|
3707
|
+
networkId,
|
|
3691
3708
|
limit
|
|
3692
3709
|
});
|
|
3693
3710
|
return c2.json(result);
|
|
@@ -4068,6 +4085,106 @@ async function deleteIndex(c2) {
|
|
|
4068
4085
|
return handleError(error, "Error deleting index");
|
|
4069
4086
|
}
|
|
4070
4087
|
}
|
|
4088
|
+
async function getVNextNetworksHandler(c2) {
|
|
4089
|
+
try {
|
|
4090
|
+
const mastra = c2.get("mastra");
|
|
4091
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4092
|
+
const networks = await getVNextNetworksHandler$1({
|
|
4093
|
+
mastra,
|
|
4094
|
+
runtimeContext
|
|
4095
|
+
});
|
|
4096
|
+
return c2.json(networks);
|
|
4097
|
+
} catch (error) {
|
|
4098
|
+
return handleError(error, "Error getting networks");
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
async function getVNextNetworkByIdHandler(c2) {
|
|
4102
|
+
try {
|
|
4103
|
+
const mastra = c2.get("mastra");
|
|
4104
|
+
const networkId = c2.req.param("networkId");
|
|
4105
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4106
|
+
const network = await getVNextNetworkByIdHandler$1({
|
|
4107
|
+
mastra,
|
|
4108
|
+
networkId,
|
|
4109
|
+
runtimeContext
|
|
4110
|
+
});
|
|
4111
|
+
return c2.json(network);
|
|
4112
|
+
} catch (error) {
|
|
4113
|
+
return handleError(error, "Error getting network by ID");
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
async function generateVNextNetworkHandler(c2) {
|
|
4117
|
+
try {
|
|
4118
|
+
const mastra = c2.get("mastra");
|
|
4119
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4120
|
+
const networkId = c2.req.param("networkId");
|
|
4121
|
+
const body = await c2.req.json();
|
|
4122
|
+
const result = await generateVNextNetworkHandler$1({
|
|
4123
|
+
mastra,
|
|
4124
|
+
runtimeContext,
|
|
4125
|
+
networkId,
|
|
4126
|
+
body
|
|
4127
|
+
});
|
|
4128
|
+
return c2.json(result);
|
|
4129
|
+
} catch (error) {
|
|
4130
|
+
return handleError(error, "Error generating from network");
|
|
4131
|
+
}
|
|
4132
|
+
}
|
|
4133
|
+
async function streamGenerateVNextNetworkHandler(c2) {
|
|
4134
|
+
try {
|
|
4135
|
+
const mastra = c2.get("mastra");
|
|
4136
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4137
|
+
const logger2 = mastra.getLogger();
|
|
4138
|
+
const networkId = c2.req.param("networkId");
|
|
4139
|
+
const body = await c2.req.json();
|
|
4140
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4141
|
+
return stream(
|
|
4142
|
+
c2,
|
|
4143
|
+
async (stream5) => {
|
|
4144
|
+
try {
|
|
4145
|
+
const result = await streamGenerateVNextNetworkHandler$1({
|
|
4146
|
+
mastra,
|
|
4147
|
+
runtimeContext,
|
|
4148
|
+
networkId,
|
|
4149
|
+
body
|
|
4150
|
+
});
|
|
4151
|
+
const reader = result.stream.getReader();
|
|
4152
|
+
stream5.onAbort(() => {
|
|
4153
|
+
void reader.cancel("request aborted");
|
|
4154
|
+
});
|
|
4155
|
+
let chunkResult;
|
|
4156
|
+
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4157
|
+
await stream5.write(JSON.stringify(chunkResult.value) + "");
|
|
4158
|
+
}
|
|
4159
|
+
} catch (err) {
|
|
4160
|
+
mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
4161
|
+
}
|
|
4162
|
+
},
|
|
4163
|
+
async (err) => {
|
|
4164
|
+
logger2.error("Error in watch stream: " + err?.message);
|
|
4165
|
+
}
|
|
4166
|
+
);
|
|
4167
|
+
} catch (error) {
|
|
4168
|
+
return handleError(error, "Error streaming from network");
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
async function loopVNextNetworkHandler(c2) {
|
|
4172
|
+
try {
|
|
4173
|
+
const mastra = c2.get("mastra");
|
|
4174
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4175
|
+
const networkId = c2.req.param("networkId");
|
|
4176
|
+
const body = await c2.req.json();
|
|
4177
|
+
const result = await loopVNextNetworkHandler$1({
|
|
4178
|
+
mastra,
|
|
4179
|
+
runtimeContext,
|
|
4180
|
+
networkId,
|
|
4181
|
+
body
|
|
4182
|
+
});
|
|
4183
|
+
return c2.json(result);
|
|
4184
|
+
} catch (error) {
|
|
4185
|
+
return handleError(error, "Error looping from network");
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4071
4188
|
async function getSpeakersHandler(c2) {
|
|
4072
4189
|
try {
|
|
4073
4190
|
const mastra = c2.get("mastra");
|
|
@@ -4182,8 +4299,9 @@ async function createWorkflowRunHandler(c2) {
|
|
|
4182
4299
|
async function startAsyncWorkflowHandler(c2) {
|
|
4183
4300
|
try {
|
|
4184
4301
|
const mastra = c2.get("mastra");
|
|
4302
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4185
4303
|
const workflowId = c2.req.param("workflowId");
|
|
4186
|
-
const { inputData
|
|
4304
|
+
const { inputData } = await c2.req.json();
|
|
4187
4305
|
const runId = c2.req.query("runId");
|
|
4188
4306
|
const result = await startAsyncWorkflowHandler$1({
|
|
4189
4307
|
mastra,
|
|
@@ -4200,8 +4318,9 @@ async function startAsyncWorkflowHandler(c2) {
|
|
|
4200
4318
|
async function startWorkflowRunHandler(c2) {
|
|
4201
4319
|
try {
|
|
4202
4320
|
const mastra = c2.get("mastra");
|
|
4321
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4203
4322
|
const workflowId = c2.req.param("workflowId");
|
|
4204
|
-
const { inputData
|
|
4323
|
+
const { inputData } = await c2.req.json();
|
|
4205
4324
|
const runId = c2.req.query("runId");
|
|
4206
4325
|
await startWorkflowRunHandler$1({
|
|
4207
4326
|
mastra,
|
|
@@ -4224,9 +4343,10 @@ function watchWorkflowHandler(c2) {
|
|
|
4224
4343
|
if (!runId) {
|
|
4225
4344
|
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
4226
4345
|
}
|
|
4346
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4227
4347
|
return stream(
|
|
4228
4348
|
c2,
|
|
4229
|
-
async (
|
|
4349
|
+
async (stream5) => {
|
|
4230
4350
|
try {
|
|
4231
4351
|
const result = await watchWorkflowHandler$1({
|
|
4232
4352
|
mastra,
|
|
@@ -4234,12 +4354,12 @@ function watchWorkflowHandler(c2) {
|
|
|
4234
4354
|
runId
|
|
4235
4355
|
});
|
|
4236
4356
|
const reader = result.getReader();
|
|
4237
|
-
|
|
4357
|
+
stream5.onAbort(() => {
|
|
4238
4358
|
void reader.cancel("request aborted");
|
|
4239
4359
|
});
|
|
4240
4360
|
let chunkResult;
|
|
4241
4361
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4242
|
-
await
|
|
4362
|
+
await stream5.write(JSON.stringify(chunkResult.value) + "");
|
|
4243
4363
|
}
|
|
4244
4364
|
} catch (err) {
|
|
4245
4365
|
mastra.getLogger().error("Error in watch stream: " + (err?.message ?? "Unknown error"));
|
|
@@ -4256,13 +4376,15 @@ function watchWorkflowHandler(c2) {
|
|
|
4256
4376
|
async function streamWorkflowHandler(c2) {
|
|
4257
4377
|
try {
|
|
4258
4378
|
const mastra = c2.get("mastra");
|
|
4379
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4259
4380
|
const logger2 = mastra.getLogger();
|
|
4260
4381
|
const workflowId = c2.req.param("workflowId");
|
|
4261
|
-
const { inputData
|
|
4382
|
+
const { inputData } = await c2.req.json();
|
|
4262
4383
|
const runId = c2.req.query("runId");
|
|
4384
|
+
c2.header("Transfer-Encoding", "chunked");
|
|
4263
4385
|
return stream(
|
|
4264
4386
|
c2,
|
|
4265
|
-
async (
|
|
4387
|
+
async (stream5) => {
|
|
4266
4388
|
try {
|
|
4267
4389
|
const result = await streamWorkflowHandler$1({
|
|
4268
4390
|
mastra,
|
|
@@ -4272,12 +4394,12 @@ async function streamWorkflowHandler(c2) {
|
|
|
4272
4394
|
runtimeContext
|
|
4273
4395
|
});
|
|
4274
4396
|
const reader = result.stream.getReader();
|
|
4275
|
-
|
|
4397
|
+
stream5.onAbort(() => {
|
|
4276
4398
|
void reader.cancel("request aborted");
|
|
4277
4399
|
});
|
|
4278
4400
|
let chunkResult;
|
|
4279
4401
|
while ((chunkResult = await reader.read()) && !chunkResult.done) {
|
|
4280
|
-
await
|
|
4402
|
+
await stream5.write(JSON.stringify(chunkResult.value) + "");
|
|
4281
4403
|
}
|
|
4282
4404
|
} catch (err) {
|
|
4283
4405
|
console.log(err);
|
|
@@ -4294,9 +4416,10 @@ async function streamWorkflowHandler(c2) {
|
|
|
4294
4416
|
async function resumeAsyncWorkflowHandler(c2) {
|
|
4295
4417
|
try {
|
|
4296
4418
|
const mastra = c2.get("mastra");
|
|
4419
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4297
4420
|
const workflowId = c2.req.param("workflowId");
|
|
4298
4421
|
const runId = c2.req.query("runId");
|
|
4299
|
-
const { step, resumeData
|
|
4422
|
+
const { step, resumeData } = await c2.req.json();
|
|
4300
4423
|
if (!runId) {
|
|
4301
4424
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
4302
4425
|
}
|
|
@@ -4315,9 +4438,10 @@ async function resumeAsyncWorkflowHandler(c2) {
|
|
|
4315
4438
|
async function resumeWorkflowHandler(c2) {
|
|
4316
4439
|
try {
|
|
4317
4440
|
const mastra = c2.get("mastra");
|
|
4441
|
+
const runtimeContext = c2.get("runtimeContext");
|
|
4318
4442
|
const workflowId = c2.req.param("workflowId");
|
|
4319
4443
|
const runId = c2.req.query("runId");
|
|
4320
|
-
const { step, resumeData
|
|
4444
|
+
const { step, resumeData } = await c2.req.json();
|
|
4321
4445
|
if (!runId) {
|
|
4322
4446
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
4323
4447
|
}
|
|
@@ -4792,6 +4916,185 @@ ${err.stack.split("\n").slice(1).join("\n")}
|
|
|
4792
4916
|
}),
|
|
4793
4917
|
getAgentsHandler
|
|
4794
4918
|
);
|
|
4919
|
+
app.get(
|
|
4920
|
+
"/api/networks/v-next",
|
|
4921
|
+
w({
|
|
4922
|
+
description: "Get all available v-next networks",
|
|
4923
|
+
tags: ["vNextNetworks"],
|
|
4924
|
+
responses: {
|
|
4925
|
+
200: {
|
|
4926
|
+
description: "List of all v-next networks"
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
}),
|
|
4930
|
+
getVNextNetworksHandler
|
|
4931
|
+
);
|
|
4932
|
+
app.get(
|
|
4933
|
+
"/api/networks/v-next/:networkId",
|
|
4934
|
+
w({
|
|
4935
|
+
description: "Get v-next network by ID",
|
|
4936
|
+
tags: ["vNextNetworks"],
|
|
4937
|
+
parameters: [
|
|
4938
|
+
{
|
|
4939
|
+
name: "networkId",
|
|
4940
|
+
in: "path",
|
|
4941
|
+
required: true,
|
|
4942
|
+
schema: { type: "string" }
|
|
4943
|
+
}
|
|
4944
|
+
],
|
|
4945
|
+
responses: {
|
|
4946
|
+
200: {
|
|
4947
|
+
description: "v-next Network details"
|
|
4948
|
+
},
|
|
4949
|
+
404: {
|
|
4950
|
+
description: "v-next Network not found"
|
|
4951
|
+
}
|
|
4952
|
+
}
|
|
4953
|
+
}),
|
|
4954
|
+
getVNextNetworkByIdHandler
|
|
4955
|
+
);
|
|
4956
|
+
app.post(
|
|
4957
|
+
"/api/networks/v-next/:networkId/generate",
|
|
4958
|
+
bodyLimit(bodyLimitOptions),
|
|
4959
|
+
w({
|
|
4960
|
+
description: "Generate a response from a v-next network",
|
|
4961
|
+
tags: ["vNextNetworks"],
|
|
4962
|
+
parameters: [
|
|
4963
|
+
{
|
|
4964
|
+
name: "networkId",
|
|
4965
|
+
in: "path",
|
|
4966
|
+
required: true,
|
|
4967
|
+
schema: { type: "string" }
|
|
4968
|
+
}
|
|
4969
|
+
],
|
|
4970
|
+
requestBody: {
|
|
4971
|
+
required: true,
|
|
4972
|
+
content: {
|
|
4973
|
+
"application/json": {
|
|
4974
|
+
schema: {
|
|
4975
|
+
type: "object",
|
|
4976
|
+
properties: {
|
|
4977
|
+
message: {
|
|
4978
|
+
type: "string",
|
|
4979
|
+
description: "Message for the v-next network"
|
|
4980
|
+
},
|
|
4981
|
+
threadId: {
|
|
4982
|
+
type: "string",
|
|
4983
|
+
description: "Thread Id of the conversation"
|
|
4984
|
+
},
|
|
4985
|
+
resourceId: {
|
|
4986
|
+
type: "string",
|
|
4987
|
+
description: "Resource Id of the conversation"
|
|
4988
|
+
}
|
|
4989
|
+
},
|
|
4990
|
+
required: ["message"]
|
|
4991
|
+
}
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
},
|
|
4995
|
+
responses: {
|
|
4996
|
+
200: {
|
|
4997
|
+
description: "Generated response"
|
|
4998
|
+
},
|
|
4999
|
+
404: {
|
|
5000
|
+
description: "v-next Network not found"
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
}),
|
|
5004
|
+
generateVNextNetworkHandler
|
|
5005
|
+
);
|
|
5006
|
+
app.post(
|
|
5007
|
+
"/api/networks/v-next/:networkId/loop",
|
|
5008
|
+
bodyLimit(bodyLimitOptions),
|
|
5009
|
+
w({
|
|
5010
|
+
description: "Loop a v-next network",
|
|
5011
|
+
tags: ["vNextNetworks"],
|
|
5012
|
+
parameters: [
|
|
5013
|
+
{
|
|
5014
|
+
name: "networkId",
|
|
5015
|
+
in: "path",
|
|
5016
|
+
required: true,
|
|
5017
|
+
schema: { type: "string" }
|
|
5018
|
+
}
|
|
5019
|
+
],
|
|
5020
|
+
requestBody: {
|
|
5021
|
+
required: true,
|
|
5022
|
+
content: {
|
|
5023
|
+
"application/json": {
|
|
5024
|
+
schema: {
|
|
5025
|
+
type: "object",
|
|
5026
|
+
properties: {
|
|
5027
|
+
message: {
|
|
5028
|
+
type: "string",
|
|
5029
|
+
description: "Message for the v-next network"
|
|
5030
|
+
}
|
|
5031
|
+
},
|
|
5032
|
+
required: ["message"]
|
|
5033
|
+
}
|
|
5034
|
+
}
|
|
5035
|
+
}
|
|
5036
|
+
},
|
|
5037
|
+
responses: {
|
|
5038
|
+
200: {
|
|
5039
|
+
description: "Looped response"
|
|
5040
|
+
},
|
|
5041
|
+
404: {
|
|
5042
|
+
description: "v-next Network not found"
|
|
5043
|
+
}
|
|
5044
|
+
}
|
|
5045
|
+
}),
|
|
5046
|
+
loopVNextNetworkHandler
|
|
5047
|
+
);
|
|
5048
|
+
app.post(
|
|
5049
|
+
"/api/networks/v-next/:networkId/stream",
|
|
5050
|
+
bodyLimit(bodyLimitOptions),
|
|
5051
|
+
w({
|
|
5052
|
+
description: "Generate a response from a v-next network",
|
|
5053
|
+
tags: ["vNextNetworks"],
|
|
5054
|
+
parameters: [
|
|
5055
|
+
{
|
|
5056
|
+
name: "networkId",
|
|
5057
|
+
in: "path",
|
|
5058
|
+
required: true,
|
|
5059
|
+
schema: { type: "string" }
|
|
5060
|
+
}
|
|
5061
|
+
],
|
|
5062
|
+
requestBody: {
|
|
5063
|
+
required: true,
|
|
5064
|
+
content: {
|
|
5065
|
+
"application/json": {
|
|
5066
|
+
schema: {
|
|
5067
|
+
type: "object",
|
|
5068
|
+
properties: {
|
|
5069
|
+
message: {
|
|
5070
|
+
type: "string",
|
|
5071
|
+
description: "Message for the v-next network"
|
|
5072
|
+
},
|
|
5073
|
+
threadId: {
|
|
5074
|
+
type: "string",
|
|
5075
|
+
description: "Thread Id of the conversation"
|
|
5076
|
+
},
|
|
5077
|
+
resourceId: {
|
|
5078
|
+
type: "string",
|
|
5079
|
+
description: "Resource Id of the conversation"
|
|
5080
|
+
}
|
|
5081
|
+
},
|
|
5082
|
+
required: ["message"]
|
|
5083
|
+
}
|
|
5084
|
+
}
|
|
5085
|
+
}
|
|
5086
|
+
},
|
|
5087
|
+
responses: {
|
|
5088
|
+
200: {
|
|
5089
|
+
description: "Generated response"
|
|
5090
|
+
},
|
|
5091
|
+
404: {
|
|
5092
|
+
description: "v-next Network not found"
|
|
5093
|
+
}
|
|
5094
|
+
}
|
|
5095
|
+
}),
|
|
5096
|
+
streamGenerateVNextNetworkHandler
|
|
5097
|
+
);
|
|
4795
5098
|
app.get(
|
|
4796
5099
|
"/api/networks",
|
|
4797
5100
|
w({
|
|
@@ -6070,6 +6373,263 @@ ${err.stack.split("\n").slice(1).join("\n")}
|
|
|
6070
6373
|
}),
|
|
6071
6374
|
executeMcpServerToolHandler
|
|
6072
6375
|
);
|
|
6376
|
+
app.get(
|
|
6377
|
+
"/api/memory/network/status",
|
|
6378
|
+
w({
|
|
6379
|
+
description: "Get network memory status",
|
|
6380
|
+
tags: ["networkMemory"],
|
|
6381
|
+
parameters: [
|
|
6382
|
+
{
|
|
6383
|
+
name: "networkId",
|
|
6384
|
+
in: "query",
|
|
6385
|
+
required: true,
|
|
6386
|
+
schema: { type: "string" }
|
|
6387
|
+
}
|
|
6388
|
+
],
|
|
6389
|
+
responses: {
|
|
6390
|
+
200: {
|
|
6391
|
+
description: "Memory status"
|
|
6392
|
+
}
|
|
6393
|
+
}
|
|
6394
|
+
}),
|
|
6395
|
+
getMemoryStatusHandler
|
|
6396
|
+
);
|
|
6397
|
+
app.get(
|
|
6398
|
+
"/api/memory/network/threads",
|
|
6399
|
+
w({
|
|
6400
|
+
description: "Get all threads",
|
|
6401
|
+
tags: ["networkMemory"],
|
|
6402
|
+
parameters: [
|
|
6403
|
+
{
|
|
6404
|
+
name: "resourceid",
|
|
6405
|
+
in: "query",
|
|
6406
|
+
required: true,
|
|
6407
|
+
schema: { type: "string" }
|
|
6408
|
+
},
|
|
6409
|
+
{
|
|
6410
|
+
name: "networkId",
|
|
6411
|
+
in: "query",
|
|
6412
|
+
required: true,
|
|
6413
|
+
schema: { type: "string" }
|
|
6414
|
+
}
|
|
6415
|
+
],
|
|
6416
|
+
responses: {
|
|
6417
|
+
200: {
|
|
6418
|
+
description: "List of all threads"
|
|
6419
|
+
}
|
|
6420
|
+
}
|
|
6421
|
+
}),
|
|
6422
|
+
getThreadsHandler
|
|
6423
|
+
);
|
|
6424
|
+
app.get(
|
|
6425
|
+
"/api/memory/network/threads/:threadId",
|
|
6426
|
+
w({
|
|
6427
|
+
description: "Get thread by ID",
|
|
6428
|
+
tags: ["networkMemory"],
|
|
6429
|
+
parameters: [
|
|
6430
|
+
{
|
|
6431
|
+
name: "threadId",
|
|
6432
|
+
in: "path",
|
|
6433
|
+
required: true,
|
|
6434
|
+
schema: { type: "string" }
|
|
6435
|
+
},
|
|
6436
|
+
{
|
|
6437
|
+
name: "networkId",
|
|
6438
|
+
in: "query",
|
|
6439
|
+
required: true,
|
|
6440
|
+
schema: { type: "string" }
|
|
6441
|
+
}
|
|
6442
|
+
],
|
|
6443
|
+
responses: {
|
|
6444
|
+
200: {
|
|
6445
|
+
description: "Thread details"
|
|
6446
|
+
},
|
|
6447
|
+
404: {
|
|
6448
|
+
description: "Thread not found"
|
|
6449
|
+
}
|
|
6450
|
+
}
|
|
6451
|
+
}),
|
|
6452
|
+
getThreadByIdHandler
|
|
6453
|
+
);
|
|
6454
|
+
app.get(
|
|
6455
|
+
"/api/memory/network/threads/:threadId/messages",
|
|
6456
|
+
w({
|
|
6457
|
+
description: "Get messages for a thread",
|
|
6458
|
+
tags: ["networkMemory"],
|
|
6459
|
+
parameters: [
|
|
6460
|
+
{
|
|
6461
|
+
name: "threadId",
|
|
6462
|
+
in: "path",
|
|
6463
|
+
required: true,
|
|
6464
|
+
schema: { type: "string" }
|
|
6465
|
+
},
|
|
6466
|
+
{
|
|
6467
|
+
name: "networkId",
|
|
6468
|
+
in: "query",
|
|
6469
|
+
required: true,
|
|
6470
|
+
schema: { type: "string" }
|
|
6471
|
+
},
|
|
6472
|
+
{
|
|
6473
|
+
name: "limit",
|
|
6474
|
+
in: "query",
|
|
6475
|
+
required: false,
|
|
6476
|
+
schema: { type: "number" },
|
|
6477
|
+
description: "Limit the number of messages to retrieve (default: 40)"
|
|
6478
|
+
}
|
|
6479
|
+
],
|
|
6480
|
+
responses: {
|
|
6481
|
+
200: {
|
|
6482
|
+
description: "List of messages"
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
}),
|
|
6486
|
+
getMessagesHandler
|
|
6487
|
+
);
|
|
6488
|
+
app.post(
|
|
6489
|
+
"/api/memory/network/threads",
|
|
6490
|
+
bodyLimit(bodyLimitOptions),
|
|
6491
|
+
w({
|
|
6492
|
+
description: "Create a new thread",
|
|
6493
|
+
tags: ["networkMemory"],
|
|
6494
|
+
parameters: [
|
|
6495
|
+
{
|
|
6496
|
+
name: "networkId",
|
|
6497
|
+
in: "query",
|
|
6498
|
+
required: true,
|
|
6499
|
+
schema: { type: "string" }
|
|
6500
|
+
}
|
|
6501
|
+
],
|
|
6502
|
+
requestBody: {
|
|
6503
|
+
required: true,
|
|
6504
|
+
content: {
|
|
6505
|
+
"application/json": {
|
|
6506
|
+
schema: {
|
|
6507
|
+
type: "object",
|
|
6508
|
+
properties: {
|
|
6509
|
+
title: { type: "string" },
|
|
6510
|
+
metadata: { type: "object" },
|
|
6511
|
+
resourceId: { type: "string" },
|
|
6512
|
+
threadId: { type: "string" }
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
}
|
|
6517
|
+
},
|
|
6518
|
+
responses: {
|
|
6519
|
+
200: {
|
|
6520
|
+
description: "Created thread"
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
}),
|
|
6524
|
+
createThreadHandler
|
|
6525
|
+
);
|
|
6526
|
+
app.patch(
|
|
6527
|
+
"/api/memory/network/threads/:threadId",
|
|
6528
|
+
w({
|
|
6529
|
+
description: "Update a thread",
|
|
6530
|
+
tags: ["networkMemory"],
|
|
6531
|
+
parameters: [
|
|
6532
|
+
{
|
|
6533
|
+
name: "threadId",
|
|
6534
|
+
in: "path",
|
|
6535
|
+
required: true,
|
|
6536
|
+
schema: { type: "string" }
|
|
6537
|
+
},
|
|
6538
|
+
{
|
|
6539
|
+
name: "networkId",
|
|
6540
|
+
in: "query",
|
|
6541
|
+
required: true,
|
|
6542
|
+
schema: { type: "string" }
|
|
6543
|
+
}
|
|
6544
|
+
],
|
|
6545
|
+
requestBody: {
|
|
6546
|
+
required: true,
|
|
6547
|
+
content: {
|
|
6548
|
+
"application/json": {
|
|
6549
|
+
schema: { type: "object" }
|
|
6550
|
+
}
|
|
6551
|
+
}
|
|
6552
|
+
},
|
|
6553
|
+
responses: {
|
|
6554
|
+
200: {
|
|
6555
|
+
description: "Updated thread"
|
|
6556
|
+
},
|
|
6557
|
+
404: {
|
|
6558
|
+
description: "Thread not found"
|
|
6559
|
+
}
|
|
6560
|
+
}
|
|
6561
|
+
}),
|
|
6562
|
+
updateThreadHandler
|
|
6563
|
+
);
|
|
6564
|
+
app.delete(
|
|
6565
|
+
"/api/memory/network/threads/:threadId",
|
|
6566
|
+
w({
|
|
6567
|
+
description: "Delete a thread",
|
|
6568
|
+
tags: ["networkMemory"],
|
|
6569
|
+
parameters: [
|
|
6570
|
+
{
|
|
6571
|
+
name: "threadId",
|
|
6572
|
+
in: "path",
|
|
6573
|
+
required: true,
|
|
6574
|
+
schema: { type: "string" }
|
|
6575
|
+
},
|
|
6576
|
+
{
|
|
6577
|
+
name: "networkId",
|
|
6578
|
+
in: "query",
|
|
6579
|
+
required: true,
|
|
6580
|
+
schema: { type: "string" }
|
|
6581
|
+
}
|
|
6582
|
+
],
|
|
6583
|
+
responses: {
|
|
6584
|
+
200: {
|
|
6585
|
+
description: "Thread deleted"
|
|
6586
|
+
},
|
|
6587
|
+
404: {
|
|
6588
|
+
description: "Thread not found"
|
|
6589
|
+
}
|
|
6590
|
+
}
|
|
6591
|
+
}),
|
|
6592
|
+
deleteThreadHandler
|
|
6593
|
+
);
|
|
6594
|
+
app.post(
|
|
6595
|
+
"/api/memory/network/save-messages",
|
|
6596
|
+
bodyLimit(bodyLimitOptions),
|
|
6597
|
+
w({
|
|
6598
|
+
description: "Save messages",
|
|
6599
|
+
tags: ["networkMemory"],
|
|
6600
|
+
parameters: [
|
|
6601
|
+
{
|
|
6602
|
+
name: "networkId",
|
|
6603
|
+
in: "query",
|
|
6604
|
+
required: true,
|
|
6605
|
+
schema: { type: "string" }
|
|
6606
|
+
}
|
|
6607
|
+
],
|
|
6608
|
+
requestBody: {
|
|
6609
|
+
required: true,
|
|
6610
|
+
content: {
|
|
6611
|
+
"application/json": {
|
|
6612
|
+
schema: {
|
|
6613
|
+
type: "object",
|
|
6614
|
+
properties: {
|
|
6615
|
+
messages: {
|
|
6616
|
+
type: "array",
|
|
6617
|
+
items: { type: "object" }
|
|
6618
|
+
}
|
|
6619
|
+
},
|
|
6620
|
+
required: ["messages"]
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6624
|
+
},
|
|
6625
|
+
responses: {
|
|
6626
|
+
200: {
|
|
6627
|
+
description: "Messages saved"
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
}),
|
|
6631
|
+
saveMessagesHandler
|
|
6632
|
+
);
|
|
6073
6633
|
app.get(
|
|
6074
6634
|
"/api/memory/status",
|
|
6075
6635
|
w({
|