@vercel/factory 0.0.14 → 0.0.16

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 (510) hide show
  1. package/CHANGELOG.md +356 -0
  2. package/README.md +96 -2
  3. package/dist/agent-routes.d.mts +113 -0
  4. package/dist/agent-routes.mjs +91 -0
  5. package/dist/agent-routes.mjs.map +1 -0
  6. package/dist/api-contracts.d.mts +1768 -0
  7. package/dist/api-contracts.mjs +119 -0
  8. package/dist/api-contracts.mjs.map +1 -0
  9. package/dist/api-images.d.mts +30 -0
  10. package/dist/api-images.mjs +28 -0
  11. package/dist/api-images.mjs.map +1 -0
  12. package/dist/api-task-graph.mjs +57 -0
  13. package/dist/api-task-graph.mjs.map +1 -0
  14. package/dist/api.d.mts +111 -216
  15. package/dist/api.mjs +1063 -99
  16. package/dist/api.mjs.map +1 -1
  17. package/dist/approval-access.d.mts +39 -0
  18. package/dist/approval-access.mjs +62 -0
  19. package/dist/approval-access.mjs.map +1 -0
  20. package/dist/approval-contracts.d.mts +698 -0
  21. package/dist/approval-contracts.mjs +27 -0
  22. package/dist/approval-contracts.mjs.map +1 -0
  23. package/dist/approval.d.mts +49 -0
  24. package/dist/approval.mjs +39 -0
  25. package/dist/approval.mjs.map +1 -0
  26. package/dist/blob/artifacts.d.mts +37 -0
  27. package/dist/blob/artifacts.mjs +45 -0
  28. package/dist/blob/artifacts.mjs.map +1 -0
  29. package/dist/blob/index.d.mts +84 -12
  30. package/dist/blob/index.mjs +179 -45
  31. package/dist/blob/index.mjs.map +1 -1
  32. package/dist/budget.d.mts +115 -0
  33. package/dist/budget.mjs +147 -0
  34. package/dist/budget.mjs.map +1 -0
  35. package/dist/budgets.d.mts +4 -0
  36. package/dist/budgets.mjs +4 -0
  37. package/dist/build-factory.d.mts +7 -4
  38. package/dist/build-factory.mjs +2 -1
  39. package/dist/build-factory.mjs.map +1 -1
  40. package/dist/change-verification/brief.d.mts +9 -0
  41. package/dist/change-verification/brief.mjs +13 -0
  42. package/dist/change-verification/brief.mjs.map +1 -0
  43. package/dist/change-verification/dispatch.d.mts +37 -0
  44. package/dist/change-verification/dispatch.mjs +83 -0
  45. package/dist/change-verification/dispatch.mjs.map +1 -0
  46. package/dist/change-verification/eve-tool.d.mts +61 -0
  47. package/dist/change-verification/eve-tool.mjs +89 -0
  48. package/dist/change-verification/eve-tool.mjs.map +1 -0
  49. package/dist/change-verification/result.mjs +130 -0
  50. package/dist/change-verification/result.mjs.map +1 -0
  51. package/dist/changes/eve-record-change.d.mts +56 -0
  52. package/dist/changes/eve-record-change.mjs +131 -0
  53. package/dist/changes/eve-record-change.mjs.map +1 -0
  54. package/dist/changes/presentation.d.mts +14 -0
  55. package/dist/changes.d.mts +24 -0
  56. package/dist/changes.mjs +29 -0
  57. package/dist/changes.mjs.map +1 -0
  58. package/dist/client-events.d.mts +25 -0
  59. package/dist/client-events.mjs +45 -0
  60. package/dist/client-events.mjs.map +1 -0
  61. package/dist/client-stream.d.mts +28 -0
  62. package/dist/client-stream.mjs +210 -0
  63. package/dist/client-stream.mjs.map +1 -0
  64. package/dist/client-transcript.d.mts +41 -0
  65. package/dist/client-transcript.mjs +233 -0
  66. package/dist/client-transcript.mjs.map +1 -0
  67. package/dist/client.d.mts +343 -0
  68. package/dist/client.mjs +366 -0
  69. package/dist/client.mjs.map +1 -0
  70. package/dist/code-review/contracts.d.mts +27 -0
  71. package/dist/code-review/eve-post-review.d.mts +70 -0
  72. package/dist/code-review/eve-post-review.mjs +195 -0
  73. package/dist/code-review/eve-post-review.mjs.map +1 -0
  74. package/dist/code-review/eve-review-comments.d.mts +75 -0
  75. package/dist/code-review/eve-review-comments.mjs +193 -0
  76. package/dist/code-review/eve-review-comments.mjs.map +1 -0
  77. package/dist/code-review/github-contracts.d.mts +10 -0
  78. package/dist/code-review/github-reporter.d.mts +46 -0
  79. package/dist/code-review/github-reporter.mjs +262 -0
  80. package/dist/code-review/github-reporter.mjs.map +1 -0
  81. package/dist/code-review/preparation.d.mts +34 -0
  82. package/dist/code-review/preparation.mjs +23 -0
  83. package/dist/code-review/preparation.mjs.map +1 -0
  84. package/dist/code-review/stall.d.mts +17 -0
  85. package/dist/code-review/stall.mjs +30 -0
  86. package/dist/code-review/stall.mjs.map +1 -0
  87. package/dist/code-review.d.mts +7 -0
  88. package/dist/code-review.mjs +5 -0
  89. package/dist/communication.d.mts +9 -0
  90. package/dist/communication.mjs +9 -0
  91. package/dist/connectors/github.d.mts +26 -0
  92. package/dist/connectors/github.mjs +55 -0
  93. package/dist/connectors/github.mjs.map +1 -0
  94. package/dist/connectors/index.d.mts +35 -3
  95. package/dist/connectors/index.mjs +3 -52
  96. package/dist/connectors/index.mjs.map +1 -1
  97. package/dist/connectors/outbox.d.mts +34 -0
  98. package/dist/connectors/outbox.mjs +50 -0
  99. package/dist/connectors/outbox.mjs.map +1 -0
  100. package/dist/connectors/slack-approval-blocks.mjs +136 -0
  101. package/dist/connectors/slack-approval-blocks.mjs.map +1 -0
  102. package/dist/connectors/slack-approvals.d.mts +29 -0
  103. package/dist/connectors/slack-approvals.mjs +346 -0
  104. package/dist/connectors/slack-approvals.mjs.map +1 -0
  105. package/dist/connectors/slack.d.mts +35 -52
  106. package/dist/connectors/slack.mjs +13 -85
  107. package/dist/connectors/slack.mjs.map +1 -1
  108. package/dist/deepsec/eve-tool.d.mts +110 -0
  109. package/dist/deepsec/eve-tool.mjs +166 -0
  110. package/dist/deepsec/eve-tool.mjs.map +1 -0
  111. package/dist/deepsec/finding.d.mts +84 -0
  112. package/dist/deepsec/finding.mjs +56 -0
  113. package/dist/deepsec/finding.mjs.map +1 -0
  114. package/dist/deepsec.d.mts +3 -0
  115. package/dist/delivery-metrics/metrics.d.mts +93 -0
  116. package/dist/delivery-metrics/metrics.mjs +200 -0
  117. package/dist/delivery-metrics/metrics.mjs.map +1 -0
  118. package/dist/delivery-metrics.d.mts +2 -0
  119. package/dist/delivery-metrics.mjs +2 -0
  120. package/dist/dispatch.d.mts +152 -0
  121. package/dist/dispatch.mjs +199 -0
  122. package/dist/dispatch.mjs.map +1 -0
  123. package/dist/errors.d.mts +15 -0
  124. package/dist/errors.mjs +38 -0
  125. package/dist/errors.mjs.map +1 -0
  126. package/dist/eve/index.d.mts +209 -1277
  127. package/dist/eve/index.mjs +312 -1073
  128. package/dist/eve/index.mjs.map +1 -1
  129. package/dist/eve/invoke.d.mts +144 -0
  130. package/dist/eve/invoke.mjs +254 -0
  131. package/dist/eve/invoke.mjs.map +1 -0
  132. package/dist/eve/session-client.d.mts +186 -0
  133. package/dist/eve/session-client.mjs +245 -0
  134. package/dist/eve/session-client.mjs.map +1 -0
  135. package/dist/eve/task-execution.d.mts +380 -0
  136. package/dist/eve/task-execution.mjs +73 -0
  137. package/dist/eve/task-execution.mjs.map +1 -0
  138. package/dist/eve/task-session.d.mts +129 -0
  139. package/dist/eve/task-session.mjs +245 -0
  140. package/dist/eve/task-session.mjs.map +1 -0
  141. package/dist/eve/transcript.d.mts +37 -0
  142. package/dist/eve/transcript.mjs +69 -0
  143. package/dist/eve/transcript.mjs.map +1 -0
  144. package/dist/execution-public.d.mts +8 -0
  145. package/dist/execution-public.mjs +7 -0
  146. package/dist/execution.d.mts +183 -0
  147. package/dist/execution.mjs +223 -0
  148. package/dist/execution.mjs.map +1 -0
  149. package/dist/finding-remediation/admission.d.mts +53 -0
  150. package/dist/finding-remediation/admission.mjs +90 -0
  151. package/dist/finding-remediation/admission.mjs.map +1 -0
  152. package/dist/finding-remediation/brief.d.mts +14 -0
  153. package/dist/finding-remediation/brief.mjs +25 -0
  154. package/dist/finding-remediation/brief.mjs.map +1 -0
  155. package/dist/finding-remediation/eve-tool.d.mts +29 -0
  156. package/dist/finding-remediation/eve-tool.mjs +34 -0
  157. package/dist/finding-remediation/eve-tool.mjs.map +1 -0
  158. package/dist/findings/fingerprint.d.mts +14 -0
  159. package/dist/findings/fingerprint.mjs +28 -0
  160. package/dist/findings/fingerprint.mjs.map +1 -0
  161. package/dist/findings.d.mts +7 -0
  162. package/dist/findings.mjs +6 -0
  163. package/dist/github-app.d.mts +54 -0
  164. package/dist/github-app.mjs +121 -0
  165. package/dist/github-app.mjs.map +1 -0
  166. package/dist/github-publication.d.mts +199 -0
  167. package/dist/github-publication.mjs +442 -0
  168. package/dist/github-publication.mjs.map +1 -0
  169. package/dist/github-transfer.d.mts +81 -0
  170. package/dist/github-transfer.mjs +273 -0
  171. package/dist/github-transfer.mjs.map +1 -0
  172. package/dist/github.d.mts +446 -2
  173. package/dist/github.mjs +357 -56
  174. package/dist/github.mjs.map +1 -1
  175. package/dist/image-input.d.mts +51 -0
  176. package/dist/image-input.mjs +63 -0
  177. package/dist/image-input.mjs.map +1 -0
  178. package/dist/inbox-activity.d.mts +53 -0
  179. package/dist/inbox-activity.mjs +41 -0
  180. package/dist/inbox-activity.mjs.map +1 -0
  181. package/dist/index.d.mts +16 -484
  182. package/dist/index.mjs +15 -522
  183. package/dist/intake-contracts.d.mts +55 -0
  184. package/dist/intake-contracts.mjs +33 -0
  185. package/dist/intake-contracts.mjs.map +1 -0
  186. package/dist/integrations/deepsec.d.mts +5 -0
  187. package/dist/integrations/deepsec.mjs +3 -0
  188. package/dist/integrations/github.d.mts +11 -0
  189. package/dist/integrations/github.mjs +9 -0
  190. package/dist/integrations/slack.d.mts +5 -0
  191. package/dist/integrations/slack.mjs +5 -0
  192. package/dist/integrations/vercel.d.mts +5 -0
  193. package/dist/integrations/vercel.mjs +4 -0
  194. package/dist/merge-resolution/contracts.d.mts +17 -0
  195. package/dist/merge-resolution/contracts.mjs +19 -0
  196. package/dist/merge-resolution/contracts.mjs.map +1 -0
  197. package/dist/merge-resolution/eve-tools.d.mts +47 -0
  198. package/dist/merge-resolution/eve-tools.mjs +122 -0
  199. package/dist/merge-resolution/eve-tools.mjs.map +1 -0
  200. package/dist/model-settings.d.mts +41 -0
  201. package/dist/model-settings.mjs +35 -0
  202. package/dist/model-settings.mjs.map +1 -0
  203. package/dist/multi-repository-changes/coordination.d.mts +49 -0
  204. package/dist/multi-repository-changes/coordination.mjs +115 -0
  205. package/dist/multi-repository-changes/coordination.mjs.map +1 -0
  206. package/dist/planning/cancellation.mjs +82 -0
  207. package/dist/planning/cancellation.mjs.map +1 -0
  208. package/dist/planning/configuration.d.mts +23 -0
  209. package/dist/planning/configuration.mjs +56 -0
  210. package/dist/planning/configuration.mjs.map +1 -0
  211. package/dist/planning/contracts.d.mts +136 -0
  212. package/dist/planning/contracts.mjs +42 -0
  213. package/dist/planning/contracts.mjs.map +1 -0
  214. package/dist/planning/dependencies.mjs +44 -0
  215. package/dist/planning/dependencies.mjs.map +1 -0
  216. package/dist/planning/effects.mjs +122 -0
  217. package/dist/planning/effects.mjs.map +1 -0
  218. package/dist/planning/reconcile.mjs +279 -0
  219. package/dist/planning/reconcile.mjs.map +1 -0
  220. package/dist/planning/runtime.d.mts +27 -0
  221. package/dist/planning/runtime.mjs +25 -0
  222. package/dist/planning/runtime.mjs.map +1 -0
  223. package/dist/planning/state.mjs +92 -0
  224. package/dist/planning/state.mjs.map +1 -0
  225. package/dist/planning/turns.mjs +262 -0
  226. package/dist/planning/turns.mjs.map +1 -0
  227. package/dist/planning/validation.mjs +106 -0
  228. package/dist/planning/validation.mjs.map +1 -0
  229. package/dist/postgres/index.d.mts +48 -1
  230. package/dist/postgres/index.mjs +45 -3
  231. package/dist/postgres/index.mjs.map +1 -1
  232. package/dist/presets/software-development/approval.d.mts +14 -0
  233. package/dist/presets/software-development/approval.mjs +21 -0
  234. package/dist/presets/software-development/approval.mjs.map +1 -0
  235. package/dist/presets/software-development/deepsec-brief.d.mts +8 -0
  236. package/dist/presets/software-development/deepsec-brief.mjs +14 -0
  237. package/dist/presets/software-development/deepsec-brief.mjs.map +1 -0
  238. package/dist/presets/software-development/dispatch.d.mts +56 -0
  239. package/dist/presets/software-development/dispatch.mjs +67 -0
  240. package/dist/presets/software-development/dispatch.mjs.map +1 -0
  241. package/dist/presets/software-development/eve-delegation-policy.d.mts +7 -0
  242. package/dist/presets/software-development/eve-delegation-policy.mjs +34 -0
  243. package/dist/presets/software-development/eve-delegation-policy.mjs.map +1 -0
  244. package/dist/presets/software-development/eve.d.mts +18 -0
  245. package/dist/presets/software-development/eve.mjs +19 -0
  246. package/dist/presets/software-development/eve.mjs.map +1 -0
  247. package/dist/presets/software-development/finish-task-policy.d.mts +7 -0
  248. package/dist/presets/software-development/finish-task-policy.mjs +9 -0
  249. package/dist/presets/software-development/finish-task-policy.mjs.map +1 -0
  250. package/dist/presets/software-development/recovery.d.mts +32 -0
  251. package/dist/presets/software-development/recovery.mjs +120 -0
  252. package/dist/presets/software-development/recovery.mjs.map +1 -0
  253. package/dist/presets/software-development/task-communication.d.mts +24 -0
  254. package/dist/presets/software-development/task-communication.mjs +157 -0
  255. package/dist/presets/software-development/task-communication.mjs.map +1 -0
  256. package/dist/presets/software-development.d.mts +10 -0
  257. package/dist/presets/software-development.mjs +9 -0
  258. package/dist/pull-requests/contracts.d.mts +72 -0
  259. package/dist/pull-requests/eve-fetch.d.mts +57 -0
  260. package/dist/pull-requests/eve-fetch.mjs +151 -0
  261. package/dist/pull-requests/eve-fetch.mjs.map +1 -0
  262. package/dist/pull-requests/github-label-manager.d.mts +27 -0
  263. package/dist/pull-requests/github-label-manager.mjs +40 -0
  264. package/dist/pull-requests/github-label-manager.mjs.map +1 -0
  265. package/dist/pull-requests/github-publisher.d.mts +67 -0
  266. package/dist/pull-requests/github-publisher.mjs +405 -0
  267. package/dist/pull-requests/github-publisher.mjs.map +1 -0
  268. package/dist/pull-requests.d.mts +6 -0
  269. package/dist/pull-requests.mjs +4 -0
  270. package/dist/receipts.d.mts +4 -0
  271. package/dist/receipts.mjs +3 -0
  272. package/dist/repositories.d.mts +18 -0
  273. package/dist/repositories.mjs +33 -0
  274. package/dist/repositories.mjs.map +1 -0
  275. package/dist/sandbox/command.d.mts +18 -0
  276. package/dist/sandbox/execution-abort.d.mts +16 -0
  277. package/dist/sandbox/execution-abort.mjs +49 -0
  278. package/dist/sandbox/execution-abort.mjs.map +1 -0
  279. package/dist/sandbox/execution-environment.d.mts +25 -0
  280. package/dist/sandbox/execution-run-ledger.d.mts +115 -0
  281. package/dist/sandbox/execution-run-ledger.mjs +209 -0
  282. package/dist/sandbox/execution-run-ledger.mjs.map +1 -0
  283. package/dist/sandbox/execution.d.mts +54 -0
  284. package/dist/sandbox/execution.mjs +228 -0
  285. package/dist/sandbox/execution.mjs.map +1 -0
  286. package/dist/sandbox/harness-runner.d.mts +79 -0
  287. package/dist/sandbox/harness-runner.mjs +162 -0
  288. package/dist/sandbox/harness-runner.mjs.map +1 -0
  289. package/dist/sandbox/index.d.mts +10 -0
  290. package/dist/sandbox/index.mjs +7 -0
  291. package/dist/sandbox/task-environment.d.mts +50 -0
  292. package/dist/sandbox/task-environment.mjs +140 -0
  293. package/dist/sandbox/task-environment.mjs.map +1 -0
  294. package/dist/sandbox/workspace.d.mts +29 -0
  295. package/dist/sandbox/workspace.mjs +28 -0
  296. package/dist/sandbox/workspace.mjs.map +1 -0
  297. package/dist/schema/agent-route.d.mts +40 -0
  298. package/dist/schema/agent-route.mjs +33 -0
  299. package/dist/schema/agent-route.mjs.map +1 -0
  300. package/dist/schema/answer.d.mts +23 -0
  301. package/dist/schema/answer.mjs +21 -0
  302. package/dist/schema/answer.mjs.map +1 -0
  303. package/dist/schema/budget.d.mts +38 -0
  304. package/dist/schema/budget.mjs +30 -0
  305. package/dist/schema/budget.mjs.map +1 -0
  306. package/dist/schema/catalog.mjs +72 -0
  307. package/dist/schema/catalog.mjs.map +1 -0
  308. package/dist/schema/change.d.mts +117 -0
  309. package/dist/schema/change.mjs +68 -0
  310. package/dist/schema/change.mjs.map +1 -0
  311. package/dist/schema/common.d.mts +33 -0
  312. package/dist/{id-BLIkCVue.mjs → schema/common.mjs} +7 -16
  313. package/dist/schema/common.mjs.map +1 -0
  314. package/dist/schema/communication.d.mts +52 -0
  315. package/dist/{communication-Kd9nU5RP.mjs → schema/communication.mjs} +8 -3
  316. package/dist/schema/communication.mjs.map +1 -0
  317. package/dist/schema/execution.d.mts +101 -0
  318. package/dist/schema/execution.mjs +86 -0
  319. package/dist/schema/execution.mjs.map +1 -0
  320. package/dist/schema/factory-config.d.mts +122 -0
  321. package/dist/schema/factory-config.mjs +90 -0
  322. package/dist/schema/factory-config.mjs.map +1 -0
  323. package/dist/schema/finding.d.mts +125 -0
  324. package/dist/schema/finding.mjs +67 -0
  325. package/dist/schema/finding.mjs.map +1 -0
  326. package/dist/schema/id.d.mts +43 -0
  327. package/dist/schema/id.mjs +32 -0
  328. package/dist/schema/id.mjs.map +1 -0
  329. package/dist/schema/outbox.d.mts +240 -0
  330. package/dist/schema/outbox.mjs +53 -0
  331. package/dist/schema/outbox.mjs.map +1 -0
  332. package/dist/schema/question-route.mjs +16 -0
  333. package/dist/schema/question-route.mjs.map +1 -0
  334. package/dist/schema/receipt.d.mts +81 -0
  335. package/dist/schema/receipt.mjs +94 -0
  336. package/dist/schema/receipt.mjs.map +1 -0
  337. package/dist/schema/repository.d.mts +30 -0
  338. package/dist/schema/repository.mjs +29 -0
  339. package/dist/schema/repository.mjs.map +1 -0
  340. package/dist/schema/session.d.mts +136 -0
  341. package/dist/schema/session.mjs +54 -0
  342. package/dist/schema/session.mjs.map +1 -0
  343. package/dist/schema/signal.d.mts +105 -0
  344. package/dist/schema/signal.mjs +81 -0
  345. package/dist/schema/signal.mjs.map +1 -0
  346. package/dist/schema/slack-pr-notifications.d.mts +12 -0
  347. package/dist/schema/slack-pr-notifications.mjs +11 -0
  348. package/dist/schema/slack-pr-notifications.mjs.map +1 -0
  349. package/dist/schema/stored-session.mjs +10 -0
  350. package/dist/schema/stored-session.mjs.map +1 -0
  351. package/dist/schema/stored-task.mjs +20 -0
  352. package/dist/schema/stored-task.mjs.map +1 -0
  353. package/dist/schema/task-effect.d.mts +39 -0
  354. package/dist/schema/task-effect.mjs +29 -0
  355. package/dist/schema/task-effect.mjs.map +1 -0
  356. package/dist/schema/task-graph.d.mts +3173 -0
  357. package/dist/schema/task-graph.mjs +97 -0
  358. package/dist/schema/task-graph.mjs.map +1 -0
  359. package/dist/schema/task-message.d.mts +254 -0
  360. package/dist/schema/task-message.mjs +189 -0
  361. package/dist/schema/task-message.mjs.map +1 -0
  362. package/dist/schema/task.d.mts +273 -0
  363. package/dist/schema/task.mjs +200 -0
  364. package/dist/schema/task.mjs.map +1 -0
  365. package/dist/schema/transcript.d.mts +176 -0
  366. package/dist/schema/transcript.mjs +87 -0
  367. package/dist/schema/transcript.mjs.map +1 -0
  368. package/dist/schema/transitions.d.mts +50 -0
  369. package/dist/schema/transitions.mjs +303 -0
  370. package/dist/schema/transitions.mjs.map +1 -0
  371. package/dist/schema/work.d.mts +150 -0
  372. package/dist/schema/work.mjs +102 -0
  373. package/dist/schema/work.mjs.map +1 -0
  374. package/dist/session-previews.d.mts +76 -0
  375. package/dist/session-previews.mjs +55 -0
  376. package/dist/session-previews.mjs.map +1 -0
  377. package/dist/session-review.d.mts +120 -0
  378. package/dist/session-review.mjs +79 -0
  379. package/dist/session-review.mjs.map +1 -0
  380. package/dist/signal-triage.d.mts +20 -0
  381. package/dist/signal-triage.mjs +85 -0
  382. package/dist/signal-triage.mjs.map +1 -0
  383. package/dist/signals.d.mts +20 -0
  384. package/dist/signals.mjs +19 -0
  385. package/dist/signals.mjs.map +1 -0
  386. package/dist/stall.d.mts +41 -0
  387. package/dist/stall.mjs +83 -0
  388. package/dist/stall.mjs.map +1 -0
  389. package/dist/storage.d.mts +4 -0
  390. package/dist/storage.mjs +4 -0
  391. package/dist/store/driver.d.mts +65 -0
  392. package/dist/store/driver.mjs +42 -0
  393. package/dist/store/driver.mjs.map +1 -0
  394. package/dist/store/engine.d.mts +683 -0
  395. package/dist/store/engine.mjs +2309 -0
  396. package/dist/store/engine.mjs.map +1 -0
  397. package/dist/store/memory.d.mts +24 -0
  398. package/dist/store/memory.mjs +69 -0
  399. package/dist/store/memory.mjs.map +1 -0
  400. package/dist/store/slack-pr-notifications.d.mts +44 -0
  401. package/dist/store/slack-pr-notifications.mjs +121 -0
  402. package/dist/store/slack-pr-notifications.mjs.map +1 -0
  403. package/dist/store/task-effects.d.mts +38 -0
  404. package/dist/store/task-effects.mjs +118 -0
  405. package/dist/store/task-effects.mjs.map +1 -0
  406. package/dist/store/task-graphs.d.mts +60 -0
  407. package/dist/store/task-graphs.mjs +212 -0
  408. package/dist/store/task-graphs.mjs.map +1 -0
  409. package/dist/store/task-messages.d.mts +136 -0
  410. package/dist/store/task-messages.mjs +475 -0
  411. package/dist/store/task-messages.mjs.map +1 -0
  412. package/dist/store/task-work.d.mts +180 -0
  413. package/dist/store/task-work.mjs +137 -0
  414. package/dist/store/task-work.mjs.map +1 -0
  415. package/dist/store/work-notifications.d.mts +19 -0
  416. package/dist/store/work-notifications.mjs +48 -0
  417. package/dist/store/work-notifications.mjs.map +1 -0
  418. package/dist/sweep.d.mts +79 -0
  419. package/dist/sweep.mjs +171 -0
  420. package/dist/sweep.mjs.map +1 -0
  421. package/dist/task-communication.d.mts +35 -0
  422. package/dist/task-communication.mjs +47 -0
  423. package/dist/task-communication.mjs.map +1 -0
  424. package/dist/task-graph-view.d.mts +267 -0
  425. package/dist/task-graph-view.mjs +17 -0
  426. package/dist/task-graph-view.mjs.map +1 -0
  427. package/dist/task-message-processing.d.mts +60 -0
  428. package/dist/task-message-processing.mjs +200 -0
  429. package/dist/task-message-processing.mjs.map +1 -0
  430. package/dist/task-protocols.d.mts +80 -0
  431. package/dist/task-protocols.mjs +47 -0
  432. package/dist/task-protocols.mjs.map +1 -0
  433. package/dist/tasks.d.mts +17 -0
  434. package/dist/tasks.mjs +17 -0
  435. package/dist/vercel-git.d.mts +53 -0
  436. package/dist/vercel-git.mjs +344 -0
  437. package/dist/vercel-git.mjs.map +1 -0
  438. package/dist/vercel-github-api.d.mts +103 -0
  439. package/dist/vercel-github-api.mjs +363 -0
  440. package/dist/vercel-github-api.mjs.map +1 -0
  441. package/dist/vercel.d.mts +34 -2
  442. package/dist/vercel.mjs +49 -3
  443. package/dist/vercel.mjs.map +1 -1
  444. package/dist/work-triage/eve-tool.d.mts +29 -0
  445. package/dist/work-triage/eve-tool.mjs +32 -0
  446. package/dist/work-triage/eve-tool.mjs.map +1 -0
  447. package/dist/work-triage/find-existing-work.d.mts +32 -0
  448. package/dist/work-triage/find-existing-work.mjs +31 -0
  449. package/dist/work-triage/find-existing-work.mjs.map +1 -0
  450. package/dist/work-triage/github.d.mts +15 -0
  451. package/dist/work-triage/github.mjs +14 -0
  452. package/dist/work-triage/github.mjs.map +1 -0
  453. package/dist/work-triage.d.mts +4 -0
  454. package/dist/work-triage.mjs +3 -0
  455. package/dist/workflows.d.mts +146 -0
  456. package/dist/workflows.mjs +139 -0
  457. package/dist/workflows.mjs.map +1 -0
  458. package/dist/workspace-diff-assembly.d.mts +33 -0
  459. package/dist/workspace-diff-assembly.mjs +95 -0
  460. package/dist/workspace-diff-assembly.mjs.map +1 -0
  461. package/dist/workspace-diff.d.mts +90 -0
  462. package/dist/workspace-diff.mjs +61 -0
  463. package/dist/workspace-diff.mjs.map +1 -0
  464. package/dist/workspace-files-git.d.mts +15 -0
  465. package/dist/workspace-files-git.mjs +61 -0
  466. package/dist/workspace-files-git.mjs.map +1 -0
  467. package/dist/workspace-files.d.mts +107 -0
  468. package/dist/workspace-files.mjs +74 -0
  469. package/dist/workspace-files.mjs.map +1 -0
  470. package/dist/workspace-snapshot.d.mts +26 -0
  471. package/dist/workspace-snapshot.mjs +80 -0
  472. package/dist/workspace-snapshot.mjs.map +1 -0
  473. package/docs/getting-started.md +104 -0
  474. package/docs/index.md +100 -0
  475. package/docs/recipes/cancellation.md +215 -0
  476. package/docs/recipes/custom-workflow.md +153 -0
  477. package/docs/recipes/dependent-tasks.md +207 -0
  478. package/docs/recipes/eve-agent.md +277 -0
  479. package/docs/recipes/human-input.md +204 -0
  480. package/docs/recipes/persistence-recovery.md +268 -0
  481. package/docs/recipes/retry-recovery.md +241 -0
  482. package/docs/recipes/task-messaging.md +215 -0
  483. package/docs/recipes/typed-eve-result.md +161 -0
  484. package/docs/runtime-integration.md +137 -0
  485. package/package.json +142 -46
  486. package/dist/approval-JX2Px9IC.mjs +0 -132
  487. package/dist/approval-JX2Px9IC.mjs.map +0 -1
  488. package/dist/budget-DzSiIA4t.mjs +0 -42
  489. package/dist/budget-DzSiIA4t.mjs.map +0 -1
  490. package/dist/change-D2U6v7Ek.mjs +0 -554
  491. package/dist/change-D2U6v7Ek.mjs.map +0 -1
  492. package/dist/communication-Kd9nU5RP.mjs.map +0 -1
  493. package/dist/coordination-Cq08hb1l.mjs +0 -76
  494. package/dist/coordination-Cq08hb1l.mjs.map +0 -1
  495. package/dist/dispatch-BaZS3PT8.d.mts +0 -76
  496. package/dist/driver-BC0Mt5KG.d.mts +0 -34
  497. package/dist/driver-Bbd25rNM.mjs +0 -23
  498. package/dist/driver-Bbd25rNM.mjs.map +0 -1
  499. package/dist/engine-DFHU2Pe-.d.mts +0 -781
  500. package/dist/engine-WaUM2cGA.mjs +0 -1068
  501. package/dist/engine-WaUM2cGA.mjs.map +0 -1
  502. package/dist/factory-config-BoRXOw43.mjs +0 -50
  503. package/dist/factory-config-BoRXOw43.mjs.map +0 -1
  504. package/dist/factory-config-D2yU3G0c.d.mts +0 -58
  505. package/dist/github-C5HNBN6p.d.mts +0 -279
  506. package/dist/id-BLIkCVue.mjs.map +0 -1
  507. package/dist/index-Bw6hggoH.d.mts +0 -40
  508. package/dist/index.mjs.map +0 -1
  509. package/dist/task-CcOyOJ3k.mjs +0 -154
  510. package/dist/task-CcOyOJ3k.mjs.map +0 -1
@@ -0,0 +1,32 @@
1
+ import { repositoryIdSchema } from "../schema/id.mjs";
2
+ import { repositoryIdsForSession } from "../eve/task-session.mjs";
3
+ import { findExistingWork } from "./find-existing-work.mjs";
4
+ import { z } from "zod";
5
+ import { defineTool } from "eve/tools";
6
+ //#region src/work-triage/eve-tool.ts
7
+ /**
8
+ * Read-only triage helper: before delegating new work or accepting a signal,
9
+ * check whether an open pull request, a recorded Change, or an in-flight
10
+ * Task already covers the same repository, so Foreman does not duplicate
11
+ * work that is already underway.
12
+ */
13
+ function createFindExistingWorkTool(input) {
14
+ const { stores, ...options } = input;
15
+ return defineTool({
16
+ description: "Check whether an open pull request, a recorded change, or an in-flight task already covers a repository's pending work. Call this before delegating new work or deciding a signal as accepted, so Factory does not duplicate work already underway. Read-only.",
17
+ inputSchema: z.object({ repositoryId: repositoryIdSchema.describe("Repository the pending signal or request is about.") }),
18
+ async execute({ repositoryId }, ctx) {
19
+ const binding = repositoryIdsForSession(ctx.session.auth.initiator);
20
+ if (binding !== null && !binding.includes(repositoryId)) throw new Error(`Repository ${repositoryId} is outside the connector-authenticated context.`);
21
+ return findExistingWork({
22
+ stores,
23
+ repositoryId,
24
+ ...options
25
+ });
26
+ }
27
+ });
28
+ }
29
+ //#endregion
30
+ export { createFindExistingWorkTool };
31
+
32
+ //# sourceMappingURL=eve-tool.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eve-tool.mjs","names":[],"sources":["../../src/work-triage/eve-tool.ts"],"sourcesContent":["import { defineTool, type ToolContext, type ToolDefinition } from \"eve/tools\";\nimport { z } from \"zod\";\nimport { repositoryIdSchema, type RepositoryId } from \"../schema/id\";\nimport type { FactoryStores } from \"../store/engine\";\nimport {\n findExistingWork,\n type ExistingWorkLookupOptions,\n type ExistingWorkLookupResult,\n} from \"./find-existing-work\";\nimport { repositoryIdsForSession } from \"../eve/task-session\";\n\n/** Change, repository, and Task capabilities required by the existing-work tool. */\nexport type FindExistingWorkToolStores = Pick<FactoryStores, \"changes\" | \"repositories\" | \"tasks\">;\n\n/** Stores and provider lookup used to construct the existing-work tool. */\nexport interface FindExistingWorkToolOptions extends ExistingWorkLookupOptions {\n stores: FindExistingWorkToolStores;\n}\n\n/** Repository selected for a read-only existing-work lookup. */\nexport interface FindExistingWorkToolInput {\n repositoryId: RepositoryId;\n}\n\n/** Eve tool that checks a repository for overlapping open work. */\nexport interface FindExistingWorkTool extends ToolDefinition<\n FindExistingWorkToolInput,\n ExistingWorkLookupResult\n> {\n execute(input: FindExistingWorkToolInput, ctx: ToolContext): Promise<ExistingWorkLookupResult>;\n}\n\n/**\n * Read-only triage helper: before delegating new work or accepting a signal,\n * check whether an open pull request, a recorded Change, or an in-flight\n * Task already covers the same repository, so Foreman does not duplicate\n * work that is already underway.\n */\nexport function createFindExistingWorkTool(\n input: FindExistingWorkToolOptions,\n): FindExistingWorkTool {\n const { stores, ...options } = input;\n return defineTool({\n description:\n \"Check whether an open pull request, a recorded change, or an in-flight task already \" +\n \"covers a repository's pending work. Call this before delegating new work or deciding a \" +\n \"signal as accepted, so Factory does not duplicate work already underway. Read-only.\",\n inputSchema: z.object({\n repositoryId: repositoryIdSchema.describe(\n \"Repository the pending signal or request is about.\",\n ),\n }),\n async execute({ repositoryId }, ctx): Promise<ExistingWorkLookupResult> {\n // The connector binding is an authorization envelope: a steered\n // conversation must not read another repository's in-flight work.\n const binding = repositoryIdsForSession(ctx.session.auth.initiator);\n if (binding !== null && !binding.includes(repositoryId)) {\n throw new Error(\n `Repository ${repositoryId} is outside the connector-authenticated context.`,\n );\n }\n return findExistingWork({ stores, repositoryId, ...options });\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,SAAgB,2BACd,OACsB;CACtB,MAAM,EAAE,QAAQ,GAAG,YAAY;CAC/B,OAAO,WAAW;EAChB,aACE;EAGF,aAAa,EAAE,OAAO,EACpB,cAAc,mBAAmB,SAC/B,oDACF,EACF,CAAC;EACD,MAAM,QAAQ,EAAE,gBAAgB,KAAwC;GAGtE,MAAM,UAAU,wBAAwB,IAAI,QAAQ,KAAK,SAAS;GAClE,IAAI,YAAY,QAAQ,CAAC,QAAQ,SAAS,YAAY,GACpD,MAAM,IAAI,MACR,cAAc,aAAa,iDAC7B;GAEF,OAAO,iBAAiB;IAAE;IAAQ;IAAc,GAAG;GAAQ,CAAC;EAC9D;CACF,CAAC;AACH"}
@@ -0,0 +1,32 @@
1
+ import { RepositoryId } from "../schema/id.mjs";
2
+ import { RepositorySlug } from "../schema/repository.mjs";
3
+ import { Task } from "../schema/task.mjs";
4
+ import { Change } from "../schema/change.mjs";
5
+ import { FactoryStores } from "../store/engine.mjs";
6
+ import { OpenPullRequest } from "../pull-requests/contracts.mjs";
7
+ //#region src/work-triage/find-existing-work.d.ts
8
+ /** Provider-neutral readers used to discover work already in progress. */
9
+ interface ExistingWorkLookupOptions {
10
+ listOpenPullRequests: (repository: RepositorySlug) => Promise<readonly OpenPullRequest[]>;
11
+ }
12
+ /** Stores, repository identity, and provider lookup used for one existing-work query. */
13
+ interface FindExistingWorkInput extends ExistingWorkLookupOptions {
14
+ stores: Pick<FactoryStores, "changes" | "repositories" | "tasks">;
15
+ repositoryId: RepositoryId;
16
+ }
17
+ /** The refusal or existing pull requests, Changes, and active Tasks found during triage. */
18
+ type ExistingWorkLookupResult = {
19
+ found: false;
20
+ reasonCode: "repository_not_found";
21
+ reason: string;
22
+ } | {
23
+ found: true;
24
+ openPullRequests: readonly OpenPullRequest[];
25
+ openChanges: readonly Change[];
26
+ activeTasks: readonly Task[];
27
+ };
28
+ /** Find open pull requests, Changes, and active Tasks for one repository. */
29
+ declare function findExistingWork(input: FindExistingWorkInput): Promise<ExistingWorkLookupResult>;
30
+ //#endregion
31
+ export { ExistingWorkLookupOptions, ExistingWorkLookupResult, FindExistingWorkInput, findExistingWork };
32
+ //# sourceMappingURL=find-existing-work.d.mts.map
@@ -0,0 +1,31 @@
1
+ //#region src/work-triage/find-existing-work.ts
2
+ const openChangeStates = /* @__PURE__ */ new Set(["verifying", "ready"]);
3
+ const activeTaskStates = /* @__PURE__ */ new Set([
4
+ "queued",
5
+ "running",
6
+ "needs_human"
7
+ ]);
8
+ /** Find open pull requests, Changes, and active Tasks for one repository. */
9
+ async function findExistingWork(input) {
10
+ const repository = await input.stores.repositories.get(input.repositoryId);
11
+ if (repository === null) return {
12
+ found: false,
13
+ reasonCode: "repository_not_found",
14
+ reason: `repository ${input.repositoryId} does not exist`
15
+ };
16
+ const [openPullRequests, changes, tasks] = await Promise.all([
17
+ input.listOpenPullRequests(repository.slug),
18
+ input.stores.changes.list(),
19
+ input.stores.tasks.list()
20
+ ]);
21
+ return {
22
+ found: true,
23
+ openPullRequests,
24
+ openChanges: changes.filter((change) => change.repositoryId === input.repositoryId && openChangeStates.has(change.state)),
25
+ activeTasks: tasks.filter((task) => task.repositoryIds.includes(input.repositoryId) && activeTaskStates.has(task.state))
26
+ };
27
+ }
28
+ //#endregion
29
+ export { findExistingWork };
30
+
31
+ //# sourceMappingURL=find-existing-work.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-existing-work.mjs","names":[],"sources":["../../src/work-triage/find-existing-work.ts"],"sourcesContent":["import type { Change } from \"../schema/change\";\nimport type { Task } from \"../schema/task\";\nimport type { FactoryStores } from \"../store/engine\";\nimport type { OpenPullRequest } from \"../pull-requests/contracts\";\nimport type { RepositoryId } from \"../schema/id\";\nimport type { RepositorySlug } from \"../schema/repository\";\n\n/** Provider-neutral readers used to discover work already in progress. */\nexport interface ExistingWorkLookupOptions {\n listOpenPullRequests: (repository: RepositorySlug) => Promise<readonly OpenPullRequest[]>;\n}\n\n/** Stores, repository identity, and provider lookup used for one existing-work query. */\nexport interface FindExistingWorkInput extends ExistingWorkLookupOptions {\n stores: Pick<FactoryStores, \"changes\" | \"repositories\" | \"tasks\">;\n repositoryId: RepositoryId;\n}\n\n/** The refusal or existing pull requests, Changes, and active Tasks found during triage. */\nexport type ExistingWorkLookupResult =\n | { found: false; reasonCode: \"repository_not_found\"; reason: string }\n | {\n found: true;\n openPullRequests: readonly OpenPullRequest[];\n openChanges: readonly Change[];\n activeTasks: readonly Task[];\n };\n\nconst openChangeStates: ReadonlySet<Change[\"state\"]> = new Set([\"verifying\", \"ready\"]);\nconst activeTaskStates: ReadonlySet<Task[\"state\"]> = new Set([\"queued\", \"running\", \"needs_human\"]);\n\n/** Find open pull requests, Changes, and active Tasks for one repository. */\nexport async function findExistingWork(\n input: FindExistingWorkInput,\n): Promise<ExistingWorkLookupResult> {\n const repository = await input.stores.repositories.get(input.repositoryId);\n if (repository === null) {\n return {\n found: false,\n reasonCode: \"repository_not_found\",\n reason: `repository ${input.repositoryId} does not exist`,\n };\n }\n const [openPullRequests, changes, tasks] = await Promise.all([\n input.listOpenPullRequests(repository.slug),\n input.stores.changes.list(),\n input.stores.tasks.list(),\n ]);\n return {\n found: true,\n openPullRequests,\n openChanges: changes.filter(\n (change) => change.repositoryId === input.repositoryId && openChangeStates.has(change.state),\n ),\n activeTasks: tasks.filter(\n (task) => task.repositoryIds.includes(input.repositoryId) && activeTaskStates.has(task.state),\n ),\n };\n}\n"],"mappings":";AA4BA,MAAM,mCAAiD,IAAI,IAAI,CAAC,aAAa,OAAO,CAAC;AACrF,MAAM,mCAA+C,IAAI,IAAI;CAAC;CAAU;CAAW;AAAa,CAAC;;AAGjG,eAAsB,iBACpB,OACmC;CACnC,MAAM,aAAa,MAAM,MAAM,OAAO,aAAa,IAAI,MAAM,YAAY;CACzE,IAAI,eAAe,MACjB,OAAO;EACL,OAAO;EACP,YAAY;EACZ,QAAQ,cAAc,MAAM,aAAa;CAC3C;CAEF,MAAM,CAAC,kBAAkB,SAAS,SAAS,MAAM,QAAQ,IAAI;EAC3D,MAAM,qBAAqB,WAAW,IAAI;EAC1C,MAAM,OAAO,QAAQ,KAAK;EAC1B,MAAM,OAAO,MAAM,KAAK;CAC1B,CAAC;CACD,OAAO;EACL,OAAO;EACP;EACA,aAAa,QAAQ,QAClB,WAAW,OAAO,iBAAiB,MAAM,gBAAgB,iBAAiB,IAAI,OAAO,KAAK,CAC7F;EACA,aAAa,MAAM,QAChB,SAAS,KAAK,cAAc,SAAS,MAAM,YAAY,KAAK,iBAAiB,IAAI,KAAK,KAAK,CAC9F;CACF;AACF"}
@@ -0,0 +1,15 @@
1
+ import { RepositorySlug } from "../schema/repository.mjs";
2
+ import { OpenPullRequest } from "../pull-requests/contracts.mjs";
3
+ //#region src/work-triage/github.d.ts
4
+ /** Lists open GitHub pull requests for one repository during work triage. */
5
+ type GitHubOpenPullRequestLister = (repository: RepositorySlug) => Promise<readonly OpenPullRequest[]>;
6
+ /** GitHub credentials and transport used to list open pull requests during work triage. */
7
+ interface GitHubOpenPullRequestListerOptions {
8
+ tokenForRepository: (repository: RepositorySlug) => Promise<string>;
9
+ fetch?: typeof globalThis.fetch;
10
+ }
11
+ /** Create the GitHub open-pull-request reader consumed by provider-neutral work triage. */
12
+ declare function createGitHubOpenPullRequestLister(options: GitHubOpenPullRequestListerOptions): GitHubOpenPullRequestLister;
13
+ //#endregion
14
+ export { GitHubOpenPullRequestLister, GitHubOpenPullRequestListerOptions, createGitHubOpenPullRequestLister };
15
+ //# sourceMappingURL=github.d.mts.map
@@ -0,0 +1,14 @@
1
+ import { listOpenPullRequests } from "../github.mjs";
2
+ //#region src/work-triage/github.ts
3
+ /** Create the GitHub open-pull-request reader consumed by provider-neutral work triage. */
4
+ function createGitHubOpenPullRequestLister(options) {
5
+ return async (repository) => listOpenPullRequests({
6
+ repository,
7
+ token: await options.tokenForRepository(repository),
8
+ fetch: options.fetch
9
+ });
10
+ }
11
+ //#endregion
12
+ export { createGitHubOpenPullRequestLister };
13
+
14
+ //# sourceMappingURL=github.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.mjs","names":[],"sources":["../../src/work-triage/github.ts"],"sourcesContent":["import { listOpenPullRequests } from \"../github\";\nimport type { OpenPullRequest } from \"../pull-requests/contracts\";\nimport type { RepositorySlug } from \"../schema/repository\";\n\n/** Lists open GitHub pull requests for one repository during work triage. */\nexport type GitHubOpenPullRequestLister = (\n repository: RepositorySlug,\n) => Promise<readonly OpenPullRequest[]>;\n\n/** GitHub credentials and transport used to list open pull requests during work triage. */\nexport interface GitHubOpenPullRequestListerOptions {\n tokenForRepository: (repository: RepositorySlug) => Promise<string>;\n fetch?: typeof globalThis.fetch;\n}\n\n/** Create the GitHub open-pull-request reader consumed by provider-neutral work triage. */\nexport function createGitHubOpenPullRequestLister(\n options: GitHubOpenPullRequestListerOptions,\n): GitHubOpenPullRequestLister {\n return async (repository) =>\n listOpenPullRequests({\n repository,\n token: await options.tokenForRepository(repository),\n fetch: options.fetch,\n });\n}\n"],"mappings":";;;AAgBA,SAAgB,kCACd,SAC6B;CAC7B,OAAO,OAAO,eACZ,qBAAqB;EACnB;EACA,OAAO,MAAM,QAAQ,mBAAmB,UAAU;EAClD,OAAO,QAAQ;CACjB,CAAC;AACL"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { ExistingWorkLookupOptions, ExistingWorkLookupResult, FindExistingWorkInput, findExistingWork } from "./work-triage/find-existing-work.mjs";
3
+ import { FindExistingWorkTool, FindExistingWorkToolInput, FindExistingWorkToolOptions, FindExistingWorkToolStores, createFindExistingWorkTool } from "./work-triage/eve-tool.mjs";
4
+ export { type ExistingWorkLookupOptions, type ExistingWorkLookupResult, type FindExistingWorkInput, type FindExistingWorkTool, type FindExistingWorkToolInput, type FindExistingWorkToolOptions, type FindExistingWorkToolStores, createFindExistingWorkTool, findExistingWork };
@@ -0,0 +1,3 @@
1
+ import { findExistingWork } from "./work-triage/find-existing-work.mjs";
2
+ import { createFindExistingWorkTool } from "./work-triage/eve-tool.mjs";
3
+ export { createFindExistingWorkTool, findExistingWork };
@@ -0,0 +1,146 @@
1
+ import { AgentRouteBinding, AgentRouteBindingInput, agentRouteBindingSchema, parseAgentRouteBinding } from "./schema/agent-route.mjs";
2
+ import { JsonValue, MAX_WORK_JSON_BYTES, MAX_WORK_JSON_DEPTH, TaskWork, TaskWorkOptions, TaskWorkResult, WorkflowBinding, WorkflowBindingInput, WorkflowReference, WorkflowReferenceInput, WorkflowTaskWorkOptions, jsonValueSchema, parseWorkflowBinding, taskWork, taskWorkResultSchema, taskWorkSchema, workflowBindingSchema } from "./schema/work.mjs";
3
+ import { AgentRoute, AgentRouteInput, AgentRouteKey, AgentRouteRegistry, RouteTaskWorkOptions, RoutedTaskWork, agentRouteSchema, defineAgentRoutes, routeKey, routeTaskWork } from "./agent-routes.mjs";
4
+ import { z } from "zod";
5
+ //#region src/workflows.d.ts
6
+ /** Generic `task@1` workflow accepting bounded JSON input and output. */
7
+ declare const defaultTaskWorkflow: Readonly<WorkflowDefinition<z.ZodCustom<JsonValue, JsonValue>, z.ZodCustom<JsonValue, JsonValue>, "task", 1>>;
8
+ /** Caller input accepted when defining one exact workflow contract. */
9
+ interface WorkflowDefinitionInput<Input extends z.ZodType = z.ZodType, Output extends z.ZodType = z.ZodType, Id extends string = string, Version extends number = number> {
10
+ /** Stable lowercase workflow identifier persisted on every Task. */
11
+ readonly id: Id;
12
+ /** Positive exact version; callers and recovery never select an implicit latest version. */
13
+ readonly version: Version;
14
+ /** Schema that validates caller input and supplies its static input type. */
15
+ readonly input: Input;
16
+ /** Schema that validates successful completion and supplies its static output type. */
17
+ readonly output: Output;
18
+ /**
19
+ * Canonical persisted-input schema required when `input` transforms its value. It must validate
20
+ * without changing the stored JSON shape.
21
+ */
22
+ readonly storedInput?: z.ZodType<NoInfer<z.output<Input>>>;
23
+ /**
24
+ * Canonical persisted-output schema required when `output` transforms its value. It must
25
+ * validate without changing the stored JSON shape.
26
+ */
27
+ readonly storedOutput?: z.ZodType<NoInfer<z.output<Output>>>;
28
+ }
29
+ /** Exact-version workflow contract with a typed binding for constructing work. */
30
+ interface WorkflowDefinition<Input extends z.ZodType = z.ZodType, Output extends z.ZodType = z.ZodType, Id extends string = string, Version extends number = number> extends WorkflowDefinitionInput<Input, Output, Id, Version>, WorkflowReference<Input, WorkflowBinding<z.input<Input> & JsonValue, z.input<Output> & JsonValue, Id, Version>> {}
31
+ /** JSON input accepted by a workflow definition before its schema transforms it. */
32
+ type WorkflowInput<Definition extends WorkflowDefinition> = z.input<Definition["input"]> & JsonValue;
33
+ /** JSON output accepted by a workflow definition before its schema transforms it. */
34
+ type WorkflowOutput<Definition extends WorkflowDefinition> = z.input<Definition["output"]> & JsonValue;
35
+ type RegisteredWorkflow<Definition extends WorkflowDefinitionInput> = Definition extends WorkflowDefinitionInput<infer Input, infer Output, infer Id, infer Version> ? WorkflowDefinition<Input, Output, Id, Version> : never;
36
+ type WorkflowForBinding<Definition extends WorkflowDefinition, Binding extends WorkflowBinding> = Definition extends WorkflowDefinition ? Binding extends {
37
+ readonly id: Definition["id"];
38
+ readonly version: Definition["version"];
39
+ } ? Definition : Definition extends {
40
+ readonly id: Binding["id"];
41
+ readonly version: Binding["version"];
42
+ } ? Definition : never : never;
43
+ /** Immutable registry that validates data against exact workflow versions. */
44
+ interface WorkflowRegistry<Definition extends WorkflowDefinition = WorkflowDefinition> {
45
+ /** Immutable exact-version definitions in registration order. */
46
+ readonly definitions: readonly Readonly<Definition>[];
47
+ /**
48
+ * Resolves one exact binding, throwing with the registered alternatives when it is unknown.
49
+ *
50
+ * @param binding - Exact workflow ID and version.
51
+ * @returns The matching immutable workflow definition.
52
+ */
53
+ resolve<const Binding extends WorkflowBinding>(binding: Binding): Readonly<WorkflowForBinding<Definition, Binding>>;
54
+ /**
55
+ * Validates caller input through the selected workflow and returns bounded canonical JSON.
56
+ *
57
+ * @param binding - Exact workflow ID and version.
58
+ * @param value - Untrusted caller input to validate and transform.
59
+ * @returns Validated bounded JSON produced by the input schema.
60
+ */
61
+ validateInput(binding: WorkflowBinding, value: unknown): JsonValue;
62
+ /**
63
+ * Validates candidate completion output through the selected workflow.
64
+ *
65
+ * @param binding - Exact workflow ID and version.
66
+ * @param value - Untrusted candidate output to validate and transform.
67
+ * @returns Validated bounded JSON produced by the output schema.
68
+ */
69
+ validateOutput(binding: WorkflowBinding, value: unknown): JsonValue;
70
+ /**
71
+ * Validates persisted input without permitting a schema transform to change its JSON shape.
72
+ *
73
+ * @param binding - Exact workflow ID and version stored on the Task.
74
+ * @param value - Canonical persisted JSON to validate.
75
+ * @returns A cloned validated value equal to the persisted JSON.
76
+ */
77
+ validateStoredInput(binding: WorkflowBinding, value: unknown): JsonValue;
78
+ /**
79
+ * Validates persisted output without permitting a schema transform to change its JSON shape.
80
+ *
81
+ * @param binding - Exact workflow ID and version stored on the Task.
82
+ * @param value - Canonical persisted JSON to validate.
83
+ * @returns A cloned validated value equal to the persisted JSON.
84
+ */
85
+ validateStoredOutput(binding: WorkflowBinding, value: unknown): JsonValue;
86
+ }
87
+ /**
88
+ * Validates and freezes one exact workflow definition without executing it.
89
+ *
90
+ * @remarks
91
+ * A definition is a typed contract, not a registered runtime. Pass every definition that stored
92
+ * Tasks may reference to `defineWorkflows`, then supply that registry to `createStores`. Input and
93
+ * output schemas may transform caller values only when `storedInput` or `storedOutput` describes
94
+ * the unchanged canonical JSON representation used after persistence.
95
+ *
96
+ * @param definition - Stable ID, positive version, and Zod input/output contracts.
97
+ * @returns An immutable definition whose binding carries the input and output types.
98
+ * @throws When the binding is invalid or the input/output fields are not Zod schemas.
99
+ * @see The shipped `docs/recipes/custom-workflow.md` recipe for registration and completion.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * import { defineWorkflow, defineWorkflows } from "@vercel/factory/workflows";
104
+ * import { z } from "zod";
105
+ *
106
+ * const greeting = defineWorkflow({
107
+ * id: "greeting",
108
+ * version: 1,
109
+ * input: z.object({ name: z.string() }),
110
+ * output: z.object({ message: z.string() }),
111
+ * });
112
+ * const workflows = defineWorkflows([greeting]);
113
+ * ```
114
+ */
115
+ declare function defineWorkflow<Input extends z.ZodType, Output extends z.ZodType, const Id extends string, const Version extends number>(definition: WorkflowDefinitionInput<Input, Output, Id, Version>): Readonly<WorkflowDefinition<Input, Output, Id, Version>>;
116
+ /**
117
+ * Builds an immutable exact-version workflow registry and rejects duplicate definitions.
118
+ *
119
+ * @remarks
120
+ * Register old versions for as long as persisted Tasks can still reference them. Resolution uses
121
+ * both ID and version and never falls forward to another version. Creating a new registry has no
122
+ * persistence side effects.
123
+ *
124
+ * @param definitions - All exact workflow versions readable by this runtime.
125
+ * @returns A registry for resolving bindings and validating caller and persisted values.
126
+ * @throws When a definition is invalid or the same `id@version` appears more than once.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { defineWorkflow, defineWorkflows } from "@vercel/factory/workflows";
131
+ * import { z } from "zod";
132
+ *
133
+ * const v1 = defineWorkflow({
134
+ * id: "report",
135
+ * version: 1,
136
+ * input: z.object({ topic: z.string() }),
137
+ * output: z.object({ summary: z.string() }),
138
+ * });
139
+ * const workflows = defineWorkflows([v1]);
140
+ * workflows.resolve(v1.binding);
141
+ * ```
142
+ */
143
+ declare function defineWorkflows<const Definition extends WorkflowDefinitionInput>(definitions: readonly Definition[]): WorkflowRegistry<RegisteredWorkflow<Definition>>;
144
+ //#endregion
145
+ export { type AgentRoute, type AgentRouteBinding, type AgentRouteBindingInput, type AgentRouteInput, type AgentRouteKey, type AgentRouteRegistry, type JsonValue, MAX_WORK_JSON_BYTES, MAX_WORK_JSON_DEPTH, type RouteTaskWorkOptions, type RoutedTaskWork, type TaskWork, type TaskWorkOptions, type TaskWorkResult, type WorkflowBinding, type WorkflowBindingInput, WorkflowDefinition, WorkflowDefinitionInput, WorkflowInput, WorkflowOutput, type WorkflowReference, type WorkflowReferenceInput, WorkflowRegistry, type WorkflowTaskWorkOptions, agentRouteBindingSchema, agentRouteSchema, defaultTaskWorkflow, defineAgentRoutes, defineWorkflow, defineWorkflows, jsonValueSchema, parseAgentRouteBinding, parseWorkflowBinding, routeKey, routeTaskWork, taskWork, taskWorkResultSchema, taskWorkSchema, workflowBindingSchema };
146
+ //# sourceMappingURL=workflows.d.mts.map
@@ -0,0 +1,139 @@
1
+ import { agentRouteBindingSchema, parseAgentRouteBinding } from "./schema/agent-route.mjs";
2
+ import { MAX_WORK_JSON_BYTES, MAX_WORK_JSON_DEPTH, jsonValueSchema, parseWorkflowBinding, taskWork, taskWorkResultSchema, taskWorkSchema, workflowBindingSchema } from "./schema/work.mjs";
3
+ import { agentRouteSchema, defineAgentRoutes, routeKey, routeTaskWork } from "./agent-routes.mjs";
4
+ import { z } from "zod";
5
+ import { isDeepStrictEqual } from "node:util";
6
+ //#region src/workflows.ts
7
+ /** Generic `task@1` workflow accepting bounded JSON input and output. */
8
+ const defaultTaskWorkflow = defineWorkflow({
9
+ id: "task",
10
+ version: 1,
11
+ input: jsonValueSchema,
12
+ output: jsonValueSchema
13
+ });
14
+ /**
15
+ * Validates and freezes one exact workflow definition without executing it.
16
+ *
17
+ * @remarks
18
+ * A definition is a typed contract, not a registered runtime. Pass every definition that stored
19
+ * Tasks may reference to `defineWorkflows`, then supply that registry to `createStores`. Input and
20
+ * output schemas may transform caller values only when `storedInput` or `storedOutput` describes
21
+ * the unchanged canonical JSON representation used after persistence.
22
+ *
23
+ * @param definition - Stable ID, positive version, and Zod input/output contracts.
24
+ * @returns An immutable definition whose binding carries the input and output types.
25
+ * @throws When the binding is invalid or the input/output fields are not Zod schemas.
26
+ * @see The shipped `docs/recipes/custom-workflow.md` recipe for registration and completion.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { defineWorkflow, defineWorkflows } from "@vercel/factory/workflows";
31
+ * import { z } from "zod";
32
+ *
33
+ * const greeting = defineWorkflow({
34
+ * id: "greeting",
35
+ * version: 1,
36
+ * input: z.object({ name: z.string() }),
37
+ * output: z.object({ message: z.string() }),
38
+ * });
39
+ * const workflows = defineWorkflows([greeting]);
40
+ * ```
41
+ */
42
+ function defineWorkflow(definition) {
43
+ const parsedBinding = parseWorkflowBinding({
44
+ id: definition.id,
45
+ version: definition.version
46
+ });
47
+ if (!(definition.input instanceof z.ZodType) || !(definition.output instanceof z.ZodType)) throw new Error(`Workflow ${definition.id}@${definition.version} requires Zod input and output schemas`);
48
+ for (const field of ["storedInput", "storedOutput"]) if (definition[field] !== void 0 && !(definition[field] instanceof z.ZodType)) throw new Error(`Workflow ${definition.id}@${definition.version} requires a Zod ${field} schema`);
49
+ const binding = Object.freeze(parsedBinding);
50
+ return Object.freeze({
51
+ id: definition.id,
52
+ version: definition.version,
53
+ binding,
54
+ input: definition.input,
55
+ output: definition.output,
56
+ storedInput: definition.storedInput,
57
+ storedOutput: definition.storedOutput
58
+ });
59
+ }
60
+ /**
61
+ * Builds an immutable exact-version workflow registry and rejects duplicate definitions.
62
+ *
63
+ * @remarks
64
+ * Register old versions for as long as persisted Tasks can still reference them. Resolution uses
65
+ * both ID and version and never falls forward to another version. Creating a new registry has no
66
+ * persistence side effects.
67
+ *
68
+ * @param definitions - All exact workflow versions readable by this runtime.
69
+ * @returns A registry for resolving bindings and validating caller and persisted values.
70
+ * @throws When a definition is invalid or the same `id@version` appears more than once.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { defineWorkflow, defineWorkflows } from "@vercel/factory/workflows";
75
+ * import { z } from "zod";
76
+ *
77
+ * const v1 = defineWorkflow({
78
+ * id: "report",
79
+ * version: 1,
80
+ * input: z.object({ topic: z.string() }),
81
+ * output: z.object({ summary: z.string() }),
82
+ * });
83
+ * const workflows = defineWorkflows([v1]);
84
+ * workflows.resolve(v1.binding);
85
+ * ```
86
+ */
87
+ function defineWorkflows(definitions) {
88
+ const registered = definitions.map((definition) => defineWorkflow(definition));
89
+ const byBinding = /* @__PURE__ */ new Map();
90
+ for (const definition of registered) {
91
+ const key = `${definition.id}@${definition.version}`;
92
+ if (byBinding.has(key)) throw new Error(`Duplicate workflow definition ${key}; register each id and version exactly once`);
93
+ byBinding.set(key, definition);
94
+ }
95
+ function resolve(binding) {
96
+ const { id, version } = workflowBindingSchema.parse(binding);
97
+ const key = `${id}@${version}`;
98
+ const definition = byBinding.get(key);
99
+ if (!definition) {
100
+ const alternatives = [...byBinding.keys()].sort().join(", ") || "none";
101
+ throw new Error(`Unknown workflow ${key}. Registered workflows: ${alternatives}`);
102
+ }
103
+ return definition;
104
+ }
105
+ const validateStored = (binding, value, field) => {
106
+ const definition = resolve(binding);
107
+ const storedField = field === "input" ? "storedInput" : "storedOutput";
108
+ const storedSchema = definition[storedField];
109
+ const json = structuredClone(jsonValueSchema.parse(value));
110
+ let parsed;
111
+ try {
112
+ parsed = (storedSchema ?? definition[field]).parse(structuredClone(json));
113
+ } catch (cause) {
114
+ if (storedSchema !== void 0) throw cause;
115
+ throw new Error(`Workflow ${definition.id}@${definition.version} cannot validate stored ${field}; provide ${storedField} when the ${field} transform changes shape`, { cause });
116
+ }
117
+ const validated = jsonValueSchema.parse(parsed);
118
+ if (!isDeepStrictEqual(json, validated)) throw new Error(`Workflow ${definition.id}@${definition.version} stored ${field} validation must preserve canonical JSON; provide a non-transforming ${storedField} schema`);
119
+ return structuredClone(validated);
120
+ };
121
+ const validate = (binding, value, field) => {
122
+ const definition = resolve(binding);
123
+ const json = jsonValueSchema.parse(value);
124
+ const parsed = jsonValueSchema.parse(definition[field].parse(structuredClone(json)));
125
+ return validateStored(binding, parsed, field);
126
+ };
127
+ return Object.freeze({
128
+ definitions: Object.freeze(registered),
129
+ resolve,
130
+ validateInput: (binding, value) => validate(binding, value, "input"),
131
+ validateOutput: (binding, value) => validate(binding, value, "output"),
132
+ validateStoredInput: (binding, value) => validateStored(binding, value, "input"),
133
+ validateStoredOutput: (binding, value) => validateStored(binding, value, "output")
134
+ });
135
+ }
136
+ //#endregion
137
+ export { MAX_WORK_JSON_BYTES, MAX_WORK_JSON_DEPTH, agentRouteBindingSchema, agentRouteSchema, defaultTaskWorkflow, defineAgentRoutes, defineWorkflow, defineWorkflows, jsonValueSchema, parseAgentRouteBinding, parseWorkflowBinding, routeKey, routeTaskWork, taskWork, taskWorkResultSchema, taskWorkSchema, workflowBindingSchema };
138
+
139
+ //# sourceMappingURL=workflows.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflows.mjs","names":[],"sources":["../src/workflows.ts"],"sourcesContent":["import { isDeepStrictEqual } from \"node:util\";\nimport { z } from \"zod\";\nimport {\n jsonValueSchema,\n parseWorkflowBinding,\n workflowBindingSchema,\n type JsonValue,\n type WorkflowBinding,\n type WorkflowReference,\n} from \"./schema/work\";\n\nexport {\n jsonValueSchema,\n MAX_WORK_JSON_BYTES,\n MAX_WORK_JSON_DEPTH,\n taskWork,\n taskWorkResultSchema,\n taskWorkSchema,\n parseWorkflowBinding,\n workflowBindingSchema,\n} from \"./schema/work\";\nexport {\n agentRouteBindingSchema,\n agentRouteSchema,\n defineAgentRoutes,\n parseAgentRouteBinding,\n routeKey,\n routeTaskWork,\n type AgentRoute,\n type AgentRouteBinding,\n type AgentRouteBindingInput,\n type AgentRouteInput,\n type AgentRouteKey,\n type AgentRouteRegistry,\n type RouteTaskWorkOptions,\n type RoutedTaskWork,\n} from \"./agent-routes\";\n\n/** Generic `task@1` workflow accepting bounded JSON input and output. */\nexport const defaultTaskWorkflow = defineWorkflow({\n id: \"task\",\n version: 1,\n input: jsonValueSchema,\n output: jsonValueSchema,\n});\nexport type {\n JsonValue,\n TaskWork,\n TaskWorkOptions,\n TaskWorkResult,\n WorkflowBinding,\n WorkflowBindingInput,\n WorkflowReference,\n WorkflowReferenceInput,\n WorkflowTaskWorkOptions,\n} from \"./schema/work\";\n\n/** Caller input accepted when defining one exact workflow contract. */\nexport interface WorkflowDefinitionInput<\n Input extends z.ZodType = z.ZodType,\n Output extends z.ZodType = z.ZodType,\n Id extends string = string,\n Version extends number = number,\n> {\n /** Stable lowercase workflow identifier persisted on every Task. */\n readonly id: Id;\n /** Positive exact version; callers and recovery never select an implicit latest version. */\n readonly version: Version;\n /** Schema that validates caller input and supplies its static input type. */\n readonly input: Input;\n /** Schema that validates successful completion and supplies its static output type. */\n readonly output: Output;\n /**\n * Canonical persisted-input schema required when `input` transforms its value. It must validate\n * without changing the stored JSON shape.\n */\n readonly storedInput?: z.ZodType<NoInfer<z.output<Input>>>;\n /**\n * Canonical persisted-output schema required when `output` transforms its value. It must\n * validate without changing the stored JSON shape.\n */\n readonly storedOutput?: z.ZodType<NoInfer<z.output<Output>>>;\n}\n\n/** Exact-version workflow contract with a typed binding for constructing work. */\nexport interface WorkflowDefinition<\n Input extends z.ZodType = z.ZodType,\n Output extends z.ZodType = z.ZodType,\n Id extends string = string,\n Version extends number = number,\n>\n extends\n WorkflowDefinitionInput<Input, Output, Id, Version>,\n WorkflowReference<\n Input,\n WorkflowBinding<z.input<Input> & JsonValue, z.input<Output> & JsonValue, Id, Version>\n > {}\n\n/** JSON input accepted by a workflow definition before its schema transforms it. */\nexport type WorkflowInput<Definition extends WorkflowDefinition> = z.input<Definition[\"input\"]> &\n JsonValue;\n\n/** JSON output accepted by a workflow definition before its schema transforms it. */\nexport type WorkflowOutput<Definition extends WorkflowDefinition> = z.input<Definition[\"output\"]> &\n JsonValue;\n\ntype RegisteredWorkflow<Definition extends WorkflowDefinitionInput> =\n Definition extends WorkflowDefinitionInput<infer Input, infer Output, infer Id, infer Version>\n ? WorkflowDefinition<Input, Output, Id, Version>\n : never;\n\ntype WorkflowForBinding<\n Definition extends WorkflowDefinition,\n Binding extends WorkflowBinding,\n> = Definition extends WorkflowDefinition\n ? Binding extends {\n readonly id: Definition[\"id\"];\n readonly version: Definition[\"version\"];\n }\n ? Definition\n : Definition extends {\n readonly id: Binding[\"id\"];\n readonly version: Binding[\"version\"];\n }\n ? Definition\n : never\n : never;\n\n/** Immutable registry that validates data against exact workflow versions. */\nexport interface WorkflowRegistry<Definition extends WorkflowDefinition = WorkflowDefinition> {\n /** Immutable exact-version definitions in registration order. */\n readonly definitions: readonly Readonly<Definition>[];\n /**\n * Resolves one exact binding, throwing with the registered alternatives when it is unknown.\n *\n * @param binding - Exact workflow ID and version.\n * @returns The matching immutable workflow definition.\n */\n resolve<const Binding extends WorkflowBinding>(\n binding: Binding,\n ): Readonly<WorkflowForBinding<Definition, Binding>>;\n /**\n * Validates caller input through the selected workflow and returns bounded canonical JSON.\n *\n * @param binding - Exact workflow ID and version.\n * @param value - Untrusted caller input to validate and transform.\n * @returns Validated bounded JSON produced by the input schema.\n */\n validateInput(binding: WorkflowBinding, value: unknown): JsonValue;\n /**\n * Validates candidate completion output through the selected workflow.\n *\n * @param binding - Exact workflow ID and version.\n * @param value - Untrusted candidate output to validate and transform.\n * @returns Validated bounded JSON produced by the output schema.\n */\n validateOutput(binding: WorkflowBinding, value: unknown): JsonValue;\n /**\n * Validates persisted input without permitting a schema transform to change its JSON shape.\n *\n * @param binding - Exact workflow ID and version stored on the Task.\n * @param value - Canonical persisted JSON to validate.\n * @returns A cloned validated value equal to the persisted JSON.\n */\n validateStoredInput(binding: WorkflowBinding, value: unknown): JsonValue;\n /**\n * Validates persisted output without permitting a schema transform to change its JSON shape.\n *\n * @param binding - Exact workflow ID and version stored on the Task.\n * @param value - Canonical persisted JSON to validate.\n * @returns A cloned validated value equal to the persisted JSON.\n */\n validateStoredOutput(binding: WorkflowBinding, value: unknown): JsonValue;\n}\n\n/**\n * Validates and freezes one exact workflow definition without executing it.\n *\n * @remarks\n * A definition is a typed contract, not a registered runtime. Pass every definition that stored\n * Tasks may reference to `defineWorkflows`, then supply that registry to `createStores`. Input and\n * output schemas may transform caller values only when `storedInput` or `storedOutput` describes\n * the unchanged canonical JSON representation used after persistence.\n *\n * @param definition - Stable ID, positive version, and Zod input/output contracts.\n * @returns An immutable definition whose binding carries the input and output types.\n * @throws When the binding is invalid or the input/output fields are not Zod schemas.\n * @see The shipped `docs/recipes/custom-workflow.md` recipe for registration and completion.\n *\n * @example\n * ```ts\n * import { defineWorkflow, defineWorkflows } from \"@vercel/factory/workflows\";\n * import { z } from \"zod\";\n *\n * const greeting = defineWorkflow({\n * id: \"greeting\",\n * version: 1,\n * input: z.object({ name: z.string() }),\n * output: z.object({ message: z.string() }),\n * });\n * const workflows = defineWorkflows([greeting]);\n * ```\n */\nexport function defineWorkflow<\n Input extends z.ZodType,\n Output extends z.ZodType,\n const Id extends string,\n const Version extends number,\n>(\n definition: WorkflowDefinitionInput<Input, Output, Id, Version>,\n): Readonly<WorkflowDefinition<Input, Output, Id, Version>> {\n const parsedBinding = parseWorkflowBinding({\n id: definition.id,\n version: definition.version,\n });\n if (!(definition.input instanceof z.ZodType) || !(definition.output instanceof z.ZodType)) {\n throw new Error(\n `Workflow ${definition.id}@${definition.version} requires Zod input and output schemas`,\n );\n }\n for (const field of [\"storedInput\", \"storedOutput\"] as const) {\n if (definition[field] !== undefined && !(definition[field] instanceof z.ZodType)) {\n throw new Error(\n `Workflow ${definition.id}@${definition.version} requires a Zod ${field} schema`,\n );\n }\n }\n const binding: WorkflowBinding<\n z.input<Input> & JsonValue,\n z.input<Output> & JsonValue,\n Id,\n Version\n > = Object.freeze(parsedBinding) as WorkflowBinding<\n z.input<Input> & JsonValue,\n z.input<Output> & JsonValue,\n Id,\n Version\n >;\n return Object.freeze({\n id: definition.id,\n version: definition.version,\n binding,\n input: definition.input,\n output: definition.output,\n storedInput: definition.storedInput,\n storedOutput: definition.storedOutput,\n });\n}\n\n/**\n * Builds an immutable exact-version workflow registry and rejects duplicate definitions.\n *\n * @remarks\n * Register old versions for as long as persisted Tasks can still reference them. Resolution uses\n * both ID and version and never falls forward to another version. Creating a new registry has no\n * persistence side effects.\n *\n * @param definitions - All exact workflow versions readable by this runtime.\n * @returns A registry for resolving bindings and validating caller and persisted values.\n * @throws When a definition is invalid or the same `id@version` appears more than once.\n *\n * @example\n * ```ts\n * import { defineWorkflow, defineWorkflows } from \"@vercel/factory/workflows\";\n * import { z } from \"zod\";\n *\n * const v1 = defineWorkflow({\n * id: \"report\",\n * version: 1,\n * input: z.object({ topic: z.string() }),\n * output: z.object({ summary: z.string() }),\n * });\n * const workflows = defineWorkflows([v1]);\n * workflows.resolve(v1.binding);\n * ```\n */\nexport function defineWorkflows<const Definition extends WorkflowDefinitionInput>(\n definitions: readonly Definition[],\n): WorkflowRegistry<RegisteredWorkflow<Definition>> {\n const registered = definitions.map((definition) =>\n defineWorkflow(definition),\n ) as unknown as readonly Readonly<RegisteredWorkflow<Definition>>[];\n const byBinding = new Map<string, Readonly<RegisteredWorkflow<Definition>>>();\n for (const definition of registered) {\n const key = `${definition.id}@${definition.version}`;\n if (byBinding.has(key)) {\n throw new Error(\n `Duplicate workflow definition ${key}; register each id and version exactly once`,\n );\n }\n byBinding.set(key, definition);\n }\n\n function resolve<const Binding extends WorkflowBinding>(\n binding: Binding,\n ): Readonly<WorkflowForBinding<RegisteredWorkflow<Definition>, Binding>>;\n function resolve(binding: WorkflowBinding): Readonly<RegisteredWorkflow<Definition>> {\n const { id, version } = workflowBindingSchema.parse(binding);\n const key = `${id}@${version}`;\n const definition = byBinding.get(key);\n if (!definition) {\n const alternatives = [...byBinding.keys()].sort().join(\", \") || \"none\";\n throw new Error(`Unknown workflow ${key}. Registered workflows: ${alternatives}`);\n }\n return definition;\n }\n const validateStored = (\n binding: WorkflowBinding,\n value: unknown,\n field: \"input\" | \"output\",\n ): JsonValue => {\n const definition = resolve(binding);\n const storedField = field === \"input\" ? \"storedInput\" : \"storedOutput\";\n const storedSchema = definition[storedField];\n const json = structuredClone(jsonValueSchema.parse(value));\n let parsed: unknown;\n try {\n parsed = (storedSchema ?? definition[field]).parse(structuredClone(json));\n } catch (cause) {\n if (storedSchema !== undefined) throw cause;\n throw new Error(\n `Workflow ${definition.id}@${definition.version} cannot validate stored ${field}; provide ${storedField} when the ${field} transform changes shape`,\n { cause },\n );\n }\n const validated = jsonValueSchema.parse(parsed);\n if (!isDeepStrictEqual(json, validated)) {\n throw new Error(\n `Workflow ${definition.id}@${definition.version} stored ${field} validation must preserve canonical JSON; provide a non-transforming ${storedField} schema`,\n );\n }\n return structuredClone(validated);\n };\n const validate = (\n binding: WorkflowBinding,\n value: unknown,\n field: \"input\" | \"output\",\n ): JsonValue => {\n const definition = resolve(binding);\n const json = jsonValueSchema.parse(value);\n const parsed = jsonValueSchema.parse(definition[field].parse(structuredClone(json)));\n return validateStored(binding, parsed, field);\n };\n\n return Object.freeze({\n definitions: Object.freeze(registered),\n resolve,\n validateInput: (binding: WorkflowBinding, value: unknown) => validate(binding, value, \"input\"),\n validateOutput: (binding: WorkflowBinding, value: unknown) =>\n validate(binding, value, \"output\"),\n validateStoredInput: (binding: WorkflowBinding, value: unknown) =>\n validateStored(binding, value, \"input\"),\n validateStoredOutput: (binding: Workfl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,SAAS,OAAO,OAAO;EAC7F,iBAAiB,SAA0B,UACzC,SAAS,SAAS,OAAO,QAAQ;EACnC,sBAAsB,SAA0B,UAC9C,eAAe,SAAS,OAAO,OAAO;EACxC,uBAAuB,SAA0B,UAC/C,eAAe,SAAS,OAAO,QAAQ;CAC3C,CAAC;AACH"}
@@ -0,0 +1,33 @@
1
+ import { WorkspaceDiff } from "./workspace-diff.mjs";
2
+ import { WorkspaceSnapshot } from "./workspace-snapshot.mjs";
3
+ //#region src/workspace-diff-assembly.d.ts
4
+ /** Metadata for one file in the pinned comparison base tree. */
5
+ interface WorkspaceBaseEntry {
6
+ readonly sha: string;
7
+ readonly size: number;
8
+ }
9
+ /** Encoded contents and metadata for one pinned base-tree blob. */
10
+ interface WorkspaceBaseBlob {
11
+ readonly content: string;
12
+ readonly encoding: string;
13
+ readonly size: number | null;
14
+ }
15
+ /** Pinned inputs and display limits used to assemble a workspace diff. */
16
+ interface WorkspaceDiffAssemblyOptions {
17
+ readonly executionId: string;
18
+ readonly baseSha: string;
19
+ readonly headSha: string;
20
+ readonly capturedAt: string;
21
+ readonly snapshot: WorkspaceSnapshot;
22
+ readonly baseEntries: readonly WorkspaceBaseEntry[];
23
+ readonly readBaseBlob: (sha: string) => Promise<WorkspaceBaseBlob>;
24
+ readonly signal?: AbortSignal;
25
+ readonly maxBlobBytes?: number;
26
+ readonly maxPatchBytes?: number;
27
+ readonly maxTotalPatchBytes?: number;
28
+ }
29
+ /** Assemble bounded unified patches from a sandbox snapshot and pinned base blobs. */
30
+ declare function assembleWorkspaceDiff(options: WorkspaceDiffAssemblyOptions): Promise<WorkspaceDiff>;
31
+ //#endregion
32
+ export { WorkspaceBaseBlob, WorkspaceBaseEntry, WorkspaceDiffAssemblyOptions, assembleWorkspaceDiff };
33
+ //# sourceMappingURL=workspace-diff-assembly.d.mts.map
@@ -0,0 +1,95 @@
1
+ import { workspaceDiffSchema } from "./workspace-diff.mjs";
2
+ import { workspaceSnapshotSchema } from "./workspace-snapshot.mjs";
3
+ import { Buffer } from "node:buffer";
4
+ import { formatPatch, structuredPatch } from "diff";
5
+ //#region src/workspace-diff-assembly.ts
6
+ /** Assemble bounded unified patches from a sandbox snapshot and pinned base blobs. */
7
+ async function assembleWorkspaceDiff(options) {
8
+ const snapshot = workspaceSnapshotSchema.parse(options.snapshot);
9
+ const maxBlobBytes = options.maxBlobBytes ?? 2e5;
10
+ const maxPatchBytes = options.maxPatchBytes ?? 1e5;
11
+ const maxTotalPatchBytes = options.maxTotalPatchBytes ?? 2e6;
12
+ const sizes = new Map(options.baseEntries.map((entry) => [entry.sha, entry.size]));
13
+ const renamed = /* @__PURE__ */ new Set();
14
+ const renames = /* @__PURE__ */ new Map();
15
+ for (const added of snapshot.files.filter((file) => file.oldMode === null && file.newSha !== null)) {
16
+ const previous = snapshot.files.find((file) => file.newMode === null && file.oldSha === added.newSha && !renamed.has(file.path));
17
+ if (previous) {
18
+ renames.set(added.path, previous);
19
+ renamed.add(previous.path);
20
+ }
21
+ }
22
+ const files = [];
23
+ let patchBytes = 0;
24
+ for (const file of snapshot.files) {
25
+ options.signal?.throwIfAborted();
26
+ if (renamed.has(file.path)) continue;
27
+ const rename = renames.get(file.path);
28
+ const oldSha = rename?.oldSha ?? file.oldSha;
29
+ const oldMode = rename?.oldMode ?? file.oldMode;
30
+ let binary = file.binary;
31
+ let omitted = file.omitted || (sizes.get(oldSha ?? "") ?? 0) > maxBlobBytes || oldMode === "160000" || file.newMode === "160000";
32
+ let before = "";
33
+ if (oldSha && !binary && !omitted && !rename) {
34
+ const blob = await options.readBaseBlob(oldSha);
35
+ if (blob.size === null || blob.size > maxBlobBytes || blob.encoding !== "base64") omitted = true;
36
+ else {
37
+ const bytes = Buffer.from(blob.content, "base64");
38
+ binary = bytes.includes(0);
39
+ if (!binary) try {
40
+ before = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
41
+ } catch {
42
+ binary = true;
43
+ }
44
+ }
45
+ }
46
+ let patch = "";
47
+ let additions = null;
48
+ let deletions = null;
49
+ if (!binary && !omitted) {
50
+ if (rename) before = file.content ?? "";
51
+ const diff = structuredPatch(rename?.path ?? file.path, file.path, before, file.content ?? "", void 0, void 0, {
52
+ context: 3,
53
+ timeout: 100,
54
+ maxEditLength: 2e4
55
+ });
56
+ if (!diff) omitted = true;
57
+ else {
58
+ patch = diff.hunks.length ? formatPatch(diff) : "";
59
+ if (patch.length > maxPatchBytes || patchBytes + Buffer.byteLength(patch) > maxTotalPatchBytes) {
60
+ patch = "";
61
+ omitted = true;
62
+ } else {
63
+ patchBytes += Buffer.byteLength(patch);
64
+ additions = diff.hunks.reduce((sum, hunk) => sum + hunk.lines.filter((line) => line.startsWith("+")).length, 0);
65
+ deletions = diff.hunks.reduce((sum, hunk) => sum + hunk.lines.filter((line) => line.startsWith("-")).length, 0);
66
+ }
67
+ }
68
+ }
69
+ files.push({
70
+ path: file.path,
71
+ ...rename ? { previousPath: rename.path } : {},
72
+ status: rename ? "renamed" : oldMode === null ? "added" : file.newMode === null ? "deleted" : "modified",
73
+ oldMode,
74
+ newMode: file.newMode,
75
+ additions,
76
+ deletions,
77
+ patch,
78
+ binary,
79
+ omitted
80
+ });
81
+ }
82
+ return workspaceDiffSchema.parse({
83
+ executionId: options.executionId,
84
+ state: "ready",
85
+ base: { sha: options.baseSha },
86
+ head: { sha: options.headSha },
87
+ capturedAt: options.capturedAt,
88
+ files,
89
+ truncated: snapshot.truncated || files.some((file) => file.omitted)
90
+ });
91
+ }
92
+ //#endregion
93
+ export { assembleWorkspaceDiff };
94
+
95
+ //# sourceMappingURL=workspace-diff-assembly.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-diff-assembly.mjs","names":[],"sources":["../src/workspace-diff-assembly.ts"],"sourcesContent":["import { Buffer } from \"node:buffer\";\nimport { formatPatch, structuredPatch } from \"diff\";\nimport { workspaceDiffSchema, type WorkspaceDiff, type WorkspaceDiffFile } from \"./workspace-diff\";\nimport { workspaceSnapshotSchema, type WorkspaceSnapshot } from \"./workspace-snapshot\";\n\n/** Metadata for one file in the pinned comparison base tree. */\nexport interface WorkspaceBaseEntry {\n readonly sha: string;\n readonly size: number;\n}\n\n/** Encoded contents and metadata for one pinned base-tree blob. */\nexport interface WorkspaceBaseBlob {\n readonly content: string;\n readonly encoding: string;\n readonly size: number | null;\n}\n\n/** Pinned inputs and display limits used to assemble a workspace diff. */\nexport interface WorkspaceDiffAssemblyOptions {\n readonly executionId: string;\n readonly baseSha: string;\n readonly headSha: string;\n readonly capturedAt: string;\n readonly snapshot: WorkspaceSnapshot;\n readonly baseEntries: readonly WorkspaceBaseEntry[];\n readonly readBaseBlob: (sha: string) => Promise<WorkspaceBaseBlob>;\n readonly signal?: AbortSignal;\n readonly maxBlobBytes?: number;\n readonly maxPatchBytes?: number;\n readonly maxTotalPatchBytes?: number;\n}\n\n/** Assemble bounded unified patches from a sandbox snapshot and pinned base blobs. */\nexport async function assembleWorkspaceDiff(\n options: WorkspaceDiffAssemblyOptions,\n): Promise<WorkspaceDiff> {\n const snapshot = workspaceSnapshotSchema.parse(options.snapshot);\n const maxBlobBytes = options.maxBlobBytes ?? 200_000;\n const maxPatchBytes = options.maxPatchBytes ?? 100_000;\n const maxTotalPatchBytes = options.maxTotalPatchBytes ?? 2_000_000;\n const sizes = new Map(options.baseEntries.map((entry) => [entry.sha, entry.size]));\n const renamed = new Set<string>();\n const renames = new Map<string, (typeof snapshot.files)[number]>();\n for (const added of snapshot.files.filter(\n (file) => file.oldMode === null && file.newSha !== null,\n )) {\n const previous = snapshot.files.find(\n (file) => file.newMode === null && file.oldSha === added.newSha && !renamed.has(file.path),\n );\n if (previous) {\n renames.set(added.path, previous);\n renamed.add(previous.path);\n }\n }\n\n const files: WorkspaceDiffFile[] = [];\n let patchBytes = 0;\n for (const file of snapshot.files) {\n options.signal?.throwIfAborted();\n if (renamed.has(file.path)) continue;\n const rename = renames.get(file.path);\n const oldSha = rename?.oldSha ?? file.oldSha;\n const oldMode = rename?.oldMode ?? file.oldMode;\n let binary = file.binary;\n let omitted =\n file.omitted ||\n (sizes.get(oldSha ?? \"\") ?? 0) > maxBlobBytes ||\n oldMode === \"160000\" ||\n file.newMode === \"160000\";\n let before = \"\";\n if (oldSha && !binary && !omitted && !rename) {\n const blob = await options.readBaseBlob(oldSha);\n if (blob.size === null || blob.size > maxBlobBytes || blob.encoding !== \"base64\") {\n omitted = true;\n } else {\n const bytes = Buffer.from(blob.content, \"base64\");\n binary = bytes.includes(0);\n if (!binary) {\n try {\n before = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } catch {\n binary = true;\n }\n }\n }\n }\n let patch = \"\";\n let additions: number | null = null;\n let deletions: number | null = null;\n if (!binary && !omitted) {\n if (rename) before = file.content ?? \"\";\n const diff = structuredPatch(\n rename?.path ?? file.path,\n file.path,\n before,\n file.content ?? \"\",\n undefined,\n undefined,\n { context: 3, timeout: 100, maxEditLength: 20_000 },\n );\n if (!diff) {\n omitted = true;\n } else {\n patch = diff.hunks.length ? formatPatch(diff) : \"\";\n if (\n patch.length > maxPatchBytes ||\n patchBytes + Buffer.byteLength(patch) > maxTotalPatchBytes\n ) {\n patch = \"\";\n omitted = true;\n } else {\n patchBytes += Buffer.byteLength(patch);\n additions = diff.hunks.reduce(\n (sum, hunk) => sum + hunk.lines.filter((line) => line.startsWith(\"+\")).length,\n 0,\n );\n deletions = diff.hunks.reduce(\n (sum, hunk) => sum + hunk.lines.filter((line) => line.startsWith(\"-\")).length,\n 0,\n );\n }\n }\n }\n files.push({\n path: file.path,\n ...(rename ? { previousPath: rename.path } : {}),\n status: rename\n ? \"renamed\"\n : oldMode === null\n ? \"added\"\n : file.newMode === null\n ? \"deleted\"\n : \"modified\",\n oldMode,\n newMode: file.newMode,\n additions,\n deletions,\n patch,\n binary,\n omitted,\n });\n }\n return workspaceDiffSchema.parse({\n executionId: options.executionId,\n state: \"ready\",\n base: { sha: options.baseSha },\n head: { sha: options.headSha },\n capturedAt: options.capturedAt,\n files,\n truncated: sn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