@openclaw/feishu 2026.5.2-beta.2 → 2026.5.3-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 (224) hide show
  1. package/dist/accounts-Ba3-WP1z.js +423 -0
  2. package/dist/api.js +2280 -0
  3. package/dist/app-registration-B8qc1MCM.js +184 -0
  4. package/dist/audio-preflight.runtime-BPlzkO3l.js +7 -0
  5. package/dist/card-interaction-BfRLgvw_.js +96 -0
  6. package/dist/channel-CSD_Jt8I.js +1668 -0
  7. package/dist/channel-entry.js +22 -0
  8. package/dist/channel-plugin-api.js +2 -0
  9. package/dist/channel.runtime-DYsXcD36.js +700 -0
  10. package/dist/client-DBVoQL5w.js +157 -0
  11. package/dist/contract-api.js +9 -0
  12. package/dist/conversation-id-DWS3Ep2A.js +139 -0
  13. package/dist/directory.static-f3EeoRJd.js +44 -0
  14. package/dist/drive-C5eJLJr7.js +883 -0
  15. package/dist/index.js +68 -0
  16. package/dist/monitor-CT189QfR.js +60 -0
  17. package/dist/monitor.account-dJV2jO8C.js +4990 -0
  18. package/dist/monitor.state-DYM02ipp.js +100 -0
  19. package/dist/policy-D6c-wMPl.js +118 -0
  20. package/dist/probe-BNzzU_uR.js +149 -0
  21. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  22. package/dist/runtime-CG0DuRCy.js +8 -0
  23. package/dist/runtime-api.js +14 -0
  24. package/dist/secret-contract-Dm4Z_zQN.js +119 -0
  25. package/dist/secret-contract-api.js +2 -0
  26. package/dist/security-audit-DqJdocrN.js +11 -0
  27. package/dist/security-audit-shared-ByuMx9cJ.js +38 -0
  28. package/dist/security-contract-api.js +2 -0
  29. package/dist/send-DowxxbpH.js +1218 -0
  30. package/dist/session-conversation-B4nrW-vo.js +27 -0
  31. package/dist/session-key-api.js +2 -0
  32. package/dist/setup-api.js +2 -0
  33. package/dist/setup-entry.js +15 -0
  34. package/dist/subagent-hooks-C3UhPVLV.js +227 -0
  35. package/dist/subagent-hooks-api.js +23 -0
  36. package/dist/targets-JMFJRKSe.js +48 -0
  37. package/dist/thread-bindings-BmS6TLes.js +222 -0
  38. package/package.json +15 -6
  39. package/api.ts +0 -31
  40. package/channel-entry.ts +0 -20
  41. package/channel-plugin-api.ts +0 -1
  42. package/contract-api.ts +0 -16
  43. package/index.ts +0 -82
  44. package/runtime-api.ts +0 -55
  45. package/secret-contract-api.ts +0 -5
  46. package/security-contract-api.ts +0 -1
  47. package/session-key-api.ts +0 -1
  48. package/setup-api.ts +0 -3
  49. package/setup-entry.test.ts +0 -14
  50. package/setup-entry.ts +0 -13
  51. package/src/accounts.test.ts +0 -459
  52. package/src/accounts.ts +0 -326
  53. package/src/app-registration.ts +0 -331
  54. package/src/approval-auth.test.ts +0 -24
  55. package/src/approval-auth.ts +0 -25
  56. package/src/async.test.ts +0 -35
  57. package/src/async.ts +0 -104
  58. package/src/audio-preflight.runtime.ts +0 -9
  59. package/src/bitable.test.ts +0 -131
  60. package/src/bitable.ts +0 -762
  61. package/src/bot-content.ts +0 -474
  62. package/src/bot-group-name.test.ts +0 -108
  63. package/src/bot-runtime-api.ts +0 -12
  64. package/src/bot-sender-name.ts +0 -125
  65. package/src/bot.broadcast.test.ts +0 -463
  66. package/src/bot.card-action.test.ts +0 -577
  67. package/src/bot.checkBotMentioned.test.ts +0 -265
  68. package/src/bot.helpers.test.ts +0 -118
  69. package/src/bot.stripBotMention.test.ts +0 -126
  70. package/src/bot.test.ts +0 -3040
  71. package/src/bot.ts +0 -1559
  72. package/src/card-action.ts +0 -447
  73. package/src/card-interaction.test.ts +0 -129
  74. package/src/card-interaction.ts +0 -159
  75. package/src/card-test-helpers.ts +0 -47
  76. package/src/card-ux-approval.ts +0 -65
  77. package/src/card-ux-launcher.test.ts +0 -99
  78. package/src/card-ux-launcher.ts +0 -121
  79. package/src/card-ux-shared.ts +0 -33
  80. package/src/channel-runtime-api.ts +0 -16
  81. package/src/channel.runtime.ts +0 -47
  82. package/src/channel.test.ts +0 -959
  83. package/src/channel.ts +0 -1313
  84. package/src/chat-schema.ts +0 -25
  85. package/src/chat.test.ts +0 -196
  86. package/src/chat.ts +0 -188
  87. package/src/client.test.ts +0 -433
  88. package/src/client.ts +0 -290
  89. package/src/comment-dispatcher-runtime-api.ts +0 -6
  90. package/src/comment-dispatcher.test.ts +0 -169
  91. package/src/comment-dispatcher.ts +0 -107
  92. package/src/comment-handler-runtime-api.ts +0 -3
  93. package/src/comment-handler.test.ts +0 -486
  94. package/src/comment-handler.ts +0 -309
  95. package/src/comment-reaction.test.ts +0 -166
  96. package/src/comment-reaction.ts +0 -259
  97. package/src/comment-shared.test.ts +0 -182
  98. package/src/comment-shared.ts +0 -406
  99. package/src/comment-target.ts +0 -44
  100. package/src/config-schema.test.ts +0 -309
  101. package/src/config-schema.ts +0 -333
  102. package/src/conversation-id.test.ts +0 -18
  103. package/src/conversation-id.ts +0 -199
  104. package/src/dedup-runtime-api.ts +0 -1
  105. package/src/dedup.ts +0 -141
  106. package/src/directory.static.ts +0 -61
  107. package/src/directory.test.ts +0 -136
  108. package/src/directory.ts +0 -124
  109. package/src/doc-schema.ts +0 -182
  110. package/src/docx-batch-insert.test.ts +0 -91
  111. package/src/docx-batch-insert.ts +0 -223
  112. package/src/docx-color-text.ts +0 -154
  113. package/src/docx-table-ops.test.ts +0 -53
  114. package/src/docx-table-ops.ts +0 -316
  115. package/src/docx-types.ts +0 -38
  116. package/src/docx.account-selection.test.ts +0 -79
  117. package/src/docx.test.ts +0 -685
  118. package/src/docx.ts +0 -1616
  119. package/src/drive-schema.ts +0 -92
  120. package/src/drive.test.ts +0 -1219
  121. package/src/drive.ts +0 -829
  122. package/src/dynamic-agent.ts +0 -137
  123. package/src/event-types.ts +0 -45
  124. package/src/external-keys.test.ts +0 -20
  125. package/src/external-keys.ts +0 -19
  126. package/src/lifecycle.test-support.ts +0 -220
  127. package/src/media.test.ts +0 -900
  128. package/src/media.ts +0 -861
  129. package/src/mention-target.types.ts +0 -5
  130. package/src/mention.ts +0 -114
  131. package/src/message-action-contract.ts +0 -13
  132. package/src/monitor-state-runtime-api.ts +0 -7
  133. package/src/monitor-transport-runtime-api.ts +0 -7
  134. package/src/monitor.account.ts +0 -468
  135. package/src/monitor.acp-init-failure.lifecycle.test-support.ts +0 -219
  136. package/src/monitor.bot-identity.ts +0 -86
  137. package/src/monitor.bot-menu-handler.ts +0 -165
  138. package/src/monitor.bot-menu.lifecycle.test-support.ts +0 -224
  139. package/src/monitor.bot-menu.test.ts +0 -178
  140. package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +0 -264
  141. package/src/monitor.card-action.lifecycle.test-support.ts +0 -373
  142. package/src/monitor.cleanup.test.ts +0 -376
  143. package/src/monitor.comment-notice-handler.ts +0 -105
  144. package/src/monitor.comment.test.ts +0 -937
  145. package/src/monitor.comment.ts +0 -1386
  146. package/src/monitor.lifecycle.test.ts +0 -4
  147. package/src/monitor.message-handler.ts +0 -339
  148. package/src/monitor.reaction.lifecycle.test-support.ts +0 -68
  149. package/src/monitor.reaction.test.ts +0 -713
  150. package/src/monitor.startup.test.ts +0 -192
  151. package/src/monitor.startup.ts +0 -74
  152. package/src/monitor.state.defaults.test.ts +0 -46
  153. package/src/monitor.state.ts +0 -170
  154. package/src/monitor.synthetic-error.ts +0 -18
  155. package/src/monitor.test-mocks.ts +0 -45
  156. package/src/monitor.transport.ts +0 -424
  157. package/src/monitor.ts +0 -100
  158. package/src/monitor.webhook-e2e.test.ts +0 -272
  159. package/src/monitor.webhook-security.test.ts +0 -264
  160. package/src/monitor.webhook.test-helpers.ts +0 -116
  161. package/src/outbound-runtime-api.ts +0 -1
  162. package/src/outbound.test.ts +0 -935
  163. package/src/outbound.ts +0 -718
  164. package/src/perm-schema.ts +0 -52
  165. package/src/perm.ts +0 -170
  166. package/src/pins.ts +0 -108
  167. package/src/policy.test.ts +0 -334
  168. package/src/policy.ts +0 -236
  169. package/src/post.test.ts +0 -105
  170. package/src/post.ts +0 -275
  171. package/src/probe.test.ts +0 -275
  172. package/src/probe.ts +0 -166
  173. package/src/processing-claims.ts +0 -59
  174. package/src/qr-terminal.ts +0 -1
  175. package/src/reactions.ts +0 -123
  176. package/src/reasoning-preview.test.ts +0 -59
  177. package/src/reasoning-preview.ts +0 -20
  178. package/src/reply-dispatcher-runtime-api.ts +0 -7
  179. package/src/reply-dispatcher.test.ts +0 -1144
  180. package/src/reply-dispatcher.ts +0 -650
  181. package/src/runtime.ts +0 -9
  182. package/src/secret-contract.ts +0 -145
  183. package/src/secret-input.ts +0 -1
  184. package/src/security-audit-shared.ts +0 -69
  185. package/src/security-audit.test.ts +0 -61
  186. package/src/security-audit.ts +0 -1
  187. package/src/send-result.ts +0 -29
  188. package/src/send-target.test.ts +0 -80
  189. package/src/send-target.ts +0 -35
  190. package/src/send.reply-fallback.test.ts +0 -292
  191. package/src/send.test.ts +0 -550
  192. package/src/send.ts +0 -800
  193. package/src/sequential-key.test.ts +0 -72
  194. package/src/sequential-key.ts +0 -28
  195. package/src/sequential-queue.test.ts +0 -92
  196. package/src/sequential-queue.ts +0 -16
  197. package/src/session-conversation.ts +0 -42
  198. package/src/session-route.ts +0 -48
  199. package/src/setup-core.ts +0 -51
  200. package/src/setup-surface.test.ts +0 -174
  201. package/src/setup-surface.ts +0 -581
  202. package/src/streaming-card.test.ts +0 -190
  203. package/src/streaming-card.ts +0 -490
  204. package/src/subagent-hooks.test.ts +0 -603
  205. package/src/subagent-hooks.ts +0 -397
  206. package/src/targets.ts +0 -97
  207. package/src/test-support/lifecycle-test-support.ts +0 -453
  208. package/src/thread-bindings.test.ts +0 -143
  209. package/src/thread-bindings.ts +0 -330
  210. package/src/tool-account-routing.test.ts +0 -187
  211. package/src/tool-account.test.ts +0 -44
  212. package/src/tool-account.ts +0 -93
  213. package/src/tool-factory-test-harness.ts +0 -79
  214. package/src/tool-result.test.ts +0 -32
  215. package/src/tool-result.ts +0 -16
  216. package/src/tools-config.test.ts +0 -21
  217. package/src/tools-config.ts +0 -22
  218. package/src/types.ts +0 -104
  219. package/src/typing.test.ts +0 -144
  220. package/src/typing.ts +0 -214
  221. package/src/wiki-schema.ts +0 -55
  222. package/src/wiki.ts +0 -227
  223. package/subagent-hooks-api.ts +0 -31
  224. package/tsconfig.json +0 -16
@@ -1,397 +0,0 @@
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 DELETED
@@ -1,97 +0,0 @@
1
- import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime";
2
- import type { FeishuIdType } from "./types.js";
3
-
4
- const CHAT_ID_PREFIX = "oc_";
5
- const OPEN_ID_PREFIX = "ou_";
6
- const USER_ID_REGEX = /^[a-zA-Z0-9_-]+$/;
7
-
8
- function stripProviderPrefix(raw: string): string {
9
- return raw.replace(/^(feishu|lark):/i, "").trim();
10
- }
11
-
12
- export function detectIdType(id: string): FeishuIdType | null {
13
- const trimmed = id.trim();
14
- if (trimmed.startsWith(CHAT_ID_PREFIX)) {
15
- return "chat_id";
16
- }
17
- if (trimmed.startsWith(OPEN_ID_PREFIX)) {
18
- return "open_id";
19
- }
20
- if (USER_ID_REGEX.test(trimmed)) {
21
- return "user_id";
22
- }
23
- return null;
24
- }
25
-
26
- export function normalizeFeishuTarget(raw: string): string | null {
27
- const trimmed = raw.trim();
28
- if (!trimmed) {
29
- return null;
30
- }
31
-
32
- const withoutProvider = stripProviderPrefix(trimmed);
33
- const lowered = normalizeLowercaseStringOrEmpty(withoutProvider);
34
- if (lowered.startsWith("chat:")) {
35
- return withoutProvider.slice("chat:".length).trim() || null;
36
- }
37
- if (lowered.startsWith("group:")) {
38
- return withoutProvider.slice("group:".length).trim() || null;
39
- }
40
- if (lowered.startsWith("channel:")) {
41
- return withoutProvider.slice("channel:".length).trim() || null;
42
- }
43
- if (lowered.startsWith("user:")) {
44
- return withoutProvider.slice("user:".length).trim() || null;
45
- }
46
- if (lowered.startsWith("dm:")) {
47
- return withoutProvider.slice("dm:".length).trim() || null;
48
- }
49
- if (lowered.startsWith("open_id:")) {
50
- return withoutProvider.slice("open_id:".length).trim() || null;
51
- }
52
-
53
- return withoutProvider;
54
- }
55
-
56
- export function resolveReceiveIdType(id: string): "chat_id" | "open_id" | "user_id" {
57
- const trimmed = id.trim();
58
- const lowered = normalizeLowercaseStringOrEmpty(trimmed);
59
- if (
60
- lowered.startsWith("chat:") ||
61
- lowered.startsWith("group:") ||
62
- lowered.startsWith("channel:")
63
- ) {
64
- return "chat_id";
65
- }
66
- if (lowered.startsWith("open_id:")) {
67
- return "open_id";
68
- }
69
- if (lowered.startsWith("user:") || lowered.startsWith("dm:")) {
70
- const normalized = trimmed.replace(/^(user|dm):/i, "").trim();
71
- return normalized.startsWith(OPEN_ID_PREFIX) ? "open_id" : "user_id";
72
- }
73
- if (trimmed.startsWith(CHAT_ID_PREFIX)) {
74
- return "chat_id";
75
- }
76
- if (trimmed.startsWith(OPEN_ID_PREFIX)) {
77
- return "open_id";
78
- }
79
- return "user_id";
80
- }
81
-
82
- export function looksLikeFeishuId(raw: string): boolean {
83
- const trimmed = stripProviderPrefix(raw.trim());
84
- if (!trimmed) {
85
- return false;
86
- }
87
- if (/^(chat|group|channel|user|dm|open_id):/i.test(trimmed)) {
88
- return true;
89
- }
90
- if (trimmed.startsWith(CHAT_ID_PREFIX)) {
91
- return true;
92
- }
93
- if (trimmed.startsWith(OPEN_ID_PREFIX)) {
94
- return true;
95
- }
96
- return false;
97
- }