create-mastra 0.1.0-alpha.31 → 0.1.0-alpha.33

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.
@@ -1,4 +1,4 @@
1
- import { createTool } from '@mastra/core';
1
+ import { createTool } from '@mastra/core/tools';
2
2
  import { z } from 'zod';
3
3
 
4
4
  interface WeatherResponse {
@@ -1,6 +1,58 @@
1
- import { Step, Workflow } from '@mastra/core';
1
+ import { openai } from '@ai-sdk/openai';
2
+ import { Agent } from '@mastra/core/agent';
3
+ import { Step, Workflow } from '@mastra/core/workflows';
2
4
  import { z } from 'zod';
3
5
 
6
+ const llm = openai('gpt-4o');
7
+
8
+ const agent = new Agent({
9
+ name: 'Weather Agent',
10
+ model: llm,
11
+ instructions: `
12
+ You are a local activities and travel expert who excels at weather-based planning. Analyze the weather data and provide practical activity recommendations.
13
+
14
+ For each day in the forecast, structure your response exactly as follows:
15
+
16
+ 📅 [Day, Month Date, Year]
17
+ ═══════════════════════════
18
+
19
+ 🌡️ WEATHER SUMMARY
20
+ • Conditions: [brief description]
21
+ • Temperature: [X°C/Y°F to A°C/B°F]
22
+ • Precipitation: [X% chance]
23
+
24
+ 🌅 MORNING ACTIVITIES
25
+ Outdoor:
26
+ • [Activity Name] - [Brief description including specific location/route]
27
+ Best timing: [specific time range]
28
+ Note: [relevant weather consideration]
29
+
30
+ 🌞 AFTERNOON ACTIVITIES
31
+ Outdoor:
32
+ • [Activity Name] - [Brief description including specific location/route]
33
+ Best timing: [specific time range]
34
+ Note: [relevant weather consideration]
35
+
36
+ 🏠 INDOOR ALTERNATIVES
37
+ • [Activity Name] - [Brief description including specific venue]
38
+ Ideal for: [weather condition that would trigger this alternative]
39
+
40
+ ⚠️ SPECIAL CONSIDERATIONS
41
+ • [Any relevant weather warnings, UV index, wind conditions, etc.]
42
+
43
+ Guidelines:
44
+ - Suggest 2-3 time-specific outdoor activities per day
45
+ - Include 1-2 indoor backup options
46
+ - For precipitation >50%, lead with indoor activities
47
+ - All activities must be specific to the location
48
+ - Include specific venues, trails, or locations
49
+ - Consider activity intensity based on temperature
50
+ - Keep descriptions concise but informative
51
+
52
+ Maintain this exact formatting for consistency, using the emoji and section headers as shown.
53
+ `,
54
+ });
55
+
4
56
  const fetchWeather = new Step({
5
57
  id: 'fetch-weather',
6
58
  description: 'Fetches weather forecast for a given city',
@@ -77,60 +129,7 @@ const planActivities = new Step({
77
129
  ${JSON.stringify(forecast, null, 2)}
78
130
  `;
79
131
 
80
- if (!mastra?.llm) {
81
- throw new Error('Mastra not found');
82
- }
83
-
84
- const llm = mastra.llm({
85
- provider: 'OPEN_AI',
86
- name: 'gpt-4o',
87
- });
88
-
89
- const response = await llm.stream([
90
- {
91
- role: 'system',
92
- content: `You are a local activities and travel expert who excels at weather-based planning. Analyze the weather data and provide practical activity recommendations.
93
-
94
- For each day in the forecast, structure your response exactly as follows:
95
-
96
- 📅 [Day, Month Date, Year]
97
- ═══════════════════════════
98
-
99
- 🌡️ WEATHER SUMMARY
100
- • Conditions: [brief description]
101
- • Temperature: [X°C/Y°F to A°C/B°F]
102
- • Precipitation: [X% chance]
103
-
104
- 🌅 MORNING ACTIVITIES
105
- Outdoor:
106
- • [Activity Name] - [Brief description including specific location/route]
107
- Best timing: [specific time range]
108
- Note: [relevant weather consideration]
109
-
110
- 🌞 AFTERNOON ACTIVITIES
111
- Outdoor:
112
- • [Activity Name] - [Brief description including specific location/route]
113
- Best timing: [specific time range]
114
- Note: [relevant weather consideration]
115
-
116
- 🏠 INDOOR ALTERNATIVES
117
- • [Activity Name] - [Brief description including specific venue]
118
- Ideal for: [weather condition that would trigger this alternative]
119
-
120
- ⚠️ SPECIAL CONSIDERATIONS
121
- • [Any relevant weather warnings, UV index, wind conditions, etc.]
122
-
123
- Guidelines:
124
- - Suggest 2-3 time-specific outdoor activities per day
125
- - Include 1-2 indoor backup options
126
- - For precipitation >50%, lead with indoor activities
127
- - All activities must be specific to the location
128
- - Include specific venues, trails, or locations
129
- - Consider activity intensity based on temperature
130
- - Keep descriptions concise but informative
131
-
132
- Maintain this exact formatting for consistency, using the emoji and section headers as shown.`,
133
- },
132
+ const response = await agent.stream([
134
133
  {
135
134
  role: 'user',
136
135
  content: prompt,
@@ -1,14 +1,14 @@
1
- import { AvailableHooks, registerHook, evaluate } from '@mastra/core';
2
-
3
1
  // @ts-ignore
4
- import { mastra } from './mastra.mjs';
2
+ import { mastra } from '#mastra';
5
3
  // @ts-ignore
6
- import { createNodeServer } from './server.mjs';
4
+ import { createNodeServer } from '#server';
5
+ import { evaluate } from '@mastra/core/eval';
6
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
7
7
 
8
8
  // @ts-ignore
9
9
  const evalStore = [];
10
10
  // @ts-ignore
11
- const server = await createNodeServer(mastra, { playground: true, swaggerUI: true, evalStore });
11
+ await createNodeServer(mastra, { playground: true, swaggerUI: true, evalStore });
12
12
 
13
13
  registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName }) => {
14
14
  evaluate({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mastra",
3
- "version": "0.1.0-alpha.31",
3
+ "version": "0.1.0-alpha.33",
4
4
  "description": "Create Mastra apps with one command",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -49,7 +49,7 @@
49
49
  "rollup-plugin-esbuild": "^6.1.1",
50
50
  "rollup-plugin-node-externals": "^8.0.0",
51
51
  "typescript": "^5.7.3",
52
- "mastra": "0.1.57-alpha.130"
52
+ "mastra": "^0.2.0-alpha.151"
53
53
  },
54
54
  "engines": {
55
55
  "node": ">=20"