create-message-kit 1.1.8-beta.1 → 1.1.8-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +17 -6
- package/package.json +1 -1
- package/templates/agent/src/handler/ens.ts +5 -6
- package/templates/agent/src/prompt.ts +4 -4
- package/templates/agent/src/skills.ts +0 -7
- package/templates/gpt/.env.example +2 -0
- package/templates/gpt/src/index.ts +37 -0
- package/templates/gpt/src/prompt.ts +20 -0
- package/templates/group/src/handler/payment.ts +2 -2
- package/templates/group/src/prompt.ts +1 -1
- package/templates/group/src/skills.ts +1 -6
- package/templates/gm/.env.example +0 -1
- package/templates/gm/src/index.ts +0 -5
package/index.js
CHANGED
@@ -84,8 +84,8 @@ async function addPackagejson(destDir, name, pkgManager) {
|
|
84
84
|
},
|
85
85
|
};
|
86
86
|
|
87
|
-
if (pkgManager.
|
88
|
-
packageTemplate.packageManager = `${pkgManager}`;
|
87
|
+
if (pkgManager.includes("yarn")) {
|
88
|
+
//packageTemplate.packageManager = `${pkgManager}`;
|
89
89
|
// Add .yarnrc.yml to disable PnP mode
|
90
90
|
}
|
91
91
|
|
@@ -101,7 +101,7 @@ async function addPackagejson(destDir, name, pkgManager) {
|
|
101
101
|
|
102
102
|
async function gatherProjectInfo() {
|
103
103
|
const templateOptions = [
|
104
|
-
{ value: "
|
104
|
+
{ value: "gpt", label: "GPT" },
|
105
105
|
{ value: "agent", label: "Agent" },
|
106
106
|
{ value: "group", label: "Group" },
|
107
107
|
];
|
@@ -203,11 +203,23 @@ yarn-error.log*
|
|
203
203
|
|
204
204
|
fs.writeFileSync(resolve(destDir, ".gitignore"), gitignoreContent.trim());
|
205
205
|
}
|
206
|
-
|
207
206
|
async function detectPackageManager() {
|
208
207
|
try {
|
209
|
-
|
208
|
+
// Check for npm_config_user_agent first
|
210
209
|
const userAgent = process.env.npm_config_user_agent;
|
210
|
+
|
211
|
+
// Check if running through bun create
|
212
|
+
if (process.env.BUN_CREATE === "true") {
|
213
|
+
return "bun";
|
214
|
+
}
|
215
|
+
|
216
|
+
// Check if running through npm init
|
217
|
+
if (userAgent?.startsWith("npm")) {
|
218
|
+
return "npm";
|
219
|
+
}
|
220
|
+
|
221
|
+
// Fallback to detect for other cases
|
222
|
+
const pkgManager = await detect();
|
211
223
|
let version = "";
|
212
224
|
|
213
225
|
if (userAgent && pkgManager === "yarn") {
|
@@ -223,7 +235,6 @@ async function detectPackageManager() {
|
|
223
235
|
return "npm";
|
224
236
|
}
|
225
237
|
}
|
226
|
-
|
227
238
|
function kebabcase(str) {
|
228
239
|
return str
|
229
240
|
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
package/package.json
CHANGED
@@ -5,7 +5,7 @@ import { clearMemory } from "@xmtp/message-kit";
|
|
5
5
|
|
6
6
|
export const frameUrl = "https://ens.steer.fun/";
|
7
7
|
export const ensUrl = "https://app.ens.domains/";
|
8
|
-
export const
|
8
|
+
export const txpayUrl = "https://txpay.vercel.app";
|
9
9
|
|
10
10
|
export async function handleEns(
|
11
11
|
context: HandlerContext,
|
@@ -128,13 +128,12 @@ export async function handleEns(
|
|
128
128
|
};
|
129
129
|
}
|
130
130
|
const data = await getUserInfo(address);
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
console.log(txUrl);
|
131
|
+
|
132
|
+
let sendUrl = `${txpayUrl}/?&amount=1&token=USDC&receiver=${address}`;
|
133
|
+
|
135
134
|
return {
|
136
135
|
code: 200,
|
137
|
-
message:
|
136
|
+
message: sendUrl,
|
138
137
|
};
|
139
138
|
} else if (skill == "cool") {
|
140
139
|
const { domain } = params;
|
@@ -2,7 +2,7 @@ import { skills } from "./skills.js";
|
|
2
2
|
import { defaultPromptTemplate } from "@xmtp/message-kit";
|
3
3
|
|
4
4
|
export async function agent_prompt(senderAddress: string) {
|
5
|
-
let
|
5
|
+
let fineTuning = `
|
6
6
|
## Example responses:
|
7
7
|
|
8
8
|
1. Check if the user does not have a ENS domain
|
@@ -23,8 +23,8 @@ export async function agent_prompt(senderAddress: string) {
|
|
23
23
|
6. If the user wants to register a ENS domain, use the command "/register [domain]"
|
24
24
|
Looks like {ENS_DOMAIN} is available! Let me help you register it\n/register {ENS_DOMAIN}
|
25
25
|
|
26
|
-
7. If the user wants to directly to tip to the ENS domain owner, use directly the command "/tip [
|
27
|
-
Here is the url to send the tip:\n/tip
|
26
|
+
7. If the user wants to directly to tip to the ENS domain owner, use directly the command "/tip [address]", this will return a url but a button to send the tip
|
27
|
+
Here is the url to send the tip:\n/tip 0x...
|
28
28
|
|
29
29
|
8. If the user wants to get information about the ENS domain, use the command "/info [domain]"
|
30
30
|
Hello! I'll help you get info about {ENS_DOMAIN}.\n Give me a moment.\n/info {ENS_DOMAIN}
|
@@ -42,5 +42,5 @@ export async function agent_prompt(senderAddress: string) {
|
|
42
42
|
You should have said something like: "Looks like vitalik.eth is registered! What about these cool alternatives?\n/cool vitalik.eth
|
43
43
|
`;
|
44
44
|
|
45
|
-
return defaultPromptTemplate(
|
45
|
+
return defaultPromptTemplate(fineTuning, senderAddress, skills, "@ens");
|
46
46
|
}
|
@@ -9,7 +9,6 @@ export const skills: SkillGroup[] = [
|
|
9
9
|
skills: [
|
10
10
|
{
|
11
11
|
skill: "/register [domain]",
|
12
|
-
triggers: ["/register"],
|
13
12
|
handler: handleEns,
|
14
13
|
description:
|
15
14
|
"Register a new ENS domain. Returns a URL to complete the registration process.",
|
@@ -22,7 +21,6 @@ export const skills: SkillGroup[] = [
|
|
22
21
|
},
|
23
22
|
{
|
24
23
|
skill: "/info [domain]",
|
25
|
-
triggers: ["/info"],
|
26
24
|
handler: handleEns,
|
27
25
|
description:
|
28
26
|
"Get detailed information about an ENS domain including owner, expiry date, and resolver.",
|
@@ -35,7 +33,6 @@ export const skills: SkillGroup[] = [
|
|
35
33
|
},
|
36
34
|
{
|
37
35
|
skill: "/renew [domain]",
|
38
|
-
triggers: ["/renew"],
|
39
36
|
handler: handleEns,
|
40
37
|
description:
|
41
38
|
"Extend the registration period of your ENS domain. Returns a URL to complete the renewal.",
|
@@ -48,7 +45,6 @@ export const skills: SkillGroup[] = [
|
|
48
45
|
},
|
49
46
|
{
|
50
47
|
skill: "/check [domain]",
|
51
|
-
triggers: ["/check"],
|
52
48
|
handler: handleEns,
|
53
49
|
examples: ["/check vitalik.eth", "/check fabri.base.eth"],
|
54
50
|
description: "Check if a domain is available.",
|
@@ -60,7 +56,6 @@ export const skills: SkillGroup[] = [
|
|
60
56
|
},
|
61
57
|
{
|
62
58
|
skill: "/cool [domain]",
|
63
|
-
triggers: ["/cool"],
|
64
59
|
examples: ["/cool vitalik.eth"],
|
65
60
|
handler: handleEns,
|
66
61
|
description: "Get cool alternatives for a .eth domain.",
|
@@ -72,7 +67,6 @@ export const skills: SkillGroup[] = [
|
|
72
67
|
},
|
73
68
|
{
|
74
69
|
skill: "/reset",
|
75
|
-
triggers: ["/reset"],
|
76
70
|
examples: ["/reset"],
|
77
71
|
handler: handleEns,
|
78
72
|
description: "Reset the conversation.",
|
@@ -81,7 +75,6 @@ export const skills: SkillGroup[] = [
|
|
81
75
|
{
|
82
76
|
skill: "/tip [address]",
|
83
77
|
description: "Show a URL for tipping a domain owner.",
|
84
|
-
triggers: ["/tip"],
|
85
78
|
handler: handleEns,
|
86
79
|
examples: ["/tip 0x1234567890123456789012345678901234567890"],
|
87
80
|
params: {
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import {
|
2
|
+
run,
|
3
|
+
HandlerContext,
|
4
|
+
textGeneration,
|
5
|
+
processMultilineResponse,
|
6
|
+
} from "@xmtp/message-kit";
|
7
|
+
import { agent_prompt } from "./prompt.js";
|
8
|
+
|
9
|
+
if (!process.env.OPEN_AI_API_KEY) {
|
10
|
+
console.error("OPEN_AI_API_KEY is not set");
|
11
|
+
}
|
12
|
+
|
13
|
+
run(async (context: HandlerContext) => {
|
14
|
+
if (!process.env.OPEN_AI_API_KEY) {
|
15
|
+
context.send("gm");
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
const {
|
19
|
+
message: {
|
20
|
+
content: { text, params },
|
21
|
+
sender,
|
22
|
+
},
|
23
|
+
} = context;
|
24
|
+
|
25
|
+
try {
|
26
|
+
let userPrompt = params?.prompt ?? text;
|
27
|
+
const { reply } = await textGeneration(
|
28
|
+
sender.address,
|
29
|
+
userPrompt,
|
30
|
+
await agent_prompt(sender.address),
|
31
|
+
);
|
32
|
+
await processMultilineResponse(sender.address, reply, context);
|
33
|
+
} catch (error) {
|
34
|
+
console.error("Error during OpenAI call:", error);
|
35
|
+
await context.send("An error occurred while processing your request.");
|
36
|
+
}
|
37
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defaultPromptTemplate } from "@xmtp/message-kit";
|
2
|
+
|
3
|
+
export async function agent_prompt(senderAddress: string) {
|
4
|
+
let fineTunedPrompt = `
|
5
|
+
|
6
|
+
### Context
|
7
|
+
|
8
|
+
You are a helpful bot agent that lives inside a web3 messaging group that helps interpret user requests and execute commands.
|
9
|
+
The message was sent by @${senderAddress}
|
10
|
+
|
11
|
+
|
12
|
+
Important:
|
13
|
+
- If a user asks jokes, make jokes about web3 devs\n
|
14
|
+
- If the user asks about performing an action and you can think of a command that would help, answer directly with the command and nothing else.
|
15
|
+
- Populate the command with the correct or random values. Always return commands with real values only, using usernames with @ and excluding addresses.\n
|
16
|
+
- If the user asks a question or makes a statement that does not clearly map to a command, respond with helpful information or a clarification question.\n
|
17
|
+
- If the user is grateful, respond asking for a tip in a playful manner.
|
18
|
+
`;
|
19
|
+
return defaultPromptTemplate(fineTunedPrompt, senderAddress, [], "@bot");
|
20
|
+
}
|
@@ -6,7 +6,7 @@ export async function handler(context: HandlerContext) {
|
|
6
6
|
content: { skill, params },
|
7
7
|
},
|
8
8
|
} = context;
|
9
|
-
const
|
9
|
+
const txpayUrl = "https://txpay.vercel.app";
|
10
10
|
|
11
11
|
if (skill === "pay") {
|
12
12
|
const { amount: amountSend, token: tokenSend, username } = params;
|
@@ -23,7 +23,7 @@ export async function handler(context: HandlerContext) {
|
|
23
23
|
};
|
24
24
|
}
|
25
25
|
|
26
|
-
let sendUrl = `${
|
26
|
+
let sendUrl = `${txpayUrl}/?&amount=${amountSend}&token=${tokenSend}&receiver=${senderInfo.address}`;
|
27
27
|
await context.send(`${sendUrl}`);
|
28
28
|
}
|
29
29
|
}
|
@@ -9,7 +9,7 @@ export async function agent_prompt(senderAddress: string) {
|
|
9
9
|
Hey! Sure let's do that.\n/game wordle
|
10
10
|
|
11
11
|
2. When user wants to pay a specific token:
|
12
|
-
I'll help you pay 1 USDC to 0x123...\n/pay 1
|
12
|
+
I'll help you pay 1 USDC to 0x123...\n/pay 1 [token] 0x123456789...
|
13
13
|
*This will return a url to pay
|
14
14
|
|
15
15
|
3. If the user wants to pay a eth domain:
|
@@ -11,8 +11,7 @@ export const skills: SkillGroup[] = [
|
|
11
11
|
description: "Group agent for tipping and transactions.",
|
12
12
|
skills: [
|
13
13
|
{
|
14
|
-
skill: "/tip [
|
15
|
-
triggers: ["/tip"],
|
14
|
+
skill: "/tip [usernames] [amount] [token]",
|
16
15
|
examples: ["/tip @vitalik 10 usdc"],
|
17
16
|
description: "Tip users in a specified token.",
|
18
17
|
handler: tipping,
|
@@ -35,7 +34,6 @@ export const skills: SkillGroup[] = [
|
|
35
34
|
},
|
36
35
|
{
|
37
36
|
skill: "/pay [amount] [token] [username]",
|
38
|
-
triggers: ["/pay"],
|
39
37
|
examples: ["/pay 10 usdc vitalik.eth", "/pay 1 @alix"],
|
40
38
|
description:
|
41
39
|
"Send a specified amount of a cryptocurrency to a destination address.",
|
@@ -58,7 +56,6 @@ export const skills: SkillGroup[] = [
|
|
58
56
|
},
|
59
57
|
{
|
60
58
|
skill: "/game [game]",
|
61
|
-
triggers: ["/game", "🔎", "🔍"],
|
62
59
|
handler: games,
|
63
60
|
description: "Play a game.",
|
64
61
|
examples: ["/game wordle", "/game slot", "/game help"],
|
@@ -72,7 +69,6 @@ export const skills: SkillGroup[] = [
|
|
72
69
|
},
|
73
70
|
{
|
74
71
|
skill: "/help",
|
75
|
-
triggers: ["/help"],
|
76
72
|
examples: ["/help"],
|
77
73
|
handler: help,
|
78
74
|
description: "Get help with the bot.",
|
@@ -83,7 +79,6 @@ export const skills: SkillGroup[] = [
|
|
83
79
|
adminOnly: true,
|
84
80
|
examples: ["/id"],
|
85
81
|
handler: help,
|
86
|
-
triggers: ["/id"],
|
87
82
|
description: "Get the group ID.",
|
88
83
|
params: {},
|
89
84
|
},
|
@@ -1 +0,0 @@
|
|
1
|
-
KEY= # the private key of the agent wallet
|