@xmanrui/dsh-im 4.36.1 → 4.38.0

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 (63) hide show
  1. package/README.en.md +14 -2
  2. package/README.md +13 -1
  3. package/assets/logo-plugin-message-link-gradient.webp +0 -0
  4. package/lib/client.js +417 -189
  5. package/lib/index.js +317 -316
  6. package/package.json +2 -2
  7. package/plugin-src/client/bot-general-settings.js +120 -0
  8. package/plugin-src/client/channels/dingtalk/api.js +3 -1
  9. package/plugin-src/client/channels/feishu/api.js +6 -2
  10. package/plugin-src/client/channels/qq/api.js +3 -1
  11. package/plugin-src/client/channels/shared/token-api.js +3 -1
  12. package/plugin-src/client/channels/wecom/api.js +3 -1
  13. package/plugin-src/client/channels/wecom-app/api.js +3 -1
  14. package/plugin-src/client/channels/weixin/api.js +3 -1
  15. package/plugin-src/client/channels/whatsapp/api.js +3 -1
  16. package/plugin-src/client/delivery-settings.js +5 -1
  17. package/plugin-src/client/i18n.js +14 -0
  18. package/plugin-src/client/styles.js +19 -0
  19. package/plugin-src/host/channels/dingtalk/rpc.mjs +11 -0
  20. package/plugin-src/host/channels/email/rpc.mjs +1 -0
  21. package/plugin-src/host/channels/feishu/production.mjs +1 -0
  22. package/plugin-src/host/channels/feishu/rpc.mjs +31 -0
  23. package/plugin-src/host/channels/imessage/rpc.mjs +1 -0
  24. package/plugin-src/host/channels/matrix/rpc.mjs +10 -0
  25. package/plugin-src/host/channels/qq/rpc.mjs +11 -0
  26. package/plugin-src/host/channels/shared/rpc.mjs +9 -0
  27. package/plugin-src/host/channels/slack/rpc.mjs +10 -0
  28. package/plugin-src/host/channels/wecom/rpc.mjs +11 -0
  29. package/plugin-src/host/channels/wecom-app/rpc.mjs +10 -0
  30. package/plugin-src/host/channels/weixin/rpc.mjs +11 -0
  31. package/plugin-src/host/channels/whatsapp/rpc.mjs +11 -0
  32. package/scripts/verify-package.mjs +11 -6
  33. package/src/channels/dingtalk/dingtalk-bridge.mjs +31 -2
  34. package/src/channels/dingtalk/dingtalk-menu.mjs +1 -1
  35. package/src/channels/dingtalk/dingtalk-runtime.mjs +2 -1
  36. package/src/channels/discord/discord-runtime.mjs +3 -1
  37. package/src/channels/feishu/bridge.mjs +91 -15
  38. package/src/channels/feishu/feishu-cards.mjs +16 -11
  39. package/src/channels/feishu/feishu-runtime.mjs +10 -1
  40. package/src/channels/feishu/multi-bot-controller.mjs +18 -0
  41. package/src/channels/feishu/plugin-config-store.mjs +2 -1
  42. package/src/channels/feishu/slash-command-panel.mjs +1 -0
  43. package/src/channels/feishu/step-push-mode.mjs +21 -0
  44. package/src/channels/matrix/matrix-crypto.mjs +19 -5
  45. package/src/channels/qq/qq-bridge.mjs +40 -2
  46. package/src/channels/qq/qq-menu.mjs +2 -2
  47. package/src/channels/shared/bot-workspace-store.mjs +69 -1
  48. package/src/channels/shared/busy-message-dispatcher.mjs +94 -0
  49. package/src/channels/shared/clear-command.mjs +85 -0
  50. package/src/channels/shared/command-catalog.mjs +3 -0
  51. package/src/channels/shared/command-permission.mjs +2 -0
  52. package/src/channels/shared/control-command.mjs +20 -11
  53. package/src/channels/shared/harness-approval.mjs +102 -2
  54. package/src/channels/shared/i18n-en/feishu.mjs +6 -4
  55. package/src/channels/shared/i18n-en/qq.mjs +2 -1
  56. package/src/channels/shared/i18n-en/shared-b.mjs +27 -0
  57. package/src/channels/shared/i18n-en/shared-c.mjs +4 -0
  58. package/src/channels/shared/message-mode.mjs +19 -0
  59. package/src/channels/shared/text-harness-bridge.mjs +48 -5
  60. package/src/channels/wecom/wecom-bridge.mjs +26 -2
  61. package/src/channels/wecom/wecom-cards.mjs +1 -1
  62. package/src/channels/wecom-app/wecom-app-bridge.mjs +26 -2
  63. package/src/channels/weixin/weixin-bridge.mjs +22 -2
@@ -1,3 +1,4 @@
1
+ import { BusyMessageDispatcher, canAutomaticallySteer } from '../shared/busy-message-dispatcher.mjs';
1
2
  import { createDeferredDeliveryCoordinator, deferredOutcomeText } from '../shared/deferred-delivery-coordinator.mjs';
2
3
  import {
3
4
  DEFAULT_WEIXIN_MAX_MESSAGE_CHARS,
@@ -21,6 +22,7 @@ import {
21
22
  isBatchInputCommand,
22
23
  } from '../shared/batch-input.mjs';
23
24
  import { runCompactCommand } from '../shared/compact-command.mjs';
25
+ import { isClearCommand, runClearCommand } from '../shared/clear-command.mjs';
24
26
  import { isHistoryCommand, runHistoryCommand } from '../shared/history-command.mjs';
25
27
  import {
26
28
  isControlCommand,
@@ -91,6 +93,7 @@ const HELP_TEXT = () => [
91
93
  t('直接发送文字、图片、文件或带文字识别结果的语音即可继续当前会话。'),
92
94
  t('/new 开启一个全新会话'),
93
95
  t('/compact 压缩当前会话的较早上下文'),
96
+ t('/clear 清空当前会话上下文(保留 Session 绑定和历史记录)'),
94
97
  t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
95
98
  t('/workspace 工作区序号或绝对路径 切换工作区'),
96
99
  t('/workspacelist 列出工作区绝对路径'),
@@ -313,6 +316,7 @@ export class WeixinHarnessBridge {
313
316
  #typingKeepaliveMs;
314
317
  #signal;
315
318
  #queues = new Map();
319
+ #busyMessages = new BusyMessageDispatcher();
316
320
  #pendingInteractions = new Map();
317
321
  #interactionKeys = new Map();
318
322
  // Keep the accepted configuration through the existing queue/reply lifecycle.
@@ -457,7 +461,8 @@ export class WeixinHarnessBridge {
457
461
  );
458
462
  }
459
463
  }
460
- const commandRunner = isHistoryCommand(commandText) ? runHistoryCommand
464
+ const commandRunner = isClearCommand(commandText) ? runClearCommand
465
+ : isHistoryCommand(commandText) ? runHistoryCommand
461
466
  : hasWeixinFileItems(message) ? null : isControlCommand(commandText)
462
467
  ? runControlCommand
463
468
  : (isModelCommand(commandText)
@@ -542,7 +547,20 @@ export class WeixinHarnessBridge {
542
547
  pending.queue = current;
543
548
  return current;
544
549
  }
545
- return this.#enqueueMessage(message, messageId, key);
550
+ return this.#busyMessages.dispatch({
551
+ key, messageId, text: commandText,
552
+ eligible: () => isNativeWeixinText(message) && !extractWeixinReplyReference(message)
553
+ && canAutomaticallySteer(this.#accessPolicy, 'direct', sender),
554
+ harness: this.#harness, state: this.#state, status: this.#status,
555
+ signal: this.#signal, control: { owner: this, key }, logger: this.#logger,
556
+ acceptedMessageIds: this.#acceptedMessageIds,
557
+ pendingInteraction: () => this.#pendingInteractions.has(key) || this.#approvals.hasPending(key),
558
+ enhancement: this.#acceptedMessageIds.get(messageId),
559
+ isQueued: () => this.#queues.has(key),
560
+ enqueue: (options) => this.#enqueueMessage(message, messageId, key, options),
561
+ send: (reply) => this.#sendOutOfBand(key, sender, reply, contextToken, runId),
562
+ onError: (error) => this.#handleInteractionFailure(message, messageId, error),
563
+ });
546
564
  }
547
565
 
548
566
  #enqueueMessage(message, messageId, key, {
@@ -684,6 +702,7 @@ export class WeixinHarnessBridge {
684
702
  }
685
703
 
686
704
  async waitForIdle() {
705
+ await this.#busyMessages.whenIdle();
687
706
  await Promise.allSettled([
688
707
  ...this.#queues.values(),
689
708
  ...[...this.#pendingInteractions.values()].flatMap((pending) => (
@@ -724,6 +743,7 @@ export class WeixinHarnessBridge {
724
743
  hasFiles: hasWeixinFileItems(message),
725
744
  pendingInteraction: this.#pendingInteractions.has(key)
726
745
  || this.#approvals.hasPending(key),
746
+ busy: this.#queues.has(key) || this.#batchInputs.status(key).phase !== 'idle',
727
747
  control: { owner: this, key },
728
748
  deferredDelivery: this.#deferred,
729
749
  enhancement: captureContextEnhancementSource(