@botharness/im-provider 4.32.0-botharness.15

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 (423) hide show
  1. package/LICENSE +21 -0
  2. package/PROVENANCE.json +25 -0
  3. package/README.en.md +445 -0
  4. package/README.md +448 -0
  5. package/THIRD_PARTY_NOTICES.md +93 -0
  6. package/assets/dingtalk-menu-template.json +6 -0
  7. package/assets/logo-dsh-im-chinese-readme-3x2.png +0 -0
  8. package/assets/logo-dsh-im-connecting-readme-3x2.png +0 -0
  9. package/assets/logo-dsh-im-connecting-square-v4.png +0 -0
  10. package/assets/logo-icon.png +0 -0
  11. package/assets/logo-plugin-message-link-gradient.webp +0 -0
  12. package/assets/logo-plugin-phone.png +0 -0
  13. package/assets/logo.png +0 -0
  14. package/assets/logo_cn.png +0 -0
  15. package/assets/screenshot-menu-card.png +0 -0
  16. package/cordis.patch.yml +3 -0
  17. package/lib/client.js +20330 -0
  18. package/lib/index.js +604 -0
  19. package/locale/en.json +5 -0
  20. package/locale/zh.json +5 -0
  21. package/package.json +181 -0
  22. package/plugin-src/client/access-policy-settings.js +362 -0
  23. package/plugin-src/client/agent-preset.js +119 -0
  24. package/plugin-src/client/bot-alias.js +169 -0
  25. package/plugin-src/client/build.mjs +38 -0
  26. package/plugin-src/client/channel-card-meta.js +132 -0
  27. package/plugin-src/client/channel-logos.js +190 -0
  28. package/plugin-src/client/channels/dingtalk/api.js +267 -0
  29. package/plugin-src/client/channels/dingtalk/index.js +954 -0
  30. package/plugin-src/client/channels/dingtalk/styles.js +136 -0
  31. package/plugin-src/client/channels/discord/api.js +11 -0
  32. package/plugin-src/client/channels/discord/index.js +25 -0
  33. package/plugin-src/client/channels/discord/styles.js +19 -0
  34. package/plugin-src/client/channels/email/api.js +52 -0
  35. package/plugin-src/client/channels/email/index.js +728 -0
  36. package/plugin-src/client/channels/email/styles.js +51 -0
  37. package/plugin-src/client/channels/feishu/api.js +405 -0
  38. package/plugin-src/client/channels/feishu/group-settings.js +581 -0
  39. package/plugin-src/client/channels/feishu/index.js +1583 -0
  40. package/plugin-src/client/channels/feishu/slash-panel-settings.js +322 -0
  41. package/plugin-src/client/channels/feishu/styles.js +573 -0
  42. package/plugin-src/client/channels/feishu/voice-editor.js +115 -0
  43. package/plugin-src/client/channels/feishu/voice-settings.js +71 -0
  44. package/plugin-src/client/channels/imessage/api.js +12 -0
  45. package/plugin-src/client/channels/imessage/index.js +46 -0
  46. package/plugin-src/client/channels/imessage/styles.js +19 -0
  47. package/plugin-src/client/channels/matrix/api.js +11 -0
  48. package/plugin-src/client/channels/matrix/index.js +151 -0
  49. package/plugin-src/client/channels/matrix/styles.js +36 -0
  50. package/plugin-src/client/channels/office/api.js +46 -0
  51. package/plugin-src/client/channels/office/index.js +153 -0
  52. package/plugin-src/client/channels/office/styles.js +50 -0
  53. package/plugin-src/client/channels/qq/api.js +171 -0
  54. package/plugin-src/client/channels/qq/index.js +593 -0
  55. package/plugin-src/client/channels/qq/styles.js +19 -0
  56. package/plugin-src/client/channels/shared/collapsible-account.js +103 -0
  57. package/plugin-src/client/channels/shared/token-api.js +124 -0
  58. package/plugin-src/client/channels/shared/token-channel.js +495 -0
  59. package/plugin-src/client/channels/slack/api.js +11 -0
  60. package/plugin-src/client/channels/slack/index.js +131 -0
  61. package/plugin-src/client/channels/slack/styles.js +34 -0
  62. package/plugin-src/client/channels/telegram/api.js +11 -0
  63. package/plugin-src/client/channels/telegram/index.js +28 -0
  64. package/plugin-src/client/channels/telegram/styles.js +31 -0
  65. package/plugin-src/client/channels/telegram/thinking-traces.js +25 -0
  66. package/plugin-src/client/channels/wecom/api.js +160 -0
  67. package/plugin-src/client/channels/wecom/index.js +625 -0
  68. package/plugin-src/client/channels/wecom/styles.js +19 -0
  69. package/plugin-src/client/channels/wecom-app/api.js +132 -0
  70. package/plugin-src/client/channels/wecom-app/index.js +634 -0
  71. package/plugin-src/client/channels/wecom-app/styles.js +25 -0
  72. package/plugin-src/client/channels/weixin/api.js +211 -0
  73. package/plugin-src/client/channels/weixin/connection-error.js +1 -0
  74. package/plugin-src/client/channels/weixin/index.js +801 -0
  75. package/plugin-src/client/channels/weixin/styles.js +115 -0
  76. package/plugin-src/client/channels/whatsapp/api.js +152 -0
  77. package/plugin-src/client/channels/whatsapp/index.js +609 -0
  78. package/plugin-src/client/channels/whatsapp/styles.js +19 -0
  79. package/plugin-src/client/connection-error.js +87 -0
  80. package/plugin-src/client/context-enhancement.js +415 -0
  81. package/plugin-src/client/credential-binding.js +118 -0
  82. package/plugin-src/client/delivery-settings.js +905 -0
  83. package/plugin-src/client/global-settings.js +433 -0
  84. package/plugin-src/client/i18n.js +1314 -0
  85. package/plugin-src/client/index.js +624 -0
  86. package/plugin-src/client/interface-language.js +89 -0
  87. package/plugin-src/client/last-message-error.js +18 -0
  88. package/plugin-src/client/lifecycle.js +86 -0
  89. package/plugin-src/client/loopback-recovery.js +75 -0
  90. package/plugin-src/client/model-setting.js +172 -0
  91. package/plugin-src/client/panel-error-boundary.js +21 -0
  92. package/plugin-src/client/plugin-page.js +51 -0
  93. package/plugin-src/client/session-channel-logos.js +243 -0
  94. package/plugin-src/client/styles.js +770 -0
  95. package/plugin-src/client/update-panel.js +14 -0
  96. package/plugin-src/client/workspace-directory-picker.js +280 -0
  97. package/plugin-src/client/workspace-editor.js +69 -0
  98. package/plugin-src/client/workspace-snapshot-fence.js +28 -0
  99. package/plugin-src/host/build.mjs +52 -0
  100. package/plugin-src/host/channels/dingtalk/connection-supervisor.mjs +130 -0
  101. package/plugin-src/host/channels/dingtalk/index.mjs +35 -0
  102. package/plugin-src/host/channels/dingtalk/production.mjs +193 -0
  103. package/plugin-src/host/channels/dingtalk/rpc.mjs +359 -0
  104. package/plugin-src/host/channels/discord/index.mjs +33 -0
  105. package/plugin-src/host/channels/discord/production.mjs +18 -0
  106. package/plugin-src/host/channels/discord/rpc.mjs +21 -0
  107. package/plugin-src/host/channels/email/availability.mjs +60 -0
  108. package/plugin-src/host/channels/email/index.mjs +36 -0
  109. package/plugin-src/host/channels/email/production.mjs +58 -0
  110. package/plugin-src/host/channels/email/rpc.mjs +163 -0
  111. package/plugin-src/host/channels/feishu/connection-supervisor.mjs +167 -0
  112. package/plugin-src/host/channels/feishu/controller.mjs +172 -0
  113. package/plugin-src/host/channels/feishu/credential-store.mjs +84 -0
  114. package/plugin-src/host/channels/feishu/index.mjs +69 -0
  115. package/plugin-src/host/channels/feishu/production.mjs +319 -0
  116. package/plugin-src/host/channels/feishu/rpc.mjs +863 -0
  117. package/plugin-src/host/channels/imessage/index.mjs +21 -0
  118. package/plugin-src/host/channels/imessage/production.mjs +13 -0
  119. package/plugin-src/host/channels/imessage/rpc.mjs +78 -0
  120. package/plugin-src/host/channels/matrix/index.mjs +31 -0
  121. package/plugin-src/host/channels/matrix/production.mjs +241 -0
  122. package/plugin-src/host/channels/matrix/rpc.mjs +228 -0
  123. package/plugin-src/host/channels/office/index.mjs +14 -0
  124. package/plugin-src/host/channels/office/production.mjs +45 -0
  125. package/plugin-src/host/channels/office/rpc.mjs +51 -0
  126. package/plugin-src/host/channels/qq/connection-supervisor.mjs +124 -0
  127. package/plugin-src/host/channels/qq/index.mjs +28 -0
  128. package/plugin-src/host/channels/qq/production.mjs +181 -0
  129. package/plugin-src/host/channels/qq/rpc.mjs +250 -0
  130. package/plugin-src/host/channels/shared/access-policy-production.mjs +137 -0
  131. package/plugin-src/host/channels/shared/access-policy-rpc.mjs +17 -0
  132. package/plugin-src/host/channels/shared/agent-preset-rpc.mjs +25 -0
  133. package/plugin-src/host/channels/shared/bot-alias-rpc.mjs +15 -0
  134. package/plugin-src/host/channels/shared/connection-supervisor.mjs +133 -0
  135. package/plugin-src/host/channels/shared/context-enhancement-rpc.mjs +17 -0
  136. package/plugin-src/host/channels/shared/model-setting-rpc.mjs +18 -0
  137. package/plugin-src/host/channels/shared/production.mjs +239 -0
  138. package/plugin-src/host/channels/shared/rpc.mjs +226 -0
  139. package/plugin-src/host/channels/shared/startup-error.mjs +55 -0
  140. package/plugin-src/host/channels/shared/startup.mjs +76 -0
  141. package/plugin-src/host/channels/shared/thinking-traces-rpc.mjs +11 -0
  142. package/plugin-src/host/channels/shared/workspace-rpc.mjs +31 -0
  143. package/plugin-src/host/channels/slack/index.mjs +31 -0
  144. package/plugin-src/host/channels/slack/production.mjs +176 -0
  145. package/plugin-src/host/channels/slack/rpc.mjs +221 -0
  146. package/plugin-src/host/channels/telegram/index.mjs +33 -0
  147. package/plugin-src/host/channels/telegram/production.mjs +19 -0
  148. package/plugin-src/host/channels/telegram/rpc.mjs +22 -0
  149. package/plugin-src/host/channels/wecom/connection-supervisor.mjs +124 -0
  150. package/plugin-src/host/channels/wecom/index.mjs +34 -0
  151. package/plugin-src/host/channels/wecom/production.mjs +187 -0
  152. package/plugin-src/host/channels/wecom/rpc.mjs +255 -0
  153. package/plugin-src/host/channels/wecom-app/index.mjs +33 -0
  154. package/plugin-src/host/channels/wecom-app/production.mjs +221 -0
  155. package/plugin-src/host/channels/wecom-app/rpc.mjs +235 -0
  156. package/plugin-src/host/channels/weixin/connection-supervisor.mjs +139 -0
  157. package/plugin-src/host/channels/weixin/index.mjs +44 -0
  158. package/plugin-src/host/channels/weixin/production.mjs +258 -0
  159. package/plugin-src/host/channels/weixin/rpc.mjs +285 -0
  160. package/plugin-src/host/channels/whatsapp/index.mjs +33 -0
  161. package/plugin-src/host/channels/whatsapp/production.mjs +198 -0
  162. package/plugin-src/host/channels/whatsapp/rpc.mjs +242 -0
  163. package/plugin-src/host/delivery-adapter.mjs +411 -0
  164. package/plugin-src/host/delivery-http.mjs +132 -0
  165. package/plugin-src/host/delivery-rpc.mjs +173 -0
  166. package/plugin-src/host/delivery-service.mjs +618 -0
  167. package/plugin-src/host/delivery-suggestions.mjs +198 -0
  168. package/plugin-src/host/harness-command-executor.mjs +48 -0
  169. package/plugin-src/host/harness-connection.mjs +20 -0
  170. package/plugin-src/host/harness-session-coordinator.mjs +183 -0
  171. package/plugin-src/host/host-language-rpc.mjs +71 -0
  172. package/plugin-src/host/host-language.mjs +157 -0
  173. package/plugin-src/host/image-input-rpc.mjs +24 -0
  174. package/plugin-src/host/inbound-ttl-rpc.mjs +86 -0
  175. package/plugin-src/host/inbound-ttl-runtime.mjs +85 -0
  176. package/plugin-src/host/inbound-ttl-service.mjs +179 -0
  177. package/plugin-src/host/index.mjs +229 -0
  178. package/plugin-src/host/injected-context.mjs +104 -0
  179. package/plugin-src/host/lark-sdk-handshake-patch.mjs +181 -0
  180. package/plugin-src/host/modern-harness-api.mjs +738 -0
  181. package/plugin-src/host/rpc-authority.mjs +12 -0
  182. package/plugin-src/host/session-sync-coordinator.mjs +233 -0
  183. package/plugin-src/host/session-title-prefix.mjs +122 -0
  184. package/plugin-src/host/update-policy.mjs +31 -0
  185. package/plugin-src/host/update-rpc.mjs +16 -0
  186. package/plugin-src/host/update-runtime.mjs +339 -0
  187. package/plugin-src/host/update-service.mjs +392 -0
  188. package/plugin-src/management-rpc.mjs +87 -0
  189. package/src/channels/dingtalk/config-store.mjs +284 -0
  190. package/src/channels/dingtalk/connection-error.mjs +292 -0
  191. package/src/channels/dingtalk/device-auth.mjs +240 -0
  192. package/src/channels/dingtalk/dingtalk-api.mjs +1140 -0
  193. package/src/channels/dingtalk/dingtalk-bridge.mjs +1889 -0
  194. package/src/channels/dingtalk/dingtalk-card-stream.mjs +242 -0
  195. package/src/channels/dingtalk/dingtalk-controller.mjs +852 -0
  196. package/src/channels/dingtalk/dingtalk-menu.mjs +95 -0
  197. package/src/channels/dingtalk/dingtalk-runtime.mjs +482 -0
  198. package/src/channels/dingtalk/harness-client.mjs +19 -0
  199. package/src/channels/dingtalk/state-store.mjs +325 -0
  200. package/src/channels/discord/config-store.mjs +28 -0
  201. package/src/channels/discord/discord-api.mjs +423 -0
  202. package/src/channels/discord/discord-bridge.mjs +16 -0
  203. package/src/channels/discord/discord-controller.mjs +29 -0
  204. package/src/channels/discord/discord-runtime.mjs +1091 -0
  205. package/src/channels/discord/external-consumer.mjs +199 -0
  206. package/src/channels/discord/external-files.mjs +97 -0
  207. package/src/channels/discord/harness-client.mjs +11 -0
  208. package/src/channels/discord/history-reader.mjs +142 -0
  209. package/src/channels/discord/nearby-history.mjs +112 -0
  210. package/src/channels/discord/state-store.mjs +3 -0
  211. package/src/channels/email/config-store.mjs +194 -0
  212. package/src/channels/email/email-api.mjs +20 -0
  213. package/src/channels/email/email-bridge.mjs +17 -0
  214. package/src/channels/email/email-controller.mjs +824 -0
  215. package/src/channels/email/email-runtime.mjs +699 -0
  216. package/src/channels/email/harness-client.mjs +7 -0
  217. package/src/channels/email/mail-format.mjs +91 -0
  218. package/src/channels/email/state-store.mjs +176 -0
  219. package/src/channels/email/transport.mjs +64 -0
  220. package/src/channels/email/transports/agent-mail.mjs +604 -0
  221. package/src/channels/email/transports/agently-cli.mjs +288 -0
  222. package/src/channels/email/transports/imap-smtp.mjs +165 -0
  223. package/src/channels/feishu/bridge.mjs +6286 -0
  224. package/src/channels/feishu/config.mjs +71 -0
  225. package/src/channels/feishu/external-cards.mjs +87 -0
  226. package/src/channels/feishu/external-consumer.mjs +89 -0
  227. package/src/channels/feishu/external-files.mjs +115 -0
  228. package/src/channels/feishu/external-images.mjs +50 -0
  229. package/src/channels/feishu/external-names.mjs +99 -0
  230. package/src/channels/feishu/feishu-app.mjs +54 -0
  231. package/src/channels/feishu/feishu-cards.mjs +1285 -0
  232. package/src/channels/feishu/feishu-channel.mjs +651 -0
  233. package/src/channels/feishu/feishu-runtime.mjs +982 -0
  234. package/src/channels/feishu/group-message-permission-manager.mjs +72 -0
  235. package/src/channels/feishu/group-response-mode.mjs +15 -0
  236. package/src/channels/feishu/harness-client.mjs +19 -0
  237. package/src/channels/feishu/history-reader.mjs +77 -0
  238. package/src/channels/feishu/live-cot.mjs +260 -0
  239. package/src/channels/feishu/message-utils.mjs +613 -0
  240. package/src/channels/feishu/multi-bot-controller.mjs +1619 -0
  241. package/src/channels/feishu/nearby-history.mjs +72 -0
  242. package/src/channels/feishu/plugin-config-store.mjs +216 -0
  243. package/src/channels/feishu/plugin-controller.mjs +254 -0
  244. package/src/channels/feishu/registration-manager.mjs +349 -0
  245. package/src/channels/feishu/repair-manager.mjs +138 -0
  246. package/src/channels/feishu/reply-context.mjs +22 -0
  247. package/src/channels/feishu/slash-command-panel.mjs +155 -0
  248. package/src/channels/feishu/slash-command-registry.mjs +495 -0
  249. package/src/channels/feishu/state-store.mjs +214 -0
  250. package/src/channels/feishu/step-push-mode.mjs +25 -0
  251. package/src/channels/feishu/voice-config.mjs +34 -0
  252. package/src/channels/feishu/voice.mjs +134 -0
  253. package/src/channels/imessage/config-store.mjs +24 -0
  254. package/src/channels/imessage/controller.mjs +37 -0
  255. package/src/channels/imessage/harness-client.mjs +7 -0
  256. package/src/channels/imessage/imessage-api.mjs +194 -0
  257. package/src/channels/imessage/imessage-bridge.mjs +16 -0
  258. package/src/channels/imessage/runtime.mjs +102 -0
  259. package/src/channels/imessage/state-store.mjs +3 -0
  260. package/src/channels/matrix/matrix-api.mjs +696 -0
  261. package/src/channels/matrix/matrix-bridge.mjs +20 -0
  262. package/src/channels/matrix/matrix-config-store.mjs +368 -0
  263. package/src/channels/matrix/matrix-controller.mjs +404 -0
  264. package/src/channels/matrix/matrix-crypto-store.mjs +279 -0
  265. package/src/channels/matrix/matrix-crypto.mjs +1014 -0
  266. package/src/channels/matrix/matrix-harness-client.mjs +11 -0
  267. package/src/channels/matrix/matrix-normalize.mjs +357 -0
  268. package/src/channels/matrix/matrix-rich-text.mjs +313 -0
  269. package/src/channels/matrix/matrix-room-history.mjs +316 -0
  270. package/src/channels/matrix/matrix-runtime.mjs +1014 -0
  271. package/src/channels/office/config-store.mjs +107 -0
  272. package/src/channels/office/office-controller.mjs +178 -0
  273. package/src/channels/office/office-job-executor.mjs +391 -0
  274. package/src/channels/office/office-runtime.mjs +175 -0
  275. package/src/channels/office/office-transport.mjs +171 -0
  276. package/src/channels/office/protocol.mjs +43 -0
  277. package/src/channels/qq/config-store.mjs +173 -0
  278. package/src/channels/qq/harness-client.mjs +11 -0
  279. package/src/channels/qq/markdown-reply.mjs +446 -0
  280. package/src/channels/qq/qq-bridge.mjs +1507 -0
  281. package/src/channels/qq/qq-controller.mjs +514 -0
  282. package/src/channels/qq/qq-menu.mjs +208 -0
  283. package/src/channels/qq/qq-runtime.mjs +303 -0
  284. package/src/channels/qq/qr-auth.mjs +24 -0
  285. package/src/channels/qq/state-error.mjs +17 -0
  286. package/src/channels/qq/state-store.mjs +143 -0
  287. package/src/channels/shared/access-policy.mjs +210 -0
  288. package/src/channels/shared/agent-preset.mjs +76 -0
  289. package/src/channels/shared/batch-input.mjs +229 -0
  290. package/src/channels/shared/bot-alias.mjs +29 -0
  291. package/src/channels/shared/bot-workspace-store.mjs +2383 -0
  292. package/src/channels/shared/command-catalog.mjs +107 -0
  293. package/src/channels/shared/command-permission.mjs +32 -0
  294. package/src/channels/shared/compact-command.mjs +109 -0
  295. package/src/channels/shared/config-read-error.mjs +24 -0
  296. package/src/channels/shared/connection-error.mjs +191 -0
  297. package/src/channels/shared/connection-test.mjs +58 -0
  298. package/src/channels/shared/context-enhancement.mjs +372 -0
  299. package/src/channels/shared/control-command.mjs +111 -0
  300. package/src/channels/shared/conversation-state-store.mjs +165 -0
  301. package/src/channels/shared/default-workspace.mjs +31 -0
  302. package/src/channels/shared/deferred-delivery-coordinator.mjs +241 -0
  303. package/src/channels/shared/deferred-delivery.mjs +161 -0
  304. package/src/channels/shared/deferred-state.mjs +53 -0
  305. package/src/channels/shared/diagnostic-details.mjs +95 -0
  306. package/src/channels/shared/editable-message-stream.mjs +100 -0
  307. package/src/channels/shared/exclusive-inbound-consumers.mjs +91 -0
  308. package/src/channels/shared/file-download.mjs +64 -0
  309. package/src/channels/shared/harness-approval.mjs +508 -0
  310. package/src/channels/shared/harness-client.mjs +2143 -0
  311. package/src/channels/shared/harness-mux.mjs +123 -0
  312. package/src/channels/shared/harness-question.mjs +95 -0
  313. package/src/channels/shared/harness-session-binding.mjs +119 -0
  314. package/src/channels/shared/history-command.mjs +193 -0
  315. package/src/channels/shared/i18n-en/diagnostics.mjs +55 -0
  316. package/src/channels/shared/i18n-en/dingtalk.mjs +81 -0
  317. package/src/channels/shared/i18n-en/discord.mjs +10 -0
  318. package/src/channels/shared/i18n-en/email.mjs +25 -0
  319. package/src/channels/shared/i18n-en/feishu.mjs +404 -0
  320. package/src/channels/shared/i18n-en/image-input.mjs +18 -0
  321. package/src/channels/shared/i18n-en/matrix.mjs +85 -0
  322. package/src/channels/shared/i18n-en/office.mjs +23 -0
  323. package/src/channels/shared/i18n-en/qq.mjs +96 -0
  324. package/src/channels/shared/i18n-en/shared-a.mjs +241 -0
  325. package/src/channels/shared/i18n-en/shared-b.mjs +263 -0
  326. package/src/channels/shared/i18n-en/shared-c.mjs +203 -0
  327. package/src/channels/shared/i18n-en/slack.mjs +27 -0
  328. package/src/channels/shared/i18n-en/telegram.mjs +27 -0
  329. package/src/channels/shared/i18n-en/wecom-app.mjs +33 -0
  330. package/src/channels/shared/i18n-en/wecom.mjs +62 -0
  331. package/src/channels/shared/i18n-en/weixin.mjs +88 -0
  332. package/src/channels/shared/i18n-en/whatsapp.mjs +17 -0
  333. package/src/channels/shared/i18n-en.mjs +45 -0
  334. package/src/channels/shared/i18n.mjs +78 -0
  335. package/src/channels/shared/im-source-guidance.mjs +65 -0
  336. package/src/channels/shared/image-input-policy.mjs +35 -0
  337. package/src/channels/shared/image-input-settings-store.mjs +60 -0
  338. package/src/channels/shared/image-input.mjs +124 -0
  339. package/src/channels/shared/image-prompt.mjs +360 -0
  340. package/src/channels/shared/inbound-access.mjs +43 -0
  341. package/src/channels/shared/inbound-file.mjs +323 -0
  342. package/src/channels/shared/inbound-ttl-store.mjs +110 -0
  343. package/src/channels/shared/inbound-ttl.mjs +22 -0
  344. package/src/channels/shared/injected-context.mjs +362 -0
  345. package/src/channels/shared/interface-language-store.mjs +127 -0
  346. package/src/channels/shared/interface-language.mjs +51 -0
  347. package/src/channels/shared/message-failure.mjs +257 -0
  348. package/src/channels/shared/model-command.mjs +741 -0
  349. package/src/channels/shared/model-setting.mjs +145 -0
  350. package/src/channels/shared/preset-command.mjs +308 -0
  351. package/src/channels/shared/semantic/artifact-delivery.mjs +177 -0
  352. package/src/channels/shared/semantic/artifact.mjs +750 -0
  353. package/src/channels/shared/semantic/delivery.mjs +193 -0
  354. package/src/channels/shared/semantic/reply-reference.mjs +148 -0
  355. package/src/channels/shared/session-binding-lock.mjs +40 -0
  356. package/src/channels/shared/session-channel-labels.mjs +28 -0
  357. package/src/channels/shared/session-reply-recovery.mjs +104 -0
  358. package/src/channels/shared/session-sync-registry.mjs +22 -0
  359. package/src/channels/shared/session-title.mjs +74 -0
  360. package/src/channels/shared/status-reaction.mjs +107 -0
  361. package/src/channels/shared/text-harness-bridge.mjs +1623 -0
  362. package/src/channels/shared/token-bot-controller.mjs +529 -0
  363. package/src/channels/shared/token-config-store.mjs +208 -0
  364. package/src/channels/shared/video-media.mjs +9 -0
  365. package/src/channels/shared/workspace-command.mjs +532 -0
  366. package/src/channels/shared/workspace-session.mjs +196 -0
  367. package/src/channels/slack/config-store.mjs +177 -0
  368. package/src/channels/slack/external-consumer.mjs +93 -0
  369. package/src/channels/slack/external-files.mjs +90 -0
  370. package/src/channels/slack/harness-client.mjs +11 -0
  371. package/src/channels/slack/history-reader.mjs +203 -0
  372. package/src/channels/slack/manifest.mjs +37 -0
  373. package/src/channels/slack/slack-api.mjs +644 -0
  374. package/src/channels/slack/slack-bridge.mjs +20 -0
  375. package/src/channels/slack/slack-controller.mjs +468 -0
  376. package/src/channels/slack/slack-runtime.mjs +895 -0
  377. package/src/channels/slack/state-store.mjs +3 -0
  378. package/src/channels/telegram/config-store.mjs +89 -0
  379. package/src/channels/telegram/harness-client.mjs +11 -0
  380. package/src/channels/telegram/state-store.mjs +3 -0
  381. package/src/channels/telegram/telegram-api.mjs +486 -0
  382. package/src/channels/telegram/telegram-bridge.mjs +81 -0
  383. package/src/channels/telegram/telegram-controller.mjs +52 -0
  384. package/src/channels/telegram/telegram-http.mjs +21 -0
  385. package/src/channels/telegram/telegram-rich-message.mjs +149 -0
  386. package/src/channels/telegram/telegram-runtime.mjs +1471 -0
  387. package/src/channels/wecom/config-store.mjs +172 -0
  388. package/src/channels/wecom/harness-client.mjs +11 -0
  389. package/src/channels/wecom/qr-auth.mjs +95 -0
  390. package/src/channels/wecom/send-error.mjs +31 -0
  391. package/src/channels/wecom/state-store.mjs +107 -0
  392. package/src/channels/wecom/wecom-bridge.mjs +1833 -0
  393. package/src/channels/wecom/wecom-cards.mjs +101 -0
  394. package/src/channels/wecom/wecom-controller.mjs +530 -0
  395. package/src/channels/wecom/wecom-runtime.mjs +269 -0
  396. package/src/channels/wecom-app/callback-server.mjs +471 -0
  397. package/src/channels/wecom-app/config-store.mjs +242 -0
  398. package/src/channels/wecom-app/harness-client.mjs +11 -0
  399. package/src/channels/wecom-app/state-store.mjs +107 -0
  400. package/src/channels/wecom-app/wecom-app-api.mjs +432 -0
  401. package/src/channels/wecom-app/wecom-app-bridge.mjs +1072 -0
  402. package/src/channels/wecom-app/wecom-app-controller.mjs +453 -0
  403. package/src/channels/wecom-app/wecom-app-runtime.mjs +222 -0
  404. package/src/channels/weixin/config-store.mjs +194 -0
  405. package/src/channels/weixin/connection-error.en.mjs +137 -0
  406. package/src/channels/weixin/connection-error.mjs +153 -0
  407. package/src/channels/weixin/diagnostic-details.mjs +1 -0
  408. package/src/channels/weixin/external-consumer.mjs +160 -0
  409. package/src/channels/weixin/external-files.mjs +84 -0
  410. package/src/channels/weixin/external-typing.mjs +120 -0
  411. package/src/channels/weixin/harness-client.mjs +19 -0
  412. package/src/channels/weixin/state-store.mjs +316 -0
  413. package/src/channels/weixin/weixin-api.mjs +1009 -0
  414. package/src/channels/weixin/weixin-bridge.mjs +1537 -0
  415. package/src/channels/weixin/weixin-controller.mjs +779 -0
  416. package/src/channels/weixin/weixin-runtime.mjs +507 -0
  417. package/src/channels/whatsapp/config-store.mjs +210 -0
  418. package/src/channels/whatsapp/harness-client.mjs +11 -0
  419. package/src/channels/whatsapp/state-store.mjs +3 -0
  420. package/src/channels/whatsapp/whatsapp-bridge.mjs +18 -0
  421. package/src/channels/whatsapp/whatsapp-controller.mjs +470 -0
  422. package/src/channels/whatsapp/whatsapp-runtime.mjs +917 -0
  423. package/src/channels/whatsapp/whatsapp-web-session.mjs +214 -0
@@ -0,0 +1,62 @@
1
+ // English translations (wecom area). Keys are exact Chinese literals passed to t().
2
+ export default {
3
+ '/menu 或 /m 打开可点击的功能菜单': '/menu or /m Open the interactive menu',
4
+ '保持当前': 'Keep current',
5
+ '会话': 'Session',
6
+ '模型': 'Model',
7
+ '预设': 'Preset',
8
+ '跟随默认模型': 'Default model',
9
+ '跟随 Host 默认': 'Follow Host default',
10
+ '新会话': 'New session',
11
+ '上一页': 'Previous',
12
+ '下一页': 'Next',
13
+ '返回': 'Back',
14
+ '更多选项…': 'More options…',
15
+ '选择会话、模型或预设后,点击应用设置。': 'Choose a session, model or preset, then apply settings.',
16
+ '应用设置': 'Apply settings',
17
+ '工作区与任务': 'Workspace & tasks',
18
+ '应用选择': 'Apply selection',
19
+ '请选择一个选项后再应用。': 'Select one option before applying.',
20
+ '设置未改变。': 'Settings unchanged.',
21
+ '已收到操作,请查看下方结果。': 'Action received. See the result below.',
22
+ '重新打开菜单': 'Reopen menu',
23
+ '暂无可用选项。': 'No options are available.',
24
+ '预设仅用于之后的新会话。': 'Presets apply to future new sessions.',
25
+ '部分模型暂不可用,可稍后重试。': 'Some models are unavailable. Try again later.',
26
+ '工作区已变化,请发送 /m 重新打开菜单后选择。': 'The workspace changed. Send /m to reopen the menu and select again.',
27
+ // Help text (wecom-bridge.mjs)
28
+ '企业微信机器人已连接 DeepSeek Harness。': 'The Enterprise WeChat bot is connected to DeepSeek Harness.',
29
+
30
+ // Bot replies and status text (wecom-bridge.mjs)
31
+
32
+ '当前待处理图片较多,请稍后重新发送。': 'Too many images are pending. Please send them again later.',
33
+
34
+ '结果文件「{name}」已生成,但企业微信智能机器人缺少素材上传或文件消息能力,请检查机器人权限。': 'The result file "{name}" was generated, but the Enterprise WeChat bot lacks media upload or file message capability. Please check the bot permissions.',
35
+ '结果文件「{name}」超过当前企业微信机器人可发送的文件大小,未发送。': 'The result file "{name}" exceeds the file size this Enterprise WeChat bot can send and was not sent.',
36
+ '结果文件「{name}」为空,企业微信不允许发送空文件。': 'The result file "{name}" is empty. Enterprise WeChat does not allow sending empty files.',
37
+ '结果文件「{name}」暂时被企业微信限流,未能发送,请稍后重试。': 'The result file "{name}" was rate-limited by Enterprise WeChat and could not be sent. Please try again later.',
38
+ '结果文件「{name}」已生成,但企业微信拒绝了该文件或文件消息。': 'The result file "{name}" was generated, but Enterprise WeChat rejected the file or file message.',
39
+ '结果文件「{name}」已生成,但暂时未能通过企业微信发送,请稍后重试。': 'The result file "{name}" was generated but could not be sent via Enterprise WeChat right now. Please try again later.',
40
+ '任务已完成,但没有生成可显示的文本。': 'The task completed, but no displayable text was generated.',
41
+ '目前支持文字、图片和语音转写消息。': 'Currently only text, images, and voice transcription messages are supported.',
42
+ '企业微信机器人与 DeepSeek Harness 连接正常。': 'The connection between the Enterprise WeChat bot and DeepSeek Harness is working.',
43
+ '正在思考中…': 'Thinking…',
44
+ '企业微信交互问题发送失败。': 'Failed to send the Enterprise WeChat interaction question.',
45
+
46
+ // Provisioning, status, and errors (wecom-controller.mjs)
47
+ '企业微信机器人凭据缺失,请移除后重新扫码。': 'The Enterprise WeChat bot credentials are missing. Please remove the bot and scan the QR code again.',
48
+ '企业微信连接未就绪,插件会自动重试。': 'The Enterprise WeChat connection is not ready. The plugin will retry automatically.',
49
+ '扫码绑定已取消。': 'QR code binding has been cancelled.',
50
+ '无法生成企业微信二维码,请稍后重试。': 'Unable to generate the Enterprise WeChat QR code. Please try again later.',
51
+ '企业微信二维码已过期,请重新生成。': 'The Enterprise WeChat QR code has expired. Please generate a new one.',
52
+ '企业微信机器人已绑定,消息连接暂未就绪。': 'The Enterprise WeChat bot is bound, but the message connection is not ready yet.',
53
+ '企业微信连接仍未就绪,请稍后重试。': 'The Enterprise WeChat connection is still not ready. Please try again later.',
54
+ '企业微信扫码没有完成,请重新生成二维码。': 'The Enterprise WeChat QR scan was not completed. Please generate a new QR code.',
55
+ '企业微信扫码服务暂时不可用,请重新生成二维码。': 'The Enterprise WeChat QR service is temporarily unavailable. Please generate a new QR code.',
56
+ '企业微信已授权,但无法安全保存接入配置。': 'Enterprise WeChat authorization succeeded, but the connection configuration could not be saved safely.',
57
+ '企业微信机器人': 'Enterprise WeChat bot',
58
+ '企业微信机器人({botId})': 'Enterprise WeChat bot ({botId})',
59
+ '企业微信 WebSocket 长连接运行正常': 'The Enterprise WeChat WebSocket long connection is running normally',
60
+ '企业微信连接未就绪,插件会自动重试': 'The Enterprise WeChat connection is not ready. The plugin will retry automatically',
61
+ '企业微信连接当前离线': 'The Enterprise WeChat connection is currently offline',
62
+ };
@@ -0,0 +1,88 @@
1
+ import diagnostics from '../../weixin/connection-error.en.mjs';
2
+ // English translations (weixin area). Keys are exact Chinese literals passed to t().
3
+ export default {
4
+ ...diagnostics,
5
+ // weixin-bridge.mjs
6
+ '微信已连接 DeepSeek Harness。': 'WeChat is connected to DeepSeek Harness.',
7
+ '结果文件「{name}」已生成,但微信机器人当前没有文件消息发送权限,请检查机器人文件消息能力。': 'The result file "{name}" was generated, but the WeChat bot currently has no permission to send file messages. Please check the bot\'s file messaging capability.',
8
+ '结果文件「{name}」超过当前微信会话可发送的文件大小,未发送。': 'The result file "{name}" exceeds the file size limit of the current WeChat conversation and was not sent.',
9
+ '结果文件「{name}」上传微信时长时间没有进展,已超时,文件尚未发送。请检查网络后重试,或压缩、拆分文件后发送。': 'The upload of "{name}" to WeChat stalled and timed out. The file has not been sent. Check your network and retry, or compress or split the file before sending.',
10
+ '结果文件「{name}」暂时被微信限流,未能发送,请稍后重试。': 'The result file "{name}" was temporarily rate-limited by WeChat and was not sent. Please try again later.',
11
+ '结果文件「{name}」已生成,但微信拒绝了该文件消息。': 'The result file "{name}" was generated, but WeChat rejected the file message.',
12
+ '结果文件「{name}」已生成,但暂时未能通过微信发送,请稍后重试。': 'The result file "{name}" was generated but could not be sent via WeChat right now. Please try again later.',
13
+ '目前支持文字、图片,以及微信已转成文字的语音消息。': 'Currently supports text, images, and voice messages that WeChat has converted to text.',
14
+ '微信与 DeepSeek Harness 连接正常。': 'WeChat is connected to DeepSeek Harness normally.',
15
+ '微信交互问题发送失败。': 'Failed to send the WeChat interaction question.',
16
+ '回复已经生成,但微信发送失败,可能只收到部分内容。请将下面的诊断信息完整反馈给管理员。': 'The reply was generated, but WeChat delivery failed and only part of it may have arrived. Please send the complete diagnostic below to the administrator.',
17
+ '微信发送诊断:{diagnostic}': 'WeChat delivery diagnostic: {diagnostic}',
18
+ '微信主动消息发送失败。长轮询在线不代表消息可以发送。': 'WeChat outbound delivery failed. Healthy long polling does not guarantee messages can be sent.',
19
+ 'iLink 拒绝发送,可能涉及会话有效期、发送额度或消息内容。可让接收者发一条消息后重试;不要通过反复发送心跳尝试续期。': 'iLink rejected the message; conversation lifetime, sending quota, or message content may be involved. Ask the recipient to send a message before retrying. Repeated heartbeat messages do not renew the conversation.',
20
+
21
+ // weixin-controller.mjs
22
+ '微信已授权,但无法读取现有登录凭据。请检查 DSH 凭据存储。': 'WeChat was authorized, but the existing login credential could not be read. Please check the DSH credential store.',
23
+ '微信已授权,但登录凭据无法写入 DSH 凭据存储。请检查凭据存储是否可写。': 'WeChat was authorized, but the login credential could not be written to the DSH credential store. Please check that the credential store is writable.',
24
+ '微信已授权,但账号配置无法写入本机。请检查 DSH_HOME 目录权限。': 'WeChat was authorized, but the account configuration could not be written locally. Please check the DSH_HOME directory permissions.',
25
+ '微信已授权,但无法初始化账号状态或工作区。请检查 DSH_HOME 和工作区目录。': 'WeChat was authorized, but the account state or workspace could not be initialized. Please check DSH_HOME and the workspace directories.',
26
+ '微信已授权,但插件无法连接本机 Harness。请检查 dsh web 地址和端口。': 'WeChat was authorized, but the plugin could not connect to the local Harness. Please check the dsh web address and port.',
27
+ '微信已授权,但 Harness 健康检查超时。请确认 dsh web 未阻塞。': 'WeChat was authorized, but the Harness health check timed out. Please confirm dsh web is not blocked.',
28
+ '微信已授权,但 Harness 健康检查需要身份认证。请检查代理、网关或自定义鉴权配置。': 'WeChat was authorized, but the Harness health check requires authentication. Please check proxy, gateway, or custom auth configuration.',
29
+ '微信已授权,但本机 Harness 请求被代理要求认证。请让回环地址绕过代理,并检查 NO_PROXY 配置。': 'WeChat was authorized, but the local Harness request was challenged for proxy authentication. Please bypass the proxy for loopback addresses and check the NO_PROXY configuration.',
30
+ '微信已授权,但 Harness 异常拒绝了回环地址的健康检查。请检查 HTTP 代理、Harness 源码版本和构建产物。': 'WeChat was authorized, but Harness unexpectedly rejected the health check from a loopback address. Please check the HTTP proxy, Harness source version, and build artifacts.',
31
+ '微信已授权,但 Harness 的 Host 信任检查拒绝了非回环地址请求。请检查 harnessBaseUrl 与 trustedHosts 配置。': 'WeChat was authorized, but the Harness Host trust check rejected a non-loopback request. Please check the harnessBaseUrl and trustedHosts configuration.',
32
+ '微信已授权,但健康检查收到了非 Harness 标准的 403 拒绝响应。请检查代理或网关配置。': 'WeChat was authorized, but the health check received a non-standard Harness 403 rejection. Please check the proxy or gateway configuration.',
33
+ '微信已授权,但找不到 Harness 健康检查接口。请确认 Harness 与插件版本兼容。': 'WeChat was authorized, but the Harness health check endpoint was not found. Please confirm the Harness and plugin versions are compatible.',
34
+ '微信已授权,但 Harness 健康检查返回服务错误。请查看 dsh web 日志。': 'WeChat was authorized, but the Harness health check returned a server error. Please check the dsh web logs.',
35
+ '微信已授权,但 Harness 返回了无法识别的响应。请确认 Harness 与插件版本兼容。': 'WeChat was authorized, but Harness returned an unrecognized response. Please confirm the Harness and plugin versions are compatible.',
36
+ '微信已授权,但 Harness 拒绝了健康检查请求。请查看 dsh web 日志。': 'WeChat was authorized, but Harness rejected the health check request. Please check the dsh web logs.',
37
+ '微信已授权,但 Harness 健康检查发生未知错误。请查看 dsh web 日志。': 'WeChat was authorized, but the Harness health check failed with an unknown error. Please check the dsh web logs.',
38
+ '微信已授权,但消息连接初始化失败。请查看 dsh web 日志后重试。': 'WeChat was authorized, but the message connection failed to initialize. Please check the dsh web logs and try again.',
39
+ '微信已授权,但激活过程中发生未知错误。请查看 dsh web 日志。': 'WeChat was authorized, but an unknown error occurred during activation. Please check the dsh web logs.',
40
+ '登录凭据缺失,请移除账号后重新扫码。': 'The login credential is missing. Please remove the account and scan the QR code again.',
41
+ '微信连接未就绪,插件会自动重试。': 'The WeChat connection is not ready; the plugin will retry automatically.',
42
+ '微信连接未就绪,插件会自动重试': 'The WeChat connection is not ready; the plugin will retry automatically',
43
+ '无法生成微信二维码,请稍后重试。': 'Unable to generate the WeChat QR code. Please try again later.',
44
+ '微信连接仍未就绪,请稍后重试。': 'The WeChat connection is still not ready. Please try again later.',
45
+ '微信机器人': 'WeChat Bot',
46
+ '微信机器人({name})': 'WeChat Bot ({name})',
47
+ '微信消息长轮询运行正常': 'WeChat message long-polling is running normally',
48
+ '微信连接当前离线': 'The WeChat connection is currently offline',
49
+ '配对码多次错误,请重新生成二维码。': 'The pairing code was entered incorrectly too many times. Please generate a new QR code.',
50
+ '该微信账号已绑定,但本机没有可恢复的凭据。': 'This WeChat account is already bound, but no recoverable credential exists on this machine.',
51
+ '微信授权成功,但返回的账号凭据不完整。': 'WeChat authorization succeeded, but the returned account credential is incomplete.',
52
+
53
+ // weixin-runtime.mjs
54
+ '微信登录凭据已失效,请移除账号后重新扫码。': 'The WeChat login credential has expired. Please remove the account and scan the QR code again.',
55
+ '微信消息同步请求被拒绝。': 'The WeChat message sync request was rejected.',
56
+
57
+ // weixin-api.mjs
58
+ '微信图片的加密密钥无效。': 'The encryption key of the WeChat image is invalid.',
59
+ '微信图片的加密数据无效。': 'The encrypted data of the WeChat image is invalid.',
60
+ '微信图片解密失败。': 'Failed to decrypt the WeChat image.',
61
+ '微信图片没有可用的下载地址。': 'The WeChat image has no usable download URL.',
62
+ '微信图片的下载地址无效。': 'The download URL of the WeChat image is invalid.',
63
+ '微信图片的下载地址不受信任。': 'The download URL of the WeChat image is not trusted.',
64
+ '微信服务返回了无效的连接地址。': 'The WeChat service returned an invalid connection URL.',
65
+ '微信服务返回了不受信任的连接地址。': 'The WeChat service returned an untrusted connection URL.',
66
+ '微信服务没有返回扫码地址。': 'The WeChat service did not return a QR-code URL.',
67
+ '微信服务返回了无效的扫码地址。': 'The WeChat service returned an invalid QR-code URL.',
68
+ '微信服务返回了不受信任的扫码地址。': 'The WeChat service returned an untrusted QR-code URL.',
69
+ '微信服务返回了无效的文件上传地址。': 'The WeChat service returned an invalid file upload URL.',
70
+ '微信服务返回了不受信任的文件上传地址。': 'The WeChat service returned an untrusted file upload URL.',
71
+ '微信服务没有返回文件上传地址。': 'The WeChat service did not return a file upload URL.',
72
+ '微信文件上传被拒绝(HTTP {status})。': 'The WeChat file upload was rejected (HTTP {status}).',
73
+ '微信文件上传失败(HTTP {status})。': 'The WeChat file upload failed (HTTP {status}).',
74
+ '微信文件上传响应缺少下载参数。': 'The WeChat file upload response is missing the download parameter.',
75
+ '微信文件上传失败。': 'The WeChat file upload failed.',
76
+ '微信文件上传长时间没有进展,已超时。': 'The WeChat file upload stalled and timed out.',
77
+ '拒绝访问不受信任的微信服务地址。': 'Refusing to access an untrusted WeChat service URL.',
78
+ '微信服务请求失败(HTTP {status})。': 'The WeChat service request failed (HTTP {status}).',
79
+ '微信服务返回了无法解析的响应。': 'The WeChat service returned an unparseable response.',
80
+ '微信服务请求超时。': 'The WeChat service request timed out.',
81
+ '暂时无法访问微信服务。': 'The WeChat service is temporarily unreachable.',
82
+ '微信服务返回了无法识别的扫码状态。': 'The WeChat service returned an unrecognized QR-code status.',
83
+ '微信服务没有返回二维码令牌。': 'The WeChat service did not return a QR-code token.',
84
+ '微信服务拒绝了回复消息。': 'The WeChat service rejected the reply message.',
85
+ '微信服务拒绝了文件上传请求。': 'The WeChat service rejected the file upload request.',
86
+ '微信服务拒绝了文件消息。': 'The WeChat service rejected the file message.',
87
+ '微信账号连接启动失败。': 'Failed to start the WeChat account connection.',
88
+ };
@@ -0,0 +1,17 @@
1
+ // English translations (whatsapp area). Keys are exact Chinese literals passed to t().
2
+ export default {
3
+ 'WhatsApp 关联设备已失效,请移除后重新扫码。': 'The WhatsApp linked device is no longer valid. Remove it and scan the QR code again.',
4
+ 'WhatsApp 连接未就绪,插件会自动重试。': 'The WhatsApp connection is not ready yet; the plugin will retry automatically.',
5
+ 'WhatsApp 连接仍未就绪,请稍后重试。': 'The WhatsApp connection is still not ready. Please try again later.',
6
+ 'WhatsApp机器人尚未连接': 'The WhatsApp bot is not connected yet',
7
+ 'WhatsApp机器人': 'WhatsApp bot',
8
+ 'WhatsApp Web 关联设备运行正常': 'The WhatsApp Web linked device is working normally',
9
+ 'WhatsApp 连接未就绪': 'The WhatsApp connection is not ready',
10
+ 'WhatsApp 连接当前离线': 'The WhatsApp connection is currently offline',
11
+ 'WhatsApp 已绑定,消息连接暂未就绪。': 'WhatsApp is linked, but the messaging connection is not ready yet.',
12
+ 'WhatsApp 已扫码,但无法保存关联设备。': 'The QR code was scanned, but the linked device could not be saved.',
13
+ '无法连接 WhatsApp,请重新生成二维码。': 'Unable to connect to WhatsApp. Please generate a new QR code.',
14
+
15
+ 'WhatsApp账号': 'WhatsApp account',
16
+ ' Web 关联设备': ' Web linked device',
17
+ };
@@ -0,0 +1,45 @@
1
+ import imageInput from './i18n-en/image-input.mjs';
2
+ import diagnostics from './i18n-en/diagnostics.mjs';
3
+ // English translations for host-side user-facing text.
4
+ // Keys are the exact Chinese literals passed to t() in src/channels/**.
5
+ // Chinese output is the identity default and needs no entries here.
6
+ // Entries are maintained per area in ./i18n-en/*.mjs and merged here.
7
+
8
+ import sharedA from './i18n-en/shared-a.mjs';
9
+ import sharedB from './i18n-en/shared-b.mjs';
10
+ import sharedC from './i18n-en/shared-c.mjs';
11
+ import feishu from './i18n-en/feishu.mjs';
12
+ import dingtalk from './i18n-en/dingtalk.mjs';
13
+ import wecom from './i18n-en/wecom.mjs';
14
+ import wecomApp from './i18n-en/wecom-app.mjs';
15
+ import qq from './i18n-en/qq.mjs';
16
+ import weixin from './i18n-en/weixin.mjs';
17
+ import slack from './i18n-en/slack.mjs';
18
+ import telegram from './i18n-en/telegram.mjs';
19
+ import discord from './i18n-en/discord.mjs';
20
+ import whatsapp from './i18n-en/whatsapp.mjs';
21
+ import matrix from './i18n-en/matrix.mjs';
22
+ import office from './i18n-en/office.mjs';
23
+ import email from './i18n-en/email.mjs';
24
+
25
+ export const EN = Object.freeze(Object.assign(
26
+ {},
27
+ diagnostics,
28
+ imageInput,
29
+ sharedA,
30
+ sharedB,
31
+ sharedC,
32
+ feishu,
33
+ dingtalk,
34
+ wecom,
35
+ wecomApp,
36
+ qq,
37
+ weixin,
38
+ slack,
39
+ telegram,
40
+ discord,
41
+ whatsapp,
42
+ matrix,
43
+ office,
44
+ email,
45
+ ));
@@ -0,0 +1,78 @@
1
+ // Host-side i18n for dsh-im. Mirrors the conventions of the settings-UI
2
+ // translator in plugin-src/client/i18n.js: dictionary keys are the exact
3
+ // Chinese source literals, and Chinese (zh) is the identity default, so
4
+ // untranslated or unrecognized text always falls back to the original
5
+ // Chinese output unchanged.
6
+ //
7
+ // The English dictionary lives in ./i18n-en.mjs to keep this module small.
8
+
9
+ import { EN } from './i18n-en.mjs';
10
+
11
+ let language = 'zh';
12
+
13
+ const listeners = new Set();
14
+
15
+ // Accepts 'en', 'en-US', 'english' (any case) as English; anything else
16
+ // (including undefined and unrecognized values) selects Chinese. Pure: use it
17
+ // to judge a candidate tag without switching the active language.
18
+ export function normalizeImHostLanguage(lang) {
19
+ const normalized = typeof lang === 'string' ? lang.trim().toLowerCase() : '';
20
+ return normalized === 'english' || /^en(?:[-_].*)?$/u.test(normalized) ? 'en' : 'zh';
21
+ }
22
+
23
+ /**
24
+ * Select the language of every host-side message. Subscribers registered
25
+ * through onImHostLanguageChange are notified only when the resolved language
26
+ * actually changes, so re-applying the same selection in a different spelling
27
+ * (or an unrecognized tag that keeps falling back to Chinese) is free.
28
+ */
29
+ export function setImHostLanguage(lang) {
30
+ const next = normalizeImHostLanguage(lang);
31
+ if (next === language) return language;
32
+ const previous = language;
33
+ language = next;
34
+ // Snapshot first: a subscriber may unsubscribe (or subscribe) while running.
35
+ for (const listener of [...listeners]) {
36
+ if (!listeners.has(listener)) continue;
37
+ try {
38
+ listener(next, previous);
39
+ } catch {
40
+ // Each subscriber owns its own diagnostics; one that fails must not
41
+ // strand the rest, nor abandon a language switch that already happened.
42
+ }
43
+ }
44
+ return language;
45
+ }
46
+
47
+ export function getImHostLanguage() {
48
+ return language;
49
+ }
50
+
51
+ /**
52
+ * Observe committed changes to the host message language. Platform-side
53
+ * surfaces that were localized once at connect time (the Telegram command
54
+ * menu, for example) re-synchronize from here instead of waiting for a
55
+ * reconnect. Subscribers must not throw; the disposer is idempotent.
56
+ */
57
+ export function onImHostLanguageChange(listener) {
58
+ if (typeof listener !== 'function') {
59
+ throw new TypeError('onImHostLanguageChange requires a listener function');
60
+ }
61
+ listeners.add(listener);
62
+ return () => {
63
+ listeners.delete(listener);
64
+ };
65
+ }
66
+
67
+ // Translate a user-facing Chinese literal. In zh mode (the default) this is
68
+ // the identity function. Optional `params` fills `{name}` placeholders in
69
+ // both the Chinese key and its translation, e.g.
70
+ // t('共 {count} 个机器人', { count: 3 })
71
+ export function t(text, params) {
72
+ if (typeof text !== 'string') return text;
73
+ const translated = language === 'en' ? EN[text] ?? text : text;
74
+ if (params == null) return translated;
75
+ return translated.replace(/\{(\w+)\}/g, (match, name) =>
76
+ Object.hasOwn(params, name) ? String(params[name]) : match,
77
+ );
78
+ }
@@ -0,0 +1,65 @@
1
+ // Session-keyed source guidance for the current conversation.
2
+ //
3
+ // The prompt RPC carries no message source, so a channel publishes the guidance
4
+ // it would otherwise repeat inside every user message when it dispatches the
5
+ // prompt. The Host materializes it once per session as dynamic prompt context
6
+ // (`systemPrompt.context`), which appends a durable snapshot only when the
7
+ // rendered text changes. The registry is module-level because one process owns
8
+ // exactly one, the same shape `outboundArtifactRegistry` uses.
9
+
10
+ /** Prompt-context name the Host materializes this guidance under. */
11
+ export const IM_SOURCE_GUIDANCE_CONTEXT = 'dsh-im:source-guidance';
12
+
13
+ /** Contexts are joined in ascending order; this one follows the policy facts. */
14
+ export const IM_SOURCE_GUIDANCE_ORDER = 125;
15
+
16
+ /** Bound for one session's guidance; the settings cap is the same size. */
17
+ const GUIDANCE_MAX_LENGTH = 8_000;
18
+
19
+ /** Bound on retained sessions, so an abandoned conversation cannot grow it. */
20
+ const MAX_SESSIONS = 1_024;
21
+
22
+ class ImSourceGuidanceRegistry {
23
+ #bySession = new Map();
24
+
25
+ /**
26
+ * Publish the guidance in force for one session. Empty guidance clears it, so
27
+ * a conversation that turns enhancement off stops contributing a snapshot.
28
+ * @param sessionId - the Session the prompt was dispatched to.
29
+ * @param guidance - the scope's guidance text, or empty when none applies.
30
+ */
31
+ publish(sessionId, guidance) {
32
+ if (typeof sessionId !== 'string' || !sessionId) return;
33
+ const text = typeof guidance === 'string' ? guidance.slice(0, GUIDANCE_MAX_LENGTH) : '';
34
+ // Delete first so the re-inserted key is the most recently used one.
35
+ this.#bySession.delete(sessionId);
36
+ if (!text.trim()) return;
37
+ this.#bySession.set(sessionId, text);
38
+ while (this.#bySession.size > MAX_SESSIONS) {
39
+ this.#bySession.delete(this.#bySession.keys().next().value);
40
+ }
41
+ }
42
+
43
+ /**
44
+ * @param sessionId - a Session id, or anything else.
45
+ * @returns the guidance in force for that session, or undefined.
46
+ */
47
+ get(sessionId) {
48
+ return typeof sessionId === 'string' ? this.#bySession.get(sessionId) : undefined;
49
+ }
50
+
51
+ /**
52
+ * Drop one session's guidance.
53
+ * @param sessionId - the Session leaving the registry.
54
+ */
55
+ forget(sessionId) {
56
+ if (typeof sessionId === 'string') this.#bySession.delete(sessionId);
57
+ }
58
+
59
+ /** @returns how many sessions currently carry guidance. */
60
+ get size() {
61
+ return this.#bySession.size;
62
+ }
63
+ }
64
+
65
+ export const imSourceGuidance = new ImSourceGuidanceRegistry();
@@ -0,0 +1,35 @@
1
+ export const IMAGE_MEGABYTE = 1024 * 1024;
2
+
3
+ export const DEFAULT_IMAGE_INPUT_SETTINGS = Object.freeze({
4
+ maxDownloadMb: 30,
5
+ maxImageMb: 5,
6
+ maxTotalMb: 20,
7
+ maxImages: 20,
8
+ });
9
+
10
+ /** Shared by the settings form and Host; reject incomplete or unsafe values. */
11
+ export function normalizeImageInputSettings(value) {
12
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
13
+ const result = {};
14
+ for (const key of Object.keys(DEFAULT_IMAGE_INPUT_SETTINGS)) {
15
+ const input = value[key];
16
+ const number = typeof input === 'string' && /^\d+$/.test(input.trim())
17
+ ? Number(input.trim()) : input;
18
+ if (!Number.isSafeInteger(number) || number < 1
19
+ || !Number.isSafeInteger(number * IMAGE_MEGABYTE)) return null;
20
+ result[key] = number;
21
+ }
22
+ if (result.maxDownloadMb < result.maxImageMb || result.maxTotalMb < result.maxImageMb) return null;
23
+ return Object.freeze(result);
24
+ }
25
+
26
+ export function imageInputLimits(settings = DEFAULT_IMAGE_INPUT_SETTINGS) {
27
+ const normalized = normalizeImageInputSettings(settings);
28
+ if (!normalized) throw new TypeError('Invalid image input settings');
29
+ return Object.freeze({
30
+ maxDownloadBytes: normalized.maxDownloadMb * IMAGE_MEGABYTE,
31
+ maxImageBytes: normalized.maxImageMb * IMAGE_MEGABYTE,
32
+ maxTotalImageBytes: normalized.maxTotalMb * IMAGE_MEGABYTE,
33
+ maxImages: normalized.maxImages,
34
+ });
35
+ }
@@ -0,0 +1,60 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
+ import { homedir } from 'node:os';
4
+ import { dirname, join, resolve } from 'node:path';
5
+
6
+ import { DEFAULT_IMAGE_INPUT_SETTINGS, normalizeImageInputSettings } from './image-input-policy.mjs';
7
+
8
+ const stores = new Map();
9
+
10
+ export class ImageInputSettingsStore {
11
+ #path;
12
+ #settings = DEFAULT_IMAGE_INPUT_SETTINGS;
13
+ #ready;
14
+ #writes = Promise.resolve();
15
+
16
+ constructor(path) { this.#path = path; }
17
+
18
+ async get() {
19
+ this.#ready ??= this.#load().catch((error) => { this.#ready = null; throw error; });
20
+ await this.#ready;
21
+ return { ...this.#settings };
22
+ }
23
+
24
+ async #load() {
25
+ let raw;
26
+ try { raw = await readFile(this.#path, 'utf8'); }
27
+ catch (error) { if (error.code === 'ENOENT') return; throw error; }
28
+ const document = JSON.parse(raw);
29
+ const settings = document.version === 1 && normalizeImageInputSettings(document.imageInput);
30
+ if (!settings) throw new Error('Invalid image input settings document');
31
+ this.#settings = settings;
32
+ }
33
+
34
+ async set(value) {
35
+ const settings = normalizeImageInputSettings(value);
36
+ if (!settings) throw new TypeError('Invalid image input settings');
37
+ const operation = this.#writes.catch(() => {}).then(async () => {
38
+ await this.get();
39
+ await mkdir(dirname(this.#path), { recursive: true, mode: 0o700 });
40
+ const temporary = `${this.#path}.${randomUUID()}.tmp`;
41
+ try {
42
+ await writeFile(temporary, `${JSON.stringify({ version: 1, imageInput: settings }, null, 2)}\n`,
43
+ { mode: 0o600, flag: 'wx' });
44
+ await rename(temporary, this.#path);
45
+ this.#settings = settings;
46
+ } finally { await rm(temporary, { force: true }); }
47
+ return { ...settings };
48
+ });
49
+ this.#writes = operation;
50
+ return operation;
51
+ }
52
+ }
53
+
54
+ /** One settings owner per DSH home, shared by the UI and channel Harness clients. */
55
+ export function getImageInputSettingsStore(config = {}) {
56
+ const root = resolve(config.dshHome ?? process.env.DSH_HOME ?? join(homedir(), '.dsh'));
57
+ const path = join(root, 'integrations', 'dsh-im', 'image-input-settings.json');
58
+ if (!stores.has(path)) stores.set(path, new ImageInputSettingsStore(path));
59
+ return stores.get(path);
60
+ }
@@ -0,0 +1,124 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { basename, join } from 'node:path';
3
+
4
+ import {
5
+ detectedImageMediaType, ImagePromptError, imageStorageName, loadedImage, imageDownloadLimitMessage,
6
+ } from './image-prompt.mjs';
7
+ import { t } from './i18n.mjs';
8
+
9
+ const MAX_INPUT_PIXELS = 64_000_000;
10
+ const COMPRESSION_STEPS = [[2048, 80], [1536, 70], [1024, 60]];
11
+ let sharpPromise;
12
+ async function loadSharp() {
13
+ sharpPromise ??= import('sharp').then((module) => module.default).catch(() => null);
14
+ return sharpPromise;
15
+ }
16
+
17
+ export const IMAGE_ORIGINALS_PROMPT = '图片原文件已保存到工作区,文件清单中的图片序号与本条消息一致。图片内容块可能经过缩放或压缩;需要查看细节时可用工具读取原文件。';
18
+ export const IMAGE_INPUT_FALLBACK_PROMPT = '部分图片未直接提供给模型,图片序号:{indexes}。原文件已保存,请使用可用工具读取或分析;不要假设自己已看到这些图片。';
19
+ export const IMAGE_HOST_LIMIT_FALLBACK_PROMPT = '宿主拒绝了本次图片输入。原图已保存到工作区,请根据文件清单使用可用工具读取或分析,不要假设自己已看到图片。';
20
+
21
+ /** Keep provider loaders intact; stage and validate each original once. */
22
+ export function inboundImagesAsFiles(images, limits) {
23
+ if (images.length > limits.maxImages) {
24
+ throw new ImagePromptError('too-many-images', 'Too many inbound images',
25
+ t('一次最多只能处理 {maxImages} 张图片。', { maxImages: limits.maxImages }));
26
+ }
27
+ const tooLarge = () => new ImagePromptError('image-too-large',
28
+ `Image exceeds ${limits.maxDownloadBytes} bytes`, imageDownloadLimitMessage(limits.maxDownloadBytes));
29
+ // Check declared sizes before any download starts, including later images.
30
+ for (const source of images) {
31
+ if (Number.isFinite(source?.size) && source.size > limits.maxDownloadBytes) throw tooLarge();
32
+ }
33
+ return images.map((source, index) => ({
34
+ async load({ signal } = {}) {
35
+ signal?.throwIfAborted();
36
+ let value;
37
+ try {
38
+ value = source.data === undefined
39
+ ? await source.load?.({ signal, maxBytes: limits.maxDownloadBytes }) : source.data;
40
+ } catch (error) {
41
+ if (signal?.aborted) throw signal.reason ?? error;
42
+ if (error?.code === 'image-too-large') throw tooLarge();
43
+ if (error instanceof ImagePromptError || ['AbortError', 'TimeoutError'].includes(error?.name)) throw error;
44
+ throw new ImagePromptError('image-download-failed', 'Unable to download image',
45
+ t('图片下载失败,请重新发送后再试。'), { cause: error });
46
+ }
47
+ signal?.throwIfAborted();
48
+ const loaded = loadedImage(value);
49
+ if (!loaded?.data.length) throw new ImagePromptError('invalid-image-data', 'Empty image',
50
+ t('未能读取图片内容,请重新发送。'));
51
+ if (loaded.data.length > limits.maxDownloadBytes) throw tooLarge();
52
+ const mediaType = detectedImageMediaType(loaded.data);
53
+ if (!mediaType) throw new ImagePromptError('unsupported-image-type', 'Unsupported image',
54
+ t('暂不支持该图片格式,请发送 JPEG、PNG、WebP 或 GIF 图片。'));
55
+ return { data: loaded.data, mediaType,
56
+ name: `${index + 1}-${imageStorageName(loaded.name ?? source.name, mediaType, index)}` };
57
+ },
58
+ }));
59
+ }
60
+
61
+ /** A missing optional codec still permits small native images and file delivery. */
62
+ export async function modelImageFromOriginal(data, mediaType, maxBytes, {
63
+ signal, sharpLoader = loadSharp,
64
+ } = {}) {
65
+ signal?.throwIfAborted();
66
+ if (maxBytes <= 0) return null;
67
+ const sharp = await sharpLoader();
68
+ signal?.throwIfAborted();
69
+ if (!sharp) return data.length <= maxBytes ? { data, mediaType } : null;
70
+ try {
71
+ const metadata = await sharp(data, { limitInputPixels: MAX_INPUT_PIXELS }).metadata();
72
+ signal?.throwIfAborted();
73
+ if (metadata.width * metadata.height > MAX_INPUT_PIXELS) return null;
74
+ if ((metadata.pages ?? 1) > 1 || mediaType === 'image/gif') {
75
+ return data.length <= maxBytes ? { data, mediaType } : null;
76
+ }
77
+ if (data.length <= maxBytes && metadata.width <= 2048 && metadata.height <= 2048) {
78
+ return { data, mediaType };
79
+ }
80
+ for (const [side, quality] of COMPRESSION_STEPS) {
81
+ signal?.throwIfAborted();
82
+ const operation = sharp(data, { limitInputPixels: MAX_INPUT_PIXELS }).rotate()
83
+ .resize({ width: side, height: side, fit: 'inside', withoutEnlargement: true });
84
+ const output = metadata.hasAlpha
85
+ ? await operation.png({ compressionLevel: 9 }).toBuffer()
86
+ : await operation.jpeg({ quality }).toBuffer();
87
+ signal?.throwIfAborted();
88
+ if (output.length <= maxBytes) return { data: output,
89
+ mediaType: metadata.hasAlpha ? 'image/png' : 'image/jpeg' };
90
+ }
91
+ } catch (error) {
92
+ signal?.throwIfAborted();
93
+ // A codec failure cannot discard an original already saved for tools.
94
+ }
95
+ return null;
96
+ }
97
+
98
+ export async function imageContentFromStaged(staged, limits, { signal, sharpLoader } = {}) {
99
+ const content = [];
100
+ const fileOnly = [];
101
+ let remaining = limits.maxTotalImageBytes;
102
+ for (const [index, file] of staged.files.entries()) {
103
+ signal?.throwIfAborted();
104
+ // Staging owns both the directory and basename; never read a user-supplied path.
105
+ const data = await readFile(join(staged.directory, basename(file.path)), { signal });
106
+ const result = await modelImageFromOriginal(data, file.mediaType,
107
+ Math.min(limits.maxImageBytes, remaining), { signal, sharpLoader });
108
+ if (!result) { fileOnly.push(index + 1); continue; }
109
+ remaining -= result.data.length;
110
+ content.push({ type: 'text', text: t('图片 {index}(原图文件:{name})', { index: index + 1, name: file.name }) },
111
+ { type: 'image', mediaType: result.mediaType, data: result.data.toString('base64'),
112
+ name: imageStorageName(file.name.replace(/\.[^.]+$/, ''), result.mediaType, index) });
113
+ }
114
+ content.push({ type: 'text', text: t(IMAGE_ORIGINALS_PROMPT) });
115
+ if (fileOnly.length) content.push({ type: 'text',
116
+ text: t(IMAGE_INPUT_FALLBACK_PROMPT, { indexes: fileOnly.join(', ') }) });
117
+ return content;
118
+ }
119
+
120
+ export function isImageAdmissionRejection(error) {
121
+ return ['attachment-error', 'session/attachment-invalid'].includes(error?.code)
122
+ && ['MODEL_DOES_NOT_SUPPORT_IMAGES', 'IMAGE_TOO_LARGE', 'IMAGES_TOO_LARGE',
123
+ 'IMAGE_TOO_MANY_PIXELS', 'TOO_MANY_IMAGES'].includes(error?.details?.reason);
124
+ }