@mastra/deployer 1.0.0-beta.14 → 1.0.0-beta.15
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 +26 -0
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- 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.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 +10 -10
- package/dist/build/index.js +3 -3
- 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/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/bundler/index.cjs +3 -3
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-IVKDKRCR.cjs → chunk-7F6JKGX4.cjs} +20 -12
- package/dist/chunk-7F6JKGX4.cjs.map +1 -0
- package/dist/{chunk-HNSVE6YO.js → chunk-BDA7RMRF.js} +191 -171
- package/dist/chunk-BDA7RMRF.js.map +1 -0
- package/dist/{chunk-UJXH5MNH.cjs → chunk-CRIOGWZD.cjs} +190 -171
- package/dist/chunk-CRIOGWZD.cjs.map +1 -0
- package/dist/{chunk-ZXT4NSIV.js → chunk-ESR6AK5N.js} +14 -6
- package/dist/chunk-ESR6AK5N.js.map +1 -0
- package/dist/{chunk-V5W7WIXT.cjs → chunk-HRCR6OKC.cjs} +11 -22
- package/dist/chunk-HRCR6OKC.cjs.map +1 -0
- package/dist/{chunk-C6UFSG3V.js → chunk-ONWHS3PA.js} +34 -79
- package/dist/chunk-ONWHS3PA.js.map +1 -0
- package/dist/{chunk-PB5O2NTZ.cjs → chunk-OVVUJ46G.cjs} +39 -85
- package/dist/chunk-OVVUJ46G.cjs.map +1 -0
- package/dist/{chunk-BFA354MH.js → chunk-WFIG7I5C.js} +5 -16
- package/dist/chunk-WFIG7I5C.js.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 +262 -14
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +260 -12
- package/dist/server/index.js.map +1 -1
- package/package.json +6 -6
- 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-BFA354MH.js.map +0 -1
- package/dist/chunk-C6UFSG3V.js.map +0 -1
- package/dist/chunk-HNSVE6YO.js.map +0 -1
- package/dist/chunk-IVKDKRCR.cjs.map +0 -1
- package/dist/chunk-PB5O2NTZ.cjs.map +0 -1
- package/dist/chunk-UJXH5MNH.cjs.map +0 -1
- package/dist/chunk-V5W7WIXT.cjs.map +0 -1
- package/dist/chunk-ZXT4NSIV.js.map +0 -1
package/dist/server/index.cjs
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
var chunkVA2CSOKJ_cjs = require('../chunk-VA2CSOKJ.cjs');
|
|
4
4
|
var promises = require('fs/promises');
|
|
5
5
|
var https = require('https');
|
|
6
|
-
var
|
|
6
|
+
var path = require('path');
|
|
7
7
|
var http = require('http');
|
|
8
8
|
var http2 = require('http2');
|
|
9
9
|
var stream$1 = require('stream');
|
|
10
10
|
var crypto = require('crypto');
|
|
11
11
|
var mime = require('hono/utils/mime');
|
|
12
12
|
var fs = require('fs');
|
|
13
|
-
var path = require('path');
|
|
14
13
|
var html = require('hono/html');
|
|
15
14
|
var tools = require('@mastra/core/tools');
|
|
15
|
+
var error = require('@mastra/server/handlers/error');
|
|
16
16
|
var serverAdapter = require('@mastra/server/server-adapter');
|
|
17
17
|
var util = require('util');
|
|
18
18
|
var buffer = require('buffer');
|
|
@@ -2868,6 +2868,209 @@ var stream = (c, cb, onError3) => {
|
|
|
2868
2868
|
})();
|
|
2869
2869
|
return c.newResponse(stream2.responseReadable);
|
|
2870
2870
|
};
|
|
2871
|
+
var util2;
|
|
2872
|
+
(function(util22) {
|
|
2873
|
+
util22.assertEqual = (_) => {
|
|
2874
|
+
};
|
|
2875
|
+
function assertIs(_arg) {
|
|
2876
|
+
}
|
|
2877
|
+
util22.assertIs = assertIs;
|
|
2878
|
+
function assertNever(_x) {
|
|
2879
|
+
throw new Error();
|
|
2880
|
+
}
|
|
2881
|
+
util22.assertNever = assertNever;
|
|
2882
|
+
util22.arrayToEnum = (items) => {
|
|
2883
|
+
const obj = {};
|
|
2884
|
+
for (const item of items) {
|
|
2885
|
+
obj[item] = item;
|
|
2886
|
+
}
|
|
2887
|
+
return obj;
|
|
2888
|
+
};
|
|
2889
|
+
util22.getValidEnumValues = (obj) => {
|
|
2890
|
+
const validKeys = util22.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
2891
|
+
const filtered = {};
|
|
2892
|
+
for (const k of validKeys) {
|
|
2893
|
+
filtered[k] = obj[k];
|
|
2894
|
+
}
|
|
2895
|
+
return util22.objectValues(filtered);
|
|
2896
|
+
};
|
|
2897
|
+
util22.objectValues = (obj) => {
|
|
2898
|
+
return util22.objectKeys(obj).map(function(e) {
|
|
2899
|
+
return obj[e];
|
|
2900
|
+
});
|
|
2901
|
+
};
|
|
2902
|
+
util22.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
2903
|
+
const keys = [];
|
|
2904
|
+
for (const key in object) {
|
|
2905
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
2906
|
+
keys.push(key);
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
return keys;
|
|
2910
|
+
};
|
|
2911
|
+
util22.find = (arr, checker) => {
|
|
2912
|
+
for (const item of arr) {
|
|
2913
|
+
if (checker(item))
|
|
2914
|
+
return item;
|
|
2915
|
+
}
|
|
2916
|
+
return void 0;
|
|
2917
|
+
};
|
|
2918
|
+
util22.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
2919
|
+
function joinValues(array, separator = " | ") {
|
|
2920
|
+
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
2921
|
+
}
|
|
2922
|
+
util22.joinValues = joinValues;
|
|
2923
|
+
util22.jsonStringifyReplacer = (_, value) => {
|
|
2924
|
+
if (typeof value === "bigint") {
|
|
2925
|
+
return value.toString();
|
|
2926
|
+
}
|
|
2927
|
+
return value;
|
|
2928
|
+
};
|
|
2929
|
+
})(util2 || (util2 = {}));
|
|
2930
|
+
var objectUtil;
|
|
2931
|
+
(function(objectUtil2) {
|
|
2932
|
+
objectUtil2.mergeShapes = (first, second) => {
|
|
2933
|
+
return {
|
|
2934
|
+
...first,
|
|
2935
|
+
...second
|
|
2936
|
+
// second overwrites first
|
|
2937
|
+
};
|
|
2938
|
+
};
|
|
2939
|
+
})(objectUtil || (objectUtil = {}));
|
|
2940
|
+
util2.arrayToEnum([
|
|
2941
|
+
"string",
|
|
2942
|
+
"nan",
|
|
2943
|
+
"number",
|
|
2944
|
+
"integer",
|
|
2945
|
+
"float",
|
|
2946
|
+
"boolean",
|
|
2947
|
+
"date",
|
|
2948
|
+
"bigint",
|
|
2949
|
+
"symbol",
|
|
2950
|
+
"function",
|
|
2951
|
+
"undefined",
|
|
2952
|
+
"null",
|
|
2953
|
+
"array",
|
|
2954
|
+
"object",
|
|
2955
|
+
"unknown",
|
|
2956
|
+
"promise",
|
|
2957
|
+
"void",
|
|
2958
|
+
"never",
|
|
2959
|
+
"map",
|
|
2960
|
+
"set"
|
|
2961
|
+
]);
|
|
2962
|
+
util2.arrayToEnum([
|
|
2963
|
+
"invalid_type",
|
|
2964
|
+
"invalid_literal",
|
|
2965
|
+
"custom",
|
|
2966
|
+
"invalid_union",
|
|
2967
|
+
"invalid_union_discriminator",
|
|
2968
|
+
"invalid_enum_value",
|
|
2969
|
+
"unrecognized_keys",
|
|
2970
|
+
"invalid_arguments",
|
|
2971
|
+
"invalid_return_type",
|
|
2972
|
+
"invalid_date",
|
|
2973
|
+
"invalid_string",
|
|
2974
|
+
"too_small",
|
|
2975
|
+
"too_big",
|
|
2976
|
+
"invalid_intersection_types",
|
|
2977
|
+
"not_multiple_of",
|
|
2978
|
+
"not_finite"
|
|
2979
|
+
]);
|
|
2980
|
+
var ZodError = class _ZodError extends Error {
|
|
2981
|
+
get errors() {
|
|
2982
|
+
return this.issues;
|
|
2983
|
+
}
|
|
2984
|
+
constructor(issues) {
|
|
2985
|
+
super();
|
|
2986
|
+
this.issues = [];
|
|
2987
|
+
this.addIssue = (sub) => {
|
|
2988
|
+
this.issues = [...this.issues, sub];
|
|
2989
|
+
};
|
|
2990
|
+
this.addIssues = (subs = []) => {
|
|
2991
|
+
this.issues = [...this.issues, ...subs];
|
|
2992
|
+
};
|
|
2993
|
+
const actualProto = new.target.prototype;
|
|
2994
|
+
if (Object.setPrototypeOf) {
|
|
2995
|
+
Object.setPrototypeOf(this, actualProto);
|
|
2996
|
+
} else {
|
|
2997
|
+
this.__proto__ = actualProto;
|
|
2998
|
+
}
|
|
2999
|
+
this.name = "ZodError";
|
|
3000
|
+
this.issues = issues;
|
|
3001
|
+
}
|
|
3002
|
+
format(_mapper) {
|
|
3003
|
+
const mapper = _mapper || function(issue) {
|
|
3004
|
+
return issue.message;
|
|
3005
|
+
};
|
|
3006
|
+
const fieldErrors = { _errors: [] };
|
|
3007
|
+
const processError = (error) => {
|
|
3008
|
+
for (const issue of error.issues) {
|
|
3009
|
+
if (issue.code === "invalid_union") {
|
|
3010
|
+
issue.unionErrors.map(processError);
|
|
3011
|
+
} else if (issue.code === "invalid_return_type") {
|
|
3012
|
+
processError(issue.returnTypeError);
|
|
3013
|
+
} else if (issue.code === "invalid_arguments") {
|
|
3014
|
+
processError(issue.argumentsError);
|
|
3015
|
+
} else if (issue.path.length === 0) {
|
|
3016
|
+
fieldErrors._errors.push(mapper(issue));
|
|
3017
|
+
} else {
|
|
3018
|
+
let curr = fieldErrors;
|
|
3019
|
+
let i = 0;
|
|
3020
|
+
while (i < issue.path.length) {
|
|
3021
|
+
const el = issue.path[i];
|
|
3022
|
+
const terminal = i === issue.path.length - 1;
|
|
3023
|
+
if (!terminal) {
|
|
3024
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
3025
|
+
} else {
|
|
3026
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
3027
|
+
curr[el]._errors.push(mapper(issue));
|
|
3028
|
+
}
|
|
3029
|
+
curr = curr[el];
|
|
3030
|
+
i++;
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
};
|
|
3035
|
+
processError(this);
|
|
3036
|
+
return fieldErrors;
|
|
3037
|
+
}
|
|
3038
|
+
static assert(value) {
|
|
3039
|
+
if (!(value instanceof _ZodError)) {
|
|
3040
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
toString() {
|
|
3044
|
+
return this.message;
|
|
3045
|
+
}
|
|
3046
|
+
get message() {
|
|
3047
|
+
return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
|
|
3048
|
+
}
|
|
3049
|
+
get isEmpty() {
|
|
3050
|
+
return this.issues.length === 0;
|
|
3051
|
+
}
|
|
3052
|
+
flatten(mapper = (issue) => issue.message) {
|
|
3053
|
+
const fieldErrors = {};
|
|
3054
|
+
const formErrors = [];
|
|
3055
|
+
for (const sub of this.issues) {
|
|
3056
|
+
if (sub.path.length > 0) {
|
|
3057
|
+
const firstEl = sub.path[0];
|
|
3058
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
3059
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
3060
|
+
} else {
|
|
3061
|
+
formErrors.push(mapper(sub));
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
return { formErrors, fieldErrors };
|
|
3065
|
+
}
|
|
3066
|
+
get formErrors() {
|
|
3067
|
+
return this.flatten();
|
|
3068
|
+
}
|
|
3069
|
+
};
|
|
3070
|
+
ZodError.create = (issues) => {
|
|
3071
|
+
const error = new ZodError(issues);
|
|
3072
|
+
return error;
|
|
3073
|
+
};
|
|
2871
3074
|
var authenticationMiddleware = async (c, next) => {
|
|
2872
3075
|
const mastra = c.get("mastra");
|
|
2873
3076
|
const authConfig = mastra.getServer()?.auth;
|
|
@@ -3061,13 +3264,48 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3061
3264
|
const queryParams = request.query();
|
|
3062
3265
|
let body;
|
|
3063
3266
|
if (route.method === "POST" || route.method === "PUT" || route.method === "PATCH") {
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3267
|
+
const contentType = request.header("content-type") || "";
|
|
3268
|
+
if (contentType.includes("multipart/form-data")) {
|
|
3269
|
+
try {
|
|
3270
|
+
const formData = await request.formData();
|
|
3271
|
+
body = await this.parseFormData(formData);
|
|
3272
|
+
} catch (error) {
|
|
3273
|
+
console.error("Failed to parse multipart form data:", error);
|
|
3274
|
+
if (error instanceof Error && error.message.toLowerCase().includes("size")) {
|
|
3275
|
+
throw error;
|
|
3276
|
+
}
|
|
3277
|
+
}
|
|
3278
|
+
} else {
|
|
3279
|
+
try {
|
|
3280
|
+
body = await request.json();
|
|
3281
|
+
} catch (error) {
|
|
3282
|
+
console.error("Failed to parse JSON body:", error);
|
|
3283
|
+
}
|
|
3067
3284
|
}
|
|
3068
3285
|
}
|
|
3069
3286
|
return { urlParams, queryParams, body };
|
|
3070
3287
|
}
|
|
3288
|
+
/**
|
|
3289
|
+
* Parse FormData into a plain object, converting File objects to Buffers.
|
|
3290
|
+
*/
|
|
3291
|
+
async parseFormData(formData) {
|
|
3292
|
+
const result = {};
|
|
3293
|
+
for (const [key, value] of formData.entries()) {
|
|
3294
|
+
if (value instanceof File) {
|
|
3295
|
+
const arrayBuffer = await value.arrayBuffer();
|
|
3296
|
+
result[key] = Buffer.from(arrayBuffer);
|
|
3297
|
+
} else if (typeof value === "string") {
|
|
3298
|
+
try {
|
|
3299
|
+
result[key] = JSON.parse(value);
|
|
3300
|
+
} catch {
|
|
3301
|
+
result[key] = value;
|
|
3302
|
+
}
|
|
3303
|
+
} else {
|
|
3304
|
+
result[key] = value;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
return result;
|
|
3308
|
+
}
|
|
3071
3309
|
async sendResponse(route, response, result) {
|
|
3072
3310
|
if (route.responseType === "json") {
|
|
3073
3311
|
return response.json(result, 200);
|
|
@@ -3137,12 +3375,15 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3137
3375
|
if (params.queryParams) {
|
|
3138
3376
|
try {
|
|
3139
3377
|
params.queryParams = await this.parseQueryParams(route, params.queryParams);
|
|
3140
|
-
} catch (error) {
|
|
3141
|
-
console.error("Error parsing query params", error);
|
|
3378
|
+
} catch (error$1) {
|
|
3379
|
+
console.error("Error parsing query params", error$1);
|
|
3380
|
+
if (error$1 instanceof ZodError) {
|
|
3381
|
+
return c.json(error.formatZodError(error$1, "query parameters"), 400);
|
|
3382
|
+
}
|
|
3142
3383
|
return c.json(
|
|
3143
3384
|
{
|
|
3144
3385
|
error: "Invalid query parameters",
|
|
3145
|
-
|
|
3386
|
+
issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
|
|
3146
3387
|
},
|
|
3147
3388
|
400
|
|
3148
3389
|
);
|
|
@@ -3151,12 +3392,15 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
3151
3392
|
if (params.body) {
|
|
3152
3393
|
try {
|
|
3153
3394
|
params.body = await this.parseBody(route, params.body);
|
|
3154
|
-
} catch (error) {
|
|
3155
|
-
console.error("Error parsing body:", error instanceof Error ? error.message : String(error));
|
|
3395
|
+
} catch (error$1) {
|
|
3396
|
+
console.error("Error parsing body:", error$1 instanceof Error ? error$1.message : String(error$1));
|
|
3397
|
+
if (error$1 instanceof ZodError) {
|
|
3398
|
+
return c.json(error.formatZodError(error$1, "request body"), 400);
|
|
3399
|
+
}
|
|
3156
3400
|
return c.json(
|
|
3157
3401
|
{
|
|
3158
3402
|
error: "Invalid request body",
|
|
3159
|
-
|
|
3403
|
+
issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
|
|
3160
3404
|
},
|
|
3161
3405
|
400
|
|
3162
3406
|
);
|
|
@@ -3395,6 +3639,7 @@ var html2 = `
|
|
|
3395
3639
|
`;
|
|
3396
3640
|
|
|
3397
3641
|
// src/server/index.ts
|
|
3642
|
+
var getStudioPath = () => process.env.MASTRA_STUDIO_PATH || "./playground";
|
|
3398
3643
|
function getToolExports(tools$1) {
|
|
3399
3644
|
try {
|
|
3400
3645
|
return tools$1.reduce((acc, toolModule) => {
|
|
@@ -3571,10 +3816,11 @@ async function createHonoServer(mastra, options = {
|
|
|
3571
3816
|
});
|
|
3572
3817
|
}
|
|
3573
3818
|
);
|
|
3819
|
+
const studioPath = getStudioPath();
|
|
3574
3820
|
app.use(
|
|
3575
3821
|
`${studioBasePath}/assets/*`,
|
|
3576
3822
|
serveStatic({
|
|
3577
|
-
root: "
|
|
3823
|
+
root: path.join(studioPath, "assets"),
|
|
3578
3824
|
rewriteRequestPath: (path) => {
|
|
3579
3825
|
let rewritten = path;
|
|
3580
3826
|
if (studioBasePath && rewritten.startsWith(studioBasePath)) {
|
|
@@ -3598,7 +3844,8 @@ async function createHonoServer(mastra, options = {
|
|
|
3598
3844
|
}
|
|
3599
3845
|
const isPlaygroundRoute = studioBasePath === "" || requestPath === studioBasePath || requestPath.startsWith(`${studioBasePath}/`);
|
|
3600
3846
|
if (options?.playground && isPlaygroundRoute) {
|
|
3601
|
-
|
|
3847
|
+
const studioPath = getStudioPath();
|
|
3848
|
+
let indexHtml = await promises.readFile(path.join(studioPath, "index.html"), "utf-8");
|
|
3602
3849
|
const port = serverOptions?.port ?? (Number(process.env.PORT) || 4111);
|
|
3603
3850
|
const hideCloudCta = process.env.MASTRA_HIDE_CLOUD_CTA === "true";
|
|
3604
3851
|
const host = serverOptions?.host ?? "localhost";
|
|
@@ -3615,11 +3862,12 @@ async function createHonoServer(mastra, options = {
|
|
|
3615
3862
|
return c.newResponse(html2, 200, { "Content-Type": "text/html" });
|
|
3616
3863
|
});
|
|
3617
3864
|
if (options?.playground) {
|
|
3865
|
+
const studioPath = getStudioPath();
|
|
3618
3866
|
const playgroundPath = studioBasePath ? `${studioBasePath}/*` : "*";
|
|
3619
3867
|
app.use(
|
|
3620
3868
|
playgroundPath,
|
|
3621
3869
|
serveStatic({
|
|
3622
|
-
root:
|
|
3870
|
+
root: studioPath,
|
|
3623
3871
|
rewriteRequestPath: (path) => {
|
|
3624
3872
|
if (studioBasePath && path.startsWith(studioBasePath)) {
|
|
3625
3873
|
return path.slice(studioBasePath.length);
|