create-message-kit 1.2.31 → 1.2.33

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -3,10 +3,11 @@ import { program } from "commander";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { log, outro, text, select } from "@clack/prompts";
6
+ import { default as fs } from "fs-extra";
6
7
  import { isCancel } from "@clack/prompts";
7
8
  import { detect } from "detect-package-manager";
8
9
  import pc from "picocolors";
9
- const defVersion = "1.2.31";
10
+ const defVersion = "1.2.33";
10
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
11
12
 
12
13
  // Read package.json to get the version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.2.31",
3
+ "version": "1.2.33",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,209 +0,0 @@
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.
@@ -1,4 +1,4 @@
1
- import { Context, getUserInfo, Skill } from "@xmtp/message-kit";
1
+ import { Context, FrameKit, getUserInfo, Skill } from "@xmtp/message-kit";
2
2
 
3
3
  export const pay: Skill[] = [
4
4
  {
@@ -24,10 +24,6 @@ export const pay: Skill[] = [
24
24
  default: "",
25
25
  type: "username",
26
26
  },
27
- address: {
28
- default: "",
29
- type: "address",
30
- },
31
27
  },
32
28
  },
33
29
  {
@@ -48,22 +44,17 @@ export async function handler(context: Context) {
48
44
  message: {
49
45
  content: {
50
46
  skill,
51
- params: { amount, token, username, address },
47
+ params: { amount, token, username },
52
48
  },
53
49
  },
54
50
  } = context;
55
- let receiverAddress = address;
56
- if (username) {
57
- receiverAddress = (await getUserInfo(username))?.address;
58
- }
59
- if (address) {
60
- //Prioritize address over username
61
- receiverAddress = address;
62
- }
51
+ let receiverAddress = username?.address;
63
52
  if (skill === "tip") {
64
53
  let tipAmount = 1;
65
- await context.framekit.requestPayment(receiverAddress, tipAmount);
54
+ const url = await FrameKit.requestPayment(receiverAddress, tipAmount);
55
+ await context.dm(url);
66
56
  } else if (skill === "pay") {
67
- await context.framekit.requestPayment(receiverAddress, amount, token);
57
+ const url = await FrameKit.requestPayment(receiverAddress, amount, token);
58
+ await context.dm(url);
68
59
  }
69
60
  }
@@ -1,209 +0,0 @@
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.
@@ -1,209 +0,0 @@
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.