@mastra/deployer 1.80.0 → 1.81.0-alpha.0

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 (105) hide show
  1. package/dist/_types/@internal_core/dist/base/index.d.ts +28 -0
  2. package/dist/_types/@internal_core/dist/index-Diz1p9N7.d.ts +316 -0
  3. package/dist/_types/@internal_core/dist/logger/index.d.ts +2 -0
  4. package/dist/_types/@internal_core/package.json +1 -0
  5. package/dist/_types/@internal_deployer/dist/_types/@internal_core/dist/index-Diz1p9N7.d.ts +316 -0
  6. package/dist/_types/@internal_deployer/dist/_types/@internal_core/dist/logger/index.d.ts +2 -0
  7. package/dist/_types/@internal_deployer/dist/bundler.d.ts +79 -0
  8. package/dist/_types/@internal_deployer/dist/deployer.d.ts +11 -0
  9. package/dist/_types/@internal_deployer/dist/index.d.ts +4 -0
  10. package/dist/_types/@internal_deployer/package.json +1 -0
  11. package/dist/{analyze-CQH2CQM9.js → analyze-BZGcfVSL.js} +4 -4
  12. package/dist/analyze-BZGcfVSL.js.map +1 -0
  13. package/dist/{analyze-SxVgkEcB.cjs → analyze-CtWBhASF.cjs} +13 -13
  14. package/dist/analyze-CtWBhASF.cjs.map +1 -0
  15. package/dist/build/analyze/analyzeEntry.d.ts +1 -1
  16. package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
  17. package/dist/build/analyze.cjs +1 -1
  18. package/dist/build/analyze.d.ts +4 -4
  19. package/dist/build/analyze.d.ts.map +1 -1
  20. package/dist/build/analyze.js +1 -1
  21. package/dist/build/babel/remove-all-options-except.d.ts +1 -1
  22. package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
  23. package/dist/build/bundler.cjs +1 -1
  24. package/dist/build/bundler.js +1 -1
  25. package/dist/build/bundlerOptions.d.ts +3 -3
  26. package/dist/build/bundlerOptions.d.ts.map +1 -1
  27. package/dist/build/deployer.d.ts +3 -3
  28. package/dist/build/deployer.d.ts.map +1 -1
  29. package/dist/build/index.cjs +5 -5
  30. package/dist/build/index.js +5 -5
  31. package/dist/build/plugins/esm-shim.d.ts.map +1 -1
  32. package/dist/build/plugins/remove-all-except.d.ts +1 -1
  33. package/dist/build/plugins/remove-all-except.d.ts.map +1 -1
  34. package/dist/build/serverOptions.d.ts +1 -1
  35. package/dist/build/serverOptions.d.ts.map +1 -1
  36. package/dist/build/shared/extract-mastra-option.d.ts +1 -1
  37. package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
  38. package/dist/{build-BlmomwDs.js → build-CkZ0xUid.js} +7 -9
  39. package/dist/build-CkZ0xUid.js.map +1 -0
  40. package/dist/{build-CXMVTo1j.cjs → build-D0eiANsp.cjs} +8 -10
  41. package/dist/build-D0eiANsp.cjs.map +1 -0
  42. package/dist/bundler/index.cjs +6 -506
  43. package/dist/bundler/index.d.ts +14 -8
  44. package/dist/bundler/index.d.ts.map +1 -1
  45. package/dist/bundler/index.js +1 -498
  46. package/dist/bundler/workspaceDependencies.d.ts +1 -1
  47. package/dist/bundler/workspaceDependencies.d.ts.map +1 -1
  48. package/dist/bundler-BBi45M7f.cjs +549 -0
  49. package/dist/bundler-BBi45M7f.cjs.map +1 -0
  50. package/dist/bundler-CNgW1Vui.js +516 -0
  51. package/dist/bundler-CNgW1Vui.js.map +1 -0
  52. package/dist/{bundler-D3Ky7WCf.js → bundler-C_LpvgiH.js} +2 -2
  53. package/dist/bundler-C_LpvgiH.js.map +1 -0
  54. package/dist/{bundler-D_3GyN0N.cjs → bundler-Cb7pRVvA.cjs} +5 -5
  55. package/dist/bundler-Cb7pRVvA.cjs.map +1 -0
  56. package/dist/{bundlerOptions-Dgt4ZEo1.cjs → bundlerOptions-BBvSNHFj.cjs} +2 -2
  57. package/dist/bundlerOptions-BBvSNHFj.cjs.map +1 -0
  58. package/dist/{bundlerOptions-BtDsaIgs.js → bundlerOptions-BlUHmPBE.js} +2 -2
  59. package/dist/bundlerOptions-BlUHmPBE.js.map +1 -0
  60. package/dist/deploy/base.d.ts +1 -1
  61. package/dist/deploy/base.d.ts.map +1 -1
  62. package/dist/deploy/log.d.ts +1 -1
  63. package/dist/deploy/log.d.ts.map +1 -1
  64. package/dist/docs/SKILL.md +1 -1
  65. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  66. package/dist/docs/references/docs-deployment-mastra-server.md +3 -1
  67. package/dist/error-BVvc5jcw.js +172 -0
  68. package/dist/error-BVvc5jcw.js.map +1 -0
  69. package/dist/error-CR4whExy.cjs +195 -0
  70. package/dist/error-CR4whExy.cjs.map +1 -0
  71. package/dist/index.cjs +5 -5
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.js +4 -4
  74. package/dist/index.js.map +1 -1
  75. package/dist/server/handlers/a2a.d.ts +31 -31
  76. package/dist/server/handlers/a2a.d.ts.map +1 -1
  77. package/dist/server/handlers/client.d.ts.map +1 -1
  78. package/dist/server/index.cjs +9 -8
  79. package/dist/server/index.cjs.map +1 -1
  80. package/dist/server/index.js +9 -8
  81. package/dist/server/index.js.map +1 -1
  82. package/dist/services/deps.d.ts +2 -2
  83. package/dist/services/deps.d.ts.map +1 -1
  84. package/dist/services/env.d.ts.map +1 -1
  85. package/dist/services/fs.d.ts.map +1 -1
  86. package/dist/services/index.cjs +1 -1
  87. package/dist/services/index.js +1 -1
  88. package/dist/{services-BJQJLQs9.js → services-CXZJN9er.js} +294 -5
  89. package/dist/services-CXZJN9er.js.map +1 -0
  90. package/dist/{services-Dqx1iouv.cjs → services-CtVt5CJq.cjs} +321 -20
  91. package/dist/services-CtVt5CJq.cjs.map +1 -0
  92. package/dist/validator/validate.d.ts.map +1 -1
  93. package/package.json +10 -8
  94. package/dist/analyze-CQH2CQM9.js.map +0 -1
  95. package/dist/analyze-SxVgkEcB.cjs.map +0 -1
  96. package/dist/build-BlmomwDs.js.map +0 -1
  97. package/dist/build-CXMVTo1j.cjs.map +0 -1
  98. package/dist/bundler/index.cjs.map +0 -1
  99. package/dist/bundler/index.js.map +0 -1
  100. package/dist/bundler-D3Ky7WCf.js.map +0 -1
  101. package/dist/bundler-D_3GyN0N.cjs.map +0 -1
  102. package/dist/bundlerOptions-BtDsaIgs.js.map +0 -1
  103. package/dist/bundlerOptions-Dgt4ZEo1.cjs.map +0 -1
  104. package/dist/services-BJQJLQs9.js.map +0 -1
  105. package/dist/services-Dqx1iouv.cjs.map +0 -1
@@ -0,0 +1,516 @@
1
+ import { c as packWorkspaceDependencies, o as collectTransitiveWorkspaceDependencies, s as getWorkspaceInformation, t as analyzeBundle } from "./analyze-BZGcfVSL.js";
2
+ import { i as DepsService, l as MastraBase, t as FileService } from "./services-CXZJN9er.js";
3
+ import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-BVvc5jcw.js";
4
+ import { a as getPackageName, m as slash, p as shouldSkipInstall, s as isBareModuleSpecifier } from "./utils-C8gwr-ur.js";
5
+ import { n as getInputOptions, r as getUnresolvedWorkspaceImport, t as createBundler } from "./bundler-C_LpvgiH.js";
6
+ import { t as getBundlerOptions } from "./bundlerOptions-BlUHmPBE.js";
7
+ import { existsSync } from "fs";
8
+ import { readFile, stat, writeFile } from "fs/promises";
9
+ import { dirname, join, posix, relative, resolve } from "path";
10
+ import { parse } from "dotenv";
11
+ import virtual from "@rollup/plugin-virtual";
12
+ import * as pkg from "empathic/package";
13
+ import fsExtra, { copy, emptyDir, ensureDir, readJSON } from "fs-extra/esm";
14
+ import { glob } from "tinyglobby";
15
+ // ../_internals/deployer/dist/index.js
16
+ /**
17
+ * Reads dotenv files in order into one map; values from later files override earlier ones.
18
+ */
19
+ async function loadEnvVars(files) {
20
+ const envVars = /* @__PURE__ */ new Map();
21
+ for (const file of files) {
22
+ const content = await readFile(file, "utf-8");
23
+ const config = parse(content);
24
+ Object.entries(config).forEach(([key, value]) => {
25
+ envVars.set(key, value);
26
+ });
27
+ }
28
+ return envVars;
29
+ }
30
+ // src/bundler/index.ts
31
+ const IS_DEFAULT = Symbol("IS_DEFAULT");
32
+ const NPM_ALIAS_PREFIX = "npm:";
33
+ /** Characters a registry range or dist tag can contain. Protocols need `:`, git shorthand needs `/` or `#`. */
34
+ const REGISTRY_SPEC_PATTERN = /^[A-Za-z0-9.+_^~><=*|!\s-]+$/;
35
+ const PACKAGE_NAME_PATTERN = /^(?:@[A-Za-z0-9._-]+\/)?[A-Za-z0-9._-]+$/;
36
+ const TARBALL_SUFFIX_PATTERN = /\.(?:tgz|tar\.gz|tar)$/i;
37
+ /** npm reads a value starting like this as a path, whatever follows. A bare `~` is a semver range. */
38
+ const FILE_SPEC_PREFIX_PATTERN = /^(?:\.|~[/\\]|[/\\]|[A-Za-z]:[/\\])/;
39
+ /** A range admitting any published version: `*`, `x`, `>=0`, and any union containing one. */
40
+ const UNBOUNDED_RANGE_PATTERN = /(?:^|\|\||\s)\s*(?:[*xX]|>=?\s*0(?:\.0)*(?:\.0)*)\s*(?:$|\|\|)/;
41
+ const toStringRecord = (value) => {
42
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
43
+ return Object.fromEntries(Object.entries(value).filter((entry) => typeof entry[1] === "string"));
44
+ };
45
+ /**
46
+ * True when a specifier is something the isolated install in `.mastra/output` can resolve from the
47
+ * registry: a semver range, a dist tag, a wildcard, or an npm alias whose target is a registry
48
+ * package and range.
49
+ *
50
+ * This is an allowlist rather than a denylist of known protocols, so an unfamiliar protocol is
51
+ * rejected without this code having to know it exists. The output directory is not a workspace, has
52
+ * no catalog definitions and has a different relative-path base, so `catalog:`, `workspace:`,
53
+ * `file:`, `link:` and git specifiers are all either uninstallable there or point somewhere else.
54
+ */
55
+ const isRegistryVersionSpec = (spec) => {
56
+ if (FILE_SPEC_PREFIX_PATTERN.test(spec) || TARBALL_SUFFIX_PATTERN.test(spec)) return false;
57
+ if (spec.startsWith(NPM_ALIAS_PREFIX)) {
58
+ const alias = spec.slice(4);
59
+ const rangeSeparator = alias.lastIndexOf("@");
60
+ const name = rangeSeparator > 0 ? alias.slice(0, rangeSeparator) : alias;
61
+ const range = rangeSeparator > 0 ? alias.slice(rangeSeparator + 1) : "*";
62
+ return PACKAGE_NAME_PATTERN.test(name) && isRegistryVersionSpec(range);
63
+ }
64
+ return REGISTRY_SPEC_PATTERN.test(spec);
65
+ };
66
+ /**
67
+ * True when a specifier names a version the output install can be held to.
68
+ *
69
+ * A range admitting anything (`*`, `latest`, `>=0`, an alias with no range) is looser than the
70
+ * version already resolved, so writing it would let a later install pull something the bundle was
71
+ * never analyzed against.
72
+ */
73
+ const isBoundedVersionSpec = (spec) => {
74
+ const range = spec.startsWith(NPM_ALIAS_PREFIX) ? (() => {
75
+ const alias = spec.slice(4);
76
+ const rangeSeparator = alias.lastIndexOf("@");
77
+ return rangeSeparator > 0 ? alias.slice(rangeSeparator + 1) : "";
78
+ })() : spec;
79
+ return /\d/.test(range) && !UNBOUNDED_RANGE_PATTERN.test(range);
80
+ };
81
+ const readManifest = async (manifestPath) => {
82
+ if (!manifestPath) return;
83
+ try {
84
+ const manifest = await readJSON(manifestPath);
85
+ return manifest && typeof manifest === "object" ? manifest : void 0;
86
+ } catch {
87
+ return;
88
+ }
89
+ };
90
+ /** Collect the package names a manifest's resolution fields pin, ignoring their values. */
91
+ const collectManifestPinnedNames = (manifest, pinned) => {
92
+ const pnpmSection = manifest?.pnpm;
93
+ const records = [
94
+ manifest?.overrides,
95
+ manifest?.resolutions,
96
+ pnpmSection && typeof pnpmSection === "object" ? pnpmSection.overrides : void 0
97
+ ];
98
+ for (const record of records) if (record && typeof record === "object" && !Array.isArray(record)) for (const key of Object.keys(record)) pinned.add(key);
99
+ };
100
+ /**
101
+ * Collect the names under a top-level `overrides:` block in `pnpm-workspace.yaml`.
102
+ *
103
+ * pnpm moved overrides out of `package.json` into this file, so a workspace on a current pnpm keeps
104
+ * them only here. Reading names off the indented block avoids a YAML dependency, the same tradeoff
105
+ * `copyPnpmWorkspaceSettings` already makes for the top-level keys it copies.
106
+ */
107
+ const collectPnpmWorkspacePinnedNames = (source, pinned) => {
108
+ const lines = source.split(/\r?\n/);
109
+ let insideOverrides = false;
110
+ for (const line of lines) {
111
+ if (/^\S/.test(line)) {
112
+ insideOverrides = /^overrides:\s*$/.test(line);
113
+ continue;
114
+ }
115
+ if (!insideOverrides) continue;
116
+ const key = /^\s+(?:'([^']+)'|"([^"]+)"|([^'"\s:][^:]*?))\s*:/.exec(line);
117
+ if (key) pinned.add((key[1] ?? key[2] ?? key[3] ?? "").trim());
118
+ }
119
+ };
120
+ /**
121
+ * Read the constraints the source app declared.
122
+ *
123
+ * `dependencies` come from the manifest at `projectRoot`, the package the build was invoked for and
124
+ * whose directory receives the output, falling back to the manifest above the entry file. Anchoring
125
+ * on `projectRoot` rather than the entry file keeps the answer deterministic when the entry handed
126
+ * to the bundler is a generated wrapper rather than the app's own source file.
127
+ *
128
+ * Resolution-field names are collected from both that manifest and the workspace root, including the
129
+ * root `pnpm-workspace.yaml`, because a name pinned anywhere means the resolved version may have been
130
+ * chosen deliberately rather than hoisted by accident.
131
+ */
132
+ const getSourceDependencyConstraints = async ({ projectRoot, mastraEntryFile, workspaceRoot }) => {
133
+ const manifestPaths = [pkg.up({ cwd: projectRoot }), pkg.up({ cwd: dirname(mastraEntryFile) })].filter((entry, index, entries) => !!entry && entries.indexOf(entry) === index);
134
+ if (workspaceRoot) manifestPaths.push(join(workspaceRoot, "package.json"));
135
+ const pinnedByResolutionField = /* @__PURE__ */ new Set();
136
+ let dependencies;
137
+ for (const manifestPath of manifestPaths) {
138
+ const manifest = await readManifest(manifestPath);
139
+ if (!manifest) continue;
140
+ dependencies ??= toStringRecord(manifest.dependencies);
141
+ collectManifestPinnedNames(manifest, pinnedByResolutionField);
142
+ }
143
+ if (workspaceRoot) try {
144
+ collectPnpmWorkspacePinnedNames(await readFile(join(workspaceRoot, "pnpm-workspace.yaml"), "utf-8"), pinnedByResolutionField);
145
+ } catch {}
146
+ return {
147
+ dependencies: dependencies ?? {},
148
+ pinnedByResolutionField
149
+ };
150
+ };
151
+ const findDeclaredConstraint = (constraints, dependencyName) => {
152
+ const names = [dependencyName, getPackageName(dependencyName)].filter((name, index, all) => !!name && all.indexOf(name) === index);
153
+ for (const name of names) if (constraints.pinnedByResolutionField.has(name)) return;
154
+ for (const name of names) {
155
+ const declared = (constraints.dependencies[name] ?? "").trim();
156
+ if (declared && isBoundedVersionSpec(declared) && isRegistryVersionSpec(declared)) return declared;
157
+ }
158
+ };
159
+ /**
160
+ * Prefer the constraint the app declared over the version resolved from `node_modules`.
161
+ *
162
+ * The resolved version is whatever the install happened to hoist, so an app declaring `zod: ^4.3.6`
163
+ * next to a hoisted `zod@3.25.76` gets the hoisted version written into the output manifest and the
164
+ * isolated install then locks it in.
165
+ */
166
+ const applySourceDependencyRange = (dependencyName, dependencyInfo, constraints) => {
167
+ const declared = findDeclaredConstraint(constraints, dependencyName);
168
+ if (!declared) return dependencyInfo;
169
+ if (declared.startsWith(NPM_ALIAS_PREFIX)) return {
170
+ ...dependencyInfo,
171
+ packageSpec: declared
172
+ };
173
+ if (dependencyInfo.packageSpec) return dependencyInfo;
174
+ return {
175
+ ...dependencyInfo,
176
+ version: declared
177
+ };
178
+ };
179
+ async function toolIdForEntry(relativeEntryFile) {
180
+ const digest = Buffer.from(await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(relativeEntryFile))).toString("hex");
181
+ return `${digest.slice(0, 8)}-${digest.slice(8, 12)}-${digest.slice(12, 16)}-${digest.slice(16, 20)}-${digest.slice(20, 32)}`;
182
+ }
183
+ var Bundler = class extends MastraBase {
184
+ analyzeOutputDir = ".build";
185
+ outputDir = "output";
186
+ platform = "node";
187
+ defaultExternalsPreset = false;
188
+ constructor(name, component = "BUNDLER") {
189
+ super({
190
+ name,
191
+ component
192
+ });
193
+ }
194
+ async loadEnvVars() {
195
+ return loadEnvVars(await this.getEnvFiles());
196
+ }
197
+ async prepare(outputDirectory) {
198
+ await emptyDir(outputDirectory);
199
+ await ensureDir(join(outputDirectory, this.analyzeOutputDir));
200
+ await ensureDir(join(outputDirectory, this.outputDir));
201
+ }
202
+ async writePackageJson(outputDirectory, dependencies, resolutions) {
203
+ this.logger.debug("Writing project's package.json");
204
+ await ensureDir(outputDirectory);
205
+ const pkgPath = join(outputDirectory, "package.json");
206
+ const dependenciesMap = /* @__PURE__ */ new Map();
207
+ for (const [key, value] of dependencies.entries()) {
208
+ const dependencyValue = typeof value === "string" ? value : value.packageSpec ?? value.version ?? "latest";
209
+ if (key.startsWith("@")) {
210
+ const pkgChunks = key.split("/");
211
+ dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);
212
+ } else {
213
+ const pkgName = key.split("/")[0] || key;
214
+ dependenciesMap.set(pkgName, dependencyValue);
215
+ }
216
+ }
217
+ await writeFile(pkgPath, JSON.stringify({
218
+ name: "server",
219
+ version: "1.0.0",
220
+ private: true,
221
+ type: "module",
222
+ main: "index.mjs",
223
+ scripts: { start: "node ./index.mjs" },
224
+ dependencies: Object.fromEntries(dependenciesMap.entries()),
225
+ ...Object.keys(resolutions ?? {}).length > 0 && { resolutions }
226
+ }, null, 2));
227
+ }
228
+ createBundler(inputOptions, outputOptions) {
229
+ return createBundler(inputOptions, outputOptions);
230
+ }
231
+ async getUserBundlerOptions(mastraEntryFile, outputDirectory) {
232
+ const defaultBundlerOptions = {
233
+ externals: [],
234
+ sourcemap: false,
235
+ transpilePackages: [],
236
+ [IS_DEFAULT]: true
237
+ };
238
+ try {
239
+ return await getBundlerOptions(mastraEntryFile, outputDirectory) ?? defaultBundlerOptions;
240
+ } catch (error) {
241
+ this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
242
+ }
243
+ return defaultBundlerOptions;
244
+ }
245
+ async analyze(entry, mastraFile, outputDirectory) {
246
+ return await analyzeBundle([].concat(entry), mastraFile, {
247
+ outputDir: join(outputDirectory, this.analyzeOutputDir),
248
+ projectRoot: outputDirectory,
249
+ platform: this.platform
250
+ }, this.logger);
251
+ }
252
+ pnpmNodeLinker;
253
+ getAdditionalEntries() {
254
+ return {};
255
+ }
256
+ async installDependencies(outputDirectory, rootDir = process.cwd(), pnpmOverrides, pnpmWorkspaceSettings) {
257
+ const deps = new DepsService(rootDir);
258
+ deps.__setLogger(this.logger);
259
+ const installOptions = {
260
+ dir: join(outputDirectory, this.outputDir),
261
+ pnpmOverrides,
262
+ pnpmNodeLinker: this.pnpmNodeLinker,
263
+ pnpmWorkspaceSettings
264
+ };
265
+ this.logger.info("Updating dependency lockfile and installing dependencies");
266
+ await deps.install(installOptions);
267
+ this.logger.info("Done updating dependency lockfile and installing dependencies");
268
+ }
269
+ async copyPublic(mastraDir, outputDirectory) {
270
+ const publicDir = join(mastraDir, "public");
271
+ try {
272
+ await stat(publicDir);
273
+ } catch {
274
+ return;
275
+ }
276
+ await copy(publicDir, join(outputDirectory, this.outputDir));
277
+ }
278
+ async copyDOTNPMRC({ rootDir = process.cwd(), outputDirectory }) {
279
+ const sourceDotNpmRcPath = join(rootDir, ".npmrc");
280
+ const targetDotNpmRcPath = join(outputDirectory, this.outputDir, ".npmrc");
281
+ try {
282
+ await stat(sourceDotNpmRcPath);
283
+ await copy(sourceDotNpmRcPath, targetDotNpmRcPath);
284
+ } catch {}
285
+ }
286
+ /**
287
+ * Writes the `mastra-project.json` deployment marker for Software Factory
288
+ * projects after public assets have been copied. Verifies that the Factory
289
+ * SPA (`factory/index.html`) exists in the output before emitting the marker.
290
+ */
291
+ async writeFactoryMarker(outputDirectory) {
292
+ const outputDir = join(outputDirectory, this.outputDir);
293
+ const factoryIndex = join(outputDir, "factory", "index.html");
294
+ if (!existsSync(factoryIndex)) throw new MastraError({
295
+ id: "DEPLOYER_BUNDLER_FACTORY_UI_MISSING",
296
+ text: "Software Factory project detected but factory/index.html was not found after copying the prebuilt Factory UI.",
297
+ domain: ErrorDomain.DEPLOYER,
298
+ category: ErrorCategory.SYSTEM
299
+ });
300
+ await writeFile(join(outputDir, "mastra-project.json"), JSON.stringify({
301
+ schemaVersion: 1,
302
+ projectType: "factory",
303
+ assets: { ui: "factory" }
304
+ }, null, 2));
305
+ this.logger.info("Wrote mastra-project.json for Software Factory project");
306
+ }
307
+ async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, { enableSourcemap, enableMinify, enableEsmShim, externals, externalsPreset, alias }, additionalEntries, projectRoot) {
308
+ const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });
309
+ const inputOptions = await getInputOptions(mastraEntryFile, analyzedBundleInfo, this.platform, { "process.env.NODE_ENV": JSON.stringify("production") }, {
310
+ sourcemap: enableSourcemap,
311
+ minify: enableMinify,
312
+ workspaceRoot,
313
+ projectRoot,
314
+ enableEsmShim,
315
+ externalsPreset: externals === true || !!externalsPreset,
316
+ explicitExternals: Array.isArray(externals) ? externals : [],
317
+ alias
318
+ });
319
+ const toolsInputOptions = await this.listToolsInputOptions(toolsPaths, projectRoot);
320
+ const entryInputs = {};
321
+ const virtualEntries = {};
322
+ const entries = {
323
+ index: serverFile,
324
+ ...additionalEntries
325
+ };
326
+ for (const [name, entry] of Object.entries(entries)) if (entry.includes("\n") || !existsSync(entry)) {
327
+ const virtualId = name === "index" ? "#entry" : `#entry-${name}`;
328
+ entryInputs[name] = virtualId;
329
+ virtualEntries[virtualId] = entry;
330
+ } else entryInputs[name] = entry;
331
+ inputOptions.input = {
332
+ ...entryInputs,
333
+ ...toolsInputOptions
334
+ };
335
+ if (Object.keys(virtualEntries).length > 0) {
336
+ if (Array.isArray(inputOptions.plugins)) inputOptions.plugins.unshift(virtual(virtualEntries));
337
+ else inputOptions.plugins = [virtual(virtualEntries)];
338
+ }
339
+ return inputOptions;
340
+ }
341
+ getAllToolPaths(mastraDir, toolsPaths = []) {
342
+ const normalizedMastraDir = slash(mastraDir);
343
+ const defaultPaths = [posix.join(normalizedMastraDir, "tools/**/*.{js,ts}"), ...[`!${posix.join(normalizedMastraDir, "tools/**/*.{test,spec}.{js,ts}")}`, `!${posix.join(normalizedMastraDir, "tools/**/__tests__/**")}`]];
344
+ if (toolsPaths.length === 0) return [defaultPaths];
345
+ return [...toolsPaths, defaultPaths];
346
+ }
347
+ async listToolsInputOptions(toolsPaths, projectRoot = process.cwd()) {
348
+ const entries = /* @__PURE__ */ new Map();
349
+ for (const toolPath of toolsPaths) {
350
+ const expandedPaths = await glob(toolPath, {
351
+ absolute: true,
352
+ expandDirectories: false
353
+ });
354
+ for (const path of expandedPaths) if (await fsExtra.pathExists(path)) {
355
+ const entryFile = new FileService().getFirstExistingFile([
356
+ join(path, "index.ts"),
357
+ join(path, "index.js"),
358
+ path
359
+ ]);
360
+ if (!entryFile || (await stat(entryFile)).isDirectory()) {
361
+ this.logger.warn("No entry file found, skipping", { path });
362
+ continue;
363
+ }
364
+ const normalizedEntryFile = entryFile.replaceAll("\\", "/");
365
+ const relativeEntryFile = relative(projectRoot, entryFile).replaceAll("\\", "/");
366
+ entries.set(relativeEntryFile, normalizedEntryFile);
367
+ } else this.logger.warn("Tool path does not exist, skipping", { path });
368
+ }
369
+ return Object.fromEntries(await Promise.all([...entries.entries()].sort(([first], [second]) => first < second ? -1 : first > second ? 1 : 0).map(async ([relativeEntryFile, entryFile]) => [`tools/${await toolIdForEntry(relativeEntryFile)}`, entryFile])));
370
+ }
371
+ async _bundle(serverFile, mastraEntryFile, { projectRoot, outputDirectory, enableEsmShim = true, alias = {} }, toolsPaths = [], bundleLocation = join(outputDirectory, this.outputDir)) {
372
+ const analyzeDir = join(outputDirectory, this.analyzeOutputDir);
373
+ const additionalEntries = this.getAdditionalEntries();
374
+ const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });
375
+ const entryProjectRoot = closestPkgJson ? dirname(closestPkgJson) : projectRoot;
376
+ const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);
377
+ const resolvedAlias = Object.fromEntries(Object.entries(alias).map(([specifier, target]) => [specifier, target.startsWith(".") ? resolve(projectRoot, target) : target]));
378
+ const internalBundlerOptions = {
379
+ enableSourcemap: !!bundlerOptions.sourcemap,
380
+ enableMinify: !!bundlerOptions.minify,
381
+ externals: bundlerOptions.externals ?? [],
382
+ externalsPreset: this.defaultExternalsPreset && bundlerOptions.externals !== false,
383
+ enableEsmShim,
384
+ alias: resolvedAlias,
385
+ dynamicPackages: bundlerOptions.dynamicPackages
386
+ };
387
+ let analyzedBundleInfo;
388
+ try {
389
+ const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths, entryProjectRoot);
390
+ analyzedBundleInfo = await analyzeBundle([
391
+ serverFile,
392
+ ...Object.values(additionalEntries),
393
+ ...Object.values(resolvedToolsPaths)
394
+ ], mastraEntryFile, {
395
+ outputDir: analyzeDir,
396
+ projectRoot: entryProjectRoot,
397
+ platform: this.platform,
398
+ bundlerOptions: internalBundlerOptions
399
+ }, this.logger);
400
+ } catch (error) {
401
+ const message = error instanceof Error ? error.message : String(error);
402
+ if (error instanceof MastraError) throw error;
403
+ throw new MastraError({
404
+ id: "DEPLOYER_BUNDLER_ANALYZE_FAILED",
405
+ text: `Failed to analyze Mastra application: ${message}`,
406
+ domain: ErrorDomain.DEPLOYER,
407
+ category: ErrorCategory.SYSTEM
408
+ }, error);
409
+ }
410
+ const { workspaceRoot } = await getWorkspaceInformation({
411
+ dir: projectRoot,
412
+ mastraEntryFile
413
+ });
414
+ const sourceDependencyConstraints = await getSourceDependencyConstraints({
415
+ projectRoot: entryProjectRoot,
416
+ mastraEntryFile,
417
+ workspaceRoot
418
+ });
419
+ const dependenciesToInstall = /* @__PURE__ */ new Map();
420
+ for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {
421
+ if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) continue;
422
+ dependenciesToInstall.set(dep, applySourceDependencyRange(dep, depInfo, sourceDependencyConstraints));
423
+ }
424
+ const initialWorkspaceDependencies = /* @__PURE__ */ new Set();
425
+ for (const dep of [...analyzedBundleInfo.dependencies.keys(), ...analyzedBundleInfo.externalDependencies.keys()]) {
426
+ const pkgName = getPackageName(dep);
427
+ if (pkgName && analyzedBundleInfo.workspaceMap.has(pkgName)) initialWorkspaceDependencies.add(pkgName);
428
+ }
429
+ const transitiveWorkspaceDependencies = await collectTransitiveWorkspaceDependencies({
430
+ workspaceMap: analyzedBundleInfo.workspaceMap,
431
+ initialDependencies: initialWorkspaceDependencies,
432
+ logger: this.logger
433
+ });
434
+ for (const [dep, packageSpec] of Object.entries(transitiveWorkspaceDependencies.resolutions)) dependenciesToInstall.set(dep, {
435
+ version: analyzedBundleInfo.workspaceMap.get(dep)?.version,
436
+ packageSpec
437
+ });
438
+ try {
439
+ await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall, transitiveWorkspaceDependencies.resolutions);
440
+ if (transitiveWorkspaceDependencies.usedWorkspacePackages.size > 0) await packWorkspaceDependencies({
441
+ workspaceMap: analyzedBundleInfo.workspaceMap,
442
+ usedWorkspacePackages: transitiveWorkspaceDependencies.usedWorkspacePackages,
443
+ bundleOutputDir: join(outputDirectory, this.outputDir),
444
+ logger: this.logger
445
+ });
446
+ this.logger.info("Bundling Mastra application");
447
+ const inputOptions = await this.getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, internalBundlerOptions, additionalEntries, entryProjectRoot);
448
+ const unresolvedWorkspaceImports = [];
449
+ await (await this.createBundler({
450
+ ...inputOptions,
451
+ logLevel: inputOptions.logLevel === "silent" ? "warn" : inputOptions.logLevel,
452
+ onwarn: (warning) => {
453
+ const unresolvedWorkspaceDep = getUnresolvedWorkspaceImport(warning, analyzedBundleInfo.workspaceMap);
454
+ if (unresolvedWorkspaceDep) unresolvedWorkspaceImports.push({ source: unresolvedWorkspaceDep });
455
+ if (warning.code === "CIRCULAR_DEPENDENCY") {
456
+ if (warning.ids?.[0]?.includes("node_modules")) return;
457
+ this.logger.warn("Circular dependency found", { dependency: warning.message.replace("Circular dependency: ", "") });
458
+ }
459
+ }
460
+ }, {
461
+ dir: bundleLocation,
462
+ manualChunks: { mastra: ["#mastra"] },
463
+ sourcemap: internalBundlerOptions.enableSourcemap
464
+ })).write();
465
+ if (unresolvedWorkspaceImports.length > 0) {
466
+ const importList = unresolvedWorkspaceImports.map((i) => ` - ${i.source}`).join("\n");
467
+ throw new MastraError({
468
+ id: "DEPLOYER_BUNDLER_UNRESOLVED_WORKSPACE_IMPORT",
469
+ text: `Workspace imports could not be resolved during bundling:\n${importList}\n\nThis means the analyzer did not capture these workspace subpath imports during the analysis phase. Try adding the package as a direct dependency of the app, or check the workspace configuration.`,
470
+ domain: ErrorDomain.DEPLOYER,
471
+ category: ErrorCategory.SYSTEM
472
+ });
473
+ }
474
+ const toolImports = [];
475
+ const toolsExports = [];
476
+ Array.from(Object.keys(inputOptions.input || {})).filter((key) => key.startsWith("tools/")).forEach((key, index) => {
477
+ const toolExport = `tool${index}`;
478
+ toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);
479
+ toolsExports.push(toolExport);
480
+ });
481
+ await writeFile(join(bundleLocation, "tools.mjs"), `${toolImports.join("\n")}
482
+
483
+ export const tools = [${toolsExports.join(", ")}]`);
484
+ this.logger.info("Bundling Mastra done");
485
+ this.logger.info("Copying public files");
486
+ await this.copyPublic(dirname(mastraEntryFile), outputDirectory);
487
+ this.logger.info("Done copying public files");
488
+ if (analyzedBundleInfo.projectType === "factory") await this.writeFactoryMarker(outputDirectory);
489
+ this.logger.info("Copying .npmrc file");
490
+ await this.copyDOTNPMRC({
491
+ outputDirectory,
492
+ rootDir: projectRoot
493
+ });
494
+ this.logger.info("Done copying .npmrc file");
495
+ if (shouldSkipInstall()) this.logger.info("Skipping dependency installation (MASTRA_BUILD_SKIP_INSTALL set)");
496
+ else await this.installDependencies(outputDirectory, projectRoot, transitiveWorkspaceDependencies.resolutions, bundlerOptions.pnpmWorkspaceSettings);
497
+ } catch (error) {
498
+ if (error instanceof MastraError && (error.id === "DEPLOYER_BUNDLER_FACTORY_UI_MISSING" || error.id === "DEPLOYER_PNPM_IGNORED_BUILDS")) throw error;
499
+ const message = error instanceof Error ? error.message : String(error);
500
+ throw new MastraError({
501
+ id: "DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED",
502
+ text: `Failed during bundler bundle stage: ${message}`,
503
+ domain: ErrorDomain.DEPLOYER,
504
+ category: ErrorCategory.SYSTEM
505
+ }, error);
506
+ }
507
+ }
508
+ async lint(_entryFile, outputDirectory, toolsPaths) {
509
+ const toolsInputOptions = await this.listToolsInputOptions(toolsPaths, dirname(outputDirectory));
510
+ const toolsLength = Object.keys(toolsInputOptions).length;
511
+ if (toolsLength > 0) this.logger.info("Found tools", { count: toolsLength });
512
+ }
513
+ };
514
+ export { isRegistryVersionSpec as a, getSourceDependencyConstraints as i, IS_DEFAULT as n, applySourceDependencyRange as r, Bundler as t };
515
+
516
+ //# sourceMappingURL=bundler-CNgW1Vui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundler-CNgW1Vui.js","names":["createBundlerUtil"],"sources":["../../_internals/deployer/dist/index.js","../src/bundler/index.ts"],"sourcesContent":["import { readFile } from \"fs/promises\";\nimport { parse } from \"dotenv\";\n// src/bundler.ts\n/**\n* Reads dotenv files in order into one map; values from later files override earlier ones.\n*/\nasync function loadEnvVars(files) {\n\tconst envVars = /* @__PURE__ */ new Map();\n\tfor (const file of files) {\n\t\tconst content = await readFile(file, \"utf-8\");\n\t\tconst config = parse(content);\n\t\tObject.entries(config).forEach(([key, value]) => {\n\t\t\tenvVars.set(key, value);\n\t\t});\n\t}\n\treturn envVars;\n}\nexport { loadEnvVars };\n\n//# sourceMappingURL=index.js.map","import { existsSync } from 'node:fs';\nimport { readFile, stat, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix, relative, resolve } from 'node:path';\nimport { MastraBase } from '@internal/core/base';\nimport { MastraError, ErrorDomain, ErrorCategory } from '@internal/core/error';\nimport { loadEnvVars } from '@internal/deployer';\nimport type { BundlerConfig, IBundler } from '@internal/deployer';\nimport virtual from '@rollup/plugin-virtual';\nimport * as pkg from 'empathic/package';\nimport fsExtra, { copy, ensureDir, emptyDir, readJSON } from 'fs-extra/esm';\nimport type { InputOptions, OutputOptions } from 'rollup';\nimport { glob } from 'tinyglobby';\nimport { analyzeBundle } from '../build/analyze';\nimport { createBundler as createBundlerUtil, getInputOptions, getUnresolvedWorkspaceImport } from '../build/bundler';\nimport { getBundlerOptions } from '../build/bundlerOptions';\nimport type { ExternalDependencyInfo, InternalBundlerOptions } from '../build/types';\nimport type { BundlerPlatform } from '../build/utils';\nimport { getPackageName, isBareModuleSpecifier, shouldSkipInstall, slash } from '../build/utils';\nimport { DepsService } from '../services/deps';\nimport { FileService } from '../services/fs';\nimport {\n collectTransitiveWorkspaceDependencies,\n getWorkspaceInformation,\n packWorkspaceDependencies,\n} from './workspaceDependencies';\n\nexport type { BundlerOptions, ExternalDependencyInfo } from '../build/types';\nexport type { BundlerPlatform } from '../build/utils';\n\nexport const IS_DEFAULT = Symbol('IS_DEFAULT');\n\nconst NPM_ALIAS_PREFIX = 'npm:';\n/** Characters a registry range or dist tag can contain. Protocols need `:`, git shorthand needs `/` or `#`. */\nconst REGISTRY_SPEC_PATTERN = /^[A-Za-z0-9.+_^~><=*|!\\s-]+$/;\nconst PACKAGE_NAME_PATTERN = /^(?:@[A-Za-z0-9._-]+\\/)?[A-Za-z0-9._-]+$/;\nconst TARBALL_SUFFIX_PATTERN = /\\.(?:tgz|tar\\.gz|tar)$/i;\n/** npm reads a value starting like this as a path, whatever follows. A bare `~` is a semver range. */\nconst FILE_SPEC_PREFIX_PATTERN = /^(?:\\.|~[/\\\\]|[/\\\\]|[A-Za-z]:[/\\\\])/;\n/** A range admitting any published version: `*`, `x`, `>=0`, and any union containing one. */\nconst UNBOUNDED_RANGE_PATTERN = /(?:^|\\|\\||\\s)\\s*(?:[*xX]|>=?\\s*0(?:\\.0)*(?:\\.0)*)\\s*(?:$|\\|\\|)/;\n\n/**\n * Constraints declared by the source app, plus the packages some resolution field pins.\n *\n * Only `dependencies` values are read. Override fields contribute names, never values: which of\n * `overrides`, `resolutions`, `pnpm.overrides` or `pnpm-workspace.yaml` a given install honoured\n * depends on the package manager and its version, so reproducing that precedence would mean\n * emulating three package managers. A name appearing in any of them is enough to know the resolved\n * version was chosen deliberately, which is all this needs.\n */\nexport type SourceDependencyConstraints = {\n dependencies: Record<string, string>;\n pinnedByResolutionField: Set<string>;\n};\n\nconst toStringRecord = (value: unknown): Record<string, string> => {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(value).filter((entry): entry is [string, string] => typeof entry[1] === 'string'),\n );\n};\n\n/**\n * True when a specifier is something the isolated install in `.mastra/output` can resolve from the\n * registry: a semver range, a dist tag, a wildcard, or an npm alias whose target is a registry\n * package and range.\n *\n * This is an allowlist rather than a denylist of known protocols, so an unfamiliar protocol is\n * rejected without this code having to know it exists. The output directory is not a workspace, has\n * no catalog definitions and has a different relative-path base, so `catalog:`, `workspace:`,\n * `file:`, `link:` and git specifiers are all either uninstallable there or point somewhere else.\n */\nexport const isRegistryVersionSpec = (spec: string): boolean => {\n if (FILE_SPEC_PREFIX_PATTERN.test(spec) || TARBALL_SUFFIX_PATTERN.test(spec)) {\n return false;\n }\n\n if (spec.startsWith(NPM_ALIAS_PREFIX)) {\n const alias = spec.slice(NPM_ALIAS_PREFIX.length);\n // Skip index 0 so `npm:@scope/pkg` reads as an alias with no range rather than an empty name.\n const rangeSeparator = alias.lastIndexOf('@');\n const name = rangeSeparator > 0 ? alias.slice(0, rangeSeparator) : alias;\n const range = rangeSeparator > 0 ? alias.slice(rangeSeparator + 1) : '*';\n\n return PACKAGE_NAME_PATTERN.test(name) && isRegistryVersionSpec(range);\n }\n\n return REGISTRY_SPEC_PATTERN.test(spec);\n};\n\n/**\n * True when a specifier names a version the output install can be held to.\n *\n * A range admitting anything (`*`, `latest`, `>=0`, an alias with no range) is looser than the\n * version already resolved, so writing it would let a later install pull something the bundle was\n * never analyzed against.\n */\nconst isBoundedVersionSpec = (spec: string): boolean => {\n const range = spec.startsWith(NPM_ALIAS_PREFIX)\n ? (() => {\n const alias = spec.slice(NPM_ALIAS_PREFIX.length);\n const rangeSeparator = alias.lastIndexOf('@');\n return rangeSeparator > 0 ? alias.slice(rangeSeparator + 1) : '';\n })()\n : spec;\n\n return /\\d/.test(range) && !UNBOUNDED_RANGE_PATTERN.test(range);\n};\n\nconst readManifest = async (manifestPath: string | undefined): Promise<Record<string, unknown> | undefined> => {\n if (!manifestPath) {\n return undefined;\n }\n\n try {\n const manifest = await readJSON(manifestPath);\n return manifest && typeof manifest === 'object' ? manifest : undefined;\n } catch {\n // A manifest that cannot be read tells us nothing about intent.\n return undefined;\n }\n};\n\n/** Collect the package names a manifest's resolution fields pin, ignoring their values. */\nconst collectManifestPinnedNames = (manifest: Record<string, unknown> | undefined, pinned: Set<string>) => {\n const pnpmSection = manifest?.pnpm;\n const records = [\n manifest?.overrides,\n manifest?.resolutions,\n pnpmSection && typeof pnpmSection === 'object' ? (pnpmSection as { overrides?: unknown }).overrides : undefined,\n ];\n\n for (const record of records) {\n if (record && typeof record === 'object' && !Array.isArray(record)) {\n for (const key of Object.keys(record)) {\n pinned.add(key);\n }\n }\n }\n};\n\n/**\n * Collect the names under a top-level `overrides:` block in `pnpm-workspace.yaml`.\n *\n * pnpm moved overrides out of `package.json` into this file, so a workspace on a current pnpm keeps\n * them only here. Reading names off the indented block avoids a YAML dependency, the same tradeoff\n * `copyPnpmWorkspaceSettings` already makes for the top-level keys it copies.\n */\nconst collectPnpmWorkspacePinnedNames = (source: string, pinned: Set<string>) => {\n const lines = source.split(/\\r?\\n/);\n let insideOverrides = false;\n\n for (const line of lines) {\n if (/^\\S/.test(line)) {\n insideOverrides = /^overrides:\\s*$/.test(line);\n continue;\n }\n\n if (!insideOverrides) {\n continue;\n }\n\n const key = /^\\s+(?:'([^']+)'|\"([^\"]+)\"|([^'\"\\s:][^:]*?))\\s*:/.exec(line);\n if (key) {\n pinned.add((key[1] ?? key[2] ?? key[3] ?? '').trim());\n }\n }\n};\n\n/**\n * Read the constraints the source app declared.\n *\n * `dependencies` come from the manifest at `projectRoot`, the package the build was invoked for and\n * whose directory receives the output, falling back to the manifest above the entry file. Anchoring\n * on `projectRoot` rather than the entry file keeps the answer deterministic when the entry handed\n * to the bundler is a generated wrapper rather than the app's own source file.\n *\n * Resolution-field names are collected from both that manifest and the workspace root, including the\n * root `pnpm-workspace.yaml`, because a name pinned anywhere means the resolved version may have been\n * chosen deliberately rather than hoisted by accident.\n */\nexport const getSourceDependencyConstraints = async ({\n projectRoot,\n mastraEntryFile,\n workspaceRoot,\n}: {\n projectRoot: string;\n mastraEntryFile: string;\n workspaceRoot?: string;\n}): Promise<SourceDependencyConstraints> => {\n const manifestPaths = [pkg.up({ cwd: projectRoot }), pkg.up({ cwd: dirname(mastraEntryFile) })].filter(\n (entry, index, entries): entry is string => !!entry && entries.indexOf(entry) === index,\n );\n\n if (workspaceRoot) {\n manifestPaths.push(join(workspaceRoot, 'package.json'));\n }\n\n const pinnedByResolutionField = new Set<string>();\n let dependencies: Record<string, string> | undefined;\n\n for (const manifestPath of manifestPaths) {\n const manifest = await readManifest(manifestPath);\n if (!manifest) {\n continue;\n }\n\n // Nearest manifest wins, and an empty `dependencies` record is still that package's answer.\n dependencies ??= toStringRecord(manifest.dependencies);\n collectManifestPinnedNames(manifest, pinnedByResolutionField);\n }\n\n if (workspaceRoot) {\n try {\n collectPnpmWorkspacePinnedNames(\n await readFile(join(workspaceRoot, 'pnpm-workspace.yaml'), 'utf-8'),\n pinnedByResolutionField,\n );\n } catch {\n // No pnpm workspace config, or unreadable: nothing to learn from it.\n }\n }\n\n return { dependencies: dependencies ?? {}, pinnedByResolutionField };\n};\n\nconst findDeclaredConstraint = (\n constraints: SourceDependencyConstraints,\n dependencyName: string,\n): string | undefined => {\n const names = [dependencyName, getPackageName(dependencyName)].filter(\n (name, index, all): name is string => !!name && all.indexOf(name) === index,\n );\n\n for (const name of names) {\n // A pinned package's resolved version is the deliberate answer, so leave it as `main` wrote it.\n if (constraints.pinnedByResolutionField.has(name)) {\n return undefined;\n }\n }\n\n for (const name of names) {\n const declared = (constraints.dependencies[name] ?? '').trim();\n if (declared && isBoundedVersionSpec(declared) && isRegistryVersionSpec(declared)) {\n return declared;\n }\n }\n\n return undefined;\n};\n\n/**\n * Prefer the constraint the app declared over the version resolved from `node_modules`.\n *\n * The resolved version is whatever the install happened to hoist, so an app declaring `zod: ^4.3.6`\n * next to a hoisted `zod@3.25.76` gets the hoisted version written into the output manifest and the\n * isolated install then locks it in.\n */\nexport const applySourceDependencyRange = (\n dependencyName: string,\n dependencyInfo: ExternalDependencyInfo,\n constraints: SourceDependencyConstraints,\n): ExternalDependencyInfo => {\n const declared = findDeclaredConstraint(constraints, dependencyName);\n if (!declared) {\n return dependencyInfo;\n }\n\n if (declared.startsWith(NPM_ALIAS_PREFIX)) {\n return { ...dependencyInfo, packageSpec: declared };\n }\n\n // `packageSpec` is set only when the resolved package's own name differs from the requested one, so\n // a bare range under this key describes a different package and the resolved alias is the answer.\n if (dependencyInfo.packageSpec) {\n return dependencyInfo;\n }\n\n return { ...dependencyInfo, version: declared };\n};\n\nasync function toolIdForEntry(relativeEntryFile: string): Promise<string> {\n const digest = Buffer.from(\n await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(relativeEntryFile)),\n ).toString('hex');\n return `${digest.slice(0, 8)}-${digest.slice(8, 12)}-${digest.slice(12, 16)}-${digest.slice(16, 20)}-${digest.slice(20, 32)}`;\n}\n\nexport abstract class Bundler extends MastraBase implements IBundler {\n protected analyzeOutputDir = '.build';\n protected outputDir = 'output';\n protected platform: BundlerPlatform = 'node';\n protected defaultExternalsPreset = false;\n\n constructor(name: string, component: 'BUNDLER' | 'DEPLOYER' = 'BUNDLER') {\n super({ name, component });\n }\n\n async loadEnvVars(): Promise<Map<string, string>> {\n return loadEnvVars(await this.getEnvFiles());\n }\n\n abstract getEnvFiles(): Promise<string[]>;\n abstract bundle(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void>;\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 | ExternalDependencyInfo>,\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 const dependencyValue = typeof value === 'string' ? value : (value.packageSpec ?? value.version ?? 'latest');\n if (key.startsWith('@')) {\n // Handle scoped packages (e.g. @org/package)\n const pkgChunks = key.split('/');\n dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, dependencyValue);\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, dependencyValue);\n }\n }\n\n await writeFile(\n pkgPath,\n JSON.stringify(\n {\n name: 'server',\n version: '1.0.0',\n private: true,\n type: 'module',\n main: 'index.mjs',\n scripts: {\n start: 'node ./index.mjs',\n },\n dependencies: Object.fromEntries(dependenciesMap.entries()),\n ...(Object.keys(resolutions ?? {}).length > 0 && { resolutions }),\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 getUserBundlerOptions(mastraEntryFile: string, outputDirectory: string): Promise<BundlerConfig> {\n const defaultBundlerOptions: BundlerConfig = {\n externals: [],\n sourcemap: false,\n transpilePackages: [],\n [IS_DEFAULT]: true,\n } as const;\n\n try {\n const bundlerOptions = await getBundlerOptions(mastraEntryFile, outputDirectory);\n\n return bundlerOptions ?? defaultBundlerOptions;\n } catch (error) {\n this.logger.debug('Failed to get bundler options, sourcemap will be disabled', { error });\n }\n\n return defaultBundlerOptions;\n }\n\n protected async analyze(entry: string | string[], mastraFile: string, outputDirectory: string) {\n return await analyzeBundle(\n ([] as string[]).concat(entry),\n mastraFile,\n {\n outputDir: join(outputDirectory, this.analyzeOutputDir),\n projectRoot: outputDirectory,\n platform: this.platform,\n },\n this.logger,\n );\n }\n\n protected pnpmNodeLinker?: 'hoisted';\n\n protected getAdditionalEntries(): Record<string, string> {\n return {};\n }\n\n protected async installDependencies(\n outputDirectory: string,\n rootDir = process.cwd(),\n pnpmOverrides?: Record<string, string>,\n pnpmWorkspaceSettings?: BundlerConfig['pnpmWorkspaceSettings'],\n ) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n const installOptions = {\n dir: join(outputDirectory, this.outputDir),\n pnpmOverrides,\n pnpmNodeLinker: this.pnpmNodeLinker,\n pnpmWorkspaceSettings,\n };\n\n this.logger.info('Updating dependency lockfile and installing dependencies');\n await deps.install(installOptions);\n this.logger.info('Done updating dependency lockfile and installing dependencies');\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 }\n\n /**\n * Writes the `mastra-project.json` deployment marker for Software Factory\n * projects after public assets have been copied. Verifies that the Factory\n * SPA (`factory/index.html`) exists in the output before emitting the marker.\n */\n protected async writeFactoryMarker(outputDirectory: string): Promise<void> {\n const outputDir = join(outputDirectory, this.outputDir);\n const factoryIndex = join(outputDir, 'factory', 'index.html');\n if (!existsSync(factoryIndex)) {\n throw new MastraError({\n id: 'DEPLOYER_BUNDLER_FACTORY_UI_MISSING',\n text: 'Software Factory project detected but factory/index.html was not found after copying the prebuilt Factory UI.',\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n });\n }\n await writeFile(\n join(outputDir, 'mastra-project.json'),\n JSON.stringify({ schemaVersion: 1, projectType: 'factory', assets: { ui: 'factory' } }, null, 2),\n );\n this.logger.info('Wrote mastra-project.json for Software Factory project');\n }\n\n protected async getBundlerOptions(\n serverFile: string,\n mastraEntryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n toolsPaths: (string | string[])[],\n { enableSourcemap, enableMinify, enableEsmShim, externals, externalsPreset, alias }: InternalBundlerOptions,\n additionalEntries: Record<string, string>,\n projectRoot: string,\n ) {\n const { workspaceRoot } = await getWorkspaceInformation({ mastraEntryFile });\n\n const inputOptions: InputOptions = await getInputOptions(\n mastraEntryFile,\n analyzedBundleInfo,\n this.platform,\n {\n 'process.env.NODE_ENV': JSON.stringify('production'),\n },\n {\n sourcemap: enableSourcemap,\n minify: enableMinify,\n workspaceRoot,\n projectRoot,\n enableEsmShim,\n externalsPreset: externals === true || !!externalsPreset,\n explicitExternals: Array.isArray(externals) ? externals : [],\n alias,\n },\n );\n const toolsInputOptions = await this.listToolsInputOptions(toolsPaths, projectRoot);\n const entryInputs: Record<string, string> = {};\n const virtualEntries: Record<string, string> = {};\n const entries = { index: serverFile, ...additionalEntries };\n\n for (const [name, entry] of Object.entries(entries)) {\n if (entry.includes('\\n') || !existsSync(entry)) {\n const virtualId = name === 'index' ? '#entry' : `#entry-${name}`;\n entryInputs[name] = virtualId;\n virtualEntries[virtualId] = entry;\n } else {\n entryInputs[name] = entry;\n }\n }\n\n inputOptions.input = { ...entryInputs, ...toolsInputOptions };\n\n if (Object.keys(virtualEntries).length > 0) {\n if (Array.isArray(inputOptions.plugins)) {\n inputOptions.plugins.unshift(virtual(virtualEntries));\n } else {\n inputOptions.plugins = [virtual(virtualEntries)];\n }\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[])[], projectRoot: string = process.cwd()) {\n const entries = new Map<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, skipping', { path });\n continue;\n }\n\n const normalizedEntryFile = entryFile.replaceAll('\\\\', '/');\n const relativeEntryFile = relative(projectRoot, entryFile).replaceAll('\\\\', '/');\n entries.set(relativeEntryFile, normalizedEntryFile);\n } else {\n this.logger.warn('Tool path does not exist, skipping', { path });\n }\n }\n }\n\n return Object.fromEntries(\n await Promise.all(\n [...entries.entries()]\n .sort(([first], [second]) => (first < second ? -1 : first > second ? 1 : 0))\n .map(\n async ([relativeEntryFile, entryFile]): Promise<[string, string]> => [\n `tools/${await toolIdForEntry(relativeEntryFile)}`,\n entryFile,\n ],\n ),\n ),\n );\n }\n\n protected async _bundle(\n serverFile: string,\n mastraEntryFile: string,\n {\n projectRoot,\n outputDirectory,\n enableEsmShim = true,\n alias = {},\n }: {\n projectRoot: string;\n outputDirectory: string;\n enableEsmShim?: boolean;\n alias?: Record<string, string>;\n },\n toolsPaths: (string | string[])[] = [],\n bundleLocation: string = join(outputDirectory, this.outputDir),\n ): Promise<void> {\n const analyzeDir = join(outputDirectory, this.analyzeOutputDir);\n const additionalEntries = this.getAdditionalEntries();\n const closestPkgJson = pkg.up({ cwd: dirname(mastraEntryFile) });\n const entryProjectRoot = closestPkgJson ? dirname(closestPkgJson) : projectRoot;\n\n const bundlerOptions = await this.getUserBundlerOptions(mastraEntryFile, outputDirectory);\n const resolvedAlias = Object.fromEntries(\n Object.entries(alias).map(([specifier, target]) => [\n specifier,\n target.startsWith('.') ? resolve(projectRoot, target) : target,\n ]),\n );\n const internalBundlerOptions: InternalBundlerOptions = {\n enableSourcemap: !!bundlerOptions.sourcemap,\n enableMinify: !!bundlerOptions.minify,\n externals: bundlerOptions.externals ?? [],\n externalsPreset: this.defaultExternalsPreset && bundlerOptions.externals !== false,\n enableEsmShim,\n alias: resolvedAlias,\n dynamicPackages: bundlerOptions.dynamicPackages,\n };\n\n let analyzedBundleInfo;\n try {\n const resolvedToolsPaths = await this.listToolsInputOptions(toolsPaths, entryProjectRoot);\n analyzedBundleInfo = await analyzeBundle(\n [serverFile, ...Object.values(additionalEntries), ...Object.values(resolvedToolsPaths)],\n mastraEntryFile,\n {\n outputDir: analyzeDir,\n projectRoot: entryProjectRoot,\n platform: this.platform,\n bundlerOptions: internalBundlerOptions,\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 { workspaceRoot } = await getWorkspaceInformation({ dir: projectRoot, mastraEntryFile });\n const sourceDependencyConstraints = await getSourceDependencyConstraints({\n projectRoot: entryProjectRoot,\n mastraEntryFile,\n workspaceRoot,\n });\n const dependenciesToInstall = new Map<string, ExternalDependencyInfo>();\n for (const [dep, depInfo] of analyzedBundleInfo.externalDependencies) {\n if (analyzedBundleInfo.workspaceMap.has(dep) || !isBareModuleSpecifier(dep)) {\n continue;\n }\n\n dependenciesToInstall.set(dep, applySourceDependencyRange(dep, depInfo, sourceDependencyConstraints));\n }\n\n const initialWorkspaceDependencies = new Set<string>();\n for (const dep of [...analyzedBundleInfo.dependencies.keys(), ...analyzedBundleInfo.externalDependencies.keys()]) {\n const pkgName = getPackageName(dep);\n if (pkgName && analyzedBundleInfo.workspaceMap.has(pkgName)) {\n initialWorkspaceDependencies.add(pkgName);\n }\n }\n\n const transitiveWorkspaceDependencies = await collectTransitiveWorkspaceDependencies({\n workspaceMap: analyzedBundleInfo.workspaceMap,\n initialDependencies: initialWorkspaceDependencies,\n logger: this.logger,\n });\n\n for (const [dep, packageSpec] of Object.entries(transitiveWorkspaceDependencies.resolutions)) {\n dependenciesToInstall.set(dep, {\n version: analyzedBundleInfo.workspaceMap.get(dep)?.version,\n packageSpec,\n });\n }\n\n try {\n await this.writePackageJson(\n join(outputDirectory, this.outputDir),\n dependenciesToInstall,\n transitiveWorkspaceDependencies.resolutions,\n );\n if (transitiveWorkspaceDependencies.usedWorkspacePackages.size > 0) {\n await packWorkspaceDependencies({\n workspaceMap: analyzedBundleInfo.workspaceMap,\n usedWorkspacePackages: transitiveWorkspaceDependencies.usedWorkspacePackages,\n bundleOutputDir: join(outputDirectory, this.outputDir),\n logger: this.logger,\n });\n }\n\n this.logger.info('Bundling Mastra application');\n\n const inputOptions: InputOptions = await this.getBundlerOptions(\n serverFile,\n mastraEntryFile,\n analyzedBundleInfo,\n toolsPaths,\n internalBundlerOptions,\n additionalEntries,\n entryProjectRoot,\n );\n\n const unresolvedWorkspaceImports: Array<{ source: string }> = [];\n\n const bundler = await this.createBundler(\n {\n ...inputOptions,\n logLevel: inputOptions.logLevel === 'silent' ? 'warn' : inputOptions.logLevel,\n onwarn: warning => {\n const unresolvedWorkspaceDep = getUnresolvedWorkspaceImport(\n warning as { code: string; source?: string; id?: string },\n analyzedBundleInfo.workspaceMap,\n );\n if (unresolvedWorkspaceDep) {\n unresolvedWorkspaceImports.push({ source: unresolvedWorkspaceDep });\n }\n\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 dependency: warning.message.replace('Circular dependency: ', ''),\n });\n }\n },\n },\n {\n dir: bundleLocation,\n manualChunks: {\n mastra: ['#mastra'],\n },\n sourcemap: internalBundlerOptions.enableSourcemap,\n },\n );\n\n await bundler.write();\n\n if (unresolvedWorkspaceImports.length > 0) {\n const importList = unresolvedWorkspaceImports.map(i => ` - ${i.source}`).join('\\n');\n throw new MastraError({\n id: 'DEPLOYER_BUNDLER_UNRESOLVED_WORKSPACE_IMPORT',\n text: `Workspace imports could not be resolved during bundling:\\n${importList}\\n\\nThis means the analyzer did not capture these workspace subpath imports during the analysis phase. Try adding the package as a direct dependency of the app, or check the workspace configuration.`,\n domain: ErrorDomain.DEPLOYER,\n category: ErrorCategory.SYSTEM,\n });\n }\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 // For Software Factory projects, write a deterministic deployment marker\n // after public assets (including the SPA) have been copied.\n if (analyzedBundleInfo.projectType === 'factory') {\n await this.writeFactoryMarker(outputDirectory);\n }\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 if (shouldSkipInstall()) {\n this.logger.info('Skipping dependency installation (MASTRA_BUILD_SKIP_INSTALL set)');\n } else {\n await this.installDependencies(\n outputDirectory,\n projectRoot,\n transitiveWorkspaceDependencies.resolutions,\n bundlerOptions.pnpmWorkspaceSettings,\n );\n }\n } catch (error) {\n if (\n error instanceof MastraError &&\n (error.id === 'DEPLOYER_BUNDLER_FACTORY_UI_MISSING' || error.id === 'DEPLOYER_PNPM_IGNORED_BUILDS')\n ) {\n throw error;\n }\n\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, dirname(outputDirectory));\n const toolsLength = Object.keys(toolsInputOptions).length;\n if (toolsLength > 0) {\n this.logger.info('Found tools', { count: toolsLength });\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,eAAe,YAAY,OAAO;CACjC,MAAM,0BAA0B,IAAI,IAAI;CACxC,KAAK,MAAM,QAAQ,OAAO;EACzB,MAAM,UAAU,MAAM,SAAS,MAAM,OAAO;EAC5C,MAAM,SAAS,MAAM,OAAO;EAC5B,OAAO,QAAQ,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,WAAW;GAChD,QAAQ,IA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B,UAAU,cAAc;GAC1B,GACA,KACF;EACF;CACF;CAEA,MAAM,KAAK,YAAoB,iBAAyB,YAAkD;EACxG,MAAM,oBAAoB,MAAM,KAAK,sBAAsB,YAAY,QAAQ,eAAe,CAAC;EAC/F,MAAM,cAAc,OAAO,KAAK,iBAAiB,CAAC,CAAC;EACnD,IAAI,cAAc,GAChB,KAAK,OAAO,KAAK,eAAe,EAAE,OAAO,YAAY,CAAC;CAE1D;AACF"}
@@ -1,9 +1,9 @@
1
+ import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "./error-BVvc5jcw.js";
1
2
  import { a as getPackageName, i as getNodeResolveOptions, l as isDependencyPartOfPackage, m as slash, s as isBareModuleSpecifier, u as isExternalProtocolImport } from "./utils-C8gwr-ur.js";
2
3
  import { builtinModules } from "module";
3
4
  import fs, { statSync } from "fs";
4
5
  import { readFile } from "fs/promises";
5
6
  import path, { dirname, isAbsolute, join, resolve, sep } from "path";
6
- import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
7
7
  import { readJSON, readJson } from "fs-extra/esm";
8
8
  import { transformAsync, types } from "@babel/core";
9
9
  import { fileURLToPath, pathToFileURL } from "url";
@@ -1017,4 +1017,4 @@ function getUnresolvedWorkspaceImport(warning, workspaceMap) {
1017
1017
  }
1018
1018
  export { mastraToolsAliasPlugin as a, removeDeployer as c, moduleAlias as d, getPackageInfo$1 as f, esbuild as g, esmShim as h, mastraInternalAliasPlugin as i, protocolExternalResolver as l, getPackageRootPath as m, getInputOptions as n, tsConfigPaths as o, getPackageMetadata as p, getUnresolvedWorkspaceImport as r, subpathExternalsResolver as s, createBundler as t, nodeModulesExtensionResolver as u };
1019
1019
 
1020
- //# sourceMappingURL=bundler-D3Ky7WCf.js.map
1020
+ //# sourceMappingURL=bundler-C_LpvgiH.js.map