@emotion-machine/claw-messenger 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ After installing, add to your config under `channels`:
30
30
  ## Features
31
31
 
32
32
  - **Send & receive** text messages and media (images, video, audio, documents)
33
- - **iMessage reactions** — love, like, dislike, laugh, emphasize, question (tapback)
33
+ - **iMessage reactions** — six standard tapbacks plus any single Unicode emoji
34
34
  - **Group chats** — send to existing groups or create new ones
35
35
  - **Typing indicators** — sent and received
36
36
  - **DM security policies** — open, pairing-based approval, or allowlist
package/dist/channel.js CHANGED
@@ -2,19 +2,9 @@ import { DEFAULT_ACCOUNT_ID as OPENCLAW_DEFAULT_ACCOUNT_ID, PAIRING_APPROVED_MES
2
2
  import { ClawMessengerConfigSchema } from "./config.js";
3
3
  import { isInboundMessageEvent, normalizeInboundMessage, validateInboundRoute, } from "./inbound.js";
4
4
  import { getRuntime } from "./runtime.js";
5
+ import { sendReaction } from "./reactions.js";
5
6
  import { WsClient } from "./ws/client.js";
6
7
  import { normalizeDirectTarget, sendText, sendMedia, sendToGroup, sendGroupMedia, sendToNewGroup, } from "./outbound/send.js";
7
- const EMOJI_TO_REACTION = {
8
- "❤️": "love", "♥️": "love", "🩷": "love", "💕": "love", "😍": "love",
9
- "👍": "like", "👍🏻": "like", "👍🏼": "like", "👍🏽": "like", "👍🏾": "like", "👍🏿": "like",
10
- "👎": "dislike", "👎🏻": "dislike", "👎🏼": "dislike", "👎🏽": "dislike", "👎🏾": "dislike", "👎🏿": "dislike",
11
- "😂": "laugh", "🤣": "laugh", "😆": "laugh",
12
- "‼️": "emphasize", "❗": "emphasize", "❕": "emphasize", "⚡": "emphasize",
13
- "❓": "question", "❔": "question", "🤔": "question",
14
- };
15
- function emojiToReaction(emoji) {
16
- return EMOJI_TO_REACTION[emoji];
17
- }
18
8
  // -- Account resolution --
19
9
  const FALLBACK_ACCOUNT_ID = "default";
20
10
  function hasAccountId(value) {
@@ -192,7 +182,7 @@ export const clawMessengerPlugin = {
192
182
  },
193
183
  agentPrompt: {
194
184
  messageToolHints: () => [
195
- "You can react to messages using iMessage tapbacks via the react action. Available: love (❤️), like (👍), dislike (👎), laugh (😂), emphasize (‼️), question (❓).",
185
+ "You can react to messages via the react action. The six iMessage tapbacks are love (❤️), like (👍), dislike (👎), laugh (😂), emphasize (‼️), and question (❓). Any other single Unicode emoji is sent as a custom reaction.",
196
186
  "Use reactions naturally — the way a real person would in iMessage.",
197
187
  "If you encounter connection issues, the server is WebSocket-only — do NOT test with HTTP. Full API docs and troubleshooting: https://clawmessenger.com/docs",
198
188
  "If a user is stuck connecting, the fix is almost always: make sure the Claw Messenger plugin is enabled and the API key is set. Verified setup guides to hand them: OpenClaw setup https://www.clawmessenger.com/blog/openclaw-imessage-setup-guide, Hermes setup https://www.clawmessenger.com/blog/hermes-imessage-setup, troubleshooting https://www.clawmessenger.com/blog/openclaw-imessage-troubleshooting.",
@@ -211,17 +201,14 @@ export const clawMessengerPlugin = {
211
201
  const messageId = params.messageId;
212
202
  if (!messageId)
213
203
  throw new Error("messageId is required for react action");
214
- const emoji = params.emoji?.trim() ?? "❤️";
204
+ const emoji = params.emoji?.trim() || "❤️";
215
205
  const remove = params.remove === true;
216
- const reactionType = emojiToReaction(emoji) ?? "love";
217
- ws.send({
218
- type: "reaction",
219
- messageId,
220
- reactionType,
221
- remove,
222
- });
206
+ const result = await sendReaction(ws, messageId, emoji, remove);
207
+ const reaction = result.reactionType === "custom"
208
+ ? result.emoji
209
+ : result.reactionType;
223
210
  return {
224
- content: [{ type: "text", text: JSON.stringify({ ok: true, action: remove ? "removed" : "added", reaction: reactionType }) }],
211
+ content: [{ type: "text", text: JSON.stringify({ ok: true, action: remove ? "removed" : "added", reaction }) }],
225
212
  };
226
213
  }
227
214
  if (action === "send") {
@@ -0,0 +1,21 @@
1
+ export type StandardReactionType = "love" | "like" | "dislike" | "laugh" | "emphasize" | "question";
2
+ export type ReactionType = StandardReactionType | "custom";
3
+ export interface ReactionResult {
4
+ type: "reaction.result";
5
+ id?: string;
6
+ ok: boolean;
7
+ messageId?: string;
8
+ reactionType?: ReactionType;
9
+ emoji?: string;
10
+ remove?: boolean;
11
+ error?: string;
12
+ errorCode?: string;
13
+ retryable?: boolean;
14
+ }
15
+ interface ReactionWsClient {
16
+ request(message: Record<string, unknown>): Promise<Record<string, unknown>>;
17
+ }
18
+ export declare function isSingleEmoji(value: string): boolean;
19
+ export declare function reactionFrame(messageId: string, rawEmoji: string, remove?: boolean): Record<string, unknown>;
20
+ export declare function sendReaction(ws: ReactionWsClient, messageId: string, emoji: string, remove?: boolean): Promise<ReactionResult>;
21
+ export {};
@@ -0,0 +1,68 @@
1
+ const STANDARD_EMOJI_TO_REACTION = {
2
+ "❤": "love",
3
+ "❤️": "love",
4
+ "♥️": "love",
5
+ "🩷": "love",
6
+ "💕": "love",
7
+ "😍": "love",
8
+ "👍": "like",
9
+ "👍🏻": "like",
10
+ "👍🏼": "like",
11
+ "👍🏽": "like",
12
+ "👍🏾": "like",
13
+ "👍🏿": "like",
14
+ "👎": "dislike",
15
+ "👎🏻": "dislike",
16
+ "👎🏼": "dislike",
17
+ "👎🏽": "dislike",
18
+ "👎🏾": "dislike",
19
+ "👎🏿": "dislike",
20
+ "😂": "laugh",
21
+ "🤣": "laugh",
22
+ "😆": "laugh",
23
+ "‼": "emphasize",
24
+ "‼️": "emphasize",
25
+ "❗": "emphasize",
26
+ "❕": "emphasize",
27
+ "⚡": "emphasize",
28
+ "❓": "question",
29
+ "❔": "question",
30
+ "🤔": "question",
31
+ };
32
+ export function isSingleEmoji(value) {
33
+ if (!value || value !== value.trim() || value.length > 64)
34
+ return false;
35
+ const segments = Array.from(new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(value));
36
+ if (segments.length !== 1)
37
+ return false;
38
+ return (/\p{Extended_Pictographic}/u.test(value)
39
+ || /^\p{Regional_Indicator}{2}$/u.test(value)
40
+ || /^[#*0-9]\uFE0F?\u20E3$/u.test(value));
41
+ }
42
+ export function reactionFrame(messageId, rawEmoji, remove = false) {
43
+ const normalizedMessageId = messageId?.trim();
44
+ if (!normalizedMessageId)
45
+ throw new Error("messageId is required for react action");
46
+ const emoji = rawEmoji?.trim();
47
+ if (!isSingleEmoji(emoji)) {
48
+ throw new Error("emoji must contain exactly one Unicode emoji");
49
+ }
50
+ const standardReaction = STANDARD_EMOJI_TO_REACTION[emoji];
51
+ return {
52
+ type: "reaction",
53
+ messageId: normalizedMessageId,
54
+ reactionType: standardReaction ?? "custom",
55
+ ...(standardReaction ? {} : { emoji }),
56
+ remove,
57
+ };
58
+ }
59
+ export async function sendReaction(ws, messageId, emoji, remove = false) {
60
+ const response = await ws.request(reactionFrame(messageId, emoji, remove));
61
+ if (response.type !== "reaction.result") {
62
+ throw new Error("Claw Messenger returned an invalid reaction response");
63
+ }
64
+ if (response.ok !== true) {
65
+ throw new Error(typeof response.error === "string" ? response.error : "Reaction request failed");
66
+ }
67
+ return response;
68
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@emotion-machine/claw-messenger",
3
- "version": "0.1.15",
4
- "description": "iMessage, RCS & SMS channel plugin for OpenClaw agents, powered by Claw Messenger, the Mac-free iMessage API for AI agents. Send and receive real texts from Linux, Docker, Windows, or any cloud. No phone or Mac required.",
3
+ "version": "0.1.17",
4
+ "description": "OpenClaw channel plugin for Claw Messenger, a managed, Mac-free iMessage, RCS, and SMS API for AI agents.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",