@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,105 @@
1
+ import { isRecord, normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-runtime";
2
+ import { ChannelType } from "discord-api-types/v10";
3
+ import { formatErrorMessage } from "klaw/plugin-sdk/error-runtime";
4
+ //#region extensions/discord/src/audit-core.ts
5
+ const REQUIRED_TEXT_CHANNEL_PERMISSIONS = ["ViewChannel", "SendMessages"];
6
+ const REQUIRED_VOICE_CHANNEL_PERMISSIONS = [
7
+ "ViewChannel",
8
+ "Connect",
9
+ "Speak",
10
+ "SendMessages",
11
+ "ReadMessageHistory"
12
+ ];
13
+ function resolveRequiredDiscordChannelPermissions(channelType) {
14
+ if (channelType === ChannelType.GuildVoice || channelType === ChannelType.GuildStageVoice) return [...REQUIRED_VOICE_CHANNEL_PERMISSIONS];
15
+ return [...REQUIRED_TEXT_CHANNEL_PERMISSIONS];
16
+ }
17
+ function shouldAuditChannelConfig(config) {
18
+ if (!config) return true;
19
+ if (config.enabled === false) return false;
20
+ return true;
21
+ }
22
+ function listConfiguredGuildChannelKeys(guilds) {
23
+ if (!guilds) return [];
24
+ const ids = /* @__PURE__ */ new Set();
25
+ for (const entry of Object.values(guilds)) {
26
+ if (!entry || typeof entry !== "object") continue;
27
+ const channelsRaw = entry.channels;
28
+ if (!isRecord(channelsRaw)) continue;
29
+ for (const [key, value] of Object.entries(channelsRaw)) {
30
+ const channelId = normalizeOptionalString(key) ?? "";
31
+ if (!channelId) continue;
32
+ if (channelId === "*") continue;
33
+ if (!shouldAuditChannelConfig(value)) continue;
34
+ ids.add(channelId);
35
+ }
36
+ }
37
+ return [...ids].toSorted((a, b) => a.localeCompare(b));
38
+ }
39
+ function collectDiscordAuditChannelIdsForGuilds(guilds) {
40
+ const keys = listConfiguredGuildChannelKeys(guilds);
41
+ const channelIds = keys.filter((key) => /^\d+$/.test(key));
42
+ return {
43
+ channelIds,
44
+ unresolvedChannels: keys.length - channelIds.length
45
+ };
46
+ }
47
+ function collectDiscordAuditChannelIdsForAccount(config) {
48
+ const collected = collectDiscordAuditChannelIdsForGuilds(config.guilds);
49
+ const channelIds = new Set(collected.channelIds);
50
+ let unresolvedVoiceChannels = 0;
51
+ for (const entry of config.voice?.autoJoin ?? []) {
52
+ const channelId = normalizeOptionalString(entry?.channelId) ?? "";
53
+ if (/^\d+$/.test(channelId)) channelIds.add(channelId);
54
+ else if (channelId) unresolvedVoiceChannels++;
55
+ }
56
+ return {
57
+ channelIds: [...channelIds].toSorted((a, b) => a.localeCompare(b)),
58
+ unresolvedChannels: collected.unresolvedChannels + unresolvedVoiceChannels
59
+ };
60
+ }
61
+ async function auditDiscordChannelPermissionsWithFetcher(params) {
62
+ const started = Date.now();
63
+ const token = normalizeOptionalString(params.token) ?? "";
64
+ if (!token || params.channelIds.length === 0) return {
65
+ ok: true,
66
+ checkedChannels: 0,
67
+ unresolvedChannels: 0,
68
+ channels: [],
69
+ elapsedMs: Date.now() - started
70
+ };
71
+ const channels = [];
72
+ for (const channelId of params.channelIds) try {
73
+ const perms = await params.fetchChannelPermissions(channelId, {
74
+ cfg: params.cfg,
75
+ token,
76
+ accountId: params.accountId ?? void 0
77
+ });
78
+ const missing = resolveRequiredDiscordChannelPermissions(perms.channelType).filter((p) => !perms.permissions.includes(p));
79
+ channels.push({
80
+ channelId,
81
+ ok: missing.length === 0,
82
+ missing: missing.length ? missing : void 0,
83
+ error: null,
84
+ matchKey: channelId,
85
+ matchSource: "id"
86
+ });
87
+ } catch (err) {
88
+ channels.push({
89
+ channelId,
90
+ ok: false,
91
+ error: formatErrorMessage(err),
92
+ matchKey: channelId,
93
+ matchSource: "id"
94
+ });
95
+ }
96
+ return {
97
+ ok: channels.every((c) => c.ok),
98
+ checkedChannels: channels.length,
99
+ unresolvedChannels: 0,
100
+ channels,
101
+ elapsedMs: Date.now() - started
102
+ };
103
+ }
104
+ //#endregion
105
+ export { collectDiscordAuditChannelIdsForAccount as n, resolveRequiredDiscordChannelPermissions as r, auditDiscordChannelPermissionsWithFetcher as t };