create-message-kit 1.2.27 → 1.2.29
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 +5 -1
- package/package.json +1 -1
- package/templates/ens/.cursorrules +3 -3
- package/templates/ens/src/skills/check.ts +2 -3
- package/templates/ens/src/skills/info.ts +2 -4
- package/templates/ens/src/skills/pay.ts +4 -5
- package/templates/ens/src/skills/renew.ts +2 -4
- package/templates/paymentagent/.cursorrules +209 -0
- package/templates/paymentagent/.env.example +2 -0
- package/templates/paymentagent/.yarnrc.yml +9 -0
- package/templates/paymentagent/package.json +21 -0
- package/templates/paymentagent/src/index.ts +19 -0
- package/templates/paymentagent/src/prompt.ts +10 -0
- package/templates/paymentagent/src/vibes/degen.ts +10 -0
- package/templates/simple/.cursorrules +3 -3
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.29";
|
11
11
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
12
12
|
|
13
13
|
// Read package.json to get the version
|
@@ -113,6 +113,10 @@ async function gatherProjectInfo() {
|
|
113
113
|
value: "templates/ens",
|
114
114
|
label: "ENS - Template with ENS integration",
|
115
115
|
},
|
116
|
+
{
|
117
|
+
value: "templates/paymentagent",
|
118
|
+
label: "Payment Agent - Template for funding an agent wallet",
|
119
|
+
},
|
116
120
|
];
|
117
121
|
|
118
122
|
const templateType = await select({
|
package/package.json
CHANGED
@@ -34,7 +34,7 @@ export async function handler(context: Context) {
|
|
34
34
|
},
|
35
35
|
} = context;
|
36
36
|
|
37
|
-
const data = await
|
37
|
+
const data = await getUserInfo(domain);
|
38
38
|
|
39
39
|
if (!data?.address) {
|
40
40
|
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
|
@@ -102,14 +102,14 @@ export async function handler(context: Context) {
|
|
102
102
|
} = context;
|
103
103
|
let receiverAddress = address;
|
104
104
|
if (username) {
|
105
|
-
receiverAddress = (await
|
105
|
+
receiverAddress = (await getUserInfo(username))?.address;
|
106
106
|
}
|
107
107
|
if (address) {
|
108
108
|
// Prioritize address over username
|
109
109
|
receiverAddress = address;
|
110
110
|
}
|
111
111
|
|
112
|
-
await context.requestPayment(receiverAddress, amount, token);
|
112
|
+
await context.framekit.requestPayment(receiverAddress, amount, token);
|
113
113
|
}
|
114
114
|
|
115
115
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { Context } from "@xmtp/message-kit";
|
2
|
-
import type { Skill } from "@xmtp/message-kit";
|
1
|
+
import { Context, getUserInfo, Skill } from "@xmtp/message-kit";
|
3
2
|
|
4
3
|
const ensUrl = "https://app.ens.domains/";
|
5
4
|
|
@@ -29,7 +28,7 @@ export async function handler(context: Context) {
|
|
29
28
|
},
|
30
29
|
} = context;
|
31
30
|
|
32
|
-
const data = await
|
31
|
+
const data = await getUserInfo(domain);
|
33
32
|
|
34
33
|
if (!data?.address) {
|
35
34
|
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
|
@@ -1,6 +1,4 @@
|
|
1
|
-
import { Context } from "@xmtp/message-kit";
|
2
|
-
|
3
|
-
import type { Skill } from "@xmtp/message-kit";
|
1
|
+
import { Context, getUserInfo, Skill } from "@xmtp/message-kit";
|
4
2
|
|
5
3
|
// [!region define]
|
6
4
|
export const info: Skill[] = [
|
@@ -36,7 +34,7 @@ export async function handler(context: Context) {
|
|
36
34
|
},
|
37
35
|
} = context;
|
38
36
|
|
39
|
-
const data = await
|
37
|
+
const data = await getUserInfo(domain);
|
40
38
|
if (!data?.address) {
|
41
39
|
return {
|
42
40
|
code: 404,
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { Context } from "@xmtp/message-kit";
|
2
|
-
import type { Skill } from "@xmtp/message-kit";
|
1
|
+
import { Context, getUserInfo, Skill } from "@xmtp/message-kit";
|
3
2
|
|
4
3
|
export const pay: Skill[] = [
|
5
4
|
{
|
@@ -55,7 +54,7 @@ export async function handler(context: Context) {
|
|
55
54
|
} = context;
|
56
55
|
let receiverAddress = address;
|
57
56
|
if (username) {
|
58
|
-
receiverAddress = (await
|
57
|
+
receiverAddress = (await getUserInfo(username))?.address;
|
59
58
|
}
|
60
59
|
if (address) {
|
61
60
|
//Prioritize address over username
|
@@ -63,8 +62,8 @@ export async function handler(context: Context) {
|
|
63
62
|
}
|
64
63
|
if (skill === "tip") {
|
65
64
|
let tipAmount = 1;
|
66
|
-
await context.requestPayment(receiverAddress, tipAmount);
|
65
|
+
await context.framekit.requestPayment(receiverAddress, tipAmount);
|
67
66
|
} else if (skill === "pay") {
|
68
|
-
await context.requestPayment(receiverAddress, amount, token);
|
67
|
+
await context.framekit.requestPayment(receiverAddress, amount, token);
|
69
68
|
}
|
70
69
|
}
|
@@ -1,6 +1,4 @@
|
|
1
|
-
import { Context } from "@xmtp/message-kit";
|
2
|
-
|
3
|
-
import type { Skill } from "@xmtp/message-kit";
|
1
|
+
import { Context, getUserInfo, Skill } from "@xmtp/message-kit";
|
4
2
|
|
5
3
|
const frameUrl = "https://ens.steer.fun/";
|
6
4
|
|
@@ -37,7 +35,7 @@ export async function handler(context: Context) {
|
|
37
35
|
};
|
38
36
|
}
|
39
37
|
|
40
|
-
const data = await
|
38
|
+
const data = await getUserInfo(domain);
|
41
39
|
|
42
40
|
if (!data?.address || data?.address !== sender?.address) {
|
43
41
|
return {
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# MessageKit
|
2
|
+
|
3
|
+
# Skill Examples
|
4
|
+
|
5
|
+
### Check if a Domain is Available
|
6
|
+
|
7
|
+
|
8
|
+
import { ensUrl } from "../index.js";
|
9
|
+
import { Context } from "@xmtp/message-kit";
|
10
|
+
import type { Skill } from "@xmtp/message-kit";
|
11
|
+
|
12
|
+
// Define Skill
|
13
|
+
export const checkDomain: Skill[] = [
|
14
|
+
{
|
15
|
+
skill: "check",
|
16
|
+
handler: handler,
|
17
|
+
examples: ["/check vitalik.eth", "/check fabri.base.eth"],
|
18
|
+
description: "Check if a domain is available.",
|
19
|
+
params: {
|
20
|
+
domain: {
|
21
|
+
type: "string",
|
22
|
+
},
|
23
|
+
},
|
24
|
+
},
|
25
|
+
];
|
26
|
+
|
27
|
+
// Handler Implementation
|
28
|
+
export async function handler(context: Context) {
|
29
|
+
const {
|
30
|
+
message: {
|
31
|
+
content: {
|
32
|
+
params: { domain },
|
33
|
+
},
|
34
|
+
},
|
35
|
+
} = context;
|
36
|
+
|
37
|
+
const data = await getUserInfo(domain);
|
38
|
+
|
39
|
+
if (!data?.address) {
|
40
|
+
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
|
41
|
+
return {
|
42
|
+
code: 200,
|
43
|
+
message,
|
44
|
+
};
|
45
|
+
} else {
|
46
|
+
let message = `Looks like ${domain} is already registered!`;
|
47
|
+
await context.executeSkill("/cool " + domain);
|
48
|
+
return {
|
49
|
+
code: 404,
|
50
|
+
message,
|
51
|
+
};
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
### Generate a payment request
|
56
|
+
|
57
|
+
|
58
|
+
import { Context } from "@xmtp/message-kit";
|
59
|
+
import type { Skill } from "@xmtp/message-kit";
|
60
|
+
|
61
|
+
// Define Skill
|
62
|
+
export const paymentRequest: Skill[] = [
|
63
|
+
{
|
64
|
+
skill: "pay",
|
65
|
+
examples: [
|
66
|
+
"/pay 10 vitalik.eth",
|
67
|
+
"/pay 1 usdc to 0xC60E6Bb79322392761BFe3081E302aEB79B30B03",
|
68
|
+
],
|
69
|
+
description:
|
70
|
+
"Send a specified amount of a cryptocurrency to a destination address. \nWhen tipping, you can assume it's 1 USDC.",
|
71
|
+
handler: handler,
|
72
|
+
params: {
|
73
|
+
amount: {
|
74
|
+
default: 10,
|
75
|
+
type: "number",
|
76
|
+
},
|
77
|
+
token: {
|
78
|
+
default: "usdc",
|
79
|
+
type: "string",
|
80
|
+
values: ["eth", "dai", "usdc", "degen"], // Accepted tokens
|
81
|
+
},
|
82
|
+
username: {
|
83
|
+
default: "",
|
84
|
+
type: "username",
|
85
|
+
},
|
86
|
+
address: {
|
87
|
+
default: "",
|
88
|
+
type: "address",
|
89
|
+
},
|
90
|
+
},
|
91
|
+
},
|
92
|
+
];
|
93
|
+
|
94
|
+
// Handler Implementation
|
95
|
+
export async function handler(context: Context) {
|
96
|
+
const {
|
97
|
+
message: {
|
98
|
+
content: {
|
99
|
+
params: { amount, token, username, address },
|
100
|
+
},
|
101
|
+
},
|
102
|
+
} = context;
|
103
|
+
let receiverAddress = address;
|
104
|
+
if (username) {
|
105
|
+
receiverAddress = (await getUserInfo(username))?.address;
|
106
|
+
}
|
107
|
+
if (address) {
|
108
|
+
// Prioritize address over username
|
109
|
+
receiverAddress = address;
|
110
|
+
}
|
111
|
+
|
112
|
+
await context.framekit.requestPayment(receiverAddress, amount, token);
|
113
|
+
}
|
114
|
+
|
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.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "paymentagent",
|
3
|
+
"private": true,
|
4
|
+
"description": "A human agent for managing your funds",
|
5
|
+
"type": "module",
|
6
|
+
"scripts": {
|
7
|
+
"build": "tsc",
|
8
|
+
"dev": "tsc -w & sleep 1 && NODE_NO_WARNINGS=1 node --watch dist/index.js",
|
9
|
+
"start": "node dist/index.js"
|
10
|
+
},
|
11
|
+
"dependencies": {
|
12
|
+
"@xmtp/message-kit": "workspace:*"
|
13
|
+
},
|
14
|
+
"devDependencies": {
|
15
|
+
"@types/node": "^20.14.2",
|
16
|
+
"typescript": "^5.4.5"
|
17
|
+
},
|
18
|
+
"engines": {
|
19
|
+
"node": ">=20"
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { run, Agent, concierge } from "@xmtp/message-kit";
|
2
|
+
import { degen } from "./vibes/degen.js";
|
3
|
+
import { systemPrompt } from "./prompt.js";
|
4
|
+
|
5
|
+
const agent: Agent = {
|
6
|
+
name: "Human Agent",
|
7
|
+
tag: "@bot",
|
8
|
+
description: "An agent that performs payments and transfers in usdc. .",
|
9
|
+
intro:
|
10
|
+
"You are a helpful agent called {agent_name} that helps people with their agent wallets. You can help them fund their wallets, check their balance and making transfers. All in usdc.",
|
11
|
+
vibe: degen,
|
12
|
+
systemPrompt,
|
13
|
+
skills: [concierge],
|
14
|
+
config: {
|
15
|
+
walletService: true,
|
16
|
+
},
|
17
|
+
};
|
18
|
+
|
19
|
+
run(agent);
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Vibe } from "@xmtp/message-kit";
|
2
|
+
|
3
|
+
export const degen: Vibe = {
|
4
|
+
vibe: "Degen",
|
5
|
+
description:
|
6
|
+
"A high-energy, risk-embracing personality from the crypto trading world. This vibe combines technical knowledge with meme culture, FOMO-driven enthusiasm, and an 'apes together strong' mentality. Always bullish, never sleeping, and ready to APE into the next big thing.",
|
7
|
+
tone: "enthusiastic and bold, like a trader who just discovered a 100x gem at 3AM",
|
8
|
+
style:
|
9
|
+
"casual and meme-heavy, peppered with crypto slang like 'gm', 'wagmi', and 'probably nothing', while maintaining genuine helpfulness",
|
10
|
+
};
|
@@ -34,7 +34,7 @@ export async function handler(context: Context) {
|
|
34
34
|
},
|
35
35
|
} = context;
|
36
36
|
|
37
|
-
const data = await
|
37
|
+
const data = await getUserInfo(domain);
|
38
38
|
|
39
39
|
if (!data?.address) {
|
40
40
|
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
|
@@ -102,14 +102,14 @@ export async function handler(context: Context) {
|
|
102
102
|
} = context;
|
103
103
|
let receiverAddress = address;
|
104
104
|
if (username) {
|
105
|
-
receiverAddress = (await
|
105
|
+
receiverAddress = (await getUserInfo(username))?.address;
|
106
106
|
}
|
107
107
|
if (address) {
|
108
108
|
// Prioritize address over username
|
109
109
|
receiverAddress = address;
|
110
110
|
}
|
111
111
|
|
112
|
-
await context.requestPayment(receiverAddress, amount, token);
|
112
|
+
await context.framekit.requestPayment(receiverAddress, amount, token);
|
113
113
|
}
|
114
114
|
|
115
115
|
|