@mastra/deployer 0.0.0-commonjs-20250227130920

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 (86) hide show
  1. package/.turbo/turbo-build.log +41 -0
  2. package/CHANGELOG.md +897 -0
  3. package/LICENSE +44 -0
  4. package/README.md +159 -0
  5. package/dist/_tsup-dts-rollup.d.cts +360 -0
  6. package/dist/_tsup-dts-rollup.d.ts +360 -0
  7. package/dist/build/analyze.cjs +367 -0
  8. package/dist/build/analyze.d.cts +1 -0
  9. package/dist/build/analyze.d.ts +1 -0
  10. package/dist/build/analyze.js +2 -0
  11. package/dist/build/bundler.cjs +353 -0
  12. package/dist/build/bundler.d.cts +2 -0
  13. package/dist/build/bundler.d.ts +2 -0
  14. package/dist/build/bundler.js +2 -0
  15. package/dist/build/index.cjs +1146 -0
  16. package/dist/build/index.d.cts +10 -0
  17. package/dist/build/index.d.ts +10 -0
  18. package/dist/build/index.js +5 -0
  19. package/dist/bundler/index.cjs +999 -0
  20. package/dist/bundler/index.d.cts +1 -0
  21. package/dist/bundler/index.d.ts +1 -0
  22. package/dist/bundler/index.js +5 -0
  23. package/dist/chunk-3ONBKVC4.js +113 -0
  24. package/dist/chunk-AXS5WSIK.js +290 -0
  25. package/dist/chunk-DTSFVNIF.js +260 -0
  26. package/dist/chunk-JMH7HCD6.js +274 -0
  27. package/dist/chunk-SGK37ZWD.js +254 -0
  28. package/dist/chunk-YNXJO2XU.js +69 -0
  29. package/dist/index.cjs +1229 -0
  30. package/dist/index.d.cts +6 -0
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.js +131 -0
  33. package/dist/server/index.cjs +4930 -0
  34. package/dist/server/index.d.cts +2 -0
  35. package/dist/server/index.d.ts +2 -0
  36. package/dist/server/index.js +4923 -0
  37. package/dist/templates/instrumentation-template.js +86 -0
  38. package/eslint.config.js +6 -0
  39. package/global.d.ts +0 -0
  40. package/package.json +112 -0
  41. package/public/templates/instrumentation-template.js +86 -0
  42. package/src/build/analyze.ts +279 -0
  43. package/src/build/babel/fix-libsql.ts +41 -0
  44. package/src/build/babel/get-deployer.ts +54 -0
  45. package/src/build/babel/get-telemetry-config.ts +62 -0
  46. package/src/build/babel/remove-deployer.ts +43 -0
  47. package/src/build/bundle.ts +139 -0
  48. package/src/build/bundler.ts +135 -0
  49. package/src/build/deployer.ts +67 -0
  50. package/src/build/deps.ts +149 -0
  51. package/src/build/env.ts +76 -0
  52. package/src/build/fs.ts +66 -0
  53. package/src/build/index.ts +7 -0
  54. package/src/build/isNodeBuiltin.ts +7 -0
  55. package/src/build/plugins/fix-libsql.ts +69 -0
  56. package/src/build/plugins/hono-alias.ts +17 -0
  57. package/src/build/plugins/pino.ts +93 -0
  58. package/src/build/plugins/remove-deployer.ts +37 -0
  59. package/src/build/plugins/telemetry-fix.ts +54 -0
  60. package/src/build/telemetry.ts +76 -0
  61. package/src/build/utils.ts +12 -0
  62. package/src/build/watcher.ts +43 -0
  63. package/src/bundler/index.ts +144 -0
  64. package/src/deploy/base.ts +30 -0
  65. package/src/deploy/index.ts +2 -0
  66. package/src/deploy/log.ts +61 -0
  67. package/src/index.ts +3 -0
  68. package/src/server/handlers/agents.ts +209 -0
  69. package/src/server/handlers/client.ts +36 -0
  70. package/src/server/handlers/error.ts +29 -0
  71. package/src/server/handlers/logs.ts +53 -0
  72. package/src/server/handlers/memory.ts +196 -0
  73. package/src/server/handlers/prompt.ts +128 -0
  74. package/src/server/handlers/root.ts +6 -0
  75. package/src/server/handlers/telemetry.ts +48 -0
  76. package/src/server/handlers/tools.ts +114 -0
  77. package/src/server/handlers/utils.ts +15 -0
  78. package/src/server/handlers/vector.ts +149 -0
  79. package/src/server/handlers/workflows.ts +119 -0
  80. package/src/server/index.ts +1355 -0
  81. package/src/server/openapi.json +434 -0
  82. package/src/server/openapi.script.js +22 -0
  83. package/src/server/types.ts +4 -0
  84. package/src/server/welcome.ts +105 -0
  85. package/tsconfig.json +5 -0
  86. package/vitest.config.ts +8 -0
@@ -0,0 +1,274 @@
1
+ import { removeDeployer } from './chunk-YNXJO2XU.js';
2
+ import commonjs from '@rollup/plugin-commonjs';
3
+ import json from '@rollup/plugin-json';
4
+ import nodeResolve from '@rollup/plugin-node-resolve';
5
+ import virtual from '@rollup/plugin-virtual';
6
+ import { existsSync } from 'node:fs';
7
+ import { fileURLToPath } from 'node:url';
8
+ import { rollup } from 'rollup';
9
+ import esbuild from 'rollup-plugin-esbuild';
10
+ import { builtinModules } from 'node:module';
11
+
12
+ function isNodeBuiltin(dep) {
13
+ const [pkg] = dep.split("/");
14
+ return dep.startsWith("node:") || builtinModules.includes(dep) || builtinModules.includes(pkg);
15
+ }
16
+ function aliasHono() {
17
+ return {
18
+ name: "hono-alias",
19
+ resolveId(id) {
20
+ if (!id.startsWith("@hono/") && !id.startsWith("hono/") && id !== "hono" && id !== "hono-openapi") {
21
+ return;
22
+ }
23
+ const path = import.meta.resolve(id);
24
+ return fileURLToPath(path);
25
+ }
26
+ };
27
+ }
28
+
29
+ // src/build/plugins/pino.ts
30
+ function pino() {
31
+ const workerFiles = [
32
+ {
33
+ id: "thread-stream-worker",
34
+ file: "pino-thread-stream-worker"
35
+ },
36
+ {
37
+ id: "pino-worker",
38
+ file: "pino-worker"
39
+ },
40
+ {
41
+ id: "pino/file",
42
+ file: "pino-file"
43
+ },
44
+ {
45
+ id: "pino-pretty",
46
+ file: "pino-pretty"
47
+ }
48
+ ];
49
+ const fileReferences = /* @__PURE__ */ new Map();
50
+ return {
51
+ name: "rollup-plugin-pino",
52
+ async resolveId(id, importee) {
53
+ if (id === "pino") {
54
+ const resolvedPino = await this.resolve(id, importee);
55
+ if (resolvedPino) {
56
+ await Promise.all(
57
+ workerFiles.map(async (file) => {
58
+ const resolvedEntry = await this.resolve(file.id, resolvedPino.id);
59
+ if (!resolvedEntry) {
60
+ return null;
61
+ }
62
+ const reference = this.emitFile({
63
+ type: "chunk",
64
+ id: resolvedEntry.id,
65
+ name: `${file.file}`
66
+ });
67
+ fileReferences.set(file.id, reference);
68
+ })
69
+ );
70
+ }
71
+ }
72
+ },
73
+ renderChunk(code, chunk) {
74
+ if (chunk.type === "chunk" && chunk.isEntry && fileReferences.size && chunk.name === "index") {
75
+ const importRegex = /^(?:import(?:["'\s]*[\w*${}\n\r\t, ]+from\s*)?["'\s].+[;"'\s]*)$/gm;
76
+ const codeToInject = `globalThis.__bundlerPathsOverrides = {
77
+ ${Array.from(fileReferences.entries()).map(([key, file]) => {
78
+ return '"' + key + '": import.meta.ROLLUP_FILE_URL_' + file;
79
+ }).join(",\n")}
80
+ };`;
81
+ const matches = Array.from(code.matchAll(importRegex));
82
+ if (matches.length > 0) {
83
+ const lastImport = matches[matches.length - 1];
84
+ const lastImportEnd = lastImport.index + lastImport[0].length;
85
+ const newCode = code.slice(0, lastImportEnd) + "\n\n" + codeToInject + "\n\n" + code.slice(lastImportEnd);
86
+ return {
87
+ code: newCode,
88
+ map: null
89
+ };
90
+ }
91
+ return {
92
+ code: `${codeToInject}
93
+
94
+ ${code}`,
95
+ map: null
96
+ };
97
+ }
98
+ }
99
+ };
100
+ }
101
+
102
+ // src/build/analyze.ts
103
+ async function analyze(entry, mastraEntry, isVirtualFile, platform, logger) {
104
+ logger.info("Analyzing dependencies...");
105
+ let virtualPlugin = null;
106
+ if (isVirtualFile) {
107
+ virtualPlugin = virtual({
108
+ "#entry": entry
109
+ });
110
+ entry = "#entry";
111
+ }
112
+ const optimizerBundler = await rollup({
113
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
114
+ input: isVirtualFile ? "#entry" : entry,
115
+ treeshake: true,
116
+ preserveSymlinks: true,
117
+ plugins: [
118
+ virtualPlugin,
119
+ {
120
+ name: "custom-alias-resolver",
121
+ resolveId(id) {
122
+ if (id === "#server") {
123
+ return fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/");
124
+ }
125
+ if (id === "#mastra") {
126
+ return mastraEntry.replaceAll("\\", "/");
127
+ }
128
+ }
129
+ },
130
+ json(),
131
+ commonjs({
132
+ strictRequires: "debug",
133
+ ignoreTryCatch: false,
134
+ transformMixedEsModules: true,
135
+ extensions: [".js", ".ts"]
136
+ }),
137
+ esbuild({
138
+ target: "node20",
139
+ platform,
140
+ minify: false
141
+ }),
142
+ removeDeployer(mastraEntry),
143
+ esbuild({
144
+ target: "node20",
145
+ platform,
146
+ minify: false
147
+ })
148
+ ].filter(Boolean)
149
+ });
150
+ const { output } = await optimizerBundler.generate({
151
+ format: "esm",
152
+ inlineDynamicImports: true
153
+ });
154
+ await optimizerBundler.close();
155
+ const depsToOptimize = new Map(Object.entries(output[0].importedBindings));
156
+ for (const dep of depsToOptimize.keys()) {
157
+ if (isNodeBuiltin(dep)) {
158
+ depsToOptimize.delete(dep);
159
+ }
160
+ }
161
+ return depsToOptimize;
162
+ }
163
+ async function bundleExternals(depsToOptimize, outputDir, logger) {
164
+ logger.info("Optimizing dependencies...");
165
+ logger.debug(
166
+ `${Array.from(depsToOptimize.keys()).map((key) => `- ${key}`).join("\n")}`
167
+ );
168
+ const reverseVirtualReferenceMap = /* @__PURE__ */ new Map();
169
+ const virtualDependencies = /* @__PURE__ */ new Map();
170
+ for (const [dep, exports] of depsToOptimize.entries()) {
171
+ const name = dep.replaceAll("/", "-");
172
+ reverseVirtualReferenceMap.set(name, dep);
173
+ const virtualFile = [];
174
+ let exportStringBuilder = [];
175
+ for (const local of exports) {
176
+ if (local === "*") {
177
+ virtualFile.push(`export * from '${dep}';`);
178
+ } else if (local === "default") {
179
+ virtualFile.push(`export * from '${dep}';`);
180
+ } else {
181
+ exportStringBuilder.push(local);
182
+ }
183
+ }
184
+ if (exportStringBuilder.length > 0) {
185
+ virtualFile.push(`export { ${exportStringBuilder.join(", ")} } from '${dep}';`);
186
+ }
187
+ virtualDependencies.set(dep, {
188
+ name,
189
+ virtual: virtualFile.join("\n")
190
+ });
191
+ }
192
+ const bundler = await rollup({
193
+ logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
194
+ input: Array.from(virtualDependencies.entries()).reduce(
195
+ (acc, [dep, virtualDep]) => {
196
+ acc[virtualDep.name] = `#virtual-${dep}`;
197
+ return acc;
198
+ },
199
+ {}
200
+ ),
201
+ // this dependency breaks the build, so we need to exclude it
202
+ // TODO actually fix this so we don't need to exclude it
203
+ external: ["jsdom"],
204
+ treeshake: "smallest",
205
+ preserveSymlinks: true,
206
+ plugins: [
207
+ virtual(
208
+ Array.from(virtualDependencies.entries()).reduce(
209
+ (acc, [dep, virtualDep]) => {
210
+ acc[`#virtual-${dep}`] = virtualDep.virtual;
211
+ return acc;
212
+ },
213
+ {}
214
+ )
215
+ ),
216
+ pino(),
217
+ commonjs({
218
+ strictRequires: "strict",
219
+ transformMixedEsModules: true,
220
+ ignoreTryCatch: false
221
+ }),
222
+ nodeResolve({
223
+ preferBuiltins: true,
224
+ exportConditions: ["node", "import", "require"],
225
+ mainFields: ["module", "main"]
226
+ }),
227
+ // hono is imported from deployer, so we need to resolve from here instead of the project root
228
+ aliasHono(),
229
+ json()
230
+ ].filter(Boolean)
231
+ });
232
+ const { output } = await bundler.write({
233
+ format: "esm",
234
+ dir: outputDir,
235
+ entryFileNames: "[name].mjs",
236
+ chunkFileNames: "[name].mjs"
237
+ });
238
+ await bundler.close();
239
+ return { output, reverseVirtualReferenceMap };
240
+ }
241
+ async function validateOutput(output, reverseVirtualReferenceMap, outputDir, logger) {
242
+ const result = {
243
+ invalidChunks: /* @__PURE__ */ new Set(),
244
+ dependencies: /* @__PURE__ */ new Map(),
245
+ externalDependencies: /* @__PURE__ */ new Set()
246
+ };
247
+ for (const file of output) {
248
+ if (file.type === "asset") {
249
+ continue;
250
+ }
251
+ try {
252
+ logger.debug(`Validating if ${file.fileName} is a valid module.`);
253
+ if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
254
+ result.dependencies.set(reverseVirtualReferenceMap.get(file.name), file.fileName);
255
+ }
256
+ await import(`file:${outputDir}/${file.fileName}`);
257
+ } catch (err) {
258
+ result.invalidChunks.add(file.fileName);
259
+ if (file.isEntry && reverseVirtualReferenceMap.has(file.name)) {
260
+ result.externalDependencies.add(reverseVirtualReferenceMap.get(file.name));
261
+ }
262
+ }
263
+ }
264
+ return result;
265
+ }
266
+ async function analyzeBundle(entry, mastraEntry, outputDir, platform, logger) {
267
+ const isVirtualFile = entry.includes("\n") || !existsSync(entry);
268
+ const depsToOptimize = await analyze(entry, mastraEntry, isVirtualFile, platform, logger);
269
+ const { output, reverseVirtualReferenceMap } = await bundleExternals(depsToOptimize, outputDir, logger);
270
+ const result = await validateOutput(output, reverseVirtualReferenceMap, outputDir, logger);
271
+ return result;
272
+ }
273
+
274
+ export { aliasHono, analyzeBundle };
@@ -0,0 +1,254 @@
1
+ import { aliasHono } from './chunk-JMH7HCD6.js';
2
+ import { getInputOptions, telemetryFix, libSqlFix } from './chunk-DTSFVNIF.js';
3
+ import { removeDeployer } from './chunk-YNXJO2XU.js';
4
+ import alias from '@rollup/plugin-alias';
5
+ import commonjs from '@rollup/plugin-commonjs';
6
+ import json from '@rollup/plugin-json';
7
+ import { nodeResolve } from '@rollup/plugin-node-resolve';
8
+ import { builtinModules } from 'node:module';
9
+ import path, { join } from 'path';
10
+ import { rollup, watch } from 'rollup';
11
+ import esbuild from 'rollup-plugin-esbuild';
12
+ import { fileURLToPath } from 'url';
13
+ import * as fs2 from 'fs';
14
+ import fs2__default from 'fs';
15
+ import fsExtra from 'fs-extra/esm';
16
+
17
+ var EnvService = class {
18
+ };
19
+ var FileEnvService = class extends EnvService {
20
+ filePath;
21
+ constructor(filePath) {
22
+ super();
23
+ this.filePath = filePath;
24
+ }
25
+ readFile(filePath) {
26
+ return new Promise((resolve, reject) => {
27
+ fs2.readFile(filePath, "utf8", (err, data) => {
28
+ if (err) reject(err);
29
+ else resolve(data);
30
+ });
31
+ });
32
+ }
33
+ writeFile({ filePath, data }) {
34
+ return new Promise((resolve, reject) => {
35
+ fs2.writeFile(filePath, data, "utf8", (err) => {
36
+ if (err) reject(err);
37
+ else resolve();
38
+ });
39
+ });
40
+ }
41
+ async updateEnvData({
42
+ key,
43
+ value,
44
+ filePath = this.filePath,
45
+ data
46
+ }) {
47
+ const regex = new RegExp(`^${key}=.*$`, "m");
48
+ if (data.match(regex)) {
49
+ data = data.replace(regex, `${key}=${value}`);
50
+ } else {
51
+ data += `
52
+ ${key}=${value}`;
53
+ }
54
+ await this.writeFile({ filePath, data });
55
+ console.log(`${key} set to ${value} in ENV file.`);
56
+ return data;
57
+ }
58
+ async getEnvValue(key) {
59
+ try {
60
+ const data = await this.readFile(this.filePath);
61
+ const regex = new RegExp(`^${key}=(.*)$`, "m");
62
+ const match = data.match(regex);
63
+ return match?.[1] || null;
64
+ } catch (err) {
65
+ console.error(`Error reading ENV value: ${err}`);
66
+ return null;
67
+ }
68
+ }
69
+ async setEnvValue(key, value) {
70
+ try {
71
+ const data = await this.readFile(this.filePath);
72
+ await this.updateEnvData({ key, value, data });
73
+ } catch (err) {
74
+ console.error(`Error writing ENV value: ${err}`);
75
+ }
76
+ }
77
+ };
78
+
79
+ // src/build/fs.ts
80
+ var FileService = class {
81
+ /**
82
+ *
83
+ * @param inputFile the file in the starter files directory to copy
84
+ * @param outputFilePath the destination path
85
+ * @param replaceIfExists flag to replace if it exists
86
+ * @returns
87
+ */
88
+ async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
89
+ const __filename = fileURLToPath(import.meta.url);
90
+ const __dirname = path.dirname(__filename);
91
+ const filePath = path.resolve(__dirname, "..", "starter-files", inputFile);
92
+ const fileString = fs2__default.readFileSync(filePath, "utf8");
93
+ if (fs2__default.existsSync(outputFilePath) && !replaceIfExists) {
94
+ console.log(`${outputFilePath} already exists`);
95
+ return false;
96
+ }
97
+ await fsExtra.outputFile(outputFilePath, fileString);
98
+ return true;
99
+ }
100
+ async setupEnvFile({ dbUrl }) {
101
+ const envPath = path.join(process.cwd(), ".env.development");
102
+ await fsExtra.ensureFile(envPath);
103
+ const fileEnvService = new FileEnvService(envPath);
104
+ await fileEnvService.setEnvValue("DB_URL", dbUrl);
105
+ }
106
+ getFirstExistingFile(files) {
107
+ for (const f of files) {
108
+ if (fs2__default.existsSync(f)) {
109
+ return f;
110
+ }
111
+ }
112
+ throw new Error("Missing required file, checked the following paths: " + files.join(", "));
113
+ }
114
+ replaceValuesInFile({
115
+ filePath,
116
+ replacements
117
+ }) {
118
+ let fileContent = fs2__default.readFileSync(filePath, "utf8");
119
+ replacements.forEach(({ search, replace }) => {
120
+ fileContent = fileContent.replaceAll(search, replace);
121
+ });
122
+ fs2__default.writeFileSync(filePath, fileContent);
123
+ }
124
+ };
125
+
126
+ // src/build/bundle.ts
127
+ function getOptions(inputOptions, platform, root) {
128
+ const fileService = new FileService();
129
+ const entry = fileService.getFirstExistingFile([
130
+ join(root, "src/mastra/index.ts"),
131
+ join(root, "src/mastra/index.js")
132
+ ]);
133
+ const nodeBuiltins = platform === "node" ? builtinModules : [];
134
+ let nodeResolvePlugin = platform === "node" ? nodeResolve({
135
+ preferBuiltins: true,
136
+ exportConditions: ["node", "import", "require"],
137
+ mainFields: ["module", "main"]
138
+ }) : nodeResolve({
139
+ preferBuiltins: false,
140
+ exportConditions: ["browser", "import", "require"],
141
+ mainFields: ["module", "main"],
142
+ browser: true
143
+ });
144
+ return {
145
+ logLevel: "silent",
146
+ ...inputOptions,
147
+ treeshake: false,
148
+ preserveSymlinks: true,
149
+ external: [
150
+ ...nodeBuiltins,
151
+ ...nodeBuiltins.map((builtin) => "node:" + builtin),
152
+ ...inputOptions.external ?? []
153
+ ],
154
+ plugins: [
155
+ ...inputOptions.plugins ?? [],
156
+ telemetryFix(),
157
+ alias({
158
+ entries: [
159
+ {
160
+ find: /^\#server$/,
161
+ replacement: fileURLToPath(import.meta.resolve("@mastra/deployer/server")).replaceAll("\\", "/")
162
+ },
163
+ { find: /^\#mastra$/, replacement: entry.replaceAll("\\", "/") },
164
+ {
165
+ find: /^hono\//,
166
+ replacement: "hono/",
167
+ customResolver: (id, importer) => {
168
+ if (!importer?.startsWith("\0virtual")) {
169
+ return null;
170
+ }
171
+ const path2 = import.meta.resolve(id);
172
+ return fileURLToPath(path2);
173
+ }
174
+ }
175
+ ]
176
+ }),
177
+ commonjs({
178
+ strictRequires: "strict",
179
+ transformMixedEsModules: true
180
+ // dynamicRequireTargets: ['node_modules/**/@libsql+win32-*/*'],
181
+ }),
182
+ libSqlFix(),
183
+ // for debugging
184
+ // {
185
+ // name: 'logger',
186
+ // // @ts-ignore
187
+ // resolveId(id, ...args) {
188
+ // console.log({ id, args });
189
+ // },
190
+ // },
191
+ nodeResolvePlugin,
192
+ json(),
193
+ esbuild({
194
+ include: /\.tsx?$/,
195
+ target: "node20",
196
+ platform,
197
+ minify: false,
198
+ define: {
199
+ "process.env.NODE_ENV": JSON.stringify("production")
200
+ }
201
+ }),
202
+ removeDeployer(entry),
203
+ esbuild({
204
+ include: entry,
205
+ target: "node20",
206
+ platform,
207
+ minify: false
208
+ })
209
+ ].filter(Boolean)
210
+ };
211
+ }
212
+ async function getBundler(inputOptions, args = {}) {
213
+ const { platform = "node", dir = process.cwd() } = args;
214
+ const bundle = await rollup(getOptions(inputOptions, platform, dir));
215
+ return bundle;
216
+ }
217
+ async function getWatcher(inputOptions, args = {}) {
218
+ const { platform = "node", dir = process.cwd() } = args;
219
+ const watcher = watch(getOptions(inputOptions, platform, dir));
220
+ return watcher;
221
+ }
222
+ async function getInputOptions2(entryFile, platform) {
223
+ const inputOptions = await getInputOptions(
224
+ entryFile,
225
+ {
226
+ dependencies: /* @__PURE__ */ new Map(),
227
+ externalDependencies: /* @__PURE__ */ new Set(),
228
+ invalidChunks: /* @__PURE__ */ new Set()
229
+ },
230
+ platform
231
+ );
232
+ if (Array.isArray(inputOptions.plugins)) {
233
+ inputOptions.plugins = inputOptions.plugins.filter(
234
+ // @ts-ignore
235
+ (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
236
+ );
237
+ inputOptions.plugins.push(aliasHono());
238
+ }
239
+ return inputOptions;
240
+ }
241
+ async function createWatcher(inputOptions, outputOptions) {
242
+ const watcher = await watch({
243
+ ...inputOptions,
244
+ output: {
245
+ ...outputOptions,
246
+ format: "esm",
247
+ entryFileNames: "[name].mjs",
248
+ chunkFileNames: "[name].mjs"
249
+ }
250
+ });
251
+ return watcher;
252
+ }
253
+
254
+ export { FileService, createWatcher, getBundler, getInputOptions2 as getInputOptions, getWatcher };
@@ -0,0 +1,69 @@
1
+ import * as babel from '@babel/core';
2
+ import babel__default from '@babel/core';
3
+
4
+ // src/build/plugins/remove-deployer.ts
5
+ function removeDeployer() {
6
+ const t = babel__default.types;
7
+ let mastraClass = null;
8
+ return {
9
+ name: "remove-deployer",
10
+ visitor: {
11
+ ImportDeclaration(path) {
12
+ if ((path.node.source.value === "@mastra/core" || path.node.source.value === "@mastra/core/mastra") && path.node.specifiers) {
13
+ const mastraObj = path.node.specifiers.find(
14
+ (p) => t.isImportSpecifier(p) && t.isIdentifier(p.imported) && p.imported.name === "Mastra"
15
+ );
16
+ if (mastraObj?.local?.name) {
17
+ mastraClass = mastraObj.local.name;
18
+ }
19
+ }
20
+ },
21
+ NewExpression(path, state) {
22
+ if (mastraClass && t.isIdentifier(path.node.callee) && path.node.callee.name === mastraClass && !state.hasReplaced) {
23
+ state.hasReplaced = true;
24
+ const newMastraObj = t.cloneNode(path.node);
25
+ if (t.isObjectExpression(newMastraObj.arguments[0]) && newMastraObj.arguments[0].properties?.[0]) {
26
+ newMastraObj.arguments[0].properties = newMastraObj.arguments[0].properties.filter(
27
+ (prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name !== "deployer"
28
+ );
29
+ path.replaceWith(newMastraObj);
30
+ }
31
+ }
32
+ }
33
+ }
34
+ };
35
+ }
36
+
37
+ // src/build/plugins/remove-deployer.ts
38
+ function removeDeployer2(mastraEntry) {
39
+ return {
40
+ name: "remove-deployer",
41
+ transform(code, id) {
42
+ if (id !== mastraEntry) {
43
+ return;
44
+ }
45
+ return new Promise((resolve, reject) => {
46
+ babel.transform(
47
+ code,
48
+ {
49
+ babelrc: false,
50
+ configFile: false,
51
+ filename: id,
52
+ plugins: [removeDeployer]
53
+ },
54
+ (err, result) => {
55
+ if (err) {
56
+ return reject(err);
57
+ }
58
+ resolve({
59
+ code: result.code,
60
+ map: result.map
61
+ });
62
+ }
63
+ );
64
+ });
65
+ }
66
+ };
67
+ }
68
+
69
+ export { removeDeployer2 as removeDeployer };