@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,31 @@
1
+ import { Hono } from "hono";
2
+ import { type SqliteEventStore } from "@codebridge/work-items";
3
+ import { type OutboundPublisher } from "./outbound-publishers.js";
4
+ import type { ApprovalService } from "@codebridge/policy";
5
+ import type { RunExecutor } from "@codebridge/run-executor";
6
+ /** 出站 API 依赖的最小 Bridge 能力面 */
7
+ export interface OutboundBridge {
8
+ setOutboundAlertStatus?(chatId: string, topicId: string, status: string, summary: string): Promise<void>;
9
+ sendOutboundFile(chatId: string, rawPath: string, topicId?: string): Promise<string>;
10
+ sendOutboundMarkdown(chatId: string, markdown: string, topicId?: string): Promise<void>;
11
+ sendOutboundMention(chatId: string, ref: string, text: string, topicId?: string): Promise<void>;
12
+ }
13
+ interface OutboundAppOptions {
14
+ publicPathPrefixes?: string[];
15
+ workItemStore?: SqliteEventStore;
16
+ publishers?: () => OutboundPublisher[];
17
+ }
18
+ /** 装配出站能力、兼容 TaskRecord API 和 Session-first API,共享同一个本地 Bearer Token。 */
19
+ export declare function createBridgeApp(bridge: OutboundBridge, token: string, workItemStore: SqliteEventStore, approvalService?: ApprovalService, executor?: RunExecutor, projectCatalogApp?: Hono, webWorkbenchApp?: Hono, sessionCatalogApp?: Hono, mcpApp?: Hono, skillApp?: Hono, publishers?: () => OutboundPublisher[]): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
20
+ /** Resolve only the current Run's persisted delivery; never infer a recipient from an ID prefix. */
21
+ export declare function resolveOutboundTarget(store: SqliteEventStore, runId: string): {
22
+ chatId: string;
23
+ topicId: string | undefined;
24
+ };
25
+ /**
26
+ * Bridge 本地出站 API:Agent 子进程内的 fcb 命令通过它把文件/消息发回飞书。
27
+ * 仅监听 127.0.0.1,Bearer 复用 runner token。
28
+ */
29
+ export declare function createOutboundApp(bridge: OutboundBridge, token: string, options?: OutboundAppOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
30
+ export {};
31
+ //# sourceMappingURL=outbound-api.d.ts.map
@@ -0,0 +1,184 @@
1
+ import { Hono } from "hono";
2
+ import { createWorkItemApp } from "./work-item-api.js";
3
+ import { OUTBOUND_ROUTES } from "./outbound-publishers.js";
4
+ /** 装配出站能力、兼容 TaskRecord API 和 Session-first API,共享同一个本地 Bearer Token。 */
5
+ export function createBridgeApp(bridge, token, workItemStore, approvalService, executor, projectCatalogApp, webWorkbenchApp, sessionCatalogApp, mcpApp, skillApp, publishers) {
6
+ const app = createOutboundApp(bridge, token, {
7
+ workItemStore,
8
+ publishers,
9
+ publicPathPrefixes: webWorkbenchApp ? ["/workbench"] : [],
10
+ });
11
+ app.route("/", createWorkItemApp(workItemStore, token, approvalService, executor));
12
+ if (sessionCatalogApp)
13
+ app.route("/", sessionCatalogApp);
14
+ if (mcpApp)
15
+ app.route("/", mcpApp);
16
+ if (skillApp)
17
+ app.route("/", skillApp);
18
+ if (projectCatalogApp)
19
+ app.route("/", projectCatalogApp);
20
+ if (webWorkbenchApp) {
21
+ app.route("/workbench", webWorkbenchApp);
22
+ app.route("/workbench/", webWorkbenchApp);
23
+ }
24
+ return app;
25
+ }
26
+ /** 把 /outbound/<name> 映射成路由名;不是已知出站路由时返回 undefined。 */
27
+ function outboundRouteOf(requestPath) {
28
+ const prefix = "/outbound/";
29
+ if (!requestPath.startsWith(prefix))
30
+ return undefined;
31
+ const name = requestPath.slice(prefix.length);
32
+ return OUTBOUND_ROUTES.includes(name) ? name : undefined;
33
+ }
34
+ /** Resolve only the current Run's persisted delivery; never infer a recipient from an ID prefix. */
35
+ export function resolveOutboundTarget(store, runId) {
36
+ const run = store.getRun(runId);
37
+ if (!run || run.status !== "running" || !run.turnId) {
38
+ throw new Error("outbound_active_run_required:请在当前 CodeBridge 任务内发送文件");
39
+ }
40
+ const deliveries = ["feishu", "telegram"].flatMap((channel) => store.listDeliveries(channel).filter((row) => row.runId === run.id && row.turnId === run.turnId)
41
+ .map((row) => ({ channel, conversationId: row.conversationId })));
42
+ const targets = [...new Map(deliveries.map((row) => [`${row.channel}:${row.conversationId}`, row])).values()];
43
+ if (targets.length !== 1) {
44
+ throw new Error("outbound_source_required:当前任务没有唯一的聊天来源,请从目标聊天窗口重新发起任务");
45
+ }
46
+ const target = targets[0];
47
+ const [chatId, topicId, extra] = target.conversationId.split("|");
48
+ if (extra !== undefined || !chatId || !(target.channel === "feishu"
49
+ ? /^oc_[A-Za-z0-9]+$/.test(chatId)
50
+ : /^telegram:-?\d+$/.test(chatId))) {
51
+ throw new Error("outbound_invalid_destination:任务来源不是有效的通道聊天 ID");
52
+ }
53
+ return { chatId, topicId: topicId || undefined };
54
+ }
55
+ /**
56
+ * Bridge 本地出站 API:Agent 子进程内的 fcb 命令通过它把文件/消息发回飞书。
57
+ * 仅监听 127.0.0.1,Bearer 复用 runner token。
58
+ */
59
+ export function createOutboundApp(bridge, token, options = {}) {
60
+ const app = new Hono();
61
+ const resolvedTargets = new WeakMap();
62
+ const publicPathPrefixes = options.publicPathPrefixes ?? [];
63
+ const publishers = options.publishers ?? (() => []);
64
+ app.use("*", async (c, next) => {
65
+ const isPublicPath = publicPathPrefixes.some((prefix) => c.req.path === prefix || c.req.path.startsWith(`${prefix}/`));
66
+ if (isPublicPath) {
67
+ await next();
68
+ return;
69
+ }
70
+ const auth = c.req.header("authorization");
71
+ if (auth === `Bearer ${token}`) {
72
+ await next();
73
+ return;
74
+ }
75
+ // 发布者凭据只认已知的 /outbound/<route>,且收件人只取配置里写死的那一个:
76
+ // 请求体给出的 chatId 依旧会被覆盖,发送方无法自己选收件人。
77
+ const route = outboundRouteOf(c.req.path);
78
+ const publisher = route
79
+ ? publishers().find((row) => auth === `Bearer ${row.token}`)
80
+ : undefined;
81
+ if (!publisher || !route) {
82
+ return c.json({ error: "unauthorized" }, 401);
83
+ }
84
+ if (!publisher.routes.includes(route)) {
85
+ return c.json({ error: `outbound_route_forbidden:${publisher.label} 未获授权发送 ${route}` }, 403);
86
+ }
87
+ resolvedTargets.set(c.req.raw, {
88
+ chatId: publisher.chatId,
89
+ topicId: publisher.topicId,
90
+ });
91
+ await next();
92
+ });
93
+ app.use("/outbound/*", async (c, next) => {
94
+ // 发布者的收件人已在鉴权时定死,不需要也不可能有 runId。
95
+ if (!options.workItemStore || resolvedTargets.has(c.req.raw)) {
96
+ await next();
97
+ return;
98
+ }
99
+ const body = await c.req.json().catch(() => null);
100
+ if (!body || typeof body.runId !== "string" || !body.runId) {
101
+ return c.json({ error: "outbound_run_required:请使用当前任务的 fcb,发送目标由 Bridge 自动解析" }, 400);
102
+ }
103
+ try {
104
+ const target = resolveOutboundTarget(options.workItemStore, body.runId);
105
+ resolvedTargets.set(c.req.raw, target);
106
+ }
107
+ catch (error) {
108
+ return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);
109
+ }
110
+ await next();
111
+ });
112
+ app.post("/outbound/alert-status", async (c) => {
113
+ // This route is deliberately absent from publisher routes: only an active Run can set a status.
114
+ const target = resolvedTargets.get(c.req.raw);
115
+ if (!options.workItemStore || !target?.topicId || !target.chatId.startsWith("oc_")) {
116
+ return c.json({ error: "alert_status_requires_feishu_run" }, 400);
117
+ }
118
+ const body = await c.req.json().catch(() => null);
119
+ if (typeof body?.status !== "string" || typeof body.summary !== "string")
120
+ return c.json({ error: "status and summary required" }, 400);
121
+ try {
122
+ if (!bridge.setOutboundAlertStatus)
123
+ throw new Error("alert_status_unavailable");
124
+ await bridge.setOutboundAlertStatus(target.chatId, target.topicId, body.status, body.summary);
125
+ return c.json({ ok: true });
126
+ }
127
+ catch (error) {
128
+ return c.json({ error: error instanceof Error ? error.message : String(error) }, 400);
129
+ }
130
+ });
131
+ app.post("/outbound/file", async (c) => {
132
+ const body = (await c.req.json().catch(() => null));
133
+ const target = resolvedTargets.get(c.req.raw);
134
+ if (body && target)
135
+ Object.assign(body, target);
136
+ if (!body?.chatId || !body?.path) {
137
+ return c.json({ error: "chatId 和 path 必填" }, 400);
138
+ }
139
+ try {
140
+ const fileName = await bridge.sendOutboundFile(body.chatId, body.path, body.topicId);
141
+ return c.json({ ok: true, fileName });
142
+ }
143
+ catch (err) {
144
+ const message = err instanceof Error ? err.message : String(err);
145
+ return c.json({ error: message }, 400);
146
+ }
147
+ });
148
+ app.post("/outbound/markdown", async (c) => {
149
+ const body = (await c.req.json().catch(() => null));
150
+ const target = resolvedTargets.get(c.req.raw);
151
+ if (body && target)
152
+ Object.assign(body, target);
153
+ if (!body?.chatId || !body?.markdown) {
154
+ return c.json({ error: "chatId 和 markdown 必填" }, 400);
155
+ }
156
+ try {
157
+ await bridge.sendOutboundMarkdown(body.chatId, body.markdown, body.topicId);
158
+ return c.json({ ok: true });
159
+ }
160
+ catch (err) {
161
+ const message = err instanceof Error ? err.message : String(err);
162
+ return c.json({ error: message }, 400);
163
+ }
164
+ });
165
+ app.post("/outbound/mention", async (c) => {
166
+ const body = (await c.req.json().catch(() => null));
167
+ const target = resolvedTargets.get(c.req.raw);
168
+ if (body && target)
169
+ Object.assign(body, target);
170
+ if (!body?.chatId || !body?.ref || !body?.text) {
171
+ return c.json({ error: "chatId、ref 和 text 必填" }, 400);
172
+ }
173
+ try {
174
+ await bridge.sendOutboundMention(body.chatId, body.ref, body.text, body.topicId);
175
+ return c.json({ ok: true });
176
+ }
177
+ catch (err) {
178
+ const message = err instanceof Error ? err.message : String(err);
179
+ return c.json({ error: message }, 400);
180
+ }
181
+ });
182
+ return app;
183
+ }
184
+ //# sourceMappingURL=outbound-api.js.map
@@ -0,0 +1,54 @@
1
+ /** 出站路由名,与 /outbound/<name> 一一对应。 */
2
+ export declare const OUTBOUND_ROUTES: readonly ["file", "markdown", "mention"];
3
+ export type OutboundRoute = (typeof OUTBOUND_ROUTES)[number];
4
+ /** 省略 routes 时的最小授权:能说话,不能外发文件。 */
5
+ export declare const DEFAULT_ROUTES: OutboundRoute[];
6
+ /**
7
+ * 出站发布者:本地定时任务一类的非 Agent 发送方。
8
+ *
9
+ * 它保证的是三件事:收件人在配置期由人写死、运行期任何发送方都改不了;
10
+ * 每条凭据只能用它被授权的那几个路由;以及 runner token 依旧必须带 runId,
11
+ * Agent 不会因为这条路径而被放行。
12
+ *
13
+ * 它不保证 Agent 永远拿不到该凭据:Agent 子进程与 Bridge 同一个系统用户,
14
+ * 能读文件就能读到它。0600 只挡其他用户。真正的隔离要靠沙箱,这里没有。
15
+ */
16
+ export interface OutboundPublisher {
17
+ label: string;
18
+ token: string;
19
+ chatId: string;
20
+ topicId?: string;
21
+ routes: OutboundRoute[];
22
+ }
23
+ export declare const PUBLISHERS_FILE = "publisher-tokens.json";
24
+ export declare function publishersPath(dataDir: string): string;
25
+ /**
26
+ * 读取 <dataDir>/publisher-tokens.json。文件缺失表示没有配置发布者;
27
+ * 文件存在但内容不合法时抛错,不把一条静默失效的凭据当成已生效。
28
+ */
29
+ export declare function loadOutboundPublishers(dataDir: string, runnerToken: string): OutboundPublisher[];
30
+ /** 签发一条新凭据;同名 label 视为轮换,旧 token 立即作废。 */
31
+ export declare function addPublisher(dataDir: string, runnerToken: string, entry: {
32
+ label: string;
33
+ chatId: string;
34
+ topicId?: string;
35
+ routes?: OutboundRoute[];
36
+ }): OutboundPublisher;
37
+ /** 列出已登记的发布者,永不返回 token 本身。 */
38
+ export declare function listPublishers(dataDir: string, runnerToken: string): Array<Omit<OutboundPublisher, "token">>;
39
+ /** 吊销一条凭据;返回是否真的删掉了。 */
40
+ export declare function revokePublisher(dataDir: string, runnerToken: string, label: string): boolean;
41
+ /**
42
+ * 按文件指纹热加载:签发或吊销后无需重启 Bridge,下一次请求即生效。
43
+ * 文件读坏时保留上一份可用凭据并上报一次,避免一个笔误就让投递全断。
44
+ */
45
+ export declare class OutboundPublisherStore {
46
+ private readonly dataDir;
47
+ private readonly runnerToken;
48
+ private readonly onError;
49
+ private cache;
50
+ private fingerprint;
51
+ constructor(dataDir: string, runnerToken: string, onError?: (error: Error) => void);
52
+ current(): OutboundPublisher[];
53
+ }
54
+ //# sourceMappingURL=outbound-publishers.d.ts.map
@@ -0,0 +1,213 @@
1
+ import crypto from "node:crypto";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ /** 出站路由名,与 /outbound/<name> 一一对应。 */
5
+ export const OUTBOUND_ROUTES = ["file", "markdown", "mention"];
6
+ /** 省略 routes 时的最小授权:能说话,不能外发文件。 */
7
+ export const DEFAULT_ROUTES = ["markdown", "mention"];
8
+ export const PUBLISHERS_FILE = "publisher-tokens.json";
9
+ const CHAT_ID_PATTERN = /^(oc_[A-Za-z0-9]+|telegram:-?\d+)$/;
10
+ const MIN_TOKEN_LENGTH = 24;
11
+ export function publishersPath(dataDir) {
12
+ return path.join(dataDir, PUBLISHERS_FILE);
13
+ }
14
+ function invalid(file, index, reason) {
15
+ return new Error(`${file} 第 ${index + 1} 条发布者${reason}`);
16
+ }
17
+ function parseRoutes(file, index, value) {
18
+ if (value === undefined)
19
+ return [...DEFAULT_ROUTES];
20
+ if (!Array.isArray(value) || value.length === 0) {
21
+ throw invalid(file, index, "的 routes 必须是非空数组");
22
+ }
23
+ for (const route of value) {
24
+ if (!OUTBOUND_ROUTES.includes(route)) {
25
+ throw invalid(file, index, `的 routes 含未知路由 ${JSON.stringify(route)}`);
26
+ }
27
+ }
28
+ return [...new Set(value)];
29
+ }
30
+ /**
31
+ * 读取 <dataDir>/publisher-tokens.json。文件缺失表示没有配置发布者;
32
+ * 文件存在但内容不合法时抛错,不把一条静默失效的凭据当成已生效。
33
+ */
34
+ export function loadOutboundPublishers(dataDir, runnerToken) {
35
+ const file = publishersPath(dataDir);
36
+ let raw;
37
+ try {
38
+ raw = fs.readFileSync(file, "utf8");
39
+ }
40
+ catch (error) {
41
+ if (error.code === "ENOENT")
42
+ return [];
43
+ throw error;
44
+ }
45
+ if ((fs.statSync(file).mode & 0o077) !== 0) {
46
+ throw new Error(`${file} 对同组或其他用户可读,请先 chmod 600`);
47
+ }
48
+ const entries = JSON.parse(raw);
49
+ if (!Array.isArray(entries))
50
+ throw new Error(`${file} 必须是发布者数组`);
51
+ const seen = new Set();
52
+ return entries.map((value, index) => {
53
+ const entry = (value ?? {});
54
+ if (typeof entry.label !== "string" || !entry.label.trim()) {
55
+ throw invalid(file, index, "缺少 label");
56
+ }
57
+ if (typeof entry.token !== "string" || entry.token.length < MIN_TOKEN_LENGTH) {
58
+ throw invalid(file, index, `的 token 少于 ${MIN_TOKEN_LENGTH} 位`);
59
+ }
60
+ if (entry.token === runnerToken) {
61
+ throw invalid(file, index, "不能复用 runner token,否则 Agent 也能拿到它");
62
+ }
63
+ if (seen.has(entry.token))
64
+ throw invalid(file, index, "的 token 与前面的重复");
65
+ seen.add(entry.token);
66
+ if (typeof entry.chatId !== "string" || !CHAT_ID_PATTERN.test(entry.chatId)) {
67
+ throw invalid(file, index, "的 chatId 不是有效的通道聊天 ID");
68
+ }
69
+ if (entry.topicId !== undefined && typeof entry.topicId !== "string") {
70
+ throw invalid(file, index, "的 topicId 必须是字符串");
71
+ }
72
+ return {
73
+ label: entry.label,
74
+ token: entry.token,
75
+ chatId: entry.chatId,
76
+ topicId: entry.topicId || undefined,
77
+ routes: parseRoutes(file, index, entry.routes),
78
+ };
79
+ });
80
+ }
81
+ const LOCK_STALE_MS = 60_000;
82
+ /** 等锁多久放弃;测试用环境变量调短,生产不设置即 5 秒。 */
83
+ function lockTimeoutMs() {
84
+ return Number(process.env.CODEBRIDGE_PUBLISHER_LOCK_TIMEOUT_MS ?? 5_000);
85
+ }
86
+ /**
87
+ * 串行化"读全量→改→整份写回",否则两个并发的 add 会互相吞掉对方新签的凭据。
88
+ * 锁文件带时间戳,进程崩溃留下的陈旧锁到点自动接管,不会把后续签发永久卡死。
89
+ */
90
+ function withPublisherLock(dataDir, action) {
91
+ const lock = `${publishersPath(dataDir)}.lock`;
92
+ fs.mkdirSync(path.dirname(lock), { recursive: true, mode: 0o700 });
93
+ const deadline = Date.now() + lockTimeoutMs();
94
+ let handle;
95
+ while (handle === undefined) {
96
+ try {
97
+ handle = fs.openSync(lock, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY, 0o600);
98
+ }
99
+ catch (error) {
100
+ if (error.code !== "EEXIST")
101
+ throw error;
102
+ const age = Date.now() - (fs.statSync(lock, { throwIfNoEntry: false })?.mtimeMs ?? Date.now());
103
+ if (age > LOCK_STALE_MS) {
104
+ fs.rmSync(lock, { force: true });
105
+ continue;
106
+ }
107
+ if (Date.now() > deadline) {
108
+ throw new Error(`${lock} 正被另一个进程占用,请稍后重试`);
109
+ }
110
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);
111
+ }
112
+ }
113
+ try {
114
+ return action();
115
+ }
116
+ finally {
117
+ fs.closeSync(handle);
118
+ fs.rmSync(lock, { force: true });
119
+ }
120
+ }
121
+ function writePublishers(dataDir, entries) {
122
+ const file = publishersPath(dataDir);
123
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
124
+ // 每个写入者用自己的临时名,免得并发写互相踩,也免得崩溃残留被下一个写入者接手。
125
+ const temporary = `${file}.${process.pid}.${crypto.randomBytes(4).toString("hex")}.tmp`;
126
+ const payload = entries.map((entry) => ({
127
+ label: entry.label,
128
+ token: entry.token,
129
+ chatId: entry.chatId,
130
+ ...(entry.topicId ? { topicId: entry.topicId } : {}),
131
+ routes: entry.routes,
132
+ }));
133
+ fs.writeFileSync(temporary, `${JSON.stringify(payload, null, 2)}\n`, { mode: 0o600 });
134
+ fs.chmodSync(temporary, 0o600);
135
+ fs.renameSync(temporary, file);
136
+ }
137
+ /** 签发一条新凭据;同名 label 视为轮换,旧 token 立即作废。 */
138
+ export function addPublisher(dataDir, runnerToken, entry) {
139
+ if (!entry.label.trim())
140
+ throw new Error("label 不能为空");
141
+ if (!CHAT_ID_PATTERN.test(entry.chatId))
142
+ throw new Error("chatId 不是有效的通道聊天 ID");
143
+ for (const route of entry.routes ?? []) {
144
+ if (!OUTBOUND_ROUTES.includes(route))
145
+ throw new Error(`未知路由 ${route}`);
146
+ }
147
+ const issued = {
148
+ label: entry.label,
149
+ token: crypto.randomBytes(24).toString("hex"),
150
+ chatId: entry.chatId,
151
+ topicId: entry.topicId || undefined,
152
+ routes: entry.routes?.length ? [...new Set(entry.routes)] : [...DEFAULT_ROUTES],
153
+ };
154
+ withPublisherLock(dataDir, () => {
155
+ const kept = loadOutboundPublishers(dataDir, runnerToken).filter((row) => row.label !== entry.label);
156
+ writePublishers(dataDir, [...kept, issued]);
157
+ });
158
+ return issued;
159
+ }
160
+ /** 列出已登记的发布者,永不返回 token 本身。 */
161
+ export function listPublishers(dataDir, runnerToken) {
162
+ return loadOutboundPublishers(dataDir, runnerToken).map(({ token: _token, ...rest }) => rest);
163
+ }
164
+ /** 吊销一条凭据;返回是否真的删掉了。 */
165
+ export function revokePublisher(dataDir, runnerToken, label) {
166
+ return withPublisherLock(dataDir, () => {
167
+ const entries = loadOutboundPublishers(dataDir, runnerToken);
168
+ const kept = entries.filter((row) => row.label !== label);
169
+ if (kept.length === entries.length)
170
+ return false;
171
+ writePublishers(dataDir, kept);
172
+ return true;
173
+ });
174
+ }
175
+ /**
176
+ * 按文件指纹热加载:签发或吊销后无需重启 Bridge,下一次请求即生效。
177
+ * 文件读坏时保留上一份可用凭据并上报一次,避免一个笔误就让投递全断。
178
+ */
179
+ export class OutboundPublisherStore {
180
+ dataDir;
181
+ runnerToken;
182
+ onError;
183
+ cache = [];
184
+ fingerprint;
185
+ constructor(dataDir, runnerToken, onError = () => { }) {
186
+ this.dataDir = dataDir;
187
+ this.runnerToken = runnerToken;
188
+ this.onError = onError;
189
+ }
190
+ current() {
191
+ let fingerprint = "";
192
+ try {
193
+ const stats = fs.statSync(publishersPath(this.dataDir));
194
+ fingerprint = `${stats.mtimeMs}:${stats.size}:${stats.ino}`;
195
+ }
196
+ catch (error) {
197
+ if (error.code !== "ENOENT") {
198
+ fingerprint = `unreadable:${String(error.code)}`;
199
+ }
200
+ }
201
+ if (fingerprint === this.fingerprint)
202
+ return this.cache;
203
+ this.fingerprint = fingerprint;
204
+ try {
205
+ this.cache = loadOutboundPublishers(this.dataDir, this.runnerToken);
206
+ }
207
+ catch (error) {
208
+ this.onError(error instanceof Error ? error : new Error(String(error)));
209
+ }
210
+ return this.cache;
211
+ }
212
+ }
213
+ //# sourceMappingURL=outbound-publishers.js.map
@@ -0,0 +1,4 @@
1
+ import { Hono } from "hono";
2
+ import type { ProjectCatalogGitRepository, ProjectCatalogStore, ProjectDiscovery } from "@codebridge/project-catalog";
3
+ export declare function createProjectCatalogApp(catalog: ProjectCatalogStore, discovery: ProjectDiscovery, token: string, gitRepository?: ProjectCatalogGitRepository): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
4
+ //# sourceMappingURL=project-api.d.ts.map
@@ -0,0 +1,161 @@
1
+ import { Hono } from "hono";
2
+ export function createProjectCatalogApp(catalog, discovery, token, gitRepository) {
3
+ const app = new Hono();
4
+ app.use("/v1/*", async (c, next) => {
5
+ if (c.req.header("authorization") !== `Bearer ${token}`) {
6
+ return c.json({ error: { code: "unauthorized", message: "未授权" } }, 401);
7
+ }
8
+ await next();
9
+ });
10
+ app.get("/v1/projects/candidates", (c) => c.json({ candidates: catalog.listCandidates().map(toApiCandidate) }));
11
+ app.get("/v1/projects", (c) => c.json({ projects: catalog.listProjects().map(toApiProject) }));
12
+ app.get("/v1/projects/drifts", (c) => {
13
+ const projectId = c.req.query("project_id");
14
+ return c.json({ drifts: catalog.listDrifts(projectId || undefined) });
15
+ });
16
+ app.post("/v1/projects/candidates/:candidate_id/proposals", async (c) => {
17
+ if (!gitRepository)
18
+ return c.json({ error: { code: "catalog_git_unavailable", message: "Project catalog Git 未配置" } }, 503);
19
+ const body = await c.req.json().catch(() => null);
20
+ if (!body || typeof body.branch !== "string" || !body.branch.trim()) {
21
+ return c.json({ error: { code: "invalid_catalog_proposal", message: "branch 必填" } }, 400);
22
+ }
23
+ try {
24
+ const projects = catalog.projectsForCandidate(c.req.param("candidate_id"));
25
+ return c.json(gitRepository.createProposal(projects, {
26
+ branch: body.branch,
27
+ message: typeof body.message === "string" ? body.message : undefined,
28
+ }), 201);
29
+ }
30
+ catch (error) {
31
+ const message = messageOf(error);
32
+ const code = message.includes("not found") ? "candidate_not_found" : "catalog_proposal_failed";
33
+ return c.json({ error: { code, message } }, code === "candidate_not_found" ? 404 : 409);
34
+ }
35
+ });
36
+ app.post("/v1/projects/catalog/sync", async (c) => {
37
+ if (!gitRepository)
38
+ return c.json({ error: { code: "catalog_git_unavailable", message: "Project catalog Git 未配置" } }, 503);
39
+ const body = await c.req.json().catch(() => null);
40
+ const ref = typeof body?.ref === "string" && body.ref.trim() ? body.ref : undefined;
41
+ try {
42
+ const revision = ref ?? gitRepository.baseRef;
43
+ const projects = gitRepository.readProjects(ref);
44
+ return c.json({ revision, projects: catalog.syncProjects(projects, revision).map(toApiProject) });
45
+ }
46
+ catch (error) {
47
+ return c.json({ error: { code: "catalog_sync_failed", message: messageOf(error) } }, 409);
48
+ }
49
+ });
50
+ app.get("/v1/projects/candidates/:candidate_id/diff", (c) => {
51
+ try {
52
+ return c.json(catalog.previewCandidate(c.req.param("candidate_id")));
53
+ }
54
+ catch (error) {
55
+ return c.json({ error: { code: "candidate_not_found", message: messageOf(error) } }, 404);
56
+ }
57
+ });
58
+ app.post("/v1/projects/candidates/:candidate_id/accept", (c) => {
59
+ try {
60
+ return c.json(toApiProject(catalog.acceptCandidate(c.req.param("candidate_id"))), 201);
61
+ }
62
+ catch (error) {
63
+ return c.json({ error: { code: "candidate_not_found", message: messageOf(error) } }, 404);
64
+ }
65
+ });
66
+ app.post("/v1/projects/drifts/:drift_id/resolve", (c) => {
67
+ const drift = catalog.resolveDrift(c.req.param("drift_id"));
68
+ if (!drift)
69
+ return c.json({ error: { code: "drift_not_found", message: "Project drift 不存在" } }, 404);
70
+ return c.json({ drift });
71
+ });
72
+ app.post("/v1/projects/drifts/:drift_id/apply", (c) => {
73
+ const project = catalog.applyDrift(c.req.param("drift_id"));
74
+ if (!project)
75
+ return c.json({ error: { code: "drift_not_found", message: "Project drift 不存在或已处理" } }, 404);
76
+ return c.json({ project: toApiProject(project) });
77
+ });
78
+ app.post("/v1/discovery/tasks", async (c) => {
79
+ const body = (await c.req.json().catch(() => null));
80
+ if (!body || typeof body.workspace_path !== "string" || !body.workspace_path.trim()) {
81
+ return c.json({ error: { code: "invalid_discovery", message: "workspace_path 必填" } }, 400);
82
+ }
83
+ const task = catalog.createDiscoveryTask({
84
+ workspacePath: body.workspace_path,
85
+ workItemId: typeof body.work_item_id === "string" ? body.work_item_id : null,
86
+ });
87
+ launchTask(task);
88
+ return c.json({ task_id: task.id, status: task.status }, 202);
89
+ });
90
+ app.get("/v1/discovery/tasks/:task_id", (c) => {
91
+ const task = catalog.getDiscoveryTask(c.req.param("task_id"));
92
+ if (!task)
93
+ return c.json({ error: { code: "task_not_found", message: "Discovery task 不存在" } }, 404);
94
+ return c.json(toApiTask(task));
95
+ });
96
+ for (const task of catalog.listDiscoveryTasks(["queued", "running"]))
97
+ launchTask(task);
98
+ return app;
99
+ function launchTask(task) {
100
+ catalog.updateDiscoveryTask(task.id, { status: "running", error: null });
101
+ void (async () => {
102
+ try {
103
+ const candidate = await discovery.observe(task.workspacePath, task.workItemId ?? undefined);
104
+ catalog.updateDiscoveryTask(task.id, { status: "succeeded", candidateId: candidate.id, error: null });
105
+ }
106
+ catch (error) {
107
+ catalog.updateDiscoveryTask(task.id, { status: "failed", error: messageOf(error) });
108
+ }
109
+ })();
110
+ }
111
+ }
112
+ function messageOf(error) {
113
+ return error instanceof Error ? error.message : String(error);
114
+ }
115
+ function toApiCandidate(candidate) {
116
+ return {
117
+ id: candidate.id,
118
+ project_id: candidate.projectId,
119
+ display_name: candidate.displayName,
120
+ repository_remote: candidate.repositoryRemote,
121
+ language: candidate.language,
122
+ deploy_service: candidate.deployService,
123
+ log_service: candidate.logService,
124
+ apm_service: candidate.apmService,
125
+ dependencies: candidate.dependencies ?? [],
126
+ confidence: candidate.confidence,
127
+ status: candidate.status,
128
+ evidence: candidate.evidence,
129
+ observed_at: candidate.observedAt,
130
+ };
131
+ }
132
+ function toApiTask(task) {
133
+ return {
134
+ task_id: task.id,
135
+ status: task.status,
136
+ workspace_path: task.workspacePath,
137
+ work_item_id: task.workItemId,
138
+ candidate_id: task.candidateId,
139
+ error: task.error,
140
+ created_at: task.createdAt,
141
+ updated_at: task.updatedAt,
142
+ };
143
+ }
144
+ function toApiProject(project) {
145
+ return {
146
+ id: project.id,
147
+ project_id: project.id,
148
+ display_name: project.displayName,
149
+ repository_remote: project.repositoryRemote,
150
+ language: project.language,
151
+ deploy_service: project.deployService,
152
+ log_service: project.logService,
153
+ apm_service: project.apmService,
154
+ dependencies: project.dependencies ?? [],
155
+ confidence: project.confidence,
156
+ status: project.status,
157
+ evidence: project.evidence,
158
+ registered_at: project.registeredAt,
159
+ };
160
+ }
161
+ //# sourceMappingURL=project-api.js.map
@@ -0,0 +1,13 @@
1
+ import { type SecretOptions } from "@codebridge/core";
2
+ export interface SecretMigration {
3
+ migrated: string[];
4
+ /** Field name -> why it was left as is (already a ref, missing, placeholder). */
5
+ skipped: Record<string, string>;
6
+ }
7
+ /**
8
+ * Move plaintext secrets from config.yaml into the OS keychain and replace them with
9
+ * keychain: refs. Each secret is read back before the file changes; the file is rewritten
10
+ * once, atomically, keeping comments and layout.
11
+ */
12
+ export declare function migrateConfigSecrets(configPath: string, options?: SecretOptions): SecretMigration;
13
+ //# sourceMappingURL=secrets-command.d.ts.map