create-message-kit 1.2.25 → 1.2.27

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -7,7 +7,7 @@ import { default as fs } from "fs-extra";
7
7
  import { isCancel } from "@clack/prompts";
8
8
  import { detect } from "detect-package-manager";
9
9
  import pc from "picocolors";
10
- const defVersion = "1.2.25";
10
+ const defVersion = "1.2.27";
11
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
12
12
 
13
13
  // Read package.json to get the version
@@ -49,6 +49,8 @@ Powered by XMTP`;
49
49
  // Create .gitignore
50
50
  createGitignore(destDir);
51
51
 
52
+ // Create .data directory
53
+ createDataDir(destDir);
52
54
  // Create .env file
53
55
  createEnvFile(destDir);
54
56
 
@@ -77,6 +79,12 @@ Powered by XMTP`;
77
79
 
78
80
  program.parse(process.argv);
79
81
 
82
+ async function createDataDir(destDir) {
83
+ if (!fs.existsSync(resolve(destDir, ".data"))) {
84
+ fs.mkdirSync(resolve(destDir, ".data"));
85
+ }
86
+ }
87
+
80
88
  async function updatePackagejson(destDir, templateType) {
81
89
  // Remove 'templates/' prefix if it exists in templateType
82
90
  const cleanTemplatePath = templateType.replace("templates/", "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.2.25",
3
+ "version": "1.2.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,12 +1,12 @@
1
- # MessageKit Skill Template
1
+ # MessageKit
2
2
 
3
- ## Examples
3
+ # Skill Examples
4
4
 
5
5
  ### Check if a Domain is Available
6
6
 
7
7
 
8
8
  import { ensUrl } from "../index.js";
9
- import { XMTPContext } from "@xmtp/message-kit";
9
+ import { Context } from "@xmtp/message-kit";
10
10
  import type { Skill } from "@xmtp/message-kit";
11
11
 
12
12
  // Define Skill
@@ -25,7 +25,7 @@ export const checkDomain: Skill[] = [
25
25
  ];
26
26
 
27
27
  // Handler Implementation
28
- export async function handler(context: XMTPContext) {
28
+ export async function handler(context: Context) {
29
29
  const {
30
30
  message: {
31
31
  content: {
@@ -55,7 +55,7 @@ export async function handler(context: XMTPContext) {
55
55
  ### Generate a payment request
56
56
 
57
57
 
58
- import { XMTPContext } from "@xmtp/message-kit";
58
+ import { Context } from "@xmtp/message-kit";
59
59
  import type { Skill } from "@xmtp/message-kit";
60
60
 
61
61
  // Define Skill
@@ -92,7 +92,7 @@ export const paymentRequest: Skill[] = [
92
92
  ];
93
93
 
94
94
  // Handler Implementation
95
- export async function handler(context: XMTPContext) {
95
+ export async function handler(context: Context) {
96
96
  const {
97
97
  message: {
98
98
  content: {
@@ -109,70 +109,101 @@ export async function handler(context: XMTPContext) {
109
109
  receiverAddress = address;
110
110
  }
111
111
 
112
- await context.requestPayment(amount, token, receiverAddress);
112
+ await context.requestPayment(receiverAddress, amount, token);
113
113
  }
114
114
 
115
- ## Example final prompt
116
-
117
- Your are a helpful and playful ens agent called @bot that lives inside a messaging app called Converse.
118
-
119
-
120
- # Rules
121
- - You can respond with multiple messages if needed. Each message should be separated by a newline character.
122
- - You can trigger skills by only sending the command in a newline message.
123
- - Each command starts with a slash (/).
124
- - Never announce actions without using a command separated by a newline character.
125
- - Never use markdown in your responses.
126
- - Do not make guesses or assumptions
127
- - Only answer if the verified information is in the prompt.
128
- - Check that you are not missing a command
129
- - Focus only on helping users with operations detailed below.
130
- - Date: Fri, 06 Dec 2024 16:03:22 GMT
131
- - When mentioning any action related to available skills, you MUST trigger the corresponding command in a new line
132
- - If you suggest an action that has a command, you must trigger that command
133
-
134
-
135
- ## User context
136
- - Start by fetch their domain from or Converse username
137
- - Call the user by their name or domain, in case they have one
138
- - Ask for a name (if they don't have one) so you can suggest domains.
139
- - Message sent date: 2024-12-06T16:03:36.582Z
140
- - Users address is: 0x40f08f0f853d1c42c61815652b7ccd5a50f0be09
141
- - Users name is: ArizonaOregon
142
- - Converse username is: ArizonaOregon
143
-
144
- ## Commands
145
- /check [domain] - Check if a domain is available.
146
- /cool [domain] - Get cool alternatives for a .eth domain.
147
- /info [domain] - Get detailed information about an ENS domain including owner, expiry date, and resolver.
148
- /register [domain] - Register a new ENS domain. Returns a URL to complete the registration process.
149
- /renew [domain] - Extend the registration period of your ENS domain. Returns a URL to complete the renewal.
150
- /reset - Reset the conversation clearing memory and usernames cache.
151
- /pay [amount] [token] [username] [address] - Send a specified amount of a cryptocurrency to a destination address.
152
- When tipping, you can asume its 1 usdc.
153
-
154
- ## Examples
155
- /check vitalik.eth
156
- /check fabri.base.eth
157
- /cool vitalik.eth
158
- /info nick.eth
159
- /register vitalik.eth
160
- /renew fabri.base.eth
161
- /reset
162
- /pay 10 vitalik.eth
163
- /pay 1 usdc to 0xC60E6Bb79322392761BFe3081E302aEB79B30B03
164
-
165
- ## Scenarios
166
- 1. Missing commands in responses
167
- **Issue**: Sometimes responses are sent without the required command.
168
- **Example**:
169
- Incorrect:
170
- > "Looks like vitalik.eth is registered! What about these cool alternatives?"
171
- Correct:
172
- > "Looks like vitalik.eth is registered! What about these cool alternatives?
173
- > /cool vitalik.eth"
174
-
175
- Incorrect:
176
- > Here is a summary of your TODOs. I will now send it via email.
177
- Correct:
178
- > /todo
115
+
116
+ # Docs
117
+
118
+ # Structure
119
+
120
+ ## File structure
121
+
122
+ Each app consists of the following files:
123
+
124
+ ```
125
+ agent/
126
+ ├── src/
127
+ │ └── index.ts
128
+ │ └── prompt.ts # Optional
129
+ │ └── plugins/ # Optional
130
+ │ └── ...
131
+ │ └── skills/ # Optional
132
+ │ └── ...
133
+ │ └── vibes/ # Optional
134
+ │ └── ...
135
+ ├── tsconfig.json
136
+ ├── package.json
137
+ └── .env
138
+ ```
139
+
140
+ ## Agent
141
+
142
+ This is the main function that runs the listener.
143
+
144
+ ```jsx
145
+ import { Agent, run, Context } from "@xmtp/message-kit";
146
+
147
+ const agent: Agent = {
148
+ name: "Agent Name",
149
+ tag: "@bot",
150
+ description: "Agent Description",
151
+ skills: [skill1, skill2],
152
+ onMessage: async (context: Context) => {
153
+ /* Logs every message in a conversation.
154
+ If not declared, the agent will automatically use the defined skills.
155
+ Alternatively, you can implement your own logic here. */
156
+ },
157
+ config: {
158
+ // Optional parameters
159
+ },
160
+ };
161
+ //starts the agent
162
+ run(agent);
163
+ ```
164
+
165
+ #### Config parameters
166
+
167
+ - `privateKey`: the private key of the agent wallet, like any normal wallet private key.
168
+ - `experimental`: experimental features like logging all group messages. Default is `false`.
169
+ - `attachments`: to receive attachments. Default is `false`.
170
+ - `gptModel`: model to be used. Default is `gpt-4o`.
171
+ - `client`: Optional parameters to pass to the XMTP client.
172
+ - `agent`: Custom agent to be used. Default is to create the skills in the `src/skills.ts` file.
173
+ - `hideInitLogMessage`: hide the init log message with messagekit logo and stuff
174
+ - `memberChange`: if true, member changes will be enabled, like adding members to the group
175
+
176
+ ## Skills
177
+
178
+ Skills are the actions of the agent. They are defined in the `src/skills/your-skill.ts` file.
179
+
180
+ ```tsx
181
+ import { Skill } from "@xmtp/message-kit";
182
+
183
+ export const checkDomain: Skill[] = [
184
+ {
185
+ skill: // name of the skill
186
+ handler: // function to handle the skill
187
+ examples: // examples of the skill
188
+ description: // description of the skill
189
+ params: // params of the skill
190
+ },
191
+ ];
192
+ ```
193
+
194
+ ## Vibes
195
+
196
+ Vibes are the personalities of the agent. They are defined in the `src/vibes/your-vibe.ts` file.
197
+
198
+ ```tsx
199
+ import { Vibe } from "@xmtp/message-kit";
200
+
201
+ export const chill: Vibe = {
202
+ vibe: // name of the vibe
203
+ description: // description of the vibe
204
+ tone: // tone of the vibe
205
+ style: // style of the vibe
206
+ };
207
+ ```
208
+
209
+ > See [Vibes](/community/vibes) for more information.
@@ -1,19 +1,16 @@
1
1
  import { run, Agent } from "@xmtp/message-kit";
2
- import { systemPrompt } from "./prompt.js";
3
2
  import { checkDomain } from "./skills/check.js";
4
3
  import { cool } from "./skills/cool.js";
5
4
  import { info } from "./skills/info.js";
6
5
  import { register } from "./skills/register.js";
7
6
  import { renew } from "./skills/renew.js";
8
7
  import { pay } from "./skills/pay.js";
9
- import { reset } from "./skills/reset.js";
10
8
 
11
9
  export const agent: Agent = {
12
10
  name: "Ens Agent",
13
11
  tag: "@bot",
14
12
  description: "A ens agent with a lot of skills.",
15
- skills: [checkDomain, cool, info, register, renew, reset, pay],
16
- systemPrompt: systemPrompt,
13
+ skills: [checkDomain, cool, info, register, renew, pay],
17
14
  };
18
15
 
19
16
  run(agent);
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
  import type { Skill } from "@xmtp/message-kit";
3
3
 
4
4
  const ensUrl = "https://app.ens.domains/";
@@ -20,7 +20,7 @@ export const checkDomain: Skill[] = [
20
20
  // [!endregion define]
21
21
 
22
22
  // [!region handle]
23
- export async function handler(context: XMTPContext) {
23
+ export async function handler(context: Context) {
24
24
  const {
25
25
  message: {
26
26
  content: {
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  import type { Skill } from "@xmtp/message-kit";
4
4
 
@@ -15,7 +15,7 @@ export const cool: Skill[] = [
15
15
  },
16
16
  },
17
17
  ];
18
- export async function handler(context: XMTPContext) {
18
+ export async function handler(context: Context) {
19
19
  const {
20
20
  message: {
21
21
  content: {
@@ -1,14 +1,21 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  import type { Skill } from "@xmtp/message-kit";
4
4
 
5
+ // [!region define]
5
6
  export const info: Skill[] = [
6
7
  {
7
8
  skill: "info",
8
9
  handler: handler,
9
10
  description:
10
11
  "Get detailed information about an ENS domain including owner, expiry date, and resolver.",
11
- examples: ["/info nick.eth"],
12
+ examples: [
13
+ "/info humanagent.eth",
14
+ "/info fabri.base.eth",
15
+ "/info @fabri",
16
+ "/info fabri.converse.xyz",
17
+ "/info vitalik.eth",
18
+ ],
12
19
  params: {
13
20
  domain: {
14
21
  type: "string",
@@ -16,8 +23,10 @@ export const info: Skill[] = [
16
23
  },
17
24
  },
18
25
  ];
26
+ // [!endregion define]
19
27
 
20
- export async function handler(context: XMTPContext) {
28
+ // [!region handle]
29
+ export async function handler(context: Context) {
21
30
  const {
22
31
  message: {
23
32
  sender,
@@ -28,15 +37,17 @@ export async function handler(context: XMTPContext) {
28
37
  } = context;
29
38
 
30
39
  const data = await context.getUserInfo(domain);
31
- if (!data?.ensDomain) {
40
+ if (!data?.address) {
32
41
  return {
33
42
  code: 404,
34
43
  message: "Domain not found.",
35
44
  };
36
45
  }
37
- console.log(data);
38
- let message = `Domain information:\n\n`;
39
- message += `URL: https://app.ens.domains/${data?.ensDomain}\n`;
46
+ let message = `Information:\n\n`;
47
+ if (data?.ensDomain)
48
+ message += `URL: https://app.ens.domains/${data?.ensDomain}\n`;
49
+ if (data?.converseUsername)
50
+ message += `Converse: https://converse.xyz/dm/${data?.converseUsername}\n`;
40
51
  if (data?.address) message += `Address: ${data?.address}\n`;
41
52
  if (data?.ensInfo?.avatar) message += `Avatar: ${data?.ensInfo?.avatar}\n`;
42
53
  if (data?.ensInfo?.description)
@@ -47,18 +58,6 @@ export async function handler(context: XMTPContext) {
47
58
  if (data?.ensInfo?.twitter) message += `Twitter: ${data?.ensInfo?.twitter}\n`;
48
59
  message += `\n\nWould you like to tip the domain owner for getting there first 🤣?`;
49
60
  message = message.trim();
50
-
51
- const { v2, v3 } = await context.isOnXMTP(
52
- context.client,
53
- context.v2client,
54
- sender?.address,
55
- );
56
- if (v2 || v3) {
57
- await context.send(
58
- `Ah, this domains is in XMTP, you can message it directly`,
59
- );
60
- await context.sendConverseDmFrame(domain);
61
- }
62
-
63
61
  return { code: 200, message };
64
62
  }
63
+ // [!endregion handle]
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
  import type { Skill } from "@xmtp/message-kit";
3
3
 
4
4
  export const pay: Skill[] = [
@@ -31,11 +31,24 @@ export const pay: Skill[] = [
31
31
  },
32
32
  },
33
33
  },
34
+ {
35
+ skill: "tip",
36
+ examples: ["/tip vitalik.eth"],
37
+ description: "Send 1 usdc.",
38
+ handler: handler,
39
+ params: {
40
+ username: {
41
+ default: "",
42
+ type: "username",
43
+ },
44
+ },
45
+ },
34
46
  ];
35
- export async function handler(context: XMTPContext) {
47
+ export async function handler(context: Context) {
36
48
  const {
37
49
  message: {
38
50
  content: {
51
+ skill,
39
52
  params: { amount, token, username, address },
40
53
  },
41
54
  },
@@ -48,6 +61,10 @@ export async function handler(context: XMTPContext) {
48
61
  //Prioritize address over username
49
62
  receiverAddress = address;
50
63
  }
51
-
52
- await context.requestPayment(amount, token, receiverAddress);
64
+ if (skill === "tip") {
65
+ let tipAmount = 1;
66
+ await context.requestPayment(receiverAddress, tipAmount);
67
+ } else if (skill === "pay") {
68
+ await context.requestPayment(receiverAddress, amount, token);
69
+ }
53
70
  }
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  const ensUrl = "https://app.ens.domains/";
4
4
  import type { Skill } from "@xmtp/message-kit";
@@ -18,7 +18,7 @@ export const register: Skill[] = [
18
18
  },
19
19
  ];
20
20
 
21
- export async function handler(context: XMTPContext) {
21
+ export async function handler(context: Context) {
22
22
  const {
23
23
  message: {
24
24
  content: {
@@ -1,4 +1,4 @@
1
- import { XMTPContext } from "@xmtp/message-kit";
1
+ import { Context } from "@xmtp/message-kit";
2
2
 
3
3
  import type { Skill } from "@xmtp/message-kit";
4
4
 
@@ -19,7 +19,7 @@ export const renew: Skill[] = [
19
19
  },
20
20
  ];
21
21
 
22
- export async function handler(context: XMTPContext) {
22
+ export async function handler(context: Context) {
23
23
  const {
24
24
  message: {
25
25
  sender,
@@ -1,12 +1,12 @@
1
- # MessageKit Skill Template
1
+ # MessageKit
2
2
 
3
- ## Examples
3
+ # Skill Examples
4
4
 
5
5
  ### Check if a Domain is Available
6
6
 
7
7
 
8
8
  import { ensUrl } from "../index.js";
9
- import { XMTPContext } from "@xmtp/message-kit";
9
+ import { Context } from "@xmtp/message-kit";
10
10
  import type { Skill } from "@xmtp/message-kit";
11
11
 
12
12
  // Define Skill
@@ -25,7 +25,7 @@ export const checkDomain: Skill[] = [
25
25
  ];
26
26
 
27
27
  // Handler Implementation
28
- export async function handler(context: XMTPContext) {
28
+ export async function handler(context: Context) {
29
29
  const {
30
30
  message: {
31
31
  content: {
@@ -55,7 +55,7 @@ export async function handler(context: XMTPContext) {
55
55
  ### Generate a payment request
56
56
 
57
57
 
58
- import { XMTPContext } from "@xmtp/message-kit";
58
+ import { Context } from "@xmtp/message-kit";
59
59
  import type { Skill } from "@xmtp/message-kit";
60
60
 
61
61
  // Define Skill
@@ -92,7 +92,7 @@ export const paymentRequest: Skill[] = [
92
92
  ];
93
93
 
94
94
  // Handler Implementation
95
- export async function handler(context: XMTPContext) {
95
+ export async function handler(context: Context) {
96
96
  const {
97
97
  message: {
98
98
  content: {
@@ -109,70 +109,101 @@ export async function handler(context: XMTPContext) {
109
109
  receiverAddress = address;
110
110
  }
111
111
 
112
- await context.requestPayment(amount, token, receiverAddress);
112
+ await context.requestPayment(receiverAddress, amount, token);
113
113
  }
114
114
 
115
- ## Example final prompt
116
-
117
- Your are a helpful and playful ens agent called @bot that lives inside a messaging app called Converse.
118
-
119
-
120
- # Rules
121
- - You can respond with multiple messages if needed. Each message should be separated by a newline character.
122
- - You can trigger skills by only sending the command in a newline message.
123
- - Each command starts with a slash (/).
124
- - Never announce actions without using a command separated by a newline character.
125
- - Never use markdown in your responses.
126
- - Do not make guesses or assumptions
127
- - Only answer if the verified information is in the prompt.
128
- - Check that you are not missing a command
129
- - Focus only on helping users with operations detailed below.
130
- - Date: Fri, 06 Dec 2024 16:03:22 GMT
131
- - When mentioning any action related to available skills, you MUST trigger the corresponding command in a new line
132
- - If you suggest an action that has a command, you must trigger that command
133
-
134
-
135
- ## User context
136
- - Start by fetch their domain from or Converse username
137
- - Call the user by their name or domain, in case they have one
138
- - Ask for a name (if they don't have one) so you can suggest domains.
139
- - Message sent date: 2024-12-06T16:03:36.582Z
140
- - Users address is: 0x40f08f0f853d1c42c61815652b7ccd5a50f0be09
141
- - Users name is: ArizonaOregon
142
- - Converse username is: ArizonaOregon
143
-
144
- ## Commands
145
- /check [domain] - Check if a domain is available.
146
- /cool [domain] - Get cool alternatives for a .eth domain.
147
- /info [domain] - Get detailed information about an ENS domain including owner, expiry date, and resolver.
148
- /register [domain] - Register a new ENS domain. Returns a URL to complete the registration process.
149
- /renew [domain] - Extend the registration period of your ENS domain. Returns a URL to complete the renewal.
150
- /reset - Reset the conversation clearing memory and usernames cache.
151
- /pay [amount] [token] [username] [address] - Send a specified amount of a cryptocurrency to a destination address.
152
- When tipping, you can asume its 1 usdc.
153
-
154
- ## Examples
155
- /check vitalik.eth
156
- /check fabri.base.eth
157
- /cool vitalik.eth
158
- /info nick.eth
159
- /register vitalik.eth
160
- /renew fabri.base.eth
161
- /reset
162
- /pay 10 vitalik.eth
163
- /pay 1 usdc to 0xC60E6Bb79322392761BFe3081E302aEB79B30B03
164
-
165
- ## Scenarios
166
- 1. Missing commands in responses
167
- **Issue**: Sometimes responses are sent without the required command.
168
- **Example**:
169
- Incorrect:
170
- > "Looks like vitalik.eth is registered! What about these cool alternatives?"
171
- Correct:
172
- > "Looks like vitalik.eth is registered! What about these cool alternatives?
173
- > /cool vitalik.eth"
174
-
175
- Incorrect:
176
- > Here is a summary of your TODOs. I will now send it via email.
177
- Correct:
178
- > /todo
115
+
116
+ # Docs
117
+
118
+ # Structure
119
+
120
+ ## File structure
121
+
122
+ Each app consists of the following files:
123
+
124
+ ```
125
+ agent/
126
+ ├── src/
127
+ │ └── index.ts
128
+ │ └── prompt.ts # Optional
129
+ │ └── plugins/ # Optional
130
+ │ └── ...
131
+ │ └── skills/ # Optional
132
+ │ └── ...
133
+ │ └── vibes/ # Optional
134
+ │ └── ...
135
+ ├── tsconfig.json
136
+ ├── package.json
137
+ └── .env
138
+ ```
139
+
140
+ ## Agent
141
+
142
+ This is the main function that runs the listener.
143
+
144
+ ```jsx
145
+ import { Agent, run, Context } from "@xmtp/message-kit";
146
+
147
+ const agent: Agent = {
148
+ name: "Agent Name",
149
+ tag: "@bot",
150
+ description: "Agent Description",
151
+ skills: [skill1, skill2],
152
+ onMessage: async (context: Context) => {
153
+ /* Logs every message in a conversation.
154
+ If not declared, the agent will automatically use the defined skills.
155
+ Alternatively, you can implement your own logic here. */
156
+ },
157
+ config: {
158
+ // Optional parameters
159
+ },
160
+ };
161
+ //starts the agent
162
+ run(agent);
163
+ ```
164
+
165
+ #### Config parameters
166
+
167
+ - `privateKey`: the private key of the agent wallet, like any normal wallet private key.
168
+ - `experimental`: experimental features like logging all group messages. Default is `false`.
169
+ - `attachments`: to receive attachments. Default is `false`.
170
+ - `gptModel`: model to be used. Default is `gpt-4o`.
171
+ - `client`: Optional parameters to pass to the XMTP client.
172
+ - `agent`: Custom agent to be used. Default is to create the skills in the `src/skills.ts` file.
173
+ - `hideInitLogMessage`: hide the init log message with messagekit logo and stuff
174
+ - `memberChange`: if true, member changes will be enabled, like adding members to the group
175
+
176
+ ## Skills
177
+
178
+ Skills are the actions of the agent. They are defined in the `src/skills/your-skill.ts` file.
179
+
180
+ ```tsx
181
+ import { Skill } from "@xmtp/message-kit";
182
+
183
+ export const checkDomain: Skill[] = [
184
+ {
185
+ skill: // name of the skill
186
+ handler: // function to handle the skill
187
+ examples: // examples of the skill
188
+ description: // description of the skill
189
+ params: // params of the skill
190
+ },
191
+ ];
192
+ ```
193
+
194
+ ## Vibes
195
+
196
+ Vibes are the personalities of the agent. They are defined in the `src/vibes/your-vibe.ts` file.
197
+
198
+ ```tsx
199
+ import { Vibe } from "@xmtp/message-kit";
200
+
201
+ export const chill: Vibe = {
202
+ vibe: // name of the vibe
203
+ description: // description of the vibe
204
+ tone: // tone of the vibe
205
+ style: // style of the vibe
206
+ };
207
+ ```
208
+
209
+ > See [Vibes](/community/vibes) for more information.
@@ -1,25 +1,16 @@
1
- import {
2
- run,
3
- agentReply,
4
- replaceVariables,
5
- XMTPContext,
6
- Agent,
7
- } from "@xmtp/message-kit";
8
- import { systemPrompt } from "./prompt.js";
1
+ // [!region index]
2
+ import { run, agentReply, Context, Agent } from "@xmtp/message-kit";
9
3
 
10
4
  export const agent: Agent = {
11
5
  name: "GPT Bot",
12
- tag: "@bot",
13
6
  description: "Use GPT to generate text responses.",
14
- onMessage: async (context: XMTPContext) => {
15
- const {
16
- message: { sender },
17
- agent,
18
- } = context;
19
-
20
- let prompt = await replaceVariables(systemPrompt, sender.address, agent);
21
- await agentReply(context, prompt);
7
+ tag: "@bot",
8
+ onMessage: async (context: Context) => {
9
+ // [!endregion index]
10
+ await agentReply(context);
11
+ // [!region final]
22
12
  },
23
13
  };
24
14
 
25
15
  run(agent);
16
+ // [!endregion final]
@@ -1,11 +0,0 @@
1
- export const systemPrompt = `
2
- {vibe}
3
-
4
- {rules}
5
-
6
- {user_context}
7
-
8
- {skills}
9
-
10
- {issues}
11
- `;
@@ -1,25 +0,0 @@
1
- import { clearInfoCache, clearMemory } from "@xmtp/message-kit";
2
- import { XMTPContext } from "@xmtp/message-kit";
3
-
4
- import type { Skill } from "@xmtp/message-kit";
5
-
6
- export const reset: Skill[] = [
7
- {
8
- skill: "reset",
9
- examples: ["/reset"],
10
- handler: handler,
11
- description: "Reset the conversation clearing memory and usernames cache.",
12
- },
13
- ];
14
- export async function handler(context: XMTPContext) {
15
- const {
16
- message: { sender },
17
- } = context;
18
- try {
19
- clearMemory(sender.address);
20
- clearInfoCache(sender.address);
21
- return { code: 200, message: "Memory and usernames cache cleared." };
22
- } catch (error) {
23
- return { code: 500, message: "Error clearing memory and usernames cache." };
24
- }
25
- }
@@ -1 +0,0 @@
1
-
@@ -1,9 +0,0 @@
1
- export const systemPrompt = `
2
- You are a helpful and playful agent called {agent_name} that lives inside a web3 messaging app called Converse.
3
-
4
- {rules}
5
-
6
- {user_context}
7
-
8
- {issues}
9
- `;