@openclaw/discord 2026.3.13 → 2026.5.2-beta.1
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/account-inspect-api.ts +6 -0
- package/action-runtime-api.ts +1 -0
- package/api.ts +132 -0
- package/channel-config-api.ts +1 -0
- package/channel-plugin-api.ts +3 -0
- package/config-api.ts +4 -0
- package/configured-state.ts +6 -0
- package/contract-api.ts +21 -0
- package/directory-contract-api.ts +4 -0
- package/doctor-contract-api.ts +1 -0
- package/index.test.ts +13 -0
- package/index.ts +18 -13
- package/openclaw.plugin.json +3326 -1
- package/package.json +68 -2
- package/runtime-api.actions.ts +15 -0
- package/runtime-api.lookup.ts +22 -0
- package/runtime-api.monitor.ts +50 -0
- package/runtime-api.send.ts +79 -0
- package/runtime-api.threads.ts +30 -0
- package/runtime-api.ts +180 -0
- package/runtime-setter-api.ts +3 -0
- package/secret-contract-api.ts +4 -0
- package/security-audit-contract-api.ts +1 -0
- package/security-contract-api.ts +4 -0
- package/session-key-api.ts +1 -0
- package/setup-entry.ts +9 -0
- package/setup-plugin-api.ts +3 -0
- package/src/account-inspect.test.ts +126 -0
- package/src/account-inspect.ts +132 -0
- package/src/accounts.test.ts +247 -0
- package/src/accounts.ts +196 -0
- package/src/actions/handle-action.guild-admin.ts +411 -0
- package/src/actions/handle-action.test.ts +306 -0
- package/src/actions/handle-action.ts +372 -0
- package/src/actions/runtime.guild.ts +446 -0
- package/src/actions/runtime.messaging.messages.ts +205 -0
- package/src/actions/runtime.messaging.reactions.ts +67 -0
- package/src/actions/runtime.messaging.runtime.ts +69 -0
- package/src/actions/runtime.messaging.send.ts +248 -0
- package/src/actions/runtime.messaging.shared.ts +97 -0
- package/src/actions/runtime.messaging.ts +37 -0
- package/src/actions/runtime.moderation-shared.ts +48 -0
- package/src/actions/runtime.moderation.authz.test.ts +151 -0
- package/src/actions/runtime.moderation.ts +116 -0
- package/src/actions/runtime.presence.test.ts +160 -0
- package/src/actions/runtime.presence.ts +117 -0
- package/src/actions/runtime.shared.ts +83 -0
- package/src/actions/runtime.test.ts +1087 -0
- package/src/actions/runtime.ts +87 -0
- package/src/api-barrel.test.ts +80 -0
- package/src/api.test.ts +130 -0
- package/src/api.ts +169 -0
- package/src/approval-handler.runtime.test.ts +41 -0
- package/src/approval-handler.runtime.ts +632 -0
- package/src/approval-native.test.ts +330 -0
- package/src/approval-native.ts +219 -0
- package/src/approval-runtime.ts +14 -0
- package/src/approval-shared.ts +53 -0
- package/src/audit-core.ts +141 -0
- package/src/audit.test.ts +145 -0
- package/src/audit.ts +32 -0
- package/src/channel-actions.contract.test.ts +45 -0
- package/src/channel-actions.runtime.ts +1 -0
- package/src/channel-actions.test.ts +275 -0
- package/src/channel-actions.ts +203 -0
- package/src/channel-api.ts +29 -0
- package/src/channel.conversation.ts +159 -0
- package/src/channel.loaders.ts +47 -0
- package/src/channel.runtime.ts +1 -0
- package/src/channel.setup.ts +12 -0
- package/src/channel.test.ts +547 -12
- package/src/channel.ts +597 -430
- package/src/chunk.test.ts +157 -0
- package/src/chunk.ts +321 -0
- package/src/client.proxy.test.ts +176 -0
- package/src/client.test.ts +76 -0
- package/src/client.ts +132 -0
- package/src/component-custom-id.ts +72 -0
- package/src/components-registry.ts +356 -0
- package/src/components.builders.ts +409 -0
- package/src/components.modal.ts +124 -0
- package/src/components.parse.ts +407 -0
- package/src/components.test.ts +312 -0
- package/src/components.ts +54 -0
- package/src/components.types.ts +187 -0
- package/src/config-schema.test.ts +325 -0
- package/src/config-schema.ts +6 -0
- package/src/config-ui-hints.ts +249 -0
- package/src/conversation-identity.ts +58 -0
- package/src/delivery-retry.ts +56 -0
- package/src/directory-cache.ts +116 -0
- package/src/directory-config.ts +58 -0
- package/src/directory-contract.test.ts +129 -0
- package/src/directory-live.test.ts +126 -0
- package/src/directory-live.ts +135 -0
- package/src/doctor-contract.ts +477 -0
- package/src/doctor-shared.ts +5 -0
- package/src/doctor.test.ts +405 -0
- package/src/doctor.ts +340 -0
- package/src/draft-chunking.test.ts +64 -0
- package/src/draft-chunking.ts +43 -0
- package/src/draft-stream.test.ts +159 -0
- package/src/draft-stream.ts +154 -0
- package/src/error-body.ts +38 -0
- package/src/exec-approvals.test.ts +88 -0
- package/src/exec-approvals.ts +110 -0
- package/src/gateway-logging.test.ts +98 -0
- package/src/gateway-logging.ts +67 -0
- package/src/group-policy.ts +113 -0
- package/src/guilds.ts +29 -0
- package/src/inbound-context.contract.test.ts +11 -0
- package/src/interactive-dispatch.ts +104 -0
- package/src/internal/api.commands.ts +51 -0
- package/src/internal/api.guild.ts +164 -0
- package/src/internal/api.interactions.ts +53 -0
- package/src/internal/api.messages.ts +113 -0
- package/src/internal/api.reactions.ts +38 -0
- package/src/internal/api.test.ts +262 -0
- package/src/internal/api.ts +61 -0
- package/src/internal/api.users.ts +19 -0
- package/src/internal/api.webhooks.ts +13 -0
- package/src/internal/client.test.ts +408 -0
- package/src/internal/client.ts +308 -0
- package/src/internal/command-deploy.ts +237 -0
- package/src/internal/commands.ts +188 -0
- package/src/internal/components.base.ts +65 -0
- package/src/internal/components.message.ts +279 -0
- package/src/internal/components.modal.ts +95 -0
- package/src/internal/components.ts +31 -0
- package/src/internal/discord.ts +11 -0
- package/src/internal/embeds.ts +35 -0
- package/src/internal/entity-cache.ts +98 -0
- package/src/internal/event-queue.ts +162 -0
- package/src/internal/gateway-close-codes.ts +25 -0
- package/src/internal/gateway-dispatch.ts +96 -0
- package/src/internal/gateway-identify-limiter.ts +26 -0
- package/src/internal/gateway-lifecycle.ts +61 -0
- package/src/internal/gateway-rate-limit.ts +104 -0
- package/src/internal/gateway.test.ts +603 -0
- package/src/internal/gateway.ts +476 -0
- package/src/internal/interaction-dispatch.test.ts +148 -0
- package/src/internal/interaction-dispatch.ts +162 -0
- package/src/internal/interaction-options.ts +98 -0
- package/src/internal/interaction-response.ts +53 -0
- package/src/internal/interactions.test.ts +325 -0
- package/src/internal/interactions.ts +378 -0
- package/src/internal/listeners.ts +85 -0
- package/src/internal/live-smoke.live.test.ts +26 -0
- package/src/internal/modal-fields.ts +95 -0
- package/src/internal/payload.ts +69 -0
- package/src/internal/rest-body.ts +115 -0
- package/src/internal/rest-errors.ts +88 -0
- package/src/internal/rest-routes.ts +50 -0
- package/src/internal/rest-scheduler.ts +557 -0
- package/src/internal/rest.test.ts +673 -0
- package/src/internal/rest.ts +322 -0
- package/src/internal/schemas.ts +36 -0
- package/src/internal/structures.test.ts +43 -0
- package/src/internal/structures.ts +280 -0
- package/src/internal/test-builders.test-support.ts +163 -0
- package/src/internal/voice.ts +49 -0
- package/src/media-detection.ts +28 -0
- package/src/mentions.test.ts +111 -0
- package/src/mentions.ts +147 -0
- package/src/monitor/access-groups.ts +55 -0
- package/src/monitor/ack-reactions.ts +70 -0
- package/src/monitor/acp-bind-here.integration.test.ts +211 -0
- package/src/monitor/agent-components-auth.ts +7 -0
- package/src/monitor/agent-components-context.ts +154 -0
- package/src/monitor/agent-components-data.ts +224 -0
- package/src/monitor/agent-components-dm-auth.ts +221 -0
- package/src/monitor/agent-components-guild-auth.ts +322 -0
- package/src/monitor/agent-components-helpers.runtime.ts +5 -0
- package/src/monitor/agent-components-helpers.ts +34 -0
- package/src/monitor/agent-components-reply.ts +10 -0
- package/src/monitor/agent-components.deps.runtime.ts +2 -0
- package/src/monitor/agent-components.dispatch.ts +366 -0
- package/src/monitor/agent-components.handlers.ts +303 -0
- package/src/monitor/agent-components.modal.ts +160 -0
- package/src/monitor/agent-components.plugin-interactive.ts +187 -0
- package/src/monitor/agent-components.runtime.ts +14 -0
- package/src/monitor/agent-components.system-controls.ts +211 -0
- package/src/monitor/agent-components.ts +70 -0
- package/src/monitor/agent-components.types.ts +58 -0
- package/src/monitor/agent-components.wildcard-controls.ts +168 -0
- package/src/monitor/agent-components.wildcard.test.ts +71 -0
- package/src/monitor/allow-list.test.ts +14 -0
- package/src/monitor/allow-list.ts +633 -0
- package/src/monitor/auto-presence.test.ts +156 -0
- package/src/monitor/auto-presence.ts +356 -0
- package/src/monitor/channel-access.test.ts +99 -0
- package/src/monitor/channel-access.ts +102 -0
- package/src/monitor/commands.test.ts +24 -0
- package/src/monitor/commands.ts +9 -0
- package/src/monitor/dm-command-auth.test.ts +197 -0
- package/src/monitor/dm-command-auth.ts +158 -0
- package/src/monitor/dm-command-decision.test.ts +113 -0
- package/src/monitor/dm-command-decision.ts +49 -0
- package/src/monitor/exec-approvals.test.ts +226 -0
- package/src/monitor/exec-approvals.ts +158 -0
- package/src/monitor/format.ts +45 -0
- package/src/monitor/gateway-handle.ts +34 -0
- package/src/monitor/gateway-metadata.test.ts +29 -0
- package/src/monitor/gateway-metadata.ts +298 -0
- package/src/monitor/gateway-plugin.test.ts +297 -0
- package/src/monitor/gateway-plugin.ts +294 -0
- package/src/monitor/gateway-registry.ts +37 -0
- package/src/monitor/gateway-supervisor.test.ts +150 -0
- package/src/monitor/gateway-supervisor.ts +206 -0
- package/src/monitor/inbound-context.test-helpers.ts +37 -0
- package/src/monitor/inbound-context.test.ts +106 -0
- package/src/monitor/inbound-context.ts +103 -0
- package/src/monitor/inbound-dedupe.ts +79 -0
- package/src/monitor/inbound-job.test.ts +203 -0
- package/src/monitor/inbound-job.ts +118 -0
- package/src/monitor/listeners.queue.ts +91 -0
- package/src/monitor/listeners.reactions.ts +610 -0
- package/src/monitor/listeners.test.ts +200 -0
- package/src/monitor/listeners.ts +150 -0
- package/src/monitor/message-channel-info.ts +96 -0
- package/src/monitor/message-forwarded.ts +107 -0
- package/src/monitor/message-handler.batch-gate.test.ts +22 -0
- package/src/monitor/message-handler.batch-gate.ts +19 -0
- package/src/monitor/message-handler.bot-self-filter.test.ts +68 -0
- package/src/monitor/message-handler.context.ts +406 -0
- package/src/monitor/message-handler.dm-preflight.ts +123 -0
- package/src/monitor/message-handler.draft-preview.ts +246 -0
- package/src/monitor/message-handler.hydration.test.ts +80 -0
- package/src/monitor/message-handler.hydration.ts +198 -0
- package/src/monitor/message-handler.inbound-context.test.ts +59 -0
- package/src/monitor/message-handler.module-test-helpers.ts +31 -0
- package/src/monitor/message-handler.preflight-channel-access.ts +86 -0
- package/src/monitor/message-handler.preflight-channel-context.test.ts +18 -0
- package/src/monitor/message-handler.preflight-channel-context.ts +58 -0
- package/src/monitor/message-handler.preflight-context.ts +54 -0
- package/src/monitor/message-handler.preflight-helpers.ts +164 -0
- package/src/monitor/message-handler.preflight-history.ts +23 -0
- package/src/monitor/message-handler.preflight-logging.ts +36 -0
- package/src/monitor/message-handler.preflight-pluralkit.ts +26 -0
- package/src/monitor/message-handler.preflight-runtime.ts +28 -0
- package/src/monitor/message-handler.preflight-thread.ts +49 -0
- package/src/monitor/message-handler.preflight.acp-bindings.test.ts +369 -0
- package/src/monitor/message-handler.preflight.test-helpers.ts +111 -0
- package/src/monitor/message-handler.preflight.test.ts +1623 -0
- package/src/monitor/message-handler.preflight.ts +679 -0
- package/src/monitor/message-handler.preflight.types.ts +110 -0
- package/src/monitor/message-handler.process.test.ts +1369 -0
- package/src/monitor/message-handler.process.ts +686 -0
- package/src/monitor/message-handler.queue.test.ts +496 -0
- package/src/monitor/message-handler.routing-preflight.ts +112 -0
- package/src/monitor/message-handler.test-harness.ts +99 -0
- package/src/monitor/message-handler.test-helpers.ts +75 -0
- package/src/monitor/message-handler.ts +274 -0
- package/src/monitor/message-media.ts +509 -0
- package/src/monitor/message-run-queue.ts +101 -0
- package/src/monitor/message-text.ts +171 -0
- package/src/monitor/message-utils.test.ts +1157 -0
- package/src/monitor/message-utils.ts +32 -0
- package/src/monitor/model-picker-preferences.test.ts +67 -0
- package/src/monitor/model-picker-preferences.ts +184 -0
- package/src/monitor/model-picker.state.ts +364 -0
- package/src/monitor/model-picker.test-utils.ts +26 -0
- package/src/monitor/model-picker.test.ts +794 -0
- package/src/monitor/model-picker.ts +38 -0
- package/src/monitor/model-picker.view.ts +695 -0
- package/src/monitor/monitor.agent-components.test.ts +375 -0
- package/src/monitor/monitor.test.ts +849 -0
- package/src/monitor/monitor.threading-utils.test.ts +598 -0
- package/src/monitor/native-command-agent-reply.ts +125 -0
- package/src/monitor/native-command-arg-ui.ts +233 -0
- package/src/monitor/native-command-auth.ts +308 -0
- package/src/monitor/native-command-bypass.ts +13 -0
- package/src/monitor/native-command-context.test.ts +98 -0
- package/src/monitor/native-command-context.ts +103 -0
- package/src/monitor/native-command-dispatch.ts +35 -0
- package/src/monitor/native-command-model-picker-apply.ts +177 -0
- package/src/monitor/native-command-model-picker-interaction.ts +461 -0
- package/src/monitor/native-command-model-picker-ui.ts +368 -0
- package/src/monitor/native-command-reply.test.ts +68 -0
- package/src/monitor/native-command-reply.ts +185 -0
- package/src/monitor/native-command-route.ts +91 -0
- package/src/monitor/native-command-status.ts +76 -0
- package/src/monitor/native-command-ui.ts +26 -0
- package/src/monitor/native-command-ui.types.ts +20 -0
- package/src/monitor/native-command.args.ts +45 -0
- package/src/monitor/native-command.command-arg.test.ts +99 -0
- package/src/monitor/native-command.commands-allowfrom.test.ts +490 -0
- package/src/monitor/native-command.model-picker.test.ts +767 -0
- package/src/monitor/native-command.options.test.ts +369 -0
- package/src/monitor/native-command.options.ts +153 -0
- package/src/monitor/native-command.plugin-dispatch.test.ts +961 -0
- package/src/monitor/native-command.runtime.ts +50 -0
- package/src/monitor/native-command.status-direct.test.ts +272 -0
- package/src/monitor/native-command.test-helpers.ts +64 -0
- package/src/monitor/native-command.think-autocomplete.test.ts +416 -0
- package/src/monitor/native-command.ts +700 -0
- package/src/monitor/native-command.types.ts +9 -0
- package/src/monitor/native-interaction-channel-context.ts +50 -0
- package/src/monitor/preflight-audio.runtime.ts +9 -0
- package/src/monitor/preflight-audio.test.ts +157 -0
- package/src/monitor/preflight-audio.ts +130 -0
- package/src/monitor/presence-cache.ts +61 -0
- package/src/monitor/presence.test.ts +44 -0
- package/src/monitor/presence.ts +50 -0
- package/src/monitor/provider-session.runtime.ts +12 -0
- package/src/monitor/provider.acp.ts +89 -0
- package/src/monitor/provider.allowlist.test.ts +149 -0
- package/src/monitor/provider.allowlist.ts +394 -0
- package/src/monitor/provider.cleanup.ts +41 -0
- package/src/monitor/provider.commands.ts +129 -0
- package/src/monitor/provider.config-log.ts +45 -0
- package/src/monitor/provider.deploy-errors.ts +362 -0
- package/src/monitor/provider.deploy.ts +221 -0
- package/src/monitor/provider.interactions.ts +160 -0
- package/src/monitor/provider.lifecycle.test.ts +713 -0
- package/src/monitor/provider.lifecycle.ts +552 -0
- package/src/monitor/provider.proxy.test.ts +745 -0
- package/src/monitor/provider.rest-proxy.test.ts +121 -0
- package/src/monitor/provider.runtime.ts +1 -0
- package/src/monitor/provider.skill-dedupe.test.ts +42 -0
- package/src/monitor/provider.startup-log.ts +32 -0
- package/src/monitor/provider.startup.test.ts +426 -0
- package/src/monitor/provider.startup.ts +323 -0
- package/src/monitor/provider.test.ts +1111 -0
- package/src/monitor/provider.ts +713 -0
- package/src/monitor/reply-context.ts +64 -0
- package/src/monitor/reply-delivery.test.ts +244 -0
- package/src/monitor/reply-delivery.ts +203 -0
- package/src/monitor/rest-fetch.ts +43 -0
- package/src/monitor/route-resolution.test.ts +204 -0
- package/src/monitor/route-resolution.ts +140 -0
- package/src/monitor/sender-identity.ts +81 -0
- package/src/monitor/startup-status.test.ts +30 -0
- package/src/monitor/startup-status.ts +10 -0
- package/src/monitor/status.ts +22 -0
- package/src/monitor/system-events.ts +55 -0
- package/src/monitor/thread-bindings.config.ts +35 -0
- package/src/monitor/thread-bindings.discord-api.test.ts +229 -0
- package/src/monitor/thread-bindings.discord-api.ts +310 -0
- package/src/monitor/thread-bindings.lifecycle.test.ts +1871 -0
- package/src/monitor/thread-bindings.lifecycle.ts +354 -0
- package/src/monitor/thread-bindings.manager.ts +553 -0
- package/src/monitor/thread-bindings.messages.ts +6 -0
- package/src/monitor/thread-bindings.persona.test.ts +34 -0
- package/src/monitor/thread-bindings.persona.ts +25 -0
- package/src/monitor/thread-bindings.session-adapter.ts +229 -0
- package/src/monitor/thread-bindings.session-shared.ts +59 -0
- package/src/monitor/thread-bindings.session-updates.ts +35 -0
- package/src/monitor/thread-bindings.shared-state.test.ts +36 -0
- package/src/monitor/thread-bindings.state.ts +540 -0
- package/src/monitor/thread-bindings.ts +48 -0
- package/src/monitor/thread-bindings.types.ts +83 -0
- package/src/monitor/thread-channel-context.ts +112 -0
- package/src/monitor/thread-session-close.test.ts +180 -0
- package/src/monitor/thread-session-close.ts +63 -0
- package/src/monitor/thread-title.generate.test.ts +197 -0
- package/src/monitor/thread-title.test.ts +31 -0
- package/src/monitor/thread-title.ts +181 -0
- package/src/monitor/threading.auto-thread.test.ts +327 -0
- package/src/monitor/threading.auto-thread.ts +287 -0
- package/src/monitor/threading.cache.ts +45 -0
- package/src/monitor/threading.parent-info.test.ts +156 -0
- package/src/monitor/threading.starter.test.ts +260 -0
- package/src/monitor/threading.starter.ts +287 -0
- package/src/monitor/threading.ts +20 -0
- package/src/monitor/threading.types.ts +102 -0
- package/src/monitor/timeouts.ts +84 -0
- package/src/monitor/typing.test.ts +42 -0
- package/src/monitor/typing.ts +17 -0
- package/src/monitor.gateway.test.ts +187 -0
- package/src/monitor.gateway.ts +75 -0
- package/src/monitor.test.ts +1397 -0
- package/src/monitor.ts +28 -0
- package/src/normalize.test.ts +56 -0
- package/src/normalize.ts +86 -0
- package/src/outbound-adapter.interactive-order.test.ts +64 -0
- package/src/outbound-adapter.test-harness.ts +207 -0
- package/src/outbound-adapter.test.ts +696 -0
- package/src/outbound-adapter.ts +291 -0
- package/src/outbound-approval.ts +29 -0
- package/src/outbound-components.ts +81 -0
- package/src/outbound-payload.contract.test.ts +38 -0
- package/src/outbound-payload.ts +134 -0
- package/src/outbound-send-context.ts +92 -0
- package/src/outbound-session-route.test.ts +34 -0
- package/src/outbound-session-route.ts +72 -0
- package/src/pluralkit.test.ts +67 -0
- package/src/pluralkit.ts +58 -0
- package/src/preview-streaming.ts +32 -0
- package/src/probe.intents.test.ts +94 -0
- package/src/probe.parse-token.test.ts +43 -0
- package/src/probe.runtime.ts +1 -0
- package/src/probe.ts +237 -0
- package/src/proxy-fetch.ts +92 -0
- package/src/proxy-request-client.test.ts +78 -0
- package/src/proxy-request-client.ts +21 -0
- package/src/recipient-resolution.ts +39 -0
- package/src/resolve-allowlist-common.test.ts +36 -0
- package/src/resolve-allowlist-common.ts +39 -0
- package/src/resolve-channels.test.ts +340 -0
- package/src/resolve-channels.ts +369 -0
- package/src/resolve-users.test.ts +222 -0
- package/src/resolve-users.ts +184 -0
- package/src/retry.test.ts +83 -0
- package/src/retry.ts +98 -0
- package/src/runtime-api.ts +64 -0
- package/src/runtime.ts +22 -5
- package/src/secret-config-contract.ts +140 -0
- package/src/security-audit.runtime.ts +1 -0
- package/src/security-audit.test.ts +246 -0
- package/src/security-audit.ts +208 -0
- package/src/security-contract.ts +47 -0
- package/src/security-doctor.test.ts +25 -0
- package/src/security-doctor.ts +20 -0
- package/src/security.ts +60 -0
- package/src/send-target-parsing.ts +14 -0
- package/src/send.channels.ts +139 -0
- package/src/send.components.test.ts +275 -0
- package/src/send.components.ts +381 -0
- package/src/send.creates-thread.test.ts +643 -0
- package/src/send.emojis-stickers.ts +57 -0
- package/src/send.guild.ts +170 -0
- package/src/send.message-request.ts +97 -0
- package/src/send.messages.test.ts +53 -0
- package/src/send.messages.ts +225 -0
- package/src/send.outbound.ts +413 -0
- package/src/send.permissions.authz.test.ts +188 -0
- package/src/send.permissions.ts +283 -0
- package/src/send.reactions.ts +155 -0
- package/src/send.sends-basic-channel-messages.test.ts +941 -0
- package/src/send.shared.ts +447 -0
- package/src/send.test-harness.ts +56 -0
- package/src/send.ts +82 -0
- package/src/send.types.ts +188 -0
- package/src/send.typing.test.ts +41 -0
- package/src/send.typing.ts +9 -0
- package/src/send.voice.ts +134 -0
- package/src/send.webhook-activity.test.ts +105 -0
- package/src/send.webhook.proxy.test.ts +191 -0
- package/src/send.webhook.ts +133 -0
- package/src/session-contract.ts +3 -0
- package/src/session-key-normalization.test.ts +44 -0
- package/src/session-key-normalization.ts +47 -0
- package/src/setup-account-state.test.ts +91 -0
- package/src/setup-account-state.ts +144 -0
- package/src/setup-adapter.ts +12 -0
- package/src/setup-core.ts +212 -0
- package/src/setup-runtime-helpers.ts +10 -0
- package/src/setup-surface.test.ts +137 -0
- package/src/setup-surface.ts +129 -0
- package/src/shared-interactive.test.ts +153 -0
- package/src/shared-interactive.ts +124 -0
- package/src/shared.test.ts +165 -0
- package/src/shared.ts +190 -0
- package/src/status-issues.test.ts +70 -0
- package/src/status-issues.ts +169 -0
- package/src/subagent-hooks.test.ts +130 -81
- package/src/subagent-hooks.ts +184 -122
- package/src/target-parsing.ts +53 -0
- package/src/target-resolver.ts +129 -0
- package/src/targets.test.ts +367 -0
- package/src/targets.ts +12 -0
- package/src/test-http-helpers.ts +10 -0
- package/src/test-support/component-runtime.ts +190 -0
- package/src/test-support/config.ts +7 -0
- package/src/test-support/configured-binding-runtime.ts +29 -0
- package/src/test-support/partial-channel.ts +26 -0
- package/src/test-support/provider.test-support.ts +545 -0
- package/src/token.test.ts +107 -0
- package/src/token.ts +60 -0
- package/src/ui-colors.ts +27 -0
- package/src/ui.ts +20 -0
- package/src/voice/access.test.ts +217 -0
- package/src/voice/access.ts +124 -0
- package/src/voice/audio.ts +173 -0
- package/src/voice/capture-state.test.ts +48 -0
- package/src/voice/capture-state.ts +120 -0
- package/src/voice/command.test.ts +164 -0
- package/src/voice/command.ts +283 -0
- package/src/voice/config.ts +8 -0
- package/src/voice/manager.e2e.test.ts +928 -0
- package/src/voice/manager.ready-listener.test.ts +37 -0
- package/src/voice/manager.runtime.ts +11 -0
- package/src/voice/manager.ts +691 -0
- package/src/voice/prompt.test.ts +16 -0
- package/src/voice/prompt.ts +17 -0
- package/src/voice/receive-recovery.test.ts +79 -0
- package/src/voice/receive-recovery.ts +159 -0
- package/src/voice/sanitize.test.ts +34 -0
- package/src/voice/sanitize.ts +32 -0
- package/src/voice/sdk-runtime.ts +14 -0
- package/src/voice/segment.ts +156 -0
- package/src/voice/session.ts +50 -0
- package/src/voice/speaker-context.ts +127 -0
- package/src/voice/tts.ts +125 -0
- package/src/voice-message.test.ts +234 -0
- package/src/voice-message.ts +444 -0
- package/subagent-hooks-api.ts +27 -0
- package/test-api.ts +4 -0
- package/thread-binding-api.ts +1 -0
- package/timeouts.ts +6 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
import { ChannelType } from "discord-api-types/v10";
|
|
2
|
+
import type { DiscordAccountConfig, OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
|
3
|
+
import { buildPluginBindingApprovalCustomId } from "openclaw/plugin-sdk/conversation-runtime";
|
|
4
|
+
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { type DiscordComponentEntry, type DiscordModalEntry } from "../components.js";
|
|
6
|
+
import type {
|
|
7
|
+
ButtonInteraction,
|
|
8
|
+
ComponentData,
|
|
9
|
+
ModalInteraction,
|
|
10
|
+
StringSelectMenuInteraction,
|
|
11
|
+
} from "../internal/discord.js";
|
|
12
|
+
import {
|
|
13
|
+
dispatchPluginInteractiveHandlerMock,
|
|
14
|
+
dispatchReplyMock,
|
|
15
|
+
enqueueSystemEventMock,
|
|
16
|
+
readSessionUpdatedAtMock,
|
|
17
|
+
recordInboundSessionMock,
|
|
18
|
+
resetDiscordComponentRuntimeMocks,
|
|
19
|
+
resolveStorePathMock,
|
|
20
|
+
} from "../test-support/component-runtime.js";
|
|
21
|
+
import type { DiscordGuildEntryResolved } from "./allow-list.js";
|
|
22
|
+
|
|
23
|
+
type CreateDiscordComponentButton =
|
|
24
|
+
typeof import("./agent-components.js").createDiscordComponentButton;
|
|
25
|
+
type CreateDiscordComponentModal =
|
|
26
|
+
typeof import("./agent-components.js").createDiscordComponentModal;
|
|
27
|
+
type CreateDiscordComponentStringSelect =
|
|
28
|
+
typeof import("./agent-components.js").createDiscordComponentStringSelect;
|
|
29
|
+
type DispatchReplyWithBufferedBlockDispatcherFn =
|
|
30
|
+
typeof import("openclaw/plugin-sdk/reply-dispatch-runtime").dispatchReplyWithBufferedBlockDispatcher;
|
|
31
|
+
type DispatchReplyWithBufferedBlockDispatcherResult = Awaited<
|
|
32
|
+
ReturnType<DispatchReplyWithBufferedBlockDispatcherFn>
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
let createDiscordComponentButton: CreateDiscordComponentButton;
|
|
36
|
+
let createDiscordComponentStringSelect: CreateDiscordComponentStringSelect;
|
|
37
|
+
let createDiscordComponentModal: CreateDiscordComponentModal;
|
|
38
|
+
let clearDiscordComponentEntries: typeof import("../components-registry.js").clearDiscordComponentEntries;
|
|
39
|
+
let registerDiscordComponentEntries: typeof import("../components-registry.js").registerDiscordComponentEntries;
|
|
40
|
+
let resolveDiscordComponentEntry: typeof import("../components-registry.js").resolveDiscordComponentEntry;
|
|
41
|
+
let resolveDiscordModalEntry: typeof import("../components-registry.js").resolveDiscordModalEntry;
|
|
42
|
+
let sendComponents: typeof import("../send.components.js");
|
|
43
|
+
|
|
44
|
+
let lastDispatchCtx: Record<string, unknown> | undefined;
|
|
45
|
+
|
|
46
|
+
function getLastRecordedCtx(): Record<string, unknown> | undefined {
|
|
47
|
+
const params = recordInboundSessionMock.mock.calls.at(-1)?.[0] as
|
|
48
|
+
| { ctx?: Record<string, unknown> }
|
|
49
|
+
| undefined;
|
|
50
|
+
return params?.ctx;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe("discord component interactions", () => {
|
|
54
|
+
let editDiscordComponentMessageMock: ReturnType<typeof vi.spyOn>;
|
|
55
|
+
const createCfg = (): OpenClawConfig =>
|
|
56
|
+
({
|
|
57
|
+
channels: {
|
|
58
|
+
discord: {
|
|
59
|
+
replyToMode: "first",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}) as OpenClawConfig;
|
|
63
|
+
|
|
64
|
+
const createDiscordConfig = (overrides?: Partial<DiscordAccountConfig>): DiscordAccountConfig =>
|
|
65
|
+
({
|
|
66
|
+
replyToMode: "first",
|
|
67
|
+
...overrides,
|
|
68
|
+
}) as DiscordAccountConfig;
|
|
69
|
+
|
|
70
|
+
type DispatchParams = Parameters<DispatchReplyWithBufferedBlockDispatcherFn>[0];
|
|
71
|
+
|
|
72
|
+
type ComponentContext = Parameters<CreateDiscordComponentButton>[0];
|
|
73
|
+
|
|
74
|
+
const createComponentContext = (overrides?: Partial<ComponentContext>) =>
|
|
75
|
+
({
|
|
76
|
+
cfg: createCfg(),
|
|
77
|
+
accountId: "default",
|
|
78
|
+
dmPolicy: "allowlist",
|
|
79
|
+
allowFrom: ["123456789"],
|
|
80
|
+
discordConfig: createDiscordConfig(),
|
|
81
|
+
token: "token",
|
|
82
|
+
...overrides,
|
|
83
|
+
}) as ComponentContext;
|
|
84
|
+
|
|
85
|
+
const createComponentInteractionBase = () => {
|
|
86
|
+
const reply = vi.fn().mockResolvedValue(undefined);
|
|
87
|
+
const defer = vi.fn().mockResolvedValue(undefined);
|
|
88
|
+
const rest = {
|
|
89
|
+
get: vi.fn().mockResolvedValue({ type: ChannelType.DM }),
|
|
90
|
+
post: vi.fn().mockResolvedValue({}),
|
|
91
|
+
patch: vi.fn().mockResolvedValue({}),
|
|
92
|
+
delete: vi.fn().mockResolvedValue(undefined),
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
reply,
|
|
96
|
+
defer,
|
|
97
|
+
client: { rest },
|
|
98
|
+
user: { id: "123456789", username: "AgentUser", discriminator: "0001" },
|
|
99
|
+
message: { id: "msg-1" },
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const createComponentButtonInteraction = (overrides: Partial<ButtonInteraction> = {}) => {
|
|
104
|
+
const base = createComponentInteractionBase();
|
|
105
|
+
const interaction = {
|
|
106
|
+
rawData: { channel_id: "dm-channel", id: "interaction-1" },
|
|
107
|
+
customId: "occomp:cid=btn_1",
|
|
108
|
+
...base,
|
|
109
|
+
...overrides,
|
|
110
|
+
} as unknown as ButtonInteraction;
|
|
111
|
+
return { interaction, defer: base.defer, reply: base.reply };
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const createComponentSelectInteraction = (
|
|
115
|
+
overrides: Partial<StringSelectMenuInteraction> = {},
|
|
116
|
+
) => {
|
|
117
|
+
const base = createComponentInteractionBase();
|
|
118
|
+
const interaction = {
|
|
119
|
+
rawData: { channel_id: "dm-channel", id: "interaction-select-1" },
|
|
120
|
+
customId: "occomp:cid=sel_1",
|
|
121
|
+
values: ["alpha"],
|
|
122
|
+
...base,
|
|
123
|
+
...overrides,
|
|
124
|
+
} as unknown as StringSelectMenuInteraction;
|
|
125
|
+
return { interaction, defer: base.defer, reply: base.reply };
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const createModalInteraction = (overrides: Partial<ModalInteraction> = {}) => {
|
|
129
|
+
const reply = vi.fn().mockResolvedValue(undefined);
|
|
130
|
+
const acknowledge = vi.fn().mockResolvedValue(undefined);
|
|
131
|
+
const rest = {
|
|
132
|
+
get: vi.fn().mockResolvedValue({ type: ChannelType.DM }),
|
|
133
|
+
post: vi.fn().mockResolvedValue({}),
|
|
134
|
+
patch: vi.fn().mockResolvedValue({}),
|
|
135
|
+
delete: vi.fn().mockResolvedValue(undefined),
|
|
136
|
+
};
|
|
137
|
+
const fields = {
|
|
138
|
+
getText: (key: string) => (key === "fld_1" ? "Casey" : undefined),
|
|
139
|
+
getStringSelect: (_key: string) => undefined,
|
|
140
|
+
getRoleSelect: (_key: string) => [],
|
|
141
|
+
getUserSelect: (_key: string) => [],
|
|
142
|
+
};
|
|
143
|
+
const interaction = {
|
|
144
|
+
rawData: { channel_id: "dm-channel", id: "interaction-2" },
|
|
145
|
+
user: { id: "123456789", username: "AgentUser", discriminator: "0001" },
|
|
146
|
+
customId: "ocmodal:mid=mdl_1",
|
|
147
|
+
fields,
|
|
148
|
+
acknowledge,
|
|
149
|
+
reply,
|
|
150
|
+
client: { rest },
|
|
151
|
+
...overrides,
|
|
152
|
+
} as unknown as ModalInteraction;
|
|
153
|
+
return { interaction, acknowledge, reply };
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const createButtonEntry = (
|
|
157
|
+
overrides: Partial<DiscordComponentEntry> = {},
|
|
158
|
+
): DiscordComponentEntry => ({
|
|
159
|
+
id: "btn_1",
|
|
160
|
+
kind: "button",
|
|
161
|
+
label: "Approve",
|
|
162
|
+
messageId: "msg-1",
|
|
163
|
+
sessionKey: "session-1",
|
|
164
|
+
agentId: "agent-1",
|
|
165
|
+
accountId: "default",
|
|
166
|
+
...overrides,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const createModalEntry = (overrides: Partial<DiscordModalEntry> = {}): DiscordModalEntry => ({
|
|
170
|
+
id: "mdl_1",
|
|
171
|
+
title: "Details",
|
|
172
|
+
messageId: "msg-2",
|
|
173
|
+
sessionKey: "session-2",
|
|
174
|
+
agentId: "agent-2",
|
|
175
|
+
accountId: "default",
|
|
176
|
+
fields: [
|
|
177
|
+
{
|
|
178
|
+
id: "fld_1",
|
|
179
|
+
name: "name",
|
|
180
|
+
label: "Name",
|
|
181
|
+
type: "text",
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
...overrides,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const createGuildPluginButton = (allowFrom: string[]) =>
|
|
188
|
+
createDiscordComponentButton(
|
|
189
|
+
createComponentContext({
|
|
190
|
+
cfg: {
|
|
191
|
+
commands: { useAccessGroups: true },
|
|
192
|
+
channels: { discord: { replyToMode: "first" } },
|
|
193
|
+
} as OpenClawConfig,
|
|
194
|
+
allowFrom,
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const createGuildPluginButtonInteraction = (interactionId: string) =>
|
|
199
|
+
createComponentButtonInteraction({
|
|
200
|
+
rawData: {
|
|
201
|
+
channel_id: "guild-channel",
|
|
202
|
+
guild_id: "guild-1",
|
|
203
|
+
id: interactionId,
|
|
204
|
+
member: { roles: [] },
|
|
205
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
206
|
+
guild: { id: "guild-1", name: "Test Guild" } as unknown as ButtonInteraction["guild"],
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
async function expectPluginGuildInteractionAuth(params: {
|
|
210
|
+
allowFrom: string[];
|
|
211
|
+
interactionId: string;
|
|
212
|
+
isAuthorizedSender: boolean;
|
|
213
|
+
}) {
|
|
214
|
+
registerDiscordComponentEntries({
|
|
215
|
+
entries: [createButtonEntry({ callbackData: "codex:approve" })],
|
|
216
|
+
modals: [],
|
|
217
|
+
});
|
|
218
|
+
dispatchPluginInteractiveHandlerMock.mockResolvedValue({
|
|
219
|
+
matched: true,
|
|
220
|
+
handled: true,
|
|
221
|
+
duplicate: false,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const button = createGuildPluginButton(params.allowFrom);
|
|
225
|
+
const { interaction } = createGuildPluginButtonInteraction(params.interactionId);
|
|
226
|
+
|
|
227
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
228
|
+
|
|
229
|
+
expect(dispatchPluginInteractiveHandlerMock).toHaveBeenCalledWith(
|
|
230
|
+
expect.objectContaining({
|
|
231
|
+
ctx: expect.objectContaining({
|
|
232
|
+
auth: { isAuthorizedSender: params.isAuthorizedSender },
|
|
233
|
+
}),
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
236
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
beforeAll(async () => {
|
|
240
|
+
({
|
|
241
|
+
createDiscordComponentButton,
|
|
242
|
+
createDiscordComponentStringSelect,
|
|
243
|
+
createDiscordComponentModal,
|
|
244
|
+
} = await import("./agent-components.js"));
|
|
245
|
+
({
|
|
246
|
+
clearDiscordComponentEntries,
|
|
247
|
+
registerDiscordComponentEntries,
|
|
248
|
+
resolveDiscordComponentEntry,
|
|
249
|
+
resolveDiscordModalEntry,
|
|
250
|
+
} = await import("../components-registry.js"));
|
|
251
|
+
sendComponents = await import("../send.components.js");
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
beforeEach(() => {
|
|
255
|
+
editDiscordComponentMessageMock = vi
|
|
256
|
+
.spyOn(sendComponents, "editDiscordComponentMessage")
|
|
257
|
+
.mockResolvedValue({
|
|
258
|
+
messageId: "msg-1",
|
|
259
|
+
channelId: "dm-channel",
|
|
260
|
+
});
|
|
261
|
+
clearDiscordComponentEntries();
|
|
262
|
+
resetDiscordComponentRuntimeMocks();
|
|
263
|
+
lastDispatchCtx = undefined;
|
|
264
|
+
enqueueSystemEventMock.mockClear();
|
|
265
|
+
dispatchReplyMock
|
|
266
|
+
.mockClear()
|
|
267
|
+
.mockImplementation(
|
|
268
|
+
async (params: DispatchParams): Promise<DispatchReplyWithBufferedBlockDispatcherResult> => {
|
|
269
|
+
lastDispatchCtx = params.ctx;
|
|
270
|
+
await params.dispatcherOptions.deliver({ text: "ok" }, { kind: "final" });
|
|
271
|
+
return {
|
|
272
|
+
queuedFinal: false,
|
|
273
|
+
counts: {
|
|
274
|
+
block: 0,
|
|
275
|
+
final: 1,
|
|
276
|
+
tool: 0,
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
recordInboundSessionMock.mockClear().mockResolvedValue(undefined);
|
|
282
|
+
readSessionUpdatedAtMock.mockClear().mockReturnValue(undefined);
|
|
283
|
+
resolveStorePathMock.mockClear().mockReturnValue("/tmp/openclaw-sessions-test.json");
|
|
284
|
+
dispatchPluginInteractiveHandlerMock.mockReset().mockResolvedValue({
|
|
285
|
+
matched: false,
|
|
286
|
+
handled: false,
|
|
287
|
+
duplicate: false,
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it("routes button clicks with reply references", async () => {
|
|
292
|
+
registerDiscordComponentEntries({
|
|
293
|
+
entries: [createButtonEntry()],
|
|
294
|
+
modals: [],
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
298
|
+
const { interaction, reply } = createComponentButtonInteraction();
|
|
299
|
+
|
|
300
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
301
|
+
|
|
302
|
+
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
|
303
|
+
expect(lastDispatchCtx?.BodyForAgent).toBe('Clicked "Approve".');
|
|
304
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
305
|
+
expect(resolveDiscordComponentEntry({ id: "btn_1" })).toBeNull();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it("records DM component interactions with user originating targets", async () => {
|
|
309
|
+
registerDiscordComponentEntries({
|
|
310
|
+
entries: [createButtonEntry()],
|
|
311
|
+
modals: [],
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
315
|
+
const { interaction } = createComponentButtonInteraction();
|
|
316
|
+
|
|
317
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
318
|
+
|
|
319
|
+
expect(lastDispatchCtx?.OriginatingTo).toBe("user:123456789");
|
|
320
|
+
expect(lastDispatchCtx?.To).toBe("channel:dm-channel");
|
|
321
|
+
expect(getLastRecordedCtx()?.OriginatingTo).toBe("user:123456789");
|
|
322
|
+
expect(getLastRecordedCtx()?.To).toBe("channel:dm-channel");
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("uses raw callbackData for built-in fallback when no plugin handler matches", async () => {
|
|
326
|
+
registerDiscordComponentEntries({
|
|
327
|
+
entries: [createButtonEntry({ callbackData: "/codex_resume --browse-projects" })],
|
|
328
|
+
modals: [],
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
332
|
+
const { interaction, reply } = createComponentButtonInteraction();
|
|
333
|
+
|
|
334
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
335
|
+
|
|
336
|
+
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
|
337
|
+
expect(lastDispatchCtx?.BodyForAgent).toBe("/codex_resume --browse-projects");
|
|
338
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("preserves selected values for select fallback when no plugin handler matches", async () => {
|
|
342
|
+
registerDiscordComponentEntries({
|
|
343
|
+
entries: [
|
|
344
|
+
{
|
|
345
|
+
id: "sel_1",
|
|
346
|
+
kind: "select",
|
|
347
|
+
label: "Pick",
|
|
348
|
+
messageId: "msg-1",
|
|
349
|
+
sessionKey: "session-1",
|
|
350
|
+
agentId: "agent-1",
|
|
351
|
+
accountId: "default",
|
|
352
|
+
callbackData: "/codex_resume",
|
|
353
|
+
selectType: "string",
|
|
354
|
+
options: [{ value: "alpha", label: "Alpha" }],
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
modals: [],
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
const select = createDiscordComponentStringSelect(createComponentContext());
|
|
361
|
+
const { interaction, reply } = createComponentSelectInteraction();
|
|
362
|
+
|
|
363
|
+
await select.run(interaction, { cid: "sel_1" } as ComponentData);
|
|
364
|
+
|
|
365
|
+
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
|
366
|
+
expect(lastDispatchCtx?.BodyForAgent).toBe('Selected Alpha from "Pick".');
|
|
367
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it("keeps reusable buttons active after use", async () => {
|
|
371
|
+
registerDiscordComponentEntries({
|
|
372
|
+
entries: [createButtonEntry({ reusable: true })],
|
|
373
|
+
modals: [],
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
377
|
+
const { interaction } = createComponentButtonInteraction();
|
|
378
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
379
|
+
|
|
380
|
+
const { interaction: secondInteraction } = createComponentButtonInteraction({
|
|
381
|
+
rawData: {
|
|
382
|
+
channel_id: "dm-channel",
|
|
383
|
+
id: "interaction-2",
|
|
384
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
385
|
+
});
|
|
386
|
+
await button.run(secondInteraction, { cid: "btn_1" } as ComponentData);
|
|
387
|
+
|
|
388
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(2);
|
|
389
|
+
expect(resolveDiscordComponentEntry({ id: "btn_1", consume: false })).not.toBeNull();
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("blocks buttons when allowedUsers does not match", async () => {
|
|
393
|
+
registerDiscordComponentEntries({
|
|
394
|
+
entries: [createButtonEntry({ allowedUsers: ["999"] })],
|
|
395
|
+
modals: [],
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
399
|
+
const { interaction, reply } = createComponentButtonInteraction();
|
|
400
|
+
|
|
401
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
402
|
+
|
|
403
|
+
expect(reply).toHaveBeenCalledWith({
|
|
404
|
+
content: "You are not authorized to use this button.",
|
|
405
|
+
ephemeral: true,
|
|
406
|
+
});
|
|
407
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
408
|
+
expect(resolveDiscordComponentEntry({ id: "btn_1", consume: false })).not.toBeNull();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("blocks buttons from guilds removed from the allowlist", async () => {
|
|
412
|
+
registerDiscordComponentEntries({
|
|
413
|
+
entries: [createButtonEntry()],
|
|
414
|
+
modals: [],
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
const button = createDiscordComponentButton(
|
|
418
|
+
createComponentContext({
|
|
419
|
+
cfg: {
|
|
420
|
+
channels: { discord: { replyToMode: "first", groupPolicy: "allowlist" } },
|
|
421
|
+
} as OpenClawConfig,
|
|
422
|
+
discordConfig: createDiscordConfig({ groupPolicy: "allowlist" }),
|
|
423
|
+
guildEntries: {},
|
|
424
|
+
}),
|
|
425
|
+
);
|
|
426
|
+
const { interaction, reply } = createComponentButtonInteraction({
|
|
427
|
+
rawData: {
|
|
428
|
+
channel_id: "guild-channel",
|
|
429
|
+
guild_id: "gone",
|
|
430
|
+
id: "interaction-guild-removed",
|
|
431
|
+
member: { roles: [] },
|
|
432
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
433
|
+
guild: { id: "gone", name: "Test Guild" } as unknown as ButtonInteraction["guild"],
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
437
|
+
|
|
438
|
+
expect(reply).toHaveBeenCalledWith({
|
|
439
|
+
content: "You are not authorized to use this button.",
|
|
440
|
+
ephemeral: true,
|
|
441
|
+
});
|
|
442
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it.each([
|
|
446
|
+
{
|
|
447
|
+
title: "blocks buttons on disabled guild channels",
|
|
448
|
+
guildId: "g1",
|
|
449
|
+
interactionId: "interaction-guild-disabled",
|
|
450
|
+
guildEntries: { g1: { channels: { "guild-channel": { enabled: false } } } },
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
title: "blocks buttons on denied guild channels",
|
|
454
|
+
guildId: "g1",
|
|
455
|
+
interactionId: "interaction-guild-denied",
|
|
456
|
+
guildEntries: { g1: { channels: { "guild-channel": { enabled: false } } } },
|
|
457
|
+
},
|
|
458
|
+
])("$title", async ({ guildId, interactionId, guildEntries }) => {
|
|
459
|
+
await expectBlockedGuildButton({ guildId, interactionId, guildEntries });
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
async function runModalSubmission(params?: { reusable?: boolean }) {
|
|
463
|
+
registerDiscordComponentEntries({
|
|
464
|
+
entries: [],
|
|
465
|
+
modals: [createModalEntry({ reusable: params?.reusable ?? false })],
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
const modal = createDiscordComponentModal(
|
|
469
|
+
createComponentContext({
|
|
470
|
+
discordConfig: createDiscordConfig({ replyToMode: "all" }),
|
|
471
|
+
}),
|
|
472
|
+
);
|
|
473
|
+
const { interaction, acknowledge } = createModalInteraction();
|
|
474
|
+
|
|
475
|
+
await modal.run(interaction, { mid: "mdl_1" } as ComponentData);
|
|
476
|
+
return { acknowledge };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async function expectBlockedGuildButton(params: {
|
|
480
|
+
guildId: string;
|
|
481
|
+
interactionId: string;
|
|
482
|
+
guildEntries: Record<string, DiscordGuildEntryResolved>;
|
|
483
|
+
}) {
|
|
484
|
+
registerDiscordComponentEntries({
|
|
485
|
+
entries: [createButtonEntry()],
|
|
486
|
+
modals: [],
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
const button = createDiscordComponentButton(
|
|
490
|
+
createComponentContext({
|
|
491
|
+
cfg: {
|
|
492
|
+
channels: { discord: { replyToMode: "first", groupPolicy: "allowlist" } },
|
|
493
|
+
} as OpenClawConfig,
|
|
494
|
+
discordConfig: createDiscordConfig({ groupPolicy: "allowlist" }),
|
|
495
|
+
guildEntries: params.guildEntries,
|
|
496
|
+
}),
|
|
497
|
+
);
|
|
498
|
+
const { interaction, reply } = createComponentButtonInteraction({
|
|
499
|
+
rawData: {
|
|
500
|
+
channel_id: "guild-channel",
|
|
501
|
+
guild_id: params.guildId,
|
|
502
|
+
id: params.interactionId,
|
|
503
|
+
member: { roles: [] },
|
|
504
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
505
|
+
guild: {
|
|
506
|
+
id: params.guildId,
|
|
507
|
+
name: "Test Guild",
|
|
508
|
+
} as unknown as ButtonInteraction["guild"],
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
512
|
+
|
|
513
|
+
expect(reply).toHaveBeenCalledWith({
|
|
514
|
+
content: "You are not authorized to use this button.",
|
|
515
|
+
ephemeral: true,
|
|
516
|
+
});
|
|
517
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
async function expectGuildModalAuth(params: {
|
|
521
|
+
allowFrom: string[];
|
|
522
|
+
interactionId: string;
|
|
523
|
+
expectedAuthorized: boolean;
|
|
524
|
+
}) {
|
|
525
|
+
registerDiscordComponentEntries({
|
|
526
|
+
entries: [],
|
|
527
|
+
modals: [createModalEntry()],
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
const modal = createDiscordComponentModal(
|
|
531
|
+
createComponentContext({
|
|
532
|
+
cfg: {
|
|
533
|
+
commands: { useAccessGroups: true },
|
|
534
|
+
channels: { discord: { replyToMode: "first" } },
|
|
535
|
+
} as OpenClawConfig,
|
|
536
|
+
allowFrom: params.allowFrom,
|
|
537
|
+
}),
|
|
538
|
+
);
|
|
539
|
+
const { interaction, acknowledge } = createModalInteraction({
|
|
540
|
+
rawData: {
|
|
541
|
+
channel_id: "guild-channel",
|
|
542
|
+
guild_id: "guild-1",
|
|
543
|
+
id: params.interactionId,
|
|
544
|
+
member: { roles: [] },
|
|
545
|
+
} as unknown as ModalInteraction["rawData"],
|
|
546
|
+
guild: { id: "guild-1", name: "Test Guild" } as unknown as ModalInteraction["guild"],
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
await modal.run(interaction, { mid: "mdl_1" } as ComponentData);
|
|
550
|
+
|
|
551
|
+
expect(acknowledge).toHaveBeenCalledTimes(1);
|
|
552
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
553
|
+
expect(lastDispatchCtx?.CommandAuthorized).toBe(params.expectedAuthorized);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
it("routes modal submissions with field values", async () => {
|
|
557
|
+
const { acknowledge } = await runModalSubmission();
|
|
558
|
+
|
|
559
|
+
expect(acknowledge).toHaveBeenCalledTimes(1);
|
|
560
|
+
expect(lastDispatchCtx?.BodyForAgent).toContain('Form "Details" submitted.');
|
|
561
|
+
expect(lastDispatchCtx?.BodyForAgent).toContain("- Name: Casey");
|
|
562
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
563
|
+
expect(resolveDiscordModalEntry({ id: "mdl_1" })).toBeNull();
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
it.each([
|
|
567
|
+
{
|
|
568
|
+
title: "does not mark guild modal events as command-authorized for non-allowlisted users",
|
|
569
|
+
allowFrom: ["owner-1"],
|
|
570
|
+
interactionId: "interaction-guild-1",
|
|
571
|
+
expectedAuthorized: false,
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
title: "marks guild modal events as command-authorized for allowlisted users",
|
|
575
|
+
allowFrom: ["123456789"],
|
|
576
|
+
interactionId: "interaction-guild-2",
|
|
577
|
+
expectedAuthorized: true,
|
|
578
|
+
},
|
|
579
|
+
])("$title", async ({ allowFrom, interactionId, expectedAuthorized }) => {
|
|
580
|
+
await expectGuildModalAuth({ allowFrom, interactionId, expectedAuthorized });
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
it("keeps reusable modal entries active after submission", async () => {
|
|
584
|
+
const { acknowledge } = await runModalSubmission({ reusable: true });
|
|
585
|
+
|
|
586
|
+
expect(acknowledge).toHaveBeenCalledTimes(1);
|
|
587
|
+
expect(resolveDiscordModalEntry({ id: "mdl_1", consume: false })).not.toBeNull();
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it("passes false auth to plugin Discord interactions for non-allowlisted guild users", async () => {
|
|
591
|
+
await expectPluginGuildInteractionAuth({
|
|
592
|
+
allowFrom: ["owner-1"],
|
|
593
|
+
interactionId: "interaction-guild-plugin-1",
|
|
594
|
+
isAuthorizedSender: false,
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
it("passes true auth to plugin Discord interactions for allowlisted guild users", async () => {
|
|
599
|
+
await expectPluginGuildInteractionAuth({
|
|
600
|
+
allowFrom: ["123456789"],
|
|
601
|
+
interactionId: "interaction-guild-plugin-2",
|
|
602
|
+
isAuthorizedSender: true,
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
it("routes plugin Discord interactions in group DMs by channel id instead of sender id", async () => {
|
|
607
|
+
registerDiscordComponentEntries({
|
|
608
|
+
entries: [createButtonEntry({ callbackData: "codex:approve" })],
|
|
609
|
+
modals: [],
|
|
610
|
+
});
|
|
611
|
+
dispatchPluginInteractiveHandlerMock.mockResolvedValue({
|
|
612
|
+
matched: true,
|
|
613
|
+
handled: true,
|
|
614
|
+
duplicate: false,
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
const button = createDiscordComponentButton(
|
|
618
|
+
createComponentContext({
|
|
619
|
+
discordConfig: createDiscordConfig({
|
|
620
|
+
dm: {
|
|
621
|
+
groupEnabled: true,
|
|
622
|
+
groupChannels: ["group-dm-1"],
|
|
623
|
+
},
|
|
624
|
+
}),
|
|
625
|
+
}),
|
|
626
|
+
);
|
|
627
|
+
const { interaction } = createComponentButtonInteraction({
|
|
628
|
+
rawData: {
|
|
629
|
+
channel_id: "group-dm-1",
|
|
630
|
+
id: "interaction-group-dm-1",
|
|
631
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
632
|
+
channel: {
|
|
633
|
+
id: "group-dm-1",
|
|
634
|
+
type: ChannelType.GroupDM,
|
|
635
|
+
} as unknown as ButtonInteraction["channel"],
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
639
|
+
|
|
640
|
+
expect(dispatchPluginInteractiveHandlerMock).toHaveBeenCalledWith(
|
|
641
|
+
expect.objectContaining({
|
|
642
|
+
ctx: expect.objectContaining({
|
|
643
|
+
conversationId: "channel:group-dm-1",
|
|
644
|
+
senderId: "123456789",
|
|
645
|
+
}),
|
|
646
|
+
}),
|
|
647
|
+
);
|
|
648
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
it("marks built-in Group DM component fallbacks with group metadata", async () => {
|
|
652
|
+
registerDiscordComponentEntries({
|
|
653
|
+
entries: [createButtonEntry()],
|
|
654
|
+
modals: [],
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
const button = createDiscordComponentButton(
|
|
658
|
+
createComponentContext({
|
|
659
|
+
discordConfig: createDiscordConfig({
|
|
660
|
+
dm: {
|
|
661
|
+
groupEnabled: true,
|
|
662
|
+
groupChannels: ["group-dm-1"],
|
|
663
|
+
},
|
|
664
|
+
}),
|
|
665
|
+
}),
|
|
666
|
+
);
|
|
667
|
+
const { interaction, reply } = createComponentButtonInteraction({
|
|
668
|
+
rawData: {
|
|
669
|
+
channel_id: "group-dm-1",
|
|
670
|
+
id: "interaction-group-dm-fallback",
|
|
671
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
672
|
+
channel: {
|
|
673
|
+
id: "group-dm-1",
|
|
674
|
+
type: ChannelType.GroupDM,
|
|
675
|
+
name: "incident-room",
|
|
676
|
+
} as unknown as ButtonInteraction["channel"],
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
680
|
+
|
|
681
|
+
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
|
682
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
683
|
+
expect(lastDispatchCtx).toMatchObject({
|
|
684
|
+
From: "discord:group:group-dm-1",
|
|
685
|
+
ChatType: "group",
|
|
686
|
+
ConversationLabel: "Group DM #incident-room channel id:group-dm-1",
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
it("blocks Group DM modal triggers before showing the modal", async () => {
|
|
691
|
+
registerDiscordComponentEntries({
|
|
692
|
+
entries: [createButtonEntry({ kind: "modal-trigger", modalId: "mdl_1" })],
|
|
693
|
+
modals: [createModalEntry()],
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
697
|
+
const showModal = vi.fn().mockResolvedValue(undefined);
|
|
698
|
+
const { interaction, reply } = createComponentButtonInteraction({
|
|
699
|
+
rawData: {
|
|
700
|
+
channel_id: "group-dm-1",
|
|
701
|
+
id: "interaction-group-dm-modal-trigger",
|
|
702
|
+
} as unknown as ButtonInteraction["rawData"],
|
|
703
|
+
channel: {
|
|
704
|
+
id: "group-dm-1",
|
|
705
|
+
type: ChannelType.GroupDM,
|
|
706
|
+
name: "incident-room",
|
|
707
|
+
} as unknown as ButtonInteraction["channel"],
|
|
708
|
+
showModal,
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
await button.run(interaction, { cid: "btn_1", mid: "mdl_1" } as ComponentData);
|
|
712
|
+
|
|
713
|
+
expect(reply).toHaveBeenCalledWith({
|
|
714
|
+
content: "Group DM interactions are disabled.",
|
|
715
|
+
ephemeral: true,
|
|
716
|
+
});
|
|
717
|
+
expect(showModal).not.toHaveBeenCalled();
|
|
718
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
it("does not fall through to Claw when a plugin Discord interaction already replied", async () => {
|
|
722
|
+
registerDiscordComponentEntries({
|
|
723
|
+
entries: [createButtonEntry({ callbackData: "codex:approve" })],
|
|
724
|
+
modals: [],
|
|
725
|
+
});
|
|
726
|
+
dispatchPluginInteractiveHandlerMock.mockImplementation(async (params: unknown) => {
|
|
727
|
+
const typedParams = params as {
|
|
728
|
+
respond: { reply: (payload: { text: string; ephemeral: boolean }) => Promise<void> };
|
|
729
|
+
};
|
|
730
|
+
await typedParams.respond.reply({ text: "✓", ephemeral: true });
|
|
731
|
+
return {
|
|
732
|
+
matched: true,
|
|
733
|
+
handled: true,
|
|
734
|
+
duplicate: false,
|
|
735
|
+
};
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
739
|
+
const { interaction, reply } = createComponentButtonInteraction();
|
|
740
|
+
|
|
741
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
742
|
+
|
|
743
|
+
expect(dispatchPluginInteractiveHandlerMock).toHaveBeenCalledTimes(1);
|
|
744
|
+
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
|
745
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
746
|
+
});
|
|
747
|
+
|
|
748
|
+
it("lets plugin Discord interactions clear components after acknowledging", async () => {
|
|
749
|
+
registerDiscordComponentEntries({
|
|
750
|
+
entries: [createButtonEntry({ callbackData: "codex:approve" })],
|
|
751
|
+
modals: [],
|
|
752
|
+
});
|
|
753
|
+
dispatchPluginInteractiveHandlerMock.mockImplementation(async (params: unknown) => {
|
|
754
|
+
const typedParams = params as {
|
|
755
|
+
respond: {
|
|
756
|
+
acknowledge: () => Promise<void>;
|
|
757
|
+
clearComponents: (payload: { text: string }) => Promise<void>;
|
|
758
|
+
};
|
|
759
|
+
};
|
|
760
|
+
await typedParams.respond.acknowledge();
|
|
761
|
+
await typedParams.respond.clearComponents({ text: "Handled" });
|
|
762
|
+
return {
|
|
763
|
+
matched: true,
|
|
764
|
+
handled: true,
|
|
765
|
+
duplicate: false,
|
|
766
|
+
};
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
770
|
+
const acknowledge = vi.fn().mockResolvedValue(undefined);
|
|
771
|
+
const reply = vi.fn().mockResolvedValue(undefined);
|
|
772
|
+
const update = vi.fn().mockResolvedValue(undefined);
|
|
773
|
+
const baseInteraction = createComponentButtonInteraction().interaction as unknown as Record<
|
|
774
|
+
string,
|
|
775
|
+
unknown
|
|
776
|
+
>;
|
|
777
|
+
const interaction = {
|
|
778
|
+
...baseInteraction,
|
|
779
|
+
acknowledge,
|
|
780
|
+
reply,
|
|
781
|
+
update,
|
|
782
|
+
} as unknown as ButtonInteraction;
|
|
783
|
+
|
|
784
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
785
|
+
|
|
786
|
+
expect(acknowledge).toHaveBeenCalledTimes(1);
|
|
787
|
+
expect(reply).toHaveBeenCalledWith({
|
|
788
|
+
content: "Handled",
|
|
789
|
+
components: [],
|
|
790
|
+
});
|
|
791
|
+
expect(update).not.toHaveBeenCalled();
|
|
792
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
it("falls through to built-in Discord component routing when a plugin declines handling", async () => {
|
|
796
|
+
registerDiscordComponentEntries({
|
|
797
|
+
entries: [createButtonEntry({ callbackData: "codex:approve" })],
|
|
798
|
+
modals: [],
|
|
799
|
+
});
|
|
800
|
+
dispatchPluginInteractiveHandlerMock.mockResolvedValue({
|
|
801
|
+
matched: true,
|
|
802
|
+
handled: false,
|
|
803
|
+
duplicate: false,
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
807
|
+
const { interaction, reply } = createComponentButtonInteraction();
|
|
808
|
+
|
|
809
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
810
|
+
|
|
811
|
+
expect(dispatchPluginInteractiveHandlerMock).toHaveBeenCalledTimes(1);
|
|
812
|
+
expect(reply).toHaveBeenCalledWith({ content: "✓", ephemeral: true });
|
|
813
|
+
expect(dispatchReplyMock).toHaveBeenCalledTimes(1);
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
it("resolves plugin binding approvals without falling through to Claw", async () => {
|
|
817
|
+
registerDiscordComponentEntries({
|
|
818
|
+
entries: [
|
|
819
|
+
createButtonEntry({
|
|
820
|
+
callbackData: buildPluginBindingApprovalCustomId("approval-1", "allow-once"),
|
|
821
|
+
}),
|
|
822
|
+
],
|
|
823
|
+
modals: [],
|
|
824
|
+
});
|
|
825
|
+
const button = createDiscordComponentButton(createComponentContext());
|
|
826
|
+
const acknowledge = vi.fn().mockResolvedValue(undefined);
|
|
827
|
+
const followUp = vi.fn().mockResolvedValue(undefined);
|
|
828
|
+
const baseInteraction = createComponentButtonInteraction().interaction as unknown as Record<
|
|
829
|
+
string,
|
|
830
|
+
unknown
|
|
831
|
+
>;
|
|
832
|
+
const interaction = {
|
|
833
|
+
...baseInteraction,
|
|
834
|
+
acknowledge,
|
|
835
|
+
followUp,
|
|
836
|
+
} as unknown as ButtonInteraction;
|
|
837
|
+
|
|
838
|
+
await button.run(interaction, { cid: "btn_1" } as ComponentData);
|
|
839
|
+
|
|
840
|
+
expect(acknowledge).toHaveBeenCalledTimes(1);
|
|
841
|
+
expect(editDiscordComponentMessageMock).toHaveBeenCalledWith(
|
|
842
|
+
"user:123456789",
|
|
843
|
+
"msg-1",
|
|
844
|
+
{ text: expect.any(String) },
|
|
845
|
+
expect.objectContaining({ accountId: "default" }),
|
|
846
|
+
);
|
|
847
|
+
expect(dispatchReplyMock).not.toHaveBeenCalled();
|
|
848
|
+
});
|
|
849
|
+
});
|