@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.
- package/dist/account-inspect-Dqw-enky.js +81 -0
- package/dist/account-inspect-api.js +10 -0
- package/dist/accounts-B7OBFePq.js +224 -0
- package/dist/action-runtime-api.js +2 -0
- package/dist/agent-components.runtime-DVY_1VB4.js +4 -0
- package/dist/allow-list-B0s7evD7.js +354 -0
- package/dist/api-CXAcv9nZ.js +130 -0
- package/dist/api.js +23 -0
- package/dist/approval-handler.runtime-B9xUAF3n.js +426 -0
- package/dist/audit-DoiK49WO.js +24 -0
- package/dist/audit-core-BGrq3G7r.js +105 -0
- package/dist/channel-U_aeoFwW.js +795 -0
- package/dist/channel-actions-BxEBnEuv.js +173 -0
- package/dist/channel-actions.runtime-CPtpH-yl.js +263 -0
- package/dist/channel-api-BfjklLby.js +21 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.setup-BUSC0apv.js +337 -0
- package/dist/components-luonoe13.js +909 -0
- package/dist/config-api-DSYGqaLQ.js +2 -0
- package/dist/config-schema-DIqJBGwC.js +357 -0
- package/dist/configured-state.js +6 -0
- package/dist/contract-api.js +8 -0
- package/dist/conversation-identity-DXAm0_Mk.js +270 -0
- package/dist/directory-config-CYbuMmPS.js +49 -0
- package/dist/directory-contract-api.js +2 -0
- package/dist/directory-live-DX4dLRpJ.js +159 -0
- package/dist/doctor-bbKSvGVD.js +244 -0
- package/dist/doctor-contract-Btjt6NJD.js +383 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/gateway-registry-BKSpa4GB.js +74 -0
- package/dist/handle-action.guild-admin-B5BArS2n.js +286 -0
- package/dist/inbound-context-WAOqhGlT.js +48 -0
- package/dist/inbound-event-delivery-C-1Ji3WP.js +65 -0
- package/dist/index.js +26 -0
- package/dist/manager.runtime-DXHynKE4.js +2356 -0
- package/dist/message-handler-mXzc3tA_.js +381 -0
- package/dist/message-handler.preflight-BPD1a347.js +1113 -0
- package/dist/message-handler.process-GUa3aV8z.js +1438 -0
- package/dist/message-utils-dUbem16p.js +549 -0
- package/dist/outbound-adapter-C18OAc1y.js +536 -0
- package/dist/pluralkit-D1Q2x0w5.js +22 -0
- package/dist/preflight-audio-CZtpWcIm.js +72 -0
- package/dist/preflight-audio.runtime-Brx_0_xW.js +7 -0
- package/dist/preview-streaming-D_slNIiO.js +8 -0
- package/dist/probe-D--Ca4JF.js +139 -0
- package/dist/probe.runtime-DQBchZzv.js +2 -0
- package/dist/provider-B2-31CIT.js +9565 -0
- package/dist/provider-session.runtime-BwzzSsrH.js +6 -0
- package/dist/provider.runtime-CP3oHLls.js +2 -0
- package/dist/resolve-allowlist-common-CqxPLcJO.js +34 -0
- package/dist/resolve-channels-0LX4pUbB.js +265 -0
- package/dist/resolve-users-CztOv0Qs.js +120 -0
- package/dist/runtime-DUaw66V_.js +1073 -0
- package/dist/runtime-api.actions.js +3 -0
- package/dist/runtime-api.js +30 -0
- package/dist/runtime-api.lookup.js +7 -0
- package/dist/runtime-api.monitor-CvVKvEXW.js +5 -0
- package/dist/runtime-api.monitor.js +8 -0
- package/dist/runtime-api.send.js +6 -0
- package/dist/runtime-api.threads.js +6 -0
- package/dist/runtime-fC6f4UF2.js +8 -0
- package/dist/runtime-setter-api.js +2 -0
- package/dist/secret-config-contract-B6WW5V88.js +115 -0
- package/dist/secret-contract-api.js +2 -0
- package/dist/security-audit-CnyIQKz6.js +120 -0
- package/dist/security-audit-contract-api.js +2 -0
- package/dist/security-audit.runtime-CQSkjNLu.js +2 -0
- package/dist/security-contract-DLvYOgLM.js +26 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/security-doctor-DepqtNCI.js +18 -0
- package/dist/send-DCtPCHGk.js +881 -0
- package/dist/send.components-Bcgxvm52.js +474 -0
- package/dist/send.outbound-S9t0UuHc.js +330 -0
- package/dist/send.receipt-CDn3GBWC.js +3119 -0
- package/dist/send.shared-D4iBnAmn.js +669 -0
- package/dist/sender-identity-CxCe3_1a.js +43 -0
- package/dist/session-contract-Dwhw3RTY.js +6 -0
- package/dist/session-key-api.js +2 -0
- package/dist/session-key-normalization-CP8dPUid.js +23 -0
- package/dist/setup-entry.js +11 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/shared-AIlvuZXt.js +171 -0
- package/dist/subagent-hooks-8bK-mgiU.js +120 -0
- package/dist/subagent-hooks-api.js +22 -0
- package/dist/system-events-Ba1TklaL.js +34 -0
- package/dist/target-resolver-BrtFQtoK.js +82 -0
- package/dist/targets-DWLLZE2l.js +3 -0
- package/dist/test-api.js +45 -0
- package/dist/thread-binding-api.js +4 -0
- package/dist/thread-bindings-9aKRmZv0.js +255 -0
- package/dist/thread-bindings.discord-api-ssGH5wc2.js +244 -0
- package/dist/thread-bindings.manager-0YBHGemk.js +534 -0
- package/dist/thread-bindings.session-updates-DJZGIwaU.js +54 -0
- package/dist/thread-bindings.state-eTFl-PqJ.js +318 -0
- package/dist/timeouts-CEwuGaWT.js +52 -0
- package/dist/timeouts.js +2 -0
- package/dist/typing-BmJKRpCS.js +14 -0
- package/package.json +19 -7
- package/account-inspect-api.js +0 -7
- package/action-runtime-api.js +0 -7
- package/api.js +0 -7
- package/channel-config-api.js +0 -7
- package/channel-plugin-api.js +0 -7
- package/configured-state.js +0 -7
- package/contract-api.js +0 -7
- package/directory-contract-api.js +0 -7
- package/doctor-contract-api.js +0 -7
- package/index.js +0 -7
- package/runtime-api.actions.js +0 -7
- package/runtime-api.js +0 -7
- package/runtime-api.lookup.js +0 -7
- package/runtime-api.monitor.js +0 -7
- package/runtime-api.send.js +0 -7
- package/runtime-api.threads.js +0 -7
- package/runtime-setter-api.js +0 -7
- package/secret-contract-api.js +0 -7
- package/security-audit-contract-api.js +0 -7
- package/security-contract-api.js +0 -7
- package/session-key-api.js +0 -7
- package/setup-entry.js +0 -7
- package/setup-plugin-api.js +0 -7
- package/subagent-hooks-api.js +0 -7
- package/test-api.js +0 -7
- package/thread-binding-api.js +0 -7
- package/timeouts.js +0 -7
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { a as readDiscordChannelCreateParams, n as isDiscordModerationAction, o as readDiscordChannelEditParams, r as readDiscordModerationCommand, s as readDiscordChannelMoveParams, t as handleDiscordAction } from "./runtime-DUaw66V_.js";
|
|
2
|
+
import "./action-runtime-api.js";
|
|
3
|
+
import { normalizeOptionalString } from "klaw/plugin-sdk/string-coerce-runtime";
|
|
4
|
+
import { readNumberParam, readStringArrayParam, readStringParam } from "klaw/plugin-sdk/agent-runtime";
|
|
5
|
+
//#region extensions/discord/src/actions/handle-action.guild-admin.ts
|
|
6
|
+
async function tryHandleDiscordMessageActionGuildAdmin(params) {
|
|
7
|
+
const { ctx, resolveChannelId } = params;
|
|
8
|
+
const { action, params: actionParams, cfg } = ctx;
|
|
9
|
+
const accountId = ctx.accountId ?? readStringParam(actionParams, "accountId");
|
|
10
|
+
if (action === "member-info") {
|
|
11
|
+
const userId = readStringParam(actionParams, "userId", { required: true });
|
|
12
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
13
|
+
return await handleDiscordAction({
|
|
14
|
+
action: "memberInfo",
|
|
15
|
+
accountId: accountId ?? void 0,
|
|
16
|
+
guildId,
|
|
17
|
+
userId
|
|
18
|
+
}, cfg);
|
|
19
|
+
}
|
|
20
|
+
if (action === "role-info") {
|
|
21
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
22
|
+
return await handleDiscordAction({
|
|
23
|
+
action: "roleInfo",
|
|
24
|
+
accountId: accountId ?? void 0,
|
|
25
|
+
guildId
|
|
26
|
+
}, cfg);
|
|
27
|
+
}
|
|
28
|
+
if (action === "emoji-list") {
|
|
29
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
30
|
+
return await handleDiscordAction({
|
|
31
|
+
action: "emojiList",
|
|
32
|
+
accountId: accountId ?? void 0,
|
|
33
|
+
guildId
|
|
34
|
+
}, cfg);
|
|
35
|
+
}
|
|
36
|
+
if (action === "emoji-upload") {
|
|
37
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
38
|
+
const name = readStringParam(actionParams, "emojiName", { required: true });
|
|
39
|
+
const mediaUrl = readStringParam(actionParams, "media", {
|
|
40
|
+
required: true,
|
|
41
|
+
trim: false
|
|
42
|
+
});
|
|
43
|
+
const roleIds = readStringArrayParam(actionParams, "roleIds");
|
|
44
|
+
return await handleDiscordAction({
|
|
45
|
+
action: "emojiUpload",
|
|
46
|
+
accountId: accountId ?? void 0,
|
|
47
|
+
guildId,
|
|
48
|
+
name,
|
|
49
|
+
mediaUrl,
|
|
50
|
+
roleIds
|
|
51
|
+
}, cfg);
|
|
52
|
+
}
|
|
53
|
+
if (action === "sticker-upload") {
|
|
54
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
55
|
+
const name = readStringParam(actionParams, "stickerName", { required: true });
|
|
56
|
+
const description = readStringParam(actionParams, "stickerDesc", { required: true });
|
|
57
|
+
const tags = readStringParam(actionParams, "stickerTags", { required: true });
|
|
58
|
+
const mediaUrl = readStringParam(actionParams, "media", {
|
|
59
|
+
required: true,
|
|
60
|
+
trim: false
|
|
61
|
+
});
|
|
62
|
+
return await handleDiscordAction({
|
|
63
|
+
action: "stickerUpload",
|
|
64
|
+
accountId: accountId ?? void 0,
|
|
65
|
+
guildId,
|
|
66
|
+
name,
|
|
67
|
+
description,
|
|
68
|
+
tags,
|
|
69
|
+
mediaUrl
|
|
70
|
+
}, cfg);
|
|
71
|
+
}
|
|
72
|
+
if (action === "role-add" || action === "role-remove") {
|
|
73
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
74
|
+
const userId = readStringParam(actionParams, "userId", { required: true });
|
|
75
|
+
const roleId = readStringParam(actionParams, "roleId", { required: true });
|
|
76
|
+
return await handleDiscordAction({
|
|
77
|
+
action: action === "role-add" ? "roleAdd" : "roleRemove",
|
|
78
|
+
accountId: accountId ?? void 0,
|
|
79
|
+
guildId,
|
|
80
|
+
userId,
|
|
81
|
+
roleId
|
|
82
|
+
}, cfg);
|
|
83
|
+
}
|
|
84
|
+
if (action === "channel-info") {
|
|
85
|
+
const channelId = readStringParam(actionParams, "channelId", { required: true });
|
|
86
|
+
return await handleDiscordAction({
|
|
87
|
+
action: "channelInfo",
|
|
88
|
+
accountId: accountId ?? void 0,
|
|
89
|
+
channelId
|
|
90
|
+
}, cfg);
|
|
91
|
+
}
|
|
92
|
+
if (action === "channel-list") {
|
|
93
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
94
|
+
return await handleDiscordAction({
|
|
95
|
+
action: "channelList",
|
|
96
|
+
accountId: accountId ?? void 0,
|
|
97
|
+
guildId
|
|
98
|
+
}, cfg);
|
|
99
|
+
}
|
|
100
|
+
if (action === "channel-create") {
|
|
101
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
102
|
+
return await handleDiscordAction({
|
|
103
|
+
action: "channelCreate",
|
|
104
|
+
accountId: accountId ?? void 0,
|
|
105
|
+
...readDiscordChannelCreateParams({
|
|
106
|
+
...actionParams,
|
|
107
|
+
guildId
|
|
108
|
+
})
|
|
109
|
+
}, cfg);
|
|
110
|
+
}
|
|
111
|
+
if (action === "channel-edit") {
|
|
112
|
+
const channelId = readStringParam(actionParams, "channelId", { required: true });
|
|
113
|
+
return await handleDiscordAction({
|
|
114
|
+
action: "channelEdit",
|
|
115
|
+
accountId: accountId ?? void 0,
|
|
116
|
+
...readDiscordChannelEditParams({
|
|
117
|
+
...actionParams,
|
|
118
|
+
channelId
|
|
119
|
+
})
|
|
120
|
+
}, cfg);
|
|
121
|
+
}
|
|
122
|
+
if (action === "channel-delete") {
|
|
123
|
+
const channelId = readStringParam(actionParams, "channelId", { required: true });
|
|
124
|
+
return await handleDiscordAction({
|
|
125
|
+
action: "channelDelete",
|
|
126
|
+
accountId: accountId ?? void 0,
|
|
127
|
+
channelId
|
|
128
|
+
}, cfg);
|
|
129
|
+
}
|
|
130
|
+
if (action === "channel-move") {
|
|
131
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
132
|
+
const channelId = readStringParam(actionParams, "channelId", { required: true });
|
|
133
|
+
return await handleDiscordAction({
|
|
134
|
+
action: "channelMove",
|
|
135
|
+
accountId: accountId ?? void 0,
|
|
136
|
+
...readDiscordChannelMoveParams({
|
|
137
|
+
...actionParams,
|
|
138
|
+
guildId,
|
|
139
|
+
channelId
|
|
140
|
+
})
|
|
141
|
+
}, cfg);
|
|
142
|
+
}
|
|
143
|
+
if (action === "category-create") {
|
|
144
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
145
|
+
const name = readStringParam(actionParams, "name", { required: true });
|
|
146
|
+
const position = readNumberParam(actionParams, "position", { integer: true });
|
|
147
|
+
return await handleDiscordAction({
|
|
148
|
+
action: "categoryCreate",
|
|
149
|
+
accountId: accountId ?? void 0,
|
|
150
|
+
guildId,
|
|
151
|
+
name,
|
|
152
|
+
position: position ?? void 0
|
|
153
|
+
}, cfg);
|
|
154
|
+
}
|
|
155
|
+
if (action === "category-edit") {
|
|
156
|
+
const categoryId = readStringParam(actionParams, "categoryId", { required: true });
|
|
157
|
+
const name = readStringParam(actionParams, "name");
|
|
158
|
+
const position = readNumberParam(actionParams, "position", { integer: true });
|
|
159
|
+
return await handleDiscordAction({
|
|
160
|
+
action: "categoryEdit",
|
|
161
|
+
accountId: accountId ?? void 0,
|
|
162
|
+
categoryId,
|
|
163
|
+
name: name ?? void 0,
|
|
164
|
+
position: position ?? void 0
|
|
165
|
+
}, cfg);
|
|
166
|
+
}
|
|
167
|
+
if (action === "category-delete") {
|
|
168
|
+
const categoryId = readStringParam(actionParams, "categoryId", { required: true });
|
|
169
|
+
return await handleDiscordAction({
|
|
170
|
+
action: "categoryDelete",
|
|
171
|
+
accountId: accountId ?? void 0,
|
|
172
|
+
categoryId
|
|
173
|
+
}, cfg);
|
|
174
|
+
}
|
|
175
|
+
if (action === "voice-status") {
|
|
176
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
177
|
+
const userId = readStringParam(actionParams, "userId", { required: true });
|
|
178
|
+
return await handleDiscordAction({
|
|
179
|
+
action: "voiceStatus",
|
|
180
|
+
accountId: accountId ?? void 0,
|
|
181
|
+
guildId,
|
|
182
|
+
userId
|
|
183
|
+
}, cfg);
|
|
184
|
+
}
|
|
185
|
+
if (action === "event-list") {
|
|
186
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
187
|
+
return await handleDiscordAction({
|
|
188
|
+
action: "eventList",
|
|
189
|
+
accountId: accountId ?? void 0,
|
|
190
|
+
guildId
|
|
191
|
+
}, cfg);
|
|
192
|
+
}
|
|
193
|
+
if (action === "event-create") {
|
|
194
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
195
|
+
const name = readStringParam(actionParams, "eventName", { required: true });
|
|
196
|
+
const startTime = readStringParam(actionParams, "startTime", { required: true });
|
|
197
|
+
const endTime = readStringParam(actionParams, "endTime");
|
|
198
|
+
const description = readStringParam(actionParams, "desc");
|
|
199
|
+
const channelId = readStringParam(actionParams, "channelId");
|
|
200
|
+
const location = readStringParam(actionParams, "location");
|
|
201
|
+
const entityType = readStringParam(actionParams, "eventType");
|
|
202
|
+
const image = readStringParam(actionParams, "image", { trim: false });
|
|
203
|
+
return await handleDiscordAction({
|
|
204
|
+
action: "eventCreate",
|
|
205
|
+
accountId: accountId ?? void 0,
|
|
206
|
+
guildId,
|
|
207
|
+
name,
|
|
208
|
+
startTime,
|
|
209
|
+
endTime,
|
|
210
|
+
description,
|
|
211
|
+
channelId,
|
|
212
|
+
location,
|
|
213
|
+
entityType,
|
|
214
|
+
image
|
|
215
|
+
}, cfg, { mediaLocalRoots: ctx.mediaLocalRoots });
|
|
216
|
+
}
|
|
217
|
+
if (isDiscordModerationAction(action)) {
|
|
218
|
+
const moderation = readDiscordModerationCommand(action, {
|
|
219
|
+
...actionParams,
|
|
220
|
+
durationMinutes: readNumberParam(actionParams, "durationMin", { integer: true }),
|
|
221
|
+
deleteMessageDays: readNumberParam(actionParams, "deleteDays", { integer: true })
|
|
222
|
+
});
|
|
223
|
+
const senderUserId = normalizeOptionalString(ctx.requesterSenderId);
|
|
224
|
+
return await handleDiscordAction({
|
|
225
|
+
action: moderation.action,
|
|
226
|
+
accountId: accountId ?? void 0,
|
|
227
|
+
guildId: moderation.guildId,
|
|
228
|
+
userId: moderation.userId,
|
|
229
|
+
durationMinutes: moderation.durationMinutes,
|
|
230
|
+
until: moderation.until,
|
|
231
|
+
reason: moderation.reason,
|
|
232
|
+
deleteMessageDays: moderation.deleteMessageDays,
|
|
233
|
+
senderUserId
|
|
234
|
+
}, cfg);
|
|
235
|
+
}
|
|
236
|
+
if (action === "thread-list") {
|
|
237
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
238
|
+
const channelId = readStringParam(actionParams, "channelId");
|
|
239
|
+
const includeArchived = typeof actionParams.includeArchived === "boolean" ? actionParams.includeArchived : void 0;
|
|
240
|
+
const before = readStringParam(actionParams, "before");
|
|
241
|
+
const limit = readNumberParam(actionParams, "limit", { integer: true });
|
|
242
|
+
return await handleDiscordAction({
|
|
243
|
+
action: "threadList",
|
|
244
|
+
accountId: accountId ?? void 0,
|
|
245
|
+
guildId,
|
|
246
|
+
channelId,
|
|
247
|
+
includeArchived,
|
|
248
|
+
before,
|
|
249
|
+
limit
|
|
250
|
+
}, cfg);
|
|
251
|
+
}
|
|
252
|
+
if (action === "thread-reply") {
|
|
253
|
+
const content = readStringParam(actionParams, "message", { required: true });
|
|
254
|
+
const mediaUrl = readStringParam(actionParams, "media", { trim: false }) ?? readStringParam(actionParams, "path", { trim: false }) ?? readStringParam(actionParams, "filePath", { trim: false });
|
|
255
|
+
const replyTo = readStringParam(actionParams, "replyTo");
|
|
256
|
+
const channelId = readStringParam(actionParams, "threadId") ?? resolveChannelId();
|
|
257
|
+
return await handleDiscordAction({
|
|
258
|
+
action: "threadReply",
|
|
259
|
+
accountId: accountId ?? void 0,
|
|
260
|
+
channelId,
|
|
261
|
+
content,
|
|
262
|
+
mediaUrl: mediaUrl ?? void 0,
|
|
263
|
+
replyTo: replyTo ?? void 0
|
|
264
|
+
}, cfg, {
|
|
265
|
+
mediaLocalRoots: ctx.mediaLocalRoots,
|
|
266
|
+
mediaReadFile: ctx.mediaReadFile
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (action === "search") {
|
|
270
|
+
const guildId = readStringParam(actionParams, "guildId", { required: true });
|
|
271
|
+
const query = readStringParam(actionParams, "query", { required: true });
|
|
272
|
+
return await handleDiscordAction({
|
|
273
|
+
action: "searchMessages",
|
|
274
|
+
accountId: accountId ?? void 0,
|
|
275
|
+
guildId,
|
|
276
|
+
content: query,
|
|
277
|
+
channelId: readStringParam(actionParams, "channelId"),
|
|
278
|
+
channelIds: readStringArrayParam(actionParams, "channelIds"),
|
|
279
|
+
authorId: readStringParam(actionParams, "authorId"),
|
|
280
|
+
authorIds: readStringArrayParam(actionParams, "authorIds"),
|
|
281
|
+
limit: readNumberParam(actionParams, "limit", { integer: true })
|
|
282
|
+
}, cfg);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
export { tryHandleDiscordMessageActionGuildAdmin as t };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { h as resolveDiscordOwnerAllowFrom, p as resolveDiscordMemberAllowed } from "./allow-list-B0s7evD7.js";
|
|
2
|
+
//#region extensions/discord/src/monitor/inbound-context.ts
|
|
3
|
+
function createDiscordSupplementalContextAccessChecker(params) {
|
|
4
|
+
return (sender) => {
|
|
5
|
+
if (!params.isGuild) return true;
|
|
6
|
+
return resolveDiscordMemberAllowed({
|
|
7
|
+
userAllowList: params.channelConfig?.users ?? params.guildInfo?.users,
|
|
8
|
+
roleAllowList: params.channelConfig?.roles ?? params.guildInfo?.roles,
|
|
9
|
+
memberRoleIds: sender.memberRoleIds ?? [],
|
|
10
|
+
userId: sender.id ?? "",
|
|
11
|
+
userName: sender.name,
|
|
12
|
+
userTag: sender.tag,
|
|
13
|
+
allowNameMatching: params.allowNameMatching
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function buildDiscordGroupSystemPrompt(channelConfig) {
|
|
18
|
+
const systemPromptParts = [channelConfig?.systemPrompt?.trim() || null].filter((entry) => Boolean(entry));
|
|
19
|
+
return systemPromptParts.length > 0 ? systemPromptParts.join("\n\n") : void 0;
|
|
20
|
+
}
|
|
21
|
+
function buildDiscordUntrustedContext(params) {
|
|
22
|
+
if (!params.isGuild) return;
|
|
23
|
+
const entries = [];
|
|
24
|
+
if (typeof params.channelTopic === "string" && params.channelTopic.trim().length > 0) entries.push({
|
|
25
|
+
label: "Discord channel metadata",
|
|
26
|
+
source: "discord",
|
|
27
|
+
type: "channel_metadata",
|
|
28
|
+
payload: { topic: params.channelTopic.trim() }
|
|
29
|
+
});
|
|
30
|
+
return entries.length > 0 ? entries : void 0;
|
|
31
|
+
}
|
|
32
|
+
function buildDiscordInboundAccessContext(params) {
|
|
33
|
+
return {
|
|
34
|
+
groupSystemPrompt: params.isGuild ? buildDiscordGroupSystemPrompt(params.channelConfig) : void 0,
|
|
35
|
+
untrustedContext: buildDiscordUntrustedContext({
|
|
36
|
+
isGuild: params.isGuild,
|
|
37
|
+
channelTopic: params.channelTopic
|
|
38
|
+
}),
|
|
39
|
+
ownerAllowFrom: resolveDiscordOwnerAllowFrom({
|
|
40
|
+
channelConfig: params.channelConfig,
|
|
41
|
+
guildInfo: params.guildInfo,
|
|
42
|
+
sender: params.sender,
|
|
43
|
+
allowNameMatching: params.allowNameMatching
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { buildDiscordInboundAccessContext as n, createDiscordSupplementalContextAccessChecker as r, buildDiscordGroupSystemPrompt as t };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region extensions/discord/src/inbound-event-delivery.ts
|
|
2
|
+
const DISCORD_INBOUND_EVENT_DELIVERY_KEY = "__klawInboundEventDelivery";
|
|
3
|
+
const registry = /* @__PURE__ */ new Map();
|
|
4
|
+
function normalizeDiscordDeliveryTarget(value) {
|
|
5
|
+
return value.trim().replace(/^discord:/iu, "").replace(/^channel:/iu, "").toLowerCase();
|
|
6
|
+
}
|
|
7
|
+
function resolveDiscordInboundEventDeliveryCorrelationKey(sessionKey, inboundEventKind) {
|
|
8
|
+
const key = sessionKey?.trim();
|
|
9
|
+
if (!key) return;
|
|
10
|
+
return inboundEventKind === "room_event" ? `${key}:room_event` : key;
|
|
11
|
+
}
|
|
12
|
+
function beginDiscordInboundEventDeliveryCorrelation(sessionKey, event, options) {
|
|
13
|
+
const key = resolveDiscordInboundEventDeliveryCorrelationKey(sessionKey, options?.inboundEventKind);
|
|
14
|
+
if (!key) return () => {};
|
|
15
|
+
registry.set(key, event);
|
|
16
|
+
return () => {
|
|
17
|
+
if (registry.get(key) === event) registry.delete(key);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function notifyDiscordInboundEventOutboundSuccess(params) {
|
|
21
|
+
const key = resolveDiscordInboundEventDeliveryCorrelationKey(params.sessionKey, params.inboundEventKind);
|
|
22
|
+
if (!key) return;
|
|
23
|
+
const event = registry.get(key);
|
|
24
|
+
if (!event || normalizeDiscordDeliveryTarget(event.outboundTo) !== normalizeDiscordDeliveryTarget(params.to)) return;
|
|
25
|
+
if (event.outboundAccountId && params.accountId && params.accountId !== event.outboundAccountId) return;
|
|
26
|
+
registry.delete(key);
|
|
27
|
+
event.markInboundEventDelivered();
|
|
28
|
+
}
|
|
29
|
+
function readRecord(value) {
|
|
30
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
31
|
+
}
|
|
32
|
+
function readString(value) {
|
|
33
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
34
|
+
}
|
|
35
|
+
function withDiscordInboundEventDeliveryMetadata(payload, params) {
|
|
36
|
+
const sessionKey = params.sessionKey?.trim();
|
|
37
|
+
if (!sessionKey || params.inboundEventKind !== "room_event") return payload;
|
|
38
|
+
const channelData = readRecord(payload.channelData) ?? {};
|
|
39
|
+
const discordData = readRecord(channelData.discord) ?? {};
|
|
40
|
+
return {
|
|
41
|
+
...payload,
|
|
42
|
+
channelData: {
|
|
43
|
+
...channelData,
|
|
44
|
+
discord: {
|
|
45
|
+
...discordData,
|
|
46
|
+
[DISCORD_INBOUND_EVENT_DELIVERY_KEY]: {
|
|
47
|
+
sessionKey,
|
|
48
|
+
inboundEventKind: params.inboundEventKind
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function notifyDiscordInboundEventOutboundPayloadSuccess(params) {
|
|
55
|
+
const metadata = readRecord(readRecord(readRecord(params.payload.channelData)?.discord)?.[DISCORD_INBOUND_EVENT_DELIVERY_KEY]);
|
|
56
|
+
if (!metadata) return;
|
|
57
|
+
notifyDiscordInboundEventOutboundSuccess({
|
|
58
|
+
sessionKey: readString(metadata.sessionKey),
|
|
59
|
+
inboundEventKind: readString(metadata.inboundEventKind),
|
|
60
|
+
to: params.to,
|
|
61
|
+
accountId: params.accountId
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { withDiscordInboundEventDeliveryMetadata as i, notifyDiscordInboundEventOutboundPayloadSuccess as n, notifyDiscordInboundEventOutboundSuccess as r, beginDiscordInboundEventDeliveryCorrelation as t };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { registerDiscordSubagentHooks } from "./subagent-hooks-api.js";
|
|
2
|
+
import { defineBundledChannelEntry } from "klaw/plugin-sdk/channel-entry-contract";
|
|
3
|
+
//#region extensions/discord/index.ts
|
|
4
|
+
var discord_default = defineBundledChannelEntry({
|
|
5
|
+
id: "discord",
|
|
6
|
+
name: "Discord",
|
|
7
|
+
description: "Discord channel plugin",
|
|
8
|
+
importMetaUrl: import.meta.url,
|
|
9
|
+
plugin: {
|
|
10
|
+
specifier: "./channel-plugin-api.js",
|
|
11
|
+
exportName: "discordPlugin"
|
|
12
|
+
},
|
|
13
|
+
runtime: {
|
|
14
|
+
specifier: "./runtime-setter-api.js",
|
|
15
|
+
exportName: "setDiscordRuntime"
|
|
16
|
+
},
|
|
17
|
+
accountInspect: {
|
|
18
|
+
specifier: "./account-inspect-api.js",
|
|
19
|
+
exportName: "inspectDiscordReadOnlyAccount"
|
|
20
|
+
},
|
|
21
|
+
registerFull(api) {
|
|
22
|
+
registerDiscordSubagentHooks(api);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { discord_default as default };
|