@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,16 @@
1
+ //#region src/sandbox/execution-abort.d.ts
2
+ /** Signals that a sandbox execution exceeded its workflow-owned deadline. */
3
+ declare class ExecutionTimeoutError extends Error {
4
+ constructor();
5
+ }
6
+ /** Configures a deadline, durable stop observation, and abort-aware execution callback. */
7
+ interface ExecutionAbortOptions<T> {
8
+ timeoutMs: number;
9
+ isStopped(): Promise<boolean>;
10
+ run(signal: AbortSignal): Promise<T>;
11
+ }
12
+ /** Run work until it completes, its deadline expires, or durable state records a stop. */
13
+ declare function withExecutionAbort<T>(options: ExecutionAbortOptions<T>): Promise<T>;
14
+ //#endregion
15
+ export { ExecutionAbortOptions, ExecutionTimeoutError, withExecutionAbort };
16
+ //# sourceMappingURL=execution-abort.d.mts.map
@@ -0,0 +1,49 @@
1
+ //#region src/sandbox/execution-abort.ts
2
+ /** Signals that a sandbox execution exceeded its workflow-owned deadline. */
3
+ var ExecutionTimeoutError = class extends Error {
4
+ constructor() {
5
+ super("Execution deadline exceeded");
6
+ this.name = "ExecutionTimeoutError";
7
+ }
8
+ };
9
+ /** Run work until it completes, its deadline expires, or durable state records a stop. */
10
+ async function withExecutionAbort(options) {
11
+ const controller = new AbortController();
12
+ let finished = false;
13
+ let pollTimer;
14
+ let pendingCheck;
15
+ const timeoutTimer = setTimeout(() => abort(new ExecutionTimeoutError()), options.timeoutMs);
16
+ function clearTimers() {
17
+ clearTimeout(timeoutTimer);
18
+ clearTimeout(pollTimer);
19
+ }
20
+ function abort(reason) {
21
+ clearTimers();
22
+ controller.abort(reason);
23
+ }
24
+ async function checkStopped() {
25
+ try {
26
+ if (await options.isStopped()) abort(new DOMException("Execution was stopped", "AbortError"));
27
+ } catch (cause) {
28
+ abort(new Error("Execution stop state could not be read", { cause }));
29
+ }
30
+ if (!finished && !controller.signal.aborted) pollTimer = setTimeout(() => {
31
+ pendingCheck = checkStopped();
32
+ }, 1e3);
33
+ }
34
+ try {
35
+ pendingCheck = checkStopped();
36
+ await pendingCheck;
37
+ controller.signal.throwIfAborted();
38
+ return await options.run(controller.signal);
39
+ } finally {
40
+ finished = true;
41
+ clearTimers();
42
+ await pendingCheck;
43
+ controller.signal.throwIfAborted();
44
+ }
45
+ }
46
+ //#endregion
47
+ export { ExecutionTimeoutError, withExecutionAbort };
48
+
49
+ //# sourceMappingURL=execution-abort.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-abort.mjs","names":[],"sources":["../../src/sandbox/execution-abort.ts"],"sourcesContent":["/** Signals that a sandbox execution exceeded its workflow-owned deadline. */\nexport class ExecutionTimeoutError extends Error {\n constructor() {\n super(\"Execution deadline exceeded\");\n this.name = \"ExecutionTimeoutError\";\n }\n}\n\n/** Configures a deadline, durable stop observation, and abort-aware execution callback. */\nexport interface ExecutionAbortOptions<T> {\n timeoutMs: number;\n isStopped(): Promise<boolean>;\n run(signal: AbortSignal): Promise<T>;\n}\n\n/** Run work until it completes, its deadline expires, or durable state records a stop. */\nexport async function withExecutionAbort<T>(options: ExecutionAbortOptions<T>): Promise<T> {\n const controller = new AbortController();\n let finished = false;\n let pollTimer: ReturnType<typeof setTimeout> | undefined;\n let pendingCheck: Promise<void> | undefined;\n const timeoutTimer = setTimeout(() => abort(new ExecutionTimeoutError()), options.timeoutMs);\n\n function clearTimers() {\n clearTimeout(timeoutTimer);\n clearTimeout(pollTimer);\n }\n\n function abort(reason: unknown) {\n clearTimers();\n controller.abort(reason);\n }\n\n async function checkStopped() {\n try {\n if (await options.isStopped()) {\n abort(new DOMException(\"Execution was stopped\", \"AbortError\"));\n }\n } catch (cause) {\n abort(new Error(\"Execution stop state could not be read\", { cause }));\n }\n if (!finished && !controller.signal.aborted) {\n pollTimer = setTimeout(() => {\n pendingCheck = checkStopped();\n }, 1000);\n }\n }\n\n try {\n pendingCheck = checkStopped();\n await pendingCheck;\n controller.signal.throwIfAborted();\n return await options.run(controller.signal);\n } finally {\n finished = true;\n clearTimers();\n await pendingCheck;\n // The run must settle before cleanup; abort reasons survive SDK error wrapping.\n controller.signal.throwIfAborted();\n }\n}\n"],"mappings":";;AACA,IAAa,wBAAb,cAA2C,MAAM;CAC/C,cAAc;EACZ,MAAM,6BAA6B;EACnC,KAAK,OAAO;CACd;AACF;;AAUA,eAAsB,mBAAsB,SAA+C;CACzF,MAAM,aAAa,IAAI,gBAAgB;CACvC,IAAI,WAAW;CACf,IAAI;CACJ,IAAI;CACJ,MAAM,eAAe,iBAAiB,MAAM,IAAI,sBAAsB,CAAC,GAAG,QAAQ,SAAS;CAE3F,SAAS,cAAc;EACrB,aAAa,YAAY;EACzB,aAAa,SAAS;CACxB;CAEA,SAAS,MAAM,QAAiB;EAC9B,YAAY;EACZ,WAAW,MAAM,MAAM;CACzB;CAEA,eAAe,eAAe;EAC5B,IAAI;GACF,IAAI,MAAM,QAAQ,UAAU,GAC1B,MAAM,IAAI,aAAa,yBAAyB,YAAY,CAAC;EAEjE,SAAS,OAAO;GACd,MAAM,IAAI,MAAM,0CAA0C,EAAE,MAAM,CAAC,CAAC;EACtE;EACA,IAAI,CAAC,YAAY,CAAC,WAAW,OAAO,SAClC,YAAY,iBAAiB;GAC3B,eAAe,aAAa;EAC9B,GAAG,GAAI;CAEX;CAEA,IAAI;EACF,eAAe,aAAa;EAC5B,MAAM;EACN,WAAW,OAAO,eAAe;EACjC,OAAO,MAAM,QAAQ,IAAI,WAAW,MAAM;CAC5C,UAAU;EACR,WAAW;EACX,YAAY;EACZ,MAAM;EAEN,WAAW,OAAO,eAAe;CACnC;AACF"}
@@ -0,0 +1,25 @@
1
+ import { CodingExecutionRequest, TaskAttemptRef } from "../schema/execution.mjs";
2
+ import { SandboxHandle } from "./harness-runner.mjs";
3
+ //#region src/sandbox/execution-environment.d.ts
4
+ /** Provider status classification used to decide whether an execution may be reattached. */
5
+ type EnvironmentLiveness = "live" | "transitioning" | "terminal";
6
+ /** Timeout and coding request used to provision an execution environment. */
7
+ interface EnsureExecutionEnvironmentOptions {
8
+ timeoutMs: number;
9
+ request: CodingExecutionRequest;
10
+ }
11
+ /** Environment handle paired with its provider-neutral liveness. */
12
+ interface ExecutionEnvironmentObservation<Handle extends SandboxHandle = SandboxHandle> {
13
+ sandbox: Handle;
14
+ liveness: EnvironmentLiveness;
15
+ }
16
+ /** Provider-neutral lifecycle contract for Task-attempt execution environments. */
17
+ interface ExecutionEnvironment<Handle extends SandboxHandle = SandboxHandle> {
18
+ name(key: TaskAttemptRef): string;
19
+ ensure(key: TaskAttemptRef, options: EnsureExecutionEnvironmentOptions): Promise<ExecutionEnvironmentObservation<Handle>>;
20
+ find(key: TaskAttemptRef): Promise<ExecutionEnvironmentObservation<Handle> | null>;
21
+ stop(sandbox: Handle): Promise<void>;
22
+ }
23
+ //#endregion
24
+ export { EnsureExecutionEnvironmentOptions, EnvironmentLiveness, ExecutionEnvironment, ExecutionEnvironmentObservation };
25
+ //# sourceMappingURL=execution-environment.d.mts.map
@@ -0,0 +1,115 @@
1
+ import { JsonValue } from "../schema/work.mjs";
2
+ import { ExecutionReference } from "../schema/task.mjs";
3
+ import "../workflows.mjs";
4
+ import { MillisecondClock } from "../schema/common.mjs";
5
+ import { CodingExecutionRequest, ExecutionLaunchKey, ExecutionResult } from "../schema/execution.mjs";
6
+ import { BlobClient } from "../blob/index.mjs";
7
+ import { HarnessTurnUsage } from "./harness-runner.mjs";
8
+ import { z } from "zod";
9
+ //#region src/sandbox/execution-run-ledger.d.ts
10
+ declare const runRecordSchema: z.ZodObject<{
11
+ key: z.ZodType<`factory-task:task_${string}:${number}`, string, z.core.$ZodTypeInternals<`factory-task:task_${string}:${number}`, string>>;
12
+ request: z.ZodObject<{
13
+ repository: z.ZodObject<{
14
+ slug: z.ZodType<`${string}/${string}`, string, z.core.$ZodTypeInternals<`${string}/${string}`, string>>;
15
+ baseSha: z.ZodString;
16
+ }, z.core.$strict>;
17
+ harness: z.ZodEnum<{
18
+ "claude-code": "claude-code";
19
+ codex: "codex";
20
+ fx: "fx";
21
+ pi: "pi";
22
+ }>;
23
+ prompt: z.ZodString;
24
+ allowedConstructs: z.ZodReadonly<z.ZodArray<z.ZodString>>;
25
+ environment: z.ZodObject<{
26
+ snapshotId: z.ZodOptional<z.ZodString>;
27
+ timeoutMs: z.ZodNumber;
28
+ }, z.core.$strict>;
29
+ limits: z.ZodObject<{
30
+ maxTokens: z.ZodOptional<z.ZodNumber>;
31
+ maxCostUsd: z.ZodOptional<z.ZodNumber>;
32
+ }, z.core.$strict>;
33
+ taskId: z.ZodType<`task_${string}`, string, z.core.$ZodTypeInternals<`task_${string}`, string>>;
34
+ attempt: z.ZodNumber;
35
+ }, z.core.$strict>;
36
+ execution: z.ZodObject<{
37
+ provider: z.ZodString;
38
+ sessionId: z.ZodString;
39
+ environmentId: z.ZodOptional<z.ZodString>;
40
+ harness: z.ZodOptional<z.ZodString>;
41
+ traceId: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strict>;
43
+ harnessSessionId: z.ZodString;
44
+ model: z.ZodString;
45
+ reportSchema: z.ZodCustom<JsonValue, JsonValue>;
46
+ createdAtMs: z.ZodNumber;
47
+ launched: z.ZodBoolean;
48
+ startedAtMs: z.ZodOptional<z.ZodNumber>;
49
+ promptedAtMs: z.ZodOptional<z.ZodNumber>;
50
+ resumeState: z.ZodOptional<z.ZodCustom<JsonValue, JsonValue>>;
51
+ turns: z.ZodReadonly<z.ZodArray<z.ZodObject<{
52
+ inputTokens: z.ZodNumber;
53
+ noCacheInputTokens: z.ZodNumber;
54
+ cacheReadTokens: z.ZodNumber;
55
+ cacheWriteTokens: z.ZodNumber;
56
+ outputTokens: z.ZodNumber;
57
+ complete: z.ZodOptional<z.ZodBoolean>;
58
+ }, z.core.$strict>>>;
59
+ lostUsage: z.ZodOptional<z.ZodBoolean>;
60
+ result: z.ZodOptional<z.ZodType<ExecutionResult, unknown, z.core.$ZodTypeInternals<ExecutionResult, unknown>>>;
61
+ }, z.core.$strict>;
62
+ /** Durable identity, continuation, usage, and terminal result for one sandbox execution. */
63
+ type RunRecord = z.infer<typeof runRecordSchema>;
64
+ /** A run record paired with the ETag required for its next confirmed CAS update. */
65
+ interface RunSnapshot {
66
+ record: RunRecord;
67
+ etag: string;
68
+ }
69
+ /** Workflow-owned outcome fields combined with observed execution identity and usage at finalize time. */
70
+ type WithoutObservedExecution<Result extends ExecutionResult> = Result extends ExecutionResult ? Omit<Result, "execution" | "usage"> : never;
71
+ /** Workflow-owned outcome fields before observed execution identity and usage are attached. */
72
+ type ExecutionOutcome = WithoutObservedExecution<ExecutionResult>;
73
+ /** Durable state, clock, and model pricing used to construct an execution ledger. */
74
+ interface ExecutionRunLedgerOptions {
75
+ state: BlobClient;
76
+ now?: MillisecondClock;
77
+ calculateCostUsd?(model: string, turns: readonly HarnessTurnUsage[]): number | undefined;
78
+ }
79
+ /** Immutable admission arguments for one stable sandbox execution key. */
80
+ interface AdmitExecutionRunInput {
81
+ request: CodingExecutionRequest;
82
+ key: ExecutionLaunchKey;
83
+ model: string;
84
+ environmentId: string;
85
+ reportSchema?: unknown;
86
+ }
87
+ /** Identifies the prompt acceptance to persist for one admitted execution run. */
88
+ interface MarkExecutionRunPromptedInput {
89
+ readonly base: RunSnapshot;
90
+ readonly resumeState: unknown;
91
+ readonly origin: "this-driver" | "recovered";
92
+ }
93
+ /** Identifies the first measured turn to persist for one admitted execution run. */
94
+ interface RecordExecutionRunTurnInput {
95
+ readonly base: RunSnapshot;
96
+ readonly turn: HarnessTurnUsage;
97
+ readonly resumeState: unknown;
98
+ readonly origin: "this-driver" | "recovered";
99
+ }
100
+ /** CAS-backed operations for one sandbox execution's admission and continuation state. */
101
+ interface ExecutionRunLedger {
102
+ usage(record: RunRecord): ExecutionResult["usage"];
103
+ read(execution: ExecutionReference): Promise<RunSnapshot | null>;
104
+ admit(input: AdmitExecutionRunInput): Promise<RunSnapshot>;
105
+ markLaunched(base: RunSnapshot, resumeState: unknown): Promise<RunSnapshot>;
106
+ markPrompted(input: MarkExecutionRunPromptedInput): Promise<RunSnapshot>;
107
+ recordTurn(input: RecordExecutionRunTurnInput): Promise<RunSnapshot>;
108
+ finalize(base: RunSnapshot, outcome: ExecutionOutcome): Promise<ExecutionResult>;
109
+ pending(): Promise<readonly ExecutionReference[]>;
110
+ }
111
+ /** Create a CAS-backed ledger for idempotent execution admission, continuation, and finalization. */
112
+ declare function createExecutionRunLedger(input: ExecutionRunLedgerOptions): ExecutionRunLedger;
113
+ //#endregion
114
+ export { AdmitExecutionRunInput, ExecutionOutcome, ExecutionRunLedger, ExecutionRunLedgerOptions, MarkExecutionRunPromptedInput, RecordExecutionRunTurnInput, RunRecord, RunSnapshot, createExecutionRunLedger };
115
+ //# sourceMappingURL=execution-run-ledger.d.mts.map
@@ -0,0 +1,209 @@
1
+ import { jsonValueSchema } from "../schema/work.mjs";
2
+ import { executionReferenceSchema } from "../schema/task.mjs";
3
+ import { codingExecutionRequestSchema, executionLaunchKeySchema, executionResultSchema } from "../schema/execution.mjs";
4
+ import { ExecutionLaunchPendingError } from "../dispatch.mjs";
5
+ import { createHash } from "node:crypto";
6
+ import { z } from "zod";
7
+ import { isDeepStrictEqual } from "node:util";
8
+ //#region src/sandbox/execution-run-ledger.ts
9
+ const turnUsageSchema = z.strictObject({
10
+ inputTokens: z.number().int().nonnegative(),
11
+ noCacheInputTokens: z.number().int().nonnegative(),
12
+ cacheReadTokens: z.number().int().nonnegative(),
13
+ cacheWriteTokens: z.number().int().nonnegative(),
14
+ outputTokens: z.number().int().nonnegative(),
15
+ complete: z.boolean().optional()
16
+ });
17
+ const runRecordSchema = z.strictObject({
18
+ key: executionLaunchKeySchema,
19
+ request: codingExecutionRequestSchema,
20
+ execution: executionReferenceSchema,
21
+ harnessSessionId: z.string().min(1),
22
+ model: z.string().min(1),
23
+ reportSchema: jsonValueSchema,
24
+ createdAtMs: z.number().int().nonnegative(),
25
+ launched: z.boolean(),
26
+ startedAtMs: z.number().int().nonnegative().optional(),
27
+ /** Set durably right after the prompt was accepted by the runtime. */
28
+ promptedAtMs: z.number().int().nonnegative().optional(),
29
+ resumeState: jsonValueSchema.optional(),
30
+ turns: z.array(turnUsageSchema).readonly(),
31
+ /** Unobserved spend makes cost permanently unknown, even if later usage is measured. */
32
+ lostUsage: z.boolean().optional(),
33
+ result: executionResultSchema.optional()
34
+ });
35
+ const sameJson = (left, right) => isDeepStrictEqual(left === void 0 ? void 0 : JSON.parse(JSON.stringify(left)), right === void 0 ? void 0 : JSON.parse(JSON.stringify(right)));
36
+ const asStoredJson = (value) => JSON.parse(JSON.stringify(value ?? null));
37
+ const runPrefix = "factory-executions/";
38
+ /** Create a CAS-backed ledger for idempotent execution admission, continuation, and finalization. */
39
+ function createExecutionRunLedger(input) {
40
+ const { state } = input;
41
+ const now = input.now ?? Date.now;
42
+ const runPath = (sessionId) => `${runPrefix}${sessionId}/run`;
43
+ async function readRun(sessionId) {
44
+ const stored = await state.read({ pathname: runPath(sessionId) });
45
+ if (!stored) return null;
46
+ return {
47
+ record: runRecordSchema.parse(JSON.parse(stored.body)),
48
+ etag: stored.etag
49
+ };
50
+ }
51
+ async function writeRun(record, etag) {
52
+ await state.write({
53
+ pathname: runPath(record.execution.sessionId),
54
+ body: JSON.stringify(record),
55
+ overwrite: etag !== void 0,
56
+ ...etag === void 0 ? {} : { ifMatch: etag }
57
+ });
58
+ }
59
+ async function persistRun(base, apply, verify) {
60
+ try {
61
+ await writeRun(apply(base.record), base.etag);
62
+ } catch {}
63
+ let current = await readRun(base.record.execution.sessionId);
64
+ if (current && !current.record.result && !verify(current.record)) {
65
+ try {
66
+ await writeRun(apply(current.record), current.etag);
67
+ } catch {}
68
+ current = await readRun(base.record.execution.sessionId);
69
+ }
70
+ if (current && (current.record.result || verify(current.record))) return current;
71
+ throw new Error("Execution state could not be persisted; drive again with the same reference");
72
+ }
73
+ function usage(record) {
74
+ const totals = {
75
+ inputTokens: record.turns.reduce((sum, turn) => sum + turn.inputTokens, 0),
76
+ outputTokens: record.turns.reduce((sum, turn) => sum + turn.outputTokens, 0)
77
+ };
78
+ const costUsd = record.lostUsage !== true && (!record.launched || record.turns.length > 0) ? input.calculateCostUsd?.(record.model, record.turns) : void 0;
79
+ return {
80
+ computeMs: Math.max(0, now() - (record.startedAtMs ?? record.createdAtMs)),
81
+ ...totals,
82
+ ...costUsd === void 0 ? {} : { costUsd }
83
+ };
84
+ }
85
+ return {
86
+ usage,
87
+ async read(execution) {
88
+ const stored = await readRun(execution.sessionId);
89
+ return stored && sameJson(stored.record.execution, execution) ? stored : null;
90
+ },
91
+ async admit(input) {
92
+ const request = codingExecutionRequestSchema.parse(input.request);
93
+ if (input.key !== `factory-task:${request.taskId}:${request.attempt}`) throw new Error("Execution key must be derived from the request's Task and attempt");
94
+ const sessionId = createHash("sha256").update(input.key).digest("hex");
95
+ const execution = executionReferenceSchema.parse({
96
+ provider: "vercel-sandbox",
97
+ sessionId,
98
+ environmentId: input.environmentId,
99
+ harness: request.harness
100
+ });
101
+ const reportSchema = jsonValueSchema.parse(asStoredJson(input.reportSchema ?? {}));
102
+ const matches = (record) => sameJson(record.request, request) && record.model === input.model && sameJson(record.reportSchema, reportSchema) && sameJson(record.execution, execution);
103
+ const existing = await readRun(sessionId);
104
+ if (existing) {
105
+ if (!matches(existing.record)) throw new Error("Launch key is already bound to a different execution request");
106
+ return existing;
107
+ }
108
+ const record = {
109
+ key: input.key,
110
+ request,
111
+ execution,
112
+ model: input.model,
113
+ reportSchema,
114
+ harnessSessionId: `factory-${sessionId.slice(0, 24)}`,
115
+ createdAtMs: now(),
116
+ launched: false,
117
+ turns: []
118
+ };
119
+ let writeError;
120
+ try {
121
+ await writeRun(record);
122
+ } catch (error) {
123
+ writeError = error;
124
+ }
125
+ let stored;
126
+ try {
127
+ stored = await readRun(sessionId);
128
+ } catch (cause) {
129
+ throw new ExecutionLaunchPendingError("Execution admission requires recovery with its original key", { cause });
130
+ }
131
+ if (!stored) {
132
+ if (writeError) throw writeError;
133
+ throw new ExecutionLaunchPendingError("Execution admission could not be confirmed");
134
+ }
135
+ if (!matches(stored.record)) throw new Error("Launch key is already bound to a different execution request");
136
+ return stored;
137
+ },
138
+ markLaunched(base, resumeState) {
139
+ const normalized = jsonValueSchema.parse(asStoredJson(resumeState));
140
+ return persistRun(base, (record) => record.launched ? record : {
141
+ ...record,
142
+ launched: true,
143
+ resumeState: normalized,
144
+ startedAtMs: now()
145
+ }, (record) => record.launched);
146
+ },
147
+ markPrompted({ base, resumeState, origin }) {
148
+ if (!base.record.launched) throw new Error("The execution must be launched before recording a prompt");
149
+ const normalized = jsonValueSchema.parse(asStoredJson(resumeState));
150
+ return persistRun(base, (record) => record.promptedAtMs !== void 0 ? record : {
151
+ ...record,
152
+ promptedAtMs: now(),
153
+ resumeState: normalized,
154
+ ...origin === "recovered" || record.lostUsage ? { lostUsage: true } : {}
155
+ }, (record) => record.promptedAtMs !== void 0);
156
+ },
157
+ recordTurn({ base, turn, resumeState, origin }) {
158
+ if (!base.record.launched) throw new Error("The execution must be launched before recording a turn");
159
+ const normalized = jsonValueSchema.parse(asStoredJson(resumeState));
160
+ const measured = turnUsageSchema.parse(turn);
161
+ return persistRun(base, (record) => record.turns.length > 0 ? record : {
162
+ ...record,
163
+ promptedAtMs: record.promptedAtMs ?? now(),
164
+ turns: [measured],
165
+ resumeState: normalized,
166
+ ...origin === "recovered" || record.lostUsage ? { lostUsage: true } : {}
167
+ }, (record) => record.turns.length > 0 && record.promptedAtMs !== void 0);
168
+ },
169
+ async finalize(base, outcome) {
170
+ if (base.record.result) return base.record.result;
171
+ const record = base.record;
172
+ const observed = usage(record);
173
+ const cancelledUsage = record.launched ? observed : {
174
+ computeMs: 0,
175
+ costUsd: 0
176
+ };
177
+ const result = executionResultSchema.parse({
178
+ ...outcome,
179
+ execution: record.execution,
180
+ usage: outcome.status === "cancelled" ? cancelledUsage : observed
181
+ });
182
+ try {
183
+ await writeRun({
184
+ ...record,
185
+ result
186
+ }, base.etag);
187
+ } catch {
188
+ const latest = await readRun(record.execution.sessionId);
189
+ if (latest?.record.result) return latest.record.result;
190
+ throw new Error("Execution result could not be recorded; retry with the same key");
191
+ }
192
+ const confirmed = await readRun(record.execution.sessionId);
193
+ if (confirmed?.record.result) return confirmed.record.result;
194
+ throw new Error("Execution result could not be recorded; retry with the same key");
195
+ },
196
+ async pending() {
197
+ const references = [];
198
+ for (const path of await state.listPaths({ prefix: runPrefix })) {
199
+ const stored = await readRun(path.slice(19).split("/")[0]);
200
+ if (stored && !stored.record.result) references.push(stored.record.execution);
201
+ }
202
+ return references;
203
+ }
204
+ };
205
+ }
206
+ //#endregion
207
+ export { createExecutionRunLedger };
208
+
209
+ //# sourceMappingURL=execution-run-ledger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-run-ledger.mjs","names":[],"sources":["../../src/sandbox/execution-run-ledger.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isDeepStrictEqual } from \"node:util\";\nimport { z } from \"zod\";\nimport { ExecutionLaunchPendingError } from \"../dispatch\";\nimport type { MillisecondClock } from \"../schema/common\";\nimport {\n codingExecutionRequestSchema,\n executionLaunchKeySchema,\n executionResultSchema,\n type CodingExecutionRequest,\n type ExecutionLaunchKey,\n type ExecutionResult,\n} from \"../schema/execution\";\nimport { executionReferenceSchema, type ExecutionReference } from \"../schema/task\";\nimport { jsonValueSchema } from \"../schema/work\";\nimport type { BlobClient } from \"../blob/index\";\nimport type { HarnessTurnUsage } from \"./harness-runner\";\n\nconst turnUsageSchema = z.strictObject({\n inputTokens: z.number().int().nonnegative(),\n noCacheInputTokens: z.number().int().nonnegative(),\n cacheReadTokens: z.number().int().nonnegative(),\n cacheWriteTokens: z.number().int().nonnegative(),\n outputTokens: z.number().int().nonnegative(),\n complete: z.boolean().optional(),\n});\n\nconst runRecordSchema = z.strictObject({\n key: executionLaunchKeySchema,\n request: codingExecutionRequestSchema,\n execution: executionReferenceSchema,\n harnessSessionId: z.string().min(1),\n model: z.string().min(1),\n reportSchema: jsonValueSchema,\n createdAtMs: z.number().int().nonnegative(),\n launched: z.boolean(),\n startedAtMs: z.number().int().nonnegative().optional(),\n /** Set durably right after the prompt was accepted by the runtime. */\n promptedAtMs: z.number().int().nonnegative().optional(),\n resumeState: jsonValueSchema.optional(),\n turns: z.array(turnUsageSchema).readonly(),\n /** Unobserved spend makes cost permanently unknown, even if later usage is measured. */\n lostUsage: z.boolean().optional(),\n result: executionResultSchema.optional(),\n});\n\n/** Durable identity, continuation, usage, and terminal result for one sandbox execution. */\nexport type RunRecord = z.infer<typeof runRecordSchema>;\n\nconst sameJson = (left: unknown, right: unknown) =>\n isDeepStrictEqual(\n left === undefined ? undefined : JSON.parse(JSON.stringify(left)),\n right === undefined ? undefined : JSON.parse(JSON.stringify(right)),\n );\n// SDK values can carry non-plain properties; validate their persisted JSON form.\nconst asStoredJson = (value: unknown) => JSON.parse(JSON.stringify(value ?? null)) as unknown;\n\n/** A run record paired with the ETag required for its next confirmed CAS update. */\nexport interface RunSnapshot {\n record: RunRecord;\n etag: string;\n}\n\n/** Workflow-owned outcome fields combined with observed execution identity and usage at finalize time. */\ntype WithoutObservedExecution<Result extends ExecutionResult> = Result extends ExecutionResult\n ? Omit<Result, \"execution\" | \"usage\">\n : never;\n\n/** Workflow-owned outcome fields before observed execution identity and usage are attached. */\nexport type ExecutionOutcome = WithoutObservedExecution<ExecutionResult>;\nconst runPrefix = \"factory-executions/\";\n\n/** Durable state, clock, and model pricing used to construct an execution ledger. */\nexport interface ExecutionRunLedgerOptions {\n state: BlobClient;\n now?: MillisecondClock;\n calculateCostUsd?(model: string, turns: readonly HarnessTurnUsage[]): number | undefined;\n}\n\n/** Immutable admission arguments for one stable sandbox execution key. */\nexport interface AdmitExecutionRunInput {\n request: CodingExecutionRequest;\n key: ExecutionLaunchKey;\n model: string;\n environmentId: string;\n reportSchema?: unknown;\n}\n\n/** Identifies the prompt acceptance to persist for one admitted execution run. */\nexport interface MarkExecutionRunPromptedInput {\n readonly base: RunSnapshot;\n readonly resumeState: unknown;\n readonly origin: \"this-driver\" | \"recovered\";\n}\n\n/** Identifies the first measured turn to persist for one admitted execution run. */\nexport interface RecordExecutionRunTurnInput {\n readonly base: RunSnapshot;\n readonly turn: HarnessTurnUsage;\n readonly resumeState: unknown;\n readonly origin: \"this-driver\" | \"recovered\";\n}\n\n/** CAS-backed operations for one sandbox execution's admission and continuation state. */\nexport interface ExecutionRunLedger {\n usage(record: RunRecord): ExecutionResult[\"usage\"];\n read(execution: ExecutionReference): Promise<RunSnapshot | null>;\n admit(input: AdmitExecutionRunInput): Promise<RunSnapshot>;\n markLaunched(base: RunSnapshot, resumeState: unknown): Promise<RunSnapshot>;\n markPrompted(input: MarkExecutionRunPromptedInput): Promise<RunSnapshot>;\n recordTurn(input: RecordExecutionRunTurnInput): Promise<RunSnapshot>;\n finalize(base: RunSnapshot, outcome: ExecutionOutcome): Promise<ExecutionResult>;\n pending(): Promise<readonly ExecutionReference[]>;\n}\n\n/** Create a CAS-backed ledger for idempotent execution admission, continuation, and finalization. */\nexport function createExecutionRunLedger(input: ExecutionRunLedgerOptions): ExecutionRunLedger {\n const { state } = input;\n const now = input.now ?? Date.now;\n const runPath = (sessionId: string) => `${runPrefix}${sessionId}/run`;\n async function readRun(sessionId: string): Promise<{ record: RunRecord; etag: string } | null> {\n const stored = await state.read({ pathname: runPath(sessionId) });\n if (!stored) return null;\n return { record: runRecordSchema.parse(JSON.parse(stored.body)), etag: stored.etag };\n }\n\n async function writeRun(record: RunRecord, etag?: string): Promise<void> {\n await state.write({\n pathname: runPath(record.execution.sessionId),\n body: JSON.stringify(record),\n overwrite: etag !== undefined,\n ...(etag === undefined ? {} : { ifMatch: etag }),\n });\n }\n\n // A lost write response is ambiguous; confirm durable state before the next provider effect.\n async function persistRun(\n base: { record: RunRecord; etag: string },\n apply: (record: RunRecord) => RunRecord,\n verify: (record: RunRecord) => boolean,\n ): Promise<{ record: RunRecord; etag: string }> {\n try {\n await writeRun(apply(base.record), base.etag);\n } catch {\n // Confirmed or retried below.\n }\n let current = await readRun(base.record.execution.sessionId);\n if (current && !current.record.result && !verify(current.record)) {\n try {\n await writeRun(apply(current.record), current.etag);\n } catch {\n // Confirmed below.\n }\n current = await readRun(base.record.execution.sessionId);\n }\n if (current && (current.record.result || verify(current.record))) return current;\n throw new Error(\"Execution state could not be persisted; drive again with the same reference\");\n }\n\n function usage(record: RunRecord): ExecutionResult[\"usage\"] {\n const totals = {\n inputTokens: record.turns.reduce((sum, turn) => sum + turn.inputTokens, 0),\n outputTokens: record.turns.reduce((sum, turn) => sum + turn.outputTokens, 0),\n };\n const costUsd =\n record.lostUsage !== true && (!record.launched || record.turns.length > 0)\n ? input.calculateCostUsd?.(record.model, record.turns)\n : undefined;\n return {\n computeMs: Math.max(0, now() - (record.startedAtMs ?? record.createdAtMs)),\n ...totals,\n ...(costUsd === undefined ? {} : { costUsd }),\n };\n }\n\n return {\n usage,\n async read(execution: ExecutionReference): Promise<RunSnapshot | null> {\n const stored = await readRun(execution.sessionId);\n return stored && sameJson(stored.record.execution, execution) ? stored : null;\n },\n async admit(input: AdmitExecutionRunInput): Promise<RunSnapshot> {\n const request = codingExecutionRequestSchema.parse(input.request);\n if (input.key !== `factory-task:${request.taskId}:${request.attempt}`)\n throw new Error(\"Execution key must be derived from the request's Task and attempt\");\n const sessionId = createHash(\"sha256\").update(input.key).digest(\"hex\");\n const execution = executionReferenceSchema.parse({\n provider: \"vercel-sandbox\",\n sessionId,\n environmentId: input.environmentId,\n harness: request.harness,\n });\n const reportSchema = jsonValueSchema.parse(asStoredJson(input.reportSchema ?? {}));\n const matches = (record: RunRecord) =>\n sameJson(record.request, request) &&\n record.model === input.model &&\n sameJson(record.reportSchema, reportSchema) &&\n sameJson(record.execution, execution);\n const existing = await readRun(sessionId);\n if (existing) {\n if (!matches(existing.record))\n throw new Error(\"Launch key is already bound to a different execution request\");\n return existing;\n }\n const record: RunRecord = {\n key: input.key,\n request,\n execution,\n model: input.model,\n reportSchema,\n harnessSessionId: `factory-${sessionId.slice(0, 24)}`,\n createdAtMs: now(),\n launched: false,\n turns: [],\n };\n let writeError: unknown;\n try {\n await writeRun(record);\n } catch (error) {\n writeError = error;\n }\n let stored: RunSnapshot | null;\n try {\n stored = await readRun(sessionId);\n } catch (cause) {\n throw new ExecutionLaunchPendingError(\n \"Execution admission requires recovery with its original key\",\n { cause },\n );\n }\n if (!stored) {\n if (writeError) throw writeError;\n throw new ExecutionLaunchPendingError(\"Execution admission could not be confirmed\");\n }\n if (!matches(stored.record))\n throw new Error(\"Launch key is already bound to a different execution request\");\n return stored;\n },\n markLaunched(base: RunSnapshot, resumeState: unknown): Promise<RunSnapshot> {\n const normalized = jsonValueSchema.parse(asStoredJson(resumeState));\n return persistRun(\n base,\n (record) =>\n record.launched\n ? record\n : {\n ...record,\n launched: true,\n resumeState: normalized,\n startedAtMs: now(),\n },\n (record) => record.launched,\n );\n },\n markPrompted({\n base,\n resumeState,\n origin,\n }: MarkExecutionRunPromptedInput): Promise<RunSnapshot> {\n if (!base.record.launched)\n throw new Error(\"The execution must be launched before recording a prompt\");\n const normalized = jsonValueSchema.parse(asStoredJson(resumeState));\n return persistRun(\n base,\n (record) =>\n record.promptedAtMs !== undefined\n ? record\n : {\n ...record,\n promptedAtMs: now(),\n resumeState: normalized,\n ...(origin === \"recovered\" || record.lostUsage ? { lostUsage: true } : {}),\n },\n (record) => record.promptedAtMs !== undefined,\n );\n },\n recordTurn({\n base,\n turn,\n resumeState,\n origin,\n }: RecordExecutionRunTurnInput): Promise<RunSnapshot> {\n if (!base.record.launched)\n throw new Error(\"The execution must be launched before recording a turn\");\n const normalized = jsonValueSchema.parse(asStoredJson(resumeState));\n const measured = turnUsageSchema.parse(turn);\n return persistRun(\n base,\n (record) =>\n record.turns.length > 0\n ? record\n : {\n ...record,\n promptedAtMs: record.promptedAtMs ?? now(),\n turns: [measured],\n resumeState: normalized,\n ...(origin === \"recovered\" || record.lostUsage ? { lostUsage: true } : {}),\n },\n (record) => record.turns.length > 0 && record.promptedAtMs !== undefined,\n );\n },\n async finalize(base: RunSnapshot, outcome: ExecutionOutcome): Promise<ExecutionResult> {\n if (base.record.result) return base.record.result;\n const record = base.record;\n const observed = usage(record);\n const cancelledUsage = record.launched ? observed : { computeMs: 0, costUsd: 0 };\n const result = executionResultSchema.parse({\n ...outcome,\n execution: record.execution,\n usage: outcome.status === \"cancelled\" ? cancelledUsage : observed,\n });\n try {\n await writeRun({ ...record, result }, base.etag);\n } catch {\n const latest = await readRun(record.execution.sessionId);\n if (latest?.record.result) return latest.record.result;\n throw new Error(\"Execution result could not be recorded; retry with the same key\");\n }\n const confirmed = await readRun(record.execution.sessionId);\n if (confirmed?.record.result) return confirmed.record.result;\n throw new Error(\"Execution result could not be recorded; retry with the same key\");\n },\n async pending(): Promise<readonly ExecutionReference[]> {\n const references: ExecutionReference[] = [];\n for (const path of await state.listPaths({ prefix: runPrefix })) {\n const stored = await readRun(path.slice(runPrefix.length).split(\"/\")[0]!);\n if (stored && !stored.record.result) references.push(stored.record.execution);\n }\n return references;\n },\n };\n}\n"],"mappings":";;;;;;;;AAkBA,MAAM,kBAAkB,EAAE,aAAa;CACrC,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CAC1C,oBAAoB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CACjD,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CAC9C,kBAAkB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CAC/C,cAAc,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CAC3C,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;AACjC,CAAC;AAED,MAAM,kBAAkB,EAAE,aAAa;CACrC,KAAK;CACL,SAAS;CACT,WAAW;CACX,kBAAkB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CAClC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;CACvB,cAAc;CACd,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;CAC1C,UAAU,EAAE,QAAQ;CACpB,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS;;CAErD,cAAc,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS;CACtD,aAAa,gBAAgB,SAAS;CACtC,OAAO,EAAE,MAAM,eAAe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AC1D,IAAI,WAAW,OAAO,QAAQ,OAAO,UAAU,OAAO;GACtD,MAAM,IAAI,MAAM,iEAAiE;EACnF;EACA,MAAM,UAAkD;GACtD,MAAM,aAAmC,CAAC;GAC1C,KAAK,MAAM,QAAQ,MAAM,MAAM,UAAU,EAAE,QAAQ,UAAU,CAAC,GAAG;IAC/D,MAAM,SAAS,MAAM,QAAQ,KAAK,MAAM,EAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAG;IACxE,IAAI,UAAU,CAAC,OAAO,OAAO,QAAQ,WAAW,KAAK,OAAO,OAAO,SAAS;GAC9E;GACA,OAAO;EACT;CACF;AACF"}
@@ -0,0 +1,54 @@
1
+ import { ExecutionReference } from "../schema/task.mjs";
2
+ import { MillisecondClock } from "../schema/common.mjs";
3
+ import { CodingExecutionRequest, ExecutionLaunchKey, ExecutionResult } from "../schema/execution.mjs";
4
+ import { BlobClient } from "../blob/index.mjs";
5
+ import { ExecutionAdapter } from "../execution.mjs";
6
+ import { ConfiguredHarnessRunner, HarnessTurnUsage, SandboxHandle } from "./harness-runner.mjs";
7
+ import { ExecutionEnvironment } from "./execution-environment.mjs";
8
+ import { ExecutionOutcome } from "./execution-run-ledger.mjs";
9
+ //#region src/sandbox/execution.d.ts
10
+ /** Context used to construct the immutable prompt for an admitted sandbox execution. */
11
+ interface SandboxExecutionPromptContext {
12
+ request: CodingExecutionRequest;
13
+ reportSchema: unknown;
14
+ sandbox: SandboxHandle;
15
+ }
16
+ /** Context used to validate and extract artifacts after a sandbox turn completes. */
17
+ interface SandboxExecutionOutcomeContext {
18
+ request: CodingExecutionRequest;
19
+ sandbox: SandboxHandle;
20
+ }
21
+ /** Configures durable state, harnesses, environments, prompts, evidence, and usage pricing. */
22
+ interface SandboxExecutionOptions {
23
+ state: BlobClient;
24
+ harnesses: Partial<Record<CodingExecutionRequest["harness"], ConfiguredHarnessRunner>>;
25
+ environment: ExecutionEnvironment;
26
+ buildPrompt(context: SandboxExecutionPromptContext): string;
27
+ extractOutcome(context: SandboxExecutionOutcomeContext): Promise<ExecutionOutcome>;
28
+ calculateCostUsd?(model: string, turns: readonly HarnessTurnUsage[]): number | undefined;
29
+ sandboxTimeoutMarginMs?: number;
30
+ now?: MillisecondClock;
31
+ }
32
+ /** Coding request, stable launch key, and optional report contract for sandbox admission. */
33
+ interface StartSandboxExecutionInput {
34
+ request: CodingExecutionRequest;
35
+ launchKey: ExecutionLaunchKey;
36
+ context?: SandboxExecutionStartContext;
37
+ }
38
+ /** Optional report contract associated with one sandbox execution launch. */
39
+ interface SandboxExecutionStartContext {
40
+ reportSchema: unknown;
41
+ }
42
+ /** Execution adapter with explicit serial driving and pending-run discovery for sandbox work. */
43
+ interface SandboxExecutionAdapter extends ExecutionAdapter {
44
+ start(input: StartSandboxExecutionInput): Promise<ExecutionReference>;
45
+ /** Serialize calls per execution; ledger CAS does not fence provider effects. */
46
+ drive(execution: ExecutionReference): Promise<ExecutionResult>;
47
+ /** Launch keys with admitted but unfinished runs, for drivers and drills. */
48
+ pending(): Promise<readonly ExecutionReference[]>;
49
+ }
50
+ /** Create a durable execution adapter that runs configured harnesses in Task-scoped sandboxes. */
51
+ declare function createSandboxExecutionAdapter(options: SandboxExecutionOptions): SandboxExecutionAdapter;
52
+ //#endregion
53
+ export { SandboxExecutionAdapter, SandboxExecutionOptions, SandboxExecutionOutcomeContext, SandboxExecutionPromptContext, SandboxExecutionStartContext, StartSandboxExecutionInput, createSandboxExecutionAdapter };
54
+ //# sourceMappingURL=execution.d.mts.map