@openclaw/feishu 2026.5.2 → 2026.5.3-beta.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 (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
@@ -0,0 +1,423 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { isRecord, normalizeOptionalString, readStringValue } from "openclaw/plugin-sdk/text-runtime";
3
+ import { DEFAULT_ACCOUNT_ID, createAccountListHelpers, normalizeAccountId, normalizeOptionalAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
4
+ import { coerceSecretRef } from "openclaw/plugin-sdk/provider-auth";
5
+ //#region extensions/feishu/src/comment-target.ts
6
+ const FEISHU_COMMENT_FILE_TYPES = [
7
+ "doc",
8
+ "docx",
9
+ "file",
10
+ "sheet",
11
+ "slides"
12
+ ];
13
+ function normalizeCommentFileType(value) {
14
+ return typeof value === "string" && FEISHU_COMMENT_FILE_TYPES.includes(value) ? value : void 0;
15
+ }
16
+ function buildFeishuCommentTarget(params) {
17
+ return `comment:${params.fileType}:${params.fileToken}:${params.commentId}`;
18
+ }
19
+ function parseFeishuCommentTarget(raw) {
20
+ const trimmed = raw?.trim();
21
+ if (!trimmed?.startsWith("comment:")) return null;
22
+ const parts = trimmed.split(":");
23
+ if (parts.length !== 4) return null;
24
+ const fileType = normalizeCommentFileType(parts[1]);
25
+ const fileToken = parts[2]?.trim();
26
+ const commentId = parts[3]?.trim();
27
+ if (!fileType || !fileToken || !commentId) return null;
28
+ return {
29
+ fileType,
30
+ fileToken,
31
+ commentId
32
+ };
33
+ }
34
+ //#endregion
35
+ //#region extensions/feishu/src/comment-shared.ts
36
+ function encodeQuery(params) {
37
+ const query = new URLSearchParams();
38
+ for (const [key, value] of Object.entries(params)) {
39
+ const trimmed = value?.trim();
40
+ if (trimmed) query.set(key, trimmed);
41
+ }
42
+ const queryString = query.toString();
43
+ return queryString ? `?${queryString}` : "";
44
+ }
45
+ const readString = readStringValue;
46
+ const normalizeString = normalizeOptionalString;
47
+ const isRecord$1 = isRecord;
48
+ function formatFeishuApiError(error, options = {}) {
49
+ if (!isRecord$1(error)) return typeof error === "string" ? error : JSON.stringify(error);
50
+ const config = isRecord$1(error.config) ? error.config : void 0;
51
+ const response = isRecord$1(error.response) ? error.response : void 0;
52
+ const responseData = isRecord$1(response?.data) ? response?.data : void 0;
53
+ const feishuLogId = readString(responseData?.log_id) || (options.includeNestedErrorLogId ? readString(isRecord$1(responseData?.error) ? responseData.error.log_id : void 0) : void 0);
54
+ const nestedError = isRecord$1(responseData?.error) ? responseData.error : void 0;
55
+ return JSON.stringify({
56
+ message: typeof error.message === "string" ? error.message : typeof error === "string" ? error : JSON.stringify(error),
57
+ code: readString(error.code),
58
+ method: readString(config?.method),
59
+ url: readString(config?.url),
60
+ ...options.includeConfigParams ? { params: config?.params } : {},
61
+ http_status: typeof response?.status === "number" ? response.status : void 0,
62
+ feishu_code: typeof responseData?.code === "number" ? responseData.code : readString(responseData?.code),
63
+ feishu_msg: readString(responseData?.msg),
64
+ feishu_log_id: feishuLogId,
65
+ feishu_troubleshooter: readString(responseData?.troubleshooter) || readString(nestedError?.troubleshooter)
66
+ });
67
+ }
68
+ function formatFeishuApiFailure(error, errorPrefix, options = {}) {
69
+ return `${errorPrefix}: ${formatFeishuApiError(error, options) || "unknown error"}`;
70
+ }
71
+ function createFeishuApiError(error, errorPrefix, options = {}) {
72
+ return new Error(formatFeishuApiFailure(error, errorPrefix, options), { cause: error });
73
+ }
74
+ async function requestFeishuApi(request, errorPrefix, options = {}) {
75
+ try {
76
+ return await request();
77
+ } catch (error) {
78
+ throw createFeishuApiError(error, errorPrefix, options);
79
+ }
80
+ }
81
+ function readDocsLinkUrl(element) {
82
+ const docsLink = isRecord$1(element.docs_link) ? element.docs_link : void 0;
83
+ return normalizeString(docsLink?.url) || normalizeString(docsLink?.link) || normalizeString(element.url) || normalizeString(element.link) || void 0;
84
+ }
85
+ function readMentionUserId(element) {
86
+ const mention = isRecord$1(element.mention) ? element.mention : void 0;
87
+ return normalizeString((isRecord$1(element.person) ? element.person : void 0)?.user_id) || normalizeString(mention?.user_id) || normalizeString(mention?.open_id) || normalizeString(element.mention_user) || normalizeString(element.user_id) || void 0;
88
+ }
89
+ function readMentionDisplayText(element, userId) {
90
+ const mention = isRecord$1(element.mention) ? element.mention : void 0;
91
+ const mentionName = normalizeString(mention?.name) || normalizeString(mention?.display_name) || normalizeString(element.name);
92
+ return mentionName ? `@${mentionName}` : `@${userId}`;
93
+ }
94
+ function normalizeCommentText(parts) {
95
+ return parts.join("").trim() || void 0;
96
+ }
97
+ function normalizeCommentSemanticText(parts) {
98
+ return parts.join("").replace(/\s+/g, " ").trim() || void 0;
99
+ }
100
+ function readElementTextPreservingWhitespace(element) {
101
+ return (isRecord$1(element.text_run) ? readString(element.text_run.content) || readString(element.text_run.text) : void 0) || readString(element.text) || readString(element.content) || readString(element.name) || void 0;
102
+ }
103
+ const FEISHU_LINK_TOKEN_MIN_LENGTH = 22;
104
+ const FEISHU_LINK_TOKEN_MAX_LENGTH = 28;
105
+ const COMMENT_LINK_KIND_ALIASES = new Map([
106
+ ["doc", "doc"],
107
+ ["docs", "doc"],
108
+ ["docx", "docx"],
109
+ ["sheet", "sheet"],
110
+ ["sheets", "sheet"],
111
+ ["slide", "slides"],
112
+ ["slides", "slides"],
113
+ ["file", "file"],
114
+ ["files", "file"],
115
+ ["wiki", "wiki"],
116
+ ["mindnote", "mindnote"],
117
+ ["mindnotes", "mindnote"],
118
+ ["bitable", "bitable"],
119
+ ["base", "base"]
120
+ ]);
121
+ function isCommentFileType(value) {
122
+ return typeof value === "string" && FEISHU_COMMENT_FILE_TYPES.includes(value);
123
+ }
124
+ function isReasonableFeishuLinkToken(token) {
125
+ return typeof token === "string" && token.length >= FEISHU_LINK_TOKEN_MIN_LENGTH && token.length <= FEISHU_LINK_TOKEN_MAX_LENGTH;
126
+ }
127
+ function parseCommentLinkedDocumentPath(pathname) {
128
+ const segments = pathname.split("/").map((segment) => segment.trim()).filter(Boolean);
129
+ const offset = segments[0]?.toLowerCase() === "space" ? 1 : 0;
130
+ const kind = COMMENT_LINK_KIND_ALIASES.get(segments[offset]?.toLowerCase() ?? "");
131
+ const token = normalizeString(segments[offset + 1]);
132
+ if (!kind || !isReasonableFeishuLinkToken(token)) return null;
133
+ return {
134
+ urlKind: kind,
135
+ token
136
+ };
137
+ }
138
+ function hasResolvedLinkedDocumentReference(link) {
139
+ return link.urlKind !== "unknown" && (Boolean(link.resolvedObjToken) || Boolean(link.wikiNodeToken));
140
+ }
141
+ function resolveCommentLinkedDocumentFromUrl(params) {
142
+ const link = {
143
+ rawUrl: params.rawUrl,
144
+ urlKind: "unknown"
145
+ };
146
+ try {
147
+ const parsedPath = parseCommentLinkedDocumentPath(new URL(params.rawUrl).pathname);
148
+ if (!parsedPath) return link;
149
+ const { urlKind, token } = parsedPath;
150
+ link.urlKind = urlKind;
151
+ if (urlKind === "wiki") {
152
+ link.urlKind = "wiki";
153
+ link.wikiNodeToken = token;
154
+ } else {
155
+ link.resolvedObjType = urlKind;
156
+ link.resolvedObjToken = token;
157
+ }
158
+ if (link.resolvedObjType && link.resolvedObjToken && isCommentFileType(link.resolvedObjType) && params.currentDocument?.fileType === link.resolvedObjType && params.currentDocument.fileToken === link.resolvedObjToken) link.isCurrentDocument = true;
159
+ else if (link.resolvedObjType && link.resolvedObjToken && isCommentFileType(link.resolvedObjType)) link.isCurrentDocument = false;
160
+ } catch {
161
+ return link;
162
+ }
163
+ return link;
164
+ }
165
+ function parseCommentContentElements(params) {
166
+ const elements = Array.isArray(params.elements) ? params.elements : [];
167
+ const plainTextParts = [];
168
+ const semanticTextParts = [];
169
+ const mentions = [];
170
+ const linkedDocuments = [];
171
+ const botIds = new Set(Array.from(params.botOpenIds ?? []).map((value) => normalizeString(value)).filter((value) => Boolean(value)));
172
+ const linkedDocumentKeys = /* @__PURE__ */ new Set();
173
+ let botMentioned = false;
174
+ for (const rawElement of elements) {
175
+ if (!isRecord$1(rawElement)) continue;
176
+ const element = rawElement;
177
+ const type = normalizeString(element.type);
178
+ const text = (type === "text_run" ? readElementTextPreservingWhitespace(element) : void 0) || (type === "text" ? readElementTextPreservingWhitespace(element) : void 0) || (type === "docs_link" || type === "link" ? readDocsLinkUrl(element) : void 0) || (type === "mention" || type === "mention_user" || type === "person" ? (() => {
179
+ const userId = readMentionUserId(element);
180
+ return userId ? readMentionDisplayText(element, userId) : void 0;
181
+ })() : void 0) || readElementTextPreservingWhitespace(element) || void 0;
182
+ if (type === "mention" || type === "mention_user" || type === "person") {
183
+ const userId = readMentionUserId(element);
184
+ if (userId) {
185
+ const displayText = readMentionDisplayText(element, userId);
186
+ const isBotMention = botIds.has(userId);
187
+ mentions.push({
188
+ userId,
189
+ displayText,
190
+ isBotMention
191
+ });
192
+ plainTextParts.push(displayText);
193
+ if (!isBotMention) semanticTextParts.push(displayText);
194
+ else botMentioned = true;
195
+ continue;
196
+ }
197
+ }
198
+ if (type === "docs_link" || type === "link") {
199
+ const rawUrl = readDocsLinkUrl(element);
200
+ if (rawUrl) {
201
+ plainTextParts.push(rawUrl);
202
+ semanticTextParts.push(rawUrl);
203
+ const linkedDocument = resolveCommentLinkedDocumentFromUrl({
204
+ rawUrl,
205
+ currentDocument: params.currentDocument
206
+ });
207
+ if (hasResolvedLinkedDocumentReference(linkedDocument)) {
208
+ const key = [
209
+ linkedDocument.rawUrl,
210
+ linkedDocument.urlKind,
211
+ linkedDocument.resolvedObjType,
212
+ linkedDocument.resolvedObjToken,
213
+ linkedDocument.wikiNodeToken
214
+ ].join(":");
215
+ if (!linkedDocumentKeys.has(key)) {
216
+ linkedDocumentKeys.add(key);
217
+ linkedDocuments.push(linkedDocument);
218
+ }
219
+ }
220
+ continue;
221
+ }
222
+ }
223
+ if (text) {
224
+ plainTextParts.push(text);
225
+ semanticTextParts.push(text);
226
+ }
227
+ }
228
+ return {
229
+ plainText: normalizeCommentText(plainTextParts),
230
+ semanticText: normalizeCommentSemanticText(semanticTextParts),
231
+ mentions,
232
+ linkedDocuments,
233
+ botMentioned
234
+ };
235
+ }
236
+ function extractReplyText(reply) {
237
+ if (!reply || !isRecord$1(reply.content)) return;
238
+ return parseCommentContentElements({ elements: Array.isArray(reply.content.elements) ? reply.content.elements : [] }).plainText;
239
+ }
240
+ //#endregion
241
+ //#region extensions/feishu/src/accounts.ts
242
+ var accounts_exports = /* @__PURE__ */ __exportAll({
243
+ FeishuSecretRefUnavailableError: () => FeishuSecretRefUnavailableError,
244
+ inspectFeishuCredentials: () => inspectFeishuCredentials,
245
+ listEnabledFeishuAccounts: () => listEnabledFeishuAccounts,
246
+ listFeishuAccountIds: () => listFeishuAccountIds,
247
+ resolveDefaultFeishuAccountId: () => resolveDefaultFeishuAccountId,
248
+ resolveDefaultFeishuAccountSelection: () => resolveDefaultFeishuAccountSelection,
249
+ resolveFeishuAccount: () => resolveFeishuAccount,
250
+ resolveFeishuCredentials: () => resolveFeishuCredentials,
251
+ resolveFeishuRuntimeAccount: () => resolveFeishuRuntimeAccount
252
+ });
253
+ const { listAccountIds: listFeishuAccountIds, resolveDefaultAccountId } = createAccountListHelpers("feishu", { allowUnlistedDefaultAccount: true });
254
+ function formatSecretRefLabel(ref) {
255
+ return `${ref.source}:${ref.provider}:${ref.id}`;
256
+ }
257
+ var FeishuSecretRefUnavailableError = class extends Error {
258
+ constructor(path, ref) {
259
+ super(`${path}: unresolved SecretRef "${formatSecretRefLabel(ref)}". Resolve this command against an active gateway runtime snapshot before reading it.`);
260
+ this.name = "FeishuSecretRefUnavailableError";
261
+ this.path = path;
262
+ }
263
+ };
264
+ function resolveFeishuSecretLike(params) {
265
+ const asString = normalizeString(params.value);
266
+ if (asString) return asString;
267
+ const ref = coerceSecretRef(params.value);
268
+ if (!ref) return;
269
+ if (params.mode === "inspect") {
270
+ if (params.allowEnvSecretRefRead && ref.source === "env") {
271
+ const envValue = normalizeString(process.env[ref.id]);
272
+ if (envValue) return envValue;
273
+ }
274
+ return;
275
+ }
276
+ throw new FeishuSecretRefUnavailableError(params.path, ref);
277
+ }
278
+ function resolveFeishuBaseCredentials(cfg, mode) {
279
+ const appId = resolveFeishuSecretLike({
280
+ value: cfg?.appId,
281
+ path: "channels.feishu.appId",
282
+ mode,
283
+ allowEnvSecretRefRead: true
284
+ });
285
+ const appSecret = resolveFeishuSecretLike({
286
+ value: cfg?.appSecret,
287
+ path: "channels.feishu.appSecret",
288
+ mode,
289
+ allowEnvSecretRefRead: true
290
+ });
291
+ if (!appId || !appSecret) return null;
292
+ return {
293
+ appId,
294
+ appSecret,
295
+ domain: cfg?.domain ?? "feishu"
296
+ };
297
+ }
298
+ function resolveFeishuEventSecrets(cfg, mode) {
299
+ return {
300
+ encryptKey: (cfg?.connectionMode ?? "websocket") === "webhook" ? resolveFeishuSecretLike({
301
+ value: cfg?.encryptKey,
302
+ path: "channels.feishu.encryptKey",
303
+ mode,
304
+ allowEnvSecretRefRead: true
305
+ }) : normalizeString(cfg?.encryptKey),
306
+ verificationToken: resolveFeishuSecretLike({
307
+ value: cfg?.verificationToken,
308
+ path: "channels.feishu.verificationToken",
309
+ mode,
310
+ allowEnvSecretRefRead: true
311
+ })
312
+ };
313
+ }
314
+ /**
315
+ * Resolve the default account selection and its source.
316
+ */
317
+ function resolveDefaultFeishuAccountSelection(cfg) {
318
+ const preferred = normalizeOptionalAccountId((cfg.channels?.feishu)?.defaultAccount);
319
+ if (preferred) return {
320
+ accountId: preferred,
321
+ source: "explicit-default"
322
+ };
323
+ const ids = listFeishuAccountIds(cfg);
324
+ if (ids.includes(DEFAULT_ACCOUNT_ID)) return {
325
+ accountId: DEFAULT_ACCOUNT_ID,
326
+ source: "mapped-default"
327
+ };
328
+ return {
329
+ accountId: ids[0] ?? DEFAULT_ACCOUNT_ID,
330
+ source: "fallback"
331
+ };
332
+ }
333
+ /**
334
+ * Resolve the default account ID.
335
+ */
336
+ function resolveDefaultFeishuAccountId(cfg) {
337
+ return resolveDefaultAccountId(cfg);
338
+ }
339
+ /**
340
+ * Merge top-level config with account-specific config.
341
+ * Account-specific fields override top-level fields.
342
+ */
343
+ function mergeFeishuAccountConfig(cfg, accountId) {
344
+ const feishuCfg = cfg.channels?.feishu;
345
+ return resolveMergedAccountConfig({
346
+ channelConfig: feishuCfg,
347
+ accounts: feishuCfg?.accounts,
348
+ accountId,
349
+ omitKeys: ["defaultAccount"]
350
+ });
351
+ }
352
+ function resolveFeishuCredentials(cfg, options) {
353
+ const mode = options?.mode ?? (options?.allowUnresolvedSecretRef ? "inspect" : "strict");
354
+ const base = resolveFeishuBaseCredentials(cfg, mode);
355
+ if (!base) return null;
356
+ const eventSecrets = resolveFeishuEventSecrets(cfg, mode);
357
+ return {
358
+ ...base,
359
+ ...eventSecrets
360
+ };
361
+ }
362
+ function inspectFeishuCredentials(cfg) {
363
+ return resolveFeishuCredentials(cfg, { mode: "inspect" });
364
+ }
365
+ function buildResolvedFeishuAccount(params) {
366
+ const hasExplicitAccountId = typeof params.accountId === "string" && params.accountId.trim() !== "";
367
+ const defaultSelection = hasExplicitAccountId ? null : resolveDefaultFeishuAccountSelection(params.cfg);
368
+ const accountId = hasExplicitAccountId ? normalizeAccountId(params.accountId) : defaultSelection?.accountId ?? DEFAULT_ACCOUNT_ID;
369
+ const selectionSource = hasExplicitAccountId ? "explicit" : defaultSelection?.source ?? "fallback";
370
+ const baseEnabled = (params.cfg.channels?.feishu)?.enabled !== false;
371
+ const merged = mergeFeishuAccountConfig(params.cfg, accountId);
372
+ const accountEnabled = merged.enabled !== false;
373
+ const enabled = baseEnabled && accountEnabled;
374
+ const baseCreds = resolveFeishuBaseCredentials(merged, params.baseMode);
375
+ const eventSecrets = resolveFeishuEventSecrets(merged, params.eventSecretMode);
376
+ const accountName = merged.name;
377
+ return {
378
+ accountId,
379
+ selectionSource,
380
+ enabled,
381
+ configured: Boolean(baseCreds),
382
+ name: typeof accountName === "string" ? accountName.trim() || void 0 : void 0,
383
+ appId: baseCreds?.appId,
384
+ appSecret: baseCreds?.appSecret,
385
+ encryptKey: eventSecrets.encryptKey,
386
+ verificationToken: eventSecrets.verificationToken,
387
+ domain: baseCreds?.domain ?? "feishu",
388
+ config: merged
389
+ };
390
+ }
391
+ /**
392
+ * Resolve a read-only Feishu account snapshot for CLI/config surfaces.
393
+ * Unresolved SecretRefs are treated as unavailable instead of throwing.
394
+ */
395
+ function resolveFeishuAccount(params) {
396
+ return buildResolvedFeishuAccount({
397
+ ...params,
398
+ baseMode: "inspect",
399
+ eventSecretMode: "inspect"
400
+ });
401
+ }
402
+ /**
403
+ * Resolve a runtime Feishu account.
404
+ * Required app credentials stay strict; event-only secrets can be required by callers.
405
+ */
406
+ function resolveFeishuRuntimeAccount(params, options) {
407
+ return buildResolvedFeishuAccount({
408
+ ...params,
409
+ baseMode: "strict",
410
+ eventSecretMode: options?.requireEventSecrets ? "strict" : "inspect"
411
+ });
412
+ }
413
+ /**
414
+ * List all enabled and configured accounts.
415
+ */
416
+ function listEnabledFeishuAccounts(cfg) {
417
+ return listFeishuAccountIds(cfg).map((accountId) => resolveFeishuAccount({
418
+ cfg,
419
+ accountId
420
+ })).filter((account) => account.enabled && account.configured);
421
+ }
422
+ //#endregion
423
+ export { buildFeishuCommentTarget as _, resolveDefaultFeishuAccountId as a, createFeishuApiError as c, formatFeishuApiError as d, isRecord$1 as f, requestFeishuApi as g, readString as h, listFeishuAccountIds as i, encodeQuery as l, parseCommentContentElements as m, inspectFeishuCredentials as n, resolveFeishuAccount as o, normalizeString as p, listEnabledFeishuAccounts as r, resolveFeishuRuntimeAccount as s, accounts_exports as t, extractReplyText as u, normalizeCommentFileType as v, parseFeishuCommentTarget as y };