mastra-starter 1.0.0 → 1.0.1

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/index.mjs ADDED
@@ -0,0 +1,35 @@
1
+ import path from 'path';
2
+ import child_process from 'child_process';
3
+
4
+ import { Command } from 'commander';
5
+ import dotenv from 'dotenv';
6
+
7
+ const __dirname = path.dirname(import.meta.url.replace('file://', ''));
8
+
9
+ // node index.mjs --character='/Users/a/eliza/characters/trump.character.json'
10
+ const main = async () => {
11
+ dotenv.config();
12
+
13
+ const program = new Command();
14
+
15
+ program
16
+ .option('--character <string>', 'character json file path')
17
+ .parse(process.argv);
18
+
19
+ const options = program.opts();
20
+
21
+ const character = options.character || 'default';
22
+
23
+ const p = path.join(__dirname, 'node_modules', 'mastra', 'dist', 'index.js');
24
+ const cp = child_process.spawn(process.execPath, [p, 'dev'], {
25
+ env: {
26
+ ...process.env,
27
+ CHARACTER_JSON_PATH: character,
28
+ },
29
+ });
30
+ cp.stdout.pipe(process.stdout);
31
+ cp.stderr.pipe(process.stderr);
32
+ };
33
+ (async () => {
34
+ await main();
35
+ })();
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "mastra-starter",
3
- "version": "1.0.0",
4
- "main": "index.js",
3
+ "version": "1.0.1",
4
+ "main": "index.mjs",
5
+ "bin": {
6
+ "mastra-starter": "./index.mjs"
7
+ },
5
8
  "scripts": {
6
9
  "test": "echo \"Error: no test specified\" && exit 1",
7
10
  "dev": "mastra dev"
@@ -15,6 +18,9 @@
15
18
  "@ai-sdk/openai": "^1.2.2",
16
19
  "@mastra/core": "^0.5.0",
17
20
  "@mastra/mcp": "^0.3.0",
21
+ "commander": "^13.1.0",
22
+ "dedent": "^1.5.3",
23
+ "dotenv": "^16.4.7",
18
24
  "mastra": "^0.3.0",
19
25
  "zod": "^3.24.2"
20
26
  },
@@ -1,36 +1,31 @@
1
+ import fs from 'fs';
1
2
  import { openai } from '@ai-sdk/openai';
2
3
  import { Agent } from '@mastra/core/agent';
3
-
4
+ import dedent from 'dedent';
4
5
  import { MCPConfiguration } from "@mastra/mcp";
5
6
 
7
+ const characterJsonPath = process.env.CHARACTER_JSON_PATH as string;
8
+ const characterJsonString = await fs.promises.readFile(characterJsonPath, 'utf8');
9
+ const characterJson = JSON.parse(characterJsonString);
10
+
6
11
  const mcp = new MCPConfiguration({
7
12
  servers: {
8
- // Telegram server configuration
9
- telegram: {
10
- command: "node",
11
- args: ["path/mcp-communicator-telegram/build/index.js"], //please add the correct path
12
- env: {
13
- TELEGRAM_TOKEN: process.env.TELEGRAM_TOKEN!,
14
- CHAT_ID: process.env.CHAT_ID!,
15
- },
16
- },
13
+ // telegram: {
14
+ // command: "node",
15
+ // args: ["path/mcp-communicator-telegram/build/index.js"], //please add the correct path
16
+ // env: {
17
+ // TELEGRAM_TOKEN: process.env.TELEGRAM_TOKEN!,
18
+ // CHAT_ID: process.env.CHAT_ID!,
19
+ // },
20
+ // },
17
21
  },
18
22
  });
19
23
 
20
-
21
-
22
- export const telegramAgent = new Agent({
23
- name: "Telegram Bot",
24
- instructions: `
25
- You are a friendly Telegram bot that provides assistance.
26
-
27
- Your primary function is to help Telegram users. When responding:
28
- - Introduce yourself as a Telegram Bot in your first message
29
- - Keep responses concise and friendly
30
- - Be responsive to Telegram-specific commands like /start and /help
31
-
32
- When users send /start or /help, provide a brief introduction and explain how to use your services.
33
- `,
24
+ export const characterAgent = new Agent({
25
+ name: "Character",
26
+ instructions: dedent`\
27
+ You are the following character:
28
+ ` + '\n' + JSON.stringify(characterJson, null, 2),
34
29
  model: openai("gpt-4o"),
35
30
  tools: { ...(await mcp.getTools()) },
36
31
  });
@@ -2,10 +2,10 @@
2
2
  import { Mastra } from '@mastra/core/mastra';
3
3
  import { createLogger } from '@mastra/core/logger';
4
4
 
5
- import { telegramAgent } from "./agents";
5
+ import { characterAgent } from "./agents";
6
6
 
7
7
  export const mastra = new Mastra({
8
- agents: { telegramAgent },
8
+ agents: { characterAgent },
9
9
  logger: createLogger({
10
10
  name: "Mastra",
11
11
  level: "info",