@mastra/deployer 0.2.5 → 0.2.6-alpha.10

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 (40) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +95 -33
  2. package/dist/_tsup-dts-rollup.d.ts +95 -33
  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 +22 -24
  8. package/dist/build/index.d.cts +3 -4
  9. package/dist/build/index.d.ts +3 -4
  10. package/dist/build/index.js +6 -4
  11. package/dist/bundler/index.cjs +2 -2
  12. package/dist/bundler/index.js +1 -1
  13. package/dist/chunk-2ZPQX6BX.cjs +254 -0
  14. package/dist/chunk-4AYFLP6G.js +227 -0
  15. package/dist/chunk-5UBGPRKT.js +185 -0
  16. package/dist/{chunk-KLVSED7T.js → chunk-74KZVNKH.js} +8 -4
  17. package/dist/{chunk-OT6UKL2S.cjs → chunk-AE4CVAPK.cjs} +11 -0
  18. package/dist/{chunk-UTZ3434D.js → chunk-BDTZS3JM.js} +3 -0
  19. package/dist/chunk-DYQ225MJ.js +115 -0
  20. package/dist/chunk-I3UVE6EH.cjs +161 -0
  21. package/dist/{chunk-XEFBJH3T.js → chunk-IKPL4RGG.js} +11 -0
  22. package/dist/chunk-NCROGJGB.cjs +142 -0
  23. package/dist/{chunk-NWERLYTR.cjs → chunk-P5SATU7G.cjs} +3 -0
  24. package/dist/chunk-VFZVVUQE.cjs +198 -0
  25. package/dist/chunk-WB3T6NKI.js +133 -0
  26. package/dist/{chunk-NXBTVZHO.cjs → chunk-WFC3CUZ3.cjs} +14 -10
  27. package/dist/index.cjs +12 -11
  28. package/dist/index.js +7 -6
  29. package/dist/server/index.cjs +617 -2682
  30. package/dist/server/index.js +512 -2577
  31. package/dist/services/index.cjs +19 -0
  32. package/dist/services/index.d.cts +3 -0
  33. package/dist/services/index.d.ts +3 -0
  34. package/dist/services/index.js +2 -0
  35. package/dist/templates/instrumentation-template.js +25 -30
  36. package/package.json +15 -4
  37. package/dist/chunk-7GYBZLVN.cjs +0 -286
  38. package/dist/chunk-KFOGAPGX.cjs +0 -433
  39. package/dist/chunk-PUX2FDGX.js +0 -252
  40. package/dist/chunk-ZAXXMFXX.js +0 -399
@@ -0,0 +1,254 @@
1
+ 'use strict';
2
+
3
+ var babel = require('@babel/core');
4
+ var rollup = require('rollup');
5
+ var esbuild = require('rollup-plugin-esbuild');
6
+ var commonjs = require('@rollup/plugin-commonjs');
7
+
8
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
29
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
30
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
31
+
32
+ // src/build/telemetry.ts
33
+ function removeAllOptionsFromMastraExcept(result, option) {
34
+ const t = babel__namespace.default.types;
35
+ return {
36
+ name: "remove-all-except-" + option + "-config",
37
+ visitor: {
38
+ ExportNamedDeclaration: {
39
+ // remove all exports
40
+ exit(path) {
41
+ path.remove();
42
+ }
43
+ },
44
+ NewExpression(path, state) {
45
+ const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
46
+ if (!varDeclaratorPath) {
47
+ return;
48
+ }
49
+ const parentNode = path.parentPath.node;
50
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
51
+ return;
52
+ }
53
+ let mastraArgs = t.objectExpression([]);
54
+ if (t.isObjectExpression(path.node.arguments[0])) {
55
+ mastraArgs = path.node.arguments[0];
56
+ }
57
+ let telemetry = mastraArgs.properties.find(
58
+ // @ts-ignore
59
+ (prop) => prop.key.name === option
60
+ );
61
+ let telemetryValue = t.objectExpression([]);
62
+ const programPath = path.scope.getProgramParent().path;
63
+ if (!programPath) {
64
+ return;
65
+ }
66
+ if (telemetry && t.isObjectProperty(telemetry) && t.isExpression(telemetry.value)) {
67
+ result.hasCustomConfig = true;
68
+ telemetryValue = telemetry.value;
69
+ if (t.isIdentifier(telemetry.value) && telemetry.value.name === option) {
70
+ const telemetryBinding = state.file.scope.getBinding(option);
71
+ if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {
72
+ const id = path.scope.generateUidIdentifier(option);
73
+ telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init));
74
+ telemetryValue = id;
75
+ }
76
+ }
77
+ }
78
+ const exportDeclaration = t.exportNamedDeclaration(
79
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), telemetryValue)]),
80
+ []
81
+ );
82
+ programPath.node.body.push(exportDeclaration);
83
+ }
84
+ }
85
+ };
86
+ }
87
+
88
+ // src/build/babel/remove-all-options-telemetry.ts
89
+ function removeAllOptionsExceptTelemetry(result) {
90
+ return removeAllOptionsFromMastraExcept(result, "telemetry");
91
+ }
92
+ function removeNonReferencedNodes() {
93
+ const t = babel__namespace.default.types;
94
+ return {
95
+ name: "remove-non-referenced-nodes",
96
+ visitor: {
97
+ Program(path) {
98
+ const scope = path.scope;
99
+ const currentBody = path.get("body");
100
+ const filteredBody = currentBody.filter((childPath) => {
101
+ if (childPath.isExportDeclaration()) {
102
+ return true;
103
+ }
104
+ if (childPath.isVariableDeclaration()) {
105
+ return childPath.node.declarations.some((decl) => {
106
+ if (!t.isIdentifier(decl.id)) {
107
+ return false;
108
+ }
109
+ const name = decl.id.name;
110
+ const binding = scope.getBinding(name);
111
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
112
+ });
113
+ }
114
+ if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
115
+ if (!t.isIdentifier(childPath.node.id)) {
116
+ return false;
117
+ }
118
+ const name = childPath.node.id.name;
119
+ const binding = scope.getBinding(name);
120
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
121
+ }
122
+ if (childPath.isImportDeclaration()) {
123
+ return childPath.node.specifiers.some((specifier) => {
124
+ const importedName = specifier.local.name;
125
+ const binding = scope.getBinding(importedName);
126
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
127
+ });
128
+ }
129
+ return false;
130
+ });
131
+ path.set(
132
+ "body",
133
+ filteredBody.map((p) => p.node)
134
+ );
135
+ }
136
+ }
137
+ };
138
+ }
139
+
140
+ // src/build/plugins/remove-unused-references.ts
141
+ function recursiveRemoveNonReferencedNodes(code) {
142
+ return new Promise(async (resolve, reject) => {
143
+ babel__namespace.transform(
144
+ code,
145
+ {
146
+ babelrc: false,
147
+ configFile: false,
148
+ plugins: [removeNonReferencedNodes()]
149
+ },
150
+ (err, result) => {
151
+ if (err) {
152
+ return reject(err);
153
+ }
154
+ if (result && result.code !== code) {
155
+ return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
156
+ }
157
+ resolve({
158
+ code: result.code,
159
+ map: result.map
160
+ });
161
+ }
162
+ );
163
+ });
164
+ }
165
+
166
+ // src/build/telemetry.ts
167
+ function getTelemetryBundler(entryFile, result) {
168
+ return rollup.rollup({
169
+ logLevel: "silent",
170
+ input: {
171
+ "telemetry-config": entryFile
172
+ },
173
+ treeshake: "smallest",
174
+ plugins: [
175
+ // transpile typescript to something we understand
176
+ esbuild__default.default({
177
+ target: "node20",
178
+ platform: "node",
179
+ minify: false
180
+ }),
181
+ commonjs__default.default({
182
+ extensions: [".js", ".ts"],
183
+ strictRequires: "strict",
184
+ transformMixedEsModules: true,
185
+ ignoreTryCatch: false
186
+ }),
187
+ {
188
+ name: "get-telemetry-config",
189
+ transform(code, id) {
190
+ if (id !== entryFile) {
191
+ return;
192
+ }
193
+ return new Promise((resolve, reject) => {
194
+ babel__namespace.transform(
195
+ code,
196
+ {
197
+ babelrc: false,
198
+ configFile: false,
199
+ filename: id,
200
+ plugins: [removeAllOptionsExceptTelemetry(result)]
201
+ },
202
+ (err, result2) => {
203
+ if (err) {
204
+ return reject(err);
205
+ }
206
+ resolve({
207
+ code: result2.code,
208
+ map: result2.map
209
+ });
210
+ }
211
+ );
212
+ });
213
+ }
214
+ },
215
+ // let esbuild remove all unused imports
216
+ esbuild__default.default({
217
+ target: "node20",
218
+ platform: "node",
219
+ minify: false
220
+ }),
221
+ {
222
+ name: "cleanup",
223
+ transform(code, id) {
224
+ if (id !== entryFile) {
225
+ return;
226
+ }
227
+ return recursiveRemoveNonReferencedNodes(code);
228
+ }
229
+ },
230
+ // let esbuild remove all unused imports
231
+ esbuild__default.default({
232
+ target: "node20",
233
+ platform: "node",
234
+ minify: false
235
+ })
236
+ ]
237
+ });
238
+ }
239
+ async function writeTelemetryConfig(entryFile, outputDir) {
240
+ const result = {
241
+ hasCustomConfig: false
242
+ };
243
+ const bundle = await getTelemetryBundler(entryFile, result);
244
+ await bundle.write({
245
+ dir: outputDir,
246
+ format: "es",
247
+ entryFileNames: "[name].mjs"
248
+ });
249
+ return result;
250
+ }
251
+
252
+ exports.recursiveRemoveNonReferencedNodes = recursiveRemoveNonReferencedNodes;
253
+ exports.removeAllOptionsFromMastraExcept = removeAllOptionsFromMastraExcept;
254
+ exports.writeTelemetryConfig = writeTelemetryConfig;
@@ -0,0 +1,227 @@
1
+ import * as babel from '@babel/core';
2
+ import babel__default from '@babel/core';
3
+ import { rollup } from 'rollup';
4
+ import esbuild from 'rollup-plugin-esbuild';
5
+ import commonjs from '@rollup/plugin-commonjs';
6
+
7
+ // src/build/telemetry.ts
8
+ function removeAllOptionsFromMastraExcept(result, option) {
9
+ const t = babel__default.types;
10
+ return {
11
+ name: "remove-all-except-" + option + "-config",
12
+ visitor: {
13
+ ExportNamedDeclaration: {
14
+ // remove all exports
15
+ exit(path) {
16
+ path.remove();
17
+ }
18
+ },
19
+ NewExpression(path, state) {
20
+ const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
21
+ if (!varDeclaratorPath) {
22
+ return;
23
+ }
24
+ const parentNode = path.parentPath.node;
25
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
26
+ return;
27
+ }
28
+ let mastraArgs = t.objectExpression([]);
29
+ if (t.isObjectExpression(path.node.arguments[0])) {
30
+ mastraArgs = path.node.arguments[0];
31
+ }
32
+ let telemetry = mastraArgs.properties.find(
33
+ // @ts-ignore
34
+ (prop) => prop.key.name === option
35
+ );
36
+ let telemetryValue = t.objectExpression([]);
37
+ const programPath = path.scope.getProgramParent().path;
38
+ if (!programPath) {
39
+ return;
40
+ }
41
+ if (telemetry && t.isObjectProperty(telemetry) && t.isExpression(telemetry.value)) {
42
+ result.hasCustomConfig = true;
43
+ telemetryValue = telemetry.value;
44
+ if (t.isIdentifier(telemetry.value) && telemetry.value.name === option) {
45
+ const telemetryBinding = state.file.scope.getBinding(option);
46
+ if (telemetryBinding && t.isVariableDeclarator(telemetryBinding.path.node)) {
47
+ const id = path.scope.generateUidIdentifier(option);
48
+ telemetryBinding.path.replaceWith(t.variableDeclarator(id, telemetryBinding.path.node.init));
49
+ telemetryValue = id;
50
+ }
51
+ }
52
+ }
53
+ const exportDeclaration = t.exportNamedDeclaration(
54
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), telemetryValue)]),
55
+ []
56
+ );
57
+ programPath.node.body.push(exportDeclaration);
58
+ }
59
+ }
60
+ };
61
+ }
62
+
63
+ // src/build/babel/remove-all-options-telemetry.ts
64
+ function removeAllOptionsExceptTelemetry(result) {
65
+ return removeAllOptionsFromMastraExcept(result, "telemetry");
66
+ }
67
+ function removeNonReferencedNodes() {
68
+ const t = babel__default.types;
69
+ return {
70
+ name: "remove-non-referenced-nodes",
71
+ visitor: {
72
+ Program(path) {
73
+ const scope = path.scope;
74
+ const currentBody = path.get("body");
75
+ const filteredBody = currentBody.filter((childPath) => {
76
+ if (childPath.isExportDeclaration()) {
77
+ return true;
78
+ }
79
+ if (childPath.isVariableDeclaration()) {
80
+ return childPath.node.declarations.some((decl) => {
81
+ if (!t.isIdentifier(decl.id)) {
82
+ return false;
83
+ }
84
+ const name = decl.id.name;
85
+ const binding = scope.getBinding(name);
86
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
87
+ });
88
+ }
89
+ if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
90
+ if (!t.isIdentifier(childPath.node.id)) {
91
+ return false;
92
+ }
93
+ const name = childPath.node.id.name;
94
+ const binding = scope.getBinding(name);
95
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
96
+ }
97
+ if (childPath.isImportDeclaration()) {
98
+ return childPath.node.specifiers.some((specifier) => {
99
+ const importedName = specifier.local.name;
100
+ const binding = scope.getBinding(importedName);
101
+ return binding && (binding.referenced || binding.referencePaths.length > 0);
102
+ });
103
+ }
104
+ return false;
105
+ });
106
+ path.set(
107
+ "body",
108
+ filteredBody.map((p) => p.node)
109
+ );
110
+ }
111
+ }
112
+ };
113
+ }
114
+
115
+ // src/build/plugins/remove-unused-references.ts
116
+ function recursiveRemoveNonReferencedNodes(code) {
117
+ return new Promise(async (resolve, reject) => {
118
+ babel.transform(
119
+ code,
120
+ {
121
+ babelrc: false,
122
+ configFile: false,
123
+ plugins: [removeNonReferencedNodes()]
124
+ },
125
+ (err, result) => {
126
+ if (err) {
127
+ return reject(err);
128
+ }
129
+ if (result && result.code !== code) {
130
+ return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
131
+ }
132
+ resolve({
133
+ code: result.code,
134
+ map: result.map
135
+ });
136
+ }
137
+ );
138
+ });
139
+ }
140
+
141
+ // src/build/telemetry.ts
142
+ function getTelemetryBundler(entryFile, result) {
143
+ return rollup({
144
+ logLevel: "silent",
145
+ input: {
146
+ "telemetry-config": entryFile
147
+ },
148
+ treeshake: "smallest",
149
+ plugins: [
150
+ // transpile typescript to something we understand
151
+ esbuild({
152
+ target: "node20",
153
+ platform: "node",
154
+ minify: false
155
+ }),
156
+ commonjs({
157
+ extensions: [".js", ".ts"],
158
+ strictRequires: "strict",
159
+ transformMixedEsModules: true,
160
+ ignoreTryCatch: false
161
+ }),
162
+ {
163
+ name: "get-telemetry-config",
164
+ transform(code, id) {
165
+ if (id !== entryFile) {
166
+ return;
167
+ }
168
+ return new Promise((resolve, reject) => {
169
+ babel.transform(
170
+ code,
171
+ {
172
+ babelrc: false,
173
+ configFile: false,
174
+ filename: id,
175
+ plugins: [removeAllOptionsExceptTelemetry(result)]
176
+ },
177
+ (err, result2) => {
178
+ if (err) {
179
+ return reject(err);
180
+ }
181
+ resolve({
182
+ code: result2.code,
183
+ map: result2.map
184
+ });
185
+ }
186
+ );
187
+ });
188
+ }
189
+ },
190
+ // let esbuild remove all unused imports
191
+ esbuild({
192
+ target: "node20",
193
+ platform: "node",
194
+ minify: false
195
+ }),
196
+ {
197
+ name: "cleanup",
198
+ transform(code, id) {
199
+ if (id !== entryFile) {
200
+ return;
201
+ }
202
+ return recursiveRemoveNonReferencedNodes(code);
203
+ }
204
+ },
205
+ // let esbuild remove all unused imports
206
+ esbuild({
207
+ target: "node20",
208
+ platform: "node",
209
+ minify: false
210
+ })
211
+ ]
212
+ });
213
+ }
214
+ async function writeTelemetryConfig(entryFile, outputDir) {
215
+ const result = {
216
+ hasCustomConfig: false
217
+ };
218
+ const bundle = await getTelemetryBundler(entryFile, result);
219
+ await bundle.write({
220
+ dir: outputDir,
221
+ format: "es",
222
+ entryFileNames: "[name].mjs"
223
+ });
224
+ return result;
225
+ }
226
+
227
+ export { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept, writeTelemetryConfig };
@@ -0,0 +1,185 @@
1
+ import { spawn } from 'child_process';
2
+ import { Transform } from 'stream';
3
+ import fs from 'fs';
4
+ import fsPromises from 'fs/promises';
5
+ import path, { dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import { MastraBase } from '@mastra/core/base';
8
+ import fsExtra from 'fs-extra/esm';
9
+
10
+ // src/deploy/log.ts
11
+ var createPinoStream = (logger) => {
12
+ return new Transform({
13
+ transform(chunk, _encoding, callback) {
14
+ const line = chunk.toString().trim();
15
+ if (line) {
16
+ console.log(line);
17
+ logger.info(line);
18
+ }
19
+ callback(null, chunk);
20
+ }
21
+ });
22
+ };
23
+ function createChildProcessLogger({ logger, root }) {
24
+ const pinoStream = createPinoStream(logger);
25
+ return async ({ cmd, args, env }) => {
26
+ try {
27
+ const subprocess = spawn(cmd, args, {
28
+ cwd: root,
29
+ shell: true,
30
+ env
31
+ });
32
+ subprocess.stdout?.pipe(pinoStream);
33
+ subprocess.stderr?.pipe(pinoStream);
34
+ return new Promise((resolve, reject) => {
35
+ subprocess.on("close", (code) => {
36
+ pinoStream.end();
37
+ if (code === 0) {
38
+ resolve({ success: true });
39
+ } else {
40
+ reject(new Error(`Process exited with code ${code}`));
41
+ }
42
+ });
43
+ subprocess.on("error", (error) => {
44
+ pinoStream.end();
45
+ logger.error("Process failed", { error });
46
+ reject(error);
47
+ });
48
+ });
49
+ } catch (error) {
50
+ console.log(error);
51
+ logger.error("Process failed", { error });
52
+ pinoStream.end();
53
+ return { success: false, error };
54
+ }
55
+ };
56
+ }
57
+ var Deps = class extends MastraBase {
58
+ packageManager;
59
+ rootDir;
60
+ constructor(rootDir = process.cwd()) {
61
+ super({ component: "DEPLOYER", name: "DEPS" });
62
+ this.rootDir = rootDir;
63
+ this.packageManager = this.getPackageManager();
64
+ }
65
+ findLockFile(dir) {
66
+ const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
67
+ for (const file of lockFiles) {
68
+ if (fs.existsSync(path.join(dir, file))) {
69
+ return file;
70
+ }
71
+ }
72
+ const parentDir = path.resolve(dir, "..");
73
+ if (parentDir !== dir) {
74
+ return this.findLockFile(parentDir);
75
+ }
76
+ return null;
77
+ }
78
+ getPackageManager() {
79
+ const lockFile = this.findLockFile(this.rootDir);
80
+ switch (lockFile) {
81
+ case "pnpm-lock.yaml":
82
+ return "pnpm";
83
+ case "package-lock.json":
84
+ return "npm";
85
+ case "yarn.lock":
86
+ return "yarn";
87
+ case "bun.lock":
88
+ return "bun";
89
+ default:
90
+ return "npm";
91
+ }
92
+ }
93
+ async install({ dir = this.rootDir, packages = [] }) {
94
+ let runCommand = this.packageManager;
95
+ switch (this.packageManager) {
96
+ case "npm":
97
+ runCommand = `${this.packageManager} i`;
98
+ break;
99
+ case "pnpm":
100
+ runCommand = `${this.packageManager} --ignore-workspace install`;
101
+ break;
102
+ default:
103
+ runCommand = `${this.packageManager} ${packages?.length > 0 ? `add` : `install`}`;
104
+ }
105
+ const cpLogger = createChildProcessLogger({
106
+ logger: this.logger,
107
+ root: dir
108
+ });
109
+ return cpLogger({
110
+ cmd: runCommand,
111
+ args: packages,
112
+ env: {
113
+ PATH: process.env.PATH
114
+ }
115
+ });
116
+ }
117
+ async installPackages(packages) {
118
+ let runCommand = this.packageManager;
119
+ if (this.packageManager === "npm") {
120
+ runCommand = `${this.packageManager} i`;
121
+ } else {
122
+ runCommand = `${this.packageManager} add`;
123
+ }
124
+ const cpLogger = createChildProcessLogger({
125
+ logger: this.logger,
126
+ root: ""
127
+ });
128
+ return cpLogger({
129
+ cmd: `${runCommand}`,
130
+ args: packages,
131
+ env: {
132
+ PATH: process.env.PATH
133
+ }
134
+ });
135
+ }
136
+ async checkDependencies(dependencies) {
137
+ try {
138
+ const packageJsonPath = path.join(this.rootDir, "package.json");
139
+ try {
140
+ await fsPromises.access(packageJsonPath);
141
+ } catch {
142
+ return "No package.json file found in the current directory";
143
+ }
144
+ const packageJson = JSON.parse(await fsPromises.readFile(packageJsonPath, "utf-8"));
145
+ for (const dependency of dependencies) {
146
+ if (!packageJson.dependencies || !packageJson.dependencies[dependency]) {
147
+ return `Please install ${dependency} before running this command (${this.packageManager} install ${dependency})`;
148
+ }
149
+ }
150
+ return "ok";
151
+ } catch (err) {
152
+ console.error(err);
153
+ return "Could not check dependencies";
154
+ }
155
+ }
156
+ async getProjectName() {
157
+ try {
158
+ const packageJsonPath = path.join(this.rootDir, "package.json");
159
+ const packageJson = await fsPromises.readFile(packageJsonPath, "utf-8");
160
+ const pkg = JSON.parse(packageJson);
161
+ return pkg.name;
162
+ } catch (err) {
163
+ throw err;
164
+ }
165
+ }
166
+ async getPackageVersion() {
167
+ const __filename = fileURLToPath(import.meta.url);
168
+ const __dirname = dirname(__filename);
169
+ const pkgJsonPath = path.join(__dirname, "..", "..", "package.json");
170
+ const content = await fsExtra.readJSON(pkgJsonPath);
171
+ return content.version;
172
+ }
173
+ async addScriptsToPackageJson(scripts) {
174
+ const packageJson = JSON.parse(await fsPromises.readFile("package.json", "utf-8"));
175
+ packageJson.scripts = {
176
+ ...packageJson.scripts,
177
+ ...scripts
178
+ };
179
+ await fsPromises.writeFile("package.json", JSON.stringify(packageJson, null, 2));
180
+ }
181
+ };
182
+ var DepsService = class extends Deps {
183
+ };
184
+
185
+ export { Deps, DepsService, createChildProcessLogger, createPinoStream };
@@ -1,6 +1,7 @@
1
- import { Deps, writeTelemetryConfig } from './chunk-ZAXXMFXX.js';
2
- import { analyzeBundle } from './chunk-UTZ3434D.js';
3
- import { createBundler, getInputOptions } from './chunk-XEFBJH3T.js';
1
+ import { writeTelemetryConfig } from './chunk-4AYFLP6G.js';
2
+ import { analyzeBundle } from './chunk-BDTZS3JM.js';
3
+ import { createBundler, getInputOptions } from './chunk-IKPL4RGG.js';
4
+ import { DepsService } from './chunk-5UBGPRKT.js';
4
5
  import { existsSync } from 'node:fs';
5
6
  import { writeFile, stat } from 'node:fs/promises';
6
7
  import { join, dirname } from 'node:path';
@@ -68,7 +69,7 @@ var Bundler = class extends MastraBundler {
68
69
  return await analyzeBundle(entry, mastraFile, join(outputDirectory, this.analyzeOutputDir), "node", this.logger);
69
70
  }
70
71
  async installDependencies(outputDirectory, rootDir = process.cwd()) {
71
- const deps = new Deps(rootDir);
72
+ const deps = new DepsService(rootDir);
72
73
  deps.__setLogger(this.logger);
73
74
  await deps.install({ dir: join(outputDirectory, this.outputDir) });
74
75
  }
@@ -116,6 +117,9 @@ var Bundler = class extends MastraBundler {
116
117
  dependenciesToInstall.set(dep, "latest");
117
118
  }
118
119
  }
120
+ if (analyzedBundleInfo.externalDependencies.has("@mastra/memory") || analyzedBundleInfo.dependencies.has("@mastra/memory")) {
121
+ dependenciesToInstall.set("fastembed", "latest");
122
+ }
119
123
  await this.writePackageJson(join(outputDirectory, this.outputDir), dependenciesToInstall);
120
124
  await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));
121
125
  this.logger.info("Bundling Mastra application");