@emotion-machine/claw-messenger 0.1.10 → 0.1.12

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
@@ -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: () => ["send", "react"],
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
- // Handle abort
388
- const stopHandler = () => {
389
- ctx.log?.info(`[${resolvedAccountId}] Stopping Claw Messenger provider`);
390
- ws.stop();
391
- wsClients.delete(resolvedAccountId);
392
- };
393
- ctx.abortSignal?.addEventListener("abort", stopHandler);
394
- return {
395
- stop: () => {
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 = (cfg) => {
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.7",
102
+ plugin_version: "0.1.11",
103
103
  node_version: process.version,
104
104
  connected: status.connected,
105
105
  server_url: status.serverUrl,
package/dist/ws/client.js CHANGED
@@ -16,6 +16,7 @@ const PONG_TIMEOUT_MS = 10_000;
16
16
  /** Close codes that indicate the client should NOT reconnect. */
17
17
  const NO_RECONNECT_CODES = new Set([
18
18
  1008, // Policy violation — connection limit reached (evicted)
19
+ 4001, // Auth failure: missing/invalid/revoked key, or tenant not found
19
20
  4003, // Subscription inactive (cancelled/expired)
20
21
  ]);
21
22
  export class WsClient {
@@ -2,6 +2,14 @@
2
2
  "id": "claw-messenger",
3
3
  "description": "Integrate Claw Messenger to send and receive messages across multiple platforms including iMessage, RCS, and SMS.",
4
4
  "channels": ["claw-messenger"],
5
+ "contracts": {
6
+ "tools": [
7
+ "claw_messenger_status",
8
+ "claw_messenger_switch_service",
9
+ "claw_messenger_create_group",
10
+ "claw_messenger_diagnose"
11
+ ]
12
+ },
5
13
  "configSchema": {
6
14
  "type": "object",
7
15
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@emotion-machine/claw-messenger",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
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",
7
7
  "types": "dist/index.d.ts",
8
8
  "homepage": "https://clawmessenger.com",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://www.npmjs.com/package/@emotion-machine/claw-messenger"
12
+ },
13
+ "bugs": {
14
+ "url": "https://www.npmjs.com/package/@emotion-machine/claw-messenger",
15
+ "email": "hello@emotionmachine.ai"
16
+ },
9
17
  "keywords": [
10
18
  "openclaw",
11
19
  "openclaw-plugin",