@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.
- 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 +604 -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 +18 -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 +319 -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 +239 -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 +258 -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 +411 -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 +618 -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 +229 -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 +28 -0
- package/src/channels/discord/discord-api.mjs +423 -0
- package/src/channels/discord/discord-bridge.mjs +16 -0
- package/src/channels/discord/discord-controller.mjs +29 -0
- package/src/channels/discord/discord-runtime.mjs +1091 -0
- package/src/channels/discord/external-consumer.mjs +199 -0
- package/src/channels/discord/external-files.mjs +97 -0
- package/src/channels/discord/harness-client.mjs +11 -0
- package/src/channels/discord/history-reader.mjs +142 -0
- package/src/channels/discord/nearby-history.mjs +112 -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-cards.mjs +87 -0
- package/src/channels/feishu/external-consumer.mjs +89 -0
- package/src/channels/feishu/external-files.mjs +115 -0
- package/src/channels/feishu/external-images.mjs +50 -0
- package/src/channels/feishu/external-names.mjs +99 -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 +982 -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 +1619 -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 +91 -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 +529 -0
- package/src/channels/shared/token-config-store.mjs +208 -0
- package/src/channels/shared/video-media.mjs +9 -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 +93 -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 +644 -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 +895 -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 +194 -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/external-consumer.mjs +160 -0
- package/src/channels/weixin/external-files.mjs +84 -0
- package/src/channels/weixin/external-typing.mjs +120 -0
- package/src/channels/weixin/harness-client.mjs +19 -0
- package/src/channels/weixin/state-store.mjs +316 -0
- package/src/channels/weixin/weixin-api.mjs +1009 -0
- package/src/channels/weixin/weixin-bridge.mjs +1537 -0
- package/src/channels/weixin/weixin-controller.mjs +779 -0
- package/src/channels/weixin/weixin-runtime.mjs +507 -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,624 @@
|
|
|
1
|
+
import { callManagementRpc } from '../management-rpc.mjs';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import manifest from '../../package.json' with { type: 'json' };
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
DingtalkLogoGlyph,
|
|
7
|
+
DiscordLogoGlyph,
|
|
8
|
+
FeishuLogoGlyph,
|
|
9
|
+
OfficeLogoGlyph,
|
|
10
|
+
QqLogoGlyph,
|
|
11
|
+
SlackLogoGlyph,
|
|
12
|
+
TelegramLogoGlyph,
|
|
13
|
+
WecomLogoGlyph,
|
|
14
|
+
WeixinLogoGlyph,
|
|
15
|
+
WhatsappLogoGlyph,
|
|
16
|
+
IMessageLogoGlyph,
|
|
17
|
+
EmailLogoGlyph,
|
|
18
|
+
MatrixLogoGlyph,
|
|
19
|
+
} from './channel-logos.js';
|
|
20
|
+
import { DINGTALK_RPC_CHANNEL } from './channels/dingtalk/api.js';
|
|
21
|
+
import { DingtalkSettingsTab } from './channels/dingtalk/index.js';
|
|
22
|
+
import { DISCORD_RPC_CHANNEL } from './channels/discord/api.js';
|
|
23
|
+
import { DiscordSettingsTab } from './channels/discord/index.js';
|
|
24
|
+
import { installDiscordStyles } from './channels/discord/styles.js';
|
|
25
|
+
import { FeishuSettingsTab } from './channels/feishu/index.js';
|
|
26
|
+
import { FEISHU_RPC_CHANNEL } from './channels/feishu/api.js';
|
|
27
|
+
import { installFeishuStyles } from './channels/feishu/styles.js';
|
|
28
|
+
import { QQ_RPC_CHANNEL } from './channels/qq/api.js';
|
|
29
|
+
import { QqSettingsTab } from './channels/qq/index.js';
|
|
30
|
+
import { installQqStyles } from './channels/qq/styles.js';
|
|
31
|
+
import { OFFICE_RPC_CHANNEL } from './channels/office/api.js';
|
|
32
|
+
import { OfficeSettingsTab } from './channels/office/index.js';
|
|
33
|
+
import { installOfficeStyles } from './channels/office/styles.js';
|
|
34
|
+
import { SLACK_RPC_CHANNEL } from './channels/slack/api.js';
|
|
35
|
+
import { SlackSettingsTab } from './channels/slack/index.js';
|
|
36
|
+
import { installSlackStyles } from './channels/slack/styles.js';
|
|
37
|
+
import { TELEGRAM_RPC_CHANNEL } from './channels/telegram/api.js';
|
|
38
|
+
import { TelegramSettingsTab } from './channels/telegram/index.js';
|
|
39
|
+
import { installTelegramStyles } from './channels/telegram/styles.js';
|
|
40
|
+
import { WECOM_RPC_CHANNEL } from './channels/wecom/api.js';
|
|
41
|
+
import { WecomSettingsTab } from './channels/wecom/index.js';
|
|
42
|
+
import { installWecomStyles } from './channels/wecom/styles.js';
|
|
43
|
+
import { WECOM_APP_RPC_CHANNEL } from './channels/wecom-app/api.js';
|
|
44
|
+
import { WecomAppSettingsTab } from './channels/wecom-app/index.js';
|
|
45
|
+
import { installWecomAppStyles } from './channels/wecom-app/styles.js';
|
|
46
|
+
import { WeixinSettingsTab } from './channels/weixin/index.js';
|
|
47
|
+
import { WEIXIN_RPC_CHANNEL } from './channels/weixin/api.js';
|
|
48
|
+
import { installWeixinStyles } from './channels/weixin/styles.js';
|
|
49
|
+
import { WHATSAPP_RPC_CHANNEL } from './channels/whatsapp/api.js';
|
|
50
|
+
import { WhatsappSettingsTab } from './channels/whatsapp/index.js';
|
|
51
|
+
import { installWhatsappStyles } from './channels/whatsapp/styles.js';
|
|
52
|
+
import { IMESSAGE_RPC_CHANNEL } from './channels/imessage/api.js';
|
|
53
|
+
import { EMAIL_RPC_CHANNEL } from './channels/email/api.js';
|
|
54
|
+
import { IMessageSettingsTab } from './channels/imessage/index.js';
|
|
55
|
+
import { EmailSettingsTab, useEmailChannelEnabled } from './channels/email/index.js';
|
|
56
|
+
import { installIMessageStyles } from './channels/imessage/styles.js';
|
|
57
|
+
import { installEmailStyles } from './channels/email/styles.js';
|
|
58
|
+
import { MATRIX_RPC_CHANNEL } from './channels/matrix/api.js';
|
|
59
|
+
import { MatrixSettingsTab } from './channels/matrix/index.js';
|
|
60
|
+
import { installMatrixStyles } from './channels/matrix/styles.js';
|
|
61
|
+
import { en, h, IM_LOCALE_NAMESPACE, setImTranslator, zh } from './i18n.js';
|
|
62
|
+
import {
|
|
63
|
+
HOST_LANGUAGE_RPC_CHANNEL,
|
|
64
|
+
installInterfaceLanguageMirror,
|
|
65
|
+
} from './interface-language.js';
|
|
66
|
+
import { BotSettingsContext } from './channel-card-meta.js';
|
|
67
|
+
import {
|
|
68
|
+
DELIVERY_RPC_CHANNEL,
|
|
69
|
+
DeliveryTargetSettingsPage,
|
|
70
|
+
} from './delivery-settings.js';
|
|
71
|
+
import {
|
|
72
|
+
GLOBAL_SETTINGS_RPC_CHANNEL,
|
|
73
|
+
GLOBAL_SETTINGS_TAB_ID,
|
|
74
|
+
GlobalSettingsLogoGlyph,
|
|
75
|
+
GlobalSettingsPanel,
|
|
76
|
+
} from './global-settings.js';
|
|
77
|
+
import {
|
|
78
|
+
createLoopbackAwareRpcCalls,
|
|
79
|
+
replacePageLocation,
|
|
80
|
+
} from './loopback-recovery.js';
|
|
81
|
+
import { installImStyles } from './styles.js';
|
|
82
|
+
import { installSessionChannelLogos } from './session-channel-logos.js';
|
|
83
|
+
import { UpdatePanel, UPDATE_RPC_CHANNEL } from './update-panel.js';
|
|
84
|
+
import { WorkspaceDirectoryPickerContext } from './workspace-editor.js';
|
|
85
|
+
import { IMPanelErrorBoundary } from './panel-error-boundary.js';
|
|
86
|
+
import { installImPluginPage } from './plugin-page.js';
|
|
87
|
+
|
|
88
|
+
export const name = 'im-settings';
|
|
89
|
+
export const inject = ['slots', 'connection', 'locale', 'workspaces'];
|
|
90
|
+
export const IM_PLUGIN_VERSION = manifest.version;
|
|
91
|
+
|
|
92
|
+
function callWorkspaceDirectoryApi(ctx, method, ...args) {
|
|
93
|
+
// Current DSH owns directory operations on uiWorkspace; legacy Hosts keep them on workspaces.
|
|
94
|
+
const uiWorkspace = typeof ctx.get === 'function' ? ctx.get('uiWorkspace') : undefined;
|
|
95
|
+
const service = typeof uiWorkspace?.[method] === 'function' ? uiWorkspace : ctx.workspaces;
|
|
96
|
+
if (typeof service?.[method] !== 'function') {
|
|
97
|
+
throw new Error('无法读取目录,请重试。');
|
|
98
|
+
}
|
|
99
|
+
return service[method](...args);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const CHANNELS = Object.freeze([
|
|
103
|
+
{ id: 'weixin', label: '微信' },
|
|
104
|
+
{ id: 'feishu', label: '飞书' },
|
|
105
|
+
{ id: 'dingtalk', label: '钉钉' },
|
|
106
|
+
{ id: 'wecom', label: '企业微信' },
|
|
107
|
+
{ id: 'qq', label: 'QQ' },
|
|
108
|
+
{ id: 'slack', label: 'Slack' },
|
|
109
|
+
{ id: 'telegram', label: 'Telegram' },
|
|
110
|
+
{ id: 'discord', label: 'Discord' },
|
|
111
|
+
{ id: 'whatsapp', label: 'WhatsApp' },
|
|
112
|
+
{ id: 'wecomApp', label: '企业微信应用', note: '(实验功能)' },
|
|
113
|
+
{ id: 'imessage', label: 'iMessage', note: '(实验功能)' },
|
|
114
|
+
{ id: 'email', label: '邮箱', note: '(实验功能)' },
|
|
115
|
+
{ id: 'matrix', label: 'Matrix', note: '(实验功能)' },
|
|
116
|
+
{ id: 'office', label: 'AI Office', note: '(实验功能)' },
|
|
117
|
+
]);
|
|
118
|
+
|
|
119
|
+
function WeixinLogo() {
|
|
120
|
+
return h('span', { className: 'dim-logo dim-logoWeixin', 'aria-hidden': 'true' },
|
|
121
|
+
h(WeixinLogoGlyph));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function FeishuLogo() {
|
|
125
|
+
return h('span', { className: 'dim-logo dim-logoFeishu', 'aria-hidden': 'true' },
|
|
126
|
+
h(FeishuLogoGlyph));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function DingtalkLogo() {
|
|
130
|
+
return h('span', { className: 'dim-logo dim-logoDingtalk', 'aria-hidden': 'true' },
|
|
131
|
+
h(DingtalkLogoGlyph));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function QqLogo() {
|
|
135
|
+
return h('span', { className: 'dim-logo dim-logoQq', 'aria-hidden': 'true' }, h(QqLogoGlyph));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function WecomLogo() {
|
|
139
|
+
return h('span', { className: 'dim-logo dim-logoWecom', 'aria-hidden': 'true' }, h(WecomLogoGlyph));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function WecomAppLogo() {
|
|
143
|
+
return h('span', { className: 'dim-logo dim-logoWecomApp', 'aria-hidden': 'true' }, h(WecomLogoGlyph));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function TelegramLogo() {
|
|
147
|
+
return h('span', { className: 'dim-logo dim-logoTelegram', 'aria-hidden': 'true' },
|
|
148
|
+
h(TelegramLogoGlyph));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function SlackLogo() {
|
|
152
|
+
return h('span', { className: 'dim-logo dim-logoSlack', 'aria-hidden': 'true' },
|
|
153
|
+
h(SlackLogoGlyph));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function DiscordLogo() {
|
|
157
|
+
return h('span', { className: 'dim-logo dim-logoDiscord', 'aria-hidden': 'true' },
|
|
158
|
+
h(DiscordLogoGlyph));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function WhatsappLogo() {
|
|
162
|
+
return h('span', { className: 'dim-logo dim-logoWhatsapp', 'aria-hidden': 'true' },
|
|
163
|
+
h(WhatsappLogoGlyph));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function IMessageLogo() {
|
|
167
|
+
return h('span', { className: 'dim-logo dim-logoIMessage', 'aria-hidden': 'true' },
|
|
168
|
+
h(IMessageLogoGlyph));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function EmailLogo() {
|
|
172
|
+
return h('span', { className: 'dim-logo dim-logoEmail', 'aria-hidden': 'true' },
|
|
173
|
+
h(EmailLogoGlyph));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function MatrixLogo() {
|
|
177
|
+
return h('span', { className: 'dim-logo dim-logoMatrix', 'aria-hidden': 'true' },
|
|
178
|
+
h(MatrixLogoGlyph));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function OfficeLogo() {
|
|
182
|
+
return h('span', { className: 'dim-logo dim-logoOffice', 'aria-hidden': 'true' },
|
|
183
|
+
h(OfficeLogoGlyph));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function ChannelLogo({ channel }) {
|
|
187
|
+
if (channel === 'weixin') return h(WeixinLogo);
|
|
188
|
+
if (channel === 'feishu') return h(FeishuLogo);
|
|
189
|
+
if (channel === 'dingtalk') return h(DingtalkLogo);
|
|
190
|
+
if (channel === 'wecom') return h(WecomLogo);
|
|
191
|
+
if (channel === 'wecomApp') return h(WecomAppLogo);
|
|
192
|
+
if (channel === 'qq') return h(QqLogo);
|
|
193
|
+
if (channel === 'slack') return h(SlackLogo);
|
|
194
|
+
if (channel === 'telegram') return h(TelegramLogo);
|
|
195
|
+
if (channel === 'discord') return h(DiscordLogo);
|
|
196
|
+
if (channel === 'whatsapp') return h(WhatsappLogo);
|
|
197
|
+
if (channel === 'imessage') return h(IMessageLogo);
|
|
198
|
+
if (channel === 'email') return h(EmailLogo);
|
|
199
|
+
if (channel === 'matrix') return h(MatrixLogo);
|
|
200
|
+
return h(OfficeLogo);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function LoopbackRecoveryNotice({ recovery, onNavigate = replacePageLocation }) {
|
|
204
|
+
return h('div', {
|
|
205
|
+
className: 'dim-loopbackRecovery',
|
|
206
|
+
role: 'alert',
|
|
207
|
+
},
|
|
208
|
+
h('div', { className: 'dim-loopbackRecoveryCopy' },
|
|
209
|
+
h('strong', null, '请改用 localhost 重新打开'),
|
|
210
|
+
h('p', null, '页面会在当前端口重新打开,机器人配置不会改变。'),
|
|
211
|
+
h('code', null, recovery.origin)),
|
|
212
|
+
h('button', {
|
|
213
|
+
type: 'button',
|
|
214
|
+
className: 'dim-loopbackRecoveryAction',
|
|
215
|
+
onClick: () => onNavigate(recovery.url),
|
|
216
|
+
}, '使用 localhost 重新打开'));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function IMSettingsTab({
|
|
220
|
+
dingtalkRpcCall,
|
|
221
|
+
discordRpcCall,
|
|
222
|
+
feishuRpcCall,
|
|
223
|
+
imessageRpcCall,
|
|
224
|
+
emailRpcCall,
|
|
225
|
+
matrixRpcCall,
|
|
226
|
+
qqRpcCall,
|
|
227
|
+
slackRpcCall,
|
|
228
|
+
telegramRpcCall,
|
|
229
|
+
wecomRpcCall,
|
|
230
|
+
wecomAppRpcCall,
|
|
231
|
+
weixinRpcCall,
|
|
232
|
+
whatsappRpcCall,
|
|
233
|
+
officeRpcCall,
|
|
234
|
+
updateRpcCall,
|
|
235
|
+
deliveryRpcCall,
|
|
236
|
+
globalSettingsRpcCall,
|
|
237
|
+
workspaceDirectoryPicker,
|
|
238
|
+
preferredSectionId,
|
|
239
|
+
browserLocation = globalThis.location,
|
|
240
|
+
navigateToRecoveryUrl = replacePageLocation,
|
|
241
|
+
}) {
|
|
242
|
+
const [selected, setSelected] = React.useState(() => (
|
|
243
|
+
preferredSectionId === GLOBAL_SETTINGS_TAB_ID
|
|
244
|
+
|| CHANNELS.some((channel) => channel.id === preferredSectionId)
|
|
245
|
+
? preferredSectionId : 'weixin'
|
|
246
|
+
));
|
|
247
|
+
const [loopbackRecovery, setLoopbackRecovery] = React.useState(null);
|
|
248
|
+
const [runningVersion, setRunningVersion] = React.useState(IM_PLUGIN_VERSION);
|
|
249
|
+
const [deliverySettings, setDeliverySettings] = React.useState(null);
|
|
250
|
+
// The Host owns email availability and reports it over RPC. The
|
|
251
|
+
// mailbox entry point is omitted entirely while it is closed, and the visible
|
|
252
|
+
// channel list is what every later lookup (active tab, rail) reads from.
|
|
253
|
+
const emailEnabled = useEmailChannelEnabled(emailRpcCall);
|
|
254
|
+
const visibleChannels = React.useMemo(
|
|
255
|
+
() => CHANNELS.filter((channel) => channel.id !== 'email' || emailEnabled),
|
|
256
|
+
[emailEnabled],
|
|
257
|
+
);
|
|
258
|
+
const githubTooltipId = React.useId();
|
|
259
|
+
const generalSettingsTooltipId = React.useId();
|
|
260
|
+
const globalSettingsSelected = selected === GLOBAL_SETTINGS_TAB_ID;
|
|
261
|
+
const active = visibleChannels.find((channel) => channel.id === selected) ?? visibleChannels[0];
|
|
262
|
+
const activeTabId = globalSettingsSelected
|
|
263
|
+
? 'dim-general-settings-trigger'
|
|
264
|
+
: `dim-tab-${active.id}`;
|
|
265
|
+
const activePanelId = globalSettingsSelected
|
|
266
|
+
? `dim-panel-${GLOBAL_SETTINGS_TAB_ID}`
|
|
267
|
+
: `dim-panel-${active.id}`;
|
|
268
|
+
const reportLoopbackRecovery = React.useCallback((recovery) => {
|
|
269
|
+
setLoopbackRecovery((current) => current?.url === recovery.url ? current : recovery);
|
|
270
|
+
}, []);
|
|
271
|
+
const reportUpdateStatus = React.useCallback((snapshot) => {
|
|
272
|
+
setRunningVersion(snapshot.runningVersion);
|
|
273
|
+
}, []);
|
|
274
|
+
const rpcCalls = React.useMemo(() => createLoopbackAwareRpcCalls({
|
|
275
|
+
dingtalkRpcCall,
|
|
276
|
+
discordRpcCall,
|
|
277
|
+
feishuRpcCall,
|
|
278
|
+
qqRpcCall,
|
|
279
|
+
slackRpcCall,
|
|
280
|
+
telegramRpcCall,
|
|
281
|
+
wecomRpcCall,
|
|
282
|
+
wecomAppRpcCall,
|
|
283
|
+
weixinRpcCall,
|
|
284
|
+
whatsappRpcCall,
|
|
285
|
+
officeRpcCall,
|
|
286
|
+
updateRpcCall,
|
|
287
|
+
deliveryRpcCall,
|
|
288
|
+
globalSettingsRpcCall,
|
|
289
|
+
imessageRpcCall,
|
|
290
|
+
emailRpcCall,
|
|
291
|
+
matrixRpcCall,
|
|
292
|
+
}, {
|
|
293
|
+
location: browserLocation,
|
|
294
|
+
onRecovery: reportLoopbackRecovery,
|
|
295
|
+
}), [
|
|
296
|
+
browserLocation,
|
|
297
|
+
dingtalkRpcCall,
|
|
298
|
+
discordRpcCall,
|
|
299
|
+
deliveryRpcCall,
|
|
300
|
+
feishuRpcCall,
|
|
301
|
+
globalSettingsRpcCall,
|
|
302
|
+
imessageRpcCall,
|
|
303
|
+
emailRpcCall,
|
|
304
|
+
matrixRpcCall,
|
|
305
|
+
officeRpcCall,
|
|
306
|
+
qqRpcCall,
|
|
307
|
+
reportLoopbackRecovery,
|
|
308
|
+
slackRpcCall,
|
|
309
|
+
telegramRpcCall,
|
|
310
|
+
updateRpcCall,
|
|
311
|
+
wecomRpcCall,
|
|
312
|
+
wecomAppRpcCall,
|
|
313
|
+
weixinRpcCall,
|
|
314
|
+
whatsappRpcCall,
|
|
315
|
+
]);
|
|
316
|
+
const botSettingsContext = React.useMemo(() => Object.freeze({
|
|
317
|
+
openBotSettings: setDeliverySettings,
|
|
318
|
+
}), []);
|
|
319
|
+
return h(WorkspaceDirectoryPickerContext.Provider, { value: workspaceDirectoryPicker },
|
|
320
|
+
h('section', { className: 'dim-page', 'aria-label': 'IM机器人设置' },
|
|
321
|
+
h('header', { className: 'dim-title' },
|
|
322
|
+
h('div', { className: 'dim-brand' },
|
|
323
|
+
h('div', { className: 'dim-brandHeading' },
|
|
324
|
+
h('strong', { className: 'dim-brandName' }, 'DSH-IM'),
|
|
325
|
+
h('span', { className: 'dim-brandVersion' }, `v${runningVersion}`)),
|
|
326
|
+
h('p', null, '让 DeepSeek Harness 触手可及')),
|
|
327
|
+
h('div', { className: 'dim-titleActions' },
|
|
328
|
+
h(UpdatePanel, {
|
|
329
|
+
rpcCall: rpcCalls.updateRpcCall,
|
|
330
|
+
clientVersion: IM_PLUGIN_VERSION,
|
|
331
|
+
onStatus: reportUpdateStatus,
|
|
332
|
+
}),
|
|
333
|
+
h('span', { className: 'dim-githubAction' },
|
|
334
|
+
h('a', {
|
|
335
|
+
className: 'dim-githubLink',
|
|
336
|
+
href: 'https://github.com/xmanrui/dsh-im',
|
|
337
|
+
target: '_blank',
|
|
338
|
+
rel: 'noopener noreferrer',
|
|
339
|
+
'aria-label': 'dsh-im GitHub',
|
|
340
|
+
'aria-describedby': githubTooltipId,
|
|
341
|
+
},
|
|
342
|
+
h('svg', {
|
|
343
|
+
width: 18,
|
|
344
|
+
height: 18,
|
|
345
|
+
viewBox: '0 0 16 16',
|
|
346
|
+
fill: 'currentColor',
|
|
347
|
+
focusable: 'false',
|
|
348
|
+
'aria-hidden': 'true',
|
|
349
|
+
}, h('path', {
|
|
350
|
+
d: 'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.65 7.65 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z',
|
|
351
|
+
}))),
|
|
352
|
+
h('span', {
|
|
353
|
+
id: githubTooltipId,
|
|
354
|
+
className: 'dim-githubTooltip',
|
|
355
|
+
role: 'tooltip',
|
|
356
|
+
}, '帮助与反馈 · 前往 GitHub')),
|
|
357
|
+
h('span', { className: 'dim-generalSettingsAction' },
|
|
358
|
+
h('button', {
|
|
359
|
+
type: 'button',
|
|
360
|
+
id: 'dim-general-settings-trigger',
|
|
361
|
+
className: 'dim-generalSettingsButton',
|
|
362
|
+
'aria-label': '通用设置',
|
|
363
|
+
'aria-describedby': generalSettingsTooltipId,
|
|
364
|
+
'aria-controls': `dim-panel-${GLOBAL_SETTINGS_TAB_ID}`,
|
|
365
|
+
'aria-current': globalSettingsSelected ? 'page' : undefined,
|
|
366
|
+
onClick: () => {
|
|
367
|
+
setSelected(GLOBAL_SETTINGS_TAB_ID);
|
|
368
|
+
setDeliverySettings(null);
|
|
369
|
+
},
|
|
370
|
+
}, h(GlobalSettingsLogoGlyph, { size: 17 })),
|
|
371
|
+
h('span', {
|
|
372
|
+
id: generalSettingsTooltipId,
|
|
373
|
+
className: 'dim-generalSettingsTooltip',
|
|
374
|
+
role: 'tooltip',
|
|
375
|
+
}, '通用设置'))),
|
|
376
|
+
),
|
|
377
|
+
h('div', { className: 'dim-layout' },
|
|
378
|
+
h('nav', { className: 'dim-rail', role: 'tablist', 'aria-label': 'IM 设置导航' },
|
|
379
|
+
visibleChannels.map((channel) => h('button', {
|
|
380
|
+
key: channel.id,
|
|
381
|
+
type: 'button',
|
|
382
|
+
role: 'tab',
|
|
383
|
+
id: `dim-tab-${channel.id}`,
|
|
384
|
+
className: 'dim-channel',
|
|
385
|
+
'aria-selected': !globalSettingsSelected && channel.id === active.id,
|
|
386
|
+
'aria-controls': `dim-panel-${channel.id}`,
|
|
387
|
+
onClick: () => {
|
|
388
|
+
setSelected(channel.id);
|
|
389
|
+
setDeliverySettings(null);
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
h(ChannelLogo, { channel: channel.id }),
|
|
393
|
+
h('span', { className: 'dim-channelCopy' },
|
|
394
|
+
h('strong', null, channel.label),
|
|
395
|
+
channel.note ? h('small', { className: 'dim-channelNote' }, channel.note) : null,
|
|
396
|
+
)))),
|
|
397
|
+
h('div', { className: 'dim-divider', 'aria-hidden': 'true' }),
|
|
398
|
+
h('main', {
|
|
399
|
+
className: 'dim-panel',
|
|
400
|
+
role: 'tabpanel',
|
|
401
|
+
id: activePanelId,
|
|
402
|
+
'aria-labelledby': activeTabId,
|
|
403
|
+
},
|
|
404
|
+
loopbackRecovery
|
|
405
|
+
? h(LoopbackRecoveryNotice, {
|
|
406
|
+
recovery: loopbackRecovery,
|
|
407
|
+
onNavigate: navigateToRecoveryUrl,
|
|
408
|
+
})
|
|
409
|
+
: null,
|
|
410
|
+
h(BotSettingsContext.Provider, { value: botSettingsContext },
|
|
411
|
+
globalSettingsSelected
|
|
412
|
+
? h(GlobalSettingsPanel, { rpcCall: rpcCalls.globalSettingsRpcCall })
|
|
413
|
+
: deliverySettings?.channel === active.id
|
|
414
|
+
? h(DeliveryTargetSettingsPage, {
|
|
415
|
+
channel: active.id,
|
|
416
|
+
account: deliverySettings,
|
|
417
|
+
rpcCall: rpcCalls.deliveryRpcCall,
|
|
418
|
+
accessRpcCall: rpcCalls[`${active.id}RpcCall`],
|
|
419
|
+
onBack: () => setDeliverySettings(null),
|
|
420
|
+
})
|
|
421
|
+
: active.id === 'weixin'
|
|
422
|
+
? h(WeixinSettingsTab, { rpcCall: rpcCalls.weixinRpcCall })
|
|
423
|
+
: active.id === 'feishu'
|
|
424
|
+
? h(FeishuSettingsTab, { rpcCall: rpcCalls.feishuRpcCall })
|
|
425
|
+
: active.id === 'dingtalk'
|
|
426
|
+
? h(DingtalkSettingsTab, { rpcCall: rpcCalls.dingtalkRpcCall })
|
|
427
|
+
: active.id === 'wecom'
|
|
428
|
+
? h(WecomSettingsTab, { rpcCall: rpcCalls.wecomRpcCall })
|
|
429
|
+
: active.id === 'wecomApp'
|
|
430
|
+
? h(WecomAppSettingsTab, { rpcCall: rpcCalls.wecomAppRpcCall })
|
|
431
|
+
: active.id === 'qq'
|
|
432
|
+
? h(QqSettingsTab, { rpcCall: rpcCalls.qqRpcCall })
|
|
433
|
+
: active.id === 'slack'
|
|
434
|
+
? h(SlackSettingsTab, { rpcCall: rpcCalls.slackRpcCall })
|
|
435
|
+
: active.id === 'telegram'
|
|
436
|
+
? h(TelegramSettingsTab, { rpcCall: rpcCalls.telegramRpcCall })
|
|
437
|
+
: active.id === 'discord'
|
|
438
|
+
? h(DiscordSettingsTab, { rpcCall: rpcCalls.discordRpcCall })
|
|
439
|
+
: active.id === 'whatsapp'
|
|
440
|
+
? h(WhatsappSettingsTab, { rpcCall: rpcCalls.whatsappRpcCall })
|
|
441
|
+
: active.id === 'imessage'
|
|
442
|
+
? h(IMessageSettingsTab, { rpcCall: rpcCalls.imessageRpcCall })
|
|
443
|
+
: active.id === 'email'
|
|
444
|
+
? h(EmailSettingsTab, { rpcCall: rpcCalls.emailRpcCall })
|
|
445
|
+
: active.id === 'matrix'
|
|
446
|
+
? h(MatrixSettingsTab, { rpcCall: rpcCalls.matrixRpcCall })
|
|
447
|
+
: h(OfficeSettingsTab, { rpcCall: rpcCalls.officeRpcCall }))),
|
|
448
|
+
),
|
|
449
|
+
));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
export function apply(ctx) {
|
|
453
|
+
ctx.effect(
|
|
454
|
+
() => ctx.locale.register(IM_LOCALE_NAMESPACE, { zh, en }),
|
|
455
|
+
'im-settings: bilingual dictionaries',
|
|
456
|
+
);
|
|
457
|
+
const t = ctx.locale.bind(IM_LOCALE_NAMESPACE);
|
|
458
|
+
setImTranslator(t);
|
|
459
|
+
|
|
460
|
+
// The settings page is the only place that knows the locale the interface is
|
|
461
|
+
// actually rendered in: DSH stores nothing when it came from the browser's
|
|
462
|
+
// language list. Report it so bot messages follow the same language.
|
|
463
|
+
ctx.effect(
|
|
464
|
+
() => installInterfaceLanguageMirror(ctx, {
|
|
465
|
+
rpcCall: (endpoint, payload, signal) =>
|
|
466
|
+
callManagementRpc(ctx.connection, HOST_LANGUAGE_RPC_CHANNEL, endpoint, payload, signal),
|
|
467
|
+
}),
|
|
468
|
+
'im-settings: mirror the DSH interface language',
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
ctx.effect(() => installSessionChannelLogos(), 'im-settings: Session channel logos');
|
|
472
|
+
|
|
473
|
+
ctx.effect(() => {
|
|
474
|
+
const disposers = [
|
|
475
|
+
installFeishuStyles(),
|
|
476
|
+
installWeixinStyles(),
|
|
477
|
+
installWecomStyles(),
|
|
478
|
+
installWecomAppStyles(),
|
|
479
|
+
installQqStyles(),
|
|
480
|
+
installSlackStyles(),
|
|
481
|
+
installTelegramStyles(),
|
|
482
|
+
installDiscordStyles(),
|
|
483
|
+
installWhatsappStyles(),
|
|
484
|
+
installIMessageStyles(),
|
|
485
|
+
installEmailStyles(),
|
|
486
|
+
installMatrixStyles(),
|
|
487
|
+
installOfficeStyles(),
|
|
488
|
+
installImStyles(),
|
|
489
|
+
];
|
|
490
|
+
return () => {
|
|
491
|
+
for (const dispose of disposers.reverse()) dispose();
|
|
492
|
+
};
|
|
493
|
+
}, 'im-settings: install combined channel styles');
|
|
494
|
+
|
|
495
|
+
const feishuRpcCall = (endpoint, payload, signal) =>
|
|
496
|
+
callManagementRpc(ctx.connection, FEISHU_RPC_CHANNEL, endpoint, payload, signal);
|
|
497
|
+
const weixinRpcCall = (endpoint, payload, signal) =>
|
|
498
|
+
callManagementRpc(ctx.connection, WEIXIN_RPC_CHANNEL, endpoint, payload, signal);
|
|
499
|
+
const dingtalkRpcCall = (endpoint, payload, signal) =>
|
|
500
|
+
callManagementRpc(ctx.connection, DINGTALK_RPC_CHANNEL, endpoint, payload, signal);
|
|
501
|
+
const qqRpcCall = (endpoint, payload, signal) =>
|
|
502
|
+
callManagementRpc(ctx.connection, QQ_RPC_CHANNEL, endpoint, payload, signal);
|
|
503
|
+
const wecomRpcCall = (endpoint, payload, signal) =>
|
|
504
|
+
callManagementRpc(ctx.connection, WECOM_RPC_CHANNEL, endpoint, payload, signal);
|
|
505
|
+
const wecomAppRpcCall = (endpoint, payload, signal) =>
|
|
506
|
+
callManagementRpc(ctx.connection, WECOM_APP_RPC_CHANNEL, endpoint, payload, signal);
|
|
507
|
+
const telegramRpcCall = (endpoint, payload, signal) =>
|
|
508
|
+
callManagementRpc(ctx.connection, TELEGRAM_RPC_CHANNEL, endpoint, payload, signal);
|
|
509
|
+
const discordRpcCall = (endpoint, payload, signal) =>
|
|
510
|
+
callManagementRpc(ctx.connection, DISCORD_RPC_CHANNEL, endpoint, payload, signal);
|
|
511
|
+
const whatsappRpcCall = (endpoint, payload, signal) =>
|
|
512
|
+
callManagementRpc(ctx.connection, WHATSAPP_RPC_CHANNEL, endpoint, payload, signal);
|
|
513
|
+
const imessageRpcCall = (endpoint, payload, signal) =>
|
|
514
|
+
callManagementRpc(ctx.connection, IMESSAGE_RPC_CHANNEL, endpoint, payload, signal);
|
|
515
|
+
const emailRpcCall = (endpoint, payload, signal) =>
|
|
516
|
+
callManagementRpc(ctx.connection, EMAIL_RPC_CHANNEL, endpoint, payload, signal);
|
|
517
|
+
const matrixRpcCall = (endpoint, payload, signal) =>
|
|
518
|
+
callManagementRpc(ctx.connection, MATRIX_RPC_CHANNEL, endpoint, payload, signal);
|
|
519
|
+
const slackRpcCall = (endpoint, payload, signal) =>
|
|
520
|
+
callManagementRpc(ctx.connection, SLACK_RPC_CHANNEL, endpoint, payload, signal);
|
|
521
|
+
const officeRpcCall = (endpoint, payload, signal) =>
|
|
522
|
+
callManagementRpc(ctx.connection, OFFICE_RPC_CHANNEL, endpoint, payload, signal);
|
|
523
|
+
const updateRpcCall = (endpoint, payload, signal) =>
|
|
524
|
+
callManagementRpc(ctx.connection, UPDATE_RPC_CHANNEL, endpoint, payload, signal);
|
|
525
|
+
const deliveryRpcCall = (endpoint, payload, signal) =>
|
|
526
|
+
callManagementRpc(ctx.connection, DELIVERY_RPC_CHANNEL, endpoint, payload, signal);
|
|
527
|
+
const globalSettingsRpcCall = (endpoint, payload, signal) =>
|
|
528
|
+
callManagementRpc(ctx.connection, GLOBAL_SETTINGS_RPC_CHANNEL, endpoint, payload, signal);
|
|
529
|
+
const workspaceDirectoryPicker = Object.freeze({
|
|
530
|
+
listDirectory: (path, signal) =>
|
|
531
|
+
callWorkspaceDirectoryApi(ctx, 'listDirectory', path, signal),
|
|
532
|
+
pickDirectory: () => callWorkspaceDirectoryApi(ctx, 'pickDirectory'),
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
const panelDependencies = {
|
|
536
|
+
dingtalkRpcCall,
|
|
537
|
+
discordRpcCall,
|
|
538
|
+
feishuRpcCall,
|
|
539
|
+
qqRpcCall,
|
|
540
|
+
slackRpcCall,
|
|
541
|
+
telegramRpcCall,
|
|
542
|
+
wecomRpcCall,
|
|
543
|
+
wecomAppRpcCall,
|
|
544
|
+
weixinRpcCall,
|
|
545
|
+
whatsappRpcCall,
|
|
546
|
+
imessageRpcCall,
|
|
547
|
+
officeRpcCall,
|
|
548
|
+
emailRpcCall,
|
|
549
|
+
matrixRpcCall,
|
|
550
|
+
updateRpcCall,
|
|
551
|
+
deliveryRpcCall,
|
|
552
|
+
globalSettingsRpcCall,
|
|
553
|
+
workspaceDirectoryPicker,
|
|
554
|
+
};
|
|
555
|
+
const subscribeLocale = (listener) => typeof ctx.on === 'function'
|
|
556
|
+
? ctx.on('locale/change', listener) : () => {};
|
|
557
|
+
const localeSnapshot = () => ctx.locale.getLocale?.()?.active ?? '';
|
|
558
|
+
|
|
559
|
+
// Stable for this plugin lifetime: creating an element must not create a
|
|
560
|
+
// new component type and reset the reader's selected tab or unsaved input.
|
|
561
|
+
function IMPanel({ preferredSectionId }) {
|
|
562
|
+
React.useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
|
|
563
|
+
return h(IMPanelErrorBoundary, null,
|
|
564
|
+
h(IMSettingsTab, { ...panelDependencies, preferredSectionId }));
|
|
565
|
+
}
|
|
566
|
+
const buildPanelElement = (props = {}) => h(IMPanel, {
|
|
567
|
+
preferredSectionId: props.preferredSectionId,
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
installImPluginPage(ctx, { packageName: manifest.name, renderPanel: buildPanelElement });
|
|
571
|
+
|
|
572
|
+
ctx.effect(() => {
|
|
573
|
+
let disposed = false;
|
|
574
|
+
let stopSettings = null;
|
|
575
|
+
let registered = false;
|
|
576
|
+
const setSettingsVisible = (visible) => {
|
|
577
|
+
if (disposed) return;
|
|
578
|
+
if (typeof visible !== 'boolean') throw new TypeError('visible must be a boolean');
|
|
579
|
+
if (visible === (stopSettings !== null)) return;
|
|
580
|
+
if (!visible) {
|
|
581
|
+
const stop = stopSettings;
|
|
582
|
+
stopSettings = null;
|
|
583
|
+
stop();
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
// The existing slot controller owns late declarations, withdrawal and
|
|
587
|
+
// re-declaration. Cancelling it also cancels a pending registration.
|
|
588
|
+
stopSettings = ctx.slots.inject('settings.section', () => {
|
|
589
|
+
const unregister = ctx.slots.register({
|
|
590
|
+
name: 'settings.section',
|
|
591
|
+
id: 'xmanrui-dsh-im',
|
|
592
|
+
order: 21,
|
|
593
|
+
label: () => t('IM机器人'),
|
|
594
|
+
locale: IM_LOCALE_NAMESPACE,
|
|
595
|
+
inject: () => panelDependencies,
|
|
596
|
+
}, buildPanelElement);
|
|
597
|
+
registered = true;
|
|
598
|
+
return () => {
|
|
599
|
+
registered = false;
|
|
600
|
+
unregister();
|
|
601
|
+
};
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
// Publish only after the default registration is established, so a
|
|
606
|
+
// consumer hiding it during service discovery cannot be overridden.
|
|
607
|
+
setSettingsVisible(true);
|
|
608
|
+
if (typeof ctx.provide === 'function') {
|
|
609
|
+
ctx.provide('dshImClient', Object.freeze({
|
|
610
|
+
version: 1,
|
|
611
|
+
render: (props) => disposed ? null : buildPanelElement(props),
|
|
612
|
+
setSettingsVisible,
|
|
613
|
+
settingsVisible: () => !disposed && registered,
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
return () => {
|
|
617
|
+
disposed = true;
|
|
618
|
+
const stop = stopSettings;
|
|
619
|
+
stopSettings = null;
|
|
620
|
+
registered = false;
|
|
621
|
+
stop?.();
|
|
622
|
+
};
|
|
623
|
+
}, 'im-settings: client panel service');
|
|
624
|
+
}
|