mastra 0.5.0 → 0.6.0-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/dist/{chunk-BY3FZLXQ.js → chunk-YW5YUAZU.js} +93 -18
- package/dist/commands/create/create.d.ts +1 -0
- package/dist/commands/create/create.js +1 -1
- package/dist/index.js +18 -15
- package/package.json +8 -8
- package/src/playground/dist/assets/{index-D6ZdaJPu.js → index-BjnmGaXc.js} +149 -154
- package/src/playground/dist/assets/{index-BCCsVJll.js → index-CUoYLlU3.js} +1 -1
- package/src/playground/dist/assets/{index-B1hUWDtm.js → index-OnsqE8gs.js} +1 -1
- package/src/playground/dist/assets/style-CUMHJ-5_.css +1 -0
- package/src/playground/dist/index.html +2 -2
- package/src/playground/dist/assets/style-BcPCJlLb.css +0 -1
|
@@ -185,20 +185,41 @@ async function writeMergedConfig(configPath) {
|
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
|
|
188
|
+
var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
|
|
188
189
|
async function installMastraDocsMCPServer({
|
|
189
190
|
editor,
|
|
190
191
|
directory
|
|
191
192
|
}) {
|
|
192
|
-
if (editor === `cursor`)
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
if (editor === `cursor`) {
|
|
194
|
+
await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"));
|
|
195
|
+
}
|
|
196
|
+
if (editor === `cursor-global`) {
|
|
197
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
198
|
+
if (alreadyInstalled) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
await writeMergedConfig(cursorGlobalMCPConfigPath);
|
|
202
|
+
}
|
|
203
|
+
if (editor === `windsurf`) {
|
|
204
|
+
const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
|
|
205
|
+
if (alreadyInstalled) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
await writeMergedConfig(windsurfGlobalMCPConfigPath);
|
|
209
|
+
}
|
|
195
210
|
}
|
|
196
|
-
async function
|
|
197
|
-
|
|
211
|
+
async function globalMCPIsAlreadyInstalled(editor) {
|
|
212
|
+
let configPath = ``;
|
|
213
|
+
if (editor === "windsurf") {
|
|
214
|
+
configPath = windsurfGlobalMCPConfigPath;
|
|
215
|
+
} else if (editor === "cursor-global") {
|
|
216
|
+
configPath = cursorGlobalMCPConfigPath;
|
|
217
|
+
}
|
|
218
|
+
if (!configPath || !existsSync(configPath)) {
|
|
198
219
|
return false;
|
|
199
220
|
}
|
|
200
221
|
try {
|
|
201
|
-
const configContents = await readJSON(
|
|
222
|
+
const configContents = await readJSON(configPath);
|
|
202
223
|
if (!configContents?.mcpServers) return false;
|
|
203
224
|
const hasMastraMCP = Object.values(configContents.mcpServers).some(
|
|
204
225
|
(server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
|
|
@@ -382,6 +403,7 @@ async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
|
382
403
|
const content = `
|
|
383
404
|
${providerImport}
|
|
384
405
|
import { Agent } from '@mastra/core/agent';
|
|
406
|
+
import { Memory } from '@mastra/memory';
|
|
385
407
|
${addExampleTool ? `import { weatherTool } from '../tools';` : ""}
|
|
386
408
|
|
|
387
409
|
export const weatherAgent = new Agent({
|
|
@@ -389,6 +411,15 @@ export const weatherAgent = new Agent({
|
|
|
389
411
|
instructions: \`${instructions}\`,
|
|
390
412
|
model: ${modelItem},
|
|
391
413
|
${addExampleTool ? "tools: { weatherTool }," : ""}
|
|
414
|
+
memory: new Memory({
|
|
415
|
+
options: {
|
|
416
|
+
lastMessages: 10,
|
|
417
|
+
semanticRecall: false,
|
|
418
|
+
threads: {
|
|
419
|
+
generateTitle: false
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
})
|
|
392
423
|
});
|
|
393
424
|
`;
|
|
394
425
|
const formattedContent = await prettier.format(content, {
|
|
@@ -643,11 +674,16 @@ export const mastra = new Mastra()
|
|
|
643
674
|
`
|
|
644
675
|
import { Mastra } from '@mastra/core/mastra';
|
|
645
676
|
import { createLogger } from '@mastra/core/logger';
|
|
677
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
646
678
|
${addWorkflow ? `import { weatherWorkflow } from './workflows';` : ""}
|
|
647
679
|
${addAgent ? `import { weatherAgent } from './agents';` : ""}
|
|
648
680
|
|
|
649
681
|
export const mastra = new Mastra({
|
|
650
682
|
${filteredExports.join("\n ")}
|
|
683
|
+
storage: new LibSQLStore({
|
|
684
|
+
// stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
|
|
685
|
+
url: ":memory:",
|
|
686
|
+
}),
|
|
651
687
|
logger: createLogger({
|
|
652
688
|
name: 'Mastra',
|
|
653
689
|
level: 'info',
|
|
@@ -659,18 +695,24 @@ export const mastra = new Mastra({
|
|
|
659
695
|
throw err;
|
|
660
696
|
}
|
|
661
697
|
};
|
|
662
|
-
var checkAndInstallCoreDeps = async () => {
|
|
698
|
+
var checkAndInstallCoreDeps = async (addExample) => {
|
|
663
699
|
const depsService = new DepsService();
|
|
664
|
-
|
|
700
|
+
let depCheck = await depsService.checkDependencies(["@mastra/core"]);
|
|
665
701
|
if (depCheck !== "ok") {
|
|
666
|
-
await installCoreDeps();
|
|
702
|
+
await installCoreDeps("@mastra/core");
|
|
703
|
+
}
|
|
704
|
+
if (addExample) {
|
|
705
|
+
depCheck = await depsService.checkDependencies(["@mastra/libsql"]);
|
|
706
|
+
if (depCheck !== "ok") {
|
|
707
|
+
await installCoreDeps("@mastra/libsql");
|
|
708
|
+
}
|
|
667
709
|
}
|
|
668
710
|
};
|
|
669
711
|
var spinner = yoctoSpinner({ text: "Installing Mastra core dependencies\n" });
|
|
670
|
-
async function installCoreDeps() {
|
|
712
|
+
async function installCoreDeps(pkg) {
|
|
671
713
|
try {
|
|
672
714
|
const confirm2 = await p.confirm({
|
|
673
|
-
message:
|
|
715
|
+
message: `You do not have the ${pkg} package installed. Would you like to install it?`,
|
|
674
716
|
initialValue: false
|
|
675
717
|
});
|
|
676
718
|
if (p.isCancel(confirm2)) {
|
|
@@ -683,7 +725,7 @@ async function installCoreDeps() {
|
|
|
683
725
|
}
|
|
684
726
|
spinner.start();
|
|
685
727
|
const depsService = new DepsService();
|
|
686
|
-
await depsService.installPackages([
|
|
728
|
+
await depsService.installPackages([`${pkg}@latest`]);
|
|
687
729
|
spinner.success("@mastra/core installed successfully");
|
|
688
730
|
} catch (err) {
|
|
689
731
|
console.error(err);
|
|
@@ -789,12 +831,22 @@ var interactivePrompt = async () => {
|
|
|
789
831
|
initialValue: false
|
|
790
832
|
}),
|
|
791
833
|
configureEditorWithDocsMCP: async () => {
|
|
792
|
-
const windsurfIsAlreadyInstalled = await
|
|
834
|
+
const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
|
|
835
|
+
const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
|
|
793
836
|
const editor = await p.select({
|
|
794
837
|
message: `Make your AI IDE into a Mastra expert? (installs Mastra docs MCP server)`,
|
|
795
838
|
options: [
|
|
796
839
|
{ value: "skip", label: "Skip for now", hint: "default" },
|
|
797
|
-
{
|
|
840
|
+
{
|
|
841
|
+
value: "cursor",
|
|
842
|
+
label: "Cursor (project only)",
|
|
843
|
+
hint: cursorIsAlreadyInstalled ? `Already installed globally` : void 0
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
value: "cursor-global",
|
|
847
|
+
label: "Cursor (global, all projects)",
|
|
848
|
+
hint: cursorIsAlreadyInstalled ? `Already installed` : void 0
|
|
849
|
+
},
|
|
798
850
|
{
|
|
799
851
|
value: "windsurf",
|
|
800
852
|
label: "Windsurf",
|
|
@@ -815,6 +867,18 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
|
|
|
815
867
|
`
|
|
816
868
|
);
|
|
817
869
|
}
|
|
870
|
+
if (editor === `cursor-global`) {
|
|
871
|
+
const confirm2 = await p.select({
|
|
872
|
+
message: `Global install will add/update ${cursorGlobalMCPConfigPath} and make the Mastra docs MCP server available in all your Cursor projects. Continue?`,
|
|
873
|
+
options: [
|
|
874
|
+
{ value: "yes", label: "Yes, I understand" },
|
|
875
|
+
{ value: "skip", label: "No, skip for now" }
|
|
876
|
+
]
|
|
877
|
+
});
|
|
878
|
+
if (confirm2 !== `yes`) {
|
|
879
|
+
return void 0;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
818
882
|
if (editor === `windsurf`) {
|
|
819
883
|
const confirm2 = await p.select({
|
|
820
884
|
message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
|
|
@@ -894,6 +958,15 @@ var init = async ({
|
|
|
894
958
|
(component) => writeCodeSample(dirPath, component, llmProvider, components)
|
|
895
959
|
)
|
|
896
960
|
]);
|
|
961
|
+
const depService = new DepsService();
|
|
962
|
+
const needsLibsql = await depService.checkDependencies(["@mastra/libsql"]) !== `ok`;
|
|
963
|
+
if (needsLibsql) {
|
|
964
|
+
await depService.installPackages(["@mastra/libsql"]);
|
|
965
|
+
}
|
|
966
|
+
const needsMemory = components.includes(`agents`) && await depService.checkDependencies(["@mastra/memory"]) !== `ok`;
|
|
967
|
+
if (needsMemory) {
|
|
968
|
+
await depService.installPackages(["@mastra/memory"]);
|
|
969
|
+
}
|
|
897
970
|
}
|
|
898
971
|
const key = await getAPIKey(llmProvider || "openai");
|
|
899
972
|
const aiSdkPackage = getAISDKPackage(llmProvider);
|
|
@@ -1033,9 +1106,11 @@ var createMastraProject = async ({
|
|
|
1033
1106
|
const versionTag = createVersionTag ? `@${createVersionTag}` : "@latest";
|
|
1034
1107
|
await installMastraDependency(pm, "mastra", versionTag, true, timeout);
|
|
1035
1108
|
s2.stop("mastra installed");
|
|
1036
|
-
s2.start("Installing
|
|
1109
|
+
s2.start("Installing dependencies");
|
|
1037
1110
|
await installMastraDependency(pm, "@mastra/core", versionTag, false, timeout);
|
|
1038
|
-
|
|
1111
|
+
await installMastraDependency(pm, "@mastra/libsql", versionTag, false, timeout);
|
|
1112
|
+
await installMastraDependency(pm, "@mastra/memory", versionTag, false, timeout);
|
|
1113
|
+
s2.stop("Dependencies installed");
|
|
1039
1114
|
s2.start("Adding .gitignore");
|
|
1040
1115
|
await exec3(`echo output.txt >> .gitignore`);
|
|
1041
1116
|
await exec3(`echo node_modules >> .gitignore`);
|
|
@@ -1058,8 +1133,8 @@ var create = async (args2) => {
|
|
|
1058
1133
|
createVersionTag: args2?.createVersionTag,
|
|
1059
1134
|
timeout: args2?.timeout
|
|
1060
1135
|
});
|
|
1061
|
-
const directory = "/
|
|
1062
|
-
if (
|
|
1136
|
+
const directory = args2.directory || "src/";
|
|
1137
|
+
if (args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0) {
|
|
1063
1138
|
const result = await interactivePrompt();
|
|
1064
1139
|
await init({
|
|
1065
1140
|
...result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { create } from '../../chunk-
|
|
1
|
+
export { create } from '../../chunk-YW5YUAZU.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, convertToViteEnvVar, FileService as FileService$1 } from './chunk-
|
|
5
|
-
export { create } from './chunk-
|
|
4
|
+
import { DepsService, create, checkPkgJson, checkAndInstallCoreDeps, interactivePrompt, init, logger, convertToViteEnvVar, FileService as FileService$1 } from './chunk-YW5YUAZU.js';
|
|
5
|
+
export { create } from './chunk-YW5YUAZU.js';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
7
|
import { config } from 'dotenv';
|
|
8
8
|
import { join as join$1, dirname } from 'node:path';
|
|
@@ -94,7 +94,7 @@ var BuildBundler = class extends Bundler {
|
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
async function build({ dir, tools }) {
|
|
97
|
-
const mastraDir = dir
|
|
97
|
+
const mastraDir = dir ? dir.startsWith("/") ? dir : join$1(process.cwd(), dir) : join$1(process.cwd(), "src", "mastra");
|
|
98
98
|
const outputDirectory = join$1(process.cwd(), ".mastra");
|
|
99
99
|
const defaultToolsPath = join$1(mastraDir, "tools");
|
|
100
100
|
const discoveredTools = [defaultToolsPath, ...tools ?? []];
|
|
@@ -106,6 +106,10 @@ async function build({ dir, tools }) {
|
|
|
106
106
|
const deployer = new BuildBundler();
|
|
107
107
|
await deployer.prepare(outputDirectory);
|
|
108
108
|
await deployer.bundle(mastraEntryFile, outputDirectory, discoveredTools);
|
|
109
|
+
logger.info(`Build successful, you can now deploy the .mastra/output directory to your target platform.`);
|
|
110
|
+
logger.info(
|
|
111
|
+
`To start the server, run: node --import=./.mastra/output/instrumentation.mjs .mastra/output/index.mjs`
|
|
112
|
+
);
|
|
109
113
|
return;
|
|
110
114
|
}
|
|
111
115
|
logger.info("Deployer found, preparing deployer build...");
|
|
@@ -213,11 +217,8 @@ var DevBundler = class extends Bundler {
|
|
|
213
217
|
{
|
|
214
218
|
name: "tools-watcher",
|
|
215
219
|
async buildEnd() {
|
|
216
|
-
const
|
|
217
|
-
await writeFile(
|
|
218
|
-
join$1(outputDir, "tools.mjs"),
|
|
219
|
-
`export const tools = ${JSON.stringify(toolsInputOptions2)};`
|
|
220
|
-
);
|
|
220
|
+
const toolsInputPaths = Array.from(Object.keys(toolsInputOptions || {})).filter((key) => key.startsWith("tools/")).map((key) => `./${key}.mjs`);
|
|
221
|
+
await writeFile(join$1(outputDir, "tools.mjs"), `export const tools = ${JSON.stringify(toolsInputPaths)};`);
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
],
|
|
@@ -335,7 +336,7 @@ async function dev({
|
|
|
335
336
|
tools
|
|
336
337
|
}) {
|
|
337
338
|
const rootDir = root || process.cwd();
|
|
338
|
-
const mastraDir = join(
|
|
339
|
+
const mastraDir = dir ? dir.startsWith("/") ? dir : join(process.cwd(), dir) : join(process.cwd(), "src", "mastra");
|
|
339
340
|
const dotMastraPath = join(rootDir, ".mastra");
|
|
340
341
|
const defaultToolsPath = join(mastraDir, "tools");
|
|
341
342
|
const discoveredTools = [defaultToolsPath, ...tools || []];
|
|
@@ -387,13 +388,14 @@ program.version(`${version}`, "-v, --version").description(`Mastra CLI ${version
|
|
|
387
388
|
} catch {
|
|
388
389
|
}
|
|
389
390
|
});
|
|
390
|
-
program.command("create").description("Create a new Mastra project").option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras))").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option(
|
|
391
|
+
program.command("create [project-name]").description("Create a new Mastra project").option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras))").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").option(
|
|
391
392
|
"-p, --project-name <string>",
|
|
392
393
|
"Project name that will be used in package.json and as the project directory name."
|
|
393
|
-
).action(async (args) => {
|
|
394
|
+
).action(async (projectNameArg, args) => {
|
|
395
|
+
const projectName = projectNameArg || args.projectName;
|
|
394
396
|
await analytics.trackCommandExecution({
|
|
395
397
|
command: "create",
|
|
396
|
-
args,
|
|
398
|
+
args: { ...args, projectName },
|
|
397
399
|
execution: async () => {
|
|
398
400
|
const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
|
|
399
401
|
if (args.default) {
|
|
@@ -411,19 +413,20 @@ program.command("create").description("Create a new Mastra project").option("--d
|
|
|
411
413
|
addExample: args.example,
|
|
412
414
|
llmApiKey: args["llm-api-key"],
|
|
413
415
|
timeout,
|
|
414
|
-
projectName
|
|
416
|
+
projectName,
|
|
417
|
+
directory: args.dir
|
|
415
418
|
});
|
|
416
419
|
},
|
|
417
420
|
origin
|
|
418
421
|
});
|
|
419
422
|
});
|
|
420
|
-
program.command("init").description("Initialize Mastra in your project").option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-d, --dir <directory>", "Directory for Mastra files to (defaults to src/)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google or cerebras))").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").action(async (args) => {
|
|
423
|
+
program.command("init").description("Initialize Mastra in your project").option("--default", "Quick start with defaults(src, OpenAI, no examples)").option("-d, --dir <directory>", "Directory for Mastra files to (defaults to src/)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google or cerebras))").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").action(async (args) => {
|
|
421
424
|
await analytics.trackCommandExecution({
|
|
422
425
|
command: "init",
|
|
423
426
|
args,
|
|
424
427
|
execution: async () => {
|
|
425
428
|
await checkPkgJson();
|
|
426
|
-
await checkAndInstallCoreDeps();
|
|
429
|
+
await checkAndInstallCoreDeps(args?.example || args?.default);
|
|
427
430
|
if (!Object.keys(args).length) {
|
|
428
431
|
const result = await interactivePrompt();
|
|
429
432
|
await init({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mastra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha.11",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"description": "cli for mastra",
|
|
6
6
|
"type": "module",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"yocto-spinner": "^0.1.2",
|
|
55
55
|
"zod": "^3.24.2",
|
|
56
56
|
"zod-to-json-schema": "^3.24.3",
|
|
57
|
-
"@mastra/
|
|
58
|
-
"@mastra/
|
|
57
|
+
"@mastra/deployer": "^0.3.1-alpha.8",
|
|
58
|
+
"@mastra/core": "^0.9.1-alpha.8"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@microsoft/api-extractor": "^7.52.
|
|
61
|
+
"@microsoft/api-extractor": "^7.52.5",
|
|
62
62
|
"@types/fs-extra": "^11.0.4",
|
|
63
63
|
"@types/node": "^20.17.27",
|
|
64
64
|
"@types/prompt": "^1.1.9",
|
|
@@ -67,14 +67,14 @@
|
|
|
67
67
|
"eslint": "^9.23.0",
|
|
68
68
|
"memfs": "^4.17.0",
|
|
69
69
|
"npm-run-all2": "^7.0.2",
|
|
70
|
-
"rollup": "^4.
|
|
70
|
+
"rollup": "^4.40.1",
|
|
71
71
|
"tsup": "^8.4.0",
|
|
72
72
|
"type-fest": "^4.37.0",
|
|
73
73
|
"typescript": "^5.8.2",
|
|
74
|
-
"vitest": "^3.
|
|
74
|
+
"vitest": "^3.1.2",
|
|
75
|
+
"@mastra/client-js": "0.1.19-alpha.8",
|
|
75
76
|
"@internal/lint": "0.0.2",
|
|
76
|
-
"@mastra/
|
|
77
|
-
"@mastra/playground-ui": "5.0.0"
|
|
77
|
+
"@mastra/playground-ui": "5.0.1-alpha.9"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"build": "npm-run-all --serial build:lib copy-starter-files copy-templates build:playground",
|