@emotion-machine/claw-messenger 0.1.10 → 0.1.11
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 +37 -23
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/channel.js
CHANGED
|
@@ -38,6 +38,7 @@ function normalizeAccountIdCompat(accountId) {
|
|
|
38
38
|
return fallback;
|
|
39
39
|
}
|
|
40
40
|
const DEFAULT_ACCOUNT_ID = normalizeAccountIdCompat(pluginSdk.DEFAULT_ACCOUNT_ID);
|
|
41
|
+
const MESSAGE_TOOL_ACTIONS = ["send", "react"];
|
|
41
42
|
function resolveAccount(cfg, accountId) {
|
|
42
43
|
const cloudConfig = (cfg.channels?.["claw-messenger"] ?? {});
|
|
43
44
|
return {
|
|
@@ -81,6 +82,21 @@ export async function createGroup(to, text) {
|
|
|
81
82
|
const result = await sendToNewGroup(ws, to, text, account.preferredService);
|
|
82
83
|
return { ok: true, ...result };
|
|
83
84
|
}
|
|
85
|
+
function resolveConfig(input) {
|
|
86
|
+
if (input && "channels" in input)
|
|
87
|
+
return input;
|
|
88
|
+
return input?.cfg ?? getRuntime().config.loadConfig();
|
|
89
|
+
}
|
|
90
|
+
function describeClawMessageTool(input) {
|
|
91
|
+
const account = resolveAccount(resolveConfig(input));
|
|
92
|
+
const ws = wsClients.get(account.accountId);
|
|
93
|
+
const connected = Boolean(ws?.connected);
|
|
94
|
+
return {
|
|
95
|
+
actions: connected ? MESSAGE_TOOL_ACTIONS : [],
|
|
96
|
+
capabilities: [],
|
|
97
|
+
schema: null,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
84
100
|
// -- Channel Plugin --
|
|
85
101
|
const meta = {
|
|
86
102
|
label: "Claw Messenger",
|
|
@@ -182,7 +198,8 @@ export const clawMessengerPlugin = {
|
|
|
182
198
|
},
|
|
183
199
|
// Legacy API (OpenClaw <2026.3.22): kept for backward compatibility
|
|
184
200
|
actions: {
|
|
185
|
-
listActions: () => [
|
|
201
|
+
listActions: () => [...MESSAGE_TOOL_ACTIONS],
|
|
202
|
+
describeMessageTool: describeClawMessageTool,
|
|
186
203
|
handleAction: async ({ action, params, cfg }) => {
|
|
187
204
|
const account = resolveAccount(cfg);
|
|
188
205
|
const ws = wsClients.get(account.accountId);
|
|
@@ -384,19 +401,25 @@ export const clawMessengerPlugin = {
|
|
|
384
401
|
});
|
|
385
402
|
ws.connect();
|
|
386
403
|
wsClients.set(resolvedAccountId, ws);
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
stopHandler();
|
|
404
|
+
return new Promise((resolve) => {
|
|
405
|
+
let stopped = false;
|
|
406
|
+
const stopHandler = () => {
|
|
407
|
+
if (stopped)
|
|
408
|
+
return;
|
|
409
|
+
stopped = true;
|
|
410
|
+
ctx.log?.info(`[${resolvedAccountId}] Stopping Claw Messenger provider`);
|
|
411
|
+
ws.stop();
|
|
412
|
+
wsClients.delete(resolvedAccountId);
|
|
397
413
|
ctx.abortSignal?.removeEventListener("abort", stopHandler);
|
|
398
|
-
|
|
399
|
-
|
|
414
|
+
resolve();
|
|
415
|
+
};
|
|
416
|
+
if (ctx.abortSignal?.aborted) {
|
|
417
|
+
stopHandler();
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
ctx.abortSignal?.addEventListener("abort", stopHandler);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
400
423
|
},
|
|
401
424
|
logoutAccount: async ({ cfg }) => {
|
|
402
425
|
const account = resolveAccount(cfg);
|
|
@@ -412,16 +435,7 @@ export const clawMessengerPlugin = {
|
|
|
412
435
|
// OpenClaw 2026.3.22+ message-action-discovery API.
|
|
413
436
|
// Added as a runtime property because the ChannelPlugin type from older SDK
|
|
414
437
|
// versions doesn't include it. Newer OpenClaw calls this; older versions ignore it.
|
|
415
|
-
clawMessengerPlugin.describeMessageTool =
|
|
416
|
-
const account = resolveAccount(cfg);
|
|
417
|
-
const ws = wsClients.get(account.accountId);
|
|
418
|
-
const connected = Boolean(ws?.connected);
|
|
419
|
-
return {
|
|
420
|
-
actions: connected ? ["send", "react"] : [],
|
|
421
|
-
capabilities: [],
|
|
422
|
-
schema: null,
|
|
423
|
-
};
|
|
424
|
-
};
|
|
438
|
+
clawMessengerPlugin.describeMessageTool = describeClawMessageTool;
|
|
425
439
|
// -- Inbound message handler --
|
|
426
440
|
async function handleInboundMessage(data, accountId, account, ctx) {
|
|
427
441
|
const from = data.from;
|
package/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ const plugin = {
|
|
|
99
99
|
const ws = getWsClient(status.accountId);
|
|
100
100
|
const diagnostics = ws?.getDiagnostics() ?? { errors: [], connectionLog: [] };
|
|
101
101
|
const report = {
|
|
102
|
-
plugin_version: "0.1.
|
|
102
|
+
plugin_version: "0.1.11",
|
|
103
103
|
node_version: process.version,
|
|
104
104
|
connected: status.connected,
|
|
105
105
|
server_url: status.serverUrl,
|
package/package.json
CHANGED