@openclaw/feishu 2026.10.5-beta.4 → 2026.10.10-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 (277) hide show
  1. package/dist/.setup/{channel-DykAJJhn.mjs → channel-VyjzWvqm.mjs} +40 -39
  2. package/dist/.setup/{channel.runtime-CC15v8AP.mjs → channel.runtime-BjGRGNPJ.mjs} +6 -6
  3. package/dist/.setup/{chat-fC3dvxFs.mjs → chat-qj1pEIcO.mjs} +2 -2
  4. package/dist/.setup/{client-wwr8PGPH.mjs → client-BTiFlqqL.mjs} +2 -2
  5. package/dist/.setup/{doctor-contract-oIpUWtNO.mjs → doctor-contract-BNXcJcWR.mjs} +2 -2
  6. package/dist/.setup/{monitor-Cy9ofY1Q.mjs → monitor-DzmCjp4q.mjs} +3 -3
  7. package/dist/.setup/{monitor.account-UbN1RhlP.mjs → monitor.account-CpMwDf-a.mjs} +151 -367
  8. package/dist/.setup/{probe-DXnFxq5j.mjs → probe-s0hiM44D.mjs} +3 -3
  9. package/dist/.setup/{reply-delivery-result-iCCrdxE1.mjs → reply-delivery-result-DknmIzOB.mjs} +128 -18
  10. package/dist/.setup/runtime-setter-api-BrQHE03y.mjs +2 -0
  11. package/dist/.setup/secret-contract-DEyvsehF.mjs +47 -0
  12. package/dist/.setup/secret-contract-api-XhxLE0dW.mjs +2 -0
  13. package/dist/.setup/setup-api-CH41-_5S.mjs +2 -0
  14. package/dist/.setup/{subagent-hooks-CGq_-NJZ.mjs → subagent-hooks-CvVuM0O4.mjs} +2 -2
  15. package/dist/.setup/{thread-bindings-Pii2fAST.mjs → thread-bindings-BxKmOara.mjs} +24 -4
  16. package/dist/api.js +15 -20
  17. package/dist/channel-plugin-api.js +1 -2
  18. package/dist/doctor-contract-api.js +1 -2
  19. package/dist/runtime-setter-api.js +1 -2
  20. package/dist/secret-contract-api.js +1 -2
  21. package/dist/security-contract-api.js +1 -2
  22. package/dist/session-binding-contract-api.js +1 -2
  23. package/dist/session-key-api.js +1 -2
  24. package/dist/setup-api.js +1 -2
  25. package/dist/setup-entry.js +3 -3
  26. package/dist/subagent-hooks-api.js +1 -1
  27. package/node_modules/@openclaw/fs-safe/CHANGELOG.md +148 -0
  28. package/node_modules/@openclaw/fs-safe/README.md +20 -4
  29. package/node_modules/@openclaw/fs-safe/dist/advanced.d.ts +2 -1
  30. package/node_modules/@openclaw/fs-safe/dist/advanced.js +1 -0
  31. package/node_modules/@openclaw/fs-safe/dist/archive-merge.js +28 -3
  32. package/node_modules/@openclaw/fs-safe/dist/archive-parser.wasm +0 -0
  33. package/node_modules/@openclaw/fs-safe/dist/archive-read.js +11 -5
  34. package/node_modules/@openclaw/fs-safe/dist/archive-zip-loader.js +4 -2
  35. package/node_modules/@openclaw/fs-safe/dist/archive.js +2 -2
  36. package/node_modules/@openclaw/fs-safe/dist/atomic-io.js +2 -2
  37. package/node_modules/@openclaw/fs-safe/dist/bounded-read.d.ts +1 -0
  38. package/node_modules/@openclaw/fs-safe/dist/bounded-read.js +9 -2
  39. package/node_modules/@openclaw/fs-safe/dist/clone-metadata.d.ts +2 -0
  40. package/node_modules/@openclaw/fs-safe/dist/clone-metadata.js +2 -1
  41. package/node_modules/@openclaw/fs-safe/dist/config.d.ts +6 -0
  42. package/node_modules/@openclaw/fs-safe/dist/config.js +5 -0
  43. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.d.ts +3 -1
  44. package/node_modules/@openclaw/fs-safe/dist/copy-file-input.js +8 -7
  45. package/node_modules/@openclaw/fs-safe/dist/copy-link.d.ts +26 -0
  46. package/node_modules/@openclaw/fs-safe/dist/copy-link.js +170 -0
  47. package/node_modules/@openclaw/fs-safe/dist/copy-metadata.d.ts +9 -0
  48. package/node_modules/@openclaw/fs-safe/dist/copy-metadata.js +39 -0
  49. package/node_modules/@openclaw/fs-safe/dist/copy-path-admission.js +11 -2
  50. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.d.ts +2 -4
  51. package/node_modules/@openclaw/fs-safe/dist/copy-root-file-sync.js +4 -2
  52. package/node_modules/@openclaw/fs-safe/dist/copy-tree-portable.js +3 -6
  53. package/node_modules/@openclaw/fs-safe/dist/copy.js +3 -3
  54. package/node_modules/@openclaw/fs-safe/dist/create.js +1 -1
  55. package/node_modules/@openclaw/fs-safe/dist/creation-boundary.js +7 -4
  56. package/node_modules/@openclaw/fs-safe/dist/darwin-acl.d.ts +12 -0
  57. package/node_modules/@openclaw/fs-safe/dist/darwin-acl.js +29 -0
  58. package/node_modules/@openclaw/fs-safe/dist/directory-durability.d.ts +7 -4
  59. package/node_modules/@openclaw/fs-safe/dist/directory-guard.js +20 -5
  60. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.d.ts +3 -0
  61. package/node_modules/@openclaw/fs-safe/dist/directory-mode-node.js +27 -2
  62. package/node_modules/@openclaw/fs-safe/dist/directory-receipt.d.ts +7 -7
  63. package/node_modules/@openclaw/fs-safe/dist/directory-receipt.js +9 -4
  64. package/node_modules/@openclaw/fs-safe/dist/durability.d.ts +2 -1
  65. package/node_modules/@openclaw/fs-safe/dist/entry-publication.js +2 -2
  66. package/node_modules/@openclaw/fs-safe/dist/exact-identity.d.ts +17 -0
  67. package/node_modules/@openclaw/fs-safe/dist/exact-identity.js +29 -0
  68. package/node_modules/@openclaw/fs-safe/dist/file-handle-transfer.js +4 -2
  69. package/node_modules/@openclaw/fs-safe/dist/file-hash.d.ts +1 -1
  70. package/node_modules/@openclaw/fs-safe/dist/file-hash.js +11 -9
  71. package/node_modules/@openclaw/fs-safe/dist/file-identity.d.ts +7 -1
  72. package/node_modules/@openclaw/fs-safe/dist/file-identity.js +27 -5
  73. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync-admission.js +1 -2
  74. package/node_modules/@openclaw/fs-safe/dist/file-lock-sync.js +8 -1
  75. package/node_modules/@openclaw/fs-safe/dist/file-lock.d.ts +1 -0
  76. package/node_modules/@openclaw/fs-safe/dist/file-lock.js +1 -0
  77. package/node_modules/@openclaw/fs-safe/dist/file-write-lease.d.ts +9 -0
  78. package/node_modules/@openclaw/fs-safe/dist/file-write-lease.js +42 -0
  79. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.d.ts +1 -0
  80. package/node_modules/@openclaw/fs-safe/dist/guarded-mkdir.js +22 -15
  81. package/node_modules/@openclaw/fs-safe/dist/guest-native-python.js +3 -0
  82. package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.d.ts +1 -0
  83. package/node_modules/@openclaw/fs-safe/dist/hardlink-fallback.js +5 -0
  84. package/node_modules/@openclaw/fs-safe/dist/index.d.ts +1 -0
  85. package/node_modules/@openclaw/fs-safe/dist/index.js +1 -0
  86. package/node_modules/@openclaw/fs-safe/dist/json-durable-queue-ownership.js +16 -3
  87. package/node_modules/@openclaw/fs-safe/dist/local-file-descriptor.js +24 -13
  88. package/node_modules/@openclaw/fs-safe/dist/native-binding.d.ts +85 -18
  89. package/node_modules/@openclaw/fs-safe/dist/native-config.d.ts +5 -0
  90. package/node_modules/@openclaw/fs-safe/dist/native-config.js +11 -0
  91. package/node_modules/@openclaw/fs-safe/dist/native-directory-observation.js +6 -4
  92. package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.d.ts +2 -1
  93. package/node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js +26 -2
  94. package/node_modules/@openclaw/fs-safe/dist/native-guidance.d.ts +3 -0
  95. package/node_modules/@openclaw/fs-safe/dist/native-guidance.js +21 -0
  96. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.d.ts +1 -1
  97. package/node_modules/@openclaw/fs-safe/dist/native-move-fallback.js +2 -0
  98. package/node_modules/@openclaw/fs-safe/dist/native-operations.js +8 -6
  99. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.d.ts +44 -4
  100. package/node_modules/@openclaw/fs-safe/dist/native-parent-admission.js +85 -15
  101. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.d.ts +3 -3
  102. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write-windows.js +33 -6
  103. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.d.ts +4 -1
  104. package/node_modules/@openclaw/fs-safe/dist/native-pinned-write.js +22 -3
  105. package/node_modules/@openclaw/fs-safe/dist/native-policy-directory-observation.js +4 -3
  106. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.d.ts +1 -1
  107. package/node_modules/@openclaw/fs-safe/dist/native-policy-parent.js +3 -0
  108. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.d.ts +3 -0
  109. package/node_modules/@openclaw/fs-safe/dist/native-staged-file-metadata.js +16 -0
  110. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.d.ts +1 -1
  111. package/node_modules/@openclaw/fs-safe/dist/native-staged-file.js +15 -5
  112. package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.d.ts +3 -0
  113. package/node_modules/@openclaw/fs-safe/dist/native-stat-identity.js +7 -0
  114. package/node_modules/@openclaw/fs-safe/dist/native-status.d.ts +17 -0
  115. package/node_modules/@openclaw/fs-safe/dist/native-status.js +30 -0
  116. package/node_modules/@openclaw/fs-safe/dist/native.d.ts +31 -4
  117. package/node_modules/@openclaw/fs-safe/dist/native.js +107 -9
  118. package/node_modules/@openclaw/fs-safe/dist/opened-realpath.js +9 -1
  119. package/node_modules/@openclaw/fs-safe/dist/overwrite-file-handle.js +4 -1
  120. package/node_modules/@openclaw/fs-safe/dist/owner-dacl-batch.js +1 -1
  121. package/node_modules/@openclaw/fs-safe/dist/owner-dacl.js +1 -1
  122. package/node_modules/@openclaw/fs-safe/dist/permission-exec.js +9 -1
  123. package/node_modules/@openclaw/fs-safe/dist/permissions-public.d.ts +1 -0
  124. package/node_modules/@openclaw/fs-safe/dist/permissions-public.js +1 -0
  125. package/node_modules/@openclaw/fs-safe/dist/permissions-windows.js +83 -47
  126. package/node_modules/@openclaw/fs-safe/dist/pinned-open.d.ts +2 -0
  127. package/node_modules/@openclaw/fs-safe/dist/pinned-open.js +8 -3
  128. package/node_modules/@openclaw/fs-safe/dist/pinned-write-input.js +13 -0
  129. package/node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js +10 -8
  130. package/node_modules/@openclaw/fs-safe/dist/pinned-write-types.d.ts +2 -1
  131. package/node_modules/@openclaw/fs-safe/dist/pinned-write.js +7 -5
  132. package/node_modules/@openclaw/fs-safe/dist/pipe.d.ts +9 -0
  133. package/node_modules/@openclaw/fs-safe/dist/pipe.js +26 -0
  134. package/node_modules/@openclaw/fs-safe/dist/private-directory.js +1 -1
  135. package/node_modules/@openclaw/fs-safe/dist/private-producer-handoff.js +2 -5
  136. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.d.ts +3 -2
  137. package/node_modules/@openclaw/fs-safe/dist/private-temp-workspace.js +38 -10
  138. package/node_modules/@openclaw/fs-safe/dist/publish-copy-stage.js +92 -10
  139. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.d.ts +3 -0
  140. package/node_modules/@openclaw/fs-safe/dist/publish-file-failure.js +3 -0
  141. package/node_modules/@openclaw/fs-safe/dist/publish-file.d.ts +5 -3
  142. package/node_modules/@openclaw/fs-safe/dist/publish-file.js +26 -20
  143. package/node_modules/@openclaw/fs-safe/dist/read-opened-file.d.ts +2 -0
  144. package/node_modules/@openclaw/fs-safe/dist/read-opened-file.js +3 -4
  145. package/node_modules/@openclaw/fs-safe/dist/realpath.js +32 -0
  146. package/node_modules/@openclaw/fs-safe/dist/regular-file.d.ts +4 -0
  147. package/node_modules/@openclaw/fs-safe/dist/regular-file.js +11 -15
  148. package/node_modules/@openclaw/fs-safe/dist/replace-file-descriptor.js +3 -2
  149. package/node_modules/@openclaw/fs-safe/dist/root-copy.d.ts +18 -0
  150. package/node_modules/@openclaw/fs-safe/dist/root-copy.js +128 -0
  151. package/node_modules/@openclaw/fs-safe/dist/root-create-native.d.ts +8 -13
  152. package/node_modules/@openclaw/fs-safe/dist/root-create-native.js +252 -27
  153. package/node_modules/@openclaw/fs-safe/dist/root-directory-creation.js +5 -1
  154. package/node_modules/@openclaw/fs-safe/dist/root-directory-list-types.d.ts +11 -8
  155. package/node_modules/@openclaw/fs-safe/dist/root-directory-list.js +35 -13
  156. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.d.ts +8 -0
  157. package/node_modules/@openclaw/fs-safe/dist/root-file-open-batch-sync.js +108 -0
  158. package/node_modules/@openclaw/fs-safe/dist/root-file.d.ts +7 -0
  159. package/node_modules/@openclaw/fs-safe/dist/root-file.js +15 -0
  160. package/node_modules/@openclaw/fs-safe/dist/root-impl.d.ts +2 -0
  161. package/node_modules/@openclaw/fs-safe/dist/root-impl.js +154 -175
  162. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.d.ts +2 -0
  163. package/node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js +239 -0
  164. package/node_modules/@openclaw/fs-safe/dist/root-move-noreplace.js +37 -15
  165. package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.d.ts +32 -0
  166. package/node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js +56 -0
  167. package/node_modules/@openclaw/fs-safe/dist/root-options.d.ts +2 -0
  168. package/node_modules/@openclaw/fs-safe/dist/root-public-types.d.ts +1 -0
  169. package/node_modules/@openclaw/fs-safe/dist/root-remove-native.js +95 -16
  170. package/node_modules/@openclaw/fs-safe/dist/root-remove.js +6 -4
  171. package/node_modules/@openclaw/fs-safe/dist/root-walk.js +23 -19
  172. package/node_modules/@openclaw/fs-safe/dist/root-write-admission.js +8 -6
  173. package/node_modules/@openclaw/fs-safe/dist/root-write-publication.js +5 -1
  174. package/node_modules/@openclaw/fs-safe/dist/secure-file-windows.js +3 -1
  175. package/node_modules/@openclaw/fs-safe/dist/secure-file.d.ts +2 -0
  176. package/node_modules/@openclaw/fs-safe/dist/secure-file.js +10 -4
  177. package/node_modules/@openclaw/fs-safe/dist/sibling-staged-file.js +1 -1
  178. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-reclaim.js +2 -2
  179. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-retained.js +1 -1
  180. package/node_modules/@openclaw/fs-safe/dist/sidecar-lock-target.js +8 -1
  181. package/node_modules/@openclaw/fs-safe/dist/staged-directory.d.ts +13 -0
  182. package/node_modules/@openclaw/fs-safe/dist/staged-directory.js +29 -0
  183. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-child-admission.js +5 -3
  184. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.d.ts +8 -0
  185. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-descriptor.js +13 -2
  186. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-owner.js +71 -3
  187. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.d.ts +2 -1
  188. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-ownership.js +22 -0
  189. package/node_modules/@openclaw/fs-safe/dist/temp-workspace-types.d.ts +3 -0
  190. package/node_modules/@openclaw/fs-safe/dist/test-hooks.d.ts +1 -0
  191. package/node_modules/@openclaw/fs-safe/dist/test-hooks.js +1 -0
  192. package/node_modules/@openclaw/fs-safe/dist/trash.js +2 -2
  193. package/node_modules/@openclaw/fs-safe/dist/types.d.ts +4 -0
  194. package/node_modules/@openclaw/fs-safe/dist/watch-native.js +2 -2
  195. package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.d.ts +5 -0
  196. package/node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js +39 -0
  197. package/node_modules/@openclaw/fs-safe/dist/windows-owner.d.ts +1 -0
  198. package/node_modules/@openclaw/fs-safe/dist/windows-owner.js +25 -36
  199. package/node_modules/@openclaw/fs-safe/dist/windows-security-command.js +24 -5
  200. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.d.ts +2 -1
  201. package/node_modules/@openclaw/fs-safe/dist/windows-security-facts.js +4 -0
  202. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.d.ts +2 -0
  203. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.exe +0 -0
  204. package/node_modules/@openclaw/fs-safe/dist/windows-security-helper.js +7 -0
  205. package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.d.ts +16 -0
  206. package/node_modules/@openclaw/fs-safe/dist/windows-test-hooks.js +51 -0
  207. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.d.ts +1 -0
  208. package/node_modules/@openclaw/fs-safe/dist/write-file-handle.js +12 -10
  209. package/node_modules/@openclaw/fs-safe/docs/advanced.md +2 -1
  210. package/node_modules/@openclaw/fs-safe/docs/archive.md +16 -0
  211. package/node_modules/@openclaw/fs-safe/docs/config.md +71 -1
  212. package/node_modules/@openclaw/fs-safe/docs/contributing.md +45 -5
  213. package/node_modules/@openclaw/fs-safe/docs/copy.md +45 -5
  214. package/node_modules/@openclaw/fs-safe/docs/durability.md +34 -7
  215. package/node_modules/@openclaw/fs-safe/docs/errors.md +8 -0
  216. package/node_modules/@openclaw/fs-safe/docs/guest.md +2 -0
  217. package/node_modules/@openclaw/fs-safe/docs/install.md +47 -27
  218. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.5.md +6 -6
  219. package/node_modules/@openclaw/fs-safe/docs/migrating-to-0.6.md +1 -1
  220. package/node_modules/@openclaw/fs-safe/docs/native-helper.md +79 -6
  221. package/node_modules/@openclaw/fs-safe/docs/native.md +279 -8
  222. package/node_modules/@openclaw/fs-safe/docs/permissions.md +64 -15
  223. package/node_modules/@openclaw/fs-safe/docs/pipe.md +81 -0
  224. package/node_modules/@openclaw/fs-safe/docs/platform-capabilities.md +63 -0
  225. package/node_modules/@openclaw/fs-safe/docs/public-api.md +10 -0
  226. package/node_modules/@openclaw/fs-safe/docs/queue-link-free-design.md +237 -0
  227. package/node_modules/@openclaw/fs-safe/docs/quickstart.md +23 -3
  228. package/node_modules/@openclaw/fs-safe/docs/reading.md +56 -2
  229. package/node_modules/@openclaw/fs-safe/docs/regular-file.md +2 -0
  230. package/node_modules/@openclaw/fs-safe/docs/secret-file.md +5 -5
  231. package/node_modules/@openclaw/fs-safe/docs/secure-file.md +1 -1
  232. package/node_modules/@openclaw/fs-safe/docs/security-model.md +35 -0
  233. package/node_modules/@openclaw/fs-safe/docs/sidecar-lock.md +31 -13
  234. package/node_modules/@openclaw/fs-safe/docs/staged-file.md +18 -0
  235. package/node_modules/@openclaw/fs-safe/docs/store.md +15 -0
  236. package/node_modules/@openclaw/fs-safe/docs/temp.md +39 -0
  237. package/node_modules/@openclaw/fs-safe/docs/testing.md +13 -0
  238. package/node_modules/@openclaw/fs-safe/docs/types.md +51 -81
  239. package/node_modules/@openclaw/fs-safe/docs/walk.md +4 -1
  240. package/node_modules/@openclaw/fs-safe/docs/watch.md +3 -2
  241. package/node_modules/@openclaw/fs-safe/docs/writing.md +121 -14
  242. package/node_modules/@openclaw/fs-safe/package.json +21 -12
  243. package/node_modules/@openclaw/fs-safe-darwin-arm64/fs-safe-native.node +0 -0
  244. package/node_modules/@openclaw/fs-safe-darwin-arm64/package.json +1 -1
  245. package/node_modules/@openclaw/fs-safe-darwin-x64/fs-safe-native.node +0 -0
  246. package/node_modules/@openclaw/fs-safe-darwin-x64/package.json +1 -1
  247. package/node_modules/@openclaw/fs-safe-freebsd-arm64/fs-safe-native.node +0 -0
  248. package/node_modules/@openclaw/fs-safe-freebsd-arm64/package.json +29 -0
  249. package/node_modules/@openclaw/fs-safe-freebsd-x64/fs-safe-native.node +0 -0
  250. package/node_modules/@openclaw/fs-safe-freebsd-x64/package.json +29 -0
  251. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/fs-safe-native.node +0 -0
  252. package/node_modules/@openclaw/fs-safe-linux-arm64-gnu/package.json +1 -1
  253. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/fs-safe-native.node +0 -0
  254. package/node_modules/@openclaw/fs-safe-linux-arm64-musl/package.json +1 -1
  255. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/fs-safe-native.node +0 -0
  256. package/node_modules/@openclaw/fs-safe-linux-x64-gnu/package.json +1 -1
  257. package/node_modules/@openclaw/fs-safe-linux-x64-musl/fs-safe-native.node +0 -0
  258. package/node_modules/@openclaw/fs-safe-linux-x64-musl/package.json +1 -1
  259. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/fs-safe-native.node +0 -0
  260. package/node_modules/@openclaw/fs-safe-win32-arm64-msvc/package.json +29 -0
  261. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/fs-safe-native.node +0 -0
  262. package/node_modules/@openclaw/fs-safe-win32-x64-msvc/package.json +1 -1
  263. package/node_modules/mdast-util-from-markdown/dev/lib/index.js +152 -45
  264. package/node_modules/mdast-util-from-markdown/dev/lib/types.d.ts +26 -0
  265. package/node_modules/mdast-util-from-markdown/lib/index.js +133 -40
  266. package/node_modules/mdast-util-from-markdown/lib/types.d.ts +26 -0
  267. package/node_modules/mdast-util-from-markdown/package.json +6 -7
  268. package/node_modules/mdast-util-from-markdown/readme.md +15 -1
  269. package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
  270. package/node_modules/typebox/package.json +1 -1
  271. package/package.json +7 -7
  272. package/dist/.setup/runtime-setter-api-CG-RC4_r.mjs +0 -3
  273. package/dist/.setup/secret-contract-CI1wCr9i.mjs +0 -60
  274. package/dist/.setup/secret-contract-api-o4CeT4nP.mjs +0 -3
  275. package/dist/.setup/setup-api-CLonEDID.mjs +0 -3
  276. package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.cs +0 -336
  277. package/node_modules/@openclaw/fs-safe/dist/windows-security-bridge.ps1 +0 -90
@@ -1,22 +1,21 @@
1
- import { c as normalizeFeishuExternalKey, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, s as normalizeFeishuWebhookPath } from "./doctor-contract-oIpUWtNO.mjs";
1
+ import { c as normalizeFeishuExternalKey, g as resolveFeishuRuntimeAccount, h as resolveFeishuAccount, s as normalizeFeishuWebhookPath } from "./doctor-contract-BNXcJcWR.mjs";
2
2
  import { o as resolveConfiguredFeishuGroupSessionScope, t as buildFeishuConversationId, u as resolveReceiveIdType } from "./conversation-id-D00i9uy5.mjs";
3
- import { c as resolveFeishuLegacyWebhookListener, l as gateway_config_runtime_exports, s as describeFeishuWebhookPathConflict } from "./channel-DykAJJhn.mjs";
4
- import { A as sendMessageFeishu, At as resolveFeishuGroupConversationIngressAccess, B as parseInteractiveCardContent, D as getMessageFeishu, Dt as normalizeFeishuAllowEntry, Et as hasExplicitFeishuGroupConfig, F as isFeishuBroadcastMention, Ft as resolveFeishuChatType, I as isMentionForwardRequest, K as deliverCommentThreadText, L as normalizeMentions, Lt as createFeishuCardInteractionEnvelope, N as formatFeishuMediaContent, Nt as resolveFeishuReplyPolicy, O as listFeishuThreadMessages, Ot as resolveFeishuDmIngressAccess, P as extractMentionTargets, Pt as normalizeFeishuChatType, R as isFeishuGroupChatType, Rt as decodeFeishuCardAction, S as sendMediaFeishu, T as chunkFeishuCardMarkdown, U as buildFeishuMediaFallbackText, V as parsePostContent, W as resolveFeishuIdentityEmoji, a as shouldSendNoVisibleReplyFallback, at as parseCommentContentElements, b as withinCardTableLimit, ct as normalizeCommentFileType, d as consumeFeishuPresentationFallbackMarker, dt as resolveFeishuCardTemplate, gt as shouldUseFeishuCard, i as noVisibleFeishuReplyDelivery, j as sendStructuredCardFeishu, jt as resolveFeishuGroupSenderActivationIngressAccess, k as sendCardFeishu, kt as resolveFeishuGroupConfig, mt as materializeFeishuPostMarkdownSoftBreaks, n as createFeishuReplyDeliveryResult, nt as encodeQuery, ot as requestFeishuApi, pt as chunkFeishuPostMarkdown, r as mergeFeishuReplyDeliveryResults, rt as extractReplyText, st as buildFeishuCommentTarget, t as createFeishuPartialReplyDeliveryError, tt as createCommentTypingReactionLifecycle, u as buildFeishuPresentationFallback, v as renderFeishuReplyPayload, w as shouldSuppressFeishuTextForVoiceMedia, x as saveMessageResourceFeishu, y as resolveFeishuRichReply, z as normalizeFeishuEventChatType } from "./reply-delivery-result-iCCrdxE1.mjs";
3
+ import { c as resolveFeishuLegacyWebhookListener, l as gateway_config_runtime_exports, s as describeFeishuWebhookPathConflict } from "./channel-VyjzWvqm.mjs";
4
+ import { A as sendMessageFeishu, At as resolveFeishuGroupConfig, B as parseInteractiveCardContent, D as getMessageFeishu, Dt as hasExplicitFeishuGroupConfig, F as isFeishuBroadcastMention, Ft as normalizeFeishuChatType, G as resolveFeishuIdentityEmoji, H as resolveFeishuSenderName, I as isMentionForwardRequest, It as resolveFeishuChatType, L as normalizeMentions, Mt as resolveFeishuGroupSenderActivationIngressAccess, N as formatFeishuMediaContent, O as listFeishuThreadMessages, Ot as normalizeFeishuAllowEntry, P as extractMentionTargets, Pt as resolveFeishuReplyPolicy, R as isFeishuGroupChatType, Rt as createFeishuCardInteractionEnvelope, S as sendMediaFeishu, T as chunkFeishuCardMarkdown, V as parsePostContent, W as buildFeishuMediaFallbackText, _t as shouldUseFeishuCard, a as shouldSendNoVisibleReplyFallback, b as withinCardTableLimit, ct as buildFeishuCommentTarget, d as consumeFeishuPresentationFallbackMarker, ft as resolveFeishuCardTemplate, ht as materializeFeishuPostMarkdownSoftBreaks, i as noVisibleFeishuReplyDelivery, it as extractReplyText, j as sendStructuredCardFeishu, jt as resolveFeishuGroupConversationIngressAccess, k as sendCardFeishu, kt as resolveFeishuDmIngressAccess, lt as normalizeCommentFileType, mt as chunkFeishuPostMarkdown, n as createFeishuReplyDeliveryResult, nt as createCommentTypingReactionLifecycle, ot as parseCommentContentElements, q as deliverCommentThreadText, r as mergeFeishuReplyDeliveryResults, rt as encodeQuery, st as requestFeishuApi, t as createFeishuPartialReplyDeliveryError, u as buildFeishuPresentationFallback, v as renderFeishuReplyPayload, w as shouldSuppressFeishuTextForVoiceMedia, x as saveMessageResourceFeishu, y as resolveFeishuRichReply, z as normalizeFeishuEventChatType, zt as decodeFeishuCardAction } from "./reply-delivery-result-DknmIzOB.mjs";
5
5
  import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.mjs";
6
- import { a as getFeishuUserAgent, f as resolveConfiguredHttpTimeoutMs, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient } from "./client-wwr8PGPH.mjs";
7
- import { r as getChatInfo } from "./chat-fC3dvxFs.mjs";
8
- import { t as createFeishuThreadBindingManager } from "./thread-bindings-Pii2fAST.mjs";
6
+ import { a as getFeishuUserAgent, f as resolveConfiguredHttpTimeoutMs, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient } from "./client-BTiFlqqL.mjs";
7
+ import { t as createFeishuThreadBindingManager } from "./thread-bindings-BxKmOara.mjs";
8
+ import { r as getChatInfo } from "./chat-qj1pEIcO.mjs";
9
9
  import { evaluateSupplementalContextVisibility, normalizeAgentId as normalizeAgentId$1, resolveChannelContextVisibilityMode } from "../runtime-api.js";
10
10
  import { t as readFeishuJsonResponse } from "./json-response-DXajw_FU.mjs";
11
- import { a as waitForAbortableDelay, i as raceWithTimeoutAndAbort } from "./probe-DXnFxq5j.mjs";
12
- import { t as fetchBotIdentityForMonitor } from "./monitor-Cy9ofY1Q.mjs";
11
+ import { a as waitForAbortableDelay, i as raceWithTimeoutAndAbort } from "./probe-s0hiM44D.mjs";
12
+ import { t as fetchBotIdentityForMonitor } from "./monitor-DzmCjp4q.mjs";
13
13
  import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
14
14
  import { DEFAULT_INGRESS_ADOPTION_STALL_MS, bindIngressLifecycleToReplyOptions, createChannelIngressError, createChannelIngressMonitor, createChannelMessageReplyPipeline, createReplyPrefixContext, formatChannelProgressDraftLineForEntry, resolveAgentOutboundIdentity, resolveChannelPreviewStreamMode, resolveChannelStreamingBlockEnabled, waitUntilAbort } from "openclaw/plugin-sdk/channel-outbound";
15
15
  import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
16
- import { ensureConfiguredBindingRouteReady, resolveConfiguredBindingRoute, resolveRuntimeConversationBindingRoute } from "openclaw/plugin-sdk/conversation-runtime";
17
16
  import { collectErrorGraphCandidates, formatErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
18
- import { asDateTimestampMs, isFutureDateTimestampMs, parseStrictNonNegativeInteger, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveExpiresAtMsFromDurationSeconds, resolvePromptHistoryLimit, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
19
- import { asBoolean, asNullableRecord, isRecord, normalizeLowercaseStringOrEmpty, normalizeNullableString, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeTrimmedStringList, readStringValue, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
17
+ import { asDateTimestampMs, isFutureDateTimestampMs, parseStrictNonNegativeInteger, resolveDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveExpiresAtMsFromDurationSeconds, resolvePromptHistoryLimit } from "openclaw/plugin-sdk/number-runtime";
18
+ import { asBoolean, asNullableRecord, isRecord, normalizeNullableString, normalizeOptionalLowercaseString, normalizeOptionalString, normalizeTrimmedStringList, readStringValue, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
20
19
  import { stripReasoningTagsFromText } from "openclaw/plugin-sdk/text-chunking";
21
20
  import { resolveDefaultGroupPolicy, resolveOpenProviderRuntimeGroupPolicy, warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
22
21
  import { fanInChannelIngressLifecycles } from "openclaw/plugin-sdk/channel-ingress-runtime";
@@ -25,7 +24,7 @@ import fs from "node:fs";
25
24
  import os from "node:os";
26
25
  import path from "node:path";
27
26
  import { normalizeAccountId, resolveAgentRoute, resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
28
- import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
27
+ import { getSessionEntryAsync, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
29
28
  import { formatAgentEnvelope, formatInboundMediaUnavailableText, isChannelPartialDeliveryError, recordChannelBotPairLoopAndCheckSuppression, resolveEnvelopeFormatOptions, resolveInboundReplyDispatchCounts, toInboundMediaFactsWithMetadata } from "openclaw/plugin-sdk/channel-inbound";
30
29
  import { getReplyPayloadTtsSupplement, resolveSendableOutboundReplyParts, resolveTextChunksWithFallback, sendMediaWithLeadingCaption } from "openclaw/plugin-sdk/reply-payload";
31
30
  import { resolvePinnedMainDmOwnerFromAllowlist, safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
@@ -33,10 +32,11 @@ import * as Lark from "@larksuiteoapi/node-sdk";
33
32
  import { isRecord as isRecord$1 } from "openclaw/plugin-sdk/channel-secret-basic-runtime";
34
33
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
35
34
  import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
35
+ import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
36
36
  import { safeParseJson, sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
37
+ import { ensureConfiguredBindingRouteReady, resolveConfiguredBindingRoute, resolveRuntimeConversationBindingRouteAsync } from "openclaw/plugin-sdk/conversation-binding-runtime";
37
38
  import * as crypto$1 from "node:crypto";
38
39
  import crypto, { createHash } from "node:crypto";
39
- import { pruneMapToMaxSize } from "openclaw/plugin-sdk/collection-runtime";
40
40
  import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
41
41
  import { createChannelHistoryWindow } from "openclaw/plugin-sdk/reply-history";
42
42
  import { createChannelReplayGuard } from "openclaw/plugin-sdk/persistent-dedupe";
@@ -100,15 +100,13 @@ function createFeishuBroadcastIngressSettlement(params) {
100
100
  const fallbackAbort = new AbortController();
101
101
  let fanoutSettled = false;
102
102
  let terminal;
103
- let adoption;
104
- let abandonment;
103
+ let terminalSettled = false;
105
104
  let finalizing = false;
106
105
  let deferred = false;
107
- let replayReleased = false;
108
106
  const settlement = createDeferred();
109
107
  params.trackTask?.(settlement.promise);
110
108
  const finishSettlement = () => {
111
- if (![...lanes].some((lane) => lane.adopting)) settlement.resolve();
109
+ if (terminalSettled && ![...lanes].some((lane) => lane.adopting)) settlement.resolve();
112
110
  };
113
111
  const beginFinalizing = () => {
114
112
  if (finalizing) return;
@@ -125,37 +123,24 @@ function createFeishuBroadcastIngressSettlement(params) {
125
123
  params.onReplayCommitError?.(error);
126
124
  } catch {}
127
125
  };
128
- const releaseReplayClaim = (error) => {
129
- if (replayReleased || terminal === "adopted") return;
130
- replayReleased = true;
131
- params.replayClaim?.release({ error });
132
- };
133
- const runAbandonment = async (error) => {
126
+ const abandon = async (error) => {
134
127
  if (terminal) return;
135
- releaseReplayClaim(error);
128
+ terminal = "abandoned";
129
+ params.replayClaim?.release({ error });
136
130
  try {
137
131
  await params.lifecycle?.onAbandoned();
138
132
  } finally {
139
- terminal = "abandoned";
140
133
  fallbackAbort.abort(error);
134
+ terminalSettled = true;
141
135
  finishSettlement();
142
136
  }
143
137
  };
144
- const abandon = async (error) => {
138
+ const adopt = async () => {
145
139
  if (terminal) return;
146
- if (adoption) {
147
- await adoption.catch(() => void 0);
148
- if (terminal) return;
149
- }
150
- const activeAbandonment = abandonment ?? runAbandonment(error);
151
- abandonment = activeAbandonment;
152
- await activeAbandonment;
153
- };
154
- const runAdoption = async () => {
140
+ terminal = "adopted";
155
141
  try {
156
142
  beginFinalizing();
157
143
  await params.lifecycle?.onAdopted();
158
- terminal = "adopted";
159
144
  try {
160
145
  params.onAdopted?.();
161
146
  } catch {}
@@ -165,29 +150,21 @@ function createFeishuBroadcastIngressSettlement(params) {
165
150
  reportReplayCommitError(error);
166
151
  }
167
152
  } catch (error) {
168
- await runAbandonment(error).catch(() => void 0);
153
+ terminal = void 0;
154
+ await abandon(error).catch(() => void 0);
169
155
  throw error;
170
156
  } finally {
157
+ terminalSettled = true;
171
158
  finishSettlement();
172
159
  }
173
160
  };
174
- const adopt = async () => {
175
- if (terminal) return;
176
- if (abandonment) {
177
- await abandonment.catch(() => void 0);
178
- if (terminal) return;
179
- }
180
- const activeAdoption = adoption ?? runAdoption();
181
- adoption = activeAdoption;
182
- await activeAdoption;
183
- };
184
161
  const maybeSettle = async () => {
185
162
  if (!fanoutSettled || terminal) return;
186
- if (failures.length > 0 || [...lanes].some((lane) => lane.status === "failed" || lane.status === "abandoned")) {
163
+ if (failures.length > 0 || [...lanes].some((lane) => lane.status === "failed")) {
187
164
  await abandon(failures.length === 1 ? failures[0] : new AggregateError(failures, "Feishu broadcast dispatch failed"));
188
165
  return;
189
166
  }
190
- if ([...lanes].some((lane) => lane.status === "pending" || lane.status === "deferred" || lane.status === "adopted")) return;
167
+ if ([...lanes].some((lane) => lane.status !== "completed")) return;
191
168
  await adopt();
192
169
  };
193
170
  return {
@@ -201,8 +178,7 @@ function createFeishuBroadcastIngressSettlement(params) {
201
178
  lifecycle: {
202
179
  abortSignal: params.lifecycle?.abortSignal ?? fallbackAbort.signal,
203
180
  onAdopted: async () => {
204
- if (terminal || lane.status === "adopted" || lane.status === "completed" || lane.status === "failed" || lane.status === "abandoned") return;
205
- lane.status = "adopted";
181
+ if (terminal || lane.adopting || lane.status === "completed" || lane.status === "failed") return;
206
182
  lane.adopting = true;
207
183
  try {
208
184
  beginFinalizing();
@@ -227,14 +203,14 @@ function createFeishuBroadcastIngressSettlement(params) {
227
203
  deferredHeartbeatIntervalMs: params.lifecycle?.deferredHeartbeatIntervalMs,
228
204
  onAdoptionFinalizing: beginFinalizing,
229
205
  onAbandoned: async () => {
230
- if (lane.status === "completed" || lane.status === "failed" || lane.status === "abandoned") return;
231
- lane.status = "abandoned";
206
+ if (lane.adopting || lane.status === "completed" || lane.status === "failed") return;
207
+ lane.status = "failed";
232
208
  lane.replayClaim?.release({ error: /* @__PURE__ */ new Error("feishu-broadcast-turn-abandoned") });
233
209
  await maybeSettle();
234
210
  }
235
211
  },
236
212
  onDispatchComplete: async (dispatched) => {
237
- if (lane.status !== "pending") return;
213
+ if (lane.adopting || lane.status !== "pending") return;
238
214
  const error = /* @__PURE__ */ new Error(dispatched ? "feishu broadcast dispatch returned before turn adoption" : "feishu broadcast lane was not dispatched");
239
215
  lane.status = "failed";
240
216
  failures.push(error);
@@ -242,7 +218,7 @@ function createFeishuBroadcastIngressSettlement(params) {
242
218
  },
243
219
  onDispatchFailed: async (error) => {
244
220
  failures.push(error);
245
- if (lane.status !== "completed") {
221
+ if (!lane.adopting && lane.status !== "completed") {
246
222
  lane.status = "failed";
247
223
  lane.replayClaim?.release({ error });
248
224
  }
@@ -438,23 +414,15 @@ const feishuGroupNameCache = /* @__PURE__ */ new Map();
438
414
  const GROUP_NAME_CACHE_TTL_MS = 18e5;
439
415
  const GROUP_NAME_CACHE_MAX_SIZE = 500;
440
416
  function evictGroupNameCache() {
441
- const now = asDateTimestampMs(Date.now());
442
- if (now === void 0) {
443
- feishuGroupNameCache.clear();
444
- return;
445
- }
446
- for (const [key, value] of feishuGroupNameCache) {
447
- const expiresAt = asDateTimestampMs(value.expiresAt);
448
- if (expiresAt === void 0 || expiresAt <= now) feishuGroupNameCache.delete(key);
449
- }
417
+ const now = Date.now();
418
+ for (const [key, value] of feishuGroupNameCache) if (value.expiresAt <= now) feishuGroupNameCache.delete(key);
450
419
  pruneMapToMaxSize(feishuGroupNameCache, GROUP_NAME_CACHE_MAX_SIZE);
451
420
  }
452
421
  function setCacheEntry(key, name) {
453
- const expiresAt = resolveExpiresAtMsFromDurationMs(GROUP_NAME_CACHE_TTL_MS);
454
422
  feishuGroupNameCache.delete(key);
455
- if (expiresAt !== void 0) feishuGroupNameCache.set(key, {
423
+ feishuGroupNameCache.set(key, {
456
424
  name,
457
- expiresAt
425
+ expiresAt: Date.now() + GROUP_NAME_CACHE_TTL_MS
458
426
  });
459
427
  }
460
428
  async function resolveGroupName(params) {
@@ -463,9 +431,7 @@ async function resolveGroupName(params) {
463
431
  const cacheKey = `${account.accountId}:${chatId}`;
464
432
  const cached = feishuGroupNameCache.get(cacheKey);
465
433
  if (cached) {
466
- const now = asDateTimestampMs(Date.now());
467
- const expiresAt = asDateTimestampMs(cached.expiresAt);
468
- if (now !== void 0 && expiresAt !== void 0 && expiresAt > now) return cached.name || void 0;
434
+ if (cached.expiresAt > Date.now()) return cached.name || void 0;
469
435
  feishuGroupNameCache.delete(cacheKey);
470
436
  }
471
437
  let resolvedName;
@@ -617,96 +583,6 @@ async function resolveFeishuBotName(params) {
617
583
  }
618
584
  }
619
585
  //#endregion
620
- //#region extensions/feishu/src/bot-sender-name.ts
621
- const STALE_CONTACT_SCOPE = "contact:contact.base:readonly";
622
- const FEISHU_USER_LOOKUP_UNAUTHORIZED_CODE = 41050;
623
- const SENDER_NAME_TTL_MS = 6e5;
624
- const SENDER_NAME_NEGATIVE_TTL_MS = 18e5;
625
- const SENDER_NAME_CACHE_MAX_SIZE = 500;
626
- const senderNameCache = /* @__PURE__ */ new Map();
627
- function extractFeishuApiError(err) {
628
- if (!err || typeof err !== "object") return null;
629
- const data = err.response?.data;
630
- if (!data || typeof data !== "object") return null;
631
- const feishuErr = data;
632
- if (typeof feishuErr.code !== "number") return null;
633
- return {
634
- code: feishuErr.code,
635
- message: typeof feishuErr.msg === "string" ? feishuErr.msg : ""
636
- };
637
- }
638
- function extractPermissionError(feishuErr) {
639
- if (feishuErr?.code !== 99991672) return null;
640
- const urlMatch = feishuErr.message.match(/https:\/\/[^\s,]+\/app\/[^\s,]+/);
641
- return {
642
- code: feishuErr.code,
643
- message: feishuErr.message,
644
- grantUrl: urlMatch?.[0]?.replaceAll(encodeURIComponent(STALE_CONTACT_SCOPE), encodeURIComponent("contact:user.base:readonly")).replaceAll(STALE_CONTACT_SCOPE, "contact:user.base:readonly")
645
- };
646
- }
647
- function writeSenderNameCache(key, entry) {
648
- senderNameCache.delete(key);
649
- senderNameCache.set(key, entry);
650
- pruneMapToMaxSize(senderNameCache, SENDER_NAME_CACHE_MAX_SIZE);
651
- }
652
- function resolveSenderLookupIdType(senderId) {
653
- if (senderId.startsWith("ou_")) return "open_id";
654
- if (senderId.startsWith("on_")) return "union_id";
655
- return "user_id";
656
- }
657
- async function resolveFeishuSenderName(params) {
658
- const { account, senderId, log } = params;
659
- if (!account.configured) return {};
660
- const normalizedSenderId = senderId.trim();
661
- if (!normalizedSenderId) return {};
662
- const cacheKey = `${account.accountId}:${normalizedSenderId}`;
663
- const cached = senderNameCache.get(cacheKey);
664
- const now = asDateTimestampMs(Date.now());
665
- const cachedExpireAt = cached ? asDateTimestampMs(cached.expireAt) : void 0;
666
- if (cached && now !== void 0 && cachedExpireAt !== void 0 && cachedExpireAt > now) return cached.kind === "resolved" ? { name: cached.name } : {};
667
- if (cached) senderNameCache.delete(cacheKey);
668
- try {
669
- const client = createFeishuClient(account);
670
- const userIdType = resolveSenderLookupIdType(normalizedSenderId);
671
- const user = (await client.contact.user.get({
672
- path: { user_id: normalizedSenderId },
673
- params: { user_id_type: userIdType }
674
- })).data?.user;
675
- const name = user?.name ?? user?.nickname ?? user?.en_name;
676
- if (name) {
677
- const expireAt = resolveExpiresAtMsFromDurationMs(SENDER_NAME_TTL_MS);
678
- if (expireAt !== void 0) writeSenderNameCache(cacheKey, {
679
- kind: "resolved",
680
- name,
681
- expireAt
682
- });
683
- return { name };
684
- }
685
- return {};
686
- } catch (err) {
687
- const feishuErr = extractFeishuApiError(err);
688
- const permErr = extractPermissionError(feishuErr);
689
- if (permErr) {
690
- if (normalizeLowercaseStringOrEmpty(permErr.message).includes(STALE_CONTACT_SCOPE)) {
691
- log(`feishu: ignoring stale permission scope error: ${permErr.message}`);
692
- return {};
693
- }
694
- log(`feishu: permission error resolving sender name: code=${permErr.code}`);
695
- return { permissionError: permErr };
696
- }
697
- if (feishuErr?.code === FEISHU_USER_LOOKUP_UNAUTHORIZED_CODE) {
698
- const expireAt = resolveExpiresAtMsFromDurationMs(SENDER_NAME_NEGATIVE_TTL_MS);
699
- if (expireAt !== void 0) writeSenderNameCache(cacheKey, {
700
- kind: "unavailable",
701
- expireAt
702
- });
703
- return {};
704
- }
705
- log(`feishu: failed to resolve sender name for ${normalizedSenderId}: ${String(err)}`);
706
- return {};
707
- }
708
- }
709
- //#endregion
710
586
  //#region extensions/feishu/src/bot-thread-mentions.ts
711
587
  async function prepareFeishuThreadRoot(params) {
712
588
  let { cfg, account } = params;
@@ -1026,15 +902,15 @@ function resolveUserPath(p) {
1026
902
  }
1027
903
  //#endregion
1028
904
  //#region extensions/feishu/src/reasoning-preview.ts
1029
- function resolveFeishuReasoningPreviewEnabled(params) {
905
+ async function resolveFeishuReasoningPreviewEnabled(params) {
1030
906
  const configDefault = resolveAgentConfig(params.cfg, params.agentId)?.reasoningDefault ?? params.cfg.agents?.defaults?.reasoningDefault ?? "off";
1031
907
  if (!params.sessionKey) return configDefault === "stream";
1032
908
  try {
1033
- const level = getSessionEntry({
909
+ const level = (await getSessionEntryAsync({
1034
910
  storePath: params.storePath,
1035
911
  sessionKey: params.sessionKey,
1036
912
  readConsistency: "latest"
1037
- })?.reasoningLevel;
913
+ }))?.reasoningLevel;
1038
914
  if (level === "on" || level === "stream" || level === "off") return level === "stream";
1039
915
  } catch {
1040
916
  return false;
@@ -1379,7 +1255,8 @@ var FeishuStreamingSession = class {
1379
1255
  const result = {
1380
1256
  visibleReplySent: visibleContentSent,
1381
1257
  ...visibleContentSent ? { content: finalState.sentText } : {},
1382
- ...finalState.messageId ? { messageId: finalState.messageId } : {}
1258
+ ...finalState.messageId ? { messageId: finalState.messageId } : {},
1259
+ ...finalWriteError === void 0 ? {} : { finalTextAccepted: false }
1383
1260
  };
1384
1261
  if (finalWriteError !== void 0 || closeError !== void 0) throw new FeishuStreamingFinalizationError(finalWriteError !== void 0 && closeError !== void 0 ? new AggregateError([finalWriteError, closeError], "Feishu streaming card finalization failed") : finalWriteError ?? closeError, result);
1385
1262
  return result;
@@ -1412,10 +1289,10 @@ var FeishuStreamingSession = class {
1412
1289
  //#region extensions/feishu/src/streaming-update.ts
1413
1290
  /** Admit captured snapshots in order while the session owns provider writes. */
1414
1291
  function queueFeishuStreamingUpdate(params) {
1415
- const { queue, session, generation, startPromise, text, accountId, runtime } = params;
1292
+ const { queue, session, startPromise, text, accountId, runtime } = params;
1416
1293
  return queue.then(async () => {
1417
1294
  if (startPromise) await startPromise;
1418
- if (generation !== void 0 && session?.isActive()) session.update(text).catch((error) => runtime.error?.(`feishu[${accountId}] streaming update failed: ${String(error)}`));
1295
+ if (session?.isActive()) session.update(text).catch((error) => runtime.error?.(`feishu[${accountId}] streaming update failed: ${String(error)}`));
1419
1296
  });
1420
1297
  }
1421
1298
  //#endregion
@@ -1643,13 +1520,12 @@ function createFeishuReplyDispatcher(params) {
1643
1520
  let lastSnapshotTextLength = 0;
1644
1521
  let hasStreamingFinalText = false;
1645
1522
  const deliveredFinalTexts = /* @__PURE__ */ new Set();
1646
- const closedStreamingSettlements = /* @__PURE__ */ new Map();
1523
+ let lastStreamingSettlement;
1647
1524
  let sentIndependentBlockText = false;
1648
1525
  let partialUpdateQueue = Promise.resolve();
1649
1526
  let streamingStartPromise = null;
1650
- let streamingGeneration = 0;
1651
- let activeStreamingGeneration;
1652
1527
  let inFlightStreamingClose;
1528
+ let closingStreamingText;
1653
1529
  let visibleReplySent = false;
1654
1530
  let replyOutcome;
1655
1531
  let idleSideEffectsPromise = Promise.resolve();
@@ -1668,7 +1544,6 @@ function createFeishuReplyDispatcher(params) {
1668
1544
  partialUpdateQueue = queueFeishuStreamingUpdate({
1669
1545
  queue: partialUpdateQueue,
1670
1546
  session: streaming,
1671
- generation: activeStreamingGeneration,
1672
1547
  startPromise: streamingStartPromise,
1673
1548
  text: combined,
1674
1549
  accountId: account.accountId,
@@ -1701,9 +1576,7 @@ function createFeishuReplyDispatcher(params) {
1701
1576
  } : null;
1702
1577
  if (!creds) return;
1703
1578
  const session = new FeishuStreamingSession(createFeishuClient(account), creds, (message) => params.runtime.log?.(`feishu[${account.accountId}] ${message}`));
1704
- const generation = ++streamingGeneration;
1705
1579
  streaming = session;
1706
- activeStreamingGeneration = generation;
1707
1580
  try {
1708
1581
  const cardHeader = resolveCardHeader(agentId, identity);
1709
1582
  const cardNote = resolveCardNote(agentId, identity, responsePrefixContextProvider());
@@ -1722,7 +1595,6 @@ function createFeishuReplyDispatcher(params) {
1722
1595
  if (streaming === session) {
1723
1596
  streaming = null;
1724
1597
  streamingStartPromise = null;
1725
- activeStreamingGeneration = void 0;
1726
1598
  }
1727
1599
  }
1728
1600
  })();
@@ -1730,7 +1602,6 @@ function createFeishuReplyDispatcher(params) {
1730
1602
  const resetStreamingState = () => {
1731
1603
  streaming = null;
1732
1604
  streamingStartPromise = null;
1733
- activeStreamingGeneration = void 0;
1734
1605
  partialUpdateQueue = Promise.resolve();
1735
1606
  streamText = "";
1736
1607
  lastPartial = "";
@@ -1740,27 +1611,21 @@ function createFeishuReplyDispatcher(params) {
1740
1611
  lastSnapshotTextLength = 0;
1741
1612
  hasStreamingFinalText = false;
1742
1613
  };
1743
- const rememberClosedStreamingSettlement = (generation, content, result, error, disposition = "closed") => {
1744
- if (generation === void 0 || !content && disposition === "closed") return;
1745
- closedStreamingSettlements.set(generation, {
1746
- disposition,
1747
- result,
1748
- content,
1749
- ...error === void 0 ? {} : { error }
1750
- });
1751
- };
1752
1614
  const performStreamingClose = async (disposition) => {
1753
1615
  const streamingToClose = streaming;
1754
- const generationToClose = activeStreamingGeneration;
1616
+ if (!streamingToClose) return lastStreamingSettlement ?? {
1617
+ disposition,
1618
+ result: noVisibleFeishuReplyDelivery
1619
+ };
1755
1620
  const startPromiseToClose = streamingStartPromise;
1756
1621
  const updateQueueToClose = partialUpdateQueue;
1757
1622
  const finalizedAnswerText = streamText;
1758
1623
  const finalizedReasoningText = reasoningText;
1759
1624
  const outcome = {
1760
1625
  disposition,
1761
- ...generationToClose === void 0 ? {} : { generation: generationToClose }
1626
+ content: finalizedAnswerText
1762
1627
  };
1763
- if (generationToClose !== void 0 && activeStreamingGeneration === generationToClose) activeStreamingGeneration = void 0;
1628
+ resetStreamingState();
1764
1629
  try {
1765
1630
  if (startPromiseToClose) await startPromiseToClose;
1766
1631
  await updateQueueToClose;
@@ -1781,61 +1646,48 @@ function createFeishuReplyDispatcher(params) {
1781
1646
  closed = error.result;
1782
1647
  finalizationError = error;
1783
1648
  }
1784
- result = createFeishuReplyDeliveryResult({
1785
- results: [closed],
1786
- visibleReplySent: closed.visibleReplySent,
1787
- content: closed.content,
1788
- kind: "card"
1789
- });
1649
+ result = {
1650
+ ...createFeishuReplyDeliveryResult({
1651
+ results: [closed],
1652
+ visibleReplySent: closed.visibleReplySent,
1653
+ content: closed.content,
1654
+ kind: "card"
1655
+ }),
1656
+ ...closed.finalTextAccepted === false ? { finalTextAccepted: false } : {}
1657
+ };
1790
1658
  if (result.visibleReplySent) visibleReplySent = true;
1791
1659
  if (disposition === "closed" && result.visibleReplySent && finalizedAnswerText && (finalizationError === void 0 || result.content === text)) deliveredFinalTexts.add(finalizedAnswerText);
1792
1660
  if (finalizationError instanceof FeishuStreamingFinalizationError && result.visibleReplySent) finalizationError = createFeishuPartialReplyDeliveryError(finalizationError.cause ?? finalizationError, result);
1793
1661
  }
1794
- if (disposition === "discarded" || finalizationError !== void 0 || result.visibleReplySent && finalizedAnswerText) rememberClosedStreamingSettlement(generationToClose, finalizedAnswerText, result, finalizationError, disposition);
1795
1662
  return {
1796
1663
  ...outcome,
1797
1664
  result,
1798
1665
  ...finalizationError === void 0 ? {} : { error: finalizationError }
1799
1666
  };
1800
1667
  } catch (error) {
1801
- if (disposition === "discarded") rememberClosedStreamingSettlement(generationToClose, finalizedAnswerText, noVisibleFeishuReplyDelivery, error, disposition);
1802
1668
  return {
1803
1669
  ...outcome,
1804
1670
  result: noVisibleFeishuReplyDelivery,
1805
1671
  error
1806
1672
  };
1807
- } finally {
1808
- if (streaming === streamingToClose) resetStreamingState();
1809
1673
  }
1810
1674
  };
1811
1675
  const closeStreaming = (disposition = "closed") => {
1812
- const session = streaming;
1813
- const generation = activeStreamingGeneration;
1814
- if (session && inFlightStreamingClose?.session === session) return inFlightStreamingClose.promise;
1815
- const content = streamText;
1816
- const closePromise = performStreamingClose(disposition);
1817
- if (session && generation !== void 0) {
1818
- const closing = {
1819
- session,
1820
- generation,
1821
- content,
1822
- disposition,
1823
- promise: closePromise
1824
- };
1825
- inFlightStreamingClose = closing;
1826
- const clear = () => {
1827
- if (inFlightStreamingClose === closing) inFlightStreamingClose = void 0;
1828
- };
1829
- closePromise.then(clear, clear);
1830
- }
1831
- return closePromise;
1676
+ if (inFlightStreamingClose) return inFlightStreamingClose;
1677
+ closingStreamingText = streamText;
1678
+ inFlightStreamingClose = performStreamingClose(disposition).then((outcome) => {
1679
+ lastStreamingSettlement = outcome;
1680
+ inFlightStreamingClose = void 0;
1681
+ closingStreamingText = void 0;
1682
+ return outcome;
1683
+ });
1684
+ return inFlightStreamingClose;
1832
1685
  };
1833
- const deferStreamingDelivery = (result, infoKind, ownerGeneration) => {
1686
+ const deferStreamingDelivery = (result, infoKind) => {
1834
1687
  const { promise: finalization, resolve, reject } = createDeferred();
1835
1688
  pendingStreamingDeliveries.push({
1836
1689
  result,
1837
1690
  ...infoKind ? { infoKind } : {},
1838
- ...ownerGeneration === void 0 ? {} : { streamingGeneration: ownerGeneration },
1839
1691
  resolve,
1840
1692
  reject
1841
1693
  });
@@ -1846,10 +1698,7 @@ function createFeishuReplyDispatcher(params) {
1846
1698
  };
1847
1699
  };
1848
1700
  const discardStreamingPreview = async () => {
1849
- if (streaming && inFlightStreamingClose?.session === streaming && inFlightStreamingClose.disposition === "closed") {
1850
- resetStreamingState();
1851
- return;
1852
- }
1701
+ if (inFlightStreamingClose && !streaming) return;
1853
1702
  const outcome = await closeStreaming("discarded");
1854
1703
  if (outcome.error !== void 0) throw toStringifiedError(outcome.error);
1855
1704
  };
@@ -1990,25 +1839,33 @@ function createFeishuReplyDispatcher(params) {
1990
1839
  params.runtime.error?.(`feishu[${account.accountId}]: sent no-visible-reply fallback (${reason})`);
1991
1840
  return true;
1992
1841
  };
1993
- const claimClosedStreamingResult = (generation, content) => {
1994
- if (generation !== void 0) {
1995
- const settlement = closedStreamingSettlements.get(generation);
1996
- if (settlement) settlement.contentClaimed = true;
1997
- return settlement;
1998
- }
1999
- let result;
2000
- for (const settlement of closedStreamingSettlements.values()) if (settlement.contentClaimed !== true && (content === void 0 || settlement.content === content)) result = settlement;
2001
- if (result) result.contentClaimed = true;
2002
- return result;
2003
- };
1842
+ const streamingRecoveries = /* @__PURE__ */ new WeakMap();
2004
1843
  const ensureVisibleStreamingDelivery = async (result, content, infoKind) => {
2005
- if (result?.visibleReplySent === true || !content?.trim()) return result;
2006
- return sendChunkedTextReply({
1844
+ if (result?.visibleReplySent === true && result.finalTextAccepted !== false || !content?.trim()) return result;
1845
+ let recoveries = result && streamingRecoveries.get(result);
1846
+ const pending = recoveries?.get(content);
1847
+ if (pending) return pending;
1848
+ const recovery = sendChunkedTextReply({
2007
1849
  text: content,
2008
1850
  useCard: withinCardTableLimit(content),
2009
1851
  infoKind,
2010
1852
  preparedPostText: true
1853
+ }).then((delivered) => {
1854
+ lastStreamingSettlement = {
1855
+ disposition: "closed",
1856
+ result: delivered,
1857
+ content
1858
+ };
1859
+ return delivered;
2011
1860
  });
1861
+ if (result) {
1862
+ if (!recoveries) {
1863
+ recoveries = /* @__PURE__ */ new Map();
1864
+ streamingRecoveries.set(result, recoveries);
1865
+ }
1866
+ recoveries.set(content, recovery);
1867
+ }
1868
+ return recovery;
2012
1869
  };
2013
1870
  function queueIdleSideEffects() {
2014
1871
  idleRequestedForReply = true;
@@ -2017,24 +1874,19 @@ function createFeishuReplyDispatcher(params) {
2017
1874
  try {
2018
1875
  do {
2019
1876
  const completions = pendingStreamingDeliveries.splice(0);
2020
- const closeOutcome = await closeStreaming();
2021
- const finalized = closeOutcome.result;
2022
- const ownsCurrentClose = (completion) => closeOutcome.generation !== void 0 && completion.streamingGeneration === closeOutcome.generation;
2023
- if (completions.some(ownsCurrentClose)) claimClosedStreamingResult(closeOutcome.generation, void 0);
1877
+ const closeOutcome = streaming || inFlightStreamingClose ? await closeStreaming() : completions.length > 0 && lastStreamingSettlement ? lastStreamingSettlement : {
1878
+ disposition: "closed",
1879
+ result: noVisibleFeishuReplyDelivery
1880
+ };
2024
1881
  for (const completion of completions) {
2025
- const claimedSettlement = ownsCurrentClose(completion) ? {
2026
- disposition: closeOutcome.disposition,
2027
- result: finalized,
2028
- ...closeOutcome.error === void 0 ? {} : { error: closeOutcome.error }
2029
- } : claimClosedStreamingResult(completion.streamingGeneration, completion.result.content);
2030
- const deliveryError = claimedSettlement?.error;
2031
- if (claimedSettlement?.disposition === "discarded") {
2032
- const retained = mergeFeishuReplyDeliveryResults([claimedSettlement.result, completion.result], claimedSettlement.result.content ?? "");
1882
+ const deliveryError = closeOutcome.error;
1883
+ if (closeOutcome.disposition === "discarded") {
1884
+ const retained = mergeFeishuReplyDeliveryResults([closeOutcome.result, completion.result], closeOutcome.result.content ?? "");
2033
1885
  if (deliveryError !== void 0) completion.reject(createFeishuPartialReplyDeliveryError(deliveryError, retained));
2034
1886
  else completion.resolve(retained);
2035
1887
  continue;
2036
1888
  }
2037
- let providerFinalized = claimedSettlement?.result;
1889
+ let providerFinalized = closeOutcome.result;
2038
1890
  try {
2039
1891
  providerFinalized = await ensureVisibleStreamingDelivery(providerFinalized, completion.result.content, completion.infoKind);
2040
1892
  } catch (fallbackError) {
@@ -2070,11 +1922,7 @@ function createFeishuReplyDispatcher(params) {
2070
1922
  let finalized = noVisibleFeishuReplyDelivery;
2071
1923
  let finalizationError;
2072
1924
  let fallbackPartial;
2073
- let settlement = claimClosedStreamingResult(paramsLocal.ownerGeneration, paramsLocal.content);
2074
- if (!settlement && paramsLocal.ownerGeneration !== void 0 && inFlightStreamingClose?.generation === paramsLocal.ownerGeneration) {
2075
- const closeOutcome = await inFlightStreamingClose.promise;
2076
- settlement = claimClosedStreamingResult(paramsLocal.ownerGeneration, paramsLocal.content) ?? closeOutcome;
2077
- } else if (!settlement && paramsLocal.ownerGeneration !== void 0 && activeStreamingGeneration === paramsLocal.ownerGeneration) settlement = await closeStreaming();
1925
+ const settlement = await closeStreaming();
2078
1926
  finalized = settlement?.result ?? finalized;
2079
1927
  finalizationError = settlement?.error;
2080
1928
  const discarded = settlement?.disposition === "discarded";
@@ -2120,7 +1968,7 @@ function createFeishuReplyDispatcher(params) {
2120
1968
  if (!replyLifecycleStateInitialized) {
2121
1969
  replyLifecycleStateInitialized = true;
2122
1970
  deliveredFinalTexts.clear();
2123
- closedStreamingSettlements.clear();
1971
+ lastStreamingSettlement = void 0;
2124
1972
  sentIndependentBlockText = false;
2125
1973
  idleRequestedForReply = false;
2126
1974
  visibleReplySent = false;
@@ -2190,7 +2038,7 @@ function createFeishuReplyDispatcher(params) {
2190
2038
  const skipTextForDuplicateFinal = !hasIndependentPresentation && info?.kind === "final" && hasText && deliveredFinalTexts.has(text);
2191
2039
  const shouldDeliverText = hasText && (!hasVoiceMedia || hasPresentationFallback) && !skipTextForDuplicateFinal;
2192
2040
  const shouldDiscardStreamingPreview = info?.kind === "final" && !(hasIndependentPresentation && payload.isError === true && hasStreamingFinalText) && (hasIndependentPresentation || finalTextExceedsStreamingLimit || hasMedia && (hasVoiceMedia && !shouldDeliverText && !ttsTextAlreadyVisible || skipTextForDuplicateFinal));
2193
- const priorClosedStreamingSettlement = info?.kind === "final" && hasText && skipTextForDuplicateFinal ? claimClosedStreamingResult(void 0, text) : void 0;
2041
+ const priorClosedStreamingSettlement = info?.kind === "final" && hasText && skipTextForDuplicateFinal && lastStreamingSettlement?.content === text ? lastStreamingSettlement : void 0;
2194
2042
  if (!shouldDeliverText && !hasMedia && !presentationCard) {
2195
2043
  if (priorClosedStreamingSettlement?.error !== void 0) throw toStringifiedError(priorClosedStreamingSettlement.error);
2196
2044
  return priorClosedStreamingSettlement?.result ?? noVisibleFeishuReplyDelivery;
@@ -2236,15 +2084,13 @@ function createFeishuReplyDispatcher(params) {
2236
2084
  }
2237
2085
  return mergeFeishuReplyDeliveryResults(deliveredResults, text);
2238
2086
  }
2239
- if (info?.kind === "block" || info?.kind === "final" && useStreamingCard) {
2087
+ const matchingClosingStream = inFlightStreamingClose !== void 0 && closingStreamingText === text;
2088
+ if (!matchingClosingStream && (info?.kind === "block" || info?.kind === "final" && useStreamingCard)) {
2240
2089
  startStreaming();
2241
2090
  if (streamingStartPromise) await streamingStartPromise;
2242
2091
  }
2243
- const shouldStreamText = info?.kind === "block" || info?.kind === "final";
2244
- const matchingInFlightClose = info?.kind === "final" && inFlightStreamingClose?.disposition === "closed" && inFlightStreamingClose.content === text ? inFlightStreamingClose : void 0;
2245
- const ownerGeneration = activeStreamingGeneration ?? matchingInFlightClose?.generation;
2246
- if (shouldStreamText && ownerGeneration !== void 0 && (streaming?.isActive() || matchingInFlightClose !== void 0)) {
2247
- if (activeStreamingGeneration !== void 0) {
2092
+ if ((info?.kind === "block" || info?.kind === "final") && (streaming?.isActive() || matchingClosingStream)) {
2093
+ if (!matchingClosingStream) {
2248
2094
  if (info?.kind === "block") queueStreamingUpdate(text, {
2249
2095
  mode: "delta",
2250
2096
  dedupeWithLastPartial: true
@@ -2263,11 +2109,10 @@ function createFeishuReplyDispatcher(params) {
2263
2109
  await throwStreamingDeliveryFailure({
2264
2110
  error,
2265
2111
  content: text,
2266
- infoKind: info?.kind,
2267
- ownerGeneration
2112
+ infoKind: info?.kind
2268
2113
  });
2269
2114
  }
2270
- return deferStreamingDelivery(mergeFeishuReplyDeliveryResults(deliveredResults, text), info?.kind, ownerGeneration);
2115
+ return deferStreamingDelivery(mergeFeishuReplyDeliveryResults(deliveredResults, text), info?.kind);
2271
2116
  }
2272
2117
  if (useStaticCard || useStreamingCard && !isStreamingStartBackedOff(account.accountId) && withinCardTableLimit(text)) deliveredResults.push(await sendChunkedTextReply({
2273
2118
  text,
@@ -2875,7 +2720,7 @@ async function handleFeishuMessage(params) {
2875
2720
  });
2876
2721
  configuredBinding = configuredRoute.bindingResolution;
2877
2722
  route = configuredRoute.route;
2878
- const runtimeRoute = resolveRuntimeConversationBindingRoute({
2723
+ const runtimeRoute = await resolveRuntimeConversationBindingRouteAsync({
2879
2724
  route,
2880
2725
  conversation: {
2881
2726
  channel: "feishu",
@@ -3360,7 +3205,7 @@ async function handleFeishuMessage(params) {
3360
3205
  log(`feishu[${account.accountId}]: failed to record broadcast inbound session ${agentSessionKey}: ${String(err)}`);
3361
3206
  }
3362
3207
  };
3363
- const allowReasoningPreview = resolveFeishuReasoningPreviewEnabled({
3208
+ const allowReasoningPreview = await resolveFeishuReasoningPreviewEnabled({
3364
3209
  cfg,
3365
3210
  agentId,
3366
3211
  storePath: agentStorePath,
@@ -3446,7 +3291,7 @@ async function handleFeishuMessage(params) {
3446
3291
  const ctxPayload = await buildCtxPayloadForAgent(route.agentId, route.sessionKey, route.accountId, ctx.mentionedBot);
3447
3292
  const identity = resolveAgentOutboundIdentity(effectiveCfg, route.agentId);
3448
3293
  const storePath = resolveStorePath(effectiveCfg.session?.store, { agentId: route.agentId });
3449
- const allowReasoningPreview = resolveFeishuReasoningPreviewEnabled({
3294
+ const allowReasoningPreview = await resolveFeishuReasoningPreviewEnabled({
3450
3295
  cfg: effectiveCfg,
3451
3296
  agentId: route.agentId,
3452
3297
  storePath,
@@ -3905,69 +3750,37 @@ function buildFeishuFlushIngressLifecycle(sources, options) {
3905
3750
  settle: async () => {}
3906
3751
  };
3907
3752
  let handedOff = false;
3908
- let terminal;
3909
- let adopting;
3910
- let abandoning;
3753
+ let settled = false;
3911
3754
  const releaseReplayClaims = () => {
3912
3755
  for (const claim of replayClaims) claim.release({ error: /* @__PURE__ */ new Error("feishu-ingress-not-adopted") });
3913
3756
  };
3914
- const runAbandon = async () => {
3915
- if (terminal) return;
3757
+ const abandonAll = async () => {
3758
+ if (settled) return;
3759
+ settled = true;
3916
3760
  releaseReplayClaims();
3917
3761
  await transportLifecycle.onAbandoned();
3918
- terminal = "abandoned";
3919
- };
3920
- const ensureAbandoned = async () => {
3921
- if (terminal) return;
3922
- const activeAbandonment = abandoning ?? runAbandon();
3923
- abandoning = activeAbandonment;
3924
- try {
3925
- await activeAbandonment;
3926
- } finally {
3927
- if (abandoning === activeAbandonment && terminal !== "abandoned") abandoning = void 0;
3928
- }
3929
- };
3930
- const abandonAll = async () => {
3931
- if (terminal) return;
3932
- if (adopting) {
3933
- await adopting.catch(() => void 0);
3934
- if (terminal) return;
3935
- }
3936
- await ensureAbandoned();
3937
3762
  };
3938
3763
  const adoptAll = async () => {
3939
- if (terminal) return;
3940
- if (abandoning) {
3941
- await abandoning.catch(() => void 0);
3942
- if (terminal) return;
3943
- }
3944
- const activeAdoption = adopting ?? (async () => {
3945
- try {
3946
- await transportLifecycle.onAdopted();
3947
- terminal = "adopted";
3948
- const results = await Promise.allSettled(replayClaims.map(async (claim) => claim.commit()));
3949
- for (const result of results) if (result.status === "rejected") try {
3950
- options?.onReplayCommitError?.(result.reason);
3951
- } catch {}
3952
- } catch (error) {
3953
- await ensureAbandoned().catch(() => void 0);
3954
- throw error;
3955
- }
3956
- })();
3957
- adopting = activeAdoption;
3958
- options?.trackTask?.(activeAdoption);
3764
+ if (settled) return;
3765
+ settled = true;
3959
3766
  try {
3960
- await activeAdoption;
3961
- } finally {
3962
- if (adopting === activeAdoption && terminal !== "adopted") adopting = void 0;
3767
+ await transportLifecycle.onAdopted();
3768
+ } catch (error) {
3769
+ releaseReplayClaims();
3770
+ await Promise.resolve(transportLifecycle.onAbandoned()).catch(() => void 0);
3771
+ throw error;
3963
3772
  }
3773
+ const results = await Promise.allSettled(replayClaims.map((claim) => claim.commit()));
3774
+ for (const result of results) if (result.status === "rejected") options?.onReplayCommitError?.(result.reason);
3964
3775
  };
3965
3776
  return {
3966
3777
  lifecycle: {
3967
3778
  abortSignal: transportLifecycle.abortSignal,
3968
3779
  onAdopted: async () => {
3969
3780
  handedOff = true;
3970
- await adoptAll();
3781
+ const adoption = adoptAll();
3782
+ options?.trackTask?.(adoption);
3783
+ await adoption;
3971
3784
  },
3972
3785
  onDeferred: () => {
3973
3786
  handedOff = true;
@@ -3990,9 +3803,9 @@ function buildFeishuFlushIngressLifecycle(sources, options) {
3990
3803
  try {
3991
3804
  transportLifecycle.onAdoptionFinalizing();
3992
3805
  await transportLifecycle.onAdopted();
3993
- terminal = "adopted";
3806
+ settled = true;
3994
3807
  } catch (error) {
3995
- await ensureAbandoned().catch(() => void 0);
3808
+ await abandonAll().catch(() => void 0);
3996
3809
  throw error;
3997
3810
  }
3998
3811
  }
@@ -4247,12 +4060,7 @@ function createQuickActionLauncherCard(params) {
4247
4060
  }
4248
4061
  async function maybeHandleFeishuQuickActionMenu(params) {
4249
4062
  if (!QUICK_ACTION_MENU_KEYS.has(normalizeOptionalLowercaseString(params.eventKey) ?? "")) return false;
4250
- const now = asDateTimestampMs(params.now ?? Date.now());
4251
- const expiresAt = now === void 0 ? void 0 : resolveExpiresAtMsFromDurationMs(FEISHU_QUICK_ACTION_CARD_TTL_MS, { nowMs: now });
4252
- if (expiresAt === void 0) {
4253
- params.runtime?.log?.(`feishu[${params.accountId ?? "default"}]: failed to open quick-action launcher for ${params.operatorOpenId}: invalid expiry clock`);
4254
- return false;
4255
- }
4063
+ const expiresAt = Date.now() + FEISHU_QUICK_ACTION_CARD_TTL_MS;
4256
4064
  try {
4257
4065
  await sendCardFeishu({
4258
4066
  cfg: params.cfg,
@@ -4894,7 +4702,7 @@ async function resolveDriveCommentEventTurn(params) {
4894
4702
  return null;
4895
4703
  }
4896
4704
  const context = await fetchDriveCommentContext({
4897
- client: createClient ? createClient(account ?? { accountId }) : createFeishuClient((await import("./doctor-contract-oIpUWtNO.mjs").then((n) => n.l)).resolveFeishuAccount({
4705
+ client: createClient ? createClient(account ?? { accountId }) : createFeishuClient((await import("./doctor-contract-BNXcJcWR.mjs").then((n) => n.l)).resolveFeishuAccount({
4898
4706
  cfg,
4899
4707
  accountId
4900
4708
  })),
@@ -5033,8 +4841,8 @@ async function handleFeishuCommentEvent(params) {
5033
4841
  senderId: turn.senderId,
5034
4842
  senderIdLine: `Your Feishu user id: ${turn.senderId}`,
5035
4843
  meta: { name: turn.senderId },
5036
- onCreated: ({ code }) => {
5037
- log(`feishu[${account.accountId}]: comment pairing request sender=${turn.senderId} code=${code}`);
4844
+ onCreated: () => {
4845
+ log(`feishu[${account.accountId}]: comment pairing request sender=${turn.senderId}`);
5038
4846
  },
5039
4847
  sendPairingReply: async (text) => {
5040
4848
  await deliverCommentThreadText(client, {
@@ -5216,11 +5024,12 @@ async function handleFeishuCommentEvent(params) {
5216
5024
  const DEFAULT_TASK_TIMEOUT_MS = 3e5;
5217
5025
  function createSequentialQueue(options = {}) {
5218
5026
  const queues = /* @__PURE__ */ new Map();
5219
- const taskTimeoutMs = options.taskTimeoutMs ?? DEFAULT_TASK_TIMEOUT_MS;
5220
5027
  const onTaskTimeout = options.onTaskTimeout;
5221
5028
  return (key, task) => {
5222
5029
  const previous = queues.get(key) ?? Promise.resolve();
5223
- const wrapped = () => boundedRun(key, task, taskTimeoutMs, onTaskTimeout);
5030
+ const wrapped = () => raceWithTimeout(task, DEFAULT_TASK_TIMEOUT_MS, () => {
5031
+ onTaskTimeout?.(key, DEFAULT_TASK_TIMEOUT_MS);
5032
+ });
5224
5033
  const next = previous.then(wrapped, wrapped);
5225
5034
  queues.set(key, next);
5226
5035
  const cleanup = () => {
@@ -5230,15 +5039,6 @@ function createSequentialQueue(options = {}) {
5230
5039
  return next;
5231
5040
  };
5232
5041
  }
5233
- async function boundedRun(key, task, timeoutMs, onTaskTimeout) {
5234
- if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) return task();
5235
- const resolvedTimeoutMs = resolveTimerTimeoutMs(timeoutMs, DEFAULT_TASK_TIMEOUT_MS);
5236
- await raceWithTimeout(task, resolvedTimeoutMs, () => {
5237
- try {
5238
- onTaskTimeout?.(key, resolvedTimeoutMs);
5239
- } catch {}
5240
- });
5241
- }
5242
5042
  //#endregion
5243
5043
  //#region extensions/feishu/src/monitor.comment-notice-handler.ts
5244
5044
  function buildCommentNoticeQueueKey(event) {
@@ -5320,15 +5120,6 @@ function mergeFeishuDebounceMentions(entries) {
5320
5120
  }
5321
5121
  return merged.size > 0 ? Array.from(merged.values()) : void 0;
5322
5122
  }
5323
- function dedupeFeishuDebounceEntriesByDedupeKey(entries) {
5324
- const seen = /* @__PURE__ */ new Set();
5325
- return entries.filter(({ messageDedupeKey }) => {
5326
- if (!messageDedupeKey) return true;
5327
- if (seen.has(messageDedupeKey)) return false;
5328
- seen.add(messageDedupeKey);
5329
- return true;
5330
- });
5331
- }
5332
5123
  function resolveFeishuDebounceMentions(params) {
5333
5124
  const { entries, botOpenId } = params;
5334
5125
  if (entries.length === 0) return;
@@ -5438,19 +5229,12 @@ function createFeishuMessageReceiveHandler({ cfg, channelRuntime, accountId, run
5438
5229
  await settle();
5439
5230
  return;
5440
5231
  }
5441
- const dedupedEntries = dedupeFeishuDebounceEntriesByDedupeKey(activeEntries);
5442
- const freshEntries = [];
5443
- for (const entry of dedupedEntries) if (!await hasProcessedMessage(entry.messageDedupeKey, accountId, log)) freshEntries.push(entry);
5444
- const dispatchEntry = freshEntries.at(-1);
5445
- if (!dispatchEntry) {
5446
- await settle();
5447
- return;
5448
- }
5232
+ const dispatchEntry = last;
5449
5233
  const dispatchDedupeKey = dispatchEntry.messageDedupeKey;
5450
- if (!lifecycle) await recordSuppressedMessageIds(dedupedEntries, dispatchDedupeKey);
5451
- const combinedText = freshEntries.map((entry) => resolveDebounceText(entry.event)).filter(Boolean).join("\n");
5234
+ if (!lifecycle) await recordSuppressedMessageIds(activeEntries, dispatchDedupeKey);
5235
+ const combinedText = activeEntries.map((entry) => resolveDebounceText(entry.event)).filter(Boolean).join("\n");
5452
5236
  const mergedMentions = resolveFeishuDebounceMentions({
5453
- entries: freshEntries.map((entry) => entry.event),
5237
+ entries: activeEntries.map((entry) => entry.event),
5454
5238
  botOpenId: getBotOpenId(accountId)
5455
5239
  });
5456
5240
  await dispatchFeishuMessage({
@@ -5893,7 +5677,7 @@ async function monitorWebhook(params) {
5893
5677
  const encryptKey = account.encryptKey?.trim();
5894
5678
  if (!encryptKey) throw new Error(`Feishu account "${accountId}" webhook mode requires encryptKey`);
5895
5679
  const rawPath = account.config.webhookPath ?? "/feishu/events";
5896
- if (normalizeFeishuWebhookPath(rawPath) !== rawPath) throw new Error(`Feishu account "${accountId}" webhookPath must be a canonical HTTP request path; run "openclaw doctor --fix" to repair it`);
5680
+ if (normalizeFeishuWebhookPath(rawPath) !== rawPath) throw new Error(`Feishu account "${accountId}" webhookPath must be a normalized HTTP request path; run "openclaw doctor --fix" to repair it`);
5897
5681
  const pathConflict = describeFeishuWebhookPathConflict(rawPath);
5898
5682
  if (pathConflict && !legacyListener) throw new Error(`Feishu account "${accountId}" ${pathConflict}`);
5899
5683
  let webhookTargets = webhookTargetsStore.tryGetRuntime();
@@ -6123,7 +5907,7 @@ async function resolveReactionSyntheticEvent(params) {
6123
5907
  const senderUserId = event.user_id?.user_id?.trim();
6124
5908
  const senderId = senderOpenId || senderUserId;
6125
5909
  if (!emoji || !messageId || !senderId) return null;
6126
- const { resolveFeishuAccount } = await import("./doctor-contract-oIpUWtNO.mjs").then((n) => n.l);
5910
+ const { resolveFeishuAccount } = await import("./doctor-contract-BNXcJcWR.mjs").then((n) => n.l);
6127
5911
  const reactionNotifications = resolveFeishuAccount({
6128
5912
  cfg,
6129
5913
  accountId
@@ -6352,13 +6136,13 @@ async function monitorSingleAccount(params) {
6352
6136
  };
6353
6137
  try {
6354
6138
  const eventDispatcher = createEventDispatcher(account);
6355
- const durableIngress = typeof eventDispatcher.invoke === "function" ? createFeishuDurableIngress({
6139
+ const durableIngress = createFeishuDurableIngress({
6356
6140
  accountId,
6357
6141
  dispatcher: eventDispatcher,
6358
6142
  ...account.encryptKey ? { encryptKey: account.encryptKey } : {},
6359
6143
  runtime: runtime ?? {}
6360
- }) : void 0;
6361
- const durableEventDispatcher = durableIngress ? Object.assign(Object.create(eventDispatcher), { invoke: durableIngress.invoke }) : eventDispatcher;
6144
+ });
6145
+ const durableEventDispatcher = Object.assign(Object.create(eventDispatcher), { invoke: durableIngress.invoke });
6362
6146
  const chatHistories = /* @__PURE__ */ new Map();
6363
6147
  threadBindingManager = createFeishuThreadBindingManager({
6364
6148
  accountId,
@@ -6375,11 +6159,11 @@ async function monitorSingleAccount(params) {
6375
6159
  trackTask,
6376
6160
  vcAutoJoin: account.config.vcAutoJoin === true,
6377
6161
  abortSignal: accountAbortSignal,
6378
- ...durableIngress ? { resolveIngressLifecycle: durableIngress.resolveLifecycle } : {},
6162
+ resolveIngressLifecycle: durableIngress.resolveLifecycle,
6379
6163
  ...params.statusSink ? { statusSink: params.statusSink } : {}
6380
6164
  });
6381
6165
  try {
6382
- durableIngress?.start();
6166
+ durableIngress.start();
6383
6167
  if (connectionMode === "webhook") return await monitorWebhook({
6384
6168
  gatewayPort: (0, gateway_config_runtime_exports.resolveGatewayPort)(cfg),
6385
6169
  account,
@@ -6387,7 +6171,7 @@ async function monitorSingleAccount(params) {
6387
6171
  runtime,
6388
6172
  abortSignal,
6389
6173
  eventDispatcher: durableEventDispatcher,
6390
- ...durableIngress ? { invokeWebhookEvent: durableIngress.invokeWebhook } : {},
6174
+ invokeWebhookEvent: durableIngress.invokeWebhook,
6391
6175
  ...params.statusSink ? { statusSink: params.statusSink } : {}
6392
6176
  });
6393
6177
  return await monitorWebSocket({
@@ -6396,13 +6180,13 @@ async function monitorSingleAccount(params) {
6396
6180
  runtime,
6397
6181
  abortSignal,
6398
6182
  eventDispatcher: durableEventDispatcher,
6399
- ...durableIngress ? { setSocketTerminator: durableIngress.setSocketTerminator } : {},
6183
+ setSocketTerminator: durableIngress.setSocketTerminator,
6400
6184
  ...params.statusSink ? { statusSink: params.statusSink } : {}
6401
6185
  });
6402
6186
  } finally {
6403
6187
  accountStopped.abort(/* @__PURE__ */ new Error("Feishu account stopped"));
6404
6188
  try {
6405
- await durableIngress?.stop();
6189
+ await durableIngress.stop();
6406
6190
  } finally {
6407
6191
  while (pendingTasks.size > 0) await Promise.allSettled(pendingTasks);
6408
6192
  }