@kodelyth/discord 2026.5.39 → 2026.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 (126) hide show
  1. package/dist/account-inspect-Dqw-enky.js +81 -0
  2. package/dist/account-inspect-api.js +10 -0
  3. package/dist/accounts-B7OBFePq.js +224 -0
  4. package/dist/action-runtime-api.js +2 -0
  5. package/dist/agent-components.runtime-DVY_1VB4.js +4 -0
  6. package/dist/allow-list-B0s7evD7.js +354 -0
  7. package/dist/api-CXAcv9nZ.js +130 -0
  8. package/dist/api.js +23 -0
  9. package/dist/approval-handler.runtime-B9xUAF3n.js +426 -0
  10. package/dist/audit-DoiK49WO.js +24 -0
  11. package/dist/audit-core-BGrq3G7r.js +105 -0
  12. package/dist/channel-U_aeoFwW.js +795 -0
  13. package/dist/channel-actions-BxEBnEuv.js +173 -0
  14. package/dist/channel-actions.runtime-CPtpH-yl.js +263 -0
  15. package/dist/channel-api-BfjklLby.js +21 -0
  16. package/dist/channel-config-api.js +2 -0
  17. package/dist/channel-plugin-api.js +2 -0
  18. package/dist/channel.setup-BUSC0apv.js +337 -0
  19. package/dist/components-luonoe13.js +909 -0
  20. package/dist/config-api-DSYGqaLQ.js +2 -0
  21. package/dist/config-schema-DIqJBGwC.js +357 -0
  22. package/dist/configured-state.js +6 -0
  23. package/dist/contract-api.js +8 -0
  24. package/dist/conversation-identity-DXAm0_Mk.js +270 -0
  25. package/dist/directory-config-CYbuMmPS.js +49 -0
  26. package/dist/directory-contract-api.js +2 -0
  27. package/dist/directory-live-DX4dLRpJ.js +159 -0
  28. package/dist/doctor-bbKSvGVD.js +244 -0
  29. package/dist/doctor-contract-Btjt6NJD.js +383 -0
  30. package/dist/doctor-contract-api.js +2 -0
  31. package/dist/gateway-registry-BKSpa4GB.js +74 -0
  32. package/dist/handle-action.guild-admin-B5BArS2n.js +286 -0
  33. package/dist/inbound-context-WAOqhGlT.js +48 -0
  34. package/dist/inbound-event-delivery-C-1Ji3WP.js +65 -0
  35. package/dist/index.js +26 -0
  36. package/dist/manager.runtime-DXHynKE4.js +2356 -0
  37. package/dist/message-handler-mXzc3tA_.js +381 -0
  38. package/dist/message-handler.preflight-BPD1a347.js +1113 -0
  39. package/dist/message-handler.process-GUa3aV8z.js +1438 -0
  40. package/dist/message-utils-dUbem16p.js +549 -0
  41. package/dist/outbound-adapter-C18OAc1y.js +536 -0
  42. package/dist/pluralkit-D1Q2x0w5.js +22 -0
  43. package/dist/preflight-audio-CZtpWcIm.js +72 -0
  44. package/dist/preflight-audio.runtime-Brx_0_xW.js +7 -0
  45. package/dist/preview-streaming-D_slNIiO.js +8 -0
  46. package/dist/probe-D--Ca4JF.js +139 -0
  47. package/dist/probe.runtime-DQBchZzv.js +2 -0
  48. package/dist/provider-B2-31CIT.js +9565 -0
  49. package/dist/provider-session.runtime-BwzzSsrH.js +6 -0
  50. package/dist/provider.runtime-CP3oHLls.js +2 -0
  51. package/dist/resolve-allowlist-common-CqxPLcJO.js +34 -0
  52. package/dist/resolve-channels-0LX4pUbB.js +265 -0
  53. package/dist/resolve-users-CztOv0Qs.js +120 -0
  54. package/dist/runtime-DUaw66V_.js +1073 -0
  55. package/dist/runtime-api.actions.js +3 -0
  56. package/dist/runtime-api.js +30 -0
  57. package/dist/runtime-api.lookup.js +7 -0
  58. package/dist/runtime-api.monitor-CvVKvEXW.js +5 -0
  59. package/dist/runtime-api.monitor.js +8 -0
  60. package/dist/runtime-api.send.js +6 -0
  61. package/dist/runtime-api.threads.js +6 -0
  62. package/dist/runtime-fC6f4UF2.js +8 -0
  63. package/dist/runtime-setter-api.js +2 -0
  64. package/dist/secret-config-contract-B6WW5V88.js +115 -0
  65. package/dist/secret-contract-api.js +2 -0
  66. package/dist/security-audit-CnyIQKz6.js +120 -0
  67. package/dist/security-audit-contract-api.js +2 -0
  68. package/dist/security-audit.runtime-CQSkjNLu.js +2 -0
  69. package/dist/security-contract-DLvYOgLM.js +26 -0
  70. package/dist/security-contract-api.js +2 -0
  71. package/dist/security-doctor-DepqtNCI.js +18 -0
  72. package/dist/send-DCtPCHGk.js +881 -0
  73. package/dist/send.components-Bcgxvm52.js +474 -0
  74. package/dist/send.outbound-S9t0UuHc.js +330 -0
  75. package/dist/send.receipt-CDn3GBWC.js +3119 -0
  76. package/dist/send.shared-D4iBnAmn.js +669 -0
  77. package/dist/sender-identity-CxCe3_1a.js +43 -0
  78. package/dist/session-contract-Dwhw3RTY.js +6 -0
  79. package/dist/session-key-api.js +2 -0
  80. package/dist/session-key-normalization-CP8dPUid.js +23 -0
  81. package/dist/setup-entry.js +11 -0
  82. package/dist/setup-plugin-api.js +2 -0
  83. package/dist/shared-AIlvuZXt.js +171 -0
  84. package/dist/subagent-hooks-8bK-mgiU.js +120 -0
  85. package/dist/subagent-hooks-api.js +22 -0
  86. package/dist/system-events-Ba1TklaL.js +34 -0
  87. package/dist/target-resolver-BrtFQtoK.js +82 -0
  88. package/dist/targets-DWLLZE2l.js +3 -0
  89. package/dist/test-api.js +45 -0
  90. package/dist/thread-binding-api.js +4 -0
  91. package/dist/thread-bindings-9aKRmZv0.js +255 -0
  92. package/dist/thread-bindings.discord-api-ssGH5wc2.js +244 -0
  93. package/dist/thread-bindings.manager-0YBHGemk.js +534 -0
  94. package/dist/thread-bindings.session-updates-DJZGIwaU.js +54 -0
  95. package/dist/thread-bindings.state-eTFl-PqJ.js +318 -0
  96. package/dist/timeouts-CEwuGaWT.js +52 -0
  97. package/dist/timeouts.js +2 -0
  98. package/dist/typing-BmJKRpCS.js +14 -0
  99. package/package.json +19 -7
  100. package/account-inspect-api.js +0 -7
  101. package/action-runtime-api.js +0 -7
  102. package/api.js +0 -7
  103. package/channel-config-api.js +0 -7
  104. package/channel-plugin-api.js +0 -7
  105. package/configured-state.js +0 -7
  106. package/contract-api.js +0 -7
  107. package/directory-contract-api.js +0 -7
  108. package/doctor-contract-api.js +0 -7
  109. package/index.js +0 -7
  110. package/runtime-api.actions.js +0 -7
  111. package/runtime-api.js +0 -7
  112. package/runtime-api.lookup.js +0 -7
  113. package/runtime-api.monitor.js +0 -7
  114. package/runtime-api.send.js +0 -7
  115. package/runtime-api.threads.js +0 -7
  116. package/runtime-setter-api.js +0 -7
  117. package/secret-contract-api.js +0 -7
  118. package/security-audit-contract-api.js +0 -7
  119. package/security-contract-api.js +0 -7
  120. package/session-key-api.js +0 -7
  121. package/setup-entry.js +0 -7
  122. package/setup-plugin-api.js +0 -7
  123. package/subagent-hooks-api.js +0 -7
  124. package/test-api.js +0 -7
  125. package/thread-binding-api.js +0 -7
  126. package/timeouts.js +0 -7
@@ -0,0 +1,337 @@
1
+ import { a as mergeDiscordAccountConfig, c as resolveDiscordAccountAllowFrom, l as resolveDiscordAccountConfig, m as resolveDiscordToken, o as resolveDefaultDiscordAccountId } from "./accounts-B7OBFePq.js";
2
+ import { i as discordSetupAdapter, t as createDiscordPluginBase } from "./shared-AIlvuZXt.js";
3
+ import { t as resolveDiscordChannelAllowlist } from "./resolve-channels-0LX4pUbB.js";
4
+ import { t as resolveDiscordUserAllowlist } from "./resolve-users-CztOv0Qs.js";
5
+ import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "klaw/plugin-sdk/account-id";
6
+ import { hasConfiguredSecretInput, normalizeSecretInputString } from "klaw/plugin-sdk/secret-input";
7
+ import { normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-runtime";
8
+ import { createAccountScopedAllowFromSection, createAccountScopedGroupAccessSection, createLegacyCompatChannelDmPolicy, createSetupTranslator, createStandardChannelSetupStatus, parseMentionOrPrefixedId, patchChannelConfigForAccount, promptLegacyChannelAllowFromForAccount, resolveEntriesWithOptionalToken, setSetupChannelEnabled } from "klaw/plugin-sdk/setup-runtime";
9
+ import { formatDocsLink } from "klaw/plugin-sdk/setup-tools";
10
+ import "klaw/plugin-sdk/account-resolution";
11
+ //#region extensions/discord/src/setup-account-state.ts
12
+ function inspectConfiguredToken(value) {
13
+ const normalized = normalizeSecretInputString(value);
14
+ if (normalized) return {
15
+ token: normalized.replace(/^Bot\s+/i, ""),
16
+ tokenSource: "config",
17
+ tokenStatus: "available"
18
+ };
19
+ if (hasConfiguredSecretInput(value)) return {
20
+ token: "",
21
+ tokenSource: "config",
22
+ tokenStatus: "configured_unavailable"
23
+ };
24
+ return null;
25
+ }
26
+ function resolveDefaultDiscordSetupAccountId(cfg) {
27
+ return resolveDefaultDiscordAccountId(cfg);
28
+ }
29
+ function resolveDiscordSetupAccountConfig(params) {
30
+ const accountId = normalizeAccountId(params.accountId ?? resolveDefaultDiscordSetupAccountId(params.cfg));
31
+ return {
32
+ accountId,
33
+ config: mergeDiscordAccountConfig(params.cfg, accountId)
34
+ };
35
+ }
36
+ function inspectDiscordSetupAccount(params) {
37
+ const { accountId, config } = resolveDiscordSetupAccountConfig(params);
38
+ const enabled = params.cfg.channels?.discord?.enabled !== false && config.enabled !== false;
39
+ const accountConfig = resolveDiscordAccountConfig(params.cfg, accountId);
40
+ const hasAccountToken = Boolean(accountConfig && Object.prototype.hasOwnProperty.call(accountConfig, "token"));
41
+ const accountToken = inspectConfiguredToken(accountConfig?.token);
42
+ if (accountToken) return {
43
+ accountId,
44
+ enabled,
45
+ token: accountToken.token,
46
+ tokenSource: accountToken.tokenSource,
47
+ tokenStatus: accountToken.tokenStatus,
48
+ configured: true,
49
+ config
50
+ };
51
+ if (hasAccountToken) return {
52
+ accountId,
53
+ enabled,
54
+ token: "",
55
+ tokenSource: "none",
56
+ tokenStatus: "missing",
57
+ configured: false,
58
+ config
59
+ };
60
+ const channelToken = inspectConfiguredToken(params.cfg.channels?.discord?.token);
61
+ if (channelToken) return {
62
+ accountId,
63
+ enabled,
64
+ token: channelToken.token,
65
+ tokenSource: channelToken.tokenSource,
66
+ tokenStatus: channelToken.tokenStatus,
67
+ configured: true,
68
+ config
69
+ };
70
+ const tokenResolution = resolveDiscordToken(params.cfg, { accountId });
71
+ if (tokenResolution.token) return {
72
+ accountId,
73
+ enabled,
74
+ token: tokenResolution.token,
75
+ tokenSource: tokenResolution.source,
76
+ tokenStatus: "available",
77
+ configured: true,
78
+ config
79
+ };
80
+ return {
81
+ accountId,
82
+ enabled,
83
+ token: "",
84
+ tokenSource: "none",
85
+ tokenStatus: "missing",
86
+ configured: false,
87
+ config
88
+ };
89
+ }
90
+ //#endregion
91
+ //#region extensions/discord/src/setup-core.ts
92
+ const t$1 = createSetupTranslator();
93
+ const channel$1 = "discord";
94
+ const DISCORD_TOKEN_HELP_LINES = [
95
+ t$1("wizard.discord.tokenHelpCreateApplication"),
96
+ t$1("wizard.discord.tokenHelpCopyToken"),
97
+ t$1("wizard.discord.tokenHelpInviteBot"),
98
+ t$1("wizard.discord.tokenHelpMessageContentIntent"),
99
+ t$1("wizard.channels.docs", { link: formatDocsLink("/discord", "discord") })
100
+ ];
101
+ function mapDiscordSetupAllowlistEntries(resolved) {
102
+ if (!Array.isArray(resolved)) return [];
103
+ return resolved.flatMap((entry) => {
104
+ if (!entry || typeof entry !== "object") return [];
105
+ const row = entry;
106
+ if (row.resolved === false) return [];
107
+ const guildKey = normalizeOptionalString(row.guildId ?? row.guildKey);
108
+ if (!guildKey) return [];
109
+ const channelKey = normalizeOptionalString(row.channelId ?? row.channelKey);
110
+ return channelKey ? [{
111
+ guildKey,
112
+ channelKey
113
+ }] : [{ guildKey }];
114
+ });
115
+ }
116
+ function setDiscordGuildChannelAllowlist(cfg, accountId, entries) {
117
+ const guilds = { ...accountId === DEFAULT_ACCOUNT_ID ? cfg.channels?.discord?.guilds ?? {} : cfg.channels?.discord?.accounts?.[accountId]?.guilds ?? {} };
118
+ for (const entry of entries) {
119
+ const guildKey = entry.guildKey || "*";
120
+ const existing = guilds[guildKey] ?? {};
121
+ if (entry.channelKey) {
122
+ const channels = { ...existing.channels };
123
+ channels[entry.channelKey] = { enabled: true };
124
+ guilds[guildKey] = {
125
+ ...existing,
126
+ channels
127
+ };
128
+ } else guilds[guildKey] = existing;
129
+ }
130
+ return patchChannelConfigForAccount({
131
+ cfg,
132
+ channel: channel$1,
133
+ accountId,
134
+ patch: { guilds }
135
+ });
136
+ }
137
+ function parseDiscordAllowFromId(value) {
138
+ return parseMentionOrPrefixedId({
139
+ value,
140
+ mentionPattern: /^<@!?(\d+)>$/,
141
+ prefixPattern: /^(user:|discord:)/i,
142
+ idPattern: /^\d+$/
143
+ });
144
+ }
145
+ function createDiscordSetupWizardBase(handlers) {
146
+ const discordDmPolicy = createLegacyCompatChannelDmPolicy({
147
+ label: "Discord",
148
+ channel: channel$1,
149
+ promptAllowFrom: handlers.promptAllowFrom
150
+ });
151
+ return {
152
+ channel: channel$1,
153
+ status: createStandardChannelSetupStatus({
154
+ channelLabel: "Discord",
155
+ configuredLabel: t$1("wizard.channels.statusConfigured"),
156
+ unconfiguredLabel: t$1("wizard.channels.statusNeedsToken"),
157
+ configuredHint: t$1("wizard.channels.statusConfigured"),
158
+ unconfiguredHint: t$1("wizard.channels.statusNeedsToken"),
159
+ configuredScore: 2,
160
+ unconfiguredScore: 1,
161
+ resolveConfigured: ({ cfg, accountId }) => inspectDiscordSetupAccount({
162
+ cfg,
163
+ accountId
164
+ }).configured
165
+ }),
166
+ credentials: [{
167
+ inputKey: "token",
168
+ providerHint: channel$1,
169
+ credentialLabel: t$1("wizard.discord.botToken"),
170
+ preferredEnvVar: "DISCORD_BOT_TOKEN",
171
+ helpTitle: t$1("wizard.discord.botToken"),
172
+ helpLines: DISCORD_TOKEN_HELP_LINES,
173
+ envPrompt: t$1("wizard.discord.tokenEnvPrompt"),
174
+ keepPrompt: t$1("wizard.discord.tokenKeepPrompt"),
175
+ inputPrompt: t$1("wizard.discord.tokenInputPrompt"),
176
+ allowEnv: ({ accountId }) => accountId === DEFAULT_ACCOUNT_ID,
177
+ inspect: ({ cfg, accountId }) => {
178
+ const account = inspectDiscordSetupAccount({
179
+ cfg,
180
+ accountId
181
+ });
182
+ return {
183
+ accountConfigured: account.configured,
184
+ hasConfiguredValue: account.tokenStatus !== "missing",
185
+ resolvedValue: normalizeOptionalString(account.token),
186
+ envValue: accountId === DEFAULT_ACCOUNT_ID ? normalizeOptionalString(process.env.DISCORD_BOT_TOKEN) : void 0
187
+ };
188
+ }
189
+ }],
190
+ groupAccess: createAccountScopedGroupAccessSection({
191
+ channel: channel$1,
192
+ label: t$1("wizard.discord.channelsLabel"),
193
+ placeholder: "My Server/#general, guildId/channelId, #support",
194
+ currentPolicy: ({ cfg, accountId }) => resolveDiscordSetupAccountConfig({
195
+ cfg,
196
+ accountId
197
+ }).config.groupPolicy ?? "allowlist",
198
+ currentEntries: ({ cfg, accountId }) => Object.entries(resolveDiscordSetupAccountConfig({
199
+ cfg,
200
+ accountId
201
+ }).config.guilds ?? {}).flatMap(([guildKey, value]) => {
202
+ const channels = value?.channels ?? {};
203
+ const channelKeys = Object.keys(channels);
204
+ if (channelKeys.length === 0) return [/^\d+$/.test(guildKey) ? `guild:${guildKey}` : guildKey];
205
+ return channelKeys.map((channelKey) => `${guildKey}/${channelKey}`);
206
+ }),
207
+ updatePrompt: ({ cfg, accountId }) => Boolean(resolveDiscordSetupAccountConfig({
208
+ cfg,
209
+ accountId
210
+ }).config.guilds),
211
+ resolveAllowlist: handlers.resolveGroupAllowlist,
212
+ fallbackResolved: (entries) => entries.map((input) => ({
213
+ input,
214
+ resolved: false
215
+ })),
216
+ applyAllowlist: ({ cfg, accountId, resolved }) => setDiscordGuildChannelAllowlist(cfg, accountId, mapDiscordSetupAllowlistEntries(resolved))
217
+ }),
218
+ allowFrom: createAccountScopedAllowFromSection({
219
+ channel: channel$1,
220
+ credentialInputKey: "token",
221
+ helpTitle: "Discord allowlist",
222
+ helpLines: [
223
+ t$1("wizard.discord.allowlistIntro"),
224
+ t$1("wizard.discord.examples"),
225
+ "- 123456789012345678",
226
+ "- @alice",
227
+ "- alice#1234",
228
+ t$1("wizard.discord.multipleEntries"),
229
+ t$1("wizard.channels.docs", { link: formatDocsLink("/discord", "discord") })
230
+ ],
231
+ message: t$1("wizard.discord.allowFromPrompt"),
232
+ placeholder: "@alice, 123456789012345678",
233
+ invalidWithoutCredentialNote: t$1("wizard.discord.allowFromInvalidWithoutToken"),
234
+ parseId: parseDiscordAllowFromId,
235
+ resolveEntries: handlers.resolveAllowFromEntries
236
+ }),
237
+ dmPolicy: discordDmPolicy,
238
+ disable: (cfg) => setSetupChannelEnabled(cfg, channel$1, false)
239
+ };
240
+ }
241
+ //#endregion
242
+ //#region extensions/discord/src/setup-surface.ts
243
+ const t = createSetupTranslator();
244
+ const channel = "discord";
245
+ async function resolveDiscordAllowFromEntries(params) {
246
+ return await resolveEntriesWithOptionalToken({
247
+ token: params.token,
248
+ entries: params.entries,
249
+ buildWithoutToken: (input) => ({
250
+ input,
251
+ resolved: false,
252
+ id: null
253
+ }),
254
+ resolveEntries: async ({ token, entries }) => (await resolveDiscordUserAllowlist({
255
+ token,
256
+ entries
257
+ })).map((entry) => ({
258
+ input: entry.input,
259
+ resolved: entry.resolved,
260
+ id: entry.id ?? null
261
+ }))
262
+ });
263
+ }
264
+ async function promptDiscordAllowFrom(params) {
265
+ return await promptLegacyChannelAllowFromForAccount({
266
+ cfg: params.cfg,
267
+ channel,
268
+ prompter: params.prompter,
269
+ accountId: params.accountId,
270
+ defaultAccountId: resolveDefaultDiscordSetupAccountId(params.cfg),
271
+ resolveAccount: (cfg, accountId) => resolveDiscordSetupAccountConfig({
272
+ cfg,
273
+ accountId
274
+ }),
275
+ noteTitle: t("wizard.discord.allowlistTitle"),
276
+ noteLines: [
277
+ t("wizard.discord.allowlistIntro"),
278
+ t("wizard.discord.examples"),
279
+ "- 123456789012345678",
280
+ "- @alice",
281
+ "- alice#1234",
282
+ t("wizard.discord.multipleEntries"),
283
+ t("wizard.channels.docs", { link: formatDocsLink("/discord", "discord") })
284
+ ],
285
+ message: t("wizard.discord.allowFromPrompt"),
286
+ placeholder: "@alice, 123456789012345678",
287
+ parseId: parseDiscordAllowFromId,
288
+ invalidWithoutTokenNote: t("wizard.discord.allowFromInvalidWithoutToken"),
289
+ resolveExisting: (account, cfg) => resolveDiscordAccountAllowFrom({
290
+ cfg,
291
+ accountId: account.accountId
292
+ }) ?? [],
293
+ resolveToken: (account) => resolveDiscordToken(params.cfg, { accountId: account.accountId }).token,
294
+ resolveEntries: async ({ token, entries }) => (await resolveDiscordUserAllowlist({
295
+ token,
296
+ entries
297
+ })).map((entry) => ({
298
+ input: entry.input,
299
+ resolved: entry.resolved,
300
+ id: entry.id ?? null
301
+ }))
302
+ });
303
+ }
304
+ async function resolveDiscordGroupAllowlist(params) {
305
+ return await resolveEntriesWithOptionalToken({
306
+ token: resolveDiscordToken(params.cfg, { accountId: params.accountId }).token || (typeof params.credentialValues.token === "string" ? params.credentialValues.token : ""),
307
+ entries: params.entries,
308
+ buildWithoutToken: (input) => ({
309
+ input,
310
+ resolved: false
311
+ }),
312
+ resolveEntries: async ({ token, entries }) => await resolveDiscordChannelAllowlist({
313
+ token,
314
+ entries
315
+ })
316
+ });
317
+ }
318
+ //#endregion
319
+ //#region extensions/discord/src/channel.setup.ts
320
+ const discordSetupPlugin = { ...createDiscordPluginBase({
321
+ setupWizard: createDiscordSetupWizardBase({
322
+ promptAllowFrom: promptDiscordAllowFrom,
323
+ resolveAllowFromEntries: async ({ cfg, accountId, credentialValues, entries }) => await resolveDiscordAllowFromEntries({
324
+ token: resolveDiscordToken(cfg, { accountId }).token || (typeof credentialValues.token === "string" ? credentialValues.token : ""),
325
+ entries
326
+ }),
327
+ resolveGroupAllowlist: async ({ cfg, accountId, credentialValues, entries }) => await resolveDiscordGroupAllowlist({
328
+ cfg,
329
+ accountId,
330
+ credentialValues,
331
+ entries
332
+ })
333
+ }),
334
+ setup: discordSetupAdapter
335
+ }) };
336
+ //#endregion
337
+ export { discordSetupPlugin as t };