@openclaw/discord 2026.5.2 → 2026.5.3-beta.2
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/dist/access-B9ujuUtS.js +89 -0
- package/dist/account-inspect-C2UEUhbG.js +81 -0
- package/dist/account-inspect-api.js +10 -0
- package/dist/accounts-BKnkNaoA.js +128 -0
- package/dist/action-runtime-api.js +2 -0
- package/dist/agent-components.runtime-DUhLr9hy.js +4 -0
- package/dist/allow-list-ek-1hMKN.js +336 -0
- package/dist/api-DzNBVTto.js +130 -0
- package/dist/api.js +24 -0
- package/dist/approval-handler.runtime-v8nzQHlT.js +426 -0
- package/dist/approval-native-DqWGp0bM.js +153 -0
- package/dist/approval-shared-DKnwwjZM.js +93 -0
- package/dist/audit-CJ92YD6J.js +102 -0
- package/dist/channel-B3aTtBj1.js +745 -0
- package/dist/channel-access-ewDxhd9q.js +62 -0
- package/dist/channel-actions-TNih7k3w.js +140 -0
- package/dist/channel-actions.runtime-CaPytiY4.js +236 -0
- package/dist/channel-api-CTSWMrnD.js +21 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.setup-Dt4tIDrl.js +336 -0
- package/dist/components-BapWDmDM.js +760 -0
- package/dist/config-api-CFZtoMaS.js +2 -0
- package/dist/config-schema-DwFkL904.js +252 -0
- package/dist/configured-state.js +6 -0
- package/dist/contract-api.js +8 -0
- package/dist/conversation-identity-BN9wSmxJ.js +31 -0
- package/dist/directory-cache-D93eSrpB.js +62 -0
- package/dist/directory-config-LyMP0sdv.js +49 -0
- package/dist/directory-contract-api.js +2 -0
- package/dist/directory-live-BQapdpkZ.js +101 -0
- package/dist/discord-D1kDh0X_.js +2751 -0
- package/dist/doctor-B2G7WqO0.js +244 -0
- package/dist/doctor-contract-D3pSutkb.js +383 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/doctor-shared-DU8RcnF5.js +4 -0
- package/dist/format-D8TsaXxW.js +24 -0
- package/dist/gateway-registry-BKG4KIVC.js +74 -0
- package/dist/handle-action.guild-admin-BuqsSVXu.js +283 -0
- package/dist/inbound-context-e_oBBJtF.js +51 -0
- package/dist/index.js +26 -0
- package/dist/manager.runtime-M2aAa7qA.js +1019 -0
- package/dist/mentions-BPZUaFk7.js +88 -0
- package/dist/message-handler-D6JfFV3P.js +381 -0
- package/dist/message-handler.preflight-DqaF3vHm.js +1022 -0
- package/dist/message-handler.process-tl3Nwnhr.js +1124 -0
- package/dist/message-utils-Dmgu-7fC.js +512 -0
- package/dist/normalize-B-ktw-T_.js +275 -0
- package/dist/outbound-adapter-DJf9_sfH.js +451 -0
- package/dist/outbound-session-route-uHGLDP-Y.js +43 -0
- package/dist/pluralkit-voQvSN3g.js +22 -0
- package/dist/preflight-audio-BpYtUAT6.js +72 -0
- package/dist/preflight-audio.runtime-BAGmU6uO.js +7 -0
- package/dist/preview-streaming-C0O92Qqz.js +14 -0
- package/dist/probe-DcNEodPI.js +139 -0
- package/dist/probe.runtime-P-e4r1Hl.js +2 -0
- package/dist/provider-CMvXOp-3.js +8440 -0
- package/dist/provider-session.runtime-JFemrDZT.js +6 -0
- package/dist/provider.runtime-BO007oR2.js +2 -0
- package/dist/reply-delivery-D9So77a6.js +131 -0
- package/dist/resolve-allowlist-common-DqqFY_qa.js +34 -0
- package/dist/resolve-channels-CGPntufJ.js +265 -0
- package/dist/resolve-users-CDvSlW0V.js +120 -0
- package/dist/rolldown-runtime-C3SqQTfK.js +28 -0
- package/dist/route-resolution-BYiC-6Cc.js +236 -0
- package/dist/runtime-K9RT6Egn.js +8 -0
- package/dist/runtime-api.actions.js +3 -0
- package/dist/runtime-api.js +31 -0
- package/dist/runtime-api.lookup.js +7 -0
- package/dist/runtime-api.monitor-BC-XN0tY.js +6 -0
- package/dist/runtime-api.monitor.js +9 -0
- package/dist/runtime-api.send.js +6 -0
- package/dist/runtime-api.threads.js +6 -0
- package/dist/runtime-n5xZHW55.js +1001 -0
- package/dist/runtime-setter-api.js +2 -0
- package/dist/secret-config-contract-CoGryS5c.js +115 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/security-audit-Cdz2iq3m.js +120 -0
- package/dist/security-audit-contract-api.js +2 -0
- package/dist/security-audit.runtime-DBV1T1_N.js +2 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/security-contract-ei3Mz8Sa.js +26 -0
- package/dist/security-doctor-CzTzpXV8.js +18 -0
- package/dist/send-B_frVn_Q.js +845 -0
- package/dist/send.components-B1EgHAds.js +468 -0
- package/dist/send.outbound-DlBAuW7y.js +211 -0
- package/dist/send.shared-Db0opnak.js +708 -0
- package/dist/sender-identity-BiSDAk2P.js +43 -0
- package/dist/session-contract-goJZckp2.js +6 -0
- package/dist/session-key-api.js +2 -0
- package/dist/session-key-normalization-Daag9II6.js +23 -0
- package/dist/setup-entry.js +11 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/shared-CqlrJmSs.js +166 -0
- package/dist/shared-interactive-KgJjCqnB.js +79 -0
- package/dist/subagent-hooks-api.js +22 -0
- package/dist/subagent-hooks-mEK5ARfP.js +113 -0
- package/dist/system-events-Bu9jmO4W.js +34 -0
- package/dist/targets-kKlbZ4ai.js +3 -0
- package/dist/test-api.js +45 -0
- package/dist/thread-binding-api.js +4 -0
- package/dist/thread-bindings-Bj1R-6QH.js +256 -0
- package/dist/thread-bindings.discord-api-ClPMuIr8.js +184 -0
- package/dist/thread-bindings.manager-BaN0l4y8.js +535 -0
- package/dist/thread-bindings.session-updates-TTP020qQ.js +54 -0
- package/dist/thread-bindings.state-Dzu1gCE7.js +318 -0
- package/dist/threading-CWhdYHVx.js +475 -0
- package/dist/timeouts-C7jeTtGs.js +52 -0
- package/dist/timeouts.js +2 -0
- package/dist/token-D-w3Rigl.js +42 -0
- package/dist/typing-CJiowRTZ.js +15 -0
- package/package.json +14 -6
- package/account-inspect-api.ts +0 -6
- package/action-runtime-api.ts +0 -1
- package/api.ts +0 -132
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -3
- package/config-api.ts +0 -4
- package/configured-state.ts +0 -6
- package/contract-api.ts +0 -21
- package/directory-contract-api.ts +0 -4
- package/doctor-contract-api.ts +0 -1
- package/index.test.ts +0 -13
- package/index.ts +0 -24
- package/runtime-api.actions.ts +0 -15
- package/runtime-api.lookup.ts +0 -22
- package/runtime-api.monitor.ts +0 -50
- package/runtime-api.send.ts +0 -79
- package/runtime-api.threads.ts +0 -30
- package/runtime-api.ts +0 -180
- package/runtime-setter-api.ts +0 -3
- package/secret-contract-api.ts +0 -4
- package/security-audit-contract-api.ts +0 -1
- package/security-contract-api.ts +0 -4
- package/session-key-api.ts +0 -1
- package/setup-entry.ts +0 -9
- package/setup-plugin-api.ts +0 -3
- package/src/account-inspect.test.ts +0 -126
- package/src/account-inspect.ts +0 -132
- package/src/accounts.test.ts +0 -247
- package/src/accounts.ts +0 -196
- package/src/actions/handle-action.guild-admin.ts +0 -411
- package/src/actions/handle-action.test.ts +0 -306
- package/src/actions/handle-action.ts +0 -372
- package/src/actions/runtime.guild.ts +0 -446
- package/src/actions/runtime.messaging.messages.ts +0 -205
- package/src/actions/runtime.messaging.reactions.ts +0 -67
- package/src/actions/runtime.messaging.runtime.ts +0 -69
- package/src/actions/runtime.messaging.send.ts +0 -248
- package/src/actions/runtime.messaging.shared.ts +0 -97
- package/src/actions/runtime.messaging.ts +0 -37
- package/src/actions/runtime.moderation-shared.ts +0 -48
- package/src/actions/runtime.moderation.authz.test.ts +0 -151
- package/src/actions/runtime.moderation.ts +0 -116
- package/src/actions/runtime.presence.test.ts +0 -160
- package/src/actions/runtime.presence.ts +0 -117
- package/src/actions/runtime.shared.ts +0 -83
- package/src/actions/runtime.test.ts +0 -1087
- package/src/actions/runtime.ts +0 -87
- package/src/api-barrel.test.ts +0 -80
- package/src/api.test.ts +0 -130
- package/src/api.ts +0 -169
- package/src/approval-handler.runtime.test.ts +0 -41
- package/src/approval-handler.runtime.ts +0 -632
- package/src/approval-native.test.ts +0 -330
- package/src/approval-native.ts +0 -219
- package/src/approval-runtime.ts +0 -14
- package/src/approval-shared.ts +0 -53
- package/src/audit-core.ts +0 -141
- package/src/audit.test.ts +0 -145
- package/src/audit.ts +0 -32
- package/src/channel-actions.contract.test.ts +0 -45
- package/src/channel-actions.runtime.ts +0 -1
- package/src/channel-actions.test.ts +0 -275
- package/src/channel-actions.ts +0 -203
- package/src/channel-api.ts +0 -29
- package/src/channel.conversation.ts +0 -159
- package/src/channel.loaders.ts +0 -47
- package/src/channel.runtime.ts +0 -1
- package/src/channel.setup.ts +0 -12
- package/src/channel.test.ts +0 -571
- package/src/channel.ts +0 -629
- package/src/chunk.test.ts +0 -157
- package/src/chunk.ts +0 -321
- package/src/client.proxy.test.ts +0 -176
- package/src/client.test.ts +0 -76
- package/src/client.ts +0 -132
- package/src/component-custom-id.ts +0 -72
- package/src/components-registry.ts +0 -356
- package/src/components.builders.ts +0 -409
- package/src/components.modal.ts +0 -124
- package/src/components.parse.ts +0 -407
- package/src/components.test.ts +0 -312
- package/src/components.ts +0 -54
- package/src/components.types.ts +0 -187
- package/src/config-schema.test.ts +0 -325
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -249
- package/src/conversation-identity.ts +0 -58
- package/src/delivery-retry.ts +0 -56
- package/src/directory-cache.ts +0 -116
- package/src/directory-config.ts +0 -58
- package/src/directory-contract.test.ts +0 -129
- package/src/directory-live.test.ts +0 -126
- package/src/directory-live.ts +0 -135
- package/src/doctor-contract.ts +0 -477
- package/src/doctor-shared.ts +0 -5
- package/src/doctor.test.ts +0 -405
- package/src/doctor.ts +0 -340
- package/src/draft-chunking.test.ts +0 -64
- package/src/draft-chunking.ts +0 -43
- package/src/draft-stream.test.ts +0 -159
- package/src/draft-stream.ts +0 -154
- package/src/error-body.ts +0 -38
- package/src/exec-approvals.test.ts +0 -88
- package/src/exec-approvals.ts +0 -110
- package/src/gateway-logging.test.ts +0 -98
- package/src/gateway-logging.ts +0 -67
- package/src/group-policy.ts +0 -113
- package/src/guilds.ts +0 -29
- package/src/inbound-context.contract.test.ts +0 -11
- package/src/interactive-dispatch.ts +0 -104
- package/src/internal/api.commands.ts +0 -51
- package/src/internal/api.guild.ts +0 -164
- package/src/internal/api.interactions.ts +0 -53
- package/src/internal/api.messages.ts +0 -113
- package/src/internal/api.reactions.ts +0 -38
- package/src/internal/api.test.ts +0 -262
- package/src/internal/api.ts +0 -61
- package/src/internal/api.users.ts +0 -19
- package/src/internal/api.webhooks.ts +0 -13
- package/src/internal/client.test.ts +0 -440
- package/src/internal/client.ts +0 -310
- package/src/internal/command-deploy.ts +0 -297
- package/src/internal/commands.ts +0 -188
- package/src/internal/components.base.ts +0 -65
- package/src/internal/components.message.ts +0 -279
- package/src/internal/components.modal.ts +0 -95
- package/src/internal/components.ts +0 -31
- package/src/internal/discord.ts +0 -11
- package/src/internal/embeds.ts +0 -35
- package/src/internal/entity-cache.ts +0 -98
- package/src/internal/event-queue.ts +0 -162
- package/src/internal/gateway-close-codes.ts +0 -25
- package/src/internal/gateway-dispatch.ts +0 -96
- package/src/internal/gateway-identify-limiter.ts +0 -26
- package/src/internal/gateway-lifecycle.ts +0 -61
- package/src/internal/gateway-rate-limit.ts +0 -104
- package/src/internal/gateway.test.ts +0 -603
- package/src/internal/gateway.ts +0 -476
- package/src/internal/interaction-dispatch.test.ts +0 -148
- package/src/internal/interaction-dispatch.ts +0 -162
- package/src/internal/interaction-options.ts +0 -98
- package/src/internal/interaction-response.ts +0 -53
- package/src/internal/interactions.test.ts +0 -325
- package/src/internal/interactions.ts +0 -378
- package/src/internal/listeners.ts +0 -85
- package/src/internal/live-smoke.live.test.ts +0 -26
- package/src/internal/modal-fields.ts +0 -95
- package/src/internal/payload.ts +0 -69
- package/src/internal/rest-body.ts +0 -115
- package/src/internal/rest-errors.ts +0 -88
- package/src/internal/rest-routes.ts +0 -50
- package/src/internal/rest-scheduler.ts +0 -557
- package/src/internal/rest.test.ts +0 -673
- package/src/internal/rest.ts +0 -322
- package/src/internal/schemas.ts +0 -36
- package/src/internal/structures.test.ts +0 -43
- package/src/internal/structures.ts +0 -280
- package/src/internal/test-builders.test-support.ts +0 -167
- package/src/internal/voice.ts +0 -49
- package/src/media-detection.ts +0 -28
- package/src/mentions.test.ts +0 -111
- package/src/mentions.ts +0 -147
- package/src/monitor/access-groups.ts +0 -55
- package/src/monitor/ack-reactions.ts +0 -70
- package/src/monitor/acp-bind-here.integration.test.ts +0 -211
- package/src/monitor/agent-components-auth.ts +0 -7
- package/src/monitor/agent-components-context.ts +0 -154
- package/src/monitor/agent-components-data.ts +0 -224
- package/src/monitor/agent-components-dm-auth.ts +0 -221
- package/src/monitor/agent-components-guild-auth.ts +0 -322
- package/src/monitor/agent-components-helpers.runtime.ts +0 -5
- package/src/monitor/agent-components-helpers.ts +0 -34
- package/src/monitor/agent-components-reply.ts +0 -10
- package/src/monitor/agent-components.deps.runtime.ts +0 -2
- package/src/monitor/agent-components.dispatch.ts +0 -366
- package/src/monitor/agent-components.handlers.ts +0 -303
- package/src/monitor/agent-components.modal.ts +0 -160
- package/src/monitor/agent-components.plugin-interactive.ts +0 -187
- package/src/monitor/agent-components.runtime.ts +0 -14
- package/src/monitor/agent-components.system-controls.ts +0 -211
- package/src/monitor/agent-components.ts +0 -70
- package/src/monitor/agent-components.types.ts +0 -58
- package/src/monitor/agent-components.wildcard-controls.ts +0 -168
- package/src/monitor/agent-components.wildcard.test.ts +0 -71
- package/src/monitor/allow-list.test.ts +0 -14
- package/src/monitor/allow-list.ts +0 -633
- package/src/monitor/auto-presence.test.ts +0 -156
- package/src/monitor/auto-presence.ts +0 -356
- package/src/monitor/channel-access.test.ts +0 -99
- package/src/monitor/channel-access.ts +0 -102
- package/src/monitor/commands.test.ts +0 -24
- package/src/monitor/commands.ts +0 -9
- package/src/monitor/dm-command-auth.test.ts +0 -197
- package/src/monitor/dm-command-auth.ts +0 -158
- package/src/monitor/dm-command-decision.test.ts +0 -113
- package/src/monitor/dm-command-decision.ts +0 -49
- package/src/monitor/exec-approvals.test.ts +0 -226
- package/src/monitor/exec-approvals.ts +0 -158
- package/src/monitor/format.ts +0 -45
- package/src/monitor/gateway-handle.ts +0 -34
- package/src/monitor/gateway-metadata.test.ts +0 -29
- package/src/monitor/gateway-metadata.ts +0 -298
- package/src/monitor/gateway-plugin.test.ts +0 -297
- package/src/monitor/gateway-plugin.ts +0 -294
- package/src/monitor/gateway-registry.ts +0 -37
- package/src/monitor/gateway-supervisor.test.ts +0 -150
- package/src/monitor/gateway-supervisor.ts +0 -206
- package/src/monitor/inbound-context.test-helpers.ts +0 -37
- package/src/monitor/inbound-context.test.ts +0 -106
- package/src/monitor/inbound-context.ts +0 -103
- package/src/monitor/inbound-dedupe.ts +0 -79
- package/src/monitor/inbound-job.test.ts +0 -203
- package/src/monitor/inbound-job.ts +0 -118
- package/src/monitor/listeners.queue.ts +0 -91
- package/src/monitor/listeners.reactions.ts +0 -610
- package/src/monitor/listeners.test.ts +0 -200
- package/src/monitor/listeners.ts +0 -150
- package/src/monitor/message-channel-info.ts +0 -96
- package/src/monitor/message-forwarded.ts +0 -107
- package/src/monitor/message-handler.batch-gate.test.ts +0 -22
- package/src/monitor/message-handler.batch-gate.ts +0 -19
- package/src/monitor/message-handler.bot-self-filter.test.ts +0 -68
- package/src/monitor/message-handler.context.ts +0 -406
- package/src/monitor/message-handler.dm-preflight.ts +0 -123
- package/src/monitor/message-handler.draft-preview.ts +0 -246
- package/src/monitor/message-handler.hydration.test.ts +0 -80
- package/src/monitor/message-handler.hydration.ts +0 -198
- package/src/monitor/message-handler.inbound-context.test.ts +0 -59
- package/src/monitor/message-handler.module-test-helpers.ts +0 -31
- package/src/monitor/message-handler.preflight-channel-access.ts +0 -86
- package/src/monitor/message-handler.preflight-channel-context.test.ts +0 -18
- package/src/monitor/message-handler.preflight-channel-context.ts +0 -58
- package/src/monitor/message-handler.preflight-context.ts +0 -54
- package/src/monitor/message-handler.preflight-helpers.ts +0 -164
- package/src/monitor/message-handler.preflight-history.ts +0 -23
- package/src/monitor/message-handler.preflight-logging.ts +0 -36
- package/src/monitor/message-handler.preflight-pluralkit.ts +0 -26
- package/src/monitor/message-handler.preflight-runtime.ts +0 -28
- package/src/monitor/message-handler.preflight-thread.ts +0 -49
- package/src/monitor/message-handler.preflight.acp-bindings.test.ts +0 -369
- package/src/monitor/message-handler.preflight.test-helpers.ts +0 -111
- package/src/monitor/message-handler.preflight.test.ts +0 -1623
- package/src/monitor/message-handler.preflight.ts +0 -679
- package/src/monitor/message-handler.preflight.types.ts +0 -110
- package/src/monitor/message-handler.process.test.ts +0 -1369
- package/src/monitor/message-handler.process.ts +0 -686
- package/src/monitor/message-handler.queue.test.ts +0 -496
- package/src/monitor/message-handler.routing-preflight.ts +0 -112
- package/src/monitor/message-handler.test-harness.ts +0 -99
- package/src/monitor/message-handler.test-helpers.ts +0 -75
- package/src/monitor/message-handler.ts +0 -274
- package/src/monitor/message-media.ts +0 -509
- package/src/monitor/message-run-queue.ts +0 -101
- package/src/monitor/message-text.ts +0 -171
- package/src/monitor/message-utils.test.ts +0 -1157
- package/src/monitor/message-utils.ts +0 -32
- package/src/monitor/model-picker-preferences.test.ts +0 -67
- package/src/monitor/model-picker-preferences.ts +0 -184
- package/src/monitor/model-picker.state.ts +0 -364
- package/src/monitor/model-picker.test-utils.ts +0 -26
- package/src/monitor/model-picker.test.ts +0 -794
- package/src/monitor/model-picker.ts +0 -38
- package/src/monitor/model-picker.view.ts +0 -695
- package/src/monitor/monitor.agent-components.test.ts +0 -375
- package/src/monitor/monitor.test.ts +0 -849
- package/src/monitor/monitor.threading-utils.test.ts +0 -598
- package/src/monitor/native-command-agent-reply.ts +0 -125
- package/src/monitor/native-command-arg-ui.ts +0 -233
- package/src/monitor/native-command-auth.ts +0 -308
- package/src/monitor/native-command-bypass.ts +0 -13
- package/src/monitor/native-command-context.test.ts +0 -98
- package/src/monitor/native-command-context.ts +0 -103
- package/src/monitor/native-command-dispatch.ts +0 -35
- package/src/monitor/native-command-model-picker-apply.ts +0 -177
- package/src/monitor/native-command-model-picker-interaction.ts +0 -461
- package/src/monitor/native-command-model-picker-ui.ts +0 -368
- package/src/monitor/native-command-reply.test.ts +0 -68
- package/src/monitor/native-command-reply.ts +0 -185
- package/src/monitor/native-command-route.ts +0 -91
- package/src/monitor/native-command-status.ts +0 -76
- package/src/monitor/native-command-ui.ts +0 -26
- package/src/monitor/native-command-ui.types.ts +0 -20
- package/src/monitor/native-command.args.ts +0 -45
- package/src/monitor/native-command.command-arg.test.ts +0 -99
- package/src/monitor/native-command.commands-allowfrom.test.ts +0 -490
- package/src/monitor/native-command.model-picker.test.ts +0 -767
- package/src/monitor/native-command.options.test.ts +0 -369
- package/src/monitor/native-command.options.ts +0 -153
- package/src/monitor/native-command.plugin-dispatch.test.ts +0 -961
- package/src/monitor/native-command.runtime.ts +0 -50
- package/src/monitor/native-command.status-direct.test.ts +0 -272
- package/src/monitor/native-command.test-helpers.ts +0 -64
- package/src/monitor/native-command.think-autocomplete.test.ts +0 -416
- package/src/monitor/native-command.ts +0 -700
- package/src/monitor/native-command.types.ts +0 -9
- package/src/monitor/native-interaction-channel-context.ts +0 -50
- package/src/monitor/preflight-audio.runtime.ts +0 -9
- package/src/monitor/preflight-audio.test.ts +0 -157
- package/src/monitor/preflight-audio.ts +0 -130
- package/src/monitor/presence-cache.ts +0 -61
- package/src/monitor/presence.test.ts +0 -44
- package/src/monitor/presence.ts +0 -50
- package/src/monitor/provider-session.runtime.ts +0 -12
- package/src/monitor/provider.acp.ts +0 -89
- package/src/monitor/provider.allowlist.test.ts +0 -149
- package/src/monitor/provider.allowlist.ts +0 -394
- package/src/monitor/provider.cleanup.ts +0 -41
- package/src/monitor/provider.commands.ts +0 -129
- package/src/monitor/provider.config-log.ts +0 -45
- package/src/monitor/provider.deploy-errors.ts +0 -362
- package/src/monitor/provider.deploy.ts +0 -221
- package/src/monitor/provider.interactions.ts +0 -160
- package/src/monitor/provider.lifecycle.test.ts +0 -713
- package/src/monitor/provider.lifecycle.ts +0 -552
- package/src/monitor/provider.proxy.test.ts +0 -745
- package/src/monitor/provider.rest-proxy.test.ts +0 -121
- package/src/monitor/provider.runtime.ts +0 -1
- package/src/monitor/provider.skill-dedupe.test.ts +0 -42
- package/src/monitor/provider.startup-log.ts +0 -32
- package/src/monitor/provider.startup.test.ts +0 -426
- package/src/monitor/provider.startup.ts +0 -330
- package/src/monitor/provider.test.ts +0 -1111
- package/src/monitor/provider.ts +0 -713
- package/src/monitor/reply-context.ts +0 -64
- package/src/monitor/reply-delivery.test.ts +0 -244
- package/src/monitor/reply-delivery.ts +0 -203
- package/src/monitor/rest-fetch.ts +0 -43
- package/src/monitor/route-resolution.test.ts +0 -204
- package/src/monitor/route-resolution.ts +0 -140
- package/src/monitor/sender-identity.ts +0 -81
- package/src/monitor/startup-status.test.ts +0 -30
- package/src/monitor/startup-status.ts +0 -10
- package/src/monitor/status.ts +0 -22
- package/src/monitor/system-events.ts +0 -55
- package/src/monitor/thread-bindings.config.ts +0 -35
- package/src/monitor/thread-bindings.discord-api.test.ts +0 -229
- package/src/monitor/thread-bindings.discord-api.ts +0 -310
- package/src/monitor/thread-bindings.lifecycle.test.ts +0 -1871
- package/src/monitor/thread-bindings.lifecycle.ts +0 -354
- package/src/monitor/thread-bindings.manager.ts +0 -553
- package/src/monitor/thread-bindings.messages.ts +0 -6
- package/src/monitor/thread-bindings.persona.test.ts +0 -34
- package/src/monitor/thread-bindings.persona.ts +0 -25
- package/src/monitor/thread-bindings.session-adapter.ts +0 -229
- package/src/monitor/thread-bindings.session-shared.ts +0 -59
- package/src/monitor/thread-bindings.session-updates.ts +0 -35
- package/src/monitor/thread-bindings.shared-state.test.ts +0 -36
- package/src/monitor/thread-bindings.state.ts +0 -540
- package/src/monitor/thread-bindings.ts +0 -48
- package/src/monitor/thread-bindings.types.ts +0 -83
- package/src/monitor/thread-channel-context.ts +0 -112
- package/src/monitor/thread-session-close.test.ts +0 -180
- package/src/monitor/thread-session-close.ts +0 -63
- package/src/monitor/thread-title.generate.test.ts +0 -197
- package/src/monitor/thread-title.test.ts +0 -31
- package/src/monitor/thread-title.ts +0 -181
- package/src/monitor/threading.auto-thread.test.ts +0 -327
- package/src/monitor/threading.auto-thread.ts +0 -287
- package/src/monitor/threading.cache.ts +0 -45
- package/src/monitor/threading.parent-info.test.ts +0 -156
- package/src/monitor/threading.starter.test.ts +0 -260
- package/src/monitor/threading.starter.ts +0 -287
- package/src/monitor/threading.ts +0 -20
- package/src/monitor/threading.types.ts +0 -102
- package/src/monitor/timeouts.ts +0 -84
- package/src/monitor/typing.test.ts +0 -42
- package/src/monitor/typing.ts +0 -17
- package/src/monitor.gateway.test.ts +0 -187
- package/src/monitor.gateway.ts +0 -75
- package/src/monitor.test.ts +0 -1397
- package/src/monitor.ts +0 -28
- package/src/normalize.test.ts +0 -56
- package/src/normalize.ts +0 -86
- package/src/outbound-adapter.interactive-order.test.ts +0 -64
- package/src/outbound-adapter.test-harness.ts +0 -207
- package/src/outbound-adapter.test.ts +0 -696
- package/src/outbound-adapter.ts +0 -291
- package/src/outbound-approval.ts +0 -29
- package/src/outbound-components.ts +0 -81
- package/src/outbound-payload.contract.test.ts +0 -38
- package/src/outbound-payload.ts +0 -134
- package/src/outbound-send-context.ts +0 -92
- package/src/outbound-session-route.test.ts +0 -34
- package/src/outbound-session-route.ts +0 -72
- package/src/pluralkit.test.ts +0 -67
- package/src/pluralkit.ts +0 -58
- package/src/preview-streaming.ts +0 -32
- package/src/probe.intents.test.ts +0 -94
- package/src/probe.parse-token.test.ts +0 -43
- package/src/probe.runtime.ts +0 -1
- package/src/probe.ts +0 -237
- package/src/proxy-fetch.ts +0 -92
- package/src/proxy-request-client.test.ts +0 -78
- package/src/proxy-request-client.ts +0 -21
- package/src/recipient-resolution.ts +0 -39
- package/src/resolve-allowlist-common.test.ts +0 -36
- package/src/resolve-allowlist-common.ts +0 -39
- package/src/resolve-channels.test.ts +0 -340
- package/src/resolve-channels.ts +0 -369
- package/src/resolve-users.test.ts +0 -222
- package/src/resolve-users.ts +0 -184
- package/src/retry.test.ts +0 -83
- package/src/retry.ts +0 -98
- package/src/runtime-api.ts +0 -64
- package/src/runtime.ts +0 -23
- package/src/secret-config-contract.ts +0 -140
- package/src/security-audit.runtime.ts +0 -1
- package/src/security-audit.test.ts +0 -246
- package/src/security-audit.ts +0 -208
- package/src/security-contract.ts +0 -47
- package/src/security-doctor.test.ts +0 -25
- package/src/security-doctor.ts +0 -20
- package/src/security.ts +0 -60
- package/src/send-target-parsing.ts +0 -14
- package/src/send.channels.ts +0 -139
- package/src/send.components.test.ts +0 -275
- package/src/send.components.ts +0 -381
- package/src/send.creates-thread.test.ts +0 -643
- package/src/send.emojis-stickers.ts +0 -57
- package/src/send.guild.ts +0 -170
- package/src/send.message-request.ts +0 -97
- package/src/send.messages.test.ts +0 -53
- package/src/send.messages.ts +0 -225
- package/src/send.outbound.ts +0 -413
- package/src/send.permissions.authz.test.ts +0 -188
- package/src/send.permissions.ts +0 -283
- package/src/send.reactions.ts +0 -155
- package/src/send.sends-basic-channel-messages.test.ts +0 -941
- package/src/send.shared.ts +0 -447
- package/src/send.test-harness.ts +0 -56
- package/src/send.ts +0 -82
- package/src/send.types.ts +0 -188
- package/src/send.typing.test.ts +0 -41
- package/src/send.typing.ts +0 -9
- package/src/send.voice.ts +0 -134
- package/src/send.webhook-activity.test.ts +0 -105
- package/src/send.webhook.proxy.test.ts +0 -191
- package/src/send.webhook.ts +0 -133
- package/src/session-contract.ts +0 -3
- package/src/session-key-normalization.test.ts +0 -44
- package/src/session-key-normalization.ts +0 -47
- package/src/setup-account-state.test.ts +0 -91
- package/src/setup-account-state.ts +0 -144
- package/src/setup-adapter.ts +0 -12
- package/src/setup-core.ts +0 -212
- package/src/setup-runtime-helpers.ts +0 -10
- package/src/setup-surface.test.ts +0 -137
- package/src/setup-surface.ts +0 -129
- package/src/shared-interactive.test.ts +0 -153
- package/src/shared-interactive.ts +0 -124
- package/src/shared.test.ts +0 -165
- package/src/shared.ts +0 -190
- package/src/status-issues.test.ts +0 -70
- package/src/status-issues.ts +0 -169
- package/src/subagent-hooks.test.ts +0 -432
- package/src/subagent-hooks.ts +0 -214
- package/src/target-parsing.ts +0 -53
- package/src/target-resolver.ts +0 -129
- package/src/targets.test.ts +0 -367
- package/src/targets.ts +0 -12
- package/src/test-http-helpers.ts +0 -10
- package/src/test-support/component-runtime.ts +0 -190
- package/src/test-support/config.ts +0 -7
- package/src/test-support/configured-binding-runtime.ts +0 -29
- package/src/test-support/partial-channel.ts +0 -26
- package/src/test-support/provider.test-support.ts +0 -545
- package/src/token.test.ts +0 -107
- package/src/token.ts +0 -60
- package/src/ui-colors.ts +0 -27
- package/src/ui.ts +0 -20
- package/src/voice/access.test.ts +0 -217
- package/src/voice/access.ts +0 -124
- package/src/voice/audio.ts +0 -173
- package/src/voice/capture-state.test.ts +0 -48
- package/src/voice/capture-state.ts +0 -120
- package/src/voice/command.test.ts +0 -164
- package/src/voice/command.ts +0 -283
- package/src/voice/config.ts +0 -8
- package/src/voice/manager.e2e.test.ts +0 -928
- package/src/voice/manager.ready-listener.test.ts +0 -37
- package/src/voice/manager.runtime.ts +0 -11
- package/src/voice/manager.ts +0 -691
- package/src/voice/prompt.test.ts +0 -16
- package/src/voice/prompt.ts +0 -17
- package/src/voice/receive-recovery.test.ts +0 -79
- package/src/voice/receive-recovery.ts +0 -159
- package/src/voice/sanitize.test.ts +0 -34
- package/src/voice/sanitize.ts +0 -32
- package/src/voice/sdk-runtime.ts +0 -14
- package/src/voice/segment.ts +0 -156
- package/src/voice/session.ts +0 -50
- package/src/voice/speaker-context.ts +0 -127
- package/src/voice/tts.ts +0 -125
- package/src/voice-message.test.ts +0 -234
- package/src/voice-message.ts +0 -444
- package/subagent-hooks-api.ts +0 -27
- package/test-api.ts +0 -4
- package/thread-binding-api.ts +0 -1
- package/timeouts.ts +0 -6
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,1022 @@
|
|
|
1
|
+
import { o as resolveDefaultDiscordAccountId } from "./accounts-BKnkNaoA.js";
|
|
2
|
+
import { S as Message, ot as getChannelMessage, t as discord_exports } from "./discord-D1kDh0X_.js";
|
|
3
|
+
import { i as resolveTimestampMs, n as formatDiscordUserTag, r as resolveDiscordSystemLocation } from "./format-D8TsaXxW.js";
|
|
4
|
+
import { _ as resolveGroupDmAllow, a as normalizeDiscordSlug, c as resolveDiscordChannelConfigWithFallback, d as resolveDiscordGuildEntry, f as resolveDiscordMemberAccessState, g as resolveDiscordShouldRequireMention, i as normalizeDiscordDisplaySlug, m as resolveDiscordOwnerAccess, n as isDiscordGroupAllowedByPolicy } from "./allow-list-ek-1hMKN.js";
|
|
5
|
+
import { t as resolveDiscordConversationIdentity } from "./conversation-identity-BN9wSmxJ.js";
|
|
6
|
+
import { l as isRecentlyUnboundThreadWebhookMessage } from "./thread-bindings.state-Dzu1gCE7.js";
|
|
7
|
+
import "./thread-bindings-Bj1R-6QH.js";
|
|
8
|
+
import { n as resolveDiscordChannelInfoSafe, r as resolveDiscordChannelNameSafe } from "./channel-access-ewDxhd9q.js";
|
|
9
|
+
import { c as resolveDiscordChannelInfo, l as resolveDiscordMessageChannelId, r as resolveDiscordMessageText } from "./message-utils-Dmgu-7fC.js";
|
|
10
|
+
import { a as shouldIgnoreStaleDiscordRouteBinding, i as resolveDiscordEffectiveRoute, o as handleDiscordDmCommandDecision, r as resolveDiscordConversationRoute, s as resolveDiscordDmCommandAccess, t as buildDiscordRoutePeer } from "./route-resolution-BYiC-6Cc.js";
|
|
11
|
+
import { n as resolveDiscordWebhookId, t as resolveDiscordSenderIdentity } from "./sender-identity-BiSDAk2P.js";
|
|
12
|
+
import { logDebug, normalizeOptionalString } from "openclaw/plugin-sdk/text-runtime";
|
|
13
|
+
import { getChildLogger, logVerbose, shouldLogVerbose } from "openclaw/plugin-sdk/runtime-env";
|
|
14
|
+
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
|
|
15
|
+
import { formatAllowlistMatchMeta } from "openclaw/plugin-sdk/allow-from";
|
|
16
|
+
import { isDangerousNameMatchingEnabled } from "openclaw/plugin-sdk/dangerous-name-runtime";
|
|
17
|
+
import { enqueueSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
|
|
18
|
+
import { buildMentionRegexes, implicitMentionKindWhen, logInboundDrop, matchesMentionWithExplicit, resolveInboundMentionDecision } from "openclaw/plugin-sdk/channel-inbound";
|
|
19
|
+
import { resolveControlCommandGate } from "openclaw/plugin-sdk/command-auth-native";
|
|
20
|
+
import { hasControlCommand } from "openclaw/plugin-sdk/command-detection";
|
|
21
|
+
import { shouldHandleTextCommands } from "openclaw/plugin-sdk/command-surface";
|
|
22
|
+
import { recordPendingHistoryEntryIfEnabled } from "openclaw/plugin-sdk/reply-history";
|
|
23
|
+
//#region extensions/discord/src/monitor/message-handler.dm-preflight.ts
|
|
24
|
+
let conversationRuntimePromise$1;
|
|
25
|
+
let discordSendRuntimePromise;
|
|
26
|
+
async function loadConversationRuntime$1() {
|
|
27
|
+
conversationRuntimePromise$1 ??= import("openclaw/plugin-sdk/conversation-binding-runtime");
|
|
28
|
+
return await conversationRuntimePromise$1;
|
|
29
|
+
}
|
|
30
|
+
async function loadDiscordSendRuntime() {
|
|
31
|
+
discordSendRuntimePromise ??= import("./send-B_frVn_Q.js").then((n) => n.t);
|
|
32
|
+
return await discordSendRuntimePromise;
|
|
33
|
+
}
|
|
34
|
+
async function resolveDiscordDmPreflightAccess(params) {
|
|
35
|
+
if (params.dmPolicy === "disabled") {
|
|
36
|
+
logVerbose("discord: drop dm (dmPolicy: disabled)");
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const directBindingConversationId = resolveDiscordConversationIdentity({
|
|
40
|
+
isDirectMessage: true,
|
|
41
|
+
userId: params.author.id
|
|
42
|
+
}) ?? `user:${params.author.id}`;
|
|
43
|
+
const directBindingRecord = (await loadConversationRuntime$1()).getSessionBindingService().resolveByConversation({
|
|
44
|
+
channel: "discord",
|
|
45
|
+
accountId: params.preflight.accountId,
|
|
46
|
+
conversationId: directBindingConversationId
|
|
47
|
+
});
|
|
48
|
+
const dmAccess = await resolveDiscordDmCommandAccess({
|
|
49
|
+
accountId: params.resolvedAccountId,
|
|
50
|
+
dmPolicy: params.dmPolicy,
|
|
51
|
+
configuredAllowFrom: params.preflight.allowFrom ?? [],
|
|
52
|
+
sender: {
|
|
53
|
+
id: params.sender.id,
|
|
54
|
+
name: params.sender.name,
|
|
55
|
+
tag: params.sender.tag
|
|
56
|
+
},
|
|
57
|
+
allowNameMatching: params.allowNameMatching,
|
|
58
|
+
useAccessGroups: params.useAccessGroups,
|
|
59
|
+
cfg: params.preflight.cfg,
|
|
60
|
+
token: params.preflight.token,
|
|
61
|
+
rest: params.preflight.client.rest
|
|
62
|
+
});
|
|
63
|
+
const commandAuthorized = dmAccess.commandAuthorized || directBindingRecord != null;
|
|
64
|
+
if (dmAccess.decision === "allow") return { commandAuthorized };
|
|
65
|
+
if (directBindingRecord) {
|
|
66
|
+
logVerbose(`discord: allow bound DM conversation ${directBindingConversationId} despite dmPolicy=${params.dmPolicy}`);
|
|
67
|
+
return { commandAuthorized };
|
|
68
|
+
}
|
|
69
|
+
const allowMatchMeta = formatAllowlistMatchMeta(dmAccess.allowMatch.allowed ? dmAccess.allowMatch : void 0);
|
|
70
|
+
await handleDiscordDmCommandDecision({
|
|
71
|
+
dmAccess,
|
|
72
|
+
accountId: params.resolvedAccountId,
|
|
73
|
+
sender: {
|
|
74
|
+
id: params.author.id,
|
|
75
|
+
tag: formatDiscordUserTag(params.author),
|
|
76
|
+
name: params.author.username ?? void 0
|
|
77
|
+
},
|
|
78
|
+
onPairingCreated: async (code) => {
|
|
79
|
+
logVerbose(`discord pairing request sender=${params.author.id} tag=${formatDiscordUserTag(params.author)} (${allowMatchMeta})`);
|
|
80
|
+
try {
|
|
81
|
+
const conversationRuntime = await loadConversationRuntime$1();
|
|
82
|
+
const { sendMessageDiscord } = await loadDiscordSendRuntime();
|
|
83
|
+
await sendMessageDiscord(`user:${params.author.id}`, conversationRuntime.buildPairingReply({
|
|
84
|
+
channel: "discord",
|
|
85
|
+
idLine: `Your Discord user id: ${params.author.id}`,
|
|
86
|
+
code
|
|
87
|
+
}), {
|
|
88
|
+
cfg: params.preflight.cfg,
|
|
89
|
+
token: params.preflight.token,
|
|
90
|
+
rest: params.preflight.client.rest,
|
|
91
|
+
accountId: params.preflight.accountId
|
|
92
|
+
});
|
|
93
|
+
} catch (err) {
|
|
94
|
+
logVerbose(`discord pairing reply failed for ${params.author.id}: ${String(err)}`);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
onUnauthorized: async () => {
|
|
98
|
+
logVerbose(`Blocked unauthorized discord sender ${params.sender.id} (dmPolicy=${params.dmPolicy}, ${allowMatchMeta})`);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region extensions/discord/src/monitor/message-handler.hydration.ts
|
|
105
|
+
function mergeFetchedDiscordMessage(base, fetched) {
|
|
106
|
+
const baseRawData = readMessageRawData(base);
|
|
107
|
+
const baseFallback = readMessageFallback(base);
|
|
108
|
+
const rawData = {
|
|
109
|
+
...baseRawData,
|
|
110
|
+
...fetched,
|
|
111
|
+
id: fetched.id ?? baseRawData.id ?? baseFallback.id,
|
|
112
|
+
channel_id: fetched.channel_id ?? baseRawData.channel_id ?? baseFallback.channel_id,
|
|
113
|
+
content: fetched.content ?? baseRawData.content ?? baseFallback.content,
|
|
114
|
+
author: fetched.author ?? baseRawData.author ?? baseFallback.author,
|
|
115
|
+
attachments: fetched.attachments ?? baseRawData.attachments ?? baseFallback.attachments,
|
|
116
|
+
embeds: fetched.embeds ?? baseRawData.embeds ?? baseFallback.embeds,
|
|
117
|
+
mentions: fetched.mentions ?? baseRawData.mentions ?? baseFallback.mentions,
|
|
118
|
+
mention_roles: fetched.mention_roles ?? baseRawData.mention_roles ?? baseFallback.mention_roles,
|
|
119
|
+
mention_everyone: fetched.mention_everyone ?? baseRawData.mention_everyone ?? baseFallback.mention_everyone,
|
|
120
|
+
timestamp: fetched.timestamp ?? baseRawData.timestamp ?? baseFallback.timestamp,
|
|
121
|
+
tts: fetched.tts ?? baseRawData.tts ?? false,
|
|
122
|
+
pinned: fetched.pinned ?? baseRawData.pinned ?? false,
|
|
123
|
+
type: fetched.type ?? baseRawData.type ?? 0,
|
|
124
|
+
message_snapshots: fetched.message_snapshots ?? baseRawData.message_snapshots ?? baseFallback.message_snapshots,
|
|
125
|
+
sticker_items: fetched.sticker_items ?? baseRawData.sticker_items ?? baseFallback.sticker_items
|
|
126
|
+
};
|
|
127
|
+
const hydrated = new Message(readMessageClient(base), rawData);
|
|
128
|
+
copyRuntimeMessageFields(base, hydrated);
|
|
129
|
+
return hydrated;
|
|
130
|
+
}
|
|
131
|
+
function readMessageClient(message) {
|
|
132
|
+
return message.client;
|
|
133
|
+
}
|
|
134
|
+
function readMessageRawData(message) {
|
|
135
|
+
try {
|
|
136
|
+
const rawData = message.rawData;
|
|
137
|
+
return rawData && typeof rawData === "object" ? rawData : {};
|
|
138
|
+
} catch {
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function readMessageFallback(message) {
|
|
143
|
+
const value = message;
|
|
144
|
+
return {
|
|
145
|
+
id: typeof value.id === "string" ? value.id : "",
|
|
146
|
+
channel_id: readString(value.channel_id) ?? readString(value.channelId) ?? "",
|
|
147
|
+
content: typeof value.content === "string" ? value.content : "",
|
|
148
|
+
author: normalizeApiUser(value.author),
|
|
149
|
+
attachments: Array.isArray(value.attachments) ? value.attachments : [],
|
|
150
|
+
embeds: Array.isArray(value.embeds) ? value.embeds : [],
|
|
151
|
+
mentions: normalizeApiUsers(value.mentionedUsers),
|
|
152
|
+
mention_roles: normalizeStringArray(value.mentionedRoles),
|
|
153
|
+
mention_everyone: value.mentionedEveryone === true,
|
|
154
|
+
timestamp: readString(value.timestamp) ?? "1970-01-01T00:00:00.000Z",
|
|
155
|
+
sticker_items: Array.isArray(value.sticker_items) ? value.sticker_items : Array.isArray(value.stickers) ? value.stickers : void 0,
|
|
156
|
+
message_snapshots: Array.isArray(value.message_snapshots) ? value.message_snapshots : void 0
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function readString(value) {
|
|
160
|
+
return typeof value === "string" ? value : void 0;
|
|
161
|
+
}
|
|
162
|
+
function normalizeStringArray(value) {
|
|
163
|
+
return Array.isArray(value) ? value.flatMap((entry) => typeof entry === "string" ? [entry] : []) : [];
|
|
164
|
+
}
|
|
165
|
+
function normalizeApiUsers(value) {
|
|
166
|
+
return Array.isArray(value) ? value.flatMap((entry) => {
|
|
167
|
+
const user = normalizeApiUser(entry);
|
|
168
|
+
return user.id ? [user] : [];
|
|
169
|
+
}) : [];
|
|
170
|
+
}
|
|
171
|
+
function normalizeApiUser(value) {
|
|
172
|
+
if (!value || typeof value !== "object") return {
|
|
173
|
+
id: "",
|
|
174
|
+
username: "",
|
|
175
|
+
discriminator: "0",
|
|
176
|
+
global_name: null,
|
|
177
|
+
avatar: null
|
|
178
|
+
};
|
|
179
|
+
const input = value;
|
|
180
|
+
return {
|
|
181
|
+
id: readString(input.id) ?? "",
|
|
182
|
+
username: readString(input.username) ?? "",
|
|
183
|
+
discriminator: readString(input.discriminator) ?? "0",
|
|
184
|
+
global_name: readString(input.global_name) ?? readString(input.globalName) ?? null,
|
|
185
|
+
avatar: input.avatar === null ? null : readString(input.avatar) ?? null,
|
|
186
|
+
...typeof input.bot === "boolean" ? { bot: input.bot } : {}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function copyRuntimeMessageFields(source, target) {
|
|
190
|
+
const channelDescriptor = Object.getOwnPropertyDescriptor(source, "channel");
|
|
191
|
+
if (channelDescriptor) Object.defineProperty(target, "channel", channelDescriptor);
|
|
192
|
+
}
|
|
193
|
+
function shouldHydrateDiscordMessage(params) {
|
|
194
|
+
let currentText = "";
|
|
195
|
+
try {
|
|
196
|
+
currentText = resolveDiscordMessageText(params.message, { includeForwarded: true });
|
|
197
|
+
} catch {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
if (!currentText) return true;
|
|
201
|
+
if ((params.message.mentionedUsers?.length ?? 0) > 0 || (params.message.mentionedRoles?.length ?? 0) > 0 || params.message.mentionedEveryone) return false;
|
|
202
|
+
return /<@!?\d+>|<@&\d+>|@everyone|@here/u.test(currentText);
|
|
203
|
+
}
|
|
204
|
+
async function hydrateDiscordMessageIfNeeded(params) {
|
|
205
|
+
params.channelInfo;
|
|
206
|
+
if (!shouldHydrateDiscordMessage({ message: params.message })) return params.message;
|
|
207
|
+
try {
|
|
208
|
+
const fetched = await getChannelMessage(params.client.rest, params.messageChannelId, params.message.id);
|
|
209
|
+
if (!fetched) return params.message;
|
|
210
|
+
logVerbose(`discord: hydrated inbound payload via REST for ${params.message.id}`);
|
|
211
|
+
return mergeFetchedDiscordMessage(params.message, fetched);
|
|
212
|
+
} catch (err) {
|
|
213
|
+
logVerbose(`discord: failed to hydrate message ${params.message.id}: ${String(err)}`);
|
|
214
|
+
return params.message;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-channel-access.ts
|
|
219
|
+
function resolveDiscordPreflightChannelAccess(params) {
|
|
220
|
+
if (params.isGuildMessage && params.channelConfig?.enabled === false) {
|
|
221
|
+
logDebug(`[discord-preflight] drop: channel disabled`);
|
|
222
|
+
logVerbose(`Blocked discord channel ${params.messageChannelId} (channel disabled, ${params.channelMatchMeta})`);
|
|
223
|
+
return {
|
|
224
|
+
allowed: false,
|
|
225
|
+
channelAllowlistConfigured: false,
|
|
226
|
+
channelAllowed: false
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const groupDmAllowed = params.isGroupDm && resolveGroupDmAllow({
|
|
230
|
+
channels: params.groupDmChannels,
|
|
231
|
+
channelId: params.messageChannelId,
|
|
232
|
+
channelName: params.displayChannelName,
|
|
233
|
+
channelSlug: params.displayChannelSlug
|
|
234
|
+
});
|
|
235
|
+
if (params.isGroupDm && !groupDmAllowed) return {
|
|
236
|
+
allowed: false,
|
|
237
|
+
channelAllowlistConfigured: false,
|
|
238
|
+
channelAllowed: false
|
|
239
|
+
};
|
|
240
|
+
const channelAllowlistConfigured = Boolean(params.guildInfo?.channels) && Object.keys(params.guildInfo?.channels ?? {}).length > 0;
|
|
241
|
+
const channelAllowed = params.channelConfig?.allowed !== false;
|
|
242
|
+
if (params.isGuildMessage && !isDiscordGroupAllowedByPolicy({
|
|
243
|
+
groupPolicy: params.groupPolicy,
|
|
244
|
+
guildAllowlisted: Boolean(params.guildInfo),
|
|
245
|
+
channelAllowlistConfigured,
|
|
246
|
+
channelAllowed
|
|
247
|
+
})) {
|
|
248
|
+
if (params.groupPolicy === "disabled") {
|
|
249
|
+
logDebug(`[discord-preflight] drop: groupPolicy disabled`);
|
|
250
|
+
logVerbose(`discord: drop guild message (groupPolicy: disabled, ${params.channelMatchMeta})`);
|
|
251
|
+
} else if (!channelAllowlistConfigured) {
|
|
252
|
+
logDebug(`[discord-preflight] drop: groupPolicy allowlist, no channel allowlist configured`);
|
|
253
|
+
logVerbose(`discord: drop guild message (groupPolicy: allowlist, no channel allowlist, ${params.channelMatchMeta})`);
|
|
254
|
+
} else {
|
|
255
|
+
logDebug(`[discord] Ignored message from channel ${params.messageChannelId} (not in guild allowlist). Add to guilds.<guildId>.channels to enable.`);
|
|
256
|
+
logVerbose(`Blocked discord channel ${params.messageChannelId} not in guild channel allowlist (groupPolicy: allowlist, ${params.channelMatchMeta})`);
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
allowed: false,
|
|
260
|
+
channelAllowlistConfigured,
|
|
261
|
+
channelAllowed
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
if (params.isGuildMessage && params.channelConfig?.allowed === false) {
|
|
265
|
+
logDebug(`[discord-preflight] drop: channelConfig.allowed===false`);
|
|
266
|
+
logVerbose(`Blocked discord channel ${params.messageChannelId} not in guild channel allowlist (${params.channelMatchMeta})`);
|
|
267
|
+
return {
|
|
268
|
+
allowed: false,
|
|
269
|
+
channelAllowlistConfigured,
|
|
270
|
+
channelAllowed
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
if (params.isGuildMessage) {
|
|
274
|
+
logDebug(`[discord-preflight] pass: channel allowed`);
|
|
275
|
+
logVerbose(`discord: allow channel ${params.messageChannelId} (${params.channelMatchMeta})`);
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
allowed: true,
|
|
279
|
+
channelAllowlistConfigured,
|
|
280
|
+
channelAllowed
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-channel-context.ts
|
|
285
|
+
function resolveDiscordPreflightChannelContext(params) {
|
|
286
|
+
const threadName = params.threadChannel?.name;
|
|
287
|
+
const configChannelName = params.threadParentName ?? params.channelName;
|
|
288
|
+
const configChannelSlug = configChannelName ? normalizeDiscordSlug(configChannelName) : "";
|
|
289
|
+
const displayChannelName = threadName ?? params.channelName;
|
|
290
|
+
const displayChannelSlug = displayChannelName ? normalizeDiscordDisplaySlug(displayChannelName) : "";
|
|
291
|
+
const guildSlug = params.guildInfo?.slug || (params.guildName ? normalizeDiscordSlug(params.guildName) : "");
|
|
292
|
+
const threadChannelSlug = params.channelName ? normalizeDiscordSlug(params.channelName) : "";
|
|
293
|
+
const threadParentSlug = params.threadParentName ? normalizeDiscordSlug(params.threadParentName) : "";
|
|
294
|
+
return {
|
|
295
|
+
threadName,
|
|
296
|
+
configChannelName,
|
|
297
|
+
configChannelSlug,
|
|
298
|
+
displayChannelName,
|
|
299
|
+
displayChannelSlug,
|
|
300
|
+
guildSlug,
|
|
301
|
+
threadChannelSlug,
|
|
302
|
+
threadParentSlug,
|
|
303
|
+
channelConfig: params.isGuildMessage ? resolveDiscordChannelConfigWithFallback({
|
|
304
|
+
guildInfo: params.guildInfo,
|
|
305
|
+
channelId: params.messageChannelId,
|
|
306
|
+
channelName: params.channelName,
|
|
307
|
+
channelSlug: threadChannelSlug,
|
|
308
|
+
parentId: params.threadParentId,
|
|
309
|
+
parentName: params.threadParentName,
|
|
310
|
+
parentSlug: threadParentSlug,
|
|
311
|
+
scope: params.threadChannel ? "thread" : "channel"
|
|
312
|
+
}) : null
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-context.ts
|
|
317
|
+
function buildDiscordMessagePreflightContext({ preflightParams, ...fields }) {
|
|
318
|
+
return {
|
|
319
|
+
cfg: preflightParams.cfg,
|
|
320
|
+
discordConfig: preflightParams.discordConfig,
|
|
321
|
+
accountId: preflightParams.accountId,
|
|
322
|
+
token: preflightParams.token,
|
|
323
|
+
runtime: preflightParams.runtime,
|
|
324
|
+
botUserId: preflightParams.botUserId,
|
|
325
|
+
abortSignal: preflightParams.abortSignal,
|
|
326
|
+
guildHistories: preflightParams.guildHistories,
|
|
327
|
+
historyLimit: preflightParams.historyLimit,
|
|
328
|
+
mediaMaxBytes: preflightParams.mediaMaxBytes,
|
|
329
|
+
textLimit: preflightParams.textLimit,
|
|
330
|
+
replyToMode: preflightParams.replyToMode,
|
|
331
|
+
ackReactionScope: preflightParams.ackReactionScope,
|
|
332
|
+
groupPolicy: preflightParams.groupPolicy,
|
|
333
|
+
...fields,
|
|
334
|
+
threadBindings: preflightParams.threadBindings,
|
|
335
|
+
discordRestFetch: preflightParams.discordRestFetch
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-helpers.ts
|
|
340
|
+
const DISCORD_BOUND_THREAD_SYSTEM_PREFIXES = [
|
|
341
|
+
"⚙️",
|
|
342
|
+
"🤖",
|
|
343
|
+
"🧰"
|
|
344
|
+
];
|
|
345
|
+
function isBoundThreadBotSystemMessage(params) {
|
|
346
|
+
if (!params.isBoundThreadSession || !params.isBotAuthor) return false;
|
|
347
|
+
const text = params.text?.trim();
|
|
348
|
+
if (!text) return false;
|
|
349
|
+
return DISCORD_BOUND_THREAD_SYSTEM_PREFIXES.some((prefix) => text.startsWith(prefix));
|
|
350
|
+
}
|
|
351
|
+
function isDiscordThreadChannelType(type) {
|
|
352
|
+
return type === discord_exports.ChannelType.PublicThread || type === discord_exports.ChannelType.PrivateThread || type === discord_exports.ChannelType.AnnouncementThread;
|
|
353
|
+
}
|
|
354
|
+
function isDiscordThreadChannelMessage(params) {
|
|
355
|
+
if (!params.isGuildMessage) return false;
|
|
356
|
+
const channel = "channel" in params.message ? params.message.channel : void 0;
|
|
357
|
+
return Boolean(channel && typeof channel === "object" && "isThread" in channel && typeof channel.isThread === "function" && channel.isThread() || isDiscordThreadChannelType(params.channelInfo?.type));
|
|
358
|
+
}
|
|
359
|
+
function resolveInjectedBoundThreadLookupRecord(params) {
|
|
360
|
+
const getByThreadId = params.threadBindings.getByThreadId;
|
|
361
|
+
if (typeof getByThreadId !== "function") return;
|
|
362
|
+
const binding = getByThreadId(params.threadId);
|
|
363
|
+
return binding && typeof binding === "object" ? binding : void 0;
|
|
364
|
+
}
|
|
365
|
+
function resolveDiscordMentionState(params) {
|
|
366
|
+
if (params.isDirectMessage) return {
|
|
367
|
+
implicitMentionKinds: [],
|
|
368
|
+
wasMentioned: false
|
|
369
|
+
};
|
|
370
|
+
const wasMentioned = params.mentionedEveryone && (!params.authorIsBot || params.senderIsPluralKit) || matchesMentionWithExplicit({
|
|
371
|
+
text: params.mentionText,
|
|
372
|
+
mentionRegexes: params.mentionRegexes,
|
|
373
|
+
explicit: {
|
|
374
|
+
hasAnyMention: params.hasAnyMention,
|
|
375
|
+
isExplicitlyMentioned: params.isExplicitlyMentioned,
|
|
376
|
+
canResolveExplicit: Boolean(params.botId)
|
|
377
|
+
},
|
|
378
|
+
transcript: params.transcript
|
|
379
|
+
});
|
|
380
|
+
return {
|
|
381
|
+
implicitMentionKinds: implicitMentionKindWhen("reply_to_bot", Boolean(params.botId) && Boolean(params.referencedAuthorId) && params.referencedAuthorId === params.botId),
|
|
382
|
+
wasMentioned
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function resolvePreflightMentionRequirement(params) {
|
|
386
|
+
if (!params.shouldRequireMention) return false;
|
|
387
|
+
return !params.bypassMentionRequirement;
|
|
388
|
+
}
|
|
389
|
+
function shouldIgnoreBoundThreadWebhookMessage(params) {
|
|
390
|
+
const webhookId = normalizeOptionalString(params.webhookId) ?? "";
|
|
391
|
+
if (!webhookId) return false;
|
|
392
|
+
const boundWebhookId = normalizeOptionalString(params.threadBinding?.webhookId) ?? normalizeOptionalString(params.threadBinding?.metadata?.webhookId) ?? "";
|
|
393
|
+
if (boundWebhookId && webhookId === boundWebhookId) return true;
|
|
394
|
+
const threadId = normalizeOptionalString(params.threadId) ?? "";
|
|
395
|
+
if (!threadId) return false;
|
|
396
|
+
if (params.threadBinding) return true;
|
|
397
|
+
return isRecentlyUnboundThreadWebhookMessage({
|
|
398
|
+
accountId: params.accountId,
|
|
399
|
+
threadId,
|
|
400
|
+
webhookId
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-history.ts
|
|
405
|
+
function buildDiscordPreflightHistoryEntry(params) {
|
|
406
|
+
const textForHistory = resolveDiscordMessageText(params.message, { includeForwarded: true });
|
|
407
|
+
return params.isGuildMessage && params.historyLimit > 0 && textForHistory ? {
|
|
408
|
+
sender: params.senderLabel,
|
|
409
|
+
body: textForHistory,
|
|
410
|
+
timestamp: resolveTimestampMs(params.message.timestamp),
|
|
411
|
+
messageId: params.message.id
|
|
412
|
+
} : void 0;
|
|
413
|
+
}
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-logging.ts
|
|
416
|
+
function logDiscordPreflightChannelConfig(params) {
|
|
417
|
+
if (!shouldLogVerbose()) return;
|
|
418
|
+
logDebug(`[discord-preflight] channelConfig=${params.channelConfig ? `allowed=${params.channelConfig.allowed} enabled=${params.channelConfig.enabled ?? "unset"} requireMention=${params.channelConfig.requireMention ?? "unset"} ignoreOtherMentions=${params.channelConfig.ignoreOtherMentions ?? "unset"} matchKey=${params.channelConfig.matchKey ?? "none"} matchSource=${params.channelConfig.matchSource ?? "none"} users=${params.channelConfig.users?.length ?? 0} roles=${params.channelConfig.roles?.length ?? 0} skills=${params.channelConfig.skills?.length ?? 0}` : "none"} channelMatchMeta=${params.channelMatchMeta} channelId=${params.channelId}`);
|
|
419
|
+
}
|
|
420
|
+
function logDiscordPreflightInboundSummary(params) {
|
|
421
|
+
if (!shouldLogVerbose()) return;
|
|
422
|
+
logVerbose(`discord: inbound id=${params.messageId} guild=${params.guildId ?? "dm"} channel=${params.channelId} mention=${params.wasMentioned ? "yes" : "no"} type=${params.isDirectMessage ? "dm" : params.isGroupDm ? "group-dm" : "guild"} content=${params.hasContent ? "yes" : "no"}`);
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-runtime.ts
|
|
426
|
+
let pluralkitRuntimePromise;
|
|
427
|
+
let preflightAudioRuntimePromise;
|
|
428
|
+
let systemEventsRuntimePromise;
|
|
429
|
+
let discordThreadingRuntimePromise;
|
|
430
|
+
async function loadPluralKitRuntime() {
|
|
431
|
+
pluralkitRuntimePromise ??= import("./pluralkit-voQvSN3g.js").then((n) => n.n);
|
|
432
|
+
return await pluralkitRuntimePromise;
|
|
433
|
+
}
|
|
434
|
+
async function loadPreflightAudioRuntime() {
|
|
435
|
+
preflightAudioRuntimePromise ??= import("./preflight-audio-BpYtUAT6.js");
|
|
436
|
+
return await preflightAudioRuntimePromise;
|
|
437
|
+
}
|
|
438
|
+
async function loadSystemEventsRuntime() {
|
|
439
|
+
systemEventsRuntimePromise ??= import("./system-events-Bu9jmO4W.js");
|
|
440
|
+
return await systemEventsRuntimePromise;
|
|
441
|
+
}
|
|
442
|
+
async function loadDiscordThreadingRuntime() {
|
|
443
|
+
discordThreadingRuntimePromise ??= import("./threading-CWhdYHVx.js").then((n) => n.t);
|
|
444
|
+
return await discordThreadingRuntimePromise;
|
|
445
|
+
}
|
|
446
|
+
function isPreflightAborted(abortSignal) {
|
|
447
|
+
return Boolean(abortSignal?.aborted);
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-pluralkit.ts
|
|
451
|
+
async function resolveDiscordPreflightPluralKitInfo(params) {
|
|
452
|
+
if (!params.config?.enabled) return null;
|
|
453
|
+
try {
|
|
454
|
+
const { fetchPluralKitMessageInfo } = await loadPluralKitRuntime();
|
|
455
|
+
const info = await fetchPluralKitMessageInfo({
|
|
456
|
+
messageId: params.message.id,
|
|
457
|
+
config: params.config
|
|
458
|
+
});
|
|
459
|
+
return isPreflightAborted(params.abortSignal) ? null : info;
|
|
460
|
+
} catch (err) {
|
|
461
|
+
logVerbose(`discord: pluralkit lookup failed for ${params.message.id}: ${String(err)}`);
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region extensions/discord/src/monitor/message-handler.preflight-thread.ts
|
|
467
|
+
async function resolveDiscordPreflightThreadContext(params) {
|
|
468
|
+
const { resolveDiscordThreadChannel, resolveDiscordThreadParentInfo } = await loadDiscordThreadingRuntime();
|
|
469
|
+
const earlyThreadChannel = resolveDiscordThreadChannel({
|
|
470
|
+
isGuildMessage: params.isGuildMessage,
|
|
471
|
+
message: params.message,
|
|
472
|
+
channelInfo: params.channelInfo,
|
|
473
|
+
messageChannelId: params.messageChannelId
|
|
474
|
+
});
|
|
475
|
+
if (!earlyThreadChannel) return { earlyThreadChannel: null };
|
|
476
|
+
const parentInfo = await resolveDiscordThreadParentInfo({
|
|
477
|
+
client: params.client,
|
|
478
|
+
threadChannel: earlyThreadChannel,
|
|
479
|
+
channelInfo: params.channelInfo
|
|
480
|
+
});
|
|
481
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
482
|
+
return {
|
|
483
|
+
earlyThreadChannel,
|
|
484
|
+
earlyThreadParentId: parentInfo.id,
|
|
485
|
+
earlyThreadParentName: parentInfo.name,
|
|
486
|
+
earlyThreadParentType: parentInfo.type
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region extensions/discord/src/monitor/message-handler.routing-preflight.ts
|
|
491
|
+
let conversationRuntimePromise;
|
|
492
|
+
async function loadConversationRuntime() {
|
|
493
|
+
conversationRuntimePromise ??= import("openclaw/plugin-sdk/conversation-binding-runtime");
|
|
494
|
+
return await conversationRuntimePromise;
|
|
495
|
+
}
|
|
496
|
+
async function resolveDiscordPreflightRoute(params) {
|
|
497
|
+
const conversationRuntime = await loadConversationRuntime();
|
|
498
|
+
const route = resolveDiscordConversationRoute({
|
|
499
|
+
cfg: params.preflight.cfg,
|
|
500
|
+
accountId: params.preflight.accountId,
|
|
501
|
+
guildId: params.preflight.data.guild_id ?? void 0,
|
|
502
|
+
memberRoleIds: params.memberRoleIds,
|
|
503
|
+
peer: buildDiscordRoutePeer({
|
|
504
|
+
isDirectMessage: params.isDirectMessage,
|
|
505
|
+
isGroupDm: params.isGroupDm,
|
|
506
|
+
directUserId: params.author.id,
|
|
507
|
+
conversationId: params.messageChannelId
|
|
508
|
+
}),
|
|
509
|
+
parentConversationId: params.earlyThreadParentId
|
|
510
|
+
});
|
|
511
|
+
const bindingConversationId = params.isDirectMessage ? resolveDiscordConversationIdentity({
|
|
512
|
+
isDirectMessage: true,
|
|
513
|
+
userId: params.author.id
|
|
514
|
+
}) ?? `user:${params.author.id}` : params.messageChannelId;
|
|
515
|
+
let runtimeRoute = conversationRuntime.resolveRuntimeConversationBindingRoute({
|
|
516
|
+
route,
|
|
517
|
+
conversation: {
|
|
518
|
+
channel: "discord",
|
|
519
|
+
accountId: params.preflight.accountId,
|
|
520
|
+
conversationId: bindingConversationId,
|
|
521
|
+
parentConversationId: params.earlyThreadParentId
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
if (shouldIgnoreStaleDiscordRouteBinding({
|
|
525
|
+
bindingRecord: runtimeRoute.bindingRecord,
|
|
526
|
+
route
|
|
527
|
+
})) {
|
|
528
|
+
logVerbose(`discord: ignoring stale route binding for conversation ${bindingConversationId} (${runtimeRoute.bindingRecord?.targetSessionKey} -> ${route.sessionKey})`);
|
|
529
|
+
runtimeRoute = {
|
|
530
|
+
bindingRecord: null,
|
|
531
|
+
route
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
let threadBinding = runtimeRoute.bindingRecord ?? void 0;
|
|
535
|
+
const configuredRoute = threadBinding == null ? conversationRuntime.resolveConfiguredBindingRoute({
|
|
536
|
+
cfg: params.preflight.cfg,
|
|
537
|
+
route,
|
|
538
|
+
conversation: {
|
|
539
|
+
channel: "discord",
|
|
540
|
+
accountId: params.preflight.accountId,
|
|
541
|
+
conversationId: params.messageChannelId,
|
|
542
|
+
parentConversationId: params.earlyThreadParentId
|
|
543
|
+
}
|
|
544
|
+
}) : null;
|
|
545
|
+
const configuredBinding = configuredRoute?.bindingResolution ?? null;
|
|
546
|
+
if (!threadBinding && configuredBinding) threadBinding = configuredBinding.record;
|
|
547
|
+
const boundSessionKey = conversationRuntime.isPluginOwnedSessionBindingRecord(threadBinding) ? "" : runtimeRoute.boundSessionKey ?? threadBinding?.targetSessionKey?.trim();
|
|
548
|
+
const effectiveRoute = runtimeRoute.boundSessionKey ? runtimeRoute.route : resolveDiscordEffectiveRoute({
|
|
549
|
+
route,
|
|
550
|
+
boundSessionKey,
|
|
551
|
+
configuredRoute,
|
|
552
|
+
matchedBy: "binding.channel"
|
|
553
|
+
});
|
|
554
|
+
return {
|
|
555
|
+
conversationRuntime,
|
|
556
|
+
threadBinding,
|
|
557
|
+
configuredBinding,
|
|
558
|
+
boundSessionKey,
|
|
559
|
+
effectiveRoute,
|
|
560
|
+
boundAgentId: boundSessionKey ? effectiveRoute.agentId : void 0,
|
|
561
|
+
baseSessionKey: effectiveRoute.sessionKey
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region extensions/discord/src/monitor/message-handler.preflight.ts
|
|
566
|
+
function resolveDiscordPreflightConversationKind(params) {
|
|
567
|
+
const isGroupDm = params.channelType === discord_exports.ChannelType.GroupDM;
|
|
568
|
+
return {
|
|
569
|
+
isDirectMessage: params.channelType === discord_exports.ChannelType.DM || !params.isGuildMessage && !isGroupDm && params.channelType == null,
|
|
570
|
+
isGroupDm
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
async function preflightDiscordMessage(params) {
|
|
574
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
575
|
+
const logger = getChildLogger({ module: "discord-auto-reply" });
|
|
576
|
+
let message = params.data.message;
|
|
577
|
+
const author = params.data.author;
|
|
578
|
+
if (!author) return null;
|
|
579
|
+
const messageChannelId = resolveDiscordMessageChannelId({
|
|
580
|
+
message,
|
|
581
|
+
eventChannelId: params.data.channel_id
|
|
582
|
+
});
|
|
583
|
+
if (!messageChannelId) {
|
|
584
|
+
logVerbose(`discord: drop message ${message.id} (missing channel id)`);
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
const allowBotsSetting = params.discordConfig?.allowBots;
|
|
588
|
+
const allowBotsMode = allowBotsSetting === "mentions" ? "mentions" : allowBotsSetting === true ? "all" : "off";
|
|
589
|
+
if (params.botUserId && author.id === params.botUserId) return null;
|
|
590
|
+
message = await hydrateDiscordMessageIfNeeded({
|
|
591
|
+
client: params.client,
|
|
592
|
+
message,
|
|
593
|
+
messageChannelId
|
|
594
|
+
});
|
|
595
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
596
|
+
const pluralkitConfig = params.discordConfig?.pluralkit;
|
|
597
|
+
const webhookId = resolveDiscordWebhookId(message);
|
|
598
|
+
const isGuildMessage = Boolean(params.data.guild_id);
|
|
599
|
+
const channelInfo = await resolveDiscordChannelInfo(params.client, messageChannelId);
|
|
600
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
601
|
+
const { isDirectMessage, isGroupDm } = resolveDiscordPreflightConversationKind({
|
|
602
|
+
isGuildMessage,
|
|
603
|
+
channelType: channelInfo?.type
|
|
604
|
+
});
|
|
605
|
+
const messageText = resolveDiscordMessageText(message, { includeForwarded: true });
|
|
606
|
+
const injectedBoundThreadBinding = !isDirectMessage && !isGroupDm ? resolveInjectedBoundThreadLookupRecord({
|
|
607
|
+
threadBindings: params.threadBindings,
|
|
608
|
+
threadId: messageChannelId
|
|
609
|
+
}) : void 0;
|
|
610
|
+
if (shouldIgnoreBoundThreadWebhookMessage({
|
|
611
|
+
accountId: params.accountId,
|
|
612
|
+
threadId: messageChannelId,
|
|
613
|
+
webhookId,
|
|
614
|
+
threadBinding: injectedBoundThreadBinding
|
|
615
|
+
})) {
|
|
616
|
+
logVerbose(`discord: drop bound-thread webhook echo message ${message.id}`);
|
|
617
|
+
return null;
|
|
618
|
+
}
|
|
619
|
+
if (isBoundThreadBotSystemMessage({
|
|
620
|
+
isBoundThreadSession: Boolean(injectedBoundThreadBinding) && isDiscordThreadChannelMessage({
|
|
621
|
+
isGuildMessage,
|
|
622
|
+
message,
|
|
623
|
+
channelInfo
|
|
624
|
+
}),
|
|
625
|
+
isBotAuthor: Boolean(author.bot),
|
|
626
|
+
text: messageText
|
|
627
|
+
})) {
|
|
628
|
+
logVerbose(`discord: drop bound-thread bot system message ${message.id}`);
|
|
629
|
+
return null;
|
|
630
|
+
}
|
|
631
|
+
const pluralkitInfo = await resolveDiscordPreflightPluralKitInfo({
|
|
632
|
+
message,
|
|
633
|
+
config: pluralkitConfig,
|
|
634
|
+
abortSignal: params.abortSignal
|
|
635
|
+
});
|
|
636
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
637
|
+
const sender = resolveDiscordSenderIdentity({
|
|
638
|
+
author,
|
|
639
|
+
member: params.data.member,
|
|
640
|
+
pluralkitInfo
|
|
641
|
+
});
|
|
642
|
+
if (author.bot) {
|
|
643
|
+
if (allowBotsMode === "off" && !sender.isPluralKit) {
|
|
644
|
+
logVerbose("discord: drop bot message (allowBots=false)");
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
const data = message === params.data.message ? params.data : {
|
|
649
|
+
...params.data,
|
|
650
|
+
message
|
|
651
|
+
};
|
|
652
|
+
logDebug(`[discord-preflight] channelId=${messageChannelId} guild_id=${params.data.guild_id} channelType=${channelInfo?.type} isGuild=${isGuildMessage} isDM=${isDirectMessage} isGroupDm=${isGroupDm}`);
|
|
653
|
+
if (isGroupDm && !params.groupDmEnabled) {
|
|
654
|
+
logVerbose("discord: drop group dm (group dms disabled)");
|
|
655
|
+
return null;
|
|
656
|
+
}
|
|
657
|
+
if (isDirectMessage && !params.dmEnabled) {
|
|
658
|
+
logVerbose("discord: drop dm (dms disabled)");
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
const dmPolicy = params.dmPolicy;
|
|
662
|
+
const useAccessGroups = params.cfg.commands?.useAccessGroups !== false;
|
|
663
|
+
const resolvedAccountId = params.accountId ?? resolveDefaultDiscordAccountId(params.cfg);
|
|
664
|
+
const allowNameMatching = isDangerousNameMatchingEnabled(params.discordConfig);
|
|
665
|
+
let commandAuthorized = true;
|
|
666
|
+
if (isDirectMessage) {
|
|
667
|
+
const access = await resolveDiscordDmPreflightAccess({
|
|
668
|
+
preflight: params,
|
|
669
|
+
author,
|
|
670
|
+
sender,
|
|
671
|
+
dmPolicy,
|
|
672
|
+
resolvedAccountId,
|
|
673
|
+
allowNameMatching,
|
|
674
|
+
useAccessGroups
|
|
675
|
+
});
|
|
676
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
677
|
+
if (!access) return null;
|
|
678
|
+
commandAuthorized = access.commandAuthorized;
|
|
679
|
+
}
|
|
680
|
+
const botId = params.botUserId;
|
|
681
|
+
const baseText = resolveDiscordMessageText(message, { includeForwarded: false });
|
|
682
|
+
if (!isDirectMessage && baseText && hasControlCommand(baseText, params.cfg)) {
|
|
683
|
+
logVerbose(`discord: drop text-based slash command ${message.id} (intercepted at gateway)`);
|
|
684
|
+
return null;
|
|
685
|
+
}
|
|
686
|
+
recordChannelActivity({
|
|
687
|
+
channel: "discord",
|
|
688
|
+
accountId: params.accountId,
|
|
689
|
+
direction: "inbound"
|
|
690
|
+
});
|
|
691
|
+
const channelName = channelInfo?.name ?? (isGuildMessage || isGroupDm ? resolveDiscordChannelNameSafe("channel" in message ? message.channel : void 0) : void 0);
|
|
692
|
+
const threadContext = await resolveDiscordPreflightThreadContext({
|
|
693
|
+
client: params.client,
|
|
694
|
+
isGuildMessage,
|
|
695
|
+
message,
|
|
696
|
+
channelInfo,
|
|
697
|
+
messageChannelId,
|
|
698
|
+
abortSignal: params.abortSignal
|
|
699
|
+
});
|
|
700
|
+
if (!threadContext) return null;
|
|
701
|
+
const { earlyThreadChannel, earlyThreadParentId, earlyThreadParentName, earlyThreadParentType } = threadContext;
|
|
702
|
+
const memberRoleIds = Array.isArray(params.data.rawMember?.roles) ? params.data.rawMember.roles : [];
|
|
703
|
+
const { conversationRuntime, threadBinding, configuredBinding, boundSessionKey, effectiveRoute, boundAgentId, baseSessionKey } = await resolveDiscordPreflightRoute({
|
|
704
|
+
preflight: params,
|
|
705
|
+
author,
|
|
706
|
+
isDirectMessage,
|
|
707
|
+
isGroupDm,
|
|
708
|
+
messageChannelId,
|
|
709
|
+
memberRoleIds,
|
|
710
|
+
earlyThreadParentId
|
|
711
|
+
});
|
|
712
|
+
if (shouldIgnoreBoundThreadWebhookMessage({
|
|
713
|
+
accountId: params.accountId,
|
|
714
|
+
threadId: messageChannelId,
|
|
715
|
+
webhookId,
|
|
716
|
+
threadBinding
|
|
717
|
+
})) {
|
|
718
|
+
logVerbose(`discord: drop bound-thread webhook echo message ${message.id}`);
|
|
719
|
+
return null;
|
|
720
|
+
}
|
|
721
|
+
const isBoundThreadSession = Boolean(threadBinding && earlyThreadChannel);
|
|
722
|
+
const bypassMentionRequirement = isBoundThreadSession;
|
|
723
|
+
if (isBoundThreadBotSystemMessage({
|
|
724
|
+
isBoundThreadSession,
|
|
725
|
+
isBotAuthor: Boolean(author.bot),
|
|
726
|
+
text: messageText
|
|
727
|
+
})) {
|
|
728
|
+
logVerbose(`discord: drop bound-thread bot system message ${message.id}`);
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
731
|
+
const mentionRegexes = buildMentionRegexes(params.cfg, effectiveRoute.agentId);
|
|
732
|
+
const explicitlyMentioned = Boolean(botId && message.mentionedUsers?.some((user) => user.id === botId));
|
|
733
|
+
const hasAnyMention = !isDirectMessage && ((message.mentionedUsers?.length ?? 0) > 0 || (message.mentionedRoles?.length ?? 0) > 0 || message.mentionedEveryone && (!author.bot || sender.isPluralKit));
|
|
734
|
+
const hasUserOrRoleMention = !isDirectMessage && ((message.mentionedUsers?.length ?? 0) > 0 || (message.mentionedRoles?.length ?? 0) > 0);
|
|
735
|
+
if (isGuildMessage && (message.type === discord_exports.MessageType.ChatInputCommand || message.type === discord_exports.MessageType.ContextMenuCommand)) {
|
|
736
|
+
logVerbose("discord: drop channel command message");
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
const guildInfo = isGuildMessage ? resolveDiscordGuildEntry({
|
|
740
|
+
guild: params.data.guild ?? void 0,
|
|
741
|
+
guildId: params.data.guild_id ?? void 0,
|
|
742
|
+
guildEntries: params.guildEntries
|
|
743
|
+
}) : null;
|
|
744
|
+
logDebug(`[discord-preflight] guild_id=${params.data.guild_id} guild_obj=${!!params.data.guild} guild_obj_id=${params.data.guild?.id} guildInfo=${!!guildInfo} guildEntries=${params.guildEntries ? Object.keys(params.guildEntries).join(",") : "none"}`);
|
|
745
|
+
if (isGuildMessage && params.guildEntries && Object.keys(params.guildEntries).length > 0 && !guildInfo) {
|
|
746
|
+
logDebug(`[discord-preflight] guild blocked: guild_id=${params.data.guild_id} guildEntries keys=${Object.keys(params.guildEntries).join(",")}`);
|
|
747
|
+
logVerbose(`Blocked discord guild ${params.data.guild_id ?? "unknown"} (not in discord.guilds)`);
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
const threadChannel = earlyThreadChannel;
|
|
751
|
+
const threadParentId = earlyThreadParentId;
|
|
752
|
+
const threadParentName = earlyThreadParentName;
|
|
753
|
+
const threadParentType = earlyThreadParentType;
|
|
754
|
+
const { threadName, configChannelName, configChannelSlug, displayChannelName, displayChannelSlug, guildSlug, channelConfig } = resolveDiscordPreflightChannelContext({
|
|
755
|
+
isGuildMessage,
|
|
756
|
+
messageChannelId,
|
|
757
|
+
channelName,
|
|
758
|
+
guildName: params.data.guild?.name,
|
|
759
|
+
guildInfo,
|
|
760
|
+
threadChannel,
|
|
761
|
+
threadParentId,
|
|
762
|
+
threadParentName
|
|
763
|
+
});
|
|
764
|
+
const channelMatchMeta = formatAllowlistMatchMeta(channelConfig);
|
|
765
|
+
logDiscordPreflightChannelConfig({
|
|
766
|
+
channelConfig,
|
|
767
|
+
channelMatchMeta,
|
|
768
|
+
channelId: messageChannelId
|
|
769
|
+
});
|
|
770
|
+
const channelAccess = resolveDiscordPreflightChannelAccess({
|
|
771
|
+
isGuildMessage,
|
|
772
|
+
isGroupDm,
|
|
773
|
+
groupPolicy: params.groupPolicy,
|
|
774
|
+
groupDmChannels: params.groupDmChannels,
|
|
775
|
+
messageChannelId,
|
|
776
|
+
displayChannelName,
|
|
777
|
+
displayChannelSlug,
|
|
778
|
+
guildInfo,
|
|
779
|
+
channelConfig,
|
|
780
|
+
channelMatchMeta
|
|
781
|
+
});
|
|
782
|
+
if (!channelAccess.allowed) return null;
|
|
783
|
+
const { channelAllowlistConfigured, channelAllowed } = channelAccess;
|
|
784
|
+
const historyEntry = buildDiscordPreflightHistoryEntry({
|
|
785
|
+
isGuildMessage,
|
|
786
|
+
historyLimit: params.historyLimit,
|
|
787
|
+
message,
|
|
788
|
+
senderLabel: sender.label
|
|
789
|
+
});
|
|
790
|
+
const threadOwnerId = threadChannel ? resolveDiscordChannelInfoSafe(threadChannel).ownerId ?? channelInfo?.ownerId : void 0;
|
|
791
|
+
const shouldRequireMentionByConfig = resolveDiscordShouldRequireMention({
|
|
792
|
+
isGuildMessage,
|
|
793
|
+
isThread: Boolean(threadChannel),
|
|
794
|
+
botId,
|
|
795
|
+
threadOwnerId,
|
|
796
|
+
channelConfig,
|
|
797
|
+
guildInfo
|
|
798
|
+
});
|
|
799
|
+
const shouldRequireMention = resolvePreflightMentionRequirement({
|
|
800
|
+
shouldRequireMention: shouldRequireMentionByConfig,
|
|
801
|
+
bypassMentionRequirement
|
|
802
|
+
});
|
|
803
|
+
const { hasAccessRestrictions, memberAllowed } = resolveDiscordMemberAccessState({
|
|
804
|
+
channelConfig,
|
|
805
|
+
guildInfo,
|
|
806
|
+
memberRoleIds,
|
|
807
|
+
sender,
|
|
808
|
+
allowNameMatching
|
|
809
|
+
});
|
|
810
|
+
if (isGuildMessage && hasAccessRestrictions && !memberAllowed) {
|
|
811
|
+
logDebug(`[discord-preflight] drop: member not allowed`);
|
|
812
|
+
logVerbose("Blocked discord guild sender (not in users/roles allowlist)");
|
|
813
|
+
return null;
|
|
814
|
+
}
|
|
815
|
+
const { resolveDiscordPreflightAudioMentionContext } = await loadPreflightAudioRuntime();
|
|
816
|
+
const { hasTypedText, transcript: preflightTranscript } = await resolveDiscordPreflightAudioMentionContext({
|
|
817
|
+
message,
|
|
818
|
+
isDirectMessage,
|
|
819
|
+
shouldRequireMention,
|
|
820
|
+
mentionRegexes,
|
|
821
|
+
cfg: params.cfg,
|
|
822
|
+
abortSignal: params.abortSignal
|
|
823
|
+
});
|
|
824
|
+
if (isPreflightAborted(params.abortSignal)) return null;
|
|
825
|
+
const mentionText = hasTypedText ? baseText : "";
|
|
826
|
+
const { implicitMentionKinds, wasMentioned } = resolveDiscordMentionState({
|
|
827
|
+
authorIsBot: Boolean(author.bot),
|
|
828
|
+
botId,
|
|
829
|
+
hasAnyMention,
|
|
830
|
+
isDirectMessage,
|
|
831
|
+
isExplicitlyMentioned: explicitlyMentioned,
|
|
832
|
+
mentionRegexes,
|
|
833
|
+
mentionText,
|
|
834
|
+
mentionedEveryone: message.mentionedEveryone,
|
|
835
|
+
referencedAuthorId: message.referencedMessage?.author?.id,
|
|
836
|
+
senderIsPluralKit: sender.isPluralKit,
|
|
837
|
+
transcript: preflightTranscript
|
|
838
|
+
});
|
|
839
|
+
logDiscordPreflightInboundSummary({
|
|
840
|
+
messageId: message.id,
|
|
841
|
+
guildId: params.data.guild_id ?? void 0,
|
|
842
|
+
channelId: messageChannelId,
|
|
843
|
+
wasMentioned,
|
|
844
|
+
isDirectMessage,
|
|
845
|
+
isGroupDm,
|
|
846
|
+
hasContent: Boolean(messageText)
|
|
847
|
+
});
|
|
848
|
+
const allowTextCommands = shouldHandleTextCommands({
|
|
849
|
+
cfg: params.cfg,
|
|
850
|
+
surface: "discord"
|
|
851
|
+
});
|
|
852
|
+
const hasControlCommandInMessage = hasControlCommand(baseText, params.cfg);
|
|
853
|
+
if (!isDirectMessage) {
|
|
854
|
+
const { ownerAllowList, ownerAllowed: ownerOk } = resolveDiscordOwnerAccess({
|
|
855
|
+
allowFrom: params.allowFrom,
|
|
856
|
+
sender: {
|
|
857
|
+
id: sender.id,
|
|
858
|
+
name: sender.name,
|
|
859
|
+
tag: sender.tag
|
|
860
|
+
},
|
|
861
|
+
allowNameMatching
|
|
862
|
+
});
|
|
863
|
+
const commandGate = resolveControlCommandGate({
|
|
864
|
+
useAccessGroups,
|
|
865
|
+
authorizers: [{
|
|
866
|
+
configured: ownerAllowList != null,
|
|
867
|
+
allowed: ownerOk
|
|
868
|
+
}, {
|
|
869
|
+
configured: hasAccessRestrictions,
|
|
870
|
+
allowed: memberAllowed
|
|
871
|
+
}],
|
|
872
|
+
modeWhenAccessGroupsOff: "configured",
|
|
873
|
+
allowTextCommands,
|
|
874
|
+
hasControlCommand: hasControlCommandInMessage
|
|
875
|
+
});
|
|
876
|
+
commandAuthorized = commandGate.commandAuthorized;
|
|
877
|
+
if (commandGate.shouldBlock) {
|
|
878
|
+
logInboundDrop({
|
|
879
|
+
log: logVerbose,
|
|
880
|
+
channel: "discord",
|
|
881
|
+
reason: "control command (unauthorized)",
|
|
882
|
+
target: sender.id
|
|
883
|
+
});
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
const canDetectMention = Boolean(botId) || mentionRegexes.length > 0;
|
|
888
|
+
const mentionDecision = resolveInboundMentionDecision({
|
|
889
|
+
facts: {
|
|
890
|
+
canDetectMention,
|
|
891
|
+
wasMentioned,
|
|
892
|
+
hasAnyMention,
|
|
893
|
+
implicitMentionKinds
|
|
894
|
+
},
|
|
895
|
+
policy: {
|
|
896
|
+
isGroup: isGuildMessage,
|
|
897
|
+
requireMention: shouldRequireMention,
|
|
898
|
+
allowTextCommands,
|
|
899
|
+
hasControlCommand: hasControlCommandInMessage,
|
|
900
|
+
commandAuthorized
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
const effectiveWasMentioned = mentionDecision.effectiveWasMentioned;
|
|
904
|
+
logDebug(`[discord-preflight] shouldRequireMention=${shouldRequireMention} baseRequireMention=${shouldRequireMentionByConfig} boundThreadSession=${isBoundThreadSession} mentionDecision.shouldSkip=${mentionDecision.shouldSkip} wasMentioned=${wasMentioned}`);
|
|
905
|
+
if (isGuildMessage && shouldRequireMention) {
|
|
906
|
+
if (mentionDecision.shouldSkip) {
|
|
907
|
+
logDebug(`[discord-preflight] drop: no-mention`);
|
|
908
|
+
logVerbose(`discord: drop guild message (mention required, botId=${botId ?? "<missing>"})`);
|
|
909
|
+
logger.info({
|
|
910
|
+
channelId: messageChannelId,
|
|
911
|
+
reason: "no-mention"
|
|
912
|
+
}, "discord: skipping guild message");
|
|
913
|
+
recordPendingHistoryEntryIfEnabled({
|
|
914
|
+
historyMap: params.guildHistories,
|
|
915
|
+
historyKey: messageChannelId,
|
|
916
|
+
limit: params.historyLimit,
|
|
917
|
+
entry: historyEntry ?? null
|
|
918
|
+
});
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
if (author.bot && !sender.isPluralKit && allowBotsMode === "mentions") {
|
|
923
|
+
if (!(isDirectMessage || wasMentioned || mentionDecision.implicitMention)) {
|
|
924
|
+
logDebug(`[discord-preflight] drop: bot message missing mention (allowBots=mentions)`);
|
|
925
|
+
logVerbose("discord: drop bot message (allowBots=mentions, missing mention)");
|
|
926
|
+
return null;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
const ignoreOtherMentions = channelConfig?.ignoreOtherMentions ?? guildInfo?.ignoreOtherMentions ?? false;
|
|
930
|
+
if (isGuildMessage && ignoreOtherMentions && hasUserOrRoleMention && !wasMentioned && !mentionDecision.implicitMention) {
|
|
931
|
+
logDebug(`[discord-preflight] drop: other-mention`);
|
|
932
|
+
logVerbose(`discord: drop guild message (another user/role mentioned, ignoreOtherMentions=true, botId=${botId})`);
|
|
933
|
+
recordPendingHistoryEntryIfEnabled({
|
|
934
|
+
historyMap: params.guildHistories,
|
|
935
|
+
historyKey: messageChannelId,
|
|
936
|
+
limit: params.historyLimit,
|
|
937
|
+
entry: historyEntry ?? null
|
|
938
|
+
});
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
const systemLocation = resolveDiscordSystemLocation({
|
|
942
|
+
isDirectMessage,
|
|
943
|
+
isGroupDm,
|
|
944
|
+
guild: params.data.guild ?? void 0,
|
|
945
|
+
channelName: channelName ?? messageChannelId
|
|
946
|
+
});
|
|
947
|
+
const { resolveDiscordSystemEvent } = await loadSystemEventsRuntime();
|
|
948
|
+
const systemText = resolveDiscordSystemEvent(message, systemLocation);
|
|
949
|
+
if (systemText) {
|
|
950
|
+
logDebug(`[discord-preflight] drop: system event`);
|
|
951
|
+
enqueueSystemEvent(systemText, {
|
|
952
|
+
sessionKey: effectiveRoute.sessionKey,
|
|
953
|
+
contextKey: `discord:system:${messageChannelId}:${message.id}`
|
|
954
|
+
});
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
if (!messageText) {
|
|
958
|
+
logDebug(`[discord-preflight] drop: empty content`);
|
|
959
|
+
logVerbose(`discord: drop message ${message.id} (empty content)`);
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
if (configuredBinding) {
|
|
963
|
+
const ensured = await conversationRuntime.ensureConfiguredBindingRouteReady({
|
|
964
|
+
cfg: params.cfg,
|
|
965
|
+
bindingResolution: configuredBinding
|
|
966
|
+
});
|
|
967
|
+
if (!ensured.ok) {
|
|
968
|
+
logVerbose(`discord: configured ACP binding unavailable for channel ${configuredBinding.record.conversation.conversationId}: ${ensured.error}`);
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
logDebug(`[discord-preflight] success: route=${effectiveRoute.agentId} sessionKey=${effectiveRoute.sessionKey}`);
|
|
973
|
+
return buildDiscordMessagePreflightContext({
|
|
974
|
+
preflightParams: params,
|
|
975
|
+
data,
|
|
976
|
+
client: params.client,
|
|
977
|
+
message,
|
|
978
|
+
messageChannelId,
|
|
979
|
+
author,
|
|
980
|
+
sender,
|
|
981
|
+
canonicalMessageId: pluralkitInfo?.original?.trim() || void 0,
|
|
982
|
+
memberRoleIds,
|
|
983
|
+
channelInfo,
|
|
984
|
+
channelName,
|
|
985
|
+
isGuildMessage,
|
|
986
|
+
isDirectMessage,
|
|
987
|
+
isGroupDm,
|
|
988
|
+
commandAuthorized,
|
|
989
|
+
baseText,
|
|
990
|
+
messageText,
|
|
991
|
+
...preflightTranscript !== void 0 ? { preflightAudioTranscript: preflightTranscript } : {},
|
|
992
|
+
wasMentioned,
|
|
993
|
+
route: effectiveRoute,
|
|
994
|
+
threadBinding,
|
|
995
|
+
boundSessionKey: boundSessionKey || void 0,
|
|
996
|
+
boundAgentId,
|
|
997
|
+
guildInfo,
|
|
998
|
+
guildSlug,
|
|
999
|
+
threadChannel,
|
|
1000
|
+
threadParentId,
|
|
1001
|
+
threadParentName,
|
|
1002
|
+
threadParentType,
|
|
1003
|
+
threadName,
|
|
1004
|
+
configChannelName,
|
|
1005
|
+
configChannelSlug,
|
|
1006
|
+
displayChannelName,
|
|
1007
|
+
displayChannelSlug,
|
|
1008
|
+
baseSessionKey,
|
|
1009
|
+
channelConfig,
|
|
1010
|
+
channelAllowlistConfigured,
|
|
1011
|
+
channelAllowed,
|
|
1012
|
+
shouldRequireMention,
|
|
1013
|
+
hasAnyMention,
|
|
1014
|
+
allowTextCommands,
|
|
1015
|
+
shouldBypassMention: mentionDecision.shouldBypassMention,
|
|
1016
|
+
effectiveWasMentioned,
|
|
1017
|
+
canDetectMention,
|
|
1018
|
+
historyEntry
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
//#endregion
|
|
1022
|
+
export { preflightDiscordMessage, resolvePreflightMentionRequirement, shouldIgnoreBoundThreadWebhookMessage };
|