@emotion-machine/claw-messenger 0.1.17 → 0.1.18
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.d.ts +1 -1
- package/dist/channel.js +7 -9
- package/dist/index.js +18 -22
- package/package.json +12 -1
- package/src/types/openclaw.d.ts +6 -3
package/dist/channel.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export declare function createGroup(to: string[], text: string): Promise<{
|
|
|
21
21
|
ok: boolean;
|
|
22
22
|
} & SendResult>;
|
|
23
23
|
export declare const clawMessengerPlugin: ChannelPlugin<ResolvedAccount>;
|
|
24
|
-
export declare function handleInboundMessage(data: Record<string, unknown>, accountId: string, account: ResolvedAccount, ctx: any): Promise<void>;
|
|
24
|
+
export declare function handleInboundMessage(data: Record<string, unknown>, accountId: string, account: ResolvedAccount, ctx: any, wsOverride?: WsClient): Promise<void>;
|
|
25
25
|
export {};
|
package/dist/channel.js
CHANGED
|
@@ -50,7 +50,7 @@ export function getWsClient(accountId) {
|
|
|
50
50
|
// -- Connection status helper (used by tools & commands in index.ts) --
|
|
51
51
|
export function getConnectionStatus() {
|
|
52
52
|
const runtime = getRuntime();
|
|
53
|
-
const cfg = runtime.config.
|
|
53
|
+
const cfg = runtime.config.current();
|
|
54
54
|
const account = resolveAccount(cfg);
|
|
55
55
|
const ws = wsClients.get(account.accountId);
|
|
56
56
|
return {
|
|
@@ -62,7 +62,7 @@ export function getConnectionStatus() {
|
|
|
62
62
|
}
|
|
63
63
|
export async function createGroup(to, text) {
|
|
64
64
|
const runtime = getRuntime();
|
|
65
|
-
const cfg = runtime.config.
|
|
65
|
+
const cfg = runtime.config.current();
|
|
66
66
|
const account = resolveAccount(cfg);
|
|
67
67
|
const ws = wsClients.get(account.accountId);
|
|
68
68
|
if (!ws)
|
|
@@ -76,7 +76,7 @@ export async function createGroup(to, text) {
|
|
|
76
76
|
function resolveConfig(input) {
|
|
77
77
|
if (input && "channels" in input)
|
|
78
78
|
return input;
|
|
79
|
-
return input?.cfg ?? getRuntime().config.
|
|
79
|
+
return input?.cfg ?? getRuntime().config.current();
|
|
80
80
|
}
|
|
81
81
|
function describeClawMessageTool(input) {
|
|
82
82
|
const account = resolveAccount(resolveConfig(input));
|
|
@@ -426,7 +426,7 @@ export const clawMessengerPlugin = {
|
|
|
426
426
|
// versions doesn't include it. Newer OpenClaw calls this; older versions ignore it.
|
|
427
427
|
clawMessengerPlugin.describeMessageTool = describeClawMessageTool;
|
|
428
428
|
// -- Inbound message handler --
|
|
429
|
-
export async function handleInboundMessage(data, accountId, account, ctx) {
|
|
429
|
+
export async function handleInboundMessage(data, accountId, account, ctx, wsOverride) {
|
|
430
430
|
const normalized = normalizeInboundMessage(data);
|
|
431
431
|
if (!normalized.ok) {
|
|
432
432
|
ctx.log?.warn?.(`[${accountId}] Dropping inbound message: ${normalized.reason}`);
|
|
@@ -434,7 +434,7 @@ export async function handleInboundMessage(data, accountId, account, ctx) {
|
|
|
434
434
|
}
|
|
435
435
|
const { from, text, messageId, attachments, isGroup, chatId, participants, } = normalized.message;
|
|
436
436
|
const runtime = getRuntime();
|
|
437
|
-
const cfg = runtime.config.
|
|
437
|
+
const cfg = runtime.config.current();
|
|
438
438
|
// Resolve routing — group by chatId, DM by sender phone
|
|
439
439
|
let rawRoute;
|
|
440
440
|
try {
|
|
@@ -482,13 +482,11 @@ export async function handleInboundMessage(data, accountId, account, ctx) {
|
|
|
482
482
|
const rawBody = text || (allMedia.length > 0 ? "<media:image>" : "");
|
|
483
483
|
if (!rawBody)
|
|
484
484
|
return;
|
|
485
|
-
const body = runtime.channel.reply.
|
|
485
|
+
const body = runtime.channel.reply.formatAgentEnvelope({
|
|
486
486
|
channel: "Claw Messenger",
|
|
487
487
|
from,
|
|
488
488
|
timestamp: Date.now(),
|
|
489
489
|
body: rawBody,
|
|
490
|
-
chatType: isGroup ? "group" : "direct",
|
|
491
|
-
sender: { id: from },
|
|
492
490
|
previousTimestamp,
|
|
493
491
|
envelope: envelopeOptions,
|
|
494
492
|
});
|
|
@@ -523,7 +521,7 @@ export async function handleInboundMessage(data, accountId, account, ctx) {
|
|
|
523
521
|
sessionKey: ctxPayload.SessionKey ?? routeSessionKey,
|
|
524
522
|
ctx: ctxPayload,
|
|
525
523
|
}).catch(() => { });
|
|
526
|
-
const ws = wsClients.get(accountId);
|
|
524
|
+
const ws = wsOverride ?? wsClients.get(accountId);
|
|
527
525
|
// Mark as read + start typing (DM only — skip for groups)
|
|
528
526
|
if (!isGroup && ws) {
|
|
529
527
|
ws.send({ type: "read", to: from });
|
package/dist/index.js
CHANGED
|
@@ -39,18 +39,16 @@ const plugin = {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
const runtime = getRuntime();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
...(cfg.channels?.["claw-messenger"] ?? {}),
|
|
42
|
+
await runtime.config.mutateConfigFile({
|
|
43
|
+
afterWrite: { mode: "auto" },
|
|
44
|
+
mutate(draft) {
|
|
45
|
+
draft.channels ??= {};
|
|
46
|
+
draft.channels["claw-messenger"] = {
|
|
47
|
+
...(draft.channels["claw-messenger"] ?? {}),
|
|
49
48
|
preferredService: service,
|
|
50
|
-
}
|
|
49
|
+
};
|
|
51
50
|
},
|
|
52
|
-
};
|
|
53
|
-
await runtime.config.writeConfigFile(updated);
|
|
51
|
+
});
|
|
54
52
|
return {
|
|
55
53
|
content: [{ type: "text", text: JSON.stringify({ ok: true, preferredService: service }) }],
|
|
56
54
|
};
|
|
@@ -99,7 +97,7 @@ const plugin = {
|
|
|
99
97
|
const ws = getWsClient(status.accountId);
|
|
100
98
|
const diagnostics = ws?.getDiagnostics() ?? { errors: [], connectionLog: [] };
|
|
101
99
|
const report = {
|
|
102
|
-
plugin_version: "0.1.
|
|
100
|
+
plugin_version: "0.1.18",
|
|
103
101
|
node_version: process.version,
|
|
104
102
|
connected: status.connected,
|
|
105
103
|
server_url: status.serverUrl,
|
|
@@ -111,7 +109,7 @@ const plugin = {
|
|
|
111
109
|
if (submit && status.connected) {
|
|
112
110
|
try {
|
|
113
111
|
const runtime = getRuntime();
|
|
114
|
-
const cfg = runtime.config.
|
|
112
|
+
const cfg = runtime.config.current();
|
|
115
113
|
const account = (cfg.channels?.["claw-messenger"] ?? {});
|
|
116
114
|
const apiKey = account.apiKey ?? "";
|
|
117
115
|
const serverUrl = account.serverUrl ?? "https://claw-messenger.onrender.com";
|
|
@@ -177,18 +175,16 @@ const plugin = {
|
|
|
177
175
|
return { text: `Invalid service "${arg}". Must be one of: ${VALID_SERVICES.join(", ")}` };
|
|
178
176
|
}
|
|
179
177
|
const runtime = getRuntime();
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
...(cfg.channels?.["claw-messenger"] ?? {}),
|
|
178
|
+
await runtime.config.mutateConfigFile({
|
|
179
|
+
afterWrite: { mode: "auto" },
|
|
180
|
+
mutate(draft) {
|
|
181
|
+
draft.channels ??= {};
|
|
182
|
+
draft.channels["claw-messenger"] = {
|
|
183
|
+
...(draft.channels["claw-messenger"] ?? {}),
|
|
187
184
|
preferredService: match,
|
|
188
|
-
}
|
|
185
|
+
};
|
|
189
186
|
},
|
|
190
|
-
};
|
|
191
|
-
await runtime.config.writeConfigFile(updated);
|
|
187
|
+
});
|
|
192
188
|
return { text: `Preferred service switched to ${match}` };
|
|
193
189
|
},
|
|
194
190
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emotion-machine/claw-messenger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
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",
|
|
@@ -59,6 +59,9 @@
|
|
|
59
59
|
"install": {
|
|
60
60
|
"npmSpec": "@emotion-machine/claw-messenger",
|
|
61
61
|
"defaultChoice": "npm"
|
|
62
|
+
},
|
|
63
|
+
"compat": {
|
|
64
|
+
"pluginApi": ">=2026.8.1"
|
|
62
65
|
}
|
|
63
66
|
},
|
|
64
67
|
"dependencies": {
|
|
@@ -66,6 +69,14 @@
|
|
|
66
69
|
"ws": "^8.18.0",
|
|
67
70
|
"zod": "^4.3.6"
|
|
68
71
|
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"openclaw": ">=2026.8.1"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"openclaw": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
69
80
|
"devDependencies": {
|
|
70
81
|
"@types/node": "^20.14.0",
|
|
71
82
|
"@types/ws": "^8.5.0",
|
package/src/types/openclaw.d.ts
CHANGED
|
@@ -150,8 +150,11 @@ declare module "openclaw/plugin-sdk/channel-core" {
|
|
|
150
150
|
export interface PluginRuntime {
|
|
151
151
|
version: string;
|
|
152
152
|
config: {
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
current(): OpenclawConfig;
|
|
154
|
+
mutateConfigFile<T = void>(params: {
|
|
155
|
+
afterWrite: { mode: "auto" | "restart" | "none"; reason?: string };
|
|
156
|
+
mutate(draft: OpenclawConfig): T | void;
|
|
157
|
+
}): Promise<{ result?: T; [key: string]: any }>;
|
|
155
158
|
};
|
|
156
159
|
system: {
|
|
157
160
|
enqueueSystemEvent(event: any): void;
|
|
@@ -175,7 +178,7 @@ declare module "openclaw/plugin-sdk/channel-core" {
|
|
|
175
178
|
reply: {
|
|
176
179
|
dispatchReplyWithBufferedBlockDispatcher(ctx: any): Promise<any>;
|
|
177
180
|
resolveEffectiveMessagesConfig(cfg: OpenclawConfig, agentId?: string): any;
|
|
178
|
-
|
|
181
|
+
formatAgentEnvelope(ctx: any): string;
|
|
179
182
|
finalizeInboundContext(ctx: any): any;
|
|
180
183
|
resolveEnvelopeFormatOptions(cfg: OpenclawConfig): any;
|
|
181
184
|
[key: string]: any;
|