@open-mercato/cezar 0.17.0-pr976.3708 → 0.17.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 (367) hide show
  1. package/README.md +4 -0
  2. package/dist/agent-config/validate.d.ts +2 -1
  3. package/dist/agent-config/validate.js.map +1 -1
  4. package/dist/api-origin.d.ts +0 -4
  5. package/dist/api-origin.js +0 -22
  6. package/dist/api-origin.js.map +1 -1
  7. package/dist/cockpit-address.d.ts +5 -0
  8. package/dist/cockpit-address.js +7 -0
  9. package/dist/cockpit-address.js.map +1 -1
  10. package/dist/contract/health.d.ts +30 -0
  11. package/dist/contract/index.d.ts +1 -0
  12. package/dist/contract/index.js +2370 -2054
  13. package/dist/contract/projects.d.ts +1 -0
  14. package/dist/contract/runs.d.ts +178 -2
  15. package/dist/contract/skills.d.ts +23 -0
  16. package/dist/contract/webhooks.d.ts +1136 -0
  17. package/dist/contract/workspace.d.ts +2 -0
  18. package/dist/core/agent-errors.d.ts +6 -0
  19. package/dist/core/agent-errors.js +13 -0
  20. package/dist/core/agent-errors.js.map +1 -1
  21. package/dist/core/agent-failure-class.d.ts +24 -0
  22. package/dist/core/agent-failure-class.js +99 -0
  23. package/dist/core/agent-failure-class.js.map +1 -0
  24. package/dist/core/agent-runner.d.ts +1 -1
  25. package/dist/core/claude-cli-runner.d.ts +2 -2
  26. package/dist/core/claude-cli-runner.js +17 -21
  27. package/dist/core/claude-cli-runner.js.map +1 -1
  28. package/dist/core/codex-app-server-runner.d.ts +1 -1
  29. package/dist/core/codex-app-server-runner.js +20 -23
  30. package/dist/core/codex-app-server-runner.js.map +1 -1
  31. package/dist/core/copilot-acp-runner.d.ts +1 -1
  32. package/dist/core/copilot-acp-runner.js +10 -10
  33. package/dist/core/copilot-acp-runner.js.map +1 -1
  34. package/dist/core/cursor-agent-runner.js +18 -22
  35. package/dist/core/cursor-agent-runner.js.map +1 -1
  36. package/dist/core/inactivity-deadline.d.ts +21 -0
  37. package/dist/core/inactivity-deadline.js +49 -0
  38. package/dist/core/inactivity-deadline.js.map +1 -0
  39. package/dist/core/junie-runner.d.ts +1 -1
  40. package/dist/core/junie-runner.js +16 -20
  41. package/dist/core/junie-runner.js.map +1 -1
  42. package/dist/core/opencode-server-runner.d.ts +2 -2
  43. package/dist/core/opencode-server-runner.js +23 -15
  44. package/dist/core/opencode-server-runner.js.map +1 -1
  45. package/dist/core/pi-runner.d.ts +1 -1
  46. package/dist/core/pi-runner.js +8 -10
  47. package/dist/core/pi-runner.js.map +1 -1
  48. package/dist/core/provider-auth.js +18 -6
  49. package/dist/core/provider-auth.js.map +1 -1
  50. package/dist/core/runner-factory.d.ts +2 -0
  51. package/dist/core/runner-factory.js +39 -0
  52. package/dist/core/runner-factory.js.map +1 -1
  53. package/dist/core/secret-redaction.js +38 -6
  54. package/dist/core/secret-redaction.js.map +1 -1
  55. package/dist/data-gitignore.d.ts +1 -1
  56. package/dist/data-gitignore.js +1 -0
  57. package/dist/data-gitignore.js.map +1 -1
  58. package/dist/disk-space.d.ts +38 -0
  59. package/dist/disk-space.js +113 -0
  60. package/dist/disk-space.js.map +1 -0
  61. package/dist/dispatch/prompts.js +1 -1
  62. package/dist/git-worktree.d.ts +2 -0
  63. package/dist/git-worktree.js +16 -0
  64. package/dist/git-worktree.js.map +1 -1
  65. package/dist/handoff.d.ts +2 -2
  66. package/dist/handoff.js +1 -1
  67. package/dist/index.js +24 -3
  68. package/dist/index.js.map +1 -1
  69. package/dist/pack-check.d.ts +10 -0
  70. package/dist/pack-check.js +7 -0
  71. package/dist/pack-check.js.map +1 -1
  72. package/dist/release/backport.d.ts +34 -0
  73. package/dist/release/backport.js +33 -0
  74. package/dist/release/backport.js.map +1 -0
  75. package/dist/runs/agent-error-telemetry.d.ts +5 -1
  76. package/dist/runs/agent-error-telemetry.js +17 -10
  77. package/dist/runs/agent-error-telemetry.js.map +1 -1
  78. package/dist/runs/failure-kind.d.ts +1 -1
  79. package/dist/runs/failure-kind.js +5 -8
  80. package/dist/runs/failure-kind.js.map +1 -1
  81. package/dist/runs/lifecycle.d.ts +55 -0
  82. package/dist/runs/lifecycle.js +24 -0
  83. package/dist/runs/lifecycle.js.map +1 -0
  84. package/dist/runs/retention.js +36 -4
  85. package/dist/runs/retention.js.map +1 -1
  86. package/dist/runs/store.d.ts +31 -0
  87. package/dist/runs/store.js +59 -5
  88. package/dist/runs/store.js.map +1 -1
  89. package/dist/server/capabilities.js +3 -0
  90. package/dist/server/capabilities.js.map +1 -1
  91. package/dist/server/disk-health.d.ts +11 -0
  92. package/dist/server/disk-health.js +26 -0
  93. package/dist/server/disk-health.js.map +1 -0
  94. package/dist/server/forge/github.d.ts +9 -1
  95. package/dist/server/forge/github.js +42 -3
  96. package/dist/server/forge/github.js.map +1 -1
  97. package/dist/server/message-receipts.d.ts +27 -0
  98. package/dist/server/message-receipts.js +54 -0
  99. package/dist/server/message-receipts.js.map +1 -0
  100. package/dist/server/project-context.d.ts +5 -0
  101. package/dist/server/project-context.js +35 -1
  102. package/dist/server/project-context.js.map +1 -1
  103. package/dist/server/server.d.ts +2744 -866
  104. package/dist/server/server.js +191 -148
  105. package/dist/server/server.js.map +1 -1
  106. package/dist/server/webhooks.d.ts +817 -0
  107. package/dist/server/webhooks.js +91 -0
  108. package/dist/server/webhooks.js.map +1 -0
  109. package/dist/server/worktree-lifecycle.d.ts +88 -88
  110. package/dist/startup-port.d.ts +12 -0
  111. package/dist/startup-port.js +33 -0
  112. package/dist/startup-port.js.map +1 -0
  113. package/dist/telemetry-service.json +1 -0
  114. package/dist/webhooks/admission.d.ts +360 -0
  115. package/dist/webhooks/admission.js +294 -0
  116. package/dist/webhooks/admission.js.map +1 -0
  117. package/dist/webhooks/coordinator.d.ts +39 -0
  118. package/dist/webhooks/coordinator.js +215 -0
  119. package/dist/webhooks/coordinator.js.map +1 -0
  120. package/dist/webhooks/destination.d.ts +24 -0
  121. package/dist/webhooks/destination.js +111 -0
  122. package/dist/webhooks/destination.js.map +1 -0
  123. package/dist/webhooks/discord.d.ts +4 -0
  124. package/dist/webhooks/discord.js +102 -0
  125. package/dist/webhooks/discord.js.map +1 -0
  126. package/dist/webhooks/endpoints.d.ts +201 -0
  127. package/dist/webhooks/endpoints.js +345 -0
  128. package/dist/webhooks/endpoints.js.map +1 -0
  129. package/dist/webhooks/history.d.ts +42 -0
  130. package/dist/webhooks/history.js +222 -0
  131. package/dist/webhooks/history.js.map +1 -0
  132. package/dist/webhooks/lifecycle.d.ts +34 -0
  133. package/dist/webhooks/lifecycle.js +60 -0
  134. package/dist/webhooks/lifecycle.js.map +1 -0
  135. package/dist/webhooks/limits.d.ts +19 -0
  136. package/dist/webhooks/limits.js +101 -0
  137. package/dist/webhooks/limits.js.map +1 -0
  138. package/dist/webhooks/links.d.ts +12 -0
  139. package/dist/webhooks/links.js +40 -0
  140. package/dist/webhooks/links.js.map +1 -0
  141. package/dist/webhooks/operations.d.ts +24 -0
  142. package/dist/webhooks/operations.js +128 -0
  143. package/dist/webhooks/operations.js.map +1 -0
  144. package/dist/webhooks/outbox.d.ts +37 -0
  145. package/dist/webhooks/outbox.js +221 -0
  146. package/dist/webhooks/outbox.js.map +1 -0
  147. package/dist/webhooks/ownership.d.ts +17 -0
  148. package/dist/webhooks/ownership.js +254 -0
  149. package/dist/webhooks/ownership.js.map +1 -0
  150. package/dist/webhooks/payload.d.ts +6 -0
  151. package/dist/webhooks/payload.js +112 -0
  152. package/dist/webhooks/payload.js.map +1 -0
  153. package/dist/webhooks/platform.d.ts +9 -0
  154. package/dist/webhooks/platform.js +12 -0
  155. package/dist/webhooks/platform.js.map +1 -0
  156. package/dist/webhooks/privacy.d.ts +4 -0
  157. package/dist/webhooks/privacy.js +43 -0
  158. package/dist/webhooks/privacy.js.map +1 -0
  159. package/dist/webhooks/process-identity.d.ts +36 -0
  160. package/dist/webhooks/process-identity.js +240 -0
  161. package/dist/webhooks/process-identity.js.map +1 -0
  162. package/dist/webhooks/scheduler.d.ts +10 -0
  163. package/dist/webhooks/scheduler.js +43 -0
  164. package/dist/webhooks/scheduler.js.map +1 -0
  165. package/dist/webhooks/service.d.ts +313 -0
  166. package/dist/webhooks/service.js +1005 -0
  167. package/dist/webhooks/service.js.map +1 -0
  168. package/dist/webhooks/signing.d.ts +3 -0
  169. package/dist/webhooks/signing.js +36 -0
  170. package/dist/webhooks/signing.js.map +1 -0
  171. package/dist/webhooks/slack.d.ts +4 -0
  172. package/dist/webhooks/slack.js +56 -0
  173. package/dist/webhooks/slack.js.map +1 -0
  174. package/dist/webhooks/source.d.ts +178 -0
  175. package/dist/webhooks/source.js +23 -0
  176. package/dist/webhooks/source.js.map +1 -0
  177. package/dist/webhooks/storage.d.ts +21 -0
  178. package/dist/webhooks/storage.js +202 -0
  179. package/dist/webhooks/storage.js.map +1 -0
  180. package/dist/webhooks/transport.d.ts +30 -0
  181. package/dist/webhooks/transport.js +235 -0
  182. package/dist/webhooks/transport.js.map +1 -0
  183. package/dist/workflows/completion-reason.d.ts +4 -0
  184. package/dist/workflows/completion-reason.js +39 -0
  185. package/dist/workflows/completion-reason.js.map +1 -0
  186. package/dist/workflows/queued-bounds.d.ts +31 -0
  187. package/dist/workflows/queued-bounds.js +81 -0
  188. package/dist/workflows/queued-bounds.js.map +1 -0
  189. package/dist/workflows/run.d.ts +113 -20
  190. package/dist/workflows/run.js +726 -191
  191. package/dist/workflows/run.js.map +1 -1
  192. package/dist/workspace/config.d.ts +8 -0
  193. package/dist/workspace/config.js +62 -19
  194. package/dist/workspace/config.js.map +1 -1
  195. package/dist/workspace/ui-state.d.ts +4 -2
  196. package/dist/workspace/ui-state.js +13 -9
  197. package/dist/workspace/ui-state.js.map +1 -1
  198. package/package.json +4 -3
  199. package/scripts/check-pack.mjs +2 -4
  200. package/scripts/mock-claude.mjs +30 -5
  201. package/scripts/webhooks-schema.mjs +5 -0
  202. package/web/dist/assets/23I4SOAX-B4MCXPfc.js +2 -0
  203. package/web/dist/assets/26H2HVXD-DnN7AaEY.js +2 -0
  204. package/web/dist/assets/2IZ5MNOH-CgfSuFFL.js +1 -0
  205. package/web/dist/assets/2P3CZEXH-kInGrvHu.js +2 -0
  206. package/web/dist/assets/3E5HRNYT-DLbBxF6y.js +5 -0
  207. package/web/dist/assets/3JIRLDUO-B9tVJ8E_.js +1 -0
  208. package/web/dist/assets/5MJ3UKSG-nDfsJSF7.js +2 -0
  209. package/web/dist/assets/5THPTBWS-Ce_hS451.js +1 -0
  210. package/web/dist/assets/7OAKGN26-t-mlpHkx.js +25 -0
  211. package/web/dist/assets/7WLXJQOR-D6QVYUu9.js +1 -0
  212. package/web/dist/assets/A255FCTW-Bx0Z-P1v.js +1 -0
  213. package/web/dist/assets/AM43MQ64-C_UmP8Ka.js +2 -0
  214. package/web/dist/assets/AOZTNTMC-Di2iVwCo.js +5 -0
  215. package/web/dist/assets/AQNLM6KG-CcWg0kGq.js +4 -0
  216. package/web/dist/assets/BNU2RHQB-M1l5nkNs.js +2 -0
  217. package/web/dist/assets/C5HTQT3I-B50g1XeK.js +4 -0
  218. package/web/dist/assets/CPKRWH5G-DHdVktma.js +12 -0
  219. package/web/dist/assets/CUVCMPQX-75g4RQep.js +1 -0
  220. package/web/dist/assets/D4V2MWCI-Bm34L6wL.js +1 -0
  221. package/web/dist/assets/DHKBVIA3-Db-JqVOb.js +1 -0
  222. package/web/dist/assets/DKTLEL5E-DciMwFJ1.js +1 -0
  223. package/web/dist/assets/DUZNPW7S-4AKJemkg.js +2 -0
  224. package/web/dist/assets/E3FWOBN4-AT8jzYgb.js +4 -0
  225. package/web/dist/assets/E65FQMJL-eiWd8F8c.js +1 -0
  226. package/web/dist/assets/FTXIJQGB-CggtIYAM.js +1 -0
  227. package/web/dist/assets/G3MDBVQH-BZmnMkFw.js +1 -0
  228. package/web/dist/assets/G3OATVW2-D5zJu3ib.js +8 -0
  229. package/web/dist/assets/GUJTEFZK-DPEFMf5Q.js +1 -0
  230. package/web/dist/assets/IHVFDU4A-pP0Mb5Iu.js +10 -0
  231. package/web/dist/assets/IV52FOAS-jWHN2JLM.js +5 -0
  232. package/web/dist/assets/JTJEEBDN-DZeTEWqk.js +2 -0
  233. package/web/dist/assets/K7FUICZ3-C9JebvoP.js +2 -0
  234. package/web/dist/assets/LHH2HHRB-DZSZGD4x.js +2 -0
  235. package/web/dist/assets/MSPQPZZY-DOCBMJ70.js +4 -0
  236. package/web/dist/assets/OB6ZFVKF-D6V5f56z.js +2 -0
  237. package/web/dist/assets/PLTZDMI2-DltbYIQQ.js +1 -0
  238. package/web/dist/assets/R7EPXMMD-Dk_RDmvY.js +5 -0
  239. package/web/dist/assets/RVARI57O-CgA1WoRv.js +1 -0
  240. package/web/dist/assets/SPBWZ4VS-8FnOEPzw.js +1 -0
  241. package/web/dist/assets/SR7OOV3Q-3uZPNU1G.js +4 -0
  242. package/web/dist/assets/STAXBNH4-C4N6ZLTR.js +2 -0
  243. package/web/dist/assets/SXFARSFO-DHdVQB4G.js +1 -0
  244. package/web/dist/assets/TC77ISAL-BgUbI3Of.js +2 -0
  245. package/web/dist/assets/TYIQQHVC-S2gy0AUp.js +13 -0
  246. package/web/dist/assets/TZUXETIT-C6qyTEYa.js +2 -0
  247. package/web/dist/assets/U7N72BGE-8vTdAst9.js +6 -0
  248. package/web/dist/assets/UFPIB6EZ-BVjLTP07.js +3 -0
  249. package/web/dist/assets/UO52YEYL-EHYBNpY5.js +3 -0
  250. package/web/dist/assets/VIK3ONSK-Cton0Rgg.js +2 -0
  251. package/web/dist/assets/VVVO4ZVP-CdFWI9EE.js +2 -0
  252. package/web/dist/assets/WRGXZO53-DYQ4OW92.js +3 -0
  253. package/web/dist/assets/X5SG7MGC-DtC_vaXe.js +2 -0
  254. package/web/dist/assets/XLHPVVFU-MQkW7HpM.js +2 -0
  255. package/web/dist/assets/XXYPNCD5-Ib-xj97c.js +5 -0
  256. package/web/dist/assets/Z6WRYFJC-C6TE3q4J.js +7 -0
  257. package/web/dist/assets/ZI2QNEGF-DwOKsV8B.js +8 -0
  258. package/web/dist/assets/{agent-task-pickers-CJAx53eR.js → agent-task-pickers-C_2o0KYX.js} +1 -1
  259. package/web/dist/assets/{alert-dialog-BugYooRk.js → alert-dialog-fzSWCIyG.js} +1 -1
  260. package/web/dist/assets/arrow-left-CpV00riO.js +1 -0
  261. package/web/dist/assets/{automation-format-Bxe-TVRX.js → automation-format-BgAhuFNq.js} +1 -1
  262. package/web/dist/assets/automations-route-Ca648Wyc.js +1 -0
  263. package/web/dist/assets/bundle-mjs-rHxsej31.js +1 -0
  264. package/web/dist/assets/button-vdGgKu1b.js +100 -0
  265. package/web/dist/assets/{centered-state-Cm8_dS47.js → centered-state-C1nDqaTs.js} +1 -1
  266. package/web/dist/assets/check-DA3yaTey.js +1 -0
  267. package/web/dist/assets/chevron-left-D1eW2pzs.js +1 -0
  268. package/web/dist/assets/chevron-right-DwqBinJp.js +1 -0
  269. package/web/dist/assets/{chunk-BO2N2NFS-CFvlB0rH.js → chunk-BO2N2NFS-Bde6epwZ.js} +4 -4
  270. package/web/dist/assets/circle-check-G0BDdNX3.js +1 -0
  271. package/web/dist/assets/clipboard-B9AGRj3s.js +1 -0
  272. package/web/dist/assets/{collapsible-BoDLSmkP.js → collapsible-Ci-k9Y0m.js} +1 -1
  273. package/web/dist/assets/{commit-list-C_l41PzR.js → commit-list-B8qutNJ9.js} +1 -1
  274. package/web/dist/assets/{compare-variants-Du6vJ7FF.js → compare-variants-CD-H9QV0.js} +1 -1
  275. package/web/dist/assets/dashboard-BuNIEyIc.js +44 -0
  276. package/web/dist/assets/diff-DdDwJ41q.js +3 -0
  277. package/web/dist/assets/{diff-view-D7b6T1ik.js → diff-view-D4eUaNtD.js} +4 -4
  278. package/web/dist/assets/{download-CHsOA7RH.js → download-C9cyRK4D.js} +1 -1
  279. package/web/dist/assets/facet-filter-BpaMiUU2.js +5 -0
  280. package/web/dist/assets/{file-Bu00nVUj.js → file-CcDDcqzK.js} +1 -1
  281. package/web/dist/assets/file-preview-DyqTWb0f.js +2 -0
  282. package/web/dist/assets/{file-text-CISqp5LY.js → file-text-C5N0APxx.js} +1 -1
  283. package/web/dist/assets/{git-pull-request-draft-D2Lm-pPz.js → git-pull-request-draft-Bqwhflhv.js} +1 -1
  284. package/web/dist/assets/git-tab-loading-BXSixY5p.js +1 -0
  285. package/web/dist/assets/git-toolbar-CB3F5Ztu.js +1 -0
  286. package/web/dist/assets/github-CjHl4MMe.js +1 -0
  287. package/web/dist/assets/{highlighted-body-OFNGDK62-CDHv8VkT.js → highlighted-body-OFNGDK62-k8gmH63p.js} +1 -1
  288. package/web/dist/assets/{host-usage-CRNpjHr0.js → host-usage-EIcPz8s9.js} +1 -1
  289. package/web/dist/assets/{icon-tooltip-BrV8FoZY.js → icon-tooltip-CCXhXgac.js} +1 -1
  290. package/web/dist/assets/index-C_k6g6fh.js +29 -0
  291. package/web/dist/assets/index-DvagaaKL.css +2 -0
  292. package/web/dist/assets/{input-6sILF4ZL.js → input-DXFchFdf.js} +1 -1
  293. package/web/dist/assets/layout-cards-DrC84hQa.js +1 -0
  294. package/web/dist/assets/lazy-DaFjwB-q.js +11 -0
  295. package/web/dist/assets/lib-xgA2N1t8.js +1 -0
  296. package/web/dist/assets/loader-circle-B2Lhi0xN.js +1 -0
  297. package/web/dist/assets/{markdown-DDUUmNxl.js → markdown-3VbTQcD0.js} +1 -1
  298. package/web/dist/assets/markdown-DxPHdOwB.js +4 -0
  299. package/web/dist/assets/mermaid-GHXKKRXX-CQo8vsdt.js +1 -0
  300. package/web/dist/assets/{message-square-CUcOsOeK.js → message-square-9JNzSy42.js} +1 -1
  301. package/web/dist/assets/plus-BHSN5Uog.js +1 -0
  302. package/web/dist/assets/preload-helper-Czpn1I53.js +1 -0
  303. package/web/dist/assets/{project-router-Uv5K_t7U.js → project-router-BzcW5R3O.js} +2 -2
  304. package/web/dist/assets/queries-XYjXpa8s.js +1 -0
  305. package/web/dist/assets/reference-chip-JX3G6Wkk.js +1 -0
  306. package/web/dist/assets/repo-git-CZTtXETi.js +1 -0
  307. package/web/dist/assets/{run-diff-CaQSFkcv.js → run-diff-C_s9tHfS.js} +2 -2
  308. package/web/dist/assets/{save-D8UGIAXq.js → save-B4O7rFCS.js} +1 -1
  309. package/web/dist/assets/{scroll-within-CEDDAUiO.js → scroll-within-DTBX-TR6.js} +1 -1
  310. package/web/dist/assets/{search-x-CG0S6SUu.js → search-x-CQPbQgV6.js} +1 -1
  311. package/web/dist/assets/{settings-2-ogt1zu3P.js → settings-2-CrmZbb_8.js} +1 -1
  312. package/web/dist/assets/skills-DXkSdyb8.js +1 -0
  313. package/web/dist/assets/{square-VAdlYQJn.js → square-DCg6avOT.js} +1 -1
  314. package/web/dist/assets/{tabs-BP29AtfS.js → tabs-Cb8MmIEQ.js} +1 -1
  315. package/web/dist/assets/{tag-4juVmU06.js → tag-CEWhwfVf.js} +1 -1
  316. package/web/dist/assets/task-commits-BruCWCkF.js +1 -0
  317. package/web/dist/assets/{task-graph-4GzVwwdu.js → task-graph-D_OLXJSk.js} +1 -1
  318. package/web/dist/assets/{task-notes-CCT7q8Fr.js → task-notes-DzOdZjqZ.js} +1 -1
  319. package/web/dist/assets/task-workspace-C5Conyc1.js +29 -0
  320. package/web/dist/assets/{terminal-DEjD4n5K.js → terminal-BVAfyHZI.js} +1 -1
  321. package/web/dist/assets/terminal-drawer-Dcg67RS8.js +3 -0
  322. package/web/dist/assets/{textarea-DJjpA11v.js → textarea-DywMDkfl.js} +1 -1
  323. package/web/dist/assets/{token-metrics-BJ1naBNS.js → token-metrics-BiFl2ovY.js} +1 -1
  324. package/web/dist/assets/{tooltip-BieGyrAz.js → tooltip-7suUQClM.js} +1 -1
  325. package/web/dist/assets/{tracker-DitRxloO.js → tracker-BFYcbTEV.js} +2 -2
  326. package/web/dist/assets/{triangle-alert-lwmk_SnN.js → triangle-alert-hMpQrXJS.js} +1 -1
  327. package/web/dist/assets/{upload-Dx8IzFX_.js → upload-Ddh5Fb-A.js} +1 -1
  328. package/web/dist/assets/use-now-BlhSvP80.js +1 -0
  329. package/web/dist/assets/{use-submit-shortcut-B-uDwQhP.js → use-submit-shortcut-BC7gmgDS.js} +1 -1
  330. package/web/dist/assets/workflow-graph-BljUjNdF.js +13 -0
  331. package/web/dist/assets/worktree-lifecycle-operation-psNUwGwT.js +18 -0
  332. package/web/dist/index.html +41 -41
  333. package/web/dist/assets/arrow-left-FG-BtI91.js +0 -1
  334. package/web/dist/assets/automations-route-BRN9qRg1.js +0 -1
  335. package/web/dist/assets/bundle-mjs-BT31bpU6.js +0 -1
  336. package/web/dist/assets/button-DFlig-3W.js +0 -100
  337. package/web/dist/assets/check-Bg7-Ecuy.js +0 -1
  338. package/web/dist/assets/chevron-left-Cd_qkrfl.js +0 -1
  339. package/web/dist/assets/chevron-right-7BUoNLSN.js +0 -1
  340. package/web/dist/assets/circle-check-D3dWBsEI.js +0 -1
  341. package/web/dist/assets/dashboard-BDtFQg4f.js +0 -44
  342. package/web/dist/assets/diff-DZjcij_W.js +0 -3
  343. package/web/dist/assets/diff-stat-BIAV32IP.js +0 -1
  344. package/web/dist/assets/facet-filter-BCQvQXmA.js +0 -5
  345. package/web/dist/assets/file-preview-B0UXYkxB.js +0 -2
  346. package/web/dist/assets/git-tab-loading-Dcf8fCoC.js +0 -1
  347. package/web/dist/assets/git-toolbar-aXyXLu2P.js +0 -1
  348. package/web/dist/assets/github-PjL79xgT.js +0 -1
  349. package/web/dist/assets/index-DvwYGTi3.css +0 -2
  350. package/web/dist/assets/index-DxwI2MZD.js +0 -25
  351. package/web/dist/assets/layout-cards-Det2whh-.js +0 -1
  352. package/web/dist/assets/lib-BQXq3kEf.js +0 -1
  353. package/web/dist/assets/loader-circle-DDkRpp8X.js +0 -1
  354. package/web/dist/assets/markdown-lc7gwiQQ.js +0 -4
  355. package/web/dist/assets/mermaid-GHXKKRXX-CbLTa2tM.js +0 -1
  356. package/web/dist/assets/plus-BqHBcC4w.js +0 -1
  357. package/web/dist/assets/queries-C09jaXiS.js +0 -1
  358. package/web/dist/assets/reference-chip-CHF-Sbml.js +0 -1
  359. package/web/dist/assets/repo-git-DT0rQqvz.js +0 -1
  360. package/web/dist/assets/skills-Cf8xEPei.js +0 -1
  361. package/web/dist/assets/task-commits-CyO2Q8jS.js +0 -1
  362. package/web/dist/assets/task-workspace-C6o0DzgB.js +0 -29
  363. package/web/dist/assets/terminal-drawer-TV4K7S4u.js +0 -3
  364. package/web/dist/assets/use-now-Cr9QvR5I.js +0 -1
  365. package/web/dist/assets/workflow-graph-g3f0xPwZ.js +0 -13
  366. package/web/dist/assets/worktree-lifecycle-operation-COUqhS7A.js +0 -18
  367. package/web/dist/assets/x-BrRT8S7Q.js +0 -1
@@ -0,0 +1,360 @@
1
+ import { z } from 'zod';
2
+ import { type WebhookHealth } from '../contract/index.js';
3
+ import { type WebhookSource } from './source.ts';
4
+ import { type PrivateReceiver } from './endpoints.ts';
5
+ export declare const deliveryRecordSchema: z.ZodObject<{
6
+ id: z.ZodString;
7
+ receiverId: z.ZodString;
8
+ deliveryRevision: z.ZodNumber;
9
+ admittedRevision: z.ZodNumber;
10
+ format: z.ZodOptional<z.ZodEnum<{
11
+ "cezar.json.v1": "cezar.json.v1";
12
+ "discord.v1": "discord.v1";
13
+ "slack.v1": "slack.v1";
14
+ }>>;
15
+ receiverName: z.ZodOptional<z.ZodString>;
16
+ profile: z.ZodEnum<{
17
+ minimal: "minimal";
18
+ standard: "standard";
19
+ }>;
20
+ eventType: z.ZodEnum<{
21
+ "task.attention_required": "task.attention_required";
22
+ "task.cancelled": "task.cancelled";
23
+ "task.failed": "task.failed";
24
+ "task.finished": "task.finished";
25
+ "task.review_ready": "task.review_ready";
26
+ "webhook.test": "webhook.test";
27
+ }>;
28
+ destination: z.ZodString;
29
+ createdAt: z.ZodISODateTime;
30
+ notBefore: z.ZodISODateTime;
31
+ expiresAt: z.ZodISODateTime;
32
+ status: z.ZodEnum<{
33
+ blocked_policy: "blocked_policy";
34
+ cancelled: "cancelled";
35
+ delivered: "delivered";
36
+ dropped: "dropped";
37
+ failed: "failed";
38
+ in_flight: "in_flight";
39
+ pending: "pending";
40
+ retrying: "retrying";
41
+ superseded: "superseded";
42
+ }>;
43
+ attempts: z.ZodNumber;
44
+ body: z.ZodOptional<z.ZodString>;
45
+ completedAt: z.ZodOptional<z.ZodISODateTime>;
46
+ reason: z.ZodOptional<z.ZodString>;
47
+ nextAttemptAt: z.ZodOptional<z.ZodISODateTime>;
48
+ httpStatus: z.ZodOptional<z.ZodNumber>;
49
+ response: z.ZodOptional<z.ZodString>;
50
+ claim: z.ZodOptional<z.ZodObject<{
51
+ token: z.ZodString;
52
+ revision: z.ZodNumber;
53
+ until: z.ZodISODateTime;
54
+ }, z.core.$strict>>;
55
+ frozen: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
56
+ disposition: z.ZodLiteral<"manual">;
57
+ }, z.core.$strict>, z.ZodObject<{
58
+ disposition: z.ZodLiteral<"scheduled">;
59
+ autoResumeAt: z.ZodISODateTime;
60
+ }, z.core.$strict>], "disposition">>;
61
+ historyPending: z.ZodOptional<z.ZodBoolean>;
62
+ resultEffects: z.ZodOptional<z.ZodObject<{
63
+ token: z.ZodString;
64
+ revision: z.ZodNumber;
65
+ at: z.ZodISODateTime;
66
+ outcome: z.ZodEnum<{
67
+ gone: "gone";
68
+ permanent: "permanent";
69
+ policy: "policy";
70
+ rate_limited: "rate_limited";
71
+ success: "success";
72
+ transient: "transient";
73
+ }>;
74
+ }, z.core.$strict>>;
75
+ operationId: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strict>;
77
+ export declare const operationReceiptSchema: z.ZodObject<{
78
+ operationId: z.ZodString;
79
+ fingerprint: z.ZodString;
80
+ receiverId: z.ZodString;
81
+ expectedRevision: z.ZodNumber;
82
+ deliveryId: z.ZodString;
83
+ action: z.ZodEnum<{
84
+ replay: "replay";
85
+ retry: "retry";
86
+ test: "test";
87
+ }>;
88
+ applied: z.ZodBoolean;
89
+ }, z.core.$strict>;
90
+ export type OperationReceipt = z.infer<typeof operationReceiptSchema>;
91
+ export declare const admissionSchema: z.ZodObject<{
92
+ version: z.ZodLiteral<1>;
93
+ id: z.ZodString;
94
+ createdAt: z.ZodISODateTime;
95
+ source: z.ZodOptional<z.ZodObject<{
96
+ trackerIssueUrl: z.ZodOptional<z.ZodURL>;
97
+ cockpitUrl: z.ZodOptional<z.ZodURL>;
98
+ version: z.ZodLiteral<1>;
99
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
100
+ id: z.ZodString;
101
+ sequence: z.ZodNumber;
102
+ installationId: z.ZodString;
103
+ projectId: z.ZodString;
104
+ previousStatus: z.ZodEnum<{
105
+ cancelled: "cancelled";
106
+ done: "done";
107
+ failed: "failed";
108
+ queued: "queued";
109
+ review: "review";
110
+ running: "running";
111
+ waiting: "waiting";
112
+ }>;
113
+ episodeId: z.ZodString;
114
+ type: z.ZodEnum<{
115
+ "task.attention_required": "task.attention_required";
116
+ "task.cancelled": "task.cancelled";
117
+ "task.failed": "task.failed";
118
+ "task.finished": "task.finished";
119
+ "task.review_ready": "task.review_ready";
120
+ }>;
121
+ occurredAt: z.ZodISODateTime;
122
+ mode: z.ZodEnum<{
123
+ hosted: "hosted";
124
+ local: "local";
125
+ }>;
126
+ snapshot: z.ZodObject<{
127
+ id: z.ZodString;
128
+ status: z.ZodEnum<{
129
+ cancelled: "cancelled";
130
+ done: "done";
131
+ failed: "failed";
132
+ queued: "queued";
133
+ review: "review";
134
+ running: "running";
135
+ waiting: "waiting";
136
+ }>;
137
+ archived: z.ZodBoolean;
138
+ continuation: z.ZodNumber;
139
+ title: z.ZodOptional<z.ZodString>;
140
+ titleOrigin: z.ZodOptional<z.ZodEnum<{
141
+ auto: "auto";
142
+ marker: "marker";
143
+ user: "user";
144
+ }>>;
145
+ attentionRequest: z.ZodOptional<z.ZodObject<{
146
+ requestId: z.ZodString;
147
+ askedAt: z.ZodISODateTime;
148
+ questions: z.ZodArray<z.ZodObject<{
149
+ question: z.ZodString;
150
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
151
+ label: z.ZodString;
152
+ description: z.ZodOptional<z.ZodString>;
153
+ }, z.core.$strict>>>;
154
+ }, z.core.$strict>>;
155
+ }, z.core.$strict>>;
156
+ completionReason: z.ZodOptional<z.ZodEnum<{
157
+ accepted: "accepted";
158
+ completed: "completed";
159
+ no_changes: "no_changes";
160
+ pr_opened: "pr_opened";
161
+ unknown: "unknown";
162
+ }>>;
163
+ autoResumeAt: z.ZodOptional<z.ZodISODateTime>;
164
+ finishedAt: z.ZodOptional<z.ZodISODateTime>;
165
+ startedAt: z.ZodOptional<z.ZodISODateTime>;
166
+ parentTaskId: z.ZodOptional<z.ZodString>;
167
+ rootTaskId: z.ZodOptional<z.ZodString>;
168
+ error: z.ZodOptional<z.ZodString>;
169
+ inputTokens: z.ZodOptional<z.ZodNumber>;
170
+ outputTokens: z.ZodOptional<z.ZodNumber>;
171
+ costUsd: z.ZodOptional<z.ZodNumber>;
172
+ automationTracker: z.ZodOptional<z.ZodObject<{
173
+ provider: z.ZodEnum<{
174
+ jira: "jira";
175
+ linear: "linear";
176
+ }>;
177
+ association: z.ZodOptional<z.ZodObject<{
178
+ kind: z.ZodEnum<{
179
+ jira: "jira";
180
+ linear: "linear";
181
+ }>;
182
+ source: z.ZodObject<{
183
+ id: z.ZodString;
184
+ webUrl: z.ZodURL;
185
+ }, z.core.$strict>;
186
+ externalId: z.ZodString;
187
+ externalName: z.ZodString;
188
+ connectionId: z.ZodOptional<z.ZodUUID>;
189
+ }, z.core.$strict>>;
190
+ key: z.ZodString;
191
+ url: z.ZodString;
192
+ }, z.core.$strict>>;
193
+ automationUrl: z.ZodOptional<z.ZodString>;
194
+ pullRequestUrl: z.ZodOptional<z.ZodString>;
195
+ referencedPullRequestUrl: z.ZodOptional<z.ZodString>;
196
+ referencedIssueUrl: z.ZodOptional<z.ZodString>;
197
+ }, z.core.$strict>;
198
+ }, z.core.$strict>>;
199
+ sourceSequence: z.ZodOptional<z.ZodNumber>;
200
+ deliveries: z.ZodArray<z.ZodObject<{
201
+ id: z.ZodString;
202
+ receiverId: z.ZodString;
203
+ deliveryRevision: z.ZodNumber;
204
+ admittedRevision: z.ZodNumber;
205
+ format: z.ZodOptional<z.ZodEnum<{
206
+ "cezar.json.v1": "cezar.json.v1";
207
+ "discord.v1": "discord.v1";
208
+ "slack.v1": "slack.v1";
209
+ }>>;
210
+ receiverName: z.ZodOptional<z.ZodString>;
211
+ profile: z.ZodEnum<{
212
+ minimal: "minimal";
213
+ standard: "standard";
214
+ }>;
215
+ eventType: z.ZodEnum<{
216
+ "task.attention_required": "task.attention_required";
217
+ "task.cancelled": "task.cancelled";
218
+ "task.failed": "task.failed";
219
+ "task.finished": "task.finished";
220
+ "task.review_ready": "task.review_ready";
221
+ "webhook.test": "webhook.test";
222
+ }>;
223
+ destination: z.ZodString;
224
+ createdAt: z.ZodISODateTime;
225
+ notBefore: z.ZodISODateTime;
226
+ expiresAt: z.ZodISODateTime;
227
+ status: z.ZodEnum<{
228
+ blocked_policy: "blocked_policy";
229
+ cancelled: "cancelled";
230
+ delivered: "delivered";
231
+ dropped: "dropped";
232
+ failed: "failed";
233
+ in_flight: "in_flight";
234
+ pending: "pending";
235
+ retrying: "retrying";
236
+ superseded: "superseded";
237
+ }>;
238
+ attempts: z.ZodNumber;
239
+ body: z.ZodOptional<z.ZodString>;
240
+ completedAt: z.ZodOptional<z.ZodISODateTime>;
241
+ reason: z.ZodOptional<z.ZodString>;
242
+ nextAttemptAt: z.ZodOptional<z.ZodISODateTime>;
243
+ httpStatus: z.ZodOptional<z.ZodNumber>;
244
+ response: z.ZodOptional<z.ZodString>;
245
+ claim: z.ZodOptional<z.ZodObject<{
246
+ token: z.ZodString;
247
+ revision: z.ZodNumber;
248
+ until: z.ZodISODateTime;
249
+ }, z.core.$strict>>;
250
+ frozen: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
251
+ disposition: z.ZodLiteral<"manual">;
252
+ }, z.core.$strict>, z.ZodObject<{
253
+ disposition: z.ZodLiteral<"scheduled">;
254
+ autoResumeAt: z.ZodISODateTime;
255
+ }, z.core.$strict>], "disposition">>;
256
+ historyPending: z.ZodOptional<z.ZodBoolean>;
257
+ resultEffects: z.ZodOptional<z.ZodObject<{
258
+ token: z.ZodString;
259
+ revision: z.ZodNumber;
260
+ at: z.ZodISODateTime;
261
+ outcome: z.ZodEnum<{
262
+ gone: "gone";
263
+ permanent: "permanent";
264
+ policy: "policy";
265
+ rate_limited: "rate_limited";
266
+ success: "success";
267
+ transient: "transient";
268
+ }>;
269
+ }, z.core.$strict>>;
270
+ operationId: z.ZodOptional<z.ZodString>;
271
+ }, z.core.$strict>>;
272
+ control: z.ZodBoolean;
273
+ taskId: z.ZodOptional<z.ZodString>;
274
+ capacityNeed: z.ZodOptional<z.ZodObject<{
275
+ retainedBytes: z.ZodNumber;
276
+ retainedObjects: z.ZodNumber;
277
+ pendingBytes: z.ZodNumber;
278
+ pendingCount: z.ZodNumber;
279
+ fileBytes: z.ZodOptional<z.ZodNumber>;
280
+ }, z.core.$strict>>;
281
+ decision: z.ZodOptional<z.ZodEnum<{
282
+ capacity: "capacity";
283
+ empty: "empty";
284
+ expired: "expired";
285
+ pending_capacity: "pending_capacity";
286
+ retained_capacity: "retained_capacity";
287
+ }>>;
288
+ operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
289
+ operationId: z.ZodString;
290
+ fingerprint: z.ZodString;
291
+ receiverId: z.ZodString;
292
+ expectedRevision: z.ZodNumber;
293
+ deliveryId: z.ZodString;
294
+ action: z.ZodEnum<{
295
+ replay: "replay";
296
+ retry: "retry";
297
+ test: "test";
298
+ }>;
299
+ applied: z.ZodBoolean;
300
+ }, z.core.$strict>>>;
301
+ }, z.core.$strict>;
302
+ export type DeliveryRecord = z.infer<typeof deliveryRecordSchema>;
303
+ export type Admission = z.infer<typeof admissionSchema>;
304
+ export declare const terminalDelivery: (status: DeliveryRecord['status']) => boolean;
305
+ /** The visible result lifetime belongs to a cycle, never to its replay chain. */
306
+ export declare const historyVisible: (delivery: {
307
+ completedAt?: string;
308
+ }, now: number) => boolean;
309
+ export interface AdmissionLimits {
310
+ retainedBytes: number;
311
+ retainedObjects: number;
312
+ controlBytes: number;
313
+ controlObjects: number;
314
+ pendingBytes: number;
315
+ pendingCount: number;
316
+ }
317
+ interface Dependencies {
318
+ now(): number;
319
+ limits?: Partial<AdmissionLimits>;
320
+ repository?: string;
321
+ secrets?: () => readonly string[];
322
+ assertOwner?: () => void;
323
+ /** Runs once, before the first unreadable admission is moved aside: the caller makes its safe reset durable first. */
324
+ beforeQuarantine?: () => Promise<void>;
325
+ }
326
+ export declare class AdmissionRepository {
327
+ private readonly directory;
328
+ private readonly deps;
329
+ private records;
330
+ private usage;
331
+ private account;
332
+ /** The single-record budget excludes metadata already reserved by account(). Physical
333
+ * bytes remain bounded by the aggregate retained/control limits (including metadata).
334
+ * Charging deferred bodies here prevents failure rendering from discovering a full file.
335
+ */
336
+ private fileBytes;
337
+ private charge;
338
+ private readonly limits;
339
+ private constructor();
340
+ static open(root: string, deps: Dependencies): Promise<AdmissionRepository>;
341
+ private quarantinedCount;
342
+ /** Unreadable admissions moved aside by this open. */
343
+ get quarantined(): number;
344
+ /** Bounded by the repository's load limits; only dirty metadata is republished. */
345
+ clearLegacyResponses(): Promise<void>;
346
+ get(id: string): Admission | undefined;
347
+ all(): Admission[];
348
+ saturation(): NonNullable<WebhookHealth['saturation']>;
349
+ private controlBlocked;
350
+ private fits;
351
+ /** One owner mutation queue must serialize admission, claims, updates and retention. */
352
+ admit(source: WebhookSource, receivers: readonly PrivateReceiver[]): Promise<Admission | undefined>;
353
+ update(id: string, mutate: (record: Admission) => void): Promise<Admission>;
354
+ insert(value: Admission): Promise<Admission>;
355
+ private save;
356
+ /** After durable source compaction, expire each settled payload independently of its history. */
357
+ prune(compactedThrough: number): Promise<void>;
358
+ private remove;
359
+ }
360
+ export {};
@@ -0,0 +1,294 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdir, readdir, rename, rm } from 'node:fs/promises';
3
+ import { join } from 'node:path';
4
+ import { z } from 'zod';
5
+ import { webhookFormatSchema, webhookDeliveryStatusSchema, webhookEventTypeSchema, webhookProfileSchema } from '../contract/index.js';
6
+ import { webhookSourceSchema } from './source.js';
7
+ import { WebhookStateError } from './endpoints.js';
8
+ import { selected } from './lifecycle.js';
9
+ import { renderPayload } from './payload.js';
10
+ import { maskDestination } from './destination.js';
11
+ import { assertNoSymlink, atomicWrite, readState, statePath, StateIntegrityError, syncDirectory } from './storage.js';
12
+ const time = z.iso.datetime();
13
+ export const deliveryRecordSchema = z.strictObject({
14
+ id: z.string().uuid(), receiverId: z.string().uuid(), deliveryRevision: z.number().int().positive(), admittedRevision: z.number().int().positive(),
15
+ format: webhookFormatSchema.optional(), receiverName: z.string().max(100).optional(),
16
+ profile: webhookProfileSchema, eventType: webhookEventTypeSchema, destination: z.string().max(300),
17
+ createdAt: time, notBefore: time, expiresAt: time, status: webhookDeliveryStatusSchema, attempts: z.number().int().nonnegative(),
18
+ body: z.string().max(65536).optional(), completedAt: time.optional(), reason: z.string().max(500).optional(), nextAttemptAt: time.optional(),
19
+ httpStatus: z.number().int().min(100).max(599).optional(), response: z.string().max(4096).optional(),
20
+ claim: z.strictObject({ token: z.string().uuid(), revision: z.number().int().positive(), until: time }).optional(),
21
+ frozen: z.discriminatedUnion('disposition', [z.strictObject({ disposition: z.literal('manual') }), z.strictObject({ disposition: z.literal('scheduled'), autoResumeAt: time })]).optional(),
22
+ historyPending: z.boolean().optional(),
23
+ resultEffects: z.strictObject({ token: z.string().uuid(), revision: z.number().int().positive(), at: time,
24
+ outcome: z.enum(['success', 'transient', 'permanent', 'gone', 'rate_limited', 'policy']),
25
+ }).optional(),
26
+ operationId: z.string().max(128).optional(),
27
+ });
28
+ export const operationReceiptSchema = z.strictObject({ operationId: z.string().max(128), fingerprint: z.string().max(1024), receiverId: z.string().uuid(), expectedRevision: z.number().int().positive(), deliveryId: z.string().uuid(), action: z.enum(['test', 'retry', 'replay']), applied: z.boolean() });
29
+ export const admissionSchema = z.strictObject({
30
+ version: z.literal(1), id: z.string().regex(/^evt_[0-9a-f-]{36}$/), createdAt: time,
31
+ source: webhookSourceSchema.optional(), sourceSequence: z.number().int().positive().optional(), deliveries: z.array(deliveryRecordSchema), control: z.boolean(),
32
+ taskId: z.string().max(128).optional(),
33
+ capacityNeed: z.strictObject({ retainedBytes: z.number().nonnegative(), retainedObjects: z.number().nonnegative(), pendingBytes: z.number().nonnegative(), pendingCount: z.number().nonnegative(), fileBytes: z.number().nonnegative().optional() }).optional(),
34
+ decision: z.enum(['empty', 'expired', 'capacity', 'pending_capacity', 'retained_capacity']).optional(), operations: z.array(operationReceiptSchema).optional(),
35
+ });
36
+ const DELIVERY_METADATA_BYTES = 8192;
37
+ const ADMISSION_PAYLOAD_BYTES = 8 * 1024 * 1024;
38
+ const DEFERRED_BODY_BYTES = 131074;
39
+ const metadataBytes = (delivery) => Buffer.byteLength(JSON.stringify({ ...delivery, body: undefined }));
40
+ export const terminalDelivery = (status) => ['delivered', 'failed', 'superseded', 'cancelled', 'dropped'].includes(status);
41
+ /** The visible result lifetime belongs to a cycle, never to its replay chain. */
42
+ export const historyVisible = (delivery, now) => !delivery.completedAt || Date.parse(delivery.completedAt) + 30 * 86400000 > now;
43
+ const defaults = { retainedBytes: 128 * 1024 * 1024, retainedObjects: 50000, controlBytes: 4 * 1024 * 1024, controlObjects: 5000, pendingBytes: 50 * 1024 * 1024, pendingCount: 10000 };
44
+ const ADMISSION_FILE = /^evt_[0-9a-f-]{36}\.json$/;
45
+ /** A decision that selected nobody: once its source is compacted away, nothing can re-evaluate it. */
46
+ const emptyDecision = (record) => record.control && !record.deliveries.length && !record.operations?.length && (record.decision === 'empty' || record.decision === 'expired');
47
+ export class AdmissionRepository {
48
+ directory;
49
+ deps;
50
+ records = new Map();
51
+ usage = { retainedBytes: 0, retainedObjects: 0, controlBytes: 0, controlObjects: 0, pendingBytes: 0, pendingCount: 0 };
52
+ account(record) {
53
+ let bytes = Buffer.byteLength(JSON.stringify(record)) + 1, pendingBytes = 0, pendingCount = 0;
54
+ if (!record.control)
55
+ for (const delivery of record.deliveries) {
56
+ // Reserved metadata covers claims, failure diagnostics and terminal state even at saturation.
57
+ // A terminal failure can never render a deferred body, including after payload expiry.
58
+ bytes += Math.max(0, DELIVERY_METADATA_BYTES - metadataBytes(delivery));
59
+ if (!delivery.body && delivery.eventType === 'task.failed' && !terminalDelivery(delivery.status))
60
+ bytes += DEFERRED_BODY_BYTES;
61
+ }
62
+ for (const delivery of record.deliveries)
63
+ if (!terminalDelivery(delivery.status)) {
64
+ pendingCount++;
65
+ pendingBytes += delivery.body ? Buffer.byteLength(delivery.body) : 65536;
66
+ }
67
+ const objects = 1 + record.deliveries.length + (record.operations?.length ?? 0);
68
+ return { retainedBytes: record.control ? 0 : bytes, retainedObjects: record.control ? 0 : objects,
69
+ controlBytes: record.control ? bytes : 0, controlObjects: record.control ? objects : 0, pendingBytes, pendingCount };
70
+ }
71
+ /** The single-record budget excludes metadata already reserved by account(). Physical
72
+ * bytes remain bounded by the aggregate retained/control limits (including metadata).
73
+ * Charging deferred bodies here prevents failure rendering from discovering a full file.
74
+ */
75
+ fileBytes(record) {
76
+ let bytes = Buffer.byteLength(JSON.stringify(record)) + 1;
77
+ if (!record.control)
78
+ for (const delivery of record.deliveries) {
79
+ bytes -= metadataBytes(delivery);
80
+ if (!delivery.body && delivery.eventType === 'task.failed' && !terminalDelivery(delivery.status))
81
+ bytes += DEFERRED_BODY_BYTES;
82
+ }
83
+ return bytes;
84
+ }
85
+ charge(record, sign) {
86
+ const cost = this.account(record);
87
+ for (const key of Object.keys(cost))
88
+ this.usage[key] += sign * cost[key];
89
+ }
90
+ limits;
91
+ constructor(directory, deps) {
92
+ this.directory = directory;
93
+ this.deps = deps;
94
+ this.limits = { ...defaults, ...deps.limits };
95
+ }
96
+ static async open(root, deps) {
97
+ const directory = join(root, 'events');
98
+ assertNoSymlink(directory);
99
+ await mkdir(directory, { recursive: true, mode: 0o700 });
100
+ const repository = new AdmissionRepository(directory, deps);
101
+ // Anything else here (a .DS_Store, an editor backup, an earlier quarantine, an interrupted
102
+ // *.tmp that cleanupInterruptedWrites owns) is not an admission and must never brick the project.
103
+ const names = (await readdir(directory)).filter(name => ADMISSION_FILE.test(name));
104
+ if (names.length > repository.limits.retainedObjects + repository.limits.controlObjects)
105
+ throw new Error('Webhook admissions exceed object limit');
106
+ for (const name of names) {
107
+ const admission = await readState(directory, name, admissionSchema).catch(error => {
108
+ if (error instanceof StateIntegrityError)
109
+ return null;
110
+ throw error;
111
+ });
112
+ if (admission === undefined)
113
+ continue;
114
+ if (admission && name === `${admission.id}.json`) {
115
+ repository.records.set(admission.id, admission);
116
+ repository.charge(admission, 1);
117
+ continue;
118
+ }
119
+ // Lost admission integrity follows the spec's safe reset, which the caller makes durable
120
+ // BEFORE the evidence moves: a crash in between can never forget that a reset is owed.
121
+ // The bytes are kept beside the original for inspection, as history quarantines do.
122
+ if (!repository.quarantinedCount)
123
+ await deps.beforeQuarantine?.();
124
+ const quarantine = statePath(directory, `${name}.corrupt-${randomUUID()}`);
125
+ deps.assertOwner?.();
126
+ await rename(statePath(directory, name), quarantine);
127
+ repository.quarantinedCount++;
128
+ console.warn(`Webhook admission ${name} was unreadable and has been quarantined as ${quarantine}; receivers require activation.`);
129
+ }
130
+ if (repository.quarantinedCount)
131
+ await syncDirectory(directory);
132
+ if (Object.keys(repository.usage).some(key => repository.usage[key] > repository.limits[key]))
133
+ throw new Error('Webhook retained capacity exceeded');
134
+ return repository;
135
+ }
136
+ quarantinedCount = 0;
137
+ /** Unreadable admissions moved aside by this open. */
138
+ get quarantined() { return this.quarantinedCount; }
139
+ /** Bounded by the repository's load limits; only dirty metadata is republished. */
140
+ async clearLegacyResponses() {
141
+ for (const record of this.records.values()) {
142
+ if (!record.deliveries.some(delivery => delivery.response !== undefined))
143
+ continue;
144
+ await this.update(record.id, next => { for (const delivery of next.deliveries)
145
+ delete delivery.response; });
146
+ }
147
+ }
148
+ get(id) { const value = this.records.get(id); return value ? structuredClone(value) : undefined; }
149
+ all() { return structuredClone([...this.records.values()]); }
150
+ saturation() {
151
+ let pending = false, retained = false, dropped = 0;
152
+ for (const record of this.records.values()) {
153
+ dropped += record.deliveries.filter(delivery => delivery.status === 'dropped').length;
154
+ const need = record.capacityNeed;
155
+ if (!need)
156
+ continue;
157
+ pending ||= this.usage.pendingBytes + need.pendingBytes > this.limits.pendingBytes || this.usage.pendingCount + need.pendingCount > this.limits.pendingCount;
158
+ // Legacy drops lack fileBytes; pending bytes are a conservative lower bound
159
+ // on the frozen fanout that could not fit in a single admission.
160
+ retained ||= (need.fileBytes ?? need.pendingBytes) > ADMISSION_PAYLOAD_BYTES || this.usage.retainedBytes + need.retainedBytes > this.limits.retainedBytes || this.usage.retainedObjects + need.retainedObjects > this.limits.retainedObjects;
161
+ }
162
+ return { pending, retained, control: this.controlBlocked, dropped };
163
+ }
164
+ controlBlocked = false;
165
+ fits(candidate) {
166
+ const cost = this.account(candidate), old = this.records.get(candidate.id), previous = old ? this.account(old) : undefined;
167
+ // Legacy records may already reserve more deferred payload than today's file
168
+ // budget. Allow that reservation to drain, without permitting further growth.
169
+ if (this.fileBytes(candidate) > Math.max(ADMISSION_PAYLOAD_BYTES, old ? this.fileBytes(old) : 0))
170
+ return false;
171
+ return Object.keys(cost).every(key => this.usage[key] - (previous?.[key] ?? 0) + cost[key] <= this.limits[key]);
172
+ }
173
+ /** One owner mutation queue must serialize admission, claims, updates and retention. */
174
+ async admit(source, receivers) {
175
+ const existing = this.records.get(source.id);
176
+ if (existing)
177
+ return structuredClone(existing);
178
+ const now = this.deps.now(), expires = Date.parse(source.occurredAt) + 72 * 3600000;
179
+ const targets = expires <= now ? [] : receivers.filter(receiver => ['active', 'suspended'].includes(receiver.state) && receiver.activation?.installationId === source.installationId &&
180
+ source.sequence > receiver.activation.sequence && selected(receiver, source.type, source.snapshot));
181
+ const deliveries = targets.map(receiver => ({
182
+ id: randomUUID(), receiverId: receiver.id, deliveryRevision: receiver.deliveryRevision, admittedRevision: receiver.revision,
183
+ format: receiver.format, profile: receiver.profile, eventType: source.type, destination: maskDestination(receiver.url), createdAt: new Date(now).toISOString(),
184
+ notBefore: new Date(Date.parse(source.occurredAt) + (source.type === 'task.failed' ? 30 : ['task.attention_required', 'task.review_ready'].includes(source.type) ? receiver.graceSeconds : 0) * 1000).toISOString(),
185
+ expiresAt: new Date(expires).toISOString(), status: 'pending', attempts: 0,
186
+ ...(source.type === 'task.failed' ? {} : { body: renderPayload(source, receiver.profile, this.deps.secrets?.() ?? [], undefined, this.deps.repository) }),
187
+ }));
188
+ let admission = { version: 1, id: source.id, createdAt: new Date(now).toISOString(), source, sourceSequence: source.sequence, deliveries, control: !deliveries.length,
189
+ ...(!deliveries.length ? { decision: expires <= now ? 'expired' : 'empty' } : {}) };
190
+ if (!deliveries.length)
191
+ admission.source = undefined;
192
+ if (!this.fits(admission)) {
193
+ const cost = this.account(admission), fileBytes = this.fileBytes(admission);
194
+ const reason = fileBytes > ADMISSION_PAYLOAD_BYTES || this.usage.retainedBytes + cost.retainedBytes > this.limits.retainedBytes || this.usage.retainedObjects + cost.retainedObjects > this.limits.retainedObjects ? 'retained_capacity' : 'pending_capacity';
195
+ const capacityNeed = { ...(fileBytes > ADMISSION_PAYLOAD_BYTES ? { fileBytes } : {}), retainedBytes: cost.retainedBytes, retainedObjects: cost.retainedObjects, pendingBytes: cost.pendingBytes, pendingCount: cost.pendingCount };
196
+ admission = { ...admission, control: true, source: undefined, taskId: source.snapshot.id, capacityNeed, decision: reason, deliveries: deliveries.map(delivery => ({
197
+ ...delivery, body: undefined, historyPending: true, status: 'dropped', completedAt: new Date(now).toISOString(), reason,
198
+ })) };
199
+ if (!this.fits(admission)) {
200
+ this.controlBlocked = true;
201
+ return undefined;
202
+ } // Preserve source and cursor; control space is exhausted.
203
+ }
204
+ this.controlBlocked = false;
205
+ await this.save(admission);
206
+ return structuredClone(admission);
207
+ }
208
+ async update(id, mutate) {
209
+ const old = this.records.get(id);
210
+ if (!old)
211
+ throw new Error('Webhook admission not found');
212
+ const next = structuredClone(old);
213
+ mutate(next);
214
+ // Raw response bytes can expand sixfold in JSON. Optional diagnostics must
215
+ // never consume the reservation needed to publish a result and its effects.
216
+ for (const delivery of next.deliveries) {
217
+ if (delivery.response !== undefined && metadataBytes(delivery) > DELIVERY_METADATA_BYTES)
218
+ delete delivery.response;
219
+ }
220
+ for (const previous of old.deliveries) {
221
+ const updated = next.deliveries.find(delivery => delivery.id === previous.id);
222
+ if (previous.body && updated?.body !== previous.body)
223
+ throw new Error('Frozen webhook bytes cannot change');
224
+ }
225
+ if (!this.fits(next))
226
+ throw new WebhookStateError(503, 'Webhook retained capacity exhausted; wait for retention to release space');
227
+ await this.save(next);
228
+ return structuredClone(next);
229
+ }
230
+ async insert(value) {
231
+ if (this.records.has(value.id))
232
+ throw new Error('Duplicate admission');
233
+ if (!this.fits(value))
234
+ throw new WebhookStateError(503, 'Webhook retained capacity exhausted; wait for retention to release space');
235
+ await this.save(value);
236
+ return structuredClone(value);
237
+ }
238
+ async save(value) {
239
+ this.deps.assertOwner?.();
240
+ const next = admissionSchema.parse(value);
241
+ await atomicWrite(this.directory, `${next.id}.json`, next);
242
+ const previous = this.records.get(next.id);
243
+ if (previous)
244
+ this.charge(previous, -1);
245
+ this.records.set(next.id, next);
246
+ this.charge(next, 1);
247
+ }
248
+ /** After durable source compaction, expire each settled payload independently of its history. */
249
+ async prune(compactedThrough) {
250
+ for (let record of this.records.values()) {
251
+ if (record.sourceSequence !== undefined && record.sourceSequence > compactedThrough)
252
+ continue;
253
+ // An empty decision only guards its source against re-evaluation. Retiring it with the source
254
+ // keeps 7 days of non-selected transitions from filling control space and stopping admission.
255
+ if (emptyDecision(record)) {
256
+ await this.remove(record);
257
+ continue;
258
+ }
259
+ // Operation receipts and source acknowledgement outlive display metadata.
260
+ // Never retire a cycle whose result publication or operation recovery is pending.
261
+ if (record.operations?.some(operation => !operation.applied))
262
+ continue;
263
+ const now = this.deps.now();
264
+ const unsettled = (delivery) => !terminalDelivery(delivery.status) || !!delivery.historyPending || !!delivery.resultEffects || !!delivery.claim;
265
+ const payloadRequired = (delivery) => unsettled(delivery) || !delivery.completedAt || Date.parse(delivery.completedAt) + 7 * 86400000 > now;
266
+ let changed = false;
267
+ const retained = record.deliveries.filter(delivery => historyVisible(delivery, now) || unsettled(delivery)).map(delivery => {
268
+ if (delivery.body === undefined || payloadRequired(delivery))
269
+ return delivery;
270
+ // Only retention may discard frozen bytes. Keep the cycle's compact metadata,
271
+ // newer replay bytes, and shared source evidence needed by other deliveries.
272
+ const { body: _, ...metadata } = delivery;
273
+ changed = true;
274
+ return metadata;
275
+ });
276
+ if (changed || retained.length !== record.deliveries.length) {
277
+ record = { ...record, deliveries: retained };
278
+ await this.save(record);
279
+ }
280
+ if (record.deliveries.some(payloadRequired))
281
+ continue;
282
+ if (!record.deliveries.length && Date.parse(record.createdAt) + 7 * 86400000 > this.deps.now())
283
+ continue;
284
+ await this.remove(record);
285
+ }
286
+ }
287
+ async remove(record) {
288
+ this.deps.assertOwner?.();
289
+ await rm(statePath(this.directory, `${record.id}.json`));
290
+ this.records.delete(record.id);
291
+ this.charge(record, -1);
292
+ }
293
+ }
294
+ //# sourceMappingURL=admission.js.map