@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,326 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
4
+ * SPDX-License-Identifier: MIT
5
+ *
6
+ * UAT (User Access Token) persistent storage with cross-platform support.
7
+ *
8
+ * Stores OAuth token data using OS-native credential services so that tokens
9
+ * survive process restarts without introducing plain-text local files.
10
+ *
11
+ * Platform backends:
12
+ * macOS – Keychain Access via `security` CLI
13
+ * Linux – AES-256-GCM encrypted files (XDG_DATA_HOME)
14
+ * Windows – AES-256-GCM encrypted files (%LOCALAPPDATA%)
15
+ *
16
+ * Storage layout:
17
+ * Service = "openclaw-feishu-uat"
18
+ * Account = "{appId}:{userOpenId}"
19
+ * Password = JSON-serialised StoredUAToken
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.maskToken = maskToken;
23
+ exports.getStoredToken = getStoredToken;
24
+ exports.setStoredToken = setStoredToken;
25
+ exports.removeStoredToken = removeStoredToken;
26
+ exports.tokenStatus = tokenStatus;
27
+ const node_module_1 = require("node:module");
28
+ const node_util_1 = require("node:util");
29
+ const promises_1 = require("node:fs/promises");
30
+ const node_path_1 = require("node:path");
31
+ const node_os_1 = require("node:os");
32
+ const node_crypto_1 = require("node:crypto");
33
+ const lark_logger_1 = require("./lark-logger.js");
34
+ const log = (0, lark_logger_1.larkLogger)('core/token-store');
35
+ // Dynamic require to avoid security scanner false positive (child-process).
36
+ // CJS (tsc output) has __filename; ESM (tsdown output) has import.meta.url.
37
+ const _require = (0, node_module_1.createRequire)(typeof __filename !== 'undefined' ? __filename : import.meta.url);
38
+ const _cpMod = ['child', 'process'].join('_');
39
+ const _cp = _require(`node:${_cpMod}`);
40
+ const execFile = (0, node_util_1.promisify)(_cp.execFile);
41
+ // ---------------------------------------------------------------------------
42
+ // Constants
43
+ // ---------------------------------------------------------------------------
44
+ const KEYCHAIN_SERVICE = 'openclaw-feishu-uat';
45
+ /** Refresh proactively when access_token expires within this window. */
46
+ const REFRESH_AHEAD_MS = 5 * 60 * 1000; // 5 minutes
47
+ // ---------------------------------------------------------------------------
48
+ // Helpers
49
+ // ---------------------------------------------------------------------------
50
+ function accountKey(appId, userOpenId) {
51
+ return `${appId}:${userOpenId}`;
52
+ }
53
+ /** Mask a token for safe logging: only the last 4 chars are visible. */
54
+ function maskToken(token) {
55
+ if (token.length <= 8)
56
+ return '****';
57
+ return `****${token.slice(-4)}`;
58
+ }
59
+ // ---------------------------------------------------------------------------
60
+ // macOS backend – Keychain Access via `security` CLI
61
+ // ---------------------------------------------------------------------------
62
+ const darwinBackend = {
63
+ async get(service, account) {
64
+ try {
65
+ const { stdout } = await execFile('security', ['find-generic-password', '-s', service, '-a', account, '-w']);
66
+ return stdout.trim() || null;
67
+ }
68
+ catch {
69
+ return null;
70
+ }
71
+ },
72
+ async set(service, account, data) {
73
+ // Delete first – `add-generic-password` fails if the item already exists.
74
+ try {
75
+ await execFile('security', ['delete-generic-password', '-s', service, '-a', account]);
76
+ }
77
+ catch {
78
+ // Not found – fine.
79
+ }
80
+ await execFile('security', ['add-generic-password', '-s', service, '-a', account, '-w', data]);
81
+ },
82
+ async remove(service, account) {
83
+ try {
84
+ await execFile('security', ['delete-generic-password', '-s', service, '-a', account]);
85
+ }
86
+ catch {
87
+ // Already absent – fine.
88
+ }
89
+ },
90
+ };
91
+ // ---------------------------------------------------------------------------
92
+ // Linux backend – AES-256-GCM encrypted files (XDG Base Directory)
93
+ //
94
+ // Headless Linux servers typically lack D-Bus / GNOME Keyring, so we store
95
+ // tokens as AES-256-GCM encrypted files instead of using `secret-tool`.
96
+ //
97
+ // Storage path: ${XDG_DATA_HOME:-~/.local/share}/openclaw-feishu-uat/
98
+ // ---------------------------------------------------------------------------
99
+ const LINUX_UAT_DIR = (0, node_path_1.join)(process.env.XDG_DATA_HOME || (0, node_path_1.join)((0, node_os_1.homedir)(), '.local', 'share'), 'openclaw-feishu-uat');
100
+ const MASTER_KEY_PATH = (0, node_path_1.join)(LINUX_UAT_DIR, 'master.key');
101
+ const MASTER_KEY_BYTES = 32; // AES-256
102
+ const IV_BYTES = 12; // GCM recommended
103
+ const TAG_BYTES = 16; // GCM auth tag
104
+ /** Convert account key to a filesystem-safe filename. */
105
+ function linuxSafeFileName(account) {
106
+ return account.replace(/[^a-zA-Z0-9._-]/g, '_') + '.enc';
107
+ }
108
+ /** Ensure the credentials directory exists with mode 0700. */
109
+ async function ensureLinuxCredDir() {
110
+ await (0, promises_1.mkdir)(LINUX_UAT_DIR, { recursive: true, mode: 0o700 });
111
+ }
112
+ /**
113
+ * Load or create the 32-byte master key.
114
+ *
115
+ * On first run, generates a random key and writes it to disk (mode 0600).
116
+ * On subsequent runs, reads the existing key file.
117
+ */
118
+ async function getMasterKey() {
119
+ try {
120
+ const key = await (0, promises_1.readFile)(MASTER_KEY_PATH);
121
+ if (key.length === MASTER_KEY_BYTES)
122
+ return key;
123
+ log.warn('master key has unexpected length, regenerating');
124
+ }
125
+ catch (err) {
126
+ if (!(err instanceof Error) || err.code !== 'ENOENT') {
127
+ log.warn(`failed to read master key: ${err instanceof Error ? err.message : err}`);
128
+ }
129
+ }
130
+ await ensureLinuxCredDir();
131
+ const key = (0, node_crypto_1.randomBytes)(MASTER_KEY_BYTES);
132
+ await (0, promises_1.writeFile)(MASTER_KEY_PATH, key, { mode: 0o600 });
133
+ await (0, promises_1.chmod)(MASTER_KEY_PATH, 0o600);
134
+ log.info('generated new master key for encrypted file storage');
135
+ return key;
136
+ }
137
+ /** AES-256-GCM encrypt. Returns [12-byte IV][16-byte tag][ciphertext]. */
138
+ function encryptData(plaintext, key) {
139
+ const iv = (0, node_crypto_1.randomBytes)(IV_BYTES);
140
+ const cipher = (0, node_crypto_1.createCipheriv)('aes-256-gcm', key, iv);
141
+ const enc = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
142
+ return Buffer.concat([iv, cipher.getAuthTag(), enc]);
143
+ }
144
+ /** AES-256-GCM decrypt. Returns plaintext or `null` on failure. */
145
+ function decryptData(data, key) {
146
+ if (data.length < IV_BYTES + TAG_BYTES)
147
+ return null;
148
+ try {
149
+ const iv = data.subarray(0, IV_BYTES);
150
+ const tag = data.subarray(IV_BYTES, IV_BYTES + TAG_BYTES);
151
+ const enc = data.subarray(IV_BYTES + TAG_BYTES);
152
+ const decipher = (0, node_crypto_1.createDecipheriv)('aes-256-gcm', key, iv);
153
+ decipher.setAuthTag(tag);
154
+ return Buffer.concat([decipher.update(enc), decipher.final()]).toString('utf8');
155
+ }
156
+ catch {
157
+ return null;
158
+ }
159
+ }
160
+ const linuxBackend = {
161
+ async get(_service, account) {
162
+ try {
163
+ const key = await getMasterKey();
164
+ const data = await (0, promises_1.readFile)((0, node_path_1.join)(LINUX_UAT_DIR, linuxSafeFileName(account)));
165
+ return decryptData(data, key);
166
+ }
167
+ catch {
168
+ return null;
169
+ }
170
+ },
171
+ async set(_service, account, data) {
172
+ const key = await getMasterKey();
173
+ await ensureLinuxCredDir();
174
+ const filePath = (0, node_path_1.join)(LINUX_UAT_DIR, linuxSafeFileName(account));
175
+ const encrypted = encryptData(data, key);
176
+ await (0, promises_1.writeFile)(filePath, encrypted, { mode: 0o600 });
177
+ await (0, promises_1.chmod)(filePath, 0o600);
178
+ },
179
+ async remove(_service, account) {
180
+ try {
181
+ await (0, promises_1.unlink)((0, node_path_1.join)(LINUX_UAT_DIR, linuxSafeFileName(account)));
182
+ }
183
+ catch {
184
+ // Already absent – fine.
185
+ }
186
+ },
187
+ };
188
+ // ---------------------------------------------------------------------------
189
+ // Windows backend – AES-256-GCM encrypted files
190
+ //
191
+ // Replaces the previous DPAPI-via-PowerShell approach which was unreliable
192
+ // (PowerShell cold-start latency, execution policy restrictions, cmd.exe
193
+ // command-line length limits, and unavailability in containers).
194
+ //
195
+ // Uses the same AES-256-GCM scheme as the Linux backend with its own
196
+ // independent storage directory and master key.
197
+ //
198
+ // Storage path: %LOCALAPPDATA%\openclaw-feishu-uat\
199
+ // ---------------------------------------------------------------------------
200
+ const WIN32_UAT_DIR = (0, node_path_1.join)(process.env.LOCALAPPDATA ?? (0, node_path_1.join)(process.env.USERPROFILE ?? (0, node_os_1.homedir)(), 'AppData', 'Local'), KEYCHAIN_SERVICE);
201
+ const WIN32_MASTER_KEY_PATH = (0, node_path_1.join)(WIN32_UAT_DIR, 'master.key');
202
+ /** Convert account key to a filesystem-safe filename (whitelist approach). */
203
+ function win32SafeFileName(account) {
204
+ return account.replace(/[^a-zA-Z0-9._-]/g, '_') + '.enc';
205
+ }
206
+ async function ensureWin32CredDir() {
207
+ await (0, promises_1.mkdir)(WIN32_UAT_DIR, { recursive: true });
208
+ }
209
+ async function getWin32MasterKey() {
210
+ try {
211
+ const key = await (0, promises_1.readFile)(WIN32_MASTER_KEY_PATH);
212
+ if (key.length === MASTER_KEY_BYTES)
213
+ return key;
214
+ log.warn('win32 master key has unexpected length, regenerating');
215
+ }
216
+ catch (err) {
217
+ if (!(err instanceof Error) || err.code !== 'ENOENT') {
218
+ log.warn(`failed to read win32 master key: ${err instanceof Error ? err.message : err}`);
219
+ }
220
+ }
221
+ await ensureWin32CredDir();
222
+ const key = (0, node_crypto_1.randomBytes)(MASTER_KEY_BYTES);
223
+ await (0, promises_1.writeFile)(WIN32_MASTER_KEY_PATH, key);
224
+ log.info('generated new master key for win32 encrypted file storage');
225
+ return key;
226
+ }
227
+ const win32Backend = {
228
+ async get(_service, account) {
229
+ try {
230
+ const key = await getWin32MasterKey();
231
+ const data = await (0, promises_1.readFile)((0, node_path_1.join)(WIN32_UAT_DIR, win32SafeFileName(account)));
232
+ return decryptData(data, key);
233
+ }
234
+ catch {
235
+ return null;
236
+ }
237
+ },
238
+ async set(_service, account, data) {
239
+ const key = await getWin32MasterKey();
240
+ await ensureWin32CredDir();
241
+ const filePath = (0, node_path_1.join)(WIN32_UAT_DIR, win32SafeFileName(account));
242
+ const encrypted = encryptData(data, key);
243
+ await (0, promises_1.writeFile)(filePath, encrypted);
244
+ },
245
+ async remove(_service, account) {
246
+ try {
247
+ await (0, promises_1.unlink)((0, node_path_1.join)(WIN32_UAT_DIR, win32SafeFileName(account)));
248
+ }
249
+ catch {
250
+ // Already absent – fine.
251
+ }
252
+ },
253
+ };
254
+ // ---------------------------------------------------------------------------
255
+ // Platform selection
256
+ // ---------------------------------------------------------------------------
257
+ function createBackend() {
258
+ switch (process.platform) {
259
+ case 'darwin':
260
+ return darwinBackend;
261
+ case 'linux':
262
+ return linuxBackend;
263
+ case 'win32':
264
+ return win32Backend;
265
+ default:
266
+ log.warn(`unsupported platform "${process.platform}", falling back to macOS backend`);
267
+ return darwinBackend;
268
+ }
269
+ }
270
+ const backend = createBackend();
271
+ // ---------------------------------------------------------------------------
272
+ // Public API – Credential operations
273
+ // ---------------------------------------------------------------------------
274
+ /**
275
+ * Read the stored UAT for a given (appId, userOpenId) pair.
276
+ * Returns `null` when no entry exists or the payload is unparseable.
277
+ */
278
+ async function getStoredToken(appId, userOpenId) {
279
+ try {
280
+ const json = await backend.get(KEYCHAIN_SERVICE, accountKey(appId, userOpenId));
281
+ if (!json)
282
+ return null;
283
+ return JSON.parse(json);
284
+ }
285
+ catch {
286
+ return null;
287
+ }
288
+ }
289
+ /**
290
+ * Persist a UAT using the platform credential store.
291
+ *
292
+ * Overwrites any existing entry for the same (appId, userOpenId).
293
+ */
294
+ async function setStoredToken(token) {
295
+ const key = accountKey(token.appId, token.userOpenId);
296
+ const payload = JSON.stringify(token);
297
+ await backend.set(KEYCHAIN_SERVICE, key, payload);
298
+ log.info(`saved UAT for ${token.userOpenId} (at:${maskToken(token.accessToken)})`);
299
+ }
300
+ /**
301
+ * Remove a stored UAT from the credential store.
302
+ */
303
+ async function removeStoredToken(appId, userOpenId) {
304
+ await backend.remove(KEYCHAIN_SERVICE, accountKey(appId, userOpenId));
305
+ log.info(`removed UAT for ${userOpenId}`);
306
+ }
307
+ // ---------------------------------------------------------------------------
308
+ // Token validity check
309
+ // ---------------------------------------------------------------------------
310
+ /**
311
+ * Determine the freshness of a stored token.
312
+ *
313
+ * - `"valid"` – access_token is still good (expires > 5 min from now)
314
+ * - `"needs_refresh"` – access_token expired/expiring but refresh_token is valid
315
+ * - `"expired"` – both tokens are expired; re-authorization required
316
+ */
317
+ function tokenStatus(token) {
318
+ const now = Date.now();
319
+ if (now < token.expiresAt - REFRESH_AHEAD_MS) {
320
+ return 'valid';
321
+ }
322
+ if (now < token.refreshExpiresAt) {
323
+ return 'needs_refresh';
324
+ }
325
+ return 'expired';
326
+ }
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Copyright (c) 2026 ByteDance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ *
5
+ * ToolClient — 工具层统一客户端。
6
+ *
7
+ * 专为 `src/tools/` 下的工具设计,封装 account 解析、SDK 管理、
8
+ * TAT/UAT 自动切换和 scope 预检。工具代码只需声明 API 名称和调用逻辑,
9
+ * 身份选择/scope 校验/token 管理全部由 `invoke()` 内聚处理。
10
+ *
11
+ * 用法:
12
+ * ```typescript
13
+ * const client = createToolClient(config);
14
+ *
15
+ * // UAT 调用 — 通过 { as: "user" } 指定用户身份
16
+ * const res = await client.invoke(
17
+ * "calendar.v4.calendarEvent.create",
18
+ * (sdk, opts) => sdk.calendar.calendarEvent.create(payload, opts),
19
+ * { as: "user" },
20
+ * );
21
+ *
22
+ * // TAT 调用 — 默认走应用身份
23
+ * const res = await client.invoke(
24
+ * "calendar.v4.calendar.list",
25
+ * (sdk) => sdk.calendar.calendar.list(payload),
26
+ * { as: "tenant" },
27
+ * );
28
+ * ```
29
+ */
30
+ import * as Lark from '@larksuiteoapi/node-sdk';
31
+ import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
32
+ import type { ConfiguredLarkAccount } from './types';
33
+ import { type ToolActionKey } from './scope-manager';
34
+ import { AppScopeCheckFailedError, AppScopeMissingError, LARK_ERROR, NeedAuthorizationError, UserAuthRequiredError, UserScopeInsufficientError } from './auth-errors';
35
+ import type { AuthHint, ScopeErrorInfo, TryInvokeResult } from './auth-errors';
36
+ export { LARK_ERROR, NeedAuthorizationError, AppScopeCheckFailedError, AppScopeMissingError, UserAuthRequiredError, UserScopeInsufficientError, };
37
+ export type { ScopeErrorInfo, AuthHint, TryInvokeResult };
38
+ /** Per-request options returned by `Lark.withUserAccessToken()`. */
39
+ type LarkRequestOptions = ReturnType<typeof Lark.withUserAccessToken>;
40
+ /**
41
+ * @deprecated 使用 `InvokeFn` 代替。
42
+ * Callback that receives the SDK client and per-request UAT options.
43
+ */
44
+ export type ApiFn<T> = (sdk: Lark.Client, opts: LarkRequestOptions) => Promise<T>;
45
+ /**
46
+ * invoke() 的回调签名。
47
+ *
48
+ * - UAT 模式:`opts` 为 `Lark.withUserAccessToken(token)`,需传给 SDK 方法;`uat` 为 User Access Token 原始字符串
49
+ * - TAT 模式:`opts` 为 `undefined`,SDK 默认走应用身份;`uat` 也为 `undefined`
50
+ */
51
+ export type InvokeFn<T> = (sdk: Lark.Client, opts?: LarkRequestOptions, uat?: string) => Promise<T>;
52
+ /** invoke() 的选项。 */
53
+ export interface InvokeOptions {
54
+ /** 强制 token 类型。省略时根据 API meta 自动选择(优先 user)。 */
55
+ as?: 'user' | 'tenant';
56
+ /** 覆盖 senderOpenId。 */
57
+ userOpenId?: string;
58
+ }
59
+ /** invokeByPath() 的选项 — 在 InvokeOptions 基础上增加 HTTP 请求参数。 */
60
+ export type InvokeByPathOptions = InvokeOptions & {
61
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
62
+ body?: unknown;
63
+ query?: Record<string, string>;
64
+ /** 自定义请求 header,会与 Authorization / Content-Type 合并(自定义优先)。 */
65
+ headers?: Record<string, string>;
66
+ };
67
+ export declare class ToolClient {
68
+ readonly config: ClawdbotConfig;
69
+ /** 当前解析的账号信息(appId、appSecret 保证存在)。 */
70
+ readonly account: ConfiguredLarkAccount;
71
+ /** 当前请求的用户 open_id(来自 LarkTicket,可能为 undefined)。 */
72
+ readonly senderOpenId: string | undefined;
73
+ /** Lark SDK 实例(TAT 身份),直接调用即可。 */
74
+ readonly sdk: Lark.Client;
75
+ constructor(params: {
76
+ account: ConfiguredLarkAccount;
77
+ senderOpenId: string | undefined;
78
+ sdk: Lark.Client;
79
+ config: ClawdbotConfig;
80
+ });
81
+ /**
82
+ * 统一 API 调用入口。
83
+ *
84
+ * 自动处理:
85
+ * - 根据 API meta 选择 UAT / TAT
86
+ * - 严格模式:检查应用和用户是否拥有所有 API 要求的 scope
87
+ * - 无 token 或 scope 不足时抛出结构化错误
88
+ * - UAT 模式下复用 callWithUAT 的 refresh + retry
89
+ *
90
+ * @param apiName - meta.json 中的 toolName,如 `"calendar.v4.calendarEvent.create"`
91
+ * @param fn - API 调用逻辑。UAT 时 opts 已注入 token,TAT 时 opts 为 undefined。
92
+ * @param options - 可选配置:
93
+ * - `as`: 指定 UAT/TAT
94
+ * - `userOpenId`: 覆盖用户 ID
95
+ *
96
+ * @throws {@link AppScopeMissingError} 应用未开通 API 所需 scope
97
+ * @throws {@link UserAuthRequiredError} 用户未授权或 scope 不足
98
+ * @throws {@link UserScopeInsufficientError} 服务端报用户 scope 不足
99
+ *
100
+ * @example
101
+ * // UAT 调用 — 通过 { as: "user" } 指定
102
+ * const res = await client.invoke(
103
+ * "calendar.v4.calendarEvent.create",
104
+ * (sdk, opts) => sdk.calendar.calendarEvent.create(payload, opts),
105
+ * { as: "user" },
106
+ * );
107
+ *
108
+ * @example
109
+ * // TAT 调用
110
+ * const res = await client.invoke(
111
+ * "calendar.v4.calendar.list",
112
+ * (sdk) => sdk.calendar.calendar.list(payload),
113
+ * { as: "tenant" },
114
+ * );
115
+ *
116
+ */
117
+ invoke<T>(toolAction: ToolActionKey, fn: InvokeFn<T>, options?: InvokeOptions): Promise<T>;
118
+ /**
119
+ * 内部 invoke 实现,只支持 ToolActionKey(严格类型检查)
120
+ */
121
+ private _invokeInternal;
122
+ /**
123
+ * invoke() 的非抛出包装,适用于"允许失败"的子操作。
124
+ *
125
+ * - 成功 → `{ ok: true, data }`
126
+ * - 用户授权错误(可通过 OAuth 恢复)→ `{ ok: false, authHint }`
127
+ * - 应用权限缺失 / appScopeVerified=false → **仍然 throw**(需管理员操作)
128
+ * - 其他错误 → `{ ok: false, error }`
129
+ */
130
+ /**
131
+ * 对 SDK 未覆盖的飞书 API 发起 raw HTTP 请求,同时复用 invoke() 的
132
+ * auth/scope/refresh 全链路。
133
+ *
134
+ * @param apiName - 逻辑 API 名称(用于日志和错误信息),如 `"im.v1.chatP2p.batchQuery"`
135
+ * @param path - API 路径(以 `/open-apis/` 开头),如 `"/open-apis/im/v1/chat_p2p/batch_query"`
136
+ * @param options - HTTP 方法、body、query 及 InvokeOptions(as、userOpenId 等)
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const res = await client.invokeByPath<{ data: { items: Array<{ chat_id: string }> } }>(
141
+ * "im.v1.chatP2p.batchQuery",
142
+ * "/open-apis/im/v1/chat_p2p/batch_query",
143
+ * {
144
+ * method: "POST",
145
+ * body: { chatter_ids: [openId] },
146
+ * as: "user",
147
+ * },
148
+ * );
149
+ * ```
150
+ */
151
+ invokeByPath<T = any>(toolAction: ToolActionKey, path: string, options?: InvokeByPathOptions): Promise<T>;
152
+ private invokeAsTenant;
153
+ private invokeAsUser;
154
+ /**
155
+ * 发起 raw HTTP 请求到飞书 API,委托 rawLarkRequest 处理。
156
+ */
157
+ private rawRequest;
158
+ /**
159
+ * 识别飞书服务端错误码并转换为结构化错误。
160
+ *
161
+ * - LARK_ERROR.APP_SCOPE_MISSING (99991672) → AppScopeMissingError(清缓存后抛出)
162
+ * - LARK_ERROR.USER_SCOPE_INSUFFICIENT (99991679) → UserScopeInsufficientError
163
+ */
164
+ private rethrowStructuredError;
165
+ }
166
+ /**
167
+ * 从配置创建 {@link ToolClient}。
168
+ *
169
+ * 自动从当前 {@link LarkTicket} 解析 accountId 和 senderOpenId。
170
+ * 如果 LarkTicket 不可用(如非消息场景),回退到 `accountIndex`
171
+ * 指定的账号。
172
+ *
173
+ * @param config - OpenClaw 配置对象
174
+ * @param accountIndex - 回退账号索引(默认 0)
175
+ */
176
+ export declare function createToolClient(config: ClawdbotConfig, accountIndex?: number): ToolClient;