@mastra/deployer 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012
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/CHANGELOG.md +600 -4
- package/dist/{arktype-aI7TBD0R-KDQREPJX.cjs → arktype-aI7TBD0R-OMYN7WLS.cjs} +3 -3
- package/dist/{arktype-aI7TBD0R-KDQREPJX.cjs.map → arktype-aI7TBD0R-OMYN7WLS.cjs.map} +1 -1
- package/dist/arktype-aI7TBD0R-QMBQV4AR.js +8 -0
- package/dist/{arktype-aI7TBD0R-ZWWNQCOB.js.map → arktype-aI7TBD0R-QMBQV4AR.js.map} +1 -1
- package/dist/build/analyze/analyzeEntry.d.ts +12 -8
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/index.cjs +9 -9
- package/dist/build/index.js +3 -3
- package/dist/bundler/index.cjs +3 -3
- package/dist/bundler/index.d.ts +3 -2
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/chunk-2QB4KRZ2.js +3 -0
- package/dist/{chunk-T4RKC5QV.js.map → chunk-2QB4KRZ2.js.map} +1 -1
- package/dist/{chunk-AWHSQOUQ.cjs → chunk-36O25PW6.cjs} +26 -13
- package/dist/chunk-36O25PW6.cjs.map +1 -0
- package/dist/{chunk-JSSXR73I.cjs → chunk-3VBSJXBZ.cjs} +3 -3
- package/dist/{chunk-JSSXR73I.cjs.map → chunk-3VBSJXBZ.cjs.map} +1 -1
- package/dist/{chunk-BDHVEJTQ.js → chunk-4KIRQ3MQ.js} +22 -9
- package/dist/chunk-4KIRQ3MQ.js.map +1 -0
- package/dist/{chunk-KT65JENA.js → chunk-AEFF4KNF.js} +3 -3
- package/dist/{chunk-KT65JENA.js.map → chunk-AEFF4KNF.js.map} +1 -1
- package/dist/{chunk-UG5NXO4O.cjs → chunk-AW5HL7NI.cjs} +3 -3
- package/dist/{chunk-UG5NXO4O.cjs.map → chunk-AW5HL7NI.cjs.map} +1 -1
- package/dist/chunk-BAZETKRJ.cjs +16 -0
- package/dist/{chunk-7BKYJAZW.cjs.map → chunk-BAZETKRJ.cjs.map} +1 -1
- package/dist/{chunk-IUSC3KWD.cjs → chunk-D5QDTUSF.cjs} +23 -9
- package/dist/chunk-D5QDTUSF.cjs.map +1 -0
- package/dist/chunk-DZCA547Z.js +6 -0
- package/dist/{chunk-ET6PLIDX.js.map → chunk-DZCA547Z.js.map} +1 -1
- package/dist/{chunk-DPDWM7HQ.js → chunk-I7JM5EHU.js} +11 -9
- package/dist/chunk-I7JM5EHU.js.map +1 -0
- package/dist/chunk-KK7AQ3E6.js +14 -0
- package/dist/{chunk-5UGF6JNH.js.map → chunk-KK7AQ3E6.js.map} +1 -1
- package/dist/{chunk-2U6TYFYX.js → chunk-MLMAPMI3.js} +23 -9
- package/dist/chunk-MLMAPMI3.js.map +1 -0
- package/dist/{chunk-JVBCN3RH.cjs → chunk-QJGW77MV.cjs} +12 -10
- package/dist/chunk-QJGW77MV.cjs.map +1 -0
- package/dist/{chunk-PBD4CW5D.cjs → chunk-QJIDGPHH.cjs} +6 -6
- package/dist/{chunk-PBD4CW5D.cjs.map → chunk-QJIDGPHH.cjs.map} +1 -1
- package/dist/{chunk-FCU32O3P.js → chunk-RPAZ7M7U.js} +3 -3
- package/dist/{chunk-FCU32O3P.js.map → chunk-RPAZ7M7U.js.map} +1 -1
- package/dist/{chunk-4IBKYKKJ.cjs → chunk-SLVYHUWE.cjs} +9 -9
- package/dist/{chunk-4IBKYKKJ.cjs.map → chunk-SLVYHUWE.cjs.map} +1 -1
- package/dist/chunk-XL2IMSPU.cjs +4 -0
- package/dist/{chunk-CDV3FABH.cjs.map → chunk-XL2IMSPU.cjs.map} +1 -1
- package/dist/{chunk-2B7VXVGJ.js → chunk-Z34VHFWS.js} +9 -9
- package/dist/{chunk-2B7VXVGJ.js.map → chunk-Z34VHFWS.js.map} +1 -1
- package/dist/default-u_dwuiYb-5HOCVF42.cjs +9 -0
- package/dist/{default-u_dwuiYb-ZFP4NIKX.cjs.map → default-u_dwuiYb-5HOCVF42.cjs.map} +1 -1
- package/dist/default-u_dwuiYb-AHUWITSW.js +3 -0
- package/dist/{default-u_dwuiYb-4JHTSSYF.js.map → default-u_dwuiYb-AHUWITSW.js.map} +1 -1
- package/dist/deploy/log.d.ts +2 -2
- package/dist/deploy/log.d.ts.map +1 -1
- package/dist/dist-M5Q4LZIO.js +521 -0
- package/dist/dist-M5Q4LZIO.js.map +1 -0
- package/dist/dist-UMLKEE6J.cjs +527 -0
- package/dist/dist-UMLKEE6J.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +7 -7
- package/dist/docs/references/docs-deployment-cloud-providers.md +5 -1
- package/dist/docs/references/docs-deployment-mastra-server.md +4 -4
- package/dist/docs/references/docs-deployment-monorepo.md +3 -3
- package/dist/docs/references/docs-deployment-overview.md +11 -8
- package/dist/{effect-QlVUlMFu-WLHFHF2M.js → effect-QlVUlMFu-GE6KSQJR.js} +4 -4
- package/dist/{effect-QlVUlMFu-WLHFHF2M.js.map → effect-QlVUlMFu-GE6KSQJR.js.map} +1 -1
- package/dist/effect-QlVUlMFu-LW2RUXNH.cjs +17 -0
- package/dist/{effect-QlVUlMFu-VG5PIUDR.cjs.map → effect-QlVUlMFu-LW2RUXNH.cjs.map} +1 -1
- package/dist/{esm-QRZBFGMJ.js → esm-5JD7C52A.js} +39 -39
- package/dist/{esm-QRZBFGMJ.js.map → esm-5JD7C52A.js.map} +1 -1
- package/dist/{esm-5FERASCB.cjs → esm-BC76JWEF.cjs} +39 -39
- package/dist/{esm-5FERASCB.cjs.map → esm-BC76JWEF.cjs.map} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.js +3 -3
- package/dist/server/handlers/a2a.d.ts +20 -0
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/index.cjs +505 -108
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +506 -109
- package/dist/server/index.js.map +1 -1
- package/dist/server/welcome.d.ts +1 -1
- package/dist/server/welcome.d.ts.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/dist/{sury-CWZTCd75-6S3EK3HQ.js → sury-CWZTCd75-JQJDKHT2.js} +4 -4
- package/dist/{sury-CWZTCd75-6S3EK3HQ.js.map → sury-CWZTCd75-JQJDKHT2.js.map} +1 -1
- package/dist/sury-CWZTCd75-TJFDB7YN.cjs +17 -0
- package/dist/{sury-CWZTCd75-CGVIVOF6.cjs.map → sury-CWZTCd75-TJFDB7YN.cjs.map} +1 -1
- package/dist/typebox-Dei93FPO-GYRBKU22.js +8 -0
- package/dist/{typebox-Dei93FPO-TMKHP62N.js.map → typebox-Dei93FPO-GYRBKU22.js.map} +1 -1
- package/dist/{typebox-Dei93FPO-UMQNRUCX.cjs → typebox-Dei93FPO-VMOENLRC.cjs} +3 -3
- package/dist/{typebox-Dei93FPO-UMQNRUCX.cjs.map → typebox-Dei93FPO-VMOENLRC.cjs.map} +1 -1
- package/dist/valibot--1zFm7rT-DBL2FAXB.cjs +17 -0
- package/dist/{valibot--1zFm7rT-JZ665QU6.cjs.map → valibot--1zFm7rT-DBL2FAXB.cjs.map} +1 -1
- package/dist/valibot--1zFm7rT-PDIN22QQ.js +15 -0
- package/dist/{valibot--1zFm7rT-R4ZJGFUC.js.map → valibot--1zFm7rT-PDIN22QQ.js.map} +1 -1
- package/dist/{valibot-D_HTw1Gn-M2UMWTWB.cjs → valibot-D_HTw1Gn-L3QJICXD.cjs} +7 -7
- package/dist/{valibot-D_HTw1Gn-M2UMWTWB.cjs.map → valibot-D_HTw1Gn-L3QJICXD.cjs.map} +1 -1
- package/dist/{valibot-D_HTw1Gn-XLQRXUSZ.js → valibot-D_HTw1Gn-YGP7CQY7.js} +5 -5
- package/dist/{valibot-D_HTw1Gn-XLQRXUSZ.js.map → valibot-D_HTw1Gn-YGP7CQY7.js.map} +1 -1
- package/dist/{zod-Bwrt9trS-VIE7ENS2.cjs → zod-Bwrt9trS-3ZVP7FWM.cjs} +7 -7
- package/dist/{zod-Bwrt9trS-VIE7ENS2.cjs.map → zod-Bwrt9trS-3ZVP7FWM.cjs.map} +1 -1
- package/dist/{zod-Bwrt9trS-VQQB2XYB.js → zod-Bwrt9trS-V2SU2SR3.js} +5 -5
- package/dist/{zod-Bwrt9trS-VQQB2XYB.js.map → zod-Bwrt9trS-V2SU2SR3.js.map} +1 -1
- package/dist/{zod-DSgpEGAE-DUJJ5BMF.cjs → zod-DSgpEGAE-LUDXIT4K.cjs} +7 -7
- package/dist/{zod-DSgpEGAE-DUJJ5BMF.cjs.map → zod-DSgpEGAE-LUDXIT4K.cjs.map} +1 -1
- package/dist/{zod-DSgpEGAE-7QSHLOWA.js → zod-DSgpEGAE-VPH7T364.js} +5 -5
- package/dist/{zod-DSgpEGAE-7QSHLOWA.js.map → zod-DSgpEGAE-VPH7T364.js.map} +1 -1
- package/package.json +18 -18
- package/dist/arktype-aI7TBD0R-ZWWNQCOB.js +0 -8
- package/dist/chunk-2U6TYFYX.js.map +0 -1
- package/dist/chunk-5UGF6JNH.js +0 -14
- package/dist/chunk-7BKYJAZW.cjs +0 -16
- package/dist/chunk-AWHSQOUQ.cjs.map +0 -1
- package/dist/chunk-BDHVEJTQ.js.map +0 -1
- package/dist/chunk-CDV3FABH.cjs +0 -4
- package/dist/chunk-DPDWM7HQ.js.map +0 -1
- package/dist/chunk-ET6PLIDX.js +0 -6
- package/dist/chunk-IUSC3KWD.cjs.map +0 -1
- package/dist/chunk-JVBCN3RH.cjs.map +0 -1
- package/dist/chunk-T4RKC5QV.js +0 -3
- package/dist/default-u_dwuiYb-4JHTSSYF.js +0 -3
- package/dist/default-u_dwuiYb-ZFP4NIKX.cjs +0 -9
- package/dist/effect-QlVUlMFu-VG5PIUDR.cjs +0 -17
- package/dist/sury-CWZTCd75-CGVIVOF6.cjs +0 -17
- package/dist/typebox-Dei93FPO-TMKHP62N.js +0 -8
- package/dist/valibot--1zFm7rT-JZ665QU6.cjs +0 -17
- package/dist/valibot--1zFm7rT-R4ZJGFUC.js +0 -15
package/dist/server/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as https from 'https';
|
|
|
4
4
|
import { join, dirname } from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { createServer } from 'http';
|
|
7
|
-
import { Http2ServerRequest } from 'http2';
|
|
7
|
+
import { Http2ServerRequest, constants } from 'http2';
|
|
8
8
|
import { Writable, Readable } from 'stream';
|
|
9
9
|
import crypto from 'crypto';
|
|
10
10
|
import { getMimeType } from 'hono/utils/mime';
|
|
@@ -167,6 +167,17 @@ var requestPrototype = {
|
|
|
167
167
|
}
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
+
Object.defineProperty(requestPrototype, /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"), {
|
|
171
|
+
value: function(depth, options, inspectFn) {
|
|
172
|
+
const props = {
|
|
173
|
+
method: this.method,
|
|
174
|
+
url: this.url,
|
|
175
|
+
headers: this.headers,
|
|
176
|
+
nativeRequest: this[requestCache]
|
|
177
|
+
};
|
|
178
|
+
return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
170
181
|
Object.setPrototypeOf(requestPrototype, Request2.prototype);
|
|
171
182
|
var newRequest = (incoming, defaultHostname) => {
|
|
172
183
|
const req = Object.create(requestPrototype);
|
|
@@ -270,6 +281,17 @@ var Response2 = class _Response {
|
|
|
270
281
|
}
|
|
271
282
|
});
|
|
272
283
|
});
|
|
284
|
+
Object.defineProperty(Response2.prototype, /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom"), {
|
|
285
|
+
value: function(depth, options, inspectFn) {
|
|
286
|
+
const props = {
|
|
287
|
+
status: this.status,
|
|
288
|
+
headers: this.headers,
|
|
289
|
+
ok: this.ok,
|
|
290
|
+
nativeResponse: this[responseCache]
|
|
291
|
+
};
|
|
292
|
+
return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
273
295
|
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
274
296
|
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
275
297
|
async function readWithoutBlocking(readPromise) {
|
|
@@ -341,6 +363,49 @@ if (typeof global.crypto === "undefined") {
|
|
|
341
363
|
global.crypto = crypto;
|
|
342
364
|
}
|
|
343
365
|
var outgoingEnded = /* @__PURE__ */ Symbol("outgoingEnded");
|
|
366
|
+
var incomingDraining = /* @__PURE__ */ Symbol("incomingDraining");
|
|
367
|
+
var DRAIN_TIMEOUT_MS = 500;
|
|
368
|
+
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
369
|
+
var drainIncoming = (incoming) => {
|
|
370
|
+
const incomingWithDrainState = incoming;
|
|
371
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
incomingWithDrainState[incomingDraining] = true;
|
|
375
|
+
if (incoming instanceof Http2ServerRequest) {
|
|
376
|
+
try {
|
|
377
|
+
incoming.stream?.close?.(constants.NGHTTP2_NO_ERROR);
|
|
378
|
+
} catch {
|
|
379
|
+
}
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
let bytesRead = 0;
|
|
383
|
+
const cleanup = () => {
|
|
384
|
+
clearTimeout(timer);
|
|
385
|
+
incoming.off("data", onData);
|
|
386
|
+
incoming.off("end", cleanup);
|
|
387
|
+
incoming.off("error", cleanup);
|
|
388
|
+
};
|
|
389
|
+
const forceClose = () => {
|
|
390
|
+
cleanup();
|
|
391
|
+
const socket = incoming.socket;
|
|
392
|
+
if (socket && !socket.destroyed) {
|
|
393
|
+
socket.destroySoon();
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
397
|
+
timer.unref?.();
|
|
398
|
+
const onData = (chunk) => {
|
|
399
|
+
bytesRead += chunk.length;
|
|
400
|
+
if (bytesRead > MAX_DRAIN_BYTES) {
|
|
401
|
+
forceClose();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
incoming.on("data", onData);
|
|
405
|
+
incoming.on("end", cleanup);
|
|
406
|
+
incoming.on("error", cleanup);
|
|
407
|
+
incoming.resume();
|
|
408
|
+
};
|
|
344
409
|
var handleRequestError = () => new Response(null, {
|
|
345
410
|
status: 400
|
|
346
411
|
});
|
|
@@ -506,14 +571,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
506
571
|
setTimeout(() => {
|
|
507
572
|
if (!incomingEnded) {
|
|
508
573
|
setTimeout(() => {
|
|
509
|
-
incoming
|
|
510
|
-
outgoing.destroy();
|
|
574
|
+
drainIncoming(incoming);
|
|
511
575
|
});
|
|
512
576
|
}
|
|
513
577
|
});
|
|
514
578
|
}
|
|
515
579
|
};
|
|
516
580
|
}
|
|
581
|
+
outgoing.on("finish", () => {
|
|
582
|
+
if (!incomingEnded) {
|
|
583
|
+
drainIncoming(incoming);
|
|
584
|
+
}
|
|
585
|
+
});
|
|
517
586
|
}
|
|
518
587
|
outgoing.on("close", () => {
|
|
519
588
|
const abortController = req[abortControllerKey];
|
|
@@ -528,7 +597,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
528
597
|
setTimeout(() => {
|
|
529
598
|
if (!incomingEnded) {
|
|
530
599
|
setTimeout(() => {
|
|
531
|
-
incoming
|
|
600
|
+
drainIncoming(incoming);
|
|
532
601
|
});
|
|
533
602
|
}
|
|
534
603
|
});
|
|
@@ -652,7 +721,7 @@ var serveStatic = (options = { root: "" }) => {
|
|
|
652
721
|
} else {
|
|
653
722
|
try {
|
|
654
723
|
filename = tryDecodeURI(c.req.path);
|
|
655
|
-
if (/(?:^|[\/\\])
|
|
724
|
+
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}/.test(filename)) {
|
|
656
725
|
throw new Error();
|
|
657
726
|
}
|
|
658
727
|
} catch {
|
|
@@ -1023,7 +1092,7 @@ var ERR_STREAM_WRITE_AFTER_END = class extends Error {
|
|
|
1023
1092
|
}
|
|
1024
1093
|
};
|
|
1025
1094
|
|
|
1026
|
-
// ../../node_modules/.pnpm/fetch-to-node@2.1.
|
|
1095
|
+
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/fetch-to-node/http-incoming.js
|
|
1027
1096
|
var kHeaders = /* @__PURE__ */ Symbol("kHeaders");
|
|
1028
1097
|
var kHeadersDistinct = /* @__PURE__ */ Symbol("kHeadersDistinct");
|
|
1029
1098
|
var kHeadersCount = /* @__PURE__ */ Symbol("kHeadersCount");
|
|
@@ -1357,7 +1426,7 @@ function onError(self, error, cb) {
|
|
|
1357
1426
|
}
|
|
1358
1427
|
}
|
|
1359
1428
|
|
|
1360
|
-
// ../../node_modules/.pnpm/fetch-to-node@2.1.
|
|
1429
|
+
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/utils/types.js
|
|
1361
1430
|
function validateString(value, name) {
|
|
1362
1431
|
if (typeof value !== "string")
|
|
1363
1432
|
throw new ERR_INVALID_ARG_TYPE(name, "string", value);
|
|
@@ -1394,19 +1463,19 @@ function isUint8Array(value) {
|
|
|
1394
1463
|
return value != null && value[Symbol.toStringTag] === "Uint8Array";
|
|
1395
1464
|
}
|
|
1396
1465
|
|
|
1397
|
-
// ../../node_modules/.pnpm/fetch-to-node@2.1.
|
|
1466
|
+
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/fetch-to-node/internal-http.js
|
|
1398
1467
|
var kNeedDrain = /* @__PURE__ */ Symbol("kNeedDrain");
|
|
1399
1468
|
var kOutHeaders = /* @__PURE__ */ Symbol("kOutHeaders");
|
|
1400
1469
|
function utcDate() {
|
|
1401
1470
|
return (/* @__PURE__ */ new Date()).toUTCString();
|
|
1402
1471
|
}
|
|
1403
1472
|
|
|
1404
|
-
// ../../node_modules/.pnpm/fetch-to-node@2.1.
|
|
1473
|
+
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/fetch-to-node/internal-streams-state.js
|
|
1405
1474
|
function getDefaultHighWaterMark(objectMode) {
|
|
1406
1475
|
return objectMode ? 16 : 64 * 1024;
|
|
1407
1476
|
}
|
|
1408
1477
|
|
|
1409
|
-
// ../../node_modules/.pnpm/fetch-to-node@2.1.
|
|
1478
|
+
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/fetch-to-node/http-common.js
|
|
1410
1479
|
var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
|
|
1411
1480
|
function checkIsHttpToken(val) {
|
|
1412
1481
|
return tokenRegExp.test(val);
|
|
@@ -2621,7 +2690,6 @@ var FetchServerResponse = class _FetchServerResponse extends FetchOutgoingMessag
|
|
|
2621
2690
|
headers.append(header, value);
|
|
2622
2691
|
}
|
|
2623
2692
|
const _this = this;
|
|
2624
|
-
let cancelled = false;
|
|
2625
2693
|
let body = this._hasBody ? new ReadableStream({
|
|
2626
2694
|
start(controller) {
|
|
2627
2695
|
for (const dataChunk of initialDataChunks) {
|
|
@@ -2631,27 +2699,17 @@ var FetchServerResponse = class _FetchServerResponse extends FetchOutgoingMessag
|
|
|
2631
2699
|
controller.close();
|
|
2632
2700
|
} else {
|
|
2633
2701
|
_this.on("finish", () => {
|
|
2634
|
-
if (cancelled) return;
|
|
2635
2702
|
finished = true;
|
|
2636
|
-
|
|
2637
|
-
controller.close();
|
|
2638
|
-
} catch (_) {
|
|
2639
|
-
}
|
|
2703
|
+
controller.close();
|
|
2640
2704
|
});
|
|
2641
2705
|
_this.on("_dataWritten", (e) => {
|
|
2642
|
-
if (finished
|
|
2706
|
+
if (finished) {
|
|
2643
2707
|
return;
|
|
2644
2708
|
}
|
|
2645
2709
|
const data = _this.dataFromDataWrittenEvent(e);
|
|
2646
|
-
|
|
2647
|
-
controller.enqueue(data);
|
|
2648
|
-
} catch (_) {
|
|
2649
|
-
}
|
|
2710
|
+
controller.enqueue(data);
|
|
2650
2711
|
});
|
|
2651
2712
|
}
|
|
2652
|
-
},
|
|
2653
|
-
cancel() {
|
|
2654
|
-
cancelled = true;
|
|
2655
2713
|
}
|
|
2656
2714
|
}) : null;
|
|
2657
2715
|
if (body != null && typeof FixedLengthStream !== "undefined") {
|
|
@@ -3352,6 +3410,13 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3352
3410
|
}
|
|
3353
3411
|
async sendResponse(route, response, result, prefix) {
|
|
3354
3412
|
const resolvedPrefix = prefix ?? this.prefix ?? "";
|
|
3413
|
+
if (result && typeof result === "object" && "__refreshHeaders" in result) {
|
|
3414
|
+
const refreshHeaders = result.__refreshHeaders;
|
|
3415
|
+
for (const [key, value] of Object.entries(refreshHeaders)) {
|
|
3416
|
+
response.header(key, value);
|
|
3417
|
+
}
|
|
3418
|
+
delete result.__refreshHeaders;
|
|
3419
|
+
}
|
|
3355
3420
|
if (route.responseType === "json") {
|
|
3356
3421
|
return response.json(result, 200);
|
|
3357
3422
|
} else if (route.responseType === "stream") {
|
|
@@ -3421,7 +3486,7 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3421
3486
|
`${prefix}${route.path}`,
|
|
3422
3487
|
...middlewares,
|
|
3423
3488
|
async (c) => {
|
|
3424
|
-
const
|
|
3489
|
+
const authResult = await this.checkRouteAuth(route, {
|
|
3425
3490
|
path: c.req.path,
|
|
3426
3491
|
method: c.req.method,
|
|
3427
3492
|
getHeader: (name) => c.req.header(name),
|
|
@@ -3430,8 +3495,15 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3430
3495
|
request: c.req.raw,
|
|
3431
3496
|
buildAuthorizeContext: () => c
|
|
3432
3497
|
});
|
|
3433
|
-
if (
|
|
3434
|
-
|
|
3498
|
+
if (authResult) {
|
|
3499
|
+
if (authResult.headers) {
|
|
3500
|
+
for (const [key, value] of Object.entries(authResult.headers)) {
|
|
3501
|
+
c.header(key, value);
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
if (authResult.error) {
|
|
3505
|
+
return c.json({ error: authResult.error }, authResult.status);
|
|
3506
|
+
}
|
|
3435
3507
|
}
|
|
3436
3508
|
const params = await this.getParams(route, c.req);
|
|
3437
3509
|
if (params.bodyParseError) {
|
|
@@ -3572,12 +3644,9 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3572
3644
|
);
|
|
3573
3645
|
}
|
|
3574
3646
|
async registerCustomApiRoutes() {
|
|
3575
|
-
|
|
3576
|
-
|
|
3647
|
+
if (!await this.buildCustomRouteHandler()) return;
|
|
3648
|
+
const routes = this.customApiRoutes ?? this.mastra.getServer()?.apiRoutes ?? [];
|
|
3577
3649
|
for (const route of routes) {
|
|
3578
|
-
const handler = "handler" in route && route.handler ? route.handler : "createHandler" in route ? await route.createHandler({ mastra: this.mastra }) : void 0;
|
|
3579
|
-
if (!handler) continue;
|
|
3580
|
-
const middlewares = [];
|
|
3581
3650
|
const serverRoute = {
|
|
3582
3651
|
method: route.method,
|
|
3583
3652
|
path: route.path,
|
|
@@ -3586,7 +3655,7 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3586
3655
|
},
|
|
3587
3656
|
requiresAuth: route.requiresAuth
|
|
3588
3657
|
};
|
|
3589
|
-
|
|
3658
|
+
const routeHandler = async (c) => {
|
|
3590
3659
|
const authError = await this.checkRouteAuth(serverRoute, {
|
|
3591
3660
|
path: c.req.path,
|
|
3592
3661
|
method: c.req.method,
|
|
@@ -3597,7 +3666,14 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3597
3666
|
buildAuthorizeContext: () => c
|
|
3598
3667
|
});
|
|
3599
3668
|
if (authError) {
|
|
3600
|
-
|
|
3669
|
+
if (authError.headers) {
|
|
3670
|
+
for (const [key, value] of Object.entries(authError.headers)) {
|
|
3671
|
+
c.header(key, value);
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
if (authError.error) {
|
|
3675
|
+
return c.json({ error: authError.error }, authError.status);
|
|
3676
|
+
}
|
|
3601
3677
|
}
|
|
3602
3678
|
const authConfig = this.mastra.getServer()?.auth;
|
|
3603
3679
|
if (authConfig) {
|
|
@@ -3613,14 +3689,24 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3613
3689
|
}
|
|
3614
3690
|
}
|
|
3615
3691
|
}
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3692
|
+
const reqHeaders = {};
|
|
3693
|
+
c.req.raw.headers.forEach((v, k) => {
|
|
3694
|
+
reqHeaders[k] = v;
|
|
3695
|
+
});
|
|
3696
|
+
const response = await this.handleCustomRouteRequest(
|
|
3697
|
+
c.req.url,
|
|
3698
|
+
c.req.method,
|
|
3699
|
+
reqHeaders,
|
|
3700
|
+
c.req.raw.body,
|
|
3701
|
+
c.get("requestContext")
|
|
3702
|
+
);
|
|
3703
|
+
if (!response) {
|
|
3704
|
+
return c.json({ error: "Not Found" }, 404);
|
|
3705
|
+
}
|
|
3706
|
+
return response;
|
|
3707
|
+
};
|
|
3622
3708
|
const method = route.method.toLowerCase();
|
|
3623
|
-
this.app[method](route.path,
|
|
3709
|
+
this.app[method](route.path, routeHandler);
|
|
3624
3710
|
}
|
|
3625
3711
|
}
|
|
3626
3712
|
registerContextMiddleware() {
|
|
@@ -3668,7 +3754,7 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
3668
3754
|
}
|
|
3669
3755
|
};
|
|
3670
3756
|
|
|
3671
|
-
// ../../node_modules/.pnpm/hono-openapi@1.3.0_@hono+standard-validator@0.2.2_@standard-schema+spec@1.1.0_hono@4.
|
|
3757
|
+
// ../../node_modules/.pnpm/hono-openapi@1.3.0_@hono+standard-validator@0.2.2_@standard-schema+spec@1.1.0_hono@4.12_7f2e589434399ce060993015d82f28dd/node_modules/hono-openapi/dist/index.js
|
|
3672
3758
|
var uniqueSymbol = /* @__PURE__ */ Symbol("openapi");
|
|
3673
3759
|
function describeRoute(spec) {
|
|
3674
3760
|
const middleware2 = async (_c, next) => {
|
|
@@ -3871,111 +3957,422 @@ async function rootHandler(c) {
|
|
|
3871
3957
|
}
|
|
3872
3958
|
|
|
3873
3959
|
// src/server/welcome.ts
|
|
3874
|
-
|
|
3960
|
+
function welcomeHtml(apiPrefix = "/api") {
|
|
3961
|
+
const prefix = "/" + apiPrefix.replace(/^\/+|\/+$/g, "");
|
|
3962
|
+
const prefixNoSlash = prefix.slice(1);
|
|
3963
|
+
return `
|
|
3875
3964
|
<!doctype html>
|
|
3876
3965
|
<html lang="en">
|
|
3877
3966
|
<head>
|
|
3878
3967
|
<meta charset="UTF-8" />
|
|
3879
3968
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
3880
|
-
<title>
|
|
3881
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/inter-ui/3.19.3/inter.min.css" />
|
|
3969
|
+
<title>Mastra Server</title>
|
|
3882
3970
|
<style>
|
|
3971
|
+
* { box-sizing: border-box; }
|
|
3972
|
+
|
|
3883
3973
|
body {
|
|
3884
3974
|
margin: 0;
|
|
3885
3975
|
padding: 0;
|
|
3886
|
-
background-color: #
|
|
3887
|
-
color: #
|
|
3888
|
-
font-family:
|
|
3889
|
-
'Inter',
|
|
3890
|
-
-apple-system,
|
|
3891
|
-
BlinkMacSystemFont,
|
|
3892
|
-
system-ui,
|
|
3893
|
-
sans-serif;
|
|
3976
|
+
background-color: #0a0a0a;
|
|
3977
|
+
color: #e4e4e7;
|
|
3978
|
+
font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
|
|
3894
3979
|
min-height: 100vh;
|
|
3980
|
+
line-height: 1.6;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
.page {
|
|
3984
|
+
max-width: 720px;
|
|
3985
|
+
margin: 0 auto;
|
|
3986
|
+
padding: 3rem 1.5rem 4rem;
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
header {
|
|
3990
|
+
margin-bottom: 2.5rem;
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
header h1 {
|
|
3994
|
+
font-size: 1.75rem;
|
|
3995
|
+
font-weight: 600;
|
|
3996
|
+
margin: 0 0 0.25rem;
|
|
3997
|
+
color: #fff;
|
|
3998
|
+
}
|
|
3999
|
+
|
|
4000
|
+
header p {
|
|
4001
|
+
color: #71717a;
|
|
4002
|
+
font-size: 0.9rem;
|
|
4003
|
+
margin: 0;
|
|
4004
|
+
}
|
|
4005
|
+
|
|
4006
|
+
.status-bar {
|
|
3895
4007
|
display: flex;
|
|
3896
|
-
|
|
4008
|
+
align-items: center;
|
|
4009
|
+
gap: 0.5rem;
|
|
4010
|
+
margin-top: 1rem;
|
|
4011
|
+
font-size: 0.8rem;
|
|
4012
|
+
color: #a1a1aa;
|
|
3897
4013
|
}
|
|
3898
4014
|
|
|
3899
|
-
|
|
3900
|
-
|
|
4015
|
+
.status-dot {
|
|
4016
|
+
width: 8px;
|
|
4017
|
+
height: 8px;
|
|
4018
|
+
border-radius: 50%;
|
|
4019
|
+
background: #22c55e;
|
|
4020
|
+
flex-shrink: 0;
|
|
4021
|
+
}
|
|
4022
|
+
|
|
4023
|
+
section {
|
|
4024
|
+
margin-bottom: 2rem;
|
|
4025
|
+
}
|
|
4026
|
+
|
|
4027
|
+
section h2 {
|
|
4028
|
+
font-size: 0.75rem;
|
|
4029
|
+
font-weight: 600;
|
|
4030
|
+
text-transform: uppercase;
|
|
4031
|
+
letter-spacing: 0.05em;
|
|
4032
|
+
color: #71717a;
|
|
4033
|
+
margin: 0 0 0.75rem;
|
|
4034
|
+
}
|
|
4035
|
+
|
|
4036
|
+
.card {
|
|
4037
|
+
background: #18181b;
|
|
4038
|
+
border: 1px solid #27272a;
|
|
4039
|
+
border-radius: 8px;
|
|
4040
|
+
overflow: hidden;
|
|
4041
|
+
}
|
|
4042
|
+
|
|
4043
|
+
.card + .card {
|
|
4044
|
+
margin-top: 0.75rem;
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
.card-row {
|
|
3901
4048
|
display: flex;
|
|
3902
|
-
flex-direction: column;
|
|
3903
4049
|
align-items: center;
|
|
3904
|
-
justify-content:
|
|
3905
|
-
padding:
|
|
3906
|
-
|
|
4050
|
+
justify-content: space-between;
|
|
4051
|
+
padding: 0.75rem 1rem;
|
|
4052
|
+
gap: 0.75rem;
|
|
3907
4053
|
}
|
|
3908
4054
|
|
|
3909
|
-
|
|
3910
|
-
|
|
4055
|
+
.card-row + .card-row {
|
|
4056
|
+
border-top: 1px solid #27272a;
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4059
|
+
.card-row-left {
|
|
4060
|
+
display: flex;
|
|
4061
|
+
align-items: center;
|
|
4062
|
+
gap: 0.75rem;
|
|
4063
|
+
min-width: 0;
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
.method {
|
|
4067
|
+
font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
|
|
4068
|
+
font-size: 0.7rem;
|
|
3911
4069
|
font-weight: 600;
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
-
|
|
3915
|
-
-webkit-text-fill-color: transparent;
|
|
3916
|
-
line-height: 1.2;
|
|
4070
|
+
padding: 2px 6px;
|
|
4071
|
+
border-radius: 4px;
|
|
4072
|
+
flex-shrink: 0;
|
|
3917
4073
|
}
|
|
3918
4074
|
|
|
3919
|
-
.
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
4075
|
+
.method-get { background: #052e16; color: #4ade80; }
|
|
4076
|
+
.method-post { background: #172554; color: #60a5fa; }
|
|
4077
|
+
|
|
4078
|
+
.endpoint-path {
|
|
4079
|
+
font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
|
|
4080
|
+
font-size: 0.8rem;
|
|
4081
|
+
color: #d4d4d8;
|
|
4082
|
+
white-space: nowrap;
|
|
4083
|
+
overflow: hidden;
|
|
4084
|
+
text-overflow: ellipsis;
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
.endpoint-desc {
|
|
4088
|
+
font-size: 0.75rem;
|
|
4089
|
+
color: #71717a;
|
|
4090
|
+
flex-shrink: 0;
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
.curl-block {
|
|
4094
|
+
position: relative;
|
|
4095
|
+
background: #111113;
|
|
4096
|
+
border: 1px solid #27272a;
|
|
4097
|
+
border-radius: 8px;
|
|
4098
|
+
overflow: hidden;
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
.curl-block + .curl-block {
|
|
4102
|
+
margin-top: 0.75rem;
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
.curl-label {
|
|
4106
|
+
display: flex;
|
|
4107
|
+
align-items: center;
|
|
4108
|
+
justify-content: space-between;
|
|
4109
|
+
padding: 0.5rem 1rem;
|
|
4110
|
+
border-bottom: 1px solid #27272a;
|
|
4111
|
+
font-size: 0.75rem;
|
|
4112
|
+
color: #a1a1aa;
|
|
4113
|
+
}
|
|
4114
|
+
|
|
4115
|
+
.copy-btn {
|
|
4116
|
+
background: none;
|
|
4117
|
+
border: 1px solid #3f3f46;
|
|
4118
|
+
border-radius: 4px;
|
|
4119
|
+
color: #a1a1aa;
|
|
4120
|
+
font-size: 0.7rem;
|
|
4121
|
+
padding: 2px 8px;
|
|
4122
|
+
cursor: pointer;
|
|
4123
|
+
font-family: inherit;
|
|
4124
|
+
transition: all 0.15s;
|
|
4125
|
+
}
|
|
4126
|
+
|
|
4127
|
+
.copy-btn:hover {
|
|
4128
|
+
background: #27272a;
|
|
4129
|
+
color: #e4e4e7;
|
|
4130
|
+
}
|
|
4131
|
+
|
|
4132
|
+
.curl-code {
|
|
4133
|
+
padding: 0.75rem 1rem;
|
|
4134
|
+
font-family: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
|
|
4135
|
+
font-size: 0.8rem;
|
|
4136
|
+
line-height: 1.5;
|
|
4137
|
+
color: #d4d4d8;
|
|
4138
|
+
overflow-x: auto;
|
|
4139
|
+
white-space: pre;
|
|
4140
|
+
margin: 0;
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
.curl-code .c-cmd { color: #a78bfa; }
|
|
4144
|
+
.curl-code .c-flag { color: #60a5fa; }
|
|
4145
|
+
.curl-code .c-url { color: #fbbf24; }
|
|
4146
|
+
.curl-code .c-str { color: #4ade80; }
|
|
4147
|
+
|
|
4148
|
+
.links-grid {
|
|
4149
|
+
display: grid;
|
|
4150
|
+
grid-template-columns: 1fr 1fr;
|
|
4151
|
+
gap: 0.75rem;
|
|
3925
4152
|
}
|
|
3926
4153
|
|
|
3927
|
-
.
|
|
3928
|
-
background-color: #1a1a1a;
|
|
3929
|
-
padding: 1rem 2rem;
|
|
3930
|
-
border-radius: 0.5rem;
|
|
4154
|
+
.link-card {
|
|
3931
4155
|
display: flex;
|
|
3932
4156
|
align-items: center;
|
|
3933
|
-
gap:
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
4157
|
+
gap: 0.75rem;
|
|
4158
|
+
padding: 0.875rem 1rem;
|
|
4159
|
+
background: #18181b;
|
|
4160
|
+
border: 1px solid #27272a;
|
|
4161
|
+
border-radius: 8px;
|
|
4162
|
+
color: #d4d4d8;
|
|
3937
4163
|
text-decoration: none;
|
|
3938
|
-
|
|
4164
|
+
font-size: 0.85rem;
|
|
4165
|
+
transition: all 0.15s;
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
.link-card:hover {
|
|
4169
|
+
background: #1f1f23;
|
|
4170
|
+
border-color: #3f3f46;
|
|
4171
|
+
color: #fff;
|
|
3939
4172
|
}
|
|
3940
4173
|
|
|
3941
|
-
.
|
|
3942
|
-
|
|
4174
|
+
.link-icon {
|
|
4175
|
+
flex-shrink: 0;
|
|
4176
|
+
width: 18px;
|
|
4177
|
+
height: 18px;
|
|
4178
|
+
color: #71717a;
|
|
3943
4179
|
}
|
|
3944
4180
|
|
|
3945
|
-
.
|
|
3946
|
-
|
|
4181
|
+
.link-card:hover .link-icon { color: #a1a1aa; }
|
|
4182
|
+
|
|
4183
|
+
footer {
|
|
4184
|
+
margin-top: 3rem;
|
|
4185
|
+
padding-top: 1.5rem;
|
|
4186
|
+
border-top: 1px solid #1c1c1f;
|
|
4187
|
+
font-size: 0.75rem;
|
|
4188
|
+
color: #52525b;
|
|
3947
4189
|
}
|
|
3948
4190
|
|
|
3949
|
-
|
|
3950
|
-
|
|
4191
|
+
@media (max-width: 480px) {
|
|
4192
|
+
.page { padding: 2rem 1rem 3rem; }
|
|
4193
|
+
header h1 { font-size: 1.5rem; }
|
|
4194
|
+
.links-grid { grid-template-columns: 1fr; }
|
|
4195
|
+
.endpoint-desc { display: none; }
|
|
3951
4196
|
}
|
|
3952
4197
|
</style>
|
|
3953
4198
|
</head>
|
|
3954
4199
|
<body>
|
|
3955
|
-
<
|
|
3956
|
-
<
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4200
|
+
<div class="page">
|
|
4201
|
+
<header>
|
|
4202
|
+
<h1>Mastra Server</h1>
|
|
4203
|
+
<p>Your server is running. Use the endpoints below to get started.</p>
|
|
4204
|
+
<div class="status-bar">
|
|
4205
|
+
<span class="status-dot"></span>
|
|
4206
|
+
<span id="base-url"></span>
|
|
4207
|
+
</div>
|
|
4208
|
+
</header>
|
|
3960
4209
|
|
|
3961
|
-
<
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
4210
|
+
<section>
|
|
4211
|
+
<h2>Quick Start</h2>
|
|
4212
|
+
|
|
4213
|
+
<div class="curl-block">
|
|
4214
|
+
<div class="curl-label">
|
|
4215
|
+
<span>Check server health</span>
|
|
4216
|
+
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
|
|
4217
|
+
</div>
|
|
4218
|
+
<pre class="curl-code" data-tpl="curl <base>/health"><span class="c-cmd">curl</span> <span class="c-url" data-url="health"></span></pre>
|
|
4219
|
+
</div>
|
|
4220
|
+
|
|
4221
|
+
<div class="curl-block">
|
|
4222
|
+
<div class="curl-label">
|
|
4223
|
+
<span>List your agents</span>
|
|
4224
|
+
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
|
|
4225
|
+
</div>
|
|
4226
|
+
<pre class="curl-code" data-tpl="curl <base>${prefix}/agents"><span class="c-cmd">curl</span> <span class="c-url" data-url="${prefixNoSlash}/agents"></span></pre>
|
|
4227
|
+
</div>
|
|
4228
|
+
|
|
4229
|
+
<div class="curl-block">
|
|
4230
|
+
<div class="curl-label">
|
|
4231
|
+
<span>Chat with an agent</span>
|
|
4232
|
+
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
|
|
4233
|
+
</div>
|
|
4234
|
+
<pre class="curl-code" data-tpl="curl -X POST <base>${prefix}/agents/:agent-id/generate -H 'Content-Type: application/json' -d '{"messages":[{"role":"user","content":"Hello"}]}'"><span class="c-cmd">curl</span> <span class="c-flag">-X POST</span> <span class="c-url" data-url="${prefixNoSlash}/agents/:agent-id/generate"></span> \\
|
|
4235
|
+
<span class="c-flag">-H</span> <span class="c-str">'Content-Type: application/json'</span> \\
|
|
4236
|
+
<span class="c-flag">-d</span> <span class="c-str">'{"messages":[{"role":"user","content":"Hello"}]}'</span></pre>
|
|
4237
|
+
</div>
|
|
4238
|
+
|
|
4239
|
+
<div class="curl-block">
|
|
4240
|
+
<div class="curl-label">
|
|
4241
|
+
<span>Stream an agent response</span>
|
|
4242
|
+
<button class="copy-btn" onclick="copyCode(this)">Copy</button>
|
|
4243
|
+
</div>
|
|
4244
|
+
<pre class="curl-code" data-tpl="curl -N -X POST <base>${prefix}/agents/:agent-id/stream -H 'Content-Type: application/json' -d '{"messages":[{"role":"user","content":"Hello"}]}'"><span class="c-cmd">curl</span> <span class="c-flag">-N -X POST</span> <span class="c-url" data-url="${prefixNoSlash}/agents/:agent-id/stream"></span> \\
|
|
4245
|
+
<span class="c-flag">-H</span> <span class="c-str">'Content-Type: application/json'</span> \\
|
|
4246
|
+
<span class="c-flag">-d</span> <span class="c-str">'{"messages":[{"role":"user","content":"Hello"}]}'</span></pre>
|
|
4247
|
+
</div>
|
|
4248
|
+
</section>
|
|
4249
|
+
|
|
4250
|
+
<section>
|
|
4251
|
+
<h2>API Endpoints</h2>
|
|
4252
|
+
<div class="card">
|
|
4253
|
+
<div class="card-row">
|
|
4254
|
+
<div class="card-row-left">
|
|
4255
|
+
<span class="method method-get">GET</span>
|
|
4256
|
+
<span class="endpoint-path">${prefix}/agents</span>
|
|
4257
|
+
</div>
|
|
4258
|
+
<span class="endpoint-desc">List all agents</span>
|
|
4259
|
+
</div>
|
|
4260
|
+
<div class="card-row">
|
|
4261
|
+
<div class="card-row-left">
|
|
4262
|
+
<span class="method method-post">POST</span>
|
|
4263
|
+
<span class="endpoint-path">${prefix}/agents/:id/generate</span>
|
|
4264
|
+
</div>
|
|
4265
|
+
<span class="endpoint-desc">Generate a response</span>
|
|
4266
|
+
</div>
|
|
4267
|
+
<div class="card-row">
|
|
4268
|
+
<div class="card-row-left">
|
|
4269
|
+
<span class="method method-post">POST</span>
|
|
4270
|
+
<span class="endpoint-path">${prefix}/agents/:id/stream</span>
|
|
4271
|
+
</div>
|
|
4272
|
+
<span class="endpoint-desc">Stream a response</span>
|
|
4273
|
+
</div>
|
|
4274
|
+
<div class="card-row">
|
|
4275
|
+
<div class="card-row-left">
|
|
4276
|
+
<span class="method method-get">GET</span>
|
|
4277
|
+
<span class="endpoint-path">${prefix}/workflows</span>
|
|
4278
|
+
</div>
|
|
4279
|
+
<span class="endpoint-desc">List all workflows</span>
|
|
4280
|
+
</div>
|
|
4281
|
+
<div class="card-row">
|
|
4282
|
+
<div class="card-row-left">
|
|
4283
|
+
<span class="method method-post">POST</span>
|
|
4284
|
+
<span class="endpoint-path">${prefix}/workflows/:id/start</span>
|
|
4285
|
+
</div>
|
|
4286
|
+
<span class="endpoint-desc">Run a workflow</span>
|
|
4287
|
+
</div>
|
|
4288
|
+
<div class="card-row">
|
|
4289
|
+
<div class="card-row-left">
|
|
4290
|
+
<span class="method method-get">GET</span>
|
|
4291
|
+
<span class="endpoint-path">${prefix}/tools</span>
|
|
4292
|
+
</div>
|
|
4293
|
+
<span class="endpoint-desc">List all tools</span>
|
|
4294
|
+
</div>
|
|
4295
|
+
<div class="card-row">
|
|
4296
|
+
<div class="card-row-left">
|
|
4297
|
+
<span class="method method-post">POST</span>
|
|
4298
|
+
<span class="endpoint-path">${prefix}/tools/:id/execute</span>
|
|
4299
|
+
</div>
|
|
4300
|
+
<span class="endpoint-desc">Execute a tool</span>
|
|
4301
|
+
</div>
|
|
4302
|
+
<div class="card-row">
|
|
4303
|
+
<div class="card-row-left">
|
|
4304
|
+
<span class="method method-get">GET</span>
|
|
4305
|
+
<span class="endpoint-path">${prefix}/memory/threads</span>
|
|
4306
|
+
</div>
|
|
4307
|
+
<span class="endpoint-desc">List memory threads</span>
|
|
4308
|
+
</div>
|
|
4309
|
+
</div>
|
|
4310
|
+
</section>
|
|
4311
|
+
|
|
4312
|
+
<section>
|
|
4313
|
+
<h2>Resources</h2>
|
|
4314
|
+
<div class="links-grid">
|
|
4315
|
+
<a href="https://mastra.ai/docs" target="_blank" rel="noopener noreferrer" class="link-card">
|
|
4316
|
+
<svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/></svg>
|
|
4317
|
+
Documentation
|
|
4318
|
+
</a>
|
|
4319
|
+
<a href="https://mastra.ai/docs/server-db/custom-api-routes" target="_blank" rel="noopener noreferrer" class="link-card">
|
|
4320
|
+
<svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 18l6-6-6-6"/><path d="M8 6l-6 6 6 6"/></svg>
|
|
4321
|
+
Custom API Routes
|
|
4322
|
+
</a>
|
|
4323
|
+
<a href="https://mastra.ai/docs/agents/overview" target="_blank" rel="noopener noreferrer" class="link-card">
|
|
4324
|
+
<svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 1v4m0 14v4m-7.8-15.4 2.8 2.8m9.6 9.6 2.8 2.8M1 12h4m14 0h4M4.2 19.8l2.8-2.8m9.6-9.6 2.8-2.8"/></svg>
|
|
4325
|
+
Agents Guide
|
|
4326
|
+
</a>
|
|
4327
|
+
<a href="https://mastra.ai/docs/workflows/overview" target="_blank" rel="noopener noreferrer" class="link-card">
|
|
4328
|
+
<svg class="link-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 3 21 3 21 8"/><line x1="4" y1="20" x2="21" y2="3"/><polyline points="21 16 21 21 16 21"/><line x1="15" y1="15" x2="21" y2="21"/><line x1="4" y1="4" x2="9" y2="9"/></svg>
|
|
4329
|
+
Workflows Guide
|
|
4330
|
+
</a>
|
|
4331
|
+
</div>
|
|
4332
|
+
</section>
|
|
4333
|
+
|
|
4334
|
+
<footer>
|
|
4335
|
+
Powered by <a href="https://mastra.ai" target="_blank" rel="noopener noreferrer" style="color:#71717a;">Mastra</a>
|
|
4336
|
+
</footer>
|
|
4337
|
+
</div>
|
|
4338
|
+
|
|
4339
|
+
<script>
|
|
4340
|
+
(function() {
|
|
4341
|
+
var base = location.origin;
|
|
4342
|
+
document.getElementById('base-url').textContent = base;
|
|
4343
|
+
|
|
4344
|
+
var els = document.querySelectorAll('[data-url]');
|
|
4345
|
+
for (var i = 0; i < els.length; i++) {
|
|
4346
|
+
els[i].textContent = base + '/' + els[i].getAttribute('data-url');
|
|
4347
|
+
}
|
|
4348
|
+
|
|
4349
|
+
var tpls = document.querySelectorAll('[data-tpl]');
|
|
4350
|
+
for (var i = 0; i < tpls.length; i++) {
|
|
4351
|
+
tpls[i].setAttribute('data-tpl', tpls[i].getAttribute('data-tpl').replace(/<base>/g, base));
|
|
4352
|
+
}
|
|
4353
|
+
})();
|
|
4354
|
+
|
|
4355
|
+
function copyCode(btn) {
|
|
4356
|
+
var pre = btn.closest('.curl-block').querySelector('.curl-code');
|
|
4357
|
+
var text = pre.getAttribute('data-tpl');
|
|
4358
|
+
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
|
4359
|
+
btn.textContent = 'Unavailable';
|
|
4360
|
+
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
|
|
4361
|
+
return;
|
|
4362
|
+
}
|
|
4363
|
+
navigator.clipboard.writeText(text).then(function() {
|
|
4364
|
+
btn.textContent = 'Copied!';
|
|
4365
|
+
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
|
|
4366
|
+
}).catch(function() {
|
|
4367
|
+
btn.textContent = 'Failed';
|
|
4368
|
+
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
</script>
|
|
3976
4372
|
</body>
|
|
3977
4373
|
</html>
|
|
3978
4374
|
`;
|
|
4375
|
+
}
|
|
3979
4376
|
|
|
3980
4377
|
// src/server/index.ts
|
|
3981
4378
|
var getStudioPath = () => {
|
|
@@ -4278,7 +4675,7 @@ async function createHonoServer(mastra, options = {
|
|
|
4278
4675
|
});
|
|
4279
4676
|
return c.newResponse(indexHtml, 200, { "Content-Type": "text/html" });
|
|
4280
4677
|
}
|
|
4281
|
-
return c.newResponse(
|
|
4678
|
+
return c.newResponse(welcomeHtml(apiPrefix), 200, { "Content-Type": "text/html" });
|
|
4282
4679
|
});
|
|
4283
4680
|
if (options?.studio) {
|
|
4284
4681
|
const studioRootPath = getStudioPath();
|