@soimy/dingtalk 3.1.3 → 3.1.4

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/src/channel.ts +15 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soimy/dingtalk",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "DingTalk (钉钉) channel plugin for OpenClaw",
5
5
  "keywords": [
6
6
  "bot",
@@ -35,6 +35,7 @@
35
35
  "format:check": "oxfmt --check package.json tsconfig.json index.ts src/*.ts",
36
36
  "lint": "oxlint --type-aware index.ts src",
37
37
  "lint:fix": "oxlint --type-aware --fix index.ts src && pnpm format",
38
+ "monitor:stream": "node scripts/dingtalk-stream-monitor.mjs",
38
39
  "test": "vitest run",
39
40
  "test:coverage": "vitest run --coverage",
40
41
  "type-check": "tsc -p tsconfig.json"
package/src/channel.ts CHANGED
@@ -292,7 +292,7 @@ export const dingtalkPlugin: DingTalkChannelPlugin = {
292
292
  clientId: config.clientId,
293
293
  clientSecret: config.clientSecret,
294
294
  debug: config.debug || false,
295
- keepAlive: true,
295
+ keepAlive: false,
296
296
  });
297
297
 
298
298
  // Disable built-in reconnect so ConnectionManager owns all retry/backoff behavior.
@@ -302,11 +302,20 @@ export const dingtalkPlugin: DingTalkChannelPlugin = {
302
302
  const messageId = res.headers?.messageId;
303
303
  const stats = getInboundCounters(account.accountId);
304
304
  stats.received += 1;
305
- try {
306
- if (messageId) {
305
+ const acknowledge = () => {
306
+ if (!messageId) {
307
+ return;
308
+ }
309
+ try {
307
310
  client.socketCallBackResponse(messageId, { success: true });
308
311
  stats.acked += 1;
312
+ } catch (ackError: any) {
313
+ ctx.log?.warn?.(
314
+ `[${account.accountId}] Failed to acknowledge callback ${messageId}: ${ackError.message}`,
315
+ );
309
316
  }
317
+ };
318
+ try {
310
319
  const data = JSON.parse(res.data) as DingTalkInboundMessage;
311
320
 
312
321
  // Message deduplication key is bot-scoped to avoid cross-account conflicts.
@@ -326,6 +335,7 @@ export const dingtalkPlugin: DingTalkChannelPlugin = {
326
335
  dingtalkConfig: config,
327
336
  });
328
337
  stats.processed += 1;
338
+ acknowledge();
329
339
  if (stats.received % INBOUND_COUNTER_LOG_EVERY === 0) {
330
340
  logInboundCounters(ctx.log, account.accountId, "periodic");
331
341
  }
@@ -335,6 +345,7 @@ export const dingtalkPlugin: DingTalkChannelPlugin = {
335
345
  if (isMessageProcessed(dedupKey)) {
336
346
  ctx.log?.debug?.(`[${account.accountId}] Skipping duplicate message: ${dedupKey}`);
337
347
  stats.dedupSkipped += 1;
348
+ acknowledge();
338
349
  logInboundCounters(ctx.log, account.accountId, "dedup-skipped");
339
350
  return;
340
351
  }
@@ -360,6 +371,7 @@ export const dingtalkPlugin: DingTalkChannelPlugin = {
360
371
  });
361
372
  stats.processed += 1;
362
373
  markMessageProcessed(dedupKey);
374
+ acknowledge();
363
375
  if (stats.received % INBOUND_COUNTER_LOG_EVERY === 0) {
364
376
  logInboundCounters(ctx.log, account.accountId, "periodic");
365
377
  }