@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,139 @@
1
+ import { p as normalizeDiscordToken } from "./accounts-B7OBFePq.js";
2
+ import { n as fetchDiscord, t as DiscordApiError } from "./api-CXAcv9nZ.js";
3
+ import { resolveFetch } from "klaw/plugin-sdk/fetch-runtime";
4
+ import { formatErrorMessage } from "klaw/plugin-sdk/error-runtime";
5
+ import { fetchWithTimeout } from "klaw/plugin-sdk/text-utility-runtime";
6
+ //#region extensions/discord/src/probe.ts
7
+ const DISCORD_API_BASE = "https://discord.com/api/v10";
8
+ const DISCORD_APP_FLAG_GATEWAY_PRESENCE = 4096;
9
+ const DISCORD_APP_FLAG_GATEWAY_PRESENCE_LIMITED = 8192;
10
+ const DISCORD_APP_FLAG_GATEWAY_GUILD_MEMBERS = 16384;
11
+ const DISCORD_APP_FLAG_GATEWAY_GUILD_MEMBERS_LIMITED = 32768;
12
+ const DISCORD_APP_FLAG_GATEWAY_MESSAGE_CONTENT = 1 << 18;
13
+ const DISCORD_APP_FLAG_GATEWAY_MESSAGE_CONTENT_LIMITED = 1 << 19;
14
+ async function fetchDiscordApplicationMe(token, timeoutMs, fetcher) {
15
+ try {
16
+ const normalized = normalizeDiscordToken(token, "channels.discord.token");
17
+ if (!normalized) return;
18
+ return await fetchDiscord("/oauth2/applications/@me", normalized, createDiscordTimeoutFetch(fetcher, timeoutMs), { retry: { attempts: 1 } });
19
+ } catch {
20
+ return;
21
+ }
22
+ }
23
+ function createDiscordTimeoutFetch(fetcher, timeoutMs) {
24
+ const fetchImpl = getResolvedFetch(fetcher);
25
+ return ((input, init) => fetchWithTimeout(typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url, init ?? {}, timeoutMs, fetchImpl));
26
+ }
27
+ function resolveDiscordPrivilegedIntentsFromFlags(flags) {
28
+ const resolve = (enabledBit, limitedBit) => {
29
+ if ((flags & enabledBit) !== 0) return "enabled";
30
+ if ((flags & limitedBit) !== 0) return "limited";
31
+ return "disabled";
32
+ };
33
+ return {
34
+ presence: resolve(DISCORD_APP_FLAG_GATEWAY_PRESENCE, DISCORD_APP_FLAG_GATEWAY_PRESENCE_LIMITED),
35
+ guildMembers: resolve(DISCORD_APP_FLAG_GATEWAY_GUILD_MEMBERS, DISCORD_APP_FLAG_GATEWAY_GUILD_MEMBERS_LIMITED),
36
+ messageContent: resolve(DISCORD_APP_FLAG_GATEWAY_MESSAGE_CONTENT, DISCORD_APP_FLAG_GATEWAY_MESSAGE_CONTENT_LIMITED)
37
+ };
38
+ }
39
+ async function fetchDiscordApplicationSummary(token, timeoutMs, fetcher = fetch) {
40
+ const json = await fetchDiscordApplicationMe(token, timeoutMs, fetcher);
41
+ if (!json) return;
42
+ const flags = typeof json.flags === "number" && Number.isFinite(json.flags) ? json.flags : void 0;
43
+ return {
44
+ id: json.id ?? null,
45
+ flags: flags ?? null,
46
+ intents: typeof flags === "number" ? resolveDiscordPrivilegedIntentsFromFlags(flags) : void 0
47
+ };
48
+ }
49
+ function getResolvedFetch(fetcher) {
50
+ const fetchImpl = resolveFetch(fetcher);
51
+ if (!fetchImpl) throw new Error("fetch is not available");
52
+ return fetchImpl;
53
+ }
54
+ async function probeDiscord(token, timeoutMs, opts) {
55
+ const started = Date.now();
56
+ const fetcher = opts?.fetcher ?? fetch;
57
+ const includeApplication = opts?.includeApplication === true;
58
+ const normalized = normalizeDiscordToken(token, "channels.discord.token");
59
+ const result = {
60
+ ok: false,
61
+ status: null,
62
+ error: null,
63
+ elapsedMs: 0
64
+ };
65
+ if (!normalized) return {
66
+ ...result,
67
+ error: "missing token",
68
+ elapsedMs: Date.now() - started
69
+ };
70
+ try {
71
+ const res = await fetchWithTimeout(`${DISCORD_API_BASE}/users/@me`, { headers: { Authorization: `Bot ${normalized}` } }, timeoutMs, getResolvedFetch(fetcher));
72
+ if (!res.ok) {
73
+ result.status = res.status;
74
+ result.error = `getMe failed (${res.status})`;
75
+ return {
76
+ ...result,
77
+ elapsedMs: Date.now() - started
78
+ };
79
+ }
80
+ const json = await res.json();
81
+ result.ok = true;
82
+ result.bot = {
83
+ id: json.id ?? null,
84
+ username: json.username ?? null
85
+ };
86
+ if (includeApplication) result.application = await fetchDiscordApplicationSummary(normalized, timeoutMs, fetcher) ?? void 0;
87
+ return {
88
+ ...result,
89
+ elapsedMs: Date.now() - started
90
+ };
91
+ } catch (err) {
92
+ return {
93
+ ...result,
94
+ status: err instanceof Response ? err.status : result.status,
95
+ error: formatErrorMessage(err),
96
+ elapsedMs: Date.now() - started
97
+ };
98
+ }
99
+ }
100
+ /**
101
+ * Extract the application (bot user) ID from a Discord bot token by
102
+ * base64-decoding the first segment. Discord tokens have the format:
103
+ * base64(user_id) . timestamp . hmac
104
+ * The decoded first segment is the numeric snowflake ID as a plain string,
105
+ * so we keep it as a string to avoid precision loss for IDs that exceed
106
+ * Number.MAX_SAFE_INTEGER.
107
+ */
108
+ function parseApplicationIdFromToken(token) {
109
+ const normalized = normalizeDiscordToken(token, "channels.discord.token");
110
+ if (!normalized) return;
111
+ const firstDot = normalized.indexOf(".");
112
+ if (firstDot <= 0) return;
113
+ try {
114
+ const decoded = Buffer.from(normalized.slice(0, firstDot), "base64").toString("utf-8");
115
+ if (/^\d+$/.test(decoded)) return decoded;
116
+ return;
117
+ } catch {
118
+ return;
119
+ }
120
+ }
121
+ async function fetchDiscordApplicationId(token, timeoutMs, fetcher = fetch) {
122
+ const normalized = normalizeDiscordToken(token, "channels.discord.token");
123
+ if (!normalized) return;
124
+ const parsedApplicationId = parseApplicationIdFromToken(token);
125
+ if (parsedApplicationId) return parsedApplicationId;
126
+ try {
127
+ const json = await fetchDiscord("/oauth2/applications/@me", normalized, createDiscordTimeoutFetch(fetcher, timeoutMs));
128
+ if (json?.id) return json.id;
129
+ return;
130
+ } catch (error) {
131
+ if (error instanceof DiscordApiError) {
132
+ if (error.status === 429) throw error;
133
+ return;
134
+ }
135
+ return;
136
+ }
137
+ }
138
+ //#endregion
139
+ export { resolveDiscordPrivilegedIntentsFromFlags as a, probeDiscord as i, fetchDiscordApplicationSummary as n, parseApplicationIdFromToken as r, fetchDiscordApplicationId as t };
@@ -0,0 +1,2 @@
1
+ import { a as resolveDiscordPrivilegedIntentsFromFlags, i as probeDiscord, n as fetchDiscordApplicationSummary, r as parseApplicationIdFromToken, t as fetchDiscordApplicationId } from "./probe-D--Ca4JF.js";
2
+ export { fetchDiscordApplicationId, fetchDiscordApplicationSummary, parseApplicationIdFromToken, probeDiscord, resolveDiscordPrivilegedIntentsFromFlags };