create-mastra 0.0.0-bump-snapshot-attempt-20251015082400 → 0.0.0-bundle-recursion-20251030002519

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/CHANGELOG.md CHANGED
@@ -1,6 +1,56 @@
1
1
  # create-mastra
2
2
 
3
- ## 0.0.0-bump-snapshot-attempt-20251015082400
3
+ ## 0.0.0-bundle-recursion-20251030002519
4
+
5
+ ### Major Changes
6
+
7
+ - Removed old tracing code based on OpenTelemetry ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
8
+
9
+ ### Patch Changes
10
+
11
+ - Update MainSidebar component to fit required changes in Cloud CTA link ([#9318](https://github.com/mastra-ai/mastra/pull/9318))
12
+
13
+ ## 0.17.3
14
+
15
+ ## 0.17.3-alpha.0
16
+
17
+ ## 0.17.2
18
+
19
+ ## 0.17.2-alpha.0
20
+
21
+ ## 0.17.1
22
+
23
+ ### Patch Changes
24
+
25
+ - Add scorers to the default weather agent in the create command. ([#9042](https://github.com/mastra-ai/mastra/pull/9042))
26
+
27
+ - Fix tool result in playground ([#9087](https://github.com/mastra-ai/mastra/pull/9087))
28
+
29
+ ## 0.17.1-alpha.1
30
+
31
+ ### Patch Changes
32
+
33
+ - Add scorers to the default weather agent in the create command. ([#9042](https://github.com/mastra-ai/mastra/pull/9042))
34
+
35
+ - Fix tool result in playground ([#9087](https://github.com/mastra-ai/mastra/pull/9087))
36
+
37
+ ## 0.17.1-alpha.0
38
+
39
+ ## 0.17.0
40
+
41
+ ### Patch Changes
42
+
43
+ - Pin `@rollup/*` dependencies to fixed versions (instead of using `^`) to: ([#8900](https://github.com/mastra-ai/mastra/pull/8900))
44
+ - Hotfix a bug inside `@rollup/plugin-commonjs`
45
+ - Have more control over the versions in the future to not have breakages over night
46
+
47
+ ## 0.17.0-alpha.0
48
+
49
+ ### Patch Changes
50
+
51
+ - Pin `@rollup/*` dependencies to fixed versions (instead of using `^`) to: ([#8900](https://github.com/mastra-ai/mastra/pull/8900))
52
+ - Hotfix a bug inside `@rollup/plugin-commonjs`
53
+ - Have more control over the versions in the future to not have breakages over night
4
54
 
5
55
  ## 0.16.0
6
56
 
package/dist/index.js CHANGED
@@ -724,13 +724,18 @@ const format = (open, close) => {
724
724
  // Handle nested colors.
725
725
 
726
726
  // We could have done this, but it's too slow (as of Node.js 22).
727
- // return openCode + string.replaceAll(closeCode, openCode) + closeCode;
727
+ // return openCode + string.replaceAll(closeCode, (close === 22 ? closeCode : '') + openCode) + closeCode;
728
728
 
729
729
  let result = openCode;
730
730
  let lastIndex = 0;
731
731
 
732
+ // SGR 22 resets both bold (1) and dim (2). When we encounter a nested
733
+ // close for styles that use 22, we need to re-open the outer style.
734
+ const reopenOnNestedClose = close === 22;
735
+ const replaceCode = (reopenOnNestedClose ? closeCode : '') + openCode;
736
+
732
737
  while (index !== -1) {
733
- result += string.slice(lastIndex, index) + openCode;
738
+ result += string.slice(lastIndex, index) + replaceCode;
734
739
  lastIndex = index + closeCode.length;
735
740
  index = string.indexOf(closeCode, lastIndex);
736
741
  }
@@ -1492,7 +1497,7 @@ var getModelIdentifier = (llmProvider) => {
1492
1497
  if (llmProvider === "openai") {
1493
1498
  return `'openai/gpt-4o-mini'`;
1494
1499
  } else if (llmProvider === "anthropic") {
1495
- return `'anthropic/claude-3-5-sonnet-20241022'`;
1500
+ return `'anthropic/claude-sonnet-4-5-20250929'`;
1496
1501
  } else if (llmProvider === "groq") {
1497
1502
  return `'groq/llama-3.3-70b-versatile'`;
1498
1503
  } else if (llmProvider === "google") {
@@ -1503,7 +1508,7 @@ var getModelIdentifier = (llmProvider) => {
1503
1508
  return `'mistral/mistral-medium-2508'`;
1504
1509
  }
1505
1510
  };
1506
- async function writeAgentSample(llmProvider, destPath, addExampleTool) {
1511
+ async function writeAgentSample(llmProvider, destPath, addExampleTool, addScorers) {
1507
1512
  const modelString = getModelIdentifier(llmProvider);
1508
1513
  const instructions = `
1509
1514
  You are a helpful weather assistant that provides accurate weather information and can help planning activities based on the weather.
@@ -1524,12 +1529,36 @@ import { Agent } from '@mastra/core/agent';
1524
1529
  import { Memory } from '@mastra/memory';
1525
1530
  import { LibSQLStore } from '@mastra/libsql';
1526
1531
  ${addExampleTool ? `import { weatherTool } from '../tools/weather-tool';` : ""}
1532
+ ${addScorers ? `import { scorers } from '../scorers/weather-scorer';` : ""}
1527
1533
 
1528
1534
  export const weatherAgent = new Agent({
1529
1535
  name: 'Weather Agent',
1530
1536
  instructions: \`${instructions}\`,
1531
1537
  model: ${modelString},
1532
1538
  ${addExampleTool ? "tools: { weatherTool }," : ""}
1539
+ ${addScorers ? `scorers: {
1540
+ toolCallAppropriateness: {
1541
+ scorer: scorers.toolCallAppropriatenessScorer,
1542
+ sampling: {
1543
+ type: 'ratio',
1544
+ rate: 1,
1545
+ },
1546
+ },
1547
+ completeness: {
1548
+ scorer: scorers.completenessScorer,
1549
+ sampling: {
1550
+ type: 'ratio',
1551
+ rate: 1,
1552
+ },
1553
+ },
1554
+ translation: {
1555
+ scorer: scorers.translationScorer,
1556
+ sampling: {
1557
+ type: 'ratio',
1558
+ rate: 1,
1559
+ },
1560
+ },
1561
+ },` : ""}
1533
1562
  memory: new Memory({
1534
1563
  storage: new LibSQLStore({
1535
1564
  url: "file:../mastra.db", // path is relative to the .mastra/output directory
@@ -1741,14 +1770,107 @@ async function writeToolSample(destPath) {
1741
1770
  const fileService = new FileService();
1742
1771
  await fileService.copyStarterFile("tools.ts", destPath);
1743
1772
  }
1773
+ async function writeScorersSample(llmProvider, destPath) {
1774
+ const modelString = getModelIdentifier(llmProvider);
1775
+ const content = `import { z } from 'zod';
1776
+ import { createToolCallAccuracyScorerCode } from '@mastra/evals/scorers/code';
1777
+ import { createCompletenessScorer } from '@mastra/evals/scorers/code';
1778
+ import { createScorer } from '@mastra/core/scores';
1779
+
1780
+ export const toolCallAppropriatenessScorer = createToolCallAccuracyScorerCode({
1781
+ expectedTool: 'weatherTool',
1782
+ strictMode: false,
1783
+ });
1784
+
1785
+ export const completenessScorer = createCompletenessScorer();
1786
+
1787
+ // Custom LLM-judged scorer: evaluates if non-English locations are translated appropriately
1788
+ export const translationScorer = createScorer({
1789
+ name: 'Translation Quality',
1790
+ description: 'Checks that non-English location names are translated and used correctly',
1791
+ type: 'agent',
1792
+ judge: {
1793
+ model: ${modelString},
1794
+ instructions:
1795
+ 'You are an expert evaluator of translation quality for geographic locations. ' +
1796
+ 'Determine whether the user text mentions a non-English location and whether the assistant correctly uses an English translation of that location. ' +
1797
+ 'Be lenient with transliteration differences and diacritics. ' +
1798
+ 'Return only the structured JSON matching the provided schema.',
1799
+ },
1800
+ })
1801
+ .preprocess(({ run }) => {
1802
+ const userText = (run.input?.inputMessages?.[0]?.content as string) || '';
1803
+ const assistantText = (run.output?.[0]?.content as string) || '';
1804
+ return { userText, assistantText };
1805
+ })
1806
+ .analyze({
1807
+ description: 'Extract location names and detect language/translation adequacy',
1808
+ outputSchema: z.object({
1809
+ nonEnglish: z.boolean(),
1810
+ translated: z.boolean(),
1811
+ confidence: z.number().min(0).max(1).default(1),
1812
+ explanation: z.string().default(''),
1813
+ }),
1814
+ createPrompt: ({ results }) => \`
1815
+ You are evaluating if a weather assistant correctly handled translation of a non-English location.
1816
+ User text:
1817
+ """
1818
+ \${results.preprocessStepResult.userText}
1819
+ """
1820
+ Assistant response:
1821
+ """
1822
+ \${results.preprocessStepResult.assistantText}
1823
+ """
1824
+ Tasks:
1825
+ 1) Identify if the user mentioned a location that appears non-English.
1826
+ 2) If non-English, check whether the assistant used a correct English translation of that location in its response.
1827
+ 3) Be lenient with transliteration differences (e.g., accents/diacritics).
1828
+ Return JSON with fields:
1829
+ {
1830
+ "nonEnglish": boolean,
1831
+ "translated": boolean,
1832
+ "confidence": number, // 0-1
1833
+ "explanation": string
1834
+ }
1835
+ \`,
1836
+ })
1837
+ .generateScore(({ results }) => {
1838
+ const r = (results as any)?.analyzeStepResult || {};
1839
+ if (!r.nonEnglish) return 1; // If not applicable, full credit
1840
+ if (r.translated) return Math.max(0, Math.min(1, 0.7 + 0.3 * (r.confidence ?? 1)));
1841
+ return 0; // Non-English but not translated
1842
+ })
1843
+ .generateReason(({ results, score }) => {
1844
+ const r = (results as any)?.analyzeStepResult || {};
1845
+ return \`Translation scoring: nonEnglish=\${r.nonEnglish ?? false}, translated=\${r.translated ?? false}, confidence=\${r.confidence ?? 0}. Score=\${score}. \${r.explanation ?? ''}\`;
1846
+ });
1847
+
1848
+ export const scorers = {
1849
+ toolCallAppropriatenessScorer,
1850
+ completenessScorer,
1851
+ translationScorer,
1852
+ };`;
1853
+ const formattedContent = await prettier.format(content, {
1854
+ parser: "typescript",
1855
+ singleQuote: true
1856
+ });
1857
+ await fs4.writeFile(destPath, formattedContent);
1858
+ }
1744
1859
  async function writeCodeSampleForComponents(llmprovider, component, destPath, importComponents) {
1745
1860
  switch (component) {
1746
1861
  case "agents":
1747
- return writeAgentSample(llmprovider, destPath, importComponents.includes("tools"));
1862
+ return writeAgentSample(
1863
+ llmprovider,
1864
+ destPath,
1865
+ importComponents.includes("tools"),
1866
+ importComponents.includes("scorers")
1867
+ );
1748
1868
  case "tools":
1749
1869
  return writeToolSample(destPath);
1750
1870
  case "workflows":
1751
1871
  return writeWorkflowSample(destPath);
1872
+ case "scorers":
1873
+ return writeScorersSample(llmprovider, destPath);
1752
1874
  default:
1753
1875
  return "";
1754
1876
  }
@@ -1761,7 +1883,8 @@ var writeIndexFile = async ({
1761
1883
  dirPath,
1762
1884
  addAgent,
1763
1885
  addExample,
1764
- addWorkflow
1886
+ addWorkflow,
1887
+ addScorers
1765
1888
  }) => {
1766
1889
  const indexPath = dirPath + "/index.ts";
1767
1890
  const destPath = path.join(indexPath);
@@ -1769,7 +1892,8 @@ var writeIndexFile = async ({
1769
1892
  await fs4.writeFile(destPath, "");
1770
1893
  const filteredExports = [
1771
1894
  addWorkflow ? `workflows: { weatherWorkflow },` : "",
1772
- addAgent ? `agents: { weatherAgent },` : ""
1895
+ addAgent ? `agents: { weatherAgent },` : "",
1896
+ addScorers ? `scorers: { toolCallAppropriatenessScorer, completenessScorer, translationScorer },` : ""
1773
1897
  ].filter(Boolean);
1774
1898
  if (!addExample) {
1775
1899
  await fs4.writeFile(
@@ -1790,6 +1914,7 @@ import { PinoLogger } from '@mastra/loggers';
1790
1914
  import { LibSQLStore } from '@mastra/libsql';
1791
1915
  ${addWorkflow ? `import { weatherWorkflow } from './workflows/weather-workflow';` : ""}
1792
1916
  ${addAgent ? `import { weatherAgent } from './agents/weather-agent';` : ""}
1917
+ ${addScorers ? `import { toolCallAppropriatenessScorer, completenessScorer, translationScorer } from './scorers/weather-scorer';` : ""}
1793
1918
 
1794
1919
  export const mastra = new Mastra({
1795
1920
  ${filteredExports.join("\n ")}
@@ -1801,13 +1926,9 @@ export const mastra = new Mastra({
1801
1926
  name: 'Mastra',
1802
1927
  level: 'info',
1803
1928
  }),
1804
- telemetry: {
1805
- // Telemetry is deprecated and will be removed in the Nov 4th release
1806
- enabled: false,
1807
- },
1808
1929
  observability: {
1809
1930
  // Enables DefaultExporter and CloudExporter for AI tracing
1810
- default: { enabled: true },
1931
+ default: { enabled: true },
1811
1932
  },
1812
1933
  });
1813
1934
  `
@@ -1816,7 +1937,6 @@ export const mastra = new Mastra({
1816
1937
  throw err;
1817
1938
  }
1818
1939
  };
1819
- yoctoSpinner({ text: "Installing Mastra core dependencies\n" });
1820
1940
  var getAPIKey = async (provider) => {
1821
1941
  let key = "OPENAI_API_KEY";
1822
1942
  switch (provider) {
@@ -1960,19 +2080,19 @@ Note: you will need to go into Cursor Settings -> MCP Settings and manually enab
1960
2080
  );
1961
2081
  }
1962
2082
  if (editor === `cursor-global`) {
1963
- const confirm2 = await ve({
2083
+ const confirm = await ve({
1964
2084
  message: `Global install will add/update ${cursorGlobalMCPConfigPath} and make the Mastra docs MCP server available in all your Cursor projects. Continue?`,
1965
2085
  options: [
1966
2086
  { value: "yes", label: "Yes, I understand" },
1967
2087
  { value: "skip", label: "No, skip for now" }
1968
2088
  ]
1969
2089
  });
1970
- if (confirm2 !== `yes`) {
2090
+ if (confirm !== `yes`) {
1971
2091
  return void 0;
1972
2092
  }
1973
2093
  }
1974
2094
  if (editor === `windsurf`) {
1975
- const confirm2 = await ve({
2095
+ const confirm = await ve({
1976
2096
  message: `Windsurf only supports a global MCP config (at ${windsurfGlobalMCPConfigPath}) is it ok to add/update that global config?
1977
2097
  This means the Mastra docs MCP server will be available in all your Windsurf projects.`,
1978
2098
  options: [
@@ -1980,7 +2100,7 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
1980
2100
  { value: "skip", label: "No, skip for now" }
1981
2101
  ]
1982
2102
  });
1983
- if (confirm2 !== `yes`) {
2103
+ if (confirm !== `yes`) {
1984
2104
  return void 0;
1985
2105
  }
1986
2106
  }
@@ -2030,10 +2150,10 @@ var exec2 = util.promisify(child_process.exec);
2030
2150
  async function cloneTemplate(options) {
2031
2151
  const { template, projectName, targetDir } = options;
2032
2152
  const projectPath = targetDir ? path.resolve(targetDir, projectName) : path.resolve(projectName);
2033
- const spinner5 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
2153
+ const spinner4 = yoctoSpinner({ text: `Cloning template "${template.title}"...` }).start();
2034
2154
  try {
2035
2155
  if (await directoryExists(projectPath)) {
2036
- spinner5.error(`Directory ${projectName} already exists`);
2156
+ spinner4.error(`Directory ${projectName} already exists`);
2037
2157
  throw new Error(`Directory ${projectName} already exists`);
2038
2158
  }
2039
2159
  await cloneRepositoryWithoutGit(template.githubUrl, projectPath);
@@ -2042,10 +2162,10 @@ async function cloneTemplate(options) {
2042
2162
  if (await fileExists(envExamplePath)) {
2043
2163
  await fs4.copyFile(envExamplePath, path.join(projectPath, ".env"));
2044
2164
  }
2045
- spinner5.success(`Template "${template.title}" cloned successfully to ${projectName}`);
2165
+ spinner4.success(`Template "${template.title}" cloned successfully to ${projectName}`);
2046
2166
  return projectPath;
2047
2167
  } catch (error) {
2048
- spinner5.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
2168
+ spinner4.error(`Failed to clone template: ${error instanceof Error ? error.message : "Unknown error"}`);
2049
2169
  throw error;
2050
2170
  }
2051
2171
  }
@@ -2100,16 +2220,16 @@ async function updatePackageJson(projectPath, projectName) {
2100
2220
  }
2101
2221
  }
2102
2222
  async function installDependencies(projectPath, packageManager) {
2103
- const spinner5 = yoctoSpinner({ text: "Installing dependencies..." }).start();
2223
+ const spinner4 = yoctoSpinner({ text: "Installing dependencies..." }).start();
2104
2224
  try {
2105
2225
  const pm = packageManager || getPackageManager();
2106
2226
  const installCommand = shellQuote2.quote([pm, "install"]);
2107
2227
  await exec2(installCommand, {
2108
2228
  cwd: projectPath
2109
2229
  });
2110
- spinner5.success("Dependencies installed successfully");
2230
+ spinner4.success("Dependencies installed successfully");
2111
2231
  } catch (error) {
2112
- spinner5.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
2232
+ spinner4.error(`Failed to install dependencies: ${error instanceof Error ? error.message : "Unknown error"}`);
2113
2233
  throw error;
2114
2234
  }
2115
2235
  }
@@ -2198,7 +2318,8 @@ var init = async ({
2198
2318
  dirPath,
2199
2319
  addExample,
2200
2320
  addWorkflow: components.includes("workflows"),
2201
- addAgent: components.includes("agents")
2321
+ addAgent: components.includes("agents"),
2322
+ addScorers: components.includes("scorers")
2202
2323
  }),
2203
2324
  ...components.map((component) => createComponentsDir(dirPath, component)),
2204
2325
  writeAPIKey({ provider: llmProvider, apiKey: llmApiKey })
@@ -2222,6 +2343,14 @@ var init = async ({
2222
2343
  if (needsLoggers) {
2223
2344
  await depService.installPackages(["@mastra/loggers"]);
2224
2345
  }
2346
+ const needsObservability = await depService.checkDependencies(["@mastra/observability"]) !== `ok`;
2347
+ if (needsObservability) {
2348
+ await depService.installPackages(["@mastra/observability"]);
2349
+ }
2350
+ const needsEvals = components.includes(`scorers`) && await depService.checkDependencies(["@mastra/evals"]) !== `ok`;
2351
+ if (needsEvals) {
2352
+ await depService.installPackages(["@mastra/evals"]);
2353
+ }
2225
2354
  }
2226
2355
  const key = await getAPIKey(llmProvider || "openai");
2227
2356
  if (configureEditorWithDocsMCP) {
@@ -2451,7 +2580,7 @@ var create = async (args2) => {
2451
2580
  await init({
2452
2581
  ...result,
2453
2582
  llmApiKey: result?.llmApiKey,
2454
- components: ["agents", "tools", "workflows"],
2583
+ components: ["agents", "tools", "workflows", "scorers"],
2455
2584
  addExample: true
2456
2585
  });
2457
2586
  postCreate({ projectName });
@@ -2567,16 +2696,16 @@ async function createFromTemplate(args2) {
2567
2696
  selectedTemplate = selected;
2568
2697
  } else if (args2.template && typeof args2.template === "string") {
2569
2698
  if (isGitHubUrl(args2.template)) {
2570
- const spinner5 = Y();
2571
- spinner5.start("Validating GitHub repository...");
2699
+ const spinner4 = Y();
2700
+ spinner4.start("Validating GitHub repository...");
2572
2701
  const validation = await validateGitHubProject(args2.template);
2573
2702
  if (!validation.isValid) {
2574
- spinner5.stop("Validation failed");
2703
+ spinner4.stop("Validation failed");
2575
2704
  M.error("This does not appear to be a valid Mastra project:");
2576
2705
  validation.errors.forEach((error) => M.error(` - ${error}`));
2577
2706
  throw new Error("Invalid Mastra project");
2578
2707
  }
2579
- spinner5.stop("Valid Mastra project \u2713");
2708
+ spinner4.stop("Valid Mastra project \u2713");
2580
2709
  selectedTemplate = await createFromGitHubUrl(args2.template);
2581
2710
  } else {
2582
2711
  const templates = await loadTemplates();
@@ -2673,7 +2802,7 @@ program.version(`${version}`, "-v, --version").description(`create-mastra ${vers
2673
2802
  program.name("create-mastra").description("Create a new Mastra project").argument("[project-name]", "Directory name of the project").option(
2674
2803
  "-p, --project-name <string>",
2675
2804
  "Project name that will be used in package.json and as the project directory name."
2676
- ).option("--default", "Quick start with defaults (src, OpenAI, 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("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)").option(
2805
+ ).option("--default", "Quick start with defaults (src, OpenAI, examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows, scorers)").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("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode)").option(
2677
2806
  "--template [template-name]",
2678
2807
  "Create project from a template (use template name, public GitHub URL, or leave blank to select from list)"
2679
2808
  ).action(async (projectNameArg, args) => {
@@ -2681,7 +2810,7 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
2681
2810
  const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
2682
2811
  if (args.default) {
2683
2812
  await create({
2684
- components: ["agents", "tools", "workflows"],
2813
+ components: ["agents", "tools", "workflows", "scorers"],
2685
2814
  llmProvider: "openai",
2686
2815
  addExample: true,
2687
2816
  createVersionTag,