mastra 0.10.4-alpha.0 → 0.10.4-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/{chunk-OPWLTSCW.js → chunk-MKPHGZFU.js} +2 -5
- package/dist/commands/create/create.js +1 -1
- package/dist/index.js +49 -30
- package/package.json +9 -9
- package/src/playground/dist/assets/{index-CGDS8Qzq.js → index-C6ixzzJo.js} +1 -1
- package/src/playground/dist/assets/{index-BGbMrToA.js → index-DjcalO2b.js} +1 -1
- package/src/playground/dist/assets/{index-C410HbRF.js → index-Mlo1jEr8.js} +220 -220
- package/src/playground/dist/assets/style-BnGp4Od9.css +1 -0
- package/src/playground/dist/index.html +2 -2
- package/src/playground/dist/assets/style-C8pQhOQV.css +0 -1
|
@@ -146,7 +146,7 @@ function getPackageManagerInstallCommand(pm) {
|
|
|
146
146
|
return "install";
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
var args = ["-y", "@mastra/mcp-docs-server
|
|
149
|
+
var args = ["-y", "@mastra/mcp-docs-server"];
|
|
150
150
|
var createMcpConfig = (editor) => {
|
|
151
151
|
if (editor === "vscode") {
|
|
152
152
|
return {
|
|
@@ -165,10 +165,7 @@ var createMcpConfig = (editor) => {
|
|
|
165
165
|
}
|
|
166
166
|
return {
|
|
167
167
|
mcpServers: {
|
|
168
|
-
mastra:
|
|
169
|
-
command: "cmd",
|
|
170
|
-
args: ["/c", "npx", ...args]
|
|
171
|
-
} : {
|
|
168
|
+
mastra: {
|
|
172
169
|
command: "npx",
|
|
173
170
|
args
|
|
174
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { create } from '../../chunk-
|
|
1
|
+
export { create } from '../../chunk-MKPHGZFU.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { PosthogAnalytics } from './chunk-7OXWUU2Q.js';
|
|
3
3
|
export { PosthogAnalytics } from './chunk-7OXWUU2Q.js';
|
|
4
|
-
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService } from './chunk-
|
|
5
|
-
export { create } from './chunk-
|
|
4
|
+
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService } from './chunk-MKPHGZFU.js';
|
|
5
|
+
export { create } from './chunk-MKPHGZFU.js';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { config } from 'dotenv';
|
|
8
8
|
import { join, dirname } from 'path';
|
|
@@ -20,11 +20,16 @@ import stripJsonComments from 'strip-json-comments';
|
|
|
20
20
|
import { spawn } from 'child_process';
|
|
21
21
|
|
|
22
22
|
var BuildBundler = class extends Bundler {
|
|
23
|
-
|
|
23
|
+
customEnvFile;
|
|
24
|
+
constructor(customEnvFile) {
|
|
24
25
|
super("Build");
|
|
26
|
+
this.customEnvFile = customEnvFile;
|
|
25
27
|
}
|
|
26
28
|
getEnvFiles() {
|
|
27
29
|
const possibleFiles = [".env.production", ".env.local", ".env"];
|
|
30
|
+
if (this.customEnvFile) {
|
|
31
|
+
possibleFiles.unshift(this.customEnvFile);
|
|
32
|
+
}
|
|
28
33
|
try {
|
|
29
34
|
const fileService = new FileService$2();
|
|
30
35
|
const envFile = fileService.getFirstExistingFile(possibleFiles);
|
|
@@ -99,7 +104,12 @@ var BuildBundler = class extends Bundler {
|
|
|
99
104
|
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
100
105
|
}
|
|
101
106
|
};
|
|
102
|
-
async function build({
|
|
107
|
+
async function build({
|
|
108
|
+
dir: dir2,
|
|
109
|
+
tools,
|
|
110
|
+
root,
|
|
111
|
+
env
|
|
112
|
+
}) {
|
|
103
113
|
const rootDir = root || process.cwd();
|
|
104
114
|
const mastraDir = dir2 ? dir2.startsWith("/") ? dir2 : join(rootDir, dir2) : join(rootDir, "src", "mastra");
|
|
105
115
|
const outputDirectory = join(rootDir, ".mastra");
|
|
@@ -110,7 +120,7 @@ async function build({ dir: dir2, tools, root }) {
|
|
|
110
120
|
const mastraEntryFile = fs2.getFirstExistingFile([join(mastraDir, "index.ts"), join(mastraDir, "index.js")]);
|
|
111
121
|
const platformDeployer = await getDeployer(mastraEntryFile, outputDirectory);
|
|
112
122
|
if (!platformDeployer) {
|
|
113
|
-
const deployer = new BuildBundler();
|
|
123
|
+
const deployer = new BuildBundler(env);
|
|
114
124
|
await deployer.prepare(outputDirectory);
|
|
115
125
|
await deployer.bundle(mastraEntryFile, outputDirectory, discoveredTools);
|
|
116
126
|
logger.info(`Build successful, you can now deploy the .mastra/output directory to your target platform.`);
|
|
@@ -162,11 +172,16 @@ async function deploy({ dir: dir2 }) {
|
|
|
162
172
|
}
|
|
163
173
|
}
|
|
164
174
|
var DevBundler = class extends Bundler {
|
|
165
|
-
|
|
175
|
+
customEnvFile;
|
|
176
|
+
constructor(customEnvFile) {
|
|
166
177
|
super("Dev");
|
|
178
|
+
this.customEnvFile = customEnvFile;
|
|
167
179
|
}
|
|
168
180
|
getEnvFiles() {
|
|
169
181
|
const possibleFiles = [".env.development", ".env.local", ".env"];
|
|
182
|
+
if (this.customEnvFile) {
|
|
183
|
+
possibleFiles.unshift(this.customEnvFile);
|
|
184
|
+
}
|
|
170
185
|
try {
|
|
171
186
|
const fileService = new FileService$1();
|
|
172
187
|
const envFile = fileService.getFirstExistingFile(possibleFiles);
|
|
@@ -175,8 +190,6 @@ var DevBundler = class extends Bundler {
|
|
|
175
190
|
}
|
|
176
191
|
return Promise.resolve([]);
|
|
177
192
|
}
|
|
178
|
-
async writePackageJson() {
|
|
179
|
-
}
|
|
180
193
|
async prepare(outputDirectory) {
|
|
181
194
|
await super.prepare(outputDirectory);
|
|
182
195
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -194,9 +207,13 @@ var DevBundler = class extends Bundler {
|
|
|
194
207
|
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development")
|
|
195
208
|
});
|
|
196
209
|
const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);
|
|
197
|
-
await writeTelemetryConfig(entryFile, join(outputDirectory, this.outputDir));
|
|
198
|
-
await this.writeInstrumentationFile(join(outputDirectory, this.outputDir));
|
|
199
210
|
const outputDir = join(outputDirectory, this.outputDir);
|
|
211
|
+
await writeTelemetryConfig(entryFile, outputDir);
|
|
212
|
+
await this.writeInstrumentationFile(outputDir);
|
|
213
|
+
await this.writePackageJson(outputDir, /* @__PURE__ */ new Map(), {});
|
|
214
|
+
this.logger.info("Installing dependencies");
|
|
215
|
+
await this.installDependencies(outputDirectory);
|
|
216
|
+
this.logger.info("Done installing dependencies");
|
|
200
217
|
const copyPublic = this.copyPublic.bind(this);
|
|
201
218
|
const watcher = await createWatcher(
|
|
202
219
|
{
|
|
@@ -275,15 +292,6 @@ var startServer = async (dotMastraPath, port, env, errorRestartCount = 0) => {
|
|
|
275
292
|
const instrumentation = import.meta.resolve("@opentelemetry/instrumentation/hook.mjs");
|
|
276
293
|
commands.push("--import=./instrumentation.mjs", `--import=${instrumentation}`);
|
|
277
294
|
}
|
|
278
|
-
let portToUse = port.toString() || process.env.PORT;
|
|
279
|
-
if (!portToUse || isNaN(Number(portToUse))) {
|
|
280
|
-
const portList = Array.from({ length: 21 }, (_, i) => 4111 + i);
|
|
281
|
-
portToUse = String(
|
|
282
|
-
await getPort({
|
|
283
|
-
port: portList
|
|
284
|
-
})
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
295
|
commands.push("index.mjs");
|
|
288
296
|
currentServerProcess = execa("node", commands, {
|
|
289
297
|
cwd: dotMastraPath,
|
|
@@ -291,7 +299,7 @@ var startServer = async (dotMastraPath, port, env, errorRestartCount = 0) => {
|
|
|
291
299
|
NODE_ENV: "production",
|
|
292
300
|
...Object.fromEntries(env),
|
|
293
301
|
MASTRA_DEV: "true",
|
|
294
|
-
PORT:
|
|
302
|
+
PORT: port.toString(),
|
|
295
303
|
MASTRA_DEFAULT_STORAGE_URL: `file:${join(dotMastraPath, "..", "mastra.db")}`
|
|
296
304
|
},
|
|
297
305
|
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
@@ -371,7 +379,8 @@ async function dev({
|
|
|
371
379
|
port,
|
|
372
380
|
dir: dir2,
|
|
373
381
|
root,
|
|
374
|
-
tools
|
|
382
|
+
tools,
|
|
383
|
+
env
|
|
375
384
|
}) {
|
|
376
385
|
const rootDir = root || process.cwd();
|
|
377
386
|
const mastraDir = dir2 ? dir2.startsWith("/") ? dir2 : join(process.cwd(), dir2) : join(process.cwd(), "src", "mastra");
|
|
@@ -380,17 +389,25 @@ async function dev({
|
|
|
380
389
|
const discoveredTools = [defaultToolsPath, ...tools || []];
|
|
381
390
|
const fileService = new FileService$1();
|
|
382
391
|
const entryFile = fileService.getFirstExistingFile([join(mastraDir, "index.ts"), join(mastraDir, "index.js")]);
|
|
383
|
-
const bundler = new DevBundler();
|
|
392
|
+
const bundler = new DevBundler(env);
|
|
384
393
|
await bundler.prepare(dotMastraPath);
|
|
385
394
|
const watcher = await bundler.watch(entryFile, dotMastraPath, discoveredTools);
|
|
386
|
-
const
|
|
395
|
+
const loadedEnv = await bundler.loadEnvVars();
|
|
387
396
|
const serverOptions = await getServerOptions(entryFile, join(dotMastraPath, "output"));
|
|
388
|
-
|
|
389
|
-
|
|
397
|
+
let portToUse = port ?? serverOptions?.port ?? process.env.PORT;
|
|
398
|
+
if (!portToUse || isNaN(Number(portToUse))) {
|
|
399
|
+
const portList = Array.from({ length: 21 }, (_, i) => 4111 + i);
|
|
400
|
+
portToUse = String(
|
|
401
|
+
await getPort({
|
|
402
|
+
port: portList
|
|
403
|
+
})
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
await startServer(join(dotMastraPath, "output"), Number(portToUse), loadedEnv);
|
|
390
407
|
watcher.on("event", (event) => {
|
|
391
408
|
if (event.code === "BUNDLE_END") {
|
|
392
409
|
logger.info("[Mastra Dev] - Bundling finished, restarting server...");
|
|
393
|
-
rebundleAndRestart(dotMastraPath,
|
|
410
|
+
rebundleAndRestart(dotMastraPath, Number(portToUse), bundler);
|
|
394
411
|
}
|
|
395
412
|
});
|
|
396
413
|
process.on("SIGINT", () => {
|
|
@@ -720,7 +737,7 @@ program.command("lint").description("Lint your Mastra project").option("-d, --di
|
|
|
720
737
|
origin
|
|
721
738
|
});
|
|
722
739
|
});
|
|
723
|
-
program.command("dev").description("Start mastra server").option("-d, --dir <dir>", "Path to your mastra folder").option("-r, --root <root>", "Path to your root folder").option("-t, --tools <toolsDirs>", "Comma-separated list of paths to tool files to include").option("-p, --port <port>", "deprecated: Port number for the development server (defaults to 4111)").action((args) => {
|
|
740
|
+
program.command("dev").description("Start mastra server").option("-d, --dir <dir>", "Path to your mastra folder").option("-r, --root <root>", "Path to your root folder").option("-t, --tools <toolsDirs>", "Comma-separated list of paths to tool files to include").option("-p, --port <port>", "deprecated: Port number for the development server (defaults to 4111)").option("-e, --env <env>", "Custom env file to include in the dev server").action((args) => {
|
|
724
741
|
analytics.trackCommand({
|
|
725
742
|
command: "dev",
|
|
726
743
|
origin
|
|
@@ -732,12 +749,13 @@ program.command("dev").description("Start mastra server").option("-d, --dir <dir
|
|
|
732
749
|
port: args?.port ? parseInt(args.port) : null,
|
|
733
750
|
dir: args?.dir,
|
|
734
751
|
root: args?.root,
|
|
735
|
-
tools: args?.tools ? args.tools.split(",") : []
|
|
752
|
+
tools: args?.tools ? args.tools.split(",") : [],
|
|
753
|
+
env: args?.env
|
|
736
754
|
}).catch((err) => {
|
|
737
755
|
logger.error(err.message);
|
|
738
756
|
});
|
|
739
757
|
});
|
|
740
|
-
program.command("build").description("Build your Mastra project").option("-d, --dir <path>", "Path to your Mastra Folder").option("-r, --root <path>", "Path to your root folder").option("-t, --tools <toolsDirs>", "Comma-separated list of paths to tool files to include").action(async (args) => {
|
|
758
|
+
program.command("build").description("Build your Mastra project").option("-d, --dir <path>", "Path to your Mastra Folder").option("-r, --root <path>", "Path to your root folder").option("-t, --tools <toolsDirs>", "Comma-separated list of paths to tool files to include").option("-e, --env <env>", "Custom env file to include in the build").action(async (args) => {
|
|
741
759
|
await analytics.trackCommandExecution({
|
|
742
760
|
command: "mastra build",
|
|
743
761
|
args,
|
|
@@ -745,7 +763,8 @@ program.command("build").description("Build your Mastra project").option("-d, --
|
|
|
745
763
|
await build({
|
|
746
764
|
dir: args?.dir,
|
|
747
765
|
root: args?.root,
|
|
748
|
-
tools: args?.tools ? args.tools.split(",") : []
|
|
766
|
+
tools: args?.tools ? args.tools.split(",") : [],
|
|
767
|
+
env: args?.env
|
|
749
768
|
});
|
|
750
769
|
},
|
|
751
770
|
origin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mastra",
|
|
3
|
-
"version": "0.10.4-alpha.
|
|
3
|
+
"version": "0.10.4-alpha.1",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"description": "cli for mastra",
|
|
6
6
|
"type": "module",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"swr": "^2.3.3",
|
|
56
56
|
"tcp-port-used": "^1.0.2",
|
|
57
57
|
"yocto-spinner": "^0.1.2",
|
|
58
|
-
"zod": "^3.
|
|
58
|
+
"zod": "^3.25.56",
|
|
59
59
|
"zod-to-json-schema": "^3.24.5",
|
|
60
|
-
"@mastra/deployer": "^0.10.4-alpha.
|
|
61
|
-
"@mastra/
|
|
62
|
-
"@mastra/
|
|
60
|
+
"@mastra/deployer": "^0.10.4-alpha.1",
|
|
61
|
+
"@mastra/loggers": "^0.10.2-alpha.0",
|
|
62
|
+
"@mastra/mcp": "^0.10.3-alpha.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@microsoft/api-extractor": "^7.52.8",
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"tsup": "^8.5.0",
|
|
77
77
|
"type-fest": "^4.37.0",
|
|
78
78
|
"typescript": "^5.8.2",
|
|
79
|
-
"vitest": "^3.
|
|
79
|
+
"vitest": "^3.2.2",
|
|
80
80
|
"@internal/lint": "0.0.10",
|
|
81
|
-
"@mastra/
|
|
82
|
-
"@mastra/
|
|
83
|
-
"@mastra/
|
|
81
|
+
"@mastra/client-js": "0.10.3-alpha.1",
|
|
82
|
+
"@mastra/core": "0.10.4-alpha.1",
|
|
83
|
+
"@mastra/playground-ui": "5.1.4-alpha.1"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"@mastra/core": "^0.10.2-alpha.0"
|