@effect/chat-discord 0.0.0 → 4.1.6

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.
Files changed (132) hide show
  1. package/AGENTS.md +434 -0
  2. package/CLAUDE.md +434 -0
  3. package/LICENSE +21 -0
  4. package/README.md +27 -0
  5. package/ai-docs/README.md +44 -0
  6. package/ai-docs/package.json +36 -0
  7. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  8. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +52 -0
  9. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  10. package/ai-docs/src/01_effect/01_basics/index.md +7 -0
  11. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  12. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  13. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  14. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  15. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  16. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  17. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  18. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  19. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  20. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  21. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  22. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  23. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  24. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  25. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  26. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  27. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  28. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  29. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  30. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  31. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  32. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  33. package/ai-docs/src/03_stream/30_encoding.ts +163 -0
  34. package/ai-docs/src/03_stream/index.md +4 -0
  35. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  36. package/ai-docs/src/04_integration/index.md +5 -0
  37. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  38. package/ai-docs/src/05_batching/index.md +3 -0
  39. package/ai-docs/src/06_schedule/10_schedules.ts +111 -0
  40. package/ai-docs/src/06_schedule/index.md +3 -0
  41. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  42. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  43. package/ai-docs/src/07_datetime/index.md +5 -0
  44. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  45. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  46. package/ai-docs/src/08_observability/index.md +7 -0
  47. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  48. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  49. package/ai-docs/src/09_testing/index.md +1 -0
  50. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  51. package/ai-docs/src/10_predicate/index.md +9 -0
  52. package/ai-docs/src/40_sql/10_basics.ts +175 -0
  53. package/ai-docs/src/40_sql/index.md +6 -0
  54. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  55. package/ai-docs/src/50_http-client/index.md +3 -0
  56. package/ai-docs/src/51_http-server/10_basics.ts +118 -0
  57. package/ai-docs/src/51_http-server/20_testing.ts +100 -0
  58. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  59. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  60. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  61. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
  62. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
  63. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  64. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
  65. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
  66. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
  67. package/ai-docs/src/51_http-server/index.md +3 -0
  68. package/ai-docs/src/52_graphql/10_basics.ts +117 -0
  69. package/ai-docs/src/52_graphql/20_testing.ts +45 -0
  70. package/ai-docs/src/52_graphql/30_batching.ts +118 -0
  71. package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
  72. package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
  73. package/ai-docs/src/52_graphql/index.md +6 -0
  74. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  75. package/ai-docs/src/60_child-process/index.md +3 -0
  76. package/ai-docs/src/70_cli/10_basics.ts +162 -0
  77. package/ai-docs/src/70_cli/index.md +5 -0
  78. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  79. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  80. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  81. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  82. package/ai-docs/src/71_ai/index.md +5 -0
  83. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  84. package/ai-docs/src/80_cluster/index.md +4 -0
  85. package/ai-docs/src/index.md +10 -0
  86. package/ai-docs/tsconfig.json +28 -0
  87. package/dist/DiscordChat.d.ts +530 -0
  88. package/dist/DiscordChat.d.ts.map +1 -0
  89. package/dist/DiscordChat.js +574 -0
  90. package/dist/DiscordChat.js.map +1 -0
  91. package/dist/index.d.ts +10 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +11 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/internal/adapter.d.ts +2 -0
  96. package/dist/internal/adapter.d.ts.map +1 -0
  97. package/dist/internal/adapter.js +492 -0
  98. package/dist/internal/adapter.js.map +1 -0
  99. package/dist/internal/errors.d.ts +2 -0
  100. package/dist/internal/errors.d.ts.map +1 -0
  101. package/dist/internal/errors.js +236 -0
  102. package/dist/internal/errors.js.map +1 -0
  103. package/dist/internal/interactions.d.ts +2 -0
  104. package/dist/internal/interactions.d.ts.map +1 -0
  105. package/dist/internal/interactions.js +490 -0
  106. package/dist/internal/interactions.js.map +1 -0
  107. package/dist/internal/length.d.ts +2 -0
  108. package/dist/internal/length.d.ts.map +1 -0
  109. package/dist/internal/length.js +31 -0
  110. package/dist/internal/length.js.map +1 -0
  111. package/dist/internal/mentions.d.ts +2 -0
  112. package/dist/internal/mentions.d.ts.map +1 -0
  113. package/dist/internal/mentions.js +93 -0
  114. package/dist/internal/mentions.js.map +1 -0
  115. package/dist/internal/normalize.d.ts +2 -0
  116. package/dist/internal/normalize.d.ts.map +1 -0
  117. package/dist/internal/normalize.js +322 -0
  118. package/dist/internal/normalize.js.map +1 -0
  119. package/dist/internal/options.d.ts +2 -0
  120. package/dist/internal/options.d.ts.map +1 -0
  121. package/dist/internal/options.js +25 -0
  122. package/dist/internal/options.js.map +1 -0
  123. package/package.json +63 -1
  124. package/src/DiscordChat.ts +703 -0
  125. package/src/index.ts +12 -0
  126. package/src/internal/adapter.ts +653 -0
  127. package/src/internal/errors.ts +184 -0
  128. package/src/internal/interactions.ts +451 -0
  129. package/src/internal/length.ts +33 -0
  130. package/src/internal/mentions.ts +101 -0
  131. package/src/internal/normalize.ts +363 -0
  132. package/src/internal/options.ts +29 -0
@@ -0,0 +1,574 @@
1
+ /**
2
+ * The Discord adapter for `effect/chat`: the `Registry` layer, the
3
+ * structural dispatch and interaction entries, the pure normalisers, the
4
+ * gateway layers, address helpers and the scoped post options. It runs on
5
+ * dfx: every REST call goes through the `DiscordREST` in context.
6
+ *
7
+ * **Details**
8
+ *
9
+ * - Gateway intents: `GUILDS`, `GUILD_MESSAGES`, `GUILD_MESSAGE_REACTIONS`,
10
+ * `DIRECT_MESSAGES`, `DIRECT_MESSAGE_REACTIONS` and `MESSAGE_CONTENT`.
11
+ * They are set in the consumer's dfx config.
12
+ * - `MESSAGE_CONTENT` is a privileged intent: switch it on for the
13
+ * application in Discord's developer portal. Without it, `text` is empty
14
+ * on every message that doesn't mention the bot, and attachments are
15
+ * missing.
16
+ * - Bot permissions: View Channel, Send Messages, Send Messages in Threads,
17
+ * Create Public Threads, Read Message History and Attach Files.
18
+ * - Slash commands need the `applications.commands` scope, and are
19
+ * registered by the consumer with the payloads `commandRequests` gives.
20
+ *
21
+ * @stability unstable
22
+ * @since 4.1.5
23
+ */
24
+ import { DiscordConfig } from "dfx/DiscordConfig";
25
+ import { DiscordGateway } from "dfx/DiscordGateway";
26
+ import { DispatchHook } from "dfx/DiscordGateway/Shard/DispatchHook";
27
+ import { DiscordREST } from "dfx/DiscordREST";
28
+ import * as Cause from "effect/Cause";
29
+ import { Registry } from "effect/chat/ChatAdapter";
30
+ import { ChatHandler, NotAccepted } from "effect/chat/ChatHandler";
31
+ import * as ChatInteraction from "effect/chat/ChatInteraction";
32
+ import * as Context from "effect/Context";
33
+ import * as Duration from "effect/Duration";
34
+ import * as Effect from "effect/Effect";
35
+ import { dual } from "effect/Function";
36
+ import * as HttpClient from "effect/http/HttpClient";
37
+ import * as Layer from "effect/Layer";
38
+ import * as Option from "effect/Option";
39
+ import * as Result from "effect/Result";
40
+ import * as Schema from "effect/Schema";
41
+ import * as Stream from "effect/Stream";
42
+ import * as Adapter from "./internal/adapter.js";
43
+ import * as Errors from "./internal/errors.js";
44
+ import * as Interactions from "./internal/interactions.js";
45
+ import * as Mentions from "./internal/mentions.js";
46
+ import * as Normalize from "./internal/normalize.js";
47
+ import { CurrentPostOptions } from "./internal/options.js";
48
+ /**
49
+ * The Discord side of the adapter, for what the core has no op for.
50
+ *
51
+ * **Details**
52
+ *
53
+ * - `botUserId` comes from `GET /users/@me`, read once. A failed read is
54
+ * tried again next time.
55
+ * - `dispatch` takes one gateway dispatch, `{ t, d }`, and hands its
56
+ * events to the `ChatHandler` one at a time. It reads `d` with a Schema
57
+ * and ignores what it doesn't know, so it takes no dfx type.
58
+ * - When a `MESSAGE_CREATE` carries no `channel_type`, `dispatch` looks
59
+ * the channel up, cached and with a five second timeout. A failed lookup
60
+ * is logged and fails with `NotAccepted`. A lookup that would fail the same
61
+ * way again, such as a deleted channel, is logged and the event dropped.
62
+ * - `interaction` takes one `INTERACTION_CREATE` payload, from the gateway
63
+ * or from an HTTP interactions endpoint. It reads it with a Schema, so it
64
+ * takes no dfx type, and ignores an interaction it can't express: a
65
+ * message or user command, an autocomplete request, a slash command with
66
+ * anything but at most one string option. It calls the handler through
67
+ * `ChatInteraction.handle` and answers through the interaction callback
68
+ * endpoint, which has to land inside Discord's 3 seconds: `deadline` is
69
+ * the handler's share, 2 seconds by default.
70
+ * - A click is answered with callback type 6, or type 9 for `OpenModal`.
71
+ * A submit's `close` is type 6. An `errors` reply is type 4 with the
72
+ * ephemeral flag, listing each message as plain text, and the modal closes: Discord
73
+ * can't show an error inside a modal, so the descriptor has no
74
+ * `modalErrors`.
75
+ * - A slash command goes to `Handler.command`. `respond` is callback type
76
+ * 4 with the message a `post` sends, `defer` type 5 and `OpenModal` type
77
+ * 9, each with the ephemeral flag when private. An `Ack`, which is what a
78
+ * command nobody handles gets, sends nothing, so a command another library
79
+ * owns is left to it. `withPostOptions` does not reach a command's
80
+ * answer, `respond` or `followUp`: a mention in it renders and notifies
81
+ * nobody.
82
+ * - Commands were recorded in a guild channel over the gateway. A command
83
+ * in a direct is from Discord's docs and was not run.
84
+ * - A click on a private answer carries the message, with the ephemeral flag
85
+ * (64). Its `messageId` tells which answer was clicked. Discord's docs
86
+ * reach an interaction's messages only through its token, under
87
+ * `/webhooks`, and say nothing of the channel routes `Chat.edit`,
88
+ * `delete` and `fetchMessage` use on an ephemeral message. Treat the id
89
+ * as one no message op works with. This is from the docs: no op on it was
90
+ * run.
91
+ * - `followUp` edits the deferred command's original response, with the
92
+ * application id and token from its `raw`, so a second call replaces the
93
+ * first answer. It fails `NotFound` with detail `interaction_expired`
94
+ * from 15 minutes after the command, read from the interaction's id,
95
+ * without calling Discord. Otherwise it makes one HTTP request, through
96
+ * the layer's `HttpClient` and not dfx's client, and never sends it
97
+ * again, unless that `HttpClient` retries by itself: a 429 fails
98
+ * `RateLimited`, for the caller to retry or not.
99
+ * Discord answers 401 with code 50027 past 15 minutes, which is
100
+ * `interaction_expired` too. Code 10015 is mapped from the docs and was
101
+ * not seen.
102
+ * - A modal that can't be built, a reply to a command that fails the checks
103
+ * of a `post`, or a callback that fails, goes to `Handler.refused`. A
104
+ * callback that comes back 404 `Unknown interaction` was late: that is
105
+ * `NotFound` with detail `interaction_expired`. A failed ack is logged.
106
+ * - `guild` reads the channel, cached. `None` for a direct.
107
+ *
108
+ * @stability unstable
109
+ * @category services
110
+ * @since 4.1.5
111
+ */
112
+ export class DiscordChat extends /*#__PURE__*/Context.Service()("@effect/chat-discord/DiscordChat") {}
113
+ /** The dispatches `normalize` reads. */
114
+ const handled = /*#__PURE__*/new Set(["MESSAGE_CREATE", "MESSAGE_REACTION_ADD", "MESSAGE_REACTION_REMOVE"]);
115
+ const lookupTimeout = /*#__PURE__*/Duration.seconds(5);
116
+ /**
117
+ * Registers the Discord adapter in the `Registry`.
118
+ *
119
+ * **Details**
120
+ *
121
+ * - Every REST call but `followUp` goes through the `DiscordREST` in
122
+ * context. dfx waits on its rate-limit buckets and sends again after a
123
+ * 429, so a rate limit shows up as a slower call.
124
+ * - `HttpClient` downloads attachments from Discord's CDN, with no token,
125
+ * and sends `followUp`'s edit, which needs no bot token either. That edit
126
+ * skips dfx's client so a 429 is not sent again past the 15 minutes. It
127
+ * goes to the `rest.baseUrl` of the `DiscordConfig` in context, or
128
+ * Discord's own API when there is none.
129
+ * - Content goes out as written: Discord reads Markdown itself. Every write
130
+ * sends `allowed_mentions: { parse: [] }` and the `SUPPRESS_EMBEDS`
131
+ * flag, on the post and on every edit, unless `withPostOptions` says
132
+ * otherwise. A reply does not ping its author.
133
+ * - `post` and `edit` fail with `TooLarge` before calling Discord past
134
+ * 2,000 code points.
135
+ * - A refused file fails `denied` with detail `file_refused` and leaves
136
+ * nothing posted: more than 10 files or 10 MiB, by the adapter's own
137
+ * check, or any `denied` answer to a post with files. The reason Discord
138
+ * gave is the `cause`.
139
+ * - A message's elements go out as classic components beside `content`,
140
+ * in action rows: five buttons to a row and a select alone in its row, in
141
+ * the order given, up to five rows. More fail `TooLarge` before the call.
142
+ * An `edit` without `actions` removes the ones there were.
143
+ * - A button's id and encoded value share one `custom_id`, joined by one
144
+ * character, and so do a modal's id and its metadata. An id may not
145
+ * contain U+241F, the join. `limits.actionDataLength` and
146
+ * `limits.modalMetadataLength` are 99 code points, the 100 of
147
+ * `custom_id` less the join.
148
+ * - Button styles: `default` is secondary, `primary` primary and
149
+ * `danger` danger.
150
+ * - A modal's inputs are Label components around a text input or a string
151
+ * select, and a `text` is a text display. Inputs and texts together are
152
+ * 5 at most. A modal over that, or with a title or label over 45
153
+ * characters, reaches `Handler.refused` as `TooLarge`. Discord has no
154
+ * submit label, so `submitLabel` is not shown.
155
+ * - `replyTo` sends a message reference. Discord refuses a reply to a
156
+ * message that is gone, unless `withPostOptions({ failIfNotExists: false })`
157
+ * lets it through as a plain message.
158
+ * - Only `DEFAULT`, `REPLY`, `CHAT_INPUT_COMMAND` and
159
+ * `CONTEXT_MENU_COMMAND` messages are messages. A forward, a poll, a
160
+ * sticker or a components-only message is `DEFAULT` and comes through,
161
+ * often with `text: ""`. Its content stays on `raw`.
162
+ * - A deferred command reply arrives empty. Its text comes in a later edit,
163
+ * which is not delivered, so only `history` and `fetchMessage` have it.
164
+ * - A webhook message has the webhook id as its author id and `isBot`.
165
+ * `getUser` on that id fails `NotFound`.
166
+ * - A mention is reported when its token is in `content` outside code and
167
+ * Discord says it resolved. A reply that pings its author is not a
168
+ * mention. Only the bot's user mention is `isSelf`: a mention of its
169
+ * managed role is the consumer's to recognise.
170
+ * - The address of a thread is its channel id. `startThread` names the
171
+ * thread after the message's text, cut to 100 characters, and gives the
172
+ * existing thread when the message already has one.
173
+ * - `history` of a thread started from a message puts the opener, from the
174
+ * parent channel, in place of Discord's placeholder. When the opener is
175
+ * deleted it starts at the first reply. A forum post's starter is in the
176
+ * thread itself.
177
+ * - `getUser` with `in` gives the guild nick, and its `raw` is Discord's
178
+ * guild member, whose `roles` are the member's role ids. Without `in`, in
179
+ * a direct, or for someone who left the guild, `raw` is the user.
180
+ * - The layer provides the `DiscordChat` service as well as registering the
181
+ * adapter, and makes every call through the `DiscordREST` it is given. A
182
+ * consumer that needs more of Discord than `Chat` has reads either from
183
+ * context beside `Chat`. dfx keeps one rate-limit state for both.
184
+ * - There is no native streaming: streamed replies post, then edit, at
185
+ * least 1.5 seconds apart.
186
+ *
187
+ * @stability unstable
188
+ * @category layers
189
+ * @since 4.1.5
190
+ */
191
+ export const layer = /*#__PURE__*/Layer.effect(DiscordChat, /*#__PURE__*/Effect.gen(function* () {
192
+ const rest = yield* DiscordREST;
193
+ const http = yield* HttpClient.HttpClient;
194
+ const registry = yield* Registry;
195
+ let cached;
196
+ const botUserId = Effect.suspend(() => {
197
+ if (cached !== undefined) return Effect.succeed(cached);
198
+ return rest.getMyUser().pipe(Effect.mapError(error => Errors.chatError("botUserId", Errors.reasonForRestError(error, {
199
+ write: false
200
+ }))), Effect.flatMap(user => {
201
+ if (typeof user.id !== "string" || user.id === "") {
202
+ return Effect.fail(Errors.chatError("botUserId", Errors.invalidResponse(false, "missing_user_id")));
203
+ }
204
+ cached = user.id;
205
+ return Effect.succeed(user.id);
206
+ }));
207
+ });
208
+ const config = yield* Effect.serviceOption(DiscordConfig);
209
+ const baseUrl = Option.match(config, {
210
+ onNone: () => Adapter.defaultBaseUrl,
211
+ onSome: _ => _.rest.baseUrl
212
+ });
213
+ const {
214
+ adapter,
215
+ channelType,
216
+ guild,
217
+ interaction
218
+ } = yield* Adapter.make({
219
+ rest,
220
+ http,
221
+ baseUrl,
222
+ botUserId
223
+ });
224
+ yield* registry.register(adapter);
225
+ const refuse = (message, error) => Effect.andThen(Effect.logWarning(message, error), Effect.fail(new NotAccepted()));
226
+ const dispatch = Effect.fnUntraced(function* (payload) {
227
+ if (!handled.has(payload.t)) return;
228
+ const handler = yield* ChatHandler;
229
+ const self = yield* Effect.catch(botUserId, error => refuse("discord dispatch: bot user lookup failed", error));
230
+ let result = Normalize.normalize(payload, {
231
+ botUserId: self
232
+ });
233
+ if (result._tag === "MissingChannelType") {
234
+ const lookup = yield* channelType(result.channelId).pipe(Effect.timeoutOrElse({
235
+ duration: lookupTimeout,
236
+ orElse: () => Effect.fail(Errors.chatError("dispatch", Errors.transport(false, "lookup_timeout")))
237
+ }), Effect.map(Option.some), Effect.catch(error => error.retry === "denied" ? Effect.as(Effect.logWarning("discord dispatch: channel lookup denied, event dropped", error), Option.none()) : refuse("discord dispatch: channel lookup failed", error)));
238
+ if (Option.isNone(lookup)) return;
239
+ result = Normalize.normalize(payload, {
240
+ botUserId: self,
241
+ channelType: lookup.value
242
+ });
243
+ if (result._tag === "MissingChannelType") return;
244
+ }
245
+ for (const event of result.events) yield* handler.handle(event);
246
+ });
247
+ return DiscordChat.of({
248
+ botUserId,
249
+ dispatch,
250
+ interaction,
251
+ guild
252
+ });
253
+ }));
254
+ /**
255
+ * The address of a Discord channel, thread or direct: its channel id.
256
+ *
257
+ * @stability unstable
258
+ * @category constructors
259
+ * @since 4.1.5
260
+ */
261
+ export const thread = Normalize.thread;
262
+ /**
263
+ * Error for a message whose channel type is in neither the payload nor the
264
+ * context, from `normalize`.
265
+ *
266
+ * @stability unstable
267
+ * @category errors
268
+ * @since 4.1.5
269
+ */
270
+ export class MissingChannelType extends /*#__PURE__*/Schema.TaggedError("@effect/chat-discord/DiscordChat/MissingChannelType")("MissingChannelType", {
271
+ channelId: Schema.String
272
+ }) {}
273
+ /**
274
+ * The normaliser behind `dispatch`, without delivering.
275
+ *
276
+ * **Details**
277
+ *
278
+ * - Pure: it never looks a channel up. It reads the channel type from the
279
+ * payload's `channel_type`, then from `context.channelType`, Discord's
280
+ * numeric type, and fails with `MissingChannelType` when neither has one.
281
+ * - Types 10, 11 and 12 are a `thread`, 1 and 3 a `direct`, and every
282
+ * other type a `channel`.
283
+ * - `MESSAGE_CREATE`, `MESSAGE_REACTION_ADD` and
284
+ * `MESSAGE_REACTION_REMOVE` give an event. Every other dispatch, and a
285
+ * message type that is not a message, gives none.
286
+ * - A custom emoji is `custom:{name}`, its id left on `raw.emoji.id`.
287
+ * - `raw` is `d`, undecoded.
288
+ *
289
+ * @stability unstable
290
+ * @category normalization
291
+ * @since 4.1.5
292
+ */
293
+ export const normalize = (dispatch, context) => {
294
+ const result = Normalize.normalize(dispatch, context);
295
+ return result._tag === "Events" ? Result.succeed(result.events) : Result.fail(new MissingChannelType({
296
+ channelId: result.channelId
297
+ }));
298
+ };
299
+ /**
300
+ * The member on a message's or added reaction's `raw`: the guild, the
301
+ * roles and the nick.
302
+ *
303
+ * **Details**
304
+ *
305
+ * Pure, with no REST call. `None` for a direct, a webhook message, or a
306
+ * payload with no member. Discord sends no member on a removed reaction, so
307
+ * it takes none.
308
+ *
309
+ * @stability unstable
310
+ * @category accessors
311
+ * @since 4.1.5
312
+ */
313
+ export const member = event => Normalize.memberOf(event.raw);
314
+ /**
315
+ * The guild on an event's `raw`.
316
+ *
317
+ * **Details**
318
+ *
319
+ * Pure, with no REST call. It works for every event, webhook messages and
320
+ * removed reactions included. `None` for a direct.
321
+ *
322
+ * @stability unstable
323
+ * @category accessors
324
+ * @since 4.1.5
325
+ */
326
+ export const guildId = event => Normalize.guildIdOf(event.raw);
327
+ /**
328
+ * For a long-running process: subscribes to dfx's gateway and feeds every
329
+ * dispatch to `DiscordChat.dispatch`, one at a time.
330
+ *
331
+ * **Details**
332
+ *
333
+ * - Intents and sharding stay in the consumer's dfx config. So does the
334
+ * gateway session: dfx keeps the session id, the resume URL and the
335
+ * sequence in the `ShardStateStore` given to `DiscordGatewayLive`.
336
+ * - It reads dfx's stream of dispatches, which a dispatch reaches after its
337
+ * sequence is stored. An event that fails with `NotAccepted` is logged
338
+ * and dropped, and so is one the process stops in the middle of: Discord
339
+ * does not send it again.
340
+ *
341
+ * @see {@link layerDispatchHook} for a host that is stopped and started again
342
+ *
343
+ * @stability unstable
344
+ * @category layers
345
+ * @since 4.1.5
346
+ */
347
+ export const layerGateway = /*#__PURE__*/Layer.effectDiscard(/*#__PURE__*/Effect.gen(function* () {
348
+ const gateway = yield* DiscordGateway;
349
+ const discord = yield* DiscordChat;
350
+ const handler = yield* ChatHandler;
351
+ yield* gateway.dispatch.pipe(Stream.runForEach(payload => {
352
+ const t = payload.t;
353
+ if (typeof t !== "string") return Effect.void;
354
+ return discord.dispatch({
355
+ t,
356
+ d: payload.d
357
+ }).pipe(Effect.provideService(ChatHandler, handler), Effect.catchCause(cause => Effect.logWarning("discord gateway: event dropped", cause)));
358
+ }), Effect.forkScoped);
359
+ }));
360
+ /**
361
+ * For a host that is stopped and started again, a Durable Object for one:
362
+ * feeds every dispatch to `DiscordChat.dispatch` from dfx's `DispatchHook`,
363
+ * before the shard stores the dispatch's sequence.
364
+ *
365
+ * **When to use**
366
+ *
367
+ * Use when an event must not be lost to a restart, in place of
368
+ * `layerGateway`. Never provide both: every event would be delivered twice.
369
+ *
370
+ * **Details**
371
+ *
372
+ * - Provide it to the dfx layer that builds the shards, `DiscordGatewayLive`
373
+ * or `ShardLive`, beside a `ShardStateStore` over storage that outlives
374
+ * the host. dfx keeps the session id, the resume URL and the sequence
375
+ * there, so a host built again sends RESUME, not IDENTIFY, and Discord
376
+ * sends what it missed.
377
+ * - The handler runs before the sequence is stored. A host stopped in the
378
+ * middle of an event never stored that event's sequence, so the RESUME
379
+ * brings the event back.
380
+ * - An event that fails with `NotAccepted` fails the hook. dfx drops the
381
+ * connection, resumes from the last stored sequence and gets the event
382
+ * again, after 1 second, doubling with every failure in a row up to 2
383
+ * minutes. An event that is refused every time holds back every event
384
+ * after it.
385
+ * - A defect in the handler is logged and the event dropped, as a replay
386
+ * would only fail the same way.
387
+ * - Delivery is at least once. A host stopped after the handler returned and
388
+ * before the sequence was stored gets that event a second time, so a
389
+ * handler that can't take an event twice remembers the ids it took.
390
+ * - The hook runs on the shard's read loop, one dispatch at a time. A
391
+ * handler slower than Discord's heartbeat interval, about 41 seconds,
392
+ * makes the shard reconnect.
393
+ * - Interactions stay with `layerGatewayInteractions`: each has 3 seconds,
394
+ * so there is nothing to resume.
395
+ *
396
+ * **Gotchas**
397
+ *
398
+ * - Discord replays only while it keeps the session. When it refuses the
399
+ * RESUME, dfx identifies again and the events in between are gone.
400
+ * - Waking the host, restarting a shard that went quiet and backing off
401
+ * after a close Discord won't change its mind on, an invalid token (4004)
402
+ * or a disallowed intent (4014), stay with the host: dfx reconnects
403
+ * whatever the close code.
404
+ *
405
+ * **Example** (Resuming from the host's own storage)
406
+ *
407
+ * ```ts
408
+ * import { DiscordChat } from "@effect/chat-discord"
409
+ * import { ShardLive } from "dfx/DiscordGateway/Shard"
410
+ * import { type ShardState, ShardStateStore } from "dfx/DiscordGateway/Shard/StateStore"
411
+ * import { Effect, Layer, Option } from "effect"
412
+ *
413
+ * // Stands in for storage that outlives the host.
414
+ * const storage = new Map<string, ShardState>()
415
+ *
416
+ * const SessionStore = Layer.succeed(
417
+ * ShardStateStore,
418
+ * ShardStateStore.of({
419
+ * forShard: ([id, count]) => {
420
+ * const key = `${id}/${count}`
421
+ * return {
422
+ * get: Effect.sync(() => Option.fromUndefinedOr(storage.get(key))),
423
+ * set: (state) => Effect.sync(() => void storage.set(key, state)),
424
+ * clear: Effect.sync(() => void storage.delete(key))
425
+ * }
426
+ * }
427
+ * })
428
+ * )
429
+ *
430
+ * // Still needs `DiscordChat`, a `ChatHandler` and the rest of dfx's gateway.
431
+ * export const ShardResuming = ShardLive.pipe(
432
+ * Layer.provide([DiscordChat.layerDispatchHook, SessionStore])
433
+ * )
434
+ * ```
435
+ *
436
+ * @see {@link layerGateway} for a process that runs until it is told to stop
437
+ *
438
+ * @stability unstable
439
+ * @category layers
440
+ * @since 4.1.5
441
+ */
442
+ export const layerDispatchHook = /*#__PURE__*/Layer.effect(DispatchHook, /*#__PURE__*/Effect.gen(function* () {
443
+ const discord = yield* DiscordChat;
444
+ const handler = yield* ChatHandler;
445
+ return payload => {
446
+ const t = payload.t;
447
+ if (typeof t !== "string" || !handled.has(t)) return Effect.void;
448
+ return discord.dispatch({
449
+ t,
450
+ d: payload.d
451
+ }).pipe(Effect.provideService(ChatHandler, handler),
452
+ // Refused or interrupted: the sequence stays unstored and a RESUME replays the event.
453
+ Effect.catchCause(cause => Cause.hasFails(cause) || Cause.hasInterrupts(cause) ? Effect.failCause(cause) : Effect.logError("discord gateway: handler defect, event dropped", cause)), Effect.orDie);
454
+ };
455
+ }));
456
+ /**
457
+ * For a long-running process: subscribes to dfx's gateway and feeds every
458
+ * `INTERACTION_CREATE` to `DiscordChat.interaction`.
459
+ *
460
+ * **Details**
461
+ *
462
+ * Interactions run concurrently, since each has its own 3 seconds. It is
463
+ * separate from `layerGateway`, so a consumer with no buttons needs no
464
+ * `ChatInteraction.Handler`.
465
+ *
466
+ * @stability unstable
467
+ * @category layers
468
+ * @since 4.1.5
469
+ */
470
+ export const layerGatewayInteractions = /*#__PURE__*/Layer.effectDiscard(/*#__PURE__*/Effect.gen(function* () {
471
+ const gateway = yield* DiscordGateway;
472
+ const discord = yield* DiscordChat;
473
+ const handler = yield* ChatInteraction.Handler;
474
+ yield* gateway.fromDispatch("INTERACTION_CREATE").pipe(Stream.mapEffect(payload => discord.interaction(payload).pipe(Effect.provideService(ChatInteraction.Handler, handler), Effect.catchCause(cause => Effect.logWarning("discord gateway: interaction dropped", cause))), {
475
+ concurrency: "unbounded"
476
+ }), Stream.runDrain, Effect.forkScoped);
477
+ }));
478
+ /**
479
+ * The normaliser behind `DiscordChat.interaction`.
480
+ *
481
+ * **Details**
482
+ *
483
+ * - Pure. A click on a button gives `ButtonClicked`, with the id and value
484
+ * split from the `custom_id`. A string select gives `SelectChanged`, and
485
+ * a modal's submit `ModalSubmitted`, its metadata split from the modal's
486
+ * `custom_id`.
487
+ * - The thread and message come from the `message` Discord sends with the
488
+ * interaction, so a modal's submit carries the message whose element
489
+ * opened it. A modal a command opened has no message, so its submit has
490
+ * no `messageId`, and its thread is the channel.
491
+ * - A submit's `values` hold each answered input by id. An input left
492
+ * empty is absent.
493
+ * - A slash command with no options, or one string option, gives
494
+ * `CommandInvoked`: `id` is its name and `text` the option's value or
495
+ * the empty string.
496
+ * - Anything else, a message or user command, a slash command with other
497
+ * options, or a click with no message, is `None`.
498
+ * - `raw` is the payload, undecoded. For a command it holds the token that
499
+ * answers it, so it is a credential for 15 minutes.
500
+ *
501
+ * @stability unstable
502
+ * @category normalization
503
+ * @since 4.1.5
504
+ */
505
+ export const normalizeInteraction = Interactions.normalize;
506
+ /**
507
+ * The create payload of each command in `group`, in the group's order, for
508
+ * Discord's application commands endpoint.
509
+ *
510
+ * **Details**
511
+ *
512
+ * - Each is a `CHAT_INPUT` command with the definition's name and
513
+ * description, and one `STRING` option when it has an `argument`. Each
514
+ * fits dfx's `ApplicationCommandCreateRequest`.
515
+ * - The definitions in `group` that are not commands are skipped.
516
+ *
517
+ * **Gotchas**
518
+ *
519
+ * - The adapter registers nothing. Discord's bulk overwrite replaces the
520
+ * application's whole list, so the consumer sends these beside its other
521
+ * commands, in one call.
522
+ * - dfx's gateway runner syncs its own commands the same way when it
523
+ * starts, which would delete these. A consumer running both adds these to
524
+ * that list, or switches the sync off with `setInteractionsSync(false)`.
525
+ * - A field the definition lacks, such as `default_member_permissions`, is
526
+ * spread onto the payload by the consumer.
527
+ *
528
+ * **Example** (Registering the commands beside dfx's own)
529
+ *
530
+ * ```ts import.meta.vitest
531
+ * import { DiscordChat } from "@effect/chat-discord"
532
+ * import { DiscordREST } from "dfx/DiscordREST"
533
+ * import { Effect } from "effect"
534
+ * import { ChatInteraction } from "effect/chat"
535
+ *
536
+ * const Commands = ChatInteraction.group(
537
+ * ChatInteraction.command("summarize", { description: "Summarize this thread" })
538
+ * )
539
+ *
540
+ * export const register = Effect.gen(function*() {
541
+ * const rest = yield* DiscordREST
542
+ * const app = yield* rest.getMyApplication()
543
+ * yield* rest.bulkSetApplicationCommands(app.id, [...DiscordChat.commandRequests(Commands)])
544
+ * })
545
+ * ```
546
+ *
547
+ * @stability unstable
548
+ * @category commands
549
+ * @since 4.1.5
550
+ */
551
+ export const commandRequests = Interactions.commandRequests;
552
+ /**
553
+ * Scoped Discord options for every write inside `effect`. Nested calls
554
+ * merge, the inner one winning field by field.
555
+ *
556
+ * @stability unstable
557
+ * @category combinators
558
+ * @since 4.1.5
559
+ */
560
+ export const withPostOptions = /*#__PURE__*/dual(2, (effect, options) => Effect.updateService(effect, CurrentPostOptions, current => ({
561
+ ...current,
562
+ ...options
563
+ })));
564
+ /**
565
+ * Reads one Discord mention token, `<@id>`, `<@!id>`, `<@&id>`,
566
+ * `<#id>`, `@everyone` or `@here`, for `ChatTest.checkMessage`,
567
+ * `ChatTest.checkEvent` and `ChatTest.conformance`.
568
+ *
569
+ * @stability unstable
570
+ * @category testing
571
+ * @since 4.1.5
572
+ */
573
+ export const parseMention = slice => Option.fromUndefinedOr(Mentions.parseToken(slice));
574
+ //# sourceMappingURL=DiscordChat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiscordChat.js","names":[],"sources":["../src/DiscordChat.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAS,aAAa,QAAQ,mBAAmB;AACjD,SAAS,cAAc,QAAQ,oBAAoB;AACnD,SAAS,YAAY,QAAQ,uCAAuC;AACpE,SAAS,WAAW,QAAQ,iBAAiB;AAC7C,OAAO,KAAK,KAAK,MAAM,cAAc;AACrC,SAAS,QAAQ,QAAQ,yBAAyB;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,EACf,MAAM,CAAC,UAAU,CAClB;AACH,CAAC,CAAC,CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,OAAO,MAAM,oBAAoB,GAC/B,YAAY,CAAC,SAAS;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,OAAO,MAAM,eAAe,GAcvB,YAAY,CAAC,eAAe;AAoCjC;;;;;;;;AAQA,OAAO,MAAM,eAAe,gBAmBxB,IAAI,CACN,CAAC,EACD,CAAU,MAA8B,EAAE,OAA2B,KACnE,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,kBAAkB,EAAG,OAAO,KAAM;EAAE,GAAG,OAAO;EAAE,GAAG;AAAO,CAAE,CAAC,CAAC,CAC9F;AAED;;;;;;;;;AASA,OAAO,MAAM,YAAY,GAAkB,KAAK,IAAK,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @stability unstable
3
+ * @since 4.1.5
4
+ */
5
+ /**
6
+ * @stability unstable
7
+ * @since 4.1.5
8
+ */
9
+ export * as DiscordChat from "./DiscordChat.ts";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @stability unstable
3
+ * @since 4.1.5
4
+ */
5
+ // @barrel: Auto-generated exports. Do not edit manually.
6
+ /**
7
+ * @stability unstable
8
+ * @since 4.1.5
9
+ */
10
+ export * as DiscordChat from "./DiscordChat.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;AAKA;AAEA;;;;AAIA,OAAO,KAAK,WAAW,MAAM,kBAAkB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/internal/adapter.ts"],"names":[],"mappings":""}