@mastra/deployer 1.0.0-beta.9 → 1.0.4
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 +811 -0
- package/dist/arktype-aI7TBD0R-CCZH3EYK.js +8 -0
- package/dist/{arktype-aI7TBD0R-OEPFT4G6.js.map → arktype-aI7TBD0R-CCZH3EYK.js.map} +1 -1
- package/dist/{arktype-aI7TBD0R-4YXBEQBG.cjs → arktype-aI7TBD0R-XHBHUL3T.cjs} +3 -3
- package/dist/{arktype-aI7TBD0R-4YXBEQBG.cjs.map → arktype-aI7TBD0R-XHBHUL3T.cjs.map} +1 -1
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/bundleExternals.d.ts +4 -5
- package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts +5 -5
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/babel/remove-deployer.d.ts.map +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.d.ts +3 -1
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/bundlerOptions.d.ts.map +1 -1
- package/dist/build/deployer.d.ts.map +1 -1
- package/dist/build/index.cjs +19 -10
- package/dist/build/index.d.ts +2 -0
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +4 -3
- package/dist/build/package-info.d.ts +9 -0
- package/dist/build/package-info.d.ts.map +1 -0
- package/dist/build/plugins/node-modules-extension-resolver.d.ts +7 -0
- package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
- package/dist/build/plugins/remove-all-except.d.ts +10 -0
- package/dist/build/plugins/remove-all-except.d.ts.map +1 -0
- package/dist/build/plugins/tsconfig-paths.d.ts +1 -1
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/build/serverOptions.d.ts.map +1 -1
- package/dist/build/shared/extract-mastra-option.d.ts +4 -8
- package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
- package/dist/build/types.d.ts +5 -0
- package/dist/build/types.d.ts.map +1 -1
- package/dist/build/utils.d.ts +35 -4
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/build/watcher.d.ts +2 -1
- package/dist/build/watcher.d.ts.map +1 -1
- package/dist/bundler/index.cjs +6 -2
- package/dist/bundler/index.d.ts +10 -7
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/chunk-2VG357HT.cjs +4 -0
- package/dist/{chunk-BTNPI4Z7.cjs.map → chunk-2VG357HT.cjs.map} +1 -1
- package/dist/chunk-5FPJTHRK.js +88 -0
- package/dist/chunk-5FPJTHRK.js.map +1 -0
- package/dist/{chunk-2OTEFUER.cjs → chunk-5TYVF4KJ.cjs} +31 -24
- package/dist/chunk-5TYVF4KJ.cjs.map +1 -0
- package/dist/{chunk-BFQ2S5UD.cjs → chunk-7EPD2XJR.cjs} +76 -20
- package/dist/chunk-7EPD2XJR.cjs.map +1 -0
- package/dist/{chunk-MMUE22EL.js → chunk-DBXWQ2CA.js} +10 -10
- package/dist/chunk-DBXWQ2CA.js.map +1 -0
- package/dist/chunk-G6GFAPPU.js +6 -0
- package/dist/{chunk-Q2YGWEXY.js.map → chunk-G6GFAPPU.js.map} +1 -1
- package/dist/chunk-GU4OME5Q.cjs +112 -0
- package/dist/chunk-GU4OME5Q.cjs.map +1 -0
- package/dist/chunk-HPGDVJAZ.js +3 -0
- package/dist/{chunk-FBT6QP7J.js.map → chunk-HPGDVJAZ.js.map} +1 -1
- package/dist/{chunk-TK2CCU7I.js → chunk-HWSYWSD7.js} +278 -190
- package/dist/chunk-HWSYWSD7.js.map +1 -0
- package/dist/{chunk-GD2TGMBP.cjs → chunk-JBE6KM7R.cjs} +3 -3
- package/dist/{chunk-GD2TGMBP.cjs.map → chunk-JBE6KM7R.cjs.map} +1 -1
- package/dist/{chunk-TXKETRIN.cjs → chunk-JRUJ546M.cjs} +10 -10
- package/dist/chunk-JRUJ546M.cjs.map +1 -0
- package/dist/{chunk-7PLNIFGZ.cjs → chunk-KE4NVPI4.cjs} +3 -3
- package/dist/{chunk-7PLNIFGZ.cjs.map → chunk-KE4NVPI4.cjs.map} +1 -1
- package/dist/chunk-MCWU6IKS.js +14 -0
- package/dist/{chunk-N5TMJUIR.js.map → chunk-MCWU6IKS.js.map} +1 -1
- package/dist/{chunk-UQZGTSBF.js → chunk-NGQZZ54Y.js} +68 -13
- package/dist/chunk-NGQZZ54Y.js.map +1 -0
- package/dist/chunk-QAOUDKHK.js +67 -0
- package/dist/chunk-QAOUDKHK.js.map +1 -0
- package/dist/{chunk-RBPCXFN7.js → chunk-SD6NHZ2H.js} +47 -28
- package/dist/chunk-SD6NHZ2H.js.map +1 -0
- package/dist/{chunk-MUWNMVNL.cjs → chunk-T7NCLSYN.cjs} +297 -209
- package/dist/chunk-T7NCLSYN.cjs.map +1 -0
- package/dist/{chunk-P4L6VIHY.js → chunk-V4HCIN6G.js} +3 -3
- package/dist/{chunk-P4L6VIHY.js.map → chunk-V4HCIN6G.js.map} +1 -1
- package/dist/{chunk-SS22TD6R.cjs → chunk-VOI3B5MX.cjs} +54 -34
- package/dist/chunk-VOI3B5MX.cjs.map +1 -0
- package/dist/chunk-ZXQ7DOYU.cjs +16 -0
- package/dist/{chunk-ID3HN3BH.cjs.map → chunk-ZXQ7DOYU.cjs.map} +1 -1
- package/dist/default-u_dwuiYb-JPNIZQKK.cjs +9 -0
- package/dist/{default-u_dwuiYb-PWN6FHC6.cjs.map → default-u_dwuiYb-JPNIZQKK.cjs.map} +1 -1
- package/dist/default-u_dwuiYb-RK5OD4MY.js +3 -0
- package/dist/{default-u_dwuiYb-65M4BHAA.js.map → default-u_dwuiYb-RK5OD4MY.js.map} +1 -1
- package/dist/docs/README.md +32 -0
- package/dist/docs/SKILL.md +36 -0
- package/dist/docs/SOURCE_MAP.json +27 -0
- package/dist/docs/deployer/01-reference.md +93 -0
- package/dist/docs/deployment/01-overview.md +64 -0
- package/dist/docs/deployment/02-mastra-server.md +129 -0
- package/dist/docs/deployment/03-monorepo.md +142 -0
- package/dist/docs/deployment/04-cloud-providers.md +17 -0
- package/dist/docs/deployment/05-web-framework.md +55 -0
- package/dist/docs/deployment/06-workflow-runners.md +11 -0
- package/dist/effect-QlVUlMFu-HN3LWZSQ.cjs +17 -0
- package/dist/{effect-QlVUlMFu-2ADPKIDF.cjs.map → effect-QlVUlMFu-HN3LWZSQ.cjs.map} +1 -1
- package/dist/{effect-QlVUlMFu-FD73M3OO.js → effect-QlVUlMFu-XOJ2F4UA.js} +4 -4
- package/dist/{effect-QlVUlMFu-FD73M3OO.js.map → effect-QlVUlMFu-XOJ2F4UA.js.map} +1 -1
- package/dist/{esm-BLVTLTJW.js → esm-6TGK2CUM.js} +3 -3
- package/dist/esm-6TGK2CUM.js.map +1 -0
- package/dist/{esm-E3NUCNVN.cjs → esm-SQKX5ABS.cjs} +3 -3
- package/dist/esm-SQKX5ABS.cjs.map +1 -0
- package/dist/index.cjs +4 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -14
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +523 -87
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +521 -86
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/sury-CWZTCd75-KEHKUXG7.cjs +17 -0
- package/dist/{sury-CWZTCd75-K3FHMZF5.cjs.map → sury-CWZTCd75-KEHKUXG7.cjs.map} +1 -1
- package/dist/{sury-CWZTCd75-Y2GURJ6K.js → sury-CWZTCd75-L2D76L25.js} +4 -4
- package/dist/{sury-CWZTCd75-Y2GURJ6K.js.map → sury-CWZTCd75-L2D76L25.js.map} +1 -1
- package/dist/typebox-Dei93FPO-LBLFC3RD.js +8 -0
- package/dist/{typebox-Dei93FPO-2WP4NOYD.js.map → typebox-Dei93FPO-LBLFC3RD.js.map} +1 -1
- package/dist/{typebox-Dei93FPO-WTXAW2LA.cjs → typebox-Dei93FPO-RDSW6DFA.cjs} +3 -3
- package/dist/{typebox-Dei93FPO-WTXAW2LA.cjs.map → typebox-Dei93FPO-RDSW6DFA.cjs.map} +1 -1
- package/dist/valibot--1zFm7rT-NVADAEQI.cjs +17 -0
- package/dist/{valibot--1zFm7rT-HMTCRBB3.cjs.map → valibot--1zFm7rT-NVADAEQI.cjs.map} +1 -1
- package/dist/{valibot--1zFm7rT-VGFBTDTW.js → valibot--1zFm7rT-R2UKWLZC.js} +4 -4
- package/dist/{valibot--1zFm7rT-VGFBTDTW.js.map → valibot--1zFm7rT-R2UKWLZC.js.map} +1 -1
- package/dist/{valibot-D_HTw1Gn-ILCWWLE4.cjs → valibot-D_HTw1Gn-DSFFOUBW.cjs} +7 -7
- package/dist/{valibot-D_HTw1Gn-ILCWWLE4.cjs.map → valibot-D_HTw1Gn-DSFFOUBW.cjs.map} +1 -1
- package/dist/{valibot-D_HTw1Gn-LLCGNU3W.js → valibot-D_HTw1Gn-KWXWP2TJ.js} +5 -5
- package/dist/{valibot-D_HTw1Gn-LLCGNU3W.js.map → valibot-D_HTw1Gn-KWXWP2TJ.js.map} +1 -1
- package/dist/validator/custom-resolver.cjs +2 -2
- package/dist/validator/custom-resolver.js +1 -1
- package/dist/{zod-Bwrt9trS-XCRGYQVE.js → zod-Bwrt9trS-GCUGPBJX.js} +5 -5
- package/dist/{zod-Bwrt9trS-XCRGYQVE.js.map → zod-Bwrt9trS-GCUGPBJX.js.map} +1 -1
- package/dist/{zod-Bwrt9trS-XDMWF3NW.cjs → zod-Bwrt9trS-ZZHFZ7YQ.cjs} +7 -7
- package/dist/{zod-Bwrt9trS-XDMWF3NW.cjs.map → zod-Bwrt9trS-ZZHFZ7YQ.cjs.map} +1 -1
- package/dist/{zod-DSgpEGAE-ZWQMF6SS.cjs → zod-DSgpEGAE-3CMS4FSB.cjs} +7 -7
- package/dist/{zod-DSgpEGAE-ZWQMF6SS.cjs.map → zod-DSgpEGAE-3CMS4FSB.cjs.map} +1 -1
- package/dist/{zod-DSgpEGAE-TKBHSSLS.js → zod-DSgpEGAE-IPE3O2NQ.js} +5 -5
- package/dist/{zod-DSgpEGAE-TKBHSSLS.js.map → zod-DSgpEGAE-IPE3O2NQ.js.map} +1 -1
- package/package.json +15 -15
- package/dist/arktype-aI7TBD0R-OEPFT4G6.js +0 -8
- package/dist/build/babel/get-deployer.d.ts +0 -3
- package/dist/build/babel/get-deployer.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-bundler.d.ts +0 -5
- package/dist/build/babel/remove-all-options-bundler.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-deployer.d.ts +0 -5
- package/dist/build/babel/remove-all-options-deployer.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-server.d.ts +0 -5
- package/dist/build/babel/remove-all-options-server.d.ts.map +0 -1
- package/dist/chunk-2OTEFUER.cjs.map +0 -1
- package/dist/chunk-5CWPEG6R.js +0 -62
- package/dist/chunk-5CWPEG6R.js.map +0 -1
- package/dist/chunk-BFQ2S5UD.cjs.map +0 -1
- package/dist/chunk-BTNPI4Z7.cjs +0 -4
- package/dist/chunk-FBT6QP7J.js +0 -3
- package/dist/chunk-ID3HN3BH.cjs +0 -16
- package/dist/chunk-MMUE22EL.js.map +0 -1
- package/dist/chunk-MUWNMVNL.cjs.map +0 -1
- package/dist/chunk-N5TMJUIR.js +0 -14
- package/dist/chunk-Q2YGWEXY.js +0 -6
- package/dist/chunk-RBPCXFN7.js.map +0 -1
- package/dist/chunk-SS22TD6R.cjs.map +0 -1
- package/dist/chunk-TK2CCU7I.js.map +0 -1
- package/dist/chunk-TXKETRIN.cjs.map +0 -1
- package/dist/chunk-UQZGTSBF.js.map +0 -1
- package/dist/chunk-X4TNUYQL.cjs +0 -196
- package/dist/chunk-X4TNUYQL.cjs.map +0 -1
- package/dist/chunk-X5QU7B2W.js +0 -169
- package/dist/chunk-X5QU7B2W.js.map +0 -1
- package/dist/default-u_dwuiYb-65M4BHAA.js +0 -3
- package/dist/default-u_dwuiYb-PWN6FHC6.cjs +0 -9
- package/dist/effect-QlVUlMFu-2ADPKIDF.cjs +0 -17
- package/dist/esm-BLVTLTJW.js.map +0 -1
- package/dist/esm-E3NUCNVN.cjs.map +0 -1
- package/dist/server/handlers/prompt.d.ts +0 -3
- package/dist/server/handlers/prompt.d.ts.map +0 -1
- package/dist/sury-CWZTCd75-K3FHMZF5.cjs +0 -17
- package/dist/typebox-Dei93FPO-2WP4NOYD.js +0 -8
- package/dist/valibot--1zFm7rT-HMTCRBB3.cjs +0 -17
package/dist/server/index.cjs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunk5TYVF4KJ_cjs = require('../chunk-5TYVF4KJ.cjs');
|
|
3
4
|
var promises = require('fs/promises');
|
|
4
5
|
var https = require('https');
|
|
5
|
-
var
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var url = require('url');
|
|
6
8
|
var http = require('http');
|
|
7
9
|
var http2 = require('http2');
|
|
8
10
|
var stream$1 = require('stream');
|
|
9
11
|
var crypto = require('crypto');
|
|
10
12
|
var mime = require('hono/utils/mime');
|
|
11
13
|
var fs = require('fs');
|
|
12
|
-
var path = require('path');
|
|
13
14
|
var html = require('hono/html');
|
|
14
15
|
var tools = require('@mastra/core/tools');
|
|
16
|
+
var error = require('@mastra/server/handlers/error');
|
|
15
17
|
var serverAdapter = require('@mastra/server/server-adapter');
|
|
16
18
|
var util = require('util');
|
|
17
19
|
var buffer = require('buffer');
|
|
@@ -23,6 +25,7 @@ var logger = require('hono/logger');
|
|
|
23
25
|
var timeout = require('hono/timeout');
|
|
24
26
|
var httpException = require('hono/http-exception');
|
|
25
27
|
|
|
28
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
26
29
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
30
|
|
|
28
31
|
function _interopNamespace(e) {
|
|
@@ -83,7 +86,7 @@ var newHeadersFromIncoming = (incoming) => {
|
|
|
83
86
|
}
|
|
84
87
|
return new Headers(headerRecord);
|
|
85
88
|
};
|
|
86
|
-
var wrapBodyStream = Symbol("wrapBodyStream");
|
|
89
|
+
var wrapBodyStream = /* @__PURE__ */ Symbol("wrapBodyStream");
|
|
87
90
|
var newRequestFromIncoming = (method, url, headers, incoming, abortController) => {
|
|
88
91
|
const init = {
|
|
89
92
|
method,
|
|
@@ -131,13 +134,13 @@ var newRequestFromIncoming = (method, url, headers, incoming, abortController) =
|
|
|
131
134
|
}
|
|
132
135
|
return new Request2(url, init);
|
|
133
136
|
};
|
|
134
|
-
var getRequestCache = Symbol("getRequestCache");
|
|
135
|
-
var requestCache = Symbol("requestCache");
|
|
136
|
-
var incomingKey = Symbol("incomingKey");
|
|
137
|
-
var urlKey = Symbol("urlKey");
|
|
138
|
-
var headersKey = Symbol("headersKey");
|
|
139
|
-
var abortControllerKey = Symbol("abortControllerKey");
|
|
140
|
-
var getAbortController = Symbol("getAbortController");
|
|
137
|
+
var getRequestCache = /* @__PURE__ */ Symbol("getRequestCache");
|
|
138
|
+
var requestCache = /* @__PURE__ */ Symbol("requestCache");
|
|
139
|
+
var incomingKey = /* @__PURE__ */ Symbol("incomingKey");
|
|
140
|
+
var urlKey = /* @__PURE__ */ Symbol("urlKey");
|
|
141
|
+
var headersKey = /* @__PURE__ */ Symbol("headersKey");
|
|
142
|
+
var abortControllerKey = /* @__PURE__ */ Symbol("abortControllerKey");
|
|
143
|
+
var getAbortController = /* @__PURE__ */ Symbol("getAbortController");
|
|
141
144
|
var requestPrototype = {
|
|
142
145
|
get method() {
|
|
143
146
|
return this[incomingKey].method || "GET";
|
|
@@ -228,9 +231,9 @@ var newRequest = (incoming, defaultHostname) => {
|
|
|
228
231
|
req[urlKey] = url.href;
|
|
229
232
|
return req;
|
|
230
233
|
};
|
|
231
|
-
var responseCache = Symbol("responseCache");
|
|
232
|
-
var getResponseCache = Symbol("getResponseCache");
|
|
233
|
-
var cacheKey = Symbol("cache");
|
|
234
|
+
var responseCache = /* @__PURE__ */ Symbol("responseCache");
|
|
235
|
+
var getResponseCache = /* @__PURE__ */ Symbol("getResponseCache");
|
|
236
|
+
var cacheKey = /* @__PURE__ */ Symbol("cache");
|
|
234
237
|
var GlobalResponse = global.Response;
|
|
235
238
|
var Response2 = class _Response {
|
|
236
239
|
#body;
|
|
@@ -372,7 +375,7 @@ global.fetch = (info, init) => {
|
|
|
372
375
|
};
|
|
373
376
|
return webFetch(info, init);
|
|
374
377
|
};
|
|
375
|
-
var outgoingEnded = Symbol("outgoingEnded");
|
|
378
|
+
var outgoingEnded = /* @__PURE__ */ Symbol("outgoingEnded");
|
|
376
379
|
var handleRequestError = () => new Response(null, {
|
|
377
380
|
status: 400
|
|
378
381
|
});
|
|
@@ -1026,12 +1029,12 @@ var ERR_STREAM_WRITE_AFTER_END = class extends Error {
|
|
|
1026
1029
|
};
|
|
1027
1030
|
|
|
1028
1031
|
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/fetch-to-node/http-incoming.js
|
|
1029
|
-
var kHeaders = Symbol("kHeaders");
|
|
1030
|
-
var kHeadersDistinct = Symbol("kHeadersDistinct");
|
|
1031
|
-
var kHeadersCount = Symbol("kHeadersCount");
|
|
1032
|
-
var kTrailers = Symbol("kTrailers");
|
|
1033
|
-
var kTrailersDistinct = Symbol("kTrailersDistinct");
|
|
1034
|
-
var kTrailersCount = Symbol("kTrailersCount");
|
|
1032
|
+
var kHeaders = /* @__PURE__ */ Symbol("kHeaders");
|
|
1033
|
+
var kHeadersDistinct = /* @__PURE__ */ Symbol("kHeadersDistinct");
|
|
1034
|
+
var kHeadersCount = /* @__PURE__ */ Symbol("kHeadersCount");
|
|
1035
|
+
var kTrailers = /* @__PURE__ */ Symbol("kTrailers");
|
|
1036
|
+
var kTrailersDistinct = /* @__PURE__ */ Symbol("kTrailersDistinct");
|
|
1037
|
+
var kTrailersCount = /* @__PURE__ */ Symbol("kTrailersCount");
|
|
1035
1038
|
var FetchIncomingMessage = class extends stream$1.Readable {
|
|
1036
1039
|
get socket() {
|
|
1037
1040
|
return null;
|
|
@@ -1397,8 +1400,8 @@ function isUint8Array(value) {
|
|
|
1397
1400
|
}
|
|
1398
1401
|
|
|
1399
1402
|
// ../../node_modules/.pnpm/fetch-to-node@2.1.0/node_modules/fetch-to-node/dist/fetch-to-node/internal-http.js
|
|
1400
|
-
var kNeedDrain = Symbol("kNeedDrain");
|
|
1401
|
-
var kOutHeaders = Symbol("kOutHeaders");
|
|
1403
|
+
var kNeedDrain = /* @__PURE__ */ Symbol("kNeedDrain");
|
|
1404
|
+
var kOutHeaders = /* @__PURE__ */ Symbol("kOutHeaders");
|
|
1402
1405
|
function utcDate() {
|
|
1403
1406
|
return (/* @__PURE__ */ new Date()).toUTCString();
|
|
1404
1407
|
}
|
|
@@ -1418,14 +1421,14 @@ function checkInvalidHeaderChar(val) {
|
|
|
1418
1421
|
return headerCharRegex.test(val);
|
|
1419
1422
|
}
|
|
1420
1423
|
var chunkExpression = /(?:^|\W)chunked(?:$|\W)/i;
|
|
1421
|
-
var kCorked = Symbol("corked");
|
|
1422
|
-
var kChunkedBuffer = Symbol("kChunkedBuffer");
|
|
1423
|
-
var kChunkedLength = Symbol("kChunkedLength");
|
|
1424
|
-
var kUniqueHeaders = Symbol("kUniqueHeaders");
|
|
1425
|
-
var kBytesWritten = Symbol("kBytesWritten");
|
|
1426
|
-
var kErrored = Symbol("errored");
|
|
1427
|
-
var kHighWaterMark = Symbol("kHighWaterMark");
|
|
1428
|
-
var kRejectNonStandardBodyWrites = Symbol("kRejectNonStandardBodyWrites");
|
|
1424
|
+
var kCorked = /* @__PURE__ */ Symbol("corked");
|
|
1425
|
+
var kChunkedBuffer = /* @__PURE__ */ Symbol("kChunkedBuffer");
|
|
1426
|
+
var kChunkedLength = /* @__PURE__ */ Symbol("kChunkedLength");
|
|
1427
|
+
var kUniqueHeaders = /* @__PURE__ */ Symbol("kUniqueHeaders");
|
|
1428
|
+
var kBytesWritten = /* @__PURE__ */ Symbol("kBytesWritten");
|
|
1429
|
+
var kErrored = /* @__PURE__ */ Symbol("errored");
|
|
1430
|
+
var kHighWaterMark = /* @__PURE__ */ Symbol("kHighWaterMark");
|
|
1431
|
+
var kRejectNonStandardBodyWrites = /* @__PURE__ */ Symbol("kRejectNonStandardBodyWrites");
|
|
1429
1432
|
var nop = () => {
|
|
1430
1433
|
};
|
|
1431
1434
|
var RE_CONN_CLOSE = /(?:^|\W)close(?:$|\W)/i;
|
|
@@ -2692,11 +2695,21 @@ function toFetchResponse(res) {
|
|
|
2692
2695
|
var HTTPException = class extends Error {
|
|
2693
2696
|
res;
|
|
2694
2697
|
status;
|
|
2698
|
+
/**
|
|
2699
|
+
* Creates an instance of `HTTPException`.
|
|
2700
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
2701
|
+
* @param options - Additional options for the exception.
|
|
2702
|
+
*/
|
|
2695
2703
|
constructor(status = 500, options) {
|
|
2696
2704
|
super(options?.message, { cause: options?.cause });
|
|
2697
2705
|
this.res = options?.res;
|
|
2698
2706
|
this.status = status;
|
|
2699
2707
|
}
|
|
2708
|
+
/**
|
|
2709
|
+
* Returns the response object associated with the exception.
|
|
2710
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
2711
|
+
* @returns The response object.
|
|
2712
|
+
*/
|
|
2700
2713
|
getResponse() {
|
|
2701
2714
|
if (this.res) {
|
|
2702
2715
|
const newResponse = new Response(this.res.body, {
|
|
@@ -2771,7 +2784,13 @@ var StreamingApi = class {
|
|
|
2771
2784
|
writable;
|
|
2772
2785
|
abortSubscribers = [];
|
|
2773
2786
|
responseReadable;
|
|
2787
|
+
/**
|
|
2788
|
+
* Whether the stream has been aborted.
|
|
2789
|
+
*/
|
|
2774
2790
|
aborted = false;
|
|
2791
|
+
/**
|
|
2792
|
+
* Whether the stream has been closed normally.
|
|
2793
|
+
*/
|
|
2775
2794
|
closed = false;
|
|
2776
2795
|
constructor(writable, _readable) {
|
|
2777
2796
|
this.writable = writable;
|
|
@@ -2823,6 +2842,10 @@ var StreamingApi = class {
|
|
|
2823
2842
|
onAbort(listener) {
|
|
2824
2843
|
this.abortSubscribers.push(listener);
|
|
2825
2844
|
}
|
|
2845
|
+
/**
|
|
2846
|
+
* Abort the stream.
|
|
2847
|
+
* You can call this method when stream is aborted by external event.
|
|
2848
|
+
*/
|
|
2826
2849
|
abort() {
|
|
2827
2850
|
if (!this.aborted) {
|
|
2828
2851
|
this.aborted = true;
|
|
@@ -2867,6 +2890,209 @@ var stream = (c, cb, onError3) => {
|
|
|
2867
2890
|
})();
|
|
2868
2891
|
return c.newResponse(stream2.responseReadable);
|
|
2869
2892
|
};
|
|
2893
|
+
var util2;
|
|
2894
|
+
(function(util22) {
|
|
2895
|
+
util22.assertEqual = (_) => {
|
|
2896
|
+
};
|
|
2897
|
+
function assertIs(_arg) {
|
|
2898
|
+
}
|
|
2899
|
+
util22.assertIs = assertIs;
|
|
2900
|
+
function assertNever(_x) {
|
|
2901
|
+
throw new Error();
|
|
2902
|
+
}
|
|
2903
|
+
util22.assertNever = assertNever;
|
|
2904
|
+
util22.arrayToEnum = (items) => {
|
|
2905
|
+
const obj = {};
|
|
2906
|
+
for (const item of items) {
|
|
2907
|
+
obj[item] = item;
|
|
2908
|
+
}
|
|
2909
|
+
return obj;
|
|
2910
|
+
};
|
|
2911
|
+
util22.getValidEnumValues = (obj) => {
|
|
2912
|
+
const validKeys = util22.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
2913
|
+
const filtered = {};
|
|
2914
|
+
for (const k of validKeys) {
|
|
2915
|
+
filtered[k] = obj[k];
|
|
2916
|
+
}
|
|
2917
|
+
return util22.objectValues(filtered);
|
|
2918
|
+
};
|
|
2919
|
+
util22.objectValues = (obj) => {
|
|
2920
|
+
return util22.objectKeys(obj).map(function(e) {
|
|
2921
|
+
return obj[e];
|
|
2922
|
+
});
|
|
2923
|
+
};
|
|
2924
|
+
util22.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
2925
|
+
const keys = [];
|
|
2926
|
+
for (const key in object) {
|
|
2927
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
2928
|
+
keys.push(key);
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
return keys;
|
|
2932
|
+
};
|
|
2933
|
+
util22.find = (arr, checker) => {
|
|
2934
|
+
for (const item of arr) {
|
|
2935
|
+
if (checker(item))
|
|
2936
|
+
return item;
|
|
2937
|
+
}
|
|
2938
|
+
return void 0;
|
|
2939
|
+
};
|
|
2940
|
+
util22.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
2941
|
+
function joinValues(array, separator = " | ") {
|
|
2942
|
+
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
2943
|
+
}
|
|
2944
|
+
util22.joinValues = joinValues;
|
|
2945
|
+
util22.jsonStringifyReplacer = (_, value) => {
|
|
2946
|
+
if (typeof value === "bigint") {
|
|
2947
|
+
return value.toString();
|
|
2948
|
+
}
|
|
2949
|
+
return value;
|
|
2950
|
+
};
|
|
2951
|
+
})(util2 || (util2 = {}));
|
|
2952
|
+
var objectUtil;
|
|
2953
|
+
(function(objectUtil2) {
|
|
2954
|
+
objectUtil2.mergeShapes = (first, second) => {
|
|
2955
|
+
return {
|
|
2956
|
+
...first,
|
|
2957
|
+
...second
|
|
2958
|
+
// second overwrites first
|
|
2959
|
+
};
|
|
2960
|
+
};
|
|
2961
|
+
})(objectUtil || (objectUtil = {}));
|
|
2962
|
+
util2.arrayToEnum([
|
|
2963
|
+
"string",
|
|
2964
|
+
"nan",
|
|
2965
|
+
"number",
|
|
2966
|
+
"integer",
|
|
2967
|
+
"float",
|
|
2968
|
+
"boolean",
|
|
2969
|
+
"date",
|
|
2970
|
+
"bigint",
|
|
2971
|
+
"symbol",
|
|
2972
|
+
"function",
|
|
2973
|
+
"undefined",
|
|
2974
|
+
"null",
|
|
2975
|
+
"array",
|
|
2976
|
+
"object",
|
|
2977
|
+
"unknown",
|
|
2978
|
+
"promise",
|
|
2979
|
+
"void",
|
|
2980
|
+
"never",
|
|
2981
|
+
"map",
|
|
2982
|
+
"set"
|
|
2983
|
+
]);
|
|
2984
|
+
util2.arrayToEnum([
|
|
2985
|
+
"invalid_type",
|
|
2986
|
+
"invalid_literal",
|
|
2987
|
+
"custom",
|
|
2988
|
+
"invalid_union",
|
|
2989
|
+
"invalid_union_discriminator",
|
|
2990
|
+
"invalid_enum_value",
|
|
2991
|
+
"unrecognized_keys",
|
|
2992
|
+
"invalid_arguments",
|
|
2993
|
+
"invalid_return_type",
|
|
2994
|
+
"invalid_date",
|
|
2995
|
+
"invalid_string",
|
|
2996
|
+
"too_small",
|
|
2997
|
+
"too_big",
|
|
2998
|
+
"invalid_intersection_types",
|
|
2999
|
+
"not_multiple_of",
|
|
3000
|
+
"not_finite"
|
|
3001
|
+
]);
|
|
3002
|
+
var ZodError = class _ZodError extends Error {
|
|
3003
|
+
get errors() {
|
|
3004
|
+
return this.issues;
|
|
3005
|
+
}
|
|
3006
|
+
constructor(issues) {
|
|
3007
|
+
super();
|
|
3008
|
+
this.issues = [];
|
|
3009
|
+
this.addIssue = (sub) => {
|
|
3010
|
+
this.issues = [...this.issues, sub];
|
|
3011
|
+
};
|
|
3012
|
+
this.addIssues = (subs = []) => {
|
|
3013
|
+
this.issues = [...this.issues, ...subs];
|
|
3014
|
+
};
|
|
3015
|
+
const actualProto = new.target.prototype;
|
|
3016
|
+
if (Object.setPrototypeOf) {
|
|
3017
|
+
Object.setPrototypeOf(this, actualProto);
|
|
3018
|
+
} else {
|
|
3019
|
+
this.__proto__ = actualProto;
|
|
3020
|
+
}
|
|
3021
|
+
this.name = "ZodError";
|
|
3022
|
+
this.issues = issues;
|
|
3023
|
+
}
|
|
3024
|
+
format(_mapper) {
|
|
3025
|
+
const mapper = _mapper || function(issue) {
|
|
3026
|
+
return issue.message;
|
|
3027
|
+
};
|
|
3028
|
+
const fieldErrors = { _errors: [] };
|
|
3029
|
+
const processError = (error) => {
|
|
3030
|
+
for (const issue of error.issues) {
|
|
3031
|
+
if (issue.code === "invalid_union") {
|
|
3032
|
+
issue.unionErrors.map(processError);
|
|
3033
|
+
} else if (issue.code === "invalid_return_type") {
|
|
3034
|
+
processError(issue.returnTypeError);
|
|
3035
|
+
} else if (issue.code === "invalid_arguments") {
|
|
3036
|
+
processError(issue.argumentsError);
|
|
3037
|
+
} else if (issue.path.length === 0) {
|
|
3038
|
+
fieldErrors._errors.push(mapper(issue));
|
|
3039
|
+
} else {
|
|
3040
|
+
let curr = fieldErrors;
|
|
3041
|
+
let i = 0;
|
|
3042
|
+
while (i < issue.path.length) {
|
|
3043
|
+
const el = issue.path[i];
|
|
3044
|
+
const terminal = i === issue.path.length - 1;
|
|
3045
|
+
if (!terminal) {
|
|
3046
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
3047
|
+
} else {
|
|
3048
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
3049
|
+
curr[el]._errors.push(mapper(issue));
|
|
3050
|
+
}
|
|
3051
|
+
curr = curr[el];
|
|
3052
|
+
i++;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
};
|
|
3057
|
+
processError(this);
|
|
3058
|
+
return fieldErrors;
|
|
3059
|
+
}
|
|
3060
|
+
static assert(value) {
|
|
3061
|
+
if (!(value instanceof _ZodError)) {
|
|
3062
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
toString() {
|
|
3066
|
+
return this.message;
|
|
3067
|
+
}
|
|
3068
|
+
get message() {
|
|
3069
|
+
return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
|
|
3070
|
+
}
|
|
3071
|
+
get isEmpty() {
|
|
3072
|
+
return this.issues.length === 0;
|
|
3073
|
+
}
|
|
3074
|
+
flatten(mapper = (issue) => issue.message) {
|
|
3075
|
+
const fieldErrors = {};
|
|
3076
|
+
const formErrors = [];
|
|
3077
|
+
for (const sub of this.issues) {
|
|
3078
|
+
if (sub.path.length > 0) {
|
|
3079
|
+
const firstEl = sub.path[0];
|
|
3080
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
3081
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
3082
|
+
} else {
|
|
3083
|
+
formErrors.push(mapper(sub));
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
return { formErrors, fieldErrors };
|
|
3087
|
+
}
|
|
3088
|
+
get formErrors() {
|
|
3089
|
+
return this.flatten();
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
3092
|
+
ZodError.create = (issues) => {
|
|
3093
|
+
const error = new ZodError(issues);
|
|
3094
|
+
return error;
|
|
3095
|
+
};
|
|
2870
3096
|
var authenticationMiddleware = async (c, next) => {
|
|
2871
3097
|
const mastra = c.get("mastra");
|
|
2872
3098
|
const authConfig = mastra.getServer()?.auth;
|
|
@@ -3010,8 +3236,6 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3010
3236
|
c.set("mastra", this.mastra);
|
|
3011
3237
|
c.set("tools", this.tools || {});
|
|
3012
3238
|
c.set("taskStore", this.taskStore);
|
|
3013
|
-
c.set("playground", this.playground === true);
|
|
3014
|
-
c.set("isDev", this.isDev === true);
|
|
3015
3239
|
c.set("abortSignal", c.req.raw.signal);
|
|
3016
3240
|
c.set("customRouteAuthConfig", this.customRouteAuthConfig);
|
|
3017
3241
|
return next();
|
|
@@ -3059,16 +3283,51 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3059
3283
|
}
|
|
3060
3284
|
async getParams(route, request) {
|
|
3061
3285
|
const urlParams = request.param();
|
|
3062
|
-
const queryParams = request.
|
|
3286
|
+
const queryParams = serverAdapter.normalizeQueryParams(request.queries());
|
|
3063
3287
|
let body;
|
|
3064
3288
|
if (route.method === "POST" || route.method === "PUT" || route.method === "PATCH") {
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3289
|
+
const contentType = request.header("content-type") || "";
|
|
3290
|
+
if (contentType.includes("multipart/form-data")) {
|
|
3291
|
+
try {
|
|
3292
|
+
const formData = await request.formData();
|
|
3293
|
+
body = await this.parseFormData(formData);
|
|
3294
|
+
} catch (error) {
|
|
3295
|
+
console.error("Failed to parse multipart form data:", error);
|
|
3296
|
+
if (error instanceof Error && error.message.toLowerCase().includes("size")) {
|
|
3297
|
+
throw error;
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
} else {
|
|
3301
|
+
try {
|
|
3302
|
+
body = await request.json();
|
|
3303
|
+
} catch (error) {
|
|
3304
|
+
console.error("Failed to parse JSON body:", error);
|
|
3305
|
+
}
|
|
3068
3306
|
}
|
|
3069
3307
|
}
|
|
3070
3308
|
return { urlParams, queryParams, body };
|
|
3071
3309
|
}
|
|
3310
|
+
/**
|
|
3311
|
+
* Parse FormData into a plain object, converting File objects to Buffers.
|
|
3312
|
+
*/
|
|
3313
|
+
async parseFormData(formData) {
|
|
3314
|
+
const result = {};
|
|
3315
|
+
for (const [key, value] of formData.entries()) {
|
|
3316
|
+
if (value instanceof File) {
|
|
3317
|
+
const arrayBuffer = await value.arrayBuffer();
|
|
3318
|
+
result[key] = Buffer.from(arrayBuffer);
|
|
3319
|
+
} else if (typeof value === "string") {
|
|
3320
|
+
try {
|
|
3321
|
+
result[key] = JSON.parse(value);
|
|
3322
|
+
} catch {
|
|
3323
|
+
result[key] = value;
|
|
3324
|
+
}
|
|
3325
|
+
} else {
|
|
3326
|
+
result[key] = value;
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
return result;
|
|
3330
|
+
}
|
|
3072
3331
|
async sendResponse(route, response, result) {
|
|
3073
3332
|
if (route.responseType === "json") {
|
|
3074
3333
|
return response.json(result, 200);
|
|
@@ -3138,12 +3397,15 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3138
3397
|
if (params.queryParams) {
|
|
3139
3398
|
try {
|
|
3140
3399
|
params.queryParams = await this.parseQueryParams(route, params.queryParams);
|
|
3141
|
-
} catch (error) {
|
|
3142
|
-
console.error("Error parsing query params", error);
|
|
3400
|
+
} catch (error$1) {
|
|
3401
|
+
console.error("Error parsing query params", error$1);
|
|
3402
|
+
if (error$1 instanceof ZodError) {
|
|
3403
|
+
return c.json(error.formatZodError(error$1, "query parameters"), 400);
|
|
3404
|
+
}
|
|
3143
3405
|
return c.json(
|
|
3144
3406
|
{
|
|
3145
3407
|
error: "Invalid query parameters",
|
|
3146
|
-
|
|
3408
|
+
issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
|
|
3147
3409
|
},
|
|
3148
3410
|
400
|
|
3149
3411
|
);
|
|
@@ -3152,12 +3414,15 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3152
3414
|
if (params.body) {
|
|
3153
3415
|
try {
|
|
3154
3416
|
params.body = await this.parseBody(route, params.body);
|
|
3155
|
-
} catch (error) {
|
|
3156
|
-
console.error("Error parsing body:", error instanceof Error ? error.message : String(error));
|
|
3417
|
+
} catch (error$1) {
|
|
3418
|
+
console.error("Error parsing body:", error$1 instanceof Error ? error$1.message : String(error$1));
|
|
3419
|
+
if (error$1 instanceof ZodError) {
|
|
3420
|
+
return c.json(error.formatZodError(error$1, "request body"), 400);
|
|
3421
|
+
}
|
|
3157
3422
|
return c.json(
|
|
3158
3423
|
{
|
|
3159
3424
|
error: "Invalid request body",
|
|
3160
|
-
|
|
3425
|
+
issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
|
|
3161
3426
|
},
|
|
3162
3427
|
400
|
|
3163
3428
|
);
|
|
@@ -3206,8 +3471,8 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3206
3471
|
}
|
|
3207
3472
|
};
|
|
3208
3473
|
|
|
3209
|
-
// ../../node_modules/.pnpm/hono-openapi@1.1.1_@hono+standard-validator@0.2.
|
|
3210
|
-
var uniqueSymbol = Symbol("openapi");
|
|
3474
|
+
// ../../node_modules/.pnpm/hono-openapi@1.1.1_@hono+standard-validator@0.2.1_@standard-schema+spec@1.1.0_hono@4.11_9131e3cfc9e6aabf665461e37801bbee/node_modules/hono-openapi/dist/index.js
|
|
3475
|
+
var uniqueSymbol = /* @__PURE__ */ Symbol("openapi");
|
|
3211
3476
|
function describeRoute(spec) {
|
|
3212
3477
|
const middleware2 = async (_c, next) => {
|
|
3213
3478
|
await next();
|
|
@@ -3288,6 +3553,126 @@ async function restartAllActiveWorkflowRunsHandler(c) {
|
|
|
3288
3553
|
}
|
|
3289
3554
|
}
|
|
3290
3555
|
|
|
3556
|
+
// src/server/handlers/root.ts
|
|
3557
|
+
async function rootHandler(c) {
|
|
3558
|
+
const baseUrl = new URL(c.req.url).origin;
|
|
3559
|
+
return c.html(
|
|
3560
|
+
/* html */
|
|
3561
|
+
`
|
|
3562
|
+
<!doctype html>
|
|
3563
|
+
<html lang="en">
|
|
3564
|
+
<head>
|
|
3565
|
+
<meta charset="UTF-8" />
|
|
3566
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
3567
|
+
<title>Mastra API</title>
|
|
3568
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/inter-ui/3.19.3/inter.min.css" />
|
|
3569
|
+
<style>
|
|
3570
|
+
body {
|
|
3571
|
+
margin: 0;
|
|
3572
|
+
padding: 0;
|
|
3573
|
+
background-color: #0d0d0d;
|
|
3574
|
+
color: #ffffff;
|
|
3575
|
+
font-family:
|
|
3576
|
+
'Inter',
|
|
3577
|
+
-apple-system,
|
|
3578
|
+
BlinkMacSystemFont,
|
|
3579
|
+
system-ui,
|
|
3580
|
+
sans-serif;
|
|
3581
|
+
min-height: 100vh;
|
|
3582
|
+
display: flex;
|
|
3583
|
+
flex-direction: column;
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
main {
|
|
3587
|
+
flex: 1;
|
|
3588
|
+
display: flex;
|
|
3589
|
+
flex-direction: column;
|
|
3590
|
+
align-items: center;
|
|
3591
|
+
justify-content: center;
|
|
3592
|
+
padding: 2rem;
|
|
3593
|
+
text-align: center;
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3596
|
+
h1 {
|
|
3597
|
+
font-size: 4rem;
|
|
3598
|
+
font-weight: 600;
|
|
3599
|
+
margin: 0 0 1rem 0;
|
|
3600
|
+
background: linear-gradient(to right, #fff, #ccc);
|
|
3601
|
+
-webkit-background-clip: text;
|
|
3602
|
+
-webkit-text-fill-color: transparent;
|
|
3603
|
+
line-height: 1.2;
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
.subtitle {
|
|
3607
|
+
color: #9ca3af;
|
|
3608
|
+
font-size: 1.25rem;
|
|
3609
|
+
max-width: 600px;
|
|
3610
|
+
margin: 0 auto 3rem auto;
|
|
3611
|
+
line-height: 1.6;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3614
|
+
.link {
|
|
3615
|
+
color: #ffffff;
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
.link:hover {
|
|
3619
|
+
text-decoration: none;
|
|
3620
|
+
}
|
|
3621
|
+
|
|
3622
|
+
.docs-link {
|
|
3623
|
+
background-color: #1a1a1a;
|
|
3624
|
+
padding: 1rem 2rem;
|
|
3625
|
+
border-radius: 0.5rem;
|
|
3626
|
+
display: flex;
|
|
3627
|
+
align-items: center;
|
|
3628
|
+
gap: 1rem;
|
|
3629
|
+
font-family: monospace;
|
|
3630
|
+
font-size: 1rem;
|
|
3631
|
+
color: #ffffff;
|
|
3632
|
+
text-decoration: none;
|
|
3633
|
+
transition: background-color 0.2s;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
.docs-link:hover {
|
|
3637
|
+
background-color: #252525;
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
.arrow-icon {
|
|
3641
|
+
transition: transform 0.2s;
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
.docs-link:hover .arrow-icon {
|
|
3645
|
+
transform: translateX(4px);
|
|
3646
|
+
}
|
|
3647
|
+
</style>
|
|
3648
|
+
</head>
|
|
3649
|
+
<body>
|
|
3650
|
+
<main>
|
|
3651
|
+
<h1>Welcome to the Mastra API</h1>
|
|
3652
|
+
<p class="subtitle">
|
|
3653
|
+
Discover all available endpoints through Swagger UI. You can also define your own <a href="https://mastra.ai/docs/server-db/custom-api-routes" target="_blank" class="link">API routes</a>.
|
|
3654
|
+
</p>
|
|
3655
|
+
<a href="${baseUrl}/swagger-ui" target="_blank" class="docs-link">
|
|
3656
|
+
Browse Swagger UI
|
|
3657
|
+
<svg
|
|
3658
|
+
class="arrow-icon"
|
|
3659
|
+
width="20"
|
|
3660
|
+
height="20"
|
|
3661
|
+
viewBox="0 0 24 24"
|
|
3662
|
+
fill="none"
|
|
3663
|
+
stroke="currentColor"
|
|
3664
|
+
strokeWidth="2"
|
|
3665
|
+
>
|
|
3666
|
+
<path d="M5 12h14M12 5l7 7-7 7" />
|
|
3667
|
+
</svg>
|
|
3668
|
+
</a>
|
|
3669
|
+
</main>
|
|
3670
|
+
</body>
|
|
3671
|
+
</html>
|
|
3672
|
+
`
|
|
3673
|
+
);
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3291
3676
|
// src/server/welcome.ts
|
|
3292
3677
|
var html2 = `
|
|
3293
3678
|
<!doctype html>
|
|
@@ -3396,6 +3781,18 @@ var html2 = `
|
|
|
3396
3781
|
`;
|
|
3397
3782
|
|
|
3398
3783
|
// src/server/index.ts
|
|
3784
|
+
var getStudioPath = () => {
|
|
3785
|
+
if (process.env.MASTRA_STUDIO_PATH) {
|
|
3786
|
+
return process.env.MASTRA_STUDIO_PATH;
|
|
3787
|
+
}
|
|
3788
|
+
let __dirname = ".";
|
|
3789
|
+
if ((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))) {
|
|
3790
|
+
const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
3791
|
+
__dirname = path.dirname(__filename);
|
|
3792
|
+
}
|
|
3793
|
+
const studioPath = process.env.MASTRA_STUDIO_PATH || path.join(__dirname, "studio");
|
|
3794
|
+
return studioPath;
|
|
3795
|
+
};
|
|
3399
3796
|
function getToolExports(tools$1) {
|
|
3400
3797
|
try {
|
|
3401
3798
|
return tools$1.reduce((acc, toolModule) => {
|
|
@@ -3431,7 +3828,13 @@ async function createHonoServer(mastra, options = {
|
|
|
3431
3828
|
customRouteAuthConfig.set(routeKey, requiresAuth);
|
|
3432
3829
|
}
|
|
3433
3830
|
}
|
|
3434
|
-
|
|
3831
|
+
const customOnError = server?.onError;
|
|
3832
|
+
app.onError((err, c) => {
|
|
3833
|
+
if (customOnError) {
|
|
3834
|
+
return customOnError(err, c);
|
|
3835
|
+
}
|
|
3836
|
+
return errorHandler(err, c, options.isDev);
|
|
3837
|
+
});
|
|
3435
3838
|
const bodyLimitOptions = {
|
|
3436
3839
|
maxSize: server?.bodySizeLimit ?? 4.5 * 1024 * 1024,
|
|
3437
3840
|
// 4.5 MB,
|
|
@@ -3442,10 +3845,8 @@ async function createHonoServer(mastra, options = {
|
|
|
3442
3845
|
mastra,
|
|
3443
3846
|
tools: options.tools,
|
|
3444
3847
|
taskStore: a2aTaskStore,
|
|
3445
|
-
playground: options.playground,
|
|
3446
|
-
isDev: options.isDev,
|
|
3447
3848
|
bodyLimitOptions,
|
|
3448
|
-
openapiPath: "/openapi.json",
|
|
3849
|
+
openapiPath: options?.isDev || server?.build?.openAPIDocs ? "/openapi.json" : void 0,
|
|
3449
3850
|
customRouteAuthConfig
|
|
3450
3851
|
});
|
|
3451
3852
|
honoServerAdapter.registerContextMiddleware();
|
|
@@ -3482,6 +3883,21 @@ async function createHonoServer(mastra, options = {
|
|
|
3482
3883
|
}),
|
|
3483
3884
|
healthHandler
|
|
3484
3885
|
);
|
|
3886
|
+
if (options?.isDev || server?.build?.swaggerUI) {
|
|
3887
|
+
app.get(
|
|
3888
|
+
"/api",
|
|
3889
|
+
describeRoute({
|
|
3890
|
+
description: "API Welcome Page",
|
|
3891
|
+
tags: ["system"],
|
|
3892
|
+
responses: {
|
|
3893
|
+
200: {
|
|
3894
|
+
description: "Success"
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
}),
|
|
3898
|
+
rootHandler
|
|
3899
|
+
);
|
|
3900
|
+
}
|
|
3485
3901
|
honoServerAdapter.registerAuthMiddleware();
|
|
3486
3902
|
if (server?.middleware) {
|
|
3487
3903
|
const normalizedMiddlewares = Array.isArray(server.middleware) ? server.middleware : [server.middleware];
|
|
@@ -3508,18 +3924,11 @@ async function createHonoServer(mastra, options = {
|
|
|
3508
3924
|
middlewares.push(describeRoute(route.openapi));
|
|
3509
3925
|
}
|
|
3510
3926
|
const handler = "handler" in route ? route.handler : await route.createHandler({ mastra });
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
app.put(route.path, ...middlewares, handler);
|
|
3517
|
-
} else if (route.method === "DELETE") {
|
|
3518
|
-
app.delete(route.path, ...middlewares, handler);
|
|
3519
|
-
} else if (route.method === "PATCH") {
|
|
3520
|
-
app.patch(route.path, ...middlewares, handler);
|
|
3521
|
-
} else if (route.method === "ALL") {
|
|
3522
|
-
app.all(route.path, ...middlewares, handler);
|
|
3927
|
+
const allHandlers = [...middlewares, handler];
|
|
3928
|
+
if (route.method === "ALL") {
|
|
3929
|
+
app.all(route.path, allHandlers[0], ...allHandlers.slice(1));
|
|
3930
|
+
} else {
|
|
3931
|
+
app.on(route.method, route.path, allHandlers[0], ...allHandlers.slice(1));
|
|
3523
3932
|
}
|
|
3524
3933
|
}
|
|
3525
3934
|
}
|
|
@@ -3528,6 +3937,12 @@ async function createHonoServer(mastra, options = {
|
|
|
3528
3937
|
}
|
|
3529
3938
|
await honoServerAdapter.registerRoutes();
|
|
3530
3939
|
if (options?.isDev || server?.build?.swaggerUI) {
|
|
3940
|
+
if (!options?.isDev && server?.build?.swaggerUI && !server?.build?.openAPIDocs) {
|
|
3941
|
+
const logger2 = mastra.getLogger();
|
|
3942
|
+
logger2.warn(
|
|
3943
|
+
"Swagger UI is enabled but OpenAPI documentation is disabled. The Swagger UI will not function properly without the OpenAPI endpoint. Please enable openAPIDocs in your server.build configuration:\n server: { build: { swaggerUI: true, openAPIDocs: true } }"
|
|
3944
|
+
);
|
|
3945
|
+
}
|
|
3531
3946
|
app.get(
|
|
3532
3947
|
"/swagger-ui",
|
|
3533
3948
|
describeRoute({
|
|
@@ -3545,23 +3960,25 @@ async function createHonoServer(mastra, options = {
|
|
|
3545
3960
|
restartAllActiveWorkflowRunsHandler
|
|
3546
3961
|
);
|
|
3547
3962
|
}
|
|
3548
|
-
|
|
3963
|
+
const serverOptions = mastra.getServer();
|
|
3964
|
+
const studioBasePath = chunk5TYVF4KJ_cjs.normalizeStudioBase(serverOptions?.studioBase ?? "/");
|
|
3965
|
+
if (options?.studio) {
|
|
3549
3966
|
app.get(
|
|
3550
|
-
|
|
3967
|
+
`${studioBasePath}/refresh-events`,
|
|
3551
3968
|
describeRoute({
|
|
3552
3969
|
hide: true
|
|
3553
3970
|
}),
|
|
3554
3971
|
handleClientsRefresh
|
|
3555
3972
|
);
|
|
3556
3973
|
app.post(
|
|
3557
|
-
|
|
3974
|
+
`${studioBasePath}/__refresh`,
|
|
3558
3975
|
describeRoute({
|
|
3559
3976
|
hide: true
|
|
3560
3977
|
}),
|
|
3561
3978
|
handleTriggerClientsRefresh
|
|
3562
3979
|
);
|
|
3563
3980
|
app.get(
|
|
3564
|
-
|
|
3981
|
+
`${studioBasePath}/__hot-reload-status`,
|
|
3565
3982
|
describeRoute({
|
|
3566
3983
|
hide: true
|
|
3567
3984
|
}),
|
|
@@ -3572,48 +3989,66 @@ async function createHonoServer(mastra, options = {
|
|
|
3572
3989
|
});
|
|
3573
3990
|
}
|
|
3574
3991
|
);
|
|
3575
|
-
|
|
3576
|
-
const path = c.req.path;
|
|
3577
|
-
if (path.endsWith(".js")) {
|
|
3578
|
-
c.header("Content-Type", "application/javascript");
|
|
3579
|
-
} else if (path.endsWith(".css")) {
|
|
3580
|
-
c.header("Content-Type", "text/css");
|
|
3581
|
-
}
|
|
3582
|
-
await next();
|
|
3583
|
-
});
|
|
3992
|
+
const studioPath = getStudioPath();
|
|
3584
3993
|
app.use(
|
|
3585
|
-
|
|
3994
|
+
`${studioBasePath}/assets/*`,
|
|
3586
3995
|
serveStatic({
|
|
3587
|
-
root: "
|
|
3996
|
+
root: path.join(studioPath, "assets"),
|
|
3997
|
+
rewriteRequestPath: (path) => {
|
|
3998
|
+
let rewritten = path;
|
|
3999
|
+
if (studioBasePath && rewritten.startsWith(studioBasePath)) {
|
|
4000
|
+
rewritten = rewritten.slice(studioBasePath.length);
|
|
4001
|
+
}
|
|
4002
|
+
if (rewritten.startsWith("/assets")) {
|
|
4003
|
+
rewritten = rewritten.slice("/assets".length);
|
|
4004
|
+
}
|
|
4005
|
+
return rewritten;
|
|
4006
|
+
}
|
|
3588
4007
|
})
|
|
3589
4008
|
);
|
|
3590
4009
|
}
|
|
3591
4010
|
app.get("*", async (c, next) => {
|
|
3592
|
-
|
|
4011
|
+
const requestPath = c.req.path;
|
|
4012
|
+
if (requestPath === "/api" || requestPath.startsWith("/api/") || requestPath.startsWith("/swagger-ui") || requestPath.startsWith("/openapi.json")) {
|
|
3593
4013
|
return await next();
|
|
3594
4014
|
}
|
|
3595
|
-
|
|
3596
|
-
if (path.includes(".") && !path.endsWith(".html")) {
|
|
4015
|
+
if (requestPath.includes(".") && !requestPath.endsWith(".html")) {
|
|
3597
4016
|
return await next();
|
|
3598
4017
|
}
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
const
|
|
4018
|
+
const isStudioRoute = studioBasePath === "" || requestPath === studioBasePath || requestPath.startsWith(`${studioBasePath}/`);
|
|
4019
|
+
if (options?.studio && isStudioRoute) {
|
|
4020
|
+
const studioPath = getStudioPath();
|
|
4021
|
+
let indexHtml = await promises.readFile(path.join(studioPath, "index.html"), "utf-8");
|
|
3602
4022
|
const port = serverOptions?.port ?? (Number(process.env.PORT) || 4111);
|
|
3603
4023
|
const hideCloudCta = process.env.MASTRA_HIDE_CLOUD_CTA === "true";
|
|
3604
4024
|
const host = serverOptions?.host ?? "localhost";
|
|
4025
|
+
const key = serverOptions?.https?.key ?? (process.env.MASTRA_HTTPS_KEY ? Buffer.from(process.env.MASTRA_HTTPS_KEY, "base64") : void 0);
|
|
4026
|
+
const cert = serverOptions?.https?.cert ?? (process.env.MASTRA_HTTPS_CERT ? Buffer.from(process.env.MASTRA_HTTPS_CERT, "base64") : void 0);
|
|
4027
|
+
const protocol = key && cert ? "https" : "http";
|
|
4028
|
+
const cloudApiEndpoint = process.env.MASTRA_CLOUD_API_ENDPOINT || "";
|
|
3605
4029
|
indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_HOST%%'`, `'${host}'`);
|
|
3606
4030
|
indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_PORT%%'`, `'${port}'`);
|
|
3607
4031
|
indexHtml = indexHtml.replace(`'%%MASTRA_HIDE_CLOUD_CTA%%'`, `'${hideCloudCta}'`);
|
|
4032
|
+
indexHtml = indexHtml.replace(`'%%MASTRA_SERVER_PROTOCOL%%'`, `'${protocol}'`);
|
|
4033
|
+
indexHtml = indexHtml.replace(`'%%MASTRA_CLOUD_API_ENDPOINT%%'`, `'${cloudApiEndpoint}'`);
|
|
4034
|
+
indexHtml = indexHtml.replaceAll("%%MASTRA_STUDIO_BASE_PATH%%", studioBasePath);
|
|
3608
4035
|
return c.newResponse(indexHtml, 200, { "Content-Type": "text/html" });
|
|
3609
4036
|
}
|
|
3610
4037
|
return c.newResponse(html2, 200, { "Content-Type": "text/html" });
|
|
3611
4038
|
});
|
|
3612
|
-
if (options?.
|
|
4039
|
+
if (options?.studio) {
|
|
4040
|
+
const studioRootPath = getStudioPath();
|
|
4041
|
+
const studioPath = studioBasePath ? `${studioBasePath}/*` : "*";
|
|
3613
4042
|
app.use(
|
|
3614
|
-
|
|
4043
|
+
studioPath,
|
|
3615
4044
|
serveStatic({
|
|
3616
|
-
root:
|
|
4045
|
+
root: studioRootPath,
|
|
4046
|
+
rewriteRequestPath: (path) => {
|
|
4047
|
+
if (studioBasePath && path.startsWith(studioBasePath)) {
|
|
4048
|
+
return path.slice(studioBasePath.length);
|
|
4049
|
+
}
|
|
4050
|
+
return path;
|
|
4051
|
+
}
|
|
3617
4052
|
})
|
|
3618
4053
|
);
|
|
3619
4054
|
}
|
|
@@ -3643,9 +4078,10 @@ async function createNodeServer(mastra, options = { tools: {} }) {
|
|
|
3643
4078
|
},
|
|
3644
4079
|
() => {
|
|
3645
4080
|
const logger2 = mastra.getLogger();
|
|
3646
|
-
logger2.info(` Mastra API running on
|
|
3647
|
-
if (options?.
|
|
3648
|
-
const
|
|
4081
|
+
logger2.info(` Mastra API running on ${protocol}://${host}:${port}/api`);
|
|
4082
|
+
if (options?.studio) {
|
|
4083
|
+
const studioBasePath = chunk5TYVF4KJ_cjs.normalizeStudioBase(serverOptions?.studioBase ?? "/");
|
|
4084
|
+
const studioUrl = `${protocol}://${host}:${port}${studioBasePath}`;
|
|
3649
4085
|
logger2.info(`\u{1F468}\u200D\u{1F4BB} Studio available at ${studioUrl}`);
|
|
3650
4086
|
}
|
|
3651
4087
|
if (process.send) {
|