create-message-kit 1.2.25 → 1.2.27
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.js +9 -1
- package/package.json +1 -1
- package/templates/ens/.cursorrules +102 -71
- package/templates/ens/src/index.ts +1 -4
- package/templates/ens/src/skills/check.ts +2 -2
- package/templates/ens/src/skills/cool.ts +2 -2
- package/templates/ens/src/skills/info.ts +19 -20
- package/templates/ens/src/skills/pay.ts +21 -4
- package/templates/ens/src/skills/register.ts +2 -2
- package/templates/ens/src/skills/renew.ts +2 -2
- package/templates/simple/.cursorrules +102 -71
- package/templates/simple/src/index.ts +8 -17
- package/templates/ens/src/prompt.ts +0 -11
- package/templates/ens/src/skills/reset.ts +0 -25
- package/templates/ens/src/skills/weather.ts +0 -1
- package/templates/simple/src/prompt.ts +0 -9
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.
|
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,12 +1,12 @@
|
|
1
|
-
# MessageKit
|
1
|
+
# MessageKit
|
2
2
|
|
3
|
-
|
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 {
|
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:
|
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 {
|
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:
|
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
|
112
|
+
await context.requestPayment(receiverAddress, amount, token);
|
113
113
|
}
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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,
|
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 {
|
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:
|
23
|
+
export async function handler(context: Context) {
|
24
24
|
const {
|
25
25
|
message: {
|
26
26
|
content: {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
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:
|
18
|
+
export async function handler(context: Context) {
|
19
19
|
const {
|
20
20
|
message: {
|
21
21
|
content: {
|
@@ -1,14 +1,21 @@
|
|
1
|
-
import {
|
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: [
|
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
|
-
|
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?.
|
40
|
+
if (!data?.address) {
|
32
41
|
return {
|
33
42
|
code: 404,
|
34
43
|
message: "Domain not found.",
|
35
44
|
};
|
36
45
|
}
|
37
|
-
|
38
|
-
|
39
|
-
|
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 {
|
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:
|
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
|
-
|
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 {
|
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:
|
21
|
+
export async function handler(context: Context) {
|
22
22
|
const {
|
23
23
|
message: {
|
24
24
|
content: {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
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:
|
22
|
+
export async function handler(context: Context) {
|
23
23
|
const {
|
24
24
|
message: {
|
25
25
|
sender,
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# MessageKit
|
1
|
+
# MessageKit
|
2
2
|
|
3
|
-
|
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 {
|
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:
|
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 {
|
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:
|
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
|
112
|
+
await context.requestPayment(receiverAddress, amount, token);
|
113
113
|
}
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
2
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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,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
|
-
|