@yaoyuanchao/dingtalk 1.7.2 → 1.7.3

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 +1 -1
  2. package/src/monitor.ts +15 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaoyuanchao/dingtalk",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "type": "module",
5
5
  "description": "DingTalk channel plugin for ClawdBot/OpenClaw with Stream Mode support",
6
6
  "license": "MIT",
package/src/monitor.ts CHANGED
@@ -1656,6 +1656,7 @@ async function dispatchWithFullPipeline(params: {
1656
1656
  log, setStatus, onFirstReply } = params;
1657
1657
 
1658
1658
  let firstReplyFired = false;
1659
+ let typingSafetyTimeout: ReturnType<typeof setTimeout> | null = null;
1659
1660
 
1660
1661
  // 1. Resolve agent route via own bindings matching (like official plugin).
1661
1662
  // OpenClaw's resolveAgentRoute doesn't handle accountId correctly for multi-account.
@@ -1751,6 +1752,7 @@ async function dispatchWithFullPipeline(params: {
1751
1752
  // Recall typing indicator on first delivery
1752
1753
  if (!firstReplyFired && onFirstReply) {
1753
1754
  firstReplyFired = true;
1755
+ if (typingSafetyTimeout) { clearTimeout(typingSafetyTimeout); typingSafetyTimeout = null; }
1754
1756
  await onFirstReply().catch((err) => {
1755
1757
  log?.info?.("[dingtalk] onFirstReply error: " + err);
1756
1758
  });
@@ -1778,12 +1780,20 @@ async function dispatchWithFullPipeline(params: {
1778
1780
  await rt.channel.reply.dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyOptions });
1779
1781
  } finally {
1780
1782
  markDispatchIdle();
1781
- // Recall typing indicator if no reply was sent (queued or error).
1782
- // Note: when a message is queued (session has active run), dispatch returns
1783
- // quickly with no delivery this is normal, not an error. The queued message
1784
- // will be processed after the current run completes.
1783
+ // Don't recall typing immediately dispatchReplyFromConfig resolves when
1784
+ // dispatch is *initiated*, not when the agent finishes. The agent may still
1785
+ // be doing tool calls for minutes before producing the first text reply.
1786
+ // The deliver callback above handles the normal recall on first delivery.
1787
+ // Set a safety timeout to recall if no delivery ever arrives (edge case).
1785
1788
  if (!firstReplyFired && onFirstReply) {
1786
- await onFirstReply().catch(() => {});
1789
+ const TYPING_SAFETY_TIMEOUT_MS = 3 * 60 * 1000; // 3 minutes
1790
+ typingSafetyTimeout = setTimeout(async () => {
1791
+ if (!firstReplyFired && onFirstReply) {
1792
+ firstReplyFired = true;
1793
+ log?.info?.('[dingtalk] Typing safety timeout — recalling after no delivery');
1794
+ await onFirstReply().catch(() => {});
1795
+ }
1796
+ }, TYPING_SAFETY_TIMEOUT_MS);
1787
1797
  }
1788
1798
  }
1789
1799