@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,101 @@
1
+ import { changeIdSchema, taskIdSchema } from "../schema/id.mjs";
2
+ import { requireTaskExecution } from "../eve/task-execution.mjs";
3
+ import { changeEvidenceSchema, changeLevelSchema } from "../schema/change.mjs";
4
+ import { z } from "zod";
5
+ import { defineTool } from "eve/tools";
6
+ //#region src/change-verification/eve-tool.ts
7
+ /**
8
+ * The verifier's outcome tool. Writes evidence onto the change and moves it
9
+ * to ready only when the verdict is pass; a failed verdict leaves the change
10
+ * verifying with the evidence recorded, and the verification task itself
11
+ * ends with a receipt either way. The change's own code_change task follows
12
+ * the verdict too: succeeded on pass, failed on fail with the verifier's
13
+ * summary as the reason, so the ledger never shows a verified-and-rejected fix
14
+ * as still in progress. Fail closed: the agent cannot mark a change ready
15
+ * without supplying every evidence field. Requires the authenticated current
16
+ * Task execution and matching parent, Change, and repository associations.
17
+ */
18
+ function createRecordVerificationTool(stores, options = {}) {
19
+ return defineTool({
20
+ description: "Record the outcome of a verification task: the evidence you gathered and whether the change passed. Pass moves the change to ready for human review; fail keeps it out of review.",
21
+ inputSchema: z.object({
22
+ taskId: taskIdSchema.describe("Your verification task."),
23
+ changeId: changeIdSchema.describe("The change you verified."),
24
+ verdict: z.enum(["pass", "fail"]),
25
+ evidence: changeEvidenceSchema,
26
+ confidence: changeLevelSchema.describe("How certain you are in the verdict."),
27
+ summary: z.string().min(1).max(2e3).describe("What you checked and what you found.")
28
+ }),
29
+ async execute({ taskId, changeId, verdict, evidence, confidence, summary }, ctx) {
30
+ const task = await requireTaskExecution(stores, ctx, taskId);
31
+ const change = await stores.changes.get(changeId);
32
+ if (change === null) return {
33
+ recorded: false,
34
+ reason: `change ${changeId} does not exist`
35
+ };
36
+ if (change.state !== "verifying" && change.state !== "ready") return {
37
+ recorded: false,
38
+ reason: `change is ${change.state}, not open for verification; nothing to record`
39
+ };
40
+ const parent = task.parentTaskId === void 0 ? null : await stores.tasks.get(task.parentTaskId);
41
+ if (task.changeId !== changeId || parent === null || parent.changeId !== changeId || parent.state !== "verifying" || task.rootTaskId !== parent.rootTaskId || task.repositoryIds.length !== 1 || task.repositoryIds[0] !== change.repositoryId || parent.repositoryIds.length !== 1 || parent.repositoryIds[0] !== change.repositoryId) return {
42
+ recorded: false,
43
+ reason: "Verification Task, parent, Change, and repository must match"
44
+ };
45
+ await requireTaskExecution(stores, ctx, taskId);
46
+ let updatedChange = change;
47
+ if (verdict === "pass" && change.state === "verifying") updatedChange = await stores.changes.transition(changeId, "ready", {
48
+ patch: {
49
+ evidence,
50
+ confidence
51
+ },
52
+ reason: summary
53
+ });
54
+ else if (verdict === "fail" && change.state === "ready") updatedChange = await stores.changes.transition(changeId, "verifying", { reason: summary });
55
+ const output = {
56
+ changeId,
57
+ verdict,
58
+ evidence,
59
+ confidence,
60
+ summary
61
+ };
62
+ if (verdict === "pass") await stores.tasks.transition(taskId, "succeeded", {
63
+ expectFrom: "running",
64
+ expectAttempt: task.attempt,
65
+ expectExecution: task.execution,
66
+ output
67
+ });
68
+ else await stores.tasks.transition(taskId, "failed", {
69
+ expectFrom: "running",
70
+ expectAttempt: task.attempt,
71
+ expectExecution: task.execution,
72
+ reason: summary
73
+ });
74
+ await (verdict === "pass" ? stores.tasks.transition(parent.id, "succeeded", {
75
+ expectFrom: "verifying",
76
+ expectAttempt: parent.attempt,
77
+ output
78
+ }) : stores.tasks.transition(parent.id, "failed", {
79
+ expectFrom: "verifying",
80
+ expectAttempt: parent.attempt,
81
+ reason: `verification failed: ${summary}`
82
+ })).catch(() => void 0);
83
+ await options.presentResult?.({
84
+ taskId,
85
+ changeId,
86
+ verdict,
87
+ summary
88
+ });
89
+ return {
90
+ recorded: true,
91
+ verdict,
92
+ changeState: updatedChange.state,
93
+ taskState: verdict === "pass" ? "succeeded" : "failed"
94
+ };
95
+ }
96
+ });
97
+ }
98
+ //#endregion
99
+ export { createRecordVerificationTool };
100
+
101
+ //# sourceMappingURL=eve-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eve-tool.mjs","names":[],"sources":["../../src/change-verification/eve-tool.ts"],"sourcesContent":["import { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\nimport {\n changeEvidenceSchema,\n changeLevelSchema,\n type ChangeEvidence,\n type ChangeLevel,\n type ChangeState,\n} from \"../schema/change\";\nimport { changeIdSchema, taskIdSchema } from \"../schema/id\";\nimport type { ChangeId, TaskId } from \"../schema/id\";\nimport type { FactoryStores } from \"../store/engine\";\nimport { requireTaskExecution } from \"../eve/task-execution\";\n\n/** Change and Task capabilities required by the verification-result tool. */\nexport type RecordVerificationToolStores = Pick<FactoryStores, \"changes\" | \"tasks\">;\n\n/** Verified outcome presented after its Task and Change updates commit. */\nexport interface PresentVerificationResultInput {\n taskId: TaskId;\n changeId: ChangeId;\n verdict: \"pass\" | \"fail\";\n summary: string;\n}\n\n/** Configures presentation after a verification verdict has been durably recorded. */\nexport interface RecordVerificationToolOptions {\n presentResult?: (input: PresentVerificationResultInput) => Promise<void>;\n}\n\n/** Evidence and verdict supplied by the verifier for one Change. */\nexport interface RecordVerificationInput {\n taskId: TaskId;\n changeId: ChangeId;\n verdict: \"pass\" | \"fail\";\n evidence: ChangeEvidence;\n confidence: ChangeLevel;\n summary: string;\n}\n\n/** Bounded refusal returned when a verification result cannot be associated safely. */\nexport interface RecordVerificationRefusal {\n readonly recorded: false;\n readonly reason: string;\n}\n\n/** Durable lifecycle state returned after a verification verdict is recorded. */\nexport interface RecordVerificationSuccess {\n readonly recorded: true;\n readonly verdict: \"pass\" | \"fail\";\n readonly changeState: ChangeState;\n readonly taskState: \"succeeded\" | \"failed\";\n}\n\n/** Recorded verification state or bounded association refusal. */\nexport type RecordVerificationResult = RecordVerificationRefusal | RecordVerificationSuccess;\n\n/** Eve outcome tool that records evidence and a verdict for one Change. */\nexport interface RecordVerificationTool extends ToolDefinition<\n RecordVerificationInput,\n RecordVerificationResult\n> {\n execute(input: RecordVerificationInput, ctx: ToolContext): Promise<RecordVerificationResult>;\n}\n\n/**\n * The verifier's outcome tool. Writes evidence onto the change and moves it\n * to ready only when the verdict is pass; a failed verdict leaves the change\n * verifying with the evidence recorded, and the verification task itself\n * ends with a receipt either way. The change's own code_change task follows\n * the verdict too: succeeded on pass, failed on fail with the verifier's\n * summary as the reason, so the ledger never shows a verified-and-rejected fix\n * as still in progress. Fail closed: the agent cannot mark a change ready\n * without supplying every evidence field. Requires the authenticated current\n * Task execution and matching parent, Change, and repository associations.\n */\nexport function createRecordVerificationTool(\n stores: RecordVerificationToolStores,\n options: RecordVerificationToolOptions = {},\n): RecordVerificationTool {\n return defineTool({\n description:\n \"Record the outcome of a verification task: the evidence you gathered and whether the change passed. Pass moves the change to ready for human review; fail keeps it out of review.\",\n inputSchema: z.object({\n taskId: taskIdSchema.describe(\"Your verification task.\"),\n changeId: changeIdSchema.describe(\"The change you verified.\"),\n verdict: z.enum([\"pass\", \"fail\"]),\n evidence: changeEvidenceSchema,\n confidence: changeLevelSchema.describe(\"How certain you are in the verdict.\"),\n summary: z.string().min(1).max(2000).describe(\"What you checked and what you found.\"),\n }),\n async execute(\n { taskId, changeId, verdict, evidence, confidence, summary },\n ctx,\n ): Promise<RecordVerificationResult> {\n const task = await requireTaskExecution(stores, ctx, taskId);\n const change = await stores.changes.get(changeId);\n if (change === null) {\n return { recorded: false as const, reason: `change ${changeId} does not exist` };\n }\n if (change.state !== \"verifying\" && change.state !== \"ready\") {\n return {\n recorded: false as const,\n reason: `change is ${change.state}, not open for verification; nothing to record`,\n };\n }\n\n const parent =\n task.parentTaskId === undefined ? null : await stores.tasks.get(task.parentTaskId);\n if (\n task.changeId !== changeId ||\n parent === null ||\n parent.changeId !== changeId ||\n parent.state !== \"verifying\" ||\n task.rootTaskId !== parent.rootTaskId ||\n task.repositoryIds.length !== 1 ||\n task.repositoryIds[0] !== change.repositoryId ||\n parent.repositoryIds.length !== 1 ||\n parent.repositoryIds[0] !== change.repositoryId\n ) {\n return {\n recorded: false as const,\n reason: \"Verification Task, parent, Change, and repository must match\",\n };\n }\n\n await requireTaskExecution(stores, ctx, taskId);\n\n let updatedChange = change;\n if (verdict === \"pass\" && change.state === \"verifying\") {\n updatedChange = await stores.changes.transition(changeId, \"ready\", {\n patch: { evidence, confidence },\n reason: summary,\n });\n } else if (verdict === \"fail\" && change.state === \"ready\") {\n updatedChange = await stores.changes.transition(changeId, \"verifying\", {\n reason: summary,\n });\n }\n\n const output = { changeId, verdict, evidence, confidence, summary };\n if (verdict === \"pass\") {\n await stores.tasks.transition(taskId, \"succeeded\", {\n expectFrom: \"running\",\n expectAttempt: task.attempt,\n expectExecution: task.execution,\n output,\n });\n } else {\n await stores.tasks.transition(taskId, \"failed\", {\n expectFrom: \"running\",\n expectAttempt: task.attempt,\n expectExecution: task.execution,\n reason: summary,\n });\n }\n\n await (\n verdict === \"pass\"\n ? stores.tasks.transition(parent.id, \"succeeded\", {\n expectFrom: \"verifying\",\n expectAttempt: parent.attempt,\n output,\n })\n : stores.tasks.transition(parent.id, \"failed\", {\n expectFrom: \"verifying\",\n expectAttempt: parent.attempt,\n reason: `verification failed: ${summary}`,\n })\n ).catch(() => undefined);\n\n await options.presentResult?.({ taskId, changeId, verdict, summary });\n\n return {\n recorded: true as const,\n verdict,\n changeState: updatedChange.state,\n taskState: verdict === \"pass\" ? (\"succeeded\" as const) : (\"failed\" as const),\n };\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4EA,SAAgB,6BACd,QACA,UAAyC,CAAC,GAClB;CACxB,OAAO,WAAW;EAChB,aACE;EACF,aAAa,EAAE,OAAO;GACpB,QAAQ,aAAa,SAAS,yBAAyB;GACvD,UAAU,eAAe,SAAS,0BAA0B;GAC5D,SAAS,EAAE,KAAK,CAAC,QAAQ,MAAM,CAAC;GAChC,UAAU;GACV,YAAY,kBAAkB,SAAS,qCAAqC;GAC5E,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI,CAAC,CAAC,SAAS,sCAAsC;EACtF,CAAC;EACD,MAAM,QACJ,EAAE,QAAQ,UAAU,SAAS,UAAU,YAAY,WACnD,KACmC;GACnC,MAAM,OAAO,MAAM,qBAAqB,QAAQ,KAAK,MAAM;GAC3D,MAAM,SAAS,MAAM,OAAO,QAAQ,IAAI,QAAQ;GAChD,IAAI,WAAW,MACb,OAAO;IAAE,UAAU;IAAgB,QAAQ,UAAU,SAAS;GAAiB;GAEjF,IAAI,OAAO,UAAU,eAAe,OAAO,UAAU,SACnD,OAAO;IACL,UAAU;IACV,QAAQ,aAAa,OAAO,MAAM;GACpC;GAGF,MAAM,SACJ,KAAK,iBAAiB,KAAA,IAAY,OAAO,MAAM,OAAO,MAAM,IAAI,KAAK,YAAY;GACnF,IACE,KAAK,aAAa,YAClB,WAAW,QACX,OAAO,aAAa,YACpB,OAAO,UAAU,eACjB,KAAK,eAAe,OAAO,cAC3B,KAAK,cAAc,WAAW,KAC9B,KAAK,cAAc,OAAO,OAAO,gBACjC,OAAO,cAAc,WAAW,KAChC,OAAO,cAAc,OAAO,OAAO,cAEnC,OAAO;IACL,UAAU;IACV,QAAQ;GACV;GAGF,MAAM,qBAAqB,QAAQ,KAAK,MAAM;GAE9C,IAAI,gBAAgB;GACpB,IAAI,YAAY,UAAU,OAAO,UAAU,aACzC,gBAAgB,MAAM,OAAO,QAAQ,WAAW,UAAU,SAAS;IACjE,OAAO;KAAE;KAAU;IAAW;IAC9B,QAAQ;GACV,CAAC;QACI,IAAI,YAAY,UAAU,OAAO,UAAU,SAChD,gBAAgB,MAAM,OAAO,QAAQ,WAAW,UAAU,aAAa,EACrE,QAAQ,QACV,CAAC;GAGH,MAAM,SAAS;IAAE;IAAU;IAAS;IAAU;IAAY;GAAQ;GAClE,IAAI,YAAY,QACd,MAAM,OAAO,MAAM,WAAW,QAAQ,aAAa;IACjD,YAAY;IACZ,eAAe,KAAK;IACpB,iBAAiB,KAAK;IACtB;GACF,CAAC;QAED,MAAM,OAAO,MAAM,WAAW,QAAQ,UAAU;IAC9C,YAAY;IACZ,eAAe,KAAK;IACpB,iBAAiB,KAAK;IACtB,QAAQ;GACV,CAAC;GAGH,OACE,YAAY,SACR,OAAO,MAAM,WAAW,OAAO,IAAI,aAAa;IAC9C,YAAY;IACZ,eAAe,OAAO;IACtB;GACF,CAAC,IACD,OAAO,MAAM,WAAW,OAAO,IAAI,UAAU;IAC3C,YAAY;IACZ,eAAe,OAAO;IACtB,QAAQ,wBAAwB;GAClC,CAAC,EAAA,CACL,YAAY,KAAA,CAAS;GAEvB,MAAM,QAAQ,gBAAgB;IAAE;IAAQ;IAAU;IAAS;GAAQ,CAAC;GAEpE,OAAO;IACL,UAAU;IACV;IACA,aAAa,cAAc;IAC3B,WAAW,YAAY,SAAU,cAAyB;GAC5D;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,56 @@
1
+ import { Task } from "../schema/task.mjs";
2
+ import { Change } from "../schema/change.mjs";
3
+ import { FactoryStores } from "../store/engine.mjs";
4
+ import { ChangePresenter } from "./presentation.mjs";
5
+ import { PullRequestPublicationGateResult } from "../pull-requests/contracts.mjs";
6
+ import { z } from "zod";
7
+ import { ToolContext, ToolDefinition } from "eve/tools";
8
+ //#region src/changes/eve-record-change.d.ts
9
+ /** Change and Task capabilities required by the record-change tool. */
10
+ type RecordChangeToolStores = Pick<FactoryStores, "changes" | "tasks">;
11
+ declare const recordChangeInputSchema: z.ZodObject<{
12
+ taskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
13
+ repositoryId: z.ZodType<`repo_${string}`, string, z.core.$ZodTypeInternals<`repo_${string}`, string>>;
14
+ prNumber: z.ZodNumber;
15
+ prUrl: z.ZodURL;
16
+ risk: z.ZodEnum<{
17
+ low: "low";
18
+ medium: "medium";
19
+ high: "high";
20
+ }>;
21
+ confidence: z.ZodEnum<{
22
+ low: "low";
23
+ medium: "medium";
24
+ high: "high";
25
+ }>;
26
+ summary: z.ZodString;
27
+ }, z.core.$strip>;
28
+ /** Validated input accepted by the tool that links a pull request to its producing Task. */
29
+ type RecordChangeInput = z.infer<typeof recordChangeInputSchema>;
30
+ /** Configures policy gates and durable presentation for the software record-change tool. */
31
+ interface RecordChangeToolOptions {
32
+ /**
33
+ * Pre-action gate for record_change, run as an Eve approval policy before
34
+ * the tool executes. Refusals reach the model as a denial with the reason.
35
+ * Gates must fail closed: when they cannot verify, they refuse.
36
+ */
37
+ recordChangeGate?: (input: RecordChangeInput) => Promise<PullRequestPublicationGateResult>;
38
+ /** Whether recorded code changes wait for an independent verification task. Default: required. */
39
+ verification?: "required" | "disabled";
40
+ /** Present the pull request after record_change persists its durable state. */
41
+ presentChange?: ChangePresenter;
42
+ }
43
+ /** Change and producing Task returned after a pull request is recorded. */
44
+ interface RecordChangeResult {
45
+ readonly change: Change;
46
+ readonly task: Task;
47
+ }
48
+ /** Eve outcome tool that links a pull request to its producing Task. */
49
+ interface RecordChangeTool extends ToolDefinition<RecordChangeInput, RecordChangeResult> {
50
+ execute(input: RecordChangeInput, ctx: ToolContext): Promise<RecordChangeResult>;
51
+ }
52
+ /** Create the supplied software workflow's pull-request outcome tool. */
53
+ declare function createRecordChangeTool(stores: RecordChangeToolStores, options?: RecordChangeToolOptions): RecordChangeTool;
54
+ //#endregion
55
+ export { RecordChangeInput, RecordChangeResult, RecordChangeTool, RecordChangeToolOptions, RecordChangeToolStores, createRecordChangeTool };
56
+ //# sourceMappingURL=eve-record-change.d.mts.map
@@ -0,0 +1,97 @@
1
+ import { repositoryIdSchema, taskIdSchema } from "../schema/id.mjs";
2
+ import { changeLevelSchema } from "../schema/change.mjs";
3
+ import { z } from "zod";
4
+ import { defineTool } from "eve/tools";
5
+ //#region src/changes/eve-record-change.ts
6
+ const recordChangeInputSchema = z.object({
7
+ taskId: taskIdSchema,
8
+ repositoryId: repositoryIdSchema,
9
+ prNumber: z.number().int().min(1),
10
+ prUrl: z.url(),
11
+ risk: changeLevelSchema.describe("Blast radius of the change if it is wrong."),
12
+ confidence: changeLevelSchema.describe("How certain you are the change is correct."),
13
+ summary: z.string().min(1).describe("One-sentence description of the change.")
14
+ });
15
+ /** Create the supplied software workflow's pull-request outcome tool. */
16
+ function createRecordChangeTool(stores, options = {}) {
17
+ const recordChangeGate = options.recordChangeGate;
18
+ const verification = options.verification ?? "required";
19
+ return defineTool({
20
+ description: verification === "required" ? "Record the pull request produced for a code_change task. Creates the change, links it to the task, and moves the task to verifying." : "Record the pull request produced for a code_change task. Creates the change and marks it ready for human review without independent verification.",
21
+ inputSchema: recordChangeInputSchema,
22
+ ...recordChangeGate === void 0 ? {} : { approval: async ({ toolInput }) => {
23
+ const parsed = recordChangeInputSchema.safeParse(toolInput);
24
+ if (!parsed.success) return {
25
+ type: "denied",
26
+ reason: "record_change input is malformed; fix the arguments and retry"
27
+ };
28
+ const verdict = await recordChangeGate(parsed.data);
29
+ return verdict.ok ? "not-applicable" : {
30
+ type: "denied",
31
+ reason: verdict.reason
32
+ };
33
+ } },
34
+ async execute({ taskId, repositoryId, prNumber, prUrl, risk, confidence, summary }) {
35
+ const currentTask = await stores.tasks.get(taskId);
36
+ if (currentTask === null) throw new Error(`task ${taskId} does not exist`);
37
+ if (currentTask.state !== "running" && currentTask.state !== "verifying" && currentTask.state !== "succeeded") throw new Error(`task ${taskId} is ${currentTask.state}, not running`);
38
+ const linkedChange = currentTask.changeId === void 0 ? void 0 : await stores.changes.get(currentTask.changeId);
39
+ if (currentTask.changeId !== void 0 && linkedChange === null) throw new Error(`change ${currentTask.changeId} does not exist`);
40
+ let change = linkedChange ?? (await stores.changes.list()).find((candidate) => candidate.taskId === taskId);
41
+ if (change === void 0) {
42
+ if (currentTask.state !== "running") throw new Error(`task ${taskId} has no recorded change`);
43
+ change = await stores.changes.create({
44
+ repositoryId,
45
+ taskId,
46
+ prNumber,
47
+ prUrl,
48
+ author: "factory",
49
+ risk,
50
+ confidence,
51
+ evidence: {
52
+ reproVerified: false,
53
+ testsAdded: 0,
54
+ checksGreen: false,
55
+ attackPassed: false,
56
+ scopeMatches: false
57
+ }
58
+ });
59
+ }
60
+ if (change === void 0) throw new Error(`task ${taskId} has no recorded change`);
61
+ let recordedChange = change;
62
+ if (currentTask.state === "running") await options.presentChange?.({
63
+ taskId,
64
+ changeId: recordedChange.id,
65
+ verification,
66
+ summary
67
+ });
68
+ let task = currentTask;
69
+ if (task.state === "running") task = await stores.tasks.transition(taskId, "verifying", {
70
+ patch: { changeId: recordedChange.id },
71
+ reason: summary
72
+ });
73
+ if (verification === "required") return {
74
+ change: recordedChange,
75
+ task
76
+ };
77
+ if (recordedChange.state === "verifying") recordedChange = await stores.changes.transition(recordedChange.id, "ready", { reason: "independent verification is not configured" });
78
+ if (task.state === "verifying") task = await stores.tasks.transition(taskId, "succeeded", {
79
+ reason: "change recorded for human review without independent verification",
80
+ output: {
81
+ changeId: recordedChange.id,
82
+ prUrl: recordedChange.prUrl,
83
+ summary,
84
+ verification
85
+ }
86
+ });
87
+ return {
88
+ change: recordedChange,
89
+ task
90
+ };
91
+ }
92
+ });
93
+ }
94
+ //#endregion
95
+ export { createRecordChangeTool };
96
+
97
+ //# sourceMappingURL=eve-record-change.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eve-record-change.mjs","names":[],"sources":["../../src/changes/eve-record-change.ts"],"sourcesContent":["import { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\nimport type { ChangePresenter } from \"./presentation\";\nimport { changeLevelSchema, type Change } from \"../schema/change\";\nimport { repositoryIdSchema, taskIdSchema } from \"../schema/id\";\nimport type { Task } from \"../schema/task\";\nimport type { PullRequestPublicationGateResult } from \"../pull-requests/contracts\";\nimport type { FactoryStores } from \"../store/engine\";\n\n/** Change and Task capabilities required by the record-change tool. */\nexport type RecordChangeToolStores = Pick<FactoryStores, \"changes\" | \"tasks\">;\n\nconst recordChangeInputSchema = z.object({\n taskId: taskIdSchema,\n repositoryId: repositoryIdSchema,\n prNumber: z.number().int().min(1),\n prUrl: z.url(),\n risk: changeLevelSchema.describe(\"Blast radius of the change if it is wrong.\"),\n confidence: changeLevelSchema.describe(\"How certain you are the change is correct.\"),\n summary: z.string().min(1).describe(\"One-sentence description of the change.\"),\n});\n\n/** Validated input accepted by the tool that links a pull request to its producing Task. */\nexport type RecordChangeInput = z.infer<typeof recordChangeInputSchema>;\n\n/** Configures policy gates and durable presentation for the software record-change tool. */\nexport interface RecordChangeToolOptions {\n /**\n * Pre-action gate for record_change, run as an Eve approval policy before\n * the tool executes. Refusals reach the model as a denial with the reason.\n * Gates must fail closed: when they cannot verify, they refuse.\n */\n recordChangeGate?: (input: RecordChangeInput) => Promise<PullRequestPublicationGateResult>;\n /** Whether recorded code changes wait for an independent verification task. Default: required. */\n verification?: \"required\" | \"disabled\";\n /** Present the pull request after record_change persists its durable state. */\n presentChange?: ChangePresenter;\n}\n\n/** Change and producing Task returned after a pull request is recorded. */\nexport interface RecordChangeResult {\n readonly change: Change;\n readonly task: Task;\n}\n\n/** Eve outcome tool that links a pull request to its producing Task. */\nexport interface RecordChangeTool extends ToolDefinition<RecordChangeInput, RecordChangeResult> {\n execute(input: RecordChangeInput, ctx: ToolContext): Promise<RecordChangeResult>;\n}\n\n/** Create the supplied software workflow's pull-request outcome tool. */\nexport function createRecordChangeTool(\n stores: RecordChangeToolStores,\n options: RecordChangeToolOptions = {},\n): RecordChangeTool {\n const recordChangeGate = options.recordChangeGate;\n const verification = options.verification ?? \"required\";\n return defineTool({\n description:\n verification === \"required\"\n ? \"Record the pull request produced for a code_change task. Creates the change, links it to the task, and moves the task to verifying.\"\n : \"Record the pull request produced for a code_change task. Creates the change and marks it ready for human review without independent verification.\",\n inputSchema: recordChangeInputSchema,\n ...(recordChangeGate === undefined\n ? {}\n : {\n approval: async ({ toolInput }: { toolInput?: unknown }) => {\n const parsed = recordChangeInputSchema.safeParse(toolInput);\n if (!parsed.success) {\n return {\n type: \"denied\" as const,\n reason: \"record_change input is malformed; fix the arguments and retry\",\n };\n }\n const verdict = await recordChangeGate(parsed.data);\n return verdict.ok\n ? (\"not-applicable\" as const)\n : { type: \"denied\" as const, reason: verdict.reason };\n },\n }),\n async execute({\n taskId,\n repositoryId,\n prNumber,\n prUrl,\n risk,\n confidence,\n summary,\n }): Promise<RecordChangeResult> {\n const currentTask = await stores.tasks.get(taskId);\n if (currentTask === null) throw new Error(`task ${taskId} does not exist`);\n if (\n currentTask.state !== \"running\" &&\n currentTask.state !== \"verifying\" &&\n currentTask.state !== \"succeeded\"\n ) {\n throw new Error(`task ${taskId} is ${currentTask.state}, not running`);\n }\n const linkedChange =\n currentTask.changeId === undefined\n ? undefined\n : await stores.changes.get(currentTask.changeId);\n if (currentTask.changeId !== undefined && linkedChange === null) {\n throw new Error(`change ${currentTask.changeId} does not exist`);\n }\n let change =\n linkedChange ??\n (await stores.changes.list()).find((candidate) => candidate.taskId === taskId);\n\n if (change === undefined) {\n if (currentTask.state !== \"running\") {\n throw new Error(`task ${taskId} has no recorded change`);\n }\n change = await stores.changes.create({\n repositoryId,\n taskId,\n prNumber,\n prUrl,\n author: \"factory\",\n risk,\n confidence,\n evidence: {\n reproVerified: false,\n testsAdded: 0,\n checksGreen: false,\n attackPassed: false,\n scopeMatches: false,\n },\n });\n }\n if (change === undefined) throw new Error(`task ${taskId} has no recorded change`);\n let recordedChange = change;\n\n if (currentTask.state === \"running\") {\n await options.presentChange?.({\n taskId,\n changeId: recordedChange.id,\n verification,\n summary,\n });\n }\n\n let task: Task = currentTask;\n if (task.state === \"running\") {\n task = await stores.tasks.transition(taskId, \"verifying\", {\n patch: { changeId: recordedChange.id },\n reason: summary,\n });\n }\n if (verification === \"required\") return { change: recordedChange, task };\n\n if (recordedChange.state === \"verifying\") {\n recordedChange = await stores.changes.transition(recordedChange.id, \"ready\", {\n reason: \"independent verification is not configured\",\n });\n }\n if (task.state === \"verifying\") {\n task = await stores.tasks.transition(taskId, \"succeeded\", {\n reason: \"change recorded for human review without independent verification\",\n output: {\n changeId: recordedChange.id,\n prUrl: recordedChange.prUrl,\n summary,\n verification,\n },\n });\n }\n return { change: recordedChange, task };\n },\n });\n}\n"],"mappings":";;;;;AAYA,MAAM,0BAA0B,EAAE,OAAO;CACvC,QAAQ;CACR,cAAc;CACd,UAAU,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;CAChC,OAAO,EAAE,IAAI;CACb,MAAM,kBAAkB,SAAS,4CAA4C;CAC7E,YAAY,kBAAkB,SAAS,4CAA4C;CACnF,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,yCAAyC;AAC/E,CAAC;;AA+BD,SAAgB,uBACd,QACA,UAAmC,CAAC,GAClB;CAClB,MAAM,mBAAmB,QAAQ;CACjC,MAAM,eAAe,QAAQ,gBAAgB;CAC7C,OAAO,WAAW;EAChB,aACE,iBAAiB,aACb,wIACA;EACN,aAAa;EACb,GAAI,qBAAqB,KAAA,IACrB,CAAC,IACD,EACE,UAAU,OAAO,EAAE,gBAAyC;GAC1D,MAAM,SAAS,wBAAwB,UAAU,SAAS;GAC1D,IAAI,CAAC,OAAO,SACV,OAAO;IACL,MAAM;IACN,QAAQ;GACV;GAEF,MAAM,UAAU,MAAM,iBAAiB,OAAO,IAAI;GAClD,OAAO,QAAQ,KACV,mBACD;IAAE,MAAM;IAAmB,QAAQ,QAAQ;GAAO;EACxD,EACF;EACJ,MAAM,QAAQ,EACZ,QACA,cACA,UACA,OACA,MACA,YACA,WAC8B;GAC9B,MAAM,cAAc,MAAM,OAAO,MAAM,IAAI,MAAM;GACjD,IAAI,gBAAgB,MAAM,MAAM,IAAI,MAAM,QAAQ,OAAO,gBAAgB;GACzE,IACE,YAAY,UAAU,aACtB,YAAY,UAAU,eACtB,YAAY,UAAU,aAEtB,MAAM,IAAI,MAAM,QAAQ,OAAO,MAAM,YAAY,MAAM,cAAc;GAEvE,MAAM,eACJ,YAAY,aAAa,KAAA,IACrB,KAAA,IACA,MAAM,OAAO,QAAQ,IAAI,YAAY,QAAQ;GACnD,IAAI,YAAY,aAAa,KAAA,KAAa,iBAAiB,MACzD,MAAM,IAAI,MAAM,UAAU,YAAY,SAAS,gBAAgB;GAEjE,IAAI,SACF,iBACC,MAAM,OAAO,QAAQ,KAAK,EAAA,CAAG,MAAM,cAAc,UAAU,WAAW,MAAM;GAE/E,IAAI,WAAW,KAAA,GAAW;IACxB,IAAI,YAAY,UAAU,WACxB,MAAM,IAAI,MAAM,QAAQ,OAAO,wBAAwB;IAEzD,SAAS,MAAM,OAAO,QAAQ,OAAO;KACnC;KACA;KACA;KACA;KACA,QAAQ;KACR;KACA;KACA,UAAU;MACR,eAAe;MACf,YAAY;MACZ,aAAa;MACb,cAAc;MACd,cAAc;KAChB;IACF,CAAC;GACH;GACA,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,MAAM,QAAQ,OAAO,wBAAwB;GACjF,IAAI,iBAAiB;GAErB,IAAI,YAAY,UAAU,WACxB,MAAM,QAAQ,gBAAgB;IAC5B;IACA,UAAU,eAAe;IACzB;IACA;GACF,CAAC;GAGH,IAAI,OAAa;GACjB,IAAI,KAAK,UAAU,WACjB,OAAO,MAAM,OAAO,MAAM,WAAW,QAAQ,aAAa;IACxD,OAAO,EAAE,UAAU,eAAe,GAAG;IACrC,QAAQ;GACV,CAAC;GAEH,IAAI,iBAAiB,YAAY,OAAO;IAAE,QAAQ;IAAgB;GAAK;GAEvE,IAAI,eAAe,UAAU,aAC3B,iBAAiB,MAAM,OAAO,QAAQ,WAAW,eAAe,IAAI,SAAS,EAC3E,QAAQ,6CACV,CAAC;GAEH,IAAI,KAAK,UAAU,aACjB,OAAO,MAAM,OAAO,MAAM,WAAW,QAAQ,aAAa;IACxD,QAAQ;IACR,QAAQ;KACN,UAAU,eAAe;KACzB,OAAO,eAAe;KACtB;KACA;IACF;GACF,CAAC;GAEH,OAAO;IAAE,QAAQ;IAAgB;GAAK;EACxC;CACF,CAAC;AACH"}
@@ -0,0 +1,14 @@
1
+ import { ChangeId, TaskId } from "../schema/id.mjs";
2
+ //#region src/changes/presentation.d.ts
3
+ /** Details presented after a pull request is durably recorded as a Change. */
4
+ interface PresentChangeInput {
5
+ taskId: TaskId;
6
+ changeId: ChangeId;
7
+ verification: "required" | "disabled";
8
+ summary: string;
9
+ }
10
+ /** Presents a newly recorded Change through an application-owned channel. */
11
+ type ChangePresenter = (input: PresentChangeInput) => Promise<void>;
12
+ //#endregion
13
+ export { ChangePresenter, PresentChangeInput };
14
+ //# sourceMappingURL=presentation.d.mts.map
@@ -0,0 +1,23 @@
1
+ import { ChangeId, RepositoryId, changeIdSchema } from "./schema/id.mjs";
2
+ import { Change, ChangeEvidence, ChangeInState, ChangeLevel, ChangeState, changeEvidenceSchema, changeLevelSchema, changeSchema, changeStateSchema } from "./schema/change.mjs";
3
+ import { ChangeAssociationError, ChangePatch, ChangeTransitionArguments, ChangeTransitionOptions, CreateChangeInput, FactoryStores } from "./store/engine.mjs";
4
+ import { changeInitialState, changeTransitions } from "./schema/transitions.mjs";
5
+ import { ChangePresenter, PresentChangeInput } from "./changes/presentation.mjs";
6
+ import { RecordChangeInput, RecordChangeResult, RecordChangeTool, RecordChangeToolOptions, RecordChangeToolStores, createRecordChangeTool } from "./changes/eve-record-change.mjs";
7
+ import { formatChangeVerificationBrief } from "./change-verification/brief.mjs";
8
+ import { ChangeVerificationStores, EnsureChangeVerificationTasksOptions, EnsureChangeVerificationTasksResult, ensureChangeVerificationTasks } from "./change-verification/dispatch.mjs";
9
+ import { PresentVerificationResultInput, RecordVerificationInput, RecordVerificationRefusal, RecordVerificationResult, RecordVerificationSuccess, RecordVerificationTool, RecordVerificationToolOptions, RecordVerificationToolStores, createRecordVerificationTool } from "./change-verification/eve-tool.mjs";
10
+ import { CreateMultiRepositoryChangeTasksInput, CreateMultiRepositoryChangeTasksStores, MultiRepositoryChangePlan, ReconcileMultiRepositoryChangeTasksResult, ReconcileMultiRepositoryChangeTasksStores, createMultiRepositoryChangeTasks, reconcileMultiRepositoryChangeTasks } from "./multi-repository-changes/coordination.mjs";
11
+ //#region src/changes.d.ts
12
+ /** Provider identity and author required to represent an existing pull request as a Change. */
13
+ interface AdoptPullRequestInput {
14
+ repositoryId: RepositoryId;
15
+ prNumber: number;
16
+ prUrl: string;
17
+ author: string;
18
+ }
19
+ /** Create a conservative, unverified Change for a pull request not authored by Factory. */
20
+ declare function adoptPullRequest(stores: Pick<FactoryStores, "changes">, input: AdoptPullRequestInput): Promise<Change>;
21
+ //#endregion
22
+ export { AdoptPullRequestInput, type Change, ChangeAssociationError, type ChangeEvidence, type ChangeId, type ChangeInState, type ChangeLevel, type ChangePatch, type ChangePresenter, type ChangeState, type ChangeTransitionArguments, type ChangeTransitionOptions, type ChangeVerificationStores, type CreateChangeInput, type CreateMultiRepositoryChangeTasksInput, type CreateMultiRepositoryChangeTasksStores, type EnsureChangeVerificationTasksOptions, type EnsureChangeVerificationTasksResult, type MultiRepositoryChangePlan, type PresentChangeInput, type PresentVerificationResultInput, type ReconcileMultiRepositoryChangeTasksResult, type ReconcileMultiRepositoryChangeTasksStores, type RecordChangeInput, type RecordChangeResult, type RecordChangeTool, type RecordChangeToolOptions, type RecordChangeToolStores, type RecordVerificationInput, type RecordVerificationRefusal, type RecordVerificationResult, type RecordVerificationSuccess, type RecordVerificationTool, type RecordVerificationToolOptions, type RecordVerificationToolStores, adoptPullRequest, changeEvidenceSchema, changeIdSchema, changeInitialState, changeLevelSchema, changeSchema, changeStateSchema, changeTransitions, createMultiRepositoryChangeTasks, createRecordChangeTool, createRecordVerificationTool, ensureChangeVerificationTasks, formatChangeVerificationBrief, reconcileMultiRepositoryChangeTasks };
23
+ //# sourceMappingURL=changes.d.mts.map
@@ -0,0 +1,29 @@
1
+ import { changeIdSchema } from "./schema/id.mjs";
2
+ import { changeInitialState, changeTransitions } from "./schema/transitions.mjs";
3
+ import { changeEvidenceSchema, changeLevelSchema, changeSchema, changeStateSchema } from "./schema/change.mjs";
4
+ import { ChangeAssociationError } from "./store/engine.mjs";
5
+ import { createRecordChangeTool } from "./changes/eve-record-change.mjs";
6
+ import { formatChangeVerificationBrief } from "./change-verification/brief.mjs";
7
+ import { ensureChangeVerificationTasks } from "./change-verification/dispatch.mjs";
8
+ import { createRecordVerificationTool } from "./change-verification/eve-tool.mjs";
9
+ import { createMultiRepositoryChangeTasks, reconcileMultiRepositoryChangeTasks } from "./multi-repository-changes/coordination.mjs";
10
+ //#region src/changes.ts
11
+ /** Create a conservative, unverified Change for a pull request not authored by Factory. */
12
+ async function adoptPullRequest(stores, input) {
13
+ return stores.changes.create({
14
+ ...input,
15
+ risk: "low",
16
+ confidence: "low",
17
+ evidence: {
18
+ reproVerified: false,
19
+ testsAdded: 0,
20
+ checksGreen: false,
21
+ attackPassed: false,
22
+ scopeMatches: false
23
+ }
24
+ });
25
+ }
26
+ //#endregion
27
+ export { ChangeAssociationError, adoptPullRequest, changeEvidenceSchema, changeIdSchema, changeInitialState, changeLevelSchema, changeSchema, changeStateSchema, changeTransitions, createMultiRepositoryChangeTasks, createRecordChangeTool, createRecordVerificationTool, ensureChangeVerificationTasks, formatChangeVerificationBrief, reconcileMultiRepositoryChangeTasks };
28
+
29
+ //# sourceMappingURL=changes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"changes.mjs","names":[],"sources":["../src/changes.ts"],"sourcesContent":["import type { Change } from \"./schema/change\";\nimport type { RepositoryId } from \"./schema/id\";\nimport type { FactoryStores } from \"./store/engine\";\n\nexport { type ChangePresenter, type PresentChangeInput } from \"./changes/presentation\";\nexport {\n createRecordChangeTool,\n type RecordChangeInput,\n type RecordChangeResult,\n type RecordChangeTool,\n type RecordChangeToolStores,\n type RecordChangeToolOptions,\n} from \"./changes/eve-record-change\";\nexport { formatChangeVerificationBrief } from \"./change-verification/brief\";\nexport {\n ensureChangeVerificationTasks,\n type ChangeVerificationStores,\n type EnsureChangeVerificationTasksOptions,\n type EnsureChangeVerificationTasksResult,\n} from \"./change-verification/dispatch\";\nexport {\n createRecordVerificationTool,\n type PresentVerificationResultInput,\n type RecordVerificationInput,\n type RecordVerificationRefusal,\n type RecordVerificationResult,\n type RecordVerificationSuccess,\n type RecordVerificationTool,\n type RecordVerificationToolStores,\n type RecordVerificationToolOptions,\n} from \"./change-verification/eve-tool\";\nexport {\n createMultiRepositoryChangeTasks,\n reconcileMultiRepositoryChangeTasks,\n type CreateMultiRepositoryChangeTasksInput,\n type CreateMultiRepositoryChangeTasksStores,\n type MultiRepositoryChangePlan,\n type ReconcileMultiRepositoryChangeTasksResult,\n type ReconcileMultiRepositoryChangeTasksStores,\n} from \"./multi-repository-changes/coordination\";\n\n/** Provider identity and author required to represent an existing pull request as a Change. */\nexport interface AdoptPullRequestInput {\n repositoryId: RepositoryId;\n prNumber: number;\n prUrl: string;\n author: string;\n}\n\n/** Create a conservative, unverified Change for a pull request not authored by Factory. */\nexport async function adoptPullRequest(\n stores: Pick<FactoryStores, \"changes\">,\n input: AdoptPullRequestInput,\n): Promise<Change> {\n return stores.changes.create({\n ...input,\n risk: \"low\",\n confidence: \"low\",\n evidence: {\n reproVerified: false,\n testsAdded: 0,\n checksGreen: false,\n attackPassed: false,\n scopeMatches: false,\n },\n });\n}\n\nexport {\n changeEvidenceSchema,\n changeSchema,\n changeStateSchema,\n changeLevelSchema,\n type Change,\n type ChangeEvidence,\n type ChangeInState,\n type ChangeState,\n type ChangeLevel,\n} from \"./schema/change\";\nexport { changeIdSchema, type ChangeId } from \"./schema/id\";\nexport { changeInitialState, changeTransitions } from \"./schema/transitions\";\nexport {\n ChangeAssociationError,\n type ChangePatch,\n type ChangeTransitionOptions,\n type ChangeTransitionArguments,\n type CreateChangeInput,\n} from \"./store/engine\";\n"],"mappings":";;;;;;;;;;;AAkDA,eAAsB,iBACpB,QACA,OACiB;CACjB,OAAO,OAAO,QAAQ,OAAO;EAC3B,GAAG;EACH,MAAM;EACN,YAAY;EACZ,UAAU;GACR,eAAe;GACf,YAAY;GACZ,aAAa;GACb,cAAc;GACd,cAAc;EAChB;CACF,CAAC;AACH"}
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ //#region src/client-events.d.ts
3
+ /** Validates one newline-delimited event from a Factory execution stream. */
4
+ declare const streamEventSchema: z.ZodObject<{
5
+ type: z.ZodString;
6
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
7
+ meta: z.ZodOptional<z.ZodObject<{
8
+ id: z.ZodOptional<z.ZodString>;
9
+ at: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>>;
11
+ }, z.core.$strip>;
12
+ /** One validated event received from a Factory execution stream. */
13
+ type StreamEvent = z.infer<typeof streamEventSchema>;
14
+ /** Parses validated newline-delimited events from a response body. */
15
+ declare function readEvents(body: ReadableStream<Uint8Array>): AsyncGenerator<StreamEvent>;
16
+ //#endregion
17
+ export { StreamEvent, readEvents, streamEventSchema };
18
+ //# sourceMappingURL=client-events.d.mts.map
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ //#region src/client-events.ts
3
+ /** Validates one newline-delimited event from a Factory execution stream. */
4
+ const streamEventSchema = z.object({
5
+ type: z.string(),
6
+ data: z.record(z.string(), z.unknown()),
7
+ meta: z.object({
8
+ id: z.string().optional(),
9
+ at: z.string().optional()
10
+ }).optional()
11
+ });
12
+ /** Parses validated newline-delimited events from a response body. */
13
+ async function* readEvents(body) {
14
+ const reader = body.getReader();
15
+ const decoder = new TextDecoder();
16
+ let pending = "";
17
+ try {
18
+ for (;;) {
19
+ const { done, value } = await reader.read();
20
+ pending += done ? decoder.decode() : decoder.decode(value, { stream: true });
21
+ let newline;
22
+ while ((newline = pending.indexOf("\n")) >= 0) {
23
+ const line = pending.slice(0, newline).trim();
24
+ pending = pending.slice(newline + 1);
25
+ if (line) yield streamEventSchema.parse(JSON.parse(line));
26
+ }
27
+ if (pending.length > 2e6) throw new Error("Stream event exceeds the 2 MB limit");
28
+ if (done) {
29
+ if (pending.trim()) yield streamEventSchema.parse(JSON.parse(pending));
30
+ return;
31
+ }
32
+ }
33
+ } finally {
34
+ await reader.cancel().catch(() => {});
35
+ reader.releaseLock();
36
+ }
37
+ }
38
+ //#endregion
39
+ export { readEvents, streamEventSchema };
40
+
41
+ //# sourceMappingURL=client-events.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-events.mjs","names":[],"sources":["../src/client-events.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Validates one newline-delimited event from a Factory execution stream. */\nexport const streamEventSchema = z.object({\n type: z.string(),\n data: z.record(z.string(), z.unknown()),\n meta: z.object({ id: z.string().optional(), at: z.string().optional() }).optional(),\n});\n/** One validated event received from a Factory execution stream. */\nexport type StreamEvent = z.infer<typeof streamEventSchema>;\n\n/** Parses validated newline-delimited events from a response body. */\nexport async function* readEvents(body: ReadableStream<Uint8Array>): AsyncGenerator<StreamEvent> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let pending = \"\";\n try {\n for (;;) {\n const { done, value } = await reader.read();\n pending += done ? decoder.decode() : decoder.decode(value, { stream: true });\n let newline: number;\n while ((newline = pending.indexOf(\"\\n\")) >= 0) {\n const line = pending.slice(0, newline).trim();\n pending = pending.slice(newline + 1);\n if (line) yield streamEventSchema.parse(JSON.parse(line));\n }\n if (pending.length > 2_000_000) throw new Error(\"Stream event exceeds the 2 MB limit\");\n if (done) {\n if (pending.trim()) yield streamEventSchema.parse(JSON.parse(pending));\n return;\n }\n }\n } finally {\n await reader.cancel().catch(() => {});\n reader.releaseLock();\n }\n}\n"],"mappings":";;;AAGA,MAAa,oBAAoB,EAAE,OAAO;CACxC,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;CACtC,MAAM,EAAE,OAAO;EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS;EAAG,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS;CAAE,CAAC,CAAC,CAAC,SAAS;AACpF,CAAC;;AAKD,gBAAuB,WAAW,MAA+D;CAC/F,MAAM,SAAS,KAAK,UAAU;CAC9B,MAAM,UAAU,IAAI,YAAY;CAChC,IAAI,UAAU;CACd,IAAI;EACF,SAAS;GACP,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;GAC1C,WAAW,OAAO,QAAQ,OAAO,IAAI,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC;GAC3E,IAAI;GACJ,QAAQ,UAAU,QAAQ,QAAQ,IAAI,MAAM,GAAG;IAC7C,MAAM,OAAO,QAAQ,MAAM,GAAG,OAAO,CAAC,CAAC,KAAK;IAC5C,UAAU,QAAQ,MAAM,UAAU,CAAC;IACnC,IAAI,MAAM,MAAM,kBAAkB,MAAM,KAAK,MAAM,IAAI,CAAC;GAC1D;GACA,IAAI,QAAQ,SAAS,KAAW,MAAM,IAAI,MAAM,qCAAqC;GACrF,IAAI,MAAM;IACR,IAAI,QAAQ,KAAK,GAAG,MAAM,kBAAkB,MAAM,KAAK,MAAM,OAAO,CAAC;IACrE;GACF;EACF;CACF,UAAU;EACR,MAAM,OAAO,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;EACpC,OAAO,YAAY;CACrB;AACF"}
@@ -0,0 +1,28 @@
1
+ import { TaskId } from "./schema/id.mjs";
2
+ import { AgentSessionId } from "./schema/session.mjs";
3
+ import { Transcript } from "./client-transcript.mjs";
4
+ import { FactoryClient } from "./client.mjs";
5
+ import { SessionView } from "./api-contracts.mjs";
6
+ //#region src/client-stream.d.ts
7
+ /** Client operations required to hydrate and follow a Factory session stream. */
8
+ type SessionStreamClient = Pick<FactoryClient, "getSessionTranscriptResponse" | "getSessionEventStreamResponse">;
9
+ /** Callbacks and exact execution identity used while following a session stream. */
10
+ interface FollowSessionStreamOptions {
11
+ readonly sessionId: AgentSessionId;
12
+ readonly executionId: string | null;
13
+ readonly taskId?: TaskId;
14
+ readonly history?: readonly NonNullable<SessionView["history"]>[number][];
15
+ readonly transcript: Transcript;
16
+ readonly signal: AbortSignal;
17
+ readonly pollIntervalMs?: number;
18
+ readonly onHydrated: () => void;
19
+ readonly onChange: () => void;
20
+ readonly onConnection: (state: "connected" | "reconnecting") => void;
21
+ readonly onError: (error: unknown) => void;
22
+ readonly onConflict: () => Promise<void>;
23
+ }
24
+ /** Hydrates a transcript and follows its current execution until completion or disconnection. */
25
+ declare function followSessionStream(client: SessionStreamClient, options: FollowSessionStreamOptions): Promise<void>;
26
+ //#endregion
27
+ export { FollowSessionStreamOptions, SessionStreamClient, followSessionStream };
28
+ //# sourceMappingURL=client-stream.d.mts.map