create-mastra 0.0.0-tool-call-parts-20250630193309 → 0.0.0-tsconfig-compile-20250703214351
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 +52 -60
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1544,14 +1544,16 @@ var getProviderImportAndModelItem = (llmProvider) => {
|
|
|
1544
1544
|
async function writeAgentSample(llmProvider, destPath, addExampleTool) {
|
|
1545
1545
|
const { providerImport, modelItem } = getProviderImportAndModelItem(llmProvider);
|
|
1546
1546
|
const instructions = `
|
|
1547
|
-
You are a helpful weather assistant that provides accurate weather information.
|
|
1547
|
+
You are a helpful weather assistant that provides accurate weather information and can help planning activities based on the weather.
|
|
1548
1548
|
|
|
1549
1549
|
Your primary function is to help users get weather details for specific locations. When responding:
|
|
1550
1550
|
- Always ask for a location if none is provided
|
|
1551
|
-
- If the location name isn
|
|
1551
|
+
- If the location name isn't in English, please translate it
|
|
1552
1552
|
- If giving a location with multiple parts (e.g. "New York, NY"), use the most relevant part (e.g. "New York")
|
|
1553
1553
|
- Include relevant details like humidity, wind conditions, and precipitation
|
|
1554
1554
|
- Keep responses concise but informative
|
|
1555
|
+
- If the user asks for activities and provides the weather forecast, suggest activities based on the weather forecast.
|
|
1556
|
+
- If the user asks for activities, respond in the format they request.
|
|
1555
1557
|
|
|
1556
1558
|
${addExampleTool ? "Use the weatherTool to fetch current weather data." : ""}
|
|
1557
1559
|
`;
|
|
@@ -1581,63 +1583,10 @@ export const weatherAgent = new Agent({
|
|
|
1581
1583
|
await fs4.writeFile(destPath, "");
|
|
1582
1584
|
await fs4.writeFile(destPath, formattedContent);
|
|
1583
1585
|
}
|
|
1584
|
-
async function writeWorkflowSample(destPath
|
|
1585
|
-
const {
|
|
1586
|
-
const content = `${providerImport}
|
|
1587
|
-
import { Agent } from '@mastra/core/agent';
|
|
1588
|
-
import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
1586
|
+
async function writeWorkflowSample(destPath) {
|
|
1587
|
+
const content = `import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
1589
1588
|
import { z } from 'zod';
|
|
1590
1589
|
|
|
1591
|
-
const llm = ${modelItem};
|
|
1592
|
-
|
|
1593
|
-
const agent = new Agent({
|
|
1594
|
-
name: 'Weather Agent',
|
|
1595
|
-
model: llm,
|
|
1596
|
-
instructions: \`
|
|
1597
|
-
You are a local activities and travel expert who excels at weather-based planning. Analyze the weather data and provide practical activity recommendations.
|
|
1598
|
-
|
|
1599
|
-
For each day in the forecast, structure your response exactly as follows:
|
|
1600
|
-
|
|
1601
|
-
\u{1F4C5} [Day, Month Date, Year]
|
|
1602
|
-
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
1603
|
-
|
|
1604
|
-
\u{1F321}\uFE0F WEATHER SUMMARY
|
|
1605
|
-
\u2022 Conditions: [brief description]
|
|
1606
|
-
\u2022 Temperature: [X\xB0C/Y\xB0F to A\xB0C/B\xB0F]
|
|
1607
|
-
\u2022 Precipitation: [X% chance]
|
|
1608
|
-
|
|
1609
|
-
\u{1F305} MORNING ACTIVITIES
|
|
1610
|
-
Outdoor:
|
|
1611
|
-
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1612
|
-
Best timing: [specific time range]
|
|
1613
|
-
Note: [relevant weather consideration]
|
|
1614
|
-
|
|
1615
|
-
\u{1F31E} AFTERNOON ACTIVITIES
|
|
1616
|
-
Outdoor:
|
|
1617
|
-
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1618
|
-
Best timing: [specific time range]
|
|
1619
|
-
Note: [relevant weather consideration]
|
|
1620
|
-
|
|
1621
|
-
\u{1F3E0} INDOOR ALTERNATIVES
|
|
1622
|
-
\u2022 [Activity Name] - [Brief description including specific venue]
|
|
1623
|
-
Ideal for: [weather condition that would trigger this alternative]
|
|
1624
|
-
|
|
1625
|
-
\u26A0\uFE0F SPECIAL CONSIDERATIONS
|
|
1626
|
-
\u2022 [Any relevant weather warnings, UV index, wind conditions, etc.]
|
|
1627
|
-
|
|
1628
|
-
Guidelines:
|
|
1629
|
-
- Suggest 2-3 time-specific outdoor activities per day
|
|
1630
|
-
- Include 1-2 indoor backup options
|
|
1631
|
-
- For precipitation >50%, lead with indoor activities
|
|
1632
|
-
- All activities must be specific to the location
|
|
1633
|
-
- Include specific venues, trails, or locations
|
|
1634
|
-
- Consider activity intensity based on temperature
|
|
1635
|
-
- Keep descriptions concise but informative
|
|
1636
|
-
|
|
1637
|
-
Maintain this exact formatting for consistency, using the emoji and section headers as shown.
|
|
1638
|
-
\`,
|
|
1639
|
-
});
|
|
1640
|
-
|
|
1641
1590
|
const forecastSchema = z.object({
|
|
1642
1591
|
date: z.string(),
|
|
1643
1592
|
maxTemp: z.number(),
|
|
@@ -1731,16 +1680,59 @@ const planActivities = createStep({
|
|
|
1731
1680
|
outputSchema: z.object({
|
|
1732
1681
|
activities: z.string(),
|
|
1733
1682
|
}),
|
|
1734
|
-
execute: async ({ inputData }) => {
|
|
1683
|
+
execute: async ({ inputData, mastra }) => {
|
|
1735
1684
|
const forecast = inputData
|
|
1736
1685
|
|
|
1737
1686
|
if (!forecast) {
|
|
1738
1687
|
throw new Error('Forecast data not found')
|
|
1739
1688
|
}
|
|
1740
1689
|
|
|
1690
|
+
const agent = mastra?.getAgent('weatherAgent');
|
|
1691
|
+
if (!agent) {
|
|
1692
|
+
throw new Error('Weather agent not found');
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1741
1695
|
const prompt = \`Based on the following weather forecast for \${forecast.location}, suggest appropriate activities:
|
|
1742
1696
|
\${JSON.stringify(forecast, null, 2)}
|
|
1743
|
-
|
|
1697
|
+
For each day in the forecast, structure your response exactly as follows:
|
|
1698
|
+
|
|
1699
|
+
\u{1F4C5} [Day, Month Date, Year]
|
|
1700
|
+
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
1701
|
+
|
|
1702
|
+
\u{1F321}\uFE0F WEATHER SUMMARY
|
|
1703
|
+
\u2022 Conditions: [brief description]
|
|
1704
|
+
\u2022 Temperature: [X\xB0C/Y\xB0F to A\xB0C/B\xB0F]
|
|
1705
|
+
\u2022 Precipitation: [X% chance]
|
|
1706
|
+
|
|
1707
|
+
\u{1F305} MORNING ACTIVITIES
|
|
1708
|
+
Outdoor:
|
|
1709
|
+
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1710
|
+
Best timing: [specific time range]
|
|
1711
|
+
Note: [relevant weather consideration]
|
|
1712
|
+
|
|
1713
|
+
\u{1F31E} AFTERNOON ACTIVITIES
|
|
1714
|
+
Outdoor:
|
|
1715
|
+
\u2022 [Activity Name] - [Brief description including specific location/route]
|
|
1716
|
+
Best timing: [specific time range]
|
|
1717
|
+
Note: [relevant weather consideration]
|
|
1718
|
+
|
|
1719
|
+
\u{1F3E0} INDOOR ALTERNATIVES
|
|
1720
|
+
\u2022 [Activity Name] - [Brief description including specific venue]
|
|
1721
|
+
Ideal for: [weather condition that would trigger this alternative]
|
|
1722
|
+
|
|
1723
|
+
\u26A0\uFE0F SPECIAL CONSIDERATIONS
|
|
1724
|
+
\u2022 [Any relevant weather warnings, UV index, wind conditions, etc.]
|
|
1725
|
+
|
|
1726
|
+
Guidelines:
|
|
1727
|
+
- Suggest 2-3 time-specific outdoor activities per day
|
|
1728
|
+
- Include 1-2 indoor backup options
|
|
1729
|
+
- For precipitation >50%, lead with indoor activities
|
|
1730
|
+
- All activities must be specific to the location
|
|
1731
|
+
- Include specific venues, trails, or locations
|
|
1732
|
+
- Consider activity intensity based on temperature
|
|
1733
|
+
- Keep descriptions concise but informative
|
|
1734
|
+
|
|
1735
|
+
Maintain this exact formatting for consistency, using the emoji and section headers as shown.\`;
|
|
1744
1736
|
|
|
1745
1737
|
const response = await agent.stream([
|
|
1746
1738
|
{
|
|
@@ -1795,7 +1787,7 @@ async function writeCodeSampleForComponents(llmprovider, component, destPath, im
|
|
|
1795
1787
|
case "tools":
|
|
1796
1788
|
return writeToolSample(destPath);
|
|
1797
1789
|
case "workflows":
|
|
1798
|
-
return writeWorkflowSample(destPath
|
|
1790
|
+
return writeWorkflowSample(destPath);
|
|
1799
1791
|
default:
|
|
1800
1792
|
return "";
|
|
1801
1793
|
}
|