@emotion-machine/claw-messenger 0.1.7 → 0.1.8
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 +3 -9
- package/dist/outbound/send.d.ts +1 -0
- package/dist/outbound/send.js +30 -2
- package/openclaw.plugin.json +33 -13
- package/package.json +1 -1
package/dist/channel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { buildChannelConfigSchema, DEFAULT_ACCOUNT_ID, formatPairingApproveHint,
|
|
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();
|
package/dist/outbound/send.d.ts
CHANGED
|
@@ -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>;
|
package/dist/outbound/send.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import { normalizeE164 } 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
|
+
export function normalizeDirectTarget(target) {
|
|
14
|
+
const stripped = stripLegacyNamespacePrefix(target);
|
|
15
|
+
if (!stripped)
|
|
16
|
+
return null;
|
|
17
|
+
return normalizeE164(stripped) ?? stripped;
|
|
18
|
+
}
|
|
1
19
|
export async function sendText(ws, to, text, service) {
|
|
2
20
|
return sendMessage(ws, to, [{ type: "text", value: text }], service);
|
|
3
21
|
}
|
|
@@ -9,9 +27,13 @@ export async function sendMedia(ws, to, mediaUrl, text, service) {
|
|
|
9
27
|
return sendMessage(ws, to, parts, service);
|
|
10
28
|
}
|
|
11
29
|
export async function sendMessage(ws, to, parts, service) {
|
|
30
|
+
const normalizedTarget = normalizeDirectTarget(to);
|
|
31
|
+
if (!normalizedTarget) {
|
|
32
|
+
throw new Error("Recipient is required");
|
|
33
|
+
}
|
|
12
34
|
const resp = await ws.request({
|
|
13
35
|
type: "send",
|
|
14
|
-
to,
|
|
36
|
+
to: normalizedTarget,
|
|
15
37
|
parts,
|
|
16
38
|
...(service ? { service } : {}),
|
|
17
39
|
});
|
|
@@ -50,9 +72,15 @@ async function sendGroupMessage(ws, chatId, parts, service) {
|
|
|
50
72
|
throw new Error(resp.error ?? "Group send failed");
|
|
51
73
|
}
|
|
52
74
|
export async function sendToNewGroup(ws, to, text, service) {
|
|
75
|
+
const normalizedTargets = to
|
|
76
|
+
.map((target) => normalizeDirectTarget(target))
|
|
77
|
+
.filter((target) => Boolean(target));
|
|
78
|
+
if (normalizedTargets.length < 2) {
|
|
79
|
+
throw new Error("Group requires at least 2 recipients");
|
|
80
|
+
}
|
|
53
81
|
const resp = await ws.request({
|
|
54
82
|
type: "send",
|
|
55
|
-
to,
|
|
83
|
+
to: normalizedTargets,
|
|
56
84
|
parts: [{ type: "text", value: text }],
|
|
57
85
|
...(service ? { service } : {}),
|
|
58
86
|
});
|
package/openclaw.plugin.json
CHANGED
|
@@ -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
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
}
|