create-mastra 0.0.0-netlify-no-bundle-20251127120354 → 0.0.0-partial-response-backport-20251204204441

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
@@ -4,7 +4,7 @@ import { randomUUID } from 'node:crypto';
4
4
  import * as fs3__default from 'node:fs';
5
5
  import fs3__default__default, { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
6
  import os from 'node:os';
7
- import path3, { dirname } from 'node:path';
7
+ import path, { dirname } from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { PostHog } from 'posthog-node';
10
10
  import fs4 from 'node:fs/promises';
@@ -23,7 +23,7 @@ import pretty from 'pino-pretty';
23
23
  import fsExtra$1 from 'fs-extra';
24
24
 
25
25
  var __filename = fileURLToPath(import.meta.url);
26
- var __dirname = path3.dirname(__filename);
26
+ var __dirname = path.dirname(__filename);
27
27
  var analyticsInstance = null;
28
28
  function getAnalytics() {
29
29
  return analyticsInstance;
@@ -39,7 +39,7 @@ var PosthogAnalytics = class {
39
39
  host = "https://app.posthog.com"
40
40
  }) {
41
41
  this.version = version;
42
- const cliConfigPath = path3.join(__dirname, "mastra-cli.json");
42
+ const cliConfigPath = path.join(__dirname, "mastra-cli.json");
43
43
  if (existsSync(cliConfigPath)) {
44
44
  try {
45
45
  const { distinctId, sessionId } = JSON.parse(readFileSync(cliConfigPath, "utf-8"));
@@ -67,7 +67,7 @@ var PosthogAnalytics = class {
67
67
  }
68
68
  writeCliConfig({ distinctId, sessionId }) {
69
69
  try {
70
- writeFileSync(path3.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
70
+ writeFileSync(path.join(__dirname, "mastra-cli.json"), JSON.stringify({ distinctId, sessionId }));
71
71
  } catch {
72
72
  }
73
73
  }
@@ -887,7 +887,6 @@ class YoctoSpinner {
887
887
  #exitHandlerBound;
888
888
  #isInteractive;
889
889
  #lastSpinnerFrameTime = 0;
890
- #isSpinning = false;
891
890
 
892
891
  constructor(options = {}) {
893
892
  const spinner = options.spinner ?? defaultSpinner;
@@ -909,17 +908,13 @@ class YoctoSpinner {
909
908
  return this;
910
909
  }
911
910
 
912
- this.#isSpinning = true;
913
911
  this.#hideCursor();
914
912
  this.#render();
915
913
  this.#subscribeToProcessEvents();
916
914
 
917
- // Only start the timer in interactive mode
918
- if (this.#isInteractive) {
919
- this.#timer = setInterval(() => {
920
- this.#render();
921
- }, this.#interval);
922
- }
915
+ this.#timer = setInterval(() => {
916
+ this.#render();
917
+ }, this.#interval);
923
918
 
924
919
  return this;
925
920
  }
@@ -929,12 +924,8 @@ class YoctoSpinner {
929
924
  return this;
930
925
  }
931
926
 
932
- this.#isSpinning = false;
933
- if (this.#timer) {
934
- clearInterval(this.#timer);
935
- this.#timer = undefined;
936
- }
937
-
927
+ clearInterval(this.#timer);
928
+ this.#timer = undefined;
938
929
  this.#showCursor();
939
930
  this.clear();
940
931
  this.#unsubscribeFromProcessEvents();
@@ -967,7 +958,7 @@ class YoctoSpinner {
967
958
  }
968
959
 
969
960
  get isSpinning() {
970
- return this.#isSpinning;
961
+ return this.#timer !== undefined;
971
962
  }
972
963
 
973
964
  get text() {
@@ -1104,11 +1095,11 @@ var MastraLogger = class {
1104
1095
  }
1105
1096
  trackException(_error) {
1106
1097
  }
1107
- async listLogs(transportId, params) {
1098
+ async getLogs(transportId, params) {
1108
1099
  if (!transportId || !this.transports.has(transportId)) {
1109
1100
  return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };
1110
1101
  }
1111
- return this.transports.get(transportId).listLogs(params) ?? {
1102
+ return this.transports.get(transportId).getLogs(params) ?? {
1112
1103
  logs: [],
1113
1104
  total: 0,
1114
1105
  page: params?.page ?? 1,
@@ -1116,7 +1107,7 @@ var MastraLogger = class {
1116
1107
  hasMore: false
1117
1108
  };
1118
1109
  }
1119
- async listLogsByRunId({
1110
+ async getLogsByRunId({
1120
1111
  transportId,
1121
1112
  runId,
1122
1113
  fromDate,
@@ -1129,7 +1120,7 @@ var MastraLogger = class {
1129
1120
  if (!transportId || !this.transports.has(transportId) || !runId) {
1130
1121
  return { logs: [], total: 0, page: page ?? 1, perPage: perPage ?? 100, hasMore: false };
1131
1122
  }
1132
- return this.transports.get(transportId).listLogsByRunId({ runId, fromDate, toDate, logLevel, filters, page, perPage }) ?? {
1123
+ return this.transports.get(transportId).getLogsByRunId({ runId, fromDate, toDate, logLevel, filters, page, perPage }) ?? {
1133
1124
  logs: [],
1134
1125
  total: 0,
1135
1126
  page: page ?? 1,
@@ -1187,8 +1178,118 @@ var PinoLogger = class extends MastraLogger {
1187
1178
  }
1188
1179
  };
1189
1180
 
1190
- var package_default = {
1191
- version: "1.0.0-beta.4"};
1181
+ var args = ["-y", "@mastra/mcp-docs-server"];
1182
+ var createMcpConfig = (editor) => {
1183
+ if (editor === "vscode") {
1184
+ return {
1185
+ servers: {
1186
+ mastra: process.platform === `win32` ? {
1187
+ command: "cmd",
1188
+ args: ["/c", "npx", ...args],
1189
+ type: "stdio"
1190
+ } : {
1191
+ command: "npx",
1192
+ args,
1193
+ type: "stdio"
1194
+ }
1195
+ }
1196
+ };
1197
+ }
1198
+ return {
1199
+ mcpServers: {
1200
+ mastra: {
1201
+ command: "npx",
1202
+ args
1203
+ }
1204
+ }
1205
+ };
1206
+ };
1207
+ function makeConfig(original, editor) {
1208
+ if (editor === "vscode") {
1209
+ return {
1210
+ ...original,
1211
+ servers: {
1212
+ ...original?.servers || {},
1213
+ ...createMcpConfig(editor).servers
1214
+ }
1215
+ };
1216
+ }
1217
+ return {
1218
+ ...original,
1219
+ mcpServers: {
1220
+ ...original?.mcpServers || {},
1221
+ ...createMcpConfig(editor).mcpServers
1222
+ }
1223
+ };
1224
+ }
1225
+ async function writeMergedConfig(configPath, editor) {
1226
+ const configExists = existsSync(configPath);
1227
+ const config = makeConfig(configExists ? await readJSON(configPath) : {}, editor);
1228
+ await ensureFile(configPath);
1229
+ await writeJSON(configPath, config, {
1230
+ spaces: 2
1231
+ });
1232
+ }
1233
+ var windsurfGlobalMCPConfigPath = path.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1234
+ var cursorGlobalMCPConfigPath = path.join(os.homedir(), ".cursor", "mcp.json");
1235
+ path.join(process.cwd(), ".vscode", "mcp.json");
1236
+ var vscodeGlobalMCPConfigPath = path.join(
1237
+ os.homedir(),
1238
+ process.platform === "win32" ? path.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path.join("Library", "Application Support", "Code", "User", "settings.json") : path.join(".config", "Code", "User", "settings.json")
1239
+ );
1240
+ async function installMastraDocsMCPServer({ editor, directory }) {
1241
+ if (editor === `cursor`) {
1242
+ await writeMergedConfig(path.join(directory, ".cursor", "mcp.json"), "cursor");
1243
+ }
1244
+ if (editor === `vscode`) {
1245
+ await writeMergedConfig(path.join(directory, ".vscode", "mcp.json"), "vscode");
1246
+ }
1247
+ if (editor === `cursor-global`) {
1248
+ const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
1249
+ if (alreadyInstalled) {
1250
+ return;
1251
+ }
1252
+ await writeMergedConfig(cursorGlobalMCPConfigPath, "cursor-global");
1253
+ }
1254
+ if (editor === `windsurf`) {
1255
+ const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor);
1256
+ if (alreadyInstalled) {
1257
+ return;
1258
+ }
1259
+ await writeMergedConfig(windsurfGlobalMCPConfigPath, editor);
1260
+ }
1261
+ }
1262
+ async function globalMCPIsAlreadyInstalled(editor) {
1263
+ let configPath = ``;
1264
+ if (editor === "windsurf") {
1265
+ configPath = windsurfGlobalMCPConfigPath;
1266
+ } else if (editor === "cursor-global") {
1267
+ configPath = cursorGlobalMCPConfigPath;
1268
+ } else if (editor === "vscode") {
1269
+ configPath = vscodeGlobalMCPConfigPath;
1270
+ }
1271
+ if (!configPath || !existsSync(configPath)) {
1272
+ return false;
1273
+ }
1274
+ try {
1275
+ const configContents = await readJSON(configPath);
1276
+ if (!configContents) return false;
1277
+ if (editor === "vscode") {
1278
+ if (!configContents.servers) return false;
1279
+ const hasMastraMCP2 = Object.values(configContents.servers).some(
1280
+ (server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
1281
+ );
1282
+ return hasMastraMCP2;
1283
+ }
1284
+ if (!configContents?.mcpServers) return false;
1285
+ const hasMastraMCP = Object.values(configContents.mcpServers).some(
1286
+ (server) => server?.args?.find((arg) => arg?.includes(`@mastra/mcp-docs-server`))
1287
+ );
1288
+ return hasMastraMCP;
1289
+ } catch {
1290
+ return false;
1291
+ }
1292
+ }
1192
1293
  function getPackageManagerAddCommand(pm) {
1193
1294
  switch (pm) {
1194
1295
  case "npm":
@@ -1211,11 +1312,11 @@ var DepsService = class {
1211
1312
  findLockFile(dir) {
1212
1313
  const lockFiles = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock"];
1213
1314
  for (const file of lockFiles) {
1214
- if (fs3__default__default.existsSync(path3.join(dir, file))) {
1315
+ if (fs3__default__default.existsSync(path.join(dir, file))) {
1215
1316
  return file;
1216
1317
  }
1217
1318
  }
1218
- const parentDir = path3.resolve(dir, "..");
1319
+ const parentDir = path.resolve(dir, "..");
1219
1320
  if (parentDir !== dir) {
1220
1321
  return this.findLockFile(parentDir);
1221
1322
  }
@@ -1248,7 +1349,7 @@ var DepsService = class {
1248
1349
  }
1249
1350
  async checkDependencies(dependencies) {
1250
1351
  try {
1251
- const packageJsonPath = path3.join(process.cwd(), "package.json");
1352
+ const packageJsonPath = path.join(process.cwd(), "package.json");
1252
1353
  try {
1253
1354
  await fs4.access(packageJsonPath);
1254
1355
  } catch {
@@ -1268,7 +1369,7 @@ var DepsService = class {
1268
1369
  }
1269
1370
  async getProjectName() {
1270
1371
  try {
1271
- const packageJsonPath = path3.join(process.cwd(), "package.json");
1372
+ const packageJsonPath = path.join(process.cwd(), "package.json");
1272
1373
  const packageJson = await fs4.readFile(packageJsonPath, "utf-8");
1273
1374
  const pkg = JSON.parse(packageJson);
1274
1375
  return pkg.name;
@@ -1356,8 +1457,8 @@ var FileService = class {
1356
1457
  */
1357
1458
  async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
1358
1459
  const __filename = fileURLToPath(import.meta.url);
1359
- const __dirname = path3.dirname(__filename);
1360
- const filePath = path3.resolve(__dirname, "starter-files", inputFile);
1460
+ const __dirname = path.dirname(__filename);
1461
+ const filePath = path.resolve(__dirname, "starter-files", inputFile);
1361
1462
  const fileString = fs3__default__default.readFileSync(filePath, "utf8");
1362
1463
  if (fs3__default__default.existsSync(outputFilePath) && !replaceIfExists) {
1363
1464
  console.info(`${outputFilePath} already exists`);
@@ -1367,7 +1468,7 @@ var FileService = class {
1367
1468
  return true;
1368
1469
  }
1369
1470
  async setupEnvFile({ dbUrl }) {
1370
- const envPath = path3.join(process.cwd(), ".env.development");
1471
+ const envPath = path.join(process.cwd(), ".env.development");
1371
1472
  await fsExtra.ensureFile(envPath);
1372
1473
  const fileEnvService = new FileEnvService(envPath);
1373
1474
  await fileEnvService.setEnvValue("DB_URL", dbUrl);
@@ -1391,142 +1492,21 @@ var FileService = class {
1391
1492
  fs3__default__default.writeFileSync(filePath, fileContent);
1392
1493
  }
1393
1494
  };
1394
- var createArgs = (versionTag) => {
1395
- const packageName = versionTag ? `@mastra/mcp-docs-server@${versionTag}` : "@mastra/mcp-docs-server";
1396
- return ["-y", packageName];
1397
- };
1398
- var createMcpConfig = (editor, versionTag) => {
1399
- const args = createArgs(versionTag);
1400
- if (editor === "vscode") {
1401
- return {
1402
- servers: {
1403
- mastra: process.platform === `win32` ? {
1404
- command: "cmd",
1405
- args: ["/c", "npx", ...args],
1406
- type: "stdio"
1407
- } : {
1408
- command: "npx",
1409
- args,
1410
- type: "stdio"
1411
- }
1412
- }
1413
- };
1414
- }
1415
- return {
1416
- mcpServers: {
1417
- mastra: {
1418
- command: "npx",
1419
- args
1420
- }
1421
- }
1422
- };
1423
- };
1424
- function makeConfig(original, editor, versionTag) {
1425
- if (editor === "vscode") {
1426
- return {
1427
- ...original,
1428
- servers: {
1429
- ...original?.servers || {},
1430
- ...createMcpConfig(editor, versionTag).servers
1431
- }
1432
- };
1433
- }
1434
- return {
1435
- ...original,
1436
- mcpServers: {
1437
- ...original?.mcpServers || {},
1438
- ...createMcpConfig(editor, versionTag).mcpServers
1439
- }
1440
- };
1441
- }
1442
- async function writeMergedConfig(configPath, editor, versionTag) {
1443
- const configExists = existsSync(configPath);
1444
- const config = makeConfig(configExists ? await readJSON(configPath) : {}, editor, versionTag);
1445
- await ensureFile(configPath);
1446
- await writeJSON(configPath, config, {
1447
- spaces: 2
1448
- });
1449
- }
1450
- var windsurfGlobalMCPConfigPath = path3.join(os.homedir(), ".codeium", "windsurf", "mcp_config.json");
1451
- var cursorGlobalMCPConfigPath = path3.join(os.homedir(), ".cursor", "mcp.json");
1452
- path3.join(process.cwd(), ".vscode", "mcp.json");
1453
- var vscodeGlobalMCPConfigPath = path3.join(
1454
- os.homedir(),
1455
- process.platform === "win32" ? path3.join("AppData", "Roaming", "Code", "User", "settings.json") : process.platform === "darwin" ? path3.join("Library", "Application Support", "Code", "User", "settings.json") : path3.join(".config", "Code", "User", "settings.json")
1456
- );
1457
- async function installMastraDocsMCPServer({
1458
- editor,
1459
- directory,
1460
- versionTag
1461
- }) {
1462
- if (editor === `cursor`) {
1463
- await writeMergedConfig(path3.join(directory, ".cursor", "mcp.json"), "cursor", versionTag);
1464
- }
1465
- if (editor === `vscode`) {
1466
- await writeMergedConfig(path3.join(directory, ".vscode", "mcp.json"), "vscode", versionTag);
1467
- }
1468
- if (editor === `cursor-global`) {
1469
- const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor, versionTag);
1470
- if (alreadyInstalled) {
1471
- return;
1472
- }
1473
- await writeMergedConfig(cursorGlobalMCPConfigPath, "cursor-global", versionTag);
1474
- }
1475
- if (editor === `windsurf`) {
1476
- const alreadyInstalled = await globalMCPIsAlreadyInstalled(editor, versionTag);
1477
- if (alreadyInstalled) {
1478
- return;
1479
- }
1480
- await writeMergedConfig(windsurfGlobalMCPConfigPath, editor, versionTag);
1481
- }
1482
- }
1483
- async function globalMCPIsAlreadyInstalled(editor, versionTag) {
1484
- let configPath = ``;
1485
- if (editor === "windsurf") {
1486
- configPath = windsurfGlobalMCPConfigPath;
1487
- } else if (editor === "cursor-global") {
1488
- configPath = cursorGlobalMCPConfigPath;
1489
- } else if (editor === "vscode") {
1490
- configPath = vscodeGlobalMCPConfigPath;
1491
- }
1492
- if (!configPath || !existsSync(configPath)) {
1493
- return false;
1494
- }
1495
- try {
1496
- const configContents = await readJSON(configPath);
1497
- if (!configContents) return false;
1498
- const expectedPackage = versionTag ? `@mastra/mcp-docs-server@${versionTag}` : "@mastra/mcp-docs-server";
1499
- if (editor === "vscode") {
1500
- if (!configContents.servers) return false;
1501
- const hasMastraMCP2 = Object.values(configContents.servers).some(
1502
- (server) => server?.args?.find((arg) => arg === expectedPackage)
1503
- );
1504
- return hasMastraMCP2;
1505
- }
1506
- if (!configContents?.mcpServers) return false;
1507
- const hasMastraMCP = Object.values(configContents.mcpServers).some(
1508
- (server) => server?.args?.find((arg) => arg === expectedPackage)
1509
- );
1510
- return hasMastraMCP;
1511
- } catch {
1512
- return false;
1513
- }
1514
- }
1515
1495
  var exec = util.promisify(child_process.exec);
1516
1496
  var getModelIdentifier = (llmProvider) => {
1517
- let model = "openai/gpt-4o";
1518
- if (llmProvider === "anthropic") {
1519
- model = "anthropic/claude-sonnet-4-5";
1497
+ if (llmProvider === "openai") {
1498
+ return `'openai/gpt-4o-mini'`;
1499
+ } else if (llmProvider === "anthropic") {
1500
+ return `'anthropic/claude-sonnet-4-5-20250929'`;
1520
1501
  } else if (llmProvider === "groq") {
1521
- model = "groq/llama-3.3-70b-versatile";
1502
+ return `'groq/llama-3.3-70b-versatile'`;
1522
1503
  } else if (llmProvider === "google") {
1523
- model = "google/gemini-2.5-pro";
1504
+ return `'google/gemini-2.5-pro'`;
1524
1505
  } else if (llmProvider === "cerebras") {
1525
- model = "cerebras/llama-3.3-70b";
1506
+ return `'cerebras/llama-3.3-70b'`;
1526
1507
  } else if (llmProvider === "mistral") {
1527
- model = "mistral/mistral-medium-2508";
1508
+ return `'mistral/mistral-medium-2508'`;
1528
1509
  }
1529
- return model;
1530
1510
  };
1531
1511
  async function writeAgentSample(llmProvider, destPath, addExampleTool, addScorers) {
1532
1512
  const modelString = getModelIdentifier(llmProvider);
@@ -1552,10 +1532,9 @@ ${addExampleTool ? `import { weatherTool } from '../tools/weather-tool';` : ""}
1552
1532
  ${addScorers ? `import { scorers } from '../scorers/weather-scorer';` : ""}
1553
1533
 
1554
1534
  export const weatherAgent = new Agent({
1555
- id: 'weather-agent',
1556
1535
  name: 'Weather Agent',
1557
1536
  instructions: \`${instructions}\`,
1558
- model: '${modelString}',
1537
+ model: ${modelString},
1559
1538
  ${addExampleTool ? "tools: { weatherTool }," : ""}
1560
1539
  ${addScorers ? `scorers: {
1561
1540
  toolCallAppropriateness: {
@@ -1582,7 +1561,6 @@ export const weatherAgent = new Agent({
1582
1561
  },` : ""}
1583
1562
  memory: new Memory({
1584
1563
  storage: new LibSQLStore({
1585
- id: "memory-storage",
1586
1564
  url: "file:../mastra.db", // path is relative to the .mastra/output directory
1587
1565
  })
1588
1566
  })
@@ -1795,10 +1773,9 @@ async function writeToolSample(destPath) {
1795
1773
  async function writeScorersSample(llmProvider, destPath) {
1796
1774
  const modelString = getModelIdentifier(llmProvider);
1797
1775
  const content = `import { z } from 'zod';
1798
- import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/prebuilt';
1799
- import { createCompletenessScorer } from '@mastra/evals/scorers/prebuilt';
1800
- import { getAssistantMessageFromRunOutput, getUserMessageFromRunInput } from '@mastra/evals/scorers/utils';
1801
- import { createScorer } from '@mastra/core/evals';
1776
+ import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/code';
1777
+ import { createCompletenessScorer } from '@mastra/evals/scorers/code';
1778
+ import { createScorer } from '@mastra/core/scores';
1802
1779
 
1803
1780
  export const toolCallAppropriatenessScorer = createToolCallAccuracyScorerCode({
1804
1781
  expectedTool: 'weatherTool',
@@ -1809,12 +1786,11 @@ export const completenessScorer = createCompletenessScorer();
1809
1786
 
1810
1787
  // Custom LLM-judged scorer: evaluates if non-English locations are translated appropriately
1811
1788
  export const translationScorer = createScorer({
1812
- id: 'translation-quality-scorer',
1813
1789
  name: 'Translation Quality',
1814
1790
  description: 'Checks that non-English location names are translated and used correctly',
1815
1791
  type: 'agent',
1816
1792
  judge: {
1817
- model: '${modelString}',
1793
+ model: ${modelString},
1818
1794
  instructions:
1819
1795
  'You are an expert evaluator of translation quality for geographic locations. ' +
1820
1796
  'Determine whether the user text mentions a non-English location and whether the assistant correctly uses an English translation of that location. ' +
@@ -1823,8 +1799,8 @@ export const translationScorer = createScorer({
1823
1799
  },
1824
1800
  })
1825
1801
  .preprocess(({ run }) => {
1826
- const userText = getUserMessageFromRunInput(run.input) || '';
1827
- const assistantText = getAssistantMessageFromRunOutput(run.output) || '';
1802
+ const userText = (run.input?.inputMessages?.[0]?.content as string) || '';
1803
+ const assistantText = (run.output?.[0]?.content as string) || '';
1828
1804
  return { userText, assistantText };
1829
1805
  })
1830
1806
  .analyze({
@@ -1911,7 +1887,7 @@ var writeIndexFile = async ({
1911
1887
  addScorers
1912
1888
  }) => {
1913
1889
  const indexPath = dirPath + "/index.ts";
1914
- const destPath = path3.join(indexPath);
1890
+ const destPath = path.join(indexPath);
1915
1891
  try {
1916
1892
  await fs4.writeFile(destPath, "");
1917
1893
  const filteredExports = [
@@ -1923,7 +1899,7 @@ var writeIndexFile = async ({
1923
1899
  await fs4.writeFile(
1924
1900
  destPath,
1925
1901
  `
1926
- import { Mastra } from '@mastra/core/mastra';
1902
+ import { Mastra } from '@mastra/core';
1927
1903
 
1928
1904
  export const mastra = new Mastra()
1929
1905
  `
@@ -1936,7 +1912,6 @@ export const mastra = new Mastra()
1936
1912
  import { Mastra } from '@mastra/core/mastra';
1937
1913
  import { PinoLogger } from '@mastra/loggers';
1938
1914
  import { LibSQLStore } from '@mastra/libsql';
1939
- import { Observability } from '@mastra/observability';
1940
1915
  ${addWorkflow ? `import { weatherWorkflow } from './workflows/weather-workflow';` : ""}
1941
1916
  ${addAgent ? `import { weatherAgent } from './agents/weather-agent';` : ""}
1942
1917
  ${addScorers ? `import { toolCallAppropriatenessScorer, completenessScorer, translationScorer } from './scorers/weather-scorer';` : ""}
@@ -1944,7 +1919,6 @@ ${addScorers ? `import { toolCallAppropriatenessScorer, completenessScorer, tran
1944
1919
  export const mastra = new Mastra({
1945
1920
  ${filteredExports.join("\n ")}
1946
1921
  storage: new LibSQLStore({
1947
- id: "mastra-storage",
1948
1922
  // stores observability, scores, ... into memory storage, if it needs to persist, change to file:../mastra.db
1949
1923
  url: ":memory:",
1950
1924
  }),
@@ -1952,10 +1926,14 @@ export const mastra = new Mastra({
1952
1926
  name: 'Mastra',
1953
1927
  level: 'info',
1954
1928
  }),
1955
- observability: new Observability({
1956
- // Enables DefaultExporter and CloudExporter for tracing
1957
- default: { enabled: true },
1958
- }),
1929
+ telemetry: {
1930
+ // Telemetry is deprecated and will be removed in the Nov 4th release
1931
+ enabled: false,
1932
+ },
1933
+ observability: {
1934
+ // Enables DefaultExporter and CloudExporter for AI tracing
1935
+ default: { enabled: true },
1936
+ },
1959
1937
  });
1960
1938
  `
1961
1939
  );
@@ -1994,7 +1972,7 @@ var writeAPIKey = async ({ provider, apiKey }) => {
1994
1972
  };
1995
1973
  var createMastraDir = async (directory) => {
1996
1974
  let dir = directory.trim().split("/").filter((item) => item !== "");
1997
- const dirPath = path3.join(process.cwd(), ...dir, "mastra");
1975
+ const dirPath = path.join(process.cwd(), ...dir, "mastra");
1998
1976
  try {
1999
1977
  await fs4.access(dirPath);
2000
1978
  return { ok: false };
@@ -2019,8 +1997,8 @@ var LLM_PROVIDERS = [
2019
1997
  { value: "cerebras", label: "Cerebras" },
2020
1998
  { value: "mistral", label: "Mistral" }
2021
1999
  ];
2022
- var interactivePrompt = async (args = {}) => {
2023
- const { skip = {}, options: { showBanner = true } = {} } = args;
2000
+ var interactivePrompt = async (args2 = {}) => {
2001
+ const { skip = {}, options: { showBanner = true } = {} } = args2;
2024
2002
  if (showBanner) {
2025
2003
  Ie(color2.inverse(" Mastra Init "));
2026
2004
  }
@@ -2058,29 +2036,46 @@ var interactivePrompt = async (args = {}) => {
2058
2036
  return void 0;
2059
2037
  },
2060
2038
  configureEditorWithDocsMCP: async () => {
2039
+ const windsurfIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`windsurf`);
2040
+ const cursorIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`cursor`);
2041
+ const vscodeIsAlreadyInstalled = await globalMCPIsAlreadyInstalled(`vscode`);
2061
2042
  const editor = await ve({
2062
2043
  message: `Make your IDE into a Mastra expert? (Installs Mastra's MCP server)`,
2063
2044
  options: [
2064
2045
  { value: "skip", label: "Skip for now", hint: "default" },
2065
2046
  {
2066
2047
  value: "cursor",
2067
- label: "Cursor (project only)"
2048
+ label: "Cursor (project only)",
2049
+ hint: cursorIsAlreadyInstalled ? `Already installed globally` : void 0
2068
2050
  },
2069
2051
  {
2070
2052
  value: "cursor-global",
2071
- label: "Cursor (global, all projects)"
2053
+ label: "Cursor (global, all projects)",
2054
+ hint: cursorIsAlreadyInstalled ? `Already installed` : void 0
2072
2055
  },
2073
2056
  {
2074
2057
  value: "windsurf",
2075
- label: "Windsurf"
2058
+ label: "Windsurf",
2059
+ hint: windsurfIsAlreadyInstalled ? `Already installed` : void 0
2076
2060
  },
2077
2061
  {
2078
2062
  value: "vscode",
2079
- label: "VSCode"
2063
+ label: "VSCode",
2064
+ hint: vscodeIsAlreadyInstalled ? `Already installed` : void 0
2080
2065
  }
2081
2066
  ]
2082
2067
  });
2083
2068
  if (editor === `skip`) return void 0;
2069
+ if (editor === `windsurf` && windsurfIsAlreadyInstalled) {
2070
+ M.message(`
2071
+ Windsurf is already installed, skipping.`);
2072
+ return void 0;
2073
+ }
2074
+ if (editor === `vscode` && vscodeIsAlreadyInstalled) {
2075
+ M.message(`
2076
+ VSCode is already installed, skipping.`);
2077
+ return void 0;
2078
+ }
2084
2079
  if (editor === `cursor`) {
2085
2080
  M.message(
2086
2081
  `
@@ -2163,23 +2158,19 @@ function createLogger(debug = false) {
2163
2158
  }
2164
2159
  var exec2 = util.promisify(child_process.exec);
2165
2160
  async function cloneTemplate(options) {
2166
- const { template, projectName, targetDir, branch, llmProvider } = options;
2167
- const projectPath = targetDir ? path3.resolve(targetDir, projectName) : path3.resolve(projectName);
2161
+ const { template, projectName, targetDir } = options;
2162
+ const projectPath = targetDir ? path.resolve(targetDir, projectName) : path.resolve(projectName);
2168
2163
  const spinner4 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
2169
2164
  try {
2170
2165
  if (await directoryExists(projectPath)) {
2171
2166
  spinner4.error(`Directory ${projectName} already exists`);
2172
2167
  throw new Error(`Directory ${projectName} already exists`);
2173
2168
  }
2174
- await cloneRepositoryWithoutGit(template.githubUrl, projectPath, branch);
2169
+ await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
2175
2170
  await updatePackageJson(projectPath, projectName);
2176
- const envExamplePath = path3.join(projectPath, ".env.example");
2171
+ const envExamplePath = path.join(projectPath, ".env.example");
2177
2172
  if (await fileExists(envExamplePath)) {
2178
- const envPath = path3.join(projectPath, ".env");
2179
- await fs4.copyFile(envExamplePath, envPath);
2180
- if (llmProvider) {
2181
- await updateEnvFile(envPath, llmProvider);
2182
- }
2173
+ await fs4.copyFile(envExamplePath, path.join(projectPath, ".env"));
2183
2174
  }
2184
2175
  spinner4.success(`Template "${template.title}" cloned successfully to ${projectName}`);
2185
2176
  return projectPath;
@@ -2204,27 +2195,21 @@ async function fileExists(filePath) {
2204
2195
  return false;
2205
2196
  }
2206
2197
  }
2207
- async function cloneRepositoryWithoutGit(repoUrl, targetPath, branch) {
2198
+ async function cloneRepositoryWithoutGit(repoUrl, targetPath) {
2208
2199
  await fs4.mkdir(targetPath, { recursive: true });
2209
2200
  try {
2210
2201
  const degitRepo = repoUrl.replace("https://github.com/", "");
2211
- const degitRepoWithBranch = branch ? `${degitRepo}#${branch}` : degitRepo;
2212
- const degitCommand = shellQuote2.quote(["npx", "degit", degitRepoWithBranch, targetPath]);
2202
+ const degitCommand = shellQuote2.quote(["npx", "degit", degitRepo, targetPath]);
2213
2203
  await exec2(degitCommand, {
2214
2204
  cwd: process.cwd()
2215
2205
  });
2216
2206
  } catch {
2217
2207
  try {
2218
- const gitArgs = ["git", "clone"];
2219
- if (branch) {
2220
- gitArgs.push("--branch", branch);
2221
- }
2222
- gitArgs.push(repoUrl, targetPath);
2223
- const gitCommand = shellQuote2.quote(gitArgs);
2208
+ const gitCommand = shellQuote2.quote(["git", "clone", repoUrl, targetPath]);
2224
2209
  await exec2(gitCommand, {
2225
2210
  cwd: process.cwd()
2226
2211
  });
2227
- const gitDir = path3.join(targetPath, ".git");
2212
+ const gitDir = path.join(targetPath, ".git");
2228
2213
  if (await directoryExists(gitDir)) {
2229
2214
  await fs4.rm(gitDir, { recursive: true, force: true });
2230
2215
  }
@@ -2234,7 +2219,7 @@ async function cloneRepositoryWithoutGit(repoUrl, targetPath, branch) {
2234
2219
  }
2235
2220
  }
2236
2221
  async function updatePackageJson(projectPath, projectName) {
2237
- const packageJsonPath = path3.join(projectPath, "package.json");
2222
+ const packageJsonPath = path.join(projectPath, "package.json");
2238
2223
  try {
2239
2224
  const packageJsonContent = await fs4.readFile(packageJsonPath, "utf-8");
2240
2225
  const packageJson = JSON.parse(packageJsonContent);
@@ -2244,22 +2229,6 @@ async function updatePackageJson(projectPath, projectName) {
2244
2229
  logger.warn(`Could not update package.json: ${error instanceof Error ? error.message : "Unknown error"}`);
2245
2230
  }
2246
2231
  }
2247
- async function updateEnvFile(envPath, llmProvider) {
2248
- try {
2249
- const envContent = await fs4.readFile(envPath, "utf-8");
2250
- const modelString = getModelIdentifier(llmProvider);
2251
- if (!modelString) {
2252
- logger.warn(`Could not get model identifier for provider: ${llmProvider}`);
2253
- return;
2254
- }
2255
- const modelValue = modelString.replace(/'/g, "");
2256
- const updatedContent = envContent.replace(/^MODEL=.*/m, `MODEL=${modelValue}`);
2257
- await fs4.writeFile(envPath, updatedContent, "utf-8");
2258
- logger.info(`Updated MODEL in .env to ${modelValue}`);
2259
- } catch (error) {
2260
- logger.warn(`Could not update .env file: ${error instanceof Error ? error.message : "Unknown error"}`);
2261
- }
2262
- }
2263
2232
  async function installDependencies(projectPath, packageManager) {
2264
2233
  const spinner4 = yoctoSpinner({ text: "Installing dependencies..." }).start();
2265
2234
  try {
@@ -2344,11 +2313,9 @@ var init = async ({
2344
2313
  llmProvider = "openai",
2345
2314
  llmApiKey,
2346
2315
  addExample = false,
2347
- configureEditorWithDocsMCP,
2348
- versionTag
2316
+ configureEditorWithDocsMCP
2349
2317
  }) => {
2350
2318
  s.start("Initializing Mastra");
2351
- const packageVersionTag = versionTag ? `@${versionTag}` : "";
2352
2319
  try {
2353
2320
  const result = await createMastraDir(directory);
2354
2321
  if (!result.ok) {
@@ -2376,31 +2343,26 @@ var init = async ({
2376
2343
  const depService = new DepsService();
2377
2344
  const needsLibsql = await depService.checkDependencies(["@mastra/libsql"]) !== `ok`;
2378
2345
  if (needsLibsql) {
2379
- await depService.installPackages([`@mastra/libsql${packageVersionTag}`]);
2346
+ await depService.installPackages(["@mastra/libsql"]);
2380
2347
  }
2381
2348
  const needsMemory = components.includes(`agents`) && await depService.checkDependencies(["@mastra/memory"]) !== `ok`;
2382
2349
  if (needsMemory) {
2383
- await depService.installPackages([`@mastra/memory${packageVersionTag}`]);
2350
+ await depService.installPackages(["@mastra/memory"]);
2384
2351
  }
2385
2352
  const needsLoggers = await depService.checkDependencies(["@mastra/loggers"]) !== `ok`;
2386
2353
  if (needsLoggers) {
2387
- await depService.installPackages([`@mastra/loggers${packageVersionTag}`]);
2388
- }
2389
- const needsObservability = await depService.checkDependencies(["@mastra/observability"]) !== `ok`;
2390
- if (needsObservability) {
2391
- await depService.installPackages([`@mastra/observability${packageVersionTag}`]);
2354
+ await depService.installPackages(["@mastra/loggers"]);
2392
2355
  }
2393
2356
  const needsEvals = components.includes(`scorers`) && await depService.checkDependencies(["@mastra/evals"]) !== `ok`;
2394
2357
  if (needsEvals) {
2395
- await depService.installPackages([`@mastra/evals${packageVersionTag}`]);
2358
+ await depService.installPackages(["@mastra/evals"]);
2396
2359
  }
2397
2360
  }
2398
2361
  const key = await getAPIKey(llmProvider || "openai");
2399
2362
  if (configureEditorWithDocsMCP) {
2400
2363
  await installMastraDocsMCPServer({
2401
2364
  editor: configureEditorWithDocsMCP,
2402
- directory: process.cwd(),
2403
- versionTag
2365
+ directory: process.cwd()
2404
2366
  });
2405
2367
  }
2406
2368
  s.stop();
@@ -2466,7 +2428,7 @@ async function getInitCommand(pm) {
2466
2428
  async function initializePackageJson(pm) {
2467
2429
  const initCommand = await getInitCommand(pm);
2468
2430
  await exec3(initCommand);
2469
- const packageJsonPath = path3.join(process.cwd(), "package.json");
2431
+ const packageJsonPath = path.join(process.cwd(), "package.json");
2470
2432
  const packageJson = JSON.parse(await fs4.readFile(packageJsonPath, "utf-8"));
2471
2433
  packageJson.type = "module";
2472
2434
  packageJson.engines = {
@@ -2535,7 +2497,7 @@ var createMastraProject = async ({
2535
2497
  s2.start("Creating project");
2536
2498
  try {
2537
2499
  await fs4.mkdir(projectName);
2538
- projectPath = path3.resolve(originalCwd, projectName);
2500
+ projectPath = path.resolve(originalCwd, projectName);
2539
2501
  } catch (error) {
2540
2502
  if (error instanceof Error && "code" in error && error.code === "EEXIST") {
2541
2503
  s2.stop(`A directory named "${projectName}" already exists. Please choose a different name.`);
@@ -2566,7 +2528,7 @@ var createMastraProject = async ({
2566
2528
  s2.start(`Installing ${pm} dependencies`);
2567
2529
  try {
2568
2530
  await exec3(`${pm} ${installCommand} zod@^4`);
2569
- await exec3(`${pm} ${installCommand} -D typescript @types/node`);
2531
+ await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
2570
2532
  await exec3(`echo '{
2571
2533
  "compilerOptions": {
2572
2534
  "target": "ES2022",
@@ -2642,48 +2604,39 @@ var createMastraProject = async ({
2642
2604
  process.exit(1);
2643
2605
  }
2644
2606
  };
2645
- var version$1 = package_default.version;
2646
- var create = async (args) => {
2647
- if (args.template !== void 0) {
2648
- await createFromTemplate({
2649
- projectName: args.projectName,
2650
- template: args.template,
2651
- timeout: args.timeout,
2652
- injectedAnalytics: args.analytics,
2653
- llmProvider: args.llmProvider
2654
- });
2607
+ var create = async (args2) => {
2608
+ if (args2.template !== void 0) {
2609
+ await createFromTemplate({ ...args2, injectedAnalytics: args2.analytics });
2655
2610
  return;
2656
2611
  }
2657
- const needsInteractive = args.components === void 0 || args.llmProvider === void 0 || args.addExample === void 0;
2612
+ const needsInteractive = args2.components === void 0 || args2.llmProvider === void 0 || args2.addExample === void 0;
2658
2613
  const { projectName, result } = await createMastraProject({
2659
- projectName: args?.projectName,
2660
- createVersionTag: args?.createVersionTag,
2661
- timeout: args?.timeout,
2662
- llmProvider: args?.llmProvider,
2663
- llmApiKey: args?.llmApiKey,
2614
+ projectName: args2?.projectName,
2615
+ createVersionTag: args2?.createVersionTag,
2616
+ timeout: args2?.timeout,
2617
+ llmProvider: args2?.llmProvider,
2618
+ llmApiKey: args2?.llmApiKey,
2664
2619
  needsInteractive
2665
2620
  });
2666
- const directory = args.directory || "src/";
2621
+ const directory = args2.directory || "src/";
2667
2622
  if (needsInteractive && result) {
2668
2623
  await init({
2669
2624
  ...result,
2670
2625
  llmApiKey: result?.llmApiKey,
2671
2626
  components: ["agents", "tools", "workflows", "scorers"],
2672
- addExample: true,
2673
- versionTag: args.createVersionTag
2627
+ addExample: true
2674
2628
  });
2675
2629
  postCreate({ projectName });
2676
2630
  return;
2677
2631
  }
2678
- const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args;
2632
+ const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args2;
2679
2633
  await init({
2680
2634
  directory,
2681
2635
  components,
2682
2636
  llmProvider,
2683
2637
  addExample,
2684
2638
  llmApiKey,
2685
- configureEditorWithDocsMCP: args.mcpServer,
2686
- versionTag: args.createVersionTag
2639
+ configureEditorWithDocsMCP: args2.mcpServer
2687
2640
  });
2688
2641
  postCreate({ projectName });
2689
2642
  };
@@ -2774,9 +2727,9 @@ async function createFromGitHubUrl(url) {
2774
2727
  workflows: []
2775
2728
  };
2776
2729
  }
2777
- async function createFromTemplate(args) {
2730
+ async function createFromTemplate(args2) {
2778
2731
  let selectedTemplate;
2779
- if (args.template === true) {
2732
+ if (args2.template === true) {
2780
2733
  const templates = await loadTemplates();
2781
2734
  const selected = await selectTemplate(templates);
2782
2735
  if (!selected) {
@@ -2784,11 +2737,11 @@ async function createFromTemplate(args) {
2784
2737
  return;
2785
2738
  }
2786
2739
  selectedTemplate = selected;
2787
- } else if (args.template && typeof args.template === "string") {
2788
- if (isGitHubUrl(args.template)) {
2740
+ } else if (args2.template && typeof args2.template === "string") {
2741
+ if (isGitHubUrl(args2.template)) {
2789
2742
  const spinner4 = Y();
2790
2743
  spinner4.start("Validating GitHub repository...");
2791
- const validation = await validateGitHubProject(args.template);
2744
+ const validation = await validateGitHubProject(args2.template);
2792
2745
  if (!validation.isValid) {
2793
2746
  spinner4.stop("Validation failed");
2794
2747
  M.error("This does not appear to be a valid Mastra project:");
@@ -2796,14 +2749,14 @@ async function createFromTemplate(args) {
2796
2749
  throw new Error("Invalid Mastra project");
2797
2750
  }
2798
2751
  spinner4.stop("Valid Mastra project \u2713");
2799
- selectedTemplate = await createFromGitHubUrl(args.template);
2752
+ selectedTemplate = await createFromGitHubUrl(args2.template);
2800
2753
  } else {
2801
2754
  const templates = await loadTemplates();
2802
- const found = findTemplateByName(templates, args.template);
2755
+ const found = findTemplateByName(templates, args2.template);
2803
2756
  if (!found) {
2804
- M.error(`Template "${args.template}" not found. Available templates:`);
2757
+ M.error(`Template "${args2.template}" not found. Available templates:`);
2805
2758
  templates.forEach((t) => M.info(` - ${t.title} (use: ${t.slug.replace("template-", "")})`));
2806
- throw new Error(`Template "${args.template}" not found`);
2759
+ throw new Error(`Template "${args2.template}" not found`);
2807
2760
  }
2808
2761
  selectedTemplate = found;
2809
2762
  }
@@ -2811,7 +2764,7 @@ async function createFromTemplate(args) {
2811
2764
  if (!selectedTemplate) {
2812
2765
  throw new Error("No template selected");
2813
2766
  }
2814
- let projectName = args.projectName;
2767
+ let projectName = args2.projectName;
2815
2768
  if (!projectName) {
2816
2769
  const defaultName = getDefaultProjectName(selectedTemplate);
2817
2770
  const response = await he({
@@ -2825,41 +2778,18 @@ async function createFromTemplate(args) {
2825
2778
  }
2826
2779
  projectName = response;
2827
2780
  }
2828
- let llmProvider = args.llmProvider;
2829
- if (!llmProvider) {
2830
- const providerResponse = await ve({
2831
- message: "Select a default provider:",
2832
- options: LLM_PROVIDERS
2833
- });
2834
- if (pD(providerResponse)) {
2835
- M.info("Project creation cancelled.");
2836
- return;
2837
- }
2838
- llmProvider = providerResponse;
2839
- }
2840
2781
  let projectPath = null;
2841
2782
  try {
2842
- const analytics = args.injectedAnalytics || getAnalytics();
2783
+ const analytics = args2.injectedAnalytics || getAnalytics();
2843
2784
  if (analytics) {
2844
2785
  analytics.trackEvent("cli_template_used", {
2845
2786
  template_slug: selectedTemplate.slug,
2846
2787
  template_title: selectedTemplate.title
2847
2788
  });
2848
- if (llmProvider) {
2849
- analytics.trackEvent("cli_model_provider_selected", {
2850
- provider: llmProvider,
2851
- selection_method: args.llmProvider ? "cli_args" : "interactive"
2852
- });
2853
- }
2854
2789
  }
2855
- const isBeta = version$1?.includes("beta") ?? false;
2856
- const isMastraTemplate = selectedTemplate.githubUrl.includes("github.com/mastra-ai/");
2857
- const branch = isBeta && isMastraTemplate ? "beta" : void 0;
2858
2790
  projectPath = await cloneTemplate({
2859
2791
  template: selectedTemplate,
2860
- projectName,
2861
- branch,
2862
- llmProvider
2792
+ projectName
2863
2793
  });
2864
2794
  await installDependencies(projectPath);
2865
2795
  Me(`
@@ -2889,7 +2819,7 @@ async function createFromTemplate(args) {
2889
2819
  async function getPackageVersion() {
2890
2820
  const __filename = fileURLToPath(import.meta.url);
2891
2821
  const __dirname = dirname(__filename);
2892
- const pkgJsonPath = path3.join(__dirname, "..", "package.json");
2822
+ const pkgJsonPath = path.join(__dirname, "..", "package.json");
2893
2823
  const content = await fsExtra$1.readJSON(pkgJsonPath);
2894
2824
  return content.version;
2895
2825
  }