create-message-kit 1.1.10-beta.4 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +4 -2
- package/package.json +1 -1
- package/templates/agent/package.json +1 -1
- package/templates/agent/src/handlers/check.ts +10 -4
- package/templates/agent/src/handlers/cool.ts +4 -4
- package/templates/agent/src/handlers/game.ts +57 -0
- package/templates/agent/src/handlers/info.ts +15 -24
- package/templates/agent/src/handlers/pay.ts +38 -0
- package/templates/agent/src/handlers/register.ts +4 -4
- package/templates/agent/src/handlers/renew.ts +4 -4
- package/templates/agent/src/handlers/reset.ts +4 -4
- package/templates/agent/src/handlers/token.ts +57 -0
- package/templates/agent/src/index.ts +24 -25
- package/templates/agent/src/prompt.ts +2 -2
- package/templates/gated/package.json +1 -1
- package/templates/gated/src/skills.ts +21 -23
- package/templates/gpt/package.json +1 -1
- package/templates/gpt/src/index.ts +8 -1
- package/templates/gpt/src/prompt.ts +0 -3
- package/templates/group/package.json +1 -1
- package/templates/group/src/handlers/game.ts +4 -4
- package/templates/group/src/handlers/helpers.ts +4 -5
- package/templates/group/src/handlers/pay.ts +38 -0
- package/templates/group/src/handlers/tipping.ts +2 -2
- package/templates/group/src/index.ts +11 -17
- package/templates/agent/src/handlers/tip.ts +0 -27
- package/templates/group/src/handlers/payment.ts +0 -51
package/index.js
CHANGED
@@ -72,7 +72,9 @@ async function updatePackagejson(destDir, templateType) {
|
|
72
72
|
packageTemplate.dependencies["@xmtp/message-kit"] = "latest";
|
73
73
|
//Add for yarn in general
|
74
74
|
packageTemplate.scripts.postinstall = "tsc";
|
75
|
-
packageTemplate
|
75
|
+
if (packageTemplate?.packageManager?.startsWith("yarn")) {
|
76
|
+
packageTemplate.packageManager = "yarn@4.5.1";
|
77
|
+
}
|
76
78
|
|
77
79
|
fs.writeJsonSync(resolve(destDir, "package.json"), packageTemplate, {
|
78
80
|
spaces: 2,
|
@@ -81,8 +83,8 @@ async function updatePackagejson(destDir, templateType) {
|
|
81
83
|
|
82
84
|
async function gatherProjectInfo() {
|
83
85
|
const templateOptions = [
|
86
|
+
{ value: "agent", label: "Web3 Agent" },
|
84
87
|
{ value: "gpt", label: "Simple Gpt" },
|
85
|
-
{ value: "agent", label: "ENS Agent" },
|
86
88
|
{ value: "group", label: "Group bot" },
|
87
89
|
{ value: "gated", label: "Gated Group" },
|
88
90
|
];
|
package/package.json
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import { ensUrl } from "../index.js";
|
2
2
|
import { XMTPContext, getUserInfo } from "@xmtp/message-kit";
|
3
|
-
import type {
|
3
|
+
import type { Skill } from "@xmtp/message-kit";
|
4
4
|
|
5
|
-
|
5
|
+
// [!region define]
|
6
|
+
export const registerSkill: Skill[] = [
|
6
7
|
{
|
7
8
|
skill: "/check [domain]",
|
8
|
-
handler:
|
9
|
+
handler: handler,
|
9
10
|
examples: ["/check vitalik.eth", "/check fabri.base.eth"],
|
10
11
|
description: "Check if a domain is available.",
|
11
12
|
params: {
|
@@ -15,7 +16,10 @@ export const registerSkill: skillAction[] = [
|
|
15
16
|
},
|
16
17
|
},
|
17
18
|
];
|
18
|
-
|
19
|
+
// [!endregion define]
|
20
|
+
|
21
|
+
// [!region handle]
|
22
|
+
export async function handler(context: XMTPContext) {
|
19
23
|
const {
|
20
24
|
message: {
|
21
25
|
content: {
|
@@ -25,6 +29,7 @@ export async function handleCheck(context: XMTPContext) {
|
|
25
29
|
} = context;
|
26
30
|
|
27
31
|
const data = await getUserInfo(domain);
|
32
|
+
|
28
33
|
if (!data?.address) {
|
29
34
|
let message = `Looks like ${domain} is available! Here you can register it: ${ensUrl}${domain} or would you like to see some cool alternatives?`;
|
30
35
|
return {
|
@@ -40,3 +45,4 @@ export async function handleCheck(context: XMTPContext) {
|
|
40
45
|
};
|
41
46
|
}
|
42
47
|
}
|
48
|
+
// [!endregion handle]
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { XMTPContext } from "@xmtp/message-kit";
|
2
2
|
|
3
|
-
import type {
|
3
|
+
import type { Skill } from "@xmtp/message-kit";
|
4
4
|
|
5
|
-
export const registerSkill:
|
5
|
+
export const registerSkill: Skill[] = [
|
6
6
|
{
|
7
7
|
skill: "/cool [domain]",
|
8
8
|
examples: ["/cool vitalik.eth"],
|
9
|
-
handler:
|
9
|
+
handler: handler,
|
10
10
|
description: "Get cool alternatives for a .eth domain.",
|
11
11
|
params: {
|
12
12
|
domain: {
|
@@ -15,7 +15,7 @@ export const registerSkill: skillAction[] = [
|
|
15
15
|
},
|
16
16
|
},
|
17
17
|
];
|
18
|
-
export async function
|
18
|
+
export async function handler(context: XMTPContext) {
|
19
19
|
const {
|
20
20
|
message: {
|
21
21
|
content: {
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { XMTPContext } from "@xmtp/message-kit";
|
2
|
+
import type { Skill } from "@xmtp/message-kit";
|
3
|
+
|
4
|
+
export const registerSkill: Skill[] = [
|
5
|
+
{
|
6
|
+
skill: "/game [game]",
|
7
|
+
handler: handler,
|
8
|
+
description: "Play a game.",
|
9
|
+
examples: ["/game wordle", "/game slot", "/game help"],
|
10
|
+
params: {
|
11
|
+
game: {
|
12
|
+
default: "",
|
13
|
+
type: "string",
|
14
|
+
values: ["wordle", "slot", "help"],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
},
|
18
|
+
];
|
19
|
+
|
20
|
+
export async function handler(context: XMTPContext) {
|
21
|
+
const {
|
22
|
+
message: {
|
23
|
+
content: { skill, params, text },
|
24
|
+
},
|
25
|
+
} = context;
|
26
|
+
if (!skill) {
|
27
|
+
if (text === "🔎" || text === "🔍") {
|
28
|
+
// Send the URL for the requested game
|
29
|
+
context.reply("https://framedl.xyz/");
|
30
|
+
}
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
// URLs for each game type
|
34
|
+
const gameUrls: { [key: string]: string } = {
|
35
|
+
wordle: "https://framedl.xyz",
|
36
|
+
slot: "https://slot-machine-frame.vercel.app",
|
37
|
+
};
|
38
|
+
// Respond with the appropriate game URL or an error message
|
39
|
+
switch (params.game) {
|
40
|
+
case "wordle":
|
41
|
+
case "slot":
|
42
|
+
// Retrieve the URL for the requested game using a simplified variable assignment
|
43
|
+
const gameUrl = gameUrls[params.game];
|
44
|
+
// Send the URL for the requested game
|
45
|
+
context.send(gameUrl);
|
46
|
+
break;
|
47
|
+
|
48
|
+
case "help":
|
49
|
+
context.send("Available games: \n/game wordle\n/game slot");
|
50
|
+
break;
|
51
|
+
default:
|
52
|
+
// Inform the user about unrecognized skills and provide available options
|
53
|
+
context.send(
|
54
|
+
"Skill not recognized. Available games: wordle, slot, or help.",
|
55
|
+
);
|
56
|
+
}
|
57
|
+
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { ensUrl } from "../index.js";
|
2
2
|
import { XMTPContext, getUserInfo, isOnXMTP } from "@xmtp/message-kit";
|
3
3
|
|
4
|
-
import type {
|
4
|
+
import type { Skill } from "@xmtp/message-kit";
|
5
5
|
|
6
|
-
export const registerSkill:
|
6
|
+
export const registerSkill: Skill[] = [
|
7
7
|
{
|
8
8
|
skill: "/info [domain]",
|
9
|
-
handler:
|
9
|
+
handler: handler,
|
10
10
|
description:
|
11
11
|
"Get detailed information about an ENS domain including owner, expiry date, and resolver.",
|
12
12
|
examples: ["/info nick.eth"],
|
@@ -18,7 +18,7 @@ export const registerSkill: skillAction[] = [
|
|
18
18
|
},
|
19
19
|
];
|
20
20
|
|
21
|
-
export async function
|
21
|
+
export async function handler(context: XMTPContext) {
|
22
22
|
const {
|
23
23
|
message: {
|
24
24
|
sender,
|
@@ -35,31 +35,22 @@ export async function handleInfo(context: XMTPContext) {
|
|
35
35
|
message: "Domain not found.",
|
36
36
|
};
|
37
37
|
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
GitHub: data?.ensInfo?.github,
|
46
|
-
Resolver: data?.ensInfo?.resolverAddress,
|
47
|
-
Twitter: data?.ensInfo?.twitter,
|
48
|
-
URL: `${ensUrl}${domain}`,
|
49
|
-
};
|
50
|
-
|
51
|
-
let message = "Domain information:\n\n";
|
52
|
-
for (const [key, value] of Object.entries(formattedData)) {
|
53
|
-
if (value) {
|
54
|
-
message += `${key}: ${value}\n`;
|
55
|
-
}
|
56
|
-
}
|
38
|
+
let message = `Domain information:\n\n`;
|
39
|
+
message += `Address: ${data?.address}\n`;
|
40
|
+
message += `Avatar URL: ${data?.ensInfo?.avatar}\n`;
|
41
|
+
message += `Description: ${data?.ensInfo?.description}\n`;
|
42
|
+
message += `ENS: ${data?.ensDomain}\n`;
|
43
|
+
message += `Primary ENS: ${data?.ensInfo?.ens_primary}\n`;
|
44
|
+
message += `GitHub: ${data?.ensInfo?.github}\n`;
|
57
45
|
message += `\n\nWould you like to tip the domain owner for getting there first 🤣?`;
|
58
46
|
message = message.trim();
|
47
|
+
|
59
48
|
if (await isOnXMTP(context.client, context.v2client, sender?.address)) {
|
60
49
|
await context.send(
|
61
|
-
`Ah, this domains is in XMTP, you can message it directly
|
50
|
+
`Ah, this domains is in XMTP, you can message it directly`,
|
62
51
|
);
|
52
|
+
await context.sendConverseDmFrame(domain);
|
63
53
|
}
|
54
|
+
|
64
55
|
return { code: 200, message };
|
65
56
|
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { XMTPContext } from "@xmtp/message-kit";
|
2
|
+
import type { Skill } from "@xmtp/message-kit";
|
3
|
+
|
4
|
+
export const registerSkill: Skill[] = [
|
5
|
+
{
|
6
|
+
skill: "/pay [amount] [token] [username]",
|
7
|
+
examples: ["/pay 10 vitalik.eth"],
|
8
|
+
description:
|
9
|
+
"Send a specified amount of a cryptocurrency to a destination address.",
|
10
|
+
handler: handler,
|
11
|
+
params: {
|
12
|
+
amount: {
|
13
|
+
default: 10,
|
14
|
+
type: "number",
|
15
|
+
},
|
16
|
+
token: {
|
17
|
+
default: "usdc",
|
18
|
+
type: "string",
|
19
|
+
values: ["eth", "dai", "usdc", "degen"], // Accepted tokens
|
20
|
+
},
|
21
|
+
username: {
|
22
|
+
default: "",
|
23
|
+
type: "username",
|
24
|
+
},
|
25
|
+
},
|
26
|
+
},
|
27
|
+
];
|
28
|
+
export async function handler(context: XMTPContext) {
|
29
|
+
const {
|
30
|
+
message: {
|
31
|
+
content: {
|
32
|
+
params: { address },
|
33
|
+
},
|
34
|
+
},
|
35
|
+
} = context;
|
36
|
+
|
37
|
+
await context.requestPayment(1, "USDC", address);
|
38
|
+
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { ensUrl } from "../index.js";
|
2
2
|
import { XMTPContext } from "@xmtp/message-kit";
|
3
3
|
|
4
|
-
import type {
|
4
|
+
import type { Skill } from "@xmtp/message-kit";
|
5
5
|
|
6
|
-
export const registerSkill:
|
6
|
+
export const registerSkill: Skill[] = [
|
7
7
|
{
|
8
8
|
skill: "/register [domain]",
|
9
|
-
handler:
|
9
|
+
handler: handler,
|
10
10
|
description:
|
11
11
|
"Register a new ENS domain. Returns a URL to complete the registration process.",
|
12
12
|
examples: ["/register vitalik.eth"],
|
@@ -18,7 +18,7 @@ export const registerSkill: skillAction[] = [
|
|
18
18
|
},
|
19
19
|
];
|
20
20
|
|
21
|
-
export async function
|
21
|
+
export async function handler(context: XMTPContext) {
|
22
22
|
const {
|
23
23
|
message: {
|
24
24
|
content: {
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { frameUrl } from "../index.js";
|
2
2
|
import { getUserInfo, XMTPContext } from "@xmtp/message-kit";
|
3
3
|
|
4
|
-
import type {
|
4
|
+
import type { Skill } from "@xmtp/message-kit";
|
5
5
|
|
6
|
-
export const registerSkill:
|
6
|
+
export const registerSkill: Skill[] = [
|
7
7
|
{
|
8
8
|
skill: "/renew [domain]",
|
9
|
-
handler:
|
9
|
+
handler: handler,
|
10
10
|
description:
|
11
11
|
"Extend the registration period of your ENS domain. Returns a URL to complete the renewal.",
|
12
12
|
examples: ["/renew fabri.base.eth"],
|
@@ -18,7 +18,7 @@ export const registerSkill: skillAction[] = [
|
|
18
18
|
},
|
19
19
|
];
|
20
20
|
|
21
|
-
export async function
|
21
|
+
export async function handler(context: XMTPContext) {
|
22
22
|
const {
|
23
23
|
message: {
|
24
24
|
sender,
|
@@ -1,18 +1,18 @@
|
|
1
1
|
import { clearInfoCache, clearMemory } from "@xmtp/message-kit";
|
2
2
|
import { XMTPContext } from "@xmtp/message-kit";
|
3
3
|
|
4
|
-
import type {
|
4
|
+
import type { Skill } from "@xmtp/message-kit";
|
5
5
|
|
6
|
-
export const registerSkill:
|
6
|
+
export const registerSkill: Skill[] = [
|
7
7
|
{
|
8
8
|
skill: "/reset",
|
9
9
|
examples: ["/reset"],
|
10
|
-
handler:
|
10
|
+
handler: handler,
|
11
11
|
description: "Reset the conversation.",
|
12
12
|
params: {},
|
13
13
|
},
|
14
14
|
];
|
15
|
-
export async function
|
15
|
+
export async function handler(context: XMTPContext) {
|
16
16
|
clearMemory();
|
17
17
|
clearInfoCache();
|
18
18
|
return { code: 200, message: "Conversation reset." };
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { XMTPContext } from "@xmtp/message-kit";
|
2
|
+
import type { Skill } from "@xmtp/message-kit";
|
3
|
+
|
4
|
+
export const registerSkill: Skill[] = [
|
5
|
+
{
|
6
|
+
skill: "/token [symbol]",
|
7
|
+
handler: handler,
|
8
|
+
examples: ["/token bitcoin", "/token ethereum"],
|
9
|
+
description: "Get real time price of a any token.",
|
10
|
+
params: {
|
11
|
+
symbol: {
|
12
|
+
type: "string",
|
13
|
+
},
|
14
|
+
},
|
15
|
+
},
|
16
|
+
];
|
17
|
+
export async function handler(context: XMTPContext) {
|
18
|
+
const {
|
19
|
+
message: {
|
20
|
+
content: {
|
21
|
+
params: { symbol },
|
22
|
+
},
|
23
|
+
},
|
24
|
+
} = context;
|
25
|
+
const response = await fetch(
|
26
|
+
`https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=${symbol}`,
|
27
|
+
);
|
28
|
+
if (!response.ok) {
|
29
|
+
context.send("Token not found");
|
30
|
+
context.send("try with its full name, instead of btc it would be bitcoin");
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
const data = (await response.json()) as any;
|
34
|
+
const token = data[0];
|
35
|
+
|
36
|
+
const tokenInfo = {
|
37
|
+
name: token.name,
|
38
|
+
symbol: token.symbol.toUpperCase(),
|
39
|
+
price: token.current_price,
|
40
|
+
image: token.image,
|
41
|
+
link: `https://www.coingecko.com/en/coins/${token.id}`,
|
42
|
+
};
|
43
|
+
|
44
|
+
let frame = {
|
45
|
+
title: tokenInfo.name,
|
46
|
+
buttons: [
|
47
|
+
{ content: "Buy", action: "link", target: tokenInfo.link },
|
48
|
+
{
|
49
|
+
content: `Price (${tokenInfo.price})`,
|
50
|
+
action: "link",
|
51
|
+
target: tokenInfo.link,
|
52
|
+
},
|
53
|
+
],
|
54
|
+
image: tokenInfo.image,
|
55
|
+
};
|
56
|
+
await context.sendCustomFrame(frame);
|
57
|
+
}
|
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
agentReply,
|
4
4
|
replaceVariables,
|
5
5
|
XMTPContext,
|
6
|
+
Agent,
|
6
7
|
} from "@xmtp/message-kit";
|
7
8
|
import { systemPrompt } from "./prompt.js";
|
8
9
|
import { registerSkill as checkSkill } from "./handlers/check.js";
|
@@ -10,8 +11,10 @@ import { registerSkill as coolSkill } from "./handlers/cool.js";
|
|
10
11
|
import { registerSkill as infoSkill } from "./handlers/info.js";
|
11
12
|
import { registerSkill as registerSkill } from "./handlers/register.js";
|
12
13
|
import { registerSkill as renewSkill } from "./handlers/renew.js";
|
14
|
+
import { registerSkill as paySkill } from "./handlers/pay.js";
|
13
15
|
import { registerSkill as resetSkill } from "./handlers/reset.js";
|
14
|
-
import { registerSkill as
|
16
|
+
import { registerSkill as tokenSkill } from "./handlers/token.js";
|
17
|
+
import { registerSkill as gameSkill } from "./handlers/game.js";
|
15
18
|
import fs from "fs";
|
16
19
|
|
17
20
|
export const frameUrl = "https://ens.steer.fun/";
|
@@ -19,22 +22,22 @@ export const ensUrl = "https://app.ens.domains/";
|
|
19
22
|
export const txpayUrl = "https://txpay.vercel.app";
|
20
23
|
|
21
24
|
// [!region skills]
|
22
|
-
export const
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
export const agent: Agent = {
|
26
|
+
name: "Web3 Agent",
|
27
|
+
tag: "@bot",
|
28
|
+
description: "A web3 agent with a lot of skills.",
|
29
|
+
skills: [
|
30
|
+
...checkSkill,
|
31
|
+
...coolSkill,
|
32
|
+
...infoSkill,
|
33
|
+
...registerSkill,
|
34
|
+
...renewSkill,
|
35
|
+
...resetSkill,
|
36
|
+
...paySkill,
|
37
|
+
...tokenSkill,
|
38
|
+
...gameSkill,
|
39
|
+
],
|
40
|
+
};
|
38
41
|
// [!endregion skills]
|
39
42
|
|
40
43
|
// [!region run]
|
@@ -42,19 +45,15 @@ run(
|
|
42
45
|
async (context: XMTPContext) => {
|
43
46
|
const {
|
44
47
|
message: { sender },
|
45
|
-
|
48
|
+
agent,
|
46
49
|
} = context;
|
47
50
|
|
48
|
-
let prompt = await replaceVariables(
|
49
|
-
|
50
|
-
sender.address,
|
51
|
-
skills,
|
52
|
-
"@ens",
|
53
|
-
);
|
51
|
+
let prompt = await replaceVariables(systemPrompt, sender.address, agent);
|
52
|
+
|
54
53
|
fs.writeFileSync("example_prompt.md", prompt);
|
55
54
|
await agentReply(context, prompt);
|
56
55
|
},
|
57
|
-
{
|
56
|
+
{ agent },
|
58
57
|
);
|
59
58
|
|
60
59
|
// [!endregion run]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export const systemPrompt = `
|
2
|
-
Your are helpful and playful agent called {agent_name} that lives inside a
|
2
|
+
Your are helpful and playful web3 agent called {agent_name} that lives inside a messaging app called Converse.
|
3
3
|
|
4
4
|
{rules}
|
5
5
|
|
@@ -34,7 +34,7 @@ Your are helpful and playful agent called {agent_name} that lives inside a web3
|
|
34
34
|
/register [domain]
|
35
35
|
7. If the user wants to directly tip the ENS domain owner:
|
36
36
|
Here is the URL to send the tip:
|
37
|
-
/
|
37
|
+
/pay 1 usdc [address]
|
38
38
|
8. If the user wants to get information about the ENS domain:
|
39
39
|
Hello! I'll help you get info about [domain].
|
40
40
|
Give me a moment.
|
@@ -1,24 +1,22 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Agent } from "@xmtp/message-kit";
|
2
2
|
|
3
|
-
export const
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
},
|
24
|
-
];
|
3
|
+
export const agent: Agent = {
|
4
|
+
name: "Group Id",
|
5
|
+
description: "Create and get group id.",
|
6
|
+
skills: [
|
7
|
+
{
|
8
|
+
skill: "/create",
|
9
|
+
examples: ["/create"],
|
10
|
+
adminOnly: true,
|
11
|
+
params: {},
|
12
|
+
description: "Create a new group.",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
skill: "/id",
|
16
|
+
examples: ["/id"],
|
17
|
+
adminOnly: true,
|
18
|
+
params: {},
|
19
|
+
description: "Get group id.",
|
20
|
+
},
|
21
|
+
],
|
22
|
+
};
|
@@ -3,15 +3,22 @@ import {
|
|
3
3
|
agentReply,
|
4
4
|
replaceVariables,
|
5
5
|
XMTPContext,
|
6
|
+
Agent,
|
6
7
|
} from "@xmtp/message-kit";
|
7
8
|
|
8
9
|
import { systemPrompt } from "./prompt.js";
|
10
|
+
export const agent: Agent = {
|
11
|
+
name: "GPT Bot",
|
12
|
+
tag: "@bot",
|
13
|
+
description: "Use GPT to answer questions.",
|
14
|
+
skills: [],
|
15
|
+
};
|
9
16
|
|
10
17
|
run(async (context: XMTPContext) => {
|
11
18
|
const {
|
12
19
|
message: { sender },
|
13
20
|
} = context;
|
14
21
|
|
15
|
-
let prompt = await replaceVariables(systemPrompt, sender.address,
|
22
|
+
let prompt = await replaceVariables(systemPrompt, sender.address, skills);
|
16
23
|
await agentReply(context, prompt);
|
17
24
|
});
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { XMTPContext } from "@xmtp/message-kit";
|
2
|
-
import type {
|
2
|
+
import type { Skill } from "@xmtp/message-kit";
|
3
3
|
|
4
|
-
export const registerSkill:
|
4
|
+
export const registerSkill: Skill[] = [
|
5
5
|
{
|
6
6
|
skill: "/game [game]",
|
7
|
-
handler:
|
7
|
+
handler: handler,
|
8
8
|
description: "Play a game.",
|
9
9
|
examples: ["/game wordle", "/game slot", "/game help"],
|
10
10
|
params: {
|
@@ -17,7 +17,7 @@ export const registerSkill: skillAction[] = [
|
|
17
17
|
},
|
18
18
|
];
|
19
19
|
|
20
|
-
export async function
|
20
|
+
export async function handler(context: XMTPContext) {
|
21
21
|
const {
|
22
22
|
message: {
|
23
23
|
content: { skill, params, text },
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { XMTPContext } from "@xmtp/message-kit";
|
2
2
|
|
3
|
-
import type {
|
3
|
+
import type { Skill } from "@xmtp/message-kit";
|
4
4
|
|
5
|
-
export const registerSkill:
|
5
|
+
export const registerSkill: Skill[] = [
|
6
6
|
{
|
7
7
|
skill: "/help",
|
8
8
|
examples: ["/help"],
|
@@ -25,14 +25,13 @@ export async function handleHelp(context: XMTPContext) {
|
|
25
25
|
content: { skill },
|
26
26
|
},
|
27
27
|
group,
|
28
|
-
|
28
|
+
agent,
|
29
29
|
} = context;
|
30
30
|
|
31
31
|
if (skill == "help") {
|
32
32
|
const intro =
|
33
33
|
"Available experiences:\n" +
|
34
|
-
skills
|
35
|
-
?.flatMap((app) => app.skills)
|
34
|
+
agent?.skills
|
36
35
|
.map((skill) => `${skill.skill} - ${skill.description}`)
|
37
36
|
.join("\n") +
|
38
37
|
"\nUse these skills to interact with specific apps.";
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { XMTPContext } from "@xmtp/message-kit";
|
2
|
+
import type { Skill } from "@xmtp/message-kit";
|
3
|
+
|
4
|
+
export const registerSkill: Skill[] = [
|
5
|
+
{
|
6
|
+
skill: "/pay [amount] [token] [username]",
|
7
|
+
examples: ["/pay 10 vitalik.eth"],
|
8
|
+
description:
|
9
|
+
"Send a specified amount of a cryptocurrency to a destination address.",
|
10
|
+
handler: handler,
|
11
|
+
params: {
|
12
|
+
amount: {
|
13
|
+
default: 10,
|
14
|
+
type: "number",
|
15
|
+
},
|
16
|
+
token: {
|
17
|
+
default: "usdc",
|
18
|
+
type: "string",
|
19
|
+
values: ["eth", "dai", "usdc", "degen"], // Accepted tokens
|
20
|
+
},
|
21
|
+
username: {
|
22
|
+
default: "",
|
23
|
+
type: "username",
|
24
|
+
},
|
25
|
+
},
|
26
|
+
},
|
27
|
+
];
|
28
|
+
export async function handler(context: XMTPContext) {
|
29
|
+
const {
|
30
|
+
message: {
|
31
|
+
content: {
|
32
|
+
params: { address },
|
33
|
+
},
|
34
|
+
},
|
35
|
+
} = context;
|
36
|
+
|
37
|
+
await context.requestPayment(1, "USDC", address);
|
38
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { getUserInfo, AbstractedMember, XMTPContext } from "@xmtp/message-kit";
|
2
|
-
import type {
|
2
|
+
import type { Skill } from "@xmtp/message-kit";
|
3
3
|
|
4
|
-
export const registerSkill:
|
4
|
+
export const registerSkill: Skill[] = [
|
5
5
|
{
|
6
6
|
skill: "/tip [usernames] [amount] [token]",
|
7
7
|
examples: ["/tip @vitalik 10 usdc"],
|
@@ -3,36 +3,30 @@ import {
|
|
3
3
|
agentReply,
|
4
4
|
XMTPContext,
|
5
5
|
replaceVariables,
|
6
|
+
Agent,
|
6
7
|
} from "@xmtp/message-kit";
|
7
8
|
import { registerSkill as tippingSkill } from "./handlers/tipping.js";
|
8
|
-
import { registerSkill as paymentSkill } from "./handlers/
|
9
|
+
import { registerSkill as paymentSkill } from "./handlers/pay.js";
|
9
10
|
import { registerSkill as gameSkill } from "./handlers/game.js";
|
10
11
|
import { registerSkill as helperSkill } from "./handlers/helpers.js";
|
11
12
|
import { systemPrompt } from "./prompt.js";
|
12
13
|
|
13
|
-
export const
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
},
|
20
|
-
];
|
14
|
+
export const agent: Agent = {
|
15
|
+
name: "Group bot",
|
16
|
+
tag: "@bot",
|
17
|
+
description: "Group agent for tipping payments, games and more.",
|
18
|
+
skills: [...tippingSkill, ...paymentSkill, ...gameSkill, ...helperSkill],
|
19
|
+
};
|
21
20
|
|
22
21
|
run(
|
23
22
|
async (context: XMTPContext) => {
|
24
23
|
const {
|
25
24
|
message: { sender },
|
26
|
-
|
25
|
+
agent,
|
27
26
|
} = context;
|
28
27
|
|
29
|
-
let prompt = await replaceVariables(
|
30
|
-
systemPrompt,
|
31
|
-
sender.address,
|
32
|
-
skills,
|
33
|
-
"@bot",
|
34
|
-
);
|
28
|
+
let prompt = await replaceVariables(systemPrompt, sender.address, agent);
|
35
29
|
await agentReply(context, prompt);
|
36
30
|
},
|
37
|
-
{
|
31
|
+
{ agent },
|
38
32
|
);
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { XMTPContext } from "@xmtp/message-kit";
|
2
|
-
|
3
|
-
import type { skillAction } from "@xmtp/message-kit";
|
4
|
-
|
5
|
-
export const registerSkill: skillAction[] = [
|
6
|
-
{
|
7
|
-
skill: "/tip [address]",
|
8
|
-
description: "Show a URL for tipping a domain owner.",
|
9
|
-
handler: handleTip,
|
10
|
-
examples: ["/tip 0x1234567890123456789012345678901234567890"],
|
11
|
-
params: {
|
12
|
-
address: {
|
13
|
-
type: "string",
|
14
|
-
},
|
15
|
-
},
|
16
|
-
},
|
17
|
-
];
|
18
|
-
export async function handleTip(context: XMTPContext) {
|
19
|
-
const {
|
20
|
-
message: {
|
21
|
-
content: {
|
22
|
-
params: { address },
|
23
|
-
},
|
24
|
-
},
|
25
|
-
} = context;
|
26
|
-
await context.sendPayment(1, "USDC", address);
|
27
|
-
}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { getUserInfo, XMTPContext } from "@xmtp/message-kit";
|
2
|
-
import type { skillAction } from "@xmtp/message-kit";
|
3
|
-
export const registerSkill: skillAction[] = [
|
4
|
-
{
|
5
|
-
skill: "/pay [amount] [token] [username]",
|
6
|
-
examples: ["/pay 10 usdc vitalik.eth", "/pay 1 @alix"],
|
7
|
-
description:
|
8
|
-
"Send a specified amount of a cryptocurrency to a destination address.",
|
9
|
-
handler: handlePay,
|
10
|
-
params: {
|
11
|
-
amount: {
|
12
|
-
default: 10,
|
13
|
-
type: "number",
|
14
|
-
},
|
15
|
-
token: {
|
16
|
-
default: "usdc",
|
17
|
-
type: "string",
|
18
|
-
values: ["eth", "dai", "usdc", "degen"], // Accepted tokens
|
19
|
-
},
|
20
|
-
username: {
|
21
|
-
default: "",
|
22
|
-
type: "username",
|
23
|
-
},
|
24
|
-
},
|
25
|
-
},
|
26
|
-
];
|
27
|
-
|
28
|
-
export async function handlePay(context: XMTPContext) {
|
29
|
-
const {
|
30
|
-
message: {
|
31
|
-
content: { params },
|
32
|
-
},
|
33
|
-
} = context;
|
34
|
-
const txpayUrl = "https://txpay.vercel.app";
|
35
|
-
|
36
|
-
const { amount: amountSend, token: tokenSend, username } = params;
|
37
|
-
let senderInfo = await getUserInfo(username);
|
38
|
-
if (!amountSend || !tokenSend || !senderInfo) {
|
39
|
-
context.reply(
|
40
|
-
"Missing required parameters. Please provide amount, token, and username.",
|
41
|
-
);
|
42
|
-
return {
|
43
|
-
code: 400,
|
44
|
-
message:
|
45
|
-
"Missing required parameters. Please provide amount, token, and username.",
|
46
|
-
};
|
47
|
-
}
|
48
|
-
|
49
|
-
let sendUrl = `${txpayUrl}/?&amount=${amountSend}&token=${tokenSend}&receiver=${senderInfo.address}`;
|
50
|
-
await context.send(`${sendUrl}`);
|
51
|
-
}
|