@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,199 @@
1
+ import { budgetMonthOf, canReserve, computeMonthSpendUsd } from "./budget.mjs";
2
+ import { InvalidTransitionError } from "./schema/transitions.mjs";
3
+ import { routeKey } from "./agent-routes.mjs";
4
+ import { RecordNotFoundError, VersionConflictError } from "./store/driver.mjs";
5
+ //#region src/dispatch.ts
6
+ /**
7
+ * The provider may have accepted the request, so the running attempt must remain available for
8
+ * recovery with its original launch key. Catchers must not queue a replacement attempt blindly.
9
+ */
10
+ var ExecutionLaunchPendingError = class extends Error {};
11
+ /** Non-terminal dispatch refusal that identifies the gated Task and retryable reason. */
12
+ var DispatchRefusedError = class extends Error {
13
+ /** Exact Task whose current dispatch attempt was refused. */
14
+ taskId;
15
+ /** Stable gate or race category suitable for branching and telemetry. */
16
+ code;
17
+ /** Human-readable refusal context; canonical Task state remains authoritative. */
18
+ reason;
19
+ constructor(taskId, code, reason) {
20
+ super(`dispatch of "${taskId}" refused: ${reason}`);
21
+ this.name = "DispatchRefusedError";
22
+ this.taskId = taskId;
23
+ this.code = code;
24
+ this.reason = reason;
25
+ }
26
+ };
27
+ /**
28
+ * An exhausted budget is definitive, not a retryable refusal: the task has
29
+ * already been failed and receipted when this throws, so it never re-enters
30
+ * the sweep. Operator retry recovers it once budget frees up.
31
+ */
32
+ var BudgetExhaustedError = class extends Error {
33
+ /** Exact Task already transitioned to `failed` by the exhausted admission. */
34
+ taskId;
35
+ /** UTC budget month whose limit refused the reservation. */
36
+ month;
37
+ /** Counted settled cost and live reservations observed for that month. */
38
+ spendUsd;
39
+ constructor(taskId, month, spendUsd) {
40
+ super(`dispatch of "${taskId}" refused: budget for ${month} is exhausted at $${spendUsd}`);
41
+ this.name = "BudgetExhaustedError";
42
+ this.taskId = taskId;
43
+ this.month = month;
44
+ this.spendUsd = spendUsd;
45
+ }
46
+ };
47
+ /** Default launch-attempt allowance covering delayed identity provisioning. */
48
+ const DEFAULT_MAX_LAUNCH_ATTEMPTS = 45;
49
+ /**
50
+ * Claims one queued Task and starts its exact execution mode.
51
+ *
52
+ * @remarks
53
+ * Dispatch first checks route, approval, dependency, and optional budget gates, then atomically
54
+ * transitions the Task from `queued` to `running`. Only the winner invokes `launch`. A successful
55
+ * provider dispatch returns only after its execution reference is stored; it does not mean the
56
+ * Task completed. `workflowOwned: true` returns the claimed running Task without starting a
57
+ * provider session.
58
+ *
59
+ * An ordinary launch failure is rethrown after a best-effort transition back to `queued`, or to
60
+ * `failed` once `maxLaunchAttempts` is exhausted. `ExecutionLaunchPendingError` instead leaves the
61
+ * attempt running because the provider may have accepted the request; recovery must inspect or
62
+ * repeat the launch with the original idempotency key. Budget exhaustion fails and receipts the
63
+ * Task before throwing `BudgetExhaustedError`. Since compensating transitions are best-effort,
64
+ * callers handling any thrown launch error should reread canonical Task state before deciding
65
+ * whether to schedule another attempt.
66
+ *
67
+ * @param stores - Task, graph, and receipt stores that own the dispatch gates.
68
+ * @param input - Exact Task identity plus either a launcher or workflow-owned marker.
69
+ * @returns The running Task, including its durably recorded execution when a launcher was used.
70
+ * @throws `RecordNotFoundError` when the Task is absent.
71
+ * @throws `DispatchRefusedError` when routing, approval, dependencies, or a budget-admission race refuses dispatch.
72
+ * @throws `InvalidTransitionError` when the Task is no longer queued when this caller claims it.
73
+ * @throws `BudgetExhaustedError` after the Task has been failed because no reservation fits.
74
+ * @throws `ExecutionLaunchPendingError` when provider acceptance is ambiguous and requires recovery.
75
+ * @see The shipped `docs/recipes/eve-agent.md` and `docs/recipes/retry-recovery.md` recipes.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import {
80
+ * DispatchRefusedError,
81
+ * dispatchTask,
82
+ * type DispatchStores,
83
+ * } from "@vercel/factory/execution";
84
+ * import type { TaskId } from "@vercel/factory/tasks";
85
+ * import { parseAgentRouteBinding } from "@vercel/factory/workflows";
86
+ *
87
+ * declare const stores: DispatchStores;
88
+ * declare const taskId: TaskId;
89
+ * const route = parseAgentRouteBinding({ id: "worker", version: 1 });
90
+ *
91
+ * try {
92
+ * await dispatchTask(stores, {
93
+ * taskId,
94
+ * route,
95
+ * launch: async () => ({ provider: "eve", sessionId: "ses_example" }),
96
+ * });
97
+ * } catch (error) {
98
+ * if (error instanceof DispatchRefusedError) {
99
+ * // `error.code` identifies the gate; canonical Task state remains authoritative.
100
+ * } else {
101
+ * throw error;
102
+ * }
103
+ * }
104
+ * ```
105
+ */
106
+ async function dispatchTask(stores, input) {
107
+ const { taskId } = input;
108
+ const options = input;
109
+ const task = await stores.tasks.get(taskId);
110
+ if (task === null) throw new RecordNotFoundError("tasks", taskId);
111
+ const route = task.work.route;
112
+ if (route !== void 0 && options.workflowOwned === true) throw new DispatchRefusedError(taskId, "route_mismatch", `agent route ${routeKey(route)} requires a launcher`);
113
+ if (route !== void 0 && (options.route?.id !== route.id || options.route?.version !== route.version)) throw new DispatchRefusedError(taskId, "route_mismatch", `launch requires exact agent route ${routeKey(route)}`);
114
+ if (task.approval === "required") throw new DispatchRefusedError(taskId, "awaiting_approval", "awaiting human approval");
115
+ if (task.approval === "denied") throw new DispatchRefusedError(taskId, "approval_denied", "approval was denied");
116
+ if (!await stores.graphs.dependenciesSatisfied({
117
+ rootTaskId: task.rootTaskId,
118
+ taskId: task.id
119
+ })) throw new DispatchRefusedError(taskId, "dependencies_unsatisfied", "graph dependencies must all be succeeded before dispatch");
120
+ let reservation;
121
+ if (options.budget !== void 0 && task.state === "queued") {
122
+ const budgetNow = (options.budget.now ?? (() => /* @__PURE__ */ new Date()))().toISOString();
123
+ const month = options.budget.month ?? budgetMonthOf(budgetNow);
124
+ const rows = (options.budget.enforce === false ? [] : options.budget.tasks ?? await stores.tasks.list()).map((row) => row.id === taskId ? {
125
+ ...row,
126
+ reservedUsd: void 0
127
+ } : row);
128
+ const spendUsd = computeMonthSpendUsd(rows, month);
129
+ const { totalUsd, perTaskReservationUsd } = options.budget.limits;
130
+ if (options.budget.enforce !== false && !canReserve(spendUsd, options.budget.limits)) {
131
+ const reason = `budget exhausted: ${month} spend $${spendUsd} cannot fit a $${perTaskReservationUsd} reservation under $${totalUsd}`;
132
+ try {
133
+ await stores.tasks.transition(taskId, "failed", {
134
+ reason,
135
+ expectFrom: "queued"
136
+ });
137
+ } catch (error) {
138
+ if (error instanceof InvalidTransitionError || error instanceof VersionConflictError) throw new DispatchRefusedError(taskId, "dispatch_race", "another dispatcher took the task");
139
+ throw error;
140
+ }
141
+ await stores.receipts.append({
142
+ repositoryIds: task.repositoryIds,
143
+ taskId,
144
+ kind: task.kind,
145
+ state: "reservation_refused",
146
+ phase: "budget",
147
+ reason,
148
+ attempt: task.attempt,
149
+ dedupeKey: `task:${taskId}:reservation_refused:${task.attempt}`
150
+ }).catch(() => void 0);
151
+ throw new BudgetExhaustedError(taskId, month, spendUsd);
152
+ }
153
+ reservation = {
154
+ reservedUsd: perTaskReservationUsd,
155
+ reservedAt: budgetNow
156
+ };
157
+ }
158
+ const running = await stores.tasks.transition(taskId, "running", {
159
+ expectFrom: "queued",
160
+ expectAttempt: task.attempt,
161
+ ...reservation === void 0 ? {} : { patch: {
162
+ reservedUsd: reservation.reservedUsd,
163
+ reservedAt: reservation.reservedAt
164
+ } },
165
+ ...task.attempt > 1 ? { phase: options.continuationAttempt === task.attempt ? "workflow" : "retry" } : {}
166
+ });
167
+ if (options.workflowOwned === true) return running;
168
+ let execution;
169
+ try {
170
+ execution = await options.launch(running);
171
+ } catch (error) {
172
+ if (error instanceof ExecutionLaunchPendingError) throw error;
173
+ const reason = (error instanceof Error ? error.message : String(error)).slice(0, 500);
174
+ const limit = options.maxLaunchAttempts ?? 45;
175
+ if (running.attempt < limit) {
176
+ const retryReason = `launch failed (attempt ${running.attempt} of ${limit}), will retry: ${reason}`;
177
+ await stores.tasks.transition(taskId, "queued", {
178
+ reason: retryReason,
179
+ phase: "retry",
180
+ expectFrom: "running",
181
+ expectAttempt: running.attempt
182
+ }).catch(() => void 0);
183
+ } else await stores.tasks.transition(taskId, "failed", {
184
+ reason: `launch failed after ${running.attempt} attempts: ${reason}`,
185
+ phase: "retry",
186
+ expectFrom: "running",
187
+ expectAttempt: running.attempt
188
+ }).catch(() => void 0);
189
+ throw error;
190
+ }
191
+ return stores.tasks.recordExecution(taskId, {
192
+ execution,
193
+ expectAttempt: running.attempt
194
+ });
195
+ }
196
+ //#endregion
197
+ export { BudgetExhaustedError, DEFAULT_MAX_LAUNCH_ATTEMPTS, DispatchRefusedError, ExecutionLaunchPendingError, dispatchTask };
198
+
199
+ //# sourceMappingURL=dispatch.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.mjs","names":[],"sources":["../src/dispatch.ts"],"sourcesContent":["import { budgetMonthOf, canReserve, computeMonthSpendUsd } from \"./budget\";\nimport type { AgentRouteBinding } from \"./agent-routes\";\nimport type { BudgetLimits, BudgetMonth } from \"./schema/budget\";\nimport type { DateClock } from \"./schema/common\";\nimport type { TaskId } from \"./schema/id\";\nimport type { ExecutionReference, Task } from \"./schema/task\";\nimport { routeKey } from \"./agent-routes\";\nimport { InvalidTransitionError } from \"./schema/transitions\";\nimport { RecordNotFoundError, VersionConflictError } from \"./store/driver\";\nimport type { FactoryStores } from \"./store/engine\";\n\n/** Minimal persistence capabilities required to gate and record one dispatch. */\nexport type DispatchStores = Pick<FactoryStores, \"graphs\" | \"receipts\" | \"tasks\">;\n\n/**\n * The provider may have accepted the request, so the running attempt must remain available for\n * recovery with its original launch key. Catchers must not queue a replacement attempt blindly.\n */\nexport class ExecutionLaunchPendingError extends Error {}\n\n/** Stable machine-readable reason a Task could not be dispatched. */\nexport type DispatchRefusalCode =\n | \"route_mismatch\"\n | \"awaiting_approval\"\n | \"approval_denied\"\n | \"dependencies_unsatisfied\"\n | \"dispatch_race\";\n\n/** Non-terminal dispatch refusal that identifies the gated Task and retryable reason. */\nexport class DispatchRefusedError extends Error {\n /** Exact Task whose current dispatch attempt was refused. */\n readonly taskId: TaskId;\n /** Stable gate or race category suitable for branching and telemetry. */\n readonly code: DispatchRefusalCode;\n /** Human-readable refusal context; canonical Task state remains authoritative. */\n readonly reason: string;\n\n constructor(taskId: TaskId, code: DispatchRefusalCode, reason: string) {\n super(`dispatch of \"${taskId}\" refused: ${reason}`);\n this.name = \"DispatchRefusedError\";\n this.taskId = taskId;\n this.code = code;\n this.reason = reason;\n }\n}\n\n/**\n * An exhausted budget is definitive, not a retryable refusal: the task has\n * already been failed and receipted when this throws, so it never re-enters\n * the sweep. Operator retry recovers it once budget frees up.\n */\nexport class BudgetExhaustedError extends Error {\n /** Exact Task already transitioned to `failed` by the exhausted admission. */\n readonly taskId: TaskId;\n /** UTC budget month whose limit refused the reservation. */\n readonly month: BudgetMonth;\n /** Counted settled cost and live reservations observed for that month. */\n readonly spendUsd: number;\n\n constructor(taskId: TaskId, month: BudgetMonth, spendUsd: number) {\n super(`dispatch of \"${taskId}\" refused: budget for ${month} is exhausted at $${spendUsd}`);\n this.name = \"BudgetExhaustedError\";\n this.taskId = taskId;\n this.month = month;\n this.spendUsd = spendUsd;\n }\n}\n\n/** Factory-wide reservation limits and snapshot used to gate one dispatch. */\nexport interface DispatchBudget {\n /** Factory-wide monthly ceiling and amount reserved for each admitted Task. */\n limits: Pick<BudgetLimits, \"totalUsd\" | \"perTaskReservationUsd\">;\n /** Defaults to true. False records reservations without enforcing the monthly ceiling. */\n enforce?: boolean;\n /** Defaults to the current UTC month. */\n month?: BudgetMonth;\n /** Clock used only to derive the reservation month and timestamp. Defaults to `new Date()`. */\n now?: DateClock;\n /** A dispatcher-wide snapshot used to calculate spend without another list. */\n tasks?: readonly Task[];\n}\n\ninterface DispatchContext {\n /** Exact workflow-confirmed continuation attempt; other replacement attempts count as retries. */\n continuationAttempt?: number;\n /**\n * Maximum Task attempt number allowed for launch failure retries. Defaults to 45. A normal\n * failure below the limit requeues the Task, which increments its attempt for the next sweep.\n */\n maxLaunchAttempts?: number;\n /** Reserve-before-execution policy for this dispatch. */\n budget?: DispatchBudget;\n}\n\n/** Exact provider launch or explicit workflow-owned execution for one Task dispatch. */\nexport type DispatchOptions = DispatchContext &\n (\n | {\n /** Required exact binding when the Task declares an agent route. */\n route?: AgentRouteBinding;\n /**\n * Starts the durable execution for the task (an Eve agent run). Runs after\n * the task has won the queued -> running transition. Its provider reference\n * is mandatory so recovery can always find an accepted run.\n */\n launch: (task: Task) => Promise<ExecutionReference>;\n workflowOwned?: never;\n }\n | {\n /**\n * Marks route-less work whose workflow advances the running Task without a provider\n * session. The caller must schedule that workflow after this admission returns.\n */\n workflowOwned: true;\n route?: never;\n launch?: never;\n }\n );\n\n/** Task identity and exact launch mode supplied to one dispatch attempt. */\nexport type DispatchTaskInput = { readonly taskId: TaskId } & DispatchOptions;\n\n// A fresh Vercel project rejects its own agents' sessions until its identity\n// finishes provisioning; at one sweep per minute the budget must outlast that.\n/** Default launch-attempt allowance covering delayed identity provisioning. */\nexport const DEFAULT_MAX_LAUNCH_ATTEMPTS = 45;\n\n/**\n * Claims one queued Task and starts its exact execution mode.\n *\n * @remarks\n * Dispatch first checks route, approval, dependency, and optional budget gates, then atomically\n * transitions the Task from `queued` to `running`. Only the winner invokes `launch`. A successful\n * provider dispatch returns only after its execution reference is stored; it does not mean the\n * Task completed. `workflowOwned: true` returns the claimed running Task without starting a\n * provider session.\n *\n * An ordinary launch failure is rethrown after a best-effort transition back to `queued`, or to\n * `failed` once `maxLaunchAttempts` is exhausted. `ExecutionLaunchPendingError` instead leaves the\n * attempt running because the provider may have accepted the request; recovery must inspect or\n * repeat the launch with the original idempotency key. Budget exhaustion fails and receipts the\n * Task before throwing `BudgetExhaustedError`. Since compensating transitions are best-effort,\n * callers handling any thrown launch error should reread canonical Task state before deciding\n * whether to schedule another attempt.\n *\n * @param stores - Task, graph, and receipt stores that own the dispatch gates.\n * @param input - Exact Task identity plus either a launcher or workflow-owned marker.\n * @returns The running Task, including its durably recorded execution when a launcher was used.\n * @throws `RecordNotFoundError` when the Task is absent.\n * @throws `DispatchRefusedError` when routing, approval, dependencies, or a budget-admission race refuses dispatch.\n * @throws `InvalidTransitionError` when the Task is no longer queued when this caller claims it.\n * @throws `BudgetExhaustedError` after the Task has been failed because no reservation fits.\n * @throws `ExecutionLaunchPendingError` when provider acceptance is ambiguous and requires recovery.\n * @see The shipped `docs/recipes/eve-agent.md` and `docs/recipes/retry-recovery.md` recipes.\n *\n * @example\n * ```ts\n * import {\n * DispatchRefusedError,\n * dispatchTask,\n * type DispatchStores,\n * } from \"@vercel/factory/execution\";\n * import type { TaskId } from \"@vercel/factory/tasks\";\n * import { parseAgentRouteBinding } from \"@vercel/factory/workflows\";\n *\n * declare const stores: DispatchStores;\n * declare const taskId: TaskId;\n * const route = parseAgentRouteBinding({ id: \"worker\", version: 1 });\n *\n * try {\n * await dispatchTask(stores, {\n * taskId,\n * route,\n * launch: async () => ({ provider: \"eve\", sessionId: \"ses_example\" }),\n * });\n * } catch (error) {\n * if (error instanceof DispatchRefusedError) {\n * // `error.code` identifies the gate; canonical Task state remains authoritative.\n * } else {\n * throw error;\n * }\n * }\n * ```\n */\nexport async function dispatchTask(\n stores: DispatchStores,\n input: DispatchTaskInput,\n): Promise<Task> {\n const { taskId } = input;\n const options: DispatchOptions = input;\n const task = await stores.tasks.get(taskId);\n if (task === null) {\n throw new RecordNotFoundError(\"tasks\", taskId);\n }\n const route = task.work.route;\n if (route !== undefined && options.workflowOwned === true) {\n throw new DispatchRefusedError(\n taskId,\n \"route_mismatch\",\n `agent route ${routeKey(route)} requires a launcher`,\n );\n }\n if (\n route !== undefined &&\n (options.route?.id !== route.id || options.route?.version !== route.version)\n ) {\n throw new DispatchRefusedError(\n taskId,\n \"route_mismatch\",\n `launch requires exact agent route ${routeKey(route)}`,\n );\n }\n if (task.approval === \"required\") {\n throw new DispatchRefusedError(taskId, \"awaiting_approval\", \"awaiting human approval\");\n }\n if (task.approval === \"denied\") {\n throw new DispatchRefusedError(taskId, \"approval_denied\", \"approval was denied\");\n }\n if (\n !(await stores.graphs.dependenciesSatisfied({\n rootTaskId: task.rootTaskId,\n taskId: task.id,\n }))\n ) {\n throw new DispatchRefusedError(\n taskId,\n \"dependencies_unsatisfied\",\n \"graph dependencies must all be succeeded before dispatch\",\n );\n }\n\n // The reservation gates queued -> running only; any other state falls\n // through to the transition below, which rejects it as invalid.\n let reservation: { reservedUsd: number; reservedAt: string } | undefined;\n if (options.budget !== undefined && task.state === \"queued\") {\n const budgetNow = (options.budget.now ?? (() => new Date()))().toISOString();\n const month = options.budget.month ?? budgetMonthOf(budgetNow);\n // This task's own retained reservation from a prior attempt is excluded,\n // because re-reserving overwrites it. Its settled cost stays counted:\n // that money was actually spent and a retry must not reopen it.\n const rows = (\n options.budget.enforce === false ? [] : (options.budget.tasks ?? (await stores.tasks.list()))\n ).map((row) => (row.id === taskId ? { ...row, reservedUsd: undefined } : row));\n const spendUsd = computeMonthSpendUsd(rows, month);\n const { totalUsd, perTaskReservationUsd } = options.budget.limits;\n if (options.budget.enforce !== false && !canReserve(spendUsd, options.budget.limits)) {\n const reason = `budget exhausted: ${month} spend $${spendUsd} cannot fit a $${perTaskReservationUsd} reservation under $${totalUsd}`;\n // Fail first, so BudgetExhaustedError's contract (task already failed)\n // holds; losing the task to a concurrent dispatcher surfaces as a\n // refusal, never as a false exhaustion with a misleading receipt.\n try {\n await stores.tasks.transition(taskId, \"failed\", { reason, expectFrom: \"queued\" });\n } catch (error) {\n if (error instanceof InvalidTransitionError || error instanceof VersionConflictError) {\n throw new DispatchRefusedError(\n taskId,\n \"dispatch_race\",\n \"another dispatcher took the task\",\n );\n }\n throw error;\n }\n // Best-effort: the failed transition above already wrote its own\n // receipt carrying this reason, so losing this supplementary one\n // cannot lose the evidence.\n await stores.receipts\n .append({\n repositoryIds: task.repositoryIds,\n taskId,\n kind: task.kind,\n state: \"reservation_refused\",\n phase: \"budget\",\n reason,\n attempt: task.attempt,\n dedupeKey: `task:${taskId}:reservation_refused:${task.attempt}`,\n })\n .catch(() => undefined);\n throw new BudgetExhaustedError(taskId, month, spendUsd);\n }\n reservation = { reservedUsd: perTaskReservationUsd, reservedAt: budgetNow };\n }\n\n const running = await stores.tasks.transition(taskId, \"running\", {\n expectFrom: \"queued\",\n expectAttempt: task.attempt,\n ...(reservation === undefined\n ? {}\n : {\n patch: {\n reservedUsd: reservation.reservedUsd,\n reservedAt: reservation.reservedAt,\n },\n }),\n ...(task.attempt > 1\n ? { phase: options.continuationAttempt === task.attempt ? \"workflow\" : \"retry\" }\n : {}),\n });\n if (options.workflowOwned === true) return running;\n let execution: ExecutionReference;\n try {\n execution = await options.launch(running);\n } catch (error) {\n if (error instanceof ExecutionLaunchPendingError) throw error;\n const reason = (error instanceof Error ? error.message : String(error)).slice(0, 500);\n const limit = options.maxLaunchAttempts ?? DEFAULT_MAX_LAUNCH_ATTEMPTS;\n if (running.attempt < limit) {\n const retryReason = `launch failed (attempt ${running.attempt} of ${limit}), will retry: ${reason}`;\n await stores.tasks\n .transition(taskId, \"queued\", {\n reason: retryReason,\n phase: \"retry\",\n expectFrom: \"running\",\n expectAttempt: running.attempt,\n })\n .catch(() => undefined);\n } else {\n await stores.tasks\n .transition(taskId, \"failed\", {\n reason: `launch failed after ${running.attempt} attempts: ${reason}`,\n phase: \"retry\",\n expectFrom: \"running\",\n expectAttempt: running.attempt,\n })\n .catch(() => undefined);\n }\n throw error;\n }\n // Surface a failed binding so a durable caller can recover the same launch;\n // never report acceptance with an unrecorded or stale execution.\n return stores.tasks.recordExecution(taskId, {\n execution,\n expectAttempt: running.attempt,\n });\n}\n"],"mappings":"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"}
@@ -0,0 +1,15 @@
1
+ //#region src/errors.d.ts
2
+ /** Returns an error message with supplied secrets and recognized credentials removed. */
3
+ declare function redactedErrorMessage(error: unknown, secrets?: readonly (string | undefined)[], fallback?: string): string;
4
+ /** Bounded, recursively redacted diagnostic details safe for structured reporting. */
5
+ interface RedactedErrorDetails {
6
+ name: string;
7
+ message: string;
8
+ stack?: string;
9
+ cause?: RedactedErrorDetails;
10
+ }
11
+ /** Builds bounded, recursively redacted diagnostic details from an unknown error. */
12
+ declare function redactedErrorDetails(error: unknown, secrets?: readonly (string | undefined)[]): RedactedErrorDetails;
13
+ //#endregion
14
+ export { RedactedErrorDetails, redactedErrorDetails, redactedErrorMessage };
15
+ //# sourceMappingURL=errors.d.mts.map
@@ -0,0 +1,38 @@
1
+ //#region src/errors.ts
2
+ const credentialPatterns = [
3
+ /github_pat_[A-Za-z0-9_]+/gu,
4
+ /gh[psoru]_[A-Za-z0-9_]+/gu,
5
+ /xox[baprs]-[A-Za-z0-9-]+/gu,
6
+ /Basic [A-Za-z0-9+/=]+/gu,
7
+ /Bearer [A-Za-z0-9._~+/-]+=*/giu,
8
+ /vercel_blob_rw_[A-Za-z0-9_]+/gu
9
+ ];
10
+ function errorMessage(error, fallback) {
11
+ return error instanceof Error ? error.message : fallback ?? String(error);
12
+ }
13
+ /** Returns an error message with supplied secrets and recognized credentials removed. */
14
+ function redactedErrorMessage(error, secrets = [], fallback) {
15
+ let message = errorMessage(error, fallback);
16
+ for (const secret of secrets) {
17
+ const value = secret?.trim();
18
+ if (value) message = message.replaceAll(value, "[REDACTED]");
19
+ }
20
+ for (const pattern of credentialPatterns) message = message.replace(pattern, (match) => match.startsWith("Basic ") ? "Basic [REDACTED]" : "[REDACTED]");
21
+ return message;
22
+ }
23
+ /** Builds bounded, recursively redacted diagnostic details from an unknown error. */
24
+ function redactedErrorDetails(error, secrets = []) {
25
+ return nestedRedactedErrorDetails(error, secrets, 0);
26
+ }
27
+ function nestedRedactedErrorDetails(error, secrets, depth) {
28
+ return {
29
+ name: error instanceof Error ? error.name : "UnknownError",
30
+ message: redactedErrorMessage(error, secrets, "Unknown error").slice(0, 2e3),
31
+ ...error instanceof Error && error.stack ? { stack: redactedErrorMessage(error.stack, secrets).slice(0, 8e3) } : {},
32
+ ...error instanceof Error && error.cause !== void 0 && depth < 2 ? { cause: nestedRedactedErrorDetails(error.cause, secrets, depth + 1) } : {}
33
+ };
34
+ }
35
+ //#endregion
36
+ export { redactedErrorDetails, redactedErrorMessage };
37
+
38
+ //# sourceMappingURL=errors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["const credentialPatterns = [\n /github_pat_[A-Za-z0-9_]+/gu,\n /gh[psoru]_[A-Za-z0-9_]+/gu,\n /xox[baprs]-[A-Za-z0-9-]+/gu,\n /Basic [A-Za-z0-9+/=]+/gu,\n /Bearer [A-Za-z0-9._~+/-]+=*/giu,\n /vercel_blob_rw_[A-Za-z0-9_]+/gu,\n] as const;\n\nfunction errorMessage(error: unknown, fallback?: string): string {\n return error instanceof Error ? error.message : (fallback ?? String(error));\n}\n\n/** Returns an error message with supplied secrets and recognized credentials removed. */\nexport function redactedErrorMessage(\n error: unknown,\n secrets: readonly (string | undefined)[] = [],\n fallback?: string,\n): string {\n let message = errorMessage(error, fallback);\n for (const secret of secrets) {\n const value = secret?.trim();\n if (value) message = message.replaceAll(value, \"[REDACTED]\");\n }\n for (const pattern of credentialPatterns) {\n message = message.replace(pattern, (match) =>\n match.startsWith(\"Basic \") ? \"Basic [REDACTED]\" : \"[REDACTED]\",\n );\n }\n return message;\n}\n\n/** Bounded, recursively redacted diagnostic details safe for structured reporting. */\nexport interface RedactedErrorDetails {\n name: string;\n message: string;\n stack?: string;\n cause?: RedactedErrorDetails;\n}\n\n/** Builds bounded, recursively redacted diagnostic details from an unknown error. */\nexport function redactedErrorDetails(\n error: unknown,\n secrets: readonly (string | undefined)[] = [],\n): RedactedErrorDetails {\n return nestedRedactedErrorDetails(error, secrets, 0);\n}\n\nfunction nestedRedactedErrorDetails(\n error: unknown,\n secrets: readonly (string | undefined)[],\n depth: number,\n): RedactedErrorDetails {\n return {\n name: error instanceof Error ? error.name : \"UnknownError\",\n message: redactedErrorMessage(error, secrets, \"Unknown error\").slice(0, 2000),\n ...(error instanceof Error && error.stack\n ? { stack: redactedErrorMessage(error.stack, secrets).slice(0, 8000) }\n : {}),\n ...(error instanceof Error && error.cause !== undefined && depth < 2\n ? { cause: nestedRedactedErrorDetails(error.cause, secrets, depth + 1) }\n : {}),\n };\n}\n"],"mappings":";AAAA,MAAM,qBAAqB;CACzB;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,aAAa,OAAgB,UAA2B;CAC/D,OAAO,iBAAiB,QAAQ,MAAM,UAAW,YAAY,OAAO,KAAK;AAC3E;;AAGA,SAAgB,qBACd,OACA,UAA2C,CAAC,GAC5C,UACQ;CACR,IAAI,UAAU,aAAa,OAAO,QAAQ;CAC1C,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,QAAQ,QAAQ,KAAK;EAC3B,IAAI,OAAO,UAAU,QAAQ,WAAW,OAAO,YAAY;CAC7D;CACA,KAAK,MAAM,WAAW,oBACpB,UAAU,QAAQ,QAAQ,UAAU,UAClC,MAAM,WAAW,QAAQ,IAAI,qBAAqB,YACpD;CAEF,OAAO;AACT;;AAWA,SAAgB,qBACd,OACA,UAA2C,CAAC,GACtB;CACtB,OAAO,2BAA2B,OAAO,SAAS,CAAC;AACrD;AAEA,SAAS,2BACP,OACA,SACA,OACsB;CACtB,OAAO;EACL,MAAM,iBAAiB,QAAQ,MAAM,OAAO;EAC5C,SAAS,qBAAqB,OAAO,SAAS,eAAe,CAAC,CAAC,MAAM,GAAG,GAAI;EAC5E,GAAI,iBAAiB,SAAS,MAAM,QAChC,EAAE,OAAO,qBAAqB,MAAM,OAAO,OAAO,CAAC,CAAC,MAAM,GAAG,GAAI,EAAE,IACnE,CAAC;EACL,GAAI,iBAAiB,SAAS,MAAM,UAAU,KAAA,KAAa,QAAQ,IAC/D,EAAE,OAAO,2BAA2B,MAAM,OAAO,SAAS,QAAQ,CAAC,EAAE,IACrE,CAAC;CACP;AACF"}