@larksuite/openclaw-lark 2025.7.15-beta.0

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 (426) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +76 -0
  3. package/bin/openclaw-lark.js +39 -0
  4. package/index.d.ts +36 -0
  5. package/index.js +188 -0
  6. package/openclaw.plugin.json +64 -0
  7. package/package.json +63 -0
  8. package/secret-contract-api.d.ts +15 -0
  9. package/secret-contract-api.js +78 -0
  10. package/skills/feishu-bitable/SKILL.md +248 -0
  11. package/skills/feishu-bitable/references/examples.md +813 -0
  12. package/skills/feishu-bitable/references/field-properties.md +763 -0
  13. package/skills/feishu-bitable/references/record-values.md +911 -0
  14. package/skills/feishu-calendar/SKILL.md +242 -0
  15. package/skills/feishu-channel-rules/SKILL.md +18 -0
  16. package/skills/feishu-channel-rules/references/markdown-syntax.md +138 -0
  17. package/skills/feishu-create-doc/SKILL.md +719 -0
  18. package/skills/feishu-fetch-doc/SKILL.md +93 -0
  19. package/skills/feishu-im-read/SKILL.md +163 -0
  20. package/skills/feishu-task/SKILL.md +340 -0
  21. package/skills/feishu-troubleshoot/SKILL.md +70 -0
  22. package/skills/feishu-update-doc/SKILL.md +285 -0
  23. package/src/card/builder.d.ts +152 -0
  24. package/src/card/builder.js +794 -0
  25. package/src/card/card-error.d.ts +91 -0
  26. package/src/card/card-error.js +206 -0
  27. package/src/card/cardkit.d.ts +90 -0
  28. package/src/card/cardkit.js +203 -0
  29. package/src/card/flush-controller.d.ts +45 -0
  30. package/src/card/flush-controller.js +138 -0
  31. package/src/card/image-resolver.d.ts +45 -0
  32. package/src/card/image-resolver.js +116 -0
  33. package/src/card/markdown-style.d.ts +16 -0
  34. package/src/card/markdown-style.js +106 -0
  35. package/src/card/reasoning-utils.d.ts +14 -0
  36. package/src/card/reasoning-utils.js +64 -0
  37. package/src/card/reply-dispatcher-types.d.ts +132 -0
  38. package/src/card/reply-dispatcher-types.js +61 -0
  39. package/src/card/reply-dispatcher.d.ts +15 -0
  40. package/src/card/reply-dispatcher.js +447 -0
  41. package/src/card/reply-mode.d.ts +41 -0
  42. package/src/card/reply-mode.js +70 -0
  43. package/src/card/streaming-card-controller.d.ts +118 -0
  44. package/src/card/streaming-card-controller.js +1045 -0
  45. package/src/card/tool-use-config.d.ts +26 -0
  46. package/src/card/tool-use-config.js +76 -0
  47. package/src/card/tool-use-display.d.ts +37 -0
  48. package/src/card/tool-use-display.js +476 -0
  49. package/src/card/tool-use-trace-store.d.ts +51 -0
  50. package/src/card/tool-use-trace-store.js +271 -0
  51. package/src/card/unavailable-guard.d.ts +35 -0
  52. package/src/card/unavailable-guard.js +87 -0
  53. package/src/channel/abort-detect.d.ts +47 -0
  54. package/src/channel/abort-detect.js +219 -0
  55. package/src/channel/chat-queue.d.ts +41 -0
  56. package/src/channel/chat-queue.js +68 -0
  57. package/src/channel/config-adapter.d.ts +23 -0
  58. package/src/channel/config-adapter.js +107 -0
  59. package/src/channel/directory.d.ts +57 -0
  60. package/src/channel/directory.js +197 -0
  61. package/src/channel/event-handlers.d.ts +17 -0
  62. package/src/channel/event-handlers.js +380 -0
  63. package/src/channel/interactive-dispatch.d.ts +59 -0
  64. package/src/channel/interactive-dispatch.js +195 -0
  65. package/src/channel/monitor.d.ts +17 -0
  66. package/src/channel/monitor.js +140 -0
  67. package/src/channel/onboarding-config.d.ts +18 -0
  68. package/src/channel/onboarding-config.js +96 -0
  69. package/src/channel/onboarding-migrate.d.ts +25 -0
  70. package/src/channel/onboarding-migrate.js +70 -0
  71. package/src/channel/onboarding.d.ts +12 -0
  72. package/src/channel/onboarding.js +300 -0
  73. package/src/channel/plugin.d.ts +13 -0
  74. package/src/channel/plugin.js +310 -0
  75. package/src/channel/probe.d.ts +14 -0
  76. package/src/channel/probe.js +24 -0
  77. package/src/channel/types.d.ts +37 -0
  78. package/src/channel/types.js +8 -0
  79. package/src/commands/auth.d.ts +21 -0
  80. package/src/commands/auth.js +165 -0
  81. package/src/commands/diagnose.d.ts +69 -0
  82. package/src/commands/diagnose.js +848 -0
  83. package/src/commands/doctor.d.ts +27 -0
  84. package/src/commands/doctor.js +588 -0
  85. package/src/commands/index.d.ts +25 -0
  86. package/src/commands/index.js +219 -0
  87. package/src/commands/locale.d.ts +7 -0
  88. package/src/commands/locale.js +8 -0
  89. package/src/core/accounts.d.ts +51 -0
  90. package/src/core/accounts.js +219 -0
  91. package/src/core/agent-config.d.ts +100 -0
  92. package/src/core/agent-config.js +148 -0
  93. package/src/core/api-error.d.ts +48 -0
  94. package/src/core/api-error.js +117 -0
  95. package/src/core/app-owner-fallback.d.ts +22 -0
  96. package/src/core/app-owner-fallback.js +39 -0
  97. package/src/core/app-scope-checker.d.ts +87 -0
  98. package/src/core/app-scope-checker.js +198 -0
  99. package/src/core/auth-errors.d.ts +144 -0
  100. package/src/core/auth-errors.js +160 -0
  101. package/src/core/card-action-operator.d.ts +33 -0
  102. package/src/core/card-action-operator.js +30 -0
  103. package/src/core/chat-info-cache.d.ts +67 -0
  104. package/src/core/chat-info-cache.js +165 -0
  105. package/src/core/comment-target.d.ts +65 -0
  106. package/src/core/comment-target.js +100 -0
  107. package/src/core/config-schema.d.ts +490 -0
  108. package/src/core/config-schema.js +223 -0
  109. package/src/core/device-flow.d.ts +77 -0
  110. package/src/core/device-flow.js +217 -0
  111. package/src/core/domains.d.ts +18 -0
  112. package/src/core/domains.js +34 -0
  113. package/src/core/feishu-fetch.d.ts +18 -0
  114. package/src/core/feishu-fetch.js +28 -0
  115. package/src/core/footer-config.d.ts +24 -0
  116. package/src/core/footer-config.js +51 -0
  117. package/src/core/lark-client.d.ts +125 -0
  118. package/src/core/lark-client.js +468 -0
  119. package/src/core/lark-logger.d.ts +23 -0
  120. package/src/core/lark-logger.js +160 -0
  121. package/src/core/lark-ticket.d.ts +29 -0
  122. package/src/core/lark-ticket.js +40 -0
  123. package/src/core/message-unavailable.d.ts +53 -0
  124. package/src/core/message-unavailable.js +142 -0
  125. package/src/core/owner-policy.d.ts +32 -0
  126. package/src/core/owner-policy.js +55 -0
  127. package/src/core/permission-url.d.ts +22 -0
  128. package/src/core/permission-url.js +76 -0
  129. package/src/core/raw-request.d.ts +27 -0
  130. package/src/core/raw-request.js +90 -0
  131. package/src/core/runtime-store.d.ts +13 -0
  132. package/src/core/runtime-store.js +29 -0
  133. package/src/core/scope-manager.d.ts +168 -0
  134. package/src/core/scope-manager.js +224 -0
  135. package/src/core/sdk-compat.d.ts +20 -0
  136. package/src/core/sdk-compat.js +28 -0
  137. package/src/core/security-check.d.ts +72 -0
  138. package/src/core/security-check.js +184 -0
  139. package/src/core/shutdown-hooks.d.ts +22 -0
  140. package/src/core/shutdown-hooks.js +61 -0
  141. package/src/core/synthetic-target.d.ts +33 -0
  142. package/src/core/synthetic-target.js +40 -0
  143. package/src/core/targets.d.ts +60 -0
  144. package/src/core/targets.js +173 -0
  145. package/src/core/token-store.d.ts +54 -0
  146. package/src/core/token-store.js +326 -0
  147. package/src/core/tool-client.d.ts +176 -0
  148. package/src/core/tool-client.js +426 -0
  149. package/src/core/tool-scopes.d.ts +156 -0
  150. package/src/core/tool-scopes.js +344 -0
  151. package/src/core/tools-config.d.ts +55 -0
  152. package/src/core/tools-config.js +143 -0
  153. package/src/core/types.d.ts +91 -0
  154. package/src/core/types.js +12 -0
  155. package/src/core/uat-client.d.ts +46 -0
  156. package/src/core/uat-client.js +192 -0
  157. package/src/core/version.d.ts +31 -0
  158. package/src/core/version.js +69 -0
  159. package/src/messaging/converters/audio.d.ts +8 -0
  160. package/src/messaging/converters/audio.js +24 -0
  161. package/src/messaging/converters/calendar.d.ts +13 -0
  162. package/src/messaging/converters/calendar.js +56 -0
  163. package/src/messaging/converters/content-converter-helpers.d.ts +30 -0
  164. package/src/messaging/converters/content-converter-helpers.js +82 -0
  165. package/src/messaging/converters/content-converter.d.ts +24 -0
  166. package/src/messaging/converters/content-converter.js +40 -0
  167. package/src/messaging/converters/file.d.ts +8 -0
  168. package/src/messaging/converters/file.js +24 -0
  169. package/src/messaging/converters/folder.d.ts +8 -0
  170. package/src/messaging/converters/folder.js +24 -0
  171. package/src/messaging/converters/hongbao.d.ts +8 -0
  172. package/src/messaging/converters/hongbao.js +20 -0
  173. package/src/messaging/converters/image.d.ts +8 -0
  174. package/src/messaging/converters/image.js +22 -0
  175. package/src/messaging/converters/index.d.ts +8 -0
  176. package/src/messaging/converters/index.js +53 -0
  177. package/src/messaging/converters/interactive/card-converter.d.ts +76 -0
  178. package/src/messaging/converters/interactive/card-converter.js +1177 -0
  179. package/src/messaging/converters/interactive/card-utils.d.ts +9 -0
  180. package/src/messaging/converters/interactive/card-utils.js +47 -0
  181. package/src/messaging/converters/interactive/index.d.ts +8 -0
  182. package/src/messaging/converters/interactive/index.js +25 -0
  183. package/src/messaging/converters/interactive/legacy.d.ts +11 -0
  184. package/src/messaging/converters/interactive/legacy.js +60 -0
  185. package/src/messaging/converters/interactive/types.d.ts +23 -0
  186. package/src/messaging/converters/interactive/types.js +27 -0
  187. package/src/messaging/converters/location.d.ts +8 -0
  188. package/src/messaging/converters/location.js +23 -0
  189. package/src/messaging/converters/merge-forward.d.ts +32 -0
  190. package/src/messaging/converters/merge-forward.js +235 -0
  191. package/src/messaging/converters/post.d.ts +11 -0
  192. package/src/messaging/converters/post.js +235 -0
  193. package/src/messaging/converters/share.d.ts +9 -0
  194. package/src/messaging/converters/share.js +28 -0
  195. package/src/messaging/converters/sticker.d.ts +8 -0
  196. package/src/messaging/converters/sticker.js +22 -0
  197. package/src/messaging/converters/system.d.ts +12 -0
  198. package/src/messaging/converters/system.js +36 -0
  199. package/src/messaging/converters/text.d.ts +8 -0
  200. package/src/messaging/converters/text.js +18 -0
  201. package/src/messaging/converters/todo.d.ts +8 -0
  202. package/src/messaging/converters/todo.js +45 -0
  203. package/src/messaging/converters/types.d.ts +114 -0
  204. package/src/messaging/converters/types.js +8 -0
  205. package/src/messaging/converters/unknown.d.ts +8 -0
  206. package/src/messaging/converters/unknown.js +20 -0
  207. package/src/messaging/converters/utils.d.ts +22 -0
  208. package/src/messaging/converters/utils.js +57 -0
  209. package/src/messaging/converters/video-chat.d.ts +8 -0
  210. package/src/messaging/converters/video-chat.js +31 -0
  211. package/src/messaging/converters/video.d.ts +8 -0
  212. package/src/messaging/converters/video.js +35 -0
  213. package/src/messaging/converters/vote.d.ts +8 -0
  214. package/src/messaging/converters/vote.js +28 -0
  215. package/src/messaging/inbound/bot-content.d.ts +84 -0
  216. package/src/messaging/inbound/bot-content.js +117 -0
  217. package/src/messaging/inbound/bot-loop-guard.d.ts +48 -0
  218. package/src/messaging/inbound/bot-loop-guard.js +89 -0
  219. package/src/messaging/inbound/comment-context.d.ts +82 -0
  220. package/src/messaging/inbound/comment-context.js +353 -0
  221. package/src/messaging/inbound/comment-handler.d.ts +30 -0
  222. package/src/messaging/inbound/comment-handler.js +269 -0
  223. package/src/messaging/inbound/dedup.d.ts +59 -0
  224. package/src/messaging/inbound/dedup.js +121 -0
  225. package/src/messaging/inbound/dispatch-builders.d.ts +104 -0
  226. package/src/messaging/inbound/dispatch-builders.js +241 -0
  227. package/src/messaging/inbound/dispatch-commands.d.ts +22 -0
  228. package/src/messaging/inbound/dispatch-commands.js +131 -0
  229. package/src/messaging/inbound/dispatch-context.d.ts +67 -0
  230. package/src/messaging/inbound/dispatch-context.js +153 -0
  231. package/src/messaging/inbound/dispatch.d.ts +50 -0
  232. package/src/messaging/inbound/dispatch.js +477 -0
  233. package/src/messaging/inbound/enrich.d.ts +102 -0
  234. package/src/messaging/inbound/enrich.js +236 -0
  235. package/src/messaging/inbound/gate-effects.d.ts +23 -0
  236. package/src/messaging/inbound/gate-effects.js +46 -0
  237. package/src/messaging/inbound/gate.d.ts +91 -0
  238. package/src/messaging/inbound/gate.js +342 -0
  239. package/src/messaging/inbound/handler-registry.d.ts +25 -0
  240. package/src/messaging/inbound/handler-registry.js +23 -0
  241. package/src/messaging/inbound/handler.d.ts +37 -0
  242. package/src/messaging/inbound/handler.js +286 -0
  243. package/src/messaging/inbound/media-resolver.d.ts +32 -0
  244. package/src/messaging/inbound/media-resolver.js +91 -0
  245. package/src/messaging/inbound/mention-registry.d.ts +59 -0
  246. package/src/messaging/inbound/mention-registry.js +115 -0
  247. package/src/messaging/inbound/mention.d.ts +48 -0
  248. package/src/messaging/inbound/mention.js +102 -0
  249. package/src/messaging/inbound/parse-io.d.ts +50 -0
  250. package/src/messaging/inbound/parse-io.js +86 -0
  251. package/src/messaging/inbound/parse.d.ts +28 -0
  252. package/src/messaging/inbound/parse.js +128 -0
  253. package/src/messaging/inbound/permission.d.ts +17 -0
  254. package/src/messaging/inbound/permission.js +44 -0
  255. package/src/messaging/inbound/policy.d.ts +95 -0
  256. package/src/messaging/inbound/policy.js +168 -0
  257. package/src/messaging/inbound/reaction-handler.d.ts +62 -0
  258. package/src/messaging/inbound/reaction-handler.js +259 -0
  259. package/src/messaging/inbound/sentinel-store.d.ts +37 -0
  260. package/src/messaging/inbound/sentinel-store.js +98 -0
  261. package/src/messaging/inbound/synthetic-message.d.ts +26 -0
  262. package/src/messaging/inbound/synthetic-message.js +59 -0
  263. package/src/messaging/inbound/user-name-cache-store.d.ts +62 -0
  264. package/src/messaging/inbound/user-name-cache-store.js +236 -0
  265. package/src/messaging/inbound/user-name-cache.d.ts +78 -0
  266. package/src/messaging/inbound/user-name-cache.js +306 -0
  267. package/src/messaging/inbound/vc-meeting-invited-handler.d.ts +20 -0
  268. package/src/messaging/inbound/vc-meeting-invited-handler.js +236 -0
  269. package/src/messaging/inbound/vc-sender.d.ts +41 -0
  270. package/src/messaging/inbound/vc-sender.js +53 -0
  271. package/src/messaging/outbound/actions.d.ts +16 -0
  272. package/src/messaging/outbound/actions.js +329 -0
  273. package/src/messaging/outbound/bot-peer-context.d.ts +42 -0
  274. package/src/messaging/outbound/bot-peer-context.js +40 -0
  275. package/src/messaging/outbound/chat-manage.d.ts +64 -0
  276. package/src/messaging/outbound/chat-manage.js +117 -0
  277. package/src/messaging/outbound/deliver.d.ts +186 -0
  278. package/src/messaging/outbound/deliver.js +410 -0
  279. package/src/messaging/outbound/fetch.d.ts +12 -0
  280. package/src/messaging/outbound/fetch.js +17 -0
  281. package/src/messaging/outbound/forward.d.ts +26 -0
  282. package/src/messaging/outbound/forward.js +51 -0
  283. package/src/messaging/outbound/media-url-utils.d.ts +29 -0
  284. package/src/messaging/outbound/media-url-utils.js +172 -0
  285. package/src/messaging/outbound/media.d.ts +260 -0
  286. package/src/messaging/outbound/media.js +865 -0
  287. package/src/messaging/outbound/normalize-mentions.d.ts +50 -0
  288. package/src/messaging/outbound/normalize-mentions.js +166 -0
  289. package/src/messaging/outbound/outbound-mention.d.ts +41 -0
  290. package/src/messaging/outbound/outbound-mention.js +112 -0
  291. package/src/messaging/outbound/outbound.d.ts +79 -0
  292. package/src/messaging/outbound/outbound.js +195 -0
  293. package/src/messaging/outbound/reactions.d.ts +124 -0
  294. package/src/messaging/outbound/reactions.js +384 -0
  295. package/src/messaging/outbound/send.d.ts +153 -0
  296. package/src/messaging/outbound/send.js +417 -0
  297. package/src/messaging/outbound/typing.d.ts +60 -0
  298. package/src/messaging/outbound/typing.js +139 -0
  299. package/src/messaging/shared/message-lookup.d.ts +54 -0
  300. package/src/messaging/shared/message-lookup.js +120 -0
  301. package/src/messaging/types.d.ts +316 -0
  302. package/src/messaging/types.js +11 -0
  303. package/src/tools/ask-user-question.d.ts +32 -0
  304. package/src/tools/ask-user-question.js +922 -0
  305. package/src/tools/auto-auth.d.ts +57 -0
  306. package/src/tools/auto-auth.js +904 -0
  307. package/src/tools/helpers.d.ts +264 -0
  308. package/src/tools/helpers.js +389 -0
  309. package/src/tools/mcp/doc/create.d.ts +12 -0
  310. package/src/tools/mcp/doc/create.js +47 -0
  311. package/src/tools/mcp/doc/fetch.d.ts +12 -0
  312. package/src/tools/mcp/doc/fetch.js +39 -0
  313. package/src/tools/mcp/doc/index.d.ts +12 -0
  314. package/src/tools/mcp/doc/index.js +50 -0
  315. package/src/tools/mcp/doc/update.d.ts +12 -0
  316. package/src/tools/mcp/doc/update.js +64 -0
  317. package/src/tools/mcp/shared.d.ts +59 -0
  318. package/src/tools/mcp/shared.js +239 -0
  319. package/src/tools/oapi/bitable/app-table-field.d.ts +16 -0
  320. package/src/tools/oapi/bitable/app-table-field.js +225 -0
  321. package/src/tools/oapi/bitable/app-table-record.d.ts +20 -0
  322. package/src/tools/oapi/bitable/app-table-record.js +439 -0
  323. package/src/tools/oapi/bitable/app-table-view.d.ts +16 -0
  324. package/src/tools/oapi/bitable/app-table-view.js +172 -0
  325. package/src/tools/oapi/bitable/app-table.d.ts +17 -0
  326. package/src/tools/oapi/bitable/app-table.js +195 -0
  327. package/src/tools/oapi/bitable/app.d.ts +18 -0
  328. package/src/tools/oapi/bitable/app.js +189 -0
  329. package/src/tools/oapi/bitable/index.d.ts +9 -0
  330. package/src/tools/oapi/bitable/index.js +17 -0
  331. package/src/tools/oapi/calendar/calendar.d.ts +15 -0
  332. package/src/tools/oapi/calendar/calendar.js +125 -0
  333. package/src/tools/oapi/calendar/event-attendee.d.ts +14 -0
  334. package/src/tools/oapi/calendar/event-attendee.js +161 -0
  335. package/src/tools/oapi/calendar/event.d.ts +16 -0
  336. package/src/tools/oapi/calendar/event.js +712 -0
  337. package/src/tools/oapi/calendar/freebusy.d.ts +13 -0
  338. package/src/tools/oapi/calendar/freebusy.js +114 -0
  339. package/src/tools/oapi/calendar/index.d.ts +8 -0
  340. package/src/tools/oapi/calendar/index.js +15 -0
  341. package/src/tools/oapi/chat/chat.d.ts +16 -0
  342. package/src/tools/oapi/chat/chat.js +127 -0
  343. package/src/tools/oapi/chat/index.d.ts +10 -0
  344. package/src/tools/oapi/chat/index.js +23 -0
  345. package/src/tools/oapi/chat/members.d.ts +11 -0
  346. package/src/tools/oapi/chat/members.js +84 -0
  347. package/src/tools/oapi/common/get-user.d.ts +12 -0
  348. package/src/tools/oapi/common/get-user.js +109 -0
  349. package/src/tools/oapi/common/index.d.ts +6 -0
  350. package/src/tools/oapi/common/index.js +11 -0
  351. package/src/tools/oapi/common/search-user.d.ts +11 -0
  352. package/src/tools/oapi/common/search-user.js +76 -0
  353. package/src/tools/oapi/drive/doc-comments.d.ts +15 -0
  354. package/src/tools/oapi/drive/doc-comments.js +351 -0
  355. package/src/tools/oapi/drive/doc-media.d.ts +19 -0
  356. package/src/tools/oapi/drive/doc-media.js +371 -0
  357. package/src/tools/oapi/drive/file.d.ts +19 -0
  358. package/src/tools/oapi/drive/file.js +519 -0
  359. package/src/tools/oapi/drive/index.d.ts +12 -0
  360. package/src/tools/oapi/drive/index.js +45 -0
  361. package/src/tools/oapi/helpers.d.ts +183 -0
  362. package/src/tools/oapi/helpers.js +385 -0
  363. package/src/tools/oapi/im/format-messages.d.ts +50 -0
  364. package/src/tools/oapi/im/format-messages.js +169 -0
  365. package/src/tools/oapi/im/index.d.ts +10 -0
  366. package/src/tools/oapi/im/index.js +25 -0
  367. package/src/tools/oapi/im/message-read.d.ts +13 -0
  368. package/src/tools/oapi/im/message-read.js +419 -0
  369. package/src/tools/oapi/im/message.d.ts +16 -0
  370. package/src/tools/oapi/im/message.js +152 -0
  371. package/src/tools/oapi/im/resource.d.ts +13 -0
  372. package/src/tools/oapi/im/resource.js +186 -0
  373. package/src/tools/oapi/im/time-utils.d.ts +46 -0
  374. package/src/tools/oapi/im/time-utils.js +212 -0
  375. package/src/tools/oapi/im/user-name-uat.d.ts +26 -0
  376. package/src/tools/oapi/im/user-name-uat.js +143 -0
  377. package/src/tools/oapi/index.d.ts +11 -0
  378. package/src/tools/oapi/index.js +64 -0
  379. package/src/tools/oapi/sdk-types.d.ts +96 -0
  380. package/src/tools/oapi/sdk-types.js +13 -0
  381. package/src/tools/oapi/search/doc-search.d.ts +13 -0
  382. package/src/tools/oapi/search/doc-search.js +194 -0
  383. package/src/tools/oapi/search/index.d.ts +12 -0
  384. package/src/tools/oapi/search/index.js +37 -0
  385. package/src/tools/oapi/sheets/index.d.ts +12 -0
  386. package/src/tools/oapi/sheets/index.js +35 -0
  387. package/src/tools/oapi/sheets/sheet.d.ts +16 -0
  388. package/src/tools/oapi/sheets/sheet.js +688 -0
  389. package/src/tools/oapi/task/attachment.d.ts +18 -0
  390. package/src/tools/oapi/task/attachment.js +107 -0
  391. package/src/tools/oapi/task/comment.d.ts +15 -0
  392. package/src/tools/oapi/task/comment.js +149 -0
  393. package/src/tools/oapi/task/index.d.ts +11 -0
  394. package/src/tools/oapi/task/index.js +21 -0
  395. package/src/tools/oapi/task/section.d.ts +17 -0
  396. package/src/tools/oapi/task/section.js +293 -0
  397. package/src/tools/oapi/task/subtask.d.ts +14 -0
  398. package/src/tools/oapi/task/subtask.js +171 -0
  399. package/src/tools/oapi/task/task.d.ts +19 -0
  400. package/src/tools/oapi/task/task.js +512 -0
  401. package/src/tools/oapi/task/task_agent.d.ts +14 -0
  402. package/src/tools/oapi/task/task_agent.js +108 -0
  403. package/src/tools/oapi/task/tasklist.d.ts +19 -0
  404. package/src/tools/oapi/task/tasklist.js +276 -0
  405. package/src/tools/oapi/wiki/index.d.ts +12 -0
  406. package/src/tools/oapi/wiki/index.js +42 -0
  407. package/src/tools/oapi/wiki/space-node.d.ts +17 -0
  408. package/src/tools/oapi/wiki/space-node.js +233 -0
  409. package/src/tools/oapi/wiki/space.d.ts +15 -0
  410. package/src/tools/oapi/wiki/space.js +133 -0
  411. package/src/tools/oauth-batch-auth.d.ts +11 -0
  412. package/src/tools/oauth-batch-auth.js +150 -0
  413. package/src/tools/oauth-cards.d.ts +39 -0
  414. package/src/tools/oauth-cards.js +324 -0
  415. package/src/tools/oauth.d.ts +47 -0
  416. package/src/tools/oauth.js +592 -0
  417. package/src/tools/onboarding-auth.d.ts +27 -0
  418. package/src/tools/onboarding-auth.js +133 -0
  419. package/src/tools/tat/im/index.d.ts +15 -0
  420. package/src/tools/tat/im/index.js +22 -0
  421. package/src/tools/tat/im/resource.d.ts +15 -0
  422. package/src/tools/tat/im/resource.js +192 -0
  423. package/tsdown.config.d.ts +2 -0
  424. package/tsdown.config.js +25 -0
  425. package/vitest.config.d.ts +2 -0
  426. package/vitest.config.js +12 -0
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Standalone text and media delivery functions for the Lark/Feishu channel.
3
+ *
4
+ * These functions operate directly on the Lark SDK without depending on
5
+ * {@link sendMessageFeishu} from `send.ts`. The outbound adapter delegates
6
+ * to these for its `sendText` and `sendMedia` implementations.
7
+ */
8
+ import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
9
+ import type { FeishuSendResult } from '../types';
10
+ /**
11
+ * Parameters for sending a text message via Feishu.
12
+ */
13
+ export interface SendTextLarkParams {
14
+ /** Plugin configuration. */
15
+ cfg: ClawdbotConfig;
16
+ /** Target identifier (chat_id, open_id, or user_id). */
17
+ to: string;
18
+ /** Message text content (supports Feishu markdown subset). */
19
+ text: string;
20
+ /** When set, the message is sent as a threaded reply. */
21
+ replyToMessageId?: string;
22
+ /** When true, the reply appears in the thread instead of main chat. */
23
+ replyInThread?: boolean;
24
+ /** Thread root id when the reply lives inside a thread; used for sentinel keying. */
25
+ threadId?: string;
26
+ /** Optional account identifier for multi-account setups. */
27
+ accountId?: string;
28
+ }
29
+ /**
30
+ * Send a text message to a Feishu chat or user.
31
+ *
32
+ * Standalone implementation that directly operates the Lark SDK.
33
+ * The text is pre-processed (table conversion, style optimization)
34
+ * and sent as a Feishu "post" message with markdown rendering.
35
+ *
36
+ * If the entire text is a valid Feishu card JSON string (v1 or v2),
37
+ * it is automatically detected and routed to {@link sendCardLark}
38
+ * instead of being sent as plain text.
39
+ *
40
+ * @param params - See {@link SendTextLarkParams}.
41
+ * @returns The message ID and chat ID.
42
+ * @throws {Error} When the target is invalid or the API call fails.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const result = await sendTextLark({
47
+ * cfg,
48
+ * to: "oc_xxx",
49
+ * text: "Hello from Feishu",
50
+ * });
51
+ * ```
52
+ */
53
+ export declare function sendTextLark(params: SendTextLarkParams): Promise<FeishuSendResult>;
54
+ /**
55
+ * Parameters for sending an interactive card message via Feishu.
56
+ */
57
+ export interface SendCardLarkParams {
58
+ /** Plugin configuration. */
59
+ cfg: ClawdbotConfig;
60
+ /** Target identifier (chat_id, open_id, or user_id). */
61
+ to: string;
62
+ /**
63
+ * Complete card JSON object (v1 Message Card or v2 CardKit).
64
+ *
65
+ * - **v1**: top-level `config`, `header`, `elements`.
66
+ * - **v2**: `schema: "2.0"`, `config`, `header`, `body.elements`.
67
+ *
68
+ * The Feishu server determines the version by the presence of
69
+ * `schema: "2.0"`.
70
+ */
71
+ card: Record<string, unknown>;
72
+ /** When set, the card is sent as a threaded reply. */
73
+ replyToMessageId?: string;
74
+ /** When true, the reply appears in the thread instead of main chat. */
75
+ replyInThread?: boolean;
76
+ /** Optional account identifier for multi-account setups. */
77
+ accountId?: string;
78
+ }
79
+ /**
80
+ * Send an interactive card message to a Feishu chat or user.
81
+ *
82
+ * Supports both v1 (Message Card) and v2 (CardKit) card formats.
83
+ * The card JSON is serialised and sent as `msg_type: "interactive"`.
84
+ *
85
+ * @param params - See {@link SendCardLarkParams}.
86
+ * @returns The message ID and chat ID.
87
+ * @throws {Error} When the target is invalid or the API call fails.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * // v1 card
92
+ * const result = await sendCardLark({
93
+ * cfg,
94
+ * to: "oc_xxx",
95
+ * card: {
96
+ * config: { wide_screen_mode: true },
97
+ * header: { title: { tag: "plain_text", content: "Hello" }, template: "blue" },
98
+ * elements: [{ tag: "div", text: { tag: "lark_md", content: "world" } }],
99
+ * },
100
+ * });
101
+ *
102
+ * // v2 card
103
+ * const result2 = await sendCardLark({
104
+ * cfg,
105
+ * to: "oc_xxx",
106
+ * card: {
107
+ * schema: "2.0",
108
+ * config: { wide_screen_mode: true },
109
+ * body: { elements: [{ tag: "markdown", content: "Hello **world**" }] },
110
+ * },
111
+ * });
112
+ * ```
113
+ */
114
+ export declare function sendCardLark(params: SendCardLarkParams): Promise<FeishuSendResult>;
115
+ /**
116
+ * Parameters for sending a single media message via Feishu.
117
+ */
118
+ export interface SendMediaLarkParams {
119
+ /** Plugin configuration. */
120
+ cfg: ClawdbotConfig;
121
+ /** Target identifier (chat_id, open_id, or user_id). */
122
+ to: string;
123
+ /** Media URL to upload and send. */
124
+ mediaUrl: string;
125
+ /** When set, the message is sent as a threaded reply. */
126
+ replyToMessageId?: string;
127
+ /** When true, the reply appears in the thread instead of main chat. */
128
+ replyInThread?: boolean;
129
+ /** Optional account identifier for multi-account setups. */
130
+ accountId?: string;
131
+ /** Allowed root directories for local file access (SSRF prevention). */
132
+ mediaLocalRoots?: readonly string[];
133
+ }
134
+ /**
135
+ * Send a single media message to a Feishu chat or user.
136
+ *
137
+ * Pure atomic operation — uploads the media and sends it. On upload
138
+ * failure, falls back to sending the URL as a clickable text link.
139
+ *
140
+ * This function does **not** handle leading text or multi-media
141
+ * orchestration; those concerns belong to the adapter's `sendMedia`
142
+ * and `sendPayload` methods.
143
+ *
144
+ * @param params - See {@link SendMediaLarkParams}.
145
+ * @returns The message ID and chat ID of the sent message.
146
+ * @throws {Error} When the target is invalid or all send attempts fail.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * const result = await sendMediaLark({
151
+ * cfg,
152
+ * to: "oc_xxx",
153
+ * mediaUrl: "https://example.com/image.png",
154
+ * });
155
+ * ```
156
+ */
157
+ export declare function sendMediaLark(params: SendMediaLarkParams): Promise<FeishuSendResult>;
158
+ /**
159
+ * Parameters for sending a reply to a Drive comment thread.
160
+ */
161
+ export interface SendCommentReplyLarkParams {
162
+ /** Plugin configuration. */
163
+ cfg: ClawdbotConfig;
164
+ /**
165
+ * Target in comment format: `comment:<fileType>:<fileToken>:<commentId>`.
166
+ * Parsed via `parseFeishuCommentTarget`.
167
+ */
168
+ to: string;
169
+ /** Reply text content. */
170
+ text: string;
171
+ /** Optional account identifier for multi-account setups. */
172
+ accountId?: string;
173
+ }
174
+ /**
175
+ * Send a text message to a Feishu Drive comment surface.
176
+ *
177
+ * Parses the comment target from `to`, then chooses one of two delivery
178
+ * strategies:
179
+ * - `reply` → reply in the existing comment thread
180
+ * - `create_whole` → create a new whole-document comment
181
+ *
182
+ * Returns a synthetic FeishuSendResult (no IM messageId).
183
+ *
184
+ * @throws {Error} When the target is not a valid comment target or API fails.
185
+ */
186
+ export declare function sendCommentReplyLark(params: SendCommentReplyLarkParams): Promise<FeishuSendResult>;
@@ -0,0 +1,410 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: MIT
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.sendTextLark = sendTextLark;
5
+ exports.sendCardLark = sendCardLark;
6
+ exports.sendMediaLark = sendMediaLark;
7
+ exports.sendCommentReplyLark = sendCommentReplyLark;
8
+ const accounts_1 = require("../../core/accounts.js");
9
+ const lark_client_1 = require("../../core/lark-client.js");
10
+ const chat_queue_1 = require("../../channel/chat-queue.js");
11
+ const targets_1 = require("../../core/targets.js");
12
+ const comment_target_1 = require("../../core/comment-target.js");
13
+ const markdown_style_1 = require("../../card/markdown-style.js");
14
+ const api_error_1 = require("../../core/api-error.js");
15
+ const lark_logger_1 = require("../../core/lark-logger.js");
16
+ const sentinel_store_1 = require("../inbound/sentinel-store.js");
17
+ const media_1 = require("./media.js");
18
+ const normalize_mentions_1 = require("./normalize-mentions.js");
19
+ const log = (0, lark_logger_1.larkLogger)('outbound/deliver');
20
+ // ---------------------------------------------------------------------------
21
+ // Internal helpers
22
+ // ---------------------------------------------------------------------------
23
+ /**
24
+ * Build a Feishu post-format content envelope from processed text.
25
+ */
26
+ function buildPostContent(text) {
27
+ return JSON.stringify({
28
+ zh_cn: {
29
+ content: [[{ tag: 'md', text }]],
30
+ },
31
+ });
32
+ }
33
+ /**
34
+ * Pre-processes text before Feishu delivery. Runs the full mention
35
+ * normalizer (tag rewrite + plain `@Name` resolution + `@all` aliases)
36
+ * and Markdown style optimization. Markdown tables/code blocks are left
37
+ * as-is so Feishu renders them natively in the post(`tag:md`).
38
+ *
39
+ * Falls back to the raw text on any normalizer failure so a parser bug
40
+ * never blocks send. Sentinels collected during normalization are
41
+ * returned for the caller to record after the send succeeds.
42
+ */
43
+ async function prepareTextForLark(cfg, text, to, accountId) {
44
+ let processed = text;
45
+ let sentinels = [];
46
+ let resolvedAccountId = accountId;
47
+ if (text?.trim()) {
48
+ try {
49
+ const account = (0, accounts_1.getLarkAccount)(cfg, accountId ?? undefined);
50
+ const ctx = {
51
+ chatId: to,
52
+ account,
53
+ log: (...args) => log.warn(args.map(String).join(' ')),
54
+ };
55
+ const r = await (0, normalize_mentions_1.normalizeOutboundMentions)(text, ctx);
56
+ processed = r.normalizedText;
57
+ sentinels = r.sentinels;
58
+ resolvedAccountId = account.accountId;
59
+ }
60
+ catch (err) {
61
+ log.warn(`normalizeOutboundMentions failed in prepareTextForLark, using raw text: ${String(err)}`);
62
+ }
63
+ }
64
+ return {
65
+ text: (0, markdown_style_1.optimizeMarkdownStyle)(processed, 1),
66
+ sentinels,
67
+ resolvedAccountId,
68
+ };
69
+ }
70
+ function recordSentinelsForChat(resolvedAccountId, to, threadId, sentinels) {
71
+ if (!resolvedAccountId || sentinels.length === 0)
72
+ return;
73
+ (0, sentinel_store_1.getSentinelStore)(resolvedAccountId).recordSentinels((0, chat_queue_1.threadScopedKey)(to, threadId), sentinels);
74
+ }
75
+ /**
76
+ * Unified IM message sender — handles both reply and create paths for any
77
+ * `msg_type`. Replaces the former `replyPostMessage`, `createPostMessage`,
78
+ * `replyInteractiveMessage` and `createInteractiveMessage` helpers.
79
+ */
80
+ async function sendImMessage(params) {
81
+ const { client, to, content, msgType, replyToMessageId, replyInThread } = params;
82
+ // --- Reply path ---
83
+ if (replyToMessageId) {
84
+ log.info(`replying to message ${replyToMessageId} ` + `(msg_type=${msgType}, thread=${replyInThread ?? false})`);
85
+ const response = await client.im.message.reply({
86
+ path: { message_id: replyToMessageId },
87
+ data: { content, msg_type: msgType, reply_in_thread: replyInThread },
88
+ });
89
+ const result = {
90
+ messageId: response?.data?.message_id ?? '',
91
+ chatId: response?.data?.chat_id ?? '',
92
+ };
93
+ log.debug(`reply sent: messageId=${result.messageId}`);
94
+ return result;
95
+ }
96
+ // --- Create path ---
97
+ const target = (0, targets_1.normalizeFeishuTarget)(to);
98
+ if (!target) {
99
+ throw new Error(`Cannot send message: "${to}" is not a valid target. ` + `Expected a chat_id (oc_*), open_id (ou_*), or user_id.`);
100
+ }
101
+ const receiveIdType = (0, targets_1.resolveReceiveIdType)(target);
102
+ log.info(`creating message to ${target} (msg_type=${msgType})`);
103
+ const response = await client.im.message.create({
104
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
+ params: { receive_id_type: receiveIdType },
106
+ data: { receive_id: target, msg_type: msgType, content },
107
+ });
108
+ const result = {
109
+ messageId: response?.data?.message_id ?? '',
110
+ chatId: response?.data?.chat_id ?? '',
111
+ };
112
+ log.debug(`message created: messageId=${result.messageId}`);
113
+ return result;
114
+ }
115
+ /**
116
+ * Detect whether a text string is a complete Feishu card JSON (v1, v2, or template).
117
+ *
118
+ * Returns the parsed card object if the text is valid card JSON, or
119
+ * `undefined` if it is plain text. Detection is conservative — only
120
+ * triggers when the **entire** trimmed text is a JSON object with
121
+ * recognisable card structure markers.
122
+ *
123
+ * - **v2**: top-level `schema` equals `"2.0"`
124
+ * - **v1**: has an `elements` array AND at least `config` or `header`
125
+ * - **template**: `type` equals `"template"` with `data.template_id`
126
+ * - **wrapped**: `msg_type` or `type` equals `"interactive"` with a nested `card` object
127
+ */
128
+ function detectCardJson(text) {
129
+ const trimmed = text.trim();
130
+ if (!trimmed.startsWith('{') || !trimmed.endsWith('}'))
131
+ return undefined;
132
+ try {
133
+ const parsed = JSON.parse(trimmed);
134
+ if (typeof parsed !== 'object' || parsed == null || Array.isArray(parsed)) {
135
+ return undefined;
136
+ }
137
+ const obj = parsed;
138
+ // v2 CardKit — must declare schema "2.0"
139
+ if (obj.schema === '2.0')
140
+ return obj;
141
+ // v1 Message Card — must have elements[] AND (config OR header)
142
+ if (Array.isArray(obj.elements) && (obj.config !== undefined || obj.header !== undefined)) {
143
+ return obj;
144
+ }
145
+ // Template card — type: "template" with data.template_id
146
+ if (obj.type === 'template' &&
147
+ typeof obj.data === 'object' &&
148
+ obj.data != null &&
149
+ typeof obj.data.template_id === 'string') {
150
+ return obj;
151
+ }
152
+ // Wrapped card — AI sometimes wraps card JSON with msg_type/type: "interactive"
153
+ if ((obj.msg_type === 'interactive' || obj.type === 'interactive') &&
154
+ typeof obj.card === 'object' &&
155
+ obj.card != null) {
156
+ return obj.card;
157
+ }
158
+ return undefined;
159
+ }
160
+ catch {
161
+ return undefined;
162
+ }
163
+ }
164
+ /**
165
+ * Send a text message to a Feishu chat or user.
166
+ *
167
+ * Standalone implementation that directly operates the Lark SDK.
168
+ * The text is pre-processed (table conversion, style optimization)
169
+ * and sent as a Feishu "post" message with markdown rendering.
170
+ *
171
+ * If the entire text is a valid Feishu card JSON string (v1 or v2),
172
+ * it is automatically detected and routed to {@link sendCardLark}
173
+ * instead of being sent as plain text.
174
+ *
175
+ * @param params - See {@link SendTextLarkParams}.
176
+ * @returns The message ID and chat ID.
177
+ * @throws {Error} When the target is invalid or the API call fails.
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * const result = await sendTextLark({
182
+ * cfg,
183
+ * to: "oc_xxx",
184
+ * text: "Hello from Feishu",
185
+ * });
186
+ * ```
187
+ */
188
+ async function sendTextLark(params) {
189
+ const { cfg, to, text, replyToMessageId, replyInThread, accountId, threadId } = params;
190
+ // Detect card JSON in text — route to card sending before text preprocessing.
191
+ const card = detectCardJson(text);
192
+ if (card) {
193
+ const version = card.schema === '2.0' ? 'v2' : 'v1';
194
+ log.info(`detected ${version} card JSON in text (target=${to}), routing to sendCardLark`);
195
+ return sendCardLark({ cfg, to, card, replyToMessageId, replyInThread, accountId });
196
+ }
197
+ log.info(`sendTextLark: target=${to}, textLength=${text.length}`);
198
+ const client = lark_client_1.LarkClient.fromCfg(cfg, accountId).sdk;
199
+ const prepared = await prepareTextForLark(cfg, text, to, accountId);
200
+ const content = buildPostContent(prepared.text);
201
+ const result = await sendImMessage({ client, to, content, msgType: 'post', replyToMessageId, replyInThread });
202
+ recordSentinelsForChat(prepared.resolvedAccountId, to, threadId, prepared.sentinels);
203
+ return result;
204
+ }
205
+ /**
206
+ * Send an interactive card message to a Feishu chat or user.
207
+ *
208
+ * Supports both v1 (Message Card) and v2 (CardKit) card formats.
209
+ * The card JSON is serialised and sent as `msg_type: "interactive"`.
210
+ *
211
+ * @param params - See {@link SendCardLarkParams}.
212
+ * @returns The message ID and chat ID.
213
+ * @throws {Error} When the target is invalid or the API call fails.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * // v1 card
218
+ * const result = await sendCardLark({
219
+ * cfg,
220
+ * to: "oc_xxx",
221
+ * card: {
222
+ * config: { wide_screen_mode: true },
223
+ * header: { title: { tag: "plain_text", content: "Hello" }, template: "blue" },
224
+ * elements: [{ tag: "div", text: { tag: "lark_md", content: "world" } }],
225
+ * },
226
+ * });
227
+ *
228
+ * // v2 card
229
+ * const result2 = await sendCardLark({
230
+ * cfg,
231
+ * to: "oc_xxx",
232
+ * card: {
233
+ * schema: "2.0",
234
+ * config: { wide_screen_mode: true },
235
+ * body: { elements: [{ tag: "markdown", content: "Hello **world**" }] },
236
+ * },
237
+ * });
238
+ * ```
239
+ */
240
+ async function sendCardLark(params) {
241
+ const { cfg, to, card, replyToMessageId, replyInThread, accountId } = params;
242
+ const version = card.schema === '2.0' ? 'v2' : 'v1';
243
+ log.info(`sendCardLark: target=${to}, cardVersion=${version}`);
244
+ const client = lark_client_1.LarkClient.fromCfg(cfg, accountId).sdk;
245
+ const content = JSON.stringify(card);
246
+ try {
247
+ return await sendImMessage({ client, to, content, msgType: 'interactive', replyToMessageId, replyInThread });
248
+ }
249
+ catch (err) {
250
+ const detail = (0, api_error_1.formatLarkError)(err);
251
+ log.error(`sendCardLark failed: ${detail}`);
252
+ throw new Error(`Card send failed: ${detail}\n\n` +
253
+ `Troubleshooting:\n` +
254
+ `- Do NOT use img/image elements with fabricated img_key values — Feishu rejects invalid keys.\n` +
255
+ `- Do NOT put URLs in img_key — it must be a real image_key from uploadImage.\n` +
256
+ `- Prefer text-only cards (markdown elements) which have 100% success rate.\n` +
257
+ `- If you need images, send them as separate media messages, not inside cards.`, { cause: err });
258
+ }
259
+ }
260
+ /**
261
+ * Send a single media message to a Feishu chat or user.
262
+ *
263
+ * Pure atomic operation — uploads the media and sends it. On upload
264
+ * failure, falls back to sending the URL as a clickable text link.
265
+ *
266
+ * This function does **not** handle leading text or multi-media
267
+ * orchestration; those concerns belong to the adapter's `sendMedia`
268
+ * and `sendPayload` methods.
269
+ *
270
+ * @param params - See {@link SendMediaLarkParams}.
271
+ * @returns The message ID and chat ID of the sent message.
272
+ * @throws {Error} When the target is invalid or all send attempts fail.
273
+ *
274
+ * @example
275
+ * ```ts
276
+ * const result = await sendMediaLark({
277
+ * cfg,
278
+ * to: "oc_xxx",
279
+ * mediaUrl: "https://example.com/image.png",
280
+ * });
281
+ * ```
282
+ */
283
+ async function sendMediaLark(params) {
284
+ const { cfg, to, mediaUrl, replyToMessageId, replyInThread, accountId, mediaLocalRoots } = params;
285
+ log.info(`sendMediaLark: target=${to}, mediaUrl=${mediaUrl}`);
286
+ try {
287
+ const result = await (0, media_1.uploadAndSendMediaLark)({
288
+ cfg,
289
+ to,
290
+ mediaUrl,
291
+ replyToMessageId,
292
+ replyInThread,
293
+ accountId,
294
+ mediaLocalRoots,
295
+ });
296
+ log.info(`media sent: messageId=${result.messageId}`);
297
+ return { messageId: result.messageId, chatId: result.chatId };
298
+ }
299
+ catch (err) {
300
+ const errMsg = err instanceof Error ? err.message : String(err);
301
+ log.error(`sendMediaLark failed for "${mediaUrl}": ${errMsg}`);
302
+ // Fallback: send the URL as a clickable text link.
303
+ log.info(`falling back to text link for "${mediaUrl}"`);
304
+ const fallbackResult = await sendTextLark({
305
+ cfg,
306
+ to,
307
+ text: `\u{1F4CE} ${mediaUrl}`,
308
+ replyToMessageId,
309
+ replyInThread,
310
+ accountId,
311
+ });
312
+ return {
313
+ ...fallbackResult,
314
+ warning: `Media upload failed for "${mediaUrl}" (${errMsg}). ` +
315
+ `A text link was sent instead. The user may need to open the link manually.`,
316
+ };
317
+ }
318
+ }
319
+ /**
320
+ * Send a text message to a Feishu Drive comment surface.
321
+ *
322
+ * Parses the comment target from `to`, then chooses one of two delivery
323
+ * strategies:
324
+ * - `reply` → reply in the existing comment thread
325
+ * - `create_whole` → create a new whole-document comment
326
+ *
327
+ * Returns a synthetic FeishuSendResult (no IM messageId).
328
+ *
329
+ * @throws {Error} When the target is not a valid comment target or API fails.
330
+ */
331
+ async function sendCommentReplyLark(params) {
332
+ const { cfg, to, text, accountId } = params;
333
+ const target = (0, comment_target_1.parseFeishuCommentTarget)(to);
334
+ if (!target) {
335
+ throw new Error(`Not a valid comment target: "${to}"`);
336
+ }
337
+ log.info(`sendCommentReplyLark: mode=${target.deliveryMode}, comment=${target.commentId}, textLength=${text.length}`);
338
+ const client = lark_client_1.LarkClient.fromCfg(cfg, accountId);
339
+ const elements = [{ type: 'text_run', text_run: { text } }];
340
+ if (target.deliveryMode === 'create_whole') {
341
+ try {
342
+ await client.sdk.drive.v1.fileComment.create({
343
+ path: { file_token: target.fileToken },
344
+ params: {
345
+ file_type: target.fileType,
346
+ user_id_type: 'open_id',
347
+ },
348
+ data: {
349
+ reply_list: {
350
+ replies: [
351
+ {
352
+ content: {
353
+ elements,
354
+ },
355
+ },
356
+ ],
357
+ },
358
+ },
359
+ });
360
+ log.info(`whole comment created successfully`);
361
+ return {
362
+ messageId: `comment-create:${target.commentId}`,
363
+ chatId: to,
364
+ };
365
+ }
366
+ catch (err) {
367
+ const detail = (0, api_error_1.formatLarkError)(err);
368
+ log.error(`sendCommentReplyLark failed to create whole comment: ${detail}`);
369
+ throw new Error(`Comment create failed: ${detail}`, { cause: err });
370
+ }
371
+ }
372
+ // sdk.request defaults to tenant_access_token (bot identity).
373
+ // Dual payload format: try content.elements first, fallback to reply_elements.
374
+ const url = `/open-apis/drive/v1/files/${target.fileToken}/comments/${target.commentId}/replies`;
375
+ const queryParams = { file_type: target.fileType, user_id_type: 'open_id' };
376
+ try {
377
+ await client.sdk.request({
378
+ method: 'POST',
379
+ url,
380
+ params: queryParams,
381
+ data: { content: { elements } },
382
+ });
383
+ log.info(`comment reply sent successfully`);
384
+ return {
385
+ messageId: `comment-reply:${target.commentId}`,
386
+ chatId: to,
387
+ };
388
+ }
389
+ catch (firstErr) {
390
+ // Fallback: some API versions use reply_elements format
391
+ try {
392
+ await client.sdk.request({
393
+ method: 'POST',
394
+ url,
395
+ params: queryParams,
396
+ data: { reply_elements: elements },
397
+ });
398
+ log.info(`comment reply sent successfully (reply_elements fallback)`);
399
+ return {
400
+ messageId: `comment-reply:${target.commentId}`,
401
+ chatId: to,
402
+ };
403
+ }
404
+ catch (secondErr) {
405
+ const detail = (0, api_error_1.formatLarkError)(firstErr);
406
+ log.error(`sendCommentReplyLark failed: ${detail}`);
407
+ throw new Error(`Comment reply failed: ${detail}`, { cause: secondErr });
408
+ }
409
+ }
410
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Message fetching re-exports for backward compatibility.
6
+ *
7
+ * The actual implementations have been moved to:
8
+ * - `getMessageFeishu` / `FeishuMessageInfo` → `../shared/message-lookup.ts`
9
+ * - `getChatTypeFeishu` → `../../core/chat-info-cache.ts`
10
+ */
11
+ export { getMessageFeishu, type FeishuMessageInfo } from '../shared/message-lookup';
12
+ export { getChatTypeFeishu } from '../../core/chat-info-cache';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Message fetching re-exports for backward compatibility.
7
+ *
8
+ * The actual implementations have been moved to:
9
+ * - `getMessageFeishu` / `FeishuMessageInfo` → `../shared/message-lookup.ts`
10
+ * - `getChatTypeFeishu` → `../../core/chat-info-cache.ts`
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.getChatTypeFeishu = exports.getMessageFeishu = void 0;
14
+ var message_lookup_1 = require("../shared/message-lookup.js");
15
+ Object.defineProperty(exports, "getMessageFeishu", { enumerable: true, get: function () { return message_lookup_1.getMessageFeishu; } });
16
+ var chat_info_cache_1 = require("../../core/chat-info-cache.js");
17
+ Object.defineProperty(exports, "getChatTypeFeishu", { enumerable: true, get: function () { return chat_info_cache_1.getChatTypeFeishu; } });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Message forwarding for the Lark/Feishu channel plugin.
6
+ *
7
+ * Provides a function to forward an existing message to another chat
8
+ * or user using the IM Message Forward API.
9
+ */
10
+ import type { OpenClawConfig } from 'openclaw/plugin-sdk';
11
+ import type { FeishuSendResult } from '../types';
12
+ /**
13
+ * Forward an existing message to another chat or user.
14
+ *
15
+ * @param params.cfg - Plugin configuration with Feishu credentials.
16
+ * @param params.messageId - The message ID to forward.
17
+ * @param params.to - Target identifier (chat_id, open_id, or user_id).
18
+ * @param params.accountId - Optional account identifier for multi-account setups.
19
+ * @returns The send result containing the new forwarded message ID.
20
+ */
21
+ export declare function forwardMessageFeishu(params: {
22
+ cfg: OpenClawConfig;
23
+ messageId: string;
24
+ to: string;
25
+ accountId?: string;
26
+ }): Promise<FeishuSendResult>;