mastra-starter 1.0.11 → 1.0.12
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 +21 -5
- package/util.mjs +9 -3
package/package.json
CHANGED
@@ -17,9 +17,19 @@ const characterJsonString = await fs.promises.readFile(
|
|
17
17
|
);
|
18
18
|
const characterJson = JSON.parse(characterJsonString);
|
19
19
|
|
20
|
+
const cleanName = (name: string) => {
|
21
|
+
return name
|
22
|
+
.replace(/[\/:]+/g, "-")
|
23
|
+
.replace(/[^a-zA-Z0-9_-]/g, "");
|
24
|
+
};
|
25
|
+
|
20
26
|
// sort plugins
|
21
27
|
const { plugins = [] } = characterJson;
|
22
|
-
const {
|
28
|
+
const {
|
29
|
+
http: httpPlugins,
|
30
|
+
npm: npmPlugins,
|
31
|
+
composio: composioPlugins,
|
32
|
+
} = sortPlugins(plugins);
|
23
33
|
|
24
34
|
// resolve npm plugins
|
25
35
|
const servers: Record<string, any> = {};
|
@@ -30,6 +40,15 @@ const pnpmPackageLookup = new PnpmPackageLookup({
|
|
30
40
|
|
31
41
|
console.log("Initializing plugin servers...");
|
32
42
|
|
43
|
+
// http plugins
|
44
|
+
for (const pluginSpecifier of httpPlugins) {
|
45
|
+
const pluginName = cleanName(pluginSpecifier)
|
46
|
+
console.log('pluginName', pluginName, pluginSpecifier);
|
47
|
+
servers[pluginName] = {
|
48
|
+
url: new URL(pluginSpecifier),
|
49
|
+
};
|
50
|
+
}
|
51
|
+
// npm plugins
|
33
52
|
for (const pluginSpecifier of npmPlugins) {
|
34
53
|
const npmPackageType = getNpmPackageType(pluginSpecifier);
|
35
54
|
|
@@ -65,10 +84,7 @@ for (const pluginSpecifier of npmPlugins) {
|
|
65
84
|
const packageJson = JSON.parse(
|
66
85
|
await fs.promises.readFile(packageJsonPath, "utf8")
|
67
86
|
);
|
68
|
-
const pluginName = pluginSpecifier
|
69
|
-
// .replace(/^github:/, "")
|
70
|
-
.replace(/[\/:]+/g, "-")
|
71
|
-
.replace(/[^a-zA-Z0-9_-]/g, "");
|
87
|
+
const pluginName = cleanName(pluginSpecifier)
|
72
88
|
if (!pluginName) {
|
73
89
|
console.error(`Could not clean up plugin name for ${pluginSpecifier}`);
|
74
90
|
continue;
|
package/util.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import path from "path";
|
2
|
-
import fs from "fs";
|
2
|
+
// import fs from "fs";
|
3
3
|
import child_process from "child_process";
|
4
4
|
import { mkdirp } from "mkdirp";
|
5
5
|
import { rimraf } from "rimraf";
|
@@ -35,24 +35,30 @@ export const runCharacter = async (characterJsonPath, { env = {} } = {}) => {
|
|
35
35
|
};
|
36
36
|
|
37
37
|
export const getPluginType = (plugin) => {
|
38
|
-
if (plugin
|
38
|
+
if (/^https?:\/\//.test(plugin)) {
|
39
|
+
return "http";
|
40
|
+
} else if (plugin.startsWith("composio:")) {
|
39
41
|
return "composio";
|
40
42
|
} else {
|
41
43
|
return "npm";
|
42
44
|
}
|
43
45
|
};
|
44
46
|
export const sortPlugins = (plugins) => {
|
47
|
+
const http = [];
|
45
48
|
const npm = [];
|
46
49
|
const composio = [];
|
47
50
|
for (const plugin of plugins) {
|
48
51
|
const pluginType = getPluginType(plugin);
|
49
|
-
if (pluginType === "
|
52
|
+
if (pluginType === "http") {
|
53
|
+
http.push(plugin);
|
54
|
+
} else if (pluginType === "npm") {
|
50
55
|
npm.push(plugin);
|
51
56
|
} else if (pluginType === "composio") {
|
52
57
|
composio.push(plugin);
|
53
58
|
}
|
54
59
|
}
|
55
60
|
return {
|
61
|
+
http,
|
56
62
|
npm,
|
57
63
|
composio,
|
58
64
|
};
|