@mastra/deployer 0.11.0-alpha.1 → 0.11.0-alpha.2

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 (34) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +79 -8
  2. package/dist/_tsup-dts-rollup.d.ts +79 -8
  3. package/dist/build/analyze.cjs +2 -2
  4. package/dist/build/analyze.js +1 -1
  5. package/dist/build/bundler.cjs +3 -3
  6. package/dist/build/bundler.js +1 -1
  7. package/dist/build/index.cjs +15 -15
  8. package/dist/build/index.js +5 -5
  9. package/dist/bundler/index.cjs +2 -2
  10. package/dist/bundler/index.js +1 -1
  11. package/dist/{chunk-GPD54HBC.js → chunk-7HFWRNM7.js} +1 -7
  12. package/dist/{chunk-Z544XXXK.js → chunk-AFR3LY44.js} +45 -4
  13. package/dist/{chunk-LT2BJRBN.js → chunk-APPDEIPA.js} +9 -4
  14. package/dist/{chunk-YFMAWUII.cjs → chunk-D73JIE6N.cjs} +37 -19
  15. package/dist/{chunk-HJGC75ZR.js → chunk-DB7LRMOC.js} +27 -9
  16. package/dist/{chunk-M2VZQFTW.cjs → chunk-E7ZSCQUV.cjs} +15 -9
  17. package/dist/{chunk-KCP5ITLV.cjs → chunk-F25LATVR.cjs} +3 -9
  18. package/dist/{chunk-TIC2KT3M.js → chunk-HZNWZQHG.js} +2 -1
  19. package/dist/{chunk-D2DCFCLH.cjs → chunk-MOG6ASL4.cjs} +4 -3
  20. package/dist/{chunk-ENT5RDOI.js → chunk-NB6XIOPQ.js} +14 -8
  21. package/dist/{chunk-YVPLA2GR.cjs → chunk-TK2RG7LU.cjs} +14 -9
  22. package/dist/{chunk-UYQZMNZL.js → chunk-TLGEPS44.js} +29 -3
  23. package/dist/{chunk-54KOF3NB.cjs → chunk-WKW236CI.cjs} +46 -4
  24. package/dist/{chunk-XKH6F4NE.cjs → chunk-WTGMSQT5.cjs} +32 -6
  25. package/dist/index.cjs +11 -11
  26. package/dist/index.js +4 -4
  27. package/dist/server/index.cjs +1169 -375
  28. package/dist/server/index.d.cts +1 -0
  29. package/dist/server/index.d.ts +1 -0
  30. package/dist/server/index.js +1174 -381
  31. package/dist/services/index.cjs +4 -4
  32. package/dist/services/index.js +1 -1
  33. package/dist/templates/instrumentation-template.js +10 -6
  34. package/package.json +3 -3
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkM2VZQFTW_cjs = require('./chunk-M2VZQFTW.cjs');
4
- var chunkXKH6F4NE_cjs = require('./chunk-XKH6F4NE.cjs');
5
- var chunkD2DCFCLH_cjs = require('./chunk-D2DCFCLH.cjs');
6
- var chunkKCP5ITLV_cjs = require('./chunk-KCP5ITLV.cjs');
3
+ var chunkE7ZSCQUV_cjs = require('./chunk-E7ZSCQUV.cjs');
4
+ var chunkWTGMSQT5_cjs = require('./chunk-WTGMSQT5.cjs');
5
+ var chunkMOG6ASL4_cjs = require('./chunk-MOG6ASL4.cjs');
6
+ var chunkF25LATVR_cjs = require('./chunk-F25LATVR.cjs');
7
7
  var fs = require('fs');
8
8
  var promises = require('fs/promises');
9
9
  var path = require('path');
@@ -54,7 +54,7 @@ function getCustomInstrumentationBundler(entryFile, result) {
54
54
  ]
55
55
  });
56
56
  }
57
- async function writeCustomInstrumentation(entryFile, outputDir) {
57
+ async function writeCustomInstrumentation(entryFile, outputDir, options = {}) {
58
58
  const result = {
59
59
  hasCustomConfig: false
60
60
  };
@@ -62,7 +62,8 @@ async function writeCustomInstrumentation(entryFile, outputDir) {
62
62
  const { output } = await bundle.write({
63
63
  dir: outputDir,
64
64
  format: "es",
65
- entryFileNames: "[name].mjs"
65
+ entryFileNames: "[name].mjs",
66
+ sourcemap: options.sourcemap
66
67
  });
67
68
  const externals = output[0].imports.filter((x) => !x.startsWith("./"));
68
69
  return { ...result, externalDependencies: externals };
@@ -102,7 +103,7 @@ var collectTransitiveWorkspaceDependencies = ({
102
103
  if (!root) {
103
104
  throw new Error("Could not find workspace root");
104
105
  }
105
- const depsService = new chunkKCP5ITLV_cjs.DepsService(root.location);
106
+ const depsService = new chunkF25LATVR_cjs.DepsService(root.location);
106
107
  depsService.__setLogger(logger);
107
108
  const sanitizedName = slugify__default.default(pkgName);
108
109
  const tgzPath = depsService.getWorkspaceDependencyPath({
@@ -130,7 +131,7 @@ var packWorkspaceDependencies = async ({
130
131
  if (!root) {
131
132
  throw new Error("Could not find workspace root");
132
133
  }
133
- const depsService = new chunkKCP5ITLV_cjs.DepsService(root.location);
134
+ const depsService = new chunkF25LATVR_cjs.DepsService(root.location);
134
135
  depsService.__setLogger(logger);
135
136
  if (usedWorkspacePackages.size > 0) {
136
137
  const workspaceDirPath = path.join(bundleOutputDir, "workspace-module");
@@ -169,7 +170,7 @@ var Bundler = class extends bundler.MastraBundler {
169
170
  }
170
171
  async writeInstrumentationFile(outputDirectory, customInstrumentationFile) {
171
172
  const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
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-YFMAWUII.cjs', document.baseURI).href))));
173
+ 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-D73JIE6N.cjs', document.baseURI).href))));
173
174
  if (customInstrumentationFile) {
174
175
  await fsExtra.copy(customInstrumentationFile, instrumentationFile);
175
176
  } else {
@@ -225,10 +226,10 @@ var Bundler = class extends bundler.MastraBundler {
225
226
  );
226
227
  }
227
228
  createBundler(inputOptions, outputOptions) {
228
- return chunkD2DCFCLH_cjs.createBundler(inputOptions, outputOptions);
229
+ return chunkMOG6ASL4_cjs.createBundler(inputOptions, outputOptions);
229
230
  }
230
231
  async analyze(entry, mastraFile, outputDirectory) {
231
- return await chunkXKH6F4NE_cjs.analyzeBundle(
232
+ return await chunkWTGMSQT5_cjs.analyzeBundle(
232
233
  [].concat(entry),
233
234
  mastraFile,
234
235
  path.join(outputDirectory, this.analyzeOutputDir),
@@ -237,7 +238,7 @@ var Bundler = class extends bundler.MastraBundler {
237
238
  );
238
239
  }
239
240
  async installDependencies(outputDirectory, rootDir = process.cwd()) {
240
- const deps = new chunkKCP5ITLV_cjs.DepsService(rootDir);
241
+ const deps = new chunkF25LATVR_cjs.DepsService(rootDir);
241
242
  deps.__setLogger(this.logger);
242
243
  await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
243
244
  }
@@ -264,7 +265,7 @@ var Bundler = class extends bundler.MastraBundler {
264
265
  }
265
266
  }
266
267
  async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths) {
267
- const inputOptions = await chunkD2DCFCLH_cjs.getInputOptions(mastraEntryFile, analyzedBundleInfo, "node", {
268
+ const inputOptions = await chunkMOG6ASL4_cjs.getInputOptions(mastraEntryFile, analyzedBundleInfo, "node", {
268
269
  "process.env.NODE_ENV": JSON.stringify("production")
269
270
  });
270
271
  const isVirtual = serverFile.includes("\n") || fs.existsSync(serverFile);
@@ -287,7 +288,7 @@ var Bundler = class extends bundler.MastraBundler {
287
288
  const expandedPaths = await globby.globby(toolPath, {});
288
289
  for (const path$1 of expandedPaths) {
289
290
  if (await fsExtra__default.default.pathExists(path$1)) {
290
- const fileService = new chunkKCP5ITLV_cjs.FileService();
291
+ const fileService = new chunkF25LATVR_cjs.FileService();
291
292
  const entryFile = fileService.getFirstExistingFile([
292
293
  path.join(path$1, "index.ts"),
293
294
  path.join(path$1, "index.js"),
@@ -309,10 +310,17 @@ var Bundler = class extends bundler.MastraBundler {
309
310
  }
310
311
  async _bundle(serverFile, mastraEntryFile, outputDirectory, toolsPaths = [], bundleLocation = path.join(outputDirectory, this.outputDir)) {
311
312
  this.logger.info("Start bundling Mastra");
313
+ let sourcemap = false;
314
+ try {
315
+ const bundlerOptions = await chunkWTGMSQT5_cjs.getBundlerOptions(mastraEntryFile, outputDirectory);
316
+ sourcemap = !!bundlerOptions?.sourcemap;
317
+ } catch (error) {
318
+ this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
319
+ }
312
320
  let analyzedBundleInfo;
313
321
  try {
314
322
  const resolvedToolsPaths = await this.getToolsInputOptions(toolsPaths);
315
- analyzedBundleInfo = await chunkXKH6F4NE_cjs.analyzeBundle(
323
+ analyzedBundleInfo = await chunkWTGMSQT5_cjs.analyzeBundle(
316
324
  [serverFile, ...Object.values(resolvedToolsPaths)],
317
325
  mastraEntryFile,
318
326
  path.join(outputDirectory, this.analyzeOutputDir),
@@ -333,7 +341,14 @@ var Bundler = class extends bundler.MastraBundler {
333
341
  }
334
342
  let externalDependencies;
335
343
  try {
336
- const result = await chunkM2VZQFTW_cjs.writeTelemetryConfig(mastraEntryFile, path.join(outputDirectory, this.outputDir));
344
+ const result = await chunkE7ZSCQUV_cjs.writeTelemetryConfig({
345
+ entryFile: mastraEntryFile,
346
+ outputDir: path.join(outputDirectory, this.outputDir),
347
+ options: {
348
+ sourcemap
349
+ },
350
+ logger: this.logger
351
+ });
337
352
  externalDependencies = result.externalDependencies;
338
353
  } catch (error$1) {
339
354
  const message = error$1 instanceof Error ? error$1.message : String(error$1);
@@ -348,7 +363,7 @@ var Bundler = class extends bundler.MastraBundler {
348
363
  );
349
364
  }
350
365
  const mastraFolder = path.dirname(mastraEntryFile);
351
- const fileService = new chunkKCP5ITLV_cjs.FileService();
366
+ const fileService = new chunkF25LATVR_cjs.FileService();
352
367
  const customInstrumentation = fileService.getFirstExistingFileOrUndefined([
353
368
  path.join(mastraFolder, "instrumentation.js"),
354
369
  path.join(mastraFolder, "instrumentation.ts"),
@@ -356,7 +371,9 @@ var Bundler = class extends bundler.MastraBundler {
356
371
  ]);
357
372
  try {
358
373
  if (customInstrumentation) {
359
- const result = await writeCustomInstrumentation(customInstrumentation, path.join(outputDirectory, this.outputDir));
374
+ const result = await writeCustomInstrumentation(customInstrumentation, path.join(outputDirectory, this.outputDir), {
375
+ sourcemap
376
+ });
360
377
  externalDependencies = [...externalDependencies, ...result.externalDependencies];
361
378
  await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir), customInstrumentation);
362
379
  } else {
@@ -450,7 +467,8 @@ var Bundler = class extends bundler.MastraBundler {
450
467
  dir: bundleLocation,
451
468
  manualChunks: {
452
469
  mastra: ["#mastra"]
453
- }
470
+ },
471
+ sourcemap
454
472
  }
455
473
  );
456
474
  await bundler.write();
@@ -1,7 +1,7 @@
1
- import { writeTelemetryConfig } from './chunk-ENT5RDOI.js';
2
- import { analyzeBundle } from './chunk-UYQZMNZL.js';
3
- import { createBundler, getInputOptions } from './chunk-TIC2KT3M.js';
4
- import { DepsService, FileService } from './chunk-GPD54HBC.js';
1
+ import { writeTelemetryConfig } from './chunk-NB6XIOPQ.js';
2
+ import { analyzeBundle, getBundlerOptions } from './chunk-TLGEPS44.js';
3
+ import { createBundler, getInputOptions } from './chunk-HZNWZQHG.js';
4
+ import { DepsService, FileService } from './chunk-7HFWRNM7.js';
5
5
  import { existsSync } from 'fs';
6
6
  import { writeFile, stat } from 'fs/promises';
7
7
  import { join, dirname } from 'path';
@@ -42,7 +42,7 @@ function getCustomInstrumentationBundler(entryFile, result) {
42
42
  ]
43
43
  });
44
44
  }
45
- async function writeCustomInstrumentation(entryFile, outputDir) {
45
+ async function writeCustomInstrumentation(entryFile, outputDir, options = {}) {
46
46
  const result = {
47
47
  hasCustomConfig: false
48
48
  };
@@ -50,7 +50,8 @@ async function writeCustomInstrumentation(entryFile, outputDir) {
50
50
  const { output } = await bundle.write({
51
51
  dir: outputDir,
52
52
  format: "es",
53
- entryFileNames: "[name].mjs"
53
+ entryFileNames: "[name].mjs",
54
+ sourcemap: options.sourcemap
54
55
  });
55
56
  const externals = output[0].imports.filter((x) => !x.startsWith("./"));
56
57
  return { ...result, externalDependencies: externals };
@@ -297,6 +298,13 @@ var Bundler = class extends MastraBundler {
297
298
  }
298
299
  async _bundle(serverFile, mastraEntryFile, outputDirectory, toolsPaths = [], bundleLocation = join(outputDirectory, this.outputDir)) {
299
300
  this.logger.info("Start bundling Mastra");
301
+ let sourcemap = false;
302
+ try {
303
+ const bundlerOptions = await getBundlerOptions(mastraEntryFile, outputDirectory);
304
+ sourcemap = !!bundlerOptions?.sourcemap;
305
+ } catch (error) {
306
+ this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
307
+ }
300
308
  let analyzedBundleInfo;
301
309
  try {
302
310
  const resolvedToolsPaths = await this.getToolsInputOptions(toolsPaths);
@@ -321,7 +329,14 @@ var Bundler = class extends MastraBundler {
321
329
  }
322
330
  let externalDependencies;
323
331
  try {
324
- const result = await writeTelemetryConfig(mastraEntryFile, join(outputDirectory, this.outputDir));
332
+ const result = await writeTelemetryConfig({
333
+ entryFile: mastraEntryFile,
334
+ outputDir: join(outputDirectory, this.outputDir),
335
+ options: {
336
+ sourcemap
337
+ },
338
+ logger: this.logger
339
+ });
325
340
  externalDependencies = result.externalDependencies;
326
341
  } catch (error) {
327
342
  const message = error instanceof Error ? error.message : String(error);
@@ -344,7 +359,9 @@ var Bundler = class extends MastraBundler {
344
359
  ]);
345
360
  try {
346
361
  if (customInstrumentation) {
347
- const result = await writeCustomInstrumentation(customInstrumentation, join(outputDirectory, this.outputDir));
362
+ const result = await writeCustomInstrumentation(customInstrumentation, join(outputDirectory, this.outputDir), {
363
+ sourcemap
364
+ });
348
365
  externalDependencies = [...externalDependencies, ...result.externalDependencies];
349
366
  await this.writeInstrumentationFile(join(outputDirectory, this.outputDir), customInstrumentation);
350
367
  } else {
@@ -438,7 +455,8 @@ var Bundler = class extends MastraBundler {
438
455
  dir: bundleLocation,
439
456
  manualChunks: {
440
457
  mastra: ["#mastra"]
441
- }
458
+ },
459
+ sourcemap
442
460
  }
443
461
  );
444
462
  await bundler.write();
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkXKH6F4NE_cjs = require('./chunk-XKH6F4NE.cjs');
3
+ var chunkWTGMSQT5_cjs = require('./chunk-WTGMSQT5.cjs');
4
4
  var babel = require('@babel/core');
5
5
  var rollup = require('rollup');
6
6
  var esbuild = require('rollup-plugin-esbuild');
@@ -31,12 +31,12 @@ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
31
31
  var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
32
32
 
33
33
  // src/build/babel/remove-all-options-telemetry.ts
34
- function removeAllOptionsExceptTelemetry(result) {
35
- return chunkXKH6F4NE_cjs.removeAllOptionsFromMastraExcept(result, "telemetry");
34
+ function removeAllOptionsExceptTelemetry(result, logger) {
35
+ return chunkWTGMSQT5_cjs.removeAllOptionsFromMastraExcept(result, "telemetry", logger);
36
36
  }
37
37
 
38
38
  // src/build/telemetry.ts
39
- function getTelemetryBundler(entryFile, result) {
39
+ function getTelemetryBundler(entryFile, result, logger) {
40
40
  return rollup.rollup({
41
41
  logLevel: "silent",
42
42
  input: {
@@ -69,7 +69,7 @@ function getTelemetryBundler(entryFile, result) {
69
69
  babelrc: false,
70
70
  configFile: false,
71
71
  filename: id,
72
- plugins: [removeAllOptionsExceptTelemetry(result)]
72
+ plugins: [removeAllOptionsExceptTelemetry(result, logger)]
73
73
  },
74
74
  (err, result2) => {
75
75
  if (err) {
@@ -96,7 +96,7 @@ function getTelemetryBundler(entryFile, result) {
96
96
  if (id !== entryFile) {
97
97
  return;
98
98
  }
99
- return chunkXKH6F4NE_cjs.recursiveRemoveNonReferencedNodes(code);
99
+ return chunkWTGMSQT5_cjs.recursiveRemoveNonReferencedNodes(code);
100
100
  }
101
101
  },
102
102
  // let esbuild remove all unused imports
@@ -108,15 +108,21 @@ function getTelemetryBundler(entryFile, result) {
108
108
  ]
109
109
  });
110
110
  }
111
- async function writeTelemetryConfig(entryFile, outputDir) {
111
+ async function writeTelemetryConfig({
112
+ entryFile,
113
+ outputDir,
114
+ options = {},
115
+ logger
116
+ }) {
112
117
  const result = {
113
118
  hasCustomConfig: false
114
119
  };
115
- const bundle = await getTelemetryBundler(entryFile, result);
120
+ const bundle = await getTelemetryBundler(entryFile, result, logger);
116
121
  const { output } = await bundle.write({
117
122
  dir: outputDir,
118
123
  format: "es",
119
- entryFileNames: "[name].mjs"
124
+ entryFileNames: "[name].mjs",
125
+ sourcemap: options.sourcemap
120
126
  });
121
127
  const externals = output[0].imports.filter((x) => !x.startsWith("./"));
122
128
  return { ...result, externalDependencies: externals };
@@ -202,16 +202,10 @@ ${Object.entries(config.supportedArchitectures).map(([key, value]) => ` ${key}:
202
202
  logger: this.logger,
203
203
  root: dir
204
204
  });
205
- const env = {
206
- PATH: process.env.PATH
207
- };
208
- if (process.env.npm_config_registry) {
209
- env.npm_config_registry = process.env.npm_config_registry;
210
- }
211
205
  return cpLogger({
212
206
  cmd: runCommand,
213
207
  args,
214
- env
208
+ env: process.env
215
209
  });
216
210
  }
217
211
  async installPackages(packages) {
@@ -267,7 +261,7 @@ ${Object.entries(config.supportedArchitectures).map(([key, value]) => ` ${key}:
267
261
  }
268
262
  }
269
263
  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-KCP5ITLV.cjs', document.baseURI).href)));
264
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-F25LATVR.cjs', document.baseURI).href)));
271
265
  const __dirname = path.dirname(__filename);
272
266
  const pkgJsonPath = path__default.default.join(__dirname, "..", "..", "package.json");
273
267
  const content = await fsExtra.readJSON(pkgJsonPath);
@@ -354,7 +348,7 @@ var FileService = class {
354
348
  * @returns
355
349
  */
356
350
  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-KCP5ITLV.cjs', document.baseURI).href)));
351
+ const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-F25LATVR.cjs', document.baseURI).href)));
358
352
  const __dirname = path__default.default.dirname(__filename);
359
353
  const filePath = path__default.default.resolve(__dirname, "..", "starter-files", inputFile);
360
354
  const fileString = fs3__namespace.default.readFileSync(filePath, "utf8");
@@ -1,4 +1,4 @@
1
- import { tsConfigPaths, removeDeployer } from './chunk-Z544XXXK.js';
1
+ import { tsConfigPaths, removeDeployer } from './chunk-AFR3LY44.js';
2
2
  import alias from '@rollup/plugin-alias';
3
3
  import commonjs from '@rollup/plugin-commonjs';
4
4
  import json from '@rollup/plugin-json';
@@ -16,6 +16,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
16
16
  browser: true
17
17
  });
18
18
  const externalsCopy = /* @__PURE__ */ new Set();
19
+ debugger;
19
20
  for (const external of analyzedBundleInfo.externalDependencies) {
20
21
  if (external.startsWith("@")) {
21
22
  const [scope, name] = external.split("/", 3);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
3
+ var chunkWKW236CI_cjs = require('./chunk-WKW236CI.cjs');
4
4
  var alias = require('@rollup/plugin-alias');
5
5
  var commonjs = require('@rollup/plugin-commonjs');
6
6
  var json = require('@rollup/plugin-json');
@@ -26,6 +26,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
26
26
  browser: true
27
27
  });
28
28
  const externalsCopy = /* @__PURE__ */ new Set();
29
+ debugger;
29
30
  for (const external of analyzedBundleInfo.externalDependencies) {
30
31
  if (external.startsWith("@")) {
31
32
  const [scope, name] = external.split("/", 3);
@@ -44,7 +45,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
44
45
  preserveSymlinks: true,
45
46
  external: externals,
46
47
  plugins: [
47
- chunk54KOF3NB_cjs.tsConfigPaths(),
48
+ chunkWKW236CI_cjs.tsConfigPaths(),
48
49
  {
49
50
  name: "alias-optimized-deps",
50
51
  // @ts-ignore
@@ -125,7 +126,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
125
126
  // },
126
127
  // },
127
128
  json__default.default(),
128
- chunk54KOF3NB_cjs.removeDeployer(entryFile),
129
+ chunkWKW236CI_cjs.removeDeployer(entryFile),
129
130
  // treeshake unused imports
130
131
  esbuild__default.default({
131
132
  include: entryFile,
@@ -1,16 +1,16 @@
1
- import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-UYQZMNZL.js';
1
+ import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-TLGEPS44.js';
2
2
  import * as babel from '@babel/core';
3
3
  import { rollup } from 'rollup';
4
4
  import esbuild from 'rollup-plugin-esbuild';
5
5
  import commonjs from '@rollup/plugin-commonjs';
6
6
 
7
7
  // src/build/babel/remove-all-options-telemetry.ts
8
- function removeAllOptionsExceptTelemetry(result) {
9
- return removeAllOptionsFromMastraExcept(result, "telemetry");
8
+ function removeAllOptionsExceptTelemetry(result, logger) {
9
+ return removeAllOptionsFromMastraExcept(result, "telemetry", logger);
10
10
  }
11
11
 
12
12
  // src/build/telemetry.ts
13
- function getTelemetryBundler(entryFile, result) {
13
+ function getTelemetryBundler(entryFile, result, logger) {
14
14
  return rollup({
15
15
  logLevel: "silent",
16
16
  input: {
@@ -43,7 +43,7 @@ function getTelemetryBundler(entryFile, result) {
43
43
  babelrc: false,
44
44
  configFile: false,
45
45
  filename: id,
46
- plugins: [removeAllOptionsExceptTelemetry(result)]
46
+ plugins: [removeAllOptionsExceptTelemetry(result, logger)]
47
47
  },
48
48
  (err, result2) => {
49
49
  if (err) {
@@ -82,15 +82,21 @@ function getTelemetryBundler(entryFile, result) {
82
82
  ]
83
83
  });
84
84
  }
85
- async function writeTelemetryConfig(entryFile, outputDir) {
85
+ async function writeTelemetryConfig({
86
+ entryFile,
87
+ outputDir,
88
+ options = {},
89
+ logger
90
+ }) {
86
91
  const result = {
87
92
  hasCustomConfig: false
88
93
  };
89
- const bundle = await getTelemetryBundler(entryFile, result);
94
+ const bundle = await getTelemetryBundler(entryFile, result, logger);
90
95
  const { output } = await bundle.write({
91
96
  dir: outputDir,
92
97
  format: "es",
93
- entryFileNames: "[name].mjs"
98
+ entryFileNames: "[name].mjs",
99
+ sourcemap: options.sourcemap
94
100
  });
95
101
  const externals = output[0].imports.filter((x) => !x.startsWith("./"));
96
102
  return { ...result, externalDependencies: externals };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkXKH6F4NE_cjs = require('./chunk-XKH6F4NE.cjs');
4
- var chunkD2DCFCLH_cjs = require('./chunk-D2DCFCLH.cjs');
5
- var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
3
+ var chunkWTGMSQT5_cjs = require('./chunk-WTGMSQT5.cjs');
4
+ var chunkMOG6ASL4_cjs = require('./chunk-MOG6ASL4.cjs');
5
+ var chunkWKW236CI_cjs = require('./chunk-WKW236CI.cjs');
6
6
  var rollup = require('rollup');
7
7
  var path = require('path');
8
8
  var resolveFrom = require('resolve-from');
@@ -113,7 +113,7 @@ function nodeModulesExtensionResolver() {
113
113
 
114
114
  // src/build/watcher.ts
115
115
  async function getInputOptions2(entryFile, platform, env) {
116
- const inputOptions = await chunkD2DCFCLH_cjs.getInputOptions(
116
+ const inputOptions = await chunkMOG6ASL4_cjs.getInputOptions(
117
117
  entryFile,
118
118
  {
119
119
  dependencies: /* @__PURE__ */ new Map(),
@@ -126,9 +126,14 @@ async function getInputOptions2(entryFile, platform, env) {
126
126
  if (Array.isArray(inputOptions.plugins)) {
127
127
  inputOptions.plugins = inputOptions.plugins.filter(
128
128
  // @ts-ignore
129
- (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
129
+ (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve" && plugin.name !== "tsconfig-paths"
130
130
  );
131
- inputOptions.plugins.push(chunkXKH6F4NE_cjs.aliasHono());
131
+ inputOptions.plugins.unshift(
132
+ chunkWKW236CI_cjs.tsConfigPaths({
133
+ localResolve: true
134
+ })
135
+ );
136
+ inputOptions.plugins.push(chunkWTGMSQT5_cjs.aliasHono());
132
137
  inputOptions.plugins.push(nodeModulesExtensionResolver());
133
138
  }
134
139
  return inputOptions;
@@ -148,7 +153,7 @@ async function createWatcher(inputOptions, outputOptions) {
148
153
 
149
154
  // src/build/babel/remove-all-options-server.ts
150
155
  function removeAllOptionsExceptServer(result) {
151
- return chunkXKH6F4NE_cjs.removeAllOptionsFromMastraExcept(result, "server");
156
+ return chunkWTGMSQT5_cjs.removeAllOptionsFromMastraExcept(result, "server");
152
157
  }
153
158
  function getServerOptionsBundler(entryFile, result) {
154
159
  return rollup.rollup({
@@ -158,7 +163,7 @@ function getServerOptionsBundler(entryFile, result) {
158
163
  },
159
164
  treeshake: "smallest",
160
165
  plugins: [
161
- chunk54KOF3NB_cjs.tsConfigPaths(),
166
+ chunkWKW236CI_cjs.tsConfigPaths(),
162
167
  // transpile typescript to something we understand
163
168
  esbuild__default.default({
164
169
  target: "node20",
@@ -211,7 +216,7 @@ function getServerOptionsBundler(entryFile, result) {
211
216
  if (id !== entryFile) {
212
217
  return;
213
218
  }
214
- return chunkXKH6F4NE_cjs.recursiveRemoveNonReferencedNodes(code);
219
+ return chunkWTGMSQT5_cjs.recursiveRemoveNonReferencedNodes(code);
215
220
  }
216
221
  },
217
222
  // let esbuild remove all unused imports
@@ -1,4 +1,4 @@
1
- import { tsConfigPaths, removeDeployer } from './chunk-Z544XXXK.js';
1
+ import { tsConfigPaths, removeDeployer } from './chunk-AFR3LY44.js';
2
2
  import commonjs2 from '@rollup/plugin-commonjs';
3
3
  import json from '@rollup/plugin-json';
4
4
  import nodeResolve from '@rollup/plugin-node-resolve';
@@ -67,7 +67,7 @@ function validate(file) {
67
67
  }
68
68
  );
69
69
  }
70
- function removeAllOptionsFromMastraExcept(result, option) {
70
+ function removeAllOptionsFromMastraExcept(result, option, logger) {
71
71
  const t = babel__default.types;
72
72
  return {
73
73
  name: "remove-all-except-" + option + "-config",
@@ -117,6 +117,28 @@ function removeAllOptionsFromMastraExcept(result, option) {
117
117
  []
118
118
  );
119
119
  programPath.node.body.push(exportDeclaration);
120
+ },
121
+ Program: {
122
+ exit(path) {
123
+ const hasExport = path.node.body.some(
124
+ (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
125
+ );
126
+ if (!hasExport) {
127
+ if (logger) {
128
+ logger.warn(`Mastra ${option} config could not be extracted. Make sure you entry file looks like
129
+ export const mastra = new Mastra({
130
+ ${option}: <value>
131
+ })
132
+
133
+ `);
134
+ }
135
+ const fallbackExportDeclaration = t.exportNamedDeclaration(
136
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
137
+ []
138
+ );
139
+ path.node.body.push(fallbackExportDeclaration);
140
+ }
141
+ }
120
142
  }
121
143
  }
122
144
  };
@@ -300,7 +322,8 @@ var globalExternals = [
300
322
  "jsdom",
301
323
  "sqlite3",
302
324
  "fastembed",
303
- "nodemailer"
325
+ "nodemailer",
326
+ "#tools"
304
327
  ];
305
328
  function findExternalImporter(module, external, allOutputs) {
306
329
  const capturedFiles = /* @__PURE__ */ new Set();
@@ -489,6 +512,9 @@ async function bundleExternals(depsToOptimize, outputDir, logger, customExternal
489
512
  const filteredChunks = output.filter((o) => o.type === "chunk");
490
513
  for (const o of filteredChunks.filter((o2) => o2.isEntry || o2.isDynamicEntry)) {
491
514
  for (const external of allExternals) {
515
+ if (external === "#tools") {
516
+ continue;
517
+ }
492
518
  const importer = findExternalImporter(o, external, filteredChunks);
493
519
  if (importer) {
494
520
  const fullPath = join(outputDir, importer.fileName);
@@ -3,6 +3,7 @@
3
3
  var babel = require('@babel/core');
4
4
  var fs = require('fs');
5
5
  var path = require('path');
6
+ var resolveFrom = require('resolve-from');
6
7
  var typescriptPaths = require('typescript-paths');
7
8
 
8
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -28,6 +29,7 @@ function _interopNamespace(e) {
28
29
  var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
29
30
  var fs__default = /*#__PURE__*/_interopDefault(fs);
30
31
  var path__default = /*#__PURE__*/_interopDefault(path);
32
+ var resolveFrom__default = /*#__PURE__*/_interopDefault(resolveFrom);
31
33
 
32
34
  // src/build/plugins/remove-deployer.ts
33
35
  function removeDeployer() {
@@ -103,7 +105,7 @@ function removeDeployer2(mastraEntry) {
103
105
  };
104
106
  }
105
107
  var PLUGIN_NAME = "tsconfig-paths";
106
- function tsConfigPaths({ tsConfigPath, respectCoreModule } = {}) {
108
+ function tsConfigPaths({ tsConfigPath, respectCoreModule, localResolve } = {}) {
107
109
  let handler;
108
110
  return {
109
111
  name: PLUGIN_NAME,
@@ -123,12 +125,52 @@ function tsConfigPaths({ tsConfigPath, respectCoreModule } = {}) {
123
125
  }
124
126
  const moduleName = handler?.(request, path.normalize(importer));
125
127
  if (!moduleName) {
126
- return this.resolve(request, importer, { skipSelf: true, ...options });
128
+ let importerMeta = {};
129
+ if (localResolve) {
130
+ const importerInfo = this.getModuleInfo(importer);
131
+ importerMeta = importerInfo?.meta || {};
132
+ if (!request.startsWith("./") && !request.startsWith("../") && importerMeta?.[PLUGIN_NAME]?.resolved) {
133
+ return {
134
+ id: resolveFrom__default.default(importer, request) ?? null,
135
+ external: true
136
+ };
137
+ }
138
+ }
139
+ const resolved = await this.resolve(request, importer, { skipSelf: true, ...options });
140
+ if (!resolved) {
141
+ return null;
142
+ }
143
+ return {
144
+ ...resolved,
145
+ meta: {
146
+ ...resolved.meta || {},
147
+ ...importerMeta
148
+ }
149
+ };
127
150
  }
128
151
  if (!path__default.default.extname(moduleName)) {
129
- return this.resolve(moduleName, importer, { skipSelf: true, ...options });
152
+ const resolved = await this.resolve(moduleName, importer, { skipSelf: true, ...options });
153
+ if (!resolved) {
154
+ return null;
155
+ }
156
+ return {
157
+ ...resolved,
158
+ meta: {
159
+ ...resolved.meta,
160
+ [PLUGIN_NAME]: {
161
+ resolved: true
162
+ }
163
+ }
164
+ };
130
165
  }
131
- return moduleName;
166
+ return {
167
+ id: moduleName,
168
+ meta: {
169
+ [PLUGIN_NAME]: {
170
+ resolved: true
171
+ }
172
+ }
173
+ };
132
174
  }
133
175
  };
134
176
  }