mastra-starter 1.0.10 → 1.0.11
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/package.json +1 -1
- package/src/mastra/agents/index.ts +32 -13
package/package.json
CHANGED
@@ -27,6 +27,9 @@ const pnpmLockYamlPath = path.resolve(rootDir, "pnpm-lock.yaml");
|
|
27
27
|
const pnpmPackageLookup = new PnpmPackageLookup({
|
28
28
|
pnpmLockYamlPath,
|
29
29
|
});
|
30
|
+
|
31
|
+
console.log("Initializing plugin servers...");
|
32
|
+
|
30
33
|
for (const pluginSpecifier of npmPlugins) {
|
31
34
|
const npmPackageType = getNpmPackageType(pluginSpecifier);
|
32
35
|
|
@@ -40,7 +43,7 @@ for (const pluginSpecifier of npmPlugins) {
|
|
40
43
|
pluginSpecifier2 =
|
41
44
|
await pnpmPackageLookup.getPackageNameBySpecifier(packageResolvedName);
|
42
45
|
if (!pluginSpecifier2) {
|
43
|
-
|
46
|
+
console.error(
|
44
47
|
`Could not resolve package name for ${JSON.stringify(
|
45
48
|
{
|
46
49
|
pluginSpecifier,
|
@@ -51,6 +54,7 @@ for (const pluginSpecifier of npmPlugins) {
|
|
51
54
|
2
|
52
55
|
)}`
|
53
56
|
);
|
57
|
+
continue;
|
54
58
|
}
|
55
59
|
} else {
|
56
60
|
pluginSpecifier2 = pluginSpecifier;
|
@@ -61,13 +65,13 @@ for (const pluginSpecifier of npmPlugins) {
|
|
61
65
|
const packageJson = JSON.parse(
|
62
66
|
await fs.promises.readFile(packageJsonPath, "utf8")
|
63
67
|
);
|
64
|
-
const pluginName =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
.replace(/[^a-zA-Z0-9_-]/g, "");
|
68
|
+
const pluginName = pluginSpecifier
|
69
|
+
// .replace(/^github:/, "")
|
70
|
+
.replace(/[\/:]+/g, "-")
|
71
|
+
.replace(/[^a-zA-Z0-9_-]/g, "");
|
69
72
|
if (!pluginName) {
|
70
|
-
|
73
|
+
console.error(`Could not clean up plugin name for ${pluginSpecifier}`);
|
74
|
+
continue;
|
71
75
|
}
|
72
76
|
if (packageJson.scripts.start) {
|
73
77
|
servers[pluginName] = {
|
@@ -85,7 +89,7 @@ for (const pluginSpecifier of npmPlugins) {
|
|
85
89
|
env: process.env as any,
|
86
90
|
};
|
87
91
|
} else {
|
88
|
-
|
92
|
+
console.error(
|
89
93
|
`No start script or bins found for ${pluginSpecifier} name ${pluginName}`
|
90
94
|
);
|
91
95
|
}
|
@@ -93,15 +97,26 @@ for (const pluginSpecifier of npmPlugins) {
|
|
93
97
|
}
|
94
98
|
|
95
99
|
// mcp tools
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
const
|
100
|
+
console.log("Retrieving MCP tools...");
|
101
|
+
let mcpTools: ToolsInput = {};
|
102
|
+
try {
|
103
|
+
const mcp = new MCPConfiguration({
|
104
|
+
servers,
|
105
|
+
});
|
106
|
+
|
107
|
+
mcpTools = await mcp.getTools();
|
108
|
+
console.log(
|
109
|
+
`Successfully initialized ${Object.keys(mcpTools).length} MCP tools`
|
110
|
+
);
|
111
|
+
} catch (error) {
|
112
|
+
console.error("Error initializing MCP tools:", error);
|
113
|
+
console.log("Continuing with limited functionality...");
|
114
|
+
}
|
100
115
|
|
101
116
|
// composio tools
|
102
117
|
const composioApiKey = process.env.COMPOSIO_API_KEY;
|
103
118
|
const composioAccountId = process.env.COMPOSIO_ACCOUNT_ID;
|
104
|
-
let composioToolset: ToolsInput
|
119
|
+
let composioToolset: ToolsInput = {};
|
105
120
|
if (composioApiKey && composioAccountId) {
|
106
121
|
const composio = new ComposioIntegration({
|
107
122
|
config: {
|
@@ -124,10 +139,12 @@ if (composioApiKey && composioAccountId) {
|
|
124
139
|
}
|
125
140
|
|
126
141
|
// agent
|
142
|
+
console.log("Initializing agent...");
|
127
143
|
const model = createOpenAI({
|
128
144
|
baseURL: process.env.OPENAI_API_URL || "https://api.openai.com/v1",
|
129
145
|
apiKey: process.env.OPENAI_API_KEY,
|
130
146
|
})("gpt-4o");
|
147
|
+
|
131
148
|
export const characterAgent = new Agent({
|
132
149
|
name: "Character",
|
133
150
|
instructions:
|
@@ -143,3 +160,5 @@ export const characterAgent = new Agent({
|
|
143
160
|
...composioToolset,
|
144
161
|
},
|
145
162
|
});
|
163
|
+
|
164
|
+
console.log("Agent initialization completed!");
|