@kodelyth/feishu 2026.5.42 → 2026.6.2

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 (192) hide show
  1. package/klaw.plugin.json +1712 -47
  2. package/package.json +19 -6
  3. package/api.ts +0 -32
  4. package/channel-entry.ts +0 -20
  5. package/channel-plugin-api.ts +0 -1
  6. package/contract-api.ts +0 -16
  7. package/index.ts +0 -82
  8. package/runtime-api.ts +0 -52
  9. package/secret-contract-api.ts +0 -5
  10. package/security-contract-api.ts +0 -1
  11. package/session-key-api.ts +0 -1
  12. package/setup-api.ts +0 -3
  13. package/setup-entry.test.ts +0 -19
  14. package/setup-entry.ts +0 -13
  15. package/src/accounts.test.ts +0 -480
  16. package/src/accounts.ts +0 -333
  17. package/src/agent-config.ts +0 -21
  18. package/src/app-registration.ts +0 -331
  19. package/src/approval-auth.test.ts +0 -24
  20. package/src/approval-auth.ts +0 -25
  21. package/src/async.test.ts +0 -35
  22. package/src/async.ts +0 -104
  23. package/src/audio-preflight.runtime.ts +0 -9
  24. package/src/bitable.test.ts +0 -136
  25. package/src/bitable.ts +0 -762
  26. package/src/bot-content.ts +0 -485
  27. package/src/bot-group-name.test.ts +0 -116
  28. package/src/bot-runtime-api.ts +0 -12
  29. package/src/bot-sender-name.ts +0 -125
  30. package/src/bot.broadcast.test.ts +0 -523
  31. package/src/bot.card-action.test.ts +0 -552
  32. package/src/bot.checkBotMentioned.test.ts +0 -265
  33. package/src/bot.helpers.test.ts +0 -135
  34. package/src/bot.stripBotMention.test.ts +0 -126
  35. package/src/bot.test.ts +0 -3671
  36. package/src/bot.ts +0 -1703
  37. package/src/card-action.ts +0 -447
  38. package/src/card-interaction.test.ts +0 -131
  39. package/src/card-interaction.ts +0 -159
  40. package/src/card-test-helpers.ts +0 -54
  41. package/src/card-ux-approval.ts +0 -65
  42. package/src/card-ux-launcher.test.ts +0 -106
  43. package/src/card-ux-launcher.ts +0 -121
  44. package/src/card-ux-shared.ts +0 -33
  45. package/src/channel-runtime-api.ts +0 -16
  46. package/src/channel.runtime.ts +0 -47
  47. package/src/channel.test.ts +0 -1151
  48. package/src/channel.ts +0 -1423
  49. package/src/chat-schema.ts +0 -25
  50. package/src/chat.test.ts +0 -240
  51. package/src/chat.ts +0 -188
  52. package/src/client-timeout.ts +0 -42
  53. package/src/client.test.ts +0 -447
  54. package/src/client.ts +0 -262
  55. package/src/comment-dispatcher-runtime-api.ts +0 -6
  56. package/src/comment-dispatcher.test.ts +0 -185
  57. package/src/comment-dispatcher.ts +0 -107
  58. package/src/comment-handler-runtime-api.ts +0 -3
  59. package/src/comment-handler.test.ts +0 -592
  60. package/src/comment-handler.ts +0 -303
  61. package/src/comment-reaction.test.ts +0 -138
  62. package/src/comment-reaction.ts +0 -259
  63. package/src/comment-shared.test.ts +0 -183
  64. package/src/comment-shared.ts +0 -406
  65. package/src/comment-target.ts +0 -44
  66. package/src/config-schema.test.ts +0 -326
  67. package/src/config-schema.ts +0 -335
  68. package/src/conversation-id.test.ts +0 -18
  69. package/src/conversation-id.ts +0 -199
  70. package/src/dedup-runtime-api.ts +0 -1
  71. package/src/dedup.ts +0 -141
  72. package/src/dedupe-key.ts +0 -72
  73. package/src/directory.static.ts +0 -61
  74. package/src/directory.test.ts +0 -141
  75. package/src/directory.ts +0 -124
  76. package/src/doc-schema.ts +0 -182
  77. package/src/docx-batch-insert.test.ts +0 -116
  78. package/src/docx-batch-insert.ts +0 -223
  79. package/src/docx-color-text.ts +0 -154
  80. package/src/docx-table-ops.test.ts +0 -53
  81. package/src/docx-table-ops.ts +0 -316
  82. package/src/docx-types.ts +0 -38
  83. package/src/docx.account-selection.test.ts +0 -95
  84. package/src/docx.test.ts +0 -701
  85. package/src/docx.ts +0 -1596
  86. package/src/drive-schema.ts +0 -92
  87. package/src/drive.test.ts +0 -1237
  88. package/src/drive.ts +0 -829
  89. package/src/dynamic-agent.test.ts +0 -155
  90. package/src/dynamic-agent.ts +0 -143
  91. package/src/event-types.ts +0 -45
  92. package/src/external-keys.test.ts +0 -20
  93. package/src/external-keys.ts +0 -19
  94. package/src/lifecycle.test-support.ts +0 -220
  95. package/src/media.test.ts +0 -955
  96. package/src/media.ts +0 -1105
  97. package/src/mention-target.types.ts +0 -5
  98. package/src/mention.ts +0 -114
  99. package/src/message-action-contract.ts +0 -13
  100. package/src/monitor-state-runtime-api.ts +0 -7
  101. package/src/monitor-transport-runtime-api.ts +0 -10
  102. package/src/monitor.account.ts +0 -492
  103. package/src/monitor.acp-init-failure.lifecycle.test-support.ts +0 -219
  104. package/src/monitor.bot-identity.ts +0 -86
  105. package/src/monitor.bot-menu-handler.ts +0 -165
  106. package/src/monitor.bot-menu.lifecycle.test-support.ts +0 -224
  107. package/src/monitor.bot-menu.test.ts +0 -188
  108. package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +0 -264
  109. package/src/monitor.card-action.lifecycle.test-support.ts +0 -421
  110. package/src/monitor.cleanup.test.ts +0 -383
  111. package/src/monitor.comment-notice-handler.ts +0 -105
  112. package/src/monitor.comment.test.ts +0 -967
  113. package/src/monitor.comment.ts +0 -1386
  114. package/src/monitor.lifecycle.test.ts +0 -4
  115. package/src/monitor.message-handler.ts +0 -350
  116. package/src/monitor.reaction.lifecycle.test-support.ts +0 -68
  117. package/src/monitor.reaction.test.ts +0 -739
  118. package/src/monitor.startup.test.ts +0 -213
  119. package/src/monitor.startup.ts +0 -74
  120. package/src/monitor.state.defaults.test.ts +0 -46
  121. package/src/monitor.state.ts +0 -170
  122. package/src/monitor.synthetic-error.ts +0 -18
  123. package/src/monitor.test-mocks.ts +0 -46
  124. package/src/monitor.transport.ts +0 -451
  125. package/src/monitor.ts +0 -100
  126. package/src/monitor.webhook-e2e.test.ts +0 -279
  127. package/src/monitor.webhook-security.test.ts +0 -389
  128. package/src/monitor.webhook.test-helpers.ts +0 -116
  129. package/src/outbound-runtime-api.ts +0 -1
  130. package/src/outbound.test.ts +0 -1118
  131. package/src/outbound.ts +0 -785
  132. package/src/perm-schema.ts +0 -52
  133. package/src/perm.ts +0 -170
  134. package/src/pins.ts +0 -108
  135. package/src/policy.test.ts +0 -223
  136. package/src/policy.ts +0 -318
  137. package/src/post.test.ts +0 -105
  138. package/src/post.ts +0 -275
  139. package/src/probe.test.ts +0 -283
  140. package/src/probe.ts +0 -166
  141. package/src/processing-claims.ts +0 -59
  142. package/src/qr-terminal.ts +0 -1
  143. package/src/reactions.ts +0 -123
  144. package/src/reasoning-preview.test.ts +0 -113
  145. package/src/reasoning-preview.ts +0 -28
  146. package/src/reply-dispatcher-runtime-api.ts +0 -7
  147. package/src/reply-dispatcher.test.ts +0 -1513
  148. package/src/reply-dispatcher.ts +0 -748
  149. package/src/runtime.ts +0 -9
  150. package/src/secret-contract.ts +0 -145
  151. package/src/secret-input.ts +0 -1
  152. package/src/security-audit-shared.ts +0 -69
  153. package/src/security-audit.test.ts +0 -59
  154. package/src/security-audit.ts +0 -1
  155. package/src/send-result.ts +0 -80
  156. package/src/send-target.test.ts +0 -86
  157. package/src/send-target.ts +0 -35
  158. package/src/send.reply-fallback.test.ts +0 -417
  159. package/src/send.test.ts +0 -621
  160. package/src/send.ts +0 -861
  161. package/src/sequential-key.test.ts +0 -72
  162. package/src/sequential-key.ts +0 -25
  163. package/src/sequential-queue.test.ts +0 -165
  164. package/src/sequential-queue.ts +0 -86
  165. package/src/session-conversation.ts +0 -42
  166. package/src/session-route.ts +0 -48
  167. package/src/setup-core.ts +0 -51
  168. package/src/setup-surface.test.ts +0 -484
  169. package/src/setup-surface.ts +0 -618
  170. package/src/streaming-card.test.ts +0 -397
  171. package/src/streaming-card.ts +0 -571
  172. package/src/subagent-hooks.test.ts +0 -627
  173. package/src/subagent-hooks.ts +0 -413
  174. package/src/targets.ts +0 -97
  175. package/src/test-support/lifecycle-test-support.ts +0 -454
  176. package/src/thread-bindings.test.ts +0 -180
  177. package/src/thread-bindings.ts +0 -331
  178. package/src/tool-account-routing.test.ts +0 -250
  179. package/src/tool-account.test.ts +0 -44
  180. package/src/tool-account.ts +0 -93
  181. package/src/tool-factory-test-harness.ts +0 -79
  182. package/src/tool-result.test.ts +0 -32
  183. package/src/tool-result.ts +0 -16
  184. package/src/tools-config.test.ts +0 -21
  185. package/src/tools-config.ts +0 -22
  186. package/src/types.ts +0 -106
  187. package/src/typing.test.ts +0 -144
  188. package/src/typing.ts +0 -214
  189. package/src/wiki-schema.ts +0 -69
  190. package/src/wiki.ts +0 -270
  191. package/subagent-hooks-api.ts +0 -31
  192. package/tsconfig.json +0 -16
@@ -1,4 +0,0 @@
1
- import "./monitor.acp-init-failure.lifecycle.test-support.js";
2
- import "./monitor.bot-menu.lifecycle.test-support.js";
3
- import "./monitor.broadcast.reply-once.lifecycle.test-support.js";
4
- import "./monitor.card-action.lifecycle.test-support.js";
@@ -1,350 +0,0 @@
1
- import type { ClawdbotConfig, HistoryEntry, PluginRuntime, RuntimeEnv } from "../runtime-api.js";
2
- import { resolveFeishuMessageDedupeKey } from "./dedupe-key.js";
3
- import type { FeishuMessageEvent } from "./event-types.js";
4
- import { isMentionForwardRequest } from "./mention.js";
5
- import {
6
- releaseFeishuMessageProcessing,
7
- tryBeginFeishuMessageProcessing,
8
- } from "./processing-claims.js";
9
- import { createSequentialQueue } from "./sequential-queue.js";
10
- import type { FeishuChatType } from "./types.js";
11
-
12
- function isRecord(value: unknown): value is Record<string, unknown> {
13
- return typeof value === "object" && value !== null && !Array.isArray(value);
14
- }
15
-
16
- function readString(value: unknown): string | undefined {
17
- return typeof value === "string" ? value : undefined;
18
- }
19
-
20
- type FeishuMessageReceiveHandlerContext = {
21
- cfg: ClawdbotConfig;
22
- core: PluginRuntime;
23
- accountId: string;
24
- runtime?: RuntimeEnv;
25
- chatHistories: Map<string, HistoryEntry[]>;
26
- fireAndForget?: boolean;
27
- handleMessage: (params: {
28
- cfg: ClawdbotConfig;
29
- event: FeishuMessageEvent;
30
- botOpenId?: string;
31
- botName?: string;
32
- runtime?: RuntimeEnv;
33
- chatHistories?: Map<string, HistoryEntry[]>;
34
- accountId?: string;
35
- processingClaimHeld?: boolean;
36
- }) => Promise<void>;
37
- resolveDebounceText: (params: {
38
- event: FeishuMessageEvent;
39
- botOpenId?: string;
40
- botName?: string;
41
- }) => string;
42
- hasProcessedMessage: (
43
- messageId: string | undefined | null,
44
- namespace: string,
45
- log?: (...args: unknown[]) => void,
46
- ) => Promise<boolean>;
47
- recordProcessedMessage: (
48
- messageId: string | undefined | null,
49
- namespace: string,
50
- log?: (...args: unknown[]) => void,
51
- ) => Promise<boolean>;
52
- getBotOpenId?: (accountId: string) => string | undefined;
53
- getBotName?: (accountId: string) => string | undefined;
54
- resolveSequentialKey?: (params: {
55
- accountId: string;
56
- event: FeishuMessageEvent;
57
- botOpenId?: string;
58
- botName?: string;
59
- }) => string;
60
- };
61
-
62
- function normalizeFeishuChatType(value: unknown): FeishuChatType | undefined {
63
- return value === "group" || value === "topic_group" || value === "private" || value === "p2p"
64
- ? value
65
- : undefined;
66
- }
67
-
68
- function parseFeishuMessageEventPayload(value: unknown): FeishuMessageEvent | null {
69
- if (!isRecord(value)) {
70
- return null;
71
- }
72
- const sender = value.sender;
73
- const message = value.message;
74
- if (!isRecord(sender) || !isRecord(message)) {
75
- return null;
76
- }
77
- const senderId = sender.sender_id;
78
- if (!isRecord(senderId)) {
79
- return null;
80
- }
81
- const messageId = readString(message.message_id);
82
- const chatId = readString(message.chat_id);
83
- const chatType = normalizeFeishuChatType(message.chat_type);
84
- const messageType = readString(message.message_type);
85
- const content = readString(message.content);
86
- if (!messageId || !chatId || !chatType || !messageType || !content) {
87
- return null;
88
- }
89
- return value as FeishuMessageEvent;
90
- }
91
-
92
- function mergeFeishuDebounceMentions(
93
- entries: FeishuMessageEvent[],
94
- ): FeishuMessageEvent["message"]["mentions"] | undefined {
95
- const merged = new Map<string, NonNullable<FeishuMessageEvent["message"]["mentions"]>[number]>();
96
- for (const entry of entries) {
97
- for (const mention of entry.message.mentions ?? []) {
98
- const stableId =
99
- mention.id.open_id?.trim() || mention.id.user_id?.trim() || mention.id.union_id?.trim();
100
- const mentionName = mention.name?.trim();
101
- const mentionKey = mention.key?.trim();
102
- const fallback =
103
- mentionName && mentionKey ? `${mentionName}|${mentionKey}` : mentionName || mentionKey;
104
- const key = stableId || fallback;
105
- if (!key || merged.has(key)) {
106
- continue;
107
- }
108
- merged.set(key, mention);
109
- }
110
- }
111
- return merged.size > 0 ? Array.from(merged.values()) : undefined;
112
- }
113
-
114
- function dedupeFeishuDebounceEntriesByDedupeKey(
115
- entries: FeishuMessageEvent[],
116
- ): FeishuMessageEvent[] {
117
- const seen = new Set<string>();
118
- const deduped: FeishuMessageEvent[] = [];
119
- for (const entry of entries) {
120
- const dedupeKey = resolveFeishuMessageDedupeKey(entry);
121
- if (!dedupeKey) {
122
- deduped.push(entry);
123
- continue;
124
- }
125
- if (seen.has(dedupeKey)) {
126
- continue;
127
- }
128
- seen.add(dedupeKey);
129
- deduped.push(entry);
130
- }
131
- return deduped;
132
- }
133
-
134
- function resolveFeishuDebounceMentions(params: {
135
- entries: FeishuMessageEvent[];
136
- botOpenId?: string;
137
- }): FeishuMessageEvent["message"]["mentions"] | undefined {
138
- const { entries, botOpenId } = params;
139
- if (entries.length === 0) {
140
- return undefined;
141
- }
142
- for (let index = entries.length - 1; index >= 0; index -= 1) {
143
- const entry = entries[index];
144
- if (isMentionForwardRequest(entry, botOpenId)) {
145
- return mergeFeishuDebounceMentions([entry]);
146
- }
147
- }
148
- const merged = mergeFeishuDebounceMentions(entries);
149
- if (!merged) {
150
- return undefined;
151
- }
152
- const normalizedBotOpenId = botOpenId?.trim();
153
- if (!normalizedBotOpenId) {
154
- return undefined;
155
- }
156
- const botMentions = merged.filter(
157
- (mention) => mention.id.open_id?.trim() === normalizedBotOpenId,
158
- );
159
- return botMentions.length > 0 ? botMentions : undefined;
160
- }
161
-
162
- export function createFeishuMessageReceiveHandler({
163
- cfg,
164
- core,
165
- accountId,
166
- runtime,
167
- chatHistories,
168
- fireAndForget,
169
- handleMessage,
170
- resolveDebounceText: resolveText,
171
- hasProcessedMessage,
172
- recordProcessedMessage,
173
- getBotOpenId = () => undefined,
174
- getBotName = () => undefined,
175
- resolveSequentialKey = ({ accountId, event }) =>
176
- `feishu:${accountId}:${event.message.chat_id?.trim() || "unknown"}`,
177
- }: FeishuMessageReceiveHandlerContext): (data: unknown) => Promise<void> {
178
- const inboundDebounceMs = core.channel.debounce.resolveInboundDebounceMs({
179
- cfg,
180
- channel: "feishu",
181
- });
182
- const log = runtime?.log ?? console.log;
183
- const error = runtime?.error ?? console.error;
184
- const enqueue = createSequentialQueue({
185
- onTaskTimeout: (key, timeoutMs) => {
186
- log(
187
- `feishu[${accountId}]: per-chat task exceeded ${timeoutMs}ms cap (key=${key}); evicting from queue so later same-key messages can proceed (#70133)`,
188
- );
189
- },
190
- });
191
-
192
- const dispatchFeishuMessage = async (event: FeishuMessageEvent) => {
193
- const sequentialKey = resolveSequentialKey({
194
- accountId,
195
- event,
196
- botOpenId: getBotOpenId(accountId),
197
- botName: getBotName(accountId),
198
- });
199
- const task = () =>
200
- handleMessage({
201
- cfg,
202
- event,
203
- botOpenId: getBotOpenId(accountId),
204
- botName: getBotName(accountId),
205
- runtime,
206
- chatHistories,
207
- accountId,
208
- processingClaimHeld: true,
209
- });
210
- await enqueue(sequentialKey, task);
211
- };
212
-
213
- const resolveSenderDebounceId = (event: FeishuMessageEvent): string | undefined => {
214
- const senderId =
215
- event.sender.sender_id.open_id?.trim() || event.sender.sender_id.user_id?.trim();
216
- return senderId || undefined;
217
- };
218
-
219
- const resolveDebounceText = (event: FeishuMessageEvent): string => {
220
- return resolveText({
221
- event,
222
- botOpenId: getBotOpenId(accountId),
223
- botName: getBotName(accountId),
224
- }).trim();
225
- };
226
-
227
- const recordSuppressedMessageIds = async (
228
- entries: FeishuMessageEvent[],
229
- dispatchDedupeKey?: string,
230
- ) => {
231
- const keepDedupeKey = dispatchDedupeKey?.trim();
232
- const suppressedIds = new Set(
233
- entries
234
- .map((entry) => resolveFeishuMessageDedupeKey(entry))
235
- .filter((id): id is string => Boolean(id) && (!keepDedupeKey || id !== keepDedupeKey)),
236
- );
237
- for (const messageId of suppressedIds) {
238
- try {
239
- await recordProcessedMessage(messageId, accountId, log);
240
- } catch (err) {
241
- error(
242
- `feishu[${accountId}]: failed to record merged dedupe id ${messageId}: ${String(err)}`,
243
- );
244
- }
245
- }
246
- };
247
-
248
- const inboundDebouncer = core.channel.debounce.createInboundDebouncer<FeishuMessageEvent>({
249
- debounceMs: inboundDebounceMs,
250
- buildKey: (event) => {
251
- const chatId = event.message.chat_id?.trim();
252
- const senderId = resolveSenderDebounceId(event);
253
- if (!chatId || !senderId) {
254
- return null;
255
- }
256
- const rootId = event.message.root_id?.trim();
257
- const threadKey = rootId ? `thread:${rootId}` : "chat";
258
- return `feishu:${accountId}:${chatId}:${threadKey}:${senderId}`;
259
- },
260
- shouldDebounce: (event) => {
261
- if (event.message.message_type !== "text") {
262
- return false;
263
- }
264
- const text = resolveDebounceText(event);
265
- return Boolean(text) && !core.channel.text.hasControlCommand(text, cfg);
266
- },
267
- onFlush: async (entries) => {
268
- const last = entries.at(-1);
269
- if (!last) {
270
- return;
271
- }
272
- if (entries.length === 1) {
273
- await dispatchFeishuMessage(last);
274
- return;
275
- }
276
- const dedupedEntries = dedupeFeishuDebounceEntriesByDedupeKey(entries);
277
- const freshEntries: FeishuMessageEvent[] = [];
278
- for (const entry of dedupedEntries) {
279
- if (!(await hasProcessedMessage(resolveFeishuMessageDedupeKey(entry), accountId, log))) {
280
- freshEntries.push(entry);
281
- }
282
- }
283
- const dispatchEntry = freshEntries.at(-1);
284
- if (!dispatchEntry) {
285
- return;
286
- }
287
- await recordSuppressedMessageIds(
288
- dedupedEntries,
289
- resolveFeishuMessageDedupeKey(dispatchEntry),
290
- );
291
- const combinedText = freshEntries
292
- .map((entry) => resolveDebounceText(entry))
293
- .filter(Boolean)
294
- .join("\n");
295
- const mergedMentions = resolveFeishuDebounceMentions({
296
- entries: freshEntries,
297
- botOpenId: getBotOpenId(accountId),
298
- });
299
- await dispatchFeishuMessage({
300
- ...dispatchEntry,
301
- message: {
302
- ...dispatchEntry.message,
303
- ...(combinedText.trim()
304
- ? {
305
- message_type: "text",
306
- content: JSON.stringify({ text: combinedText }),
307
- }
308
- : {}),
309
- mentions: mergedMentions ?? dispatchEntry.message.mentions,
310
- },
311
- });
312
- },
313
- onError: (err, entries) => {
314
- for (const entry of entries) {
315
- releaseFeishuMessageProcessing(resolveFeishuMessageDedupeKey(entry), accountId);
316
- }
317
- error(`feishu[${accountId}]: inbound debounce flush failed: ${String(err)}`);
318
- },
319
- });
320
-
321
- return async (data) => {
322
- const event = parseFeishuMessageEventPayload(data);
323
- if (!event) {
324
- error(`feishu[${accountId}]: ignoring malformed message event payload`);
325
- return;
326
- }
327
- const messageId = event.message?.message_id?.trim();
328
- const messageDedupeKey = resolveFeishuMessageDedupeKey(event);
329
- if (!tryBeginFeishuMessageProcessing(messageDedupeKey, accountId)) {
330
- log(`feishu[${accountId}]: dropping duplicate event for message ${messageId}`);
331
- return;
332
- }
333
- const processMessage = async () => {
334
- await inboundDebouncer.enqueue(event);
335
- };
336
- if (fireAndForget) {
337
- void processMessage().catch((err) => {
338
- releaseFeishuMessageProcessing(messageDedupeKey, accountId);
339
- error(`feishu[${accountId}]: error handling message: ${String(err)}`);
340
- });
341
- return;
342
- }
343
- try {
344
- await processMessage();
345
- } catch (err) {
346
- releaseFeishuMessageProcessing(messageDedupeKey, accountId);
347
- error(`feishu[${accountId}]: error handling message: ${String(err)}`);
348
- }
349
- };
350
- }
@@ -1,68 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import type { ClawdbotConfig } from "../runtime-api.js";
3
- import {
4
- resolveReactionSyntheticEvent,
5
- type FeishuReactionCreatedEvent,
6
- } from "./monitor.account.js";
7
-
8
- const cfg = {} as ClawdbotConfig;
9
-
10
- function makeReactionEvent(
11
- overrides: Partial<FeishuReactionCreatedEvent> = {},
12
- ): FeishuReactionCreatedEvent {
13
- return {
14
- message_id: "om_msg1",
15
- reaction_type: { emoji_type: "THUMBSUP" },
16
- operator_type: "user",
17
- user_id: { open_id: "ou_user1" },
18
- ...overrides,
19
- };
20
- }
21
-
22
- describe("Feishu reaction lifecycle", () => {
23
- it("builds a created synthetic interaction payload", async () => {
24
- const result = await resolveReactionSyntheticEvent({
25
- cfg,
26
- accountId: "default",
27
- event: makeReactionEvent({ user_id: { open_id: "ou_user1", user_id: "on_user1" } }),
28
- botOpenId: "ou_bot",
29
- fetchMessage: async () => ({
30
- messageId: "om_msg1",
31
- chatId: "oc_group_1",
32
- chatType: "group",
33
- senderOpenId: "ou_bot",
34
- senderType: "app",
35
- content: "hello",
36
- contentType: "text",
37
- }),
38
- uuid: () => "fixed-uuid",
39
- });
40
-
41
- expect(result?.sender.sender_id).toEqual({ open_id: "ou_user1", user_id: "on_user1" });
42
- expect(result?.message.content).toBe('{"text":"[reacted with THUMBSUP to message om_msg1]"}');
43
- });
44
-
45
- it("builds a deleted synthetic interaction payload", async () => {
46
- const result = await resolveReactionSyntheticEvent({
47
- cfg,
48
- accountId: "default",
49
- event: makeReactionEvent(),
50
- botOpenId: "ou_bot",
51
- fetchMessage: async () => ({
52
- messageId: "om_msg1",
53
- chatId: "oc_group_1",
54
- chatType: "group",
55
- senderOpenId: "ou_bot",
56
- senderType: "app",
57
- content: "hello",
58
- contentType: "text",
59
- }),
60
- uuid: () => "fixed-uuid",
61
- action: "deleted",
62
- });
63
-
64
- expect(result?.message.content).toBe(
65
- '{"text":"[removed reaction THUMBSUP from message om_msg1]"}',
66
- );
67
- });
68
- });