@openclaw/feishu 2026.3.13 → 2026.5.2-beta.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 (187) hide show
  1. package/api.ts +31 -0
  2. package/channel-entry.ts +20 -0
  3. package/channel-plugin-api.ts +1 -0
  4. package/contract-api.ts +16 -0
  5. package/index.ts +70 -53
  6. package/openclaw.plugin.json +1827 -4
  7. package/package.json +32 -7
  8. package/runtime-api.ts +55 -0
  9. package/secret-contract-api.ts +5 -0
  10. package/security-contract-api.ts +1 -0
  11. package/session-key-api.ts +1 -0
  12. package/setup-api.ts +3 -0
  13. package/setup-entry.test.ts +14 -0
  14. package/setup-entry.ts +13 -0
  15. package/src/accounts.test.ts +95 -7
  16. package/src/accounts.ts +199 -117
  17. package/src/app-registration.ts +331 -0
  18. package/src/approval-auth.test.ts +24 -0
  19. package/src/approval-auth.ts +25 -0
  20. package/src/async.test.ts +35 -0
  21. package/src/async.ts +43 -1
  22. package/src/audio-preflight.runtime.ts +9 -0
  23. package/src/bitable.test.ts +131 -0
  24. package/src/bitable.ts +59 -22
  25. package/src/bot-content.ts +474 -0
  26. package/src/bot-group-name.test.ts +108 -0
  27. package/src/bot-runtime-api.ts +12 -0
  28. package/src/bot-sender-name.ts +125 -0
  29. package/src/bot.broadcast.test.ts +463 -0
  30. package/src/bot.card-action.test.ts +519 -5
  31. package/src/bot.checkBotMentioned.test.ts +92 -20
  32. package/src/bot.helpers.test.ts +118 -0
  33. package/src/bot.stripBotMention.test.ts +13 -21
  34. package/src/bot.test.ts +1334 -401
  35. package/src/bot.ts +778 -775
  36. package/src/card-action.ts +408 -40
  37. package/src/card-interaction.test.ts +129 -0
  38. package/src/card-interaction.ts +159 -0
  39. package/src/card-test-helpers.ts +47 -0
  40. package/src/card-ux-approval.ts +65 -0
  41. package/src/card-ux-launcher.test.ts +99 -0
  42. package/src/card-ux-launcher.ts +121 -0
  43. package/src/card-ux-shared.ts +33 -0
  44. package/src/channel-runtime-api.ts +16 -0
  45. package/src/channel.runtime.ts +47 -0
  46. package/src/channel.test.ts +914 -3
  47. package/src/channel.ts +1253 -309
  48. package/src/chat-schema.ts +5 -4
  49. package/src/chat.test.ts +135 -28
  50. package/src/chat.ts +68 -10
  51. package/src/client.test.ts +212 -103
  52. package/src/client.ts +115 -21
  53. package/src/comment-dispatcher-runtime-api.ts +6 -0
  54. package/src/comment-dispatcher.test.ts +169 -0
  55. package/src/comment-dispatcher.ts +107 -0
  56. package/src/comment-handler-runtime-api.ts +3 -0
  57. package/src/comment-handler.test.ts +486 -0
  58. package/src/comment-handler.ts +309 -0
  59. package/src/comment-reaction.test.ts +166 -0
  60. package/src/comment-reaction.ts +259 -0
  61. package/src/comment-shared.test.ts +182 -0
  62. package/src/comment-shared.ts +406 -0
  63. package/src/comment-target.ts +44 -0
  64. package/src/config-schema.test.ts +63 -1
  65. package/src/config-schema.ts +31 -4
  66. package/src/conversation-id.test.ts +18 -0
  67. package/src/conversation-id.ts +199 -0
  68. package/src/dedup-runtime-api.ts +1 -0
  69. package/src/dedup.ts +33 -95
  70. package/src/directory.static.ts +61 -0
  71. package/src/directory.test.ts +116 -20
  72. package/src/directory.ts +60 -92
  73. package/src/doc-schema.ts +1 -1
  74. package/src/docx-batch-insert.test.ts +39 -38
  75. package/src/docx-batch-insert.ts +55 -19
  76. package/src/docx-color-text.ts +9 -4
  77. package/src/docx-table-ops.test.ts +53 -0
  78. package/src/docx-table-ops.ts +52 -34
  79. package/src/docx-types.ts +38 -0
  80. package/src/docx.account-selection.test.ts +12 -3
  81. package/src/docx.test.ts +314 -74
  82. package/src/docx.ts +278 -122
  83. package/src/drive-schema.ts +47 -1
  84. package/src/drive.test.ts +1219 -0
  85. package/src/drive.ts +614 -13
  86. package/src/dynamic-agent.ts +10 -4
  87. package/src/event-types.ts +45 -0
  88. package/src/external-keys.ts +1 -1
  89. package/src/lifecycle.test-support.ts +220 -0
  90. package/src/media.test.ts +403 -26
  91. package/src/media.ts +509 -132
  92. package/src/mention-target.types.ts +5 -0
  93. package/src/mention.ts +32 -51
  94. package/src/message-action-contract.ts +13 -0
  95. package/src/monitor-state-runtime-api.ts +7 -0
  96. package/src/monitor-transport-runtime-api.ts +7 -0
  97. package/src/monitor.account.ts +218 -312
  98. package/src/monitor.acp-init-failure.lifecycle.test-support.ts +219 -0
  99. package/src/monitor.bot-identity.ts +86 -0
  100. package/src/monitor.bot-menu-handler.ts +165 -0
  101. package/src/monitor.bot-menu.lifecycle.test-support.ts +224 -0
  102. package/src/monitor.bot-menu.test.ts +178 -0
  103. package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +264 -0
  104. package/src/monitor.card-action.lifecycle.test-support.ts +373 -0
  105. package/src/monitor.cleanup.test.ts +376 -0
  106. package/src/monitor.comment-notice-handler.ts +105 -0
  107. package/src/monitor.comment.test.ts +937 -0
  108. package/src/monitor.comment.ts +1386 -0
  109. package/src/monitor.lifecycle.test.ts +4 -0
  110. package/src/monitor.message-handler.ts +339 -0
  111. package/src/monitor.reaction.lifecycle.test-support.ts +68 -0
  112. package/src/monitor.reaction.test.ts +108 -48
  113. package/src/monitor.startup.test.ts +11 -9
  114. package/src/monitor.startup.ts +26 -16
  115. package/src/monitor.state.ts +20 -5
  116. package/src/monitor.synthetic-error.ts +18 -0
  117. package/src/monitor.test-mocks.ts +2 -2
  118. package/src/monitor.transport.ts +220 -60
  119. package/src/monitor.ts +15 -10
  120. package/src/monitor.webhook-e2e.test.ts +65 -7
  121. package/src/monitor.webhook-security.test.ts +122 -0
  122. package/src/monitor.webhook.test-helpers.ts +44 -26
  123. package/src/outbound-runtime-api.ts +1 -0
  124. package/src/outbound.test.ts +616 -37
  125. package/src/outbound.ts +623 -81
  126. package/src/perm-schema.ts +1 -1
  127. package/src/perm.ts +1 -7
  128. package/src/pins.ts +108 -0
  129. package/src/policy.test.ts +297 -117
  130. package/src/policy.ts +142 -29
  131. package/src/post.ts +7 -6
  132. package/src/probe.test.ts +14 -9
  133. package/src/probe.ts +26 -16
  134. package/src/processing-claims.ts +59 -0
  135. package/src/qr-terminal.ts +1 -0
  136. package/src/reactions.ts +4 -34
  137. package/src/reasoning-preview.test.ts +59 -0
  138. package/src/reasoning-preview.ts +20 -0
  139. package/src/reply-dispatcher-runtime-api.ts +7 -0
  140. package/src/reply-dispatcher.test.ts +660 -29
  141. package/src/reply-dispatcher.ts +407 -154
  142. package/src/runtime.ts +6 -3
  143. package/src/secret-contract.ts +145 -0
  144. package/src/secret-input.ts +1 -13
  145. package/src/security-audit-shared.ts +69 -0
  146. package/src/security-audit.test.ts +61 -0
  147. package/src/security-audit.ts +1 -0
  148. package/src/send-result.ts +1 -1
  149. package/src/send-target.test.ts +9 -3
  150. package/src/send-target.ts +10 -4
  151. package/src/send.reply-fallback.test.ts +105 -2
  152. package/src/send.test.ts +386 -4
  153. package/src/send.ts +414 -95
  154. package/src/sequential-key.test.ts +72 -0
  155. package/src/sequential-key.ts +28 -0
  156. package/src/sequential-queue.test.ts +92 -0
  157. package/src/sequential-queue.ts +16 -0
  158. package/src/session-conversation.ts +42 -0
  159. package/src/session-route.ts +48 -0
  160. package/src/setup-core.ts +51 -0
  161. package/src/{onboarding.test.ts → setup-surface.test.ts} +52 -21
  162. package/src/setup-surface.ts +581 -0
  163. package/src/streaming-card.test.ts +138 -2
  164. package/src/streaming-card.ts +134 -18
  165. package/src/subagent-hooks.test.ts +603 -0
  166. package/src/subagent-hooks.ts +397 -0
  167. package/src/targets.ts +3 -13
  168. package/src/test-support/lifecycle-test-support.ts +453 -0
  169. package/src/thread-bindings.test.ts +143 -0
  170. package/src/thread-bindings.ts +330 -0
  171. package/src/tool-account-routing.test.ts +66 -8
  172. package/src/tool-account.test.ts +44 -0
  173. package/src/tool-account.ts +40 -17
  174. package/src/tool-factory-test-harness.ts +11 -8
  175. package/src/tool-result.ts +3 -1
  176. package/src/tools-config.ts +1 -1
  177. package/src/types.ts +16 -15
  178. package/src/typing.ts +10 -6
  179. package/src/wiki-schema.ts +1 -1
  180. package/src/wiki.ts +1 -7
  181. package/subagent-hooks-api.ts +31 -0
  182. package/tsconfig.json +16 -0
  183. package/src/feishu-command-handler.ts +0 -59
  184. package/src/onboarding.status.test.ts +0 -25
  185. package/src/onboarding.ts +0 -489
  186. package/src/send-message.ts +0 -71
  187. package/src/targets.test.ts +0 -70
@@ -0,0 +1,397 @@
1
+ import {
2
+ normalizeOptionalLowercaseString,
3
+ normalizeOptionalString,
4
+ } from "openclaw/plugin-sdk/text-runtime";
5
+ import { buildFeishuConversationId, parseFeishuConversationId } from "./conversation-id.js";
6
+ import { normalizeFeishuTarget } from "./targets.js";
7
+ import { getFeishuThreadBindingManager } from "./thread-bindings.js";
8
+
9
+ function summarizeError(err: unknown): string {
10
+ if (err instanceof Error) {
11
+ return err.message;
12
+ }
13
+ if (typeof err === "string") {
14
+ return err;
15
+ }
16
+ return "error";
17
+ }
18
+
19
+ function stripProviderPrefix(raw: string): string {
20
+ return raw.replace(/^(feishu|lark):/i, "").trim();
21
+ }
22
+
23
+ function resolveFeishuRequesterConversation(params: {
24
+ accountId?: string;
25
+ to?: string;
26
+ threadId?: string | number;
27
+ requesterSessionKey?: string;
28
+ }): {
29
+ accountId: string;
30
+ conversationId: string;
31
+ parentConversationId?: string;
32
+ } | null {
33
+ const manager = getFeishuThreadBindingManager(params.accountId);
34
+ if (!manager) {
35
+ return null;
36
+ }
37
+ const rawTo = params.to?.trim();
38
+ const withoutProviderPrefix = rawTo ? stripProviderPrefix(rawTo) : "";
39
+ const normalizedTarget = rawTo ? normalizeFeishuTarget(rawTo) : null;
40
+ const threadId =
41
+ params.threadId != null && params.threadId !== "" ? String(params.threadId).trim() : "";
42
+ const isChatTarget = /^(chat|group|channel):/i.test(withoutProviderPrefix);
43
+ const parsedRequesterTopic =
44
+ normalizedTarget && threadId && isChatTarget
45
+ ? parseFeishuConversationId({
46
+ conversationId: buildFeishuConversationId({
47
+ chatId: normalizedTarget,
48
+ scope: "group_topic",
49
+ topicId: threadId,
50
+ }),
51
+ parentConversationId: normalizedTarget,
52
+ })
53
+ : null;
54
+ const requesterSessionKey = params.requesterSessionKey?.trim();
55
+ if (requesterSessionKey) {
56
+ const existingBindings = manager.listBySessionKey(requesterSessionKey);
57
+ if (existingBindings.length === 1) {
58
+ const existing = existingBindings[0];
59
+ return {
60
+ accountId: existing.accountId,
61
+ conversationId: existing.conversationId,
62
+ parentConversationId: existing.parentConversationId,
63
+ };
64
+ }
65
+ if (existingBindings.length > 1) {
66
+ if (rawTo && normalizedTarget && !threadId && !isChatTarget) {
67
+ const directMatches = existingBindings.filter(
68
+ (entry) =>
69
+ entry.accountId === manager.accountId &&
70
+ entry.conversationId === normalizedTarget &&
71
+ !entry.parentConversationId,
72
+ );
73
+ if (directMatches.length === 1) {
74
+ const existing = directMatches[0];
75
+ return {
76
+ accountId: existing.accountId,
77
+ conversationId: existing.conversationId,
78
+ parentConversationId: existing.parentConversationId,
79
+ };
80
+ }
81
+ return null;
82
+ }
83
+ if (parsedRequesterTopic) {
84
+ const matchingTopicBindings = existingBindings.filter((entry) => {
85
+ const parsed = parseFeishuConversationId({
86
+ conversationId: entry.conversationId,
87
+ parentConversationId: entry.parentConversationId,
88
+ });
89
+ return (
90
+ parsed?.chatId === parsedRequesterTopic.chatId &&
91
+ parsed?.topicId === parsedRequesterTopic.topicId
92
+ );
93
+ });
94
+ if (matchingTopicBindings.length === 1) {
95
+ const existing = matchingTopicBindings[0];
96
+ return {
97
+ accountId: existing.accountId,
98
+ conversationId: existing.conversationId,
99
+ parentConversationId: existing.parentConversationId,
100
+ };
101
+ }
102
+ const senderScopedTopicBindings = matchingTopicBindings.filter((entry) => {
103
+ const parsed = parseFeishuConversationId({
104
+ conversationId: entry.conversationId,
105
+ parentConversationId: entry.parentConversationId,
106
+ });
107
+ return parsed?.scope === "group_topic_sender";
108
+ });
109
+ if (
110
+ senderScopedTopicBindings.length === 1 &&
111
+ matchingTopicBindings.length === senderScopedTopicBindings.length
112
+ ) {
113
+ const existing = senderScopedTopicBindings[0];
114
+ return {
115
+ accountId: existing.accountId,
116
+ conversationId: existing.conversationId,
117
+ parentConversationId: existing.parentConversationId,
118
+ };
119
+ }
120
+ return null;
121
+ }
122
+ }
123
+ }
124
+
125
+ if (!rawTo) {
126
+ return null;
127
+ }
128
+ if (!normalizedTarget) {
129
+ return null;
130
+ }
131
+
132
+ if (threadId) {
133
+ if (!isChatTarget) {
134
+ return null;
135
+ }
136
+ return {
137
+ accountId: manager.accountId,
138
+ conversationId: buildFeishuConversationId({
139
+ chatId: normalizedTarget,
140
+ scope: "group_topic",
141
+ topicId: threadId,
142
+ }),
143
+ parentConversationId: normalizedTarget,
144
+ };
145
+ }
146
+
147
+ if (isChatTarget) {
148
+ return null;
149
+ }
150
+
151
+ return {
152
+ accountId: manager.accountId,
153
+ conversationId: normalizedTarget,
154
+ };
155
+ }
156
+
157
+ function resolveFeishuDeliveryOrigin(params: {
158
+ conversationId: string;
159
+ parentConversationId?: string;
160
+ accountId: string;
161
+ deliveryTo?: string;
162
+ deliveryThreadId?: string;
163
+ }): {
164
+ channel: "feishu";
165
+ accountId: string;
166
+ to: string;
167
+ threadId?: string;
168
+ } {
169
+ const deliveryTo = params.deliveryTo?.trim();
170
+ const deliveryThreadId = params.deliveryThreadId?.trim();
171
+ if (deliveryTo) {
172
+ return {
173
+ channel: "feishu",
174
+ accountId: params.accountId,
175
+ to: deliveryTo,
176
+ ...(deliveryThreadId ? { threadId: deliveryThreadId } : {}),
177
+ };
178
+ }
179
+ const parsed = parseFeishuConversationId({
180
+ conversationId: params.conversationId,
181
+ parentConversationId: params.parentConversationId,
182
+ });
183
+ if (parsed?.topicId) {
184
+ return {
185
+ channel: "feishu",
186
+ accountId: params.accountId,
187
+ to: `chat:${params.parentConversationId?.trim() || parsed.chatId}`,
188
+ threadId: parsed.topicId,
189
+ };
190
+ }
191
+ return {
192
+ channel: "feishu",
193
+ accountId: params.accountId,
194
+ to: `user:${params.conversationId}`,
195
+ };
196
+ }
197
+
198
+ function resolveMatchingChildBinding(params: {
199
+ accountId?: string;
200
+ childSessionKey: string;
201
+ requesterSessionKey?: string;
202
+ requesterOrigin?: {
203
+ to?: string;
204
+ threadId?: string | number;
205
+ };
206
+ }) {
207
+ const manager = getFeishuThreadBindingManager(params.accountId);
208
+ if (!manager) {
209
+ return null;
210
+ }
211
+ const childBindings = manager.listBySessionKey(params.childSessionKey.trim());
212
+ if (childBindings.length === 0) {
213
+ return null;
214
+ }
215
+
216
+ const requesterConversation = resolveFeishuRequesterConversation({
217
+ accountId: manager.accountId,
218
+ to: params.requesterOrigin?.to,
219
+ threadId: params.requesterOrigin?.threadId,
220
+ requesterSessionKey: params.requesterSessionKey,
221
+ });
222
+ if (requesterConversation) {
223
+ const matched = childBindings.find(
224
+ (entry) =>
225
+ entry.accountId === requesterConversation.accountId &&
226
+ entry.conversationId === requesterConversation.conversationId &&
227
+ normalizeOptionalString(entry.parentConversationId) ===
228
+ normalizeOptionalString(requesterConversation.parentConversationId),
229
+ );
230
+ if (matched) {
231
+ return matched;
232
+ }
233
+ }
234
+
235
+ return childBindings.length === 1 ? childBindings[0] : null;
236
+ }
237
+
238
+ type FeishuSubagentContext = {
239
+ requesterSessionKey?: string;
240
+ };
241
+
242
+ type FeishuSubagentSpawningEvent = {
243
+ threadRequested?: boolean;
244
+ requester?: {
245
+ channel?: string;
246
+ accountId?: string;
247
+ to?: string;
248
+ threadId?: string | number;
249
+ };
250
+ childSessionKey: string;
251
+ agentId?: string;
252
+ label?: string;
253
+ };
254
+
255
+ type FeishuSubagentDeliveryTargetEvent = {
256
+ expectsCompletionMessage?: boolean;
257
+ requesterOrigin?: {
258
+ channel?: string;
259
+ accountId?: string;
260
+ to?: string;
261
+ threadId?: string | number;
262
+ };
263
+ childSessionKey: string;
264
+ requesterSessionKey?: string;
265
+ };
266
+
267
+ type FeishuSubagentEndedEvent = {
268
+ accountId?: string;
269
+ targetSessionKey: string;
270
+ };
271
+
272
+ type FeishuSubagentSpawningResult =
273
+ | { status: "ok"; threadBindingReady?: boolean }
274
+ | { status: "error"; error: string }
275
+ | undefined;
276
+
277
+ type FeishuSubagentDeliveryTargetResult =
278
+ | {
279
+ origin: {
280
+ channel: "feishu";
281
+ accountId?: string;
282
+ to?: string;
283
+ threadId?: string | number;
284
+ };
285
+ }
286
+ | undefined;
287
+
288
+ export async function handleFeishuSubagentSpawning(
289
+ event: FeishuSubagentSpawningEvent,
290
+ ctx: FeishuSubagentContext,
291
+ ): Promise<FeishuSubagentSpawningResult> {
292
+ if (!event.threadRequested) {
293
+ return undefined;
294
+ }
295
+ const requesterChannel = normalizeOptionalLowercaseString(event.requester?.channel);
296
+ if (requesterChannel !== "feishu") {
297
+ return undefined;
298
+ }
299
+
300
+ const manager = getFeishuThreadBindingManager(event.requester?.accountId);
301
+ if (!manager) {
302
+ return {
303
+ status: "error" as const,
304
+ error:
305
+ "Feishu current-conversation binding is unavailable because the Feishu account monitor is not active.",
306
+ };
307
+ }
308
+
309
+ const conversation = resolveFeishuRequesterConversation({
310
+ accountId: event.requester?.accountId,
311
+ to: event.requester?.to,
312
+ threadId: event.requester?.threadId,
313
+ requesterSessionKey: ctx.requesterSessionKey,
314
+ });
315
+ if (!conversation) {
316
+ return {
317
+ status: "error" as const,
318
+ error:
319
+ "Feishu current-conversation binding is only available in direct messages or topic conversations.",
320
+ };
321
+ }
322
+
323
+ try {
324
+ const binding = manager.bindConversation({
325
+ conversationId: conversation.conversationId,
326
+ parentConversationId: conversation.parentConversationId,
327
+ targetKind: "subagent",
328
+ targetSessionKey: event.childSessionKey,
329
+ metadata: {
330
+ agentId: event.agentId,
331
+ label: event.label,
332
+ boundBy: "system",
333
+ deliveryTo: event.requester?.to,
334
+ deliveryThreadId:
335
+ event.requester?.threadId != null && event.requester.threadId !== ""
336
+ ? String(event.requester.threadId)
337
+ : undefined,
338
+ },
339
+ });
340
+ if (!binding) {
341
+ return {
342
+ status: "error" as const,
343
+ error:
344
+ "Unable to bind this Feishu conversation to the spawned subagent session. Session mode is unavailable for this target.",
345
+ };
346
+ }
347
+ return {
348
+ status: "ok" as const,
349
+ threadBindingReady: true,
350
+ };
351
+ } catch (err) {
352
+ return {
353
+ status: "error" as const,
354
+ error: `Feishu conversation bind failed: ${summarizeError(err)}`,
355
+ };
356
+ }
357
+ }
358
+
359
+ export function handleFeishuSubagentDeliveryTarget(
360
+ event: FeishuSubagentDeliveryTargetEvent,
361
+ ): FeishuSubagentDeliveryTargetResult {
362
+ if (!event.expectsCompletionMessage) {
363
+ return undefined;
364
+ }
365
+ const requesterChannel = normalizeOptionalLowercaseString(event.requesterOrigin?.channel);
366
+ if (requesterChannel !== "feishu") {
367
+ return undefined;
368
+ }
369
+
370
+ const binding = resolveMatchingChildBinding({
371
+ accountId: event.requesterOrigin?.accountId,
372
+ childSessionKey: event.childSessionKey,
373
+ requesterSessionKey: event.requesterSessionKey,
374
+ requesterOrigin: {
375
+ to: event.requesterOrigin?.to,
376
+ threadId: event.requesterOrigin?.threadId,
377
+ },
378
+ });
379
+ if (!binding) {
380
+ return undefined;
381
+ }
382
+
383
+ return {
384
+ origin: resolveFeishuDeliveryOrigin({
385
+ conversationId: binding.conversationId,
386
+ parentConversationId: binding.parentConversationId,
387
+ accountId: binding.accountId,
388
+ deliveryTo: binding.deliveryTo,
389
+ deliveryThreadId: binding.deliveryThreadId,
390
+ }),
391
+ };
392
+ }
393
+
394
+ export function handleFeishuSubagentEnded(event: FeishuSubagentEndedEvent) {
395
+ const manager = getFeishuThreadBindingManager(event.accountId);
396
+ manager?.unbindBySessionKey(event.targetSessionKey);
397
+ }
package/src/targets.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
1
2
  import type { FeishuIdType } from "./types.js";
2
3
 
3
4
  const CHAT_ID_PREFIX = "oc_";
@@ -29,7 +30,7 @@ export function normalizeFeishuTarget(raw: string): string | null {
29
30
  }
30
31
 
31
32
  const withoutProvider = stripProviderPrefix(trimmed);
32
- const lowered = withoutProvider.toLowerCase();
33
+ const lowered = normalizeLowercaseStringOrEmpty(withoutProvider);
33
34
  if (lowered.startsWith("chat:")) {
34
35
  return withoutProvider.slice("chat:".length).trim() || null;
35
36
  }
@@ -52,20 +53,9 @@ export function normalizeFeishuTarget(raw: string): string | null {
52
53
  return withoutProvider;
53
54
  }
54
55
 
55
- export function formatFeishuTarget(id: string, type?: FeishuIdType): string {
56
- const trimmed = id.trim();
57
- if (type === "chat_id" || trimmed.startsWith(CHAT_ID_PREFIX)) {
58
- return `chat:${trimmed}`;
59
- }
60
- if (type === "open_id" || trimmed.startsWith(OPEN_ID_PREFIX)) {
61
- return `user:${trimmed}`;
62
- }
63
- return trimmed;
64
- }
65
-
66
56
  export function resolveReceiveIdType(id: string): "chat_id" | "open_id" | "user_id" {
67
57
  const trimmed = id.trim();
68
- const lowered = trimmed.toLowerCase();
58
+ const lowered = normalizeLowercaseStringOrEmpty(trimmed);
69
59
  if (
70
60
  lowered.startsWith("chat:") ||
71
61
  lowered.startsWith("group:") ||