@xmanrui/dsh-im 4.35.1 → 4.36.1

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 (65) hide show
  1. package/PROACTIVE_DELIVERY.en.md +50 -0
  2. package/PROACTIVE_DELIVERY.md +22 -0
  3. package/README.en.md +3 -1
  4. package/README.md +3 -1
  5. package/lib/client.js +30 -8
  6. package/lib/index.js +309 -309
  7. package/package.json +3 -3
  8. package/plugin-src/client/connection-error.js +2 -1
  9. package/plugin-src/host/channels/dingtalk/production.mjs +1 -1
  10. package/plugin-src/host/channels/feishu/production.mjs +4 -2
  11. package/plugin-src/host/channels/matrix/production.mjs +1 -1
  12. package/plugin-src/host/channels/qq/production.mjs +1 -1
  13. package/plugin-src/host/channels/shared/production.mjs +1 -1
  14. package/plugin-src/host/channels/slack/production.mjs +1 -1
  15. package/plugin-src/host/channels/wecom/production.mjs +1 -1
  16. package/plugin-src/host/channels/wecom-app/production.mjs +1 -1
  17. package/plugin-src/host/channels/weixin/production.mjs +1 -1
  18. package/plugin-src/host/channels/whatsapp/production.mjs +1 -1
  19. package/plugin-src/host/delivery-adapter.mjs +60 -12
  20. package/plugin-src/host/delivery-service.mjs +127 -1
  21. package/plugin-src/host/delivery-suggestions.mjs +2 -1
  22. package/plugin-src/host/harness-connection.mjs +3 -7
  23. package/plugin-src/host/index.mjs +5 -2
  24. package/plugin-src/host/modern-harness-api.mjs +139 -4
  25. package/src/channels/dingtalk/dingtalk-bridge.mjs +6 -0
  26. package/src/channels/dingtalk/dingtalk-controller.mjs +14 -0
  27. package/src/channels/dingtalk/dingtalk-runtime.mjs +10 -0
  28. package/src/channels/discord/discord-runtime.mjs +13 -0
  29. package/src/channels/feishu/bridge.mjs +30 -13
  30. package/src/channels/feishu/external-consumer.mjs +118 -0
  31. package/src/channels/feishu/feishu-runtime.mjs +72 -3
  32. package/src/channels/feishu/history-reader.mjs +92 -0
  33. package/src/channels/feishu/multi-bot-controller.mjs +130 -2
  34. package/src/channels/feishu/nearby-history.mjs +72 -0
  35. package/src/channels/feishu/plugin-config-store.mjs +1 -0
  36. package/src/channels/matrix/matrix-controller.mjs +9 -0
  37. package/src/channels/matrix/matrix-runtime.mjs +14 -0
  38. package/src/channels/qq/qq-bridge.mjs +6 -0
  39. package/src/channels/qq/qq-controller.mjs +14 -0
  40. package/src/channels/qq/qq-runtime.mjs +10 -0
  41. package/src/channels/shared/connection-error.mjs +1 -0
  42. package/src/channels/shared/diagnostic-details.mjs +7 -1
  43. package/src/channels/shared/harness-approval.mjs +84 -7
  44. package/src/channels/shared/harness-client.mjs +51 -40
  45. package/src/channels/shared/i18n-en/diagnostics.mjs +3 -0
  46. package/src/channels/shared/i18n-en/shared-c.mjs +3 -0
  47. package/src/channels/shared/message-failure.mjs +1 -1
  48. package/src/channels/shared/text-harness-bridge.mjs +6 -0
  49. package/src/channels/shared/token-bot-controller.mjs +16 -0
  50. package/src/channels/slack/manifest.mjs +1 -0
  51. package/src/channels/slack/slack-api.mjs +7 -0
  52. package/src/channels/slack/slack-controller.mjs +14 -0
  53. package/src/channels/slack/slack-runtime.mjs +12 -0
  54. package/src/channels/telegram/telegram-runtime.mjs +10 -0
  55. package/src/channels/wecom/wecom-bridge.mjs +6 -0
  56. package/src/channels/wecom/wecom-controller.mjs +14 -0
  57. package/src/channels/wecom/wecom-runtime.mjs +10 -0
  58. package/src/channels/wecom-app/wecom-app-bridge.mjs +6 -0
  59. package/src/channels/wecom-app/wecom-app-controller.mjs +14 -0
  60. package/src/channels/wecom-app/wecom-app-runtime.mjs +10 -0
  61. package/src/channels/weixin/weixin-bridge.mjs +6 -0
  62. package/src/channels/weixin/weixin-controller.mjs +14 -0
  63. package/src/channels/weixin/weixin-runtime.mjs +10 -0
  64. package/src/channels/whatsapp/whatsapp-controller.mjs +14 -0
  65. package/src/channels/whatsapp/whatsapp-runtime.mjs +10 -0
@@ -248,6 +248,20 @@ export class WhatsappController {
248
248
  });
249
249
  }
250
250
 
251
+ async presentSessionSyncApproval(botId, target, interaction, options = {}) {
252
+ const config = this.#configStore.get(botId);
253
+ if (!config) throw new Error('Unknown WhatsApp bot');
254
+ return this.#withBotTransition(botId, async () => {
255
+ const runtime = this.#runtimes.get(botId);
256
+ if (!runtime?.status?.ready || typeof runtime.presentSessionSyncApproval !== 'function') {
257
+ const error = new Error(t('WhatsApp机器人尚未连接'));
258
+ error.code = 'bot-not-connected';
259
+ throw error;
260
+ }
261
+ return runtime.presentSessionSyncApproval(target, interaction, options);
262
+ });
263
+ }
264
+
251
265
  async setAccessPolicy(botId, value) {
252
266
  if (this.#closed) throw new Error('WhatsApp controller is closed');
253
267
  const accessPolicy = normalizeWhatsappAccessPolicy(value);
@@ -876,6 +876,16 @@ export class WhatsappRuntime {
876
876
  return { sent: true };
877
877
  }
878
878
 
879
+ async presentSessionSyncApproval(target, interaction, options = {}) {
880
+ if (!this.#status.ready || !this.#bridge) return false;
881
+ const actor = typeof target?.route?.jid === 'string' ? target.route.jid.trim() : '';
882
+ if (!actor) return false;
883
+ return this.#bridge.presentSessionSyncApproval(interaction, {
884
+ key: options.key, actor, validate: options.validate,
885
+ send: (text) => this.sendProactiveText(target, text),
886
+ }, options);
887
+ }
888
+
879
889
  async sendProactiveText(target, text, { signal } = {}) {
880
890
  const jid = typeof target?.route?.jid === 'string' ? target.route.jid.trim() : '';
881
891
  const validUser = target?.kind === 'user'