create-message-kit 1.1.8-beta.2 → 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 CHANGED
@@ -84,8 +84,8 @@ async function addPackagejson(destDir, name, pkgManager) {
84
84
  },
85
85
  };
86
86
 
87
- if (pkgManager.startsWith("yarn")) {
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: "gm", label: "GM" },
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
- const pkgManager = await detect();
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.1.8-beta.2",
3
+ "version": "1.1.8-beta.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -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,2 @@
1
+ KEY= # the private key of the agent wallet
2
+ OPEN_AI_API_KEY= # the API key for OpenAI
@@ -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
+ }
@@ -12,7 +12,6 @@ export const skills: SkillGroup[] = [
12
12
  skills: [
13
13
  {
14
14
  skill: "/tip [usernames] [amount] [token]",
15
- triggers: ["/tip"],
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
@@ -1,5 +0,0 @@
1
- import { run, HandlerContext } from "@xmtp/message-kit";
2
-
3
- run(async (context: HandlerContext) => {
4
- context.send("gm");
5
- });