@vercel/factory 0.0.13 → 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 (458) hide show
  1. package/README.md +307 -1
  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 +77 -0
  14. package/dist/api.mjs +1087 -0
  15. package/dist/api.mjs.map +1 -0
  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 +44 -8
  29. package/dist/blob/index.mjs +159 -35
  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 -2
  92. package/dist/connectors/index.mjs +4 -26
  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 -41
  103. package/dist/connectors/slack.mjs +13 -69
  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 -1561
  124. package/dist/eve/index.mjs +244 -1063
  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 +250 -37
  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 -314
  175. package/dist/index.mjs +14 -1124
  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-DwCihQr4.mjs → schema/common.mjs} +7 -14
  303. package/dist/schema/common.mjs.map +1 -0
  304. package/dist/schema/communication.d.mts +52 -0
  305. package/dist/schema/communication.mjs +35 -0
  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 -40
  443. package/dist/approval-CwhTP1XB.mjs +0 -269
  444. package/dist/approval-CwhTP1XB.mjs.map +0 -1
  445. package/dist/change-CzEAoFVE.mjs +0 -620
  446. package/dist/change-CzEAoFVE.mjs.map +0 -1
  447. package/dist/dispatch-B77cuPxh.d.mts +0 -713
  448. package/dist/driver-BJutB0PE.d.mts +0 -34
  449. package/dist/driver-Bbd25rNM.mjs +0 -23
  450. package/dist/driver-Bbd25rNM.mjs.map +0 -1
  451. package/dist/factory-config-BJcjsPKl.mjs +0 -86
  452. package/dist/factory-config-BJcjsPKl.mjs.map +0 -1
  453. package/dist/factory-config-D2yU3G0c.d.mts +0 -58
  454. package/dist/github-DXsxboUL.d.mts +0 -271
  455. package/dist/id-DwCihQr4.mjs.map +0 -1
  456. package/dist/index-Cy4jfXh5.d.mts +0 -67
  457. package/dist/index.mjs.map +0 -1
  458. package/dist/signal-CHVEmzvI.d.mts +0 -59
@@ -0,0 +1,80 @@
1
+ import { z } from "zod";
2
+ //#region src/workspace-snapshot.ts
3
+ /** Validates the bounded committed-tree snapshot captured inside an execution workspace. */
4
+ const workspaceSnapshotSchema = z.object({
5
+ truncated: z.boolean(),
6
+ files: z.array(z.object({
7
+ path: z.string(),
8
+ oldMode: z.string().nullable(),
9
+ newMode: z.string().nullable(),
10
+ oldSha: z.string().nullable(),
11
+ newSha: z.string().nullable(),
12
+ content: z.string().max(2e5).nullable(),
13
+ binary: z.boolean(),
14
+ omitted: z.boolean()
15
+ })).max(200).readonly()
16
+ });
17
+ /**
18
+ * Captures a bounded committed-tree snapshot using only sandbox Node.js built-ins without
19
+ * writing the checkout or Git index.
20
+ */
21
+ const workspaceSnapshotScript = String.raw`
22
+ const fs = require('node:fs');
23
+ const path = require('node:path');
24
+ const { execFileSync } = require('node:child_process');
25
+ const input = JSON.parse(fs.readFileSync(process.argv[1], 'utf8'));
26
+ const root = input.root;
27
+ const started = Date.now();
28
+ const runGit = (args, encoding) => execFileSync('git', ['--no-optional-locks', '-c', 'core.fsmonitor=false', ...args], { cwd: root, timeout: 10000, maxBuffer: 16000000, encoding, env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' } });
29
+ const git = (args) => runGit(args, 'utf8');
30
+ const safe = (p) => p && !path.isAbsolute(p) && !p.split('/').some((v) => v === '..' || v === '.' || v.toLowerCase() === '.git' || !v);
31
+ function tree(ref) {
32
+ const entries = new Map();
33
+ for (const line of git(['ls-tree', '-rz', '-r', '--long', '--full-tree', ref]).split('\0').filter(Boolean)) {
34
+ const match = /^(\d+) (\w+) ([a-f0-9]+)\s+(-|\d+)\t([\s\S]+)$/u.exec(line);
35
+ if (!match || !safe(match[5])) throw new Error('Invalid repository tree');
36
+ entries.set(match[5], { mode: match[1], type: match[2], sha: match[3], size: match[4] === '-' ? null : Number(match[4]) });
37
+ }
38
+ return entries;
39
+ }
40
+ function entryBytes(entry) {
41
+ if (!entry) return Buffer.alloc(0);
42
+ if (entry.type !== 'blob' || entry.size === null || entry.size > 200000) return null;
43
+ return runGit(['cat-file', 'blob', entry.sha], null);
44
+ }
45
+ function text(data) {
46
+ if (data === null) return { content: null, binary: false };
47
+ if (data.includes(0)) return { content: null, binary: true };
48
+ try { return { content: new TextDecoder('utf-8', { fatal: true }).decode(data), binary: false }; }
49
+ catch { return { content: null, binary: true }; }
50
+ }
51
+ try {
52
+ if (fs.realpathSync(root) !== root || !fs.lstatSync(path.join(root, '.git')).isDirectory()) throw new Error('Workspace checkout unavailable');
53
+ if (!/^[a-f0-9]{40,64}$/u.test(input.headSha) || git(['rev-parse', '--verify', input.headSha + '^{commit}']).trim() !== input.headSha) throw new Error('Invalid branch head');
54
+ const base = new Map(input.tree.map((file) => [file.path, file]));
55
+ const head = tree(input.headSha);
56
+ const paths = [...new Set([...base.keys(), ...head.keys()])].sort();
57
+ const files = [];
58
+ let truncated = false, bytes = 0;
59
+ for (const p of paths) {
60
+ if (!safe(p)) throw new Error('Invalid repository path');
61
+ if (Date.now() - started > 15000 || files.length >= 200) { truncated = true; break; }
62
+ const before = base.get(p);
63
+ const after = head.get(p);
64
+ if (before && after && before.sha === after.sha && before.mode === after.mode) continue;
65
+ const decoded = text(entryBytes(after));
66
+ if (decoded.content !== null) bytes += Buffer.byteLength(decoded.content);
67
+ const omitted = Boolean(after && decoded.content === null && !decoded.binary) || bytes > 2000000 || before?.mode === '160000' || after?.mode === '160000';
68
+ files.push({ path: p, oldMode: before?.mode ?? null, newMode: after?.mode ?? null, oldSha: before?.sha ?? null, newSha: after?.sha ?? null, content: omitted ? null : decoded.content, binary: decoded.binary, omitted });
69
+ if (bytes > 2000000) truncated = true;
70
+ }
71
+ process.stdout.write(JSON.stringify({ files, truncated }));
72
+ } catch (error) {
73
+ process.stderr.write('Workspace inspection failed\n');
74
+ process.exitCode = 1;
75
+ }
76
+ `;
77
+ //#endregion
78
+ export { workspaceSnapshotSchema, workspaceSnapshotScript };
79
+
80
+ //# sourceMappingURL=workspace-snapshot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-snapshot.mjs","names":[],"sources":["../src/workspace-snapshot.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Validates the bounded committed-tree snapshot captured inside an execution workspace. */\nexport const workspaceSnapshotSchema = z.object({\n truncated: z.boolean(),\n files: z\n .array(\n z.object({\n path: z.string(),\n oldMode: z.string().nullable(),\n newMode: z.string().nullable(),\n oldSha: z.string().nullable(),\n newSha: z.string().nullable(),\n content: z.string().max(200_000).nullable(),\n binary: z.boolean(),\n omitted: z.boolean(),\n }),\n )\n .max(200)\n .readonly(),\n});\n\n/** A bounded committed-tree snapshot captured inside an execution workspace. */\nexport type WorkspaceSnapshot = z.infer<typeof workspaceSnapshotSchema>;\n\n/**\n * Captures a bounded committed-tree snapshot using only sandbox Node.js built-ins without\n * writing the checkout or Git index.\n */\nexport const workspaceSnapshotScript = String.raw`\nconst fs = require('node:fs');\nconst path = require('node:path');\nconst { execFileSync } = require('node:child_process');\nconst input = JSON.parse(fs.readFileSync(process.argv[1], 'utf8'));\nconst root = input.root;\nconst started = Date.now();\nconst runGit = (args, encoding) => execFileSync('git', ['--no-optional-locks', '-c', 'core.fsmonitor=false', ...args], { cwd: root, timeout: 10000, maxBuffer: 16000000, encoding, env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' } });\nconst git = (args) => runGit(args, 'utf8');\nconst safe = (p) => p && !path.isAbsolute(p) && !p.split('/').some((v) => v === '..' || v === '.' || v.toLowerCase() === '.git' || !v);\nfunction tree(ref) {\n const entries = new Map();\n for (const line of git(['ls-tree', '-rz', '-r', '--long', '--full-tree', ref]).split('\\0').filter(Boolean)) {\n const match = /^(\\d+) (\\w+) ([a-f0-9]+)\\s+(-|\\d+)\\t([\\s\\S]+)$/u.exec(line);\n if (!match || !safe(match[5])) throw new Error('Invalid repository tree');\n entries.set(match[5], { mode: match[1], type: match[2], sha: match[3], size: match[4] === '-' ? null : Number(match[4]) });\n }\n return entries;\n}\nfunction entryBytes(entry) {\n if (!entry) return Buffer.alloc(0);\n if (entry.type !== 'blob' || entry.size === null || entry.size > 200000) return null;\n return runGit(['cat-file', 'blob', entry.sha], null);\n}\nfunction text(data) {\n if (data === null) return { content: null, binary: false };\n if (data.includes(0)) return { content: null, binary: true };\n try { return { content: new TextDecoder('utf-8', { fatal: true }).decode(data), binary: false }; }\n catch { return { content: null, binary: true }; }\n}\ntry {\n if (fs.realpathSync(root) !== root || !fs.lstatSync(path.join(root, '.git')).isDirectory()) throw new Error('Workspace checkout unavailable');\n if (!/^[a-f0-9]{40,64}$/u.test(input.headSha) || git(['rev-parse', '--verify', input.headSha + '^{commit}']).trim() !== input.headSha) throw new Error('Invalid branch head');\n const base = new Map(input.tree.map((file) => [file.path, file]));\n const head = tree(input.headSha);\n const paths = [...new Set([...base.keys(), ...head.keys()])].sort();\n const files = [];\n let truncated = false, bytes = 0;\n for (const p of paths) {\n if (!safe(p)) throw new Error('Invalid repository path');\n if (Date.now() - started > 15000 || files.length >= 200) { truncated = true; break; }\n const before = base.get(p);\n const after = head.get(p);\n if (before && after && before.sha === after.sha && before.mode === after.mode) continue;\n const decoded = text(entryBytes(after));\n if (decoded.content !== null) bytes += Buffer.byteLength(decoded.content);\n const omitted = Boolean(after && decoded.content === null && !decoded.binary) || bytes > 2000000 || before?.mode === '160000' || after?.mode === '160000';\n files.push({ path: p, oldMode: before?.mode ?? null, newMode: after?.mode ?? null, oldSha: before?.sha ?? null, newSha: after?.sha ?? null, content: omitted ? null : decoded.content, binary: decoded.binary, omitted });\n if (bytes > 2000000) truncated = true;\n }\n process.stdout.write(JSON.stringify({ files, truncated }));\n} catch (error) {\n process.stderr.write('Workspace inspection failed\\n');\n process.exitCode = 1;\n}\n`;\n"],"mappings":";;;AAGA,MAAa,0BAA0B,EAAE,OAAO;CAC9C,WAAW,EAAE,QAAQ;CACrB,OAAO,EACJ,MACC,EAAE,OAAO;EACP,MAAM,EAAE,OAAO;EACf,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;EAC7B,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;EAC7B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;EAC5B,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;EAC5B,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,GAAO,CAAC,CAAC,SAAS;EAC1C,QAAQ,EAAE,QAAQ;EAClB,SAAS,EAAE,QAAQ;CACrB,CAAC,CACH,CAAC,CACA,IAAI,GAAG,CAAC,CACR,SAAS;AACd,CAAC;;;;;AASD,MAAa,0BAA0B,OAAO,GAAG"}
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "@vercel/factory",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "Schema, state machines, and kernel primitives for Agent Factory.",
5
+ "files": [
6
+ "dist"
7
+ ],
5
8
  "type": "module",
6
9
  "sideEffects": false,
7
10
  "main": "./dist/index.mjs",
@@ -12,80 +15,166 @@
12
15
  "import": "./dist/index.mjs",
13
16
  "default": "./dist/index.mjs"
14
17
  },
18
+ "./tasks": {
19
+ "types": "./dist/tasks.d.mts",
20
+ "import": "./dist/tasks.mjs"
21
+ },
22
+ "./workflows": {
23
+ "types": "./dist/workflows.d.mts",
24
+ "import": "./dist/workflows.mjs"
25
+ },
26
+ "./execution": {
27
+ "types": "./dist/execution-public.d.mts",
28
+ "import": "./dist/execution-public.mjs"
29
+ },
30
+ "./planning": {
31
+ "types": "./dist/planning/runtime.d.mts",
32
+ "import": "./dist/planning/runtime.mjs"
33
+ },
34
+ "./budgets": {
35
+ "types": "./dist/budgets.d.mts",
36
+ "import": "./dist/budgets.mjs"
37
+ },
38
+ "./signals": {
39
+ "types": "./dist/signals.d.mts",
40
+ "import": "./dist/signals.mjs"
41
+ },
42
+ "./receipts": {
43
+ "types": "./dist/receipts.d.mts",
44
+ "import": "./dist/receipts.mjs"
45
+ },
46
+ "./storage": {
47
+ "types": "./dist/storage.d.mts",
48
+ "import": "./dist/storage.mjs"
49
+ },
50
+ "./storage/blob": {
51
+ "types": "./dist/blob/index.d.mts",
52
+ "import": "./dist/blob/index.mjs"
53
+ },
54
+ "./storage/postgres": {
55
+ "types": "./dist/postgres/index.d.mts",
56
+ "import": "./dist/postgres/index.mjs"
57
+ },
58
+ "./communication": {
59
+ "types": "./dist/communication.d.mts",
60
+ "import": "./dist/communication.mjs"
61
+ },
62
+ "./integrations/deepsec": {
63
+ "types": "./dist/integrations/deepsec.d.mts",
64
+ "import": "./dist/integrations/deepsec.mjs"
65
+ },
66
+ "./integrations/github": {
67
+ "types": "./dist/integrations/github.d.mts",
68
+ "import": "./dist/integrations/github.mjs"
69
+ },
70
+ "./integrations/slack": {
71
+ "types": "./dist/integrations/slack.d.mts",
72
+ "import": "./dist/integrations/slack.mjs"
73
+ },
74
+ "./integrations/vercel": {
75
+ "types": "./dist/integrations/vercel.d.mts",
76
+ "import": "./dist/integrations/vercel.mjs"
77
+ },
78
+ "./client": {
79
+ "types": "./dist/client.d.mts",
80
+ "import": "./dist/client.mjs"
81
+ },
82
+ "./api": {
83
+ "types": "./dist/api.d.mts",
84
+ "import": "./dist/api.mjs"
85
+ },
15
86
  "./next": {
16
87
  "types": "./dist/build-factory.d.mts",
17
88
  "import": "./dist/build-factory.mjs",
18
89
  "default": "./dist/build-factory.mjs"
19
90
  },
20
- "./postgres": {
21
- "types": "./dist/postgres/index.d.mts",
22
- "import": "./dist/postgres/index.mjs"
91
+ "./changes": {
92
+ "types": "./dist/changes.d.mts",
93
+ "import": "./dist/changes.mjs"
23
94
  },
24
- "./blob": {
25
- "types": "./dist/blob/index.d.mts",
26
- "import": "./dist/blob/index.mjs"
95
+ "./findings": {
96
+ "types": "./dist/findings.d.mts",
97
+ "import": "./dist/findings.mjs"
27
98
  },
28
- "./eve": {
29
- "types": "./dist/eve/index.d.mts",
30
- "import": "./dist/eve/index.mjs"
99
+ "./code-review": {
100
+ "types": "./dist/code-review.d.mts",
101
+ "import": "./dist/code-review.mjs"
31
102
  },
32
- "./github": {
33
- "types": "./dist/github.d.mts",
34
- "import": "./dist/github.mjs"
103
+ "./pull-requests": {
104
+ "types": "./dist/pull-requests.d.mts",
105
+ "import": "./dist/pull-requests.mjs"
35
106
  },
36
- "./connectors/slack": {
37
- "types": "./dist/connectors/slack.d.mts",
38
- "import": "./dist/connectors/slack.mjs"
107
+ "./work-triage": {
108
+ "types": "./dist/work-triage.d.mts",
109
+ "import": "./dist/work-triage.mjs"
39
110
  },
40
- "./vercel": {
41
- "types": "./dist/vercel.d.mts",
42
- "import": "./dist/vercel.mjs"
111
+ "./delivery-metrics": {
112
+ "types": "./dist/delivery-metrics.d.mts",
113
+ "import": "./dist/delivery-metrics.mjs"
43
114
  },
44
- "./connectors": {
45
- "types": "./dist/connectors/index.d.mts",
46
- "import": "./dist/connectors/index.mjs"
115
+ "./presets/software-development": {
116
+ "types": "./dist/presets/software-development.d.mts",
117
+ "import": "./dist/presets/software-development.mjs",
118
+ "default": "./dist/presets/software-development.mjs"
119
+ },
120
+ "./sandbox": {
121
+ "types": "./dist/sandbox/index.d.mts",
122
+ "import": "./dist/sandbox/index.mjs"
47
123
  },
48
124
  "./package.json": "./package.json"
49
125
  },
50
- "files": [
51
- "dist"
52
- ],
53
- "engines": {
54
- "node": ">=22"
126
+ "dependencies": {
127
+ "diff": "8.0.2"
128
+ },
129
+ "devDependencies": {
130
+ "@ai-sdk/harness": "1.0.108",
131
+ "@ai-sdk/harness-claude-code": "1.0.112",
132
+ "@ai-sdk/sandbox-vercel": "1.0.108",
133
+ "@electric-sql/pglite": "^0.5.7",
134
+ "@types/node": "24.x",
135
+ "@vercel/blob": "^2.8.0",
136
+ "@vercel/sandbox": "2.10.0-beta.0",
137
+ "drizzle-orm": "^0.45.2",
138
+ "eve": "^0.46.1",
139
+ "tsdown": "^0.22.14",
140
+ "typescript": "5.9.3",
141
+ "vitest": "4.1.9",
142
+ "zod": "4.4.3"
55
143
  },
56
144
  "peerDependencies": {
145
+ "@ai-sdk/harness": "^1.0.0",
146
+ "@ai-sdk/sandbox-vercel": "^1.0.0",
57
147
  "@vercel/blob": "^2.6.0",
148
+ "@vercel/sandbox": ">=2.10.0-beta.0 <4",
58
149
  "drizzle-orm": "^0.45.0",
59
150
  "eve": "^0.46.0",
60
151
  "zod": "^4.4.3"
61
152
  },
62
153
  "peerDependenciesMeta": {
154
+ "@ai-sdk/harness": {
155
+ "optional": true
156
+ },
157
+ "@ai-sdk/sandbox-vercel": {
158
+ "optional": true
159
+ },
63
160
  "@vercel/blob": {
64
161
  "optional": true
65
162
  },
66
- "drizzle-orm": {
163
+ "@vercel/sandbox": {
67
164
  "optional": true
68
165
  },
69
- "eve": {
166
+ "drizzle-orm": {
70
167
  "optional": true
71
168
  }
72
169
  },
73
- "devDependencies": {
74
- "@electric-sql/pglite": "^0.5.7",
75
- "@types/node": "24.x",
76
- "@vercel/blob": "^2.8.0",
77
- "drizzle-orm": "^0.45.2",
78
- "eve": "^0.46.1",
79
- "tsdown": "^0.22.14",
80
- "typescript": "5.9.3",
81
- "vitest": "4.1.9",
82
- "zod": "4.4.3"
170
+ "engines": {
171
+ "node": ">=24"
83
172
  },
84
173
  "scripts": {
85
174
  "build": "tsdown",
86
175
  "clean": "rm -rf dist",
87
176
  "dead-exports": "knip --directory ../.. --workspace @vercel/factory --exports",
88
- "lint": "eslint .",
177
+ "lint": "oxlint --config ../../.oxlintrc.json --max-warnings 0 .",
89
178
  "lint:logs": "node ../../scripts/check-structured-logging.mjs src",
90
179
  "test": "vitest run",
91
180
  "typecheck": "tsc"
@@ -1,269 +0,0 @@
1
- import { a as repositoryIdsSchema, d as schemaVersionSchema, f as usdSchema, i as repositoryIdSchema, l as isoDateTimeSchema, o as signalIdSchema, p as vocabularySchema, s as taskIdSchema, t as changeIdSchema, u as replyToSchema } from "./id-DwCihQr4.mjs";
2
- import { z } from "zod";
3
- import { createHash } from "node:crypto";
4
- //#region src/schema/task.ts
5
- /**
6
- * Kinds the standard loop understands. Any vocabulary value is valid; the
7
- * kind-scoped rules below apply only to these standard kinds.
8
- */
9
- const standardTaskKinds = [
10
- "coordination",
11
- "code_change",
12
- "verification",
13
- "investigation",
14
- "question"
15
- ];
16
- const taskKindSchema = vocabularySchema.describe("What kind of work this is, e.g. code_change, question, or a registered custom kind.");
17
- const taskStateSchema = z.enum([
18
- "queued",
19
- "running",
20
- "stalled",
21
- "verifying",
22
- "succeeded",
23
- "failed",
24
- "needs_human",
25
- "cancelled"
26
- ]).describe("Lifecycle state. Transitions are fixed; see taskTransitions.");
27
- const taskApprovalSchema = z.enum([
28
- "required",
29
- "granted",
30
- "denied"
31
- ]).describe("Human approval status. Absent means no approval is needed. Stamped required at creation by policy; granted or denied by an operator.");
32
- const taskExecutionRepositoryIdsSchema = z.tuple([repositoryIdSchema]).describe("The one repository used to execute a task.");
33
- const coordinationRepositoryIdsSchema = z.tuple([repositoryIdSchema, repositoryIdSchema]).rest(repositoryIdSchema).refine((repositoryIds) => new Set(repositoryIds).size === repositoryIds.length, { message: "Coordination tasks require distinct repositories." }).describe("The distinct repositories coordinated by a non-executable parent task.");
34
- const taskOriginSchema = z.strictObject({
35
- signalId: signalIdSchema.optional().describe("Signal that led to this task."),
36
- parentTaskId: taskIdSchema.optional().describe("Parent task that planned this child."),
37
- operator: z.string().min(1).optional().describe("Human operator who requested it.")
38
- }).refine((origin) => origin.signalId !== void 0 || origin.parentTaskId !== void 0 || origin.operator !== void 0, { message: "origin requires a signalId, parentTaskId, or operator" });
39
- const harnessSchema = z.string().min(1).describe("Coding harness running inside the execution environment, e.g. claude-code or codex.");
40
- /**
41
- * The provider's handle on the current attempt's execution. Opaque to the
42
- * lifecycle: Factory records it so the execution can be inspected or
43
- * cancelled, never to mirror the provider's own state machine.
44
- */
45
- const executionReferenceSchema = z.strictObject({
46
- provider: z.string().min(1).describe("Execution provider, e.g. eve."),
47
- sessionId: z.string().min(1).describe("Provider-side session running this attempt."),
48
- environmentId: z.string().min(1).optional().describe("Provider-side execution environment."),
49
- harness: harnessSchema.optional(),
50
- traceId: z.string().min(1).optional().describe("Provider-side trace for this execution.")
51
- });
52
- const tokenCountSchema = z.number().int().nonnegative();
53
- const taskUsageSchema = z.strictObject({
54
- costUsd: usdSchema.describe("AI Gateway cost summed over recorded steps."),
55
- inputTokens: tokenCountSchema,
56
- outputTokens: tokenCountSchema,
57
- cacheReadTokens: tokenCountSchema,
58
- cacheWriteTokens: tokenCountSchema,
59
- steps: z.record(z.string().min(1), tokenCountSchema).describe("Highest recorded stepIndex per turnId; steps at or below it are already counted.")
60
- });
61
- const taskQuestionSchema = z.strictObject({
62
- text: z.string().min(1).describe("The input or action requested from a human before work can resume."),
63
- options: z.array(z.string().min(1)).describe("Suggested replies; free-text is also allowed."),
64
- answer: z.string().min(1).optional(),
65
- answeredBy: z.string().min(1).optional().describe("Authenticated operator who answered.")
66
- });
67
- const taskSchema = z.strictObject({
68
- schemaVersion: schemaVersionSchema,
69
- id: taskIdSchema,
70
- repositoryIds: repositoryIdsSchema.describe("Repositories the task concerns."),
71
- kind: taskKindSchema,
72
- area: z.string().min(1).optional().describe("Investigation area, e.g. onboarding or security. Investigation tasks only."),
73
- state: taskStateSchema,
74
- approval: taskApprovalSchema.optional(),
75
- origin: taskOriginSchema,
76
- dependsOn: z.array(taskIdSchema).min(1).optional().describe("Sibling tasks that must produce a change before this one may run."),
77
- replyTo: replyToSchema,
78
- attempt: z.number().int().min(1).describe("Execution attempt, starting at 1; bumps on retry."),
79
- execution: executionReferenceSchema.optional().describe("Execution of the current attempt, recorded at dispatch and replaced on retry."),
80
- lastProgressAt: isoDateTimeSchema.optional().describe("Last time the execution demonstrably advanced: dispatch, or a completed model step."),
81
- stalledAt: isoDateTimeSchema.optional().describe("When the reconciler marked the task stalled."),
82
- stalledReason: z.string().min(1).optional().describe("Why the task was marked stalled."),
83
- reservedUsd: usdSchema.optional().describe("Budget reserved before dispatch."),
84
- reservedAt: isoDateTimeSchema.optional().describe("When the reservation was stamped; attributes spend to a budget month."),
85
- usage: taskUsageSchema.optional().describe("Measured model usage, accumulated per step by recordUsage and settled into settledUsd."),
86
- settledUsd: usdSchema.optional().describe("Measured cost settled after execution. A task settles once; re-execution cost is not separately metered (see the unresolved multi-attempt accounting decision)."),
87
- question: taskQuestionSchema.optional(),
88
- changeId: changeIdSchema.optional().describe("Change produced or verified by this task."),
89
- reportRef: z.string().min(1).optional().describe("Reference to the report artifact an investigation produced."),
90
- createdAt: isoDateTimeSchema,
91
- updatedAt: isoDateTimeSchema
92
- }).superRefine((task, ctx) => {
93
- if (task.kind === "coordination" && !coordinationRepositoryIdsSchema.safeParse(task.repositoryIds).success) ctx.addIssue({
94
- code: "custom",
95
- path: ["repositoryIds"],
96
- message: "coordination tasks require at least two distinct repositories"
97
- });
98
- if ((task.kind === "code_change" || task.kind === "verification") && task.repositoryIds.length !== 1) ctx.addIssue({
99
- code: "custom",
100
- path: ["repositoryIds"],
101
- message: `${task.kind} tasks require exactly one repository`
102
- });
103
- if (task.area !== void 0 && task.kind !== "investigation") ctx.addIssue({
104
- code: "custom",
105
- path: ["area"],
106
- message: "area is only valid on investigation tasks"
107
- });
108
- if (task.kind === "question") {
109
- if (task.question === void 0) ctx.addIssue({
110
- code: "custom",
111
- path: ["question"],
112
- message: "question tasks require a question"
113
- });
114
- } else if (task.question !== void 0) ctx.addIssue({
115
- code: "custom",
116
- path: ["question"],
117
- message: "question is only valid on question tasks"
118
- });
119
- if (task.state !== "stalled" && (task.stalledAt !== void 0 || task.stalledReason !== void 0)) ctx.addIssue({
120
- code: "custom",
121
- path: ["stalledAt"],
122
- message: "stalledAt and stalledReason are only valid while the task is stalled"
123
- });
124
- if ((task.kind === "question" || task.kind === "coordination") && task.execution !== void 0) ctx.addIssue({
125
- code: "custom",
126
- path: ["execution"],
127
- message: `${task.kind} tasks never execute`
128
- });
129
- if (task.changeId !== void 0 && task.kind !== "code_change" && task.kind !== "verification") ctx.addIssue({
130
- code: "custom",
131
- path: ["changeId"],
132
- message: "changeId is only valid on code_change or verification tasks"
133
- });
134
- if (task.reportRef !== void 0 && task.kind !== "investigation") ctx.addIssue({
135
- code: "custom",
136
- path: ["reportRef"],
137
- message: "reportRef is only valid on investigation tasks"
138
- });
139
- });
140
- //#endregion
141
- //#region src/schema/finding.ts
142
- const findingPrioritySchema = z.enum([
143
- "P0",
144
- "P1",
145
- "P2",
146
- "P3"
147
- ]).describe("Urgency of a finding: P0 is drop-everything, P3 is nice-to-have.");
148
- const findingCategorySchema = z.enum([
149
- "security",
150
- "correctness",
151
- "reliability",
152
- "performance",
153
- "compatibility",
154
- "accessibility",
155
- "documentation",
156
- "maintainability",
157
- "testing",
158
- "usability"
159
- ]);
160
- const findingVerificationLevelSchema = z.enum([
161
- "unverified",
162
- "supported",
163
- "confirmed"
164
- ]).describe("How sure the reporter is: unverified = suspected from reading; supported = evidence points to it; confirmed = demonstrated.");
165
- const findingVerificationMethodSchema = z.enum([
166
- "code_inspection",
167
- "static_analysis",
168
- "manual_reproduction",
169
- "unit_test",
170
- "integration_test",
171
- "e2e_test",
172
- "runtime_observation",
173
- "documentation"
174
- ]);
175
- /**
176
- * What was done to check the finding. Forces a reporter to distinguish "I
177
- * think this is a problem" from "I demonstrated it", which is the axis a human
178
- * approving fixes cares about most.
179
- */
180
- const findingVerificationSchema = z.strictObject({
181
- level: findingVerificationLevelSchema,
182
- method: findingVerificationMethodSchema,
183
- summary: z.string().min(1).max(2e3).describe("What was checked and what it showed."),
184
- limitations: z.string().min(1).max(2e3).optional().describe("What could not be checked.")
185
- });
186
- /** A single problem found in a repository, as a scanner or agent reports it. */
187
- const findingSchema = z.strictObject({
188
- title: z.string().min(1).max(200),
189
- body: z.string().min(1).max(8e3).describe("The problem, its impact, and how to fix it. Markdown."),
190
- path: z.string().min(1).max(500).optional().describe("Repository-relative file path."),
191
- line: z.number().int().min(1).optional(),
192
- endLine: z.number().int().min(1).optional(),
193
- priority: findingPrioritySchema,
194
- category: findingCategorySchema,
195
- verification: findingVerificationSchema,
196
- tool: z.string().min(1).max(100).optional().describe("Scanner that produced it, e.g. deepsec."),
197
- ruleId: z.string().min(1).max(200).optional().describe("Scanner rule or check id, when there is one.")
198
- });
199
- /**
200
- * Stable identity of a finding across scans, used as the signal's delivery id
201
- * so re-reporting is a no-op instead of a second task. A scanner finding is
202
- * the same problem when the same tool reports the same rule on the same file;
203
- * its title is model-written prose and changes between runs, so it is left
204
- * out. Without a rule id the title is all there is, normalised.
205
- */
206
- function findingFingerprint(repositoryId, finding) {
207
- const parts = finding.tool !== void 0 && finding.ruleId !== void 0 && finding.path !== void 0 ? [
208
- repositoryId,
209
- finding.tool,
210
- finding.ruleId,
211
- finding.path
212
- ] : [
213
- repositoryId,
214
- finding.tool ?? "",
215
- finding.ruleId ?? "",
216
- finding.path ?? "",
217
- finding.title.trim().toLowerCase().replaceAll(/\s+/gu, " ")
218
- ];
219
- return createHash("sha256").update(parts.join(" ")).digest("hex").slice(0, 32);
220
- }
221
- //#endregion
222
- //#region src/approval.ts
223
- /**
224
- * One approval rule. Every listed field must match for the rule to apply;
225
- * absent fields match anything. Rules are evaluated first-match.
226
- */
227
- const approvalRuleSchema = z.strictObject({
228
- source: vocabularySchema.optional().describe("Signal source, e.g. security_scan or github_issue."),
229
- kind: vocabularySchema.optional().describe("Task kind, e.g. code_change."),
230
- priority: z.array(findingPrioritySchema).min(1).optional().describe("Finding priorities the rule applies to."),
231
- require: z.boolean().describe("Whether matching tasks wait for a human before dispatch.")
232
- });
233
- const approvalPolicySchema = z.array(approvalRuleSchema).describe("First-match rules deciding which tasks need a human before they run.");
234
- /**
235
- * The default: fixes for security findings wait for a human; everything else
236
- * runs as it always has. Handoffs between agents (verification) never wait,
237
- * because a human already approved the work they continue.
238
- */
239
- const defaultApprovalPolicy = [
240
- {
241
- kind: "verification",
242
- require: false
243
- },
244
- {
245
- source: "security_scan",
246
- require: true
247
- },
248
- { require: false }
249
- ];
250
- /**
251
- * Decide at task-creation time whether a task needs approval. Pure: the answer
252
- * is stamped on the task and never re-evaluated, so a later policy change
253
- * cannot silently release work a human was expecting to see.
254
- */
255
- function requiresApproval(policy, subject) {
256
- for (const rule of policy) {
257
- if (rule.source !== void 0 && rule.source !== subject.source) continue;
258
- if (rule.kind !== void 0 && rule.kind !== subject.kind) continue;
259
- if (rule.priority !== void 0) {
260
- if (subject.priority === void 0 || !rule.priority.includes(subject.priority)) continue;
261
- }
262
- return rule.require;
263
- }
264
- return false;
265
- }
266
- //#endregion
267
- export { taskUsageSchema as C, taskStateSchema as S, taskExecutionRepositoryIdsSchema as _, findingCategorySchema as a, taskQuestionSchema as b, findingSchema as c, findingVerificationSchema as d, coordinationRepositoryIdsSchema as f, taskApprovalSchema as g, standardTaskKinds as h, requiresApproval as i, findingVerificationLevelSchema as l, harnessSchema as m, approvalRuleSchema as n, findingFingerprint as o, executionReferenceSchema as p, defaultApprovalPolicy as r, findingPrioritySchema as s, approvalPolicySchema as t, findingVerificationMethodSchema as u, taskKindSchema as v, taskSchema as x, taskOriginSchema as y };
268
-
269
- //# sourceMappingURL=approval-CwhTP1XB.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approval-CwhTP1XB.mjs","names":[],"sources":["../src/schema/task.ts","../src/schema/finding.ts","../src/approval.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n isoDateTimeSchema,\n replyToSchema,\n schemaVersionSchema,\n usdSchema,\n vocabularySchema,\n} from \"./common\";\nimport {\n changeIdSchema,\n repositoryIdSchema,\n repositoryIdsSchema,\n signalIdSchema,\n taskIdSchema,\n} from \"./id\";\n\n/**\n * Kinds the standard loop understands. Any vocabulary value is valid; the\n * kind-scoped rules below apply only to these standard kinds.\n */\nexport const standardTaskKinds = [\n \"coordination\",\n \"code_change\",\n \"verification\",\n \"investigation\",\n \"question\",\n] as const;\n\nexport const taskKindSchema = vocabularySchema.describe(\n \"What kind of work this is, e.g. code_change, question, or a registered custom kind.\",\n);\n\nexport const taskStateSchema = z\n .enum([\"queued\", \"running\", \"stalled\", \"verifying\", \"succeeded\", \"failed\", \"needs_human\", \"cancelled\"])\n .describe(\"Lifecycle state. Transitions are fixed; see taskTransitions.\");\n\nexport const taskApprovalSchema = z\n .enum([\"required\", \"granted\", \"denied\"])\n .describe(\n \"Human approval status. Absent means no approval is needed. Stamped required at creation by policy; granted or denied by an operator.\",\n );\n\nexport const taskExecutionRepositoryIdsSchema = z\n .tuple([repositoryIdSchema])\n .describe(\"The one repository used to execute a task.\");\n\nexport const coordinationRepositoryIdsSchema = z\n .tuple([repositoryIdSchema, repositoryIdSchema])\n .rest(repositoryIdSchema)\n .refine((repositoryIds) => new Set(repositoryIds).size === repositoryIds.length, {\n message: \"Coordination tasks require distinct repositories.\",\n })\n .describe(\"The distinct repositories coordinated by a non-executable parent task.\");\n\nexport const taskOriginSchema = z\n .strictObject({\n signalId: signalIdSchema.optional().describe(\"Signal that led to this task.\"),\n parentTaskId: taskIdSchema.optional().describe(\"Parent task that planned this child.\"),\n operator: z.string().min(1).optional().describe(\"Human operator who requested it.\"),\n })\n .refine(\n (origin) =>\n origin.signalId !== undefined ||\n origin.parentTaskId !== undefined ||\n origin.operator !== undefined,\n { message: \"origin requires a signalId, parentTaskId, or operator\" },\n );\n\nexport const harnessSchema = z\n .string()\n .min(1)\n .describe(\"Coding harness running inside the execution environment, e.g. claude-code or codex.\");\n\n/**\n * The provider's handle on the current attempt's execution. Opaque to the\n * lifecycle: Factory records it so the execution can be inspected or\n * cancelled, never to mirror the provider's own state machine.\n */\nexport const executionReferenceSchema = z.strictObject({\n provider: z.string().min(1).describe(\"Execution provider, e.g. eve.\"),\n sessionId: z.string().min(1).describe(\"Provider-side session running this attempt.\"),\n environmentId: z.string().min(1).optional().describe(\"Provider-side execution environment.\"),\n harness: harnessSchema.optional(),\n traceId: z.string().min(1).optional().describe(\"Provider-side trace for this execution.\"),\n});\n\nconst tokenCountSchema = z.number().int().nonnegative();\n\nexport const taskUsageSchema = z.strictObject({\n costUsd: usdSchema.describe(\"AI Gateway cost summed over recorded steps.\"),\n inputTokens: tokenCountSchema,\n outputTokens: tokenCountSchema,\n cacheReadTokens: tokenCountSchema,\n cacheWriteTokens: tokenCountSchema,\n steps: z\n .record(z.string().min(1), tokenCountSchema)\n .describe(\"Highest recorded stepIndex per turnId; steps at or below it are already counted.\"),\n});\n\nexport const taskQuestionSchema = z.strictObject({\n text: z.string().min(1).describe(\"The input or action requested from a human before work can resume.\"),\n options: z.array(z.string().min(1)).describe(\"Suggested replies; free-text is also allowed.\"),\n answer: z.string().min(1).optional(),\n answeredBy: z.string().min(1).optional().describe(\"Authenticated operator who answered.\"),\n});\n\nexport const taskSchema = z\n .strictObject({\n schemaVersion: schemaVersionSchema,\n id: taskIdSchema,\n repositoryIds: repositoryIdsSchema.describe(\"Repositories the task concerns.\"),\n kind: taskKindSchema,\n area: z\n .string()\n .min(1)\n .optional()\n .describe(\"Investigation area, e.g. onboarding or security. Investigation tasks only.\"),\n state: taskStateSchema,\n approval: taskApprovalSchema.optional(),\n origin: taskOriginSchema,\n dependsOn: z\n .array(taskIdSchema)\n .min(1)\n .optional()\n .describe(\"Sibling tasks that must produce a change before this one may run.\"),\n replyTo: replyToSchema,\n attempt: z\n .number()\n .int()\n .min(1)\n .describe(\"Execution attempt, starting at 1; bumps on retry.\"),\n execution: executionReferenceSchema\n .optional()\n .describe(\"Execution of the current attempt, recorded at dispatch and replaced on retry.\"),\n lastProgressAt: isoDateTimeSchema\n .optional()\n .describe(\"Last time the execution demonstrably advanced: dispatch, or a completed model step.\"),\n stalledAt: isoDateTimeSchema.optional().describe(\"When the reconciler marked the task stalled.\"),\n stalledReason: z.string().min(1).optional().describe(\"Why the task was marked stalled.\"),\n reservedUsd: usdSchema.optional().describe(\"Budget reserved before dispatch.\"),\n reservedAt: isoDateTimeSchema\n .optional()\n .describe(\"When the reservation was stamped; attributes spend to a budget month.\"),\n usage: taskUsageSchema\n .optional()\n .describe(\"Measured model usage, accumulated per step by recordUsage and settled into settledUsd.\"),\n settledUsd: usdSchema\n .optional()\n .describe(\n \"Measured cost settled after execution. A task settles once; re-execution cost is not separately metered (see the unresolved multi-attempt accounting decision).\",\n ),\n question: taskQuestionSchema.optional(),\n changeId: changeIdSchema.optional().describe(\"Change produced or verified by this task.\"),\n reportRef: z\n .string()\n .min(1)\n .optional()\n .describe(\"Reference to the report artifact an investigation produced.\"),\n createdAt: isoDateTimeSchema,\n updatedAt: isoDateTimeSchema,\n })\n .superRefine((task, ctx) => {\n if (\n task.kind === \"coordination\" &&\n !coordinationRepositoryIdsSchema.safeParse(task.repositoryIds).success\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"repositoryIds\"],\n message: \"coordination tasks require at least two distinct repositories\",\n });\n }\n if (\n (task.kind === \"code_change\" || task.kind === \"verification\") &&\n task.repositoryIds.length !== 1\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"repositoryIds\"],\n message: `${task.kind} tasks require exactly one repository`,\n });\n }\n if (task.area !== undefined && task.kind !== \"investigation\") {\n ctx.addIssue({\n code: \"custom\",\n path: [\"area\"],\n message: \"area is only valid on investigation tasks\",\n });\n }\n if (task.kind === \"question\") {\n if (task.question === undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"question\"],\n message: \"question tasks require a question\",\n });\n }\n } else if (task.question !== undefined) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"question\"],\n message: \"question is only valid on question tasks\",\n });\n }\n if (task.state !== \"stalled\" && (task.stalledAt !== undefined || task.stalledReason !== undefined)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"stalledAt\"],\n message: \"stalledAt and stalledReason are only valid while the task is stalled\",\n });\n }\n if (\n (task.kind === \"question\" || task.kind === \"coordination\") &&\n task.execution !== undefined\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"execution\"],\n message: `${task.kind} tasks never execute`,\n });\n }\n if (\n task.changeId !== undefined &&\n task.kind !== \"code_change\" &&\n task.kind !== \"verification\"\n ) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"changeId\"],\n message: \"changeId is only valid on code_change or verification tasks\",\n });\n }\n if (task.reportRef !== undefined && task.kind !== \"investigation\") {\n ctx.addIssue({\n code: \"custom\",\n path: [\"reportRef\"],\n message: \"reportRef is only valid on investigation tasks\",\n });\n }\n });\n\nexport type TaskApproval = z.infer<typeof taskApprovalSchema>;\nexport type TaskKind = z.infer<typeof taskKindSchema>;\nexport type TaskState = z.infer<typeof taskStateSchema>;\nexport type TaskUsage = z.infer<typeof taskUsageSchema>;\nexport type ExecutionReference = z.infer<typeof executionReferenceSchema>;\nexport type Task = z.infer<typeof taskSchema>;\n","import { createHash } from \"node:crypto\";\nimport { z } from \"zod\";\n\nexport const findingPrioritySchema = z\n .enum([\"P0\", \"P1\", \"P2\", \"P3\"])\n .describe(\"Urgency of a finding: P0 is drop-everything, P3 is nice-to-have.\");\n\nexport const findingCategorySchema = z.enum([\n \"security\",\n \"correctness\",\n \"reliability\",\n \"performance\",\n \"compatibility\",\n \"accessibility\",\n \"documentation\",\n \"maintainability\",\n \"testing\",\n \"usability\",\n]);\n\nexport const findingVerificationLevelSchema = z\n .enum([\"unverified\", \"supported\", \"confirmed\"])\n .describe(\n \"How sure the reporter is: unverified = suspected from reading; supported = evidence points to it; confirmed = demonstrated.\",\n );\n\nexport const findingVerificationMethodSchema = z.enum([\n \"code_inspection\",\n \"static_analysis\",\n \"manual_reproduction\",\n \"unit_test\",\n \"integration_test\",\n \"e2e_test\",\n \"runtime_observation\",\n \"documentation\",\n]);\n\n/**\n * What was done to check the finding. Forces a reporter to distinguish \"I\n * think this is a problem\" from \"I demonstrated it\", which is the axis a human\n * approving fixes cares about most.\n */\nexport const findingVerificationSchema = z.strictObject({\n level: findingVerificationLevelSchema,\n method: findingVerificationMethodSchema,\n summary: z.string().min(1).max(2000).describe(\"What was checked and what it showed.\"),\n limitations: z.string().min(1).max(2000).optional().describe(\"What could not be checked.\"),\n});\n\n/** A single problem found in a repository, as a scanner or agent reports it. */\nexport const findingSchema = z.strictObject({\n title: z.string().min(1).max(200),\n body: z.string().min(1).max(8000).describe(\"The problem, its impact, and how to fix it. Markdown.\"),\n path: z.string().min(1).max(500).optional().describe(\"Repository-relative file path.\"),\n line: z.number().int().min(1).optional(),\n endLine: z.number().int().min(1).optional(),\n priority: findingPrioritySchema,\n category: findingCategorySchema,\n verification: findingVerificationSchema,\n tool: z.string().min(1).max(100).optional().describe(\"Scanner that produced it, e.g. deepsec.\"),\n ruleId: z.string().min(1).max(200).optional().describe(\"Scanner rule or check id, when there is one.\"),\n});\n\nexport type FindingPriority = z.infer<typeof findingPrioritySchema>;\nexport type FindingCategory = z.infer<typeof findingCategorySchema>;\nexport type FindingVerification = z.infer<typeof findingVerificationSchema>;\nexport type Finding = z.infer<typeof findingSchema>;\n\n/**\n * Stable identity of a finding across scans, used as the signal's delivery id\n * so re-reporting is a no-op instead of a second task. A scanner finding is\n * the same problem when the same tool reports the same rule on the same file;\n * its title is model-written prose and changes between runs, so it is left\n * out. Without a rule id the title is all there is, normalised.\n */\nexport function findingFingerprint(repositoryId: string, finding: Finding): string {\n const parts =\n finding.tool !== undefined && finding.ruleId !== undefined && finding.path !== undefined\n ? [repositoryId, finding.tool, finding.ruleId, finding.path]\n : [\n repositoryId,\n finding.tool ?? \"\",\n finding.ruleId ?? \"\",\n finding.path ?? \"\",\n finding.title.trim().toLowerCase().replaceAll(/\\s+/gu, \" \"),\n ];\n return createHash(\"sha256\").update(parts.join(\" \")).digest(\"hex\").slice(0, 32);\n}\n","import { z } from \"zod\";\nimport { vocabularySchema } from \"./schema/common\";\nimport { findingPrioritySchema, type FindingPriority } from \"./schema/finding\";\n\n/**\n * One approval rule. Every listed field must match for the rule to apply;\n * absent fields match anything. Rules are evaluated first-match.\n */\nexport const approvalRuleSchema = z.strictObject({\n source: vocabularySchema.optional().describe(\"Signal source, e.g. security_scan or github_issue.\"),\n kind: vocabularySchema.optional().describe(\"Task kind, e.g. code_change.\"),\n priority: z\n .array(findingPrioritySchema)\n .min(1)\n .optional()\n .describe(\"Finding priorities the rule applies to.\"),\n require: z.boolean().describe(\"Whether matching tasks wait for a human before dispatch.\"),\n});\n\nexport const approvalPolicySchema = z\n .array(approvalRuleSchema)\n .describe(\"First-match rules deciding which tasks need a human before they run.\");\n\nexport type ApprovalRule = z.infer<typeof approvalRuleSchema>;\nexport type ApprovalPolicy = z.infer<typeof approvalPolicySchema>;\n\n/**\n * The default: fixes for security findings wait for a human; everything else\n * runs as it always has. Handoffs between agents (verification) never wait,\n * because a human already approved the work they continue.\n */\nexport const defaultApprovalPolicy: ApprovalPolicy = [\n { kind: \"verification\", require: false },\n { source: \"security_scan\", require: true },\n { require: false },\n];\n\nexport interface ApprovalSubject {\n source?: string;\n kind: string;\n priority?: FindingPriority;\n}\n\n/**\n * Decide at task-creation time whether a task needs approval. Pure: the answer\n * is stamped on the task and never re-evaluated, so a later policy change\n * cannot silently release work a human was expecting to see.\n */\nexport function requiresApproval(policy: ApprovalPolicy, subject: ApprovalSubject): boolean {\n for (const rule of policy) {\n if (rule.source !== undefined && rule.source !== subject.source) continue;\n if (rule.kind !== undefined && rule.kind !== subject.kind) continue;\n if (rule.priority !== undefined) {\n if (subject.priority === undefined || !rule.priority.includes(subject.priority)) continue;\n }\n return rule.require;\n }\n return false;\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,iBAAiB,iBAAiB,SAC7C,qFACF;AAEA,MAAa,kBAAkB,EAC5B,KAAK;CAAC;CAAU;CAAW;CAAW;CAAa;CAAa;CAAU;CAAe;AAAW,CAAC,CAAC,CACtG,SAAS,8DAA8D;AAE1E,MAAa,qBAAqB,EAC/B,KAAK;CAAC;CAAY;CAAW;AAAQ,CAAC,CAAC,CACvC,SACC,sIACF;AAEF,MAAa,mCAAmC,EAC7C,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAC3B,SAAS,4CAA4C;AAExD,MAAa,kCAAkC,EAC5C,MAAM,CAAC,oBAAoB,kBAAkB,CAAC,CAAC,CAC/C,KAAK,kBAAkB,CAAC,CACxB,QAAQ,kBAAkB,IAAI,IAAI,aAAa,CAAC,CAAC,SAAS,cAAc,QAAQ,EAC/E,SAAS,oDACX,CAAC,CAAC,CACD,SAAS,wEAAwE;AAEpF,MAAa,mBAAmB,EAC7B,aAAa;CACZ,UAAU,eAAe,SAAS,CAAC,CAAC,SAAS,+BAA+B;CAC5E,cAAc,aAAa,SAAS,CAAC,CAAC,SAAS,sCAAsC;CACrF,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,kCAAkC;AACpF,CAAC,CAAC,CACD,QACE,WACC,OAAO,aAAa,KAAA,KACpB,OAAO,iBAAiB,KAAA,KACxB,OAAO,aAAa,KAAA,GACtB,EAAE,SAAS,wDAAwD,CACrE;AAEF,MAAa,gBAAgB,EAC1B,OAAO,CAAC,CACR,IAAI,CAAC,CAAC,CACN,SAAS,qFAAqF;;;;;;AAOjG,MAAa,2BAA2B,EAAE,aAAa;CACrD,UAAU,EAAE,O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