mastra-starter 1.0.6 → 1.0.8

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/.env.example CHANGED
@@ -1,2 +1,3 @@
1
1
  OPENAI_API_KEY=
2
- COMPOSIO_API_KEY=
2
+ COMPOSIO_API_KEY=
3
+ COMPOSIO_ACCOUNT_ID=
package/index.mjs CHANGED
@@ -6,7 +6,12 @@ import fs from 'fs';
6
6
  import { Command } from 'commander';
7
7
  import dotenv from 'dotenv';
8
8
 
9
- import { runCharacter, installPackages, buildPackages } from './util.mjs';
9
+ import {
10
+ runCharacter,
11
+ getPluginType,
12
+ installNpmPackages,
13
+ buildNpmPackages,
14
+ } from "./util.mjs";
10
15
 
11
16
  const main = async () => {
12
17
  dotenv.config();
@@ -42,8 +47,8 @@ const main = async () => {
42
47
  .argument('<packages...>', 'packages to install')
43
48
  .action(async (packages) => {
44
49
  try {
45
- await installPackages(packages);
46
- await buildPackages(packages);
50
+ await installNpmPackages(packages);
51
+ await buildNpmPackages(packages);
47
52
  } catch (error) {
48
53
  console.error(`Error in install command: ${error.message}`);
49
54
  }
@@ -65,7 +70,11 @@ const main = async () => {
65
70
  const characterJson = JSON.parse(characterJsonString);
66
71
 
67
72
  if (characterJson.plugins && Array.isArray(characterJson.plugins)) {
68
- characterJson.plugins.forEach(plugin => pluginsToInstall.add(plugin));
73
+ characterJson.plugins.forEach(plugin => {
74
+ if (getPluginType(plugin) === 'npm') {
75
+ pluginsToInstall.add(plugin);
76
+ }
77
+ });
69
78
  }
70
79
  }
71
80
 
@@ -74,8 +83,8 @@ const main = async () => {
74
83
  return;
75
84
  }
76
85
 
77
- await installPackages([...pluginsToInstall]);
78
- await buildPackages([...pluginsToInstall]);
86
+ await installNpmPackages([...pluginsToInstall]);
87
+ await buildNpmPackages([...pluginsToInstall]);
79
88
  } catch (error) {
80
89
  console.error(`Error in installall command: ${error.message}`);
81
90
  }
@@ -89,7 +98,7 @@ const main = async () => {
89
98
  .argument('<packages...>', 'packages to build')
90
99
  .action(async (packages) => {
91
100
  try {
92
- await buildPackages(packages);
101
+ await buildNpmPackages(packages);
93
102
  } catch (error) {
94
103
  console.error(`Error in build command: ${error.message}`);
95
104
  }
@@ -111,7 +120,11 @@ const main = async () => {
111
120
  const characterJson = JSON.parse(characterJsonString);
112
121
 
113
122
  if (characterJson.plugins && Array.isArray(characterJson.plugins)) {
114
- characterJson.plugins.forEach(plugin => pluginsToBuild.add(plugin));
123
+ characterJson.plugins.forEach(plugin => {
124
+ if (getPluginType(plugin) === 'npm') {
125
+ pluginsToBuild.add(plugin);
126
+ }
127
+ });
115
128
  }
116
129
  }
117
130
 
@@ -120,7 +133,7 @@ const main = async () => {
120
133
  return;
121
134
  }
122
135
 
123
- await buildPackages([...pluginsToBuild]);
136
+ await buildNpmPackages([...pluginsToBuild]);
124
137
  } catch (error) {
125
138
  console.error(`Error in buildall command: ${error.message}`);
126
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastra-starter",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "index.mjs",
5
5
  "bin": {
6
6
  "mastra-starter": "./index.mjs"
@@ -5,6 +5,7 @@ import { Agent, ToolsInput } from '@mastra/core/agent';
5
5
  import dedent from 'dedent';
6
6
  import { MCPConfiguration } from "@mastra/mcp";
7
7
  import { ComposioIntegration } from '@mastra/composio';
8
+ import { sortPlugins } from '../../../util.mjs';
8
9
  import { PnpmPackageLookup } from 'pnpm-package-lookup';
9
10
 
10
11
  // character
@@ -17,15 +18,10 @@ const characterJson = JSON.parse(characterJsonString);
17
18
 
18
19
  // sort plugins
19
20
  const { plugins = [] } = characterJson;
20
- const npmPlugins: string[] = [];
21
- const composioPlugins: string[] = [];
22
- for (const plugin of plugins) {
23
- if (plugin.startsWith('composio:')) {
24
- composioPlugins.push(plugin);
25
- } else {
26
- npmPlugins.push(plugin);
27
- }
28
- }
21
+ const {
22
+ npm: npmPlugins,
23
+ composio: composioPlugins,
24
+ } = sortPlugins(plugins);
29
25
 
30
26
  // resolve npm plugins
31
27
  const servers: Record<string, any> = {};
@@ -51,23 +47,27 @@ const mcp = new MCPConfiguration({
51
47
  const mcpTools = await mcp.getTools();
52
48
 
53
49
  // composio tools
54
- const composio = new ComposioIntegration({
55
- config: {
56
- API_KEY: process.env.COMPOSIO_API_KEY!,
57
- entityId: 'default',
58
- // connectedAccountId: '899144e5-a466-428b-8a00-7c931fb57f9f',
59
- connectedAccountId: '4d79004e-320a-4dc9-be1a-1037a6fe9866',
60
- },
61
- });
62
- // const actionsEnums = [
63
- // 'GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER',
64
- // 'GITHUB_ACTIVITY_LIST_STARGAZERS_FOR_REPO',
65
- // 'GITHUB_GET_OCTOCAT',
66
- // ];
67
- const actionsEnums = composioPlugins.map((plugin) => plugin.replace('composio:', ''));
68
- const composioToolset = await composio.getTools({
69
- actions: actionsEnums,
70
- }) as ToolsInput;
50
+ const composioApiKey = process.env.COMPOSIO_API_KEY;
51
+ const composioAccountId = process.env.COMPOSIO_ACCOUNT_ID;
52
+ let composioToolset: ToolsInput | undefined;
53
+ if (composioApiKey && composioAccountId) {
54
+ const composio = new ComposioIntegration({
55
+ config: {
56
+ API_KEY: composioApiKey,
57
+ entityId: 'default',
58
+ connectedAccountId: composioAccountId,
59
+ },
60
+ });
61
+ // const actionsEnums = [
62
+ // 'GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER',
63
+ // 'GITHUB_ACTIVITY_LIST_STARGAZERS_FOR_REPO',
64
+ // 'GITHUB_GET_OCTOCAT',
65
+ // ];
66
+ const actionsEnums = composioPlugins.map((plugin: string) => plugin.replace('composio:', ''));
67
+ composioToolset = await composio.getTools({
68
+ actions: actionsEnums,
69
+ }) as ToolsInput;
70
+ }
71
71
 
72
72
  // agent
73
73
  export const characterAgent = new Agent({
@@ -10,7 +10,10 @@
10
10
  }
11
11
  },
12
12
  "plugins": [
13
- "github:v-3/discordmcp"
13
+ "github:v-3/discordmcp",
14
+ "composio:GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER",
15
+ "composio:GITHUB_ACTIVITY_LIST_STARGAZERS_FOR_REPO",
16
+ "composio:GITHUB_GET_OCTOCAT"
14
17
  ],
15
18
  "bio": [
16
19
  "secured the Southern Border COMPLETELY (until they DESTROYED it)",
package/util.mjs CHANGED
@@ -29,7 +29,32 @@ export const runCharacter = async (characterJsonPath, {
29
29
  });
30
30
  });
31
31
  };
32
- export const installPackages = (packageSpecifiers) => {
32
+
33
+ export const getPluginType = (plugin) => {
34
+ if (plugin.startsWith('composio:')) {
35
+ return 'composio';
36
+ } else {
37
+ return 'npm';
38
+ }
39
+ };
40
+ export const sortPlugins = (plugins) => {
41
+ const npm = [];
42
+ const composio = [];
43
+ for (const plugin of plugins) {
44
+ const pluginType = getPluginType(plugin);
45
+ if (pluginType === 'npm') {
46
+ npm.push(plugin);
47
+ } else if (pluginType === 'composio') {
48
+ composio.push(plugin);
49
+ }
50
+ }
51
+ return {
52
+ npm,
53
+ composio,
54
+ };
55
+ };
56
+
57
+ export const installNpmPackages = (packageSpecifiers) => {
33
58
  console.log(`Installing packages: ${packageSpecifiers.join(", ")}`);
34
59
 
35
60
  return new Promise((resolve, reject) => {
@@ -53,7 +78,7 @@ export const installPackages = (packageSpecifiers) => {
53
78
  });
54
79
  });
55
80
  };
56
- export const buildPackages = async (packageSpecifiers) => {
81
+ export const buildNpmPackages = async (packageSpecifiers) => {
57
82
  console.log(`Building packages: ${packageSpecifiers.join(", ")}`);
58
83
 
59
84
  // get the packagePaths from the packageSpecifiers