@vercel/factory 0.0.14 → 0.0.15

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 (467) hide show
  1. package/README.md +306 -0
  2. package/dist/agent-routes.d.mts +69 -0
  3. package/dist/agent-routes.mjs +64 -0
  4. package/dist/agent-routes.mjs.map +1 -0
  5. package/dist/api-contracts.d.mts +1749 -0
  6. package/dist/api-contracts.mjs +118 -0
  7. package/dist/api-contracts.mjs.map +1 -0
  8. package/dist/api-images.d.mts +30 -0
  9. package/dist/api-images.mjs +28 -0
  10. package/dist/api-images.mjs.map +1 -0
  11. package/dist/api-task-graph.mjs +57 -0
  12. package/dist/api-task-graph.mjs.map +1 -0
  13. package/dist/api.d.mts +68 -216
  14. package/dist/api.mjs +872 -97
  15. package/dist/api.mjs.map +1 -1
  16. package/dist/approval-access.d.mts +39 -0
  17. package/dist/approval-access.mjs +62 -0
  18. package/dist/approval-access.mjs.map +1 -0
  19. package/dist/approval-contracts.d.mts +692 -0
  20. package/dist/approval-contracts.mjs +27 -0
  21. package/dist/approval-contracts.mjs.map +1 -0
  22. package/dist/approval.d.mts +49 -0
  23. package/dist/approval.mjs +39 -0
  24. package/dist/approval.mjs.map +1 -0
  25. package/dist/blob/artifacts.d.mts +37 -0
  26. package/dist/blob/artifacts.mjs +45 -0
  27. package/dist/blob/artifacts.mjs.map +1 -0
  28. package/dist/blob/index.d.mts +41 -6
  29. package/dist/blob/index.mjs +158 -40
  30. package/dist/blob/index.mjs.map +1 -1
  31. package/dist/budget.d.mts +108 -0
  32. package/dist/budget.mjs +141 -0
  33. package/dist/budget.mjs.map +1 -0
  34. package/dist/budgets.d.mts +4 -0
  35. package/dist/budgets.mjs +4 -0
  36. package/dist/build-factory.d.mts +6 -4
  37. package/dist/build-factory.mjs +2 -1
  38. package/dist/build-factory.mjs.map +1 -1
  39. package/dist/change-verification/brief.d.mts +9 -0
  40. package/dist/change-verification/brief.mjs +13 -0
  41. package/dist/change-verification/brief.mjs.map +1 -0
  42. package/dist/change-verification/dispatch.d.mts +24 -0
  43. package/dist/change-verification/dispatch.mjs +45 -0
  44. package/dist/change-verification/dispatch.mjs.map +1 -0
  45. package/dist/change-verification/eve-tool.d.mts +60 -0
  46. package/dist/change-verification/eve-tool.mjs +101 -0
  47. package/dist/change-verification/eve-tool.mjs.map +1 -0
  48. package/dist/changes/eve-record-change.d.mts +56 -0
  49. package/dist/changes/eve-record-change.mjs +97 -0
  50. package/dist/changes/eve-record-change.mjs.map +1 -0
  51. package/dist/changes/presentation.d.mts +14 -0
  52. package/dist/changes.d.mts +23 -0
  53. package/dist/changes.mjs +29 -0
  54. package/dist/changes.mjs.map +1 -0
  55. package/dist/client-events.d.mts +18 -0
  56. package/dist/client-events.mjs +41 -0
  57. package/dist/client-events.mjs.map +1 -0
  58. package/dist/client-stream.d.mts +28 -0
  59. package/dist/client-stream.mjs +204 -0
  60. package/dist/client-stream.mjs.map +1 -0
  61. package/dist/client-transcript.d.mts +41 -0
  62. package/dist/client-transcript.mjs +229 -0
  63. package/dist/client-transcript.mjs.map +1 -0
  64. package/dist/client.d.mts +234 -0
  65. package/dist/client.mjs +258 -0
  66. package/dist/client.mjs.map +1 -0
  67. package/dist/code-review/contracts.d.mts +26 -0
  68. package/dist/code-review/eve-post-review.d.mts +70 -0
  69. package/dist/code-review/eve-post-review.mjs +183 -0
  70. package/dist/code-review/eve-post-review.mjs.map +1 -0
  71. package/dist/code-review/eve-review-comments.d.mts +64 -0
  72. package/dist/code-review/eve-review-comments.mjs +159 -0
  73. package/dist/code-review/eve-review-comments.mjs.map +1 -0
  74. package/dist/code-review/github-contracts.d.mts +10 -0
  75. package/dist/code-review/github-reporter.d.mts +44 -0
  76. package/dist/code-review/github-reporter.mjs +260 -0
  77. package/dist/code-review/github-reporter.mjs.map +1 -0
  78. package/dist/code-review/preparation.d.mts +34 -0
  79. package/dist/code-review/preparation.mjs +23 -0
  80. package/dist/code-review/preparation.mjs.map +1 -0
  81. package/dist/code-review/stall.d.mts +17 -0
  82. package/dist/code-review/stall.mjs +30 -0
  83. package/dist/code-review/stall.mjs.map +1 -0
  84. package/dist/code-review.d.mts +6 -0
  85. package/dist/code-review.mjs +5 -0
  86. package/dist/communication.d.mts +9 -0
  87. package/dist/communication.mjs +9 -0
  88. package/dist/connectors/github.d.mts +26 -0
  89. package/dist/connectors/github.mjs +55 -0
  90. package/dist/connectors/github.mjs.map +1 -0
  91. package/dist/connectors/index.d.mts +35 -3
  92. package/dist/connectors/index.mjs +3 -52
  93. package/dist/connectors/index.mjs.map +1 -1
  94. package/dist/connectors/outbox.d.mts +34 -0
  95. package/dist/connectors/outbox.mjs +50 -0
  96. package/dist/connectors/outbox.mjs.map +1 -0
  97. package/dist/connectors/slack-approval-blocks.mjs +136 -0
  98. package/dist/connectors/slack-approval-blocks.mjs.map +1 -0
  99. package/dist/connectors/slack-approvals.d.mts +29 -0
  100. package/dist/connectors/slack-approvals.mjs +346 -0
  101. package/dist/connectors/slack-approvals.mjs.map +1 -0
  102. package/dist/connectors/slack.d.mts +35 -52
  103. package/dist/connectors/slack.mjs +13 -85
  104. package/dist/connectors/slack.mjs.map +1 -1
  105. package/dist/deepsec/eve-tool.d.mts +110 -0
  106. package/dist/deepsec/eve-tool.mjs +164 -0
  107. package/dist/deepsec/eve-tool.mjs.map +1 -0
  108. package/dist/deepsec/finding.d.mts +84 -0
  109. package/dist/deepsec/finding.mjs +56 -0
  110. package/dist/deepsec/finding.mjs.map +1 -0
  111. package/dist/deepsec.d.mts +3 -0
  112. package/dist/delivery-metrics/metrics.d.mts +93 -0
  113. package/dist/delivery-metrics/metrics.mjs +200 -0
  114. package/dist/delivery-metrics/metrics.mjs.map +1 -0
  115. package/dist/delivery-metrics.d.mts +2 -0
  116. package/dist/delivery-metrics.mjs +2 -0
  117. package/dist/dispatch.d.mts +81 -0
  118. package/dist/dispatch.mjs +140 -0
  119. package/dist/dispatch.mjs.map +1 -0
  120. package/dist/errors.d.mts +15 -0
  121. package/dist/errors.mjs +38 -0
  122. package/dist/errors.mjs.map +1 -0
  123. package/dist/eve/index.d.mts +143 -1271
  124. package/dist/eve/index.mjs +233 -1065
  125. package/dist/eve/index.mjs.map +1 -1
  126. package/dist/eve/invoke.d.mts +144 -0
  127. package/dist/eve/invoke.mjs +241 -0
  128. package/dist/eve/invoke.mjs.map +1 -0
  129. package/dist/eve/session-client.d.mts +68 -0
  130. package/dist/eve/session-client.mjs +131 -0
  131. package/dist/eve/session-client.mjs.map +1 -0
  132. package/dist/eve/task-execution.mjs +18 -0
  133. package/dist/eve/task-execution.mjs.map +1 -0
  134. package/dist/eve/task-session.d.mts +87 -0
  135. package/dist/eve/task-session.mjs +203 -0
  136. package/dist/eve/task-session.mjs.map +1 -0
  137. package/dist/eve/transcript.d.mts +37 -0
  138. package/dist/eve/transcript.mjs +65 -0
  139. package/dist/eve/transcript.mjs.map +1 -0
  140. package/dist/execution-public.d.mts +8 -0
  141. package/dist/execution-public.mjs +7 -0
  142. package/dist/execution.d.mts +75 -0
  143. package/dist/execution.mjs +153 -0
  144. package/dist/execution.mjs.map +1 -0
  145. package/dist/finding-remediation/admission.d.mts +51 -0
  146. package/dist/finding-remediation/admission.mjs +87 -0
  147. package/dist/finding-remediation/admission.mjs.map +1 -0
  148. package/dist/finding-remediation/brief.d.mts +14 -0
  149. package/dist/finding-remediation/brief.mjs +25 -0
  150. package/dist/finding-remediation/brief.mjs.map +1 -0
  151. package/dist/finding-remediation/eve-tool.d.mts +29 -0
  152. package/dist/finding-remediation/eve-tool.mjs +34 -0
  153. package/dist/finding-remediation/eve-tool.mjs.map +1 -0
  154. package/dist/findings/fingerprint.d.mts +14 -0
  155. package/dist/findings/fingerprint.mjs +28 -0
  156. package/dist/findings/fingerprint.mjs.map +1 -0
  157. package/dist/findings.d.mts +6 -0
  158. package/dist/findings.mjs +6 -0
  159. package/dist/github-app.d.mts +54 -0
  160. package/dist/github-app.mjs +121 -0
  161. package/dist/github-app.mjs.map +1 -0
  162. package/dist/github-publication.d.mts +198 -0
  163. package/dist/github-publication.mjs +429 -0
  164. package/dist/github-publication.mjs.map +1 -0
  165. package/dist/github-transfer.d.mts +72 -0
  166. package/dist/github-transfer.mjs +125 -0
  167. package/dist/github-transfer.mjs.map +1 -0
  168. package/dist/github.d.mts +406 -2
  169. package/dist/github.mjs +239 -40
  170. package/dist/github.mjs.map +1 -1
  171. package/dist/image-input.d.mts +51 -0
  172. package/dist/image-input.mjs +63 -0
  173. package/dist/image-input.mjs.map +1 -0
  174. package/dist/index.d.mts +14 -484
  175. package/dist/index.mjs +14 -522
  176. package/dist/intake-contracts.d.mts +56 -0
  177. package/dist/intake-contracts.mjs +33 -0
  178. package/dist/intake-contracts.mjs.map +1 -0
  179. package/dist/integrations/deepsec.d.mts +4 -0
  180. package/dist/integrations/deepsec.mjs +3 -0
  181. package/dist/integrations/github.d.mts +11 -0
  182. package/dist/integrations/github.mjs +9 -0
  183. package/dist/integrations/slack.d.mts +3 -0
  184. package/dist/integrations/slack.mjs +3 -0
  185. package/dist/integrations/vercel.d.mts +3 -0
  186. package/dist/integrations/vercel.mjs +3 -0
  187. package/dist/merge-resolution/contracts.d.mts +17 -0
  188. package/dist/merge-resolution/contracts.mjs +19 -0
  189. package/dist/merge-resolution/contracts.mjs.map +1 -0
  190. package/dist/merge-resolution/eve-tools.d.mts +46 -0
  191. package/dist/merge-resolution/eve-tools.mjs +117 -0
  192. package/dist/merge-resolution/eve-tools.mjs.map +1 -0
  193. package/dist/multi-repository-changes/coordination.d.mts +49 -0
  194. package/dist/multi-repository-changes/coordination.mjs +115 -0
  195. package/dist/multi-repository-changes/coordination.mjs.map +1 -0
  196. package/dist/planning/cancellation.mjs +82 -0
  197. package/dist/planning/cancellation.mjs.map +1 -0
  198. package/dist/planning/configuration.d.mts +23 -0
  199. package/dist/planning/configuration.mjs +56 -0
  200. package/dist/planning/configuration.mjs.map +1 -0
  201. package/dist/planning/contracts.d.mts +136 -0
  202. package/dist/planning/contracts.mjs +42 -0
  203. package/dist/planning/contracts.mjs.map +1 -0
  204. package/dist/planning/dependencies.mjs +44 -0
  205. package/dist/planning/dependencies.mjs.map +1 -0
  206. package/dist/planning/effects.mjs +122 -0
  207. package/dist/planning/effects.mjs.map +1 -0
  208. package/dist/planning/reconcile.mjs +273 -0
  209. package/dist/planning/reconcile.mjs.map +1 -0
  210. package/dist/planning/runtime.d.mts +27 -0
  211. package/dist/planning/runtime.mjs +25 -0
  212. package/dist/planning/runtime.mjs.map +1 -0
  213. package/dist/planning/state.mjs +92 -0
  214. package/dist/planning/state.mjs.map +1 -0
  215. package/dist/planning/turns.mjs +262 -0
  216. package/dist/planning/turns.mjs.map +1 -0
  217. package/dist/planning/validation.mjs +106 -0
  218. package/dist/planning/validation.mjs.map +1 -0
  219. package/dist/postgres/index.d.mts +7 -1
  220. package/dist/postgres/index.mjs +7 -3
  221. package/dist/postgres/index.mjs.map +1 -1
  222. package/dist/presets/software-development/approval.d.mts +14 -0
  223. package/dist/presets/software-development/approval.mjs +21 -0
  224. package/dist/presets/software-development/approval.mjs.map +1 -0
  225. package/dist/presets/software-development/deepsec-brief.d.mts +8 -0
  226. package/dist/presets/software-development/deepsec-brief.mjs +14 -0
  227. package/dist/presets/software-development/deepsec-brief.mjs.map +1 -0
  228. package/dist/presets/software-development/dispatch.d.mts +53 -0
  229. package/dist/presets/software-development/dispatch.mjs +66 -0
  230. package/dist/presets/software-development/dispatch.mjs.map +1 -0
  231. package/dist/presets/software-development/eve-delegation-policy.d.mts +7 -0
  232. package/dist/presets/software-development/eve-delegation-policy.mjs +34 -0
  233. package/dist/presets/software-development/eve-delegation-policy.mjs.map +1 -0
  234. package/dist/presets/software-development/eve.d.mts +18 -0
  235. package/dist/presets/software-development/eve.mjs +19 -0
  236. package/dist/presets/software-development/eve.mjs.map +1 -0
  237. package/dist/presets/software-development/finish-task-policy.d.mts +7 -0
  238. package/dist/presets/software-development/finish-task-policy.mjs +9 -0
  239. package/dist/presets/software-development/finish-task-policy.mjs.map +1 -0
  240. package/dist/presets/software-development/recovery.d.mts +32 -0
  241. package/dist/presets/software-development/recovery.mjs +120 -0
  242. package/dist/presets/software-development/recovery.mjs.map +1 -0
  243. package/dist/presets/software-development/task-communication.d.mts +23 -0
  244. package/dist/presets/software-development/task-communication.mjs +120 -0
  245. package/dist/presets/software-development/task-communication.mjs.map +1 -0
  246. package/dist/presets/software-development.d.mts +9 -0
  247. package/dist/presets/software-development.mjs +9 -0
  248. package/dist/pull-requests/contracts.d.mts +72 -0
  249. package/dist/pull-requests/eve-fetch.d.mts +57 -0
  250. package/dist/pull-requests/eve-fetch.mjs +151 -0
  251. package/dist/pull-requests/eve-fetch.mjs.map +1 -0
  252. package/dist/pull-requests/github-label-manager.d.mts +27 -0
  253. package/dist/pull-requests/github-label-manager.mjs +40 -0
  254. package/dist/pull-requests/github-label-manager.mjs.map +1 -0
  255. package/dist/pull-requests/github-publisher.d.mts +53 -0
  256. package/dist/pull-requests/github-publisher.mjs +345 -0
  257. package/dist/pull-requests/github-publisher.mjs.map +1 -0
  258. package/dist/pull-requests.d.mts +5 -0
  259. package/dist/pull-requests.mjs +4 -0
  260. package/dist/receipts.d.mts +4 -0
  261. package/dist/receipts.mjs +3 -0
  262. package/dist/repositories.d.mts +18 -0
  263. package/dist/repositories.mjs +33 -0
  264. package/dist/repositories.mjs.map +1 -0
  265. package/dist/sandbox/command.d.mts +18 -0
  266. package/dist/sandbox/execution-abort.d.mts +16 -0
  267. package/dist/sandbox/execution-abort.mjs +49 -0
  268. package/dist/sandbox/execution-abort.mjs.map +1 -0
  269. package/dist/sandbox/execution-environment.d.mts +25 -0
  270. package/dist/sandbox/execution-run-ledger.d.mts +115 -0
  271. package/dist/sandbox/execution-run-ledger.mjs +209 -0
  272. package/dist/sandbox/execution-run-ledger.mjs.map +1 -0
  273. package/dist/sandbox/execution.d.mts +54 -0
  274. package/dist/sandbox/execution.mjs +228 -0
  275. package/dist/sandbox/execution.mjs.map +1 -0
  276. package/dist/sandbox/harness-runner.d.mts +79 -0
  277. package/dist/sandbox/harness-runner.mjs +162 -0
  278. package/dist/sandbox/harness-runner.mjs.map +1 -0
  279. package/dist/sandbox/index.d.mts +9 -0
  280. package/dist/sandbox/index.mjs +7 -0
  281. package/dist/sandbox/task-environment.d.mts +50 -0
  282. package/dist/sandbox/task-environment.mjs +140 -0
  283. package/dist/sandbox/task-environment.mjs.map +1 -0
  284. package/dist/sandbox/workspace.d.mts +29 -0
  285. package/dist/sandbox/workspace.mjs +28 -0
  286. package/dist/sandbox/workspace.mjs.map +1 -0
  287. package/dist/schema/agent-route.d.mts +22 -0
  288. package/dist/schema/agent-route.mjs +15 -0
  289. package/dist/schema/agent-route.mjs.map +1 -0
  290. package/dist/schema/answer.d.mts +23 -0
  291. package/dist/schema/answer.mjs +21 -0
  292. package/dist/schema/answer.mjs.map +1 -0
  293. package/dist/schema/budget.d.mts +38 -0
  294. package/dist/schema/budget.mjs +30 -0
  295. package/dist/schema/budget.mjs.map +1 -0
  296. package/dist/schema/catalog.mjs +72 -0
  297. package/dist/schema/catalog.mjs.map +1 -0
  298. package/dist/schema/change.d.mts +117 -0
  299. package/dist/schema/change.mjs +68 -0
  300. package/dist/schema/change.mjs.map +1 -0
  301. package/dist/schema/common.d.mts +33 -0
  302. package/dist/{id-BLIkCVue.mjs → schema/common.mjs} +7 -16
  303. package/dist/schema/common.mjs.map +1 -0
  304. package/dist/schema/communication.d.mts +52 -0
  305. package/dist/{communication-Kd9nU5RP.mjs → schema/communication.mjs} +8 -3
  306. package/dist/schema/communication.mjs.map +1 -0
  307. package/dist/schema/execution.d.mts +101 -0
  308. package/dist/schema/execution.mjs +86 -0
  309. package/dist/schema/execution.mjs.map +1 -0
  310. package/dist/schema/factory-config.d.mts +95 -0
  311. package/dist/schema/factory-config.mjs +60 -0
  312. package/dist/schema/factory-config.mjs.map +1 -0
  313. package/dist/schema/finding.d.mts +125 -0
  314. package/dist/schema/finding.mjs +67 -0
  315. package/dist/schema/finding.mjs.map +1 -0
  316. package/dist/schema/id.d.mts +43 -0
  317. package/dist/schema/id.mjs +32 -0
  318. package/dist/schema/id.mjs.map +1 -0
  319. package/dist/schema/outbox.d.mts +240 -0
  320. package/dist/schema/outbox.mjs +53 -0
  321. package/dist/schema/outbox.mjs.map +1 -0
  322. package/dist/schema/question-route.mjs +16 -0
  323. package/dist/schema/question-route.mjs.map +1 -0
  324. package/dist/schema/receipt.d.mts +81 -0
  325. package/dist/schema/receipt.mjs +94 -0
  326. package/dist/schema/receipt.mjs.map +1 -0
  327. package/dist/schema/repository.d.mts +26 -0
  328. package/dist/schema/repository.mjs +25 -0
  329. package/dist/schema/repository.mjs.map +1 -0
  330. package/dist/schema/session.d.mts +135 -0
  331. package/dist/schema/session.mjs +53 -0
  332. package/dist/schema/session.mjs.map +1 -0
  333. package/dist/schema/signal.d.mts +105 -0
  334. package/dist/schema/signal.mjs +81 -0
  335. package/dist/schema/signal.mjs.map +1 -0
  336. package/dist/schema/stored-session.mjs +10 -0
  337. package/dist/schema/stored-session.mjs.map +1 -0
  338. package/dist/schema/stored-task.mjs +20 -0
  339. package/dist/schema/stored-task.mjs.map +1 -0
  340. package/dist/schema/task-effect.d.mts +39 -0
  341. package/dist/schema/task-effect.mjs +29 -0
  342. package/dist/schema/task-effect.mjs.map +1 -0
  343. package/dist/schema/task-graph.d.mts +3134 -0
  344. package/dist/schema/task-graph.mjs +97 -0
  345. package/dist/schema/task-graph.mjs.map +1 -0
  346. package/dist/schema/task-message.d.mts +254 -0
  347. package/dist/schema/task-message.mjs +189 -0
  348. package/dist/schema/task-message.mjs.map +1 -0
  349. package/dist/schema/task.d.mts +272 -0
  350. package/dist/schema/task.mjs +199 -0
  351. package/dist/schema/task.mjs.map +1 -0
  352. package/dist/schema/transcript.d.mts +170 -0
  353. package/dist/schema/transcript.mjs +86 -0
  354. package/dist/schema/transcript.mjs.map +1 -0
  355. package/dist/schema/transitions.d.mts +50 -0
  356. package/dist/schema/transitions.mjs +303 -0
  357. package/dist/schema/transitions.mjs.map +1 -0
  358. package/dist/schema/work.d.mts +101 -0
  359. package/dist/schema/work.mjs +102 -0
  360. package/dist/schema/work.mjs.map +1 -0
  361. package/dist/signal-triage.d.mts +20 -0
  362. package/dist/signal-triage.mjs +85 -0
  363. package/dist/signal-triage.mjs.map +1 -0
  364. package/dist/signals.d.mts +19 -0
  365. package/dist/signals.mjs +19 -0
  366. package/dist/signals.mjs.map +1 -0
  367. package/dist/stall.d.mts +38 -0
  368. package/dist/stall.mjs +79 -0
  369. package/dist/stall.mjs.map +1 -0
  370. package/dist/storage.d.mts +4 -0
  371. package/dist/storage.mjs +4 -0
  372. package/dist/store/driver.d.mts +65 -0
  373. package/dist/store/driver.mjs +42 -0
  374. package/dist/store/driver.mjs.map +1 -0
  375. package/dist/store/engine.d.mts +485 -0
  376. package/dist/store/engine.mjs +2175 -0
  377. package/dist/store/engine.mjs.map +1 -0
  378. package/dist/store/memory.d.mts +7 -0
  379. package/dist/store/memory.mjs +52 -0
  380. package/dist/store/memory.mjs.map +1 -0
  381. package/dist/store/task-effects.d.mts +38 -0
  382. package/dist/store/task-effects.mjs +118 -0
  383. package/dist/store/task-effects.mjs.map +1 -0
  384. package/dist/store/task-graphs.d.mts +60 -0
  385. package/dist/store/task-graphs.mjs +212 -0
  386. package/dist/store/task-graphs.mjs.map +1 -0
  387. package/dist/store/task-messages.d.mts +136 -0
  388. package/dist/store/task-messages.mjs +475 -0
  389. package/dist/store/task-messages.mjs.map +1 -0
  390. package/dist/store/task-work.d.mts +65 -0
  391. package/dist/store/task-work.mjs +134 -0
  392. package/dist/store/task-work.mjs.map +1 -0
  393. package/dist/store/work-notifications.d.mts +19 -0
  394. package/dist/store/work-notifications.mjs +48 -0
  395. package/dist/store/work-notifications.mjs.map +1 -0
  396. package/dist/sweep.d.mts +57 -0
  397. package/dist/sweep.mjs +143 -0
  398. package/dist/sweep.mjs.map +1 -0
  399. package/dist/task-communication.d.mts +35 -0
  400. package/dist/task-communication.mjs +47 -0
  401. package/dist/task-communication.mjs.map +1 -0
  402. package/dist/task-graph-view.d.mts +264 -0
  403. package/dist/task-graph-view.mjs +17 -0
  404. package/dist/task-graph-view.mjs.map +1 -0
  405. package/dist/task-message-processing.d.mts +60 -0
  406. package/dist/task-message-processing.mjs +200 -0
  407. package/dist/task-message-processing.mjs.map +1 -0
  408. package/dist/task-protocols.d.mts +80 -0
  409. package/dist/task-protocols.mjs +47 -0
  410. package/dist/task-protocols.mjs.map +1 -0
  411. package/dist/tasks.d.mts +17 -0
  412. package/dist/tasks.mjs +17 -0
  413. package/dist/vercel-git.d.mts +21 -0
  414. package/dist/vercel-git.mjs +112 -0
  415. package/dist/vercel-git.mjs.map +1 -0
  416. package/dist/vercel.d.mts +33 -2
  417. package/dist/vercel.mjs +48 -3
  418. package/dist/vercel.mjs.map +1 -1
  419. package/dist/work-triage/eve-tool.d.mts +29 -0
  420. package/dist/work-triage/eve-tool.mjs +32 -0
  421. package/dist/work-triage/eve-tool.mjs.map +1 -0
  422. package/dist/work-triage/find-existing-work.d.mts +32 -0
  423. package/dist/work-triage/find-existing-work.mjs +31 -0
  424. package/dist/work-triage/find-existing-work.mjs.map +1 -0
  425. package/dist/work-triage/github.d.mts +15 -0
  426. package/dist/work-triage/github.mjs +14 -0
  427. package/dist/work-triage/github.mjs.map +1 -0
  428. package/dist/work-triage.d.mts +3 -0
  429. package/dist/work-triage.mjs +3 -0
  430. package/dist/workflows.d.mts +48 -0
  431. package/dist/workflows.mjs +86 -0
  432. package/dist/workflows.mjs.map +1 -0
  433. package/dist/workspace-diff-assembly.d.mts +33 -0
  434. package/dist/workspace-diff-assembly.mjs +95 -0
  435. package/dist/workspace-diff-assembly.mjs.map +1 -0
  436. package/dist/workspace-diff.d.mts +90 -0
  437. package/dist/workspace-diff.mjs +61 -0
  438. package/dist/workspace-diff.mjs.map +1 -0
  439. package/dist/workspace-snapshot.d.mts +26 -0
  440. package/dist/workspace-snapshot.mjs +80 -0
  441. package/dist/workspace-snapshot.mjs.map +1 -0
  442. package/package.json +129 -44
  443. package/dist/approval-JX2Px9IC.mjs +0 -132
  444. package/dist/approval-JX2Px9IC.mjs.map +0 -1
  445. package/dist/budget-DzSiIA4t.mjs +0 -42
  446. package/dist/budget-DzSiIA4t.mjs.map +0 -1
  447. package/dist/change-D2U6v7Ek.mjs +0 -554
  448. package/dist/change-D2U6v7Ek.mjs.map +0 -1
  449. package/dist/communication-Kd9nU5RP.mjs.map +0 -1
  450. package/dist/coordination-Cq08hb1l.mjs +0 -76
  451. package/dist/coordination-Cq08hb1l.mjs.map +0 -1
  452. package/dist/dispatch-BaZS3PT8.d.mts +0 -76
  453. package/dist/driver-BC0Mt5KG.d.mts +0 -34
  454. package/dist/driver-Bbd25rNM.mjs +0 -23
  455. package/dist/driver-Bbd25rNM.mjs.map +0 -1
  456. package/dist/engine-DFHU2Pe-.d.mts +0 -781
  457. package/dist/engine-WaUM2cGA.mjs +0 -1068
  458. package/dist/engine-WaUM2cGA.mjs.map +0 -1
  459. package/dist/factory-config-BoRXOw43.mjs +0 -50
  460. package/dist/factory-config-BoRXOw43.mjs.map +0 -1
  461. package/dist/factory-config-D2yU3G0c.d.mts +0 -58
  462. package/dist/github-C5HNBN6p.d.mts +0 -279
  463. package/dist/id-BLIkCVue.mjs.map +0 -1
  464. package/dist/index-Bw6hggoH.d.mts +0 -40
  465. package/dist/index.mjs.map +0 -1
  466. package/dist/task-CcOyOJ3k.mjs +0 -154
  467. package/dist/task-CcOyOJ3k.mjs.map +0 -1
@@ -0,0 +1,70 @@
1
+ import { ChangeId, TaskId } from "../schema/id.mjs";
2
+ import { RepositorySlug } from "../schema/repository.mjs";
3
+ import { TaskState } from "../schema/task.mjs";
4
+ import { FactoryStores } from "../store/engine.mjs";
5
+ import { CompletedReview, CompletedReviewFinding } from "./contracts.mjs";
6
+ import { SubmittedPullRequestReview } from "../github.mjs";
7
+ import { PublishedGitHubReview } from "./github-contracts.mjs";
8
+ import { ToolContext, ToolDefinition } from "eve/tools";
9
+ //#region src/code-review/eve-post-review.d.ts
10
+ /** Change, repository, and Task capabilities required by the review publication tool. */
11
+ type GitHubPostReviewToolStores = Pick<FactoryStores, "changes" | "repositories" | "tasks">;
12
+ /** Configures GitHub access, publication, and durable review-reporting callbacks. */
13
+ interface GitHubPostReviewToolOptions {
14
+ stores: GitHubPostReviewToolStores;
15
+ tokenForRepository: (repository: RepositorySlug) => Promise<string>;
16
+ publishReviews?: boolean;
17
+ onCompleted?: (completed: CompletedReview) => Promise<void>;
18
+ onPublished?: (published: PublishedGitHubReview) => Promise<void>;
19
+ fetch?: typeof globalThis.fetch;
20
+ }
21
+ /** Machine-readable reason a code review could not be recorded. */
22
+ type GitHubPostReviewFailureCode = "task_not_found" | "task_kind_mismatch" | "task_not_running" | "change_not_found" | "change_not_reviewable" | "repository_not_found" | "stale_pull_request_head";
23
+ /** Outcome returned after validating, recording, and optionally publishing a code review. */
24
+ type GitHubPostReviewResult = {
25
+ readonly recorded: false;
26
+ readonly code: GitHubPostReviewFailureCode;
27
+ readonly reason: string;
28
+ readonly taskState?: TaskState;
29
+ readonly verdict?: never;
30
+ readonly published?: never;
31
+ readonly review?: never;
32
+ } | {
33
+ readonly recorded: true;
34
+ readonly verdict: CompletedReview["verdict"];
35
+ readonly published: false;
36
+ readonly review?: never;
37
+ readonly taskState: "succeeded";
38
+ } | {
39
+ readonly recorded: true;
40
+ readonly verdict: CompletedReview["verdict"];
41
+ readonly published: true;
42
+ readonly review: SubmittedPullRequestReview;
43
+ readonly taskState: "succeeded";
44
+ };
45
+ /** Inline review finding accepted before Factory assigns its stable fingerprint. */
46
+ interface GitHubPostReviewCommentInput extends Pick<CompletedReviewFinding, "path" | "line" | "body"> {
47
+ key?: string;
48
+ title?: string;
49
+ }
50
+ /** Completed review supplied for validation, recording, and optional GitHub publication. */
51
+ interface GitHubPostReviewInput {
52
+ taskId: TaskId;
53
+ changeId: ChangeId;
54
+ verdict: CompletedReview["verdict"];
55
+ headSha: string;
56
+ summary: string;
57
+ comments: readonly GitHubPostReviewCommentInput[];
58
+ }
59
+ /** Eve outcome tool that records and optionally publishes one completed code review. */
60
+ interface GitHubPostReviewTool extends ToolDefinition<GitHubPostReviewInput, GitHubPostReviewResult> {
61
+ execute(input: GitHubPostReviewInput, ctx: ToolContext): Promise<GitHubPostReviewResult>;
62
+ }
63
+ /**
64
+ * Publish an independent review of an existing pull request and finish the
65
+ * review task without changing the pull request's factory lifecycle.
66
+ */
67
+ declare function createGitHubPostReviewTool(input: GitHubPostReviewToolOptions): GitHubPostReviewTool;
68
+ //#endregion
69
+ export { GitHubPostReviewCommentInput, GitHubPostReviewFailureCode, GitHubPostReviewInput, GitHubPostReviewResult, GitHubPostReviewTool, GitHubPostReviewToolOptions, GitHubPostReviewToolStores, createGitHubPostReviewTool };
70
+ //# sourceMappingURL=eve-post-review.d.mts.map
@@ -0,0 +1,183 @@
1
+ import { changeIdSchema, taskIdSchema } from "../schema/id.mjs";
2
+ import { requireTaskExecution } from "../eve/task-execution.mjs";
3
+ import { StalePullRequestHeadError, readPullRequestHead, submitPullRequestReview } from "../github.mjs";
4
+ import { createHash } from "node:crypto";
5
+ import { z } from "zod";
6
+ import { defineTool } from "eve/tools";
7
+ //#region src/code-review/eve-post-review.ts
8
+ const reviewCommentSchema = z.strictObject({
9
+ key: z.string().min(1).max(80).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional().describe("Stable kebab-case identity for this defect and cause; keep it unchanged across reruns."),
10
+ title: z.string().min(1).max(200).optional().describe("Short finding title."),
11
+ path: z.string().min(1).max(500).describe("Repository-relative file path."),
12
+ line: z.number().int().min(1).describe("Line in the pull request's new version."),
13
+ body: z.string().min(1).max(5e3).describe("Markdown explaining the finding and a concrete fix.")
14
+ });
15
+ const reviewCommentsSchema = z.array(reviewCommentSchema).max(50).default([]).superRefine((comments, context) => {
16
+ const seen = /* @__PURE__ */ new Set();
17
+ comments.forEach((comment, index) => {
18
+ if (comment.key === void 0) return;
19
+ if (seen.has(comment.key)) context.addIssue({
20
+ code: "custom",
21
+ message: `duplicate finding key: ${comment.key}`,
22
+ path: [index, "key"]
23
+ });
24
+ seen.add(comment.key);
25
+ });
26
+ }).readonly();
27
+ /**
28
+ * Publish an independent review of an existing pull request and finish the
29
+ * review task without changing the pull request's factory lifecycle.
30
+ */
31
+ function createGitHubPostReviewTool(input) {
32
+ const { stores, ...options } = input;
33
+ return defineTool({
34
+ description: "Record a completed code review and finish your code_review task. Results may be reported through completion callbacks instead of a GitHub review; use request_changes only for blocking findings.",
35
+ inputSchema: z.object({
36
+ taskId: taskIdSchema.describe("Your code_review task."),
37
+ changeId: changeIdSchema.describe("The pull request change from your starting message."),
38
+ verdict: z.enum([
39
+ "approve",
40
+ "request_changes",
41
+ "comment"
42
+ ]),
43
+ headSha: z.string().regex(/^[0-9a-f]{40}$/).describe("Commit returned by fetch_pull_request."),
44
+ summary: z.string().min(1).max(5e3).describe("Markdown summary of what you reviewed and found."),
45
+ comments: reviewCommentsSchema
46
+ }),
47
+ async execute({ taskId, changeId, verdict, headSha, summary, comments }, ctx) {
48
+ const task = await requireTaskExecution(stores, ctx, taskId);
49
+ if (task.kind !== "code_review") return {
50
+ recorded: false,
51
+ code: "task_kind_mismatch",
52
+ reason: `${taskId} is not a code_review task`
53
+ };
54
+ if (task.state !== "running") return {
55
+ recorded: false,
56
+ code: "task_not_running",
57
+ reason: `task is ${task.state}, not running`
58
+ };
59
+ const change = await stores.changes.get(changeId);
60
+ if (change === null) return {
61
+ recorded: false,
62
+ code: "change_not_found",
63
+ reason: `change ${changeId} does not exist`
64
+ };
65
+ if (change.state !== "verifying" && change.state !== "ready") return {
66
+ recorded: false,
67
+ code: "change_not_reviewable",
68
+ reason: `change is ${change.state}, not open for review`
69
+ };
70
+ const repository = await stores.repositories.get(change.repositoryId);
71
+ if (repository === null) return {
72
+ recorded: false,
73
+ code: "repository_not_found",
74
+ reason: `repository ${change.repositoryId} does not exist`
75
+ };
76
+ if (task.changeId !== change.id || task.repositoryIds.length !== 1 || task.repositoryIds[0] !== repository.id) throw new Error("Authenticated review Task, Change, and repository must match");
77
+ const token = await options.tokenForRepository(repository.slug);
78
+ await requireTaskExecution(stores, ctx, taskId);
79
+ const completedComments = comments.map((comment) => {
80
+ const key = comment.key ?? legacyFindingKey(comment);
81
+ return {
82
+ ...comment,
83
+ key,
84
+ title: comment.title ?? "Review finding",
85
+ fingerprint: createHash("sha256").update(`${repository.slug.toLowerCase()}#${change.prNumber}:${key}`).digest("hex")
86
+ };
87
+ });
88
+ const completed = {
89
+ taskId,
90
+ changeId,
91
+ repository: repository.slug,
92
+ pullRequestNumber: change.prNumber,
93
+ headSha,
94
+ verdict,
95
+ summary,
96
+ comments: completedComments
97
+ };
98
+ const publish = options.publishReviews !== false;
99
+ let review;
100
+ try {
101
+ if (publish) review = await submitPullRequestReview({
102
+ repository: repository.slug,
103
+ token,
104
+ fetch: options.fetch,
105
+ pullRequestNumber: change.prNumber,
106
+ commitId: headSha,
107
+ event: verdict === "approve" ? "APPROVE" : verdict === "request_changes" ? "REQUEST_CHANGES" : "COMMENT",
108
+ body: summary,
109
+ comments: completedComments
110
+ });
111
+ else {
112
+ const head = await readPullRequestHead({
113
+ repository: repository.slug,
114
+ token,
115
+ fetch: options.fetch,
116
+ pullRequestNumber: change.prNumber
117
+ });
118
+ if (head.sha !== headSha) throw new StalePullRequestHeadError(headSha, head.sha);
119
+ }
120
+ } catch (error) {
121
+ if (!(error instanceof StalePullRequestHeadError)) throw error;
122
+ const resolved = await stores.tasks.transition(taskId, "cancelled", {
123
+ expectFrom: "running",
124
+ expectAttempt: task.attempt,
125
+ expectExecution: task.execution,
126
+ reason: `review superseded by newer commits: ${error.message}`
127
+ }).catch(() => null);
128
+ return {
129
+ recorded: false,
130
+ code: "stale_pull_request_head",
131
+ reason: error.message,
132
+ taskState: resolved?.state ?? (await stores.tasks.get(taskId).catch(() => null))?.state ?? task.state
133
+ };
134
+ }
135
+ await requireTaskExecution(stores, ctx, taskId);
136
+ if (review !== void 0) await options.onPublished?.({
137
+ ...completed,
138
+ review
139
+ });
140
+ await requireTaskExecution(stores, ctx, taskId);
141
+ await options.onCompleted?.(completed);
142
+ await stores.tasks.transition(taskId, "verifying", {
143
+ expectFrom: "running",
144
+ expectAttempt: task.attempt,
145
+ expectExecution: task.execution,
146
+ reason: summary
147
+ });
148
+ await stores.tasks.transition(taskId, "succeeded", {
149
+ expectFrom: "verifying",
150
+ expectAttempt: task.attempt,
151
+ expectExecution: task.execution,
152
+ output: {
153
+ changeId,
154
+ headSha,
155
+ verdict,
156
+ summary,
157
+ findingCount: completedComments.length,
158
+ published: review !== void 0,
159
+ ...review === void 0 ? {} : { review }
160
+ }
161
+ });
162
+ return review === void 0 ? {
163
+ recorded: true,
164
+ verdict,
165
+ published: false,
166
+ taskState: "succeeded"
167
+ } : {
168
+ recorded: true,
169
+ verdict,
170
+ published: true,
171
+ review,
172
+ taskState: "succeeded"
173
+ };
174
+ }
175
+ });
176
+ }
177
+ function legacyFindingKey(comment) {
178
+ return `legacy-${createHash("sha256").update(`${comment.path}:${comment.line}:${comment.body}`).digest("hex").slice(0, 24)}`;
179
+ }
180
+ //#endregion
181
+ export { createGitHubPostReviewTool };
182
+
183
+ //# sourceMappingURL=eve-post-review.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eve-post-review.mjs","names":[],"sources":["../../src/code-review/eve-post-review.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\nimport type { CompletedReview, CompletedReviewFinding } from \"../code-review/contracts\";\nimport type { PublishedGitHubReview } from \"../code-review/github-contracts\";\nimport { requireTaskExecution } from \"../eve/task-execution\";\nimport {\n readPullRequestHead,\n StalePullRequestHeadError,\n submitPullRequestReview,\n type PullRequestReviewComment,\n type SubmittedPullRequestReview,\n} from \"../github\";\nimport { changeIdSchema, taskIdSchema, type ChangeId, type TaskId } from \"../schema/id\";\nimport type { RepositorySlug } from \"../schema/repository\";\nimport type { TaskState } from \"../schema/task\";\nimport type { FactoryStores } from \"../store/engine\";\n\n/** Change, repository, and Task capabilities required by the review publication tool. */\nexport type GitHubPostReviewToolStores = Pick<FactoryStores, \"changes\" | \"repositories\" | \"tasks\">;\n\n/** Configures GitHub access, publication, and durable review-reporting callbacks. */\nexport interface GitHubPostReviewToolOptions {\n stores: GitHubPostReviewToolStores;\n tokenForRepository: (repository: RepositorySlug) => Promise<string>;\n publishReviews?: boolean;\n onCompleted?: (completed: CompletedReview) => Promise<void>;\n onPublished?: (published: PublishedGitHubReview) => Promise<void>;\n fetch?: typeof globalThis.fetch;\n}\n\n/** Machine-readable reason a code review could not be recorded. */\nexport type GitHubPostReviewFailureCode =\n | \"task_not_found\"\n | \"task_kind_mismatch\"\n | \"task_not_running\"\n | \"change_not_found\"\n | \"change_not_reviewable\"\n | \"repository_not_found\"\n | \"stale_pull_request_head\";\n\n/** Outcome returned after validating, recording, and optionally publishing a code review. */\nexport type GitHubPostReviewResult =\n | {\n readonly recorded: false;\n readonly code: GitHubPostReviewFailureCode;\n readonly reason: string;\n readonly taskState?: TaskState;\n readonly verdict?: never;\n readonly published?: never;\n readonly review?: never;\n }\n | {\n readonly recorded: true;\n readonly verdict: CompletedReview[\"verdict\"];\n readonly published: false;\n readonly review?: never;\n readonly taskState: \"succeeded\";\n }\n | {\n readonly recorded: true;\n readonly verdict: CompletedReview[\"verdict\"];\n readonly published: true;\n readonly review: SubmittedPullRequestReview;\n readonly taskState: \"succeeded\";\n };\n\n/** Inline review finding accepted before Factory assigns its stable fingerprint. */\nexport interface GitHubPostReviewCommentInput extends Pick<\n CompletedReviewFinding,\n \"path\" | \"line\" | \"body\"\n> {\n key?: string;\n title?: string;\n}\n\n/** Completed review supplied for validation, recording, and optional GitHub publication. */\nexport interface GitHubPostReviewInput {\n taskId: TaskId;\n changeId: ChangeId;\n verdict: CompletedReview[\"verdict\"];\n headSha: string;\n summary: string;\n comments: readonly GitHubPostReviewCommentInput[];\n}\n\n/** Eve outcome tool that records and optionally publishes one completed code review. */\nexport interface GitHubPostReviewTool extends ToolDefinition<\n GitHubPostReviewInput,\n GitHubPostReviewResult\n> {\n execute(input: GitHubPostReviewInput, ctx: ToolContext): Promise<GitHubPostReviewResult>;\n}\n\nconst reviewCommentSchema = z.strictObject({\n key: z\n .string()\n .min(1)\n .max(80)\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)\n .optional()\n .describe(\n \"Stable kebab-case identity for this defect and cause; keep it unchanged across reruns.\",\n ),\n title: z.string().min(1).max(200).optional().describe(\"Short finding title.\"),\n path: z.string().min(1).max(500).describe(\"Repository-relative file path.\"),\n line: z.number().int().min(1).describe(\"Line in the pull request's new version.\"),\n body: z.string().min(1).max(5000).describe(\"Markdown explaining the finding and a concrete fix.\"),\n});\nconst reviewCommentsSchema = z\n .array(reviewCommentSchema)\n .max(50)\n .default([])\n .superRefine((comments, context) => {\n const seen = new Set<string>();\n comments.forEach((comment, index) => {\n if (comment.key === undefined) return;\n if (seen.has(comment.key)) {\n context.addIssue({\n code: \"custom\",\n message: `duplicate finding key: ${comment.key}`,\n path: [index, \"key\"],\n });\n }\n seen.add(comment.key);\n });\n })\n .readonly();\n\n/**\n * Publish an independent review of an existing pull request and finish the\n * review task without changing the pull request's factory lifecycle.\n */\nexport function createGitHubPostReviewTool(\n input: GitHubPostReviewToolOptions,\n): GitHubPostReviewTool {\n const { stores, ...options } = input;\n return defineTool({\n description:\n \"Record a completed code review and finish your code_review task. Results may be reported through completion callbacks instead of a GitHub review; use request_changes only for blocking findings.\",\n inputSchema: z.object({\n taskId: taskIdSchema.describe(\"Your code_review task.\"),\n changeId: changeIdSchema.describe(\"The pull request change from your starting message.\"),\n verdict: z.enum([\"approve\", \"request_changes\", \"comment\"]),\n headSha: z\n .string()\n .regex(/^[0-9a-f]{40}$/)\n .describe(\"Commit returned by fetch_pull_request.\"),\n summary: z\n .string()\n .min(1)\n .max(5000)\n .describe(\"Markdown summary of what you reviewed and found.\"),\n comments: reviewCommentsSchema,\n }),\n async execute(\n { taskId, changeId, verdict, headSha, summary, comments },\n ctx,\n ): Promise<GitHubPostReviewResult> {\n const task = await requireTaskExecution(stores, ctx, taskId);\n if (task.kind !== \"code_review\") {\n return {\n recorded: false as const,\n code: \"task_kind_mismatch\",\n reason: `${taskId} is not a code_review task`,\n };\n }\n if (task.state !== \"running\") {\n return {\n recorded: false as const,\n code: \"task_not_running\",\n reason: `task is ${task.state}, not running`,\n };\n }\n\n const change = await stores.changes.get(changeId);\n if (change === null) {\n return {\n recorded: false as const,\n code: \"change_not_found\",\n reason: `change ${changeId} does not exist`,\n };\n }\n if (change.state !== \"verifying\" && change.state !== \"ready\") {\n return {\n recorded: false as const,\n code: \"change_not_reviewable\",\n reason: `change is ${change.state}, not open for review`,\n };\n }\n const repository = await stores.repositories.get(change.repositoryId);\n if (repository === null) {\n return {\n recorded: false as const,\n code: \"repository_not_found\",\n reason: `repository ${change.repositoryId} does not exist`,\n };\n }\n if (\n task.changeId !== change.id ||\n task.repositoryIds.length !== 1 ||\n task.repositoryIds[0] !== repository.id\n ) {\n throw new Error(\"Authenticated review Task, Change, and repository must match\");\n }\n\n const token = await options.tokenForRepository(repository.slug);\n await requireTaskExecution(stores, ctx, taskId);\n const completedComments = comments.map((comment) => {\n const key = comment.key ?? legacyFindingKey(comment);\n return {\n ...comment,\n key,\n title: comment.title ?? \"Review finding\",\n fingerprint: createHash(\"sha256\")\n .update(`${repository.slug.toLowerCase()}#${change.prNumber}:${key}`)\n .digest(\"hex\"),\n };\n });\n const completed = {\n taskId,\n changeId,\n repository: repository.slug,\n pullRequestNumber: change.prNumber,\n headSha,\n verdict,\n summary,\n comments: completedComments,\n } satisfies CompletedReview;\n const publish = options.publishReviews !== false;\n let review: SubmittedPullRequestReview | undefined;\n try {\n if (publish) {\n review = await submitPullRequestReview({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n commitId: headSha,\n event:\n verdict === \"approve\"\n ? \"APPROVE\"\n : verdict === \"request_changes\"\n ? \"REQUEST_CHANGES\"\n : \"COMMENT\",\n body: summary,\n comments: completedComments,\n });\n } else {\n const head = await readPullRequestHead({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n });\n if (head.sha !== headSha) {\n throw new StalePullRequestHeadError(headSha, head.sha);\n }\n }\n } catch (error) {\n if (!(error instanceof StalePullRequestHeadError)) {\n throw error;\n }\n // The reviewer refused a stale head: the change moved on while this\n // review was in flight, so an identical retry against the same head\n // can never succeed either. Resolve the task as superseded right\n // here instead of leaving it running for the stall watchdog to\n // eventually -- and misleadingly -- report as \"stalled\".\n const resolved = await stores.tasks\n .transition(taskId, \"cancelled\", {\n expectFrom: \"running\",\n expectAttempt: task.attempt,\n expectExecution: task.execution,\n reason: `review superseded by newer commits: ${error.message}`,\n })\n .catch(() => null);\n return {\n recorded: false as const,\n code: \"stale_pull_request_head\",\n reason: error.message,\n taskState:\n resolved?.state ??\n (await stores.tasks.get(taskId).catch(() => null))?.state ??\n task.state,\n };\n }\n await requireTaskExecution(stores, ctx, taskId);\n if (review !== undefined) await options.onPublished?.({ ...completed, review });\n await requireTaskExecution(stores, ctx, taskId);\n await options.onCompleted?.(completed);\n await stores.tasks.transition(taskId, \"verifying\", {\n expectFrom: \"running\",\n expectAttempt: task.attempt,\n expectExecution: task.execution,\n reason: summary,\n });\n await stores.tasks.transition(taskId, \"succeeded\", {\n expectFrom: \"verifying\",\n expectAttempt: task.attempt,\n expectExecution: task.execution,\n output: {\n changeId,\n headSha,\n verdict,\n summary,\n findingCount: completedComments.length,\n published: review !== undefined,\n ...(review === undefined ? {} : { review }),\n },\n });\n return review === undefined\n ? {\n recorded: true,\n verdict,\n published: false,\n taskState: \"succeeded\",\n }\n : {\n recorded: true,\n verdict,\n published: true,\n review,\n taskState: \"succeeded\",\n };\n },\n });\n}\n\nfunction legacyFindingKey(comment: PullRequestReviewComment): string {\n const digest = createHash(\"sha256\")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M;GAC9C,IAAI,WAAW,KAAA,GAAW,MAAM,QAAQ,cAAc;IAAE,GAAG;IAAW;GAAO,CAAC;GAC9E,MAAM,qBAAqB,QAAQ,KAAK,MAAM;GAC9C,MAAM,QAAQ,cAAc,SAAS;GACrC,MAAM,OAAO,MAAM,WAAW,QAAQ,aAAa;IACjD,YAAY;IACZ,eAAe,KAAK;IACpB,iBAAiB,KAAK;IACtB,QAAQ;GACV,CAAC;GACD,MAAM,OAAO,MAAM,WAAW,QAAQ,aAAa;IACjD,YAAY;IACZ,eAAe,KAAK;IACpB,iBAAiB,KAAK;IACtB,QAAQ;KACN;KACA;KACA;KACA;KACA,cAAc,kBAAkB;KAChC,WAAW,WAAW,KAAA;KACtB,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;IAC3C;GACF,CAAC;GACD,OAAO,WAAW,KAAA,IACd;IACE,UAAU;IACV;IACA,WAAW;IACX,WAAW;GACb,IACA;IACE,UAAU;IACV;IACA,WAAW;IACX;IACA,WAAW;GACb;EACN;CACF,CAAC;AACH;AAEA,SAAS,iBAAiB,SAA2C;CAKnE,OAAO,UAJQ,WAAW,QAAQ,CAAC,CAChC,OAAO,GAAG,QAAQ,KAAK,GAAG,QAAQ,KAAK,GAAG,QAAQ,MAAM,CAAC,CACzD,OAAO,KAAK,CAAC,CACb,MAAM,GAAG,EACU;AACxB"}
@@ -0,0 +1,64 @@
1
+ import { ChangeId } from "../schema/id.mjs";
2
+ import { RepositorySlug } from "../schema/repository.mjs";
3
+ import { FactoryStores } from "../store/engine.mjs";
4
+ import { GitHubGitTransport } from "../github-transfer.mjs";
5
+ import { GitHubReviewComment } from "../github.mjs";
6
+ import { ToolContext, ToolDefinition } from "eve/tools";
7
+ //#region src/code-review/eve-review-comments.d.ts
8
+ /** Task, Change, and repository capabilities required by the pull-request review-comment tools. */
9
+ type GitHubReviewCommentToolsStores = Pick<FactoryStores, "changes" | "repositories" | "tasks">;
10
+ /** Configures GitHub access and optional credentialed publication for review-comment tools. */
11
+ interface GitHubReviewCommentToolsOptions {
12
+ stores: GitHubReviewCommentToolsStores;
13
+ tokenForRepository: (repository: RepositorySlug) => Promise<string>;
14
+ git?: GitHubGitTransport;
15
+ fetch?: typeof globalThis.fetch;
16
+ repoPath?: string;
17
+ }
18
+ /** Change and inline-comment identity accepted by the review-comment reader. */
19
+ interface GitHubReadReviewCommentInput {
20
+ changeId: ChangeId;
21
+ commentId: number;
22
+ }
23
+ /** Reply content posted to one inline pull-request review comment. */
24
+ interface GitHubAnswerReviewCommentInput extends GitHubReadReviewCommentInput {
25
+ body: string;
26
+ }
27
+ /** Medium-confidence suggested edit posted to one inline review comment. */
28
+ interface GitHubSuggestReviewFixInput extends GitHubReadReviewCommentInput {
29
+ confidence: "medium";
30
+ replacement: string;
31
+ summary: string;
32
+ }
33
+ /** High-confidence committed edit published to one reviewed pull request. */
34
+ interface GitHubApplyReviewFixInput extends GitHubReadReviewCommentInput {
35
+ confidence: "high";
36
+ summary: string;
37
+ }
38
+ /** Pull-request update and reply returned after publishing a committed review fix. */
39
+ interface GitHubApplyReviewFixResult {
40
+ readonly updated: true;
41
+ readonly prNumber: number;
42
+ readonly prUrl: string;
43
+ readonly reply: GitHubReviewComment;
44
+ }
45
+ /** Tools for reading, answering, suggesting, and applying GitHub review comments. */
46
+ interface GitHubReviewCommentTools {
47
+ readonly read_review_comment: ToolDefinition<GitHubReadReviewCommentInput, GitHubReviewComment> & {
48
+ execute(input: GitHubReadReviewCommentInput, ctx: ToolContext): Promise<GitHubReviewComment>;
49
+ };
50
+ readonly answer_review_comment: ToolDefinition<GitHubAnswerReviewCommentInput, GitHubReviewComment> & {
51
+ execute(input: GitHubAnswerReviewCommentInput, ctx: ToolContext): Promise<GitHubReviewComment>;
52
+ };
53
+ readonly suggest_review_fix: ToolDefinition<GitHubSuggestReviewFixInput, GitHubReviewComment> & {
54
+ execute(input: GitHubSuggestReviewFixInput, ctx: ToolContext): Promise<GitHubReviewComment>;
55
+ };
56
+ readonly apply_review_fix: ToolDefinition<GitHubApplyReviewFixInput, GitHubApplyReviewFixResult> & {
57
+ execute(input: GitHubApplyReviewFixInput, ctx: ToolContext): Promise<GitHubApplyReviewFixResult>;
58
+ };
59
+ }
60
+ /** Create tools for reading, answering, suggesting, and applying pull-request review fixes. */
61
+ declare function createGitHubReviewCommentTools(input: GitHubReviewCommentToolsOptions): GitHubReviewCommentTools;
62
+ //#endregion
63
+ export { GitHubAnswerReviewCommentInput, GitHubApplyReviewFixInput, GitHubApplyReviewFixResult, GitHubReadReviewCommentInput, GitHubReviewCommentTools, GitHubReviewCommentToolsOptions, GitHubReviewCommentToolsStores, GitHubSuggestReviewFixInput, createGitHubReviewCommentTools };
64
+ //# sourceMappingURL=eve-review-comments.d.mts.map
@@ -0,0 +1,159 @@
1
+ import { changeIdSchema } from "../schema/id.mjs";
2
+ import { taskBindingForSession } from "../eve/task-session.mjs";
3
+ import { requireTaskExecution } from "../eve/task-execution.mjs";
4
+ import { pushGitHubHead } from "../github-transfer.mjs";
5
+ import { answerReviewComment, readPullRequestHead, readReviewComment } from "../github.mjs";
6
+ import { z } from "zod";
7
+ import { defineTool } from "eve/tools";
8
+ //#region src/code-review/eve-review-comments.ts
9
+ async function authorizeReviewChange(stores, ctx, changeId) {
10
+ const taskId = taskBindingForSession(ctx.session?.auth?.initiator).taskId;
11
+ const task = await requireTaskExecution(stores, ctx, taskId);
12
+ const change = await stores.changes.get(changeId);
13
+ if (change === null) throw new Error(`change ${changeId} does not exist`);
14
+ if (change.state !== "verifying" && change.state !== "ready") throw new Error(`change is ${change.state}, not open for review`);
15
+ const repository = await stores.repositories.get(change.repositoryId);
16
+ if (repository === null) throw new Error(`repository ${change.repositoryId} does not exist`);
17
+ if (task.changeId !== change.id || task.repositoryIds.length !== 1 || task.repositoryIds[0] !== repository.id) throw new Error("Authenticated Task, Change, and repository must match");
18
+ return {
19
+ task,
20
+ change,
21
+ repository
22
+ };
23
+ }
24
+ async function requireCurrentExecution(stores, ctx, task) {
25
+ await requireTaskExecution(stores, ctx, task.id);
26
+ }
27
+ /** Create tools for reading, answering, suggesting, and applying pull-request review fixes. */
28
+ function createGitHubReviewCommentTools(input) {
29
+ const { stores, ...options } = input;
30
+ const repoPath = options.repoPath ?? "repo";
31
+ const commentInputSchema = z.object({
32
+ changeId: changeIdSchema.describe("The change under review, from your starting message."),
33
+ commentId: z.number().int().positive().describe("The GitHub review comment id.")
34
+ });
35
+ return {
36
+ read_review_comment: defineTool({
37
+ description: "Read an inline review comment on a change under verification or ready for human review. By default this refuses to return comments from people without write access to the repository.",
38
+ inputSchema: commentInputSchema,
39
+ async execute({ changeId, commentId }, ctx) {
40
+ const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);
41
+ const token = await options.tokenForRepository(repository.slug);
42
+ await requireCurrentExecution(stores, ctx, task);
43
+ const comment = await readReviewComment({
44
+ repository: repository.slug,
45
+ token,
46
+ fetch: options.fetch,
47
+ pullRequestNumber: change.prNumber,
48
+ commentId
49
+ });
50
+ await requireCurrentExecution(stores, ctx, task);
51
+ return comment;
52
+ }
53
+ }),
54
+ answer_review_comment: defineTool({
55
+ description: "Reply to an inline review comment on a change under verification or ready for human review. Use for findings and low-confidence responses, not for a concrete medium- or high-confidence fix.",
56
+ inputSchema: commentInputSchema.extend({ body: z.string().min(1).max(5e3).describe("The Markdown reply to post.") }),
57
+ async execute({ changeId, commentId, body }, ctx) {
58
+ const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);
59
+ const token = await options.tokenForRepository(repository.slug);
60
+ await requireCurrentExecution(stores, ctx, task);
61
+ const reply = await answerReviewComment({
62
+ repository: repository.slug,
63
+ token,
64
+ fetch: options.fetch,
65
+ pullRequestNumber: change.prNumber,
66
+ commentId,
67
+ body
68
+ });
69
+ await requireCurrentExecution(stores, ctx, task);
70
+ return reply;
71
+ }
72
+ }),
73
+ suggest_review_fix: defineTool({
74
+ description: "Post a concrete, apply-able GitHub suggested change for a medium-confidence fix. The replacement must cover exactly the lines attached to the inline review comment.",
75
+ inputSchema: commentInputSchema.extend({
76
+ confidence: z.literal("medium"),
77
+ replacement: z.string().min(1).max(5e3).describe("Exact replacement text for the commented lines."),
78
+ summary: z.string().min(1).max(1e3).describe("A brief explanation of the suggested fix.")
79
+ }),
80
+ async execute({ changeId, commentId, replacement, summary }, ctx) {
81
+ const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);
82
+ const token = await options.tokenForRepository(repository.slug);
83
+ await requireCurrentExecution(stores, ctx, task);
84
+ const reply = await answerReviewComment({
85
+ repository: repository.slug,
86
+ token,
87
+ fetch: options.fetch,
88
+ pullRequestNumber: change.prNumber,
89
+ commentId,
90
+ body: `${summary}\n\n\`\`\`suggestion\n${replacement}\n\`\`\``
91
+ });
92
+ await requireCurrentExecution(stores, ctx, task);
93
+ return reply;
94
+ }
95
+ }),
96
+ apply_review_fix: defineTool({
97
+ description: "Publish a tested, committed high-confidence fix to the existing same-repository pull request branch. Fails if the checkout is dirty, the PR changed, or the PR comes from a fork.",
98
+ inputSchema: commentInputSchema.extend({
99
+ confidence: z.literal("high"),
100
+ summary: z.string().min(1).max(1e3).describe("What was fixed and verified.")
101
+ }),
102
+ async execute({ changeId, commentId, summary }, ctx) {
103
+ const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);
104
+ if (options.git === void 0) throw new Error("applying review fixes is not configured");
105
+ const token = await options.tokenForRepository(repository.slug);
106
+ await requireCurrentExecution(stores, ctx, task);
107
+ await readReviewComment({
108
+ repository: repository.slug,
109
+ token,
110
+ fetch: options.fetch,
111
+ pullRequestNumber: change.prNumber,
112
+ commentId
113
+ });
114
+ await requireCurrentExecution(stores, ctx, task);
115
+ const head = await readPullRequestHead({
116
+ repository: repository.slug,
117
+ token,
118
+ fetch: options.fetch,
119
+ pullRequestNumber: change.prNumber
120
+ });
121
+ if (head.repository !== repository.slug.toLowerCase()) throw new Error("cannot apply a fix to a pull request from a fork");
122
+ const sandbox = await ctx.getSandbox();
123
+ const git = `git -C ${repoPath}`;
124
+ if ((await sandbox.run({ command: `${git} status --porcelain` })).stdout.trim() !== "") throw new Error("commit the review fix before publishing");
125
+ if ((await sandbox.run({ command: `${git} merge-base --is-ancestor ${head.sha} HEAD` })).exitCode !== 0) throw new Error("pull request changed after it was fetched; fetch it again before applying the fix");
126
+ if ((await sandbox.run({ command: `${git} rev-parse HEAD` })).stdout.trim() === head.sha) throw new Error("no committed review fix to publish");
127
+ await requireCurrentExecution(stores, ctx, task);
128
+ await pushGitHubHead({
129
+ sandbox,
130
+ transport: options.git,
131
+ repository: repository.slug,
132
+ branch: head.branch,
133
+ expectedHead: head.sha,
134
+ repositoryPath: repoPath
135
+ });
136
+ await requireCurrentExecution(stores, ctx, task);
137
+ const reply = await answerReviewComment({
138
+ repository: repository.slug,
139
+ token,
140
+ fetch: options.fetch,
141
+ pullRequestNumber: change.prNumber,
142
+ commentId,
143
+ body: summary
144
+ });
145
+ await requireCurrentExecution(stores, ctx, task);
146
+ return {
147
+ updated: true,
148
+ prNumber: change.prNumber,
149
+ prUrl: change.prUrl,
150
+ reply
151
+ };
152
+ }
153
+ })
154
+ };
155
+ }
156
+ //#endregion
157
+ export { createGitHubReviewCommentTools };
158
+
159
+ //# sourceMappingURL=eve-review-comments.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eve-review-comments.mjs","names":[],"sources":["../../src/code-review/eve-review-comments.ts"],"sourcesContent":["import { pushGitHubHead, type GitHubGitTransport } from \"../github-transfer\";\nimport {\n answerReviewComment,\n readPullRequestHead,\n readReviewComment,\n type GitHubReviewComment,\n} from \"../github\";\nimport { requireTaskExecution } from \"../eve/task-execution\";\nimport { taskBindingForSession } from \"../eve/task-session\";\nimport { changeIdSchema, type ChangeId } from \"../schema/id\";\nimport type { RepositorySlug } from \"../schema/repository\";\nimport type { Change } from \"../schema/change\";\nimport type { Repository } from \"../schema/repository\";\nimport type { Task } from \"../schema/task\";\nimport type { FactoryStores } from \"../store/engine\";\nimport { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\n\n/** Task, Change, and repository capabilities required by the pull-request review-comment tools. */\nexport type GitHubReviewCommentToolsStores = Pick<\n FactoryStores,\n \"changes\" | \"repositories\" | \"tasks\"\n>;\n\n/** Configures GitHub access and optional credentialed publication for review-comment tools. */\nexport interface GitHubReviewCommentToolsOptions {\n stores: GitHubReviewCommentToolsStores;\n tokenForRepository: (repository: RepositorySlug) => Promise<string>;\n git?: GitHubGitTransport;\n fetch?: typeof globalThis.fetch;\n repoPath?: string;\n}\n\n/** Change and inline-comment identity accepted by the review-comment reader. */\nexport interface GitHubReadReviewCommentInput {\n changeId: ChangeId;\n commentId: number;\n}\n\n/** Reply content posted to one inline pull-request review comment. */\nexport interface GitHubAnswerReviewCommentInput extends GitHubReadReviewCommentInput {\n body: string;\n}\n\n/** Medium-confidence suggested edit posted to one inline review comment. */\nexport interface GitHubSuggestReviewFixInput extends GitHubReadReviewCommentInput {\n confidence: \"medium\";\n replacement: string;\n summary: string;\n}\n\n/** High-confidence committed edit published to one reviewed pull request. */\nexport interface GitHubApplyReviewFixInput extends GitHubReadReviewCommentInput {\n confidence: \"high\";\n summary: string;\n}\n\n/** Pull-request update and reply returned after publishing a committed review fix. */\nexport interface GitHubApplyReviewFixResult {\n readonly updated: true;\n readonly prNumber: number;\n readonly prUrl: string;\n readonly reply: GitHubReviewComment;\n}\n\n/** Tools for reading, answering, suggesting, and applying GitHub review comments. */\nexport interface GitHubReviewCommentTools {\n readonly read_review_comment: ToolDefinition<\n GitHubReadReviewCommentInput,\n GitHubReviewComment\n > & {\n execute(input: GitHubReadReviewCommentInput, ctx: ToolContext): Promise<GitHubReviewComment>;\n };\n readonly answer_review_comment: ToolDefinition<\n GitHubAnswerReviewCommentInput,\n GitHubReviewComment\n > & {\n execute(input: GitHubAnswerReviewCommentInput, ctx: ToolContext): Promise<GitHubReviewComment>;\n };\n readonly suggest_review_fix: ToolDefinition<GitHubSuggestReviewFixInput, GitHubReviewComment> & {\n execute(input: GitHubSuggestReviewFixInput, ctx: ToolContext): Promise<GitHubReviewComment>;\n };\n readonly apply_review_fix: ToolDefinition<\n GitHubApplyReviewFixInput,\n GitHubApplyReviewFixResult\n > & {\n execute(\n input: GitHubApplyReviewFixInput,\n ctx: ToolContext,\n ): Promise<GitHubApplyReviewFixResult>;\n };\n}\n\nasync function authorizeReviewChange(\n stores: GitHubReviewCommentToolsStores,\n ctx: ToolContext,\n changeId: ChangeId,\n): Promise<{ task: Task; change: Change; repository: Repository }> {\n const taskId = taskBindingForSession(ctx.session?.auth?.initiator).taskId;\n const task = await requireTaskExecution(stores, ctx, taskId);\n const change = await stores.changes.get(changeId);\n if (change === null) throw new Error(`change ${changeId} does not exist`);\n if (change.state !== \"verifying\" && change.state !== \"ready\") {\n throw new Error(`change is ${change.state}, not open for review`);\n }\n const repository = await stores.repositories.get(change.repositoryId);\n if (repository === null) throw new Error(`repository ${change.repositoryId} does not exist`);\n if (\n task.changeId !== change.id ||\n task.repositoryIds.length !== 1 ||\n task.repositoryIds[0] !== repository.id\n ) {\n throw new Error(\"Authenticated Task, Change, and repository must match\");\n }\n return { task, change, repository };\n}\n\nasync function requireCurrentExecution(\n stores: GitHubReviewCommentToolsStores,\n ctx: ToolContext,\n task: Task,\n): Promise<void> {\n await requireTaskExecution(stores, ctx, task.id);\n}\n\n/** Create tools for reading, answering, suggesting, and applying pull-request review fixes. */\nexport function createGitHubReviewCommentTools(\n input: GitHubReviewCommentToolsOptions,\n): GitHubReviewCommentTools {\n const { stores, ...options } = input;\n const repoPath = options.repoPath ?? \"repo\";\n const commentInputSchema = z.object({\n changeId: changeIdSchema.describe(\"The change under review, from your starting message.\"),\n commentId: z.number().int().positive().describe(\"The GitHub review comment id.\"),\n });\n\n return {\n read_review_comment: defineTool({\n description:\n \"Read an inline review comment on a change under verification or ready for human review. By default this refuses to return comments from people without write access to the repository.\",\n inputSchema: commentInputSchema,\n async execute({ changeId, commentId }, ctx): Promise<GitHubReviewComment> {\n const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);\n const token = await options.tokenForRepository(repository.slug);\n await requireCurrentExecution(stores, ctx, task);\n const comment = await readReviewComment({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n commentId,\n });\n await requireCurrentExecution(stores, ctx, task);\n return comment;\n },\n }),\n answer_review_comment: defineTool({\n description:\n \"Reply to an inline review comment on a change under verification or ready for human review. Use for findings and low-confidence responses, not for a concrete medium- or high-confidence fix.\",\n inputSchema: commentInputSchema.extend({\n body: z.string().min(1).max(5000).describe(\"The Markdown reply to post.\"),\n }),\n async execute({ changeId, commentId, body }, ctx): Promise<GitHubReviewComment> {\n const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);\n const token = await options.tokenForRepository(repository.slug);\n await requireCurrentExecution(stores, ctx, task);\n const reply = await answerReviewComment({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n commentId,\n body,\n });\n await requireCurrentExecution(stores, ctx, task);\n return reply;\n },\n }),\n suggest_review_fix: defineTool({\n description:\n \"Post a concrete, apply-able GitHub suggested change for a medium-confidence fix. The replacement must cover exactly the lines attached to the inline review comment.\",\n inputSchema: commentInputSchema.extend({\n confidence: z.literal(\"medium\"),\n replacement: z\n .string()\n .min(1)\n .max(5000)\n .describe(\"Exact replacement text for the commented lines.\"),\n summary: z.string().min(1).max(1000).describe(\"A brief explanation of the suggested fix.\"),\n }),\n async execute(\n { changeId, commentId, replacement, summary },\n ctx,\n ): Promise<GitHubReviewComment> {\n const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);\n const token = await options.tokenForRepository(repository.slug);\n await requireCurrentExecution(stores, ctx, task);\n const reply = await answerReviewComment({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n commentId,\n body: `${summary}\\n\\n\\`\\`\\`suggestion\\n${replacement}\\n\\`\\`\\``,\n });\n await requireCurrentExecution(stores, ctx, task);\n return reply;\n },\n }),\n apply_review_fix: defineTool({\n description:\n \"Publish a tested, committed high-confidence fix to the existing same-repository pull request branch. Fails if the checkout is dirty, the PR changed, or the PR comes from a fork.\",\n inputSchema: commentInputSchema.extend({\n confidence: z.literal(\"high\"),\n summary: z.string().min(1).max(1000).describe(\"What was fixed and verified.\"),\n }),\n async execute({ changeId, commentId, summary }, ctx): Promise<GitHubApplyReviewFixResult> {\n const { task, change, repository } = await authorizeReviewChange(stores, ctx, changeId);\n if (options.git === undefined) {\n throw new Error(\"applying review fixes is not configured\");\n }\n const token = await options.tokenForRepository(repository.slug);\n await requireCurrentExecution(stores, ctx, task);\n await readReviewComment({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n commentId,\n });\n await requireCurrentExecution(stores, ctx, task);\n const head = await readPullRequestHead({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n });\n if (head.repository !== repository.slug.toLowerCase()) {\n throw new Error(\"cannot apply a fix to a pull request from a fork\");\n }\n const sandbox = await ctx.getSandbox();\n const git = `git -C ${repoPath}`;\n const clean = await sandbox.run({ command: `${git} status --porcelain` });\n if (clean.stdout.trim() !== \"\") throw new Error(\"commit the review fix before publishing\");\n const ancestor = await sandbox.run({\n command: `${git} merge-base --is-ancestor ${head.sha} HEAD`,\n });\n if (ancestor.exitCode !== 0) {\n throw new Error(\n \"pull request changed after it was fetched; fetch it again before applying the fix\",\n );\n }\n const localHead = await sandbox.run({ command: `${git} rev-parse HEAD` });\n if (localHead.stdout.trim() === head.sha)\n throw new Error(\"no committed review fix to publish\");\n await requireCurrentExecution(stores, ctx, task);\n await pushGitHubHead({\n sandbox,\n transport: options.git,\n repository: repository.slug,\n branch: head.branch,\n expectedHead: head.sha,\n repositoryPath: repoPath,\n });\n await requireCurrentExecution(stores, ctx, task);\n const reply = await answerReviewComment({\n repository: repository.slug,\n token,\n fetch: options.fetch,\n pullRequestNumber: change.prNumber,\n commentId,\n body: summary,\n });\n await requireCurrentExecution(stores, ctx, task);\n return { updated: true as const, prNumber: change.prNumber, prUrl: change.prUrl, reply };\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;AA6FA,eAAe,sBACb,QACA,KACA,UACiE;CACjE,MAAM,SAAS,sBAAsB,IAAI,SAAS,MAAM,SAAS,CAAC,CAAC;CACnE,MAAM,OAAO,MAAM,qBAAqB,QAAQ,KAAK,MAAM;CAC3D,MAAM,SAAS,MAAM,OAAO,QAAQ,IAAI,QAAQ;CAChD,IAAI,WAAW,MAAM,MAAM,IAAI,MAAM,UAAU,SAAS,gBAAgB;CACxE,IAAI,OAAO,UAAU,eAAe,OAAO,UAAU,SACnD,MAAM,IAAI,MAAM,aAAa,OAAO,MAAM,sBAAsB;CAElE,MAAM,aAAa,MAAM,OAAO,aAAa,IAAI,OAAO,YAAY;CACpE,IAAI,eAAe,MAAM,MAAM,IAAI,MAAM,cAAc,OAAO,aAAa,gBAAgB;CAC3F,IACE,KAAK,aAAa,OAAO,MACzB,KAAK,cAAc,WAAW,KAC9B,KAAK,cAAc,OAAO,WAAW,IAErC,MAAM,IAAI,MAAM,uDAAuD;CAEzE,OAAO;EAAE;EAAM;EAAQ;CAAW;AACpC;AAEA,eAAe,wBACb,QACA,KACA,MACe;CACf,MAAM,qBAAqB,QAAQ,KAAK,KAAK,EAAE;AACjD;;AAGA,SAAgB,+BACd,OAC0B;CAC1B,MAAM,EAAE,QAAQ,GAAG,YAAY;CAC/B,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,qBAAqB,EAAE,OAAO;EAClC,UAAU,eAAe,SAAS,sDAAsD;EACxF,WAAW,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,+BAA+B;CACjF,CAAC;CAED,OAAO;EACL,qBAAqB,WAAW;GAC9B,aACE;GACF,aAAa;GACb,MAAM,QAAQ,EAAE,UAAU,aAAa,KAAmC;IACxE,MAAM,EAAE,MAAM,QAAQ,eA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;IACrC,MAAM,MAAM,UAAU;IAEtB,KAAI,MADgB,QAAQ,IAAI,EAAE,SAAS,GAAG,IAAI,qBAAqB,CAAC,EAAA,CAC9D,OAAO,KAAK,MAAM,IAAI,MAAM,IAAI,MAAM,yCAAyC;IAIzF,KAAI,MAHmB,QAAQ,IAAI,EACjC,SAAS,GAAG,IAAI,4BAA4B,KAAK,IAAI,OACvD,CAAC,EAAA,CACY,aAAa,GACxB,MAAM,IAAI,MACR,mFACF;IAGF,KAAI,MADoB,QAAQ,IAAI,EAAE,SAAS,GAAG,IAAI,iBAAiB,CAAC,EAAA,CAC1D,OAAO,KAAK,MAAM,KAAK,KACnC,MAAM,IAAI,MAAM,oCAAoC;IACtD,MAAM,wBAAwB,QAAQ,KAAK,IAAI;IAC/C,MAAM,eAAe;KACnB;KACA,WAAW,QAAQ;KACnB,YAAY,WAAW;KACvB,QAAQ,KAAK;KACb,cAAc,KAAK;KACnB,gBAAgB;IAClB,CAAC;IACD,MAAM,wBAAwB,QAAQ,KAAK,IAAI;IAC/C,MAAM,QAAQ,MAAM,oBAAoB;KACtC,YAAY,WAAW;KACvB;KACA,OAAO,QAAQ;KACf,mBAAmB,OAAO;KAC1B;KACA,MAAM;IACR,CAAC;IACD,MAAM,wBAAwB,QAAQ,KAAK,IAAI;IAC/C,OAAO;KAAE,SAAS;KAAe,UAAU,OAAO;KAAU,OAAO,OAAO;KAAO;IAAM;GACzF;EACF,CAAC;CACH;AACF"}
@@ -0,0 +1,10 @@
1
+ import { CompletedReview } from "./contracts.mjs";
2
+ import { SubmittedPullRequestReview } from "../github.mjs";
3
+ //#region src/code-review/github-contracts.d.ts
4
+ /** A completed review together with the GitHub review created from it. */
5
+ interface PublishedGitHubReview extends CompletedReview {
6
+ review: SubmittedPullRequestReview;
7
+ }
8
+ //#endregion
9
+ export { PublishedGitHubReview };
10
+ //# sourceMappingURL=github-contracts.d.mts.map
@@ -0,0 +1,44 @@
1
+ import { TaskId } from "../schema/id.mjs";
2
+ import { RepositorySlug } from "../schema/repository.mjs";
3
+ import { Task } from "../schema/task.mjs";
4
+ import { DateClock } from "../schema/common.mjs";
5
+ import { FactoryStores } from "../store/engine.mjs";
6
+ import { CompletedReview } from "./contracts.mjs";
7
+ import { StartReviewCheckInput } from "./preparation.mjs";
8
+ //#region src/code-review/github-reporter.d.ts
9
+ /** Storage, credentials, and presentation settings for GitHub review reporting. */
10
+ interface GitHubReviewReporterOptions {
11
+ stores: Pick<FactoryStores, "taskEffects" | "changes" | "repositories">;
12
+ tokenForRepository(repositorySlug: RepositorySlug): Promise<string>;
13
+ fetch?: typeof globalThis.fetch;
14
+ checkName?: string;
15
+ summaryHeading?: string;
16
+ now?: DateClock;
17
+ }
18
+ /** Check-run and pull-request summary lifecycle for supplied code reviews. */
19
+ interface GitHubReviewReporter {
20
+ startReviewCheck(input: StartReviewCheckInput): Promise<void>;
21
+ completeReviewCheck(review: CompletedReview): Promise<void>;
22
+ reconcileReviewChecks(input: ReconcileReviewChecksInput): Promise<ReconcileReviewChecksResult>;
23
+ }
24
+ /** Bounded rotating-page controls for abandoned review-check recovery. */
25
+ interface ReconcileReviewChecksOptions {
26
+ batchSize?: number;
27
+ /** Stable page selector; defaults to the current five-minute recovery window. */
28
+ candidatePage?: number;
29
+ now?: DateClock;
30
+ }
31
+ /** Review Tasks and bounded recovery controls for one reconciliation pass. */
32
+ interface ReconcileReviewChecksInput extends ReconcileReviewChecksOptions {
33
+ tasks: readonly Task[];
34
+ }
35
+ /** Review Tasks whose check effects were concluded or durably resolved in one pass. */
36
+ interface ReconcileReviewChecksResult {
37
+ concluded: readonly TaskId[];
38
+ stamped: readonly TaskId[];
39
+ }
40
+ /** Create the supplied GitHub check-run and pull-request summary reporter for code reviews. */
41
+ declare function createGitHubReviewReporter(options: GitHubReviewReporterOptions): GitHubReviewReporter;
42
+ //#endregion
43
+ export { GitHubReviewReporter, GitHubReviewReporterOptions, ReconcileReviewChecksInput, ReconcileReviewChecksOptions, ReconcileReviewChecksResult, createGitHubReviewReporter };
44
+ //# sourceMappingURL=github-reporter.d.mts.map