@emotion-machine/claw-messenger 0.1.7 → 0.1.9

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/dist/channel.js CHANGED
@@ -1,8 +1,8 @@
1
- import { buildChannelConfigSchema, DEFAULT_ACCOUNT_ID, formatPairingApproveHint, normalizeE164, PAIRING_APPROVED_MESSAGE, } from "openclaw/plugin-sdk";
1
+ import { buildChannelConfigSchema, DEFAULT_ACCOUNT_ID, formatPairingApproveHint, PAIRING_APPROVED_MESSAGE, } from "openclaw/plugin-sdk";
2
2
  import { ClawMessengerConfigSchema } from "./config.js";
3
3
  import { getRuntime } from "./runtime.js";
4
4
  import { WsClient } from "./ws/client.js";
5
- import { sendText, sendMedia, sendToGroup, sendGroupMedia, sendToNewGroup } from "./outbound/send.js";
5
+ import { normalizeDirectTarget, sendText, sendMedia, sendToGroup, sendGroupMedia, sendToNewGroup, } from "./outbound/send.js";
6
6
  const EMOJI_TO_REACTION = {
7
7
  "❤️": "love", "♥️": "love", "🩷": "love", "💕": "love", "😍": "love",
8
8
  "👍": "like", "👍🏻": "like", "👍🏼": "like", "👍🏽": "like", "👍🏾": "like", "👍🏿": "like",
@@ -138,13 +138,7 @@ export const clawMessengerPlugin = {
138
138
  },
139
139
  },
140
140
  messaging: {
141
- normalizeTarget: (target) => {
142
- const trimmed = target.trim();
143
- if (!trimmed)
144
- return null;
145
- const normalized = normalizeE164(trimmed);
146
- return normalized ?? trimmed;
147
- },
141
+ normalizeTarget: (target) => normalizeDirectTarget(target),
148
142
  targetResolver: {
149
143
  looksLikeId: (raw) => {
150
144
  const trimmed = raw?.trim();
@@ -3,6 +3,7 @@ export interface SendResult {
3
3
  messageId: string;
4
4
  chatId: string;
5
5
  }
6
+ export declare function normalizeDirectTarget(target: string): string | null;
6
7
  export declare function sendText(ws: WsClient, to: string, text: string, service?: string): Promise<SendResult>;
7
8
  export declare function sendMedia(ws: WsClient, to: string, mediaUrl: string, text?: string, service?: string): Promise<SendResult>;
8
9
  export declare function sendMessage(ws: WsClient, to: string, parts: Array<Record<string, unknown>>, service?: string): Promise<SendResult>;
@@ -1,3 +1,43 @@
1
+ import * as pluginSdk from "openclaw/plugin-sdk";
2
+ function stripLegacyNamespacePrefix(target) {
3
+ let normalized = target.trim();
4
+ while (normalized.startsWith("claw-messenger:") || normalized.startsWith("linq:")) {
5
+ if (normalized.startsWith("claw-messenger:")) {
6
+ normalized = normalized.slice("claw-messenger:".length).trim();
7
+ continue;
8
+ }
9
+ normalized = normalized.slice("linq:".length).trim();
10
+ }
11
+ return normalized;
12
+ }
13
+ function fallbackNormalizeE164(input) {
14
+ if (!input)
15
+ return null;
16
+ const stripped = input.trim().replace(/[\s\-().]/g, "");
17
+ if (/^\+\d{10,15}$/.test(stripped))
18
+ return stripped;
19
+ if (/^\d{10,15}$/.test(stripped))
20
+ return `+${stripped}`;
21
+ return null;
22
+ }
23
+ function normalizeE164Compat(input) {
24
+ const sdkNormalize = typeof pluginSdk.normalizeE164 === "function" ? pluginSdk.normalizeE164 : null;
25
+ if (sdkNormalize) {
26
+ try {
27
+ return sdkNormalize(input);
28
+ }
29
+ catch {
30
+ // Older OpenClaw builds may not expose a callable normalizeE164 helper yet.
31
+ }
32
+ }
33
+ return fallbackNormalizeE164(input);
34
+ }
35
+ export function normalizeDirectTarget(target) {
36
+ const stripped = stripLegacyNamespacePrefix(target);
37
+ if (!stripped)
38
+ return null;
39
+ return normalizeE164Compat(stripped) ?? stripped;
40
+ }
1
41
  export async function sendText(ws, to, text, service) {
2
42
  return sendMessage(ws, to, [{ type: "text", value: text }], service);
3
43
  }
@@ -9,9 +49,13 @@ export async function sendMedia(ws, to, mediaUrl, text, service) {
9
49
  return sendMessage(ws, to, parts, service);
10
50
  }
11
51
  export async function sendMessage(ws, to, parts, service) {
52
+ const normalizedTarget = normalizeDirectTarget(to);
53
+ if (!normalizedTarget) {
54
+ throw new Error("Recipient is required");
55
+ }
12
56
  const resp = await ws.request({
13
57
  type: "send",
14
- to,
58
+ to: normalizedTarget,
15
59
  parts,
16
60
  ...(service ? { service } : {}),
17
61
  });
@@ -50,9 +94,15 @@ async function sendGroupMessage(ws, chatId, parts, service) {
50
94
  throw new Error(resp.error ?? "Group send failed");
51
95
  }
52
96
  export async function sendToNewGroup(ws, to, text, service) {
97
+ const normalizedTargets = to
98
+ .map((target) => normalizeDirectTarget(target))
99
+ .filter((target) => Boolean(target));
100
+ if (normalizedTargets.length < 2) {
101
+ throw new Error("Group requires at least 2 recipients");
102
+ }
53
103
  const resp = await ws.request({
54
104
  type: "send",
55
- to,
105
+ to: normalizedTargets,
56
106
  parts: [{ type: "text", value: text }],
57
107
  ...(service ? { service } : {}),
58
108
  });
@@ -5,19 +5,39 @@
5
5
  "configSchema": {
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
- "properties": {
9
- "apiKey": { "type": "string" },
10
- "serverUrl": { "type": "string" },
11
- "preferredService": { "type": "string", "enum": ["iMessage", "RCS", "SMS"] },
12
- "dmPolicy": { "type": "string", "enum": ["open", "pairing", "allowlist"] },
13
- "allowFrom": { "type": "array", "items": { "type": "string" } }
14
- }
8
+ "properties": {}
15
9
  },
16
- "uiHints": {
17
- "apiKey": { "label": "API Key", "sensitive": true, "placeholder": "cm_live_..." },
18
- "serverUrl": { "label": "Server URL", "placeholder": "ws://claw-messenger.onrender.com" },
19
- "preferredService": { "label": "Preferred Service" },
20
- "dmPolicy": { "label": "DM Policy" },
21
- "allowFrom": { "label": "Allow List" }
10
+ "channelConfigs": {
11
+ "claw-messenger": {
12
+ "schema": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "enabled": { "type": "boolean" },
17
+ "apiKey": { "type": "string" },
18
+ "serverUrl": { "type": "string" },
19
+ "preferredService": { "type": "string", "enum": ["iMessage", "RCS", "SMS"] },
20
+ "dmPolicy": { "type": "string", "enum": ["open", "pairing", "allowlist"] },
21
+ "allowFrom": { "type": "array", "items": { "type": "string" } },
22
+ "groupPolicy": { "type": "string", "enum": ["open", "disabled", "allowlist"] },
23
+ "groupAllowFrom": { "type": "array", "items": { "type": "string" } }
24
+ }
25
+ },
26
+ "label": "Claw Messenger",
27
+ "description": "Claw Messenger channel settings for iMessage, RCS, and SMS relay access.",
28
+ "uiHints": {
29
+ "": {
30
+ "label": "Claw Messenger",
31
+ "help": "Configure your Claw Messenger API key, relay URL, and direct-message access policy here."
32
+ },
33
+ "apiKey": { "label": "API Key", "sensitive": true, "placeholder": "cm_live_..." },
34
+ "serverUrl": { "label": "Server URL", "placeholder": "wss://claw-messenger.onrender.com" },
35
+ "preferredService": { "label": "Preferred Service" },
36
+ "dmPolicy": { "label": "DM Policy" },
37
+ "allowFrom": { "label": "Allow List" },
38
+ "groupPolicy": { "label": "Group Policy" },
39
+ "groupAllowFrom": { "label": "Group Allow List" }
40
+ }
41
+ }
22
42
  }
23
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emotion-machine/claw-messenger",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "iMessage, RCS & SMS channel plugin for OpenClaw — no phone or Mac Mini required",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",