@botharness/im-provider 4.32.0-botharness.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/PROVENANCE.json +25 -0
- package/README.en.md +445 -0
- package/README.md +448 -0
- package/THIRD_PARTY_NOTICES.md +93 -0
- package/assets/dingtalk-menu-template.json +6 -0
- package/assets/logo-dsh-im-chinese-readme-3x2.png +0 -0
- package/assets/logo-dsh-im-connecting-readme-3x2.png +0 -0
- package/assets/logo-dsh-im-connecting-square-v4.png +0 -0
- package/assets/logo-icon.png +0 -0
- package/assets/logo-plugin-message-link-gradient.webp +0 -0
- package/assets/logo-plugin-phone.png +0 -0
- package/assets/logo.png +0 -0
- package/assets/logo_cn.png +0 -0
- package/assets/screenshot-menu-card.png +0 -0
- package/cordis.patch.yml +3 -0
- package/lib/client.js +20330 -0
- package/lib/index.js +602 -0
- package/locale/en.json +5 -0
- package/locale/zh.json +5 -0
- package/package.json +181 -0
- package/plugin-src/client/access-policy-settings.js +362 -0
- package/plugin-src/client/agent-preset.js +119 -0
- package/plugin-src/client/bot-alias.js +169 -0
- package/plugin-src/client/build.mjs +38 -0
- package/plugin-src/client/channel-card-meta.js +132 -0
- package/plugin-src/client/channel-logos.js +190 -0
- package/plugin-src/client/channels/dingtalk/api.js +267 -0
- package/plugin-src/client/channels/dingtalk/index.js +954 -0
- package/plugin-src/client/channels/dingtalk/styles.js +136 -0
- package/plugin-src/client/channels/discord/api.js +11 -0
- package/plugin-src/client/channels/discord/index.js +25 -0
- package/plugin-src/client/channels/discord/styles.js +19 -0
- package/plugin-src/client/channels/email/api.js +52 -0
- package/plugin-src/client/channels/email/index.js +728 -0
- package/plugin-src/client/channels/email/styles.js +51 -0
- package/plugin-src/client/channels/feishu/api.js +405 -0
- package/plugin-src/client/channels/feishu/group-settings.js +581 -0
- package/plugin-src/client/channels/feishu/index.js +1583 -0
- package/plugin-src/client/channels/feishu/slash-panel-settings.js +322 -0
- package/plugin-src/client/channels/feishu/styles.js +573 -0
- package/plugin-src/client/channels/feishu/voice-editor.js +115 -0
- package/plugin-src/client/channels/feishu/voice-settings.js +71 -0
- package/plugin-src/client/channels/imessage/api.js +12 -0
- package/plugin-src/client/channels/imessage/index.js +46 -0
- package/plugin-src/client/channels/imessage/styles.js +19 -0
- package/plugin-src/client/channels/matrix/api.js +11 -0
- package/plugin-src/client/channels/matrix/index.js +151 -0
- package/plugin-src/client/channels/matrix/styles.js +36 -0
- package/plugin-src/client/channels/office/api.js +46 -0
- package/plugin-src/client/channels/office/index.js +153 -0
- package/plugin-src/client/channels/office/styles.js +50 -0
- package/plugin-src/client/channels/qq/api.js +171 -0
- package/plugin-src/client/channels/qq/index.js +593 -0
- package/plugin-src/client/channels/qq/styles.js +19 -0
- package/plugin-src/client/channels/shared/collapsible-account.js +103 -0
- package/plugin-src/client/channels/shared/token-api.js +124 -0
- package/plugin-src/client/channels/shared/token-channel.js +495 -0
- package/plugin-src/client/channels/slack/api.js +11 -0
- package/plugin-src/client/channels/slack/index.js +131 -0
- package/plugin-src/client/channels/slack/styles.js +34 -0
- package/plugin-src/client/channels/telegram/api.js +11 -0
- package/plugin-src/client/channels/telegram/index.js +28 -0
- package/plugin-src/client/channels/telegram/styles.js +31 -0
- package/plugin-src/client/channels/telegram/thinking-traces.js +25 -0
- package/plugin-src/client/channels/wecom/api.js +160 -0
- package/plugin-src/client/channels/wecom/index.js +625 -0
- package/plugin-src/client/channels/wecom/styles.js +19 -0
- package/plugin-src/client/channels/wecom-app/api.js +132 -0
- package/plugin-src/client/channels/wecom-app/index.js +634 -0
- package/plugin-src/client/channels/wecom-app/styles.js +25 -0
- package/plugin-src/client/channels/weixin/api.js +211 -0
- package/plugin-src/client/channels/weixin/connection-error.js +1 -0
- package/plugin-src/client/channels/weixin/index.js +801 -0
- package/plugin-src/client/channels/weixin/styles.js +115 -0
- package/plugin-src/client/channels/whatsapp/api.js +152 -0
- package/plugin-src/client/channels/whatsapp/index.js +609 -0
- package/plugin-src/client/channels/whatsapp/styles.js +19 -0
- package/plugin-src/client/connection-error.js +87 -0
- package/plugin-src/client/context-enhancement.js +415 -0
- package/plugin-src/client/credential-binding.js +118 -0
- package/plugin-src/client/delivery-settings.js +905 -0
- package/plugin-src/client/global-settings.js +433 -0
- package/plugin-src/client/i18n.js +1314 -0
- package/plugin-src/client/index.js +624 -0
- package/plugin-src/client/interface-language.js +89 -0
- package/plugin-src/client/last-message-error.js +18 -0
- package/plugin-src/client/lifecycle.js +86 -0
- package/plugin-src/client/loopback-recovery.js +75 -0
- package/plugin-src/client/model-setting.js +172 -0
- package/plugin-src/client/panel-error-boundary.js +21 -0
- package/plugin-src/client/plugin-page.js +51 -0
- package/plugin-src/client/session-channel-logos.js +243 -0
- package/plugin-src/client/styles.js +770 -0
- package/plugin-src/client/update-panel.js +14 -0
- package/plugin-src/client/workspace-directory-picker.js +280 -0
- package/plugin-src/client/workspace-editor.js +69 -0
- package/plugin-src/client/workspace-snapshot-fence.js +28 -0
- package/plugin-src/host/build.mjs +52 -0
- package/plugin-src/host/channels/dingtalk/connection-supervisor.mjs +130 -0
- package/plugin-src/host/channels/dingtalk/index.mjs +35 -0
- package/plugin-src/host/channels/dingtalk/production.mjs +193 -0
- package/plugin-src/host/channels/dingtalk/rpc.mjs +359 -0
- package/plugin-src/host/channels/discord/index.mjs +33 -0
- package/plugin-src/host/channels/discord/production.mjs +17 -0
- package/plugin-src/host/channels/discord/rpc.mjs +21 -0
- package/plugin-src/host/channels/email/availability.mjs +60 -0
- package/plugin-src/host/channels/email/index.mjs +36 -0
- package/plugin-src/host/channels/email/production.mjs +58 -0
- package/plugin-src/host/channels/email/rpc.mjs +163 -0
- package/plugin-src/host/channels/feishu/connection-supervisor.mjs +167 -0
- package/plugin-src/host/channels/feishu/controller.mjs +172 -0
- package/plugin-src/host/channels/feishu/credential-store.mjs +84 -0
- package/plugin-src/host/channels/feishu/index.mjs +69 -0
- package/plugin-src/host/channels/feishu/production.mjs +318 -0
- package/plugin-src/host/channels/feishu/rpc.mjs +863 -0
- package/plugin-src/host/channels/imessage/index.mjs +21 -0
- package/plugin-src/host/channels/imessage/production.mjs +13 -0
- package/plugin-src/host/channels/imessage/rpc.mjs +78 -0
- package/plugin-src/host/channels/matrix/index.mjs +31 -0
- package/plugin-src/host/channels/matrix/production.mjs +241 -0
- package/plugin-src/host/channels/matrix/rpc.mjs +228 -0
- package/plugin-src/host/channels/office/index.mjs +14 -0
- package/plugin-src/host/channels/office/production.mjs +45 -0
- package/plugin-src/host/channels/office/rpc.mjs +51 -0
- package/plugin-src/host/channels/qq/connection-supervisor.mjs +124 -0
- package/plugin-src/host/channels/qq/index.mjs +28 -0
- package/plugin-src/host/channels/qq/production.mjs +181 -0
- package/plugin-src/host/channels/qq/rpc.mjs +250 -0
- package/plugin-src/host/channels/shared/access-policy-production.mjs +137 -0
- package/plugin-src/host/channels/shared/access-policy-rpc.mjs +17 -0
- package/plugin-src/host/channels/shared/agent-preset-rpc.mjs +25 -0
- package/plugin-src/host/channels/shared/bot-alias-rpc.mjs +15 -0
- package/plugin-src/host/channels/shared/connection-supervisor.mjs +133 -0
- package/plugin-src/host/channels/shared/context-enhancement-rpc.mjs +17 -0
- package/plugin-src/host/channels/shared/model-setting-rpc.mjs +18 -0
- package/plugin-src/host/channels/shared/production.mjs +237 -0
- package/plugin-src/host/channels/shared/rpc.mjs +226 -0
- package/plugin-src/host/channels/shared/startup-error.mjs +55 -0
- package/plugin-src/host/channels/shared/startup.mjs +76 -0
- package/plugin-src/host/channels/shared/thinking-traces-rpc.mjs +11 -0
- package/plugin-src/host/channels/shared/workspace-rpc.mjs +31 -0
- package/plugin-src/host/channels/slack/index.mjs +31 -0
- package/plugin-src/host/channels/slack/production.mjs +176 -0
- package/plugin-src/host/channels/slack/rpc.mjs +221 -0
- package/plugin-src/host/channels/telegram/index.mjs +33 -0
- package/plugin-src/host/channels/telegram/production.mjs +19 -0
- package/plugin-src/host/channels/telegram/rpc.mjs +22 -0
- package/plugin-src/host/channels/wecom/connection-supervisor.mjs +124 -0
- package/plugin-src/host/channels/wecom/index.mjs +34 -0
- package/plugin-src/host/channels/wecom/production.mjs +187 -0
- package/plugin-src/host/channels/wecom/rpc.mjs +255 -0
- package/plugin-src/host/channels/wecom-app/index.mjs +33 -0
- package/plugin-src/host/channels/wecom-app/production.mjs +221 -0
- package/plugin-src/host/channels/wecom-app/rpc.mjs +235 -0
- package/plugin-src/host/channels/weixin/connection-supervisor.mjs +139 -0
- package/plugin-src/host/channels/weixin/index.mjs +44 -0
- package/plugin-src/host/channels/weixin/production.mjs +257 -0
- package/plugin-src/host/channels/weixin/rpc.mjs +285 -0
- package/plugin-src/host/channels/whatsapp/index.mjs +33 -0
- package/plugin-src/host/channels/whatsapp/production.mjs +198 -0
- package/plugin-src/host/channels/whatsapp/rpc.mjs +242 -0
- package/plugin-src/host/delivery-adapter.mjs +388 -0
- package/plugin-src/host/delivery-http.mjs +132 -0
- package/plugin-src/host/delivery-rpc.mjs +173 -0
- package/plugin-src/host/delivery-service.mjs +552 -0
- package/plugin-src/host/delivery-suggestions.mjs +198 -0
- package/plugin-src/host/harness-command-executor.mjs +48 -0
- package/plugin-src/host/harness-connection.mjs +20 -0
- package/plugin-src/host/harness-session-coordinator.mjs +183 -0
- package/plugin-src/host/host-language-rpc.mjs +71 -0
- package/plugin-src/host/host-language.mjs +157 -0
- package/plugin-src/host/image-input-rpc.mjs +24 -0
- package/plugin-src/host/inbound-ttl-rpc.mjs +86 -0
- package/plugin-src/host/inbound-ttl-runtime.mjs +85 -0
- package/plugin-src/host/inbound-ttl-service.mjs +179 -0
- package/plugin-src/host/index.mjs +224 -0
- package/plugin-src/host/injected-context.mjs +104 -0
- package/plugin-src/host/lark-sdk-handshake-patch.mjs +181 -0
- package/plugin-src/host/modern-harness-api.mjs +738 -0
- package/plugin-src/host/rpc-authority.mjs +12 -0
- package/plugin-src/host/session-sync-coordinator.mjs +233 -0
- package/plugin-src/host/session-title-prefix.mjs +122 -0
- package/plugin-src/host/update-policy.mjs +31 -0
- package/plugin-src/host/update-rpc.mjs +16 -0
- package/plugin-src/host/update-runtime.mjs +339 -0
- package/plugin-src/host/update-service.mjs +392 -0
- package/plugin-src/management-rpc.mjs +87 -0
- package/src/channels/dingtalk/config-store.mjs +284 -0
- package/src/channels/dingtalk/connection-error.mjs +292 -0
- package/src/channels/dingtalk/device-auth.mjs +240 -0
- package/src/channels/dingtalk/dingtalk-api.mjs +1140 -0
- package/src/channels/dingtalk/dingtalk-bridge.mjs +1889 -0
- package/src/channels/dingtalk/dingtalk-card-stream.mjs +242 -0
- package/src/channels/dingtalk/dingtalk-controller.mjs +852 -0
- package/src/channels/dingtalk/dingtalk-menu.mjs +95 -0
- package/src/channels/dingtalk/dingtalk-runtime.mjs +482 -0
- package/src/channels/dingtalk/harness-client.mjs +19 -0
- package/src/channels/dingtalk/state-store.mjs +325 -0
- package/src/channels/discord/config-store.mjs +25 -0
- package/src/channels/discord/discord-api.mjs +347 -0
- package/src/channels/discord/discord-bridge.mjs +16 -0
- package/src/channels/discord/discord-controller.mjs +16 -0
- package/src/channels/discord/discord-runtime.mjs +974 -0
- package/src/channels/discord/harness-client.mjs +11 -0
- package/src/channels/discord/state-store.mjs +3 -0
- package/src/channels/email/config-store.mjs +194 -0
- package/src/channels/email/email-api.mjs +20 -0
- package/src/channels/email/email-bridge.mjs +17 -0
- package/src/channels/email/email-controller.mjs +824 -0
- package/src/channels/email/email-runtime.mjs +699 -0
- package/src/channels/email/harness-client.mjs +7 -0
- package/src/channels/email/mail-format.mjs +91 -0
- package/src/channels/email/state-store.mjs +176 -0
- package/src/channels/email/transport.mjs +64 -0
- package/src/channels/email/transports/agent-mail.mjs +604 -0
- package/src/channels/email/transports/agently-cli.mjs +288 -0
- package/src/channels/email/transports/imap-smtp.mjs +165 -0
- package/src/channels/feishu/bridge.mjs +6286 -0
- package/src/channels/feishu/config.mjs +71 -0
- package/src/channels/feishu/external-consumer.mjs +77 -0
- package/src/channels/feishu/external-files.mjs +111 -0
- package/src/channels/feishu/feishu-app.mjs +54 -0
- package/src/channels/feishu/feishu-cards.mjs +1285 -0
- package/src/channels/feishu/feishu-channel.mjs +651 -0
- package/src/channels/feishu/feishu-runtime.mjs +950 -0
- package/src/channels/feishu/group-message-permission-manager.mjs +72 -0
- package/src/channels/feishu/group-response-mode.mjs +15 -0
- package/src/channels/feishu/harness-client.mjs +19 -0
- package/src/channels/feishu/history-reader.mjs +77 -0
- package/src/channels/feishu/live-cot.mjs +260 -0
- package/src/channels/feishu/message-utils.mjs +613 -0
- package/src/channels/feishu/multi-bot-controller.mjs +1588 -0
- package/src/channels/feishu/nearby-history.mjs +72 -0
- package/src/channels/feishu/plugin-config-store.mjs +216 -0
- package/src/channels/feishu/plugin-controller.mjs +254 -0
- package/src/channels/feishu/registration-manager.mjs +349 -0
- package/src/channels/feishu/repair-manager.mjs +138 -0
- package/src/channels/feishu/reply-context.mjs +22 -0
- package/src/channels/feishu/slash-command-panel.mjs +155 -0
- package/src/channels/feishu/slash-command-registry.mjs +495 -0
- package/src/channels/feishu/state-store.mjs +214 -0
- package/src/channels/feishu/step-push-mode.mjs +25 -0
- package/src/channels/feishu/voice-config.mjs +34 -0
- package/src/channels/feishu/voice.mjs +134 -0
- package/src/channels/imessage/config-store.mjs +24 -0
- package/src/channels/imessage/controller.mjs +37 -0
- package/src/channels/imessage/harness-client.mjs +7 -0
- package/src/channels/imessage/imessage-api.mjs +194 -0
- package/src/channels/imessage/imessage-bridge.mjs +16 -0
- package/src/channels/imessage/runtime.mjs +102 -0
- package/src/channels/imessage/state-store.mjs +3 -0
- package/src/channels/matrix/matrix-api.mjs +696 -0
- package/src/channels/matrix/matrix-bridge.mjs +20 -0
- package/src/channels/matrix/matrix-config-store.mjs +368 -0
- package/src/channels/matrix/matrix-controller.mjs +404 -0
- package/src/channels/matrix/matrix-crypto-store.mjs +279 -0
- package/src/channels/matrix/matrix-crypto.mjs +1014 -0
- package/src/channels/matrix/matrix-harness-client.mjs +11 -0
- package/src/channels/matrix/matrix-normalize.mjs +357 -0
- package/src/channels/matrix/matrix-rich-text.mjs +313 -0
- package/src/channels/matrix/matrix-room-history.mjs +316 -0
- package/src/channels/matrix/matrix-runtime.mjs +1014 -0
- package/src/channels/office/config-store.mjs +107 -0
- package/src/channels/office/office-controller.mjs +178 -0
- package/src/channels/office/office-job-executor.mjs +391 -0
- package/src/channels/office/office-runtime.mjs +175 -0
- package/src/channels/office/office-transport.mjs +171 -0
- package/src/channels/office/protocol.mjs +43 -0
- package/src/channels/qq/config-store.mjs +173 -0
- package/src/channels/qq/harness-client.mjs +11 -0
- package/src/channels/qq/markdown-reply.mjs +446 -0
- package/src/channels/qq/qq-bridge.mjs +1507 -0
- package/src/channels/qq/qq-controller.mjs +514 -0
- package/src/channels/qq/qq-menu.mjs +208 -0
- package/src/channels/qq/qq-runtime.mjs +303 -0
- package/src/channels/qq/qr-auth.mjs +24 -0
- package/src/channels/qq/state-error.mjs +17 -0
- package/src/channels/qq/state-store.mjs +143 -0
- package/src/channels/shared/access-policy.mjs +210 -0
- package/src/channels/shared/agent-preset.mjs +76 -0
- package/src/channels/shared/batch-input.mjs +229 -0
- package/src/channels/shared/bot-alias.mjs +29 -0
- package/src/channels/shared/bot-workspace-store.mjs +2383 -0
- package/src/channels/shared/command-catalog.mjs +107 -0
- package/src/channels/shared/command-permission.mjs +32 -0
- package/src/channels/shared/compact-command.mjs +109 -0
- package/src/channels/shared/config-read-error.mjs +24 -0
- package/src/channels/shared/connection-error.mjs +191 -0
- package/src/channels/shared/connection-test.mjs +58 -0
- package/src/channels/shared/context-enhancement.mjs +372 -0
- package/src/channels/shared/control-command.mjs +111 -0
- package/src/channels/shared/conversation-state-store.mjs +165 -0
- package/src/channels/shared/default-workspace.mjs +31 -0
- package/src/channels/shared/deferred-delivery-coordinator.mjs +241 -0
- package/src/channels/shared/deferred-delivery.mjs +161 -0
- package/src/channels/shared/deferred-state.mjs +53 -0
- package/src/channels/shared/diagnostic-details.mjs +95 -0
- package/src/channels/shared/editable-message-stream.mjs +100 -0
- package/src/channels/shared/exclusive-inbound-consumers.mjs +71 -0
- package/src/channels/shared/file-download.mjs +64 -0
- package/src/channels/shared/harness-approval.mjs +508 -0
- package/src/channels/shared/harness-client.mjs +2143 -0
- package/src/channels/shared/harness-mux.mjs +123 -0
- package/src/channels/shared/harness-question.mjs +95 -0
- package/src/channels/shared/harness-session-binding.mjs +119 -0
- package/src/channels/shared/history-command.mjs +193 -0
- package/src/channels/shared/i18n-en/diagnostics.mjs +55 -0
- package/src/channels/shared/i18n-en/dingtalk.mjs +81 -0
- package/src/channels/shared/i18n-en/discord.mjs +10 -0
- package/src/channels/shared/i18n-en/email.mjs +25 -0
- package/src/channels/shared/i18n-en/feishu.mjs +404 -0
- package/src/channels/shared/i18n-en/image-input.mjs +18 -0
- package/src/channels/shared/i18n-en/matrix.mjs +85 -0
- package/src/channels/shared/i18n-en/office.mjs +23 -0
- package/src/channels/shared/i18n-en/qq.mjs +96 -0
- package/src/channels/shared/i18n-en/shared-a.mjs +241 -0
- package/src/channels/shared/i18n-en/shared-b.mjs +263 -0
- package/src/channels/shared/i18n-en/shared-c.mjs +203 -0
- package/src/channels/shared/i18n-en/slack.mjs +27 -0
- package/src/channels/shared/i18n-en/telegram.mjs +27 -0
- package/src/channels/shared/i18n-en/wecom-app.mjs +33 -0
- package/src/channels/shared/i18n-en/wecom.mjs +62 -0
- package/src/channels/shared/i18n-en/weixin.mjs +88 -0
- package/src/channels/shared/i18n-en/whatsapp.mjs +17 -0
- package/src/channels/shared/i18n-en.mjs +45 -0
- package/src/channels/shared/i18n.mjs +78 -0
- package/src/channels/shared/im-source-guidance.mjs +65 -0
- package/src/channels/shared/image-input-policy.mjs +35 -0
- package/src/channels/shared/image-input-settings-store.mjs +60 -0
- package/src/channels/shared/image-input.mjs +124 -0
- package/src/channels/shared/image-prompt.mjs +360 -0
- package/src/channels/shared/inbound-access.mjs +43 -0
- package/src/channels/shared/inbound-file.mjs +323 -0
- package/src/channels/shared/inbound-ttl-store.mjs +110 -0
- package/src/channels/shared/inbound-ttl.mjs +22 -0
- package/src/channels/shared/injected-context.mjs +362 -0
- package/src/channels/shared/interface-language-store.mjs +127 -0
- package/src/channels/shared/interface-language.mjs +51 -0
- package/src/channels/shared/message-failure.mjs +257 -0
- package/src/channels/shared/model-command.mjs +741 -0
- package/src/channels/shared/model-setting.mjs +145 -0
- package/src/channels/shared/preset-command.mjs +308 -0
- package/src/channels/shared/semantic/artifact-delivery.mjs +177 -0
- package/src/channels/shared/semantic/artifact.mjs +750 -0
- package/src/channels/shared/semantic/delivery.mjs +193 -0
- package/src/channels/shared/semantic/reply-reference.mjs +148 -0
- package/src/channels/shared/session-binding-lock.mjs +40 -0
- package/src/channels/shared/session-channel-labels.mjs +28 -0
- package/src/channels/shared/session-reply-recovery.mjs +104 -0
- package/src/channels/shared/session-sync-registry.mjs +22 -0
- package/src/channels/shared/session-title.mjs +74 -0
- package/src/channels/shared/status-reaction.mjs +107 -0
- package/src/channels/shared/text-harness-bridge.mjs +1623 -0
- package/src/channels/shared/token-bot-controller.mjs +417 -0
- package/src/channels/shared/token-config-store.mjs +208 -0
- package/src/channels/shared/workspace-command.mjs +532 -0
- package/src/channels/shared/workspace-session.mjs +196 -0
- package/src/channels/slack/config-store.mjs +177 -0
- package/src/channels/slack/external-consumer.mjs +80 -0
- package/src/channels/slack/external-files.mjs +90 -0
- package/src/channels/slack/harness-client.mjs +11 -0
- package/src/channels/slack/history-reader.mjs +203 -0
- package/src/channels/slack/manifest.mjs +37 -0
- package/src/channels/slack/slack-api.mjs +636 -0
- package/src/channels/slack/slack-bridge.mjs +20 -0
- package/src/channels/slack/slack-controller.mjs +468 -0
- package/src/channels/slack/slack-runtime.mjs +879 -0
- package/src/channels/slack/state-store.mjs +3 -0
- package/src/channels/telegram/config-store.mjs +89 -0
- package/src/channels/telegram/harness-client.mjs +11 -0
- package/src/channels/telegram/state-store.mjs +3 -0
- package/src/channels/telegram/telegram-api.mjs +486 -0
- package/src/channels/telegram/telegram-bridge.mjs +81 -0
- package/src/channels/telegram/telegram-controller.mjs +52 -0
- package/src/channels/telegram/telegram-http.mjs +21 -0
- package/src/channels/telegram/telegram-rich-message.mjs +149 -0
- package/src/channels/telegram/telegram-runtime.mjs +1471 -0
- package/src/channels/wecom/config-store.mjs +172 -0
- package/src/channels/wecom/harness-client.mjs +11 -0
- package/src/channels/wecom/qr-auth.mjs +95 -0
- package/src/channels/wecom/send-error.mjs +31 -0
- package/src/channels/wecom/state-store.mjs +107 -0
- package/src/channels/wecom/wecom-bridge.mjs +1833 -0
- package/src/channels/wecom/wecom-cards.mjs +101 -0
- package/src/channels/wecom/wecom-controller.mjs +530 -0
- package/src/channels/wecom/wecom-runtime.mjs +269 -0
- package/src/channels/wecom-app/callback-server.mjs +471 -0
- package/src/channels/wecom-app/config-store.mjs +242 -0
- package/src/channels/wecom-app/harness-client.mjs +11 -0
- package/src/channels/wecom-app/state-store.mjs +107 -0
- package/src/channels/wecom-app/wecom-app-api.mjs +432 -0
- package/src/channels/wecom-app/wecom-app-bridge.mjs +1072 -0
- package/src/channels/wecom-app/wecom-app-controller.mjs +453 -0
- package/src/channels/wecom-app/wecom-app-runtime.mjs +222 -0
- package/src/channels/weixin/config-store.mjs +192 -0
- package/src/channels/weixin/connection-error.en.mjs +137 -0
- package/src/channels/weixin/connection-error.mjs +153 -0
- package/src/channels/weixin/diagnostic-details.mjs +1 -0
- package/src/channels/weixin/harness-client.mjs +19 -0
- package/src/channels/weixin/state-store.mjs +291 -0
- package/src/channels/weixin/weixin-api.mjs +949 -0
- package/src/channels/weixin/weixin-bridge.mjs +1537 -0
- package/src/channels/weixin/weixin-controller.mjs +669 -0
- package/src/channels/weixin/weixin-runtime.mjs +416 -0
- package/src/channels/whatsapp/config-store.mjs +210 -0
- package/src/channels/whatsapp/harness-client.mjs +11 -0
- package/src/channels/whatsapp/state-store.mjs +3 -0
- package/src/channels/whatsapp/whatsapp-bridge.mjs +18 -0
- package/src/channels/whatsapp/whatsapp-controller.mjs +470 -0
- package/src/channels/whatsapp/whatsapp-runtime.mjs +917 -0
- package/src/channels/whatsapp/whatsapp-web-session.mjs +214 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { h } from '../../i18n.js';
|
|
4
|
+
import { FEISHU_ENDPOINTS, normalizeBotsSnapshot, unwrapRpcResult } from './api.js';
|
|
5
|
+
import { VoiceEditor } from './voice-editor.js';
|
|
6
|
+
|
|
7
|
+
export function FeishuVoiceSettingsPage({ account, rpcCall }) {
|
|
8
|
+
const [voice, setVoice] = React.useState(null);
|
|
9
|
+
const [phase, setPhase] = React.useState('loading');
|
|
10
|
+
const [error, setError] = React.useState(null);
|
|
11
|
+
const mounted = React.useRef(true);
|
|
12
|
+
|
|
13
|
+
const invoke = React.useCallback(async (endpoint, payload, signal) => {
|
|
14
|
+
if (typeof rpcCall !== 'function') throw new Error('飞书语音设置暂不可用。');
|
|
15
|
+
return unwrapRpcResult(await rpcCall(endpoint, payload, signal));
|
|
16
|
+
}, [rpcCall]);
|
|
17
|
+
|
|
18
|
+
const applySnapshot = React.useCallback((value) => {
|
|
19
|
+
const bot = normalizeBotsSnapshot(value).bots.find((entry) => entry.botId === account.botId);
|
|
20
|
+
if (!bot) throw new Error('未找到当前飞书机器人,请返回列表后重试。');
|
|
21
|
+
if (mounted.current) setVoice(bot.voice);
|
|
22
|
+
}, [account.botId]);
|
|
23
|
+
|
|
24
|
+
const loadSettings = React.useCallback(async (signal) => {
|
|
25
|
+
setPhase('loading');
|
|
26
|
+
setError(null);
|
|
27
|
+
try {
|
|
28
|
+
const value = await invoke(FEISHU_ENDPOINTS.status, {}, signal);
|
|
29
|
+
if (signal?.aborted || !mounted.current) return;
|
|
30
|
+
applySnapshot(value);
|
|
31
|
+
setPhase('ready');
|
|
32
|
+
} catch (cause) {
|
|
33
|
+
if (signal?.aborted || !mounted.current) return;
|
|
34
|
+
setError(cause?.message ?? '飞书语音设置暂不可用。');
|
|
35
|
+
setPhase('error');
|
|
36
|
+
}
|
|
37
|
+
}, [applySnapshot, invoke]);
|
|
38
|
+
|
|
39
|
+
React.useEffect(() => {
|
|
40
|
+
mounted.current = true;
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
void loadSettings(controller.signal);
|
|
43
|
+
return () => {
|
|
44
|
+
mounted.current = false;
|
|
45
|
+
controller.abort();
|
|
46
|
+
};
|
|
47
|
+
}, [loadSettings]);
|
|
48
|
+
|
|
49
|
+
const saveVoice = async (settings) => {
|
|
50
|
+
const value = await invoke(FEISHU_ENDPOINTS.setVoice, {
|
|
51
|
+
botId: account.botId,
|
|
52
|
+
voice: settings === null ? null : { ...voice, ...settings },
|
|
53
|
+
});
|
|
54
|
+
if (mounted.current) applySnapshot(value);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (phase === 'loading') {
|
|
58
|
+
return h('div', { className: 'dim-deliveryState', role: 'status', 'aria-busy': 'true' },
|
|
59
|
+
'正在读取语音设置…');
|
|
60
|
+
}
|
|
61
|
+
if (phase === 'error') {
|
|
62
|
+
return h('div', { className: 'dim-deliveryState', role: 'alert' },
|
|
63
|
+
h('p', null, error),
|
|
64
|
+
h('button', {
|
|
65
|
+
type: 'button',
|
|
66
|
+
className: 'dim-deliveryButton',
|
|
67
|
+
onClick: () => void loadSettings(),
|
|
68
|
+
}, '重新读取'));
|
|
69
|
+
}
|
|
70
|
+
return h(VoiceEditor, { value: voice, onSave: saveVoice });
|
|
71
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TOKEN_BOT_ENDPOINTS, createTokenChannelApi } from '../shared/token-api.js';
|
|
2
|
+
|
|
3
|
+
export const IMESSAGE_RPC_CHANNEL = '/imessage';
|
|
4
|
+
export const IMESSAGE_ENDPOINTS = Object.freeze({
|
|
5
|
+
...TOKEN_BOT_ENDPOINTS,
|
|
6
|
+
bindCredentials: 'bot.bind-native',
|
|
7
|
+
});
|
|
8
|
+
const api = createTokenChannelApi('iMessage', ' macOS Messages 连接');
|
|
9
|
+
export { api as imessageClientApi };
|
|
10
|
+
export const unwrapRpcResult = api.unwrapRpcResult;
|
|
11
|
+
export const normalizeSnapshot = api.normalizeSnapshot;
|
|
12
|
+
export const presentError = api.presentError;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ConnectionError } from '../../connection-error.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { IMessageLogoGlyph } from '../../channel-logos.js';
|
|
4
|
+
import { createTokenChannelSettings } from '../shared/token-channel.js';
|
|
5
|
+
import { IMESSAGE_ENDPOINTS, imessageClientApi } from './api.js';
|
|
6
|
+
import { installIMessageStyles } from './styles.js';
|
|
7
|
+
import { h } from '../../i18n.js';
|
|
8
|
+
|
|
9
|
+
function PermissionPanel({ permissions, busy, error, onSubmit, onCancel }) {
|
|
10
|
+
const databaseReady = permissions?.database === 'granted';
|
|
11
|
+
const automationReady = permissions?.automation === 'granted';
|
|
12
|
+
return h('section', { className: 'ddt-card dim-surfaceCard dim-imessagePermissionPanel' },
|
|
13
|
+
h('h3', null, '启用 macOS 原生 iMessage'),
|
|
14
|
+
h('p', null, '支持同账号自聊:在 iPhone 或 Mac 上给自己已登录的 iMessage 邮箱或号码发指令。AI 回复以 🤖 DSH 开头,不会再次触发机器人。'),
|
|
15
|
+
h('p', null, 'DeepSeek Harness 通过 macOS Messages.app 收发文本消息。首次使用需要授予以下权限:'),
|
|
16
|
+
h('ol', { className: 'dim-imessagePermissionSteps' },
|
|
17
|
+
h('li', null,
|
|
18
|
+
h('strong', null, databaseReady ? '✓ 完全磁盘访问权限已授予' : '1. 授予完全磁盘访问权限'),
|
|
19
|
+
databaseReady ? null : h('p', null, '在“系统设置 → 隐私与安全性 → 完全磁盘访问权限”中,打开运行 DeepSeek Harness 的终端或应用。'),
|
|
20
|
+
databaseReady ? null : h('a', { href: 'x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles' }, '打开完全磁盘访问权限设置')),
|
|
21
|
+
h('li', null,
|
|
22
|
+
h('strong', null, automationReady ? '✓ Messages 自动化权限已授予' : '2. 允许自动化控制 Messages'),
|
|
23
|
+
automationReady ? null : h('p', null, '在“系统设置 → 隐私与安全性 → 自动化”中,允许运行 DeepSeek Harness 的应用控制 Messages。'),
|
|
24
|
+
automationReady ? null : h('a', { href: 'x-apple.systempreferences:com.apple.preference.security?Privacy_Automation' }, '打开自动化设置'))),
|
|
25
|
+
error ? h(ConnectionError, { error: error }) : null,
|
|
26
|
+
h('div', { className: 'ddt-actions dim-viewActions' },
|
|
27
|
+
h('button', { type: 'button', className: 'ddt-button', onClick: onCancel, disabled: busy }, '取消'),
|
|
28
|
+
h('button', { type: 'button', className: 'ddt-button', 'data-kind': 'primary', onClick: () => onSubmit({}), disabled: busy },
|
|
29
|
+
busy ? '正在检查…' : '检查权限并启用')));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const channel = createTokenChannelSettings({
|
|
33
|
+
channel: 'iMessage', endpoints: IMESSAGE_ENDPOINTS, api: imessageClientApi,
|
|
34
|
+
LogoGlyph: IMessageLogoGlyph, installStyles: installIMessageStyles,
|
|
35
|
+
pageClass: 'dim-pageIMessage', avatarClass: 'dim-avatarIMessage',
|
|
36
|
+
connectionLabel: ' macOS Messages 连接',
|
|
37
|
+
tokenPlaceholder: '', emptyTitle: '接入 macOS 原生 iMessage',
|
|
38
|
+
emptyDescription: '无需安装第三方服务;请按指引授予 macOS Messages 访问权限。',
|
|
39
|
+
platformLabel: 'macOS Messages', credentialPayload: () => ({}),
|
|
40
|
+
CredentialPanel: PermissionPanel,
|
|
41
|
+
credentialAriaLabel: '配置 macOS Messages 权限', credentialOpenLabel: '配置本机权限',
|
|
42
|
+
credentialNoun: 'macOS Messages 权限', emptyActionLabel: '配置本机权限',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const IMessageSettingsTab = channel.SettingsTab;
|
|
46
|
+
export const IMessageAccountCard = channel.AccountCard;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const IMESSAGE_STYLE_ID = 'xmanrui-dsh-im-imessage-settings';
|
|
2
|
+
const CSS = String.raw`
|
|
3
|
+
.dim-pageIMessage { --ddt-accent: #32a852; --ddt-accent-deep: #248a40; --ddt-accent-wash: #edf9f0; }
|
|
4
|
+
.dim-avatarIMessage { color: #fff; background: linear-gradient(180deg, #5bf675 0%, #28d944 50%, #0fbd2c 100%); box-shadow: inset 0 1px 1px rgb(255 255 255 / 45%), 0 1px 3px rgb(31 35 41 / 12%); }
|
|
5
|
+
.dim-avatarIMessage svg { display: block; }
|
|
6
|
+
.dim-imessagePermissionPanel { padding: 20px; }
|
|
7
|
+
.dim-imessagePermissionPanel p { color: var(--dsw-alias-label-secondary, #646a73); }
|
|
8
|
+
.dim-imessagePermissionSteps { margin: 16px 0; padding-left: 22px; }
|
|
9
|
+
.dim-imessagePermissionSteps li { margin: 12px 0; }
|
|
10
|
+
.dim-imessagePermissionSteps a { color: var(--ddt-accent-deep); }
|
|
11
|
+
`;
|
|
12
|
+
export function installIMessageStyles() {
|
|
13
|
+
if (typeof document === 'undefined') return () => {};
|
|
14
|
+
const existing = document.querySelector(`style[data-plugin-css="${IMESSAGE_STYLE_ID}"]`);
|
|
15
|
+
if (existing) return () => {};
|
|
16
|
+
const style = document.createElement('style'); style.dataset.plugin = '@xmanrui/dsh-im';
|
|
17
|
+
style.dataset.pluginCss = IMESSAGE_STYLE_ID; style.textContent = CSS; document.head.appendChild(style);
|
|
18
|
+
return () => style.remove();
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TOKEN_BOT_ENDPOINTS, createTokenChannelApi } from '../shared/token-api.js';
|
|
2
|
+
|
|
3
|
+
export const MATRIX_RPC_CHANNEL = '/matrix';
|
|
4
|
+
export const MATRIX_ENDPOINTS = TOKEN_BOT_ENDPOINTS;
|
|
5
|
+
|
|
6
|
+
const api = createTokenChannelApi('Matrix', ' CS API 长轮询');
|
|
7
|
+
|
|
8
|
+
export const unwrapRpcResult = api.unwrapRpcResult;
|
|
9
|
+
export const normalizeSnapshot = api.normalizeSnapshot;
|
|
10
|
+
export const presentError = api.presentError;
|
|
11
|
+
export { api as matrixClientApi };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { MatrixLogoGlyph } from '../../channel-logos.js';
|
|
4
|
+
import { h } from '../../i18n.js';
|
|
5
|
+
import { createTokenChannelSettings } from '../shared/token-channel.js';
|
|
6
|
+
import { MATRIX_ENDPOINTS, matrixClientApi } from './api.js';
|
|
7
|
+
import { installMatrixStyles } from './styles.js';
|
|
8
|
+
|
|
9
|
+
const MATRIX_USER_ID_PATTERN = /^@[^:@\s]+:[^:@\s]+(?::\d{1,5})?$/u;
|
|
10
|
+
|
|
11
|
+
function validHomeserver(value) {
|
|
12
|
+
if (!value || value.length > 2_048) return false;
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(value);
|
|
15
|
+
return (url.protocol === 'https:' || url.protocol === 'http:')
|
|
16
|
+
&& !url.username && !url.password && !url.hash;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function MatrixCredentialPanel({ busy, error, onSubmit, onCancel }) {
|
|
23
|
+
const [homeserver, setHomeserver] = React.useState('');
|
|
24
|
+
const [accessToken, setAccessToken] = React.useState('');
|
|
25
|
+
const [userId, setUserId] = React.useState('');
|
|
26
|
+
const [password, setPassword] = React.useState('');
|
|
27
|
+
const headingId = React.useId();
|
|
28
|
+
|
|
29
|
+
const normalizedHomeserver = homeserver.trim();
|
|
30
|
+
const normalizedUserId = userId.trim();
|
|
31
|
+
const tokenMode = Boolean(accessToken.trim());
|
|
32
|
+
const loginMode = Boolean(normalizedUserId) && Boolean(password);
|
|
33
|
+
const canSubmit = validHomeserver(normalizedHomeserver)
|
|
34
|
+
&& (tokenMode
|
|
35
|
+
? (!normalizedUserId && !password && accessToken.trim().length >= 8)
|
|
36
|
+
: (!accessToken.trim() && MATRIX_USER_ID_PATTERN.test(normalizedUserId) && password.length >= 1));
|
|
37
|
+
|
|
38
|
+
const submit = (event) => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
if (!canSubmit || busy) return;
|
|
41
|
+
void onSubmit?.(tokenMode
|
|
42
|
+
? { homeserver: normalizedHomeserver, accessToken: accessToken.trim() }
|
|
43
|
+
: {
|
|
44
|
+
homeserver: normalizedHomeserver,
|
|
45
|
+
userId: normalizedUserId,
|
|
46
|
+
password,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return h('section', {
|
|
51
|
+
className: 'ddt-card dim-surfaceCard dim-credentialPanel dmt-setup',
|
|
52
|
+
'aria-labelledby': headingId,
|
|
53
|
+
},
|
|
54
|
+
h('h3', { id: headingId, className: 'dim-credentialTitle' }, '接入 Matrix 机器人'),
|
|
55
|
+
h('div', { className: 'dmt-guide' },
|
|
56
|
+
h('div', { className: 'dmt-guideCopy' },
|
|
57
|
+
h('strong', null, '连接你的 Matrix homeserver'),
|
|
58
|
+
h('p', null, '填写 homeserver 地址,并提供访问令牌,或者用户 ID 与密码的组合。机器人只访问该 homeserver,不连接第三方服务器。'))),
|
|
59
|
+
h('form', { className: 'dim-credentialForm dim-credentialFormSingle', onSubmit: submit },
|
|
60
|
+
h('div', { className: 'dmt-fields' },
|
|
61
|
+
h('label', { className: 'dim-credentialField dmt-fieldWide' },
|
|
62
|
+
h('span', null, 'Homeserver 地址'),
|
|
63
|
+
h('input', {
|
|
64
|
+
type: 'url',
|
|
65
|
+
value: homeserver,
|
|
66
|
+
onChange: (event) => setHomeserver(event.target.value),
|
|
67
|
+
placeholder: 'https://matrix.example.org',
|
|
68
|
+
maxLength: 2048,
|
|
69
|
+
autoCapitalize: 'none',
|
|
70
|
+
autoCorrect: 'off',
|
|
71
|
+
spellCheck: false,
|
|
72
|
+
disabled: busy,
|
|
73
|
+
required: true,
|
|
74
|
+
})),
|
|
75
|
+
h('label', { className: 'dim-credentialField dmt-fieldWide' },
|
|
76
|
+
h('span', null, '访问令牌(与用户 ID、密码二选一)'),
|
|
77
|
+
h('input', {
|
|
78
|
+
type: 'password',
|
|
79
|
+
value: accessToken,
|
|
80
|
+
onChange: (event) => setAccessToken(event.target.value),
|
|
81
|
+
placeholder: 'syt_…',
|
|
82
|
+
maxLength: 4096,
|
|
83
|
+
autoCapitalize: 'none',
|
|
84
|
+
autoCorrect: 'off',
|
|
85
|
+
spellCheck: false,
|
|
86
|
+
autoComplete: 'new-password',
|
|
87
|
+
disabled: busy,
|
|
88
|
+
})),
|
|
89
|
+
h('label', { className: 'dim-credentialField' },
|
|
90
|
+
h('span', null, '用户 ID(可选)'),
|
|
91
|
+
h('input', {
|
|
92
|
+
type: 'text',
|
|
93
|
+
value: userId,
|
|
94
|
+
onChange: (event) => setUserId(event.target.value),
|
|
95
|
+
placeholder: '@bot:example.org',
|
|
96
|
+
maxLength: 512,
|
|
97
|
+
autoCapitalize: 'none',
|
|
98
|
+
autoCorrect: 'off',
|
|
99
|
+
spellCheck: false,
|
|
100
|
+
disabled: busy,
|
|
101
|
+
})),
|
|
102
|
+
h('label', { className: 'dim-credentialField' },
|
|
103
|
+
h('span', null, '密码(可选)'),
|
|
104
|
+
h('input', {
|
|
105
|
+
type: 'password',
|
|
106
|
+
value: password,
|
|
107
|
+
onChange: (event) => setPassword(event.target.value),
|
|
108
|
+
maxLength: 1024,
|
|
109
|
+
autoComplete: 'new-password',
|
|
110
|
+
disabled: busy,
|
|
111
|
+
})),
|
|
112
|
+
h('p', { className: 'dmt-tokenHint' }, '访问令牌来自 Element 设置 → 帮助 → 编辑设置,或 homeserver 的登录接口;用户 ID 与密码方式会为本安装派生稳定设备会话。')),
|
|
113
|
+
error ? h('p', { className: 'dim-credentialError', role: 'alert' }, error.message ?? String(error)) : null,
|
|
114
|
+
h('div', { className: 'ddt-actions dim-viewActions dim-credentialActions' },
|
|
115
|
+
h('button', {
|
|
116
|
+
type: 'submit',
|
|
117
|
+
className: 'ddt-button',
|
|
118
|
+
'data-kind': 'primary',
|
|
119
|
+
disabled: busy || !canSubmit,
|
|
120
|
+
}, busy ? '正在验证并连接…' : '验证并连接'),
|
|
121
|
+
h('button', {
|
|
122
|
+
type: 'button',
|
|
123
|
+
className: 'ddt-button',
|
|
124
|
+
onClick: onCancel,
|
|
125
|
+
disabled: busy,
|
|
126
|
+
}, '取消'))));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const channel = createTokenChannelSettings({
|
|
130
|
+
channel: 'Matrix',
|
|
131
|
+
endpoints: MATRIX_ENDPOINTS,
|
|
132
|
+
api: matrixClientApi,
|
|
133
|
+
LogoGlyph: MatrixLogoGlyph,
|
|
134
|
+
installStyles: installMatrixStyles,
|
|
135
|
+
pageClass: 'dmt-page',
|
|
136
|
+
avatarClass: 'dmt-avatar',
|
|
137
|
+
connectionLabel: 'CS API 长轮询',
|
|
138
|
+
emptyTitle: '接入 Matrix 机器人',
|
|
139
|
+
emptyDescription: '填写 homeserver 地址与访问令牌,或者用户 ID 与密码,即可让机器人以 CS API 长轮询接收消息并以富文本回复。',
|
|
140
|
+
platformLabel: 'Matrix homeserver',
|
|
141
|
+
CredentialPanel: MatrixCredentialPanel,
|
|
142
|
+
credentialPayload: ({ homeserver, accessToken, userId, password }) => ({ homeserver, accessToken, userId, password }),
|
|
143
|
+
credentialAriaLabel: '使用 homeserver 与凭据接入 Matrix 机器人',
|
|
144
|
+
credentialOpenLabel: '接入机器人',
|
|
145
|
+
credentialCloseLabel: '收起接入',
|
|
146
|
+
credentialNoun: '访问令牌或用户 ID 与密码',
|
|
147
|
+
emptyActionLabel: '开始接入',
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export const MatrixSettingsTab = channel.SettingsTab;
|
|
151
|
+
export const MatrixAccountCard = channel.AccountCard;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const MATRIX_STYLE_ID = 'xmanrui-dsh-im-matrix-settings';
|
|
2
|
+
|
|
3
|
+
const CSS = String.raw`
|
|
4
|
+
.dmt-page { --ddt-accent: #1a8f6f; --ddt-accent-deep: #12654f; --ddt-accent-wash: #eef8f4; }
|
|
5
|
+
.dmt-avatar { background: linear-gradient(145deg, #fff, #f6faf8); border: 1px solid #e2eae7; }
|
|
6
|
+
.dmt-avatar svg { display: block; }
|
|
7
|
+
.dim-logoMatrix { color: white; background: #0dbd8b; }
|
|
8
|
+
.dim-logoMatrix svg { width: 22px; height: 22px; }
|
|
9
|
+
.dmt-setup { display: grid; gap: 18px; }
|
|
10
|
+
.dmt-guide { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 18px; padding: 16px; border: 1px solid color-mix(in srgb, #1a8f6f 18%, var(--dsw-alias-border-l2, #e5e6eb)); border-radius: 11px; background: color-mix(in srgb, #1a8f6f 4%, var(--dsw-alias-bg-layer-1, #fff)); }
|
|
11
|
+
.dmt-guideCopy { min-width: 0; }
|
|
12
|
+
.dmt-guideCopy strong { display: block; margin-bottom: 5px; color: var(--dsw-alias-label-primary, #1f2329); font-size: 13px; }
|
|
13
|
+
.dmt-guideCopy p { margin: 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 1.6; }
|
|
14
|
+
.dmt-guideActions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
|
|
15
|
+
.dmt-guideActions .ddt-button { white-space: nowrap; }
|
|
16
|
+
.dmt-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
|
17
|
+
.dmt-fields .dmt-fieldWide { grid-column: 1 / -1; }
|
|
18
|
+
.dmt-tokenHint { grid-column: 1 / -1; margin: -4px 0 0; color: var(--dsw-alias-label-tertiary, #8f959e); font-size: 11px; line-height: 1.55; }
|
|
19
|
+
@container (max-width: 680px) {
|
|
20
|
+
.dmt-guide { grid-template-columns: minmax(0, 1fr); }
|
|
21
|
+
.dmt-guideActions { justify-content: flex-start; }
|
|
22
|
+
.dmt-fields { grid-template-columns: minmax(0, 1fr); }
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export function installMatrixStyles() {
|
|
27
|
+
if (typeof document === 'undefined') return () => {};
|
|
28
|
+
const existing = document.querySelector(`style[data-plugin-css="${MATRIX_STYLE_ID}"]`);
|
|
29
|
+
if (existing) return () => {};
|
|
30
|
+
const style = document.createElement('style');
|
|
31
|
+
style.dataset.plugin = '@xmanrui/dsh-im';
|
|
32
|
+
style.dataset.pluginCss = MATRIX_STYLE_ID;
|
|
33
|
+
style.textContent = CSS;
|
|
34
|
+
document.head.appendChild(style);
|
|
35
|
+
return () => style.remove();
|
|
36
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { diagnosticFields } from '../../../../src/channels/shared/diagnostic-details.mjs';
|
|
2
|
+
import {
|
|
3
|
+
OFFICE_PROTOCOL_VERSION,
|
|
4
|
+
OFFICE_RPC_CHANNEL,
|
|
5
|
+
OFFICE_RPC_ENDPOINTS,
|
|
6
|
+
officeHookUrls,
|
|
7
|
+
} from '../../../../src/channels/office/protocol.mjs';
|
|
8
|
+
|
|
9
|
+
function record(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
|
|
10
|
+
|
|
11
|
+
export function unwrapOfficeRpc(result) {
|
|
12
|
+
if (!record(result) || typeof result.ok !== 'boolean') throw new Error('AI Office 服务返回了无法识别的响应');
|
|
13
|
+
if (!result.ok) {
|
|
14
|
+
const error = new Error(typeof result.error?.message === 'string' ? result.error.message : 'AI Office 操作失败');
|
|
15
|
+
error.code = typeof result.error?.code === 'string' ? result.error.code : 'office-rpc-error';
|
|
16
|
+
Object.assign(error, diagnosticFields(result.error));
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
return result.value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function normalizeOfficeStatus(value) {
|
|
23
|
+
if (!record(value) || value.configured !== true) {
|
|
24
|
+
return { configured: false, connected: false, state: 'unconfigured', config: null, health: null };
|
|
25
|
+
}
|
|
26
|
+
const config = record(value.config) ? value.config : {};
|
|
27
|
+
return {
|
|
28
|
+
configured: true,
|
|
29
|
+
connected: value.connected === true,
|
|
30
|
+
state: typeof value.state === 'string' ? value.state : 'idle',
|
|
31
|
+
tokenConfigured: value.tokenConfigured === true,
|
|
32
|
+
config: {
|
|
33
|
+
protocolVersion: config.protocolVersion ?? OFFICE_PROTOCOL_VERSION,
|
|
34
|
+
baseUrl: typeof config.baseUrl === 'string' ? config.baseUrl : '',
|
|
35
|
+
deviceId: typeof config.deviceId === 'string' ? config.deviceId : '',
|
|
36
|
+
maxConcurrency: Number(config.maxConcurrency ?? 1),
|
|
37
|
+
heartbeatSeconds: Number(config.heartbeatSeconds ?? 30),
|
|
38
|
+
workspaces: record(config.workspaces) ? config.workspaces : {},
|
|
39
|
+
instructionPresets: record(config.instructionPresets) ? config.instructionPresets : {},
|
|
40
|
+
hooks: record(config.hooks) ? config.hooks : {},
|
|
41
|
+
},
|
|
42
|
+
health: record(value.health) ? value.health : null,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { OFFICE_PROTOCOL_VERSION, OFFICE_RPC_CHANNEL, OFFICE_RPC_ENDPOINTS, officeHookUrls };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { ConnectionError } from '../../connection-error.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { h } from '../../i18n.js';
|
|
5
|
+
import {
|
|
6
|
+
OFFICE_PROTOCOL_VERSION,
|
|
7
|
+
OFFICE_RPC_ENDPOINTS,
|
|
8
|
+
normalizeOfficeStatus,
|
|
9
|
+
officeHookUrls,
|
|
10
|
+
unwrapOfficeRpc,
|
|
11
|
+
} from './api.js';
|
|
12
|
+
|
|
13
|
+
function Button({ children, kind = 'secondary', ...props }) {
|
|
14
|
+
return h('button', { ...props, type: 'button', className: 'ddt-button', 'data-kind': kind }, children);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function mapText(value) {
|
|
18
|
+
return Object.entries(value ?? {}).map(([key, item]) => `${key}=${item}`).join('\n');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function parseMap(value, label) {
|
|
22
|
+
const output = {};
|
|
23
|
+
for (const raw of value.split(/\r?\n/)) {
|
|
24
|
+
const line = raw.trim();
|
|
25
|
+
if (!line) continue;
|
|
26
|
+
const index = line.indexOf('=');
|
|
27
|
+
if (index < 1 || !line.slice(index + 1).trim()) {
|
|
28
|
+
throw new Error(label === 'Workspace 映射'
|
|
29
|
+
? 'Workspace 映射每行必须使用 alias=value'
|
|
30
|
+
: 'Instruction Preset 映射每行必须使用 alias=value');
|
|
31
|
+
}
|
|
32
|
+
output[line.slice(0, index).trim()] = line.slice(index + 1).trim();
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stateLabel(model) {
|
|
38
|
+
if (model.connected) return '已连接 Office';
|
|
39
|
+
if (!model.configured) return '尚未配置';
|
|
40
|
+
if (model.state === 'connecting') return '正在连接';
|
|
41
|
+
if (model.state === 'reconnecting') return '等待重连';
|
|
42
|
+
if (model.state === 'missing-token') return '凭据缺失';
|
|
43
|
+
return '已配置';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function OfficeSettingsTab({ rpcCall, initialStatus }) {
|
|
47
|
+
const [model, setModel] = React.useState(normalizeOfficeStatus(initialStatus));
|
|
48
|
+
const [phase, setPhase] = React.useState(initialStatus === undefined ? 'loading' : 'ready');
|
|
49
|
+
const [busy, setBusy] = React.useState('');
|
|
50
|
+
const [error, setError] = React.useState('');
|
|
51
|
+
const [notice, setNotice] = React.useState('');
|
|
52
|
+
const [form, setForm] = React.useState({
|
|
53
|
+
baseUrl: '', deviceId: 'local-harness', deviceToken: '',
|
|
54
|
+
maxConcurrency: '1', heartbeatSeconds: '30', workspaces: '', instructionPresets: '',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const invoke = React.useCallback(async (endpoint, payload = {}) => {
|
|
58
|
+
if (typeof rpcCall !== 'function') throw new Error('AI Office 设置页缺少 RPC 连接');
|
|
59
|
+
return unwrapOfficeRpc(await rpcCall(endpoint, payload));
|
|
60
|
+
}, [rpcCall]);
|
|
61
|
+
|
|
62
|
+
const adopt = React.useCallback((value) => {
|
|
63
|
+
const next = normalizeOfficeStatus(value?.snapshot ?? value);
|
|
64
|
+
setModel(next);
|
|
65
|
+
if (next.config) setForm((current) => ({
|
|
66
|
+
...current,
|
|
67
|
+
baseUrl: next.config.baseUrl,
|
|
68
|
+
deviceId: next.config.deviceId,
|
|
69
|
+
maxConcurrency: String(next.config.maxConcurrency),
|
|
70
|
+
heartbeatSeconds: String(next.config.heartbeatSeconds),
|
|
71
|
+
workspaces: mapText(next.config.workspaces),
|
|
72
|
+
instructionPresets: mapText(next.config.instructionPresets),
|
|
73
|
+
deviceToken: '',
|
|
74
|
+
}));
|
|
75
|
+
return next;
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const load = React.useCallback(async () => {
|
|
79
|
+
try { adopt(await invoke(OFFICE_RPC_ENDPOINTS.status)); setPhase('ready'); setError(''); }
|
|
80
|
+
catch (caught) { setPhase('error'); setError(caught); }
|
|
81
|
+
}, [adopt, invoke]);
|
|
82
|
+
|
|
83
|
+
React.useEffect(() => { void load(); }, [load]);
|
|
84
|
+
|
|
85
|
+
const run = async (name, operation) => {
|
|
86
|
+
setBusy(name); setError(''); setNotice('');
|
|
87
|
+
try { const value = await operation(); adopt(value); if (value?.warnings?.length) setError(value.warnings[0]); setNotice(name === 'test' ? '连接测试通过。' : '配置已保存。'); }
|
|
88
|
+
catch (caught) { setError(caught); }
|
|
89
|
+
finally { setBusy(''); }
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const hooks = React.useMemo(() => {
|
|
93
|
+
try { return officeHookUrls(form.baseUrl); } catch { return {}; }
|
|
94
|
+
}, [form.baseUrl]);
|
|
95
|
+
const health = model.health ?? {};
|
|
96
|
+
|
|
97
|
+
if (phase === 'loading') return h('div', { className: 'ddt-card ddt-loading', 'aria-busy': 'true' }, '正在读取 AI Office Connector…');
|
|
98
|
+
|
|
99
|
+
return h('section', { className: 'dof-page', 'aria-label': 'AI Office 设置' },
|
|
100
|
+
h('div', { className: 'dof-hero' },
|
|
101
|
+
h('div', { className: 'dof-heroCopy' },
|
|
102
|
+
h('h3', null, 'AI Office Connector'),
|
|
103
|
+
h('p', null, '本机主动连接公网 Office;Harness 不开放端口。协议 Hook 固定为 ', OFFICE_PROTOCOL_VERSION, '。')),
|
|
104
|
+
h('span', { className: 'dof-status', 'data-connected': String(model.connected) },
|
|
105
|
+
h('span', { className: 'dof-dot' }), stateLabel(model))),
|
|
106
|
+
model.configured ? h('div', { className: 'dof-metrics' },
|
|
107
|
+
h('div', { className: 'dof-metric' }, h('span', null, '最近心跳'), h('strong', null, health.lastHeartbeatAt ?? '尚无')),
|
|
108
|
+
h('div', { className: 'dof-metric' }, h('span', null, '最近事件'), h('strong', null, health.lastEventType ?? '尚无')),
|
|
109
|
+
h('div', { className: 'dof-metric' }, h('span', null, '重连次数'), h('strong', null, String(health.reconnects ?? 0))),
|
|
110
|
+
h('div', { className: 'dof-metric' }, h('span', null, 'Job Offer'), h('strong', null, String(health.jobsOffered ?? 0))),
|
|
111
|
+
h('div', { className: 'dof-metric' }, h('span', null, '运行 Job'), h('strong', null, String(health.jobs?.running ?? 0))),
|
|
112
|
+
h('div', { className: 'dof-metric' }, h('span', null, '完成 Job'), h('strong', null, String(health.jobs?.completed ?? 0)))) : null,
|
|
113
|
+
h('div', { className: 'dof-card' },
|
|
114
|
+
h('div', { className: 'dof-cardTitle' }, h('h4', null, '设备连接'), h('span', null, 'Token 只写入本机凭据存储')),
|
|
115
|
+
h('div', { className: 'dof-grid' },
|
|
116
|
+
h('label', { className: 'dof-field', 'data-wide': 'true' }, 'Office Base URL',
|
|
117
|
+
h('input', { value: form.baseUrl, placeholder: 'https://office.example.com', onChange: (event) => setForm({ ...form, baseUrl: event.target.value }) })),
|
|
118
|
+
h('label', { className: 'dof-field' }, 'Device ID',
|
|
119
|
+
h('input', { value: form.deviceId, placeholder: 'local-harness', onChange: (event) => setForm({ ...form, deviceId: event.target.value }) })),
|
|
120
|
+
h('label', { className: 'dof-field' }, 'Device Token',
|
|
121
|
+
h('input', { type: 'password', value: form.deviceToken, placeholder: model.tokenConfigured ? '已安全保存;留空保持不变' : '粘贴 Office 一次性凭据', autoComplete: 'new-password', onChange: (event) => setForm({ ...form, deviceToken: event.target.value }) })),
|
|
122
|
+
h('label', { className: 'dof-field' }, '最大并发',
|
|
123
|
+
h('input', { type: 'number', min: 1, max: 4, value: form.maxConcurrency, onChange: (event) => setForm({ ...form, maxConcurrency: event.target.value }) })),
|
|
124
|
+
h('label', { className: 'dof-field' }, 'Heartbeat 秒数',
|
|
125
|
+
h('input', { type: 'number', min: 10, max: 300, value: form.heartbeatSeconds, onChange: (event) => setForm({ ...form, heartbeatSeconds: event.target.value }) })),
|
|
126
|
+
h('label', { className: 'dof-field', 'data-wide': 'true' }, 'Workspace 映射',
|
|
127
|
+
h('textarea', { value: form.workspaces, placeholder: 'office-project=/Users/you/projects/ai-office', onChange: (event) => setForm({ ...form, workspaces: event.target.value }) }),
|
|
128
|
+
h('small', null, '每行 alias=/本机/绝对路径;Office 只能看到 alias。')),
|
|
129
|
+
h('label', { className: 'dof-field', 'data-wide': 'true' }, 'Instruction Preset 映射',
|
|
130
|
+
h('textarea', { value: form.instructionPresets, placeholder: 'action-items=转换为负责人、截止和验收明确的工单', onChange: (event) => setForm({ ...form, instructionPresets: event.target.value }) }),
|
|
131
|
+
h('small', null, '每行 alias=指令;新增 preset 不需要改 Office 代码。'))),
|
|
132
|
+
error ? h(ConnectionError, { error }) : null,
|
|
133
|
+
notice ? h('p', { className: 'dof-notice', role: 'status' }, notice) : null,
|
|
134
|
+
health.error?.message ? h(ConnectionError, { error: health.error }) : null,
|
|
135
|
+
h('div', { className: 'dof-actions' },
|
|
136
|
+
h(Button, { kind: 'primary', disabled: Boolean(busy), onClick: () => void run('save', () => invoke(OFFICE_RPC_ENDPOINTS.configure, {
|
|
137
|
+
baseUrl: form.baseUrl,
|
|
138
|
+
deviceId: form.deviceId,
|
|
139
|
+
...(form.deviceToken ? { deviceToken: form.deviceToken } : {}),
|
|
140
|
+
maxConcurrency: Number(form.maxConcurrency),
|
|
141
|
+
heartbeatSeconds: Number(form.heartbeatSeconds),
|
|
142
|
+
workspaces: parseMap(form.workspaces, 'Workspace 映射'),
|
|
143
|
+
instructionPresets: parseMap(form.instructionPresets, 'Instruction Preset 映射'),
|
|
144
|
+
})) }, busy === 'save' ? '保存中…' : '保存并连接'),
|
|
145
|
+
h(Button, { disabled: !model.configured || Boolean(busy), onClick: () => void run('test', () => invoke(OFFICE_RPC_ENDPOINTS.test)) }, busy === 'test' ? '测试中…' : '测试连接'),
|
|
146
|
+
h(Button, { disabled: !model.configured || Boolean(busy), onClick: () => void run('reconnect', () => invoke(OFFICE_RPC_ENDPOINTS.reconnect)) }, '重新连接'),
|
|
147
|
+
h(Button, { kind: 'danger', disabled: !model.configured || Boolean(busy), onClick: () => void run('remove', () => invoke(OFFICE_RPC_ENDPOINTS.remove, { confirm: true })) }, '移除连接'))),
|
|
148
|
+
h('div', { className: 'dof-card' },
|
|
149
|
+
h('div', { className: 'dof-cardTitle' }, h('h4', null, '协议 Hook 预览'), h('span', null, '由 Base URL 自动派生,不单独填写')),
|
|
150
|
+
h('div', { className: 'dof-hooks' },
|
|
151
|
+
[['SSE', hooks.stream], ['Heartbeat', hooks.heartbeat], ['Job', hooks.job], ['Result', hooks.result]].map(([label, url]) => h('div', { className: 'dof-hook', key: label }, h('strong', null, label), h('code', null, url ?? 'Base URL 无效'))))),
|
|
152
|
+
h('p', { className: 'dof-notice' }, 'Office Hook 尚未部署时,配置会安全保存并自动重试;出现 HTTP 404 代表协议端点待上线,不代表 Harness 故障。'));
|
|
153
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const OFFICE_STYLE_ID = 'xmanrui-dsh-im-office-settings';
|
|
2
|
+
|
|
3
|
+
const CSS = `
|
|
4
|
+
.dof-page { --dof-accent: var(--dsw-alias-brand-primary, #3964fe); }
|
|
5
|
+
.dof-hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-bottom: 12px; padding: 18px; border: 1px solid var(--dsw-alias-border-l2, #e5e6eb); border-radius: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--dof-accent) 9%, var(--dsw-alias-bg-layer-1, #fff)), var(--dsw-alias-bg-layer-1, #fff) 62%); }
|
|
6
|
+
.dof-hero::after { content: ""; position: absolute; width: 150px; height: 150px; right: -75px; top: -90px; border: 24px solid color-mix(in srgb, var(--dof-accent) 12%, transparent); border-radius: 50%; pointer-events: none; }
|
|
7
|
+
.dof-heroCopy { min-width: 0; }
|
|
8
|
+
.dof-heroCopy h3 { margin: 0; color: var(--dsw-alias-label-primary, #1f2329); font-size: 17px; line-height: 1.35; }
|
|
9
|
+
.dof-heroCopy p { margin: 6px 0 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 1.6; }
|
|
10
|
+
.dof-status { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--dsw-alias-border-l2, #e5e6eb); border-radius: 999px; background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; white-space: nowrap; }
|
|
11
|
+
.dof-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dsw-alias-state-warn-primary, #d97706); }
|
|
12
|
+
.dof-status[data-connected="true"] .dof-dot { background: var(--dsw-alias-state-success-primary, #20a162); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-state-success-primary, #20a162) 14%, transparent); }
|
|
13
|
+
.dof-card { margin-top: 10px; padding: 16px; border: 1px solid var(--dsw-alias-border-l2, #e5e6eb); border-radius: 14px; background: var(--dsw-alias-bg-layer-1, #fff); }
|
|
14
|
+
.dof-cardTitle { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 12px; }
|
|
15
|
+
.dof-cardTitle h4 { margin: 0; color: var(--dsw-alias-label-primary, #1f2329); font-size: 14px; }
|
|
16
|
+
.dof-cardTitle span { color: var(--dsw-alias-label-tertiary, #8f959e); font-size: 11px; }
|
|
17
|
+
.dof-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
|
18
|
+
.dof-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; }
|
|
19
|
+
.dof-field[data-wide="true"] { grid-column: 1 / -1; }
|
|
20
|
+
.dof-field input, .dof-field textarea { box-sizing: border-box; width: 100%; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 9px; background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1f2329); font: inherit; font-size: 13px; line-height: 1.5; outline: none; }
|
|
21
|
+
.dof-field input { height: 38px; padding: 0 11px; }
|
|
22
|
+
.dof-field textarea { min-height: 86px; resize: vertical; padding: 9px 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
23
|
+
.dof-field input:focus, .dof-field textarea:focus { border-color: var(--dof-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dof-accent) 12%, transparent); }
|
|
24
|
+
.dof-field small { color: var(--dsw-alias-label-tertiary, #8f959e); line-height: 1.45; }
|
|
25
|
+
.dof-hooks { display: grid; gap: 7px; }
|
|
26
|
+
.dof-hook { min-width: 0; display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 10px; border-radius: 9px; background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
|
27
|
+
.dof-hook strong { color: var(--dsw-alias-label-secondary, #646a73); font-size: 11px; }
|
|
28
|
+
.dof-hook code { overflow: hidden; color: var(--dsw-alias-label-primary, #1f2329); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
|
|
29
|
+
.dof-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
|
|
30
|
+
.dof-actions .ddt-button[data-kind="primary"] { color: #fff; border-color: var(--dof-accent); background: var(--dof-accent); }
|
|
31
|
+
.dof-error, .dof-notice { margin: 10px 0 0; padding: 9px 11px; border-radius: 9px; font-size: 12px; line-height: 1.5; }
|
|
32
|
+
.dof-error { color: var(--dsw-alias-state-error-primary, #d54941); background: var(--dsw-alias-state-error-secondary, #fff0ef); }
|
|
33
|
+
.dof-notice { color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
|
34
|
+
.dof-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
|
|
35
|
+
.dof-metric { min-width: 0; padding: 9px; border-radius: 10px; background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
|
36
|
+
.dof-metric span { display: block; color: var(--dsw-alias-label-tertiary, #8f959e); font-size: 10px; }
|
|
37
|
+
.dof-metric strong { display: block; overflow: hidden; margin-top: 4px; color: var(--dsw-alias-label-primary, #1f2329); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
|
38
|
+
@container (max-width: 680px) { .dof-grid { grid-template-columns: minmax(0, 1fr); } .dof-field[data-wide="true"] { grid-column: auto; } .dof-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
39
|
+
@media (prefers-reduced-motion: reduce) { .dof-page * { transition: none !important; } }
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export function installOfficeStyles() {
|
|
43
|
+
if (typeof document === 'undefined') return () => {};
|
|
44
|
+
if (document.querySelector(`style[data-plugin-css="${OFFICE_STYLE_ID}"]`)) return () => {};
|
|
45
|
+
const style = document.createElement('style');
|
|
46
|
+
style.dataset.pluginCss = OFFICE_STYLE_ID;
|
|
47
|
+
style.textContent = CSS;
|
|
48
|
+
document.head.append(style);
|
|
49
|
+
return () => style.remove();
|
|
50
|
+
}
|