mastra 0.4.5-alpha.1 → 0.4.5-alpha.11
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/README.md +1 -1
- package/dist/analytics/index.js +1 -1
- package/dist/{chunk-SDQ6DRUS.js → chunk-GY75DPXZ.js} +3 -2
- package/dist/{chunk-4QQ2IFQI.js → chunk-SIN6LLKM.js} +25 -13
- package/dist/commands/create/create.js +1 -1
- package/dist/index.js +49 -36
- package/dist/templates/dev.entry.js +4 -0
- package/package.json +7 -7
- package/src/playground/dist/assets/GeistMonoVF-BHyMa335.woff +0 -0
- package/src/playground/dist/assets/{index-DTo-u5qO.js → index-DsUSHcnm.js} +1 -1
- package/src/playground/dist/assets/{index--rwBVm0G.js → index-hodzN7iD.js} +1 -1
- package/src/playground/dist/assets/index-pacfg0rB.js +592 -0
- package/src/playground/dist/assets/style-B03jYXLF.css +1 -0
- package/src/playground/dist/favicon.ico +0 -0
- package/src/playground/dist/index.html +2 -2
- package/src/playground/dist/mastra.svg +9 -1
- package/src/playground/dist/assets/index-qZPylYUP.js +0 -634
- package/src/playground/dist/assets/style-DPNeRdn7.css +0 -1
- package/src/playground/dist/mastra-light.ico +0 -0
package/README.md
CHANGED
package/dist/analytics/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PosthogAnalytics } from '../chunk-
|
|
1
|
+
export { PosthogAnalytics } from '../chunk-GY75DPXZ.js';
|
|
@@ -64,7 +64,7 @@ var PosthogAnalytics = class {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
isTelemetryEnabled() {
|
|
67
|
-
if (process.env.
|
|
67
|
+
if (process.env.MASTRA_TELEMETRY_DISABLED) {
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
70
|
return true;
|
|
@@ -81,7 +81,8 @@ var PosthogAnalytics = class {
|
|
|
81
81
|
platform: process.arch,
|
|
82
82
|
session_id: this.sessionId,
|
|
83
83
|
cli_version: this.version || "unknown",
|
|
84
|
-
machine_id: os.hostname()
|
|
84
|
+
machine_id: os.hostname(),
|
|
85
|
+
geoip_disable: false
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
captureSessionStart() {
|
|
@@ -145,6 +145,16 @@ function getPackageManagerInstallCommand(pm) {
|
|
|
145
145
|
return "install";
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
+
function convertToViteEnvVar(envVars, keysToConvert) {
|
|
149
|
+
const envEntries = Array.from(envVars.entries());
|
|
150
|
+
const formattedEnvEntries = envEntries.map(([key, value]) => {
|
|
151
|
+
if (keysToConvert.includes(key)) {
|
|
152
|
+
return [`VITE_${key.toUpperCase()}`, value];
|
|
153
|
+
}
|
|
154
|
+
return [key, value];
|
|
155
|
+
});
|
|
156
|
+
return new Map(formattedEnvEntries);
|
|
157
|
+
}
|
|
148
158
|
var args = ["-y", "@mastra/mcp-docs-server@latest"];
|
|
149
159
|
var mcpConfig = {
|
|
150
160
|
mcpServers: {
|
|
@@ -445,12 +455,24 @@ const agent = new Agent({
|
|
|
445
455
|
\`,
|
|
446
456
|
});
|
|
447
457
|
|
|
458
|
+
const forecastSchema = z.array(
|
|
459
|
+
z.object({
|
|
460
|
+
date: z.string(),
|
|
461
|
+
maxTemp: z.number(),
|
|
462
|
+
minTemp: z.number(),
|
|
463
|
+
precipitationChance: z.number(),
|
|
464
|
+
condition: z.string(),
|
|
465
|
+
location: z.string(),
|
|
466
|
+
}),
|
|
467
|
+
);
|
|
468
|
+
|
|
448
469
|
const fetchWeather = new Step({
|
|
449
470
|
id: 'fetch-weather',
|
|
450
471
|
description: 'Fetches weather forecast for a given city',
|
|
451
472
|
inputSchema: z.object({
|
|
452
473
|
city: z.string().describe('The city to get the weather for'),
|
|
453
474
|
}),
|
|
475
|
+
outputSchema: forecastSchema,
|
|
454
476
|
execute: async ({ context }) => {
|
|
455
477
|
const triggerData = context?.getStepResult<{ city: string }>('trigger');
|
|
456
478
|
|
|
@@ -495,23 +517,12 @@ const fetchWeather = new Step({
|
|
|
495
517
|
},
|
|
496
518
|
});
|
|
497
519
|
|
|
498
|
-
const forecastSchema = z.array(
|
|
499
|
-
z.object({
|
|
500
|
-
date: z.string(),
|
|
501
|
-
maxTemp: z.number(),
|
|
502
|
-
minTemp: z.number(),
|
|
503
|
-
precipitationChance: z.number(),
|
|
504
|
-
condition: z.string(),
|
|
505
|
-
location: z.string(),
|
|
506
|
-
}),
|
|
507
|
-
);
|
|
508
520
|
|
|
509
521
|
const planActivities = new Step({
|
|
510
522
|
id: 'plan-activities',
|
|
511
523
|
description: 'Suggests activities based on weather conditions',
|
|
512
|
-
inputSchema: forecastSchema,
|
|
513
524
|
execute: async ({ context, mastra }) => {
|
|
514
|
-
const forecast = context?.getStepResult
|
|
525
|
+
const forecast = context?.getStepResult(fetchWeather);
|
|
515
526
|
|
|
516
527
|
if (!forecast || forecast.length === 0) {
|
|
517
528
|
throw new Error('Forecast data not found');
|
|
@@ -1021,6 +1032,7 @@ var createMastraProject = async ({
|
|
|
1021
1032
|
await exec3(`echo .env.development >> .gitignore`);
|
|
1022
1033
|
await exec3(`echo .env >> .gitignore`);
|
|
1023
1034
|
await exec3(`echo *.db >> .gitignore`);
|
|
1035
|
+
await exec3(`echo *.db-* >> .gitignore`);
|
|
1024
1036
|
s2.stop(".gitignore added");
|
|
1025
1037
|
p.outro("Project created successfully");
|
|
1026
1038
|
console.log("");
|
|
@@ -1063,4 +1075,4 @@ var postCreate = ({ projectName }) => {
|
|
|
1063
1075
|
`);
|
|
1064
1076
|
};
|
|
1065
1077
|
|
|
1066
|
-
export { DepsService, FileService, checkAndInstallCoreDeps, checkPkgJson, create, init, interactivePrompt, logger };
|
|
1078
|
+
export { DepsService, FileService, checkAndInstallCoreDeps, checkPkgJson, convertToViteEnvVar, create, init, interactivePrompt, logger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { create } from '../../chunk-
|
|
1
|
+
export { create } from '../../chunk-SIN6LLKM.js';
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import { PosthogAnalytics } from './chunk-
|
|
3
|
-
export { PosthogAnalytics } from './chunk-
|
|
4
|
-
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, FileService as FileService$1 } from './chunk-
|
|
5
|
-
export { create } from './chunk-
|
|
2
|
+
import { PosthogAnalytics } from './chunk-GY75DPXZ.js';
|
|
3
|
+
export { PosthogAnalytics } from './chunk-GY75DPXZ.js';
|
|
4
|
+
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, convertToViteEnvVar, FileService as FileService$1 } from './chunk-SIN6LLKM.js';
|
|
5
|
+
export { create } from './chunk-SIN6LLKM.js';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
+
import { config } from 'dotenv';
|
|
7
8
|
import { join as join$1, dirname, basename } from 'node:path';
|
|
8
|
-
import { getWatcherInputOptions, writeTelemetryConfig, createWatcher, FileService as FileService$2 } from '@mastra/deployer/build';
|
|
9
|
+
import { getServerOptions, getWatcherInputOptions, writeTelemetryConfig, createWatcher, FileService as FileService$2 } from '@mastra/deployer/build';
|
|
9
10
|
import { Bundler } from '@mastra/deployer/bundler';
|
|
10
11
|
import * as fsExtra2 from 'fs-extra';
|
|
11
12
|
import { readFileSync } from 'node:fs';
|
|
12
13
|
import { fileURLToPath } from 'node:url';
|
|
13
14
|
import { join } from 'path';
|
|
14
15
|
import { FileService, getDeployer } from '@mastra/deployer';
|
|
16
|
+
import { isWebContainer } from '@webcontainer/env';
|
|
15
17
|
import { execa } from 'execa';
|
|
16
18
|
import { stat } from 'node:fs/promises';
|
|
17
|
-
import { config } from 'dotenv';
|
|
18
19
|
|
|
19
20
|
var BuildBundler = class extends Bundler {
|
|
20
21
|
constructor() {
|
|
@@ -51,15 +52,11 @@ var BuildBundler = class extends Bundler {
|
|
|
51
52
|
|
|
52
53
|
// src/commands/build/build.ts
|
|
53
54
|
async function build({ dir }) {
|
|
54
|
-
const mastraDir = dir ?? process.cwd();
|
|
55
|
-
const outputDirectory = join$1(
|
|
55
|
+
const mastraDir = dir ?? join$1(process.cwd(), "src", "mastra");
|
|
56
|
+
const outputDirectory = join$1(process.cwd(), ".mastra");
|
|
56
57
|
const deployer = new BuildBundler();
|
|
57
58
|
const fs = new FileService$1();
|
|
58
|
-
const mastraEntryFile = fs.getFirstExistingFile([
|
|
59
|
-
join$1(mastraDir, "src", "mastra", "index.ts"),
|
|
60
|
-
join$1(mastraDir, "src", "mastra", "index.js")
|
|
61
|
-
]);
|
|
62
|
-
console.log(join$1(mastraDir, "index.ts"), join$1(mastraDir, "index.js"));
|
|
59
|
+
const mastraEntryFile = fs.getFirstExistingFile([join$1(mastraDir, "index.ts"), join$1(mastraDir, "index.js")]);
|
|
63
60
|
await deployer.prepare(outputDirectory);
|
|
64
61
|
await deployer.bundle(mastraEntryFile, outputDirectory);
|
|
65
62
|
}
|
|
@@ -252,21 +249,22 @@ var isRestarting = false;
|
|
|
252
249
|
var startServer = async (dotMastraPath, port, env) => {
|
|
253
250
|
try {
|
|
254
251
|
logger.info("[Mastra Dev] - Starting server...");
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
"
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
252
|
+
const commands = [];
|
|
253
|
+
if (!isWebContainer()) {
|
|
254
|
+
const instrumentation = import.meta.resolve("@opentelemetry/instrumentation/hook.mjs");
|
|
255
|
+
commands.push("--import=./instrumentation.mjs", `--import=${instrumentation}`);
|
|
256
|
+
}
|
|
257
|
+
commands.push("index.mjs");
|
|
258
|
+
currentServerProcess = execa("node", commands, {
|
|
259
|
+
cwd: dotMastraPath,
|
|
260
|
+
env: {
|
|
261
|
+
...Object.fromEntries(env),
|
|
262
|
+
PORT: port.toString() || process.env.PORT || "4111",
|
|
263
|
+
MASTRA_DEFAULT_STORAGE_URL: `file:${join(dotMastraPath, "..", "mastra.db")}`
|
|
264
|
+
},
|
|
265
|
+
stdio: "inherit",
|
|
266
|
+
reject: false
|
|
267
|
+
});
|
|
270
268
|
if (currentServerProcess?.exitCode && currentServerProcess?.exitCode !== 0) {
|
|
271
269
|
if (!currentServerProcess) {
|
|
272
270
|
throw new Error(`Server failed to start`);
|
|
@@ -303,7 +301,7 @@ var startServer = async (dotMastraPath, port, env) => {
|
|
|
303
301
|
if (execaError.stdout) logger.debug("Server output:", { stdout: execaError.stdout });
|
|
304
302
|
}
|
|
305
303
|
};
|
|
306
|
-
async function rebundleAndRestart(dotMastraPath, port, bundler
|
|
304
|
+
async function rebundleAndRestart(dotMastraPath, port, bundler) {
|
|
307
305
|
if (isRestarting) {
|
|
308
306
|
return;
|
|
309
307
|
}
|
|
@@ -319,7 +317,12 @@ async function rebundleAndRestart(dotMastraPath, port, bundler, tools) {
|
|
|
319
317
|
isRestarting = false;
|
|
320
318
|
}
|
|
321
319
|
}
|
|
322
|
-
async function dev({
|
|
320
|
+
async function dev({
|
|
321
|
+
port,
|
|
322
|
+
dir,
|
|
323
|
+
root,
|
|
324
|
+
tools
|
|
325
|
+
}) {
|
|
323
326
|
const rootDir = root || process.cwd();
|
|
324
327
|
const mastraDir = join(rootDir, dir || "src/mastra");
|
|
325
328
|
const dotMastraPath = join(rootDir, ".mastra");
|
|
@@ -331,11 +334,14 @@ async function dev({ port, dir, root, tools }) {
|
|
|
331
334
|
await bundler.prepare(dotMastraPath);
|
|
332
335
|
const watcher = await bundler.watch(entryFile, dotMastraPath, discoveredTools);
|
|
333
336
|
const env = await bundler.loadEnvVars();
|
|
334
|
-
|
|
337
|
+
const formattedEnv = convertToViteEnvVar(env, ["MASTRA_TELEMETRY_DISABLED"]);
|
|
338
|
+
const serverOptions = await getServerOptions(entryFile, join(dotMastraPath, "output"));
|
|
339
|
+
const startPort = port ?? serverOptions?.port ?? 4111;
|
|
340
|
+
await startServer(join(dotMastraPath, "output"), startPort, formattedEnv);
|
|
335
341
|
watcher.on("event", (event) => {
|
|
336
342
|
if (event.code === "BUNDLE_END") {
|
|
337
343
|
logger.info("[Mastra Dev] - Bundling finished, restarting server...");
|
|
338
|
-
rebundleAndRestart(dotMastraPath,
|
|
344
|
+
rebundleAndRestart(dotMastraPath, startPort, bundler);
|
|
339
345
|
}
|
|
340
346
|
});
|
|
341
347
|
process.on("SIGINT", () => {
|
|
@@ -343,10 +349,14 @@ async function dev({ port, dir, root, tools }) {
|
|
|
343
349
|
if (currentServerProcess) {
|
|
344
350
|
currentServerProcess.kill();
|
|
345
351
|
}
|
|
346
|
-
watcher.close()
|
|
347
|
-
|
|
352
|
+
watcher.close().catch(() => {
|
|
353
|
+
}).finally(() => {
|
|
354
|
+
process.exit(0);
|
|
355
|
+
});
|
|
348
356
|
});
|
|
349
357
|
}
|
|
358
|
+
|
|
359
|
+
// src/index.ts
|
|
350
360
|
var depsService = new DepsService();
|
|
351
361
|
var version = await depsService.getPackageVersion();
|
|
352
362
|
var analytics = new PosthogAnalytics({
|
|
@@ -433,13 +443,16 @@ program.command("init").description("Initialize Mastra in your project").option(
|
|
|
433
443
|
origin
|
|
434
444
|
});
|
|
435
445
|
});
|
|
436
|
-
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>", "Port number for the development server (defaults to 4111)").action((args) => {
|
|
446
|
+
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) => {
|
|
437
447
|
analytics.trackCommand({
|
|
438
448
|
command: "dev",
|
|
439
449
|
origin
|
|
440
450
|
});
|
|
451
|
+
if (args?.port) {
|
|
452
|
+
logger.warn("The --port option is deprecated. Use the server key in the Mastra instance instead.");
|
|
453
|
+
}
|
|
441
454
|
dev({
|
|
442
|
-
port: args?.port ? parseInt(args.port) :
|
|
455
|
+
port: args?.port ? parseInt(args.port) : null,
|
|
443
456
|
dir: args?.dir,
|
|
444
457
|
root: args?.root,
|
|
445
458
|
tools: args?.tools ? args.tools.split(",") : []
|
|
@@ -21,6 +21,10 @@ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agen
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
if (mastra.storage) {
|
|
25
|
+
await mastra.storage.init();
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
25
29
|
if (mastra.storage) {
|
|
26
30
|
// Check for required fields
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mastra",
|
|
3
|
-
"version": "0.4.5-alpha.
|
|
3
|
+
"version": "0.4.5-alpha.11",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "cli for mastra",
|
|
6
6
|
"type": "module",
|
|
@@ -37,8 +37,7 @@
|
|
|
37
37
|
"@clack/prompts": "^0.8.2",
|
|
38
38
|
"@lukeed/uuid": "^2.0.1",
|
|
39
39
|
"@opentelemetry/instrumentation": "^0.57.2",
|
|
40
|
-
"@
|
|
41
|
-
"chokidar": "^4.0.3",
|
|
40
|
+
"@webcontainer/env": "^1.1.1",
|
|
42
41
|
"commander": "^12.1.0",
|
|
43
42
|
"dotenv": "^16.4.7",
|
|
44
43
|
"execa": "^9.5.2",
|
|
@@ -55,8 +54,8 @@
|
|
|
55
54
|
"yocto-spinner": "^0.1.2",
|
|
56
55
|
"zod": "^3.24.2",
|
|
57
56
|
"zod-to-json-schema": "^3.24.3",
|
|
58
|
-
"@mastra/core": "^0.8.0-alpha.
|
|
59
|
-
"@mastra/deployer": "^0.2.6-alpha.
|
|
57
|
+
"@mastra/core": "^0.8.0-alpha.8",
|
|
58
|
+
"@mastra/deployer": "^0.2.6-alpha.10"
|
|
60
59
|
},
|
|
61
60
|
"devDependencies": {
|
|
62
61
|
"@microsoft/api-extractor": "^7.52.1",
|
|
@@ -73,9 +72,9 @@
|
|
|
73
72
|
"type-fest": "^4.37.0",
|
|
74
73
|
"typescript": "^5.8.2",
|
|
75
74
|
"vitest": "^3.0.9",
|
|
76
|
-
"@mastra/client-js": "0.1.14-alpha.1",
|
|
77
75
|
"@internal/lint": "0.0.1",
|
|
78
|
-
"@mastra/
|
|
76
|
+
"@mastra/client-js": "0.1.14-alpha.8",
|
|
77
|
+
"@mastra/playground-ui": "4.0.0-alpha.9"
|
|
79
78
|
},
|
|
80
79
|
"scripts": {
|
|
81
80
|
"build": "npm-run-all --serial build:lib copy-starter-files copy-templates build:playground",
|
|
@@ -85,6 +84,7 @@
|
|
|
85
84
|
"copy-templates": "cpy \"src/templates/**/*\" \"dist/templates/\"",
|
|
86
85
|
"build:playground": "cd ../cli/src/playground && pnpm build",
|
|
87
86
|
"dev:playground": "cd src/playground && pnpm dev",
|
|
87
|
+
"build:with-playground-ui": "cd ../playground-ui && pnpm build && cd ../cli && pnpm build",
|
|
88
88
|
"test": "vitest run",
|
|
89
89
|
"test:watch": "vitest watch",
|
|
90
90
|
"clean": "rm -rf dist && rm -rf node_modules",
|
|
Binary file
|