@graychennpm/codebridge 0.0.0-stage → 0.1.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 (434) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/README.md +217 -2
  4. package/README.zh-CN.md +222 -0
  5. package/apps/web/public/brand/agent-logo-carbon.svg +1 -0
  6. package/apps/web/public/brand/agent-logo.svg +1 -0
  7. package/docs/zh-CN/npm-release.md +77 -0
  8. package/node_modules/@codebridge/agent-registry/dist/index.d.ts +32 -0
  9. package/node_modules/@codebridge/agent-registry/dist/index.js +177 -0
  10. package/node_modules/@codebridge/agent-registry/dist/setup.d.ts +9 -0
  11. package/node_modules/@codebridge/agent-registry/dist/setup.js +115 -0
  12. package/node_modules/@codebridge/agent-registry/package.json +17 -0
  13. package/node_modules/@codebridge/backends/dist/acp/acp-active-session.d.ts +12 -0
  14. package/node_modules/@codebridge/backends/dist/acp/acp-active-session.js +57 -0
  15. package/node_modules/@codebridge/backends/dist/acp/acp-claude-activity.d.ts +9 -0
  16. package/node_modules/@codebridge/backends/dist/acp/acp-claude-activity.js +49 -0
  17. package/node_modules/@codebridge/backends/dist/acp/acp-config-options.d.ts +46 -0
  18. package/node_modules/@codebridge/backends/dist/acp/acp-config-options.js +220 -0
  19. package/node_modules/@codebridge/backends/dist/acp/acp-doctor.d.ts +3 -0
  20. package/node_modules/@codebridge/backends/dist/acp/acp-doctor.js +18 -0
  21. package/node_modules/@codebridge/backends/dist/acp/acp-event-mapper.d.ts +5 -0
  22. package/node_modules/@codebridge/backends/dist/acp/acp-event-mapper.js +136 -0
  23. package/node_modules/@codebridge/backends/dist/acp/acp-kill.d.ts +10 -0
  24. package/node_modules/@codebridge/backends/dist/acp/acp-kill.js +24 -0
  25. package/node_modules/@codebridge/backends/dist/acp/acp-race.d.ts +6 -0
  26. package/node_modules/@codebridge/backends/dist/acp/acp-race.js +29 -0
  27. package/node_modules/@codebridge/backends/dist/acp/acp-session-list.d.ts +32 -0
  28. package/node_modules/@codebridge/backends/dist/acp/acp-session-list.js +218 -0
  29. package/node_modules/@codebridge/backends/dist/acp/acp-session-pool.d.ts +85 -0
  30. package/node_modules/@codebridge/backends/dist/acp/acp-session-pool.js +165 -0
  31. package/node_modules/@codebridge/backends/dist/acp/acp-session-runner.d.ts +78 -0
  32. package/node_modules/@codebridge/backends/dist/acp/acp-session-runner.js +550 -0
  33. package/node_modules/@codebridge/backends/dist/acp/acp-spawn-profiles.d.ts +9 -0
  34. package/node_modules/@codebridge/backends/dist/acp/acp-spawn-profiles.js +28 -0
  35. package/node_modules/@codebridge/backends/dist/acp/headless-client.d.ts +19 -0
  36. package/node_modules/@codebridge/backends/dist/acp/headless-client.js +47 -0
  37. package/node_modules/@codebridge/backends/dist/acp/index.d.ts +9 -0
  38. package/node_modules/@codebridge/backends/dist/acp/index.js +9 -0
  39. package/node_modules/@codebridge/backends/dist/agent-setup.d.ts +60 -0
  40. package/node_modules/@codebridge/backends/dist/agent-setup.js +504 -0
  41. package/node_modules/@codebridge/backends/dist/attachment-prompt.d.ts +8 -0
  42. package/node_modules/@codebridge/backends/dist/attachment-prompt.js +28 -0
  43. package/node_modules/@codebridge/backends/dist/auth-error-hints.d.ts +8 -0
  44. package/node_modules/@codebridge/backends/dist/auth-error-hints.js +33 -0
  45. package/node_modules/@codebridge/backends/dist/codex-skill-commands.d.ts +3 -0
  46. package/node_modules/@codebridge/backends/dist/codex-skill-commands.js +88 -0
  47. package/node_modules/@codebridge/backends/dist/index.d.ts +18 -0
  48. package/node_modules/@codebridge/backends/dist/index.js +34 -0
  49. package/node_modules/@codebridge/backends/dist/pi-providers.d.ts +45 -0
  50. package/node_modules/@codebridge/backends/dist/pi-providers.js +148 -0
  51. package/node_modules/@codebridge/backends/dist/pi-session-runner.d.ts +85 -0
  52. package/node_modules/@codebridge/backends/dist/pi-session-runner.js +460 -0
  53. package/node_modules/@codebridge/backends/dist/provider-connection.d.ts +17 -0
  54. package/node_modules/@codebridge/backends/dist/provider-connection.js +99 -0
  55. package/node_modules/@codebridge/backends/dist/session-discovery.d.ts +23 -0
  56. package/node_modules/@codebridge/backends/dist/session-discovery.js +340 -0
  57. package/node_modules/@codebridge/backends/dist/skill-control-plane.d.ts +147 -0
  58. package/node_modules/@codebridge/backends/dist/skill-control-plane.js +832 -0
  59. package/node_modules/@codebridge/backends/package.json +22 -0
  60. package/node_modules/@codebridge/bridge/dist/alert-notification-rules.d.ts +14 -0
  61. package/node_modules/@codebridge/bridge/dist/alert-notification-rules.js +37 -0
  62. package/node_modules/@codebridge/bridge/dist/channel-config.d.ts +4 -0
  63. package/node_modules/@codebridge/bridge/dist/channel-config.js +9 -0
  64. package/node_modules/@codebridge/bridge/dist/channel-ingress.d.ts +5 -0
  65. package/node_modules/@codebridge/bridge/dist/channel-ingress.js +403 -0
  66. package/node_modules/@codebridge/bridge/dist/cli.d.ts +3 -0
  67. package/node_modules/@codebridge/bridge/dist/cli.js +581 -0
  68. package/node_modules/@codebridge/bridge/dist/deployment.d.ts +46 -0
  69. package/node_modules/@codebridge/bridge/dist/deployment.js +174 -0
  70. package/node_modules/@codebridge/bridge/dist/event-loop-lag.d.ts +19 -0
  71. package/node_modules/@codebridge/bridge/dist/event-loop-lag.js +33 -0
  72. package/node_modules/@codebridge/bridge/dist/feishu-alert-monitor.d.ts +70 -0
  73. package/node_modules/@codebridge/bridge/dist/feishu-alert-monitor.js +591 -0
  74. package/node_modules/@codebridge/bridge/dist/init-wizard.d.ts +52 -0
  75. package/node_modules/@codebridge/bridge/dist/init-wizard.js +571 -0
  76. package/node_modules/@codebridge/bridge/dist/mcp-api.d.ts +4 -0
  77. package/node_modules/@codebridge/bridge/dist/mcp-api.js +100 -0
  78. package/node_modules/@codebridge/bridge/dist/outbound-api.d.ts +31 -0
  79. package/node_modules/@codebridge/bridge/dist/outbound-api.js +184 -0
  80. package/node_modules/@codebridge/bridge/dist/outbound-publishers.d.ts +54 -0
  81. package/node_modules/@codebridge/bridge/dist/outbound-publishers.js +213 -0
  82. package/node_modules/@codebridge/bridge/dist/project-api.d.ts +4 -0
  83. package/node_modules/@codebridge/bridge/dist/project-api.js +161 -0
  84. package/node_modules/@codebridge/bridge/dist/secrets-command.d.ts +13 -0
  85. package/node_modules/@codebridge/bridge/dist/secrets-command.js +34 -0
  86. package/node_modules/@codebridge/bridge/dist/session-api.d.ts +26 -0
  87. package/node_modules/@codebridge/bridge/dist/session-api.js +1378 -0
  88. package/node_modules/@codebridge/bridge/dist/session-history-import.d.ts +24 -0
  89. package/node_modules/@codebridge/bridge/dist/session-history-import.js +82 -0
  90. package/node_modules/@codebridge/bridge/dist/session-runtime-api.d.ts +19 -0
  91. package/node_modules/@codebridge/bridge/dist/session-runtime-api.js +453 -0
  92. package/node_modules/@codebridge/bridge/dist/session-runtime-migration.d.ts +21 -0
  93. package/node_modules/@codebridge/bridge/dist/session-runtime-migration.js +43 -0
  94. package/node_modules/@codebridge/bridge/dist/session-runtime-types.d.ts +85 -0
  95. package/node_modules/@codebridge/bridge/dist/session-runtime-types.js +98 -0
  96. package/node_modules/@codebridge/bridge/dist/skill-api.d.ts +28 -0
  97. package/node_modules/@codebridge/bridge/dist/skill-api.js +129 -0
  98. package/node_modules/@codebridge/bridge/dist/startup-surfaces.d.ts +15 -0
  99. package/node_modules/@codebridge/bridge/dist/startup-surfaces.js +13 -0
  100. package/node_modules/@codebridge/bridge/dist/web-frontend.d.ts +8 -0
  101. package/node_modules/@codebridge/bridge/dist/web-frontend.js +76 -0
  102. package/node_modules/@codebridge/bridge/dist/work-item-api.d.ts +6 -0
  103. package/node_modules/@codebridge/bridge/dist/work-item-api.js +414 -0
  104. package/node_modules/@codebridge/bridge/package.json +28 -0
  105. package/node_modules/@codebridge/channel-feishu/dist/alert-reactions.d.ts +6 -0
  106. package/node_modules/@codebridge/channel-feishu/dist/alert-reactions.js +58 -0
  107. package/node_modules/@codebridge/channel-feishu/dist/alert-types.d.ts +35 -0
  108. package/node_modules/@codebridge/channel-feishu/dist/alert-types.js +2 -0
  109. package/node_modules/@codebridge/channel-feishu/dist/bridge.d.ts +130 -0
  110. package/node_modules/@codebridge/channel-feishu/dist/bridge.js +1231 -0
  111. package/node_modules/@codebridge/channel-feishu/dist/cardkit-writer.d.ts +48 -0
  112. package/node_modules/@codebridge/channel-feishu/dist/cardkit-writer.js +153 -0
  113. package/node_modules/@codebridge/channel-feishu/dist/chain-topics.d.ts +20 -0
  114. package/node_modules/@codebridge/channel-feishu/dist/chain-topics.js +35 -0
  115. package/node_modules/@codebridge/channel-feishu/dist/coalescing-card-writer.d.ts +12 -0
  116. package/node_modules/@codebridge/channel-feishu/dist/coalescing-card-writer.js +53 -0
  117. package/node_modules/@codebridge/channel-feishu/dist/delivery-reconciler.d.ts +19 -0
  118. package/node_modules/@codebridge/channel-feishu/dist/delivery-reconciler.js +53 -0
  119. package/node_modules/@codebridge/channel-feishu/dist/durable-markdown-card.d.ts +19 -0
  120. package/node_modules/@codebridge/channel-feishu/dist/durable-markdown-card.js +77 -0
  121. package/node_modules/@codebridge/channel-feishu/dist/feishu-extra-events.d.ts +27 -0
  122. package/node_modules/@codebridge/channel-feishu/dist/feishu-extra-events.js +24 -0
  123. package/node_modules/@codebridge/channel-feishu/dist/feishu-http.d.ts +4 -0
  124. package/node_modules/@codebridge/channel-feishu/dist/feishu-http.js +25 -0
  125. package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-context.d.ts +13 -0
  126. package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-context.js +45 -0
  127. package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-media.d.ts +22 -0
  128. package/node_modules/@codebridge/channel-feishu/dist/feishu-inbound-media.js +273 -0
  129. package/node_modules/@codebridge/channel-feishu/dist/feishu-mention-gate.d.ts +13 -0
  130. package/node_modules/@codebridge/channel-feishu/dist/feishu-mention-gate.js +22 -0
  131. package/node_modules/@codebridge/channel-feishu/dist/feishu-outbound-file.d.ts +12 -0
  132. package/node_modules/@codebridge/channel-feishu/dist/feishu-outbound-file.js +38 -0
  133. package/node_modules/@codebridge/channel-feishu/dist/feishu-quoted-message.d.ts +30 -0
  134. package/node_modules/@codebridge/channel-feishu/dist/feishu-quoted-message.js +183 -0
  135. package/node_modules/@codebridge/channel-feishu/dist/index.d.ts +7 -0
  136. package/node_modules/@codebridge/channel-feishu/dist/index.js +3 -0
  137. package/node_modules/@codebridge/channel-feishu/dist/redacting-logger.d.ts +17 -0
  138. package/node_modules/@codebridge/channel-feishu/dist/redacting-logger.js +41 -0
  139. package/node_modules/@codebridge/channel-feishu/dist/run-status.d.ts +39 -0
  140. package/node_modules/@codebridge/channel-feishu/dist/run-status.js +166 -0
  141. package/node_modules/@codebridge/channel-feishu/dist/session-watcher.d.ts +98 -0
  142. package/node_modules/@codebridge/channel-feishu/dist/session-watcher.js +655 -0
  143. package/node_modules/@codebridge/channel-feishu/package.json +19 -0
  144. package/node_modules/@codebridge/channel-telegram/dist/coalescing-message-writer.d.ts +14 -0
  145. package/node_modules/@codebridge/channel-telegram/dist/coalescing-message-writer.js +56 -0
  146. package/node_modules/@codebridge/channel-telegram/dist/index.d.ts +3 -0
  147. package/node_modules/@codebridge/channel-telegram/dist/index.js +3 -0
  148. package/node_modules/@codebridge/channel-telegram/dist/telegram-api.d.ts +62 -0
  149. package/node_modules/@codebridge/channel-telegram/dist/telegram-api.js +72 -0
  150. package/node_modules/@codebridge/channel-telegram/dist/telegram-bridge.d.ts +64 -0
  151. package/node_modules/@codebridge/channel-telegram/dist/telegram-bridge.js +469 -0
  152. package/node_modules/@codebridge/channel-telegram/dist/telegram-session-watcher.d.ts +41 -0
  153. package/node_modules/@codebridge/channel-telegram/dist/telegram-session-watcher.js +184 -0
  154. package/node_modules/@codebridge/channel-telegram/package.json +18 -0
  155. package/node_modules/@codebridge/core/dist/config-schema.d.ts +1195 -0
  156. package/node_modules/@codebridge/core/dist/config-schema.js +293 -0
  157. package/node_modules/@codebridge/core/dist/config-store.d.ts +48 -0
  158. package/node_modules/@codebridge/core/dist/config-store.js +207 -0
  159. package/node_modules/@codebridge/core/dist/index.d.ts +11 -0
  160. package/node_modules/@codebridge/core/dist/index.js +10 -0
  161. package/node_modules/@codebridge/core/dist/json-file-store.d.ts +16 -0
  162. package/node_modules/@codebridge/core/dist/json-file-store.js +46 -0
  163. package/node_modules/@codebridge/core/dist/mcp-types.d.ts +7 -0
  164. package/node_modules/@codebridge/core/dist/mcp-types.js +2 -0
  165. package/node_modules/@codebridge/core/dist/mentions.d.ts +36 -0
  166. package/node_modules/@codebridge/core/dist/mentions.js +138 -0
  167. package/node_modules/@codebridge/core/dist/secret-migration.d.ts +14 -0
  168. package/node_modules/@codebridge/core/dist/secret-migration.js +55 -0
  169. package/node_modules/@codebridge/core/dist/secret-refs.d.ts +34 -0
  170. package/node_modules/@codebridge/core/dist/secret-refs.js +142 -0
  171. package/node_modules/@codebridge/core/dist/session-event-wire.d.ts +17 -0
  172. package/node_modules/@codebridge/core/dist/session-event-wire.js +28 -0
  173. package/node_modules/@codebridge/core/dist/types.d.ts +363 -0
  174. package/node_modules/@codebridge/core/dist/types.js +22 -0
  175. package/node_modules/@codebridge/core/dist/workspace-key.d.ts +11 -0
  176. package/node_modules/@codebridge/core/dist/workspace-key.js +25 -0
  177. package/node_modules/@codebridge/core/package.json +22 -0
  178. package/node_modules/@codebridge/mcp-runtime/dist/.tsbuildinfo +1 -0
  179. package/node_modules/@codebridge/mcp-runtime/dist/index.d.ts +92 -0
  180. package/node_modules/@codebridge/mcp-runtime/dist/index.js +377 -0
  181. package/node_modules/@codebridge/mcp-runtime/package.json +19 -0
  182. package/node_modules/@codebridge/policy/dist/capability-runtime.d.ts +123 -0
  183. package/node_modules/@codebridge/policy/dist/capability-runtime.js +195 -0
  184. package/node_modules/@codebridge/policy/dist/demo-capabilities.d.ts +4 -0
  185. package/node_modules/@codebridge/policy/dist/demo-capabilities.js +134 -0
  186. package/node_modules/@codebridge/policy/dist/equity-capabilities.d.ts +8 -0
  187. package/node_modules/@codebridge/policy/dist/equity-capabilities.js +35 -0
  188. package/node_modules/@codebridge/policy/dist/index.d.ts +107 -0
  189. package/node_modules/@codebridge/policy/dist/index.js +317 -0
  190. package/node_modules/@codebridge/policy/package.json +17 -0
  191. package/node_modules/@codebridge/project-catalog/dist/index.d.ts +145 -0
  192. package/node_modules/@codebridge/project-catalog/dist/index.js +699 -0
  193. package/node_modules/@codebridge/project-catalog/package.json +18 -0
  194. package/node_modules/@codebridge/router/dist/channel-stream-projector.d.ts +19 -0
  195. package/node_modules/@codebridge/router/dist/channel-stream-projector.js +68 -0
  196. package/node_modules/@codebridge/router/dist/command-help.d.ts +14 -0
  197. package/node_modules/@codebridge/router/dist/command-help.js +151 -0
  198. package/node_modules/@codebridge/router/dist/feishu-stream-presenter.d.ts +18 -0
  199. package/node_modules/@codebridge/router/dist/feishu-stream-presenter.js +193 -0
  200. package/node_modules/@codebridge/router/dist/index.d.ts +9 -0
  201. package/node_modules/@codebridge/router/dist/index.js +9 -0
  202. package/node_modules/@codebridge/router/dist/model-effort.d.ts +5 -0
  203. package/node_modules/@codebridge/router/dist/model-effort.js +33 -0
  204. package/node_modules/@codebridge/router/dist/orchestrator.d.ts +56 -0
  205. package/node_modules/@codebridge/router/dist/orchestrator.js +290 -0
  206. package/node_modules/@codebridge/router/dist/session-list-format.d.ts +19 -0
  207. package/node_modules/@codebridge/router/dist/session-list-format.js +97 -0
  208. package/node_modules/@codebridge/router/dist/session-rotation.d.ts +9 -0
  209. package/node_modules/@codebridge/router/dist/session-rotation.js +31 -0
  210. package/node_modules/@codebridge/router/dist/session-router.d.ts +59 -0
  211. package/node_modules/@codebridge/router/dist/session-router.js +182 -0
  212. package/node_modules/@codebridge/router/dist/slash-commands.d.ts +78 -0
  213. package/node_modules/@codebridge/router/dist/slash-commands.js +874 -0
  214. package/node_modules/@codebridge/router/package.json +18 -0
  215. package/node_modules/@codebridge/run-executor/dist/agent-event-aggregator.d.ts +18 -0
  216. package/node_modules/@codebridge/run-executor/dist/agent-event-aggregator.js +88 -0
  217. package/node_modules/@codebridge/run-executor/dist/index.d.ts +55 -0
  218. package/node_modules/@codebridge/run-executor/dist/index.js +754 -0
  219. package/node_modules/@codebridge/run-executor/dist/run-heartbeat.d.ts +14 -0
  220. package/node_modules/@codebridge/run-executor/dist/run-heartbeat.js +24 -0
  221. package/node_modules/@codebridge/run-executor/package.json +20 -0
  222. package/node_modules/@codebridge/runner-client/dist/index.d.ts +142 -0
  223. package/node_modules/@codebridge/runner-client/dist/index.js +439 -0
  224. package/node_modules/@codebridge/runner-client/package.json +18 -0
  225. package/node_modules/@codebridge/runner-host/dist/cli.d.ts +3 -0
  226. package/node_modules/@codebridge/runner-host/dist/cli.js +58 -0
  227. package/node_modules/@codebridge/runner-host/dist/codex-session-ownership.d.ts +13 -0
  228. package/node_modules/@codebridge/runner-host/dist/codex-session-ownership.js +79 -0
  229. package/node_modules/@codebridge/runner-host/dist/deployment-mcp-server.d.ts +10 -0
  230. package/node_modules/@codebridge/runner-host/dist/deployment-mcp-server.js +54 -0
  231. package/node_modules/@codebridge/runner-host/dist/fcb-script.d.ts +3 -0
  232. package/node_modules/@codebridge/runner-host/dist/fcb-script.js +99 -0
  233. package/node_modules/@codebridge/runner-host/dist/index.d.ts +3 -0
  234. package/node_modules/@codebridge/runner-host/dist/index.js +2 -0
  235. package/node_modules/@codebridge/runner-host/dist/materialize-attachments.d.ts +4 -0
  236. package/node_modules/@codebridge/runner-host/dist/materialize-attachments.js +62 -0
  237. package/node_modules/@codebridge/runner-host/dist/server.d.ts +150 -0
  238. package/node_modules/@codebridge/runner-host/dist/server.js +1295 -0
  239. package/node_modules/@codebridge/runner-host/dist/session-lease.d.ts +12 -0
  240. package/node_modules/@codebridge/runner-host/dist/session-lease.js +146 -0
  241. package/node_modules/@codebridge/runner-host/package.json +26 -0
  242. package/node_modules/@codebridge/session-catalog/dist/index.d.ts +124 -0
  243. package/node_modules/@codebridge/session-catalog/dist/index.js +411 -0
  244. package/node_modules/@codebridge/session-catalog/package.json +17 -0
  245. package/node_modules/@codebridge/session-coordinator/dist/coordinator.d.ts +111 -0
  246. package/node_modules/@codebridge/session-coordinator/dist/coordinator.js +364 -0
  247. package/node_modules/@codebridge/session-coordinator/dist/index.d.ts +5 -0
  248. package/node_modules/@codebridge/session-coordinator/dist/index.js +5 -0
  249. package/node_modules/@codebridge/session-coordinator/dist/lease.d.ts +14 -0
  250. package/node_modules/@codebridge/session-coordinator/dist/lease.js +26 -0
  251. package/node_modules/@codebridge/session-coordinator/dist/queued-claim.d.ts +20 -0
  252. package/node_modules/@codebridge/session-coordinator/dist/queued-claim.js +45 -0
  253. package/node_modules/@codebridge/session-coordinator/dist/recovery.d.ts +31 -0
  254. package/node_modules/@codebridge/session-coordinator/dist/recovery.js +114 -0
  255. package/node_modules/@codebridge/session-coordinator/package.json +17 -0
  256. package/node_modules/@codebridge/web/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  257. package/node_modules/@codebridge/web/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  258. package/node_modules/@codebridge/web/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  259. package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  260. package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  261. package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  262. package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  263. package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  264. package/node_modules/@codebridge/web/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  265. package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  266. package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  267. package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  268. package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  269. package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  270. package/node_modules/@codebridge/web/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  271. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  272. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  273. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  274. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  275. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  276. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  277. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  278. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  279. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  280. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  281. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  282. package/node_modules/@codebridge/web/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  283. package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  284. package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  285. package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  286. package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  287. package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  288. package/node_modules/@codebridge/web/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  289. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  290. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  291. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  292. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  293. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  294. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  295. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  296. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  297. package/node_modules/@codebridge/web/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  298. package/node_modules/@codebridge/web/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  299. package/node_modules/@codebridge/web/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  300. package/node_modules/@codebridge/web/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  301. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  302. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  303. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  304. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  305. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  306. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  307. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  308. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  309. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  310. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  311. package/node_modules/@codebridge/web/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  312. package/node_modules/@codebridge/web/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  313. package/node_modules/@codebridge/web/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  314. package/node_modules/@codebridge/web/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  315. package/node_modules/@codebridge/web/dist/assets/abnfDiagram-N423BO3Z-C-JdFv0U.js +1 -0
  316. package/node_modules/@codebridge/web/dist/assets/arc-DsNROjzU.js +1 -0
  317. package/node_modules/@codebridge/web/dist/assets/architecture-TIHT7OUA-ZEBHG2JZ.js +1 -0
  318. package/node_modules/@codebridge/web/dist/assets/architectureDiagram-T3A2C74G-OsrxcwPM.js +36 -0
  319. package/node_modules/@codebridge/web/dist/assets/array-BifhSqXX.js +1 -0
  320. package/node_modules/@codebridge/web/dist/assets/blockDiagram-VBNYF7ZC-DRgfNeNW.js +132 -0
  321. package/node_modules/@codebridge/web/dist/assets/c4Diagram-5PPSVZJV-BtOGKTh8.js +10 -0
  322. package/node_modules/@codebridge/web/dist/assets/channel-MhXyjxUS.js +1 -0
  323. package/node_modules/@codebridge/web/dist/assets/chunk-2GRJ4B5K-Dy1gJ7sY.js +1 -0
  324. package/node_modules/@codebridge/web/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  325. package/node_modules/@codebridge/web/dist/assets/chunk-4I5QYGJK-1pOLR_SG.js +1 -0
  326. package/node_modules/@codebridge/web/dist/assets/chunk-5RXB4S5H-CP43rgsO.js +231 -0
  327. package/node_modules/@codebridge/web/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  328. package/node_modules/@codebridge/web/dist/assets/chunk-6Q2QTUOP-Bi3Xrp6W.js +88 -0
  329. package/node_modules/@codebridge/web/dist/assets/chunk-7BUUIJ7U-Bb538aSH.js +1 -0
  330. package/node_modules/@codebridge/web/dist/assets/chunk-7Z6QIM7H-CILAW2Nk.js +10 -0
  331. package/node_modules/@codebridge/web/dist/assets/chunk-GF5L2VYU-CAp09yhq.js +206 -0
  332. package/node_modules/@codebridge/web/dist/assets/chunk-I66GZJ75-B_rJXmNu.js +128 -0
  333. package/node_modules/@codebridge/web/dist/assets/chunk-JQJVKLGR-OVeOJFCx.js +156 -0
  334. package/node_modules/@codebridge/web/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  335. package/node_modules/@codebridge/web/dist/assets/chunk-KBJHAD2P-uaupp0k5.js +1 -0
  336. package/node_modules/@codebridge/web/dist/assets/chunk-KEIR6QF5-BICK3FdT.js +161 -0
  337. package/node_modules/@codebridge/web/dist/assets/chunk-NSK5VX7P-fIHF5wwn.js +2 -0
  338. package/node_modules/@codebridge/web/dist/assets/chunk-QR6OTTB3-DxkJuF2b.js +62 -0
  339. package/node_modules/@codebridge/web/dist/assets/chunk-RYQCIY6F-CC5j3u-X.js +1 -0
  340. package/node_modules/@codebridge/web/dist/assets/chunk-UBXNYLIW-DB35O-6R.js +1 -0
  341. package/node_modules/@codebridge/web/dist/assets/chunk-W5SLKNZC-bkRBsbq-.js +1 -0
  342. package/node_modules/@codebridge/web/dist/assets/chunk-WRU74C26-DwvEoD-1.js +70 -0
  343. package/node_modules/@codebridge/web/dist/assets/chunk-XXDRQBXY-DRyYA-HY.js +1 -0
  344. package/node_modules/@codebridge/web/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  345. package/node_modules/@codebridge/web/dist/assets/classDiagram-JCYQIIEL-B8r7z8ii.js +1 -0
  346. package/node_modules/@codebridge/web/dist/assets/classDiagram-v2-OCEON4UE-B8r7z8ii.js +1 -0
  347. package/node_modules/@codebridge/web/dist/assets/cose-bilkent-JH36ORCC-CLkwlrX7.js +1 -0
  348. package/node_modules/@codebridge/web/dist/assets/cynefin-VYW2F7L2-C3_Llw02.js +1 -0
  349. package/node_modules/@codebridge/web/dist/assets/cynefinDiagram-MW4NZA55-D5v7UnJy.js +62 -0
  350. package/node_modules/@codebridge/web/dist/assets/cytoscape.esm-B-NFISlW.js +321 -0
  351. package/node_modules/@codebridge/web/dist/assets/dagre-Buvkdvvj.js +1 -0
  352. package/node_modules/@codebridge/web/dist/assets/dagre-VZM6K2ZE-Cr0IibwW.js +4 -0
  353. package/node_modules/@codebridge/web/dist/assets/defaultLocale-BFoDCU3G.js +1 -0
  354. package/node_modules/@codebridge/web/dist/assets/diagram-7IWD3JNH-CpQXDIzA.js +30 -0
  355. package/node_modules/@codebridge/web/dist/assets/diagram-B4RE2ZJO-VaOkH0Ya.js +3 -0
  356. package/node_modules/@codebridge/web/dist/assets/diagram-LBJQPF4R-D0iXyNks.js +24 -0
  357. package/node_modules/@codebridge/web/dist/assets/diagram-Q27KOJAE-CtqYk01P.js +24 -0
  358. package/node_modules/@codebridge/web/dist/assets/diagram-UB23O5K3-CFnd3H1_.js +41 -0
  359. package/node_modules/@codebridge/web/dist/assets/dist-D2L7nRdk.js +1 -0
  360. package/node_modules/@codebridge/web/dist/assets/ebnfDiagram-BXEA7PRR-B0GIbJYt.js +1 -0
  361. package/node_modules/@codebridge/web/dist/assets/erDiagram-JOGREHBK-BApaLGVA.js +85 -0
  362. package/node_modules/@codebridge/web/dist/assets/eventmodeling-45OFAUF4-DqGGjcld.js +1 -0
  363. package/node_modules/@codebridge/web/dist/assets/flowDiagram-UKHOOZJN-I_qlizLH.js +1 -0
  364. package/node_modules/@codebridge/web/dist/assets/ganttDiagram-PKOTCBZU-B-QZ-J82.js +292 -0
  365. package/node_modules/@codebridge/web/dist/assets/gitGraph-TEB2WS4Q-DK2SJ2Ne.js +1 -0
  366. package/node_modules/@codebridge/web/dist/assets/gitGraphDiagram-DS77QQ5N-B6Z-pu0D.js +106 -0
  367. package/node_modules/@codebridge/web/dist/assets/graphlib-DS17s2tU.js +1 -0
  368. package/node_modules/@codebridge/web/dist/assets/index-8BzpyygS.js +559 -0
  369. package/node_modules/@codebridge/web/dist/assets/index-Bzaz89LE.css +1 -0
  370. package/node_modules/@codebridge/web/dist/assets/info-DKCQHKI2-CGWxt_Py.js +1 -0
  371. package/node_modules/@codebridge/web/dist/assets/infoDiagram-6WML65LV-77XjrPZs.js +2 -0
  372. package/node_modules/@codebridge/web/dist/assets/init-C-OQMol4.js +1 -0
  373. package/node_modules/@codebridge/web/dist/assets/ishikawaDiagram-WSZJBQD7-P1bZAz2x.js +70 -0
  374. package/node_modules/@codebridge/web/dist/assets/journeyDiagram-NVQOT4AX-C4rwMcBY.js +139 -0
  375. package/node_modules/@codebridge/web/dist/assets/kanban-definition-27J2QSJJ-mtw4a9bc.js +89 -0
  376. package/node_modules/@codebridge/web/dist/assets/line-DP4RkYqm.js +1 -0
  377. package/node_modules/@codebridge/web/dist/assets/linear-DMg3PPio.js +1 -0
  378. package/node_modules/@codebridge/web/dist/assets/map-BaFkSB1l.js +1 -0
  379. package/node_modules/@codebridge/web/dist/assets/mermaid-parser.core-HY84kHw1.js +7 -0
  380. package/node_modules/@codebridge/web/dist/assets/mermaid.core-DdgCdsnM.js +42 -0
  381. package/node_modules/@codebridge/web/dist/assets/mindmap-definition-FAOFIHXS-Cw1EnbhZ.js +96 -0
  382. package/node_modules/@codebridge/web/dist/assets/ordinal-BDEzSJ7C.js +1 -0
  383. package/node_modules/@codebridge/web/dist/assets/packet-7NZHBO7P-CEbrbJH3.js +1 -0
  384. package/node_modules/@codebridge/web/dist/assets/path-fybaL0A-.js +1 -0
  385. package/node_modules/@codebridge/web/dist/assets/pegDiagram-VL7TDLO6-CEc1Gedb.js +1 -0
  386. package/node_modules/@codebridge/web/dist/assets/pie-RZYD4A2V-DPXVs-IW.js +1 -0
  387. package/node_modules/@codebridge/web/dist/assets/pieDiagram-7S7Q4E2Y-hoQeGMFH.js +39 -0
  388. package/node_modules/@codebridge/web/dist/assets/quadrantDiagram-CIZ2JOQS-C-Nmxx0f.js +7 -0
  389. package/node_modules/@codebridge/web/dist/assets/radar-I7S5WNFK-BVd3X3Pd.js +1 -0
  390. package/node_modules/@codebridge/web/dist/assets/railroad-3IZDKUUU-CxLxzr_v.js +1 -0
  391. package/node_modules/@codebridge/web/dist/assets/railroad-abnf-AHOZXSZD-MA1zPI84.js +1 -0
  392. package/node_modules/@codebridge/web/dist/assets/railroad-ebnf-EBAXGLYW-Bqug_umD.js +1 -0
  393. package/node_modules/@codebridge/web/dist/assets/railroad-peg-LSFZ7HO6-DRcRFwpq.js +1 -0
  394. package/node_modules/@codebridge/web/dist/assets/railroadDiagram-AXF67PYL-B007ZkL9.js +1 -0
  395. package/node_modules/@codebridge/web/dist/assets/requirementDiagram-LRYGKXZP-LrTCcEi5.js +84 -0
  396. package/node_modules/@codebridge/web/dist/assets/rough.esm-Dy-Kn_BL.js +1 -0
  397. package/node_modules/@codebridge/web/dist/assets/sankeyDiagram-W5VNT64P-Ch4mzHck.js +40 -0
  398. package/node_modules/@codebridge/web/dist/assets/sequenceDiagram-SI44F4Z6-CHg4OzLX.js +162 -0
  399. package/node_modules/@codebridge/web/dist/assets/sizeCapture-X5ZJPWSS-B0uUizjq.js +1 -0
  400. package/node_modules/@codebridge/web/dist/assets/src-BrO6_odD.js +1 -0
  401. package/node_modules/@codebridge/web/dist/assets/stateDiagram-OKZ733FA-7cVkr5nR.js +1 -0
  402. package/node_modules/@codebridge/web/dist/assets/stateDiagram-v2-UEYNNEHI-CTy_mAXb.js +1 -0
  403. package/node_modules/@codebridge/web/dist/assets/swimlanes-SLNWSIFB-BwSVF5qy.js +2 -0
  404. package/node_modules/@codebridge/web/dist/assets/swimlanesDiagram-ULZ7WXOC-BBQnfZ1j.js +8 -0
  405. package/node_modules/@codebridge/web/dist/assets/timeline-definition-Z64GVDOM-BaHEkVDV.js +120 -0
  406. package/node_modules/@codebridge/web/dist/assets/treeView-QDETBFTQ-CF0kLN62.js +1 -0
  407. package/node_modules/@codebridge/web/dist/assets/treemap-6X3UGDF4-BB8A8uux.js +1 -0
  408. package/node_modules/@codebridge/web/dist/assets/vennDiagram-T6HMQDX7-BFK12Iro.js +34 -0
  409. package/node_modules/@codebridge/web/dist/assets/wardley-OPB4EBWU-C_3y61zk.js +1 -0
  410. package/node_modules/@codebridge/web/dist/assets/wardleyDiagram-T6FBY63Y-W2oGu4WK.js +78 -0
  411. package/node_modules/@codebridge/web/dist/assets/xychartDiagram-ELKLHX3M-BiVRnbvz.js +7 -0
  412. package/node_modules/@codebridge/web/dist/brand/agent-logo-carbon.svg +1 -0
  413. package/node_modules/@codebridge/web/dist/brand/agent-logo.svg +1 -0
  414. package/node_modules/@codebridge/web/dist/brand/agnet-logo-carbon.svg +1 -0
  415. package/node_modules/@codebridge/web/dist/brand/agnet-logo.svg +1 -0
  416. package/node_modules/@codebridge/web/dist/brand/agnet-mark-carbon.svg +1 -0
  417. package/node_modules/@codebridge/web/dist/brand/agnet-mark.svg +1 -0
  418. package/node_modules/@codebridge/web/dist/fonts/CommitMono-400-Regular.otf +0 -0
  419. package/node_modules/@codebridge/web/dist/fonts/CommitMono-700-Regular.otf +0 -0
  420. package/node_modules/@codebridge/web/dist/fonts/CommitMono-OFL.txt +21 -0
  421. package/node_modules/@codebridge/web/dist/fonts/DepartureMono-OFL.txt +21 -0
  422. package/node_modules/@codebridge/web/dist/fonts/DepartureMono-Regular.woff2 +0 -0
  423. package/node_modules/@codebridge/web/dist/index.html +25 -0
  424. package/node_modules/@codebridge/web/package.json +7 -0
  425. package/node_modules/@codebridge/work-items/dist/index.d.ts +371 -0
  426. package/node_modules/@codebridge/work-items/dist/index.js +1784 -0
  427. package/node_modules/@codebridge/work-items/dist/session-projector.d.ts +4 -0
  428. package/node_modules/@codebridge/work-items/dist/session-projector.js +506 -0
  429. package/node_modules/@codebridge/work-items/dist/session-runtime.d.ts +274 -0
  430. package/node_modules/@codebridge/work-items/dist/session-runtime.js +1103 -0
  431. package/node_modules/@codebridge/work-items/dist/session-schema.d.ts +9 -0
  432. package/node_modules/@codebridge/work-items/dist/session-schema.js +292 -0
  433. package/node_modules/@codebridge/work-items/package.json +20 -0
  434. package/package.json +75 -4
@@ -0,0 +1,273 @@
1
+ import path from "node:path";
2
+ // Feishu requires range requests for resources >= 100 MB. Keep this path bounded.
3
+ export const MAX_INBOUND_ATTACHMENT_BYTES = 100_000_000 - 1;
4
+ export const MAX_INBOUND_MESSAGE_BYTES = MAX_INBOUND_ATTACHMENT_BYTES;
5
+ const FILE_EXT_MIME = {
6
+ csv: "text/csv",
7
+ tsv: "text/tab-separated-values",
8
+ log: "text/plain",
9
+ rtf: "application/rtf",
10
+ ppt: "application/vnd.ms-powerpoint",
11
+ odt: "application/vnd.oasis.opendocument.text",
12
+ ods: "application/vnd.oasis.opendocument.spreadsheet",
13
+ mp4: "video/mp4",
14
+ m4v: "video/mp4",
15
+ mov: "video/quicktime",
16
+ webm: "video/webm",
17
+ mkv: "video/x-matroska",
18
+ avi: "video/x-msvideo",
19
+ mp3: "audio/mpeg",
20
+ m4a: "audio/mp4",
21
+ aac: "audio/aac",
22
+ wav: "audio/wav",
23
+ ogg: "audio/ogg",
24
+ opus: "audio/ogg",
25
+ amr: "audio/amr",
26
+ flac: "audio/flac",
27
+ bmp: "image/bmp",
28
+ tif: "image/tiff",
29
+ tiff: "image/tiff",
30
+ heic: "image/heic",
31
+ svg: "image/svg+xml",
32
+ xml: "application/xml",
33
+ html: "text/html",
34
+ yaml: "application/yaml",
35
+ yml: "application/yaml",
36
+ gz: "application/gzip",
37
+ tar: "application/x-tar",
38
+ rar: "application/vnd.rar",
39
+ "7z": "application/x-7z-compressed",
40
+ doc: "application/msword",
41
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
42
+ gif: "image/gif",
43
+ jpeg: "image/jpeg",
44
+ jpg: "image/jpeg",
45
+ json: "application/json",
46
+ md: "text/markdown",
47
+ pdf: "application/pdf",
48
+ png: "image/png",
49
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
50
+ txt: "text/plain",
51
+ webp: "image/webp",
52
+ xls: "application/vnd.ms-excel",
53
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
54
+ zip: "application/zip",
55
+ };
56
+ class AttachmentLimitError extends Error {
57
+ bytes;
58
+ limit;
59
+ constructor(bytes, limit) {
60
+ super(`${formatBytes(bytes)},超过 ${formatBytes(limit)}`);
61
+ this.bytes = bytes;
62
+ this.limit = limit;
63
+ }
64
+ }
65
+ async function bufferFromDownloadResponse(raw, maxBytes) {
66
+ if (Buffer.isBuffer(raw)) {
67
+ if (raw.length > maxBytes)
68
+ throw new AttachmentLimitError(raw.length, maxBytes);
69
+ return raw;
70
+ }
71
+ if (raw instanceof Uint8Array) {
72
+ if (raw.byteLength > maxBytes)
73
+ throw new AttachmentLimitError(raw.byteLength, maxBytes);
74
+ return Buffer.from(raw);
75
+ }
76
+ if (typeof raw === "object" && raw !== null) {
77
+ const r = raw;
78
+ if (typeof r.getReadableStream === "function") {
79
+ return readableToBuffer(r.getReadableStream(), maxBytes);
80
+ }
81
+ if (Buffer.isBuffer(r.data))
82
+ return bufferFromDownloadResponse(r.data, maxBytes);
83
+ if (r.data instanceof Uint8Array)
84
+ return bufferFromDownloadResponse(r.data, maxBytes);
85
+ }
86
+ throw new Error("unexpected download response type");
87
+ }
88
+ async function readableToBuffer(stream, maxBytes) {
89
+ const chunks = [];
90
+ let size = 0;
91
+ try {
92
+ for await (const chunk of stream) {
93
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
94
+ size += buffer.length;
95
+ if (size > maxBytes)
96
+ throw new AttachmentLimitError(size, maxBytes);
97
+ chunks.push(buffer);
98
+ }
99
+ return Buffer.concat(chunks, size);
100
+ }
101
+ finally {
102
+ if (!stream.destroyed)
103
+ stream.destroy();
104
+ }
105
+ }
106
+ export function inboundResourceType(type) {
107
+ if (type === "image")
108
+ return "image";
109
+ if (type === "file" || type === "video" || type === "audio")
110
+ return "file";
111
+ return undefined;
112
+ }
113
+ /** 下载用户消息中的图片或文件(需 message_id + file_key 配对) */
114
+ export async function downloadMessageResource(channel, messageId, fileKey, type, maxBytes = MAX_INBOUND_ATTACHMENT_BYTES) {
115
+ const r = await channel.rawClient.im.v1.messageResource.get({
116
+ path: { message_id: messageId, file_key: fileKey },
117
+ params: { type },
118
+ });
119
+ return bufferFromDownloadResponse(r, maxBytes);
120
+ }
121
+ export async function downloadMessageImage(channel, messageId, fileKey) {
122
+ return downloadMessageResource(channel, messageId, fileKey, "image");
123
+ }
124
+ export function sniffImageMime(buf) {
125
+ if (buf.length >= 3 && buf[0] === 0xff && buf[1] === 0xd8 && buf[2] === 0xff) {
126
+ return "image/jpeg";
127
+ }
128
+ if (buf.length >= 8 &&
129
+ buf[0] === 0x89 &&
130
+ buf[1] === 0x50 &&
131
+ buf[2] === 0x4e &&
132
+ buf[3] === 0x47) {
133
+ return "image/png";
134
+ }
135
+ if (buf.length >= 6 &&
136
+ buf[0] === 0x47 &&
137
+ buf[1] === 0x49 &&
138
+ buf[2] === 0x46) {
139
+ return "image/gif";
140
+ }
141
+ if (buf.length >= 12 &&
142
+ buf.toString("ascii", 0, 4) === "RIFF" &&
143
+ buf.toString("ascii", 8, 12) === "WEBP") {
144
+ return "image/webp";
145
+ }
146
+ if (buf.toString("ascii", 0, 2) === "BM")
147
+ return "image/bmp";
148
+ if (buf.subarray(0, 4).equals(Buffer.from([0x49, 0x49, 0x2a, 0]))
149
+ || buf.subarray(0, 4).equals(Buffer.from([0x4d, 0x4d, 0, 0x2a])))
150
+ return "image/tiff";
151
+ if (buf.length >= 12 && buf.toString("ascii", 4, 8) === "ftyp"
152
+ && ["heic", "heix", "hevc", "hevx", "mif1"].includes(buf.toString("ascii", 8, 12)))
153
+ return "image/heic";
154
+ return "application/octet-stream";
155
+ }
156
+ export function mimeFromFileName(fileName) {
157
+ if (!fileName)
158
+ return undefined;
159
+ const ext = path.extname(fileName).slice(1).toLowerCase();
160
+ if (!ext)
161
+ return undefined;
162
+ return FILE_EXT_MIME[ext];
163
+ }
164
+ export function mimeToImageExt(mimeType) {
165
+ switch (mimeType) {
166
+ case "image/jpeg":
167
+ return ".jpg";
168
+ case "image/gif":
169
+ return ".gif";
170
+ case "image/webp":
171
+ return ".webp";
172
+ case "image/png":
173
+ return ".png";
174
+ case "image/bmp":
175
+ return ".bmp";
176
+ case "image/tiff":
177
+ return ".tiff";
178
+ case "image/heic":
179
+ return ".heic";
180
+ default:
181
+ return ".bin";
182
+ }
183
+ }
184
+ export function imageAttachmentName(index, mimeType) {
185
+ return `feishu-image-${index + 1}${mimeToImageExt(mimeType)}`;
186
+ }
187
+ export function fileAttachmentName(index, fileName) {
188
+ const base = fileName?.trim() ? path.basename(fileName) : "";
189
+ if (base && base !== "." && base !== "..")
190
+ return base;
191
+ return `feishu-file-${index + 1}.bin`;
192
+ }
193
+ export function resolveInboundPrompt(content, attachmentCount) {
194
+ const stripped = content
195
+ .replace(/!\[[^\]]*\]\([^)]+\)/g, "")
196
+ .replace(/<(?:file|video|audio)\b[^>]*\/>/g, "")
197
+ .replace(/^\[(?:video|audio|file)\]$/i, "")
198
+ .trim();
199
+ if (stripped)
200
+ return stripped;
201
+ if (attachmentCount > 0)
202
+ return "请查看用户发送的附件。";
203
+ return "";
204
+ }
205
+ function formatBytes(n) {
206
+ if (n < 1024)
207
+ return `${n}B`;
208
+ if (n < 1024 * 1024)
209
+ return `${Math.round(n / 1024)}KB`;
210
+ return `${(n / 1_000_000).toFixed(1)}MB`;
211
+ }
212
+ export async function downloadInboundAttachments(channel, messageId, resources, maxTotalBytes = MAX_INBOUND_MESSAGE_BYTES) {
213
+ const attachments = [];
214
+ const skipped = [];
215
+ let imageIndex = 0;
216
+ let fileIndex = 0;
217
+ let totalBytes = 0;
218
+ for (const resource of resources) {
219
+ const type = inboundResourceType(resource.type);
220
+ const label = resource.fileName || resource.fileKey || "未命名附件";
221
+ if (!type) {
222
+ skipped.push(`${label}(不支持的资源类型 ${resource.type ?? "unknown"})`);
223
+ continue;
224
+ }
225
+ if (!resource.fileKey) {
226
+ skipped.push(`${label}(缺少 file_key)`);
227
+ continue;
228
+ }
229
+ const remaining = Math.min(maxTotalBytes, MAX_INBOUND_MESSAGE_BYTES) - totalBytes;
230
+ if (remaining <= 0) {
231
+ skipped.push(`${label}(单条消息附件总量已达到 ${formatBytes(MAX_INBOUND_MESSAGE_BYTES)})`);
232
+ continue;
233
+ }
234
+ try {
235
+ const buf = await downloadMessageResource(channel, messageId, resource.fileKey, type, Math.min(MAX_INBOUND_ATTACHMENT_BYTES, remaining));
236
+ totalBytes += buf.length;
237
+ if (type === "image") {
238
+ const mimeType = sniffImageMime(buf);
239
+ attachments.push({
240
+ name: resource.fileName ?? imageAttachmentName(imageIndex, mimeType),
241
+ mimeType,
242
+ dataBase64: buf.toString("base64"),
243
+ });
244
+ imageIndex += 1;
245
+ }
246
+ else {
247
+ const mimeType = mimeFromFileName(resource.fileName)
248
+ ?? (resource.type === "video" ? "video/mp4" : resource.type === "audio" ? "audio/ogg" : "application/octet-stream");
249
+ const fileName = resource.fileName || (resource.type === "video"
250
+ ? `feishu-video-${fileIndex + 1}.mp4`
251
+ : resource.type === "audio" ? `feishu-audio-${fileIndex + 1}.ogg` : undefined);
252
+ attachments.push({
253
+ name: fileAttachmentName(fileIndex, fileName),
254
+ mimeType,
255
+ dataBase64: buf.toString("base64"),
256
+ });
257
+ fileIndex += 1;
258
+ }
259
+ }
260
+ catch (err) {
261
+ const message = err instanceof Error ? err.message : String(err);
262
+ skipped.push(err instanceof AttachmentLimitError
263
+ ? `${label}(${message};单条消息总量限制 ${formatBytes(MAX_INBOUND_MESSAGE_BYTES)})`
264
+ : `${label}(下载失败:${message})`);
265
+ }
266
+ }
267
+ return { attachments, skipped };
268
+ }
269
+ export async function downloadInboundImages(channel, messageId, resources) {
270
+ const { attachments } = await downloadInboundAttachments(channel, messageId, resources.filter((resource) => resource.type === "image"));
271
+ return attachments;
272
+ }
273
+ //# sourceMappingURL=feishu-inbound-media.js.map
@@ -0,0 +1,13 @@
1
+ import type { FeishuMessage } from "./bridge.js";
2
+ export interface GroupMentionGateInput {
3
+ chatId: string;
4
+ mentionedBot?: boolean;
5
+ topicId?: string;
6
+ requireMention: boolean;
7
+ /** 本话题是否已有 Agent session 或 bot 已回复过 */
8
+ topicActive: boolean;
9
+ }
10
+ /** 群消息是否应触发 Agent(@ 要求由 Bridge 判断,SDK 层需关闭 requireMention) */
11
+ export declare function shouldAcceptGroupMessage(input: GroupMentionGateInput): boolean;
12
+ export declare function topicActiveForMessage(msg: FeishuMessage, topicId: string | undefined, hasSession: boolean, participatedTopics: ReadonlySet<string>): boolean;
13
+ //# sourceMappingURL=feishu-mention-gate.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** 群消息是否应触发 Agent(@ 要求由 Bridge 判断,SDK 层需关闭 requireMention) */
2
+ export function shouldAcceptGroupMessage(input) {
3
+ if (!input.requireMention)
4
+ return true;
5
+ if (input.mentionedBot)
6
+ return true;
7
+ if (input.topicId && input.topicActive)
8
+ return true;
9
+ return false;
10
+ }
11
+ export function topicActiveForMessage(msg, topicId, hasSession, participatedTopics) {
12
+ if (!topicId)
13
+ return false;
14
+ if (hasSession)
15
+ return true;
16
+ if (participatedTopics.has(topicId))
17
+ return true;
18
+ if (msg.threadId === topicId && msg.mentionedBot)
19
+ return true;
20
+ return false;
21
+ }
22
+ //# sourceMappingURL=feishu-mention-gate.js.map
@@ -0,0 +1,12 @@
1
+ /** 飞书文件消息上限 30MB */
2
+ export declare const MAX_OUTBOUND_FILE_BYTES: number;
3
+ export interface OutboundFile {
4
+ path: string;
5
+ fileName: string;
6
+ }
7
+ /**
8
+ * 校验 /send 要外发的本地文件:仅允许主目录内的普通文件,
9
+ * 防止把系统文件或目录发进聊天。
10
+ */
11
+ export declare function resolveOutboundFile(raw: string, homeDir?: string): Promise<OutboundFile>;
12
+ //# sourceMappingURL=feishu-outbound-file.d.ts.map
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs/promises";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ /** 飞书文件消息上限 30MB */
5
+ export const MAX_OUTBOUND_FILE_BYTES = 30 * 1024 * 1024;
6
+ /**
7
+ * 校验 /send 要外发的本地文件:仅允许主目录内的普通文件,
8
+ * 防止把系统文件或目录发进聊天。
9
+ */
10
+ export async function resolveOutboundFile(raw, homeDir = os.homedir()) {
11
+ const expanded = raw === "~" || raw.startsWith("~/")
12
+ ? path.join(homeDir, raw.slice(1))
13
+ : raw;
14
+ if (!path.isAbsolute(expanded)) {
15
+ throw new Error("请提供绝对路径(可用 `~/` 开头)");
16
+ }
17
+ let real;
18
+ try {
19
+ real = await fs.realpath(expanded);
20
+ }
21
+ catch {
22
+ throw new Error(`文件不存在: ${expanded}`);
23
+ }
24
+ const realHome = await fs.realpath(homeDir);
25
+ const rel = path.relative(realHome, real);
26
+ if (rel.startsWith("..") || path.isAbsolute(rel)) {
27
+ throw new Error("仅允许发送主目录内的文件");
28
+ }
29
+ const stat = await fs.stat(real);
30
+ if (!stat.isFile()) {
31
+ throw new Error("目标不是普通文件");
32
+ }
33
+ if (stat.size > MAX_OUTBOUND_FILE_BYTES) {
34
+ throw new Error(`文件超过飞书 30MB 上限(实际 ${(stat.size / 1024 / 1024).toFixed(1)}MB)`);
35
+ }
36
+ return { path: real, fileName: path.basename(real) };
37
+ }
38
+ //# sourceMappingURL=feishu-outbound-file.js.map
@@ -0,0 +1,30 @@
1
+ import type { LarkChannel } from "@larksuiteoapi/node-sdk";
2
+ import type { RunAttachment } from "@codebridge/core";
3
+ /** 引用内容注入 prompt 的长度上限,防止长消息撑爆上下文 */
4
+ export declare const QUOTE_MAX_CHARS = 2000;
5
+ interface QuotedMention {
6
+ key: string;
7
+ name: string;
8
+ }
9
+ /**
10
+ * 从飞书消息体提取纯文本。text/post 按结构解析并还原 @ 提及;
11
+ * 其他类型(卡片等)递归收集 text 字段,尽力而为。
12
+ */
13
+ export declare function extractMessageText(msgType: string | undefined, rawContent: string, mentions?: QuotedMention[]): string;
14
+ export declare function formatQuotedContext(text: string, senderName?: string): string;
15
+ export declare function formatTopicRootContext(text: string, senderName?: string): string;
16
+ /**
17
+ * 拉取指定消息并格式化为 prompt 上下文块。
18
+ * skipSelfApp:跳过本 bot 自己发的消息(会话里已有)
19
+ */
20
+ export declare function fetchMessageContext(channel: LarkChannel, messageId: string, options: {
21
+ selfAppId?: string;
22
+ skipSelfApp?: boolean;
23
+ preserveLongText?: (text: string, messageId: string) => string;
24
+ addImage?: (attachment: RunAttachment) => void;
25
+ resolveOwnText?: (messageId: string) => Promise<string | undefined>;
26
+ format: (text: string, senderName?: string) => string;
27
+ }): Promise<string | undefined>;
28
+ export declare function fetchQuotedMessage(channel: LarkChannel, messageId: string, selfAppId?: string, preserveLongText?: (text: string, messageId: string) => string, addImage?: (attachment: RunAttachment) => void, resolveOwnText?: (messageId: string) => Promise<string | undefined>): Promise<string | undefined>;
29
+ export {};
30
+ //# sourceMappingURL=feishu-quoted-message.d.ts.map
@@ -0,0 +1,183 @@
1
+ import { downloadMessageResource, sniffImageMime } from "./feishu-inbound-media.js";
2
+ function quotedImageKeys(value, keys = new Set()) {
3
+ if (value && typeof value === "object") {
4
+ for (const [key, child] of Object.entries(value)) {
5
+ if ((key === "image_key" || key === "img_key") && typeof child === "string" && child)
6
+ keys.add(child);
7
+ else if (child && typeof child === "object")
8
+ quotedImageKeys(child, keys);
9
+ }
10
+ }
11
+ return keys;
12
+ }
13
+ /** 引用内容注入 prompt 的长度上限,防止长消息撑爆上下文 */
14
+ export const QUOTE_MAX_CHARS = 2000;
15
+ /**
16
+ * 从飞书消息体提取纯文本。text/post 按结构解析并还原 @ 提及;
17
+ * 其他类型(卡片等)递归收集 text 字段,尽力而为。
18
+ */
19
+ export function extractMessageText(msgType, rawContent, mentions) {
20
+ let parsed;
21
+ try {
22
+ parsed = JSON.parse(rawContent);
23
+ }
24
+ catch {
25
+ return rawContent;
26
+ }
27
+ let text;
28
+ if (msgType === "text") {
29
+ text = String(parsed.text ?? "");
30
+ }
31
+ else if (msgType === "post") {
32
+ text = extractPostText(parsed);
33
+ }
34
+ else if (msgType === "image") {
35
+ return "[图片]";
36
+ }
37
+ else {
38
+ const collected = collectTextFields(parsed);
39
+ text = collected || `[${msgType ?? "未知类型"} 消息]`;
40
+ }
41
+ for (const m of mentions ?? []) {
42
+ text = text.split(m.key).join(`@${m.name}`);
43
+ }
44
+ return text.trim();
45
+ }
46
+ /** post 消息:{title, content: [[{tag, text|href|user_name}]]} 逐行拼接 */
47
+ function extractPostText(parsed) {
48
+ if (parsed && typeof parsed === "object" && !("content" in parsed)) {
49
+ const localized = Object.values(parsed).find((value) => value && typeof value === "object" && "content" in value);
50
+ if (localized)
51
+ parsed = localized;
52
+ }
53
+ const post = parsed;
54
+ const lines = [];
55
+ if (post.title)
56
+ lines.push(post.title);
57
+ for (const line of post.content ?? []) {
58
+ const parts = line.map((el) => el.tag === "at" ? `@${el.user_name ?? ""}` : (el.text ?? ""));
59
+ lines.push(parts.join(""));
60
+ }
61
+ return lines.join("\n");
62
+ }
63
+ /** 兜底:递归收集对象里的 title/text/content 字符串字段(卡片消息等) */
64
+ function collectTextFields(value, depth = 0) {
65
+ if (depth > 8)
66
+ return "";
67
+ if (typeof value === "string")
68
+ return "";
69
+ if (Array.isArray(value)) {
70
+ return value
71
+ .map((v) => collectTextFields(v, depth + 1))
72
+ .filter(Boolean)
73
+ .join("\n");
74
+ }
75
+ if (typeof value === "object" && value !== null) {
76
+ const out = [];
77
+ for (const [k, v] of Object.entries(value)) {
78
+ if ((k === "title" || k === "text" || k === "content") &&
79
+ typeof v === "string") {
80
+ out.push(v);
81
+ }
82
+ else {
83
+ const nested = collectTextFields(v, depth + 1);
84
+ if (nested)
85
+ out.push(nested);
86
+ }
87
+ }
88
+ return out.join("\n");
89
+ }
90
+ return "";
91
+ }
92
+ export function formatQuotedContext(text, senderName) {
93
+ const truncated = text.length > QUOTE_MAX_CHARS
94
+ ? `${text.slice(0, QUOTE_MAX_CHARS)}\n…(引用内容已截断)`
95
+ : text;
96
+ const header = senderName
97
+ ? `【用户引用的消息|发送者:${senderName}】`
98
+ : "【用户引用的消息】";
99
+ return `${header}\n${truncated}\n【引用消息结束】`;
100
+ }
101
+ export function formatTopicRootContext(text, senderName) {
102
+ const truncated = text.length > QUOTE_MAX_CHARS
103
+ ? `${text.slice(0, QUOTE_MAX_CHARS)}\n…(话题根消息已截断)`
104
+ : text;
105
+ const header = senderName
106
+ ? `【话题根消息|发送者:${senderName}】`
107
+ : "【话题根消息】";
108
+ return `${header}\n${truncated}\n【话题根消息结束】`;
109
+ }
110
+ /**
111
+ * 拉取指定消息并格式化为 prompt 上下文块。
112
+ * skipSelfApp:跳过本 bot 自己发的消息(会话里已有)
113
+ */
114
+ export async function fetchMessageContext(channel, messageId, options) {
115
+ const res = await channel.rawClient.im.v1.message.get({
116
+ path: { message_id: messageId },
117
+ });
118
+ if (res.code !== undefined && res.code !== 0)
119
+ throw new Error("message_fetch_failed");
120
+ const item = res.data?.items?.[0];
121
+ if (!item?.body?.content)
122
+ return undefined;
123
+ if (options.skipSelfApp !== false &&
124
+ options.selfAppId &&
125
+ item.sender?.sender_type === "app" &&
126
+ item.sender.id === options.selfAppId) {
127
+ return undefined;
128
+ }
129
+ let text = extractMessageText(item.msg_type, item.body.content, item.mentions?.map((m) => ({ key: m.key, name: m.name })));
130
+ const placeholder = item.msg_type === "interactive" && text.includes("请升级至最新版本客户端");
131
+ if (placeholder) {
132
+ const ownText = item.sender?.sender_type === "app" && item.sender.id === options.selfAppId
133
+ ? await options.resolveOwnText?.(messageId) : undefined;
134
+ if (!ownText)
135
+ throw new Error("interactive_card_content_unavailable");
136
+ text = ownText;
137
+ }
138
+ let keys = new Set();
139
+ if (!placeholder) {
140
+ try {
141
+ keys = quotedImageKeys(JSON.parse(item.body.content));
142
+ }
143
+ catch { /* Plain text has no image keys. */ }
144
+ }
145
+ let index = 0;
146
+ for (const key of keys) {
147
+ index++;
148
+ if (!options.addImage || index > 10) {
149
+ text += "\n[引用图片未传递:附件数量或通道限制,请勿猜测图片内容]";
150
+ break;
151
+ }
152
+ try {
153
+ const data = await downloadMessageResource(channel, messageId, key, "image", 10_000_000);
154
+ const mimeType = sniffImageMime(data);
155
+ if (!mimeType.startsWith("image/"))
156
+ throw new Error("invalid_image");
157
+ const name = `quoted-${messageId.replace(/[^a-zA-Z0-9_-]/g, "_")}-${index}.${mimeType.split("/")[1]}`;
158
+ options.addImage({ name, mimeType, dataBase64: data.toString("base64") });
159
+ text += `\n[引用图片附件:${name};请读取原图,若模型不支持视觉请明确说明]`;
160
+ }
161
+ catch {
162
+ text += `\n[引用图片 ${index} 未读取成功,请勿猜测图片内容]`;
163
+ }
164
+ }
165
+ if (!text)
166
+ return undefined;
167
+ const fullText = text.length > QUOTE_MAX_CHARS
168
+ ? options.preserveLongText?.(text, messageId)
169
+ : undefined;
170
+ return `${options.format(text, item.sender?.sender_name)}\n引用消息 ID:${messageId}`
171
+ + (fullText ? `\n完整内容见附件:${fullText};处理代码或参数前请先读取全文。` : "");
172
+ }
173
+ export async function fetchQuotedMessage(channel, messageId, selfAppId, preserveLongText, addImage, resolveOwnText) {
174
+ return fetchMessageContext(channel, messageId, {
175
+ selfAppId,
176
+ skipSelfApp: false,
177
+ preserveLongText,
178
+ addImage,
179
+ resolveOwnText,
180
+ format: formatQuotedContext,
181
+ });
182
+ }
183
+ //# sourceMappingURL=feishu-quoted-message.js.map
@@ -0,0 +1,7 @@
1
+ export { FeishuBridge, runDoctor } from "./bridge.js";
2
+ export type { FeishuBridgeOptions, FeishuMention, FeishuMessage, } from "./bridge.js";
3
+ export type { FeishuAlertMessage, FeishuAlertPage, FeishuAlertReply } from "./alert-types.js";
4
+ export { FEISHU_ALERT_STATUSES } from "./alert-types.js";
5
+ export type { FeishuAlertStatus } from "./alert-types.js";
6
+ export type { FeishuAlertReaction } from "./alert-types.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { FeishuBridge, runDoctor } from "./bridge.js";
2
+ export { FEISHU_ALERT_STATUSES } from "./alert-types.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,17 @@
1
+ /** Same shape as the Feishu SDK's Logger; the SDK passes each call's arguments as one array. */
2
+ export interface SdkLogger {
3
+ error: (...msg: unknown[]) => void;
4
+ warn: (...msg: unknown[]) => void;
5
+ info: (...msg: unknown[]) => void;
6
+ debug: (...msg: unknown[]) => void;
7
+ trace: (...msg: unknown[]) => void;
8
+ }
9
+ /** Render a value the way console would, then strip known secrets and credential patterns. */
10
+ export declare function redact(value: unknown, secrets: readonly (string | undefined)[]): string;
11
+ /**
12
+ * SDK logger that never writes credentials. The SDK's default logger dumps whole Axios
13
+ * errors on network failures, including the token request body with app_secret.
14
+ * `secrets` is read on every call so hot-reloaded config is honoured.
15
+ */
16
+ export declare function redactingLogger(secrets: () => readonly (string | undefined)[], sink?: Pick<Console, "log" | "warn" | "info" | "debug" | "trace">): SdkLogger;
17
+ //# sourceMappingURL=redacting-logger.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { inspect } from "node:util";
2
+ const REDACTED = "[REDACTED]";
3
+ /** Credential-shaped values the SDK puts in request bodies, headers and responses. */
4
+ const PATTERNS = [
5
+ [/((?:app_secret|appSecret|encrypt_key|verification_token)\\?["']?\s*[:=]\s*\\?["']?)[^"'\\\s,}]+/gi, `$1${REDACTED}`],
6
+ [/((?:tenant|app|user)_access_token\\?["']?\s*[:=]\s*\\?["']?)[^"'\\\s,}]+/gi, `$1${REDACTED}`],
7
+ [/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, `$1${REDACTED}`],
8
+ // Tenant / user access tokens issued by Feishu.
9
+ [/\b[tu]-[A-Za-z0-9_-]{20,}/g, REDACTED],
10
+ ];
11
+ /** Render a value the way console would, then strip known secrets and credential patterns. */
12
+ export function redact(value, secrets) {
13
+ let text = typeof value === "string" ? value : inspect(value, { depth: 4, breakLength: 120 });
14
+ for (const secret of secrets) {
15
+ if (secret && secret.length >= 8)
16
+ text = text.split(secret).join(REDACTED);
17
+ }
18
+ for (const [pattern, replacement] of PATTERNS)
19
+ text = text.replace(pattern, replacement);
20
+ return text;
21
+ }
22
+ /**
23
+ * SDK logger that never writes credentials. The SDK's default logger dumps whole Axios
24
+ * errors on network failures, including the token request body with app_secret.
25
+ * `secrets` is read on every call so hot-reloaded config is honoured.
26
+ */
27
+ export function redactingLogger(secrets, sink = console) {
28
+ const write = (level, out) => (...msg) => {
29
+ const values = secrets();
30
+ out(`[${level}]:`, ...msg.map((item) => redact(item, values)));
31
+ };
32
+ // Mirror the SDK default: errors go to stdout (console.log), the rest to their console level.
33
+ return {
34
+ error: write("error", sink.log.bind(sink)),
35
+ warn: write("warn", sink.warn.bind(sink)),
36
+ info: write("info", sink.info.bind(sink)),
37
+ debug: write("debug", sink.debug.bind(sink)),
38
+ trace: write("trace", sink.trace.bind(sink)),
39
+ };
40
+ }
41
+ //# sourceMappingURL=redacting-logger.js.map