mastra 0.2.0-alpha.169 → 0.2.0-alpha.171

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.
@@ -497,7 +497,7 @@ var checkPkgJson = async () => {
497
497
  if (isPkgJsonPresent) {
498
498
  return;
499
499
  }
500
- logger.debug('no package.json found, create one or run "mastra create" to create a new project');
500
+ logger.debug('package.json not found, create one or run "mastra create" to create a new project');
501
501
  process.exit(0);
502
502
  };
503
503
 
@@ -1 +1 @@
1
- export { create } from '../../chunk-UU6XEV7T.js';
1
+ export { create } from '../../chunk-TT6FMV27.js';
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #! /usr/bin/env node
2
2
  import { PosthogAnalytics } from './chunk-K5HPNH5H.js';
3
3
  export { PosthogAnalytics } from './chunk-K5HPNH5H.js';
4
- import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, FileService, logger } from './chunk-UU6XEV7T.js';
5
- export { create } from './chunk-UU6XEV7T.js';
4
+ import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, FileService, logger } from './chunk-TT6FMV27.js';
5
+ export { create } from './chunk-TT6FMV27.js';
6
6
  import { Command } from 'commander';
7
7
  import 'picocolors';
8
8
  import { join, dirname } from 'node:path';
9
- import { FileService as FileService$1, getWatcherInputOptions, createWatcher } from '@mastra/deployer/build';
9
+ import { FileService as FileService$2, getWatcherInputOptions, writeTelemetryConfig, createWatcher } from '@mastra/deployer/build';
10
10
  import { Bundler } from '@mastra/deployer/bundler';
11
- import * as fsExtra2 from 'fs-extra';
11
+ import * as fsExtra from 'fs-extra';
12
12
  import { readFileSync } from 'node:fs';
13
13
  import { fileURLToPath } from 'node:url';
14
- import { getDeployer, FileService as FileService$2 } from '@mastra/deployer';
14
+ import { getDeployer, FileService as FileService$1 } from '@mastra/deployer';
15
15
  import { join as join$1 } from 'path';
16
16
  import { execa } from 'execa';
17
- import { MastraBundler } from '@mastra/core/bundler';
17
+ import '@mastra/core/bundler';
18
18
  import 'dotenv';
19
19
 
20
20
  var BuildBundler = class extends Bundler {
@@ -24,7 +24,7 @@ var BuildBundler = class extends Bundler {
24
24
  getEnvFiles() {
25
25
  const possibleFiles = [".env.production", ".env"];
26
26
  try {
27
- const fileService = new FileService$1();
27
+ const fileService = new FileService$2();
28
28
  const envFile = fileService.getFirstExistingFile(possibleFiles);
29
29
  return Promise.resolve([envFile]);
30
30
  } catch (err) {
@@ -36,7 +36,7 @@ var BuildBundler = class extends Bundler {
36
36
  const __filename = fileURLToPath(import.meta.url);
37
37
  const __dirname = dirname(__filename);
38
38
  const playgroundServePath = join(outputDirectory, this.outputDir, "playground");
39
- await fsExtra2.copy(join(dirname(__dirname), "src/playground/dist"), playgroundServePath, {
39
+ await fsExtra.copy(join(dirname(__dirname), "src/playground/dist"), playgroundServePath, {
40
40
  overwrite: true
41
41
  });
42
42
  }
@@ -95,19 +95,14 @@ async function deploy({ dir }) {
95
95
  logger.warn("No deployer found.");
96
96
  }
97
97
  }
98
- var DevBundler = class extends MastraBundler {
99
- mastraDir;
100
- constructor(mastraDir) {
101
- super({
102
- name: "Dev",
103
- component: "BUNDLER"
104
- });
105
- this.mastraDir = mastraDir;
98
+ var DevBundler = class extends Bundler {
99
+ constructor() {
100
+ super("Dev");
106
101
  }
107
102
  getEnvFiles() {
108
103
  const possibleFiles = [".env.development", ".env"];
109
104
  try {
110
- const fileService = new FileService$2();
105
+ const fileService = new FileService$1();
111
106
  const envFile = fileService.getFirstExistingFile(possibleFiles);
112
107
  return Promise.resolve([envFile]);
113
108
  } catch (err) {
@@ -117,25 +112,21 @@ var DevBundler = class extends MastraBundler {
117
112
  async writePackageJson() {
118
113
  }
119
114
  async prepare(outputDirectory) {
120
- await fsExtra2.ensureDir(outputDirectory);
121
- await fsExtra2.emptyDir(outputDirectory);
115
+ await super.prepare(outputDirectory);
122
116
  const __filename = fileURLToPath(import.meta.url);
123
117
  const __dirname = dirname(__filename);
124
- const playgroundServePath = join(outputDirectory, "playground");
125
- await fsExtra2.copy(join(dirname(__dirname), "src/playground/dist"), playgroundServePath, {
118
+ const playgroundServePath = join(outputDirectory, this.outputDir, "playground");
119
+ await fsExtra.copy(join(dirname(__dirname), "src/playground/dist"), playgroundServePath, {
126
120
  overwrite: true
127
121
  });
128
122
  }
129
- async watch(outputDirectory) {
123
+ async watch(entryFile, outputDirectory) {
130
124
  const __filename = fileURLToPath(import.meta.url);
131
125
  const __dirname = dirname(__filename);
132
- const fileService = new FileService$2();
133
- const entryFile = fileService.getFirstExistingFile([
134
- join(this.mastraDir, "index.ts"),
135
- join(this.mastraDir, "index.js")
136
- ]);
137
126
  const envFiles = await this.getEnvFiles();
138
127
  const inputOptions = await getWatcherInputOptions(entryFile, "node");
128
+ await writeTelemetryConfig(entryFile, join(outputDirectory, this.outputDir));
129
+ await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));
139
130
  const watcher = await createWatcher(
140
131
  {
141
132
  ...inputOptions,
@@ -156,7 +147,7 @@ var DevBundler = class extends MastraBundler {
156
147
  }
157
148
  },
158
149
  {
159
- dir: outputDirectory
150
+ dir: join(outputDirectory, this.outputDir)
160
151
  }
161
152
  );
162
153
  this.logger.info("Starting watcher...");
@@ -187,15 +178,20 @@ var isRestarting = false;
187
178
  var startServer = async (dotMastraPath, port, env) => {
188
179
  try {
189
180
  logger.info("[Mastra Dev] - Starting server...");
190
- currentServerProcess = execa("node", ["index.mjs"], {
191
- cwd: dotMastraPath,
192
- env: {
193
- PORT: port.toString() || "4111",
194
- ...Object.fromEntries(env)
195
- },
196
- stdio: "inherit",
197
- reject: false
198
- });
181
+ currentServerProcess = execa(
182
+ "node",
183
+ ["--import=./instrumentation.mjs", "--import=@opentelemetry/instrumentation/hook.mjs", "index.mjs"],
184
+ {
185
+ cwd: dotMastraPath,
186
+ env: {
187
+ PORT: port.toString() || "4111",
188
+ ...Object.fromEntries(env),
189
+ MASTRA_DEFAULT_STORAGE_URL: `file:${join$1(dotMastraPath, "..", "mastra.db")}`
190
+ },
191
+ stdio: "inherit",
192
+ reject: false
193
+ }
194
+ );
199
195
  if (currentServerProcess?.exitCode && currentServerProcess?.exitCode !== 0) {
200
196
  if (!currentServerProcess) {
201
197
  throw new Error(`Server failed to start`);
@@ -253,11 +249,13 @@ async function dev({ port, dir, root }) {
253
249
  const rootDir = root || process.cwd();
254
250
  const mastraDir = join$1(rootDir, dir || "src/mastra");
255
251
  const dotMastraPath = join$1(rootDir, ".mastra");
256
- const bundler = new DevBundler(mastraDir);
252
+ const fileService = new FileService$1();
253
+ const entryFile = fileService.getFirstExistingFile([join$1(mastraDir, "index.ts"), join$1(mastraDir, "index.js")]);
254
+ const bundler = new DevBundler();
257
255
  const env = await bundler.loadEnvVars();
258
256
  await bundler.prepare(dotMastraPath);
259
- const watcher = await bundler.watch(dotMastraPath);
260
- await startServer(dotMastraPath, port, env);
257
+ const watcher = await bundler.watch(entryFile, dotMastraPath);
258
+ await startServer(join$1(dotMastraPath, "output"), port, env);
261
259
  watcher.on("event", (event) => {
262
260
  if (event.code === "BUNDLE_END") {
263
261
  logger.info("[Mastra Dev] - Bundling finished, restarting server...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastra",
3
- "version": "0.2.0-alpha.169",
3
+ "version": "0.2.0-alpha.171",
4
4
  "license": "MIT",
5
5
  "description": "cli for mastra",
6
6
  "type": "module",
@@ -51,12 +51,11 @@
51
51
  "superjson": "^2.2.2",
52
52
  "swr": "^2.2.5",
53
53
  "tcp-port-used": "^1.0.2",
54
- "typescript": "^5.7.3",
55
54
  "yocto-spinner": "^0.1.1",
56
55
  "zod": "^3.24.1",
57
56
  "zod-to-json-schema": "^3.24.1",
58
- "@mastra/core": "^0.2.0-alpha.109",
59
- "@mastra/deployer": "^0.1.0-alpha.61"
57
+ "@mastra/core": "^0.2.0-alpha.110",
58
+ "@mastra/deployer": "^0.1.0-alpha.63"
60
59
  },
61
60
  "devDependencies": {
62
61
  "@ai-sdk/openai": "^1.1.9",
@@ -72,6 +71,7 @@
72
71
  "rollup": "^4.30.1",
73
72
  "tsup": "^8.3.5",
74
73
  "type-fest": "^4.30.0",
74
+ "typescript": "^5.7.3",
75
75
  "vitest": "^3.0.4"
76
76
  },
77
77
  "scripts": {