@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,12 @@
|
|
|
1
|
+
const RPC_AUTHORITIES = new Set(['loopback', 'trusted-host']);
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the browser authority accepted by an IM management RPC channel.
|
|
5
|
+
* By default, use the browser authentication and Host/Origin trust checks
|
|
6
|
+
* already enforced by Harness before it dispatches a management Fetch route.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveRpcAuthority(value) {
|
|
9
|
+
if (value === undefined) return 'trusted-host';
|
|
10
|
+
if (RPC_AUTHORITIES.has(value)) return value;
|
|
11
|
+
throw new TypeError('dsh-im rpcAuthority must be "loopback" or "trusted-host"');
|
|
12
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssistantTextAccumulator,
|
|
3
|
+
consumeDshImInputOrigin,
|
|
4
|
+
textFromHarnessContent,
|
|
5
|
+
} from '../../src/channels/shared/harness-client.mjs';
|
|
6
|
+
import { deliverSessionSyncMirror } from '../../src/channels/shared/session-sync-registry.mjs';
|
|
7
|
+
|
|
8
|
+
const DSH_USER_PREFIX = '[来自 DSH]\n';
|
|
9
|
+
const DSH_ASSISTANT_PREFIX = '[DSH 助手]\n';
|
|
10
|
+
|
|
11
|
+
function completedTurn(reason) {
|
|
12
|
+
return (typeof reason === 'string' ? reason : reason?.kind) === 'completed';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function recipientKey(target) {
|
|
16
|
+
return JSON.stringify([target.channel, target.botId, target.targetId]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function sessionIdOf(session) {
|
|
20
|
+
const value = session?.id ?? session?.sessionId;
|
|
21
|
+
return typeof value === 'string' && value ? value : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function userInputOrigin(scope, event) {
|
|
25
|
+
const source = event?.data?.source;
|
|
26
|
+
if (source?.kind === 'schedule') return 'dsh';
|
|
27
|
+
if (source?.kind !== 'user' || typeof source.rpcId !== 'string' || !source.rpcId) {
|
|
28
|
+
return 'other';
|
|
29
|
+
}
|
|
30
|
+
return consumeDshImInputOrigin(scope, source.rpcId) ? 'im' : 'dsh';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function validRecipient(target) {
|
|
34
|
+
return target && typeof target === 'object'
|
|
35
|
+
&& typeof target.channel === 'string' && target.channel
|
|
36
|
+
&& typeof target.botId === 'string' && target.botId
|
|
37
|
+
&& typeof target.targetId === 'string' && target.targetId;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function createSessionSyncCoordinator({ deliveryService, logger = console }) {
|
|
41
|
+
if (typeof deliveryService?.listSessionSyncTargets !== 'function'
|
|
42
|
+
|| typeof deliveryService?.sendSessionSyncText !== 'function') {
|
|
43
|
+
throw new TypeError('Session sync requires a complete delivery service');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const turns = new Map();
|
|
47
|
+
const tails = new Map();
|
|
48
|
+
let closed = false;
|
|
49
|
+
|
|
50
|
+
const logFailure = (phase, target, error) => {
|
|
51
|
+
logger.warn?.(
|
|
52
|
+
`[dsh-im] ignored Session sync ${phase} failure`
|
|
53
|
+
+ (target ? ` (${target.channel}/${target.botId}/${target.targetId})` : '')
|
|
54
|
+
+ ` [${error?.code ?? error?.name ?? 'unknown-error'}]`,
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const deliver = async (sessionId, targets, text, phase) => {
|
|
59
|
+
const unique = new Map();
|
|
60
|
+
for (const target of targets) {
|
|
61
|
+
if (validRecipient(target)) unique.set(recipientKey(target), target);
|
|
62
|
+
}
|
|
63
|
+
const entries = [...unique.entries()];
|
|
64
|
+
const results = await Promise.allSettled(entries.map(([, target]) => (
|
|
65
|
+
deliveryService.sendSessionSyncText(
|
|
66
|
+
target.botId,
|
|
67
|
+
target.targetId,
|
|
68
|
+
sessionId,
|
|
69
|
+
text,
|
|
70
|
+
)
|
|
71
|
+
)));
|
|
72
|
+
const successful = new Map();
|
|
73
|
+
results.forEach((result, index) => {
|
|
74
|
+
const [key, target] = entries[index];
|
|
75
|
+
if (result.status === 'fulfilled') successful.set(key, target);
|
|
76
|
+
else logFailure(phase, target, result.reason);
|
|
77
|
+
});
|
|
78
|
+
return successful;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const processEvent = async (sessionId, event, origin) => {
|
|
82
|
+
if (closed || !event || typeof event !== 'object') return;
|
|
83
|
+
|
|
84
|
+
if (event.type === 'turn/start') {
|
|
85
|
+
const turn = event.data?.turn;
|
|
86
|
+
if (!Number.isSafeInteger(turn)) return;
|
|
87
|
+
turns.set(sessionId, {
|
|
88
|
+
turn,
|
|
89
|
+
step: null,
|
|
90
|
+
origin: 'unknown',
|
|
91
|
+
recipients: null,
|
|
92
|
+
assistant: new AssistantTextAccumulator(),
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const state = turns.get(sessionId);
|
|
98
|
+
if (!state) return;
|
|
99
|
+
|
|
100
|
+
if (event.type === 'step/start') {
|
|
101
|
+
if (event.data?.turn !== undefined && event.data.turn !== state.turn) return;
|
|
102
|
+
state.step = Number.isSafeInteger(event.data?.step) ? event.data.step : null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (event.type === 'step/end') {
|
|
107
|
+
if (event.data?.turn !== undefined && event.data.turn !== state.turn) return;
|
|
108
|
+
if (event.data?.step === undefined || event.data.step === state.step) state.step = null;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (event.type === 'user/message') {
|
|
113
|
+
if (event.surfaceOp !== 'append') return;
|
|
114
|
+
if (state.origin === 'unknown') state.origin = origin;
|
|
115
|
+
if (state.origin !== 'dsh' || origin !== 'dsh') return;
|
|
116
|
+
const scheduled = event.data?.source?.kind === 'schedule';
|
|
117
|
+
const text = textFromHarnessContent(event.data?.content);
|
|
118
|
+
if (!text && !scheduled) return;
|
|
119
|
+
|
|
120
|
+
let targets;
|
|
121
|
+
try {
|
|
122
|
+
targets = await deliveryService.listSessionSyncTargets(sessionId);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
logFailure('lookup', null, error);
|
|
125
|
+
targets = [];
|
|
126
|
+
}
|
|
127
|
+
// Scheduled framing is internal: select its recipients without echoing it.
|
|
128
|
+
// Direct DSH input still requires a successful echo before the final answer.
|
|
129
|
+
const recipients = scheduled
|
|
130
|
+
? new Map(targets.filter(validRecipient).map((target) => [recipientKey(target), target]))
|
|
131
|
+
: await deliver(sessionId, targets, `${DSH_USER_PREFIX}${text}`, 'user delivery');
|
|
132
|
+
if (state.recipients === null) {
|
|
133
|
+
state.recipients = recipients;
|
|
134
|
+
} else {
|
|
135
|
+
for (const key of [...state.recipients.keys()]) {
|
|
136
|
+
if (!recipients.has(key)) state.recipients.delete(key);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (event.type === 'assistant/message') {
|
|
143
|
+
if (state.origin !== 'dsh' || event.surfaceOp !== 'append'
|
|
144
|
+
|| event.data?.interrupted === true
|
|
145
|
+
|| (event.data?.turn !== undefined && event.data.turn !== state.turn)) return;
|
|
146
|
+
const text = textFromHarnessContent(event.data?.message?.content);
|
|
147
|
+
const step = Number.isSafeInteger(event.data?.step) ? event.data.step : state.step;
|
|
148
|
+
state.assistant.setCanonical(step, text);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (event.type !== 'turn/end' || event.data?.turn !== state.turn) return;
|
|
153
|
+
turns.delete(sessionId);
|
|
154
|
+
if (state.origin !== 'dsh' || !completedTurn(event.data?.reason)
|
|
155
|
+
|| !state.recipients?.size || !state.assistant.text) return;
|
|
156
|
+
// A pending card is not proof of delivery. Only suppress this target's
|
|
157
|
+
// text after its renderer confirms the complete final answer is visible.
|
|
158
|
+
// Targets without a renderer retain the original text delivery path.
|
|
159
|
+
const recipients = [...state.recipients.values()];
|
|
160
|
+
const rendered = await Promise.all(recipients.map(async (target) => {
|
|
161
|
+
try {
|
|
162
|
+
return await deliverSessionSyncMirror(target, sessionId, state.turn, state.assistant.text);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
logFailure('card delivery', target, error);
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}));
|
|
168
|
+
const plain = recipients.filter((_target, index) => !rendered[index]);
|
|
169
|
+
if (plain.length === 0) return;
|
|
170
|
+
await deliver(
|
|
171
|
+
sessionId,
|
|
172
|
+
plain,
|
|
173
|
+
`${DSH_ASSISTANT_PREFIX}${state.assistant.text}`,
|
|
174
|
+
'assistant delivery',
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const enqueue = (sessionId, event, origin = 'other') => {
|
|
179
|
+
if (closed || typeof sessionId !== 'string' || !sessionId) return Promise.resolve();
|
|
180
|
+
const previous = tails.get(sessionId) ?? Promise.resolve();
|
|
181
|
+
const task = previous.then(
|
|
182
|
+
() => processEvent(sessionId, event, origin),
|
|
183
|
+
() => processEvent(sessionId, event, origin),
|
|
184
|
+
);
|
|
185
|
+
const tail = task.catch((error) => logFailure('event handling', null, error)).finally(() => {
|
|
186
|
+
if (tails.get(sessionId) === tail) tails.delete(sessionId);
|
|
187
|
+
});
|
|
188
|
+
tails.set(sessionId, tail);
|
|
189
|
+
return tail;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
return Object.freeze({
|
|
193
|
+
enqueue,
|
|
194
|
+
async whenIdle() {
|
|
195
|
+
while (tails.size > 0) await Promise.allSettled([...tails.values()]);
|
|
196
|
+
},
|
|
197
|
+
close() {
|
|
198
|
+
closed = true;
|
|
199
|
+
turns.clear();
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function installSessionSyncCoordinator(ctx, deliveryService, {
|
|
205
|
+
logger = console,
|
|
206
|
+
inputScope = ctx?.root ?? ctx,
|
|
207
|
+
} = {}) {
|
|
208
|
+
if (typeof ctx?.on !== 'function') {
|
|
209
|
+
throw new TypeError('Session sync requires Host session events');
|
|
210
|
+
}
|
|
211
|
+
const coordinator = createSessionSyncCoordinator({ deliveryService, logger });
|
|
212
|
+
const disposeEvent = ctx.on('session/event', (session, event) => {
|
|
213
|
+
const sessionId = sessionIdOf(session);
|
|
214
|
+
if (!sessionId) return;
|
|
215
|
+
// Origin lookup must be synchronous: the originating ask may clean its id
|
|
216
|
+
// immediately after this event callback returns.
|
|
217
|
+
const origin = event?.type === 'user/message'
|
|
218
|
+
? userInputOrigin(inputScope, event)
|
|
219
|
+
: 'other';
|
|
220
|
+
void coordinator.enqueue(sessionId, event, origin);
|
|
221
|
+
}, { global: true });
|
|
222
|
+
let disposed = false;
|
|
223
|
+
const close = () => {
|
|
224
|
+
if (disposed) return;
|
|
225
|
+
disposed = true;
|
|
226
|
+
disposeEvent?.();
|
|
227
|
+
coordinator.close();
|
|
228
|
+
};
|
|
229
|
+
if (typeof ctx.effect === 'function') {
|
|
230
|
+
ctx.effect(() => close, 'dsh-im: Session sync coordinator');
|
|
231
|
+
}
|
|
232
|
+
return Object.freeze({ ...coordinator, close });
|
|
233
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { getImHostLanguage } from '../../src/channels/shared/i18n.mjs';
|
|
2
|
+
import { SESSION_CHANNEL_LABELS as CHANNEL_LABELS } from '../../src/channels/shared/session-channel-labels.mjs';
|
|
3
|
+
const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
|
4
|
+
// HarnessClient uses these ids for prompts and steering, independently of
|
|
5
|
+
// context enhancement. Read the durable source, never the message's text.
|
|
6
|
+
const IM_RPC_ID = new RegExp(`^(${Object.keys(CHANNEL_LABELS).join('|')})-(?:steer-)?${UUID}$`, 'u');
|
|
7
|
+
const LEGACY_SESSION_ID = new RegExp(`^(${Object.keys(CHANNEL_LABELS).join('|')})-.+`, 'u');
|
|
8
|
+
|
|
9
|
+
function eventsOf(session) {
|
|
10
|
+
const events = typeof session?.snapshotEvents === 'function'
|
|
11
|
+
? session.snapshotEvents()
|
|
12
|
+
: session?.events;
|
|
13
|
+
return Array.isArray(events) ? events : [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function channelOf(session, events) {
|
|
17
|
+
// A Web-created fork must not acquire a channel just from its parent's
|
|
18
|
+
// messages. Both supported Session implementations expose this boundary.
|
|
19
|
+
const inherited = session.inheritedEventCount;
|
|
20
|
+
if (session.header?.parentSession && !Number.isSafeInteger(inherited)) return null;
|
|
21
|
+
for (const event of events) {
|
|
22
|
+
if (Number.isSafeInteger(inherited) && event.seq < inherited) continue;
|
|
23
|
+
if (event.type !== 'user/message' || event.data?.source?.kind !== 'user') continue;
|
|
24
|
+
const channel = IM_RPC_ID.exec(event.data.source.rpcId)?.[1];
|
|
25
|
+
if (channel) return channel;
|
|
26
|
+
}
|
|
27
|
+
if (session.header?.parentSession) return null;
|
|
28
|
+
return LEGACY_SESSION_ID.exec(session.id ?? session.sessionId)?.[1] ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function withSessionChannelPrefix(title, channel, language = getImHostLanguage()) {
|
|
32
|
+
const labels = CHANNEL_LABELS[channel];
|
|
33
|
+
if (!labels || typeof title !== 'string' || !title.trim()) return title;
|
|
34
|
+
// Keep the original title intact, including Unicode graphemes. The Host
|
|
35
|
+
// has already normalized and capped its generated text before this point.
|
|
36
|
+
if (labels.some((label) => title.startsWith(`${label} · `))) return title;
|
|
37
|
+
return `${labels[language === 'en' ? 1 : 0]} · ${title}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function validTitleData(data) {
|
|
41
|
+
if (typeof data?.title !== 'string' || !data.title.trim()
|
|
42
|
+
|| !Array.isArray(data.messageSeqs)) return false;
|
|
43
|
+
if (data.source?.kind === 'user') return data.messageSeqs.length === 0;
|
|
44
|
+
if (!['fallback', 'provider'].includes(data.source?.kind)
|
|
45
|
+
|| data.messageSeqs.length === 0
|
|
46
|
+
|| data.messageSeqs.some((seq) => !Number.isSafeInteger(seq) || seq < 0)) return false;
|
|
47
|
+
return data.source.kind !== 'provider'
|
|
48
|
+
|| (typeof data.source.provider === 'string' && Boolean(data.source.provider));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Decorate accepted titles without session.rename(): rename pins them as
|
|
53
|
+
* user-owned and supersedes automatic generation. Appending a log-only title
|
|
54
|
+
* with the same source and citations preserves the Host's scheduling and
|
|
55
|
+
* explicit-rename semantics. No provider, prompt, or stored event is changed.
|
|
56
|
+
*/
|
|
57
|
+
export function installSessionTitlePrefix(ctx, { logger = console } = {}) {
|
|
58
|
+
if (typeof ctx?.on !== 'function' || typeof ctx?.sessions?.get !== 'function'
|
|
59
|
+
|| typeof ctx?.sessions?.list !== 'function') {
|
|
60
|
+
throw new TypeError('Session title prefixes require Host sessions and events');
|
|
61
|
+
}
|
|
62
|
+
const pending = new Map();
|
|
63
|
+
let closed = false;
|
|
64
|
+
|
|
65
|
+
const decorate = (session) => {
|
|
66
|
+
if (closed || ctx.sessions.get(session.id ?? session.sessionId) !== session
|
|
67
|
+
|| typeof session.append !== 'function') return;
|
|
68
|
+
const events = eventsOf(session);
|
|
69
|
+
const channel = channelOf(session, events);
|
|
70
|
+
if (!channel) return;
|
|
71
|
+
const latest = events.findLast((event) => event.type === 'session/title');
|
|
72
|
+
if (!validTitleData(latest?.data)) return;
|
|
73
|
+
const title = withSessionChannelPrefix(latest.data.title, channel);
|
|
74
|
+
if (title === latest.data.title) return;
|
|
75
|
+
// There is no await between the latest-title read and this append. A
|
|
76
|
+
// queued old result can therefore never replace a newer/manual title.
|
|
77
|
+
session.append('session/title', {
|
|
78
|
+
...structuredClone(latest.data),
|
|
79
|
+
title,
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const enqueue = (session) => {
|
|
84
|
+
if (closed || pending.has(session)) return;
|
|
85
|
+
// Leave the current append/notification stack before writing another
|
|
86
|
+
// event, so persistence and client projections observe monotonically
|
|
87
|
+
// ordered events. Read the newest title when the microtask runs.
|
|
88
|
+
const task = Promise.resolve().then(() => {
|
|
89
|
+
pending.delete(session);
|
|
90
|
+
decorate(session);
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
logger.warn?.('[dsh-im] unable to add Session channel prefix:', error?.message ?? error);
|
|
93
|
+
}).finally(() => {
|
|
94
|
+
if (pending.get(session) === task) pending.delete(session);
|
|
95
|
+
});
|
|
96
|
+
pending.set(session, task);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const disposeEvent = ctx.on('session/event', (session, event) => {
|
|
100
|
+
if (event?.type === 'session/title'
|
|
101
|
+
|| (event?.type === 'user/message' && IM_RPC_ID.test(event.data?.source?.rpcId))) {
|
|
102
|
+
enqueue(session);
|
|
103
|
+
}
|
|
104
|
+
}, { global: true });
|
|
105
|
+
const disposeCreated = ctx.on('session/created', enqueue, { global: true });
|
|
106
|
+
const close = () => {
|
|
107
|
+
if (closed) return;
|
|
108
|
+
closed = true;
|
|
109
|
+
disposeEvent?.();
|
|
110
|
+
disposeCreated?.();
|
|
111
|
+
};
|
|
112
|
+
if (typeof ctx.effect === 'function') {
|
|
113
|
+
ctx.effect(() => close, 'dsh-im: Session title channel prefixes');
|
|
114
|
+
}
|
|
115
|
+
for (const session of ctx.sessions.list()) enqueue(session);
|
|
116
|
+
return Object.freeze({
|
|
117
|
+
close,
|
|
118
|
+
async whenIdle() {
|
|
119
|
+
while (pending.size) await Promise.allSettled([...pending.values()]);
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function productManagedUpdate(endpoint, payload, signal, version) {
|
|
2
|
+
if (signal?.aborted)
|
|
3
|
+
return { ok: false, error: { code: 'cancelled', message: 'Request cancelled.' } };
|
|
4
|
+
if (
|
|
5
|
+
endpoint !== 'update.status' ||
|
|
6
|
+
payload === null ||
|
|
7
|
+
typeof payload !== 'object' ||
|
|
8
|
+
Array.isArray(payload) ||
|
|
9
|
+
Object.keys(payload).length !== 0
|
|
10
|
+
)
|
|
11
|
+
return {
|
|
12
|
+
ok: false,
|
|
13
|
+
error: { code: 'product-managed', message: 'Update this Provider with BotHarness.' },
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
ok: true,
|
|
17
|
+
value: {
|
|
18
|
+
runningVersion: version,
|
|
19
|
+
installedVersion: version,
|
|
20
|
+
latestVersion: null,
|
|
21
|
+
canInstall: false,
|
|
22
|
+
sourceInstall: false,
|
|
23
|
+
blockedReason: 'product-managed',
|
|
24
|
+
profileName: null,
|
|
25
|
+
environmentKind: 'product',
|
|
26
|
+
checkedAt: null,
|
|
27
|
+
checkId: null,
|
|
28
|
+
job: null,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import manifest from '../../package.json' with { type: 'json' };
|
|
2
|
+
import { registerManagementRpc } from '../management-rpc.mjs';
|
|
3
|
+
import { productManagedUpdate } from './update-policy.mjs';
|
|
4
|
+
|
|
5
|
+
export const UPDATE_RPC_CHANNEL = '/dsh-im';
|
|
6
|
+
export const UPDATE_ENDPOINTS = Object.freeze(['update.status', 'update.check', 'update.install']);
|
|
7
|
+
|
|
8
|
+
export function installUpdateRpc(ctx) {
|
|
9
|
+
return registerManagementRpc(
|
|
10
|
+
ctx,
|
|
11
|
+
UPDATE_RPC_CHANNEL,
|
|
12
|
+
async (endpoint, payload, signal) =>
|
|
13
|
+
productManagedUpdate(endpoint, payload, signal, manifest.version),
|
|
14
|
+
{ authority: 'loopback' },
|
|
15
|
+
);
|
|
16
|
+
}
|