create-message-kit 1.1.7-beta.4 → 1.1.7-beta.6

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-message-kit",
3
- "version": "1.1.7-beta.4",
3
+ "version": "1.1.7-beta.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,7 +1,7 @@
1
1
  import { HandlerContext, SkillResponse } from "@xmtp/message-kit";
2
- import { getUserInfo, clearInfoCache, isOnXMTP } from "../lib/resolver.js";
2
+ import { getUserInfo, clearInfoCache, isOnXMTP } from "@xmtp/message-kit";
3
3
  import { isAddress } from "viem";
4
- import { clearMemory } from "../lib/gpt.js";
4
+ 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/";
@@ -14,7 +14,6 @@ export async function handleEns(
14
14
  message: {
15
15
  content: { command, params, sender },
16
16
  },
17
- skill,
18
17
  } = context;
19
18
  if (command == "reset") {
20
19
  clearMemory();
@@ -87,13 +86,7 @@ export async function handleEns(
87
86
  }
88
87
  message += `\n\nWould you like to tip the domain owner for getting there first 🤣?`;
89
88
  message = message.trim();
90
- if (
91
- await isOnXMTP(
92
- context.v2client,
93
- data?.ensInfo?.ens,
94
- data?.ensInfo?.address,
95
- )
96
- ) {
89
+ if (await isOnXMTP(context.client, context.v2client, sender?.address)) {
97
90
  await context.send(
98
91
  `Ah, this domains is in XMTP, you can message it directly: https://converse.xyz/dm/${domain}`,
99
92
  );
@@ -118,7 +111,7 @@ export async function handleEns(
118
111
  };
119
112
  } else {
120
113
  let message = `Looks like ${domain} is already registered!`;
121
- await skill("/cool " + domain);
114
+ await context.executeSkill("/cool " + domain);
122
115
  return {
123
116
  code: 404,
124
117
  message,
@@ -1,7 +1,7 @@
1
1
  import { run, HandlerContext } from "@xmtp/message-kit";
2
- import { textGeneration, processMultilineResponse } from "./lib/gpt.js";
2
+ import { textGeneration, processMultilineResponse } from "@xmtp/message-kit";
3
3
  import { agent_prompt } from "./prompt.js";
4
- import { getUserInfo } from "./lib/resolver.js";
4
+ import { getUserInfo } from "@xmtp/message-kit";
5
5
 
6
6
  run(async (context: HandlerContext) => {
7
7
  /*All the skills are handled through the skills file*/
@@ -126,7 +126,7 @@ export async function processMultilineResponse(
126
126
  console.log(messages);
127
127
  for (const message of messages) {
128
128
  if (message.startsWith("/")) {
129
- const response = await context.skill(message);
129
+ const response = await context.executeSkill(message);
130
130
  if (response && typeof response.message === "string") {
131
131
  let msg = parseMarkdown(response.message);
132
132
  chatMemory.addEntry(memoryKey, {
@@ -108,8 +108,8 @@ export const getUserInfo = async (
108
108
  }),
109
109
  });
110
110
  const converseData = (await response.json()) as ConverseProfile;
111
- if (process.env.MSG_LOG === "true")
112
- console.log("Converse data", keyToUse, converseData);
111
+ //if (process.env.MSG_LOG === "true")
112
+ //console.log("Converse data", keyToUse, converseData);
113
113
  data.converseUsername =
114
114
  converseData?.formattedName || converseData?.name || undefined;
115
115
  data.address = converseData?.address || undefined;
@@ -1,6 +1,11 @@
1
1
  import { skills } from "./skills.js";
2
- import { UserInfo, PROMPT_USER_CONTENT } from "./lib/resolver.js";
3
- import { PROMPT_RULES, PROMPT_SKILLS_AND_EXAMPLES } from "./lib/gpt.js";
2
+ import {
3
+ getUserInfo,
4
+ UserInfo,
5
+ PROMPT_USER_CONTENT,
6
+ PROMPT_RULES,
7
+ PROMPT_SKILLS_AND_EXAMPLES,
8
+ } from "@xmtp/message-kit";
4
9
 
5
10
  export async function agent_prompt(userInfo: UserInfo) {
6
11
  let { address, ensDomain, converseUsername, preferredName } = userInfo;
@@ -1,5 +1,5 @@
1
1
  import { HandlerContext, AbstractedMember } from "@xmtp/message-kit";
2
- import { textGeneration } from "../lib/gpt.js";
2
+ import { textGeneration } from "@xmtp/message-kit";
3
3
 
4
4
  export async function handler(context: HandlerContext) {
5
5
  if (!process?.env?.OPEN_AI_API_KEY) {
@@ -12,7 +12,6 @@ export async function handler(context: HandlerContext) {
12
12
  sender,
13
13
  content: { content, params },
14
14
  },
15
- skill,
16
15
  } = context;
17
16
 
18
17
  const systemPrompt = generateSystemPrompt(context);
@@ -24,7 +23,7 @@ export async function handler(context: HandlerContext) {
24
23
  userPrompt,
25
24
  systemPrompt,
26
25
  );
27
- skill(reply);
26
+ context.executeSkill(reply);
28
27
  } catch (error) {
29
28
  console.error("Error during OpenAI call:", error);
30
29
  await context.reply("An error occurred while processing your request.");
@@ -0,0 +1,24 @@
1
+ import { HandlerContext } from "@xmtp/message-kit";
2
+
3
+ export async function handler(context: HandlerContext) {
4
+ const {
5
+ skills,
6
+ group,
7
+ message: {
8
+ content: { command },
9
+ },
10
+ } = context;
11
+
12
+ if (command == "help") {
13
+ const intro =
14
+ "Available experiences:\n" +
15
+ skills
16
+ ?.flatMap((app) => app.skills)
17
+ .map((skill) => `${skill.command} - ${skill.description}`)
18
+ .join("\n") +
19
+ "\nUse these skills to interact with specific apps.";
20
+ context.send(intro);
21
+ } else if (command == "id") {
22
+ context.send(context.group?.id);
23
+ }
24
+ }
@@ -1,5 +1,5 @@
1
1
  import { HandlerContext, AbstractedMember } from "@xmtp/message-kit";
2
- import { getUserInfo } from "../lib/resolver.js";
2
+ import { getUserInfo } from "@xmtp/message-kit";
3
3
 
4
4
  export async function handler(context: HandlerContext) {
5
5
  const {
@@ -1,5 +1,5 @@
1
1
  import { HandlerContext } from "@xmtp/message-kit";
2
- import { getUserInfo } from "../lib/resolver.js";
2
+ import { getUserInfo } from "@xmtp/message-kit";
3
3
 
4
4
  // Main handler function for processing commands
5
5
  export async function handler(context: HandlerContext) {
@@ -30,5 +30,5 @@ async function handleReply(context: HandlerContext) {
30
30
  version,
31
31
  v2client.address,
32
32
  );
33
- //await context.skill(chain);
33
+ //await context.executeSkill(chain);
34
34
  }
@@ -126,7 +126,7 @@ export async function processMultilineResponse(
126
126
  console.log(messages);
127
127
  for (const message of messages) {
128
128
  if (message.startsWith("/")) {
129
- const response = await context.skill(message);
129
+ const response = await context.executeSkill(message);
130
130
  if (response && typeof response.message === "string") {
131
131
  let msg = parseMarkdown(response.message);
132
132
  chatMemory.addEntry(memoryKey, {
@@ -108,8 +108,8 @@ export const getUserInfo = async (
108
108
  }),
109
109
  });
110
110
  const converseData = (await response.json()) as ConverseProfile;
111
- if (process.env.MSG_LOG === "true")
112
- console.log("Converse data", keyToUse, converseData);
111
+ /// if (process.env.MSG_LOG === "true")
112
+ //console.log("Converse data", keyToUse, converseData);
113
113
  data.converseUsername =
114
114
  converseData?.formattedName || converseData?.name || undefined;
115
115
  data.address = converseData?.address || undefined;
@@ -3,7 +3,7 @@ import { handler as agent } from "./handler/agent.js";
3
3
  import { handler as transaction } from "./handler/transaction.js";
4
4
  import { handler as games } from "./handler/game.js";
5
5
  import { handler as loyalty } from "./handler/loyalty.js";
6
- import { handler as groupHelp } from "./handler/group.js";
6
+ import { handler as groupHelp } from "./handler/helpers.js";
7
7
  import type { SkillGroup } from "@xmtp/message-kit";
8
8
 
9
9
  export const skills: SkillGroup[] = [