mastra 0.2.9-alpha.9 → 0.3.0
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 +77 -11
- package/package.json +25 -26
- package/src/playground/dist/assets/index-8IsFq_Tz.js +612 -0
- package/src/playground/dist/assets/{index-W3r2adO1.js → index-AChV6zfi.js} +1 -1
- package/src/playground/dist/assets/{index-CXGHj3NH.js → index-CeAJwbzU.js} +1 -1
- package/src/playground/dist/assets/style-DDEGD7OC.css +1 -0
- package/src/playground/dist/index.html +2 -2
- package/src/playground/dist/assets/index-BPMnO8pg.js +0 -536
- package/src/playground/dist/assets/style-G82Qq-am.css +0 -1
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ export { PosthogAnalytics } from './chunk-SLGHDOYI.js';
|
|
|
4
4
|
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService as FileService$1 } from './chunk-UHTCQK5H.js';
|
|
5
5
|
export { create } from './chunk-UHTCQK5H.js';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
-
import { join as join$1, dirname } from 'node:path';
|
|
7
|
+
import { join as join$1, dirname, basename } from 'node:path';
|
|
8
8
|
import { getWatcherInputOptions, writeTelemetryConfig, createWatcher, FileService as FileService$2 } from '@mastra/deployer/build';
|
|
9
9
|
import { Bundler } from '@mastra/deployer/bundler';
|
|
10
|
-
import * as
|
|
10
|
+
import * as fsExtra2 from 'fs-extra';
|
|
11
11
|
import { readFileSync } from 'node:fs';
|
|
12
12
|
import { fileURLToPath } from 'node:url';
|
|
13
13
|
import { join } from 'path';
|
|
@@ -33,7 +33,7 @@ var BuildBundler = class extends Bundler {
|
|
|
33
33
|
const __filename = fileURLToPath(import.meta.url);
|
|
34
34
|
const __dirname = dirname(__filename);
|
|
35
35
|
const playgroundServePath = join$1(outputDirectory, this.outputDir, "playground");
|
|
36
|
-
await
|
|
36
|
+
await fsExtra2.copy(join$1(dirname(__dirname), "src/playground/dist"), playgroundServePath, {
|
|
37
37
|
overwrite: true
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -93,6 +93,7 @@ async function deploy({ dir }) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
var DevBundler = class extends Bundler {
|
|
96
|
+
mastraToolsPaths = [];
|
|
96
97
|
constructor() {
|
|
97
98
|
super("Dev");
|
|
98
99
|
}
|
|
@@ -106,6 +107,11 @@ var DevBundler = class extends Bundler {
|
|
|
106
107
|
}
|
|
107
108
|
return Promise.resolve([]);
|
|
108
109
|
}
|
|
110
|
+
async loadEnvVars() {
|
|
111
|
+
const superEnvVars = await super.loadEnvVars();
|
|
112
|
+
superEnvVars.set("MASTRA_TOOLS_PATH", this.mastraToolsPaths.join(","));
|
|
113
|
+
return superEnvVars;
|
|
114
|
+
}
|
|
109
115
|
async writePackageJson() {
|
|
110
116
|
}
|
|
111
117
|
async prepare(outputDirectory) {
|
|
@@ -113,17 +119,64 @@ var DevBundler = class extends Bundler {
|
|
|
113
119
|
const __filename = fileURLToPath(import.meta.url);
|
|
114
120
|
const __dirname = dirname(__filename);
|
|
115
121
|
const playgroundServePath = join$1(outputDirectory, this.outputDir, "playground");
|
|
116
|
-
await
|
|
122
|
+
await fsExtra2.copy(join$1(dirname(__dirname), "src/playground/dist"), playgroundServePath, {
|
|
117
123
|
overwrite: true
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
|
-
async watch(entryFile, outputDirectory) {
|
|
126
|
+
async watch(entryFile, outputDirectory, toolsPaths) {
|
|
121
127
|
const __filename = fileURLToPath(import.meta.url);
|
|
122
128
|
const __dirname = dirname(__filename);
|
|
123
129
|
const envFiles = await this.getEnvFiles();
|
|
124
130
|
const inputOptions = await getWatcherInputOptions(entryFile, "node");
|
|
125
131
|
await writeTelemetryConfig(entryFile, join$1(outputDirectory, this.outputDir));
|
|
126
132
|
await this.writeInstrumentationFile(join$1(outputDirectory, this.outputDir));
|
|
133
|
+
if (toolsPaths?.length) {
|
|
134
|
+
for (const toolPath of toolsPaths) {
|
|
135
|
+
if (await fsExtra2.pathExists(toolPath)) {
|
|
136
|
+
const toolName = basename(toolPath);
|
|
137
|
+
const toolOutputPath = join$1(outputDirectory, this.outputDir, "tools", toolName);
|
|
138
|
+
const fileService = new FileService();
|
|
139
|
+
const entryFile2 = fileService.getFirstExistingFile([
|
|
140
|
+
join$1(toolPath, "index.ts"),
|
|
141
|
+
join$1(toolPath, "index.js"),
|
|
142
|
+
toolPath
|
|
143
|
+
// if toolPath itself is a file
|
|
144
|
+
]);
|
|
145
|
+
if (!entryFile2) {
|
|
146
|
+
this.logger.warn(`No entry file found in ${toolPath}, skipping...`);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const toolInputOptions = await getWatcherInputOptions(entryFile2, "node");
|
|
150
|
+
const watcher2 = await createWatcher(
|
|
151
|
+
{
|
|
152
|
+
...toolInputOptions,
|
|
153
|
+
input: {
|
|
154
|
+
index: entryFile2
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
dir: toolOutputPath
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
await new Promise((resolve, reject) => {
|
|
162
|
+
const cb = (event) => {
|
|
163
|
+
if (event.code === "BUNDLE_END") {
|
|
164
|
+
watcher2.off("event", cb);
|
|
165
|
+
resolve(void 0);
|
|
166
|
+
}
|
|
167
|
+
if (event.code === "ERROR") {
|
|
168
|
+
watcher2.off("event", cb);
|
|
169
|
+
reject(event);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
watcher2.on("event", cb);
|
|
173
|
+
});
|
|
174
|
+
this.mastraToolsPaths.push(join$1(toolOutputPath, "index.mjs"));
|
|
175
|
+
} else {
|
|
176
|
+
this.logger.warn(`Tool path ${toolPath} does not exist, skipping...`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
127
180
|
const watcher = await createWatcher(
|
|
128
181
|
{
|
|
129
182
|
...inputOptions,
|
|
@@ -138,6 +191,16 @@ var DevBundler = class extends Bundler {
|
|
|
138
191
|
this.addWatchFile(envFile);
|
|
139
192
|
}
|
|
140
193
|
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "tools-watcher",
|
|
197
|
+
buildStart() {
|
|
198
|
+
if (toolsPaths?.length) {
|
|
199
|
+
for (const toolPath of toolsPaths) {
|
|
200
|
+
this.addWatchFile(toolPath);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
141
204
|
}
|
|
142
205
|
],
|
|
143
206
|
input: {
|
|
@@ -227,7 +290,7 @@ var startServer = async (dotMastraPath, port, env) => {
|
|
|
227
290
|
if (execaError.stdout) logger.debug("Server output:", { stdout: execaError.stdout });
|
|
228
291
|
}
|
|
229
292
|
};
|
|
230
|
-
async function rebundleAndRestart(dotMastraPath, port, bundler) {
|
|
293
|
+
async function rebundleAndRestart(dotMastraPath, port, bundler, tools) {
|
|
231
294
|
if (isRestarting) {
|
|
232
295
|
return;
|
|
233
296
|
}
|
|
@@ -235,7 +298,7 @@ async function rebundleAndRestart(dotMastraPath, port, bundler) {
|
|
|
235
298
|
try {
|
|
236
299
|
if (currentServerProcess) {
|
|
237
300
|
logger.debug("Stopping current server...");
|
|
238
|
-
currentServerProcess.kill("
|
|
301
|
+
currentServerProcess.kill("SIGINT");
|
|
239
302
|
}
|
|
240
303
|
const env = await bundler.loadEnvVars();
|
|
241
304
|
await startServer(join(dotMastraPath, "output"), port, env);
|
|
@@ -243,16 +306,18 @@ async function rebundleAndRestart(dotMastraPath, port, bundler) {
|
|
|
243
306
|
isRestarting = false;
|
|
244
307
|
}
|
|
245
308
|
}
|
|
246
|
-
async function dev({ port, dir, root }) {
|
|
309
|
+
async function dev({ port, dir, root, tools }) {
|
|
247
310
|
const rootDir = root || process.cwd();
|
|
248
311
|
const mastraDir = join(rootDir, dir || "src/mastra");
|
|
249
312
|
const dotMastraPath = join(rootDir, ".mastra");
|
|
313
|
+
const defaultToolsPath = join(mastraDir, "tools");
|
|
314
|
+
const discoveredTools = [defaultToolsPath, ...tools || []];
|
|
250
315
|
const fileService = new FileService();
|
|
251
316
|
const entryFile = fileService.getFirstExistingFile([join(mastraDir, "index.ts"), join(mastraDir, "index.js")]);
|
|
252
317
|
const bundler = new DevBundler();
|
|
253
|
-
const env = await bundler.loadEnvVars();
|
|
254
318
|
await bundler.prepare(dotMastraPath);
|
|
255
|
-
const watcher = await bundler.watch(entryFile, dotMastraPath);
|
|
319
|
+
const watcher = await bundler.watch(entryFile, dotMastraPath, discoveredTools);
|
|
320
|
+
const env = await bundler.loadEnvVars();
|
|
256
321
|
await startServer(join(dotMastraPath, "output"), port, env);
|
|
257
322
|
watcher.on("event", (event) => {
|
|
258
323
|
if (event.code === "BUNDLE_END") {
|
|
@@ -356,7 +421,8 @@ program.command("dev").description("Start mastra server").option("-d, --dir <dir
|
|
|
356
421
|
dev({
|
|
357
422
|
port: args?.port ? parseInt(args.port) : 4111,
|
|
358
423
|
dir: args?.dir,
|
|
359
|
-
root: args?.root
|
|
424
|
+
root: args?.root,
|
|
425
|
+
tools: args?.tools ? args.tools.split(",") : []
|
|
360
426
|
}).catch((err) => {
|
|
361
427
|
logger.error(err.message);
|
|
362
428
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mastra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "cli for mastra",
|
|
6
6
|
"type": "module",
|
|
@@ -35,47 +35,46 @@
|
|
|
35
35
|
"author": "",
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@clack/prompts": "^0.8.2",
|
|
38
|
-
"@dagrejs/dagre": "^1.1.4",
|
|
39
38
|
"@lukeed/uuid": "^2.0.1",
|
|
40
39
|
"@opentelemetry/instrumentation": "^0.57.2",
|
|
41
|
-
"@swc/core": "^1.
|
|
40
|
+
"@swc/core": "^1.11.8",
|
|
42
41
|
"chokidar": "^4.0.3",
|
|
43
42
|
"commander": "^12.1.0",
|
|
44
|
-
"dotenv": "^16.
|
|
45
|
-
"execa": "^9.
|
|
43
|
+
"dotenv": "^16.4.7",
|
|
44
|
+
"execa": "^9.5.2",
|
|
46
45
|
"fs-extra": "^11.3.0",
|
|
47
|
-
"json-schema-to-zod": "^2.
|
|
46
|
+
"json-schema-to-zod": "^2.6.0",
|
|
48
47
|
"picocolors": "^1.1.1",
|
|
49
|
-
"posthog-node": "^4.
|
|
50
|
-
"prettier": "^3.
|
|
48
|
+
"posthog-node": "^4.10.1",
|
|
49
|
+
"prettier": "^3.5.3",
|
|
51
50
|
"prompt": "^1.3.0",
|
|
52
|
-
"shiki": "^1.
|
|
51
|
+
"shiki": "^1.29.2",
|
|
53
52
|
"superjson": "^2.2.2",
|
|
54
|
-
"swr": "^2.
|
|
53
|
+
"swr": "^2.3.3",
|
|
55
54
|
"tcp-port-used": "^1.0.2",
|
|
56
|
-
"yocto-spinner": "^0.1.
|
|
57
|
-
"zod": "^3.24.
|
|
58
|
-
"zod-to-json-schema": "^3.24.
|
|
59
|
-
"@mastra/core": "^0.5.0
|
|
60
|
-
"@mastra/deployer": "^0.1.8
|
|
55
|
+
"yocto-spinner": "^0.1.2",
|
|
56
|
+
"zod": "^3.24.2",
|
|
57
|
+
"zod-to-json-schema": "^3.24.3",
|
|
58
|
+
"@mastra/core": "^0.5.0",
|
|
59
|
+
"@mastra/deployer": "^0.1.8"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
|
-
"@microsoft/api-extractor": "^7.
|
|
62
|
+
"@microsoft/api-extractor": "^7.52.1",
|
|
64
63
|
"@types/express": "^5.0.0",
|
|
65
64
|
"@types/fs-extra": "^11.0.4",
|
|
66
|
-
"@types/node": "^22.13.
|
|
67
|
-
"@types/prompt": "^1.1.
|
|
65
|
+
"@types/node": "^22.13.10",
|
|
66
|
+
"@types/prompt": "^1.1.9",
|
|
68
67
|
"@types/tcp-port-used": "^1.0.4",
|
|
69
68
|
"cpy-cli": "^5.0.0",
|
|
70
|
-
"eslint": "^9.
|
|
71
|
-
"memfs": "^4.
|
|
69
|
+
"eslint": "^9.22.0",
|
|
70
|
+
"memfs": "^4.17.0",
|
|
72
71
|
"npm-run-all": "^4.1.5",
|
|
73
|
-
"rollup": "^4.
|
|
74
|
-
"tsup": "^8.
|
|
75
|
-
"type-fest": "^4.
|
|
76
|
-
"typescript": "^5.
|
|
77
|
-
"vitest": "^3.0.
|
|
78
|
-
"@internal/lint": "0.0.
|
|
72
|
+
"rollup": "^4.35.0",
|
|
73
|
+
"tsup": "^8.4.0",
|
|
74
|
+
"type-fest": "^4.37.0",
|
|
75
|
+
"typescript": "^5.8.2",
|
|
76
|
+
"vitest": "^3.0.8",
|
|
77
|
+
"@internal/lint": "0.0.1"
|
|
79
78
|
},
|
|
80
79
|
"scripts": {
|
|
81
80
|
"build": "npm-run-all --serial build:lib copy-starter-files copy-templates build:playground",
|