@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,1001 @@
|
|
|
1
|
+
import { o as resolveDefaultDiscordAccountId, t as createDiscordActionGate } from "./accounts-BKnkNaoA.js";
|
|
2
|
+
import { s as resolveDiscordChannelId } from "./normalize-B-ktw-T_.js";
|
|
3
|
+
import { c as jsonResult, d as readNumberParam, f as readReactionParams, g as withNormalizedTimestamp, h as resolvePollMaxSelections, l as parseAvailableTags, m as readStringParam, p as readStringArrayParam, r as sendDiscordComponentMessage, s as assertMediaNotDataUrl, u as readBooleanParam } from "./send.components-B1EgHAds.js";
|
|
4
|
+
import { n as getGateway, o as getPresence } from "./gateway-registry-BKG4KIVC.js";
|
|
5
|
+
import { O as hasAnyGuildPermissionDiscord, P as createDiscordRuntimeAccountContext, T as fetchChannelPermissionsDiscord, d as resolveDiscordTargetChannelId } from "./send.shared-Db0opnak.js";
|
|
6
|
+
import { A as removeRoleDiscord, B as removeChannelPermissionDiscord, C as fetchChannelInfoDiscord, D as kickMemberDiscord, E as fetchVoiceStatusDiscord, F as uploadStickerDiscord, I as createChannelDiscord, L as deleteChannelDiscord, M as timeoutMemberDiscord, N as listGuildEmojisDiscord, O as listGuildChannelsDiscord, P as uploadEmojiDiscord, R as editChannelDiscord, S as createScheduledEventDiscord, T as fetchRoleInfoDiscord, V as setChannelPermissionDiscord, _ as readMessagesDiscord, a as removeReactionDiscord, b as addRoleDiscord, d as deleteMessageDiscord, f as editMessageDiscord, g as pinMessageDiscord, h as listThreadsDiscord, i as removeOwnReactionsDiscord, j as resolveEventCoverImage, k as listScheduledEventsDiscord, l as DiscordThreadInitialMessageError, m as listPinsDiscord, n as fetchReactionsDiscord, p as fetchMessageDiscord, r as reactMessageDiscord, s as sendVoiceMessageDiscord, u as createThreadDiscord, v as searchMessagesDiscord, w as fetchMemberInfoDiscord, x as banMemberDiscord, y as unpinMessageDiscord, z as moveChannelDiscord } from "./send-B_frVn_Q.js";
|
|
7
|
+
import { n as sendPollDiscord, r as sendStickerDiscord, t as sendMessageDiscord } from "./send.outbound-DlBAuW7y.js";
|
|
8
|
+
import { c as readDiscordComponentSpec } from "./components-BapWDmDM.js";
|
|
9
|
+
import "./targets-kKlbZ4ai.js";
|
|
10
|
+
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
|
|
11
|
+
import { PermissionFlagsBits } from "discord-api-types/v10";
|
|
12
|
+
//#region extensions/discord/src/actions/runtime.shared.ts
|
|
13
|
+
function readDiscordParentIdParam(params) {
|
|
14
|
+
if (params.clearParent === true) return null;
|
|
15
|
+
if (params.parentId === null) return null;
|
|
16
|
+
return readStringParam(params, "parentId");
|
|
17
|
+
}
|
|
18
|
+
function readDiscordBooleanParam(params, key) {
|
|
19
|
+
return typeof params[key] === "boolean" ? params[key] : void 0;
|
|
20
|
+
}
|
|
21
|
+
function createDiscordActionOptions(params) {
|
|
22
|
+
return {
|
|
23
|
+
cfg: params.cfg,
|
|
24
|
+
...params.accountId ? { accountId: params.accountId } : {},
|
|
25
|
+
...params.extra ?? {}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function readDiscordChannelCreateParams(params) {
|
|
29
|
+
const parentId = readDiscordParentIdParam(params);
|
|
30
|
+
return {
|
|
31
|
+
guildId: readStringParam(params, "guildId", { required: true }),
|
|
32
|
+
name: readStringParam(params, "name", { required: true }),
|
|
33
|
+
type: readNumberParam(params, "type", { integer: true }) ?? void 0,
|
|
34
|
+
parentId: parentId ?? void 0,
|
|
35
|
+
topic: readStringParam(params, "topic") ?? void 0,
|
|
36
|
+
position: readNumberParam(params, "position", { integer: true }) ?? void 0,
|
|
37
|
+
nsfw: readDiscordBooleanParam(params, "nsfw")
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function readDiscordChannelEditParams(params) {
|
|
41
|
+
const parentId = readDiscordParentIdParam(params);
|
|
42
|
+
return {
|
|
43
|
+
channelId: readStringParam(params, "channelId", { required: true }),
|
|
44
|
+
name: readStringParam(params, "name") ?? void 0,
|
|
45
|
+
topic: readStringParam(params, "topic") ?? void 0,
|
|
46
|
+
position: readNumberParam(params, "position", { integer: true }) ?? void 0,
|
|
47
|
+
parentId: parentId === void 0 ? void 0 : parentId,
|
|
48
|
+
nsfw: readDiscordBooleanParam(params, "nsfw"),
|
|
49
|
+
rateLimitPerUser: readNumberParam(params, "rateLimitPerUser", { integer: true }) ?? void 0,
|
|
50
|
+
archived: readDiscordBooleanParam(params, "archived"),
|
|
51
|
+
locked: readDiscordBooleanParam(params, "locked"),
|
|
52
|
+
autoArchiveDuration: readNumberParam(params, "autoArchiveDuration", { integer: true }) ?? void 0,
|
|
53
|
+
availableTags: parseAvailableTags(params.availableTags)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function readDiscordChannelMoveParams(params) {
|
|
57
|
+
const parentId = readDiscordParentIdParam(params);
|
|
58
|
+
return {
|
|
59
|
+
guildId: readStringParam(params, "guildId", { required: true }),
|
|
60
|
+
channelId: readStringParam(params, "channelId", { required: true }),
|
|
61
|
+
parentId: parentId === void 0 ? void 0 : parentId,
|
|
62
|
+
position: readNumberParam(params, "position", { integer: true }) ?? void 0
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region extensions/discord/src/actions/runtime.guild.ts
|
|
67
|
+
const discordGuildActionRuntime = {
|
|
68
|
+
addRoleDiscord,
|
|
69
|
+
createChannelDiscord,
|
|
70
|
+
createScheduledEventDiscord,
|
|
71
|
+
resolveEventCoverImage,
|
|
72
|
+
deleteChannelDiscord,
|
|
73
|
+
editChannelDiscord,
|
|
74
|
+
fetchChannelInfoDiscord,
|
|
75
|
+
fetchMemberInfoDiscord,
|
|
76
|
+
fetchRoleInfoDiscord,
|
|
77
|
+
fetchVoiceStatusDiscord,
|
|
78
|
+
listGuildChannelsDiscord,
|
|
79
|
+
listGuildEmojisDiscord,
|
|
80
|
+
listScheduledEventsDiscord,
|
|
81
|
+
moveChannelDiscord,
|
|
82
|
+
removeChannelPermissionDiscord,
|
|
83
|
+
removeRoleDiscord,
|
|
84
|
+
setChannelPermissionDiscord,
|
|
85
|
+
uploadEmojiDiscord,
|
|
86
|
+
uploadStickerDiscord
|
|
87
|
+
};
|
|
88
|
+
async function runRoleMutation(params) {
|
|
89
|
+
const guildId = readStringParam(params.values, "guildId", { required: true });
|
|
90
|
+
const userId = readStringParam(params.values, "userId", { required: true });
|
|
91
|
+
const roleId = readStringParam(params.values, "roleId", { required: true });
|
|
92
|
+
await params.mutate({
|
|
93
|
+
guildId,
|
|
94
|
+
userId,
|
|
95
|
+
roleId
|
|
96
|
+
}, createDiscordActionOptions({
|
|
97
|
+
cfg: params.cfg,
|
|
98
|
+
accountId: params.accountId
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
function readChannelPermissionTarget(params) {
|
|
102
|
+
return {
|
|
103
|
+
channelId: readStringParam(params, "channelId", { required: true }),
|
|
104
|
+
targetId: readStringParam(params, "targetId", { required: true })
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function handleDiscordGuildAction(action, params, isActionEnabled, cfg, options) {
|
|
108
|
+
const accountId = readStringParam(params, "accountId");
|
|
109
|
+
if (!cfg) throw new Error("Discord guild actions require a resolved runtime config.");
|
|
110
|
+
const withOpts = (extra) => createDiscordActionOptions({
|
|
111
|
+
cfg,
|
|
112
|
+
accountId,
|
|
113
|
+
extra
|
|
114
|
+
});
|
|
115
|
+
switch (action) {
|
|
116
|
+
case "memberInfo": {
|
|
117
|
+
if (!isActionEnabled("memberInfo")) throw new Error("Discord member info is disabled.");
|
|
118
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
119
|
+
const userId = readStringParam(params, "userId", { required: true });
|
|
120
|
+
const effectiveAccountId = accountId ?? resolveDefaultDiscordAccountId(cfg);
|
|
121
|
+
const member = await discordGuildActionRuntime.fetchMemberInfoDiscord(guildId, userId, createDiscordActionOptions({
|
|
122
|
+
cfg,
|
|
123
|
+
accountId: effectiveAccountId
|
|
124
|
+
}));
|
|
125
|
+
const presence = getPresence(effectiveAccountId, userId);
|
|
126
|
+
const activities = presence?.activities ?? void 0;
|
|
127
|
+
const status = presence?.status ?? void 0;
|
|
128
|
+
return jsonResult({
|
|
129
|
+
ok: true,
|
|
130
|
+
member,
|
|
131
|
+
...presence ? {
|
|
132
|
+
status,
|
|
133
|
+
activities
|
|
134
|
+
} : {}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
case "roleInfo": {
|
|
138
|
+
if (!isActionEnabled("roleInfo")) throw new Error("Discord role info is disabled.");
|
|
139
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
140
|
+
return jsonResult({
|
|
141
|
+
ok: true,
|
|
142
|
+
roles: await discordGuildActionRuntime.fetchRoleInfoDiscord(guildId, withOpts())
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
case "emojiList": {
|
|
146
|
+
if (!isActionEnabled("reactions")) throw new Error("Discord reactions are disabled.");
|
|
147
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
148
|
+
return jsonResult({
|
|
149
|
+
ok: true,
|
|
150
|
+
emojis: await discordGuildActionRuntime.listGuildEmojisDiscord(guildId, withOpts())
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
case "emojiUpload": {
|
|
154
|
+
if (!isActionEnabled("emojiUploads")) throw new Error("Discord emoji uploads are disabled.");
|
|
155
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
156
|
+
const name = readStringParam(params, "name", { required: true });
|
|
157
|
+
const mediaUrl = readStringParam(params, "mediaUrl", { required: true });
|
|
158
|
+
const roleIds = readStringArrayParam(params, "roleIds");
|
|
159
|
+
return jsonResult({
|
|
160
|
+
ok: true,
|
|
161
|
+
emoji: await discordGuildActionRuntime.uploadEmojiDiscord({
|
|
162
|
+
guildId,
|
|
163
|
+
name,
|
|
164
|
+
mediaUrl,
|
|
165
|
+
roleIds: roleIds?.length ? roleIds : void 0
|
|
166
|
+
}, withOpts())
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
case "stickerUpload": {
|
|
170
|
+
if (!isActionEnabled("stickerUploads")) throw new Error("Discord sticker uploads are disabled.");
|
|
171
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
172
|
+
const name = readStringParam(params, "name", { required: true });
|
|
173
|
+
const description = readStringParam(params, "description", { required: true });
|
|
174
|
+
const tags = readStringParam(params, "tags", { required: true });
|
|
175
|
+
const mediaUrl = readStringParam(params, "mediaUrl", { required: true });
|
|
176
|
+
return jsonResult({
|
|
177
|
+
ok: true,
|
|
178
|
+
sticker: await discordGuildActionRuntime.uploadStickerDiscord({
|
|
179
|
+
guildId,
|
|
180
|
+
name,
|
|
181
|
+
description,
|
|
182
|
+
tags,
|
|
183
|
+
mediaUrl
|
|
184
|
+
}, withOpts())
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
case "roleAdd":
|
|
188
|
+
if (!isActionEnabled("roles", false)) throw new Error("Discord role changes are disabled.");
|
|
189
|
+
await runRoleMutation({
|
|
190
|
+
cfg,
|
|
191
|
+
accountId,
|
|
192
|
+
values: params,
|
|
193
|
+
mutate: discordGuildActionRuntime.addRoleDiscord
|
|
194
|
+
});
|
|
195
|
+
return jsonResult({ ok: true });
|
|
196
|
+
case "roleRemove":
|
|
197
|
+
if (!isActionEnabled("roles", false)) throw new Error("Discord role changes are disabled.");
|
|
198
|
+
await runRoleMutation({
|
|
199
|
+
cfg,
|
|
200
|
+
accountId,
|
|
201
|
+
values: params,
|
|
202
|
+
mutate: discordGuildActionRuntime.removeRoleDiscord
|
|
203
|
+
});
|
|
204
|
+
return jsonResult({ ok: true });
|
|
205
|
+
case "channelInfo": {
|
|
206
|
+
if (!isActionEnabled("channelInfo")) throw new Error("Discord channel info is disabled.");
|
|
207
|
+
const channelId = readStringParam(params, "channelId", { required: true });
|
|
208
|
+
return jsonResult({
|
|
209
|
+
ok: true,
|
|
210
|
+
channel: await discordGuildActionRuntime.fetchChannelInfoDiscord(channelId, withOpts())
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
case "channelList": {
|
|
214
|
+
if (!isActionEnabled("channelInfo")) throw new Error("Discord channel info is disabled.");
|
|
215
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
216
|
+
return jsonResult({
|
|
217
|
+
ok: true,
|
|
218
|
+
channels: await discordGuildActionRuntime.listGuildChannelsDiscord(guildId, withOpts())
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
case "voiceStatus": {
|
|
222
|
+
if (!isActionEnabled("voiceStatus")) throw new Error("Discord voice status is disabled.");
|
|
223
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
224
|
+
const userId = readStringParam(params, "userId", { required: true });
|
|
225
|
+
return jsonResult({
|
|
226
|
+
ok: true,
|
|
227
|
+
voice: await discordGuildActionRuntime.fetchVoiceStatusDiscord(guildId, userId, withOpts())
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
case "eventList": {
|
|
231
|
+
if (!isActionEnabled("events")) throw new Error("Discord events are disabled.");
|
|
232
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
233
|
+
return jsonResult({
|
|
234
|
+
ok: true,
|
|
235
|
+
events: await discordGuildActionRuntime.listScheduledEventsDiscord(guildId, withOpts())
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
case "eventCreate": {
|
|
239
|
+
if (!isActionEnabled("events")) throw new Error("Discord events are disabled.");
|
|
240
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
241
|
+
const name = readStringParam(params, "name", { required: true });
|
|
242
|
+
const startTime = readStringParam(params, "startTime", { required: true });
|
|
243
|
+
const endTime = readStringParam(params, "endTime");
|
|
244
|
+
const description = readStringParam(params, "description");
|
|
245
|
+
const channelId = readStringParam(params, "channelId");
|
|
246
|
+
const location = readStringParam(params, "location");
|
|
247
|
+
const imageUrl = readStringParam(params, "image", { trim: false });
|
|
248
|
+
const entityTypeRaw = readStringParam(params, "entityType");
|
|
249
|
+
const entityType = entityTypeRaw === "stage" ? 1 : entityTypeRaw === "external" ? 3 : 2;
|
|
250
|
+
const image = imageUrl ? await discordGuildActionRuntime.resolveEventCoverImage(imageUrl, { localRoots: options?.mediaLocalRoots }) : void 0;
|
|
251
|
+
const payload = {
|
|
252
|
+
name,
|
|
253
|
+
description,
|
|
254
|
+
scheduled_start_time: startTime,
|
|
255
|
+
scheduled_end_time: endTime,
|
|
256
|
+
entity_type: entityType,
|
|
257
|
+
channel_id: channelId,
|
|
258
|
+
entity_metadata: entityType === 3 && location ? { location } : void 0,
|
|
259
|
+
image,
|
|
260
|
+
privacy_level: 2
|
|
261
|
+
};
|
|
262
|
+
return jsonResult({
|
|
263
|
+
ok: true,
|
|
264
|
+
event: await discordGuildActionRuntime.createScheduledEventDiscord(guildId, payload, withOpts())
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
case "channelCreate":
|
|
268
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
269
|
+
return jsonResult({
|
|
270
|
+
ok: true,
|
|
271
|
+
channel: await discordGuildActionRuntime.createChannelDiscord(readDiscordChannelCreateParams(params), withOpts())
|
|
272
|
+
});
|
|
273
|
+
case "channelEdit":
|
|
274
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
275
|
+
return jsonResult({
|
|
276
|
+
ok: true,
|
|
277
|
+
channel: await discordGuildActionRuntime.editChannelDiscord(readDiscordChannelEditParams(params), withOpts())
|
|
278
|
+
});
|
|
279
|
+
case "channelDelete": {
|
|
280
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
281
|
+
const channelId = readStringParam(params, "channelId", { required: true });
|
|
282
|
+
return jsonResult(await discordGuildActionRuntime.deleteChannelDiscord(channelId, withOpts()));
|
|
283
|
+
}
|
|
284
|
+
case "channelMove":
|
|
285
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
286
|
+
await discordGuildActionRuntime.moveChannelDiscord(readDiscordChannelMoveParams(params), withOpts());
|
|
287
|
+
return jsonResult({ ok: true });
|
|
288
|
+
case "categoryCreate": {
|
|
289
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
290
|
+
const guildId = readStringParam(params, "guildId", { required: true });
|
|
291
|
+
const name = readStringParam(params, "name", { required: true });
|
|
292
|
+
const position = readNumberParam(params, "position", { integer: true });
|
|
293
|
+
return jsonResult({
|
|
294
|
+
ok: true,
|
|
295
|
+
category: await discordGuildActionRuntime.createChannelDiscord({
|
|
296
|
+
guildId,
|
|
297
|
+
name,
|
|
298
|
+
type: 4,
|
|
299
|
+
position: position ?? void 0
|
|
300
|
+
}, withOpts())
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
case "categoryEdit": {
|
|
304
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
305
|
+
const categoryId = readStringParam(params, "categoryId", { required: true });
|
|
306
|
+
const name = readStringParam(params, "name");
|
|
307
|
+
const position = readNumberParam(params, "position", { integer: true });
|
|
308
|
+
return jsonResult({
|
|
309
|
+
ok: true,
|
|
310
|
+
category: await discordGuildActionRuntime.editChannelDiscord({
|
|
311
|
+
channelId: categoryId,
|
|
312
|
+
name: name ?? void 0,
|
|
313
|
+
position: position ?? void 0
|
|
314
|
+
}, withOpts())
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
case "categoryDelete": {
|
|
318
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
319
|
+
const categoryId = readStringParam(params, "categoryId", { required: true });
|
|
320
|
+
return jsonResult(await discordGuildActionRuntime.deleteChannelDiscord(categoryId, withOpts()));
|
|
321
|
+
}
|
|
322
|
+
case "channelPermissionSet": {
|
|
323
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
324
|
+
const { channelId, targetId } = readChannelPermissionTarget(params);
|
|
325
|
+
const targetType = readStringParam(params, "targetType", { required: true }) === "member" ? 1 : 0;
|
|
326
|
+
const allow = readStringParam(params, "allow");
|
|
327
|
+
const deny = readStringParam(params, "deny");
|
|
328
|
+
await discordGuildActionRuntime.setChannelPermissionDiscord({
|
|
329
|
+
channelId,
|
|
330
|
+
targetId,
|
|
331
|
+
targetType,
|
|
332
|
+
allow: allow ?? void 0,
|
|
333
|
+
deny: deny ?? void 0
|
|
334
|
+
}, withOpts());
|
|
335
|
+
return jsonResult({ ok: true });
|
|
336
|
+
}
|
|
337
|
+
case "channelPermissionRemove": {
|
|
338
|
+
if (!isActionEnabled("channels")) throw new Error("Discord channel management is disabled.");
|
|
339
|
+
const { channelId, targetId } = readChannelPermissionTarget(params);
|
|
340
|
+
await discordGuildActionRuntime.removeChannelPermissionDiscord(channelId, targetId, withOpts());
|
|
341
|
+
return jsonResult({ ok: true });
|
|
342
|
+
}
|
|
343
|
+
default: throw new Error(`Unknown action: ${action}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region extensions/discord/src/actions/runtime.messaging.runtime.ts
|
|
348
|
+
const discordMessagingActionRuntime = {
|
|
349
|
+
createThreadDiscord,
|
|
350
|
+
deleteMessageDiscord,
|
|
351
|
+
editMessageDiscord,
|
|
352
|
+
fetchChannelPermissionsDiscord,
|
|
353
|
+
fetchMessageDiscord,
|
|
354
|
+
fetchReactionsDiscord,
|
|
355
|
+
listPinsDiscord,
|
|
356
|
+
listThreadsDiscord,
|
|
357
|
+
pinMessageDiscord,
|
|
358
|
+
reactMessageDiscord,
|
|
359
|
+
readDiscordComponentSpec,
|
|
360
|
+
readMessagesDiscord,
|
|
361
|
+
removeOwnReactionsDiscord,
|
|
362
|
+
removeReactionDiscord,
|
|
363
|
+
resolveDiscordReactionTargetChannelId,
|
|
364
|
+
resolveDiscordChannelId,
|
|
365
|
+
searchMessagesDiscord,
|
|
366
|
+
sendDiscordComponentMessage,
|
|
367
|
+
sendMessageDiscord,
|
|
368
|
+
sendPollDiscord,
|
|
369
|
+
sendStickerDiscord,
|
|
370
|
+
sendVoiceMessageDiscord,
|
|
371
|
+
unpinMessageDiscord
|
|
372
|
+
};
|
|
373
|
+
async function resolveDiscordReactionTargetChannelId(params) {
|
|
374
|
+
try {
|
|
375
|
+
return resolveDiscordChannelId(params.target);
|
|
376
|
+
} catch {
|
|
377
|
+
return (await resolveDiscordTargetChannelId(params.target, {
|
|
378
|
+
cfg: params.cfg,
|
|
379
|
+
accountId: params.accountId
|
|
380
|
+
})).channelId;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region extensions/discord/src/actions/runtime.messaging.messages.ts
|
|
385
|
+
function parseDiscordMessageLink(link) {
|
|
386
|
+
const match = link.trim().match(/^(?:https?:\/\/)?(?:ptb\.|canary\.)?discord(?:app)?\.com\/channels\/(\d+)\/(\d+)\/(\d+)(?:\/?|\?.*)$/i);
|
|
387
|
+
if (!match) throw new Error("Invalid Discord message link. Expected https://discord.com/channels/<guildId>/<channelId>/<messageId>.");
|
|
388
|
+
return {
|
|
389
|
+
guildId: match[1],
|
|
390
|
+
channelId: match[2],
|
|
391
|
+
messageId: match[3]
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
async function handleDiscordMessageManagementAction(ctx) {
|
|
395
|
+
switch (ctx.action) {
|
|
396
|
+
case "permissions": {
|
|
397
|
+
if (!ctx.isActionEnabled("permissions")) throw new Error("Discord permissions are disabled.");
|
|
398
|
+
const channelId = ctx.resolveChannelId();
|
|
399
|
+
return jsonResult({
|
|
400
|
+
ok: true,
|
|
401
|
+
permissions: await discordMessagingActionRuntime.fetchChannelPermissionsDiscord(channelId, ctx.withOpts())
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
case "fetchMessage": {
|
|
405
|
+
if (!ctx.isActionEnabled("messages")) throw new Error("Discord message reads are disabled.");
|
|
406
|
+
const messageLink = readStringParam(ctx.params, "messageLink");
|
|
407
|
+
let guildId = readStringParam(ctx.params, "guildId");
|
|
408
|
+
let channelId = readStringParam(ctx.params, "channelId");
|
|
409
|
+
let messageId = readStringParam(ctx.params, "messageId");
|
|
410
|
+
if (messageLink) {
|
|
411
|
+
const parsed = parseDiscordMessageLink(messageLink);
|
|
412
|
+
guildId = parsed.guildId;
|
|
413
|
+
channelId = parsed.channelId;
|
|
414
|
+
messageId = parsed.messageId;
|
|
415
|
+
}
|
|
416
|
+
if (!guildId || !channelId || !messageId) throw new Error("Discord message fetch requires guildId, channelId, and messageId (or a valid messageLink).");
|
|
417
|
+
const message = await discordMessagingActionRuntime.fetchMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
418
|
+
return jsonResult({
|
|
419
|
+
ok: true,
|
|
420
|
+
message: ctx.normalizeMessage(message),
|
|
421
|
+
guildId,
|
|
422
|
+
channelId,
|
|
423
|
+
messageId
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
case "readMessages": {
|
|
427
|
+
if (!ctx.isActionEnabled("messages")) throw new Error("Discord message reads are disabled.");
|
|
428
|
+
const channelId = ctx.resolveChannelId();
|
|
429
|
+
const query = {
|
|
430
|
+
limit: readNumberParam(ctx.params, "limit"),
|
|
431
|
+
before: readStringParam(ctx.params, "before"),
|
|
432
|
+
after: readStringParam(ctx.params, "after"),
|
|
433
|
+
around: readStringParam(ctx.params, "around")
|
|
434
|
+
};
|
|
435
|
+
return jsonResult({
|
|
436
|
+
ok: true,
|
|
437
|
+
messages: (await discordMessagingActionRuntime.readMessagesDiscord(channelId, query, ctx.withOpts())).map((message) => ctx.normalizeMessage(message))
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
case "editMessage": {
|
|
441
|
+
if (!ctx.isActionEnabled("messages")) throw new Error("Discord message edits are disabled.");
|
|
442
|
+
const channelId = ctx.resolveChannelId();
|
|
443
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
444
|
+
const content = readStringParam(ctx.params, "content", { required: true });
|
|
445
|
+
return jsonResult({
|
|
446
|
+
ok: true,
|
|
447
|
+
message: await discordMessagingActionRuntime.editMessageDiscord(channelId, messageId, { content }, ctx.withOpts())
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
case "deleteMessage": {
|
|
451
|
+
if (!ctx.isActionEnabled("messages")) throw new Error("Discord message deletes are disabled.");
|
|
452
|
+
const channelId = ctx.resolveChannelId();
|
|
453
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
454
|
+
await discordMessagingActionRuntime.deleteMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
455
|
+
return jsonResult({ ok: true });
|
|
456
|
+
}
|
|
457
|
+
case "pinMessage": {
|
|
458
|
+
if (!ctx.isActionEnabled("pins")) throw new Error("Discord pins are disabled.");
|
|
459
|
+
const channelId = ctx.resolveChannelId();
|
|
460
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
461
|
+
await discordMessagingActionRuntime.pinMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
462
|
+
return jsonResult({ ok: true });
|
|
463
|
+
}
|
|
464
|
+
case "unpinMessage": {
|
|
465
|
+
if (!ctx.isActionEnabled("pins")) throw new Error("Discord pins are disabled.");
|
|
466
|
+
const channelId = ctx.resolveChannelId();
|
|
467
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
468
|
+
await discordMessagingActionRuntime.unpinMessageDiscord(channelId, messageId, ctx.withOpts());
|
|
469
|
+
return jsonResult({ ok: true });
|
|
470
|
+
}
|
|
471
|
+
case "listPins": {
|
|
472
|
+
if (!ctx.isActionEnabled("pins")) throw new Error("Discord pins are disabled.");
|
|
473
|
+
const channelId = ctx.resolveChannelId();
|
|
474
|
+
return jsonResult({
|
|
475
|
+
ok: true,
|
|
476
|
+
pins: (await discordMessagingActionRuntime.listPinsDiscord(channelId, ctx.withOpts())).map((pin) => ctx.normalizeMessage(pin))
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
case "searchMessages": {
|
|
480
|
+
if (!ctx.isActionEnabled("search")) throw new Error("Discord search is disabled.");
|
|
481
|
+
const guildId = readStringParam(ctx.params, "guildId", { required: true });
|
|
482
|
+
const content = readStringParam(ctx.params, "content", { required: true });
|
|
483
|
+
const channelId = readStringParam(ctx.params, "channelId");
|
|
484
|
+
const channelIds = readStringArrayParam(ctx.params, "channelIds");
|
|
485
|
+
const authorId = readStringParam(ctx.params, "authorId");
|
|
486
|
+
const authorIds = readStringArrayParam(ctx.params, "authorIds");
|
|
487
|
+
const limit = readNumberParam(ctx.params, "limit");
|
|
488
|
+
const channelIdList = [...channelIds ?? [], ...channelId ? [channelId] : []];
|
|
489
|
+
const authorIdList = [...authorIds ?? [], ...authorId ? [authorId] : []];
|
|
490
|
+
const results = await discordMessagingActionRuntime.searchMessagesDiscord({
|
|
491
|
+
guildId,
|
|
492
|
+
content,
|
|
493
|
+
channelIds: channelIdList.length ? channelIdList : void 0,
|
|
494
|
+
authorIds: authorIdList.length ? authorIdList : void 0,
|
|
495
|
+
limit
|
|
496
|
+
}, ctx.withOpts());
|
|
497
|
+
if (!results || typeof results !== "object") return jsonResult({
|
|
498
|
+
ok: true,
|
|
499
|
+
results
|
|
500
|
+
});
|
|
501
|
+
const resultsRecord = results;
|
|
502
|
+
const messages = resultsRecord.messages;
|
|
503
|
+
const normalizedMessages = Array.isArray(messages) ? messages.map((group) => Array.isArray(group) ? group.map((msg) => ctx.normalizeMessage(msg)) : group) : messages;
|
|
504
|
+
return jsonResult({
|
|
505
|
+
ok: true,
|
|
506
|
+
results: {
|
|
507
|
+
...resultsRecord,
|
|
508
|
+
messages: normalizedMessages
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
default: return;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region extensions/discord/src/actions/runtime.messaging.reactions.ts
|
|
517
|
+
async function handleDiscordReactionMessagingAction(ctx) {
|
|
518
|
+
switch (ctx.action) {
|
|
519
|
+
case "react": {
|
|
520
|
+
if (!ctx.isActionEnabled("reactions")) throw new Error("Discord reactions are disabled.");
|
|
521
|
+
const channelId = await ctx.resolveReactionChannelId();
|
|
522
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
523
|
+
const { emoji, remove, isEmpty } = readReactionParams(ctx.params, { removeErrorMessage: "Emoji is required to remove a Discord reaction." });
|
|
524
|
+
if (remove) {
|
|
525
|
+
await discordMessagingActionRuntime.removeReactionDiscord(channelId, messageId, emoji, ctx.withReactionRuntimeOptions());
|
|
526
|
+
return jsonResult({
|
|
527
|
+
ok: true,
|
|
528
|
+
removed: emoji
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
if (isEmpty) return jsonResult({
|
|
532
|
+
ok: true,
|
|
533
|
+
removed: (await discordMessagingActionRuntime.removeOwnReactionsDiscord(channelId, messageId, ctx.withReactionRuntimeOptions())).removed
|
|
534
|
+
});
|
|
535
|
+
await discordMessagingActionRuntime.reactMessageDiscord(channelId, messageId, emoji, ctx.withReactionRuntimeOptions());
|
|
536
|
+
return jsonResult({
|
|
537
|
+
ok: true,
|
|
538
|
+
added: emoji
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
case "reactions": {
|
|
542
|
+
if (!ctx.isActionEnabled("reactions")) throw new Error("Discord reactions are disabled.");
|
|
543
|
+
const channelId = await ctx.resolveReactionChannelId();
|
|
544
|
+
const messageId = readStringParam(ctx.params, "messageId", { required: true });
|
|
545
|
+
const limit = readNumberParam(ctx.params, "limit");
|
|
546
|
+
return jsonResult({
|
|
547
|
+
ok: true,
|
|
548
|
+
reactions: await discordMessagingActionRuntime.fetchReactionsDiscord(channelId, messageId, ctx.withReactionRuntimeOptions({ limit }))
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
default: return;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region extensions/discord/src/actions/runtime.messaging.send.ts
|
|
556
|
+
function hasDiscordComponentObjectKeys(value) {
|
|
557
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0);
|
|
558
|
+
}
|
|
559
|
+
async function handleDiscordMessageSendAction(ctx) {
|
|
560
|
+
switch (ctx.action) {
|
|
561
|
+
case "sticker": {
|
|
562
|
+
if (!ctx.isActionEnabled("stickers")) throw new Error("Discord stickers are disabled.");
|
|
563
|
+
const to = readStringParam(ctx.params, "to", { required: true });
|
|
564
|
+
const content = readStringParam(ctx.params, "content");
|
|
565
|
+
const stickerIds = readStringArrayParam(ctx.params, "stickerIds", {
|
|
566
|
+
required: true,
|
|
567
|
+
label: "stickerIds"
|
|
568
|
+
});
|
|
569
|
+
await discordMessagingActionRuntime.sendStickerDiscord(to, stickerIds, ctx.withOpts({ content }));
|
|
570
|
+
return jsonResult({ ok: true });
|
|
571
|
+
}
|
|
572
|
+
case "poll": {
|
|
573
|
+
if (!ctx.isActionEnabled("polls")) throw new Error("Discord polls are disabled.");
|
|
574
|
+
const to = readStringParam(ctx.params, "to", { required: true });
|
|
575
|
+
const content = readStringParam(ctx.params, "content");
|
|
576
|
+
const question = readStringParam(ctx.params, "question", { required: true });
|
|
577
|
+
const answers = readStringArrayParam(ctx.params, "answers", {
|
|
578
|
+
required: true,
|
|
579
|
+
label: "answers"
|
|
580
|
+
});
|
|
581
|
+
const allowMultiselect = readBooleanParam(ctx.params, "allowMultiselect");
|
|
582
|
+
const durationHours = readNumberParam(ctx.params, "durationHours");
|
|
583
|
+
const maxSelections = resolvePollMaxSelections(answers.length, allowMultiselect);
|
|
584
|
+
await discordMessagingActionRuntime.sendPollDiscord(to, {
|
|
585
|
+
question,
|
|
586
|
+
options: answers,
|
|
587
|
+
maxSelections,
|
|
588
|
+
durationHours
|
|
589
|
+
}, ctx.withOpts({ content }));
|
|
590
|
+
return jsonResult({ ok: true });
|
|
591
|
+
}
|
|
592
|
+
case "sendMessage": {
|
|
593
|
+
if (!ctx.isActionEnabled("messages")) throw new Error("Discord message sends are disabled.");
|
|
594
|
+
const to = readStringParam(ctx.params, "to", { required: true });
|
|
595
|
+
const asVoice = ctx.params.asVoice === true;
|
|
596
|
+
const silent = ctx.params.silent === true;
|
|
597
|
+
const rawComponents = ctx.params.components;
|
|
598
|
+
const componentSpec = hasDiscordComponentObjectKeys(rawComponents) ? discordMessagingActionRuntime.readDiscordComponentSpec(rawComponents) : null;
|
|
599
|
+
const components = Array.isArray(rawComponents) || typeof rawComponents === "function" ? rawComponents : void 0;
|
|
600
|
+
const mediaUrl = readStringParam(ctx.params, "mediaUrl", { trim: false }) ?? readStringParam(ctx.params, "path", { trim: false }) ?? readStringParam(ctx.params, "filePath", { trim: false });
|
|
601
|
+
const content = readStringParam(ctx.params, "content", {
|
|
602
|
+
required: !asVoice && !componentSpec && !components && !mediaUrl,
|
|
603
|
+
allowEmpty: true
|
|
604
|
+
});
|
|
605
|
+
const filename = readStringParam(ctx.params, "filename");
|
|
606
|
+
const replyTo = readStringParam(ctx.params, "replyTo");
|
|
607
|
+
const rawEmbeds = ctx.params.embeds;
|
|
608
|
+
const embeds = Array.isArray(rawEmbeds) ? rawEmbeds : void 0;
|
|
609
|
+
const sessionKey = readStringParam(ctx.params, "__sessionKey");
|
|
610
|
+
const agentId = readStringParam(ctx.params, "__agentId");
|
|
611
|
+
if (componentSpec) {
|
|
612
|
+
if (asVoice) throw new Error("Discord components cannot be sent as voice messages.");
|
|
613
|
+
if (embeds?.length) throw new Error("Discord components cannot include embeds.");
|
|
614
|
+
const normalizedContent = content?.trim() ? content : void 0;
|
|
615
|
+
const payload = componentSpec.text ? componentSpec : {
|
|
616
|
+
...componentSpec,
|
|
617
|
+
text: normalizedContent
|
|
618
|
+
};
|
|
619
|
+
return jsonResult({
|
|
620
|
+
ok: true,
|
|
621
|
+
result: await discordMessagingActionRuntime.sendDiscordComponentMessage(to, payload, {
|
|
622
|
+
...ctx.withOpts(),
|
|
623
|
+
silent,
|
|
624
|
+
replyTo: replyTo ?? void 0,
|
|
625
|
+
sessionKey: sessionKey ?? void 0,
|
|
626
|
+
agentId: agentId ?? void 0,
|
|
627
|
+
mediaUrl: mediaUrl ?? void 0,
|
|
628
|
+
filename: filename ?? void 0,
|
|
629
|
+
mediaAccess: ctx.options?.mediaAccess,
|
|
630
|
+
mediaLocalRoots: ctx.options?.mediaLocalRoots,
|
|
631
|
+
mediaReadFile: ctx.options?.mediaReadFile
|
|
632
|
+
}),
|
|
633
|
+
components: true
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
if (asVoice) {
|
|
637
|
+
if (!mediaUrl) throw new Error("Voice messages require a media file reference (mediaUrl, path, or filePath).");
|
|
638
|
+
if (content && content.trim()) throw new Error("Voice messages cannot include text content (Discord limitation). Remove the content parameter.");
|
|
639
|
+
assertMediaNotDataUrl(mediaUrl);
|
|
640
|
+
return jsonResult({
|
|
641
|
+
ok: true,
|
|
642
|
+
result: await discordMessagingActionRuntime.sendVoiceMessageDiscord(to, mediaUrl, {
|
|
643
|
+
...ctx.withOpts(),
|
|
644
|
+
replyTo,
|
|
645
|
+
silent
|
|
646
|
+
}),
|
|
647
|
+
voiceMessage: true
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
return jsonResult({
|
|
651
|
+
ok: true,
|
|
652
|
+
result: await discordMessagingActionRuntime.sendMessageDiscord(to, content ?? "", {
|
|
653
|
+
...ctx.withOpts(),
|
|
654
|
+
mediaAccess: ctx.options?.mediaAccess,
|
|
655
|
+
mediaUrl,
|
|
656
|
+
filename: filename ?? void 0,
|
|
657
|
+
mediaLocalRoots: ctx.options?.mediaLocalRoots,
|
|
658
|
+
mediaReadFile: ctx.options?.mediaReadFile,
|
|
659
|
+
replyTo,
|
|
660
|
+
components,
|
|
661
|
+
embeds,
|
|
662
|
+
silent
|
|
663
|
+
})
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
case "threadCreate": {
|
|
667
|
+
if (!ctx.isActionEnabled("threads")) throw new Error("Discord threads are disabled.");
|
|
668
|
+
const channelId = ctx.resolveChannelId();
|
|
669
|
+
const name = readStringParam(ctx.params, "name", { required: true });
|
|
670
|
+
const messageId = readStringParam(ctx.params, "messageId");
|
|
671
|
+
const content = readStringParam(ctx.params, "content");
|
|
672
|
+
const payload = {
|
|
673
|
+
name,
|
|
674
|
+
messageId,
|
|
675
|
+
autoArchiveMinutes: readNumberParam(ctx.params, "autoArchiveMinutes"),
|
|
676
|
+
content,
|
|
677
|
+
appliedTags: readStringArrayParam(ctx.params, "appliedTags") ?? void 0
|
|
678
|
+
};
|
|
679
|
+
try {
|
|
680
|
+
return jsonResult({
|
|
681
|
+
ok: true,
|
|
682
|
+
thread: await discordMessagingActionRuntime.createThreadDiscord(channelId, payload, ctx.withOpts())
|
|
683
|
+
});
|
|
684
|
+
} catch (error) {
|
|
685
|
+
if (error instanceof DiscordThreadInitialMessageError) return jsonResult({
|
|
686
|
+
ok: true,
|
|
687
|
+
partial: true,
|
|
688
|
+
thread: error.thread,
|
|
689
|
+
warning: "Discord thread was created, but sending the initial message failed.",
|
|
690
|
+
initialMessageError: error.initialMessageError
|
|
691
|
+
});
|
|
692
|
+
throw error;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
case "threadList": {
|
|
696
|
+
if (!ctx.isActionEnabled("threads")) throw new Error("Discord threads are disabled.");
|
|
697
|
+
const guildId = readStringParam(ctx.params, "guildId", { required: true });
|
|
698
|
+
const channelId = readStringParam(ctx.params, "channelId");
|
|
699
|
+
const includeArchived = readBooleanParam(ctx.params, "includeArchived");
|
|
700
|
+
const before = readStringParam(ctx.params, "before");
|
|
701
|
+
const limit = readNumberParam(ctx.params, "limit");
|
|
702
|
+
return jsonResult({
|
|
703
|
+
ok: true,
|
|
704
|
+
threads: await discordMessagingActionRuntime.listThreadsDiscord({
|
|
705
|
+
guildId,
|
|
706
|
+
channelId,
|
|
707
|
+
includeArchived,
|
|
708
|
+
before,
|
|
709
|
+
limit
|
|
710
|
+
}, ctx.withOpts())
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
case "threadReply": {
|
|
714
|
+
if (!ctx.isActionEnabled("threads")) throw new Error("Discord threads are disabled.");
|
|
715
|
+
const channelId = ctx.resolveChannelId();
|
|
716
|
+
const content = readStringParam(ctx.params, "content", { required: true });
|
|
717
|
+
const mediaUrl = readStringParam(ctx.params, "mediaUrl");
|
|
718
|
+
const replyTo = readStringParam(ctx.params, "replyTo");
|
|
719
|
+
return jsonResult({
|
|
720
|
+
ok: true,
|
|
721
|
+
result: await discordMessagingActionRuntime.sendMessageDiscord(`channel:${channelId}`, content, {
|
|
722
|
+
...ctx.withOpts(),
|
|
723
|
+
mediaUrl,
|
|
724
|
+
mediaLocalRoots: ctx.options?.mediaLocalRoots,
|
|
725
|
+
mediaReadFile: ctx.options?.mediaReadFile,
|
|
726
|
+
replyTo
|
|
727
|
+
})
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
default: return;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region extensions/discord/src/actions/runtime.messaging.shared.ts
|
|
735
|
+
function createDiscordMessagingActionContext(params) {
|
|
736
|
+
const accountId = readStringParam(params.input, "accountId");
|
|
737
|
+
const cfgOptions = { cfg: params.cfg };
|
|
738
|
+
const withOpts = (extra) => createDiscordActionOptions({
|
|
739
|
+
cfg: params.cfg,
|
|
740
|
+
accountId,
|
|
741
|
+
extra
|
|
742
|
+
});
|
|
743
|
+
const resolvedReactionAccountId = accountId ?? resolveDefaultDiscordAccountId(params.cfg);
|
|
744
|
+
const reactionRuntimeOptions = resolvedReactionAccountId ? createDiscordRuntimeAccountContext({
|
|
745
|
+
cfg: params.cfg,
|
|
746
|
+
accountId: resolvedReactionAccountId
|
|
747
|
+
}) : cfgOptions;
|
|
748
|
+
return {
|
|
749
|
+
action: params.action,
|
|
750
|
+
params: params.input,
|
|
751
|
+
isActionEnabled: params.isActionEnabled,
|
|
752
|
+
cfg: params.cfg,
|
|
753
|
+
options: params.options,
|
|
754
|
+
accountId,
|
|
755
|
+
resolveChannelId: () => discordMessagingActionRuntime.resolveDiscordChannelId(readStringParam(params.input, "channelId", { required: true })),
|
|
756
|
+
resolveReactionChannelId: async () => {
|
|
757
|
+
const target = readStringParam(params.input, "channelId") ?? readStringParam(params.input, "to", { required: true });
|
|
758
|
+
return await discordMessagingActionRuntime.resolveDiscordReactionTargetChannelId({
|
|
759
|
+
target,
|
|
760
|
+
cfg: params.cfg,
|
|
761
|
+
accountId: resolvedReactionAccountId
|
|
762
|
+
});
|
|
763
|
+
},
|
|
764
|
+
withOpts,
|
|
765
|
+
withReactionRuntimeOptions: (extra) => ({
|
|
766
|
+
...reactionRuntimeOptions ?? cfgOptions,
|
|
767
|
+
...extra
|
|
768
|
+
}),
|
|
769
|
+
normalizeMessage: (message) => {
|
|
770
|
+
if (!message || typeof message !== "object") return message;
|
|
771
|
+
return withNormalizedTimestamp(message, message.timestamp);
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region extensions/discord/src/actions/runtime.messaging.ts
|
|
777
|
+
async function handleDiscordMessagingAction(action, params, isActionEnabled, cfg, options) {
|
|
778
|
+
if (!cfg) throw new Error("Discord messaging actions require a resolved runtime config.");
|
|
779
|
+
const ctx = createDiscordMessagingActionContext({
|
|
780
|
+
action,
|
|
781
|
+
input: params,
|
|
782
|
+
isActionEnabled,
|
|
783
|
+
cfg,
|
|
784
|
+
options
|
|
785
|
+
});
|
|
786
|
+
return await handleDiscordReactionMessagingAction(ctx) ?? await handleDiscordMessageSendAction(ctx) ?? await handleDiscordMessageManagementAction(ctx) ?? (() => {
|
|
787
|
+
throw new Error(`Unknown action: ${action}`);
|
|
788
|
+
})();
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region extensions/discord/src/actions/runtime.moderation-shared.ts
|
|
792
|
+
const moderationPermissions = {
|
|
793
|
+
timeout: PermissionFlagsBits.ModerateMembers,
|
|
794
|
+
kick: PermissionFlagsBits.KickMembers,
|
|
795
|
+
ban: PermissionFlagsBits.BanMembers
|
|
796
|
+
};
|
|
797
|
+
function isDiscordModerationAction(action) {
|
|
798
|
+
return action === "timeout" || action === "kick" || action === "ban";
|
|
799
|
+
}
|
|
800
|
+
function requiredGuildPermissionForModerationAction(action) {
|
|
801
|
+
return moderationPermissions[action];
|
|
802
|
+
}
|
|
803
|
+
function readDiscordModerationCommand(action, params) {
|
|
804
|
+
if (!isDiscordModerationAction(action)) throw new Error(`Unsupported Discord moderation action: ${action}`);
|
|
805
|
+
return {
|
|
806
|
+
action,
|
|
807
|
+
guildId: readStringParam(params, "guildId", { required: true }),
|
|
808
|
+
userId: readStringParam(params, "userId", { required: true }),
|
|
809
|
+
durationMinutes: readNumberParam(params, "durationMinutes", { integer: true }),
|
|
810
|
+
until: readStringParam(params, "until"),
|
|
811
|
+
reason: readStringParam(params, "reason"),
|
|
812
|
+
deleteMessageDays: readNumberParam(params, "deleteMessageDays", { integer: true })
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region extensions/discord/src/actions/runtime.moderation.ts
|
|
817
|
+
const discordModerationActionRuntime = {
|
|
818
|
+
banMemberDiscord,
|
|
819
|
+
hasAnyGuildPermissionDiscord,
|
|
820
|
+
kickMemberDiscord,
|
|
821
|
+
timeoutMemberDiscord
|
|
822
|
+
};
|
|
823
|
+
async function verifySenderModerationPermission(params) {
|
|
824
|
+
if (!params.senderUserId) return;
|
|
825
|
+
if (!await discordModerationActionRuntime.hasAnyGuildPermissionDiscord(params.guildId, params.senderUserId, [params.requiredPermission], createDiscordActionOptions({
|
|
826
|
+
cfg: params.cfg,
|
|
827
|
+
accountId: params.accountId
|
|
828
|
+
}))) throw new Error("Sender does not have required permissions for this moderation action.");
|
|
829
|
+
}
|
|
830
|
+
async function handleDiscordModerationAction(action, params, isActionEnabled, cfg) {
|
|
831
|
+
if (!isDiscordModerationAction(action)) throw new Error(`Unknown action: ${action}`);
|
|
832
|
+
if (!isActionEnabled("moderation", false)) throw new Error("Discord moderation is disabled.");
|
|
833
|
+
if (!cfg) throw new Error("Discord moderation actions require a resolved runtime config.");
|
|
834
|
+
const accountId = readStringParam(params, "accountId");
|
|
835
|
+
const command = readDiscordModerationCommand(action, params);
|
|
836
|
+
const senderUserId = readStringParam(params, "senderUserId");
|
|
837
|
+
const withOpts = () => createDiscordActionOptions({
|
|
838
|
+
cfg,
|
|
839
|
+
accountId
|
|
840
|
+
});
|
|
841
|
+
await verifySenderModerationPermission({
|
|
842
|
+
guildId: command.guildId,
|
|
843
|
+
senderUserId,
|
|
844
|
+
requiredPermission: requiredGuildPermissionForModerationAction(command.action),
|
|
845
|
+
accountId,
|
|
846
|
+
cfg
|
|
847
|
+
});
|
|
848
|
+
switch (command.action) {
|
|
849
|
+
case "timeout": return jsonResult({
|
|
850
|
+
ok: true,
|
|
851
|
+
member: await discordModerationActionRuntime.timeoutMemberDiscord({
|
|
852
|
+
guildId: command.guildId,
|
|
853
|
+
userId: command.userId,
|
|
854
|
+
durationMinutes: command.durationMinutes,
|
|
855
|
+
until: command.until,
|
|
856
|
+
reason: command.reason
|
|
857
|
+
}, withOpts())
|
|
858
|
+
});
|
|
859
|
+
case "kick":
|
|
860
|
+
await discordModerationActionRuntime.kickMemberDiscord({
|
|
861
|
+
guildId: command.guildId,
|
|
862
|
+
userId: command.userId,
|
|
863
|
+
reason: command.reason
|
|
864
|
+
}, withOpts());
|
|
865
|
+
return jsonResult({ ok: true });
|
|
866
|
+
case "ban":
|
|
867
|
+
await discordModerationActionRuntime.banMemberDiscord({
|
|
868
|
+
guildId: command.guildId,
|
|
869
|
+
userId: command.userId,
|
|
870
|
+
reason: command.reason,
|
|
871
|
+
deleteMessageDays: command.deleteMessageDays
|
|
872
|
+
}, withOpts());
|
|
873
|
+
return jsonResult({ ok: true });
|
|
874
|
+
}
|
|
875
|
+
throw new Error("Unsupported Discord moderation action");
|
|
876
|
+
}
|
|
877
|
+
//#endregion
|
|
878
|
+
//#region extensions/discord/src/actions/runtime.presence.ts
|
|
879
|
+
const ACTIVITY_TYPE_MAP = {
|
|
880
|
+
playing: 0,
|
|
881
|
+
streaming: 1,
|
|
882
|
+
listening: 2,
|
|
883
|
+
watching: 3,
|
|
884
|
+
custom: 4,
|
|
885
|
+
competing: 5
|
|
886
|
+
};
|
|
887
|
+
const VALID_STATUSES = new Set([
|
|
888
|
+
"online",
|
|
889
|
+
"dnd",
|
|
890
|
+
"idle",
|
|
891
|
+
"invisible"
|
|
892
|
+
]);
|
|
893
|
+
async function handleDiscordPresenceAction(action, params, isActionEnabled) {
|
|
894
|
+
if (action !== "setPresence") throw new Error(`Unknown presence action: ${action}`);
|
|
895
|
+
if (!isActionEnabled("presence", false)) throw new Error("Discord presence changes are disabled.");
|
|
896
|
+
const accountId = readStringParam(params, "accountId");
|
|
897
|
+
const gateway = getGateway(accountId);
|
|
898
|
+
if (!gateway) throw new Error(`Discord gateway not available${accountId ? ` for account "${accountId}"` : ""}. The bot may not be connected.`);
|
|
899
|
+
if (!gateway.isConnected) throw new Error(`Discord gateway is not connected${accountId ? ` for account "${accountId}"` : ""}.`);
|
|
900
|
+
const statusRaw = readStringParam(params, "status") ?? "online";
|
|
901
|
+
if (!VALID_STATUSES.has(statusRaw)) throw new Error(`Invalid status "${statusRaw}". Must be one of: ${[...VALID_STATUSES].join(", ")}`);
|
|
902
|
+
const status = statusRaw;
|
|
903
|
+
const activityTypeRaw = readStringParam(params, "activityType");
|
|
904
|
+
const activityName = readStringParam(params, "activityName");
|
|
905
|
+
const activities = [];
|
|
906
|
+
if (activityTypeRaw || activityName) {
|
|
907
|
+
if (!activityTypeRaw) throw new Error(`activityType is required when activityName is provided. Valid types: ${Object.keys(ACTIVITY_TYPE_MAP).join(", ")}`);
|
|
908
|
+
const typeNum = ACTIVITY_TYPE_MAP[normalizeLowercaseStringOrEmpty(activityTypeRaw)];
|
|
909
|
+
if (typeNum === void 0) throw new Error(`Invalid activityType "${activityTypeRaw}". Must be one of: ${Object.keys(ACTIVITY_TYPE_MAP).join(", ")}`);
|
|
910
|
+
const activity = {
|
|
911
|
+
name: activityName ?? "",
|
|
912
|
+
type: typeNum
|
|
913
|
+
};
|
|
914
|
+
if (typeNum === 1) {
|
|
915
|
+
const url = readStringParam(params, "activityUrl");
|
|
916
|
+
if (url) activity.url = url;
|
|
917
|
+
}
|
|
918
|
+
const state = readStringParam(params, "activityState");
|
|
919
|
+
if (state) activity.state = state;
|
|
920
|
+
activities.push(activity);
|
|
921
|
+
}
|
|
922
|
+
const presenceData = {
|
|
923
|
+
since: null,
|
|
924
|
+
activities,
|
|
925
|
+
status,
|
|
926
|
+
afk: false
|
|
927
|
+
};
|
|
928
|
+
gateway.updatePresence(presenceData);
|
|
929
|
+
return jsonResult({
|
|
930
|
+
ok: true,
|
|
931
|
+
status,
|
|
932
|
+
activities: activities.map((a) => Object.assign({
|
|
933
|
+
type: a.type,
|
|
934
|
+
name: a.name
|
|
935
|
+
}, a.url ? { url: a.url } : {}, a.state ? { state: a.state } : {}))
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
//#endregion
|
|
939
|
+
//#region extensions/discord/src/actions/runtime.ts
|
|
940
|
+
const messagingActions = new Set([
|
|
941
|
+
"react",
|
|
942
|
+
"reactions",
|
|
943
|
+
"sticker",
|
|
944
|
+
"poll",
|
|
945
|
+
"permissions",
|
|
946
|
+
"fetchMessage",
|
|
947
|
+
"readMessages",
|
|
948
|
+
"sendMessage",
|
|
949
|
+
"editMessage",
|
|
950
|
+
"deleteMessage",
|
|
951
|
+
"threadCreate",
|
|
952
|
+
"threadList",
|
|
953
|
+
"threadReply",
|
|
954
|
+
"pinMessage",
|
|
955
|
+
"unpinMessage",
|
|
956
|
+
"listPins",
|
|
957
|
+
"searchMessages"
|
|
958
|
+
]);
|
|
959
|
+
const guildActions = new Set([
|
|
960
|
+
"memberInfo",
|
|
961
|
+
"roleInfo",
|
|
962
|
+
"emojiList",
|
|
963
|
+
"emojiUpload",
|
|
964
|
+
"stickerUpload",
|
|
965
|
+
"roleAdd",
|
|
966
|
+
"roleRemove",
|
|
967
|
+
"channelInfo",
|
|
968
|
+
"channelList",
|
|
969
|
+
"voiceStatus",
|
|
970
|
+
"eventList",
|
|
971
|
+
"eventCreate",
|
|
972
|
+
"channelCreate",
|
|
973
|
+
"channelEdit",
|
|
974
|
+
"channelDelete",
|
|
975
|
+
"channelMove",
|
|
976
|
+
"categoryCreate",
|
|
977
|
+
"categoryEdit",
|
|
978
|
+
"categoryDelete",
|
|
979
|
+
"channelPermissionSet",
|
|
980
|
+
"channelPermissionRemove"
|
|
981
|
+
]);
|
|
982
|
+
const moderationActions = new Set([
|
|
983
|
+
"timeout",
|
|
984
|
+
"kick",
|
|
985
|
+
"ban"
|
|
986
|
+
]);
|
|
987
|
+
const presenceActions = new Set(["setPresence"]);
|
|
988
|
+
async function handleDiscordAction(params, cfg, options) {
|
|
989
|
+
const action = readStringParam(params, "action", { required: true });
|
|
990
|
+
const isActionEnabled = createDiscordActionGate({
|
|
991
|
+
cfg,
|
|
992
|
+
accountId: readStringParam(params, "accountId")
|
|
993
|
+
});
|
|
994
|
+
if (messagingActions.has(action)) return await handleDiscordMessagingAction(action, params, isActionEnabled, cfg, options);
|
|
995
|
+
if (guildActions.has(action)) return await handleDiscordGuildAction(action, params, isActionEnabled, cfg, options);
|
|
996
|
+
if (moderationActions.has(action)) return await handleDiscordModerationAction(action, params, isActionEnabled, cfg);
|
|
997
|
+
if (presenceActions.has(action)) return await handleDiscordPresenceAction(action, params, isActionEnabled);
|
|
998
|
+
throw new Error(`Unknown action: ${action}`);
|
|
999
|
+
}
|
|
1000
|
+
//#endregion
|
|
1001
|
+
export { readDiscordChannelCreateParams as a, readDiscordParentIdParam as c, requiredGuildPermissionForModerationAction as i, isDiscordModerationAction as n, readDiscordChannelEditParams as o, readDiscordModerationCommand as r, readDiscordChannelMoveParams as s, handleDiscordAction as t };
|