@openclaw/feishu 2026.11.7 → 2026.11.10-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 (100) hide show
  1. package/dist/.setup/{app-registration-DhnIp0Kd.mjs → app-registration-CBgQSu2L.mjs} +1 -2
  2. package/dist/.setup/async-WkOXCAZ1.mjs +32 -0
  3. package/dist/.setup/{channel-FEEIr2Sd.mjs → channel-Dig34MUl.mjs} +125 -128
  4. package/dist/.setup/{channel.runtime-D0haxEQL.mjs → channel.runtime-DtdoPtQ3.mjs} +10 -14
  5. package/dist/.setup/{chat-g8dTUdIb.mjs → chat-XINRHAOR.mjs} +3 -4
  6. package/dist/.setup/{client-DqGMyzOi.mjs → client-BAiJnY41.mjs} +4 -7
  7. package/dist/.setup/{conversation-id-BLsHZ7pf.mjs → conversation-id-N6q3vKm-.mjs} +2 -4
  8. package/dist/.setup/{doctor-contract-CPh2u5-o.mjs → doctor-contract-ItAh0keT.mjs} +10 -20
  9. package/dist/.setup/{message-action-contract-DMVMY_ng.mjs → message-action-contract-BZK6bpAl.mjs} +1 -2
  10. package/dist/.setup/{monitor-Bu-H1IvN.mjs → monitor-DGgVDZZK.mjs} +7 -10
  11. package/dist/.setup/{monitor.account-CTBV_Rk9.mjs → monitor.account-Doce9cKt.mjs} +337 -282
  12. package/dist/.setup/{probe-CbNVGjv_.mjs → probe-DMOl26H9.mjs} +11 -41
  13. package/dist/.setup/{reply-delivery-result-BjOCvaPo.mjs → reply-delivery-result-Dcan9Dz_.mjs} +211 -150
  14. package/dist/.setup/{runtime-C5JxBWZp.mjs → runtime-6V3uDMw5.mjs} +1 -2
  15. package/dist/.setup/runtime-setter-api-DSLLnejl.mjs +2 -0
  16. package/dist/.setup/{secret-contract-Do6HTIFT.mjs → secret-contract-BAucuP6O.mjs} +1 -2
  17. package/dist/.setup/{secret-contract-api-LwCXK5Qg.mjs → secret-contract-api-DR5mIHhJ.mjs} +1 -1
  18. package/dist/.setup/{security-audit-b86aSgH2.mjs → security-audit-CYRW0D76.mjs} +1 -2
  19. package/dist/.setup/{session-conversation-CM3UgYZY.mjs → session-conversation-DLgXP0-H.mjs} +2 -3
  20. package/dist/.setup/{setup-api-L7UpEkae.mjs → setup-api-qmezzejF.mjs} +1 -1
  21. package/dist/.setup/{subagent-hooks-DdiyEIi7.mjs → subagent-hooks-BRem84Mh.mjs} +4 -5
  22. package/dist/.setup/{thread-bindings-BxKmOara.mjs → thread-bindings-6eyktxK_.mjs} +1 -2
  23. package/dist/.source-module-urls/6579f1b33dd01f8f0aaea28311ed6df1a635f9ad1e6fa86dcba53bca46407e55.json +1 -1
  24. package/dist/api.js +20 -30
  25. package/dist/channel-entry.js +1 -2
  26. package/dist/channel-plugin-api.js +1 -1
  27. package/dist/configured-state.js +1 -2
  28. package/dist/contract-api.js +3 -3
  29. package/dist/doctor-contract-api.js +1 -1
  30. package/dist/index.js +1 -2
  31. package/dist/runtime-api.js +2 -2
  32. package/dist/runtime-setter-api.js +1 -1
  33. package/dist/secret-contract-api.js +1 -1
  34. package/dist/security-contract-api.js +1 -1
  35. package/dist/session-binding-contract-api.js +1 -1
  36. package/dist/session-key-api.js +1 -1
  37. package/dist/setup-api.js +1 -1
  38. package/dist/setup-entry.js +4 -5
  39. package/dist/subagent-hooks-api.js +2 -3
  40. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/README.md +41 -106
  41. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.js +931 -278
  42. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js +2 -2
  43. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/axios.min.js.map +1 -1
  44. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/browser/axios.cjs +948 -268
  45. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.js +948 -268
  46. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js +2 -2
  47. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  48. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/dist/node/axios.cjs +925 -242
  49. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.cts +20 -1
  50. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/index.d.ts +18 -1
  51. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/fetch.js +73 -20
  52. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/http.js +145 -26
  53. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/adapters/xhr.js +120 -13
  54. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/Axios.js +67 -12
  55. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/AxiosError.js +59 -0
  56. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
  57. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/InterceptorManager.js +13 -2
  58. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
  59. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/createMultipartBody.js +37 -0
  60. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/dispatchRequest.js +20 -0
  61. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/core/mergeConfig.js +183 -120
  62. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/defaults/transitional.js +1 -0
  63. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/env/data.js +1 -1
  64. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
  65. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/Http2Sessions.js +2 -1
  66. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/composeSignals.js +6 -3
  67. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/cookies.js +30 -6
  68. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
  69. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
  70. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
  71. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/fromDataURI.js +8 -2
  72. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
  73. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
  74. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
  75. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/resolveConfig.js +16 -3
  76. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/helpers/shouldBypassProxy.js +16 -1
  77. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/lib/utils.js +61 -10
  78. package/node_modules/@larksuiteoapi/node-sdk/node_modules/axios/package.json +1 -2
  79. package/node_modules/@larksuiteoapi/node-sdk/node_modules/follow-redirects/README.md +27 -1
  80. package/node_modules/@larksuiteoapi/node-sdk/node_modules/follow-redirects/index.js +1 -5
  81. package/node_modules/@larksuiteoapi/node-sdk/node_modules/follow-redirects/package.json +1 -1
  82. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/.editorconfig +1 -1
  83. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/CHANGELOG.md +87 -22
  84. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/README.md +63 -10
  85. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/dist/qs.js +17 -17
  86. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/eslint.config.mjs +61 -50
  87. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/formats.js +7 -2
  88. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/parse.js +29 -10
  89. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/stringify.js +5 -3
  90. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/lib/utils.js +28 -9
  91. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/package.json +6 -6
  92. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/parse.js +335 -2
  93. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/stringify.js +222 -0
  94. package/node_modules/@larksuiteoapi/node-sdk/node_modules/qs/test/utils.js +61 -3
  95. package/node_modules/typebox/build/format/date_time.d.mts +2 -1
  96. package/node_modules/typebox/build/format/date_time.mjs +12 -3
  97. package/node_modules/typebox/package.json +1 -1
  98. package/openclaw.plugin.json +5 -0
  99. package/package.json +5 -5
  100. package/dist/.setup/runtime-setter-api-BrQHE03y.mjs +0 -2
@@ -1,7 +1,8 @@
1
- import { c as normalizeFeishuExternalKey, d as listEnabledFeishuAccounts, f as listFeishuAccountIds, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, m as resolveDefaultFeishuAccountId } from "./doctor-contract-CPh2u5-o.mjs";
2
- import { l as normalizeFeishuTarget, s as detectIdType, u as resolveReceiveIdType } from "./conversation-id-BLsHZ7pf.mjs";
3
- import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.mjs";
4
- import { c as withFeishuMessageDispatch, o as captureFeishuSendAuthority, r as createFeishuClient, s as runBeforeFeishuMessageDispatch } from "./client-DqGMyzOi.mjs";
1
+ import { c as normalizeFeishuExternalKey, d as listEnabledFeishuAccounts, f as listFeishuAccountIds, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, m as resolveDefaultFeishuAccountId } from "./doctor-contract-ItAh0keT.mjs";
2
+ import { l as normalizeFeishuTarget, s as detectIdType, u as resolveReceiveIdType } from "./conversation-id-N6q3vKm-.mjs";
3
+ import { t as getFeishuRuntime } from "./runtime-6V3uDMw5.mjs";
4
+ import { c as withFeishuMessageDispatch, o as captureFeishuSendAuthority, r as createFeishuClient, s as runBeforeFeishuMessageDispatch } from "./client-BAiJnY41.mjs";
5
+ import { t as raceWithTimeoutAndAbort } from "./async-WkOXCAZ1.mjs";
5
6
  import { normalizeAccountId, normalizeOptionalAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
6
7
  import { compileAllowlist, resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
7
8
  import { ToolAuthorizationError } from "openclaw/plugin-sdk/channel-actions";
@@ -15,6 +16,7 @@ import { convertMarkdownTables, markdownToIRWithMeta } from "openclaw/plugin-sdk
15
16
  import { jsonResult } from "openclaw/plugin-sdk/tool-results";
16
17
  import { resolveDefaultGroupPolicy, resolveOpenProviderRuntimeGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
17
18
  import { defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
19
+ import { evaluateSupplementalContextVisibility } from "openclaw/plugin-sdk/context-visibility-runtime";
18
20
  import path from "node:path";
19
21
  import { fromMarkdown } from "mdast-util-from-markdown";
20
22
  import { gfmTableFromMarkdown } from "mdast-util-gfm-table";
@@ -22,21 +24,22 @@ import { gfmTable } from "micromark-extension-gfm-table";
22
24
  import { chunkMarkdownTextWithMode } from "openclaw/plugin-sdk/reply-chunking";
23
25
  import { createAcceptedChannelDeliveryResult, createChannelPartialDeliveryError } from "openclaw/plugin-sdk/channel-inbound";
24
26
  import { resolveMarkdownTableMode } from "openclaw/plugin-sdk/markdown-table-runtime";
25
- import { wrapExternalContent } from "openclaw/plugin-sdk/security-runtime";
26
- import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
27
+ import { wrapExternalContent, writeExternalFileWithinRoot } from "openclaw/plugin-sdk/security-runtime";
28
+ import { isTransientNetworkError, retryAsync } from "openclaw/plugin-sdk/retry-runtime";
27
29
  import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers";
28
30
  import { Type } from "typebox";
29
31
  import { isBlockedHostnameOrIp, resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
30
32
  import { containsAsciiControlCharacter } from "openclaw/plugin-sdk/string-normalization-runtime";
31
33
  import { detectMime, mediaKindFromMime } from "openclaw/plugin-sdk/media-mime";
32
- import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, buildOutboundMediaLoadOptions, runFfprobe, transcodeAudioBufferToOpus } from "openclaw/plugin-sdk/media-runtime";
34
+ import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, buildOutboundMediaLoadOptions, runFfmpeg, runFfprobe, transcodeAudioBufferToOpus } from "openclaw/plugin-sdk/media-runtime";
33
35
  import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
34
- import { saveMediaStream } from "openclaw/plugin-sdk/media-store";
35
- import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
36
36
  import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
37
+ import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
38
+ import { saveMediaStream } from "openclaw/plugin-sdk/media-store";
37
39
  import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
38
40
  import { escapeHtml, escapeRegExp, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
39
- //#region extensions/feishu/src/card-interaction.ts
41
+ import { randomUUID } from "node:crypto";
42
+ // extensions/feishu/src/card-interaction.ts
40
43
  const FEISHU_CARD_INTERACTION_VERSION = "ocf1";
41
44
  function isInteractionKind(value) {
42
45
  return value === "button" || value === "quick" || value === "meta";
@@ -114,8 +117,7 @@ function decodeFeishuCardAction(event) {
114
117
  envelope: actionValue
115
118
  };
116
119
  }
117
- //#endregion
118
- //#region extensions/feishu/src/chat-type.ts
120
+ // extensions/feishu/src/chat-type.ts
119
121
  function normalizeFeishuChatType(value) {
120
122
  if (value === "group" || value === "topic_group") return "group";
121
123
  if (value === "p2p") return "p2p";
@@ -126,8 +128,7 @@ function normalizeFeishuChatMode(value) {
126
128
  function resolveFeishuChatType(chat) {
127
129
  return normalizeFeishuChatMode(chat.chat_mode) ?? normalizeFeishuChatType(chat.chat_type);
128
130
  }
129
- //#endregion
130
- //#region extensions/feishu/src/policy.ts
131
+ // extensions/feishu/src/policy.ts
131
132
  const FEISHU_PROVIDER_PREFIX_RE = /^(feishu|lark):/i;
132
133
  const FEISHU_TYPED_PREFIX_RE = /^(chat|group|channel|user|dm|open_id):/i;
133
134
  const FEISHU_ID_KIND = "plugin:feishu-id";
@@ -285,8 +286,26 @@ function resolveFeishuReplyPolicy(params) {
285
286
  groupId: params.groupId
286
287
  })?.requireMention ?? resolvedCfg.requireMention ?? params.groupPolicy !== "open" };
287
288
  }
288
- //#endregion
289
- //#region extensions/feishu/src/read-policy.ts
289
+ async function shouldIncludeFetchedGroupContextMessage(params) {
290
+ let senderAllowed = !params.isGroup || params.allowFrom.length === 0 || params.senderType === "app";
291
+ const senderId = params.senderId?.trim();
292
+ if (!senderAllowed && senderId) senderAllowed = (await resolveFeishuGroupSenderActivationIngressAccess({
293
+ cfg: params.cfg,
294
+ accountId: params.accountId,
295
+ chatId: params.chatId,
296
+ allowFrom: params.allowFrom,
297
+ senderOpenId: senderId,
298
+ senderUserId: senderId,
299
+ requireMention: false,
300
+ mentionedBot: true
301
+ })).senderAccess.decision === "allow";
302
+ return evaluateSupplementalContextVisibility({
303
+ mode: params.mode,
304
+ kind: params.kind,
305
+ senderAllowed
306
+ }).include;
307
+ }
308
+ // extensions/feishu/src/read-policy.ts
290
309
  function isActionContext(ctx) {
291
310
  return "toolContext" in ctx;
292
311
  }
@@ -439,8 +458,7 @@ function canEnumerateAllFeishuGroups(cfg, account) {
439
458
  const policy = resolveFeishuReadGroupPolicy(cfg, account);
440
459
  return policy === "open" || policy === "allowlist" && compileAllowlist(normalizeFeishuAllowlist(account.config.groupAllowFrom)).wildcard;
441
460
  }
442
- //#endregion
443
- //#region extensions/feishu/src/markdown.ts
461
+ // extensions/feishu/src/markdown.ts
444
462
  const FEISHU_POST_MAX_BYTES = 30720;
445
463
  function shouldUseFeishuCard(text) {
446
464
  return /```[\s\S]*?```/.test(text) || /\|.+\|[\r\n]+\|[-:| ]+\|/.test(text);
@@ -580,8 +598,7 @@ function chunkFeishuMarkdownByEnvelope(params) {
580
598
  }
581
599
  return output;
582
600
  }
583
- //#endregion
584
- //#region extensions/feishu/src/native-card.ts
601
+ // extensions/feishu/src/native-card.ts
585
602
  const FEISHU_CARD_TEMPLATES = /* @__PURE__ */ new Set([
586
603
  "blue",
587
604
  "green",
@@ -712,8 +729,7 @@ function readNativeFeishuCardJson(text, options) {
712
729
  return;
713
730
  }
714
731
  }
715
- //#endregion
716
- //#region extensions/feishu/src/comment-target.ts
732
+ // extensions/feishu/src/comment-target.ts
717
733
  const FEISHU_COMMENT_FILE_TYPES = [
718
734
  "doc",
719
735
  "docx",
@@ -742,8 +758,7 @@ function parseFeishuCommentTarget(raw) {
742
758
  commentId
743
759
  };
744
760
  }
745
- //#endregion
746
- //#region extensions/feishu/src/comment-shared.ts
761
+ // extensions/feishu/src/comment-shared.ts
747
762
  var FeishuReplyCommentError = class extends Error {
748
763
  constructor(params) {
749
764
  super(params.message);
@@ -794,18 +809,9 @@ function formatFeishuApiError(error, options = {}) {
794
809
  feishu_troubleshooter: meta.troubleshooter
795
810
  });
796
811
  }
797
- const FEISHU_SEND_RETRY_BASE_MS = 500;
798
812
  const FEISHU_SEND_RATE_LIMIT_CODES = /* @__PURE__ */ new Set([230020, 11232]);
799
- function getFeishuSendRateLimitCode(error) {
800
- if (!isRecord(error)) return;
801
- const response = isRecord(error.response) ? error.response : void 0;
802
- if (response?.status === 429) return 429;
803
- return getFeishuSendRateLimitCodeFromResponse(response?.data);
804
- }
805
- function getFeishuSendRateLimitCodeFromResponse(response) {
806
- if (!isRecord(response)) return;
807
- const code = response.code;
808
- return typeof code === "number" && FEISHU_SEND_RATE_LIMIT_CODES.has(code) ? code : void 0;
813
+ function isRetryableFeishuResponse(response, retryTransient = false) {
814
+ return isRecord(response) && typeof response.code === "number" && (FEISHU_SEND_RATE_LIMIT_CODES.has(response.code) || retryTransient && response.code === 230049);
809
815
  }
810
816
  async function requestFeishuApi(request, errorPrefix, options = {}) {
811
817
  const assertSendAuthority = captureFeishuSendAuthority();
@@ -813,16 +819,20 @@ async function requestFeishuApi(request, errorPrefix, options = {}) {
813
819
  return await retryAsync(async () => {
814
820
  assertSendAuthority?.();
815
821
  const result = await request();
816
- const fulfilledRateLimit = getFeishuSendRateLimitCodeFromResponse(result);
817
- if (fulfilledRateLimit !== void 0) throw Object.assign(/* @__PURE__ */ new Error(`Request fulfilled with rate-limit code ${fulfilledRateLimit}`), { response: {
822
+ if (isRetryableFeishuResponse(result, options.retryTransient)) throw Object.assign(/* @__PURE__ */ new Error("Request fulfilled with a retryable Feishu error"), { response: {
818
823
  status: 200,
819
824
  data: result
820
825
  } });
821
826
  return result;
822
827
  }, {
823
828
  attempts: 3,
824
- minDelayMs: FEISHU_SEND_RETRY_BASE_MS,
825
- shouldRetry: (error) => getFeishuSendRateLimitCode(error) !== void 0
829
+ minDelayMs: 500,
830
+ shouldRetry: (error) => {
831
+ if (!isRecord(error) || error.retryable === false) return false;
832
+ const response = isRecord(error.response) ? error.response : void 0;
833
+ const status = response?.status;
834
+ return status === 429 || isRetryableFeishuResponse(response?.data, options.retryTransient) || options.retryTransient === true && (isTransientNetworkError(error) || error.code === "ERR_NETWORK" || typeof status === "number" && (status === 408 || status === 425 || status >= 500 && status <= 599));
835
+ }
826
836
  });
827
837
  } catch (error) {
828
838
  const details = formatFeishuApiError(error, options);
@@ -967,8 +977,7 @@ function extractReplyText(reply) {
967
977
  if (!reply || !isRecord(reply.content)) return;
968
978
  return parseCommentContentElements({ elements: Array.isArray(reply.content.elements) ? reply.content.elements : [] }).plainText;
969
979
  }
970
- //#endregion
971
- //#region extensions/feishu/src/comment-reaction.ts
980
+ // extensions/feishu/src/comment-reaction.ts
972
981
  const COMMENT_TYPING_REACTION_TYPE = "Typing";
973
982
  const COMMENT_REACTION_TIMEOUT_MS = 3e4;
974
983
  const activeCommentTypingReactions = /* @__PURE__ */ new Set();
@@ -1062,13 +1071,11 @@ function createCommentTypingReactionLifecycle(params) {
1062
1071
  }
1063
1072
  };
1064
1073
  }
1065
- //#endregion
1066
- //#region extensions/feishu/src/api-response.ts
1074
+ // extensions/feishu/src/api-response.ts
1067
1075
  function assertFeishuApiSuccess(response, errorPrefix) {
1068
1076
  if (response.code !== 0) throw new Error(errorPrefix === void 0 ? response.msg : `${errorPrefix}: ${response.msg || `code ${response.code}`}`);
1069
1077
  }
1070
- //#endregion
1071
- //#region extensions/feishu/src/tools-config.ts
1078
+ // extensions/feishu/src/tools-config.ts
1072
1079
  const DEFAULT_TOOLS_CONFIG = {
1073
1080
  doc: true,
1074
1081
  chat: true,
@@ -1084,8 +1091,7 @@ function resolveToolsConfig(cfg) {
1084
1091
  ...cfg
1085
1092
  };
1086
1093
  }
1087
- //#endregion
1088
- //#region extensions/feishu/src/tool-account.ts
1094
+ // extensions/feishu/src/tool-account.ts
1089
1095
  function resolveImplicitToolAccountId(params) {
1090
1096
  const explicitAccountId = normalizeOptionalString(params.executeParams?.accountId);
1091
1097
  if (explicitAccountId) {
@@ -1135,13 +1141,12 @@ function resolveFeishuToolAccount(params) {
1135
1141
  function createFeishuToolClient(params) {
1136
1142
  return createFeishuClient(resolveFeishuToolAccount(params));
1137
1143
  }
1138
- //#endregion
1139
- //#region extensions/feishu/src/tool-result.ts
1144
+ // extensions/feishu/src/tool-result.ts
1140
1145
  function feishuExternalToolResult(details) {
1141
1146
  return {
1142
1147
  content: [{
1143
1148
  type: "text",
1144
- text: wrapExternalContent(JSON.stringify(details, null, 2), {
1149
+ text: wrapExternalContent(JSON.stringify(details), {
1145
1150
  source: "api",
1146
1151
  includeWarning: false
1147
1152
  })
@@ -1170,8 +1175,7 @@ function toolExecutionErrorResult(error) {
1170
1175
  }
1171
1176
  return feishuExternalToolResult({ error: message });
1172
1177
  }
1173
- //#endregion
1174
- //#region extensions/feishu/src/tool-registration.ts
1178
+ // extensions/feishu/src/tool-registration.ts
1175
1179
  function registerFeishuTool(api, tool) {
1176
1180
  api.registerTool((ctx) => {
1177
1181
  const cfg = ctx.runtimeConfig ?? ctx.config ?? api.config;
@@ -1204,8 +1208,7 @@ function registerFeishuTool(api, tool) {
1204
1208
  ...tool.workspaceAccess !== void 0 ? { workspaceAccess: tool.workspaceAccess } : {}
1205
1209
  });
1206
1210
  }
1207
- //#endregion
1208
- //#region extensions/feishu/src/drive.ts
1211
+ // extensions/feishu/src/drive.ts
1209
1212
  const FileType = Type.Union([
1210
1213
  Type.Literal("doc"),
1211
1214
  Type.Literal("docx"),
@@ -1591,8 +1594,7 @@ function registerFeishuDriveTools(api) {
1591
1594
  }
1592
1595
  });
1593
1596
  }
1594
- //#endregion
1595
- //#region extensions/feishu/src/identity-header.ts
1597
+ // extensions/feishu/src/identity-header.ts
1596
1598
  const emojiSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
1597
1599
  const keycapEmojiPattern = /^[0-9#*]\uFE0F?\u20E3$/u;
1598
1600
  const emojiLikeSegmentPattern = /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}]/u;
@@ -1626,8 +1628,7 @@ function resolveCardNote(agentId, identity, prefixCtx) {
1626
1628
  if (prefixCtx.provider) parts.push(`Provider: ${prefixCtx.provider}`);
1627
1629
  return parts.join(" | ");
1628
1630
  }
1629
- //#endregion
1630
- //#region extensions/feishu/src/media-fallback.ts
1631
+ // extensions/feishu/src/media-fallback.ts
1631
1632
  const FEISHU_MEDIA_UPLOAD_FAILURE_FALLBACK_TEXT = "Media upload failed. Please try again.";
1632
1633
  async function resolvePublicFeishuMediaReference(value) {
1633
1634
  const raw = value?.trim();
@@ -1647,8 +1648,7 @@ async function buildFeishuMediaFallbackText(params) {
1647
1648
  const attachmentText = mediaUrl ? `${params.mediaLinkStyle === "plain" ? "" : "📎 "}${mediaUrl}` : FEISHU_MEDIA_UPLOAD_FAILURE_FALLBACK_TEXT;
1648
1649
  return [params.text?.trim(), attachmentText].filter(Boolean).join("\n\n");
1649
1650
  }
1650
- //#endregion
1651
- //#region extensions/feishu/src/media-chunk-idle.ts
1651
+ // extensions/feishu/src/media-chunk-idle.ts
1652
1652
  async function saveMediaStreamWithIdleTimeout(stream, contentType, maxBytes, fileName, chunkTimeoutMs) {
1653
1653
  let teardownAttempted = false;
1654
1654
  const teardownSource = () => {
@@ -1690,15 +1690,13 @@ async function saveMediaStreamWithIdleTimeout(stream, contentType, maxBytes, fil
1690
1690
  throw error;
1691
1691
  }
1692
1692
  }
1693
- //#endregion
1694
- //#region extensions/feishu/src/configured-client.ts
1693
+ // extensions/feishu/src/configured-client.ts
1695
1694
  function createConfiguredFeishuClient(params) {
1696
1695
  const account = resolveFeishuRuntimeAccount(params);
1697
1696
  if (!account.configured) throw new Error(`Feishu account "${account.accountId}" not configured`);
1698
1697
  return createFeishuClient(account);
1699
1698
  }
1700
- //#endregion
1701
- //#region extensions/feishu/src/send-target.ts
1699
+ // extensions/feishu/src/send-target.ts
1702
1700
  function resolveFeishuSendTarget(params) {
1703
1701
  const target = params.to.trim();
1704
1702
  const client = createConfiguredFeishuClient(params);
@@ -1711,8 +1709,7 @@ function resolveFeishuSendTarget(params) {
1711
1709
  receiveIdType: resolveReceiveIdType(withoutProviderPrefix)
1712
1710
  };
1713
1711
  }
1714
- //#endregion
1715
- //#region extensions/feishu/src/bot-sender-name.ts
1712
+ // extensions/feishu/src/bot-sender-name.ts
1716
1713
  const STALE_CONTACT_SCOPE = "contact:contact.base:readonly";
1717
1714
  const FEISHU_USER_LOOKUP_UNAUTHORIZED_CODE = 41050;
1718
1715
  const SENDER_NAME_TTL_MS = 6e5;
@@ -1735,7 +1732,7 @@ async function resolveFeishuSenderName(params) {
1735
1732
  if (!normalizedSenderId) return {};
1736
1733
  const cacheKey = `${account.accountId}:${normalizedSenderId}`;
1737
1734
  const cached = senderNameCache.get(cacheKey);
1738
- if (cached && cached.expireAt > Date.now()) return cached.kind === "resolved" ? { name: cached.name } : {};
1735
+ if (cached && cached.expireAt > performance.now()) return cached.kind === "resolved" ? { name: cached.name } : {};
1739
1736
  if (cached) senderNameCache.delete(cacheKey);
1740
1737
  try {
1741
1738
  const client = createFeishuClient(account);
@@ -1749,7 +1746,7 @@ async function resolveFeishuSenderName(params) {
1749
1746
  writeSenderNameCache(cacheKey, {
1750
1747
  kind: "resolved",
1751
1748
  name,
1752
- expireAt: Date.now() + SENDER_NAME_TTL_MS
1749
+ expireAt: performance.now() + SENDER_NAME_TTL_MS
1753
1750
  });
1754
1751
  return { name };
1755
1752
  }
@@ -1772,7 +1769,7 @@ async function resolveFeishuSenderName(params) {
1772
1769
  if (feishuErr?.code === FEISHU_USER_LOOKUP_UNAUTHORIZED_CODE) {
1773
1770
  writeSenderNameCache(cacheKey, {
1774
1771
  kind: "unavailable",
1775
- expireAt: Date.now() + SENDER_NAME_NEGATIVE_TTL_MS
1772
+ expireAt: performance.now() + SENDER_NAME_NEGATIVE_TTL_MS
1776
1773
  });
1777
1774
  return {};
1778
1775
  }
@@ -1780,8 +1777,7 @@ async function resolveFeishuSenderName(params) {
1780
1777
  return {};
1781
1778
  }
1782
1779
  }
1783
- //#endregion
1784
- //#region extensions/feishu/src/post.ts
1780
+ // extensions/feishu/src/post.ts
1785
1781
  const FALLBACK_POST_TEXT = "[Rich text message]";
1786
1782
  const MARKDOWN_SPECIAL_CHARS = /([\\`*_{}[\]()#+\-!|>~])/g;
1787
1783
  function toStringOrEmpty(value) {
@@ -1810,7 +1806,7 @@ function renderLinkElement(element) {
1810
1806
  const text = toStringOrEmpty(element.text) || href;
1811
1807
  if (!text) return "";
1812
1808
  if (!href) return escapeMarkdownText(text);
1813
- return `[${escapeMarkdownText(text)}](${href})`;
1809
+ return `[${escapeMarkdownText(text)}](${href.replace(/[\\()<>\s]/gu, (character) => character === "(" || character === ")" ? `\\${character}` : encodeURIComponent(character))})`;
1814
1810
  }
1815
1811
  function renderMentionElement(element) {
1816
1812
  const mention = toStringOrEmpty(element.user_name) || toStringOrEmpty(element.user_id) || toStringOrEmpty(element.open_id);
@@ -1951,8 +1947,7 @@ function renderPostContent(parsed, options = {}) {
1951
1947
  };
1952
1948
  }
1953
1949
  }
1954
- //#endregion
1955
- //#region extensions/feishu/src/interactive-message-content.ts
1950
+ // extensions/feishu/src/interactive-message-content.ts
1956
1951
  const INTERACTIVE_CARD_FALLBACK_TEXT = "[Interactive Card]";
1957
1952
  const POST_FALLBACK_TEXT = "[Rich text message]";
1958
1953
  function normalizeCardTemplateVariable(value) {
@@ -2073,16 +2068,14 @@ function parseInteractiveCardContent(parsed) {
2073
2068
  if (postText && postText !== POST_FALLBACK_TEXT) return postText;
2074
2069
  return title || INTERACTIVE_CARD_FALLBACK_TEXT;
2075
2070
  }
2076
- //#endregion
2077
- //#region extensions/feishu/src/types.ts
2071
+ // extensions/feishu/src/types.ts
2078
2072
  function normalizeFeishuEventChatType(value) {
2079
2073
  return value === "group" || value === "topic_group" || value === "private" || value === "p2p" ? value : void 0;
2080
2074
  }
2081
2075
  function isFeishuGroupChatType(chatType) {
2082
2076
  return chatType === "group" || chatType === "topic_group";
2083
2077
  }
2084
- //#endregion
2085
- //#region extensions/feishu/src/mention.ts
2078
+ // extensions/feishu/src/mention.ts
2086
2079
  function normalizeMentions(text, mentions) {
2087
2080
  if (!mentions || mentions.length === 0) return text;
2088
2081
  const escapeName = (value) => value.replace(/</g, "&lt;").replace(/>/g, "&gt;");
@@ -2130,8 +2123,7 @@ function buildMentionedCardContent(targets, message) {
2130
2123
  if (targets.length === 0) return message;
2131
2124
  return `${targets.map((target) => `<at id=${target.openId}></at>`).join(" ")} ${message}`;
2132
2125
  }
2133
- //#endregion
2134
- //#region extensions/feishu/src/message-content.ts
2126
+ // extensions/feishu/src/message-content.ts
2135
2127
  function formatFeishuMediaContent(parsed, messageType) {
2136
2128
  if (messageType === "sticker") {
2137
2129
  const fileKey = normalizeFeishuExternalKey(parsed?.file_key);
@@ -2183,8 +2175,32 @@ async function parseMergeForwardContent(items, resolveSenderName) {
2183
2175
  return rendered.length <= 2e4 ? rendered : `${truncateUtf16Safe(rendered, 19961).trimEnd()}
2184
2176
  ... [Merged-forward content truncated]`;
2185
2177
  }
2186
- //#endregion
2187
- //#region extensions/feishu/src/send-result.ts
2178
+ // extensions/feishu/src/message-send.ts
2179
+ function sendFeishuMessage(target, params, errorPrefix) {
2180
+ const data = {
2181
+ content: params.content,
2182
+ msg_type: params.msgType,
2183
+ uuid: randomUUID()
2184
+ };
2185
+ return requestFeishuApi(() => withFeishuMessageDispatch(() => params.replyToMessageId ? target.client.im.message.reply({
2186
+ path: { message_id: params.replyToMessageId },
2187
+ data: {
2188
+ ...data,
2189
+ ...params.replyInThread ? { reply_in_thread: true } : {}
2190
+ }
2191
+ }) : target.client.im.message.create({
2192
+ params: { receive_id_type: target.receiveIdType },
2193
+ data: {
2194
+ ...data,
2195
+ receive_id: target.receiveId,
2196
+ ...params.rootId ? { root_id: params.rootId } : {}
2197
+ }
2198
+ })), errorPrefix, {
2199
+ includeNestedErrorLogId: true,
2200
+ retryTransient: true
2201
+ });
2202
+ }
2203
+ // extensions/feishu/src/send-result.ts
2188
2204
  function resolveFeishuReceiptKind(msgType) {
2189
2205
  switch (msgType) {
2190
2206
  case "audio": return "voice";
@@ -2229,19 +2245,7 @@ function toFeishuSendResult(response, chatId, kind, errorPrefix = "Feishu send f
2229
2245
  })
2230
2246
  };
2231
2247
  }
2232
- function toFeishuMessageSendResult(result, kind) {
2233
- const receipt = result.receipt ?? createFeishuSendReceipt({
2234
- messageId: result.messageId,
2235
- chatId: result.chatId ?? "",
2236
- kind
2237
- });
2238
- return {
2239
- messageId: result.messageId || receipt.primaryPlatformMessageId,
2240
- receipt
2241
- };
2242
- }
2243
- //#endregion
2244
- //#region extensions/feishu/src/send.ts
2248
+ // extensions/feishu/src/send.ts
2245
2249
  const WITHDRAWN_REPLY_ERROR_CODES = /* @__PURE__ */ new Set([230011, 231003]);
2246
2250
  function shouldFallbackFromReplyTarget(response) {
2247
2251
  if (response.code !== void 0 && WITHDRAWN_REPLY_ERROR_CODES.has(response.code)) return true;
@@ -2259,16 +2263,12 @@ function isWithdrawnReplyError(err) {
2259
2263
  return false;
2260
2264
  }
2261
2265
  async function sendReplyOrFallbackDirect(target, params) {
2262
- const { client, receiveId, receiveIdType } = target;
2266
+ const { receiveId } = target;
2263
2267
  const sendDirect = async () => {
2264
- const response = await requestFeishuApi(() => withFeishuMessageDispatch(() => client.im.message.create({
2265
- params: { receive_id_type: receiveIdType },
2266
- data: {
2267
- receive_id: receiveId,
2268
- content: params.content,
2269
- msg_type: params.msgType
2270
- }
2271
- })), params.directErrorPrefix, { includeNestedErrorLogId: true });
2268
+ const response = await sendFeishuMessage(target, {
2269
+ ...params,
2270
+ replyToMessageId: void 0
2271
+ }, params.directErrorPrefix);
2272
2272
  assertFeishuApiSuccess(response, params.directErrorPrefix);
2273
2273
  return toFeishuSendResult(response, receiveId, resolveFeishuReceiptKind(params.msgType), params.directErrorPrefix);
2274
2274
  };
@@ -2276,14 +2276,7 @@ async function sendReplyOrFallbackDirect(target, params) {
2276
2276
  const replyTargetFallbackError = params.replyInThread && params.allowTopLevelReplyFallback !== true ? /* @__PURE__ */ new Error("Feishu thread reply failed: reply target is unavailable and cannot safely fall back to a top-level send.") : null;
2277
2277
  let response;
2278
2278
  try {
2279
- response = await requestFeishuApi(() => withFeishuMessageDispatch(() => client.im.message.reply({
2280
- path: { message_id: params.replyToMessageId },
2281
- data: {
2282
- content: params.content,
2283
- msg_type: params.msgType,
2284
- ...params.replyInThread ? { reply_in_thread: true } : {}
2285
- }
2286
- })), params.replyErrorPrefix, { includeNestedErrorLogId: true });
2279
+ response = await sendFeishuMessage(target, params, params.replyErrorPrefix);
2287
2280
  } catch (err) {
2288
2281
  if (!isWithdrawnReplyError(err)) throw err;
2289
2282
  if (replyTargetFallbackError) throw replyTargetFallbackError;
@@ -2533,8 +2526,7 @@ async function sendStructuredCardFeishu(params) {
2533
2526
  card: buildStructuredCard(params.text, params)
2534
2527
  });
2535
2528
  }
2536
- //#endregion
2537
- //#region extensions/feishu/src/media.ts
2529
+ // extensions/feishu/src/media.ts
2538
2530
  const FEISHU_MEDIA_HTTP_TIMEOUT_MS = 12e4;
2539
2531
  const FEISHU_MAX_FILE_UPLOAD_BYTES = 31457280;
2540
2532
  const FEISHU_MAX_IMAGE_UPLOAD_BYTES = 10485760;
@@ -2568,7 +2560,7 @@ const FEISHU_TRANSCODABLE_AUDIO_EXTS = /* @__PURE__ */ new Set([
2568
2560
  ".webm",
2569
2561
  ".wma"
2570
2562
  ]);
2571
- function createConfiguredFeishuMediaClient(params) {
2563
+ function createConfiguredFeishuMediaClient(params, httpTimeoutMs = FEISHU_MEDIA_HTTP_TIMEOUT_MS) {
2572
2564
  const account = resolveFeishuRuntimeAccount({
2573
2565
  cfg: params.cfg,
2574
2566
  accountId: params.accountId
@@ -2576,7 +2568,7 @@ function createConfiguredFeishuMediaClient(params) {
2576
2568
  if (!account.configured) throw new Error(`Feishu account "${account.accountId}" not configured`);
2577
2569
  return createFeishuClient({
2578
2570
  ...account,
2579
- httpTimeoutMs: FEISHU_MEDIA_HTTP_TIMEOUT_MS
2571
+ httpTimeoutMs
2580
2572
  });
2581
2573
  }
2582
2574
  function asHeaderMap(value) {
@@ -2613,14 +2605,35 @@ function recoverUtf8FileNameFromLatin1Header(value) {
2613
2605
  if (recovered !== value && !recovered.includes("�") && containsEastAsianScript(recovered)) return recovered;
2614
2606
  return value;
2615
2607
  }
2608
+ function findDispositionParameter(value, name) {
2609
+ let start = 0;
2610
+ let quoted = false;
2611
+ let escaped = false;
2612
+ for (let index = 0; index <= value.length; index++) {
2613
+ const char = value[index];
2614
+ if (index === value.length || char === ";" && !quoted) {
2615
+ const parameter = value.slice(start, index).trim();
2616
+ const separator = parameter.indexOf("=");
2617
+ if (separator >= 0 && parameter.slice(0, separator).trim().toLowerCase() === name) return parameter.slice(separator + 1).trim();
2618
+ start = index + 1;
2619
+ continue;
2620
+ }
2621
+ if (quoted && escaped) escaped = false;
2622
+ else if (quoted && char === "\\") escaped = true;
2623
+ else if (char === "\"") quoted = !quoted;
2624
+ }
2625
+ }
2616
2626
  function decodeDispositionFileName(value) {
2617
- const utf8Match = value.match(/filename\*=UTF-8''([^;]+)/i);
2627
+ const utf8Match = findDispositionParameter(value, "filename*")?.match(/^UTF-8''(.+)$/i);
2618
2628
  if (utf8Match?.[1]) try {
2619
2629
  return decodeURIComponent(utf8Match[1].trim().replace(/^"(.*)"$/, "$1"));
2620
2630
  } catch {
2621
2631
  return utf8Match[1].trim().replace(/^"(.*)"$/, "$1");
2622
2632
  }
2623
- const plainFileName = value.match(/filename="?([^";]+)"?/i)?.[1]?.trim();
2633
+ const plainValue = findDispositionParameter(value, "filename");
2634
+ let plainFileName;
2635
+ if (plainValue?.startsWith("\"")) plainFileName = plainValue.match(/^"((?:\\.|[^"\\])*)"$/s)?.[1]?.replace(/\\(.)/gs, "$1").trim();
2636
+ else if (plainValue && /^[^";]*$/.test(plainValue)) plainFileName = plainValue.trim();
2624
2637
  return plainFileName ? recoverUtf8FileNameFromLatin1Header(plainFileName) : void 0;
2625
2638
  }
2626
2639
  async function saveMessageResourceWithType(params) {
@@ -2710,7 +2723,7 @@ async function resolveFeishuOutboundMediaKind(params) {
2710
2723
  const ext = normalizeLowercaseStringOrEmpty(path.extname(fileName));
2711
2724
  const detectedContentType = await detectMime({ buffer }) ?? "";
2712
2725
  if (FEISHU_SUPPORTED_IMAGE_CONTENT_TYPES.has(detectedContentType)) return { msgType: "image" };
2713
- if (ext === ".opus" || ext === ".ogg" || contentType === "audio/ogg" || contentType === "audio/opus") return {
2726
+ if (isOggOpusAudio(buffer)) return {
2714
2727
  fileType: "opus",
2715
2728
  msgType: "audio"
2716
2729
  };
@@ -2735,6 +2748,12 @@ function assertFeishuUploadWithinEnvelope(params) {
2735
2748
  throw new Error(`Feishu ${label} exceeds its ${String(maxBytes)}-byte upload limit`);
2736
2749
  }
2737
2750
  }
2751
+ function isOggOpusAudio(buffer) {
2752
+ const segmentCount = buffer[26];
2753
+ if (!segmentCount || buffer.toString("latin1", 0, 4) !== "OggS") return false;
2754
+ const packetOffset = 27 + segmentCount;
2755
+ return buffer.length >= packetOffset + 19 && buffer.toString("latin1", packetOffset, packetOffset + 8) === "OpusHead";
2756
+ }
2738
2757
  function isFeishuNativeVoiceAudio(params) {
2739
2758
  const ext = normalizeLowercaseStringOrEmpty(path.extname(params.fileName));
2740
2759
  const contentType = normalizeLowercaseStringOrEmpty(params.contentType);
@@ -2787,6 +2806,46 @@ async function probeMediaDurationMs(params) {
2787
2806
  return;
2788
2807
  }
2789
2808
  }
2809
+ async function prepareVideoCover(buffer, maxBytes, uploadImage) {
2810
+ try {
2811
+ const cover = await withTempWorkspace({
2812
+ rootDir: resolvePreferredOpenClawTmpDir(),
2813
+ prefix: "feishu-video-cover-"
2814
+ }, async (workspace) => {
2815
+ const input = await workspace.write("video", buffer);
2816
+ await writeExternalFileWithinRoot({
2817
+ rootDir: workspace.dir,
2818
+ path: "cover.jpg",
2819
+ write: async (output) => {
2820
+ await runFfmpeg([
2821
+ "-y",
2822
+ "-i",
2823
+ input,
2824
+ "-frames:v",
2825
+ "1",
2826
+ "-vf",
2827
+ "scale=1280:720:force_original_aspect_ratio=decrease",
2828
+ "-c:v",
2829
+ "mjpeg",
2830
+ "-f",
2831
+ "image2",
2832
+ "-fs",
2833
+ String(maxBytes + 1),
2834
+ output
2835
+ ], { timeoutMs: 5e3 });
2836
+ }
2837
+ });
2838
+ return workspace.read("cover.jpg");
2839
+ });
2840
+ if (!cover.length || cover.length > maxBytes) throw new Error("Video cover is empty or exceeds the image upload limit");
2841
+ const result = await raceWithTimeoutAndAbort(uploadImage(cover), { timeoutMs: 5e3 });
2842
+ if (result.status !== "resolved") throw new Error("Video cover upload timed out");
2843
+ return result.value;
2844
+ } catch (err) {
2845
+ console.warn("[feishu] video cover unavailable; sending file:", String(err));
2846
+ return;
2847
+ }
2848
+ }
2790
2849
  /**
2791
2850
  * Upload and send media (image or file) from URL, local path, or buffer.
2792
2851
  * Local paths require host-owned mediaAccess or approved legacy roots/readers.
@@ -2831,7 +2890,7 @@ async function sendMediaFeishu(params) {
2831
2890
  msgType: loadedRouting.msgType
2832
2891
  }));
2833
2892
  const prepared = await runBeforeFeishuMessageDispatch(async () => {
2834
- if (isFeishuNativeVoiceAudio(loaded) || audioAsVoice !== true) return loaded;
2893
+ if (isOggOpusAudio(loaded.buffer) || audioAsVoice !== true) return loaded;
2835
2894
  const ext = normalizeLowercaseStringOrEmpty(path.extname(loaded.fileName));
2836
2895
  const contentType = normalizeLowercaseStringOrEmpty(loaded.contentType);
2837
2896
  if (!FEISHU_TRANSCODABLE_AUDIO_EXTS.has(ext) && mediaKindFromMime(contentType) !== "audio") return loaded;
@@ -2875,36 +2934,40 @@ async function sendMediaFeishu(params) {
2875
2934
  fileName: name,
2876
2935
  contentType
2877
2936
  }) : void 0;
2937
+ const upload = (uploadBuffer, isImage, httpTimeoutMs) => runBeforeFeishuMessageDispatch(async () => {
2938
+ const client = createConfiguredFeishuMediaClient({
2939
+ cfg,
2940
+ accountId
2941
+ }, httpTimeoutMs);
2942
+ const errorPrefix = `Feishu ${isImage ? "image" : "file"} upload failed`;
2943
+ const response = await requestFeishuApi(() => isImage ? client.im.image.create({ data: {
2944
+ image_type: "message",
2945
+ image: uploadBuffer
2946
+ } }) : client.im.file.create({ data: {
2947
+ file_type: routing.fileType ?? "stream",
2948
+ file_name: sanitizeFileNameForUpload(name),
2949
+ file: uploadBuffer,
2950
+ ...durationMs !== void 0 ? { duration: durationMs } : {}
2951
+ } }), errorPrefix, { includeNestedErrorLogId: true });
2952
+ const keyName = isImage ? "image_key" : "file_key";
2953
+ if (!response) throw new Error(`${errorPrefix}: empty response`);
2954
+ const wrappedResponse = response;
2955
+ if (wrappedResponse.code !== void 0 && wrappedResponse.code !== 0) throw new Error(`${errorPrefix}: ${wrappedResponse.msg || `code ${wrappedResponse.code}`}`);
2956
+ const key = wrappedResponse[keyName] ?? wrappedResponse.data?.[keyName];
2957
+ if (!key) throw new Error(`${errorPrefix}: no ${keyName} returned`);
2958
+ return key;
2959
+ });
2960
+ const key = await upload(buffer, routing.msgType === "image");
2961
+ const imageKey = routing.msgType === "media" ? await prepareVideoCover(buffer, Math.min(mediaMaxBytes, FEISHU_MAX_IMAGE_UPLOAD_BYTES), (image) => upload(image, true, 5e3)) : void 0;
2878
2962
  return {
2879
- ...await sendUploadedMediaFeishu(params, await runBeforeFeishuMessageDispatch(async () => {
2880
- const client = createConfiguredFeishuMediaClient({
2881
- cfg,
2882
- accountId
2883
- });
2884
- const isImage = routing.msgType === "image";
2885
- const errorPrefix = `Feishu ${isImage ? "image" : "file"} upload failed`;
2886
- const response = await requestFeishuApi(() => isImage ? client.im.image.create({ data: {
2887
- image_type: "message",
2888
- image: buffer
2889
- } }) : client.im.file.create({ data: {
2890
- file_type: routing.fileType ?? "stream",
2891
- file_name: sanitizeFileNameForUpload(name),
2892
- file: buffer,
2893
- ...durationMs !== void 0 ? { duration: durationMs } : {}
2894
- } }), errorPrefix, { includeNestedErrorLogId: true });
2895
- const keyName = isImage ? "image_key" : "file_key";
2896
- if (!response) throw new Error(`${errorPrefix}: empty response`);
2897
- const wrappedResponse = response;
2898
- if (wrappedResponse.code !== void 0 && wrappedResponse.code !== 0) throw new Error(`${errorPrefix}: ${wrappedResponse.msg || `code ${wrappedResponse.code}`}`);
2899
- const key = wrappedResponse[keyName] ?? wrappedResponse.data?.[keyName];
2900
- if (!key) throw new Error(`${errorPrefix}: no ${keyName} returned`);
2901
- return isImage ? { image_key: key } : { file_key: key };
2902
- }), routing.msgType),
2963
+ ...await sendUploadedMediaFeishu(params, routing.msgType === "image" ? { image_key: key } : {
2964
+ file_key: key,
2965
+ ...imageKey ? { image_key: imageKey } : {}
2966
+ }, routing.msgType === "media" && !imageKey ? "file" : routing.msgType),
2903
2967
  ...voiceIntentDegradedToFile ? { voiceIntentDegradedToFile: true } : {}
2904
2968
  };
2905
2969
  }
2906
- //#endregion
2907
- //#region extensions/feishu/src/presentation-card.ts
2970
+ // extensions/feishu/src/presentation-card.ts
2908
2971
  const RENDERED_FEISHU_CARD = Symbol("openclaw.renderedFeishuCard");
2909
2972
  const FEISHU_PRESENTATION_FALLBACK_MARKER = "__openclawPresentationFallback";
2910
2973
  const FEISHU_PRESENTATION_CAPABILITIES = {
@@ -3216,8 +3279,7 @@ async function renderFeishuReplyPayload(payload, ctx) {
3216
3279
  card: readNativeFeishuCard(withoutInteractive)
3217
3280
  };
3218
3281
  }
3219
- //#endregion
3220
- //#region extensions/feishu/src/reply-delivery-result.ts
3282
+ // extensions/feishu/src/reply-delivery-result.ts
3221
3283
  const noVisibleFeishuReplyDelivery = { visibleReplySent: false };
3222
3284
  function shouldSendNoVisibleReplyFallback(dispatchResult) {
3223
3285
  const emptyEligibleDispatch = dispatchResult.noVisibleReplyFallbackEligible === true && dispatchResult.settledReceipt?.anyVisibleDelivered !== true;
@@ -3258,5 +3320,4 @@ function createFeishuPartialReplyDeliveryError(cause, result) {
3258
3320
  visibleReplySent: true
3259
3321
  });
3260
3322
  }
3261
- //#endregion
3262
- export { resolveFeishuToolAccount as $, sendMessageFeishu as A, resolveFeishuGroupConfig as At, parseInteractiveCardContent as B, sendStickerFeishu as C, isFeishuGroupReadAllowed as Ct, getMessageFeishu as D, hasExplicitFeishuGroupConfig as Dt, editMessageFeishu as E, resolveFeishuChatReadPreliminaryAuthorization as Et, isFeishuBroadcastMention as F, normalizeFeishuChatType as Ft, resolveCardHeader as G, resolveFeishuSenderName as H, isMentionForwardRequest as I, resolveFeishuChatType as It, deliverCommentThreadText as J, resolveCardNote as K, normalizeMentions as L, FEISHU_CARD_INTERACTION_VERSION as Lt, toFeishuMessageSendResult as M, resolveFeishuGroupSenderActivationIngressAccess as Mt, formatFeishuMediaContent as N, resolveFeishuGroupToolPolicy as Nt, listFeishuThreadMessages as O, normalizeFeishuAllowEntry as Ot, extractMentionTargets as P, resolveFeishuReplyPolicy as Pt, unknownToolActionResult as Q, isFeishuGroupChatType as R, createFeishuCardInteractionEnvelope as Rt, sendMediaFeishu as S, canEnumerateAllFeishuPeers as St, chunkFeishuCardMarkdown as T, readFeishuChatInfoWithAuthorization as Tt, createConfiguredFeishuClient as U, parsePostContent as V, buildFeishuMediaFallbackText as W, registerFeishuTool as X, registerFeishuDriveTools as Y, feishuExternalToolResult as Z, renderFeishuPresentationPayload as _, shouldUseFeishuCard as _t, shouldSendNoVisibleReplyFallback as a, formatFeishuApiError as at, withinCardTableLimit as b, authorizeFeishuChatMemberRead as bt, buildFeishuPayloadCard as c, buildFeishuCommentTarget as ct, consumeFeishuPresentationFallbackMarker as d, readNativeFeishuCardJson as dt, assertFeishuApiSuccess as et, feishuCardWithinTableLimit as f, resolveFeishuCardTemplate as ft, renderFeishuPresentationFallbackText as g, parseFeishuMarkdown as gt, readNativeFeishuCard as h, materializeFeishuPostMarkdownSoftBreaks as ht, noVisibleFeishuReplyDelivery as i, extractFeishuApiErrorMeta as it, sendStructuredCardFeishu as j, resolveFeishuGroupConversationIngressAccess as jt, sendCardFeishu as k, resolveFeishuDmIngressAccess as kt, buildFeishuPresentationCard as l, normalizeCommentFileType as lt, markRenderedFeishuCard as m, chunkFeishuPostMarkdown as mt, createFeishuReplyDeliveryResult as n, createCommentTypingReactionLifecycle as nt, FEISHU_PRESENTATION_CAPABILITIES as o, parseCommentContentElements as ot, isFeishuCardWithinEnvelope as p, chunkFeishuMarkdown as pt, resolveFeishuIdentityHeaderTitle as q, mergeFeishuReplyDeliveryResults as r, encodeQuery as rt, assertFeishuCardWithinEnvelope as s, requestFeishuApi as st, createFeishuPartialReplyDeliveryError as t, cleanupAmbientCommentTypingReaction as tt, buildFeishuPresentationFallback as u, parseFeishuCommentTarget as ut, renderFeishuReplyPayload as v, visitFeishuMarkdown as vt, shouldSuppressFeishuTextForVoiceMedia as w, isFeishuGroupReadEnabled as wt, saveMessageResourceFeishu as x, canEnumerateAllFeishuGroups as xt, resolveFeishuRichReply as y, assertFeishuChatReadAllowed as yt, normalizeFeishuEventChatType as z, decodeFeishuCardAction as zt };
3323
+ export { resolveFeishuToolAccount as $, sendMessageFeishu as A, resolveFeishuGroupConversationIngressAccess as At, parseInteractiveCardContent as B, sendStickerFeishu as C, isFeishuGroupReadEnabled as Ct, getMessageFeishu as D, normalizeFeishuAllowEntry as Dt, editMessageFeishu as E, hasExplicitFeishuGroupConfig as Et, isFeishuBroadcastMention as F, normalizeFeishuChatType as Ft, resolveCardHeader as G, resolveFeishuSenderName as H, isMentionForwardRequest as I, resolveFeishuChatType as It, deliverCommentThreadText as J, resolveCardNote as K, normalizeMentions as L, FEISHU_CARD_INTERACTION_VERSION as Lt, sendFeishuMessage as M, resolveFeishuGroupToolPolicy as Mt, formatFeishuMediaContent as N, resolveFeishuReplyPolicy as Nt, listFeishuThreadMessages as O, resolveFeishuDmIngressAccess as Ot, extractMentionTargets as P, shouldIncludeFetchedGroupContextMessage as Pt, unknownToolActionResult as Q, isFeishuGroupChatType as R, createFeishuCardInteractionEnvelope as Rt, sendMediaFeishu as S, isFeishuGroupReadAllowed as St, chunkFeishuCardMarkdown as T, resolveFeishuChatReadPreliminaryAuthorization as Tt, createConfiguredFeishuClient as U, parsePostContent as V, buildFeishuMediaFallbackText as W, registerFeishuTool as X, registerFeishuDriveTools as Y, feishuExternalToolResult as Z, renderFeishuPresentationPayload as _, visitFeishuMarkdown as _t, shouldSendNoVisibleReplyFallback as a, formatFeishuApiError as at, withinCardTableLimit as b, canEnumerateAllFeishuGroups as bt, buildFeishuPayloadCard as c, normalizeCommentFileType as ct, consumeFeishuPresentationFallbackMarker as d, resolveFeishuCardTemplate as dt, assertFeishuApiSuccess as et, feishuCardWithinTableLimit as f, chunkFeishuMarkdown as ft, renderFeishuPresentationFallbackText as g, shouldUseFeishuCard as gt, readNativeFeishuCard as h, parseFeishuMarkdown as ht, noVisibleFeishuReplyDelivery as i, extractFeishuApiErrorMeta as it, sendStructuredCardFeishu as j, resolveFeishuGroupSenderActivationIngressAccess as jt, sendCardFeishu as k, resolveFeishuGroupConfig as kt, buildFeishuPresentationCard as l, parseFeishuCommentTarget as lt, markRenderedFeishuCard as m, materializeFeishuPostMarkdownSoftBreaks as mt, createFeishuReplyDeliveryResult as n, createCommentTypingReactionLifecycle as nt, FEISHU_PRESENTATION_CAPABILITIES as o, parseCommentContentElements as ot, isFeishuCardWithinEnvelope as p, chunkFeishuPostMarkdown as pt, resolveFeishuIdentityHeaderTitle as q, mergeFeishuReplyDeliveryResults as r, encodeQuery as rt, assertFeishuCardWithinEnvelope as s, buildFeishuCommentTarget as st, createFeishuPartialReplyDeliveryError as t, cleanupAmbientCommentTypingReaction as tt, buildFeishuPresentationFallback as u, readNativeFeishuCardJson as ut, renderFeishuReplyPayload as v, assertFeishuChatReadAllowed as vt, shouldSuppressFeishuTextForVoiceMedia as w, readFeishuChatInfoWithAuthorization as wt, saveMessageResourceFeishu as x, canEnumerateAllFeishuPeers as xt, resolveFeishuRichReply as y, authorizeFeishuChatMemberRead as yt, normalizeFeishuEventChatType as z, decodeFeishuCardAction as zt };