@mastra/deployer 0.24.0 → 1.0.0-beta.1
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 +240 -95
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.js +1 -1
- package/dist/build/index.cjs +10 -15
- package/dist/build/index.d.ts +0 -1
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +3 -4
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.ts +2 -2
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-OART5HV7.cjs → chunk-AQAOWLJJ.cjs} +29 -124
- package/dist/chunk-AQAOWLJJ.cjs.map +1 -0
- package/dist/{chunk-IAEJ3C3J.cjs → chunk-C74EXQSL.cjs} +12 -12
- package/dist/chunk-C74EXQSL.cjs.map +1 -0
- package/dist/{chunk-CVRN2K4O.js → chunk-H3LLQ2MW.js} +12 -12
- package/dist/chunk-H3LLQ2MW.js.map +1 -0
- package/dist/{chunk-FD5X42ZU.js → chunk-HQJR52M7.js} +4 -4
- package/dist/{chunk-FD5X42ZU.js.map → chunk-HQJR52M7.js.map} +1 -1
- package/dist/{chunk-NSINCI76.cjs → chunk-IL2VLNIJ.cjs} +9 -9
- package/dist/{chunk-NSINCI76.cjs.map → chunk-IL2VLNIJ.cjs.map} +1 -1
- package/dist/{chunk-XHLN6E4D.js → chunk-OFUWEVGF.js} +3 -3
- package/dist/{chunk-XHLN6E4D.js.map → chunk-OFUWEVGF.js.map} +1 -1
- package/dist/{chunk-Z546LAA6.cjs → chunk-TDWIGFVF.cjs} +14 -14
- package/dist/{chunk-Z546LAA6.cjs.map → chunk-TDWIGFVF.cjs.map} +1 -1
- package/dist/{chunk-VDRZB7JQ.js → chunk-WBAWUM7Z.js} +23 -116
- package/dist/chunk-WBAWUM7Z.js.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +2 -2
- package/dist/server/handlers/health.d.ts +5 -0
- package/dist/server/handlers/health.d.ts.map +1 -0
- package/dist/server/handlers/prompt.d.ts.map +1 -1
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts +5 -2
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/agent-builder/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts +21 -143
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/agents/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/logs/handlers.d.ts +3 -3
- package/dist/server/handlers/routes/logs/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts +1 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/memory/handlers.d.ts +2 -4
- package/dist/server/handlers/routes/memory/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/memory/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/observability/handlers.d.ts +3 -3
- package/dist/server/handlers/routes/observability/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/observability/router.d.ts.map +1 -1
- package/dist/server/handlers/routes/scores/handlers.d.ts +8 -6
- package/dist/server/handlers/routes/scores/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts +1 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/workflows/handlers.d.ts +2 -4
- package/dist/server/handlers/routes/workflows/handlers.d.ts.map +1 -1
- package/dist/server/handlers/routes/workflows/router.d.ts.map +1 -1
- package/dist/server/handlers/utils/query-parsers.d.ts +15 -0
- package/dist/server/handlers/utils/query-parsers.d.ts.map +1 -1
- package/dist/server/index.cjs +1207 -1559
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1214 -1566
- 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/package.json +12 -16
- package/dist/build/babel/remove-all-options-telemetry.d.ts +0 -5
- package/dist/build/babel/remove-all-options-telemetry.d.ts.map +0 -1
- package/dist/build/customInstrumentation.d.ts +0 -10
- package/dist/build/customInstrumentation.d.ts.map +0 -1
- package/dist/build/telemetry.d.ts +0 -8
- package/dist/build/telemetry.d.ts.map +0 -1
- package/dist/chunk-AJX72IGP.cjs +0 -28
- package/dist/chunk-AJX72IGP.cjs.map +0 -1
- package/dist/chunk-B2Q76NIL.js +0 -26
- package/dist/chunk-B2Q76NIL.js.map +0 -1
- package/dist/chunk-CVRN2K4O.js.map +0 -1
- package/dist/chunk-IAEJ3C3J.cjs.map +0 -1
- package/dist/chunk-OART5HV7.cjs.map +0 -1
- package/dist/chunk-VDRZB7JQ.js.map +0 -1
- package/dist/server/handlers/routes/telemetry/handlers.d.ts +0 -4
- package/dist/server/handlers/routes/telemetry/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/telemetry/router.d.ts +0 -3
- package/dist/server/handlers/routes/telemetry/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts +0 -11
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts.map +0 -1
- package/dist/templates/instrumentation-template.js +0 -172
package/dist/bundler/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare abstract class Bundler extends MastraBundler {
|
|
|
6
6
|
protected outputDir: string;
|
|
7
7
|
constructor(name: string, component?: 'BUNDLER' | 'DEPLOYER');
|
|
8
8
|
prepare(outputDirectory: string): Promise<void>;
|
|
9
|
-
writeInstrumentationFile(outputDirectory: string, customInstrumentationFile?: string): Promise<void>;
|
|
10
9
|
writePackageJson(outputDirectory: string, dependencies: Map<string, string>, resolutions?: Record<string, string>): Promise<void>;
|
|
11
10
|
protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & {
|
|
12
11
|
dir: string;
|
|
@@ -31,7 +30,8 @@ export declare abstract class Bundler extends MastraBundler {
|
|
|
31
30
|
enableSourcemap?: boolean;
|
|
32
31
|
enableEsmShim?: boolean;
|
|
33
32
|
}): Promise<InputOptions>;
|
|
34
|
-
|
|
33
|
+
getAllToolPaths(mastraDir: string, toolsPaths?: (string | string[])[]): (string | string[])[];
|
|
34
|
+
listToolsInputOptions(toolsPaths: (string | string[])[]): Promise<Record<string, string>>;
|
|
35
35
|
protected _bundle(serverFile: string, mastraEntryFile: string, { projectRoot, outputDirectory, enableEsmShim, }: {
|
|
36
36
|
projectRoot: string;
|
|
37
37
|
outputDirectory: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAKrD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAQjD,8BAAsB,OAAQ,SAAQ,aAAa;IACjD,SAAS,CAAC,gBAAgB,SAAY;IACtC,SAAS,CAAC,SAAS,SAAY;gBAEnB,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,SAAS,GAAG,UAAsB;IAIjE,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/C,gBAAgB,CACpB,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IA8CtC,SAAS,CAAC,aAAa,CAAC,YAAY,EAAE,YA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AAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,EAC5E,UAAU,GAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAO,EACtC,cAAc,GAAE,MAA8C,GAC7D,OAAO,CAAC,IAAI,CAAC;IA+IV,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAO3G"}
|
package/dist/bundler/index.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var chunkIAEJ3C3J_cjs = require('./chunk-IAEJ3C3J.cjs');
|
|
3
|
+
var chunkIL2VLNIJ_cjs = require('./chunk-IL2VLNIJ.cjs');
|
|
4
|
+
var chunkC74EXQSL_cjs = require('./chunk-C74EXQSL.cjs');
|
|
6
5
|
var chunk3JYRSECU_cjs = require('./chunk-3JYRSECU.cjs');
|
|
7
6
|
var fs = require('fs');
|
|
8
7
|
var promises = require('fs/promises');
|
|
9
8
|
var path = require('path');
|
|
10
|
-
var url = require('url');
|
|
11
9
|
var bundler = require('@mastra/core/bundler');
|
|
12
10
|
var error = require('@mastra/core/error');
|
|
13
11
|
var virtual = require('@rollup/plugin-virtual');
|
|
14
12
|
var pkg = require('empathic/package');
|
|
15
13
|
var fsExtra = require('fs-extra/esm');
|
|
16
14
|
var tinyglobby = require('tinyglobby');
|
|
17
|
-
var rollup = require('rollup');
|
|
18
|
-
var commonjs = require('@rollup/plugin-commonjs');
|
|
19
15
|
|
|
20
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
21
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
17
|
|
|
23
18
|
function _interopNamespace(e) {
|
|
@@ -41,43 +36,7 @@ function _interopNamespace(e) {
|
|
|
41
36
|
var virtual__default = /*#__PURE__*/_interopDefault(virtual);
|
|
42
37
|
var pkg__namespace = /*#__PURE__*/_interopNamespace(pkg);
|
|
43
38
|
var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
|
|
44
|
-
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
45
39
|
|
|
46
|
-
function getCustomInstrumentationBundler(entryFile, result) {
|
|
47
|
-
return rollup.rollup({
|
|
48
|
-
logLevel: "silent",
|
|
49
|
-
input: {
|
|
50
|
-
instrumentation: entryFile
|
|
51
|
-
},
|
|
52
|
-
treeshake: false,
|
|
53
|
-
plugins: [
|
|
54
|
-
// transpile typescript to something we understand
|
|
55
|
-
chunkIAEJ3C3J_cjs.esbuild(),
|
|
56
|
-
commonjs__default.default({
|
|
57
|
-
extensions: [".js", ".ts"],
|
|
58
|
-
strictRequires: "strict",
|
|
59
|
-
transformMixedEsModules: true,
|
|
60
|
-
ignoreTryCatch: false
|
|
61
|
-
})
|
|
62
|
-
]
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async function writeCustomInstrumentation(entryFile, outputDir, options = {}) {
|
|
66
|
-
const result = {
|
|
67
|
-
hasCustomConfig: false
|
|
68
|
-
};
|
|
69
|
-
const bundle = await getCustomInstrumentationBundler(entryFile);
|
|
70
|
-
const { output } = await bundle.write({
|
|
71
|
-
dir: outputDir,
|
|
72
|
-
format: "es",
|
|
73
|
-
entryFileNames: "[name].mjs",
|
|
74
|
-
sourcemap: options.sourcemap
|
|
75
|
-
});
|
|
76
|
-
const externals = output[0].imports.filter((x) => !x.startsWith("./"));
|
|
77
|
-
return { ...result, externalDependencies: externals };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/bundler/index.ts
|
|
81
40
|
var Bundler = class extends bundler.MastraBundler {
|
|
82
41
|
analyzeOutputDir = ".build";
|
|
83
42
|
outputDir = "output";
|
|
@@ -89,15 +48,6 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
89
48
|
await fsExtra.ensureDir(path.join(outputDirectory, this.analyzeOutputDir));
|
|
90
49
|
await fsExtra.ensureDir(path.join(outputDirectory, this.outputDir));
|
|
91
50
|
}
|
|
92
|
-
async writeInstrumentationFile(outputDirectory, customInstrumentationFile) {
|
|
93
|
-
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
94
|
-
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-OART5HV7.cjs', document.baseURI).href))));
|
|
95
|
-
if (customInstrumentationFile) {
|
|
96
|
-
await fsExtra.copy(customInstrumentationFile, instrumentationFile);
|
|
97
|
-
} else {
|
|
98
|
-
await fsExtra.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
51
|
async writePackageJson(outputDirectory, dependencies, resolutions) {
|
|
102
52
|
this.logger.debug(`Writing project's package.json`);
|
|
103
53
|
await fsExtra.ensureDir(outputDirectory);
|
|
@@ -112,16 +62,6 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
112
62
|
dependenciesMap.set(pkgName, value);
|
|
113
63
|
}
|
|
114
64
|
}
|
|
115
|
-
dependenciesMap.set("@opentelemetry/core", "^2.0.1");
|
|
116
|
-
dependenciesMap.set("@opentelemetry/api", "^1.9.0");
|
|
117
|
-
dependenciesMap.set("@opentelemetry/auto-instrumentations-node", "^0.59.0");
|
|
118
|
-
dependenciesMap.set("@opentelemetry/exporter-trace-otlp-grpc", "^0.201.0");
|
|
119
|
-
dependenciesMap.set("@opentelemetry/exporter-trace-otlp-http", "^0.201.0");
|
|
120
|
-
dependenciesMap.set("@opentelemetry/resources", "^2.0.1");
|
|
121
|
-
dependenciesMap.set("@opentelemetry/sdk-node", "^0.201.0");
|
|
122
|
-
dependenciesMap.set("@opentelemetry/sdk-trace-base", "^2.0.1");
|
|
123
|
-
dependenciesMap.set("@opentelemetry/semantic-conventions", "^1.33.0");
|
|
124
|
-
dependenciesMap.set("@opentelemetry/instrumentation", "^0.202.0");
|
|
125
65
|
await promises.writeFile(
|
|
126
66
|
pkgPath,
|
|
127
67
|
JSON.stringify(
|
|
@@ -132,7 +72,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
132
72
|
type: "module",
|
|
133
73
|
main: "index.mjs",
|
|
134
74
|
scripts: {
|
|
135
|
-
start: "node
|
|
75
|
+
start: "node ./index.mjs"
|
|
136
76
|
},
|
|
137
77
|
author: "Mastra",
|
|
138
78
|
license: "ISC",
|
|
@@ -148,10 +88,10 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
148
88
|
);
|
|
149
89
|
}
|
|
150
90
|
createBundler(inputOptions, outputOptions) {
|
|
151
|
-
return
|
|
91
|
+
return chunkIL2VLNIJ_cjs.createBundler(inputOptions, outputOptions);
|
|
152
92
|
}
|
|
153
93
|
async analyze(entry, mastraFile, outputDirectory, { enableEsmShim = true } = {}) {
|
|
154
|
-
return await
|
|
94
|
+
return await chunkC74EXQSL_cjs.analyzeBundle(
|
|
155
95
|
[].concat(entry),
|
|
156
96
|
mastraFile,
|
|
157
97
|
{
|
|
@@ -193,10 +133,10 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
193
133
|
}
|
|
194
134
|
}
|
|
195
135
|
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, { enableSourcemap = false, enableEsmShim = true } = {}) {
|
|
196
|
-
const { workspaceRoot } = await
|
|
136
|
+
const { workspaceRoot } = await chunkC74EXQSL_cjs.getWorkspaceInformation({ mastraEntryFile });
|
|
197
137
|
const closestPkgJson = pkg__namespace.up({ cwd: path.dirname(mastraEntryFile) });
|
|
198
138
|
const projectRoot = closestPkgJson ? path.dirname(closestPkgJson) : process.cwd();
|
|
199
|
-
const inputOptions = await
|
|
139
|
+
const inputOptions = await chunkIL2VLNIJ_cjs.getInputOptions(
|
|
200
140
|
mastraEntryFile,
|
|
201
141
|
analyzedBundleInfo,
|
|
202
142
|
"node",
|
|
@@ -206,7 +146,7 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
206
146
|
{ sourcemap: enableSourcemap, workspaceRoot, projectRoot, enableEsmShim }
|
|
207
147
|
);
|
|
208
148
|
const isVirtual = serverFile.includes("\n") || fs.existsSync(serverFile);
|
|
209
|
-
const toolsInputOptions = await this.
|
|
149
|
+
const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);
|
|
210
150
|
if (isVirtual) {
|
|
211
151
|
inputOptions.input = { index: "#entry", ...toolsInputOptions };
|
|
212
152
|
if (Array.isArray(inputOptions.plugins)) {
|
|
@@ -219,7 +159,20 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
219
159
|
}
|
|
220
160
|
return inputOptions;
|
|
221
161
|
}
|
|
222
|
-
|
|
162
|
+
getAllToolPaths(mastraDir, toolsPaths = []) {
|
|
163
|
+
const normalizedMastraDir = chunkC74EXQSL_cjs.slash(mastraDir);
|
|
164
|
+
const defaultToolsPath = path.posix.join(normalizedMastraDir, "tools/**/*.{js,ts}");
|
|
165
|
+
const defaultToolsIgnorePaths = [
|
|
166
|
+
`!${path.posix.join(normalizedMastraDir, "tools/**/*.{test,spec}.{js,ts}")}`,
|
|
167
|
+
`!${path.posix.join(normalizedMastraDir, "tools/**/__tests__/**")}`
|
|
168
|
+
];
|
|
169
|
+
const defaultPaths = [defaultToolsPath, ...defaultToolsIgnorePaths];
|
|
170
|
+
if (toolsPaths.length === 0) {
|
|
171
|
+
return [defaultPaths];
|
|
172
|
+
}
|
|
173
|
+
return [...toolsPaths, defaultPaths];
|
|
174
|
+
}
|
|
175
|
+
async listToolsInputOptions(toolsPaths) {
|
|
223
176
|
const inputs = {};
|
|
224
177
|
for (const toolPath of toolsPaths) {
|
|
225
178
|
const expandedPaths = await tinyglobby.glob(toolPath, {
|
|
@@ -257,15 +210,15 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
257
210
|
const analyzeDir = path.join(outputDirectory, this.analyzeOutputDir);
|
|
258
211
|
let sourcemap = false;
|
|
259
212
|
try {
|
|
260
|
-
const bundlerOptions = await
|
|
213
|
+
const bundlerOptions = await chunkC74EXQSL_cjs.getBundlerOptions(mastraEntryFile, analyzeDir);
|
|
261
214
|
sourcemap = !!bundlerOptions?.sourcemap;
|
|
262
215
|
} catch (error) {
|
|
263
216
|
this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
|
|
264
217
|
}
|
|
265
218
|
let analyzedBundleInfo;
|
|
266
219
|
try {
|
|
267
|
-
const resolvedToolsPaths = await this.
|
|
268
|
-
analyzedBundleInfo = await
|
|
220
|
+
const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);
|
|
221
|
+
analyzedBundleInfo = await chunkC74EXQSL_cjs.analyzeBundle(
|
|
269
222
|
[serverFile, ...Object.values(resolvedToolsPaths)],
|
|
270
223
|
mastraEntryFile,
|
|
271
224
|
{
|
|
@@ -293,61 +246,13 @@ var Bundler = class extends bundler.MastraBundler {
|
|
|
293
246
|
error$1
|
|
294
247
|
);
|
|
295
248
|
}
|
|
296
|
-
let externalDependencies;
|
|
297
|
-
try {
|
|
298
|
-
const result = await chunkAJX72IGP_cjs.writeTelemetryConfig(mastraEntryFile, path.join(outputDirectory, this.outputDir));
|
|
299
|
-
externalDependencies = result?.externalDependencies ?? [];
|
|
300
|
-
} catch (error$1) {
|
|
301
|
-
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
302
|
-
throw new error.MastraError(
|
|
303
|
-
{
|
|
304
|
-
id: "DEPLOYER_BUNDLER_TELEMETRY_FAILED",
|
|
305
|
-
text: `Failed to write telemetry config: ${message}`,
|
|
306
|
-
domain: error.ErrorDomain.DEPLOYER,
|
|
307
|
-
category: error.ErrorCategory.SYSTEM
|
|
308
|
-
},
|
|
309
|
-
error$1
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
const mastraFolder = path.dirname(mastraEntryFile);
|
|
313
|
-
const fileService = new chunk3JYRSECU_cjs.FileService();
|
|
314
|
-
const customInstrumentation = fileService.getFirstExistingFileOrUndefined([
|
|
315
|
-
path.join(mastraFolder, "instrumentation.js"),
|
|
316
|
-
path.join(mastraFolder, "instrumentation.ts"),
|
|
317
|
-
path.join(mastraFolder, "instrumentation.mjs")
|
|
318
|
-
]);
|
|
319
|
-
try {
|
|
320
|
-
if (customInstrumentation) {
|
|
321
|
-
const result = await writeCustomInstrumentation(customInstrumentation, path.join(outputDirectory, this.outputDir), {
|
|
322
|
-
sourcemap
|
|
323
|
-
});
|
|
324
|
-
externalDependencies = [...externalDependencies, ...result.externalDependencies];
|
|
325
|
-
await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir), customInstrumentation);
|
|
326
|
-
} else {
|
|
327
|
-
await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir));
|
|
328
|
-
}
|
|
329
|
-
} catch (error$1) {
|
|
330
|
-
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
331
|
-
throw new error.MastraError(
|
|
332
|
-
{
|
|
333
|
-
id: "DEPLOYER_BUNDLER_INSTRUMENTATION_FILE_FAILED",
|
|
334
|
-
text: `Failed to write instrumentation file: ${message}, ${customInstrumentation ? ` Found custom instrumentation file: ${customInstrumentation}` : ""}`,
|
|
335
|
-
domain: error.ErrorDomain.DEPLOYER,
|
|
336
|
-
category: error.ErrorCategory.SYSTEM
|
|
337
|
-
},
|
|
338
|
-
error$1
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
249
|
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
342
|
-
for (const external of externalDependencies) {
|
|
343
|
-
dependenciesToInstall.set(external, "latest");
|
|
344
|
-
}
|
|
345
250
|
for (const dep of analyzedBundleInfo.externalDependencies) {
|
|
346
251
|
try {
|
|
347
252
|
if (analyzedBundleInfo.workspaceMap.has(dep)) {
|
|
348
253
|
continue;
|
|
349
254
|
}
|
|
350
|
-
const rootPath = await
|
|
255
|
+
const rootPath = await chunkC74EXQSL_cjs.getPackageRootPath(dep);
|
|
351
256
|
const pkg2 = await fsExtra.readJSON(`${rootPath}/package.json`);
|
|
352
257
|
dependenciesToInstall.set(dep, pkg2.version || "latest");
|
|
353
258
|
} catch {
|
|
@@ -424,7 +329,7 @@ export const tools = [${toolsExports.join(", ")}]`
|
|
|
424
329
|
}
|
|
425
330
|
}
|
|
426
331
|
async lint(_entryFile, _outputDirectory, toolsPaths) {
|
|
427
|
-
const toolsInputOptions = await this.
|
|
332
|
+
const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);
|
|
428
333
|
const toolsLength = Object.keys(toolsInputOptions).length;
|
|
429
334
|
if (toolsLength > 0) {
|
|
430
335
|
this.logger.info(`Found ${toolsLength} ${toolsLength === 1 ? "tool" : "tools"}`);
|
|
@@ -433,5 +338,5 @@ export const tools = [${toolsExports.join(", ")}]`
|
|
|
433
338
|
};
|
|
434
339
|
|
|
435
340
|
exports.Bundler = Bundler;
|
|
436
|
-
//# sourceMappingURL=chunk-
|
|
437
|
-
//# sourceMappingURL=chunk-
|
|
341
|
+
//# sourceMappingURL=chunk-AQAOWLJJ.cjs.map
|
|
342
|
+
//# sourceMappingURL=chunk-AQAOWLJJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bundler/index.ts"],"names":["MastraBundler","emptyDir","ensureDir","join","writeFile","createBundler","analyzeBundle","DepsService","stat","copy","getWorkspaceInformation","pkg","dirname","getInputOptions","existsSync","virtual","slash","posix","glob","path","fsExtra","FileService","getBundlerOptions","error","MastraError","ErrorDomain","ErrorCategory","getPackageRootPath","readJSON"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,IAAe,OAAA,GAAf,cAA+BA,qBAAA,CAAc;AAAA,EACxC,gBAAA,GAAmB,QAAA;AAAA,EACnB,SAAA,GAAY,QAAA;AAAA,EAEtB,WAAA,CAA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E,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,0BAA0B,CAAA;AAE3C,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,yBAAyB,CAAA;AAC1C,MAAA,MAAM,IAAA,CAAK,mBAAA,CAAoB,eAAA,EAAiB,WAAW,CAAA;AAE3D,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,8BAA8B,CAAA;AAAA,IACjD,SAASW,OAAA,EAAO;AACd,MAAA,MAAM,UAAUA,OAAA,YAAiB,KAAA,GAAQA,OAAA,CAAM,OAAA,GAAU,OAAOA,OAAK,CAAA;AACrE,MAAA,MAAM,IAAIC,iBAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,sCAAA;AAAA,UACJ,IAAA,EAAM,uCAAuC,OAAO,CAAA,CAAA;AAAA,UACpD,QAAQC,iBAAA,CAAY,QAAA;AAAA,UACpB,UAAUC,mBAAA,CAAc;AAAA,SAC1B;AAAA,QACAH;AAAA,OACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,IAAA,CAAK,UAAA,EAAoB,gBAAA,EAA0B,UAAA,EAAkD;AACzG,IAAA,MAAM,iBAAA,GAAoB,MAAM,IAAA,CAAK,qBAAA,CAAsB,UAAU,CAAA;AACrE,IAAA,MAAM,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,iBAAiB,CAAA,CAAE,MAAA;AACnD,IAAA,IAAI,cAAc,CAAA,EAAG;AACnB,MAAA,IAAA,CAAK,MAAA,CAAO,KAAK,CAAA,MAAA,EAAS,WAAW,IAAI,WAAA,KAAgB,CAAA,GAAI,MAAA,GAAS,OAAO,CAAA,CAAE,CAAA;AAAA,IACjF;AAAA,EACF;AACF","file":"chunk-AQAOWLJJ.cjs","sourcesContent":["import { existsSync } from 'node:fs';\nimport { stat, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix } from 'node:path';\nimport { MastraBundler } from '@mastra/core/bundler';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport virtual from '@rollup/plugin-virtual';\nimport * as pkg from 'empathic/package';\nimport fsExtra, { copy, ensureDir, readJSON, emptyDir } from 'fs-extra/esm';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { glob } from 'tinyglobby';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport { getPackageRootPath, slash } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport { getWorkspaceInformation } from './workspaceDependencies';\n\nexport abstract class Bundler extends MastraBundler {\n protected analyzeOutputDir = '.build';\n protected outputDir = 'output';\n\n constructor(name: string, component: 'BUNDLER' | 'DEPLOYER' = 'BUNDLER') {\n super({ name, component });\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n // Clean up the output directory first\n await emptyDir(outputDirectory);\n\n await ensureDir(join(outputDirectory, this.analyzeOutputDir));\n await ensureDir(join(outputDirectory, this.outputDir));\n }\n\n async writePackageJson(\n outputDirectory: string,\n dependencies: Map<string, string>,\n resolutions?: Record<string, string>,\n ) {\n this.logger.debug(`Writing project's package.json`);\n\n await ensureDir(outputDirectory);\n const pkgPath = join(outputDirectory, 'package.json');\n\n const dependenciesMap = new Map();\n for (const [key, value] of dependencies.entries()) {\n if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, value);\n } else {\n // For non-scoped packages, take only the first part before any slash\n const pkgName = key.split('/')[0] || key;\n dependenciesMap.set(pkgName, value);\n }\n }\n\n await writeFile(\n pkgPath,\n JSON.stringify(\n {\n name: 'server',\n version: '1.0.0',\n description: '',\n type: 'module',\n main: 'index.mjs',\n scripts: {\n start: 'node ./index.mjs',\n },\n author: 'Mastra',\n license: 'ISC',\n dependencies: Object.fromEntries(dependenciesMap.entries()),\n ...(Object.keys(resolutions ?? {}).length > 0 && { resolutions }),\n pnpm: {\n neverBuiltDependencies: [],\n },\n },\n null,\n 2,\n ),\n );\n }\n\n protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & { dir: string }) {\n return createBundlerUtil(inputOptions, outputOptions);\n }\n\n protected async analyze(\n entry: string | string[],\n mastraFile: string,\n outputDirectory: string,\n { enableEsmShim = true }: { enableEsmShim?: boolean } = {},\n ) {\n return await analyzeBundle(\n ([] as string[]).concat(entry),\n mastraFile,\n {\n outputDir: join(outputDirectory, this.analyzeOutputDir),\n projectRoot: outputDirectory,\n platform: 'node',\n bundlerOptions: {\n enableEsmShim,\n },\n },\n this.logger,\n );\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({ dir: join(outputDirectory, this.outputDir) });\n }\n\n protected async copyPublic(mastraDir: string, outputDirectory: string) {\n const publicDir = join(mastraDir, 'public');\n\n try {\n await stat(publicDir);\n } catch {\n return;\n }\n\n await copy(publicDir, join(outputDirectory, this.outputDir));\n }\n\n protected async copyDOTNPMRC({\n rootDir = process.cwd(),\n outputDirectory,\n }: {\n rootDir?: string;\n outputDirectory: string;\n }) {\n const sourceDotNpmRcPath = join(rootDir, '.npmrc');\n const targetDotNpmRcPath = join(outputDirectory, this.outputDir, '.npmrc');\n\n try {\n await stat(sourceDotNpmRcPath);\n await copy(sourceDotNpmRcPath, targetDotNpmRcPath);\n } catch {\n return;\n }\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n { enableSourcemap = false, enableEsmShim = true }: { enableSourcemap?: boolean; enableEsmShim?: boolean } = {},\n ) {\n const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });\n const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });\n const projectRoot = closestPkgJson ? dirname(closestPkgJson) : process.cwd();\n\n const inputOptions: InputOptions = await getInputOptions(\n mastraEntryFile,\n analyzedBundleInfo,\n 'node',\n {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n },\n { sourcemap: enableSourcemap, workspaceRoot, projectRoot, enableEsmShim },\n );\n const isVirtual = serverFile.includes('\\n') || existsSync(serverFile);\n\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n\n if (isVirtual) {\n inputOptions.input = { index: '#entry', ...toolsInputOptions };\n\n if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.unshift(virtual({ '#entry': serverFile }));\n } else {\n inputOptions.plugins = [virtual({ '#entry': serverFile })];\n }\n } else {\n inputOptions.input = { index: serverFile, ...toolsInputOptions };\n }\n\n return inputOptions;\n }\n\n getAllToolPaths(mastraDir: string, toolsPaths: (string | string[])[] = []): (string | string[])[] {\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedMastraDir = slash(mastraDir);\n\n // Prepare default tools paths with glob patterns\n const defaultToolsPath = posix.join(normalizedMastraDir, 'tools/**/*.{js,ts}');\n const defaultToolsIgnorePaths = [\n `!${posix.join(normalizedMastraDir, 'tools/**/*.{test,spec}.{js,ts}')}`,\n `!${posix.join(normalizedMastraDir, 'tools/**/__tests__/**')}`,\n ];\n\n // Combine default path with ignore patterns\n const defaultPaths = [defaultToolsPath, ...defaultToolsIgnorePaths];\n\n // If no tools paths provided, use only the default paths\n if (toolsPaths.length === 0) {\n return [defaultPaths];\n }\n\n // If tools paths are provided, add the default paths to ensure standard tools are always included\n return [...toolsPaths, defaultPaths];\n }\n\n async listToolsInputOptions(toolsPaths: (string | string[])[]) {\n const inputs: Record<string, string> = {};\n\n for (const toolPath of toolsPaths) {\n const expandedPaths = await glob(toolPath, {\n absolute: true,\n expandDirectories: false,\n });\n\n for (const path of expandedPaths) {\n if (await fsExtra.pathExists(path)) {\n const fileService = new FileService();\n const entryFile = fileService.getFirstExistingFile([\n join(path, 'index.ts'),\n join(path, 'index.js'),\n path, // if path itself is a file\n ]);\n\n // if it doesn't exist or is a dir skip it. using a dir as a tool will crash the process\n if (!entryFile || (await stat(entryFile)).isDirectory()) {\n this.logger.warn(`No entry file found in ${path}, skipping...`);\n continue;\n }\n\n const uniqueToolID = crypto.randomUUID();\n // Normalize Windows paths to forward slashes for consistent handling\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;\n } else {\n this.logger.warn(`Tool path ${path} does not exist, skipping...`);\n }\n }\n }\n\n return inputs;\n }\n\n protected async _bundle(\n serverFile: string,\n mastraEntryFile: string,\n {\n projectRoot,\n outputDirectory,\n enableEsmShim = true,\n }: { projectRoot: string; outputDirectory: string; enableEsmShim?: boolean },\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n const analyzeDir = join(outputDirectory, this.analyzeOutputDir);\n let sourcemap = false;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, analyzeDir);\n sourcemap = !!bundlerOptions?.sourcemap;\n } catch (error) {\n this.logger.debug('Failed to get bundler options, sourcemap will be disabled', { error });\n }\n\n let analyzedBundleInfo;\n try {\n const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n {\n outputDir: analyzeDir,\n projectRoot,\n platform: 'node',\n bundlerOptions: {\n enableEsmShim,\n },\n },\n this.logger,\n );\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n\n if (error instanceof MastraError) {\n throw error;\n }\n\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_ANALYZE_FAILED',\n text: `Failed to analyze Mastra application: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n\n const dependenciesToInstall = new Map<string, string>();\n for (const dep of analyzedBundleInfo.externalDependencies) {\n try {\n if (analyzedBundleInfo.workspaceMap.has(dep)) {\n continue;\n }\n\n const rootPath = await getPackageRootPath(dep);\n const pkg = await readJSON(`${rootPath}/package.json`);\n\n dependenciesToInstall.set(dep, pkg.version || 'latest');\n } catch {\n dependenciesToInstall.set(dep, 'latest');\n }\n }\n\n try {\n await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall);\n\n this.logger.info('Bundling Mastra application');\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n { enableSourcemap: sourcemap, enableEsmShim },\n );\n\n const bundler = await this.createBundler(\n {\n ...inputOptions,\n logLevel: inputOptions.logLevel === 'silent' ? 'warn' : inputOptions.logLevel,\n onwarn: warning => {\n if (warning.code === 'CIRCULAR_DEPENDENCY') {\n if (warning.ids?.[0]?.includes('node_modules')) {\n return;\n }\n\n this.logger.warn(`Circular dependency found:\n\\t${warning.message.replace('Circular dependency: ', '')}`);\n }\n },\n },\n {\n dir: bundleLocation,\n manualChunks: {\n mastra: ['#mastra'],\n },\n sourcemap,\n },\n );\n\n await bundler.write();\n const toolImports: string[] = [];\n const toolsExports: string[] = [];\n Array.from(Object.keys(inputOptions.input || {}))\n .filter(key => key.startsWith('tools/'))\n .forEach((key, index) => {\n const toolExport = `tool${index}`;\n toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);\n toolsExports.push(toolExport);\n });\n\n await writeFile(\n join(bundleLocation, 'tools.mjs'),\n `${toolImports.join('\\n')}\n\nexport const tools = [${toolsExports.join(', ')}]`,\n );\n this.logger.info('Bundling Mastra done');\n\n this.logger.info('Copying public files');\n await this.copyPublic(dirname(mastraEntryFile), outputDirectory);\n this.logger.info('Done copying public files');\n\n this.logger.info('Copying .npmrc file');\n await this.copyDOTNPMRC({ outputDirectory, rootDir: projectRoot });\n\n this.logger.info('Done copying .npmrc file');\n\n this.logger.info('Installing dependencies');\n await this.installDependencies(outputDirectory, projectRoot);\n\n this.logger.info('Done installing dependencies');\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new MastraError(\n {\n id: 'DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED',\n text: `Failed during bundler bundle stage: ${message}`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n },\n error,\n );\n }\n }\n\n async lint(_entryFile: string, _outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);\n const toolsLength = Object.keys(toolsInputOptions).length;\n if (toolsLength > 0) {\n this.logger.info(`Found ${toolsLength} ${toolsLength === 1 ? 'tool' : 'tools'}`);\n }\n }\n}\n"]}
|
|
@@ -194,29 +194,29 @@ function removeAllOptionsFromMastraExcept(result, option, logger) {
|
|
|
194
194
|
if (t.isObjectExpression(path3.node.arguments[0])) {
|
|
195
195
|
mastraArgs = path3.node.arguments[0];
|
|
196
196
|
}
|
|
197
|
-
let
|
|
197
|
+
let configProperty = mastraArgs.properties.find(
|
|
198
198
|
// @ts-ignore
|
|
199
199
|
(prop) => prop.key.name === option
|
|
200
200
|
);
|
|
201
|
-
let
|
|
201
|
+
let configValue = t.objectExpression([]);
|
|
202
202
|
const programPath = path3.scope.getProgramParent().path;
|
|
203
203
|
if (!programPath) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
|
-
if (
|
|
206
|
+
if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
|
|
207
207
|
result.hasCustomConfig = true;
|
|
208
|
-
|
|
209
|
-
if (t.isIdentifier(
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
208
|
+
configValue = configProperty.value;
|
|
209
|
+
if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
|
|
210
|
+
const configBinding = state.file.scope.getBinding(option);
|
|
211
|
+
if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
|
|
212
212
|
const id = path3.scope.generateUidIdentifier(option);
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
|
|
214
|
+
configValue = id;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
const exportDeclaration = t.exportNamedDeclaration(
|
|
219
|
-
t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option),
|
|
219
|
+
t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
|
|
220
220
|
[]
|
|
221
221
|
);
|
|
222
222
|
programPath.node.body.push(exportDeclaration);
|
|
@@ -1350,5 +1350,5 @@ exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
|
|
|
1350
1350
|
exports.removeDeployer = removeDeployer2;
|
|
1351
1351
|
exports.slash = slash;
|
|
1352
1352
|
exports.tsConfigPaths = tsConfigPaths;
|
|
1353
|
-
//# sourceMappingURL=chunk-
|
|
1354
|
-
//# sourceMappingURL=chunk-
|
|
1353
|
+
//# sourceMappingURL=chunk-C74EXQSL.cjs.map
|
|
1354
|
+
//# sourceMappingURL=chunk-C74EXQSL.cjs.map
|