@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,235 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Converter for "post" (rich text) message type.
7
+ *
8
+ * Preserves structure as Markdown: links as `[text](href)`,
9
+ * images as `![image](key)`, code blocks, and mention resolution.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.convertPost = void 0;
13
+ const lark_logger_1 = require("../../core/lark-logger.js");
14
+ const content_converter_helpers_1 = require("./content-converter-helpers.js");
15
+ const utils_1 = require("./utils.js");
16
+ const log = (0, lark_logger_1.larkLogger)('converters/post');
17
+ /** Preferred locale order for multi-language post unwrapping. */
18
+ const LOCALE_PRIORITY = ['zh_cn', 'en_us', 'ja_jp'];
19
+ /**
20
+ * Scan token for native markdown: a code region to SKIP, OR an image to intercept.
21
+ * Group 1 (code region) matches first so `![alt](key)` inside code is consumed
22
+ * verbatim and never intercepted:
23
+ * - fenced block: ```...``` or ~~~...~~~ (multi-line, lazy)
24
+ * - inline span: ``...`` or `...` (single-line)
25
+ * Group 2 (alt) + Group 3 (target) are the image when no code region matched.
26
+ */
27
+ const MD_SCAN_RE = /(```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[^`\n]*`)|!\[([^\]]*)\]\(([^)]+)\)/g;
28
+ /** Feishu image_key prefix (aligned with markdown-style.ts stripInvalidImageKeys & case 'img'). */
29
+ const FEISHU_IMAGE_KEY_RE = /^img_/;
30
+ /**
31
+ * Inbound native-markdown size ceiling (chars). Guards against pathological
32
+ * posts (huge tables / deep nesting) blowing up memory/token before the
33
+ * downstream chunker runs. One order above the outbound chunk magnitude
34
+ * (outbound default 15000). Tunable; per-account config override is a follow-up.
35
+ */
36
+ const MAX_INBOUND_MD_LEN = 100_000;
37
+ /**
38
+ * Unwrap a parsed post object that may be locale-wrapped.
39
+ *
40
+ * Feishu post messages come in two shapes:
41
+ * - Flat: `{ title, content }`
42
+ * - Locale: `{ zh_cn: { title, content }, en_us: { title, content } }`
43
+ */
44
+ function unwrapLocale(parsed) {
45
+ if ('title' in parsed || 'content' in parsed || 'content_v2' in parsed) {
46
+ return parsed;
47
+ }
48
+ for (const locale of LOCALE_PRIORITY) {
49
+ const localeData = parsed[locale];
50
+ if (localeData != null && typeof localeData === 'object') {
51
+ return localeData;
52
+ }
53
+ }
54
+ const firstKey = Object.keys(parsed)[0];
55
+ if (firstKey) {
56
+ const firstValue = parsed[firstKey];
57
+ if (firstValue != null && typeof firstValue === 'object') {
58
+ return firstValue;
59
+ }
60
+ }
61
+ return undefined;
62
+ }
63
+ const convertPost = (raw, ctx) => {
64
+ const rawParsed = (0, utils_1.safeParse)(raw);
65
+ if (rawParsed == null || typeof rawParsed !== 'object') {
66
+ return { content: '[rich text message]', resources: [] };
67
+ }
68
+ const parsed = unwrapLocale(rawParsed);
69
+ if (!parsed) {
70
+ return { content: '[rich text message]', resources: [] };
71
+ }
72
+ const resources = [];
73
+ const lines = [];
74
+ const seenFileKeys = new Set();
75
+ // Title
76
+ if (parsed.title) {
77
+ lines.push(`**${parsed.title}**`, '');
78
+ }
79
+ const v2 = parsed.content_v2;
80
+ const usedV2 = Array.isArray(v2) && v2.length > 0;
81
+ const contentBlocks = usedV2 ? v2 : (parsed.content ?? []);
82
+ log.info('post content source selected', {
83
+ messageId: ctx.messageId,
84
+ source: usedV2 ? 'content_v2' : 'content',
85
+ hasV2: Array.isArray(v2),
86
+ v2Len: Array.isArray(v2) ? v2.length : 0,
87
+ });
88
+ for (const paragraph of contentBlocks) {
89
+ if (!Array.isArray(paragraph))
90
+ continue;
91
+ let line = '';
92
+ for (const el of paragraph) {
93
+ line += renderElement(el, ctx, resources, seenFileKeys);
94
+ }
95
+ lines.push(line);
96
+ }
97
+ let content = lines.join('\n').trim() || '[rich text message]';
98
+ content = (0, content_converter_helpers_1.resolveMentions)(content, ctx);
99
+ content = capInboundLength(content, resources);
100
+ return { content, resources };
101
+ };
102
+ exports.convertPost = convertPost;
103
+ function renderElement(el, ctx, resources, seenFileKeys) {
104
+ switch (el.tag) {
105
+ case 'text': {
106
+ let text = el.text ?? '';
107
+ text = applyStyle(text, el.style);
108
+ return text;
109
+ }
110
+ case 'a': {
111
+ const text = el.text ?? el.href ?? '';
112
+ return el.href ? `[${text}](${el.href})` : text;
113
+ }
114
+ case 'at': {
115
+ // At-mention in post — use placeholder key if available via context,
116
+ // otherwise fall back to @user_name.
117
+ const userId = el.user_id ?? '';
118
+ if (userId === 'all')
119
+ return '@all';
120
+ const name = el.user_name ?? userId;
121
+ // O(1) lookup via reverse map
122
+ const info = ctx.mentionsByOpenId.get(userId);
123
+ if (info) {
124
+ // Let resolveMentions handle it — return the placeholder key
125
+ return info.key;
126
+ }
127
+ return `@${name}`;
128
+ }
129
+ case 'img': {
130
+ if (el.image_key) {
131
+ resources.push({ type: 'image', fileKey: el.image_key });
132
+ return `![image](${el.image_key})`;
133
+ }
134
+ return '';
135
+ }
136
+ case 'media': {
137
+ if (el.file_key) {
138
+ resources.push({ type: 'file', fileKey: el.file_key });
139
+ return `<file key="${el.file_key}"/>`;
140
+ }
141
+ return '';
142
+ }
143
+ case 'md': {
144
+ return renderInlineImages(el.text ?? '', resources, seenFileKeys);
145
+ }
146
+ case 'code_block': {
147
+ const lang = el.language ?? '';
148
+ const code = el.text ?? '';
149
+ return `\n\`\`\`${lang}\n${code}\n\`\`\`\n`;
150
+ }
151
+ case 'hr':
152
+ return '\n---\n';
153
+ default:
154
+ return el.text ?? '';
155
+ }
156
+ }
157
+ function applyStyle(text, style) {
158
+ if (!style || style.length === 0)
159
+ return text;
160
+ let result = text;
161
+ if (style.includes('bold'))
162
+ result = `**${result}**`;
163
+ if (style.includes('italic'))
164
+ result = `*${result}*`;
165
+ if (style.includes('underline'))
166
+ result = `<u>${result}</u>`;
167
+ if (style.includes('lineThrough'))
168
+ result = `~~${result}~~`;
169
+ if (style.includes('codeInline'))
170
+ result = `\`${result}\``;
171
+ return result;
172
+ }
173
+ /**
174
+ * Scan native markdown for `![alt](target)` and intercept feishu image_keys.
175
+ * - target matches `^img_` → register a downloadable resource (Set-deduped) and
176
+ * normalize the FIRST occurrence to `![image](key)` (the only form
177
+ * substituteMediaPaths can replace); later occurrences of the same key collapse
178
+ * to sanitized alt text so no bare key / un-replaceable marker leaks downstream.
179
+ * - everything else (https/http, data:, protocol-relative, relative/anchor) is kept
180
+ * verbatim and never downloaded.
181
+ * Image syntax inside a code region (fenced block or inline span) is left verbatim
182
+ * and never intercepted — code is shown as-is, not rendered.
183
+ */
184
+ function renderInlineImages(md, resources, seen) {
185
+ return md.replace(MD_SCAN_RE, (whole, codeRegion, alt, target) => {
186
+ if (codeRegion !== undefined) {
187
+ return whole; // fenced block / inline code → keep verbatim, never intercept
188
+ }
189
+ if (!FEISHU_IMAGE_KEY_RE.test(target)) {
190
+ return whole;
191
+ }
192
+ if (!seen.has(target)) {
193
+ seen.add(target);
194
+ resources.push({ type: 'image', fileKey: target });
195
+ return `![image](${target})`;
196
+ }
197
+ return sanitizeAlt(alt);
198
+ });
199
+ }
200
+ /** Strip nested image syntax and bare feishu keys from alt so it cannot be
201
+ * re-matched by substituteMediaPaths nor inject UGC markers. */
202
+ function sanitizeAlt(alt) {
203
+ return alt
204
+ .replace(/!\[[^\]]*\]\([^)]*\)/g, '')
205
+ .replace(/img_[A-Za-z0-9_-]+/g, '')
206
+ .trim();
207
+ }
208
+ /**
209
+ * Cap inbound text length at a safe boundary (never split an `![image](key)`
210
+ * marker), tag `[truncated]`, and drop image resources whose marker fell off the
211
+ * end so we never register an orphan download with no in-text marker.
212
+ */
213
+ function capInboundLength(content, resources) {
214
+ if (content.length <= MAX_INBOUND_MD_LEN)
215
+ return content;
216
+ let cut = content.lastIndexOf('\n', MAX_INBOUND_MD_LEN);
217
+ if (cut <= 0) {
218
+ // Single huge line: back off so we never cut inside an image marker.
219
+ cut = MAX_INBOUND_MD_LEN;
220
+ const markerStart = content.lastIndexOf('![image](', cut);
221
+ if (markerStart !== -1) {
222
+ const markerEnd = content.indexOf(')', markerStart);
223
+ if (markerEnd === -1 || markerEnd >= cut)
224
+ cut = markerStart;
225
+ }
226
+ }
227
+ const truncated = `${content.slice(0, cut).replace(/\s+$/, '')}\n[truncated]`;
228
+ for (let i = resources.length - 1; i >= 0; i--) {
229
+ const r = resources[i];
230
+ if (r.type === 'image' && !truncated.includes(`![image](${r.fileKey})`)) {
231
+ resources.splice(i, 1);
232
+ }
233
+ }
234
+ return truncated;
235
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Converter for "share_chat" and "share_user" message types.
6
+ */
7
+ import type { ContentConverterFn } from './types';
8
+ export declare const convertShareChat: ContentConverterFn;
9
+ export declare const convertShareUser: ContentConverterFn;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Converter for "share_chat" and "share_user" message types.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.convertShareUser = exports.convertShareChat = void 0;
10
+ const utils_1 = require("./utils.js");
11
+ const convertShareChat = (raw) => {
12
+ const parsed = (0, utils_1.safeParse)(raw);
13
+ const chatId = parsed?.chat_id ?? '';
14
+ return {
15
+ content: `<group_card id="${chatId}"/>`,
16
+ resources: [],
17
+ };
18
+ };
19
+ exports.convertShareChat = convertShareChat;
20
+ const convertShareUser = (raw) => {
21
+ const parsed = (0, utils_1.safeParse)(raw);
22
+ const userId = parsed?.user_id ?? '';
23
+ return {
24
+ content: `<contact_card id="${userId}"/>`,
25
+ resources: [],
26
+ };
27
+ };
28
+ exports.convertShareUser = convertShareUser;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Converter for "sticker" message type.
6
+ */
7
+ import type { ContentConverterFn } from './types';
8
+ export declare const convertSticker: ContentConverterFn;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Converter for "sticker" message type.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.convertSticker = void 0;
10
+ const utils_1 = require("./utils.js");
11
+ const convertSticker = (raw) => {
12
+ const parsed = (0, utils_1.safeParse)(raw);
13
+ const fileKey = parsed?.file_key;
14
+ if (!fileKey) {
15
+ return { content: '[sticker]', resources: [] };
16
+ }
17
+ return {
18
+ content: `<sticker key="${fileKey}"/>`,
19
+ resources: [{ type: 'sticker', fileKey }],
20
+ };
21
+ };
22
+ exports.convertSticker = convertSticker;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Converter for "system" message type.
6
+ *
7
+ * System messages use a template string with placeholders like
8
+ * `{from_user}`, `{to_chatters}`, `{divider_text}` that are replaced
9
+ * with actual values from the message body.
10
+ */
11
+ import type { ContentConverterFn } from './types';
12
+ export declare const convertSystem: ContentConverterFn;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Converter for "system" message type.
7
+ *
8
+ * System messages use a template string with placeholders like
9
+ * `{from_user}`, `{to_chatters}`, `{divider_text}` that are replaced
10
+ * with actual values from the message body.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.convertSystem = void 0;
14
+ const utils_1 = require("./utils.js");
15
+ const convertSystem = (raw) => {
16
+ const parsed = (0, utils_1.safeParse)(raw);
17
+ if (!parsed?.template) {
18
+ return { content: '[system message]', resources: [] };
19
+ }
20
+ let content = parsed.template;
21
+ const replacements = {
22
+ '{from_user}': parsed.from_user?.length ? parsed.from_user.filter(Boolean).join(', ') : undefined,
23
+ '{to_chatters}': parsed.to_chatters?.length ? parsed.to_chatters.filter(Boolean).join(', ') : undefined,
24
+ '{divider_text}': parsed.divider_text?.text,
25
+ };
26
+ for (const [placeholder, value] of Object.entries(replacements)) {
27
+ if (value != null) {
28
+ content = content.replaceAll(placeholder, value);
29
+ }
30
+ else {
31
+ content = content.replaceAll(placeholder, '');
32
+ }
33
+ }
34
+ return { content: content.trim(), resources: [] };
35
+ };
36
+ exports.convertSystem = convertSystem;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Converter for "text" message type.
6
+ */
7
+ import type { ContentConverterFn } from './types';
8
+ export declare const convertText: ContentConverterFn;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Converter for "text" message type.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.convertText = void 0;
10
+ const content_converter_helpers_1 = require("./content-converter-helpers.js");
11
+ const utils_1 = require("./utils.js");
12
+ const convertText = (raw, ctx) => {
13
+ const parsed = (0, utils_1.safeParse)(raw);
14
+ const text = parsed?.text ?? raw;
15
+ const content = (0, content_converter_helpers_1.resolveMentions)(text, ctx);
16
+ return { content, resources: [] };
17
+ };
18
+ exports.convertText = convertText;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Converter for "todo" message type.
6
+ */
7
+ import type { ContentConverterFn } from './types';
8
+ export declare const convertTodo: ContentConverterFn;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Converter for "todo" message type.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.convertTodo = void 0;
10
+ const utils_1 = require("./utils.js");
11
+ /** Extract plain text from post-style content blocks. */
12
+ function extractPlainText(content) {
13
+ const lines = [];
14
+ for (const paragraph of content) {
15
+ if (!Array.isArray(paragraph))
16
+ continue;
17
+ let line = '';
18
+ for (const el of paragraph) {
19
+ if (el.text)
20
+ line += el.text;
21
+ }
22
+ lines.push(line);
23
+ }
24
+ return lines.join('\n').trim();
25
+ }
26
+ const convertTodo = (raw) => {
27
+ const parsed = (0, utils_1.safeParse)(raw);
28
+ const parts = [];
29
+ // Build title from summary.title and summary.content
30
+ const title = parsed?.summary?.title ?? '';
31
+ const body = parsed?.summary?.content ? extractPlainText(parsed.summary.content) : '';
32
+ const fullTitle = [title, body].filter(Boolean).join('\n');
33
+ if (fullTitle) {
34
+ parts.push(fullTitle);
35
+ }
36
+ if (parsed?.due_time) {
37
+ parts.push(`Due: ${(0, utils_1.millisToDatetime)(parsed.due_time)}`);
38
+ }
39
+ const inner = parts.join('\n') || '[todo]';
40
+ return {
41
+ content: `<todo>\n${inner}\n</todo>`,
42
+ resources: [],
43
+ };
44
+ };
45
+ exports.convertTodo = convertTodo;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Shared types for the content converter system.
6
+ */
7
+ import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
8
+ import type { LarkAccount } from '../../core/types';
9
+ import type { MentionInfo, ResourceDescriptor } from '../types';
10
+ /**
11
+ * Shape of a message item returned by the Feishu IM API.
12
+ *
13
+ * Used by `buildConvertContextFromItem` (content-converter) and the
14
+ * `merge_forward` converter to process sub-messages and history items
15
+ * without resorting to `any`.
16
+ */
17
+ export interface ApiMessageItem {
18
+ message_id?: string;
19
+ msg_type?: string;
20
+ create_time?: string;
21
+ upper_message_id?: string;
22
+ body?: {
23
+ content?: string;
24
+ };
25
+ sender?: {
26
+ id?: string;
27
+ sender_type?: string;
28
+ };
29
+ mentions?: Array<{
30
+ key: string;
31
+ id: unknown;
32
+ name?: string;
33
+ }>;
34
+ parent_id?: string;
35
+ thread_id?: string;
36
+ deleted?: boolean;
37
+ updated?: boolean;
38
+ }
39
+ /** Context passed to every converter function. */
40
+ export interface ConvertContext {
41
+ /** Map from placeholder key ("@_user_X") to structured mention info. */
42
+ mentions: Map<string, MentionInfo>;
43
+ /** Reverse map from openId to MentionInfo for O(1) lookup. */
44
+ mentionsByOpenId: Map<string, MentionInfo>;
45
+ messageId: string;
46
+ botOpenId?: string;
47
+ /** Plugin config — retained for non-converter downstream consumers. */
48
+ cfg?: ClawdbotConfig;
49
+ /**
50
+ * Pre-resolved account — retained for non-converter downstream consumers.
51
+ * merge_forward no longer reads this; it uses injected callbacks instead.
52
+ */
53
+ account?: LarkAccount;
54
+ /** Account identifier for multi-account setups. */
55
+ accountId?: string;
56
+ /** Synchronous lookup of cached user display name by openId. */
57
+ resolveUserName?: (openId: string) => string | undefined;
58
+ /**
59
+ * Async batch name resolution callback.
60
+ *
61
+ * Called by merge_forward to resolve sub-message sender names.
62
+ * The callback should populate whatever cache `resolveUserName` reads from.
63
+ * All callers must inject this; merge_forward has no internal fallback.
64
+ */
65
+ batchResolveNames?: (openIds: string[]) => Promise<void>;
66
+ /**
67
+ * Async callback to fetch sub-messages of a merge_forward container.
68
+ *
69
+ * Returns the flat items array from the IM API response.
70
+ * All callers must inject this; merge_forward has no internal fallback
71
+ * and returns `<forwarded_messages/>` when not provided.
72
+ */
73
+ fetchSubMessages?: (messageId: string) => Promise<ApiMessageItem[]>;
74
+ /**
75
+ * Recursive dispatcher used by converters such as merge_forward.
76
+ *
77
+ * Injected by `convertMessageContent()` so converter modules do not need
78
+ * to import the main dispatcher directly.
79
+ */
80
+ convertMessageContent?: (raw: string, messageType: string, ctx: ConvertContext) => Promise<ConvertResult>;
81
+ /** 是否删除机器人 mention(事件推送场景=true,历史消息读取=false) */
82
+ stripBotMentions?: boolean;
83
+ }
84
+ /** Result produced by a converter function. */
85
+ export interface ConvertResult {
86
+ /** AI-friendly formatted text. */
87
+ content: string;
88
+ /** Resource descriptors (images, files, audio, video, stickers). */
89
+ resources: ResourceDescriptor[];
90
+ }
91
+ /**
92
+ * Converter function for a single message type.
93
+ *
94
+ * May return a ConvertResult synchronously or a Promise for types that
95
+ * require async operations (e.g. merge_forward expansion via API).
96
+ */
97
+ export type ContentConverterFn = (raw: string, ctx: ConvertContext) => ConvertResult | Promise<ConvertResult>;
98
+ /**
99
+ * Element within a Feishu "post" (rich text) content block.
100
+ *
101
+ * Shared by the `post` and `todo` converters.
102
+ */
103
+ export interface PostElement {
104
+ tag: string;
105
+ text?: string;
106
+ href?: string;
107
+ image_key?: string;
108
+ file_key?: string;
109
+ user_id?: string;
110
+ user_name?: string;
111
+ style?: string[];
112
+ language?: string;
113
+ un_escape?: boolean;
114
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Shared types for the content converter system.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Fallback converter for unsupported message types.
6
+ */
7
+ import type { ContentConverterFn } from './types';
8
+ export declare const convertUnknown: ContentConverterFn;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Fallback converter for unsupported message types.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.convertUnknown = void 0;
10
+ const utils_1 = require("./utils.js");
11
+ const convertUnknown = (raw) => {
12
+ const parsed = (0, utils_1.safeParse)(raw);
13
+ if (parsed != null && typeof parsed === 'object' && 'text' in parsed) {
14
+ const text = parsed.text;
15
+ if (typeof text === 'string')
16
+ return { content: text, resources: [] };
17
+ }
18
+ return { content: '[unsupported message]', resources: [] };
19
+ };
20
+ exports.convertUnknown = convertUnknown;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * Shared utilities for content converters.
6
+ */
7
+ /** Escape a string for safe use inside a RegExp. */
8
+ export declare function escapeRegExp(str: string): string;
9
+ /**
10
+ * Safely parse a JSON string, returning undefined on failure.
11
+ */
12
+ export declare function safeParse(raw: string): unknown | undefined;
13
+ /**
14
+ * Format a duration in milliseconds to a human-readable string.
15
+ *
16
+ * Examples: 1500 → "1.5s", 65000 → "65s"
17
+ */
18
+ export declare function formatDuration(ms: number): string;
19
+ /**
20
+ * Convert a millisecond timestamp to "YYYY-MM-DD HH:mm" in UTC+8 (Beijing time).
21
+ */
22
+ export declare function millisToDatetime(ms: string | number): string;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * Shared utilities for content converters.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.escapeRegExp = escapeRegExp;
10
+ exports.safeParse = safeParse;
11
+ exports.formatDuration = formatDuration;
12
+ exports.millisToDatetime = millisToDatetime;
13
+ /** Escape a string for safe use inside a RegExp. */
14
+ function escapeRegExp(str) {
15
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
16
+ }
17
+ /**
18
+ * Safely parse a JSON string, returning undefined on failure.
19
+ */
20
+ function safeParse(raw) {
21
+ try {
22
+ return JSON.parse(raw);
23
+ }
24
+ catch {
25
+ return undefined;
26
+ }
27
+ }
28
+ /**
29
+ * Format a duration in milliseconds to a human-readable string.
30
+ *
31
+ * Examples: 1500 → "1.5s", 65000 → "65s"
32
+ */
33
+ function formatDuration(ms) {
34
+ const seconds = ms / 1000;
35
+ if (seconds < 1)
36
+ return `${ms}ms`;
37
+ if (Number.isInteger(seconds))
38
+ return `${seconds}s`;
39
+ return `${seconds.toFixed(1)}s`;
40
+ }
41
+ /**
42
+ * Convert a millisecond timestamp to "YYYY-MM-DD HH:mm" in UTC+8 (Beijing time).
43
+ */
44
+ function millisToDatetime(ms) {
45
+ const num = Number(ms);
46
+ if (!Number.isFinite(num))
47
+ return String(ms);
48
+ // UTC+8 offset in milliseconds
49
+ const utc8Offset = 8 * 60 * 60 * 1000;
50
+ const d = new Date(num + utc8Offset);
51
+ const year = d.getUTCFullYear();
52
+ const month = String(d.getUTCMonth() + 1).padStart(2, '0');
53
+ const day = String(d.getUTCDate()).padStart(2, '0');
54
+ const hour = String(d.getUTCHours()).padStart(2, '0');
55
+ const minute = String(d.getUTCMinutes()).padStart(2, '0');
56
+ return `${year}-${month}-${day} ${hour}:${minute}`;
57
+ }