create-mastra 0.0.0-storage-20250225005900 → 0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806162745
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/LICENSE.md +15 -0
- package/README.md +1 -2
- package/dist/index.js +1369 -464
- package/dist/index.js.map +1 -1
- package/dist/starter-files/config.d.ts +26 -0
- package/dist/starter-files/config.d.ts.map +1 -0
- package/dist/starter-files/tools.d.ts +79 -0
- package/dist/starter-files/tools.d.ts.map +1 -0
- package/dist/templates/dev.entry.d.ts +2 -0
- package/dist/templates/dev.entry.d.ts.map +1 -0
- package/dist/templates/dev.entry.js +18 -12
- package/package.json +20 -19
- package/LICENSE +0 -44
- package/dist/starter-files/workflow.ts +0 -182
- package/starter-files/config.ts +0 -28
- package/starter-files/mastra-pg.docker-compose.yaml +0 -15
- package/starter-files/tools.ts +0 -95
- package/starter-files/workflow.ts +0 -183
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const config: {
|
|
2
|
+
readonly name: "PROJECT_NAME";
|
|
3
|
+
readonly integrations: readonly [];
|
|
4
|
+
readonly db: {
|
|
5
|
+
readonly provider: "postgres";
|
|
6
|
+
readonly uri: string;
|
|
7
|
+
};
|
|
8
|
+
readonly runner: {
|
|
9
|
+
readonly provider: "inngest";
|
|
10
|
+
readonly uri: string;
|
|
11
|
+
readonly signingKey: string;
|
|
12
|
+
readonly eventKey: string;
|
|
13
|
+
};
|
|
14
|
+
readonly workflows: {
|
|
15
|
+
readonly blueprintDirPath: "/mastra/blueprints";
|
|
16
|
+
readonly systemEvents: {};
|
|
17
|
+
readonly systemApis: readonly [];
|
|
18
|
+
};
|
|
19
|
+
readonly agents: {
|
|
20
|
+
readonly agentDirPath: "/mastra/agents";
|
|
21
|
+
readonly vectorProvider: readonly [];
|
|
22
|
+
};
|
|
23
|
+
readonly systemHostURL: string;
|
|
24
|
+
readonly routeRegistrationPath: "/api/mastra";
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/starter-files/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;CAwBT,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const weatherTool: import("@mastra/core/tools").Tool<z.ZodObject<{
|
|
3
|
+
location: z.ZodString;
|
|
4
|
+
}, "strip", z.ZodTypeAny, {
|
|
5
|
+
location: string;
|
|
6
|
+
}, {
|
|
7
|
+
location: string;
|
|
8
|
+
}>, z.ZodObject<{
|
|
9
|
+
temperature: z.ZodNumber;
|
|
10
|
+
feelsLike: z.ZodNumber;
|
|
11
|
+
humidity: z.ZodNumber;
|
|
12
|
+
windSpeed: z.ZodNumber;
|
|
13
|
+
windGust: z.ZodNumber;
|
|
14
|
+
conditions: z.ZodString;
|
|
15
|
+
location: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
location: string;
|
|
18
|
+
temperature: number;
|
|
19
|
+
feelsLike: number;
|
|
20
|
+
humidity: number;
|
|
21
|
+
windSpeed: number;
|
|
22
|
+
windGust: number;
|
|
23
|
+
conditions: string;
|
|
24
|
+
}, {
|
|
25
|
+
location: string;
|
|
26
|
+
temperature: number;
|
|
27
|
+
feelsLike: number;
|
|
28
|
+
humidity: number;
|
|
29
|
+
windSpeed: number;
|
|
30
|
+
windGust: number;
|
|
31
|
+
conditions: string;
|
|
32
|
+
}>, import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
33
|
+
location: z.ZodString;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
location: string;
|
|
36
|
+
}, {
|
|
37
|
+
location: string;
|
|
38
|
+
}>>> & {
|
|
39
|
+
inputSchema: z.ZodObject<{
|
|
40
|
+
location: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
location: string;
|
|
43
|
+
}, {
|
|
44
|
+
location: string;
|
|
45
|
+
}>;
|
|
46
|
+
outputSchema: z.ZodObject<{
|
|
47
|
+
temperature: z.ZodNumber;
|
|
48
|
+
feelsLike: z.ZodNumber;
|
|
49
|
+
humidity: z.ZodNumber;
|
|
50
|
+
windSpeed: z.ZodNumber;
|
|
51
|
+
windGust: z.ZodNumber;
|
|
52
|
+
conditions: z.ZodString;
|
|
53
|
+
location: z.ZodString;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
location: string;
|
|
56
|
+
temperature: number;
|
|
57
|
+
feelsLike: number;
|
|
58
|
+
humidity: number;
|
|
59
|
+
windSpeed: number;
|
|
60
|
+
windGust: number;
|
|
61
|
+
conditions: string;
|
|
62
|
+
}, {
|
|
63
|
+
location: string;
|
|
64
|
+
temperature: number;
|
|
65
|
+
feelsLike: number;
|
|
66
|
+
humidity: number;
|
|
67
|
+
windSpeed: number;
|
|
68
|
+
windGust: number;
|
|
69
|
+
conditions: string;
|
|
70
|
+
}>;
|
|
71
|
+
execute: (context: import("@mastra/core").ToolExecutionContext<z.ZodObject<{
|
|
72
|
+
location: z.ZodString;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
location: string;
|
|
75
|
+
}, {
|
|
76
|
+
location: string;
|
|
77
|
+
}>>) => Promise<any>;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/starter-files/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.entry.d.ts","sourceRoot":"","sources":["../../src/templates/dev.entry.js"],"names":[],"mappings":""}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
2
|
// @ts-ignore
|
|
3
|
-
import { mastra } from '#mastra';
|
|
4
|
-
import { createNodeServer } from '#server';
|
|
5
3
|
import { evaluate } from '@mastra/core/eval';
|
|
6
4
|
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
7
5
|
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
6
|
+
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
7
|
+
import { mastra } from '#mastra';
|
|
8
|
+
import { createNodeServer, getToolExports } from '#server';
|
|
9
|
+
import { tools } from '#tools';
|
|
14
10
|
// @ts-ignore
|
|
15
|
-
await createNodeServer(mastra, {
|
|
11
|
+
await createNodeServer(mastra, {
|
|
12
|
+
playground: true,
|
|
13
|
+
isDev: true,
|
|
14
|
+
tools: getToolExports(tools),
|
|
15
|
+
});
|
|
16
16
|
|
|
17
17
|
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
18
18
|
evaluate({
|
|
@@ -27,13 +27,19 @@ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agen
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const storage = mastra.getStorage();
|
|
31
|
+
if (storage) {
|
|
32
|
+
// Check for required fields
|
|
33
|
+
const logger = mastra?.getLogger();
|
|
34
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
35
|
+
if (!areFieldsValid) return;
|
|
36
|
+
|
|
37
|
+
await storage.insert({
|
|
32
38
|
tableName: TABLE_EVALS,
|
|
33
39
|
record: {
|
|
34
40
|
input: traceObject.input,
|
|
35
41
|
output: traceObject.output,
|
|
36
|
-
result: JSON.stringify(traceObject.result),
|
|
42
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
37
43
|
agent_name: traceObject.agentName,
|
|
38
44
|
metric_name: traceObject.metricName,
|
|
39
45
|
instructions: traceObject.instructions,
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-mastra",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806162745",
|
|
4
4
|
"description": "Create Mastra apps with one command",
|
|
5
|
+
"license": "Apache-2.0",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "dist/index.js",
|
|
7
8
|
"bin": {
|
|
@@ -30,29 +31,29 @@
|
|
|
30
31
|
"project"
|
|
31
32
|
],
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"commander": "^12.
|
|
34
|
-
"execa": "^9.
|
|
35
|
-
"fs-extra": "^11.
|
|
36
|
-
"pino": "^9.
|
|
34
|
+
"commander": "^12.1.0",
|
|
35
|
+
"execa": "^9.6.0",
|
|
36
|
+
"fs-extra": "^11.3.0",
|
|
37
|
+
"pino": "^9.7.0",
|
|
37
38
|
"pino-pretty": "^13.0.0",
|
|
38
|
-
"posthog-node": "^4.
|
|
39
|
-
"prettier": "^3.
|
|
39
|
+
"posthog-node": "^4.18.0",
|
|
40
|
+
"prettier": "^3.6.2"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@microsoft/api-extractor": "^7.
|
|
43
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
43
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
44
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
44
45
|
"@rollup/plugin-json": "^6.1.0",
|
|
45
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
46
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
46
47
|
"@types/fs-extra": "^11.0.4",
|
|
47
|
-
"@types/node": "^
|
|
48
|
-
"esbuild": "^0.
|
|
49
|
-
"eslint": "^9.
|
|
50
|
-
"rollup": "^4.
|
|
51
|
-
"rollup-plugin-esbuild": "^6.
|
|
52
|
-
"rollup-plugin-node-externals": "^8.0.
|
|
53
|
-
"typescript": "^5.
|
|
54
|
-
"
|
|
55
|
-
"
|
|
48
|
+
"@types/node": "^20.19.0",
|
|
49
|
+
"esbuild": "^0.25.8",
|
|
50
|
+
"eslint": "^9.30.1",
|
|
51
|
+
"rollup": "^4.42.0",
|
|
52
|
+
"rollup-plugin-esbuild": "^6.2.1",
|
|
53
|
+
"rollup-plugin-node-externals": "^8.0.1",
|
|
54
|
+
"typescript": "^5.8.3",
|
|
55
|
+
"@internal/lint": "0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806162745",
|
|
56
|
+
"mastra": "0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806162745"
|
|
56
57
|
},
|
|
57
58
|
"engines": {
|
|
58
59
|
"node": ">=20"
|
package/LICENSE
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
Elastic License 2.0 (ELv2)
|
|
2
|
-
|
|
3
|
-
**Acceptance**
|
|
4
|
-
By using the software, you agree to all of the terms and conditions below.
|
|
5
|
-
|
|
6
|
-
**Copyright License**
|
|
7
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
8
|
-
|
|
9
|
-
**Limitations**
|
|
10
|
-
You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
|
|
11
|
-
|
|
12
|
-
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
|
|
13
|
-
|
|
14
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
15
|
-
|
|
16
|
-
**Patents**
|
|
17
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
18
|
-
|
|
19
|
-
**Notices**
|
|
20
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
21
|
-
|
|
22
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
23
|
-
|
|
24
|
-
**No Other Rights**
|
|
25
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
26
|
-
|
|
27
|
-
**Termination**
|
|
28
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
29
|
-
|
|
30
|
-
**No Liability**
|
|
31
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
32
|
-
|
|
33
|
-
**Definitions**
|
|
34
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
35
|
-
|
|
36
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
37
|
-
|
|
38
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
39
|
-
|
|
40
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
41
|
-
|
|
42
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
43
|
-
|
|
44
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { openai } from '@ai-sdk/openai';
|
|
2
|
-
import { Agent } from '@mastra/core/agent';
|
|
3
|
-
import { Step, Workflow } from '@mastra/core/workflows';
|
|
4
|
-
import { z } from 'zod';
|
|
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
|
-
|
|
56
|
-
const fetchWeather = new Step({
|
|
57
|
-
id: 'fetch-weather',
|
|
58
|
-
description: 'Fetches weather forecast for a given city',
|
|
59
|
-
inputSchema: z.object({
|
|
60
|
-
city: z.string().describe('The city to get the weather for'),
|
|
61
|
-
}),
|
|
62
|
-
execute: async ({ context }) => {
|
|
63
|
-
const triggerData = context?.getStepPayload<{ city: string }>('trigger');
|
|
64
|
-
|
|
65
|
-
if (!triggerData) {
|
|
66
|
-
throw new Error('Trigger data not found');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const geocodingUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(triggerData.city)}&count=1`;
|
|
70
|
-
const geocodingResponse = await fetch(geocodingUrl);
|
|
71
|
-
const geocodingData = (await geocodingResponse.json()) as {
|
|
72
|
-
results: { latitude: number; longitude: number; name: string }[];
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
if (!geocodingData.results?.[0]) {
|
|
76
|
-
throw new Error(`Location '${triggerData.city}' not found`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const { latitude, longitude, name } = geocodingData.results[0];
|
|
80
|
-
|
|
81
|
-
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`;
|
|
82
|
-
const response = await fetch(weatherUrl);
|
|
83
|
-
const data = (await response.json()) as {
|
|
84
|
-
daily: {
|
|
85
|
-
time: string[];
|
|
86
|
-
temperature_2m_max: number[];
|
|
87
|
-
temperature_2m_min: number[];
|
|
88
|
-
precipitation_probability_mean: number[];
|
|
89
|
-
weathercode: number[];
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const forecast = data.daily.time.map((date: string, index: number) => ({
|
|
94
|
-
date,
|
|
95
|
-
maxTemp: data.daily.temperature_2m_max[index],
|
|
96
|
-
minTemp: data.daily.temperature_2m_min[index],
|
|
97
|
-
precipitationChance: data.daily.precipitation_probability_mean[index],
|
|
98
|
-
condition: getWeatherCondition(data.daily.weathercode[index]!),
|
|
99
|
-
location: name,
|
|
100
|
-
}));
|
|
101
|
-
|
|
102
|
-
return forecast;
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const forecastSchema = z.array(
|
|
107
|
-
z.object({
|
|
108
|
-
date: z.string(),
|
|
109
|
-
maxTemp: z.number(),
|
|
110
|
-
minTemp: z.number(),
|
|
111
|
-
precipitationChance: z.number(),
|
|
112
|
-
condition: z.string(),
|
|
113
|
-
location: z.string(),
|
|
114
|
-
}),
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const planActivities = new Step({
|
|
118
|
-
id: 'plan-activities',
|
|
119
|
-
description: 'Suggests activities based on weather conditions',
|
|
120
|
-
inputSchema: forecastSchema,
|
|
121
|
-
execute: async ({ context, mastra }) => {
|
|
122
|
-
const forecast = context?.getStepPayload<z.infer<typeof forecastSchema>>('fetch-weather');
|
|
123
|
-
|
|
124
|
-
if (!forecast || forecast.length === 0) {
|
|
125
|
-
throw new Error('Forecast data not found');
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const prompt = `Based on the following weather forecast for ${forecast[0]?.location}, suggest appropriate activities:
|
|
129
|
-
${JSON.stringify(forecast, null, 2)}
|
|
130
|
-
`;
|
|
131
|
-
|
|
132
|
-
const response = await agent.stream([
|
|
133
|
-
{
|
|
134
|
-
role: 'user',
|
|
135
|
-
content: prompt,
|
|
136
|
-
},
|
|
137
|
-
]);
|
|
138
|
-
|
|
139
|
-
for await (const chunk of response.textStream) {
|
|
140
|
-
process.stdout.write(chunk);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
activities: response.text,
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
function getWeatherCondition(code: number): string {
|
|
150
|
-
const conditions: Record<number, string> = {
|
|
151
|
-
0: 'Clear sky',
|
|
152
|
-
1: 'Mainly clear',
|
|
153
|
-
2: 'Partly cloudy',
|
|
154
|
-
3: 'Overcast',
|
|
155
|
-
45: 'Foggy',
|
|
156
|
-
48: 'Depositing rime fog',
|
|
157
|
-
51: 'Light drizzle',
|
|
158
|
-
53: 'Moderate drizzle',
|
|
159
|
-
55: 'Dense drizzle',
|
|
160
|
-
61: 'Slight rain',
|
|
161
|
-
63: 'Moderate rain',
|
|
162
|
-
65: 'Heavy rain',
|
|
163
|
-
71: 'Slight snow fall',
|
|
164
|
-
73: 'Moderate snow fall',
|
|
165
|
-
75: 'Heavy snow fall',
|
|
166
|
-
95: 'Thunderstorm',
|
|
167
|
-
};
|
|
168
|
-
return conditions[code] || 'Unknown';
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const weatherWorkflow = new Workflow({
|
|
172
|
-
name: 'weather-workflow',
|
|
173
|
-
triggerSchema: z.object({
|
|
174
|
-
city: z.string().describe('The city to get the weather for'),
|
|
175
|
-
}),
|
|
176
|
-
})
|
|
177
|
-
.step(fetchWeather)
|
|
178
|
-
.then(planActivities);
|
|
179
|
-
|
|
180
|
-
weatherWorkflow.commit();
|
|
181
|
-
|
|
182
|
-
export { weatherWorkflow };
|
package/starter-files/config.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import { Config } from '@mastra/core';
|
|
3
|
-
|
|
4
|
-
export const config: Config = {
|
|
5
|
-
name: 'PROJECT_NAME',
|
|
6
|
-
integrations: [],
|
|
7
|
-
db: {
|
|
8
|
-
provider: 'postgres',
|
|
9
|
-
uri: process.env.DB_URL!,
|
|
10
|
-
},
|
|
11
|
-
runner: {
|
|
12
|
-
provider: 'inngest',
|
|
13
|
-
uri: process.env.INNGEST_URL!,
|
|
14
|
-
signingKey: process.env.INNGEST_SIGNING_KEY!,
|
|
15
|
-
eventKey: process.env.INNGEST_EVENT_KEY!,
|
|
16
|
-
},
|
|
17
|
-
workflows: {
|
|
18
|
-
blueprintDirPath: '/mastra/blueprints',
|
|
19
|
-
systemEvents: {},
|
|
20
|
-
systemApis: [],
|
|
21
|
-
},
|
|
22
|
-
agents: {
|
|
23
|
-
agentDirPath: '/mastra/agents',
|
|
24
|
-
vectorProvider: [],
|
|
25
|
-
},
|
|
26
|
-
systemHostURL: process.env.APP_URL!,
|
|
27
|
-
routeRegistrationPath: '/api/mastra',
|
|
28
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
db:
|
|
3
|
-
image: pgvector/pgvector:pg16
|
|
4
|
-
container_name: 'REPLACE_PROJECT_NAME-db'
|
|
5
|
-
ports:
|
|
6
|
-
- 'REPLACE_DB_PORT:5432'
|
|
7
|
-
environment:
|
|
8
|
-
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
|
9
|
-
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres}
|
|
10
|
-
POSTGRES_DB: ${POSTGRES_DB:-mastra}
|
|
11
|
-
volumes:
|
|
12
|
-
- pgdata:/var/lib/postgresql/data
|
|
13
|
-
|
|
14
|
-
volumes:
|
|
15
|
-
pgdata:
|
package/starter-files/tools.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { createTool } from '@mastra/core';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
interface WeatherResponse {
|
|
5
|
-
current: {
|
|
6
|
-
time: string;
|
|
7
|
-
temperature_2m: number;
|
|
8
|
-
apparent_temperature: number;
|
|
9
|
-
relative_humidity_2m: number;
|
|
10
|
-
wind_speed_10m: number;
|
|
11
|
-
wind_gusts_10m: number;
|
|
12
|
-
weather_code: number;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const weatherTool = createTool({
|
|
17
|
-
id: 'get-weather',
|
|
18
|
-
description: 'Get current weather for a location',
|
|
19
|
-
inputSchema: z.object({
|
|
20
|
-
location: z.string().describe('City name'),
|
|
21
|
-
}),
|
|
22
|
-
outputSchema: z.object({
|
|
23
|
-
temperature: z.number(),
|
|
24
|
-
feelsLike: z.number(),
|
|
25
|
-
humidity: z.number(),
|
|
26
|
-
windSpeed: z.number(),
|
|
27
|
-
windGust: z.number(),
|
|
28
|
-
conditions: z.string(),
|
|
29
|
-
location: z.string(),
|
|
30
|
-
}),
|
|
31
|
-
execute: async ({ context }) => {
|
|
32
|
-
return await getWeather(context.location);
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const getWeather = async (location: string) => {
|
|
37
|
-
const geocodingUrl = `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(location)}&count=1`;
|
|
38
|
-
const geocodingResponse = await fetch(geocodingUrl);
|
|
39
|
-
const geocodingData = await geocodingResponse.json();
|
|
40
|
-
|
|
41
|
-
if (!geocodingData.results?.[0]) {
|
|
42
|
-
throw new Error(`Location '${location}' not found`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const { latitude, longitude, name } = geocodingData.results[0];
|
|
46
|
-
|
|
47
|
-
const weatherUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,apparent_temperature,relative_humidity_2m,wind_speed_10m,wind_gusts_10m,weather_code`;
|
|
48
|
-
|
|
49
|
-
const response = await fetch(weatherUrl);
|
|
50
|
-
const data: WeatherResponse = await response.json();
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
temperature: data.current.temperature_2m,
|
|
54
|
-
feelsLike: data.current.apparent_temperature,
|
|
55
|
-
humidity: data.current.relative_humidity_2m,
|
|
56
|
-
windSpeed: data.current.wind_speed_10m,
|
|
57
|
-
windGust: data.current.wind_gusts_10m,
|
|
58
|
-
conditions: getWeatherCondition(data.current.weather_code),
|
|
59
|
-
location: name,
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
function getWeatherCondition(code: number): string {
|
|
64
|
-
const conditions: Record<number, string> = {
|
|
65
|
-
0: 'Clear sky',
|
|
66
|
-
1: 'Mainly clear',
|
|
67
|
-
2: 'Partly cloudy',
|
|
68
|
-
3: 'Overcast',
|
|
69
|
-
45: 'Foggy',
|
|
70
|
-
48: 'Depositing rime fog',
|
|
71
|
-
51: 'Light drizzle',
|
|
72
|
-
53: 'Moderate drizzle',
|
|
73
|
-
55: 'Dense drizzle',
|
|
74
|
-
56: 'Light freezing drizzle',
|
|
75
|
-
57: 'Dense freezing drizzle',
|
|
76
|
-
61: 'Slight rain',
|
|
77
|
-
63: 'Moderate rain',
|
|
78
|
-
65: 'Heavy rain',
|
|
79
|
-
66: 'Light freezing rain',
|
|
80
|
-
67: 'Heavy freezing rain',
|
|
81
|
-
71: 'Slight snow fall',
|
|
82
|
-
73: 'Moderate snow fall',
|
|
83
|
-
75: 'Heavy snow fall',
|
|
84
|
-
77: 'Snow grains',
|
|
85
|
-
80: 'Slight rain showers',
|
|
86
|
-
81: 'Moderate rain showers',
|
|
87
|
-
82: 'Violent rain showers',
|
|
88
|
-
85: 'Slight snow showers',
|
|
89
|
-
86: 'Heavy snow showers',
|
|
90
|
-
95: 'Thunderstorm',
|
|
91
|
-
96: 'Thunderstorm with slight hail',
|
|
92
|
-
99: 'Thunderstorm with heavy hail',
|
|
93
|
-
};
|
|
94
|
-
return conditions[code] || 'Unknown';
|
|
95
|
-
}
|