create-mastra 0.15.1 → 0.15.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # create-mastra
2
2
 
3
+ ## 0.15.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Use model-router in create-mastra starter template ([#8631](https://github.com/mastra-ai/mastra/pull/8631))
8
+
9
+ - Adds reset button to model picker to reset to original model set on the agent. ([#8633](https://github.com/mastra-ai/mastra/pull/8633))
10
+
11
+ - Refactor EntryList component and Scorer and Observability pages ([#8652](https://github.com/mastra-ai/mastra/pull/8652))
12
+
3
13
  ## 0.15.1
4
14
 
5
15
  ### Patch Changes
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
  }
@@ -1665,56 +1670,23 @@ var FileService = class {
1665
1670
  }
1666
1671
  };
1667
1672
  var exec2 = util.promisify(child_process.exec);
1668
- var getAISDKPackageVersion = (llmProvider) => {
1669
- switch (llmProvider) {
1670
- default:
1671
- return "latest";
1672
- }
1673
- };
1674
- var getAISDKPackage = (llmProvider) => {
1675
- switch (llmProvider) {
1676
- case "openai":
1677
- return "@ai-sdk/openai";
1678
- case "anthropic":
1679
- return "@ai-sdk/anthropic";
1680
- case "groq":
1681
- return "@ai-sdk/groq";
1682
- case "google":
1683
- return "@ai-sdk/google";
1684
- case "cerebras":
1685
- return "@ai-sdk/cerebras";
1686
- case "mistral":
1687
- return "@ai-sdk/mistral";
1688
- default:
1689
- return "@ai-sdk/openai";
1690
- }
1691
- };
1692
- var getProviderImportAndModelItem = (llmProvider) => {
1693
- let providerImport = "";
1694
- let modelItem = "";
1673
+ var getModelIdentifier = (llmProvider) => {
1695
1674
  if (llmProvider === "openai") {
1696
- providerImport = `import { openai } from '${getAISDKPackage(llmProvider)}';`;
1697
- modelItem = `openai('gpt-4o-mini')`;
1675
+ return `'openai/gpt-4o-mini'`;
1698
1676
  } else if (llmProvider === "anthropic") {
1699
- providerImport = `import { anthropic } from '${getAISDKPackage(llmProvider)}';`;
1700
- modelItem = `anthropic('claude-3-5-sonnet-20241022')`;
1677
+ return `'anthropic/claude-3-5-sonnet-20241022'`;
1701
1678
  } else if (llmProvider === "groq") {
1702
- providerImport = `import { groq } from '${getAISDKPackage(llmProvider)}';`;
1703
- modelItem = `groq('llama-3.3-70b-versatile')`;
1679
+ return `'groq/llama-3.3-70b-versatile'`;
1704
1680
  } else if (llmProvider === "google") {
1705
- providerImport = `import { google } from '${getAISDKPackage(llmProvider)}';`;
1706
- modelItem = `google('gemini-2.5-pro')`;
1681
+ return `'google/gemini-2.5-pro'`;
1707
1682
  } else if (llmProvider === "cerebras") {
1708
- providerImport = `import { cerebras } from '${getAISDKPackage(llmProvider)}';`;
1709
- modelItem = `cerebras('llama-3.3-70b')`;
1683
+ return `'cerebras/llama-3.3-70b'`;
1710
1684
  } else if (llmProvider === "mistral") {
1711
- providerImport = `import { mistral } from '${getAISDKPackage(llmProvider)}';`;
1712
- modelItem = `mistral('mistral-medium-2508')`;
1685
+ return `'mistral/mistral-medium-2508'`;
1713
1686
  }
1714
- return { providerImport, modelItem };
1715
1687
  };
1716
1688
  async function writeAgentSample(llmProvider, destPath, addExampleTool) {
1717
- const { providerImport, modelItem } = getProviderImportAndModelItem(llmProvider);
1689
+ const modelString = getModelIdentifier(llmProvider);
1718
1690
  const instructions = `
1719
1691
  You are a helpful weather assistant that provides accurate weather information and can help planning activities based on the weather.
1720
1692
 
@@ -1730,7 +1702,6 @@ async function writeAgentSample(llmProvider, destPath, addExampleTool) {
1730
1702
  ${addExampleTool ? "Use the weatherTool to fetch current weather data." : ""}
1731
1703
  `;
1732
1704
  const content = `
1733
- ${providerImport}
1734
1705
  import { Agent } from '@mastra/core/agent';
1735
1706
  import { Memory } from '@mastra/memory';
1736
1707
  import { LibSQLStore } from '@mastra/libsql';
@@ -1739,7 +1710,7 @@ ${addExampleTool ? `import { weatherTool } from '../tools/weather-tool';` : ""}
1739
1710
  export const weatherAgent = new Agent({
1740
1711
  name: 'Weather Agent',
1741
1712
  instructions: \`${instructions}\`,
1742
- model: ${modelItem},
1713
+ model: ${modelString},
1743
1714
  ${addExampleTool ? "tools: { weatherTool }," : ""}
1744
1715
  memory: new Memory({
1745
1716
  storage: new LibSQLStore({
@@ -2208,7 +2179,6 @@ This means the Mastra docs MCP server will be available in all your Windsurf pro
2208
2179
  return mastraProject;
2209
2180
  };
2210
2181
  var s = Y();
2211
- var exec3 = util.promisify(child_process.exec);
2212
2182
  var init = async ({
2213
2183
  directory,
2214
2184
  addExample = false,
@@ -2256,12 +2226,6 @@ var init = async ({
2256
2226
  }
2257
2227
  }
2258
2228
  const key = await getAPIKey(llmProvider || "openai");
2259
- const aiSdkPackage = getAISDKPackage(llmProvider);
2260
- const aiSdkPackageVersion = getAISDKPackageVersion(llmProvider);
2261
- const depsService = new DepsService();
2262
- const pm = depsService.packageManager;
2263
- const installCommand = getPackageManagerAddCommand(pm);
2264
- await exec3(`${pm} ${installCommand} ${aiSdkPackage}@${aiSdkPackageVersion}`);
2265
2229
  if (configureEditorWithDocsMCP) {
2266
2230
  await installMastraDocsMCPServer({
2267
2231
  editor: configureEditorWithDocsMCP,
@@ -2288,10 +2252,10 @@ var init = async ({
2288
2252
  return { success: false };
2289
2253
  }
2290
2254
  };
2291
- var exec4 = util.promisify(child_process.exec);
2255
+ var exec3 = util.promisify(child_process.exec);
2292
2256
  var execWithTimeout = async (command, timeoutMs) => {
2293
2257
  try {
2294
- const promise = exec4(command, { killSignal: "SIGTERM" });
2258
+ const promise = exec3(command, { killSignal: "SIGTERM" });
2295
2259
  if (!timeoutMs) {
2296
2260
  return await promise;
2297
2261
  }
@@ -2386,9 +2350,9 @@ var createMastraProject = async ({
2386
2350
  const installCommand = getPackageManagerAddCommand(pm);
2387
2351
  s2.message("Initializing project structure");
2388
2352
  try {
2389
- await exec4(`npm init -y`);
2390
- await exec4(`npm pkg set type="module"`);
2391
- await exec4(`npm pkg set engines.node=">=20.9.0"`);
2353
+ await exec3(`npm init -y`);
2354
+ await exec3(`npm pkg set type="module"`);
2355
+ await exec3(`npm pkg set engines.node=">=20.9.0"`);
2392
2356
  const depsService = new DepsService();
2393
2357
  await depsService.addScriptsToPackageJson({
2394
2358
  dev: "mastra dev",
@@ -2403,9 +2367,9 @@ var createMastraProject = async ({
2403
2367
  s2.stop("Project structure created");
2404
2368
  s2.start(`Installing ${pm} dependencies`);
2405
2369
  try {
2406
- await exec4(`${pm} ${installCommand} zod@^3`);
2407
- await exec4(`${pm} ${installCommand} typescript @types/node --save-dev`);
2408
- await exec4(`echo '{
2370
+ await exec3(`${pm} ${installCommand} zod@^3`);
2371
+ await exec3(`${pm} ${installCommand} typescript @types/node --save-dev`);
2372
+ await exec3(`echo '{
2409
2373
  "compilerOptions": {
2410
2374
  "target": "ES2022",
2411
2375
  "module": "ES2022",
@@ -2448,14 +2412,14 @@ var createMastraProject = async ({
2448
2412
  s2.stop("Mastra dependencies installed");
2449
2413
  s2.start("Adding .gitignore");
2450
2414
  try {
2451
- await exec4(`echo output.txt >> .gitignore`);
2452
- await exec4(`echo node_modules >> .gitignore`);
2453
- await exec4(`echo dist >> .gitignore`);
2454
- await exec4(`echo .mastra >> .gitignore`);
2455
- await exec4(`echo .env.development >> .gitignore`);
2456
- await exec4(`echo .env >> .gitignore`);
2457
- await exec4(`echo *.db >> .gitignore`);
2458
- await exec4(`echo *.db-* >> .gitignore`);
2415
+ await exec3(`echo output.txt >> .gitignore`);
2416
+ await exec3(`echo node_modules >> .gitignore`);
2417
+ await exec3(`echo dist >> .gitignore`);
2418
+ await exec3(`echo .mastra >> .gitignore`);
2419
+ await exec3(`echo .env.development >> .gitignore`);
2420
+ await exec3(`echo .env >> .gitignore`);
2421
+ await exec3(`echo *.db >> .gitignore`);
2422
+ await exec3(`echo *.db-* >> .gitignore`);
2459
2423
  } catch (error) {
2460
2424
  throw new Error(`Failed to create .gitignore: ${error instanceof Error ? error.message : "Unknown error"}`);
2461
2425
  }