@openclaw/feishu 2026.10.1 → 2026.10.5-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 (116) hide show
  1. package/dist/.setup/{app-registration-BB6TubaW.mjs → app-registration-DQOq5urV.mjs} +13 -32
  2. package/dist/.setup/{channel-DoRSlOQd.mjs → channel-CjGGyrdx.mjs} +87 -174
  3. package/dist/.setup/{channel.runtime-jLSFNkJh.mjs → channel.runtime-SaC_uTPM.mjs} +57 -74
  4. package/dist/.setup/{chat-mTBvMMvx.mjs → chat-fC3dvxFs.mjs} +16 -28
  5. package/dist/.setup/{client-CcxmEkoy.mjs → client-wwr8PGPH.mjs} +24 -30
  6. package/dist/.setup/{conversation-id-C1ofUfU8.mjs → conversation-id-D00i9uy5.mjs} +5 -10
  7. package/dist/.setup/{doctor-contract-DyOo8NvC.mjs → doctor-contract-oIpUWtNO.mjs} +8 -15
  8. package/dist/.setup/{monitor-DX3vAlY9.mjs → monitor-Yt__BUki.mjs} +33 -54
  9. package/dist/.setup/{monitor.account-C_uDFPtG.mjs → monitor.account-CVz16781.mjs} +377 -664
  10. package/dist/.setup/{probe-BjSykXB8.mjs → probe-DXnFxq5j.mjs} +14 -17
  11. package/dist/.setup/{reply-delivery-result-laBNOmBu.mjs → reply-delivery-result-iCCrdxE1.mjs} +153 -181
  12. package/dist/.setup/{session-conversation-C53IEUWt.mjs → session-conversation-BSBNK5Mq.mjs} +1 -1
  13. package/dist/.setup/{setup-api-DTTsvzfC.mjs → setup-api-B_LFQQ-Q.mjs} +1 -1
  14. package/dist/.setup/{subagent-hooks-C8Z_x3KJ.mjs → subagent-hooks-9Pc1-k37.mjs} +7 -17
  15. package/dist/.setup/{thread-bindings-jW2x5VuN.mjs → thread-bindings-DdNLxoL3.mjs} +21 -44
  16. package/dist/api.js +218 -326
  17. package/dist/channel-plugin-api.js +1 -1
  18. package/dist/contract-api.js +1 -1
  19. package/dist/doctor-contract-api.js +1 -1
  20. package/dist/session-binding-contract-api.js +1 -1
  21. package/dist/session-key-api.js +1 -1
  22. package/dist/setup-api.js +1 -1
  23. package/dist/setup-entry.js +1 -1
  24. package/dist/subagent-hooks-api.js +1 -1
  25. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +35 -0
  26. package/node_modules/@openclaw/fs-safe/README.md +1 -1
  27. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +1 -1
  28. package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -1
  29. package/node_modules/@openclaw/fs-safe/dist/archive-durability.js +1 -1
  30. package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +4 -4
  31. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  32. package/node_modules/@openclaw/fs-safe/dist/archive-read.js +5 -4
  33. package/node_modules/@openclaw/fs-safe/dist/archive-staging.d.ts +1 -1
  34. package/node_modules/@openclaw/fs-safe/dist/archive-staging.js +22 -38
  35. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.d.ts +17 -0
  36. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +117 -0
  37. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +8 -5
  38. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +27 -50
  39. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.d.ts +3 -0
  40. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-acquire.js +57 -11
  41. package/node_modules/@openclaw/fs-safe/dist/guarded-mutation.js +5 -5
  42. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +52 -5
  43. package/node_modules/@openclaw/fs-safe/dist/guest.js +1 -1
  44. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +1 -0
  45. package/node_modules/@openclaw/fs-safe/dist/native-operations.d.ts +0 -1
  46. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +22 -26
  47. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +5 -1
  48. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +4 -1
  49. package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +2 -1
  50. package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +6 -1
  51. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +2 -2
  52. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +34 -7
  53. package/node_modules/@openclaw/fs-safe/dist/replace-file-copy-fallback.js +1 -4
  54. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +6 -0
  55. package/node_modules/@openclaw/fs-safe/dist/root-create-input.d.ts +15 -1
  56. package/node_modules/@openclaw/fs-safe/dist/root-create-input.js +4 -0
  57. package/node_modules/@openclaw/fs-safe/dist/root-directory-entry.js +1 -1
  58. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.d.ts +0 -1
  59. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +6 -12
  60. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +15 -15
  61. package/node_modules/@openclaw/fs-safe/dist/root-paths.js +1 -1
  62. package/node_modules/@openclaw/fs-safe/dist/root-walk.js +4 -4
  63. package/node_modules/@openclaw/fs-safe/dist/root-write-verification.d.ts +10 -1
  64. package/node_modules/@openclaw/fs-safe/dist/root-write-verification.js +20 -0
  65. package/node_modules/@openclaw/fs-safe/dist/secure-temp-dir.js +19 -7
  66. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-acquire.js +25 -3
  67. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-admission.d.ts +2 -0
  68. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.d.ts +14 -0
  69. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +187 -0
  70. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock.js +15 -1
  71. package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.d.ts +10 -0
  72. package/node_modules/@openclaw/fs-safe/dist/temp-directory-diagnostics.js +29 -0
  73. package/node_modules/@openclaw/fs-safe/dist/temp-target.js +1 -1
  74. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-admission.js +6 -6
  75. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.d.ts +4 -4
  76. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +17 -16
  77. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +20 -28
  78. package/node_modules/@openclaw/fs-safe/dist/walk.js +2 -13
  79. package/node_modules/@openclaw/fs-safe/dist/watch-native.d.ts +2 -2
  80. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +3 -1
  81. package/node_modules/@openclaw/fs-safe/dist/watch-rescan.js +3 -9
  82. package/node_modules/@openclaw/fs-safe/dist/watch.js +2 -3
  83. package/node_modules/@openclaw/fs-safe/docs/advanced.md +1 -1
  84. package/node_modules/@openclaw/fs-safe/docs/archive.md +3 -0
  85. package/node_modules/@openclaw/fs-safe/docs/atomic.md +11 -3
  86. package/node_modules/@openclaw/fs-safe/docs/contributing.md +1 -1
  87. package/node_modules/@openclaw/fs-safe/docs/copy.md +48 -0
  88. package/node_modules/@openclaw/fs-safe/docs/guest.md +21 -4
  89. package/node_modules/@openclaw/fs-safe/docs/path-scope.md +4 -0
  90. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +46 -8
  91. package/node_modules/@openclaw/fs-safe/docs/temp.md +12 -0
  92. package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
  93. package/node_modules/@openclaw/fs-safe/package.json +15 -15
  94. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  95. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  96. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  97. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  98. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  99. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  100. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  101. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  102. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  103. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  104. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  105. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  106. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  107. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  108. package/node_modules/follow-redirects/index.js +10 -1
  109. package/node_modules/follow-redirects/package.json +1 -1
  110. package/package.json +5 -5
  111. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.d.ts +0 -17
  112. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-root-arbitration.js +0 -66
  113. package/node_modules/@openclaw/fs-safe/dist/publish-file-native.d.ts +0 -4
  114. package/node_modules/@openclaw/fs-safe/dist/publish-file-native.js +0 -35
  115. package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.d.ts +0 -7
  116. package/node_modules/@openclaw/fs-safe/dist/root-move-preflight.js +0 -16
@@ -1,7 +1,7 @@
1
- import { c as normalizeFeishuExternalKey, d as listEnabledFeishuAccounts, f as listFeishuAccountIds, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, m as resolveDefaultFeishuAccountId } from "./doctor-contract-DyOo8NvC.mjs";
2
- import { l as normalizeFeishuTarget, s as detectIdType, u as resolveReceiveIdType } from "./conversation-id-C1ofUfU8.mjs";
1
+ import { c as normalizeFeishuExternalKey, d as listEnabledFeishuAccounts, f as listFeishuAccountIds, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, m as resolveDefaultFeishuAccountId } from "./doctor-contract-oIpUWtNO.mjs";
2
+ import { l as normalizeFeishuTarget, s as detectIdType, u as resolveReceiveIdType } from "./conversation-id-D00i9uy5.mjs";
3
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-CcxmEkoy.mjs";
4
+ import { c as withFeishuMessageDispatch, o as captureFeishuSendAuthority, r as createFeishuClient, s as runBeforeFeishuMessageDispatch } from "./client-wwr8PGPH.mjs";
5
5
  import { normalizeAccountId, normalizeOptionalAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
6
6
  import { compileAllowlist, resolveAllowlistMatchByCandidates } from "openclaw/plugin-sdk/allow-from";
7
7
  import { ToolAuthorizationError } from "openclaw/plugin-sdk/channel-actions";
@@ -27,12 +27,13 @@ import { retryAsync } from "openclaw/plugin-sdk/retry-runtime";
27
27
  import { readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers";
28
28
  import { Type } from "typebox";
29
29
  import { isBlockedHostnameOrIp, resolvePinnedHostnameWithPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
30
+ import { containsAsciiControlCharacter } from "openclaw/plugin-sdk/string-normalization-runtime";
30
31
  import { detectMime, mediaKindFromMime } from "openclaw/plugin-sdk/media-mime";
31
32
  import { MEDIA_FFMPEG_MAX_AUDIO_DURATION_SECS, buildOutboundMediaLoadOptions, runFfmpeg, runFfprobe } from "openclaw/plugin-sdk/media-runtime";
32
33
  import { resolvePreferredOpenClawTmpDir, withTempWorkspace } from "openclaw/plugin-sdk/temp-path";
33
34
  import { saveMediaStream } from "openclaw/plugin-sdk/media-store";
34
35
  import { logVerbose } from "openclaw/plugin-sdk/runtime-env";
35
- import { escapeHtml, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
36
+ import { escapeHtml, escapeRegExp, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
36
37
  //#region extensions/feishu/src/card-interaction.ts
37
38
  const FEISHU_CARD_INTERACTION_VERSION = "ocf1";
38
39
  function isInteractionKind(value) {
@@ -350,11 +351,7 @@ function isFeishuGroupReadAllowed(cfg, account, chatId, current) {
350
351
  }).allowed;
351
352
  }
352
353
  function isFeishuGroupReadEnabled(cfg, account, chatId) {
353
- if (resolveFeishuReadGroupPolicy(cfg, account) === "disabled") return false;
354
- return resolveFeishuGroupConfig({
355
- cfg: account.config,
356
- groupId: chatId
357
- })?.enabled !== false;
354
+ return isFeishuGroupReadAllowed(cfg, account, chatId, true);
358
355
  }
359
356
  function canEnumerateAllFeishuPeers(account) {
360
357
  return compileAllowlist(normalizeFeishuAllowlist(account.config.allowFrom)).wildcard;
@@ -403,19 +400,15 @@ async function readFeishuChatInfoWithAuthorization(params, readChatInfo) {
403
400
  chat = await readChatInfo(params.preliminary.chatId);
404
401
  } catch (error) {
405
402
  if (params.preliminary.decision === "needs-metadata") assertFeishuChatReadAllowed({
406
- cfg: params.cfg,
407
- account: params.account,
408
- chatId: params.preliminary.chatId,
409
- ctx: params.ctx
403
+ ...params,
404
+ chatId: params.preliminary.chatId
410
405
  });
411
406
  throw error;
412
407
  }
413
408
  assertFeishuChatReadAllowed({
414
- cfg: params.cfg,
415
- account: params.account,
409
+ ...params,
416
410
  chatId: params.preliminary.chatId,
417
- chatType: resolveFeishuChatType(chat),
418
- ctx: params.ctx
411
+ chatType: resolveFeishuChatType(chat)
419
412
  });
420
413
  return chat;
421
414
  }
@@ -620,13 +613,8 @@ function escapeFeishuCardPlainText(text) {
620
613
  }
621
614
  function resolveSafeFeishuButtonUrl(url) {
622
615
  const trimmed = typeof url === "string" ? url.trim() : "";
623
- if (!trimmed) return;
624
- try {
625
- const parsed = new URL(trimmed);
626
- return parsed.protocol === "https:" || parsed.protocol === "http:" ? trimmed : void 0;
627
- } catch {
628
- return;
629
- }
616
+ const parsed = URL.parse(trimmed);
617
+ return parsed?.protocol === "https:" || parsed?.protocol === "http:" ? trimmed : void 0;
630
618
  }
631
619
  function sanitizeNativeFeishuButtonBehavior(behavior) {
632
620
  if (!isRecord(behavior)) return;
@@ -792,24 +780,37 @@ function encodeQuery(params) {
792
780
  const queryString = query.toString();
793
781
  return queryString ? `?${queryString}` : "";
794
782
  }
795
- function formatFeishuApiError(error, options = {}) {
796
- if (!isRecord(error)) return typeof error === "string" ? error : JSON.stringify(error);
797
- const config = isRecord(error.config) ? error.config : void 0;
783
+ function extractFeishuApiErrorMeta(error) {
784
+ if (!isRecord(error)) return { message: typeof error === "string" ? error : JSON.stringify(error) };
798
785
  const response = isRecord(error.response) ? error.response : void 0;
799
786
  const responseData = isRecord(response?.data) ? response?.data : void 0;
800
- const feishuLogId = readStringValue(responseData?.log_id) || (options.includeNestedErrorLogId ? readStringValue(isRecord(responseData?.error) ? responseData.error.log_id : void 0) : void 0);
801
787
  const nestedError = isRecord(responseData?.error) ? responseData.error : void 0;
802
- return JSON.stringify({
788
+ return {
803
789
  message: typeof error.message === "string" ? error.message : JSON.stringify(error),
804
790
  code: readStringValue(error.code),
805
- method: readStringValue(config?.method),
806
- url: readStringValue(config?.url),
807
- ...options.includeConfigParams ? { params: config?.params } : {},
808
- http_status: typeof response?.status === "number" ? response.status : void 0,
809
- feishu_code: typeof responseData?.code === "number" ? responseData.code : readStringValue(responseData?.code),
810
- feishu_msg: readStringValue(responseData?.msg),
811
- feishu_log_id: feishuLogId,
812
- feishu_troubleshooter: readStringValue(responseData?.troubleshooter) || readStringValue(nestedError?.troubleshooter)
791
+ config: isRecord(error.config) ? error.config : void 0,
792
+ httpStatus: typeof response?.status === "number" ? response.status : void 0,
793
+ feishuCode: typeof responseData?.code === "number" ? responseData.code : readStringValue(responseData?.code),
794
+ feishuMsg: readStringValue(responseData?.msg),
795
+ feishuLogId: readStringValue(responseData?.log_id),
796
+ nestedErrorLogId: readStringValue(nestedError?.log_id),
797
+ troubleshooter: readStringValue(responseData?.troubleshooter) || readStringValue(nestedError?.troubleshooter)
798
+ };
799
+ }
800
+ function formatFeishuApiError(error, options = {}) {
801
+ if (!isRecord(error)) return typeof error === "string" ? error : JSON.stringify(error);
802
+ const meta = extractFeishuApiErrorMeta(error);
803
+ return JSON.stringify({
804
+ message: meta.message,
805
+ code: meta.code,
806
+ method: readStringValue(meta.config?.method),
807
+ url: readStringValue(meta.config?.url),
808
+ ...options.includeConfigParams ? { params: meta.config?.params } : {},
809
+ http_status: meta.httpStatus,
810
+ feishu_code: meta.feishuCode,
811
+ feishu_msg: meta.feishuMsg,
812
+ feishu_log_id: meta.feishuLogId || (options.includeNestedErrorLogId ? meta.nestedErrorLogId : void 0),
813
+ feishu_troubleshooter: meta.troubleshooter
813
814
  });
814
815
  }
815
816
  const FEISHU_SEND_RETRY_BASE_MS = 500;
@@ -877,35 +878,28 @@ function parseCommentLinkedDocumentPath(pathname) {
877
878
  const segments = normalizeStringEntries(pathname.split("/"));
878
879
  const offset = segments[0]?.toLowerCase() === "space" ? 1 : 0;
879
880
  const kind = COMMENT_LINK_KIND_ALIASES.get(segments[offset]?.toLowerCase() ?? "");
880
- const token = normalizeOptionalString(segments[offset + 1]);
881
+ const token = segments[offset + 1];
881
882
  if (!kind || !isReasonableFeishuLinkToken(token)) return null;
882
883
  return {
883
884
  urlKind: kind,
884
885
  token
885
886
  };
886
887
  }
887
- function hasResolvedLinkedDocumentReference(link) {
888
- return link.urlKind !== "unknown" && (Boolean(link.resolvedObjToken) || Boolean(link.wikiNodeToken));
889
- }
890
888
  function resolveCommentLinkedDocumentFromUrl(params) {
889
+ const parsed = URL.parse(params.rawUrl);
890
+ const parsedPath = parsed && parseCommentLinkedDocumentPath(parsed.pathname);
891
+ if (!parsedPath) return;
892
+ const { urlKind, token } = parsedPath;
891
893
  const link = {
892
894
  rawUrl: params.rawUrl,
893
- urlKind: "unknown"
895
+ urlKind
894
896
  };
895
- try {
896
- const parsedPath = parseCommentLinkedDocumentPath(new URL(params.rawUrl).pathname);
897
- if (!parsedPath) return link;
898
- const { urlKind, token } = parsedPath;
899
- link.urlKind = urlKind;
900
- if (urlKind === "wiki") link.wikiNodeToken = token;
901
- else {
902
- link.resolvedObjType = urlKind;
903
- link.resolvedObjToken = token;
904
- }
905
- if (link.resolvedObjType && link.resolvedObjToken && normalizeCommentFileType(link.resolvedObjType)) link.isCurrentDocument = params.currentDocument?.fileType === link.resolvedObjType && params.currentDocument.fileToken === link.resolvedObjToken;
906
- } catch {
907
- return link;
897
+ if (urlKind === "wiki") link.wikiNodeToken = token;
898
+ else {
899
+ link.resolvedObjType = urlKind;
900
+ link.resolvedObjToken = token;
908
901
  }
902
+ if (link.resolvedObjType && link.resolvedObjToken && normalizeCommentFileType(link.resolvedObjType)) link.isCurrentDocument = params.currentDocument?.fileType === link.resolvedObjType && params.currentDocument.fileToken === link.resolvedObjToken;
909
903
  return link;
910
904
  }
911
905
  function parseCommentContentElements(params) {
@@ -946,7 +940,7 @@ function parseCommentContentElements(params) {
946
940
  rawUrl,
947
941
  currentDocument: params.currentDocument
948
942
  });
949
- if (hasResolvedLinkedDocumentReference(linkedDocument)) {
943
+ if (linkedDocument) {
950
944
  const key = [
951
945
  linkedDocument.rawUrl,
952
946
  linkedDocument.urlKind,
@@ -1083,14 +1077,14 @@ async function cleanupAmbientCommentTypingReaction(params) {
1083
1077
  });
1084
1078
  }
1085
1079
  function createCommentTypingReactionLifecycle(params) {
1086
- const key = params.replyId?.trim() ? buildCommentTypingReactionKey({
1080
+ const replyId = params.replyId?.trim();
1081
+ const key = replyId ? buildCommentTypingReactionKey({
1087
1082
  ...params,
1088
- replyId: params.replyId.trim()
1083
+ replyId
1089
1084
  }) : void 0;
1090
1085
  const state = key ? ensureCommentTypingReactionState(key) : void 0;
1091
1086
  return {
1092
1087
  start: async () => {
1093
- const replyId = params.replyId?.trim();
1094
1088
  if (!state || state.cleaned || state.active || !replyId) return;
1095
1089
  state.active = await requestCommentTypingReaction({
1096
1090
  ...params,
@@ -1099,7 +1093,6 @@ function createCommentTypingReactionLifecycle(params) {
1099
1093
  });
1100
1094
  },
1101
1095
  cleanup: async () => {
1102
- const replyId = params.replyId?.trim();
1103
1096
  if (!key || !replyId) return;
1104
1097
  await cleanupCommentTypingReactionByKey({
1105
1098
  key,
@@ -1208,11 +1201,6 @@ const FeishuDriveSchema = Type.Union([
1208
1201
  ]);
1209
1202
  //#endregion
1210
1203
  //#region extensions/feishu/src/tools-config.ts
1211
- /**
1212
- * Default tool configuration.
1213
- * - doc, chat, wiki, drive, scopes, bitable: enabled by default
1214
- * - perm: disabled by default (sensitive operation)
1215
- */
1216
1204
  const DEFAULT_TOOLS_CONFIG = {
1217
1205
  doc: true,
1218
1206
  chat: true,
@@ -1319,7 +1307,22 @@ function unknownToolActionResult(action) {
1319
1307
  return jsonResult({ error: `Unknown action: ${String(action)}` });
1320
1308
  }
1321
1309
  function toolExecutionErrorResult(error) {
1322
- return feishuExternalToolResult({ error: formatErrorMessage(error) });
1310
+ let message = formatErrorMessage(error);
1311
+ const response = isRecord(error) && isRecord(error.response) ? error.response : void 0;
1312
+ if (isRecord(response?.data) ? response.data : void 0) {
1313
+ const meta = extractFeishuApiErrorMeta({
1314
+ message,
1315
+ response
1316
+ });
1317
+ message = formatErrorMessage(JSON.stringify({
1318
+ message,
1319
+ http_status: meta.httpStatus,
1320
+ feishu_code: meta.feishuCode,
1321
+ feishu_msg: meta.feishuMsg,
1322
+ feishu_log_id: meta.feishuLogId || meta.nestedErrorLogId
1323
+ }));
1324
+ }
1325
+ return feishuExternalToolResult({ error: message });
1323
1326
  }
1324
1327
  //#endregion
1325
1328
  //#region extensions/feishu/src/tool-registration.ts
@@ -1390,13 +1393,10 @@ function normalizeCommentPageSize(pageSize) {
1390
1393
  if (typeof pageSize !== "number" || !Number.isFinite(pageSize)) return;
1391
1394
  return String(Math.min(Math.max(Math.floor(pageSize), 1), 100));
1392
1395
  }
1393
- function resolveAmbientCommentTarget(context) {
1394
- const deliveryContext = context?.deliveryContext;
1395
- if (deliveryContext?.channel && deliveryContext.channel !== "feishu") return null;
1396
- return parseFeishuCommentTarget(deliveryContext?.to);
1397
- }
1398
- function resolveDriveCommentParams(params, context, action) {
1399
- const ambient = resolveAmbientCommentTarget(context);
1396
+ function resolveDriveCommentParams(params, context) {
1397
+ const { action } = params;
1398
+ const delivery = context.deliveryContext;
1399
+ const ambient = delivery?.channel && delivery.channel !== "feishu" ? null : parseFeishuCommentTarget(delivery?.to);
1400
1400
  let resolved = params;
1401
1401
  if (ambient && (action !== "add_comment" || ambient.fileType === "doc" || ambient.fileType === "docx")) resolved = {
1402
1402
  ...params,
@@ -1411,26 +1411,6 @@ function resolveDriveCommentParams(params, context, action) {
1411
1411
  file_type: fileType
1412
1412
  };
1413
1413
  }
1414
- function extractDriveApiErrorMeta(error) {
1415
- if (!isRecord(error)) return { message: typeof error === "string" ? error : JSON.stringify(error) };
1416
- const response = isRecord(error.response) ? error.response : void 0;
1417
- const responseData = isRecord(response?.data) ? response?.data : void 0;
1418
- return {
1419
- message: typeof error.message === "string" ? error.message : JSON.stringify(error),
1420
- httpStatus: typeof response?.status === "number" ? response.status : void 0,
1421
- feishuCode: typeof responseData?.code === "number" ? responseData.code : readStringValue(responseData?.code),
1422
- feishuMsg: readStringValue(responseData?.msg),
1423
- feishuLogId: readStringValue(responseData?.log_id)
1424
- };
1425
- }
1426
- async function getRootFolderToken(client) {
1427
- const domain = client.domain ?? "https://open.feishu.cn";
1428
- const res = await client.httpInstance.get(`${domain}/open-apis/drive/explorer/v2/root_folder/meta`);
1429
- if (res.code !== 0) throw new Error(res.msg ?? "Failed to get root folder");
1430
- const token = res.data?.token;
1431
- if (!token) throw new Error("Root folder token not found");
1432
- return token;
1433
- }
1434
1414
  async function listFolder(client, params = {}) {
1435
1415
  const folderToken = typeof params.folder_token === "string" ? params.folder_token.trim() : void 0;
1436
1416
  const validFolderToken = folderToken && folderToken !== "0" ? folderToken : void 0;
@@ -1477,7 +1457,7 @@ async function getFileInfo(client, fileToken, type) {
1477
1457
  with_url: true
1478
1458
  } });
1479
1459
  } catch (error) {
1480
- if (extractDriveApiErrorMeta(error).feishuCode === 99991672) return getRootFileInfo(client, fileToken);
1460
+ if (extractFeishuApiErrorMeta(error).feishuCode === 99991672) return getRootFileInfo(client, fileToken);
1481
1461
  throw error;
1482
1462
  }
1483
1463
  if (res.code === 99991672) return getRootFileInfo(client, fileToken);
@@ -1497,7 +1477,9 @@ async function getFileInfo(client, fileToken, type) {
1497
1477
  async function createFolder(client, name, folderToken) {
1498
1478
  let effectiveToken = folderToken && folderToken !== "0" ? folderToken : "0";
1499
1479
  if (effectiveToken === "0") try {
1500
- effectiveToken = await getRootFolderToken(client);
1480
+ const domain = client.domain ?? "https://open.feishu.cn";
1481
+ const root = await client.httpInstance.get(`${domain}/open-apis/drive/explorer/v2/root_folder/meta`);
1482
+ if (root.code === 0 && root.data?.token) effectiveToken = root.data.token;
1501
1483
  } catch {}
1502
1484
  const res = await client.drive.file.createFolder({ data: {
1503
1485
  name,
@@ -1509,50 +1491,6 @@ async function createFolder(client, name, folderToken) {
1509
1491
  url: res.data?.url
1510
1492
  };
1511
1493
  }
1512
- async function moveFile(client, fileToken, type, folderToken) {
1513
- const res = await client.drive.file.move({
1514
- path: { file_token: fileToken },
1515
- data: {
1516
- type,
1517
- folder_token: folderToken
1518
- }
1519
- });
1520
- assertFeishuApiSuccess(res);
1521
- return {
1522
- success: true,
1523
- task_id: res.data?.task_id
1524
- };
1525
- }
1526
- async function deleteFile(client, fileToken, type) {
1527
- const res = await client.drive.file.delete({
1528
- path: { file_token: fileToken },
1529
- params: { type }
1530
- });
1531
- assertFeishuApiSuccess(res);
1532
- return {
1533
- success: true,
1534
- task_id: res.data?.task_id
1535
- };
1536
- }
1537
- async function listDriveCommentPage(client, params) {
1538
- const filePath = `/open-apis/drive/v1/files/${encodeURIComponent(params.file_token)}/comments`;
1539
- const isReplies = params.action === "list_comment_replies";
1540
- const response = assertDriveApiSuccess(await requestDriveApi({
1541
- client,
1542
- method: "GET",
1543
- url: (isReplies ? `${filePath}/${encodeURIComponent(params.comment_id)}/replies` : filePath) + encodeQuery({
1544
- file_type: params.file_type,
1545
- page_size: normalizeCommentPageSize(params.page_size),
1546
- page_token: params.page_token,
1547
- user_id_type: "open_id"
1548
- })
1549
- }));
1550
- return {
1551
- has_more: response.data?.has_more ?? false,
1552
- page_token: response.data?.page_token,
1553
- ...isReplies ? { replies: (response.data?.items ?? []).map(normalizeCommentReply) } : { comments: (response.data?.items ?? []).map(normalizeCommentCard) }
1554
- };
1555
- }
1556
1494
  async function addComment(client, params) {
1557
1495
  if (params.block_id?.trim() && params.file_type !== "docx") throw new Error("block_id is only supported for docx comments");
1558
1496
  return {
@@ -1572,17 +1510,6 @@ async function addComment(client, params) {
1572
1510
  }))).data
1573
1511
  };
1574
1512
  }
1575
- async function queryCommentById(client, params) {
1576
- return assertDriveApiSuccess(await requestDriveApi({
1577
- client,
1578
- method: "POST",
1579
- url: `/open-apis/drive/v1/files/${encodeURIComponent(params.file_token)}/comments/batch_query` + encodeQuery({
1580
- file_type: params.file_type,
1581
- user_id_type: "open_id"
1582
- }),
1583
- data: { comment_ids: [params.comment_id] }
1584
- })).data?.items?.find((comment) => comment.comment_id?.trim() === params.comment_id);
1585
- }
1586
1513
  async function replyComment(client, params) {
1587
1514
  const url = `/open-apis/drive/v1/files/${encodeURIComponent(params.file_token)}/comments/${encodeURIComponent(params.comment_id)}/replies`;
1588
1515
  const query = { file_type: params.file_type };
@@ -1610,7 +1537,7 @@ async function replyComment(client, params) {
1610
1537
  });
1611
1538
  } catch (error) {
1612
1539
  if (error instanceof FeishuReplyCommentError || error instanceof PlatformMessageNotDispatchedError) throw error;
1613
- const meta = extractDriveApiErrorMeta(error);
1540
+ const meta = extractFeishuApiErrorMeta(error);
1614
1541
  console.warn(`[feishu_drive] replyComment threw comment=${params.comment_id} file_type=${params.file_type} error=${formatFeishuApiError(error, { includeConfigParams: true })}`);
1615
1542
  throw new FeishuReplyCommentError(meta);
1616
1543
  }
@@ -1618,7 +1545,15 @@ async function replyComment(client, params) {
1618
1545
  async function deliverCommentThreadText(client, params) {
1619
1546
  let isWholeComment = params.is_whole_comment;
1620
1547
  if (isWholeComment === void 0) try {
1621
- isWholeComment = (await queryCommentById(client, params))?.is_whole === true;
1548
+ isWholeComment = (assertDriveApiSuccess(await requestDriveApi({
1549
+ client,
1550
+ method: "POST",
1551
+ url: `/open-apis/drive/v1/files/${encodeURIComponent(params.file_token)}/comments/batch_query` + encodeQuery({
1552
+ file_type: params.file_type,
1553
+ user_id_type: "open_id"
1554
+ }),
1555
+ data: { comment_ids: [params.comment_id] }
1556
+ })).data?.items?.find((item) => item.comment_id?.trim() === params.comment_id))?.is_whole === true;
1622
1557
  } catch (error) {
1623
1558
  console.warn(`[feishu_drive] comment metadata preflight failed comment=${params.comment_id} file_type=${params.file_type} error=${formatErrorMessage(error)}`);
1624
1559
  isWholeComment = false;
@@ -1668,13 +1603,49 @@ function registerFeishuDriveTools(api) {
1668
1603
  case "list": return feishuExternalToolResult(await listFolder(client, p));
1669
1604
  case "info": return feishuExternalToolResult(await getFileInfo(client, p.file_token, p.type));
1670
1605
  case "create_folder": return feishuExternalToolResult(await createFolder(client, p.name, p.folder_token));
1671
- case "move": return feishuExternalToolResult(await moveFile(client, p.file_token, p.type, p.folder_token));
1672
- case "delete": return feishuExternalToolResult(await deleteFile(client, p.file_token, p.type));
1606
+ case "move":
1607
+ case "delete": {
1608
+ const path = { file_token: p.file_token };
1609
+ const res = p.action === "move" ? await client.drive.file.move({
1610
+ path,
1611
+ data: {
1612
+ type: p.type,
1613
+ folder_token: p.folder_token
1614
+ }
1615
+ }) : await client.drive.file.delete({
1616
+ path,
1617
+ params: { type: p.type }
1618
+ });
1619
+ assertFeishuApiSuccess(res);
1620
+ return feishuExternalToolResult({
1621
+ success: true,
1622
+ task_id: res.data?.task_id
1623
+ });
1624
+ }
1673
1625
  case "list_comments":
1674
- case "list_comment_replies": return feishuExternalToolResult(await listDriveCommentPage(client, resolveDriveCommentParams(p, ctx, p.action)));
1626
+ case "list_comment_replies": {
1627
+ const resolved = resolveDriveCommentParams(p, ctx);
1628
+ const filePath = `/open-apis/drive/v1/files/${encodeURIComponent(resolved.file_token)}/comments`;
1629
+ const isReplies = resolved.action === "list_comment_replies";
1630
+ const response = assertDriveApiSuccess(await requestDriveApi({
1631
+ client,
1632
+ method: "GET",
1633
+ url: (isReplies ? `${filePath}/${encodeURIComponent(resolved.comment_id)}/replies` : filePath) + encodeQuery({
1634
+ file_type: resolved.file_type,
1635
+ page_size: normalizeCommentPageSize(resolved.page_size),
1636
+ page_token: resolved.page_token,
1637
+ user_id_type: "open_id"
1638
+ })
1639
+ }));
1640
+ return feishuExternalToolResult({
1641
+ has_more: response.data?.has_more ?? false,
1642
+ page_token: response.data?.page_token,
1643
+ ...isReplies ? { replies: (response.data?.items ?? []).map(normalizeCommentReply) } : { comments: (response.data?.items ?? []).map(normalizeCommentCard) }
1644
+ });
1645
+ }
1675
1646
  case "add_comment":
1676
1647
  case "reply_comment": {
1677
- const resolved = resolveDriveCommentParams(p, ctx, p.action);
1648
+ const resolved = resolveDriveCommentParams(p, ctx);
1678
1649
  try {
1679
1650
  return feishuExternalToolResult(await (resolved.action === "add_comment" ? addComment(client, resolved) : deliverCommentThreadText(client, resolved)));
1680
1651
  } finally {
@@ -1716,15 +1687,9 @@ function resolveFeishuIdentityHeaderTitle(identity) {
1716
1687
  //#endregion
1717
1688
  //#region extensions/feishu/src/media-fallback.ts
1718
1689
  const FEISHU_MEDIA_UPLOAD_FAILURE_FALLBACK_TEXT = "Media upload failed. Please try again.";
1719
- function hasAsciiControlCharacter(value) {
1720
- return Array.from(value).some((character) => {
1721
- const code = character.charCodeAt(0);
1722
- return code <= 31 || code === 127;
1723
- });
1724
- }
1725
1690
  async function resolvePublicFeishuMediaReference(value) {
1726
1691
  const raw = value?.trim();
1727
- if (!raw || hasAsciiControlCharacter(raw)) return;
1692
+ if (!raw || containsAsciiControlCharacter(raw)) return;
1728
1693
  try {
1729
1694
  const parsed = new URL(raw);
1730
1695
  if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return;
@@ -2103,13 +2068,11 @@ function extractInteractiveElementsText(elements, variables) {
2103
2068
  }
2104
2069
  function readInteractiveElementArrays(parsed) {
2105
2070
  const body = isRecord(parsed.body) ? parsed.body : void 0;
2106
- const elementArrays = [];
2107
- for (const candidate of [parsed.elements, body?.elements]) if (Array.isArray(candidate)) elementArrays.push(candidate);
2108
- for (const candidate of [parsed.i18n_elements, body?.i18n_elements]) {
2109
- if (!isRecord(candidate)) continue;
2110
- for (const localeElements of Object.values(candidate)) if (Array.isArray(localeElements)) elementArrays.push(localeElements);
2111
- }
2112
- return elementArrays;
2071
+ return [
2072
+ parsed.elements,
2073
+ body?.elements,
2074
+ ...[parsed.i18n_elements, body?.i18n_elements].flatMap((candidate) => isRecord(candidate) ? Object.values(candidate) : [])
2075
+ ].filter(Array.isArray);
2113
2076
  }
2114
2077
  function readInteractiveCardTitle(parsed, variables) {
2115
2078
  if (typeof parsed.title === "string") return applyCardTemplateVariables(parsed.title, variables).trim();
@@ -2139,6 +2102,18 @@ function isFeishuGroupChatType(chatType) {
2139
2102
  }
2140
2103
  //#endregion
2141
2104
  //#region extensions/feishu/src/mention.ts
2105
+ function normalizeMentions(text, mentions, botStripId) {
2106
+ if (!mentions || mentions.length === 0) return text;
2107
+ const escapeName = (value) => value.replace(/</g, "&lt;").replace(/>/g, "&gt;");
2108
+ const replacements = /* @__PURE__ */ new Map();
2109
+ for (const mention of mentions) {
2110
+ const mentionId = typeof mention.id === "string" ? mention.id : mention.id.open_id;
2111
+ const replacement = botStripId && mentionId === botStripId ? "" : mentionId ? `<at user_id="${mentionId}">${escapeName(mention.name)}</at>` : `@${mention.name}`;
2112
+ replacements.set(mention.key, replacement);
2113
+ }
2114
+ const keys = [...replacements.keys()].toSorted((a, b) => b.length - a.length).map(escapeRegExp);
2115
+ return text.replace(new RegExp(keys.join("|"), "g"), (key) => replacements.get(key)).trim();
2116
+ }
2142
2117
  function isFeishuBroadcastMention(mention) {
2143
2118
  const normalizedKey = mention.key?.trim().toLowerCase();
2144
2119
  if (normalizedKey === "@all" || normalizedKey === "@_all") return true;
@@ -2148,9 +2123,6 @@ function isFeishuBroadcastMention(mention) {
2148
2123
  mention.id?.union_id
2149
2124
  ].some((id) => id?.trim().toLowerCase() === "all");
2150
2125
  }
2151
- /**
2152
- * Extract mention targets from message event (excluding the bot itself)
2153
- */
2154
2126
  function extractMentionTargets(event, botOpenId) {
2155
2127
  return (event.message.mentions ?? []).filter((m) => !isFeishuBroadcastMention(m) && m.id.open_id !== botOpenId && Boolean(m.id.open_id)).map((m) => ({
2156
2128
  openId: m.id.open_id,
@@ -2188,11 +2160,11 @@ function formatFeishuMediaContent(parsed, messageType) {
2188
2160
  if (speechToText) return speechToText;
2189
2161
  return "";
2190
2162
  }
2191
- function formatSubMessageContent(content, contentType) {
2163
+ function formatSubMessageContent(content, contentType, mentions) {
2192
2164
  try {
2193
2165
  const parsed = JSON.parse(content);
2194
2166
  switch (contentType) {
2195
- case "text": return parsed.text || content;
2167
+ case "text": return normalizeMentions(parsed.text || content, mentions);
2196
2168
  case "post": return renderPostContent(parsed).textContent;
2197
2169
  case "interactive": return parseInteractiveCardContent(parsed);
2198
2170
  case "image": return "[Image]";
@@ -2215,7 +2187,7 @@ function parseMergeForwardContent(items) {
2215
2187
  if (subMessages.length === 0) return "[Merged and Forwarded Message - no sub-messages found]";
2216
2188
  subMessages.sort((a, b) => (parseStrictNonNegativeInteger(a.create_time) ?? 0) - (parseStrictNonNegativeInteger(b.create_time) ?? 0));
2217
2189
  const lines = ["[Merged and Forwarded Messages]"];
2218
- for (const item of subMessages.slice(0, maxMessages)) lines.push(`- ${formatSubMessageContent(item.body?.content || "", item.msg_type || "text")}`);
2190
+ for (const item of subMessages.slice(0, maxMessages)) lines.push(`- ${formatSubMessageContent(item.body?.content || "", item.msg_type || "text", item.mentions)}`);
2219
2191
  if (subMessages.length > maxMessages) lines.push(`... and ${subMessages.length - maxMessages} more messages`);
2220
2192
  const rendered = lines.join("\n");
2221
2193
  return rendered.length <= 2e4 ? rendered : `${truncateUtf16Safe(rendered, 19961).trimEnd()}
@@ -2360,7 +2332,7 @@ function parseFeishuMessageContent(rawContent, msgType, messageId) {
2360
2332
  }
2361
2333
  function parseFeishuMessageItem(item, fallbackMessageId) {
2362
2334
  const msgType = item.msg_type ?? "text";
2363
- const rawContent = item.body?.content ?? "";
2335
+ const content = parseFeishuMessageContent(item.body?.content ?? "", msgType, item.message_id);
2364
2336
  return {
2365
2337
  messageId: item.message_id ?? fallbackMessageId ?? "",
2366
2338
  chatId: item.chat_id ?? "",
@@ -2368,7 +2340,7 @@ function parseFeishuMessageItem(item, fallbackMessageId) {
2368
2340
  senderId: item.sender?.id,
2369
2341
  senderOpenId: item.sender?.id_type === "open_id" ? item.sender?.id : void 0,
2370
2342
  senderType: item.sender?.sender_type,
2371
- content: parseFeishuMessageContent(rawContent, msgType, item.message_id),
2343
+ content: msgType === "text" ? normalizeMentions(content, item.mentions) : content,
2372
2344
  contentType: msgType,
2373
2345
  createTime: parseStrictNonNegativeInteger(item.create_time),
2374
2346
  ...item.root_id ? { rootId: item.root_id } : {},
@@ -2886,7 +2858,7 @@ async function probeMediaDurationMs(params) {
2886
2858
  return Math.max(1, Math.round(seconds * 1e3));
2887
2859
  });
2888
2860
  } catch (err) {
2889
- console.warn("[feishu] failed to probe media duration; upload will omit it:", err);
2861
+ console.warn("[feishu] failed to check media duration; upload will omit it:", err);
2890
2862
  return;
2891
2863
  }
2892
2864
  }
@@ -3329,7 +3301,7 @@ function mergeFeishuReplyDeliveryResults(results, content) {
3329
3301
  return createFeishuReplyDeliveryResult({
3330
3302
  results: visible,
3331
3303
  visibleReplySent: visible.length > 0,
3332
- content: content === void 0 ? acceptedContent.length > 0 ? acceptedContent.join("\n\n") : void 0 : content
3304
+ content: content ?? (acceptedContent.length > 0 ? acceptedContent.join("\n\n") : void 0)
3333
3305
  });
3334
3306
  }
3335
3307
  /** Keeps a failed outcome while exposing the provider-visible subset to core lifecycle hooks. */
@@ -3341,4 +3313,4 @@ function createFeishuPartialReplyDeliveryError(cause, result) {
3341
3313
  });
3342
3314
  }
3343
3315
  //#endregion
3344
- export { cleanupAmbientCommentTypingReaction as $, sendMessageFeishu as A, resolveFeishuGroupSenderActivationIngressAccess as At, parsePostContent as B, sendStickerFeishu as C, readFeishuChatInfoWithAuthorization as Ct, getMessageFeishu as D, resolveFeishuDmIngressAccess as Dt, editMessageFeishu as E, normalizeFeishuAllowEntry as Et, isFeishuBroadcastMention as F, FEISHU_CARD_INTERACTION_VERSION as Ft, deliverCommentThreadText as G, buildFeishuMediaFallbackText as H, isMentionForwardRequest as I, createFeishuCardInteractionEnvelope as It, feishuExternalToolResult as J, registerFeishuDriveTools as K, isFeishuGroupChatType as L, decodeFeishuCardAction as Lt, toFeishuMessageSendResult as M, resolveFeishuReplyPolicy as Mt, formatFeishuMediaContent as N, normalizeFeishuChatType as Nt, listFeishuThreadMessages as O, resolveFeishuGroupConfig as Ot, extractMentionTargets as P, resolveFeishuChatType as Pt, assertFeishuApiSuccess as Q, normalizeFeishuEventChatType as R, sendMediaFeishu as S, isFeishuGroupReadEnabled as St, chunkFeishuCardMarkdown as T, hasExplicitFeishuGroupConfig as Tt, resolveFeishuIdentityEmoji as U, createConfiguredFeishuClient as V, resolveFeishuIdentityHeaderTitle as W, createFeishuToolClient as X, unknownToolActionResult as Y, resolveFeishuToolAccount as Z, renderFeishuPresentationPayload as _, assertFeishuChatReadAllowed as _t, shouldSendNoVisibleReplyFallback as a, requestFeishuApi as at, withinCardTableLimit as b, canEnumerateAllFeishuPeers as bt, buildFeishuPayloadCard as c, parseFeishuCommentTarget as ct, consumeFeishuPresentationFallbackMarker as d, chunkFeishuMarkdown as dt, createCommentTypingReactionLifecycle as et, feishuCardWithinTableLimit as f, chunkFeishuPostMarkdown as ft, renderFeishuPresentationFallbackText as g, visitFeishuMarkdown as gt, readNativeFeishuCard as h, shouldUseFeishuCard as ht, noVisibleFeishuReplyDelivery as i, parseCommentContentElements as it, sendStructuredCardFeishu as j, resolveFeishuGroupToolPolicy as jt, sendCardFeishu as k, resolveFeishuGroupConversationIngressAccess as kt, buildFeishuPresentationCard as l, readNativeFeishuCardJson as lt, markRenderedFeishuCard as m, parseFeishuMarkdown as mt, createFeishuReplyDeliveryResult as n, extractReplyText as nt, FEISHU_PRESENTATION_CAPABILITIES as o, buildFeishuCommentTarget as ot, isFeishuCardWithinEnvelope as p, materializeFeishuPostMarkdownSoftBreaks as pt, registerFeishuTool as q, mergeFeishuReplyDeliveryResults as r, formatFeishuApiError as rt, assertFeishuCardWithinEnvelope as s, normalizeCommentFileType as st, createFeishuPartialReplyDeliveryError as t, encodeQuery as tt, buildFeishuPresentationFallback as u, resolveFeishuCardTemplate as ut, renderFeishuReplyPayload as v, authorizeFeishuChatMemberRead as vt, shouldSuppressFeishuTextForVoiceMedia as w, resolveFeishuChatReadPreliminaryAuthorization as wt, saveMessageResourceFeishu as x, isFeishuGroupReadAllowed as xt, resolveFeishuRichReply as y, canEnumerateAllFeishuGroups as yt, parseInteractiveCardContent as z };
3316
+ export { assertFeishuApiSuccess 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, resolveFeishuChatType as Ft, resolveFeishuIdentityHeaderTitle as G, createConfiguredFeishuClient as H, isMentionForwardRequest as I, FEISHU_CARD_INTERACTION_VERSION as It, registerFeishuTool as J, deliverCommentThreadText as K, normalizeMentions as L, createFeishuCardInteractionEnvelope as Lt, toFeishuMessageSendResult as M, resolveFeishuGroupToolPolicy as Mt, formatFeishuMediaContent as N, resolveFeishuReplyPolicy as Nt, listFeishuThreadMessages as O, resolveFeishuDmIngressAccess as Ot, extractMentionTargets as P, normalizeFeishuChatType as Pt, resolveFeishuToolAccount as Q, isFeishuGroupChatType as R, decodeFeishuCardAction as Rt, sendMediaFeishu as S, isFeishuGroupReadAllowed as St, chunkFeishuCardMarkdown as T, resolveFeishuChatReadPreliminaryAuthorization as Tt, buildFeishuMediaFallbackText as U, parsePostContent as V, resolveFeishuIdentityEmoji as W, unknownToolActionResult as X, feishuExternalToolResult as Y, createFeishuToolClient as Z, renderFeishuPresentationPayload as _, visitFeishuMarkdown as _t, shouldSendNoVisibleReplyFallback as a, parseCommentContentElements as at, withinCardTableLimit as b, canEnumerateAllFeishuGroups as bt, buildFeishuPayloadCard as c, normalizeCommentFileType as ct, consumeFeishuPresentationFallbackMarker as d, resolveFeishuCardTemplate as dt, cleanupAmbientCommentTypingReaction as et, feishuCardWithinTableLimit as f, chunkFeishuMarkdown as ft, renderFeishuPresentationFallbackText as g, shouldUseFeishuCard as gt, readNativeFeishuCard as h, parseFeishuMarkdown as ht, noVisibleFeishuReplyDelivery as i, formatFeishuApiError 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, encodeQuery as nt, FEISHU_PRESENTATION_CAPABILITIES as o, requestFeishuApi as ot, isFeishuCardWithinEnvelope as p, chunkFeishuPostMarkdown as pt, registerFeishuDriveTools as q, mergeFeishuReplyDeliveryResults as r, extractReplyText as rt, assertFeishuCardWithinEnvelope as s, buildFeishuCommentTarget as st, createFeishuPartialReplyDeliveryError as t, createCommentTypingReactionLifecycle 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 };
@@ -1,4 +1,4 @@
1
- import { r as parseFeishuConversationId, t as buildFeishuConversationId } from "./conversation-id-C1ofUfU8.mjs";
1
+ import { r as parseFeishuConversationId, t as buildFeishuConversationId } from "./conversation-id-D00i9uy5.mjs";
2
2
  //#region extensions/feishu/src/session-conversation.ts
3
3
  function resolveFeishuParentConversationCandidates(rawId) {
4
4
  const parsed = parseFeishuConversationId({ conversationId: rawId });
@@ -1,3 +1,3 @@
1
- import { i as feishuSetupAdapter, n as feishuSetupWizard, t as feishuPlugin } from "./channel-DoRSlOQd.mjs";
1
+ import { i as feishuSetupAdapter, n as feishuSetupWizard, t as feishuPlugin } from "./channel-CjGGyrdx.mjs";
2
2
  import "../setup-api.js";
3
3
  export { feishuPlugin, feishuSetupAdapter, feishuSetupWizard };
@@ -1,6 +1,6 @@
1
- import { _ as __exportAll } from "./doctor-contract-DyOo8NvC.mjs";
2
- import { d as stripFeishuProviderPrefix, l as normalizeFeishuTarget, r as parseFeishuConversationId, t as buildFeishuConversationId } from "./conversation-id-C1ofUfU8.mjs";
3
- import { n as getFeishuThreadBindingManager } from "./thread-bindings-jW2x5VuN.mjs";
1
+ import { _ as __exportAll } from "./doctor-contract-oIpUWtNO.mjs";
2
+ import { d as stripFeishuProviderPrefix, l as normalizeFeishuTarget, r as parseFeishuConversationId, t as buildFeishuConversationId } from "./conversation-id-D00i9uy5.mjs";
3
+ import { n as getFeishuThreadBindingManager } from "./thread-bindings-DdNLxoL3.mjs";
4
4
  import { normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  //#region extensions/feishu/src/subagent-hooks.ts
6
6
  var subagent_hooks_exports = /* @__PURE__ */ __exportAll({
@@ -66,26 +66,16 @@ function resolveFeishuRequesterConversation(manager, params) {
66
66
  function resolveFeishuDeliveryOrigin(params) {
67
67
  const deliveryTo = params.deliveryTo?.trim();
68
68
  const deliveryThreadId = params.deliveryThreadId?.trim();
69
- if (deliveryTo) return {
70
- channel: "feishu",
71
- accountId: params.accountId,
72
- to: deliveryTo,
73
- ...deliveryThreadId ? { threadId: deliveryThreadId } : {}
74
- };
75
- const parsed = parseFeishuConversationId({
69
+ const parsed = deliveryTo ? null : parseFeishuConversationId({
76
70
  conversationId: params.conversationId,
77
71
  parentConversationId: params.parentConversationId
78
72
  });
79
- if (parsed?.topicId) return {
80
- channel: "feishu",
81
- accountId: params.accountId,
82
- to: `chat:${params.parentConversationId?.trim() || parsed.chatId}`,
83
- threadId: parsed.topicId
84
- };
73
+ const threadId = deliveryTo ? deliveryThreadId : parsed?.topicId;
85
74
  return {
86
75
  channel: "feishu",
87
76
  accountId: params.accountId,
88
- to: `user:${params.conversationId}`
77
+ to: deliveryTo || (parsed?.topicId ? `chat:${params.parentConversationId?.trim() || parsed.chatId}` : `user:${params.conversationId}`),
78
+ ...threadId ? { threadId } : {}
89
79
  };
90
80
  }
91
81
  function resolveMatchingChildBinding(params) {