@botharness/im-provider 4.32.0-botharness.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.
- package/LICENSE +21 -0
- package/PROVENANCE.json +25 -0
- package/README.en.md +445 -0
- package/README.md +448 -0
- package/THIRD_PARTY_NOTICES.md +93 -0
- package/assets/dingtalk-menu-template.json +6 -0
- package/assets/logo-dsh-im-chinese-readme-3x2.png +0 -0
- package/assets/logo-dsh-im-connecting-readme-3x2.png +0 -0
- package/assets/logo-dsh-im-connecting-square-v4.png +0 -0
- package/assets/logo-icon.png +0 -0
- package/assets/logo-plugin-message-link-gradient.webp +0 -0
- package/assets/logo-plugin-phone.png +0 -0
- package/assets/logo.png +0 -0
- package/assets/logo_cn.png +0 -0
- package/assets/screenshot-menu-card.png +0 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +20330 -0
- package/lib/index.js +602 -0
- package/locale/en.json +5 -0
- package/locale/zh.json +5 -0
- package/package.json +181 -0
- package/plugin-src/client/access-policy-settings.js +362 -0
- package/plugin-src/client/agent-preset.js +119 -0
- package/plugin-src/client/bot-alias.js +169 -0
- package/plugin-src/client/build.mjs +38 -0
- package/plugin-src/client/channel-card-meta.js +132 -0
- package/plugin-src/client/channel-logos.js +190 -0
- package/plugin-src/client/channels/dingtalk/api.js +267 -0
- package/plugin-src/client/channels/dingtalk/index.js +954 -0
- package/plugin-src/client/channels/dingtalk/styles.js +136 -0
- package/plugin-src/client/channels/discord/api.js +11 -0
- package/plugin-src/client/channels/discord/index.js +25 -0
- package/plugin-src/client/channels/discord/styles.js +19 -0
- package/plugin-src/client/channels/email/api.js +52 -0
- package/plugin-src/client/channels/email/index.js +728 -0
- package/plugin-src/client/channels/email/styles.js +51 -0
- package/plugin-src/client/channels/feishu/api.js +405 -0
- package/plugin-src/client/channels/feishu/group-settings.js +581 -0
- package/plugin-src/client/channels/feishu/index.js +1583 -0
- package/plugin-src/client/channels/feishu/slash-panel-settings.js +322 -0
- package/plugin-src/client/channels/feishu/styles.js +573 -0
- package/plugin-src/client/channels/feishu/voice-editor.js +115 -0
- package/plugin-src/client/channels/feishu/voice-settings.js +71 -0
- package/plugin-src/client/channels/imessage/api.js +12 -0
- package/plugin-src/client/channels/imessage/index.js +46 -0
- package/plugin-src/client/channels/imessage/styles.js +19 -0
- package/plugin-src/client/channels/matrix/api.js +11 -0
- package/plugin-src/client/channels/matrix/index.js +151 -0
- package/plugin-src/client/channels/matrix/styles.js +36 -0
- package/plugin-src/client/channels/office/api.js +46 -0
- package/plugin-src/client/channels/office/index.js +153 -0
- package/plugin-src/client/channels/office/styles.js +50 -0
- package/plugin-src/client/channels/qq/api.js +171 -0
- package/plugin-src/client/channels/qq/index.js +593 -0
- package/plugin-src/client/channels/qq/styles.js +19 -0
- package/plugin-src/client/channels/shared/collapsible-account.js +103 -0
- package/plugin-src/client/channels/shared/token-api.js +124 -0
- package/plugin-src/client/channels/shared/token-channel.js +495 -0
- package/plugin-src/client/channels/slack/api.js +11 -0
- package/plugin-src/client/channels/slack/index.js +131 -0
- package/plugin-src/client/channels/slack/styles.js +34 -0
- package/plugin-src/client/channels/telegram/api.js +11 -0
- package/plugin-src/client/channels/telegram/index.js +28 -0
- package/plugin-src/client/channels/telegram/styles.js +31 -0
- package/plugin-src/client/channels/telegram/thinking-traces.js +25 -0
- package/plugin-src/client/channels/wecom/api.js +160 -0
- package/plugin-src/client/channels/wecom/index.js +625 -0
- package/plugin-src/client/channels/wecom/styles.js +19 -0
- package/plugin-src/client/channels/wecom-app/api.js +132 -0
- package/plugin-src/client/channels/wecom-app/index.js +634 -0
- package/plugin-src/client/channels/wecom-app/styles.js +25 -0
- package/plugin-src/client/channels/weixin/api.js +211 -0
- package/plugin-src/client/channels/weixin/connection-error.js +1 -0
- package/plugin-src/client/channels/weixin/index.js +801 -0
- package/plugin-src/client/channels/weixin/styles.js +115 -0
- package/plugin-src/client/channels/whatsapp/api.js +152 -0
- package/plugin-src/client/channels/whatsapp/index.js +609 -0
- package/plugin-src/client/channels/whatsapp/styles.js +19 -0
- package/plugin-src/client/connection-error.js +87 -0
- package/plugin-src/client/context-enhancement.js +415 -0
- package/plugin-src/client/credential-binding.js +118 -0
- package/plugin-src/client/delivery-settings.js +905 -0
- package/plugin-src/client/global-settings.js +433 -0
- package/plugin-src/client/i18n.js +1314 -0
- package/plugin-src/client/index.js +624 -0
- package/plugin-src/client/interface-language.js +89 -0
- package/plugin-src/client/last-message-error.js +18 -0
- package/plugin-src/client/lifecycle.js +86 -0
- package/plugin-src/client/loopback-recovery.js +75 -0
- package/plugin-src/client/model-setting.js +172 -0
- package/plugin-src/client/panel-error-boundary.js +21 -0
- package/plugin-src/client/plugin-page.js +51 -0
- package/plugin-src/client/session-channel-logos.js +243 -0
- package/plugin-src/client/styles.js +770 -0
- package/plugin-src/client/update-panel.js +14 -0
- package/plugin-src/client/workspace-directory-picker.js +280 -0
- package/plugin-src/client/workspace-editor.js +69 -0
- package/plugin-src/client/workspace-snapshot-fence.js +28 -0
- package/plugin-src/host/build.mjs +52 -0
- package/plugin-src/host/channels/dingtalk/connection-supervisor.mjs +130 -0
- package/plugin-src/host/channels/dingtalk/index.mjs +35 -0
- package/plugin-src/host/channels/dingtalk/production.mjs +193 -0
- package/plugin-src/host/channels/dingtalk/rpc.mjs +359 -0
- package/plugin-src/host/channels/discord/index.mjs +33 -0
- package/plugin-src/host/channels/discord/production.mjs +17 -0
- package/plugin-src/host/channels/discord/rpc.mjs +21 -0
- package/plugin-src/host/channels/email/availability.mjs +60 -0
- package/plugin-src/host/channels/email/index.mjs +36 -0
- package/plugin-src/host/channels/email/production.mjs +58 -0
- package/plugin-src/host/channels/email/rpc.mjs +163 -0
- package/plugin-src/host/channels/feishu/connection-supervisor.mjs +167 -0
- package/plugin-src/host/channels/feishu/controller.mjs +172 -0
- package/plugin-src/host/channels/feishu/credential-store.mjs +84 -0
- package/plugin-src/host/channels/feishu/index.mjs +69 -0
- package/plugin-src/host/channels/feishu/production.mjs +318 -0
- package/plugin-src/host/channels/feishu/rpc.mjs +863 -0
- package/plugin-src/host/channels/imessage/index.mjs +21 -0
- package/plugin-src/host/channels/imessage/production.mjs +13 -0
- package/plugin-src/host/channels/imessage/rpc.mjs +78 -0
- package/plugin-src/host/channels/matrix/index.mjs +31 -0
- package/plugin-src/host/channels/matrix/production.mjs +241 -0
- package/plugin-src/host/channels/matrix/rpc.mjs +228 -0
- package/plugin-src/host/channels/office/index.mjs +14 -0
- package/plugin-src/host/channels/office/production.mjs +45 -0
- package/plugin-src/host/channels/office/rpc.mjs +51 -0
- package/plugin-src/host/channels/qq/connection-supervisor.mjs +124 -0
- package/plugin-src/host/channels/qq/index.mjs +28 -0
- package/plugin-src/host/channels/qq/production.mjs +181 -0
- package/plugin-src/host/channels/qq/rpc.mjs +250 -0
- package/plugin-src/host/channels/shared/access-policy-production.mjs +137 -0
- package/plugin-src/host/channels/shared/access-policy-rpc.mjs +17 -0
- package/plugin-src/host/channels/shared/agent-preset-rpc.mjs +25 -0
- package/plugin-src/host/channels/shared/bot-alias-rpc.mjs +15 -0
- package/plugin-src/host/channels/shared/connection-supervisor.mjs +133 -0
- package/plugin-src/host/channels/shared/context-enhancement-rpc.mjs +17 -0
- package/plugin-src/host/channels/shared/model-setting-rpc.mjs +18 -0
- package/plugin-src/host/channels/shared/production.mjs +237 -0
- package/plugin-src/host/channels/shared/rpc.mjs +226 -0
- package/plugin-src/host/channels/shared/startup-error.mjs +55 -0
- package/plugin-src/host/channels/shared/startup.mjs +76 -0
- package/plugin-src/host/channels/shared/thinking-traces-rpc.mjs +11 -0
- package/plugin-src/host/channels/shared/workspace-rpc.mjs +31 -0
- package/plugin-src/host/channels/slack/index.mjs +31 -0
- package/plugin-src/host/channels/slack/production.mjs +176 -0
- package/plugin-src/host/channels/slack/rpc.mjs +221 -0
- package/plugin-src/host/channels/telegram/index.mjs +33 -0
- package/plugin-src/host/channels/telegram/production.mjs +19 -0
- package/plugin-src/host/channels/telegram/rpc.mjs +22 -0
- package/plugin-src/host/channels/wecom/connection-supervisor.mjs +124 -0
- package/plugin-src/host/channels/wecom/index.mjs +34 -0
- package/plugin-src/host/channels/wecom/production.mjs +187 -0
- package/plugin-src/host/channels/wecom/rpc.mjs +255 -0
- package/plugin-src/host/channels/wecom-app/index.mjs +33 -0
- package/plugin-src/host/channels/wecom-app/production.mjs +221 -0
- package/plugin-src/host/channels/wecom-app/rpc.mjs +235 -0
- package/plugin-src/host/channels/weixin/connection-supervisor.mjs +139 -0
- package/plugin-src/host/channels/weixin/index.mjs +44 -0
- package/plugin-src/host/channels/weixin/production.mjs +257 -0
- package/plugin-src/host/channels/weixin/rpc.mjs +285 -0
- package/plugin-src/host/channels/whatsapp/index.mjs +33 -0
- package/plugin-src/host/channels/whatsapp/production.mjs +198 -0
- package/plugin-src/host/channels/whatsapp/rpc.mjs +242 -0
- package/plugin-src/host/delivery-adapter.mjs +388 -0
- package/plugin-src/host/delivery-http.mjs +132 -0
- package/plugin-src/host/delivery-rpc.mjs +173 -0
- package/plugin-src/host/delivery-service.mjs +552 -0
- package/plugin-src/host/delivery-suggestions.mjs +198 -0
- package/plugin-src/host/harness-command-executor.mjs +48 -0
- package/plugin-src/host/harness-connection.mjs +20 -0
- package/plugin-src/host/harness-session-coordinator.mjs +183 -0
- package/plugin-src/host/host-language-rpc.mjs +71 -0
- package/plugin-src/host/host-language.mjs +157 -0
- package/plugin-src/host/image-input-rpc.mjs +24 -0
- package/plugin-src/host/inbound-ttl-rpc.mjs +86 -0
- package/plugin-src/host/inbound-ttl-runtime.mjs +85 -0
- package/plugin-src/host/inbound-ttl-service.mjs +179 -0
- package/plugin-src/host/index.mjs +224 -0
- package/plugin-src/host/injected-context.mjs +104 -0
- package/plugin-src/host/lark-sdk-handshake-patch.mjs +181 -0
- package/plugin-src/host/modern-harness-api.mjs +738 -0
- package/plugin-src/host/rpc-authority.mjs +12 -0
- package/plugin-src/host/session-sync-coordinator.mjs +233 -0
- package/plugin-src/host/session-title-prefix.mjs +122 -0
- package/plugin-src/host/update-policy.mjs +31 -0
- package/plugin-src/host/update-rpc.mjs +16 -0
- package/plugin-src/host/update-runtime.mjs +339 -0
- package/plugin-src/host/update-service.mjs +392 -0
- package/plugin-src/management-rpc.mjs +87 -0
- package/src/channels/dingtalk/config-store.mjs +284 -0
- package/src/channels/dingtalk/connection-error.mjs +292 -0
- package/src/channels/dingtalk/device-auth.mjs +240 -0
- package/src/channels/dingtalk/dingtalk-api.mjs +1140 -0
- package/src/channels/dingtalk/dingtalk-bridge.mjs +1889 -0
- package/src/channels/dingtalk/dingtalk-card-stream.mjs +242 -0
- package/src/channels/dingtalk/dingtalk-controller.mjs +852 -0
- package/src/channels/dingtalk/dingtalk-menu.mjs +95 -0
- package/src/channels/dingtalk/dingtalk-runtime.mjs +482 -0
- package/src/channels/dingtalk/harness-client.mjs +19 -0
- package/src/channels/dingtalk/state-store.mjs +325 -0
- package/src/channels/discord/config-store.mjs +25 -0
- package/src/channels/discord/discord-api.mjs +347 -0
- package/src/channels/discord/discord-bridge.mjs +16 -0
- package/src/channels/discord/discord-controller.mjs +16 -0
- package/src/channels/discord/discord-runtime.mjs +974 -0
- package/src/channels/discord/harness-client.mjs +11 -0
- package/src/channels/discord/state-store.mjs +3 -0
- package/src/channels/email/config-store.mjs +194 -0
- package/src/channels/email/email-api.mjs +20 -0
- package/src/channels/email/email-bridge.mjs +17 -0
- package/src/channels/email/email-controller.mjs +824 -0
- package/src/channels/email/email-runtime.mjs +699 -0
- package/src/channels/email/harness-client.mjs +7 -0
- package/src/channels/email/mail-format.mjs +91 -0
- package/src/channels/email/state-store.mjs +176 -0
- package/src/channels/email/transport.mjs +64 -0
- package/src/channels/email/transports/agent-mail.mjs +604 -0
- package/src/channels/email/transports/agently-cli.mjs +288 -0
- package/src/channels/email/transports/imap-smtp.mjs +165 -0
- package/src/channels/feishu/bridge.mjs +6286 -0
- package/src/channels/feishu/config.mjs +71 -0
- package/src/channels/feishu/external-consumer.mjs +77 -0
- package/src/channels/feishu/external-files.mjs +111 -0
- package/src/channels/feishu/feishu-app.mjs +54 -0
- package/src/channels/feishu/feishu-cards.mjs +1285 -0
- package/src/channels/feishu/feishu-channel.mjs +651 -0
- package/src/channels/feishu/feishu-runtime.mjs +950 -0
- package/src/channels/feishu/group-message-permission-manager.mjs +72 -0
- package/src/channels/feishu/group-response-mode.mjs +15 -0
- package/src/channels/feishu/harness-client.mjs +19 -0
- package/src/channels/feishu/history-reader.mjs +77 -0
- package/src/channels/feishu/live-cot.mjs +260 -0
- package/src/channels/feishu/message-utils.mjs +613 -0
- package/src/channels/feishu/multi-bot-controller.mjs +1588 -0
- package/src/channels/feishu/nearby-history.mjs +72 -0
- package/src/channels/feishu/plugin-config-store.mjs +216 -0
- package/src/channels/feishu/plugin-controller.mjs +254 -0
- package/src/channels/feishu/registration-manager.mjs +349 -0
- package/src/channels/feishu/repair-manager.mjs +138 -0
- package/src/channels/feishu/reply-context.mjs +22 -0
- package/src/channels/feishu/slash-command-panel.mjs +155 -0
- package/src/channels/feishu/slash-command-registry.mjs +495 -0
- package/src/channels/feishu/state-store.mjs +214 -0
- package/src/channels/feishu/step-push-mode.mjs +25 -0
- package/src/channels/feishu/voice-config.mjs +34 -0
- package/src/channels/feishu/voice.mjs +134 -0
- package/src/channels/imessage/config-store.mjs +24 -0
- package/src/channels/imessage/controller.mjs +37 -0
- package/src/channels/imessage/harness-client.mjs +7 -0
- package/src/channels/imessage/imessage-api.mjs +194 -0
- package/src/channels/imessage/imessage-bridge.mjs +16 -0
- package/src/channels/imessage/runtime.mjs +102 -0
- package/src/channels/imessage/state-store.mjs +3 -0
- package/src/channels/matrix/matrix-api.mjs +696 -0
- package/src/channels/matrix/matrix-bridge.mjs +20 -0
- package/src/channels/matrix/matrix-config-store.mjs +368 -0
- package/src/channels/matrix/matrix-controller.mjs +404 -0
- package/src/channels/matrix/matrix-crypto-store.mjs +279 -0
- package/src/channels/matrix/matrix-crypto.mjs +1014 -0
- package/src/channels/matrix/matrix-harness-client.mjs +11 -0
- package/src/channels/matrix/matrix-normalize.mjs +357 -0
- package/src/channels/matrix/matrix-rich-text.mjs +313 -0
- package/src/channels/matrix/matrix-room-history.mjs +316 -0
- package/src/channels/matrix/matrix-runtime.mjs +1014 -0
- package/src/channels/office/config-store.mjs +107 -0
- package/src/channels/office/office-controller.mjs +178 -0
- package/src/channels/office/office-job-executor.mjs +391 -0
- package/src/channels/office/office-runtime.mjs +175 -0
- package/src/channels/office/office-transport.mjs +171 -0
- package/src/channels/office/protocol.mjs +43 -0
- package/src/channels/qq/config-store.mjs +173 -0
- package/src/channels/qq/harness-client.mjs +11 -0
- package/src/channels/qq/markdown-reply.mjs +446 -0
- package/src/channels/qq/qq-bridge.mjs +1507 -0
- package/src/channels/qq/qq-controller.mjs +514 -0
- package/src/channels/qq/qq-menu.mjs +208 -0
- package/src/channels/qq/qq-runtime.mjs +303 -0
- package/src/channels/qq/qr-auth.mjs +24 -0
- package/src/channels/qq/state-error.mjs +17 -0
- package/src/channels/qq/state-store.mjs +143 -0
- package/src/channels/shared/access-policy.mjs +210 -0
- package/src/channels/shared/agent-preset.mjs +76 -0
- package/src/channels/shared/batch-input.mjs +229 -0
- package/src/channels/shared/bot-alias.mjs +29 -0
- package/src/channels/shared/bot-workspace-store.mjs +2383 -0
- package/src/channels/shared/command-catalog.mjs +107 -0
- package/src/channels/shared/command-permission.mjs +32 -0
- package/src/channels/shared/compact-command.mjs +109 -0
- package/src/channels/shared/config-read-error.mjs +24 -0
- package/src/channels/shared/connection-error.mjs +191 -0
- package/src/channels/shared/connection-test.mjs +58 -0
- package/src/channels/shared/context-enhancement.mjs +372 -0
- package/src/channels/shared/control-command.mjs +111 -0
- package/src/channels/shared/conversation-state-store.mjs +165 -0
- package/src/channels/shared/default-workspace.mjs +31 -0
- package/src/channels/shared/deferred-delivery-coordinator.mjs +241 -0
- package/src/channels/shared/deferred-delivery.mjs +161 -0
- package/src/channels/shared/deferred-state.mjs +53 -0
- package/src/channels/shared/diagnostic-details.mjs +95 -0
- package/src/channels/shared/editable-message-stream.mjs +100 -0
- package/src/channels/shared/exclusive-inbound-consumers.mjs +71 -0
- package/src/channels/shared/file-download.mjs +64 -0
- package/src/channels/shared/harness-approval.mjs +508 -0
- package/src/channels/shared/harness-client.mjs +2143 -0
- package/src/channels/shared/harness-mux.mjs +123 -0
- package/src/channels/shared/harness-question.mjs +95 -0
- package/src/channels/shared/harness-session-binding.mjs +119 -0
- package/src/channels/shared/history-command.mjs +193 -0
- package/src/channels/shared/i18n-en/diagnostics.mjs +55 -0
- package/src/channels/shared/i18n-en/dingtalk.mjs +81 -0
- package/src/channels/shared/i18n-en/discord.mjs +10 -0
- package/src/channels/shared/i18n-en/email.mjs +25 -0
- package/src/channels/shared/i18n-en/feishu.mjs +404 -0
- package/src/channels/shared/i18n-en/image-input.mjs +18 -0
- package/src/channels/shared/i18n-en/matrix.mjs +85 -0
- package/src/channels/shared/i18n-en/office.mjs +23 -0
- package/src/channels/shared/i18n-en/qq.mjs +96 -0
- package/src/channels/shared/i18n-en/shared-a.mjs +241 -0
- package/src/channels/shared/i18n-en/shared-b.mjs +263 -0
- package/src/channels/shared/i18n-en/shared-c.mjs +203 -0
- package/src/channels/shared/i18n-en/slack.mjs +27 -0
- package/src/channels/shared/i18n-en/telegram.mjs +27 -0
- package/src/channels/shared/i18n-en/wecom-app.mjs +33 -0
- package/src/channels/shared/i18n-en/wecom.mjs +62 -0
- package/src/channels/shared/i18n-en/weixin.mjs +88 -0
- package/src/channels/shared/i18n-en/whatsapp.mjs +17 -0
- package/src/channels/shared/i18n-en.mjs +45 -0
- package/src/channels/shared/i18n.mjs +78 -0
- package/src/channels/shared/im-source-guidance.mjs +65 -0
- package/src/channels/shared/image-input-policy.mjs +35 -0
- package/src/channels/shared/image-input-settings-store.mjs +60 -0
- package/src/channels/shared/image-input.mjs +124 -0
- package/src/channels/shared/image-prompt.mjs +360 -0
- package/src/channels/shared/inbound-access.mjs +43 -0
- package/src/channels/shared/inbound-file.mjs +323 -0
- package/src/channels/shared/inbound-ttl-store.mjs +110 -0
- package/src/channels/shared/inbound-ttl.mjs +22 -0
- package/src/channels/shared/injected-context.mjs +362 -0
- package/src/channels/shared/interface-language-store.mjs +127 -0
- package/src/channels/shared/interface-language.mjs +51 -0
- package/src/channels/shared/message-failure.mjs +257 -0
- package/src/channels/shared/model-command.mjs +741 -0
- package/src/channels/shared/model-setting.mjs +145 -0
- package/src/channels/shared/preset-command.mjs +308 -0
- package/src/channels/shared/semantic/artifact-delivery.mjs +177 -0
- package/src/channels/shared/semantic/artifact.mjs +750 -0
- package/src/channels/shared/semantic/delivery.mjs +193 -0
- package/src/channels/shared/semantic/reply-reference.mjs +148 -0
- package/src/channels/shared/session-binding-lock.mjs +40 -0
- package/src/channels/shared/session-channel-labels.mjs +28 -0
- package/src/channels/shared/session-reply-recovery.mjs +104 -0
- package/src/channels/shared/session-sync-registry.mjs +22 -0
- package/src/channels/shared/session-title.mjs +74 -0
- package/src/channels/shared/status-reaction.mjs +107 -0
- package/src/channels/shared/text-harness-bridge.mjs +1623 -0
- package/src/channels/shared/token-bot-controller.mjs +417 -0
- package/src/channels/shared/token-config-store.mjs +208 -0
- package/src/channels/shared/workspace-command.mjs +532 -0
- package/src/channels/shared/workspace-session.mjs +196 -0
- package/src/channels/slack/config-store.mjs +177 -0
- package/src/channels/slack/external-consumer.mjs +80 -0
- package/src/channels/slack/external-files.mjs +90 -0
- package/src/channels/slack/harness-client.mjs +11 -0
- package/src/channels/slack/history-reader.mjs +203 -0
- package/src/channels/slack/manifest.mjs +37 -0
- package/src/channels/slack/slack-api.mjs +636 -0
- package/src/channels/slack/slack-bridge.mjs +20 -0
- package/src/channels/slack/slack-controller.mjs +468 -0
- package/src/channels/slack/slack-runtime.mjs +879 -0
- package/src/channels/slack/state-store.mjs +3 -0
- package/src/channels/telegram/config-store.mjs +89 -0
- package/src/channels/telegram/harness-client.mjs +11 -0
- package/src/channels/telegram/state-store.mjs +3 -0
- package/src/channels/telegram/telegram-api.mjs +486 -0
- package/src/channels/telegram/telegram-bridge.mjs +81 -0
- package/src/channels/telegram/telegram-controller.mjs +52 -0
- package/src/channels/telegram/telegram-http.mjs +21 -0
- package/src/channels/telegram/telegram-rich-message.mjs +149 -0
- package/src/channels/telegram/telegram-runtime.mjs +1471 -0
- package/src/channels/wecom/config-store.mjs +172 -0
- package/src/channels/wecom/harness-client.mjs +11 -0
- package/src/channels/wecom/qr-auth.mjs +95 -0
- package/src/channels/wecom/send-error.mjs +31 -0
- package/src/channels/wecom/state-store.mjs +107 -0
- package/src/channels/wecom/wecom-bridge.mjs +1833 -0
- package/src/channels/wecom/wecom-cards.mjs +101 -0
- package/src/channels/wecom/wecom-controller.mjs +530 -0
- package/src/channels/wecom/wecom-runtime.mjs +269 -0
- package/src/channels/wecom-app/callback-server.mjs +471 -0
- package/src/channels/wecom-app/config-store.mjs +242 -0
- package/src/channels/wecom-app/harness-client.mjs +11 -0
- package/src/channels/wecom-app/state-store.mjs +107 -0
- package/src/channels/wecom-app/wecom-app-api.mjs +432 -0
- package/src/channels/wecom-app/wecom-app-bridge.mjs +1072 -0
- package/src/channels/wecom-app/wecom-app-controller.mjs +453 -0
- package/src/channels/wecom-app/wecom-app-runtime.mjs +222 -0
- package/src/channels/weixin/config-store.mjs +192 -0
- package/src/channels/weixin/connection-error.en.mjs +137 -0
- package/src/channels/weixin/connection-error.mjs +153 -0
- package/src/channels/weixin/diagnostic-details.mjs +1 -0
- package/src/channels/weixin/harness-client.mjs +19 -0
- package/src/channels/weixin/state-store.mjs +291 -0
- package/src/channels/weixin/weixin-api.mjs +949 -0
- package/src/channels/weixin/weixin-bridge.mjs +1537 -0
- package/src/channels/weixin/weixin-controller.mjs +669 -0
- package/src/channels/weixin/weixin-runtime.mjs +416 -0
- package/src/channels/whatsapp/config-store.mjs +210 -0
- package/src/channels/whatsapp/harness-client.mjs +11 -0
- package/src/channels/whatsapp/state-store.mjs +3 -0
- package/src/channels/whatsapp/whatsapp-bridge.mjs +18 -0
- package/src/channels/whatsapp/whatsapp-controller.mjs +470 -0
- package/src/channels/whatsapp/whatsapp-runtime.mjs +917 -0
- package/src/channels/whatsapp/whatsapp-web-session.mjs +214 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { normalizeSlackHistoryText, slackRefusal, slackTimestamp } from './external-consumer.mjs';
|
|
3
|
+
|
|
4
|
+
const micros = value => BigInt(value.replace('.', ''));
|
|
5
|
+
const timestamp = value => `${value / 1_000_000n}.${String(value % 1_000_000n).padStart(6, '0')}`;
|
|
6
|
+
const compare = (a, b) => micros(a) < micros(b) ? -1 : micros(a) > micros(b) ? 1 : 0;
|
|
7
|
+
const coverage = 'provider-visible-human-text';
|
|
8
|
+
|
|
9
|
+
/** Runtime-local signed continuations contain native IDs/counts, never message bodies or credentials. */
|
|
10
|
+
export function createSlackHistoryReader({ now = Date.now } = {}) {
|
|
11
|
+
const key = randomBytes(32);
|
|
12
|
+
const sign = body => createHmac('sha256', key).update(body).digest('base64url');
|
|
13
|
+
function encode(binding, state) {
|
|
14
|
+
const body = Buffer.from(JSON.stringify({ binding, state })).toString('base64url');
|
|
15
|
+
const cursor = `${body}.${sign(body)}`;
|
|
16
|
+
if (cursor.length > 4096) throw slackRefusal('history-unavailable');
|
|
17
|
+
return cursor;
|
|
18
|
+
}
|
|
19
|
+
function decode(cursor, binding) {
|
|
20
|
+
try {
|
|
21
|
+
if (typeof cursor !== 'string' || cursor.length > 4096) throw new Error();
|
|
22
|
+
const parts = cursor.split('.');
|
|
23
|
+
if (parts.length !== 2) throw new Error();
|
|
24
|
+
const actual = Buffer.from(parts[1]);
|
|
25
|
+
const expected = Buffer.from(sign(parts[0]));
|
|
26
|
+
if (actual.length !== expected.length || !timingSafeEqual(actual, expected)) throw new Error();
|
|
27
|
+
const parsed = JSON.parse(Buffer.from(parts[0], 'base64url').toString());
|
|
28
|
+
if (parsed.binding !== binding) throw new Error();
|
|
29
|
+
return parsed.state;
|
|
30
|
+
} catch { throw slackRefusal('invalid-history-query'); }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return async function read(api, identity, route, query, signal, assertCurrent) {
|
|
34
|
+
if (!query || (query.cursor !== undefined && (typeof query.cursor !== 'string' || !query.cursor))
|
|
35
|
+
|| !['group', 'thread', 'nearby'].includes(query.scope)
|
|
36
|
+
|| !Number.isInteger(query.limit) || query.limit < 1 || query.limit > 20
|
|
37
|
+
|| (query.scope !== 'nearby' && (query.beforeCount !== undefined || query.afterCount !== undefined)))
|
|
38
|
+
throw slackRefusal('invalid-history-query');
|
|
39
|
+
const minBefore = query.beforeCount ?? 10;
|
|
40
|
+
const minAfter = query.afterCount ?? 5;
|
|
41
|
+
if (![minBefore, minAfter].every(n => Number.isInteger(n) && n >= 0 && n <= 20))
|
|
42
|
+
throw slackRefusal('invalid-history-query');
|
|
43
|
+
const binding = createHash('sha256').update(JSON.stringify({ identity, route,
|
|
44
|
+
scope: query.scope, limit: query.limit, minBefore, minAfter })).digest('hex');
|
|
45
|
+
const state = query.cursor ? decode(query.cursor, binding) : {
|
|
46
|
+
phase: query.scope === 'nearby' ? 'window' : 'page',
|
|
47
|
+
snapshot: timestamp(BigInt(now()) * 1000n), before: 0, after: 0, candidates: [],
|
|
48
|
+
};
|
|
49
|
+
const check = () => { signal?.throwIfAborted(); assertCurrent(); };
|
|
50
|
+
const checked = async call => { check(); const value = await call(); check(); return value; };
|
|
51
|
+
const normalize = message => normalizeSlackHistoryText(message, { ...identity, conversationId: route.conversationId });
|
|
52
|
+
const decorate = async events => {
|
|
53
|
+
const names = new Map();
|
|
54
|
+
return Promise.all(events.map(async event => {
|
|
55
|
+
if (!names.has(event.actor.id)) names.set(event.actor.id, (async () => {
|
|
56
|
+
try {
|
|
57
|
+
const user = await checked(() => api.userInfo({ userId: event.actor.id, signal }));
|
|
58
|
+
const name = user?.id === event.actor.id && (user.real_name || user.profile?.display_name || user.name);
|
|
59
|
+
return typeof name === 'string' && name ? name.slice(0, 512) : undefined;
|
|
60
|
+
} catch { check(); return undefined; }
|
|
61
|
+
})());
|
|
62
|
+
const name = await names.get(event.actor.id);
|
|
63
|
+
return name ? { ...event, actor: { ...event.actor, name } } : event;
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
const output = async (events, omitted, more, window) => ({ version: 1, scope: query.scope,
|
|
67
|
+
events: await decorate(events), omitted, hasMore: more,
|
|
68
|
+
...(more ? { nextCursor: encode(binding, state) } : {}), ...(window ? { window } : {}), coverage });
|
|
69
|
+
const page = async (options, direction, bounds = {}) => {
|
|
70
|
+
const raw = await checked(() => query.scope === 'thread'
|
|
71
|
+
? api.threadPage({ channelId: route.conversationId, threadTs: route.threadId, ...options, limit: Math.max(1, query.limit - 1), signal })
|
|
72
|
+
: api.historyPage({ channelId: route.conversationId, ...options, limit: query.limit, signal }));
|
|
73
|
+
if (!Array.isArray(raw?.messages)) throw slackRefusal('history-unavailable');
|
|
74
|
+
let messages = raw.messages;
|
|
75
|
+
const pinned = query.scope === 'thread' && messages[0]?.ts === route.threadId;
|
|
76
|
+
// Slack may add the root outside the requested reply count, including on continuation pages.
|
|
77
|
+
const nativeBound = query.scope === 'thread' ? Math.max(1, query.limit - 1) : query.limit;
|
|
78
|
+
if (messages.length > nativeBound + (pinned ? 1 : 0)) throw slackRefusal('history-unavailable');
|
|
79
|
+
if (pinned && state.rootSeen) messages = messages.slice(1);
|
|
80
|
+
if (pinned) state.rootSeen = true;
|
|
81
|
+
const cursor = raw.response_metadata?.next_cursor?.trim() || undefined;
|
|
82
|
+
if ((cursor && (typeof cursor !== 'string' || cursor.length > 1800 || cursor === state.page))
|
|
83
|
+
|| (raw.has_more === true && !cursor) || (cursor && raw.messages.length === 0))
|
|
84
|
+
throw slackRefusal('history-unavailable');
|
|
85
|
+
let last = query.scope === 'thread' ? undefined : state.last;
|
|
86
|
+
for (const message of messages) {
|
|
87
|
+
if (!slackTimestamp(message?.ts) || (last && compare(message.ts, last) !== direction)
|
|
88
|
+
|| (bounds.lower && (compare(message.ts, bounds.lower) < 0
|
|
89
|
+
|| (!bounds.inclusive && message.ts === bounds.lower)))
|
|
90
|
+
|| (bounds.upper && (compare(message.ts, bounds.upper) > 0
|
|
91
|
+
|| (!bounds.inclusive && message.ts === bounds.upper))))
|
|
92
|
+
throw slackRefusal('history-unavailable');
|
|
93
|
+
last = message.ts;
|
|
94
|
+
if (query.scope === 'thread' && (message.thread_ts ?? message.ts) !== route.threadId)
|
|
95
|
+
throw slackRefusal('stale-route');
|
|
96
|
+
}
|
|
97
|
+
if (query.scope === 'thread') {
|
|
98
|
+
const children = messages.filter(message => message.ts !== route.threadId);
|
|
99
|
+
if (children.length) {
|
|
100
|
+
const low = children[0].ts;
|
|
101
|
+
const high = children.at(-1).ts;
|
|
102
|
+
if (state.threadLow) {
|
|
103
|
+
const direction = compare(high, state.threadLow) < 0 ? 'older'
|
|
104
|
+
: compare(low, state.threadHigh) > 0 ? 'newer' : undefined;
|
|
105
|
+
if (!direction || (state.threadDirection && direction !== state.threadDirection))
|
|
106
|
+
throw slackRefusal('history-unavailable');
|
|
107
|
+
state.threadDirection = direction;
|
|
108
|
+
if (direction === 'older') state.threadLow = low;
|
|
109
|
+
else state.threadHigh = high;
|
|
110
|
+
} else { state.threadLow = low; state.threadHigh = high; }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
state.page = cursor;
|
|
114
|
+
state.last = last;
|
|
115
|
+
if (messages.length > query.limit) {
|
|
116
|
+
// Only limit=1 can leave one extra root-page item. Re-read its exact native ID next call.
|
|
117
|
+
state.pending = messages.at(-1).ts;
|
|
118
|
+
messages = messages.slice(0, query.limit);
|
|
119
|
+
}
|
|
120
|
+
return { messages, more: Boolean(cursor) || Boolean(state.pending) };
|
|
121
|
+
};
|
|
122
|
+
try {
|
|
123
|
+
check();
|
|
124
|
+
if (query.scope !== 'nearby') {
|
|
125
|
+
if (state.pending) {
|
|
126
|
+
const pending = state.pending;
|
|
127
|
+
const raw = await checked(() => api.threadMessage({ channelId: route.conversationId,
|
|
128
|
+
threadTs: route.threadId, messageTs: pending, signal }));
|
|
129
|
+
if (raw && (raw.ts !== pending || (raw.thread_ts ?? raw.ts) !== route.threadId))
|
|
130
|
+
throw slackRefusal('stale-route');
|
|
131
|
+
const event = raw ? normalize(raw) : null;
|
|
132
|
+
delete state.pending;
|
|
133
|
+
return await output(event ? [event] : [], event ? 0 : 1, Boolean(state.page));
|
|
134
|
+
}
|
|
135
|
+
const result = await page({ cursor: state.page, latest: state.snapshot }, query.scope === 'thread' ? 1 : -1,
|
|
136
|
+
{ upper: state.snapshot });
|
|
137
|
+
const events = result.messages.map(normalize).filter(Boolean);
|
|
138
|
+
return await output(events, result.messages.length - events.length, result.more);
|
|
139
|
+
}
|
|
140
|
+
const center = micros(route.messageId);
|
|
141
|
+
const start = timestamp(center - 300_000_000n);
|
|
142
|
+
const end = timestamp(center + 300_000_000n);
|
|
143
|
+
const ceiling = compare(end, state.snapshot) < 0 ? end : state.snapshot;
|
|
144
|
+
const window = { start: Number(micros(start) / 1_000_000n), end: Number(micros(end) / 1_000_000n) + 1 };
|
|
145
|
+
const transition = phase => { state.phase = phase; delete state.page; delete state.last; };
|
|
146
|
+
const needsAfter = () => state.after < minAfter && compare(end, state.snapshot) < 0;
|
|
147
|
+
if (state.phase === 'emit') {
|
|
148
|
+
const selected = state.candidates.splice(0, query.limit);
|
|
149
|
+
const events = [];
|
|
150
|
+
for (const ts of selected) {
|
|
151
|
+
const raw = await checked(() => api.getMessage({ channelId: route.conversationId, messageTs: ts, signal }));
|
|
152
|
+
const event = raw?.ts === ts ? normalize(raw) : null;
|
|
153
|
+
if (event) events.push(event);
|
|
154
|
+
}
|
|
155
|
+
return await output(events, selected.length - events.length, state.candidates.length > 0, window);
|
|
156
|
+
}
|
|
157
|
+
const options = state.phase === 'window'
|
|
158
|
+
? { oldest: start, latest: ceiling, inclusive: true }
|
|
159
|
+
: state.phase === 'before' ? { latest: start, inclusive: false }
|
|
160
|
+
: { oldest: end, latest: state.snapshot, inclusive: false };
|
|
161
|
+
const result = await page({ ...options, cursor: state.page }, -1, {
|
|
162
|
+
lower: options.oldest, upper: options.latest, inclusive: options.inclusive,
|
|
163
|
+
});
|
|
164
|
+
const normalized = result.messages.map(normalize);
|
|
165
|
+
const events = [];
|
|
166
|
+
let omitted = normalized.filter(event => !event).length;
|
|
167
|
+
for (const event of normalized.filter(Boolean)) {
|
|
168
|
+
if (state.phase === 'window') {
|
|
169
|
+
if (compare(event.messageId, route.messageId) < 0) state.before = Math.min(20, state.before + 1);
|
|
170
|
+
if (compare(event.messageId, route.messageId) > 0) state.after = Math.min(20, state.after + 1);
|
|
171
|
+
events.push(event);
|
|
172
|
+
} else if (state.phase === 'before') {
|
|
173
|
+
if (state.before < minBefore) { state.before++; events.push(event); } else omitted++;
|
|
174
|
+
} else {
|
|
175
|
+
// History is newest-first: retain only closest IDs while scanning towards the window.
|
|
176
|
+
state.candidates.push(event.messageId);
|
|
177
|
+
state.candidates.sort(compare);
|
|
178
|
+
state.candidates = state.candidates.slice(0, minAfter - state.after);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
let more = result.more;
|
|
182
|
+
if (state.phase === 'window' && !result.more) {
|
|
183
|
+
if (state.before < minBefore) { transition('before'); more = true; }
|
|
184
|
+
else if (needsAfter()) { transition('after'); more = true; }
|
|
185
|
+
} else if (state.phase === 'before' && (state.before >= minBefore || !result.more)) {
|
|
186
|
+
more = needsAfter();
|
|
187
|
+
if (more) transition('after');
|
|
188
|
+
} else if (state.phase === 'after' && !result.more) {
|
|
189
|
+
more = state.candidates.length > 0;
|
|
190
|
+
if (more) transition('emit');
|
|
191
|
+
}
|
|
192
|
+
return await output(events, omitted, more, window);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
check();
|
|
195
|
+
if (error?.code === 'invalid-history-query' || error?.code === 'stale-route'
|
|
196
|
+
|| error?.code === 'history-unavailable') throw error;
|
|
197
|
+
if (['missing_scope', 'not_in_channel', 'channel_not_found', 'is_archived', 'no_permission'].includes(error?.providerCode))
|
|
198
|
+
throw slackRefusal('history-permission-denied');
|
|
199
|
+
if (error?.providerCode === 'thread_not_found') throw slackRefusal('thread-unavailable');
|
|
200
|
+
throw slackRefusal('history-unavailable');
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const SLACK_APP_MANIFEST_YAML = `_metadata:
|
|
2
|
+
major_version: 1
|
|
3
|
+
display_information:
|
|
4
|
+
name: DeepSeek Harness
|
|
5
|
+
description: Connect Slack conversations to a local DeepSeek Harness agent.
|
|
6
|
+
background_color: "#4A154B"
|
|
7
|
+
features:
|
|
8
|
+
app_home:
|
|
9
|
+
home_tab_enabled: false
|
|
10
|
+
messages_tab_enabled: true
|
|
11
|
+
messages_tab_read_only_enabled: false
|
|
12
|
+
bot_user:
|
|
13
|
+
display_name: DeepSeek Harness
|
|
14
|
+
always_online: false
|
|
15
|
+
oauth_config:
|
|
16
|
+
scopes:
|
|
17
|
+
bot:
|
|
18
|
+
- app_mentions:read
|
|
19
|
+
- chat:write
|
|
20
|
+
- channels:history
|
|
21
|
+
- files:read
|
|
22
|
+
- files:write
|
|
23
|
+
- groups:history
|
|
24
|
+
- im:history
|
|
25
|
+
- mpim:history
|
|
26
|
+
- reactions:write
|
|
27
|
+
settings:
|
|
28
|
+
event_subscriptions:
|
|
29
|
+
bot_events:
|
|
30
|
+
- app_mention
|
|
31
|
+
- message.im
|
|
32
|
+
org_deploy_enabled: false
|
|
33
|
+
socket_mode_enabled: true
|
|
34
|
+
token_rotation_enabled: false
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export const SLACK_CREATE_APP_URL = 'https://api.slack.com/apps?new_app=1';
|