@mastra/deployer 0.10.11 → 0.10.12-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.
@@ -79,7 +79,7 @@ export declare abstract class Bundler extends MastraBundler {
79
79
  protected outputDir: string;
80
80
  constructor(name: string, component?: 'BUNDLER' | 'DEPLOYER');
81
81
  prepare(outputDirectory: string): Promise<void>;
82
- writeInstrumentationFile(outputDirectory: string): Promise<void>;
82
+ writeInstrumentationFile(outputDirectory: string, customInstrumentationFile?: string): Promise<void>;
83
83
  writePackageJson(outputDirectory: string, dependencies: Map<string, string>, resolutions?: Record<string, string>): Promise<void>;
84
84
  protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & {
85
85
  dir: string;
@@ -267,6 +267,12 @@ declare class FileService {
267
267
  dbUrl: string;
268
268
  }): Promise<void>;
269
269
  getFirstExistingFile(files: string[]): string;
270
+ /**
271
+ * Returns the first existing file from the provided array, or undefined if none exist
272
+ * @param files array of file paths to check
273
+ * @returns the first existing file path or undefined
274
+ */
275
+ getFirstExistingFileOrUndefined(files: string[]): string | undefined;
270
276
  replaceValuesInFile({ filePath, replacements, }: {
271
277
  filePath: string;
272
278
  replacements: {
@@ -354,6 +360,10 @@ export declare function getBundlerOptionsBundler(entryFile: string, result: {
354
360
  hasCustomConfig: false;
355
361
  }): Promise<RollupBuild>;
356
362
 
363
+ export declare function getCustomInstrumentationBundler(entryFile: string, result: {
364
+ hasCustomConfig: false;
365
+ }): Promise<RollupBuild>;
366
+
357
367
  declare function getDeployer(entryFile: string, outputDir: string): Promise<MastraDeployer | undefined>;
358
368
  export { getDeployer }
359
369
  export { getDeployer as getDeployer_alias_1 }
@@ -811,6 +821,11 @@ declare type WorkspacePackageInfo = {
811
821
  version: string | undefined;
812
822
  };
813
823
 
824
+ export declare function writeCustomInstrumentation(entryFile: string, outputDir: string): Promise<{
825
+ hasCustomConfig: boolean;
826
+ externalDependencies: string[];
827
+ }>;
828
+
814
829
  declare function writeTelemetryConfig(entryFile: string, outputDir: string): Promise<{
815
830
  hasCustomConfig: boolean;
816
831
  externalDependencies: string[];
@@ -79,7 +79,7 @@ export declare abstract class Bundler extends MastraBundler {
79
79
  protected outputDir: string;
80
80
  constructor(name: string, component?: 'BUNDLER' | 'DEPLOYER');
81
81
  prepare(outputDirectory: string): Promise<void>;
82
- writeInstrumentationFile(outputDirectory: string): Promise<void>;
82
+ writeInstrumentationFile(outputDirectory: string, customInstrumentationFile?: string): Promise<void>;
83
83
  writePackageJson(outputDirectory: string, dependencies: Map<string, string>, resolutions?: Record<string, string>): Promise<void>;
84
84
  protected createBundler(inputOptions: InputOptions, outputOptions: Partial<OutputOptions> & {
85
85
  dir: string;
@@ -267,6 +267,12 @@ declare class FileService {
267
267
  dbUrl: string;
268
268
  }): Promise<void>;
269
269
  getFirstExistingFile(files: string[]): string;
270
+ /**
271
+ * Returns the first existing file from the provided array, or undefined if none exist
272
+ * @param files array of file paths to check
273
+ * @returns the first existing file path or undefined
274
+ */
275
+ getFirstExistingFileOrUndefined(files: string[]): string | undefined;
270
276
  replaceValuesInFile({ filePath, replacements, }: {
271
277
  filePath: string;
272
278
  replacements: {
@@ -354,6 +360,10 @@ export declare function getBundlerOptionsBundler(entryFile: string, result: {
354
360
  hasCustomConfig: false;
355
361
  }): Promise<RollupBuild>;
356
362
 
363
+ export declare function getCustomInstrumentationBundler(entryFile: string, result: {
364
+ hasCustomConfig: false;
365
+ }): Promise<RollupBuild>;
366
+
357
367
  declare function getDeployer(entryFile: string, outputDir: string): Promise<MastraDeployer | undefined>;
358
368
  export { getDeployer }
359
369
  export { getDeployer as getDeployer_alias_1 }
@@ -811,6 +821,11 @@ declare type WorkspacePackageInfo = {
811
821
  version: string | undefined;
812
822
  };
813
823
 
824
+ export declare function writeCustomInstrumentation(entryFile: string, outputDir: string): Promise<{
825
+ hasCustomConfig: boolean;
826
+ externalDependencies: string[];
827
+ }>;
828
+
814
829
  declare function writeTelemetryConfig(entryFile: string, outputDir: string): Promise<{
815
830
  hasCustomConfig: boolean;
816
831
  externalDependencies: string[];
@@ -4,7 +4,7 @@ var chunkFK2WUSEN_cjs = require('../chunk-FK2WUSEN.cjs');
4
4
  var chunkM2VZQFTW_cjs = require('../chunk-M2VZQFTW.cjs');
5
5
  var chunkXKH6F4NE_cjs = require('../chunk-XKH6F4NE.cjs');
6
6
  var chunkD2DCFCLH_cjs = require('../chunk-D2DCFCLH.cjs');
7
- var chunk7ICGDVC3_cjs = require('../chunk-7ICGDVC3.cjs');
7
+ var chunkKCP5ITLV_cjs = require('../chunk-KCP5ITLV.cjs');
8
8
 
9
9
 
10
10
 
@@ -42,9 +42,9 @@ Object.defineProperty(exports, "getBundlerInputOptions", {
42
42
  });
43
43
  Object.defineProperty(exports, "Deps", {
44
44
  enumerable: true,
45
- get: function () { return chunk7ICGDVC3_cjs.Deps; }
45
+ get: function () { return chunkKCP5ITLV_cjs.Deps; }
46
46
  });
47
47
  Object.defineProperty(exports, "FileService", {
48
48
  enumerable: true,
49
- get: function () { return chunk7ICGDVC3_cjs.FileService; }
49
+ get: function () { return chunkKCP5ITLV_cjs.FileService; }
50
50
  });
@@ -2,4 +2,4 @@ export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOpti
2
2
  export { writeTelemetryConfig } from '../chunk-ENT5RDOI.js';
3
3
  export { analyzeBundle, getBundlerOptions } from '../chunk-UYQZMNZL.js';
4
4
  export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-TIC2KT3M.js';
5
- export { Deps, FileService } from '../chunk-4VKGIENI.js';
5
+ export { Deps, FileService } from '../chunk-GPD54HBC.js';
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk2AILHSHN_cjs = require('../chunk-2AILHSHN.cjs');
3
+ var chunkMKB7NDY3_cjs = require('../chunk-MKB7NDY3.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Bundler", {
8
8
  enumerable: true,
9
- get: function () { return chunk2AILHSHN_cjs.Bundler; }
9
+ get: function () { return chunkMKB7NDY3_cjs.Bundler; }
10
10
  });
@@ -1 +1 @@
1
- export { Bundler } from '../chunk-C2ZZNU67.js';
1
+ export { Bundler } from '../chunk-2C7ENC5E.js';
@@ -1,7 +1,7 @@
1
1
  import { writeTelemetryConfig } from './chunk-ENT5RDOI.js';
2
2
  import { analyzeBundle } from './chunk-UYQZMNZL.js';
3
3
  import { createBundler, getInputOptions } from './chunk-TIC2KT3M.js';
4
- import { DepsService, FileService } from './chunk-4VKGIENI.js';
4
+ import { DepsService, FileService } from './chunk-GPD54HBC.js';
5
5
  import { existsSync } from 'fs';
6
6
  import { writeFile, stat } from 'fs/promises';
7
7
  import { join, dirname } from 'path';
@@ -12,10 +12,49 @@ import virtual from '@rollup/plugin-virtual';
12
12
  import fsExtra, { emptyDir, ensureDir, copy, readJSON } from 'fs-extra/esm';
13
13
  import { globby } from 'globby';
14
14
  import resolveFrom from 'resolve-from';
15
+ import { rollup } from 'rollup';
16
+ import esbuild from 'rollup-plugin-esbuild';
17
+ import commonjs from '@rollup/plugin-commonjs';
15
18
  import slugify from '@sindresorhus/slugify';
16
19
  import { findWorkspaces, findWorkspacesRoot } from 'find-workspaces';
17
20
  import { ensureDir as ensureDir$1 } from 'fs-extra';
18
21
 
22
+ function getCustomInstrumentationBundler(entryFile, result) {
23
+ return rollup({
24
+ logLevel: "silent",
25
+ input: {
26
+ instrumentation: entryFile
27
+ },
28
+ treeshake: false,
29
+ plugins: [
30
+ // transpile typescript to something we understand
31
+ esbuild({
32
+ target: "node20",
33
+ platform: "node",
34
+ minify: false
35
+ }),
36
+ commonjs({
37
+ extensions: [".js", ".ts"],
38
+ strictRequires: "strict",
39
+ transformMixedEsModules: true,
40
+ ignoreTryCatch: false
41
+ })
42
+ ]
43
+ });
44
+ }
45
+ async function writeCustomInstrumentation(entryFile, outputDir) {
46
+ const result = {
47
+ hasCustomConfig: false
48
+ };
49
+ const bundle = await getCustomInstrumentationBundler(entryFile);
50
+ const { output } = await bundle.write({
51
+ dir: outputDir,
52
+ format: "es",
53
+ entryFileNames: "[name].mjs"
54
+ });
55
+ const externals = output[0].imports.filter((x) => !x.startsWith("./"));
56
+ return { ...result, externalDependencies: externals };
57
+ }
19
58
  var createWorkspacePackageMap = async () => {
20
59
  const workspaces = await findWorkspaces();
21
60
  const workspaceMap = new Map(
@@ -116,10 +155,14 @@ var Bundler = class extends MastraBundler {
116
155
  await ensureDir(join(outputDirectory, this.analyzeOutputDir));
117
156
  await ensureDir(join(outputDirectory, this.outputDir));
118
157
  }
119
- async writeInstrumentationFile(outputDirectory) {
158
+ async writeInstrumentationFile(outputDirectory, customInstrumentationFile) {
120
159
  const instrumentationFile = join(outputDirectory, "instrumentation.mjs");
121
160
  const __dirname = dirname(fileURLToPath(import.meta.url));
122
- await copy(join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
161
+ if (customInstrumentationFile) {
162
+ await copy(customInstrumentationFile, instrumentationFile);
163
+ } else {
164
+ await copy(join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
165
+ }
123
166
  }
124
167
  async writePackageJson(outputDirectory, dependencies, resolutions) {
125
168
  this.logger.debug(`Writing project's package.json`);
@@ -279,6 +322,33 @@ var Bundler = class extends MastraBundler {
279
322
  error
280
323
  );
281
324
  }
325
+ const mastraFolder = dirname(mastraEntryFile);
326
+ const fileService = new FileService();
327
+ const customInstrumentation = fileService.getFirstExistingFileOrUndefined([
328
+ join(mastraFolder, "instrumentation.js"),
329
+ join(mastraFolder, "instrumentation.ts"),
330
+ join(mastraFolder, "instrumentation.mjs")
331
+ ]);
332
+ try {
333
+ if (customInstrumentation) {
334
+ const result = await writeCustomInstrumentation(customInstrumentation, join(outputDirectory, this.outputDir));
335
+ externalDependencies = [...externalDependencies, ...result.externalDependencies];
336
+ await this.writeInstrumentationFile(join(outputDirectory, this.outputDir), customInstrumentation);
337
+ } else {
338
+ await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));
339
+ }
340
+ } catch (error) {
341
+ const message = error instanceof Error ? error.message : String(error);
342
+ throw new MastraError(
343
+ {
344
+ id: "DEPLOYER_BUNDLER_INSTRUMENTATION_FILE_FAILED",
345
+ text: `Failed to write instrumentation file: ${message}, ${customInstrumentation ? ` Found custom instrumentation file: ${customInstrumentation}` : ""}`,
346
+ domain: ErrorDomain.DEPLOYER,
347
+ category: ErrorCategory.SYSTEM
348
+ },
349
+ error
350
+ );
351
+ }
282
352
  const dependenciesToInstall = /* @__PURE__ */ new Map();
283
353
  for (const external of externalDependencies) {
284
354
  dependenciesToInstall.set(external, "latest");
@@ -330,7 +400,6 @@ var Bundler = class extends MastraBundler {
330
400
  }
331
401
  try {
332
402
  await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall, resolutions);
333
- await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));
334
403
  this.logger.info("Bundling Mastra application");
335
404
  const inputOptions = await this.getBundlerOptions(
336
405
  serverFile,
@@ -352,6 +352,19 @@ var FileService = class {
352
352
  }
353
353
  throw new Error("Missing required file, checked the following paths: " + files.join(", "));
354
354
  }
355
+ /**
356
+ * Returns the first existing file from the provided array, or undefined if none exist
357
+ * @param files array of file paths to check
358
+ * @returns the first existing file path or undefined
359
+ */
360
+ getFirstExistingFileOrUndefined(files) {
361
+ for (const f of files) {
362
+ if (fs3__default.existsSync(f)) {
363
+ return f;
364
+ }
365
+ }
366
+ return void 0;
367
+ }
355
368
  replaceValuesInFile({
356
369
  filePath,
357
370
  replacements
@@ -267,7 +267,7 @@ ${Object.entries(config.supportedArchitectures).map(([key, value]) => ` ${key}:
267
267
  }
268
268
  }
269
269
  async getPackageVersion() {
270
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-7ICGDVC3.cjs', document.baseURI).href)));
270
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KCP5ITLV.cjs', document.baseURI).href)));
271
271
  const __dirname = path.dirname(__filename);
272
272
  const pkgJsonPath = path__default.default.join(__dirname, "..", "..", "package.json");
273
273
  const content = await fsExtra.readJSON(pkgJsonPath);
@@ -354,7 +354,7 @@ var FileService = class {
354
354
  * @returns
355
355
  */
356
356
  async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
357
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-7ICGDVC3.cjs', document.baseURI).href)));
357
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KCP5ITLV.cjs', document.baseURI).href)));
358
358
  const __dirname = path__default.default.dirname(__filename);
359
359
  const filePath = path__default.default.resolve(__dirname, "..", "starter-files", inputFile);
360
360
  const fileString = fs3__namespace.default.readFileSync(filePath, "utf8");
@@ -379,6 +379,19 @@ var FileService = class {
379
379
  }
380
380
  throw new Error("Missing required file, checked the following paths: " + files.join(", "));
381
381
  }
382
+ /**
383
+ * Returns the first existing file from the provided array, or undefined if none exist
384
+ * @param files array of file paths to check
385
+ * @returns the first existing file path or undefined
386
+ */
387
+ getFirstExistingFileOrUndefined(files) {
388
+ for (const f of files) {
389
+ if (fs3__namespace.default.existsSync(f)) {
390
+ return f;
391
+ }
392
+ }
393
+ return void 0;
394
+ }
382
395
  replaceValuesInFile({
383
396
  filePath,
384
397
  replacements
@@ -3,7 +3,7 @@
3
3
  var chunkM2VZQFTW_cjs = require('./chunk-M2VZQFTW.cjs');
4
4
  var chunkXKH6F4NE_cjs = require('./chunk-XKH6F4NE.cjs');
5
5
  var chunkD2DCFCLH_cjs = require('./chunk-D2DCFCLH.cjs');
6
- var chunk7ICGDVC3_cjs = require('./chunk-7ICGDVC3.cjs');
6
+ var chunkKCP5ITLV_cjs = require('./chunk-KCP5ITLV.cjs');
7
7
  var fs = require('fs');
8
8
  var promises = require('fs/promises');
9
9
  var path = require('path');
@@ -14,6 +14,9 @@ var virtual = require('@rollup/plugin-virtual');
14
14
  var fsExtra = require('fs-extra/esm');
15
15
  var globby = require('globby');
16
16
  var resolveFrom = require('resolve-from');
17
+ var rollup = require('rollup');
18
+ var esbuild = require('rollup-plugin-esbuild');
19
+ var commonjs = require('@rollup/plugin-commonjs');
17
20
  var slugify = require('@sindresorhus/slugify');
18
21
  var findWorkspaces = require('find-workspaces');
19
22
  var fsExtra$1 = require('fs-extra');
@@ -24,8 +27,46 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
27
  var virtual__default = /*#__PURE__*/_interopDefault(virtual);
25
28
  var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
26
29
  var resolveFrom__default = /*#__PURE__*/_interopDefault(resolveFrom);
30
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
31
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
27
32
  var slugify__default = /*#__PURE__*/_interopDefault(slugify);
28
33
 
34
+ function getCustomInstrumentationBundler(entryFile, result) {
35
+ return rollup.rollup({
36
+ logLevel: "silent",
37
+ input: {
38
+ instrumentation: entryFile
39
+ },
40
+ treeshake: false,
41
+ plugins: [
42
+ // transpile typescript to something we understand
43
+ esbuild__default.default({
44
+ target: "node20",
45
+ platform: "node",
46
+ minify: false
47
+ }),
48
+ commonjs__default.default({
49
+ extensions: [".js", ".ts"],
50
+ strictRequires: "strict",
51
+ transformMixedEsModules: true,
52
+ ignoreTryCatch: false
53
+ })
54
+ ]
55
+ });
56
+ }
57
+ async function writeCustomInstrumentation(entryFile, outputDir) {
58
+ const result = {
59
+ hasCustomConfig: false
60
+ };
61
+ const bundle = await getCustomInstrumentationBundler(entryFile);
62
+ const { output } = await bundle.write({
63
+ dir: outputDir,
64
+ format: "es",
65
+ entryFileNames: "[name].mjs"
66
+ });
67
+ const externals = output[0].imports.filter((x) => !x.startsWith("./"));
68
+ return { ...result, externalDependencies: externals };
69
+ }
29
70
  var createWorkspacePackageMap = async () => {
30
71
  const workspaces = await findWorkspaces.findWorkspaces();
31
72
  const workspaceMap = new Map(
@@ -61,7 +102,7 @@ var collectTransitiveWorkspaceDependencies = ({
61
102
  if (!root) {
62
103
  throw new Error("Could not find workspace root");
63
104
  }
64
- const depsService = new chunk7ICGDVC3_cjs.DepsService(root.location);
105
+ const depsService = new chunkKCP5ITLV_cjs.DepsService(root.location);
65
106
  depsService.__setLogger(logger);
66
107
  const sanitizedName = slugify__default.default(pkgName);
67
108
  const tgzPath = depsService.getWorkspaceDependencyPath({
@@ -89,7 +130,7 @@ var packWorkspaceDependencies = async ({
89
130
  if (!root) {
90
131
  throw new Error("Could not find workspace root");
91
132
  }
92
- const depsService = new chunk7ICGDVC3_cjs.DepsService(root.location);
133
+ const depsService = new chunkKCP5ITLV_cjs.DepsService(root.location);
93
134
  depsService.__setLogger(logger);
94
135
  if (usedWorkspacePackages.size > 0) {
95
136
  const workspaceDirPath = path.join(bundleOutputDir, "workspace-module");
@@ -126,10 +167,14 @@ var Bundler = class extends bundler.MastraBundler {
126
167
  await fsExtra.ensureDir(path.join(outputDirectory, this.analyzeOutputDir));
127
168
  await fsExtra.ensureDir(path.join(outputDirectory, this.outputDir));
128
169
  }
129
- async writeInstrumentationFile(outputDirectory) {
170
+ async writeInstrumentationFile(outputDirectory, customInstrumentationFile) {
130
171
  const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
131
- 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-2AILHSHN.cjs', document.baseURI).href))));
132
- await fsExtra.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
172
+ 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-MKB7NDY3.cjs', document.baseURI).href))));
173
+ if (customInstrumentationFile) {
174
+ await fsExtra.copy(customInstrumentationFile, instrumentationFile);
175
+ } else {
176
+ await fsExtra.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
177
+ }
133
178
  }
134
179
  async writePackageJson(outputDirectory, dependencies, resolutions) {
135
180
  this.logger.debug(`Writing project's package.json`);
@@ -192,7 +237,7 @@ var Bundler = class extends bundler.MastraBundler {
192
237
  );
193
238
  }
194
239
  async installDependencies(outputDirectory, rootDir = process.cwd()) {
195
- const deps = new chunk7ICGDVC3_cjs.DepsService(rootDir);
240
+ const deps = new chunkKCP5ITLV_cjs.DepsService(rootDir);
196
241
  deps.__setLogger(this.logger);
197
242
  await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
198
243
  }
@@ -229,7 +274,7 @@ var Bundler = class extends bundler.MastraBundler {
229
274
  const expandedPaths = await globby.globby(toolPath, {});
230
275
  for (const path$1 of expandedPaths) {
231
276
  if (await fsExtra__default.default.pathExists(path$1)) {
232
- const fileService = new chunk7ICGDVC3_cjs.FileService();
277
+ const fileService = new chunkKCP5ITLV_cjs.FileService();
233
278
  const entryFile = fileService.getFirstExistingFile([
234
279
  path.join(path$1, "index.ts"),
235
280
  path.join(path$1, "index.js"),
@@ -289,6 +334,33 @@ var Bundler = class extends bundler.MastraBundler {
289
334
  error$1
290
335
  );
291
336
  }
337
+ const mastraFolder = path.dirname(mastraEntryFile);
338
+ const fileService = new chunkKCP5ITLV_cjs.FileService();
339
+ const customInstrumentation = fileService.getFirstExistingFileOrUndefined([
340
+ path.join(mastraFolder, "instrumentation.js"),
341
+ path.join(mastraFolder, "instrumentation.ts"),
342
+ path.join(mastraFolder, "instrumentation.mjs")
343
+ ]);
344
+ try {
345
+ if (customInstrumentation) {
346
+ const result = await writeCustomInstrumentation(customInstrumentation, path.join(outputDirectory, this.outputDir));
347
+ externalDependencies = [...externalDependencies, ...result.externalDependencies];
348
+ await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir), customInstrumentation);
349
+ } else {
350
+ await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir));
351
+ }
352
+ } catch (error$1) {
353
+ const message = error$1 instanceof Error ? error$1.message : String(error$1);
354
+ throw new error.MastraError(
355
+ {
356
+ id: "DEPLOYER_BUNDLER_INSTRUMENTATION_FILE_FAILED",
357
+ text: `Failed to write instrumentation file: ${message}, ${customInstrumentation ? ` Found custom instrumentation file: ${customInstrumentation}` : ""}`,
358
+ domain: error.ErrorDomain.DEPLOYER,
359
+ category: error.ErrorCategory.SYSTEM
360
+ },
361
+ error$1
362
+ );
363
+ }
292
364
  const dependenciesToInstall = /* @__PURE__ */ new Map();
293
365
  for (const external of externalDependencies) {
294
366
  dependenciesToInstall.set(external, "latest");
@@ -340,7 +412,6 @@ var Bundler = class extends bundler.MastraBundler {
340
412
  }
341
413
  try {
342
414
  await this.writePackageJson(path.join(outputDirectory, this.outputDir), dependenciesToInstall, resolutions);
343
- await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir));
344
415
  this.logger.info("Bundling Mastra application");
345
416
  const inputOptions = await this.getBundlerOptions(
346
417
  serverFile,
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk2AILHSHN_cjs = require('./chunk-2AILHSHN.cjs');
3
+ var chunkMKB7NDY3_cjs = require('./chunk-MKB7NDY3.cjs');
4
4
  var chunkXKH6F4NE_cjs = require('./chunk-XKH6F4NE.cjs');
5
- var chunk7ICGDVC3_cjs = require('./chunk-7ICGDVC3.cjs');
5
+ var chunkKCP5ITLV_cjs = require('./chunk-KCP5ITLV.cjs');
6
6
  var babel = require('@babel/core');
7
7
  var rollup = require('rollup');
8
8
  var esbuild = require('rollup-plugin-esbuild');
@@ -33,8 +33,8 @@ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
33
33
  var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
34
34
 
35
35
  // src/deploy/base.ts
36
- var Deployer = class extends chunk2AILHSHN_cjs.Bundler {
37
- deps = new chunk7ICGDVC3_cjs.DepsService();
36
+ var Deployer = class extends chunkMKB7NDY3_cjs.Bundler {
37
+ deps = new chunkKCP5ITLV_cjs.DepsService();
38
38
  constructor(args) {
39
39
  super(args.name, "DEPLOYER");
40
40
  this.deps.__setLogger(this.logger);
@@ -42,7 +42,7 @@ var Deployer = class extends chunk2AILHSHN_cjs.Bundler {
42
42
  getEnvFiles() {
43
43
  const possibleFiles = [".env.production", ".env.local", ".env"];
44
44
  try {
45
- const fileService = new chunk7ICGDVC3_cjs.FileService();
45
+ const fileService = new chunkKCP5ITLV_cjs.FileService();
46
46
  const envFile = fileService.getFirstExistingFile(possibleFiles);
47
47
  return Promise.resolve([envFile]);
48
48
  } catch {
@@ -176,19 +176,19 @@ async function getDeployer(entryFile, outputDir) {
176
176
 
177
177
  Object.defineProperty(exports, "Deps", {
178
178
  enumerable: true,
179
- get: function () { return chunk7ICGDVC3_cjs.Deps; }
179
+ get: function () { return chunkKCP5ITLV_cjs.Deps; }
180
180
  });
181
181
  Object.defineProperty(exports, "FileService", {
182
182
  enumerable: true,
183
- get: function () { return chunk7ICGDVC3_cjs.FileService; }
183
+ get: function () { return chunkKCP5ITLV_cjs.FileService; }
184
184
  });
185
185
  Object.defineProperty(exports, "createChildProcessLogger", {
186
186
  enumerable: true,
187
- get: function () { return chunk7ICGDVC3_cjs.createChildProcessLogger; }
187
+ get: function () { return chunkKCP5ITLV_cjs.createChildProcessLogger; }
188
188
  });
189
189
  Object.defineProperty(exports, "createPinoStream", {
190
190
  enumerable: true,
191
- get: function () { return chunk7ICGDVC3_cjs.createPinoStream; }
191
+ get: function () { return chunkKCP5ITLV_cjs.createPinoStream; }
192
192
  });
193
193
  exports.Deployer = Deployer;
194
194
  exports.getDeployer = getDeployer;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Bundler } from './chunk-C2ZZNU67.js';
1
+ import { Bundler } from './chunk-2C7ENC5E.js';
2
2
  import { recursiveRemoveNonReferencedNodes } from './chunk-UYQZMNZL.js';
3
- import { DepsService, FileService } from './chunk-4VKGIENI.js';
4
- export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-4VKGIENI.js';
3
+ import { DepsService, FileService } from './chunk-GPD54HBC.js';
4
+ export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-GPD54HBC.js';
5
5
  import * as babel from '@babel/core';
6
6
  import babel__default from '@babel/core';
7
7
  import { rollup } from 'rollup';
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunk7ICGDVC3_cjs = require('../chunk-7ICGDVC3.cjs');
3
+ var chunkKCP5ITLV_cjs = require('../chunk-KCP5ITLV.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "DepsService", {
8
8
  enumerable: true,
9
- get: function () { return chunk7ICGDVC3_cjs.DepsService; }
9
+ get: function () { return chunkKCP5ITLV_cjs.DepsService; }
10
10
  });
11
11
  Object.defineProperty(exports, "EnvService", {
12
12
  enumerable: true,
13
- get: function () { return chunk7ICGDVC3_cjs.EnvService; }
13
+ get: function () { return chunkKCP5ITLV_cjs.EnvService; }
14
14
  });
15
15
  Object.defineProperty(exports, "FileService", {
16
16
  enumerable: true,
17
- get: function () { return chunk7ICGDVC3_cjs.FileService; }
17
+ get: function () { return chunkKCP5ITLV_cjs.FileService; }
18
18
  });
@@ -1 +1 @@
1
- export { DepsService, EnvService, FileService } from '../chunk-4VKGIENI.js';
1
+ export { DepsService, EnvService, FileService } from '../chunk-GPD54HBC.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer",
3
- "version": "0.10.11",
3
+ "version": "0.10.12-alpha.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -108,7 +108,7 @@
108
108
  "rollup-plugin-node-externals": "^8.0.1",
109
109
  "typescript-paths": "^1.5.1",
110
110
  "zod": "^3.25.67",
111
- "@mastra/server": "^0.10.11"
111
+ "@mastra/server": "^0.10.12-alpha.0"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@hono/node-server": "^1.14.4",
@@ -127,9 +127,9 @@
127
127
  "type-fest": "^4.41.0",
128
128
  "typescript": "^5.8.3",
129
129
  "vitest": "^3.2.4",
130
- "@mastra/core": "0.10.11",
130
+ "@internal/lint": "0.0.18",
131
131
  "@mastra/mcp": "^0.10.6",
132
- "@internal/lint": "0.0.18"
132
+ "@mastra/core": "0.10.12-alpha.0"
133
133
  },
134
134
  "peerDependencies": {
135
135
  "@mastra/core": ">=0.10.9-0 <0.11.0-0"