@spinabot/brigade 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/agents/agent-loop.d.ts.map +1 -1
  2. package/dist/agents/agent-loop.js +51 -1
  3. package/dist/agents/agent-loop.js.map +1 -1
  4. package/dist/agents/channels/bundled-channel-metas.d.ts +2 -0
  5. package/dist/agents/channels/bundled-channel-metas.d.ts.map +1 -1
  6. package/dist/agents/channels/bundled-channel-metas.js +11 -0
  7. package/dist/agents/channels/bundled-channel-metas.js.map +1 -1
  8. package/dist/agents/channels/discord/account-config.d.ts +117 -0
  9. package/dist/agents/channels/discord/account-config.d.ts.map +1 -0
  10. package/dist/agents/channels/discord/account-config.js +260 -0
  11. package/dist/agents/channels/discord/account-config.js.map +1 -0
  12. package/dist/agents/channels/discord/adapter.d.ts +56 -0
  13. package/dist/agents/channels/discord/adapter.d.ts.map +1 -0
  14. package/dist/agents/channels/discord/adapter.js +526 -0
  15. package/dist/agents/channels/discord/adapter.js.map +1 -0
  16. package/dist/agents/channels/discord/approval-authorize.d.ts +43 -0
  17. package/dist/agents/channels/discord/approval-authorize.d.ts.map +1 -0
  18. package/dist/agents/channels/discord/approval-authorize.js +71 -0
  19. package/dist/agents/channels/discord/approval-authorize.js.map +1 -0
  20. package/dist/agents/channels/discord/approval-native.d.ts +68 -0
  21. package/dist/agents/channels/discord/approval-native.d.ts.map +1 -0
  22. package/dist/agents/channels/discord/approval-native.js +81 -0
  23. package/dist/agents/channels/discord/approval-native.js.map +1 -0
  24. package/dist/agents/channels/discord/command-menu.d.ts +49 -0
  25. package/dist/agents/channels/discord/command-menu.d.ts.map +1 -0
  26. package/dist/agents/channels/discord/command-menu.js +73 -0
  27. package/dist/agents/channels/discord/command-menu.js.map +1 -0
  28. package/dist/agents/channels/discord/components.d.ts +97 -0
  29. package/dist/agents/channels/discord/components.d.ts.map +1 -0
  30. package/dist/agents/channels/discord/components.js +131 -0
  31. package/dist/agents/channels/discord/components.js.map +1 -0
  32. package/dist/agents/channels/discord/connection.d.ts +387 -0
  33. package/dist/agents/channels/discord/connection.d.ts.map +1 -0
  34. package/dist/agents/channels/discord/connection.js +786 -0
  35. package/dist/agents/channels/discord/connection.js.map +1 -0
  36. package/dist/agents/channels/discord/draft-stream.d.ts +92 -0
  37. package/dist/agents/channels/discord/draft-stream.d.ts.map +1 -0
  38. package/dist/agents/channels/discord/draft-stream.js +213 -0
  39. package/dist/agents/channels/discord/draft-stream.js.map +1 -0
  40. package/dist/agents/channels/discord/format.d.ts +55 -0
  41. package/dist/agents/channels/discord/format.d.ts.map +1 -0
  42. package/dist/agents/channels/discord/format.js +247 -0
  43. package/dist/agents/channels/discord/format.js.map +1 -0
  44. package/dist/agents/channels/discord/inbound-extras.d.ts +220 -0
  45. package/dist/agents/channels/discord/inbound-extras.d.ts.map +1 -0
  46. package/dist/agents/channels/discord/inbound-extras.js +351 -0
  47. package/dist/agents/channels/discord/inbound-extras.js.map +1 -0
  48. package/dist/agents/channels/discord/index.d.ts +14 -0
  49. package/dist/agents/channels/discord/index.d.ts.map +1 -0
  50. package/dist/agents/channels/discord/index.js +14 -0
  51. package/dist/agents/channels/discord/index.js.map +1 -0
  52. package/dist/agents/channels/discord/media.d.ts +85 -0
  53. package/dist/agents/channels/discord/media.d.ts.map +1 -0
  54. package/dist/agents/channels/discord/media.js +242 -0
  55. package/dist/agents/channels/discord/media.js.map +1 -0
  56. package/dist/agents/channels/discord/module.d.ts +15 -0
  57. package/dist/agents/channels/discord/module.d.ts.map +1 -0
  58. package/dist/agents/channels/discord/module.js +22 -0
  59. package/dist/agents/channels/discord/module.js.map +1 -0
  60. package/dist/agents/channels/discord/plugin.d.ts +73 -0
  61. package/dist/agents/channels/discord/plugin.d.ts.map +1 -0
  62. package/dist/agents/channels/discord/plugin.js +303 -0
  63. package/dist/agents/channels/discord/plugin.js.map +1 -0
  64. package/dist/agents/channels/discord/probe.d.ts +93 -0
  65. package/dist/agents/channels/discord/probe.d.ts.map +1 -0
  66. package/dist/agents/channels/discord/probe.js +158 -0
  67. package/dist/agents/channels/discord/probe.js.map +1 -0
  68. package/dist/agents/channels/discord/reasoning-lane.d.ts +42 -0
  69. package/dist/agents/channels/discord/reasoning-lane.d.ts.map +1 -0
  70. package/dist/agents/channels/discord/reasoning-lane.js +68 -0
  71. package/dist/agents/channels/discord/reasoning-lane.js.map +1 -0
  72. package/dist/agents/channels/inbound-pipeline.d.ts.map +1 -1
  73. package/dist/agents/channels/inbound-pipeline.js +65 -7
  74. package/dist/agents/channels/inbound-pipeline.js.map +1 -1
  75. package/dist/agents/channels/sdk.d.ts +2 -0
  76. package/dist/agents/channels/sdk.d.ts.map +1 -1
  77. package/dist/agents/channels/sdk.js +2 -0
  78. package/dist/agents/channels/sdk.js.map +1 -1
  79. package/dist/agents/extensions/modules/index.d.ts.map +1 -1
  80. package/dist/agents/extensions/modules/index.js +5 -0
  81. package/dist/agents/extensions/modules/index.js.map +1 -1
  82. package/dist/agents/tools/cron-tool.d.ts.map +1 -1
  83. package/dist/agents/tools/cron-tool.js +4 -1
  84. package/dist/agents/tools/cron-tool.js.map +1 -1
  85. package/dist/buildstamp.json +1 -1
  86. package/dist/core/auth-bridge.d.ts +1 -0
  87. package/dist/core/auth-bridge.d.ts.map +1 -1
  88. package/dist/core/auth-bridge.js +46 -1
  89. package/dist/core/auth-bridge.js.map +1 -1
  90. package/dist/core/server.d.ts.map +1 -1
  91. package/dist/core/server.js +18 -2
  92. package/dist/core/server.js.map +1 -1
  93. package/dist/cron/isolated-agent/run-executor.d.ts +11 -0
  94. package/dist/cron/isolated-agent/run-executor.d.ts.map +1 -1
  95. package/dist/cron/isolated-agent/run-executor.js +20 -4
  96. package/dist/cron/isolated-agent/run-executor.js.map +1 -1
  97. package/dist/cron/types.d.ts +8 -0
  98. package/dist/cron/types.d.ts.map +1 -1
  99. package/dist/system-prompt/assembler.d.ts.map +1 -1
  100. package/dist/system-prompt/assembler.js +4 -2
  101. package/dist/system-prompt/assembler.js.map +1 -1
  102. package/package.json +2 -1
@@ -0,0 +1,526 @@
1
+ /**
2
+ * Discord channel adapter.
3
+ *
4
+ * Implements the Brigade `ChannelAdapter` contract on top of the discord.js
5
+ * Gateway + REST connection. Like Slack, Discord is TOKEN-based: the operator
6
+ * pastes a bot token from the Discord Developer Portal, so this adapter declares
7
+ * a `setup` wizard (one credential) and has NO QR/link flow. Enablement is
8
+ * explicit — `channels.discord.enabled: true` plus a resolvable bot token.
9
+ *
10
+ * Modeled directly on `slack/adapter.ts`: same health-flag mirroring, same
11
+ * deferred-media passthrough on inbound, same chunk-then-send outbound shape
12
+ * (chunk markdown ≤2000, convert each chunk to Discord markup, send). Discord
13
+ * markup never "fails to parse" the way Telegram HTML can, so the outbound path
14
+ * is simple — an empty rendered chunk falls back to the raw chunk.
15
+ *
16
+ * Capabilities: edit (message.edit), unsend (message.delete), reactions
17
+ * (message.react), reply (reply reference + threads), threads, media
18
+ * (AttachmentBuilder), buttons (ActionRow + Button), and NATIVE slash commands
19
+ * (registered via REST application commands on connect). Unlike Slack, Discord's
20
+ * command menu IS pushed programmatically — `nativeCommands: true`.
21
+ */
22
+ import { loadConfig } from "../../../core/config.js";
23
+ // Channel SDK barrel — the single import surface for the channel-authoring
24
+ // contract + shared helpers. Contract types + `chunkText` + `buildBundledCommands`
25
+ // come from one place instead of scattered paths.
26
+ import { buildBundledCommands, chunkText, } from "../sdk.js";
27
+ import { discordChannelEnabled, discordLiveStreamEnabled, discordStreamThrottleMs, discordSurfaceReasoning, listDiscordAccountIds, resolveDiscordBotToken, resolveDiscordProxyUrl, DISCORD_CHANNEL_ID, DISCORD_DEFAULT_ACCOUNT_ID, } from "./account-config.js";
28
+ import { resolveDiscordApprover } from "./approval-authorize.js";
29
+ import { buildDiscordApprovalMessage } from "./approval-native.js";
30
+ import { buildDiscordButtonRows } from "./components.js";
31
+ import { buildDiscordCommandManifest } from "./command-menu.js";
32
+ import { connectDiscord } from "./connection.js";
33
+ import { createDraftStream } from "./draft-stream.js";
34
+ import { discordTextIsEmpty, markdownToDiscord } from "./format.js";
35
+ import { splitDiscordReasoning } from "./reasoning-lane.js";
36
+ /** Discord's per-message text limit (chars) for chunked sends. */
37
+ const DISCORD_TEXT_LIMIT = 2_000;
38
+ export function createDiscordAdapter(opts = {}) {
39
+ const accountId = opts.accountId?.trim() || DISCORD_DEFAULT_ACCOUNT_ID;
40
+ const connectImpl = opts.connectImpl ?? connectDiscord;
41
+ let connection = null;
42
+ // The ChannelStartContext doesn't carry the config, but the manager ALWAYS
43
+ // calls `isConfigured(cfg, env)` immediately before `start(ctx)` — so we
44
+ // capture the config + env it passed there and read the token from them in
45
+ // start(). This avoids a second config load and keeps the adapter pure.
46
+ let lastConfig = null;
47
+ let lastEnv = process.env;
48
+ // Health flags mirrored from the connection lifecycle so health() never has to
49
+ // round-trip Discord on the hot path (cron timer / send pre-flight).
50
+ // - `connected` flips true on a successful login + ready.
51
+ // - `tokenInvalid` is STICKY: an auth error means the token is dead and the
52
+ // only recovery is `brigade channels add --channel discord` with a new token.
53
+ let connected = false;
54
+ let tokenInvalid = false;
55
+ const adapter = {
56
+ id: DISCORD_CHANNEL_ID,
57
+ label: "Discord",
58
+ isConfigured(cfg, env) {
59
+ // Capture for start() — the manager calls this right before start(ctx).
60
+ lastConfig = cfg;
61
+ lastEnv = env ?? process.env;
62
+ if (!discordChannelEnabled(cfg))
63
+ return false;
64
+ // Need a resolvable bot token (config `${VAR}` ref, sealed token, or
65
+ // DISCORD_BOT_TOKEN env).
66
+ if (!resolveDiscordBotToken(cfg, accountId, env ?? process.env))
67
+ return false;
68
+ // Multi-account follow-up: when the operator declares >1 account, the
69
+ // plugin path owns lifecycle and the legacy single adapter steps aside.
70
+ const isLegacyAdapter = accountId === DISCORD_DEFAULT_ACCOUNT_ID;
71
+ if (isLegacyAdapter && listDiscordAccountIds(cfg).length > 1)
72
+ return false;
73
+ return true;
74
+ },
75
+ async start(ctx) {
76
+ // Resolve the token from the config the manager handed isConfigured().
77
+ // Fall back to a fresh load defensively (e.g. a direct start() in a test
78
+ // that skipped isConfigured).
79
+ const cfg = lastConfig ?? (await loadStartConfig());
80
+ const botToken = resolveDiscordBotToken(cfg, accountId, lastEnv);
81
+ if (!botToken) {
82
+ ctx.log("Discord not started — no bot token resolved (set channels.discord.botToken or DISCORD_BOT_TOKEN).");
83
+ return;
84
+ }
85
+ // Optional proxy — routes the REST + Gateway websocket through it on
86
+ // networks where discord.com is blocked. Empty → direct (unchanged).
87
+ const proxyUrl = resolveDiscordProxyUrl(cfg, accountId, lastEnv);
88
+ // The native slash-command manifest, derived from Brigade's central
89
+ // channel commands; registered right after the connection is live (below).
90
+ const commandManifest = buildDiscordCommandManifest(buildBundledCommands(adapter));
91
+ const conn = await connectImpl({
92
+ botToken,
93
+ ...(proxyUrl ? { proxyUrl } : {}),
94
+ accountId,
95
+ log: ctx.log,
96
+ onConnected: () => {
97
+ connected = true;
98
+ tokenInvalid = false;
99
+ ctx.log("Discord ready");
100
+ ctx.onConnected?.();
101
+ },
102
+ onTokenInvalid: () => {
103
+ connected = false;
104
+ tokenInvalid = true;
105
+ ctx.log("Discord token was rejected. Run `brigade channels add --channel discord` with a fresh bot token.");
106
+ ctx.onLoggedOut?.();
107
+ },
108
+ onMessage: (msg) => {
109
+ void ctx.onInbound({
110
+ channel: DISCORD_CHANNEL_ID,
111
+ accountId,
112
+ conversationId: msg.conversationId,
113
+ messageId: msg.messageId,
114
+ messageTimestampMs: msg.messageTimestampMs,
115
+ from: msg.from,
116
+ fromName: msg.fromName,
117
+ text: msg.text,
118
+ chatType: msg.chatType,
119
+ isGroup: msg.chatType === "group",
120
+ threadId: msg.threadId,
121
+ // Discord routes on guildId + member role ids (NOT teamId — that
122
+ // is Slack's workspace tier; setting it would risk colliding with
123
+ // a Slack team binding).
124
+ guildId: msg.guildId,
125
+ memberRoleIds: msg.memberRoleIds,
126
+ mentions: msg.mentions,
127
+ replyTo: msg.replyTo,
128
+ // Edit provenance rides through so the central pipeline / agent see
129
+ // "this was an edit".
130
+ ...(msg.edited ? { edited: true } : {}),
131
+ // Deferred media thunk rides through untouched — the pipeline
132
+ // resolves it only after the access gate admits the sender.
133
+ resolveMedia: msg.resolveMedia,
134
+ raw: msg.raw,
135
+ });
136
+ },
137
+ // Inbound reaction → synthesise a short note and route it through the
138
+ // SAME inbound pipeline as a normal message so the access gate + routing
139
+ // apply uniformly. The note carries the added emoji(s) + the target id.
140
+ onReaction: (msg) => {
141
+ if (!msg.reaction)
142
+ return;
143
+ const note = buildReactionNote(msg.reaction.emojis, msg.reaction.targetMessageId, msg.fromName);
144
+ void ctx.onInbound({
145
+ channel: DISCORD_CHANNEL_ID,
146
+ accountId,
147
+ conversationId: msg.conversationId,
148
+ from: msg.from,
149
+ ...(msg.fromName !== undefined ? { fromName: msg.fromName } : {}),
150
+ text: note,
151
+ chatType: msg.chatType,
152
+ isGroup: msg.chatType === "group",
153
+ ...(msg.threadId !== undefined ? { threadId: msg.threadId } : {}),
154
+ ...(msg.guildId !== undefined ? { guildId: msg.guildId } : {}),
155
+ ...(msg.memberRoleIds !== undefined ? { memberRoleIds: msg.memberRoleIds } : {}),
156
+ reaction: msg.reaction,
157
+ raw: msg.raw,
158
+ });
159
+ },
160
+ // Button press → emit an InboundMessage carrying `callbackQuery` so the
161
+ // central pipeline's approval-callback path resolves it. The connection
162
+ // has already acked the press.
163
+ onCallbackQuery: (msg) => {
164
+ if (!msg.callbackQuery)
165
+ return;
166
+ void ctx.onInbound({
167
+ channel: DISCORD_CHANNEL_ID,
168
+ accountId,
169
+ conversationId: msg.conversationId,
170
+ from: msg.from,
171
+ ...(msg.fromName !== undefined ? { fromName: msg.fromName } : {}),
172
+ text: "",
173
+ chatType: msg.chatType,
174
+ isGroup: msg.chatType === "group",
175
+ ...(msg.threadId !== undefined ? { threadId: msg.threadId } : {}),
176
+ ...(msg.guildId !== undefined ? { guildId: msg.guildId } : {}),
177
+ ...(msg.memberRoleIds !== undefined ? { memberRoleIds: msg.memberRoleIds } : {}),
178
+ callbackQuery: msg.callbackQuery,
179
+ raw: msg.raw,
180
+ });
181
+ },
182
+ });
183
+ connection = conn;
184
+ // Register the native slash commands now that the connection exists.
185
+ // `connectDiscord` resolves once the first connect (or terminal failure)
186
+ // settles, so a successful boot is already live here. Best-effort: a
187
+ // registration failure is logged inside `registerCommands` and never
188
+ // blocks startup. When the token was rejected we skip (nothing to push).
189
+ if (connected && !tokenInvalid) {
190
+ void conn.registerCommands(commandManifest).catch(() => { });
191
+ }
192
+ },
193
+ async stop() {
194
+ await connection?.close();
195
+ connection = null;
196
+ connected = false;
197
+ },
198
+ /**
199
+ * Synchronous read of the cached connection state:
200
+ * - `{ ok: true }` once the Gateway is live.
201
+ * - `{ ok: false, kind: "logged-out" }` after an auth error (sticky; re-token).
202
+ * - `{ ok: false, kind: "starting" }` between start() and first connect.
203
+ * - `{ ok: false, kind: "disconnected" }` for a transient drop mid-reconnect.
204
+ */
205
+ health() {
206
+ if (tokenInvalid || connection?.isTokenInvalid()) {
207
+ return {
208
+ ok: false,
209
+ kind: "logged-out",
210
+ reason: "Discord token was rejected — Brigade can't send until a new token is set.",
211
+ remediation: "Run `brigade channels add --channel discord` and paste a fresh bot token.",
212
+ };
213
+ }
214
+ if (!connection) {
215
+ return { ok: false, kind: "starting", reason: "Discord adapter is not started yet." };
216
+ }
217
+ if (!connected || !connection.isConnected()) {
218
+ return {
219
+ ok: false,
220
+ kind: "disconnected",
221
+ reason: "Discord is reconnecting — sends will fail until the Gateway resumes.",
222
+ };
223
+ }
224
+ return { ok: true };
225
+ },
226
+ async sendText(conversationId, text, opts) {
227
+ if (!connection)
228
+ throw new Error("Discord channel is not started");
229
+ if (tokenInvalid || connection.isTokenInvalid()) {
230
+ throw new Error("Discord token is invalid — run `brigade channels add --channel discord` with a new token, then retry.");
231
+ }
232
+ const threadId = opts?.threadId;
233
+ // Native reply target — applied to the FIRST chunk only (threading every
234
+ // chunk of a long reply is redundant once the first lands). Omitted →
235
+ // unthreaded send (unchanged).
236
+ const replyToMessageId = opts?.replyToId;
237
+ const sendExtras = {};
238
+ if (threadId)
239
+ sendExtras.threadId = threadId;
240
+ // Chunk on the RAW markdown so fences/paragraphs aren't shredded, then
241
+ // convert each chunk to Discord markup and send. A chunk whose rendered
242
+ // markup is empty (syntax-only) is re-sent as the raw chunk.
243
+ const chunks = chunkText(text, { limit: DISCORD_TEXT_LIMIT });
244
+ let first = true;
245
+ for (const chunk of chunks) {
246
+ const replyOpt = first && replyToMessageId ? { replyToMessageId } : {};
247
+ const rendered = markdownToDiscord(chunk);
248
+ const body = discordTextIsEmpty(rendered) ? chunk : rendered;
249
+ if (body.trim().length === 0)
250
+ continue;
251
+ await connection.sendText(conversationId, body, { ...sendExtras, ...replyOpt });
252
+ first = false;
253
+ }
254
+ },
255
+ /**
256
+ * Open a LIVE reply stream — the gateway feeds the accumulating answer text
257
+ * via `update()`, this edits one Discord message in place (throttled
258
+ * ~1×/sec), and `finalize()` settles it on turn end. Returns `null` when
259
+ * streaming is disabled in config (`channels.discord.liveStream` is not true)
260
+ * OR the connection isn't live, so the pipeline falls back to the single
261
+ * final `sendText` — byte-unchanged from before streaming existed.
262
+ *
263
+ * Each draft chunk is rendered through the SAME markdown→Discord converter
264
+ * the final path uses. When the running answer exceeds the limit the stream
265
+ * finalizes the current message at a boundary and rolls overflow into a new
266
+ * message.
267
+ */
268
+ beginReplyStream(conversationId, sendOpts) {
269
+ if (!connection)
270
+ return null;
271
+ if (tokenInvalid || connection.isTokenInvalid())
272
+ return null;
273
+ const cfg = lastConfig;
274
+ if (!cfg || !discordLiveStreamEnabled(cfg))
275
+ return null;
276
+ const conn = connection;
277
+ const threadId = sendOpts?.threadId;
278
+ const stream = createDraftStream({
279
+ transport: {
280
+ async postMessage(text, o) {
281
+ const sent = await conn.sendText(conversationId, text, {
282
+ ...(o.threadId !== undefined ? { threadId: o.threadId } : {}),
283
+ });
284
+ return { id: sent.messageId };
285
+ },
286
+ async editMessage(id, text) {
287
+ await conn.editMessageText(conversationId, id, text);
288
+ },
289
+ },
290
+ ...(threadId !== undefined ? { threadId } : {}),
291
+ throttleMs: discordStreamThrottleMs(cfg),
292
+ maxChars: DISCORD_TEXT_LIMIT,
293
+ // Render each draft chunk to Discord markup; fall back to the plain chunk
294
+ // when it renders empty (syntax-only).
295
+ renderText: (chunk) => {
296
+ const rendered = markdownToDiscord(chunk);
297
+ return { text: discordTextIsEmpty(rendered) ? chunk : rendered };
298
+ },
299
+ });
300
+ return {
301
+ update: (text) => stream.update(text),
302
+ async finalize(finalText) {
303
+ await stream.finalize(finalText);
304
+ const ids = stream.messageIds();
305
+ const last = ids[ids.length - 1];
306
+ return last !== undefined ? { messageId: last } : undefined;
307
+ },
308
+ stop: () => stream.stop(),
309
+ };
310
+ },
311
+ /**
312
+ * OPTIONAL reasoning lane (default OFF). When `channels.discord.
313
+ * surfaceReasoning` is true, split the raw reply's `<think>` trace out and
314
+ * send it as a separate `🧠 Reasoning:` message BEFORE the answer. When the
315
+ * config gate is off (the default) OR the reply carried no reasoning, this
316
+ * sends NOTHING — the answer message the pipeline sends afterward is
317
+ * byte-identical either way.
318
+ */
319
+ async deliverReasoning(conversationId, rawReply, sendOpts) {
320
+ if (!connection)
321
+ return;
322
+ if (tokenInvalid || connection.isTokenInvalid())
323
+ return;
324
+ const cfg = lastConfig;
325
+ if (!cfg || !discordSurfaceReasoning(cfg))
326
+ return;
327
+ const { reasoningText } = splitDiscordReasoning(rawReply ?? "");
328
+ if (!reasoningText)
329
+ return;
330
+ // Reuse the adapter's own chunk+render send path so a long reasoning trace
331
+ // is chunked at 2000 and formatted consistently with replies.
332
+ await adapter.sendText(conversationId, reasoningText, sendOpts);
333
+ },
334
+ // Discord ids are user snowflakes; the pairing challenge card uses the
335
+ // "account" label. The bot is a SEPARATE account from the operator (its own
336
+ // app), so ownership is bootstrapped from the first CLI `pairing approve` —
337
+ // see `botIsSeparateFromOperator`.
338
+ pairing: { idLabel: "account", botIsSeparateFromOperator: true },
339
+ // Token-based setup wizard — `brigade channels add --channel discord` prompts
340
+ // for the bot token and writes `channels.discord.botToken`. The OAuth invite
341
+ // URL + the privileged "Message Content" gateway intent toggle CAN'T be
342
+ // granted programmatically, so the two setup steps the operator must do by
343
+ // hand are baked into the bot-token prompt copy:
344
+ // 1. Enable the MESSAGE CONTENT intent (Bot → Privileged Gateway Intents),
345
+ // or Brigade can't read message text.
346
+ // 2. Invite the bot with the `bot` + `applications.commands` scopes (OAuth2
347
+ // → URL Generator) + Send Messages / Read Message History / Add Reactions.
348
+ setup: {
349
+ credentialKeys: [
350
+ {
351
+ key: "botToken",
352
+ prompt: "Discord bot token (Developer Portal → Bot → Reset Token). Also: enable the MESSAGE CONTENT intent (Bot → Privileged Gateway Intents) and invite the bot with the bot + applications.commands scopes.",
353
+ secret: true,
354
+ envVar: "DISCORD_BOT_TOKEN",
355
+ docsUrl: "https://discord.com/developers/docs/topics/oauth2#bots",
356
+ },
357
+ ],
358
+ validateInput(key, value) {
359
+ const v = value.trim();
360
+ // Allow a `${VAR}` ref through (resolved at runtime).
361
+ if (/^\$\{[A-Z_][A-Z0-9_]*\}$/.test(v))
362
+ return null;
363
+ if (key === "botToken") {
364
+ // Discord bot tokens are `<id>.<ts>.<secret>` (optionally `Bot `-prefixed).
365
+ if (/^(Bot\s+)?[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{20,}$/.test(v))
366
+ return null;
367
+ return "That doesn't look like a Discord bot token — expected the `…. …. …` token from the Developer Portal.";
368
+ }
369
+ return null;
370
+ },
371
+ },
372
+ async sendMedia(conversationId, media) {
373
+ if (!connection)
374
+ throw new Error("Discord channel is not started");
375
+ await connection.sendMedia(conversationId, media);
376
+ },
377
+ async react(conversationId, messageId, emoji) {
378
+ if (!connection)
379
+ return; // cosmetic — refuse silently when not started
380
+ await connection.react(conversationId, messageId, emoji);
381
+ },
382
+ async setComposing(conversationId, state) {
383
+ if (!connection)
384
+ return;
385
+ await connection.setComposing(conversationId, state);
386
+ },
387
+ // Static capability flags. The central `message_action` tool PRE-CHECKS the
388
+ // relevant flag here before calling `handleAction`, so an unsupported action
389
+ // fails cleanly without touching the adapter.
390
+ capabilities: DISCORD_CAPABILITIES,
391
+ // Native component-button approvals. When a channel-routed turn raises an
392
+ // approval, the central router calls `sendApprovalPrompt` to render the
393
+ // question as buttons (payloads from the central codec); the press comes back
394
+ // as `InboundMessage.callbackQuery` and is resolved centrally. A pathological
395
+ // approval id that can't be encoded falls back to the text prompt.
396
+ approvalCapability: {
397
+ async sendApprovalPrompt(params) {
398
+ if (!connection)
399
+ throw new Error("Discord channel is not started");
400
+ const message = buildDiscordApprovalMessage({
401
+ approvalId: params.approvalId,
402
+ command: params.command,
403
+ approvalKind: params.approvalKind,
404
+ ...(params.toolName !== undefined ? { toolName: params.toolName } : {}),
405
+ });
406
+ if (!message) {
407
+ // Couldn't build byte-safe buttons — let the router fall back to text.
408
+ throw new Error("discord approval prompt: approval id too long for buttons");
409
+ }
410
+ await connection.sendInteractive(params.conversationId, message.text, message.rows, {
411
+ ...(params.threadId !== undefined ? { threadId: params.threadId } : {}),
412
+ });
413
+ },
414
+ authorizeApprover(p) {
415
+ return resolveDiscordApprover({
416
+ cfg: p.cfg,
417
+ ...(p.senderId !== undefined ? { senderId: p.senderId } : {}),
418
+ ...(p.accountId !== undefined ? { accountId: p.accountId } : {}),
419
+ });
420
+ },
421
+ },
422
+ // Edit / delete / react / reply a message + attach buttons. The manager
423
+ // pre-checks the capability flag (above) before calling, so an action only
424
+ // reaches here when Discord advertised support for it.
425
+ async handleAction(p) {
426
+ if (!connection)
427
+ return { ok: false, error: "Discord channel is not started" };
428
+ if (tokenInvalid || connection.isTokenInvalid()) {
429
+ return { ok: false, error: "Discord token is invalid — re-token before acting on messages." };
430
+ }
431
+ const a = p.action;
432
+ try {
433
+ switch (a.kind) {
434
+ case "edit": {
435
+ const rendered = markdownToDiscord(a.text);
436
+ const body = discordTextIsEmpty(rendered) ? a.text : rendered;
437
+ await connection.editMessageText(p.conversationId, a.messageId, body);
438
+ return { ok: true, messageId: a.messageId };
439
+ }
440
+ case "delete":
441
+ await connection.deleteMessage(p.conversationId, a.messageId);
442
+ return { ok: true, messageId: a.messageId };
443
+ case "react":
444
+ // An EMPTY emoji means "clear" (parity with WhatsApp/Telegram/Slack):
445
+ // remove the bot's OWN reactions on this message; a non-empty emoji
446
+ // adds as before.
447
+ if (a.emoji.trim() === "") {
448
+ await connection.removeOwnReactions(p.conversationId, a.messageId);
449
+ }
450
+ else {
451
+ await connection.react(p.conversationId, a.messageId, a.emoji);
452
+ }
453
+ return { ok: true, messageId: a.messageId };
454
+ case "reply": {
455
+ // A reply is a send with a native reply reference; surface the new id.
456
+ const sent = await connection.sendText(p.conversationId, a.text, {
457
+ ...(a.threadId !== undefined ? { threadId: a.threadId } : {}),
458
+ });
459
+ return { ok: true, messageId: sent.messageId };
460
+ }
461
+ case "buttons": {
462
+ // Send a NEW message with a general button keyboard. The button ids
463
+ // are prefixed/sanitized by the builder; a press arrives as
464
+ // `callbackQuery` and routes through the pipeline as a turn (the
465
+ // central approval path declines a general payload).
466
+ const rows = buildDiscordButtonRows(a.buttons.map((row) => row.map((b) => ({ text: b.text, data: b.data }))));
467
+ if (!rows) {
468
+ return { ok: false, error: "no usable buttons (each needs a label + a data token ≤ 100 chars)" };
469
+ }
470
+ const rendered = markdownToDiscord(a.text);
471
+ const body = discordTextIsEmpty(rendered) ? a.text : rendered;
472
+ const sent = await connection.sendInteractive(p.conversationId, body, rows, {
473
+ ...(a.threadId !== undefined ? { threadId: a.threadId } : {}),
474
+ });
475
+ return { ok: true, messageId: sent.messageId };
476
+ }
477
+ default:
478
+ return { ok: false, error: `unsupported action kind` };
479
+ }
480
+ }
481
+ catch (err) {
482
+ return { ok: false, error: err instanceof Error ? err.message : String(err) };
483
+ }
484
+ },
485
+ selfId() {
486
+ return connection?.selfId() ?? undefined;
487
+ },
488
+ connectedAt() {
489
+ return connection?.connectedAt() ?? null;
490
+ },
491
+ lastEventAt() {
492
+ return connection?.lastEventAt() ?? null;
493
+ },
494
+ };
495
+ return adapter;
496
+ }
497
+ /**
498
+ * Synthesise the agent-facing note for an inbound reaction. The reaction itself
499
+ * carries no text, so the note ("<who> reacted :emoji: to message <id>") is what
500
+ * the central pipeline routes through dispatchTurn so the agent has context.
501
+ */
502
+ export function buildReactionNote(emojis, targetMessageId, fromName) {
503
+ const who = fromName?.trim() || "Someone";
504
+ // A custom emoji surfaces as `name:id` — show just the name for the note.
505
+ const emoji = emojis.map((e) => `:${e.includes(":") ? e.split(":")[0] : e}:`).join(" ");
506
+ return `${who} reacted ${emoji} to message ${targetMessageId}.`;
507
+ }
508
+ /** Static Discord capability flags (shared by the legacy adapter + plugin meta). */
509
+ export const DISCORD_CAPABILITIES = {
510
+ chatTypes: ["direct", "group", "thread"],
511
+ reactions: true,
512
+ edit: true,
513
+ unsend: true,
514
+ reply: true,
515
+ threads: true,
516
+ media: true,
517
+ nativeCommands: true,
518
+ };
519
+ /**
520
+ * Defensive config fallback for a direct `start()` that skipped `isConfigured`
521
+ * (the manager always calls isConfigured first, so this is the rare path).
522
+ */
523
+ async function loadStartConfig() {
524
+ return loadConfig();
525
+ }
526
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../src/agents/channels/discord/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,2EAA2E;AAC3E,mFAAmF;AACnF,kDAAkD;AAClD,OAAO,EACN,oBAAoB,EACpB,SAAS,GAWT,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,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,WAAW;YACV,OAAO,UAAU,EAAE,WAAW,EAAE,IAAI,IAAI,CAAC;QAC1C,CAAC;QAED,WAAW;YACV,OAAO,UAAU,EAAE,WAAW,EAAE,IAAI,IAAI,CAAC;QAC1C,CAAC;KACD,CAAC;IAEF,OAAO,OAAO,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAgB,EAAE,eAAuB,EAAE,QAAiB;IAC7F,MAAM,GAAG,GAAG,QAAQ,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC;IAC1C,0EAA0E;IAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACxF,OAAO,GAAG,GAAG,YAAY,KAAK,eAAe,eAAe,GAAG,CAAC;AACjE,CAAC;AAED,oFAAoF;AACpF,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACxD,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC;IACxC,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,cAAc,EAAE,IAAI;CACpB,CAAC;AAgBF;;;GAGG;AACH,KAAK,UAAU,eAAe;IAC7B,OAAO,UAAU,EAAE,CAAC;AACrB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Discord inline-approval authorization.
3
+ *
4
+ * When an approval prompt is rendered as buttons, ANY member who can see the
5
+ * message could press a button. Brigade's central inbound pipeline already runs
6
+ * the access-control gate before a button press reaches the approval-callback
7
+ * path, so only an admitted (allow-listed / owner) peer gets here at all — but a
8
+ * SHARED Discord guild channel is the edge case: in a channel the bot is in, an
9
+ * admitted member's button press should still be allowed only when that presser
10
+ * is an approved approver, not merely present in the room. Discord's
11
+ * multi-member guilds make this gate more load-bearing than a 1:1 DM.
12
+ *
13
+ * This predicate is the channel's `approvalCapability.authorizeApprover`. It is
14
+ * invoked CENTRALLY by `tryConsumeChannelApprovalCallback` with the presser's
15
+ * `senderId` (the Discord user id, a snowflake); returning `{ authorized: false,
16
+ * reason }` refuses the press without consuming the operator's pending approval
17
+ * (so the real operator can still answer). Policy:
18
+ *
19
+ * - When the channel has an explicit allow-from list configured (the approved
20
+ * senders), only those ids may approve.
21
+ * - When NO allow-from list is configured, defer to the access gate that
22
+ * already admitted the inbound and authorize the press (matches the text-
23
+ * reply path, which has no extra approver gate).
24
+ *
25
+ * Pure + deterministic over its `cfg` + `senderId` inputs — no I/O. Discord
26
+ * mirror of `slack/approval-authorize.ts`.
27
+ */
28
+ import type { BrigadeConfig } from "../../../config/io.js";
29
+ /**
30
+ * Resolve whether `senderId` is allowed to answer a Discord inline approval.
31
+ * Returns `{ authorized: true }` when no explicit allow-from gate applies (the
32
+ * central access gate already admitted the inbound), or when the presser is on
33
+ * the configured allow-from list. Otherwise refuses with a reason.
34
+ */
35
+ export declare function resolveDiscordApprover(args: {
36
+ cfg: BrigadeConfig;
37
+ senderId?: string;
38
+ accountId?: string;
39
+ }): {
40
+ authorized: boolean;
41
+ reason?: string;
42
+ };
43
+ //# sourceMappingURL=approval-authorize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-authorize.d.ts","sourceRoot":"","sources":["../../../../src/agents/channels/discord/approval-authorize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA0B3D;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAU3C"}