@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,24 @@
1
+ import type { SessionCatalogStore } from "@codebridge/session-catalog";
2
+ import type { RunnerClient } from "@codebridge/runner-client";
3
+ import type { ProviderHistoryImportResult, SqliteEventStore } from "@codebridge/work-items";
4
+ export declare class ProviderHistoryImporter {
5
+ private readonly dependencies;
6
+ constructor(dependencies: {
7
+ store: SqliteEventStore;
8
+ catalog: SessionCatalogStore;
9
+ runner: RunnerClient;
10
+ defaultCwd?: string;
11
+ });
12
+ preview(sessionId: string): Promise<{
13
+ providerSessionId: string;
14
+ importedPosition: number;
15
+ providerPosition: number;
16
+ importableEvents: number;
17
+ nextDigest: string;
18
+ }>;
19
+ import(sessionId: string, idempotencyKey: string): Promise<ProviderHistoryImportResult>;
20
+ private bindTaskRecord;
21
+ private requireBoundSession;
22
+ private load;
23
+ }
24
+ //# sourceMappingURL=session-history-import.d.ts.map
@@ -0,0 +1,82 @@
1
+ import { createHash } from "node:crypto";
2
+ function digest(events, end = events.length) {
3
+ return `sha256:${createHash("sha256")
4
+ .update(JSON.stringify(events.slice(0, end)))
5
+ .digest("hex")}`;
6
+ }
7
+ export class ProviderHistoryImporter {
8
+ dependencies;
9
+ constructor(dependencies) {
10
+ this.dependencies = dependencies;
11
+ }
12
+ async preview(sessionId) {
13
+ const session = this.requireBoundSession(sessionId);
14
+ const history = await this.load(session);
15
+ const prior = this.dependencies.store.getProviderHistoryImport(session.id, session.providerSessionId);
16
+ if (prior
17
+ && digest(history, prior.importedPosition)
18
+ !== prior.providerDigest) {
19
+ throw new Error("provider_history_prefix_changed");
20
+ }
21
+ return {
22
+ providerSessionId: session.providerSessionId,
23
+ importedPosition: prior?.importedPosition ?? 0,
24
+ providerPosition: history.length,
25
+ importableEvents: history.length - (prior?.importedPosition ?? 0),
26
+ nextDigest: digest(history),
27
+ };
28
+ }
29
+ async import(sessionId, idempotencyKey) {
30
+ const namespace = `session:history-import:${sessionId}`;
31
+ const cached = this.dependencies.store.getIdempotencyResponse(namespace, idempotencyKey);
32
+ if (cached) {
33
+ this.bindTaskRecord(sessionId);
34
+ return cached;
35
+ }
36
+ const session = this.requireBoundSession(sessionId);
37
+ const history = await this.load(session);
38
+ const prior = this.dependencies.store.getProviderHistoryImport(session.id, session.providerSessionId);
39
+ const priorPosition = prior?.importedPosition ?? 0;
40
+ const priorDigest = digest(history, priorPosition);
41
+ if (prior && priorDigest !== prior.providerDigest) {
42
+ throw new Error("provider_history_prefix_changed");
43
+ }
44
+ const result = this.dependencies.store.importProviderHistory({
45
+ sessionId,
46
+ providerSessionId: session.providerSessionId,
47
+ priorPosition,
48
+ priorDigest,
49
+ nextDigest: digest(history),
50
+ events: history.slice(priorPosition),
51
+ idempotencyKey,
52
+ });
53
+ this.bindTaskRecord(sessionId);
54
+ return result;
55
+ }
56
+ bindTaskRecord(sessionId) {
57
+ const workItem = this.dependencies.store.getWorkItemBySessionId(sessionId);
58
+ if (!workItem) {
59
+ throw new Error("provider_history_work_item_missing");
60
+ }
61
+ if (this.dependencies.catalog.getSession(sessionId)?.taskRecordId
62
+ === workItem.id) {
63
+ return;
64
+ }
65
+ this.dependencies.catalog.updateSession(sessionId, {
66
+ taskRecordId: workItem.id,
67
+ });
68
+ }
69
+ requireBoundSession(sessionId) {
70
+ const session = this.dependencies.catalog.getSession(sessionId);
71
+ if (!session)
72
+ throw new Error("session_not_found");
73
+ if (!session.providerSessionId) {
74
+ throw new Error("provider_session_not_bound");
75
+ }
76
+ return session;
77
+ }
78
+ load(session) {
79
+ return this.dependencies.runner.loadSessionHistory(session.agentId, session.cwd ?? this.dependencies.defaultCwd ?? process.cwd(), session.providerSessionId, session.additionalDirectories);
80
+ }
81
+ }
82
+ //# sourceMappingURL=session-history-import.js.map
@@ -0,0 +1,19 @@
1
+ import type { CapabilityRegistry } from "@codebridge/policy";
2
+ import type { RunExecutor } from "@codebridge/run-executor";
3
+ import type { SessionCatalogStore } from "@codebridge/session-catalog";
4
+ import { type SessionCoordinator } from "@codebridge/session-coordinator";
5
+ import type { SqliteEventStore } from "@codebridge/work-items";
6
+ import type { Hono } from "hono";
7
+ export interface SessionRuntimeApiOptions {
8
+ catalog: SessionCatalogStore;
9
+ workItems: SqliteEventStore;
10
+ coordinator?: SessionCoordinator;
11
+ executor?: RunExecutor;
12
+ capabilities?: CapabilityRegistry;
13
+ channelOriginToken?: string;
14
+ }
15
+ export declare function registerSessionRuntimeCommandRoutes(app: Hono, options: SessionRuntimeApiOptions & {
16
+ coordinator: SessionCoordinator;
17
+ }): void;
18
+ export declare function registerSessionRuntimeReadRoutes(app: Hono, options: SessionRuntimeApiOptions): void;
19
+ //# sourceMappingURL=session-runtime-api.d.ts.map
@@ -0,0 +1,453 @@
1
+ import { SessionCommandError } from "@codebridge/session-coordinator";
2
+ import { streamSSE } from "hono/streaming";
3
+ import { randomUUID } from "node:crypto";
4
+ import { toApiRun, toApiSession, toApiSessionEvent, toApiSessionTurn, toApiTimeline, } from "./session-runtime-types.js";
5
+ export function registerSessionRuntimeCommandRoutes(app, options) {
6
+ app.post("/v1/sessions/:session_id/messages", async (c) => {
7
+ const session = options.catalog.getSession(c.req.param("session_id"));
8
+ if (!session)
9
+ return c.json({ error: "session_not_found" }, 404);
10
+ const key = c.req.header("idempotency-key");
11
+ if (!key)
12
+ return c.json({ error: "idempotency_key_required" }, 400);
13
+ const body = await c.req.json().catch(() => null);
14
+ if (!body || typeof body.message !== "string" || !body.message.trim()) {
15
+ return c.json({ error: "message_required" }, 400);
16
+ }
17
+ const attachments = parseAttachments(body.attachments);
18
+ if (!attachments)
19
+ return c.json({ error: "invalid_attachments" }, 400);
20
+ const dryRun = false;
21
+ const origin = options.channelOriginToken
22
+ && c.req.header("x-codebridge-channel-origin") === options.channelOriginToken
23
+ ? "channel" : "web";
24
+ const delivery = parseDelivery(body.delivery);
25
+ if (delivery === null) {
26
+ return c.json({ error: "invalid_delivery" }, 400);
27
+ }
28
+ try {
29
+ const result = options.coordinator.submitTurn({
30
+ sessionId: session.id,
31
+ idempotencyKey: key,
32
+ attachments,
33
+ message: {
34
+ text: body.message,
35
+ attachmentIds: [],
36
+ model: nullable(body.model, session.model),
37
+ effort: nullable(body.effort, session.effort),
38
+ permissionMode: nullable(body.permission_mode, session.permissionMode),
39
+ actorRef: origin === "web"
40
+ ? { channel: "web", id: "local" }
41
+ : channelActorRef(body.actor_ref),
42
+ executionKind: "agent",
43
+ plan: null,
44
+ },
45
+ workItem: {
46
+ title: body.message.slice(0, 80),
47
+ mode: "auto",
48
+ conversationId: `conv_${session.id.replace(/^sess_/, "")}`,
49
+ agentId: session.agentId,
50
+ workspaceScope: session.cwd ? [session.cwd] : [],
51
+ riskLevel: "read_only",
52
+ },
53
+ delivery,
54
+ });
55
+ options.catalog.updateSession(session.id, {
56
+ taskRecordId: result.workItemId,
57
+ model: result.turn.message.model,
58
+ effort: result.turn.message.effort,
59
+ permissionMode: result.turn.message.permissionMode,
60
+ title: session.title ?? body.message.slice(0, 80),
61
+ status: "active",
62
+ });
63
+ if (result.run) {
64
+ await observeExecution(options, result.run.id, dryRun, false);
65
+ }
66
+ return c.json(toSubmitReceipt(options, result), 202);
67
+ }
68
+ catch (error) {
69
+ return commandError(c, options, error);
70
+ }
71
+ });
72
+ app.get("/v1/sessions/:session_id/submissions/:idempotency_key", (c) => {
73
+ const result = options.workItems.getIdempotencyResponse(`session:message:${c.req.param("session_id")}`, c.req.param("idempotency_key"));
74
+ return result
75
+ ? c.json(toSubmitReceipt(options, result))
76
+ : c.json({ error: "submission_not_found" }, 404);
77
+ });
78
+ app.delete("/v1/sessions/:session_id/queue/:turn_id", (c) => {
79
+ const headers = commandHeaders(c);
80
+ if ("error" in headers)
81
+ return c.json({ error: headers.error }, headers.status);
82
+ try {
83
+ const result = options.coordinator.cancelQueuedTurn({
84
+ sessionId: c.req.param("session_id"),
85
+ turnId: c.req.param("turn_id"),
86
+ expectedVersion: headers.version,
87
+ idempotencyKey: headers.key,
88
+ });
89
+ return c.json({
90
+ turn: toApiSessionTurn(result.turn),
91
+ runtime: runtimeView(options, c.req.param("session_id")),
92
+ });
93
+ }
94
+ catch (error) {
95
+ return commandError(c, options, error);
96
+ }
97
+ });
98
+ app.post("/v1/sessions/:session_id/queue/resume", (c) => {
99
+ const headers = commandHeaders(c);
100
+ if ("error" in headers)
101
+ return c.json({ error: headers.error }, headers.status);
102
+ try {
103
+ const result = options.coordinator.resumeQueue({
104
+ sessionId: c.req.param("session_id"),
105
+ expectedRuntimeVersion: headers.version,
106
+ idempotencyKey: headers.key,
107
+ });
108
+ if (result.dispatched) {
109
+ observeExecution(options, result.dispatched.run.id);
110
+ }
111
+ return c.json({
112
+ runtime: runtimeView(options, c.req.param("session_id")),
113
+ });
114
+ }
115
+ catch (error) {
116
+ return commandError(c, options, error);
117
+ }
118
+ });
119
+ app.post("/v1/runs/:run_id/cancel", (c) => {
120
+ const headers = commandHeaders(c);
121
+ if ("error" in headers)
122
+ return c.json({ error: headers.error }, headers.status);
123
+ const run = options.workItems.getRun(c.req.param("run_id"));
124
+ if (!run?.sessionId)
125
+ return c.json({ error: "run_not_found" }, 404);
126
+ try {
127
+ const result = options.coordinator.requestRunCancellation({
128
+ sessionId: run.sessionId,
129
+ runId: run.id,
130
+ expectedRuntimeVersion: headers.version,
131
+ idempotencyKey: headers.key,
132
+ });
133
+ if (result.disposition === "interrupting") {
134
+ void options.executor?.cancelRunAndWait(run.id).catch(() => { });
135
+ }
136
+ return c.json({
137
+ disposition: result.disposition,
138
+ run: toApiRun(result.run, run.sessionId),
139
+ }, result.disposition === "interrupting" ? 202 : 200);
140
+ }
141
+ catch (error) {
142
+ return commandError(c, options, error);
143
+ }
144
+ });
145
+ app.post("/v1/sessions/:session_id/runs", (c) => c.json({
146
+ error: "run_creation_moved",
147
+ message: "POST /messages now creates or queues the Run atomically",
148
+ }, 410));
149
+ }
150
+ export function registerSessionRuntimeReadRoutes(app, options) {
151
+ app.get("/v1/sessions/:session_id", (c) => {
152
+ const session = options.catalog.getSession(c.req.param("session_id"));
153
+ if (!session)
154
+ return c.json({ error: "session_not_found" }, 404);
155
+ const runtime = options.workItems.getSessionRuntime(session.id);
156
+ const activeRun = runtime?.activeRunId
157
+ ? options.workItems.getRun(runtime.activeRunId)
158
+ : undefined;
159
+ const queue = options.workItems.listQueuedTurns(session.id, {
160
+ limit: 100,
161
+ });
162
+ const timeline = options.workItems.listTimelineTurns(session.id, {
163
+ limit: 50,
164
+ contentBudgetBytes: 1_048_576,
165
+ });
166
+ const workItem = options.workItems.getWorkItemBySessionId(session.id);
167
+ return c.json({
168
+ session: toApiSession({
169
+ ...session,
170
+ taskRecordId: session.taskRecordId ?? workItem?.id ?? null,
171
+ }),
172
+ runtime: {
173
+ active_run: activeRun ? toApiRun(activeRun, session.id) : null,
174
+ queue_state: runtime?.queueState ?? "ready",
175
+ queue_pause_reason: runtime?.queuePauseReason ?? null,
176
+ queue: {
177
+ turns: queue.turns.map(toApiSessionTurn),
178
+ total: queue.total,
179
+ next_cursor: queue.nextCursor,
180
+ },
181
+ version: runtime?.version ?? 1,
182
+ last_event_sequence: runtime?.lastEventSequence ?? 0,
183
+ },
184
+ timeline: toApiTimeline(timeline),
185
+ commands: options.workItems.listSessionCommands(session.id),
186
+ });
187
+ });
188
+ app.get("/v1/sessions/:session_id/timeline", (c) => {
189
+ if (!options.catalog.getSession(c.req.param("session_id"))) {
190
+ return c.json({ error: "session_not_found" }, 404);
191
+ }
192
+ return c.json(toApiTimeline(options.workItems.listTimelineTurns(c.req.param("session_id"), {
193
+ before: integerQuery(c.req.query("before")),
194
+ limit: integerQuery(c.req.query("limit")) ?? 50,
195
+ contentBudgetBytes: 1_048_576,
196
+ })));
197
+ });
198
+ app.get("/v1/sessions/:session_id/blocks/:block_id/segments", (c) => {
199
+ if (!options.catalog.getSession(c.req.param("session_id"))) {
200
+ return c.json({ error: "session_not_found" }, 404);
201
+ }
202
+ const page = options.workItems.listTimelineSegments(c.req.param("block_id"), {
203
+ after: integerQuery(c.req.query("after")),
204
+ limit: integerQuery(c.req.query("limit")) ?? 100,
205
+ });
206
+ return c.json({
207
+ segments: page.segments.map((segment) => ({
208
+ segment_id: segment.segmentId,
209
+ segment_index: segment.segmentIndex,
210
+ content: segment.content,
211
+ byte_length: segment.byteLength,
212
+ sealed: segment.sealed,
213
+ })),
214
+ next_cursor: page.nextCursor,
215
+ });
216
+ });
217
+ app.get("/v1/sessions/:session_id/queue", (c) => {
218
+ if (!options.catalog.getSession(c.req.param("session_id"))) {
219
+ return c.json({ error: "session_not_found" }, 404);
220
+ }
221
+ const page = options.workItems.listQueuedTurns(c.req.param("session_id"), {
222
+ afterPosition: integerQuery(c.req.query("after_position")),
223
+ limit: integerQuery(c.req.query("limit")) ?? 100,
224
+ });
225
+ return c.json({
226
+ turns: page.turns.map(toApiSessionTurn),
227
+ total: page.total,
228
+ next_cursor: page.nextCursor,
229
+ });
230
+ });
231
+ app.get("/v1/sessions/:session_id/events", (c) => {
232
+ const session = options.catalog.getSession(c.req.param("session_id"));
233
+ if (!session)
234
+ return c.json({ error: "session_not_found" }, 404);
235
+ let workItem = options.workItems.getWorkItemBySessionId(session.id)
236
+ ?? (session.taskRecordId
237
+ ? options.workItems.getWorkItem(session.taskRecordId)
238
+ : undefined);
239
+ const after = integerQuery(c.req.query("after_sequence")) ?? 0;
240
+ if (c.req.query("live") === "true") {
241
+ return streamSSE(c, async (stream) => {
242
+ let cursor = after;
243
+ let aborted = false;
244
+ stream.onAbort(() => { aborted = true; });
245
+ while (!aborted) {
246
+ workItem ??= options.workItems.getWorkItemBySessionId(session.id)
247
+ ?? (options.catalog.getSession(session.id)?.taskRecordId
248
+ ? options.workItems.getWorkItem(options.catalog.getSession(session.id).taskRecordId)
249
+ : undefined);
250
+ const candidates = workItem
251
+ ? options.workItems.listEventsPage(workItem.id, cursor, 500)
252
+ : [];
253
+ let bytes = 0;
254
+ let wrote = false;
255
+ for (const event of candidates) {
256
+ const data = JSON.stringify(toApiSessionEvent(event));
257
+ const size = Buffer.byteLength(data, "utf8");
258
+ if (wrote && bytes + size > 1_048_576)
259
+ break;
260
+ await stream.writeSSE({
261
+ id: String(event.sequence),
262
+ event: "session_event",
263
+ data,
264
+ });
265
+ cursor = event.sequence;
266
+ bytes += size;
267
+ wrote = true;
268
+ }
269
+ if (!wrote)
270
+ await stream.sleep(250);
271
+ }
272
+ });
273
+ }
274
+ if (!workItem) {
275
+ return c.json({
276
+ events: [],
277
+ next_sequence: after,
278
+ has_more: false,
279
+ });
280
+ }
281
+ const tail = integerQuery(c.req.query("tail"));
282
+ if (tail !== undefined) {
283
+ const events = options.workItems.listRecentEvents(workItem.id, Math.min(500, Math.max(1, tail)));
284
+ return c.json({
285
+ events: events.map(toApiSessionEvent),
286
+ next_sequence: events.at(-1)?.sequence ?? after,
287
+ has_more: false,
288
+ });
289
+ }
290
+ {
291
+ const requested = integerQuery(c.req.query("limit")) ?? 500;
292
+ const limit = Math.min(500, Math.max(1, requested));
293
+ const rows = options.workItems.listEventsPage(workItem.id, after, limit + 1);
294
+ const events = rows.slice(0, limit);
295
+ return c.json({
296
+ events: events.map(toApiSessionEvent),
297
+ next_sequence: events.at(-1)?.sequence ?? after,
298
+ has_more: rows.length > events.length,
299
+ });
300
+ }
301
+ });
302
+ }
303
+ function integerQuery(value) {
304
+ if (value === undefined || !/^-?\d+$/.test(value))
305
+ return undefined;
306
+ return Number(value);
307
+ }
308
+ function nullable(value, fallback) {
309
+ return value === undefined
310
+ ? fallback
311
+ : typeof value === "string"
312
+ ? value
313
+ : null;
314
+ }
315
+ function channelActorRef(value) {
316
+ if (!value || typeof value !== "object")
317
+ return undefined;
318
+ const actor = value;
319
+ if ((actor.channel !== "feishu" && actor.channel !== "telegram")
320
+ || typeof actor.id !== "string"
321
+ || !actor.id.trim()) {
322
+ return undefined;
323
+ }
324
+ return { channel: actor.channel, id: actor.id.trim() };
325
+ }
326
+ function parseDelivery(value) {
327
+ if (value === undefined)
328
+ return undefined;
329
+ if (!value || typeof value !== "object")
330
+ return null;
331
+ const delivery = value;
332
+ if (typeof delivery.channel !== "string"
333
+ || typeof delivery.conversation_id !== "string"
334
+ || typeof delivery.reply_to_message_id !== "string"
335
+ || typeof delivery.show_thinking !== "boolean") {
336
+ return null;
337
+ }
338
+ return {
339
+ channel: delivery.channel,
340
+ conversationId: delivery.conversation_id,
341
+ replyToMessageId: delivery.reply_to_message_id,
342
+ showThinking: delivery.show_thinking,
343
+ };
344
+ }
345
+ function parseAttachments(value) {
346
+ if (value === undefined)
347
+ return [];
348
+ if (!Array.isArray(value))
349
+ return null;
350
+ const result = [];
351
+ for (const item of value) {
352
+ if (!item || typeof item !== "object")
353
+ return null;
354
+ const attachment = item;
355
+ const name = attachment.name;
356
+ const mimeType = attachment.mime_type ?? attachment.mimeType;
357
+ const dataBase64 = attachment.data_base64 ?? attachment.dataBase64;
358
+ if (typeof name !== "string"
359
+ || typeof mimeType !== "string"
360
+ || typeof dataBase64 !== "string") {
361
+ return null;
362
+ }
363
+ result.push({
364
+ id: `att_${randomUUID().replaceAll("-", "")}`,
365
+ name,
366
+ mimeType,
367
+ dataBase64,
368
+ });
369
+ }
370
+ return result;
371
+ }
372
+ function runtimeView(options, sessionId) {
373
+ const runtime = options.workItems.getSessionRuntime(sessionId);
374
+ const activeRun = runtime?.activeRunId
375
+ ? options.workItems.getRun(runtime.activeRunId)
376
+ : undefined;
377
+ const queue = options.workItems.listQueuedTurns(sessionId, {
378
+ limit: 100,
379
+ });
380
+ return {
381
+ active_run: activeRun ? toApiRun(activeRun, sessionId) : null,
382
+ queue_state: runtime?.queueState ?? "ready",
383
+ queue_pause_reason: runtime?.queuePauseReason ?? null,
384
+ queue: {
385
+ turns: queue.turns.map(toApiSessionTurn),
386
+ total: queue.total,
387
+ next_cursor: queue.nextCursor,
388
+ },
389
+ version: runtime?.version ?? 1,
390
+ last_event_sequence: runtime?.lastEventSequence ?? 0,
391
+ };
392
+ }
393
+ function toSubmitReceipt(options, result) {
394
+ return {
395
+ acceptance: result.acceptance,
396
+ run_id: result.run?.id ?? null,
397
+ turn: toApiSessionTurn(result.turn),
398
+ runtime: runtimeView(options, result.turn.sessionId),
399
+ };
400
+ }
401
+ function commandHeaders(c) {
402
+ const key = c.req.header("idempotency-key");
403
+ if (!key)
404
+ return { error: "idempotency_key_required", status: 400 };
405
+ const raw = c.req.header("if-match");
406
+ if (!raw || !/^\d+$/.test(raw)) {
407
+ return { error: "if_match_required", status: 428 };
408
+ }
409
+ return { key, version: Number(raw) };
410
+ }
411
+ function commandError(c, options, error) {
412
+ if (!(error instanceof SessionCommandError))
413
+ throw error;
414
+ const payload = { error: error.code };
415
+ if (error.code === "turn_version_conflict") {
416
+ const turnId = c.req.param("turn_id");
417
+ payload.turn = turnId
418
+ ? options.workItems.getTurn(turnId)
419
+ : undefined;
420
+ }
421
+ if (error.code === "runtime_version_conflict") {
422
+ const runId = c.req.param("run_id");
423
+ const sessionId = c.req.param("session_id")
424
+ || (runId ? options.workItems.getRun(runId)?.sessionId : null);
425
+ if (sessionId)
426
+ payload.runtime = runtimeView(options, sessionId);
427
+ }
428
+ if (error.status === 404)
429
+ return c.json(payload, 404);
430
+ if (error.status === 409)
431
+ return c.json(payload, 409);
432
+ return c.json(payload, 422);
433
+ }
434
+ async function observeExecution(options, runId, dryRun, wait = false) {
435
+ const execution = options.executor?.execute(runId, undefined, { dryRun });
436
+ if (!execution)
437
+ return;
438
+ if (!wait) {
439
+ void execution.catch(() => { });
440
+ return;
441
+ }
442
+ try {
443
+ await execution;
444
+ }
445
+ catch (error) {
446
+ const run = options.workItems.getRun(runId);
447
+ if (run && ["failed", "succeeded", "cancelled", "interrupted"].includes(run.status)) {
448
+ return;
449
+ }
450
+ throw error;
451
+ }
452
+ }
453
+ //# sourceMappingURL=session-runtime-api.js.map
@@ -0,0 +1,21 @@
1
+ import type { SessionCatalogStore } from "@codebridge/session-catalog";
2
+ import type { SqliteEventStore } from "@codebridge/work-items";
3
+ export interface SessionRuntimeMigrationConflict {
4
+ sessionId: string;
5
+ activeRunIds: string[];
6
+ }
7
+ export interface SessionRuntimeMigrationResult {
8
+ migratedSessions: number;
9
+ projectedEvents: number;
10
+ conflicts: SessionRuntimeMigrationConflict[];
11
+ }
12
+ export declare class SessionRuntimeMigration {
13
+ private readonly catalog;
14
+ private readonly store;
15
+ constructor(catalog: SessionCatalogStore, store: SqliteEventStore);
16
+ run(options: {
17
+ batchSize: number;
18
+ maximumBatches?: number;
19
+ }): SessionRuntimeMigrationResult;
20
+ }
21
+ //# sourceMappingURL=session-runtime-migration.d.ts.map
@@ -0,0 +1,43 @@
1
+ export class SessionRuntimeMigration {
2
+ catalog;
3
+ store;
4
+ constructor(catalog, store) {
5
+ this.catalog = catalog;
6
+ this.store = store;
7
+ }
8
+ run(options) {
9
+ const bindings = this.catalog
10
+ .listSessions(undefined, { includeArchived: true })
11
+ .filter((session) => session.taskRecordId)
12
+ .map((session) => ({
13
+ sessionId: session.id,
14
+ workItemId: session.taskRecordId,
15
+ }));
16
+ const preview = this.store.previewSessionRuntimeMigration(bindings);
17
+ if (preview.conflicts.length) {
18
+ const error = new Error("session_runtime_migration_conflict");
19
+ error.conflicts = preview.conflicts;
20
+ throw error;
21
+ }
22
+ let projectedEvents = 0;
23
+ let batches = 0;
24
+ for (const binding of bindings) {
25
+ this.store.bindWorkItemToSession(binding.sessionId, binding.workItemId);
26
+ this.store.backfillRunTurns(binding.sessionId, binding.workItemId);
27
+ this.store.ensureRuntimeFromRuns(binding.sessionId);
28
+ while (batches < (options.maximumBatches ?? Number.POSITIVE_INFINITY)) {
29
+ const count = this.store.backfillSessionProjection(binding.sessionId, binding.workItemId, options.batchSize);
30
+ if (!count)
31
+ break;
32
+ projectedEvents += count;
33
+ batches += 1;
34
+ }
35
+ }
36
+ return {
37
+ migratedSessions: bindings.length,
38
+ projectedEvents,
39
+ conflicts: [],
40
+ };
41
+ }
42
+ }
43
+ //# sourceMappingURL=session-runtime-migration.js.map