create-mastra 0.1.0-alpha.23 → 0.1.0-alpha.25

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.
Files changed (47) hide show
  1. package/LICENSE +44 -0
  2. package/dist/AssumeRoleCommand-Cse3dzcY.js +3650 -0
  3. package/dist/AssumeRoleCommand-Cse3dzcY.js.map +1 -0
  4. package/dist/create-aggregated-client-BFp7oxSr.js +24 -0
  5. package/dist/create-aggregated-client-BFp7oxSr.js.map +1 -0
  6. package/dist/extended-encode-uri-component-Dlbpb2Wd.js +8 -0
  7. package/dist/extended-encode-uri-component-Dlbpb2Wd.js.map +1 -0
  8. package/dist/index-B6QXpY-b.js +37 -0
  9. package/dist/index-B6QXpY-b.js.map +1 -0
  10. package/dist/index-BRCgFUbU.js +37 -0
  11. package/dist/index-BRCgFUbU.js.map +1 -0
  12. package/dist/index-BZHBFaQF.js +37 -0
  13. package/dist/index-BZHBFaQF.js.map +1 -0
  14. package/dist/index-B_Yunpbk.js +37 -0
  15. package/dist/index-B_Yunpbk.js.map +1 -0
  16. package/dist/index-BpMCSgn8.js +1145 -0
  17. package/dist/index-BpMCSgn8.js.map +1 -0
  18. package/dist/index-BxJx8yLU.js +37 -0
  19. package/dist/index-BxJx8yLU.js.map +1 -0
  20. package/dist/index-CF0rZfmW.js +37 -0
  21. package/dist/index-CF0rZfmW.js.map +1 -0
  22. package/dist/index-DeZeG5u4.js +3726 -0
  23. package/dist/index-DeZeG5u4.js.map +1 -0
  24. package/dist/index-_YTyVz_X.js +298 -0
  25. package/dist/index-_YTyVz_X.js.map +1 -0
  26. package/dist/index-lqkrgSwk.js +37 -0
  27. package/dist/index-lqkrgSwk.js.map +1 -0
  28. package/dist/index.js +152931 -39
  29. package/dist/index.js.map +1 -0
  30. package/dist/loadCognitoIdentity-CWxGlq_8.js +828 -0
  31. package/dist/loadCognitoIdentity-CWxGlq_8.js.map +1 -0
  32. package/dist/loadSso-MEAVww3h.js +615 -0
  33. package/dist/loadSso-MEAVww3h.js.map +1 -0
  34. package/dist/loadSts-DEnlAvEU.js +40 -0
  35. package/dist/loadSts-DEnlAvEU.js.map +1 -0
  36. package/dist/parseJsonBody-C_mcRkFo.js +161 -0
  37. package/dist/parseJsonBody-C_mcRkFo.js.map +1 -0
  38. package/dist/requestBuilder-CuNXirlx.js +90 -0
  39. package/dist/requestBuilder-CuNXirlx.js.map +1 -0
  40. package/package.json +16 -5
  41. package/starter-files/config.ts +28 -0
  42. package/starter-files/mastra-pg.docker-compose.yaml +15 -0
  43. package/starter-files/tools.ts +95 -0
  44. package/starter-files/workflow.ts +173 -0
  45. package/dist/index.d.ts +0 -2
  46. package/dist/utils.d.ts +0 -1
  47. package/dist/utils.js +0 -11
@@ -0,0 +1,173 @@
1
+ import { Step, Workflow } from '@mastra/core';
2
+ import { z } from 'zod';
3
+
4
+ const fetchWeather = new Step({
5
+ id: 'fetch-weather',
6
+ description: 'Fetches weather forecast for a given city',
7
+ inputSchema: z.object({
8
+ city: z.string().describe('The city to get the weather for'),
9
+ }),
10
+ execute: async ({ context }) => {
11
+ const triggerData = context.machineContext?.getStepPayload<{ city: string }>('trigger');
12
+
13
+ if (!triggerData) {
14
+ throw new Error('Trigger data not found');
15
+ }
16
+
17
+ const geocodingUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(triggerData.city)}&count=1`;
18
+ const geocodingResponse = await fetch(geocodingUrl);
19
+ const geocodingData = await geocodingResponse.json();
20
+
21
+ if (!geocodingData.results?.[0]) {
22
+ throw new Error(`Location '${triggerData.city}' not found`);
23
+ }
24
+
25
+ const { latitude, longitude, name } = geocodingData.results[0];
26
+
27
+ const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=temperature_2m_max,temperature_2m_min,precipitation_probability_mean,weathercode&timezone=auto`;
28
+ const response = await fetch(weatherUrl);
29
+ const data = await response.json();
30
+
31
+ const forecast = data.daily.time.map((date: string, index: number) => ({
32
+ date,
33
+ maxTemp: data.daily.temperature_2m_max[index],
34
+ minTemp: data.daily.temperature_2m_min[index],
35
+ precipitationChance: data.daily.precipitation_probability_mean[index],
36
+ condition: getWeatherCondition(data.daily.weathercode[index]),
37
+ location: name,
38
+ }));
39
+
40
+ return forecast;
41
+ },
42
+ });
43
+
44
+ const forecastSchema = z.array(
45
+ z.object({
46
+ date: z.string(),
47
+ maxTemp: z.number(),
48
+ minTemp: z.number(),
49
+ precipitationChance: z.number(),
50
+ condition: z.string(),
51
+ location: z.string(),
52
+ }),
53
+ );
54
+
55
+ const planActivities = new Step({
56
+ id: 'plan-activities',
57
+ description: 'Suggests activities based on weather conditions',
58
+ inputSchema: forecastSchema,
59
+ execute: async ({ context, mastra }) => {
60
+ const forecast = context.machineContext?.getStepPayload<z.infer<typeof forecastSchema>>('fetch-weather');
61
+
62
+ if (!forecast) {
63
+ throw new Error('Forecast data not found');
64
+ }
65
+
66
+ const prompt = `Based on the following weather forecast for ${forecast[0].location}, suggest appropriate activities:
67
+ ${JSON.stringify(forecast, null, 2)}
68
+ `;
69
+
70
+ if (!mastra?.llm) {
71
+ throw new Error('Mastra not found');
72
+ }
73
+
74
+ const llm = mastra.llm({
75
+ provider: 'OPEN_AI',
76
+ name: 'gpt-4o',
77
+ });
78
+
79
+ const response = await llm.stream([
80
+ {
81
+ role: 'system',
82
+ content: `You are a local activities and travel expert who excels at weather-based planning. Analyze the weather data and provide practical activity recommendations.
83
+
84
+ For each day in the forecast, structure your response exactly as follows:
85
+
86
+ 📅 [Day, Month Date, Year]
87
+ ═══════════════════════════
88
+
89
+ 🌡️ WEATHER SUMMARY
90
+ • Conditions: [brief description]
91
+ • Temperature: [X°C/Y°F to A°C/B°F]
92
+ • Precipitation: [X% chance]
93
+
94
+ 🌅 MORNING ACTIVITIES
95
+ Outdoor:
96
+ • [Activity Name] - [Brief description including specific location/route]
97
+ Best timing: [specific time range]
98
+ Note: [relevant weather consideration]
99
+
100
+ 🌞 AFTERNOON ACTIVITIES
101
+ Outdoor:
102
+ • [Activity Name] - [Brief description including specific location/route]
103
+ Best timing: [specific time range]
104
+ Note: [relevant weather consideration]
105
+
106
+ 🏠 INDOOR ALTERNATIVES
107
+ • [Activity Name] - [Brief description including specific venue]
108
+ Ideal for: [weather condition that would trigger this alternative]
109
+
110
+ ⚠️ SPECIAL CONSIDERATIONS
111
+ • [Any relevant weather warnings, UV index, wind conditions, etc.]
112
+
113
+ Guidelines:
114
+ - Suggest 2-3 time-specific outdoor activities per day
115
+ - Include 1-2 indoor backup options
116
+ - For precipitation >50%, lead with indoor activities
117
+ - All activities must be specific to the location
118
+ - Include specific venues, trails, or locations
119
+ - Consider activity intensity based on temperature
120
+ - Keep descriptions concise but informative
121
+
122
+ Maintain this exact formatting for consistency, using the emoji and section headers as shown.`,
123
+ },
124
+ {
125
+ role: 'user',
126
+ content: prompt,
127
+ },
128
+ ]);
129
+
130
+ for await (const chunk of response.textStream) {
131
+ process.stdout.write(chunk);
132
+ }
133
+
134
+ return {
135
+ activities: response.text,
136
+ };
137
+ },
138
+ });
139
+
140
+ function getWeatherCondition(code: number): string {
141
+ const conditions: Record<number, string> = {
142
+ 0: 'Clear sky',
143
+ 1: 'Mainly clear',
144
+ 2: 'Partly cloudy',
145
+ 3: 'Overcast',
146
+ 45: 'Foggy',
147
+ 48: 'Depositing rime fog',
148
+ 51: 'Light drizzle',
149
+ 53: 'Moderate drizzle',
150
+ 55: 'Dense drizzle',
151
+ 61: 'Slight rain',
152
+ 63: 'Moderate rain',
153
+ 65: 'Heavy rain',
154
+ 71: 'Slight snow fall',
155
+ 73: 'Moderate snow fall',
156
+ 75: 'Heavy snow fall',
157
+ 95: 'Thunderstorm',
158
+ };
159
+ return conditions[code] || 'Unknown';
160
+ }
161
+
162
+ const weatherWorkflow = new Workflow({
163
+ name: 'weather-workflow',
164
+ triggerSchema: z.object({
165
+ city: z.string().describe('The city to get the weather for'),
166
+ }),
167
+ })
168
+ .step(fetchWeather)
169
+ .then(planActivities);
170
+
171
+ weatherWorkflow.commit();
172
+
173
+ export { weatherWorkflow };
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- export {};
package/dist/utils.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function getPackageVersion(): Promise<any>;
package/dist/utils.js DELETED
@@ -1,11 +0,0 @@
1
- import fsExtra from 'fs-extra';
2
- import { dirname } from 'path';
3
- import path from 'path';
4
- import { fileURLToPath } from 'url';
5
- export async function getPackageVersion() {
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = dirname(__filename);
8
- const pkgJsonPath = path.join(__dirname, '..', 'package.json');
9
- const content = await fsExtra.readJSON(pkgJsonPath);
10
- return content.version;
11
- }