@mastra/deployer 1.58.0-alpha.0 → 1.58.0-alpha.12

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +164 -0
  2. package/dist/_types/@hono_node-server/dist/index.d.mts +101 -0
  3. package/dist/_types/@mastra_hono/dist/index.d.ts +24 -1
  4. package/dist/{analyze-C6SiypMS.cjs → analyze-BIrkd7zx.cjs} +12 -5
  5. package/dist/{analyze-C6SiypMS.cjs.map → analyze-BIrkd7zx.cjs.map} +1 -1
  6. package/dist/{analyze-mZfLnmw2.js → analyze-CNv6Qdaz.js} +12 -5
  7. package/dist/{analyze-mZfLnmw2.js.map → analyze-CNv6Qdaz.js.map} +1 -1
  8. package/dist/build/analyze.cjs +1 -1
  9. package/dist/build/analyze.d.ts.map +1 -1
  10. package/dist/build/analyze.js +1 -1
  11. package/dist/build/bundler.cjs +1 -1
  12. package/dist/build/bundler.d.ts +2 -1
  13. package/dist/build/bundler.d.ts.map +1 -1
  14. package/dist/build/bundler.js +1 -1
  15. package/dist/build/fs-routing/codegen.d.ts +5 -4
  16. package/dist/build/fs-routing/codegen.d.ts.map +1 -1
  17. package/dist/build/fs-routing/discover.d.ts +12 -5
  18. package/dist/build/fs-routing/discover.d.ts.map +1 -1
  19. package/dist/build/index.cjs +5 -5
  20. package/dist/build/index.js +5 -5
  21. package/dist/build/types.d.ts +11 -0
  22. package/dist/build/types.d.ts.map +1 -1
  23. package/dist/build/watcher.d.ts.map +1 -1
  24. package/dist/{build-BEtx4cTU.cjs → build-BERX35Pi.cjs} +31 -19
  25. package/dist/build-BERX35Pi.cjs.map +1 -0
  26. package/dist/{build-C5mUjLVf.js → build-kZfvpuh9.js} +31 -19
  27. package/dist/build-kZfvpuh9.js.map +1 -0
  28. package/dist/bundler/entries.d.ts +12 -0
  29. package/dist/bundler/entries.d.ts.map +1 -0
  30. package/dist/bundler/index.cjs +6 -345
  31. package/dist/bundler/index.d.ts +52 -2
  32. package/dist/bundler/index.d.ts.map +1 -1
  33. package/dist/bundler/index.js +2 -340
  34. package/dist/bundler-Ct1ToG6x.js +565 -0
  35. package/dist/bundler-Ct1ToG6x.js.map +1 -0
  36. package/dist/{bundler-u9WOUtpl.cjs → bundler-DCGtF4jP.cjs} +7 -3
  37. package/dist/{bundler-u9WOUtpl.cjs.map → bundler-DCGtF4jP.cjs.map} +1 -1
  38. package/dist/bundler-DLXwkS7b.cjs +598 -0
  39. package/dist/bundler-DLXwkS7b.cjs.map +1 -0
  40. package/dist/{bundler-U9F2---r.js → bundler-gff4vn1T.js} +8 -4
  41. package/dist/bundler-gff4vn1T.js.map +1 -0
  42. package/dist/{bundlerOptions-CYRir4LE.cjs → bundlerOptions-CjjAPZYp.cjs} +2 -2
  43. package/dist/{bundlerOptions-CYRir4LE.cjs.map → bundlerOptions-CjjAPZYp.cjs.map} +1 -1
  44. package/dist/{bundlerOptions-9DigsVhY.js → bundlerOptions-NMtZPD7p.js} +2 -2
  45. package/dist/{bundlerOptions-9DigsVhY.js.map → bundlerOptions-NMtZPD7p.js.map} +1 -1
  46. package/dist/docs/SKILL.md +1 -1
  47. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  48. package/dist/index.cjs +5 -5
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.js +4 -4
  51. package/dist/server/index.cjs +954 -167
  52. package/dist/server/index.cjs.map +1 -1
  53. package/dist/server/index.d.ts +1 -1
  54. package/dist/server/index.d.ts.map +1 -1
  55. package/dist/server/index.js +955 -167
  56. package/dist/server/index.js.map +1 -1
  57. package/dist/services/deps.d.ts +3 -1
  58. package/dist/services/deps.d.ts.map +1 -1
  59. package/dist/services/index.cjs +1 -1
  60. package/dist/services/index.js +1 -1
  61. package/dist/{services-CHz7RuZ1.js → services-BRF1RRXB.js} +39 -4
  62. package/dist/services-BRF1RRXB.js.map +1 -0
  63. package/dist/{services-Cw3Ho44Z.cjs → services-_ksvysL5.cjs} +39 -4
  64. package/dist/services-_ksvysL5.cjs.map +1 -0
  65. package/package.json +9 -8
  66. package/dist/_types/@hono_node-server/dist/index.d.ts +0 -8
  67. package/dist/_types/@hono_node-server/dist/listener.d.ts +0 -13
  68. package/dist/_types/@hono_node-server/dist/request.d.ts +0 -25
  69. package/dist/_types/@hono_node-server/dist/server.d.ts +0 -10
  70. package/dist/_types/@hono_node-server/dist/types.d.ts +0 -44
  71. package/dist/build-BEtx4cTU.cjs.map +0 -1
  72. package/dist/build-C5mUjLVf.js.map +0 -1
  73. package/dist/bundler/index.cjs.map +0 -1
  74. package/dist/bundler/index.js.map +0 -1
  75. package/dist/bundler-U9F2---r.js.map +0 -1
  76. package/dist/services-CHz7RuZ1.js.map +0 -1
  77. package/dist/services-Cw3Ho44Z.cjs.map +0 -1
@@ -1,346 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../rolldown-runtime-emK7D4bc.cjs");
3
- const require_analyze = require("../analyze-C6SiypMS.cjs");
4
- const require_utils = require("../utils-O98BGdnP.cjs");
5
- const require_services = require("../services-Cw3Ho44Z.cjs");
6
- const require_bundler = require("../bundler-u9WOUtpl.cjs");
7
- const require_bundlerOptions = require("../bundlerOptions-CYRir4LE.cjs");
8
- let child_process = require("child_process");
9
- let fs = require("fs");
10
- let fs_promises = require("fs/promises");
11
- let path = require("path");
12
- let _mastra_core_bundler = require("@mastra/core/bundler");
13
- let _mastra_core_error = require("@mastra/core/error");
14
- let _rollup_plugin_virtual = require("@rollup/plugin-virtual");
15
- _rollup_plugin_virtual = require_rolldown_runtime.__toESM(_rollup_plugin_virtual, 1);
16
- let empathic_package = require("empathic/package");
17
- empathic_package = require_rolldown_runtime.__toESM(empathic_package, 1);
18
- let fs_extra_esm = require("fs-extra/esm");
19
- fs_extra_esm = require_rolldown_runtime.__toESM(fs_extra_esm, 1);
20
- let tinyglobby = require("tinyglobby");
21
- //#region src/bundler/index.ts
22
- const IS_DEFAULT = Symbol("IS_DEFAULT");
23
- var Bundler = class extends _mastra_core_bundler.MastraBundler {
24
- analyzeOutputDir = ".build";
25
- outputDir = "output";
26
- platform = "node";
27
- constructor(name, component = "BUNDLER") {
28
- super({
29
- name,
30
- component
31
- });
32
- }
33
- async prepare(outputDirectory) {
34
- await (0, fs_extra_esm.emptyDir)(outputDirectory);
35
- await (0, fs_extra_esm.ensureDir)((0, path.join)(outputDirectory, this.analyzeOutputDir));
36
- await (0, fs_extra_esm.ensureDir)((0, path.join)(outputDirectory, this.outputDir));
37
- }
38
- async writePackageJson(outputDirectory, dependencies, resolutions) {
39
- this.logger.debug("Writing project's package.json");
40
- await (0, fs_extra_esm.ensureDir)(outputDirectory);
41
- const pkgPath = (0, path.join)(outputDirectory, "package.json");
42
- const dependenciesMap = /* @__PURE__ */ new Map();
43
- for (const [key, value] of dependencies.entries()) {
44
- const dependencyValue = typeof value === "string" ? value : value.packageSpec ?? value.version ?? "latest";
45
- if (key.startsWith("@")) {
46
- const pkgChunks = key.split("/");
47
- dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);
48
- } else {
49
- const pkgName = key.split("/")[0] || key;
50
- dependenciesMap.set(pkgName, dependencyValue);
51
- }
52
- }
53
- await (0, fs_promises.writeFile)(pkgPath, JSON.stringify({
54
- name: "server",
55
- version: "1.0.0",
56
- private: true,
57
- type: "module",
58
- main: "index.mjs",
59
- scripts: { start: "node ./index.mjs" },
60
- dependencies: Object.fromEntries(dependenciesMap.entries()),
61
- ...Object.keys(resolutions ?? {}).length > 0 && { resolutions }
62
- }, null, 2));
63
- }
64
- createBundler(inputOptions, outputOptions) {
65
- return require_bundler.createBundler(inputOptions, outputOptions);
66
- }
67
- async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
68
- const defaultBundlerOptions = {
69
- externals: [],
70
- sourcemap: false,
71
- transpilePackages: [],
72
- [IS_DEFAULT]: true
73
- };
74
- try {
75
- return await require_bundlerOptions.getBundlerOptions(mastraEntryFile, outputDirectory) ?? defaultBundlerOptions;
76
- } catch (error) {
77
- this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
78
- }
79
- return defaultBundlerOptions;
80
- }
81
- async analyze(entry, mastraFile, outputDirectory) {
82
- return await require_analyze.analyzeBundle([].concat(entry), mastraFile, {
83
- outputDir: (0, path.join)(outputDirectory, this.analyzeOutputDir),
84
- projectRoot: outputDirectory,
85
- platform: this.platform
86
- }, this.logger);
87
- }
88
- async installDependencies(outputDirectory, rootDir = process.cwd(), pnpmOverrides) {
89
- const deps = new require_services.DepsService(rootDir);
90
- deps.__setLogger(this.logger);
91
- await deps.install({
92
- dir: (0, path.join)(outputDirectory, this.outputDir),
93
- pnpmOverrides
94
- });
95
- }
96
- /**
97
- * Generate a package-lock.json for the output directory so that deploy targets
98
- * can use `npm ci` instead of `npm install`, skipping version resolution entirely.
99
- * This is a lockfile-only operation — no packages are downloaded.
100
- *
101
- * Temporarily moves node_modules out of the way because pnpm's symlink-based
102
- * layout confuses npm's arborist, then restores it afterwards so that
103
- * `mastra start` (or wrangler) can still resolve dependencies at runtime.
104
- */
105
- async generateNpmLockfile(outputDir) {
106
- const nodeModules = (0, path.join)(outputDir, "node_modules");
107
- const nodeModulesTmp = (0, path.join)(outputDir, "node_modules.__tmp");
108
- let movedNodeModules = false;
109
- try {
110
- if (await fs_extra_esm.default.pathExists(nodeModules)) {
111
- await fs_extra_esm.default.move(nodeModules, nodeModulesTmp, { overwrite: true });
112
- movedNodeModules = true;
113
- }
114
- (0, child_process.execSync)("npm install --package-lock-only --force", {
115
- cwd: outputDir,
116
- stdio: "pipe",
117
- timeout: 6e4
118
- });
119
- } catch {
120
- this.logger.warn("Failed to generate package-lock.json — deploy will fall back to npm install");
121
- } finally {
122
- if (movedNodeModules) {
123
- await (0, fs_promises.rm)(nodeModules, {
124
- recursive: true,
125
- force: true
126
- });
127
- await fs_extra_esm.default.move(nodeModulesTmp, nodeModules, { overwrite: true });
128
- }
129
- }
130
- }
131
- async copyPublic(mastraDir, outputDirectory) {
132
- const publicDir = (0, path.join)(mastraDir, "public");
133
- try {
134
- await (0, fs_promises.stat)(publicDir);
135
- } catch {
136
- return;
137
- }
138
- await (0, fs_extra_esm.copy)(publicDir, (0, path.join)(outputDirectory, this.outputDir));
139
- }
140
- async copyDOTNPMRC({ rootDir = process.cwd(), outputDirectory }) {
141
- const sourceDotNpmRcPath = (0, path.join)(rootDir, ".npmrc");
142
- const targetDotNpmRcPath = (0, path.join)(outputDirectory, this.outputDir, ".npmrc");
143
- try {
144
- await (0, fs_promises.stat)(sourceDotNpmRcPath);
145
- await (0, fs_extra_esm.copy)(sourceDotNpmRcPath, targetDotNpmRcPath);
146
- } catch {
147
- return;
148
- }
149
- }
150
- /**
151
- * Writes the `mastra-project.json` deployment marker for Software Factory
152
- * projects after public assets have been copied. Verifies that the Factory
153
- * SPA (`factory/index.html`) exists in the output before emitting the marker.
154
- */
155
- async writeFactoryMarker(outputDirectory) {
156
- const outputDir = (0, path.join)(outputDirectory, this.outputDir);
157
- if (!(0, fs.existsSync)((0, path.join)(outputDir, "factory", "index.html"))) throw new _mastra_core_error.MastraError({
158
- id: "DEPLOYER_BUNDLER_FACTORY_UI_MISSING",
159
- text: "Software Factory project detected but factory/index.html was not found after copying the prebuilt Factory UI.",
160
- domain: _mastra_core_error.ErrorDomain.DEPLOYER,
161
- category: _mastra_core_error.ErrorCategory.SYSTEM
162
- });
163
- await (0, fs_promises.writeFile)((0, path.join)(outputDir, "mastra-project.json"), JSON.stringify({
164
- schemaVersion: 1,
165
- projectType: "factory",
166
- assets: { ui: "factory" }
167
- }, null, 2));
168
- this.logger.info("Wrote mastra-project.json for Software Factory project");
169
- }
170
- async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, { enableSourcemap, enableEsmShim, externals }) {
171
- const { workspaceRoot } = await require_analyze.getWorkspaceInformation({ mastraEntryFile });
172
- const closestPkgJson = empathic_package.up({ cwd: (0, path.dirname)(mastraEntryFile) });
173
- const projectRoot = closestPkgJson ? (0, path.dirname)(closestPkgJson) : process.cwd();
174
- const inputOptions = await require_bundler.getInputOptions(mastraEntryFile, analyzedBundleInfo, this.platform, { "process.env.NODE_ENV": JSON.stringify("production") }, {
175
- sourcemap: enableSourcemap,
176
- workspaceRoot,
177
- projectRoot,
178
- enableEsmShim,
179
- externalsPreset: externals === true
180
- });
181
- const isVirtual = serverFile.includes("\n") || !(0, fs.existsSync)(serverFile);
182
- const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);
183
- if (isVirtual) {
184
- inputOptions.input = {
185
- index: "#entry",
186
- ...toolsInputOptions
187
- };
188
- if (Array.isArray(inputOptions.plugins)) inputOptions.plugins.unshift((0, _rollup_plugin_virtual.default)({ "#entry": serverFile }));
189
- else inputOptions.plugins = [(0, _rollup_plugin_virtual.default)({ "#entry": serverFile })];
190
- } else inputOptions.input = {
191
- index: serverFile,
192
- ...toolsInputOptions
193
- };
194
- return inputOptions;
195
- }
196
- getAllToolPaths(mastraDir, toolsPaths = []) {
197
- const normalizedMastraDir = require_utils.slash(mastraDir);
198
- const defaultPaths = [path.posix.join(normalizedMastraDir, "tools/**/*.{js,ts}"), ...[`!${path.posix.join(normalizedMastraDir, "tools/**/*.{test,spec}.{js,ts}")}`, `!${path.posix.join(normalizedMastraDir, "tools/**/__tests__/**")}`]];
199
- if (toolsPaths.length === 0) return [defaultPaths];
200
- return [...toolsPaths, defaultPaths];
201
- }
202
- async listToolsInputOptions(toolsPaths) {
203
- const inputs = {};
204
- for (const toolPath of toolsPaths) {
205
- const expandedPaths = await (0, tinyglobby.glob)(toolPath, {
206
- absolute: true,
207
- expandDirectories: false
208
- });
209
- for (const path$1 of expandedPaths) if (await fs_extra_esm.default.pathExists(path$1)) {
210
- const entryFile = new require_services.FileService().getFirstExistingFile([
211
- (0, path.join)(path$1, "index.ts"),
212
- (0, path.join)(path$1, "index.js"),
213
- path$1
214
- ]);
215
- if (!entryFile || (await (0, fs_promises.stat)(entryFile)).isDirectory()) {
216
- this.logger.warn("No entry file found, skipping", { path: path$1 });
217
- continue;
218
- }
219
- const uniqueToolID = crypto.randomUUID();
220
- const normalizedEntryFile = entryFile.replaceAll("\\", "/");
221
- inputs[`tools/${uniqueToolID}`] = normalizedEntryFile;
222
- } else this.logger.warn("Tool path does not exist, skipping", { path: path$1 });
223
- }
224
- return inputs;
225
- }
226
- async _bundle(serverFile, mastraEntryFile, { projectRoot, outputDirectory, enableEsmShim = true }, toolsPaths = [], bundleLocation = (0, path.join)(outputDirectory, this.outputDir)) {
227
- const analyzeDir = (0, path.join)(outputDirectory, this.analyzeOutputDir);
228
- const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);
229
- const internalBundlerOptions = {
230
- enableSourcemap: !!bundlerOptions.sourcemap,
231
- externals: bundlerOptions.externals ?? [],
232
- enableEsmShim,
233
- dynamicPackages: bundlerOptions.dynamicPackages
234
- };
235
- let analyzedBundleInfo;
236
- try {
237
- const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths);
238
- analyzedBundleInfo = await require_analyze.analyzeBundle([serverFile, ...Object.values(resolvedToolsPaths)], mastraEntryFile, {
239
- outputDir: analyzeDir,
240
- projectRoot,
241
- platform: this.platform,
242
- bundlerOptions: internalBundlerOptions
243
- }, this.logger);
244
- } catch (error) {
245
- const message = error instanceof Error ? error.message : String(error);
246
- if (error instanceof _mastra_core_error.MastraError) throw error;
247
- throw new _mastra_core_error.MastraError({
248
- id: "DEPLOYER_BUNDLER_ANALYZE_FAILED",
249
- text: `Failed to analyze Mastra application: ${message}`,
250
- domain: _mastra_core_error.ErrorDomain.DEPLOYER,
251
- category: _mastra_core_error.ErrorCategory.SYSTEM
252
- }, error);
253
- }
254
- const dependenciesToInstall = /* @__PURE__ */ new Map();
255
- for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {
256
- if (analyzedBundleInfo.workspaceMap.has(dep) || !require_utils.isBareModuleSpecifier(dep)) continue;
257
- dependenciesToInstall.set(dep, depInfo);
258
- }
259
- const initialWorkspaceDependencies = /* @__PURE__ */ new Set();
260
- for (const dep of analyzedBundleInfo.dependencies.keys()) {
261
- const pkgName = require_utils.getPackageName(dep);
262
- if (pkgName && analyzedBundleInfo.workspaceMap.has(pkgName)) initialWorkspaceDependencies.add(pkgName);
263
- }
264
- const transitiveWorkspaceDependencies = require_analyze.collectTransitiveWorkspaceDependencies({
265
- workspaceMap: analyzedBundleInfo.workspaceMap,
266
- initialDependencies: initialWorkspaceDependencies,
267
- logger: this.logger
268
- });
269
- for (const [dep, packageSpec] of Object.entries(transitiveWorkspaceDependencies.resolutions)) dependenciesToInstall.set(dep, {
270
- version: analyzedBundleInfo.workspaceMap.get(dep)?.version,
271
- packageSpec
272
- });
273
- try {
274
- await this.writePackageJson((0, path.join)(outputDirectory, this.outputDir), dependenciesToInstall, transitiveWorkspaceDependencies.resolutions);
275
- if (transitiveWorkspaceDependencies.usedWorkspacePackages.size > 0) await require_analyze.packWorkspaceDependencies({
276
- workspaceMap: analyzedBundleInfo.workspaceMap,
277
- usedWorkspacePackages: transitiveWorkspaceDependencies.usedWorkspacePackages,
278
- bundleOutputDir: (0, path.join)(outputDirectory, this.outputDir),
279
- logger: this.logger
280
- });
281
- this.logger.info("Bundling Mastra application");
282
- const inputOptions = await this.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, internalBundlerOptions);
283
- await (await this.createBundler({
284
- ...inputOptions,
285
- logLevel: inputOptions.logLevel === "silent" ? "warn" : inputOptions.logLevel,
286
- onwarn: (warning) => {
287
- if (warning.code === "CIRCULAR_DEPENDENCY") {
288
- if (warning.ids?.[0]?.includes("node_modules")) return;
289
- this.logger.warn("Circular dependency found", { dependency: warning.message.replace("Circular dependency: ", "") });
290
- }
291
- }
292
- }, {
293
- dir: bundleLocation,
294
- manualChunks: { mastra: ["#mastra"] },
295
- sourcemap: internalBundlerOptions.enableSourcemap
296
- })).write();
297
- const toolImports = [];
298
- const toolsExports = [];
299
- Array.from(Object.keys(inputOptions.input || {})).filter((key) => key.startsWith("tools/")).forEach((key, index) => {
300
- const toolExport = `tool${index}`;
301
- toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);
302
- toolsExports.push(toolExport);
303
- });
304
- await (0, fs_promises.writeFile)((0, path.join)(bundleLocation, "tools.mjs"), `${toolImports.join("\n")}
305
-
306
- export const tools = [${toolsExports.join(", ")}]`);
307
- this.logger.info("Bundling Mastra done");
308
- this.logger.info("Copying public files");
309
- await this.copyPublic((0, path.dirname)(mastraEntryFile), outputDirectory);
310
- this.logger.info("Done copying public files");
311
- if (analyzedBundleInfo.projectType === "factory") await this.writeFactoryMarker(outputDirectory);
312
- this.logger.info("Copying .npmrc file");
313
- await this.copyDOTNPMRC({
314
- outputDirectory,
315
- rootDir: projectRoot
316
- });
317
- this.logger.info("Done copying .npmrc file");
318
- this.logger.info("Installing dependencies");
319
- await this.installDependencies(outputDirectory, projectRoot, transitiveWorkspaceDependencies.resolutions);
320
- this.logger.info("Done installing dependencies");
321
- if (Object.keys(transitiveWorkspaceDependencies.resolutions).length === 0) {
322
- this.logger.info("Generating package-lock.json for deploy");
323
- await this.generateNpmLockfile((0, path.join)(outputDirectory, this.outputDir));
324
- this.logger.info("Done generating package-lock.json");
325
- } else this.logger.warn("Skipping package-lock.json generation because the output contains packed workspace dependencies");
326
- } catch (error) {
327
- if (error instanceof _mastra_core_error.MastraError && error.id === "DEPLOYER_BUNDLER_FACTORY_UI_MISSING") throw error;
328
- throw new _mastra_core_error.MastraError({
329
- id: "DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED",
330
- text: `Failed during bundler bundle stage: ${error instanceof Error ? error.message : String(error)}`,
331
- domain: _mastra_core_error.ErrorDomain.DEPLOYER,
332
- category: _mastra_core_error.ErrorCategory.SYSTEM
333
- }, error);
334
- }
335
- }
336
- async lint(_entryFile, _outputDirectory, toolsPaths) {
337
- const toolsInputOptions = await this.listToolsInputOptions(toolsPaths);
338
- const toolsLength = Object.keys(toolsInputOptions).length;
339
- if (toolsLength > 0) this.logger.info("Found tools", { count: toolsLength });
340
- }
341
- };
342
- //#endregion
343
- exports.Bundler = Bundler;
344
- exports.IS_DEFAULT = IS_DEFAULT;
345
-
346
- //# sourceMappingURL=index.cjs.map
2
+ const require_bundler = require("../bundler-DLXwkS7b.cjs");
3
+ exports.Bundler = require_bundler.Bundler;
4
+ exports.IS_DEFAULT = require_bundler.IS_DEFAULT;
5
+ exports.applySourceDependencyRange = require_bundler.applySourceDependencyRange;
6
+ exports.getSourceDependencyConstraints = require_bundler.getSourceDependencyConstraints;
7
+ exports.isRegistryVersionSpec = require_bundler.isRegistryVersionSpec;
@@ -4,9 +4,58 @@ import type { InputOptions, OutputOptions } from 'rollup';
4
4
  import { analyzeBundle } from '../build/analyze/index.js';
5
5
  import type { BundlerOptions, ExternalDependencyInfo } from '../build/types.js';
6
6
  import type { BundlerPlatform } from '../build/utils.js';
7
- export type { BundlerOptions } from '../build/types.js';
7
+ export type { BundlerOptions, ExternalDependencyInfo } from '../build/types.js';
8
8
  export type { BundlerPlatform } from '../build/utils.js';
9
9
  export declare const IS_DEFAULT: unique symbol;
10
+ /**
11
+ * Constraints declared by the source app, plus the packages some resolution field pins.
12
+ *
13
+ * Only `dependencies` values are read. Override fields contribute names, never values: which of
14
+ * `overrides`, `resolutions`, `pnpm.overrides` or `pnpm-workspace.yaml` a given install honoured
15
+ * depends on the package manager and its version, so reproducing that precedence would mean
16
+ * emulating three package managers. A name appearing in any of them is enough to know the resolved
17
+ * version was chosen deliberately, which is all this needs.
18
+ */
19
+ export type SourceDependencyConstraints = {
20
+ dependencies: Record<string, string>;
21
+ pinnedByResolutionField: Set<string>;
22
+ };
23
+ /**
24
+ * True when a specifier is something the isolated install in `.mastra/output` can resolve from the
25
+ * registry: a semver range, a dist tag, a wildcard, or an npm alias whose target is a registry
26
+ * package and range.
27
+ *
28
+ * This is an allowlist rather than a denylist of known protocols, so an unfamiliar protocol is
29
+ * rejected without this code having to know it exists. The output directory is not a workspace, has
30
+ * no catalog definitions and has a different relative-path base, so `catalog:`, `workspace:`,
31
+ * `file:`, `link:` and git specifiers are all either uninstallable there or point somewhere else.
32
+ */
33
+ export declare const isRegistryVersionSpec: (spec: string) => boolean;
34
+ /**
35
+ * Read the constraints the source app declared.
36
+ *
37
+ * `dependencies` come from the manifest at `projectRoot`, the package the build was invoked for and
38
+ * whose directory receives the output, falling back to the manifest above the entry file. Anchoring
39
+ * on `projectRoot` rather than the entry file keeps the answer deterministic when the entry handed
40
+ * to the bundler is a generated wrapper rather than the app's own source file.
41
+ *
42
+ * Resolution-field names are collected from both that manifest and the workspace root, including the
43
+ * root `pnpm-workspace.yaml`, because a name pinned anywhere means the resolved version may have been
44
+ * chosen deliberately rather than hoisted by accident.
45
+ */
46
+ export declare const getSourceDependencyConstraints: ({ projectRoot, mastraEntryFile, workspaceRoot, }: {
47
+ projectRoot: string;
48
+ mastraEntryFile: string;
49
+ workspaceRoot?: string;
50
+ }) => Promise<SourceDependencyConstraints>;
51
+ /**
52
+ * Prefer the constraint the app declared over the version resolved from `node_modules`.
53
+ *
54
+ * The resolved version is whatever the install happened to hoist, so an app declaring `zod: ^4.3.6`
55
+ * next to a hoisted `zod@3.25.76` gets the hoisted version written into the output manifest and the
56
+ * isolated install then locks it in.
57
+ */
58
+ export declare const applySourceDependencyRange: (dependencyName: string, dependencyInfo: ExternalDependencyInfo, constraints: SourceDependencyConstraints) => ExternalDependencyInfo;
10
59
  export declare abstract class Bundler extends MastraBundler {
11
60
  protected analyzeOutputDir: string;
12
61
  protected outputDir: string;
@@ -30,6 +79,7 @@ export declare abstract class Bundler extends MastraBundler {
30
79
  dependencies: Map<string, string>;
31
80
  workspaceMap: Map<string, import("./workspaceDependencies").WorkspacePackageInfo>;
32
81
  }>;
82
+ protected pnpmNodeLinker?: 'hoisted';
33
83
  protected installDependencies(outputDirectory: string, rootDir?: string, pnpmOverrides?: Record<string, string>): Promise<void>;
34
84
  /**
35
85
  * Generate a package-lock.json for the output directory so that deploy targets
@@ -52,7 +102,7 @@ export declare abstract class Bundler extends MastraBundler {
52
102
  * SPA (`factory/index.html`) exists in the output before emitting the marker.
53
103
  */
54
104
  protected writeFactoryMarker(outputDirectory: string): Promise<void>;
55
- protected getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>, toolsPaths: (string | string[])[], { enableSourcemap, enableEsmShim, externals }: BundlerOptions): Promise<InputOptions>;
105
+ protected getBundlerOptions(serverFile: string, mastraEntryFile: string, analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>, toolsPaths: (string | string[])[], { enableSourcemap, enableMinify, enableEsmShim, externals, entries }: BundlerOptions): Promise<InputOptions>;
56
106
  getAllToolPaths(mastraDir: string, toolsPaths?: (string | string[])[]): (string | string[])[];
57
107
  listToolsInputOptions(toolsPaths: (string | string[])[]): Promise<Record<string, string>>;
58
108
  protected _bundle(serverFile: string, mastraEntryFile: string, { projectRoot, outputDirectory, enableEsmShim, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAUtD,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,eAAO,MAAM,UAAU,eAAuB,CAAC;AAE/C,8BAAs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