mastra 0.10.5 → 0.10.6-alpha.1

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.
package/dist/index.js CHANGED
@@ -12,12 +12,13 @@ import { getDeployer, FileService as FileService$1 } from '@mastra/deployer';
12
12
  import { isWebContainer } from '@webcontainer/env';
13
13
  import { execa } from 'execa';
14
14
  import getPort from 'get-port';
15
- import { writeFile } from 'fs/promises';
15
+ import { spawn, exec } from 'child_process';
16
16
  import { fileURLToPath } from 'url';
17
+ import open from 'open';
18
+ import { writeFile } from 'fs/promises';
17
19
  import * as fsExtra from 'fs-extra';
18
20
  import fs, { readFileSync } from 'fs';
19
21
  import stripJsonComments from 'strip-json-comments';
20
- import { spawn } from 'child_process';
21
22
 
22
23
  var BuildBundler = class extends Bundler {
23
24
  customEnvFile;
@@ -135,7 +136,7 @@ async function build({
135
136
  logger.info("You can now deploy the .mastra/output directory to your target platform.");
136
137
  } catch (error) {
137
138
  if (error instanceof Error) {
138
- logger.error(`Mastra Build failed`);
139
+ logger.error(`Mastra Build failed`, { error });
139
140
  }
140
141
  process.exit(1);
141
142
  }
@@ -171,6 +172,69 @@ async function deploy({ dir: dir2 }) {
171
172
  logger.warn("No deployer found.");
172
173
  }
173
174
  }
175
+ function openBrowser(url, opt) {
176
+ const browser = process.env.BROWSER || "";
177
+ if (browser.toLowerCase() !== "none") {
178
+ const browserArgs = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(" ") : [];
179
+ void startBrowserProcess(browser, browserArgs, url);
180
+ }
181
+ }
182
+ var supportedChromiumBrowsers = [
183
+ "Google Chrome Canary",
184
+ "Google Chrome Dev",
185
+ "Google Chrome Beta",
186
+ "Google Chrome",
187
+ "Microsoft Edge",
188
+ "Brave Browser",
189
+ "Vivaldi",
190
+ "Chromium",
191
+ "Arc"
192
+ ];
193
+ async function startBrowserProcess(browser, browserArgs, url) {
194
+ const preferredOSXBrowser = browser === "google chrome" ? "Google Chrome" : browser;
195
+ const shouldTryOpenChromeWithAppleScript = process.platform === "darwin" && (!preferredOSXBrowser || supportedChromiumBrowsers.includes(preferredOSXBrowser));
196
+ if (shouldTryOpenChromeWithAppleScript) {
197
+ try {
198
+ const ps = await execAsync("ps cax");
199
+ const openedBrowser = preferredOSXBrowser && ps.includes(preferredOSXBrowser) ? preferredOSXBrowser : supportedChromiumBrowsers.find((b) => ps.includes(b));
200
+ if (openedBrowser) {
201
+ const packageDir = dirname(fileURLToPath(import.meta.resolve("mastra/package.json")));
202
+ await execAsync(`osascript openChrome.applescript "${url}" "${openedBrowser}"`, {
203
+ cwd: join(packageDir, "bin")
204
+ });
205
+ return true;
206
+ }
207
+ } catch {
208
+ }
209
+ }
210
+ if (process.platform === "darwin" && browser === "open") {
211
+ browser = void 0;
212
+ }
213
+ try {
214
+ const options = browser ? { app: { name: browser, arguments: browserArgs } } : {};
215
+ new Promise((_, reject) => {
216
+ open(url, options).then((subprocess) => {
217
+ subprocess.on("error", reject);
218
+ }).catch(reject);
219
+ }).catch((err) => {
220
+ console.error(err.stack || err.message);
221
+ });
222
+ return true;
223
+ } catch {
224
+ return false;
225
+ }
226
+ }
227
+ function execAsync(command, options) {
228
+ return new Promise((resolve, reject) => {
229
+ exec(command, options, (error, stdout) => {
230
+ if (error) {
231
+ reject(error);
232
+ } else {
233
+ resolve(stdout.toString());
234
+ }
235
+ });
236
+ });
237
+ }
174
238
  var DevBundler = class extends Bundler {
175
239
  customEnvFile;
176
240
  constructor(customEnvFile) {
@@ -282,6 +346,7 @@ var DevBundler = class extends Bundler {
282
346
  // src/commands/dev/dev.ts
283
347
  var currentServerProcess;
284
348
  var isRestarting = false;
349
+ var isInitialServerStart = true;
285
350
  var ON_ERROR_MAX_RESTARTS = 3;
286
351
  var startServer = async (dotMastraPath, port, env, errorRestartCount = 0) => {
287
352
  let serverIsReady = false;
@@ -316,6 +381,10 @@ var startServer = async (dotMastraPath, port, env, errorRestartCount = 0) => {
316
381
  currentServerProcess.on("message", async (message) => {
317
382
  if (message?.type === "server-ready") {
318
383
  serverIsReady = true;
384
+ if (isInitialServerStart) {
385
+ isInitialServerStart = false;
386
+ void openBrowser(`http://localhost:${port}`, true);
387
+ }
319
388
  try {
320
389
  await fetch(`http://localhost:${port}/__refresh`, {
321
390
  method: "POST",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastra",
3
- "version": "0.10.5",
3
+ "version": "0.10.6-alpha.1",
4
4
  "license": "Elastic-2.0",
5
5
  "description": "cli for mastra",
6
6
  "type": "module",
@@ -40,47 +40,48 @@
40
40
  "@webcontainer/env": "^1.1.1",
41
41
  "commander": "^12.1.0",
42
42
  "dotenv": "^16.5.0",
43
- "execa": "^9.5.2",
43
+ "execa": "^9.6.0",
44
44
  "fs-extra": "^11.3.0",
45
45
  "get-port": "^7.1.0",
46
- "json-schema-to-zod": "^2.6.0",
46
+ "json-schema-to-zod": "^2.6.1",
47
+ "open": "^10.1.2",
47
48
  "picocolors": "^1.1.1",
48
49
  "posthog-node": "4.16.0",
49
50
  "prettier": "^3.5.3",
50
51
  "prompt": "^1.3.0",
51
- "shell-quote": "^1.8.2",
52
+ "shell-quote": "^1.8.3",
52
53
  "shiki": "^1.29.2",
53
- "strip-json-comments": "^5.0.1",
54
+ "strip-json-comments": "^5.0.2",
54
55
  "superjson": "^2.2.2",
55
56
  "swr": "^2.3.3",
56
57
  "tcp-port-used": "^1.0.2",
57
58
  "yocto-spinner": "^0.1.2",
58
- "zod": "^3.25.56",
59
+ "zod": "^3.25.57",
59
60
  "zod-to-json-schema": "^3.24.5",
60
- "@mastra/deployer": "^0.10.5",
61
- "@mastra/mcp": "^0.10.3",
62
- "@mastra/loggers": "^0.10.2"
61
+ "@mastra/deployer": "^0.10.6-alpha.0",
62
+ "@mastra/loggers": "^0.10.2",
63
+ "@mastra/mcp": "^0.10.4-alpha.0"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@microsoft/api-extractor": "^7.52.8",
66
67
  "@types/fs-extra": "^11.0.4",
67
- "@types/node": "^20.17.57",
68
+ "@types/node": "^20.19.0",
68
69
  "@types/prompt": "^1.1.9",
69
70
  "@types/shell-quote": "^1.7.5",
70
71
  "@types/tcp-port-used": "^1.0.4",
71
72
  "cpy-cli": "^5.0.0",
72
73
  "eslint": "^9.28.0",
73
- "memfs": "^4.17.0",
74
+ "memfs": "^4.17.2",
74
75
  "npm-run-all2": "^7.0.2",
75
- "rollup": "^4.41.1",
76
+ "rollup": "^4.42.0",
76
77
  "tsup": "^8.5.0",
77
- "type-fest": "^4.37.0",
78
- "typescript": "^5.8.2",
79
- "vitest": "^3.2.2",
78
+ "type-fest": "^4.41.0",
79
+ "typescript": "^5.8.3",
80
+ "vitest": "^3.2.3",
80
81
  "@internal/lint": "0.0.12",
81
- "@mastra/client-js": "0.10.4",
82
- "@mastra/core": "0.10.5",
83
- "@mastra/playground-ui": "5.1.5"
82
+ "@mastra/client-js": "0.10.5-alpha.0",
83
+ "@mastra/core": "0.10.6-alpha.0",
84
+ "@mastra/playground-ui": "5.1.6-alpha.0"
84
85
  },
85
86
  "peerDependencies": {
86
87
  "@mastra/core": "^0.10.2-alpha.0"