@cnc-tools/storm 0.15.0 → 0.17.0

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 (305) hide show
  1. package/dist/application.d.ts +22 -13
  2. package/dist/application.js +21 -10
  3. package/dist/bin/run.d.ts +18 -0
  4. package/dist/bin/run.js +31 -0
  5. package/dist/bin/storm.js +42 -26
  6. package/dist/build-info.js +1 -1
  7. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
  8. package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
  9. package/dist/chunks/{chunk-SZEURWRS.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-QVS7HRU7.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-QUHY6FGN.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-DADEYJDW.js} +174 -153
  18. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  19. package/dist/chunks/chunk-F4MOYHRY.js +198 -0
  20. package/dist/chunks/{chunk-CXAT7ZKP.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-OX7X4B2L.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-PN5ULTTH.js → chunk-HWIQ2S7K.js} +5 -5
  24. package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
  25. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
  26. package/dist/chunks/{chunk-XEVHP5ZW.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-L36GBUBB.js → chunk-RNAS7JHE.js} +1755 -522
  29. package/dist/chunks/{chunk-5GBMR4HM.js → chunk-RWIXDDCK.js} +4 -192
  30. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
  31. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  32. package/dist/chunks/{chunk-YV7GE6EV.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-PI3BAN6Y.js → live-app-R76JQXZL.js} +15 -13
  34. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
  35. package/dist/commands/exec/across-sandboxes-outcomes.js +4 -3
  36. package/dist/commands/exec/before-run.d.ts +123 -0
  37. package/dist/commands/exec/before-run.js +105 -0
  38. package/dist/commands/exec/command.d.ts +39 -4
  39. package/dist/commands/exec/command.js +31 -95
  40. package/dist/commands/exec/driver-plan.d.ts +9 -4
  41. package/dist/commands/exec/driver-plan.js +8 -8
  42. package/dist/commands/exec/exec-words.js +1 -1
  43. package/dist/commands/exec/execute-run.d.ts +39 -0
  44. package/dist/commands/exec/execute-run.js +325 -0
  45. package/dist/commands/exec/live-view.d.ts +3 -3
  46. package/dist/commands/exec/live-view.js +16 -15
  47. package/dist/commands/exec/metadata.js +1 -1
  48. package/dist/commands/exec/mint-failed.d.ts +38 -0
  49. package/dist/commands/exec/mint-failed.js +27 -4
  50. package/dist/commands/exec/outcomes.d.ts +38 -9
  51. package/dist/commands/exec/outcomes.js +32 -25
  52. package/dist/commands/exec/plan-run.d.ts +58 -150
  53. package/dist/commands/exec/plan-run.js +232 -88
  54. package/dist/commands/exec/planned-outcome.js +8 -1
  55. package/dist/commands/exec/progress.d.ts +10 -6
  56. package/dist/commands/exec/progress.js +38 -25
  57. package/dist/commands/exec/run-bin.d.ts +11 -11
  58. package/dist/commands/exec/run-bin.js +9 -9
  59. package/dist/commands/exec/run-flags.d.ts +69 -0
  60. package/dist/commands/exec/run-flags.js +58 -0
  61. package/dist/commands/exec/run-metadata.js +5 -5
  62. package/dist/commands/exec/run-summary.d.ts +58 -0
  63. package/dist/commands/exec/run-summary.js +205 -0
  64. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  65. package/dist/commands/exec/runner-refusals.js +71 -0
  66. package/dist/commands/exec/sandbox-progress.js +3 -0
  67. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  68. package/dist/commands/exec/stopped-outcome.js +77 -0
  69. package/dist/commands/exec/view.d.ts +20 -11
  70. package/dist/commands/exec/view.js +103 -47
  71. package/dist/commands/runs/facts.d.ts +9 -4
  72. package/dist/commands/runs/facts.js +28 -11
  73. package/dist/commands/runs/list/command.d.ts +16 -6
  74. package/dist/commands/runs/list/command.js +10 -10
  75. package/dist/commands/runs/list/outcomes.d.ts +8 -3
  76. package/dist/commands/runs/logs/command.d.ts +6 -2
  77. package/dist/commands/runs/logs/command.js +10 -10
  78. package/dist/commands/runs/logs/outcomes.d.ts +3 -1
  79. package/dist/commands/runs/past-run.d.ts +14 -5
  80. package/dist/commands/runs/past-run.js +16 -5
  81. package/dist/commands/runs/show/command.d.ts +20 -8
  82. package/dist/commands/runs/show/command.js +30 -28
  83. package/dist/commands/runs/show/outcomes.d.ts +10 -4
  84. package/dist/commands/runs/show/outcomes.js +7 -5
  85. package/dist/commands/snapshots/access.d.ts +111 -0
  86. package/dist/commands/snapshots/access.js +96 -0
  87. package/dist/commands/snapshots/build/command.d.ts +360 -93
  88. package/dist/commands/snapshots/build/command.js +446 -150
  89. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  90. package/dist/commands/snapshots/build/metadata.js +31 -11
  91. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  92. package/dist/commands/snapshots/build/outcomes.js +200 -36
  93. package/dist/commands/snapshots/list/command.d.ts +368 -27
  94. package/dist/commands/snapshots/list/command.js +296 -66
  95. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  96. package/dist/commands/snapshots/list/metadata.js +29 -6
  97. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  98. package/dist/commands/snapshots/list/outcomes.js +221 -50
  99. package/dist/commands/snapshots/metadata.js +1 -1
  100. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  101. package/dist/commands/snapshots/prune/command.js +161 -0
  102. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  103. package/dist/commands/snapshots/prune/metadata.js +39 -0
  104. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  105. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  106. package/dist/commands/suites/list/command.js +19 -18
  107. package/dist/commands/suites/list/outcomes.js +4 -4
  108. package/dist/commands/test/command.d.ts +39 -4
  109. package/dist/commands/test/command.js +50 -255
  110. package/dist/commands/test/metadata.js +1 -1
  111. package/dist/commands/test/outcomes.d.ts +19 -2
  112. package/dist/commands/test/outcomes.js +2 -2
  113. package/dist/config/check-runner.d.ts +5 -3
  114. package/dist/config/check-runner.js +33 -7
  115. package/dist/config/check-suites.js +1 -0
  116. package/dist/config/credential-resolver.d.ts +50 -5
  117. package/dist/config/credential-resolver.js +51 -19
  118. package/dist/config/credential-settle.d.ts +6 -2
  119. package/dist/config/credential-settle.js +11 -5
  120. package/dist/config/gateways.d.ts +7 -3
  121. package/dist/config/index.d.ts +4 -5
  122. package/dist/config/index.js +3 -4
  123. package/dist/config/live/config-gateway.js +5 -2
  124. package/dist/config/load.d.ts +21 -4
  125. package/dist/config/load.js +129 -15
  126. package/dist/config/runner.d.ts +7 -8
  127. package/dist/config/runner.js +1 -1
  128. package/dist/config/schema.d.ts +17 -5
  129. package/dist/config/schema.js +11 -3
  130. package/dist/config/typed-options.d.ts +1 -6
  131. package/dist/config/typed-options.js +2 -10
  132. package/dist/config-file/define.d.ts +1 -11
  133. package/dist/config-file/define.js +3 -3
  134. package/dist/config-file/runner.d.ts +5 -6
  135. package/dist/config-file/toolchain.d.ts +13 -7
  136. package/dist/config-file/toolchain.js +53 -37
  137. package/dist/context.d.ts +8 -6
  138. package/dist/context.js +7 -6
  139. package/dist/core/across-sandboxes.d.ts +7 -6
  140. package/dist/core/across-sandboxes.js +123 -152
  141. package/dist/core/coordinator.d.ts +166 -0
  142. package/dist/core/coordinator.js +233 -0
  143. package/dist/core/events.d.ts +2 -2
  144. package/dist/core/index.d.ts +4 -2
  145. package/dist/core/index.js +1 -1
  146. package/dist/core/outcomes.d.ts +148 -0
  147. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  148. package/dist/core/resources.d.ts +31 -53
  149. package/dist/core/resources.js +32 -70
  150. package/dist/core/run-state.d.ts +7 -1
  151. package/dist/core/run-state.js +2 -0
  152. package/dist/core/run.d.ts +32 -236
  153. package/dist/core/run.js +106 -266
  154. package/dist/core/state-directory.d.ts +1 -1
  155. package/dist/core/state-directory.js +2 -2
  156. package/dist/credential/gateways.d.ts +15 -1
  157. package/dist/credential/index.d.ts +4 -3
  158. package/dist/credential/index.js +3 -2
  159. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  160. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  161. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  162. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  163. package/dist/credential/source.d.ts +73 -6
  164. package/dist/credential/source.js +55 -2
  165. package/dist/extension-commands.d.ts +6 -1
  166. package/dist/extension-commands.js +15 -1
  167. package/dist/extensions/github/resource.d.ts +1 -1
  168. package/dist/extensions/github/resource.js +1 -1
  169. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  170. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  171. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  172. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  173. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  174. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  175. package/dist/extensions/testserver/credential-facts.js +29 -11
  176. package/dist/extensions/testserver/lifecycle.js +7 -1
  177. package/dist/extensions/testserver/limit.d.ts +3 -0
  178. package/dist/extensions/testserver/limit.js +3 -0
  179. package/dist/extensions/testserver/provision.d.ts +8 -1
  180. package/dist/extensions/testserver/provision.js +8 -3
  181. package/dist/extensions/testserver/refusals.d.ts +6 -1
  182. package/dist/extensions/testserver/refusals.js +16 -1
  183. package/dist/extensions/testserver/resource.d.ts +2 -2
  184. package/dist/extensions/testserver/resource.js +2 -2
  185. package/dist/extensions/testserver/result.d.ts +1 -1
  186. package/dist/extensions/testserver/result.js +9 -4
  187. package/dist/planning/driver-file-lists.d.ts +0 -15
  188. package/dist/planning/driver-file-lists.js +2 -21
  189. package/dist/planning/plan-only.d.ts +7 -15
  190. package/dist/planning/plan-only.js +16 -22
  191. package/dist/planning/run-kind-flags.js +2 -2
  192. package/dist/planning/run-plan.d.ts +45 -13
  193. package/dist/planning/run-plan.js +4 -3
  194. package/dist/planning/suites.d.ts +1 -1
  195. package/dist/planning/suites.js +2 -2
  196. package/dist/planning/test-plan.d.ts +9 -0
  197. package/dist/planning/test-plan.js +10 -2
  198. package/dist/run-directory/recording.js +2 -2
  199. package/dist/run-directory/run-record.d.ts +21 -6
  200. package/dist/run-directory/run-record.js +12 -9
  201. package/dist/runner/base.d.ts +0 -6
  202. package/dist/runner/base.js +1 -16
  203. package/dist/runner/build-snapshots.d.ts +55 -29
  204. package/dist/runner/build-snapshots.js +135 -35
  205. package/dist/runner/context.d.ts +15 -7
  206. package/dist/runner/context.js +19 -6
  207. package/dist/runner/events.d.ts +16 -10
  208. package/dist/runner/gateways.d.ts +92 -21
  209. package/dist/runner/gateways.js +1 -1
  210. package/dist/runner/index.d.ts +11 -7
  211. package/dist/runner/index.js +9 -4
  212. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  213. package/dist/runner/live/sandbox-errors.js +4 -0
  214. package/dist/runner/live/sandbox-gateway.js +141 -3
  215. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  216. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  217. package/dist/runner/live/snapshot-records.js +6 -7
  218. package/dist/runner/local-snapshot-index.d.ts +199 -0
  219. package/dist/runner/local-snapshot-index.js +211 -0
  220. package/dist/runner/network-policy.d.ts +6 -6
  221. package/dist/runner/network-policy.js +7 -7
  222. package/dist/runner/policy-writes.d.ts +1 -1
  223. package/dist/runner/policy-writes.js +1 -1
  224. package/dist/runner/prepare.d.ts +25 -24
  225. package/dist/runner/prepare.js +28 -20
  226. package/dist/runner/ready.d.ts +18 -10
  227. package/dist/runner/ready.js +104 -33
  228. package/dist/runner/sandboxed-command.d.ts +3 -3
  229. package/dist/runner/sandboxed-command.js +3 -3
  230. package/dist/runner/scope.d.ts +10 -6
  231. package/dist/runner/scope.js +10 -3
  232. package/dist/runner/secrets.d.ts +13 -13
  233. package/dist/runner/secrets.js +18 -15
  234. package/dist/runner/session.d.ts +8 -8
  235. package/dist/runner/session.js +3 -3
  236. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  237. package/dist/runner/shared-snapshot-entry.js +168 -0
  238. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  239. package/dist/runner/shared-snapshot-list.js +155 -0
  240. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  241. package/dist/runner/shared-snapshot-lookup.js +118 -0
  242. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  243. package/dist/runner/shared-snapshot-prune.js +133 -0
  244. package/dist/runner/snapshot-build.d.ts +42 -14
  245. package/dist/runner/snapshot-build.js +38 -28
  246. package/dist/runner/snapshot-choice.js +1 -1
  247. package/dist/runner/snapshot-inspect.d.ts +39 -40
  248. package/dist/runner/snapshot-inspect.js +58 -38
  249. package/dist/runner/snapshot-key.d.ts +30 -21
  250. package/dist/runner/snapshot-key.js +49 -29
  251. package/dist/runner/steps.d.ts +1 -1
  252. package/dist/runner/steps.js +1 -1
  253. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  254. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  255. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +82 -82
  256. package/dist/runner/vercel-sandbox-options.js +510 -0
  257. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  258. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  259. package/dist/sdk/extension/commands.d.ts +8 -3
  260. package/dist/sdk/extension/commands.js +3 -1
  261. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  262. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  263. package/dist/sdk/extension/credential-source.d.ts +20 -3
  264. package/dist/sdk/extension/credential-source.js +4 -4
  265. package/dist/sdk/extension/index.d.ts +3 -2
  266. package/dist/sdk/extension/index.js +2 -1
  267. package/dist/sdk/extension/resource-definition.d.ts +4 -3
  268. package/dist/sdk/extension/resource-definition.js +3 -2
  269. package/dist/sdk/extension/resource-factory.js +3 -4
  270. package/dist/sdk/extension/secret-source.d.ts +1 -1
  271. package/dist/sdk/extension/secret-source.js +1 -1
  272. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  273. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  274. package/dist/sdk/run/present.d.ts +3 -3
  275. package/dist/sdk/run/present.js +1 -3
  276. package/dist/shared/cleanup.d.ts +3 -3
  277. package/dist/shared/cleanup.js +15 -5
  278. package/dist/shared/snapshot-text.d.ts +4 -4
  279. package/dist/shared/snapshot-text.js +11 -11
  280. package/dist/time/duration.js +1 -1
  281. package/package.json +3 -2
  282. package/skills/overview.md +6 -4
  283. package/skills/plan-runs.md +2 -2
  284. package/skills/read-run-output.md +6 -6
  285. package/dist/chunks/chunk-E4PJNZVG.js +0 -783
  286. package/dist/chunks/chunk-RAQEXKL6.js +0 -2591
  287. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  288. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  289. package/dist/commands/exec/plan-only.d.ts +0 -10
  290. package/dist/commands/exec/plan-only.js +0 -46
  291. package/dist/commands/exec/run-command.d.ts +0 -476
  292. package/dist/commands/exec/run-command.js +0 -604
  293. package/dist/commands/exec/run-planned.d.ts +0 -20
  294. package/dist/commands/exec/run-planned.js +0 -22
  295. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  296. package/dist/commands/exec/sandbox-view.js +0 -72
  297. package/dist/commands/test/plan.d.ts +0 -92
  298. package/dist/commands/test/plan.js +0 -128
  299. package/dist/config/recipe-run.d.ts +0 -33
  300. package/dist/config/recipe-run.js +0 -28
  301. package/dist/core/sandbox-end.d.ts +0 -64
  302. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  303. package/dist/runner/recipe.js +0 -425
  304. package/dist/runner/snapshot-cache.d.ts +0 -148
  305. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,41 +1,47 @@
1
+ import {
2
+ PROJECT_FIELDS,
3
+ SNAPSHOT_ACCESS_CLI,
4
+ SNAPSHOT_ACCESS_FIELDS,
5
+ settleSnapshotAccess
6
+ } from "../../../chunks/chunk-HP3CURSZ.js";
1
7
  import {
2
8
  suiteNotFoundErrors
3
- } from "../../../chunks/chunk-4U4DZ7VG.js";
9
+ } from "../../../chunks/chunk-7DZE67QM.js";
10
+ import {
11
+ lineProgress
12
+ } from "../../../chunks/chunk-MR77L2GK.js";
13
+ import "../../../chunks/chunk-I5GZLOLQ.js";
4
14
  import {
5
15
  RUN_CLEANUP,
6
- lineProgress,
7
16
  notDeletedText,
8
17
  notStoppedText,
9
18
  prepareRefusal,
10
19
  runErrors,
11
20
  runnerFailureFacts
12
- } from "../../../chunks/chunk-RAQEXKL6.js";
13
- import "../../../chunks/chunk-I5GZLOLQ.js";
14
- import "../../../chunks/chunk-5GBMR4HM.js";
15
- import "../../../chunks/chunk-PN5ULTTH.js";
16
- import "../../../chunks/chunk-R7XVBZOY.js";
17
- import "../../../chunks/chunk-CN4EFA5J.js";
21
+ } from "../../../chunks/chunk-2VP4GRJM.js";
18
22
  import {
19
23
  redactStrings,
20
24
  redactor
21
- } from "../../../chunks/chunk-CXAT7ZKP.js";
22
- import "../../../chunks/chunk-XEVHP5ZW.js";
23
- import "../../../chunks/chunk-VUPZH7J2.js";
24
- import "../../../chunks/chunk-ZG3WQ4UF.js";
25
- import "../../../chunks/chunk-5CCP36QQ.js";
25
+ } from "../../../chunks/chunk-FNBB6V4R.js";
26
+ import "../../../chunks/chunk-M7EKRGVD.js";
27
+ import "../../../chunks/chunk-F4MOYHRY.js";
28
+ import "../../../chunks/chunk-HWIQ2S7K.js";
29
+ import "../../../chunks/chunk-EEENLQHE.js";
30
+ import "../../../chunks/chunk-72ZFEMAW.js";
31
+ import "../../../chunks/chunk-D27KILIA.js";
32
+ import "../../../chunks/chunk-2RNDPDTJ.js";
26
33
  import {
27
34
  renderOutcome
28
- } from "../../../chunks/chunk-TJNFVNKR.js";
29
- import "../../../chunks/chunk-QUHY6FGN.js";
30
- import "../../../chunks/chunk-SZEURWRS.js";
35
+ } from "../../../chunks/chunk-LKTZ5OXS.js";
31
36
  import {
32
37
  seconds,
33
38
  short
34
- } from "../../../chunks/chunk-OX7X4B2L.js";
39
+ } from "../../../chunks/chunk-GRT3UIBV.js";
40
+ import "../../../chunks/chunk-4O5C2XGJ.js";
35
41
  import "../../../chunks/chunk-F6N34UWB.js";
36
42
  import {
37
43
  megabytesText
38
- } from "../../../chunks/chunk-YV7GE6EV.js";
44
+ } from "../../../chunks/chunk-YEPFSLQR.js";
39
45
  import {
40
46
  buildSnapshots,
41
47
  configErrors,
@@ -45,18 +51,17 @@ import {
45
51
  effectiveConfig,
46
52
  fileSettings,
47
53
  prepareSnapshotBuild,
48
- readCredentials,
49
- requireTarget
50
- } from "../../../chunks/chunk-L36GBUBB.js";
54
+ readCredentials
55
+ } from "../../../chunks/chunk-RNAS7JHE.js";
51
56
  import {
52
57
  SECRET_MIN_LENGTH
53
- } from "../../../chunks/chunk-AWBSONHB.js";
58
+ } from "../../../chunks/chunk-XBDRVFEV.js";
54
59
  import {
55
60
  stormCommands
56
- } from "../../../chunks/chunk-5VXBKPW6.js";
61
+ } from "../../../chunks/chunk-WV3DP6NR.js";
57
62
  import {
58
63
  defineOutcomes
59
- } from "../../../chunks/chunk-VL7WFTVQ.js";
64
+ } from "../../../chunks/chunk-4WAMTUWZ.js";
60
65
 
61
66
  // src/commands/snapshots/build/command.ts
62
67
  import { z as z2 } from "zod";
@@ -74,55 +79,162 @@ function snapshotOf(entry) {
74
79
  return { snapshotId: entry.snapshotId, base: entry.base, expiresAt: entry.expiresAt };
75
80
  }
76
81
  function snapshotText({ snapshotId, base }) {
77
- return `base snapshot ${snapshotId} at ${short(base)}`;
82
+ return `runner snapshot ${snapshotId} at ${short(base)}`;
78
83
  }
79
- var whereFields = {
80
- /** The config file that gave the runner recipe. */
81
- configFile: z.string().nullable(),
82
- recipe: z.string(),
83
- /** The team and project the credential was minted for: the sandboxes ran there, and the snapshots are theirs. */
84
- team: z.string(),
85
- project: z.string(),
86
- /** HEAD's commit, a full SHA. */
87
- head: z.string(),
84
+ var baseFields = {
88
85
  /** What it built at: HEAD's merge-base with `baseRef`, or with --base the commit the ref names, a full SHA. */
89
86
  base: z.string(),
90
87
  baseRef: z.string(),
91
88
  /** With --base, whether the working tree had uncommitted changes, which a base snapshot doesn't hold; else null. */
92
89
  uncommitted: z.boolean().nullable(),
90
+ /** With --base, whether the commit is HEAD's merge-base with a base ref; else null. */
91
+ atMergeBase: z.boolean().nullable(),
93
92
  /**
94
- * With --base, whether the commit is HEAD's merge-base with a base ref; else null. A run here starts only from a
95
- * snapshot at its merge-base.
93
+ * With --base, whether the commit is an ancestor of HEAD's merge-base, a commit behind it on the base ref (false at
94
+ * the merge-base itself); else null. A run here starts only from a snapshot at its merge-base or at such a commit.
96
95
  */
97
- atMergeBase: z.boolean().nullable()
96
+ ancestorOfMergeBase: z.boolean().nullable()
97
+ };
98
+ var whereFields = {
99
+ /** The config file that gave the Vercel Sandbox runner. */
100
+ configFile: z.string().nullable(),
101
+ runner: z.string(),
102
+ /** The Vercel project the sandboxes ran in, whose snapshots they are. */
103
+ ...PROJECT_FIELDS,
104
+ /** HEAD's commit, a full SHA. */
105
+ head: z.string(),
106
+ ...baseFields
98
107
  };
99
108
  var builtSchema = z.object({
100
109
  ...whereFields,
101
- /** The base snapshot it built and cached. */
110
+ /** The runner snapshot it built and indexed. */
102
111
  snapshot: snapshotSchema,
103
112
  /** How long the build took, and the snapshot's size. */
104
113
  ms: z.number(),
105
114
  sizeBytes: z.number(),
115
+ /**
116
+ * With --publish, the stopped sandbox that holds the runner snapshot as the shared snapshot index entry; null without
117
+ * --publish.
118
+ */
119
+ sandboxName: z.string().nullable(),
120
+ /**
121
+ * Whether the local snapshot index on this machine recorded the snapshot. Only --publish ends `built` without it,
122
+ * since a run finds the snapshot in the shared snapshot index.
123
+ */
124
+ localIndexWritten: z.boolean(),
106
125
  /** What the build couldn't clean up. */
107
126
  cleanup: RUN_CLEANUP.schema
108
127
  });
109
128
  var upToDateSchema = z.object({
110
129
  ...whereFields,
111
- /** The base snapshot the cache holds at that commit for the team and project. */
112
- snapshot: snapshotSchema
130
+ /** The runner snapshot the local snapshot index holds, or with --publish the shared snapshot index holds, at that commit. */
131
+ snapshot: snapshotSchema,
132
+ /** With --publish, the stopped sandbox that holds it as the shared snapshot index entry; null without --publish. */
133
+ sandboxName: z.string().nullable()
134
+ });
135
+ var alreadyBuildingSchema = z.object({
136
+ ...whereFields,
137
+ /** The shared snapshot index entry's sandbox, which another build owns. */
138
+ sandboxName: z.string(),
139
+ /** Its status, such as `running` or `snapshotting`; null when another build took the name as this one started. */
140
+ status: z.string().nullable()
141
+ });
142
+ var runnerBuildCommon = {
143
+ runner: z.string(),
144
+ region: z.string(),
145
+ runtime: z.string(),
146
+ /** Whether the top-level runner uses this runner configuration. */
147
+ topLevel: z.boolean(),
148
+ /** The suites whose effective runner uses this runner configuration, in declaration order. */
149
+ suites: z.array(z.string()),
150
+ ...baseFields
151
+ };
152
+ var runnerBuildSchema = z.discriminatedUnion("result", [
153
+ z.object({
154
+ ...runnerBuildCommon,
155
+ result: z.literal("built"),
156
+ /** The runner snapshot it built. */
157
+ snapshot: snapshotSchema,
158
+ /** With --publish, the shared snapshot index entry's sandbox; null without --publish. */
159
+ sandboxName: z.string().nullable(),
160
+ /** How long the build took, in milliseconds. */
161
+ ms: z.number(),
162
+ /** The snapshot's size, in bytes. */
163
+ sizeBytes: z.number(),
164
+ /** Whether the local snapshot index on this machine recorded the snapshot. */
165
+ localIndexWritten: z.boolean()
166
+ }),
167
+ z.object({
168
+ ...runnerBuildCommon,
169
+ result: z.literal("up_to_date"),
170
+ /** The runner snapshot it found. */
171
+ snapshot: snapshotSchema,
172
+ /** With --publish, the shared snapshot index entry's sandbox; null without --publish. */
173
+ sandboxName: z.string().nullable()
174
+ }),
175
+ z.object({
176
+ ...runnerBuildCommon,
177
+ result: z.literal("already_building"),
178
+ /** The shared snapshot index entry's sandbox, which another build owns. */
179
+ sandboxName: z.string(),
180
+ /** Its status, such as `running` or `snapshotting`; null when another build took the name as this one started. */
181
+ status: z.string().nullable()
182
+ })
183
+ ]);
184
+ var allSuitesBuiltSchema = z.object({
185
+ configFile: z.string().nullable(),
186
+ /** The Vercel project the sandboxes ran in, whose snapshots they are. */
187
+ ...PROJECT_FIELDS,
188
+ /** HEAD's commit, a full SHA. */
189
+ head: z.string(),
190
+ /** Each distinct runner, in the order the config file first declares it, and how its build ended. */
191
+ runners: z.array(runnerBuildSchema),
192
+ /** What the builds couldn't clean up. */
193
+ cleanup: RUN_CLEANUP.schema
113
194
  });
195
+ function statusText(status) {
196
+ return status === null ? "another build took its name first" : `status ${status}`;
197
+ }
198
+ function alreadyBuildingText(facts) {
199
+ return `Sandbox ${facts.sandboxName} is already building this runner snapshot (${statusText(facts.status)}), so nothing started.`;
200
+ }
201
+ function upToDateText(facts) {
202
+ return facts.sandboxName === null ? `The local snapshot index holds ${snapshotText(facts.snapshot)} for this team and project. --full builds a new one.` : `The shared snapshot index holds ${snapshotText(facts.snapshot)} for this team and project. --full builds a new one.`;
203
+ }
204
+ function builtText(facts) {
205
+ const published = facts.sandboxName === null ? "" : ", and published it to the shared snapshot index";
206
+ return `Built ${snapshotText(facts.snapshot)} in ${seconds(facts.ms)} (${megabytesText(facts.sizeBytes)})${published}.`;
207
+ }
208
+ function usedByText(facts) {
209
+ return [...facts.topLevel ? ["the top level"] : [], ...facts.suites.map((suite) => `suite ${suite}`)].join(", ");
210
+ }
211
+ function runnerBuildText(facts) {
212
+ const where = `${facts.runner} (${usedByText(facts)})`;
213
+ switch (facts.result) {
214
+ case "already_building":
215
+ return `${where}: ${alreadyBuildingText(facts)}`;
216
+ case "up_to_date":
217
+ return `${where}: ${upToDateText(facts)}`;
218
+ case "built":
219
+ return `${where}: ${builtText(facts)}`;
220
+ }
221
+ }
222
+ var LOCAL_INDEX_NOT_WRITTEN = {
223
+ reason: "local_index_not_written",
224
+ message: "The local snapshot index couldn't record the snapshot; a run here finds it in the shared snapshot index instead."
225
+ };
114
226
  function warningsOf(facts) {
115
227
  return [
116
228
  ...facts.uncommitted === true ? [
117
229
  {
118
230
  reason: "uncommitted_changes_not_included",
119
- message: "The working tree has uncommitted changes: a base snapshot holds only the commit's tracked files."
231
+ message: "The working tree has uncommitted changes: a runner snapshot holds only the commit's tracked files."
120
232
  }
121
233
  ] : [],
122
- ...facts.atMergeBase === false ? [
234
+ ...facts.atMergeBase === false && facts.ancestorOfMergeBase === false ? [
123
235
  {
124
- reason: "commit_not_merge_base",
125
- message: `${facts.baseRef}'s commit is not HEAD's merge-base, so a run here doesn't start from the snapshot: a run starts only from a snapshot at its merge-base.`
236
+ reason: "commit_not_merge_base_or_ancestor",
237
+ message: `${facts.baseRef}'s commit is neither HEAD's merge-base nor an ancestor of it, so a run here doesn't start from the snapshot: a run starts only from a snapshot at its merge-base or at a commit behind it on the base ref.`
126
238
  }
127
239
  ] : []
128
240
  ];
@@ -131,30 +243,77 @@ var outcomes = defineOutcomes({
131
243
  results: {
132
244
  built: {
133
245
  schema: builtSchema,
134
- description: "It built a base snapshot that the cache lacked, at the merge-base or, with --base, at the commit the ref names, and cached it.",
246
+ description: "It built a runner snapshot that the local snapshot index lacked, at the merge-base or, with --base, at the commit the ref names, and indexed it.",
135
247
  render: (built) => {
136
- const warnings = warningsOf(built);
248
+ const warnings = [...warningsOf(built), ...built.localIndexWritten ? [] : [LOCAL_INDEX_NOT_WRITTEN]];
137
249
  return renderOutcome({
138
- rows: [["Recipe", built.recipe], ...RUN_CLEANUP.rows(built.cleanup)],
139
- message: `Built ${snapshotText(built.snapshot)} in ${seconds(built.ms)} (${megabytesText(built.sizeBytes)}).`,
250
+ rows: [["Runner", built.runner], ...RUN_CLEANUP.rows(built.cleanup)],
251
+ message: builtText(built),
140
252
  ...warnings.length === 0 ? {} : { warnings }
141
253
  });
142
254
  }
143
255
  },
144
256
  upToDate: {
145
257
  schema: upToDateSchema,
146
- description: "Nothing to build, so nothing started: the cache holds a base snapshot at the commit, the merge-base or the one --base names, for the team and project.",
258
+ description: "Nothing to build, so nothing started: the local snapshot index holds a runner snapshot at the commit, the merge-base or the one --base names, for the team and project. With --publish, the shared snapshot index holds it instead, and the local snapshot index now records it too.",
147
259
  render: (facts) => {
148
260
  const warnings = warningsOf(facts);
149
261
  return renderOutcome({
150
- rows: [["Recipe", facts.recipe]],
151
- message: `The cache holds ${snapshotText(facts.snapshot)} for this team and project. --full builds a new one.`,
262
+ rows: [["Runner", facts.runner]],
263
+ message: upToDateText(facts),
264
+ ...warnings.length === 0 ? {} : { warnings }
265
+ });
266
+ }
267
+ },
268
+ alreadyBuilding: {
269
+ schema: alreadyBuildingSchema,
270
+ description: "With --publish, another build already owns the shared snapshot index entry's sandbox for the commit, so nothing started.",
271
+ render: (facts) => {
272
+ const warnings = warningsOf(facts);
273
+ return renderOutcome({
274
+ rows: [
275
+ ["Runner", facts.runner],
276
+ ["Sandbox", facts.sandboxName]
277
+ ],
278
+ message: alreadyBuildingText(facts),
279
+ ...warnings.length === 0 ? {} : { warnings }
280
+ });
281
+ }
282
+ },
283
+ allSuitesBuilt: {
284
+ schema: allSuitesBuiltSchema,
285
+ description: "With --all-suites, it built or checked the runner snapshot of each distinct vercelSandbox({ \u2026 }) runner that the top level and the suites use.",
286
+ render: (facts) => {
287
+ const warnings = [
288
+ ...new Map(
289
+ facts.runners.flatMap(warningsOf).map((warning) => [`${warning.reason}\0${warning.message}`, warning])
290
+ ).values(),
291
+ ...facts.runners.some((runner) => runner.result === "built" && !runner.localIndexWritten) ? [LOCAL_INDEX_NOT_WRITTEN] : []
292
+ ];
293
+ return renderOutcome({
294
+ rows: [["Runners", facts.runners.map(runnerBuildText)], ...RUN_CLEANUP.rows(facts.cleanup)],
295
+ message: `Built or checked ${facts.runners.length === 1 ? "1 runner" : `${facts.runners.length} runners`}.`,
152
296
  ...warnings.length === 0 ? {} : { warnings }
153
297
  });
154
298
  }
155
299
  }
156
300
  },
157
301
  errors: {
302
+ conflictingOptions: {
303
+ exitCode: 2,
304
+ description: "--suite and --all-suites were both given: --suite builds one runner, and --all-suites builds them all.",
305
+ schema: z.object({
306
+ /** Each conflicting flag, as typed, and why it doesn't fit. */
307
+ conflicts: z.array(z.object({ flag: z.string(), message: z.string() }))
308
+ }),
309
+ render: ({
310
+ conflicts
311
+ }) => ({
312
+ message: conflicts.map(({ message }) => message).join(" "),
313
+ rows: [["Conflicts", conflicts.map(({ flag }) => flag)]],
314
+ next: [{ type: "text", text: "Pass --suite <name> or --all-suites, not both." }]
315
+ })
316
+ },
158
317
  invalidConfig: configErrors.invalidConfig,
159
318
  ...suiteNotFoundErrors,
160
319
  missingRunner: runErrors.missingRunner,
@@ -181,8 +340,7 @@ var outcomes = defineOutcomes({
181
340
  credentialsInvalid: runErrors.credentialsInvalid,
182
341
  noBaseRef: runErrors.noBaseRef,
183
342
  submodulesRefused: runErrors.submodulesRefused,
184
- mintFailed: credentialSourceErrors.mintFailed,
185
- tokenRequestFailed: credentialSourceErrors.tokenRequestFailed,
343
+ ...credentialSourceErrors,
186
344
  runnerFailed: runErrors.runnerFailed,
187
345
  refNotFound: {
188
346
  exitCode: 1,
@@ -196,20 +354,20 @@ var outcomes = defineOutcomes({
196
354
  next: [{ type: "text", text: `Fetch the ref, such as git fetch origin, then run again.` }]
197
355
  })
198
356
  },
199
- snapshotNotCached: {
357
+ snapshotNotIndexed: {
200
358
  exitCode: 1,
201
- description: "It built and saved the base snapshot, but couldn't write its cache entry, so no run finds it.",
359
+ description: "It built and saved the runner snapshot, but couldn't write its local snapshot index entry, so no run finds it.",
202
360
  schema: z.object({
203
- /** The snapshot it saved, whose cache entry it couldn't write. */
361
+ /** The snapshot it saved, whose local snapshot index entry it couldn't write. */
204
362
  snapshot: snapshotSchema,
205
- /** The cache file the write failed on. */
363
+ /** The local snapshot index file the write failed on. */
206
364
  path: z.string(),
207
365
  /** What the operating system said. */
208
366
  message: z.string(),
209
367
  cleanup: RUN_CLEANUP.schema
210
368
  }),
211
369
  render: (facts) => ({
212
- message: `Saved ${snapshotText(facts.snapshot)}, but couldn't write its cache entry: ${facts.message}`,
370
+ message: `Saved ${snapshotText(facts.snapshot)}, but couldn't write its local snapshot index entry: ${facts.message}`,
213
371
  rows: [["Path", facts.path], ...RUN_CLEANUP.rows(facts.cleanup)],
214
372
  next: [
215
373
  {
@@ -226,120 +384,258 @@ var outcomes = defineOutcomes({
226
384
  var command_default = stormCommands.define({
227
385
  requestSchema: z2.object({
228
386
  suite: z2.string().min(1).optional(),
387
+ allSuites: z2.boolean().default(false),
229
388
  full: z2.boolean().default(false),
389
+ publish: z2.boolean().default(false),
230
390
  base: z2.string().min(1).optional(),
231
- scope: z2.string().min(1).optional(),
232
- project: z2.string().min(1).optional()
391
+ ...SNAPSHOT_ACCESS_FIELDS
233
392
  }),
234
- cli: { options: { project: { short: "p" } } },
393
+ cli: SNAPSHOT_ACCESS_CLI,
235
394
  response: outcomes,
236
395
  handler: async ({ app, ui, signal }, request) => {
396
+ if (request.suite !== void 0 && request.allSuites)
397
+ return outcomes.conflictingOptions({
398
+ conflicts: [
399
+ { flag: "--suite", message: "--suite builds the one runner a suite uses," },
400
+ { flag: "--all-suites", message: "and --all-suites builds every runner storm.config.ts declares." }
401
+ ]
402
+ });
237
403
  const file = await app.config.loadFile();
238
404
  if (!file.ok) return file.refusal;
239
405
  const configFile = file.path;
240
- if (request.suite !== void 0) {
241
- const suites = Object.keys(file.values?.suites ?? {});
242
- if (file.values === void 0 || !Object.hasOwn(file.values.suites, request.suite)) {
243
- return outcomes.suiteNotFound({ suite: request.suite, suites, configFile });
406
+ const resolved = resolveBuildTargets(file, request);
407
+ if (!resolved.ok) return resolved.refusal;
408
+ const chosen = settleSnapshotAccess(app, request.credential, resolved.settings, ui.progress);
409
+ if (!chosen.ok) return chosen.refusal;
410
+ const redact = redactor(resolved.targets.flatMap(({ options }) => declaredSecretValues(options, app.env)));
411
+ const planning = await planBuilds(app, request, resolved.targets, { configFile, redact });
412
+ if (!planning.ok) return planning.refusal;
413
+ const { builds } = planning;
414
+ const progress = buildProgress(app, ui.progress, (line) => redactStrings(line, redact));
415
+ const single = request.allSuites ? void 0 : builds[0].build;
416
+ if (single !== void 0 && single.ref === null && single.mergeBase !== null)
417
+ await progress.prepared({ base: single.mergeBase.commit, baseRef: single.mergeBase.ref });
418
+ if (signal.aborted) return outcomes.canceled({ changed: "Nothing was built.\nNothing was minted or started." });
419
+ const obtained = await chosen.settled.obtain();
420
+ if (!obtained.ok) return obtained.refusal;
421
+ const { access, target, teamId, projectId, team, project } = obtained;
422
+ const results = [];
423
+ const cleanups = [];
424
+ const cleanupFacts = () => RUN_CLEANUP.facts({ runnerCleanup: { ...mergedCleanup(cleanups), target }, resourceCleanup: {} });
425
+ for (const planned of builds) {
426
+ const { build, credentials } = planned;
427
+ const ended = await buildSnapshots(
428
+ app.context,
429
+ { build, access, user: app.user, credentials, publish: request.publish },
430
+ { signal },
431
+ request.allSuites ? labeledProgress(planned, progress, (line) => ui.progress?.(redact(line))) : progress
432
+ );
433
+ const outcome = redactStrings(ended, redact);
434
+ cleanups.push(outcome.cleanup);
435
+ switch (outcome.kind) {
436
+ case "not-indexed":
437
+ return outcomes.snapshotNotIndexed({
438
+ snapshot: snapshotOf(outcome.snapshot),
439
+ path: outcome.failure.path,
440
+ message: outcome.failure.message,
441
+ cleanup: cleanupFacts()
442
+ });
443
+ case "failed":
444
+ return runErrors.runnerFailed({ failure: runnerFailureFacts(outcome.failure), cleanup: cleanupFacts() });
445
+ case "aborted":
446
+ return outcomes.canceled({ changed: abortedChanges(outcome, cleanupFacts().runner) });
447
+ case "up-to-date":
448
+ case "built":
449
+ case "already-building":
450
+ results.push(runnerBuildFacts(outcome, planned));
244
451
  }
245
452
  }
246
- const effective = effectiveConfig(file, request.suite ?? null);
247
- const settings = fileSettings(effective, request);
248
- const runner = settings.runner?.value;
249
- if (runner === void 0) return runErrors.missingRunner({ configFile });
250
- if (runner.kind === "launch-machine") {
251
- return outcomes.launchMachineHasNoSnapshot({ suite: request.suite ?? null, configFile });
252
- }
253
- const { recipe } = runner;
254
- const required = requireTarget(settings.scope, settings.project);
255
- if (!required.ok) return required.refusal;
256
- const { target } = required;
257
- const chosen = app.credentials.source(
258
- "mint",
259
- { scope: settings.scope, project: settings.project },
260
- { progress: ui.progress }
261
- );
262
- if (!chosen.ok) return chosen.refusal;
263
- const credentials = readCredentials(recipe, app.env);
453
+ const where = { configFile, teamId, projectId, team, project, head: builds[0].build.head.commit };
454
+ return single === void 0 ? outcomes.allSuitesBuilt({ ...where, runners: results, cleanup: cleanupFacts() }) : singleResult(results[0], where, cleanupFacts());
455
+ }
456
+ });
457
+ async function planBuilds(app, request, targets, words) {
458
+ const { configFile, redact } = words;
459
+ const credentialsByRunner = /* @__PURE__ */ new Map();
460
+ for (const { options } of targets) {
461
+ if (credentialsByRunner.has(options)) continue;
462
+ const credentials = readCredentials(options, app.env);
264
463
  if (!credentials.ok)
265
- return runErrors.credentialsInvalid({
266
- variables: credentials.variables.map(({ name, problem }) => ({ name, problem })),
267
- minLength: SECRET_MIN_LENGTH,
268
- configFile
464
+ return {
465
+ ok: false,
466
+ refusal: runErrors.credentialsInvalid({
467
+ variables: credentials.variables.map(({ name, problem }) => ({ name, problem })),
468
+ minLength: SECRET_MIN_LENGTH,
469
+ configFile
470
+ })
471
+ };
472
+ credentialsByRunner.set(options, credentials.credentials);
473
+ }
474
+ const preparedByRunner = /* @__PURE__ */ new Map();
475
+ const builds = [];
476
+ for (const { suite, options } of targets) {
477
+ let build = preparedByRunner.get(options);
478
+ if (build === void 0) {
479
+ const prepared = await prepareSnapshotBuild(app.context, {
480
+ cwd: app.cwd,
481
+ options,
482
+ ref: request.base,
483
+ full: request.full
269
484
  });
270
- const redact = redactor(declaredSecretValues(recipe, app.env));
271
- const prepared = await prepareSnapshotBuild(app.context, {
272
- cwd: app.cwd,
273
- recipe,
274
- ref: request.base,
275
- full: request.full
276
- });
277
- if (prepared.kind === "ref-not-found") return outcomes.refNotFound({ ref: prepared.ref });
278
- if (prepared.kind !== "ok") return redactStrings(prepareRefusal(prepared, configFile), redact);
279
- const { build } = prepared;
280
- const progress = buildProgress(app, ui.progress, (line) => redactStrings(line, redact));
281
- if (build.ref === null && build.mergeBase !== null)
282
- await progress.prepared({ base: build.mergeBase.commit, baseRef: build.mergeBase.ref });
283
- if (signal.aborted) return outcomes.canceled({ changed: "Nothing was built.\nNothing was minted or started." });
284
- const got = await chosen.source.obtain();
285
- if (!got.ok) return got.refusal;
286
- const owner = got.credential.vercelProject();
287
- if (owner === void 0)
288
- return runErrors.runnerFailed({
289
- failure: runnerFailureFacts({ kind: "credential-claims-missing", target }),
290
- cleanup: RUN_CLEANUP.facts({ runnerCleanup: null, resourceCleanup: {} })
485
+ if (prepared.kind === "ref-not-found") return { ok: false, refusal: outcomes.refNotFound({ ref: prepared.ref }) };
486
+ if (prepared.kind !== "ok")
487
+ return { ok: false, refusal: redactStrings(prepareRefusal(prepared, configFile), redact) };
488
+ build = prepared.build;
489
+ preparedByRunner.set(options, build);
490
+ }
491
+ const { plan } = build;
492
+ let same = builds.find(
493
+ ({ build: { plan: seen } }) => seen.options.name === plan.options.name && seen.options.region === plan.options.region && seen.options.runtime === plan.options.runtime && seen.snapshotKey === plan.snapshotKey
494
+ );
495
+ if (same === void 0) {
496
+ same = { build, credentials: credentialsByRunner.get(options) ?? [], topLevel: false, suites: [] };
497
+ builds.push(same);
498
+ }
499
+ if (suite === null) same.topLevel = true;
500
+ else same.suites.push(suite);
501
+ }
502
+ return { ok: true, builds };
503
+ }
504
+ function labeledProgress(planned, progress, heading) {
505
+ const { build } = planned;
506
+ let labeled = false;
507
+ return {
508
+ emit: async (event) => {
509
+ if (!labeled) {
510
+ labeled = true;
511
+ await heading(`Runner ${build.plan.options.name} (${usedByText(planned)}):`);
512
+ if (build.ref === null && build.mergeBase !== null)
513
+ await progress.prepared({ base: build.mergeBase.commit, baseRef: build.mergeBase.ref });
514
+ }
515
+ await progress.emit(event);
516
+ }
517
+ };
518
+ }
519
+ function runnerBuildFacts(outcome, planned) {
520
+ const { build, topLevel, suites } = planned;
521
+ const { options } = build.plan;
522
+ const facts = {
523
+ runner: options.name,
524
+ region: options.region,
525
+ runtime: options.runtime,
526
+ topLevel,
527
+ suites: [...suites],
528
+ base: build.plan.base,
529
+ baseRef: build.ref ?? build.mergeBase?.ref ?? build.plan.base,
530
+ ...build.ref === null ? { uncommitted: null, atMergeBase: null, ancestorOfMergeBase: null } : {
531
+ uncommitted: build.head.dirty,
532
+ atMergeBase: build.atMergeBase,
533
+ ancestorOfMergeBase: build.ancestorOfMergeBase
534
+ }
535
+ };
536
+ switch (outcome.kind) {
537
+ case "up-to-date":
538
+ return {
539
+ ...facts,
540
+ result: "up_to_date",
541
+ snapshot: snapshotOf(outcome.snapshot),
542
+ sandboxName: outcome.sandboxName ?? null
543
+ };
544
+ case "built":
545
+ return {
546
+ ...facts,
547
+ result: "built",
548
+ snapshot: snapshotOf(outcome.snapshot),
549
+ sandboxName: outcome.sandboxName ?? null,
550
+ ms: outcome.ms,
551
+ sizeBytes: outcome.sizeBytes,
552
+ localIndexWritten: outcome.localIndexFailure === void 0
553
+ };
554
+ case "already-building":
555
+ return { ...facts, result: "already_building", sandboxName: outcome.sandboxName, status: outcome.status };
556
+ }
557
+ }
558
+ function singleResult(facts, where, cleanup) {
559
+ const common = {
560
+ ...where,
561
+ runner: facts.runner,
562
+ base: facts.base,
563
+ baseRef: facts.baseRef,
564
+ uncommitted: facts.uncommitted,
565
+ atMergeBase: facts.atMergeBase,
566
+ ancestorOfMergeBase: facts.ancestorOfMergeBase
567
+ };
568
+ switch (facts.result) {
569
+ case "up_to_date":
570
+ return outcomes.upToDate({ ...common, snapshot: facts.snapshot, sandboxName: facts.sandboxName });
571
+ case "built":
572
+ return outcomes.built({
573
+ ...common,
574
+ snapshot: facts.snapshot,
575
+ ms: facts.ms,
576
+ sizeBytes: facts.sizeBytes,
577
+ sandboxName: facts.sandboxName,
578
+ localIndexWritten: facts.localIndexWritten,
579
+ cleanup
291
580
  });
292
- const ended = await buildSnapshots(
293
- app.context,
294
- { build, access: { credential: got.credential, ...owner }, user: app.user, credentials: credentials.credentials },
295
- { signal },
296
- progress
581
+ case "already_building":
582
+ return outcomes.alreadyBuilding({ ...common, sandboxName: facts.sandboxName, status: facts.status });
583
+ }
584
+ }
585
+ function resolveBuildTargets(file, request) {
586
+ const configFile = file.path;
587
+ if (request.allSuites) {
588
+ const settings2 = fileSettings(file, request);
589
+ const runners = [
590
+ { suite: null, runner: settings2.runner?.value },
591
+ ...Object.keys(file.values?.suites ?? {}).map((suite) => ({
592
+ suite,
593
+ runner: fileSettings(effectiveConfig(file, suite), request).runner?.value
594
+ }))
595
+ ];
596
+ const targets = runners.flatMap(
597
+ ({ suite, runner: runner2 }) => runner2?.kind === "vercel-sandbox" ? [{ suite, options: runner2.options }] : []
297
598
  );
298
- const outcome = redactStrings(ended, redact);
299
- const cleanup = RUN_CLEANUP.facts({ runnerCleanup: { ...outcome.cleanup, target }, resourceCleanup: {} });
300
- const where = {
301
- configFile,
302
- recipe: recipe.name,
303
- team: target.team,
304
- project: target.project,
305
- head: build.head.commit,
306
- base: build.plan.base,
307
- baseRef: build.ref ?? build.mergeBase?.ref ?? build.plan.base,
308
- // What a --base build checked of its commit, for its warnings; null for a build at the merge-base.
309
- ...build.ref === null ? { uncommitted: null, atMergeBase: null } : { uncommitted: build.head.dirty, atMergeBase: build.atMergeBase }
310
- };
311
- switch (outcome.kind) {
312
- case "up-to-date":
313
- return outcomes.upToDate({ ...where, snapshot: snapshotOf(outcome.snapshot) });
314
- case "built":
315
- return outcomes.built({
316
- ...where,
317
- snapshot: snapshotOf(outcome.snapshot),
318
- ms: outcome.ms,
319
- sizeBytes: outcome.sizeBytes,
320
- cleanup
321
- });
322
- case "not-cached":
323
- return outcomes.snapshotNotCached({
324
- snapshot: snapshotOf(outcome.snapshot),
325
- path: outcome.failure.path,
326
- message: outcome.failure.message,
327
- cleanup
328
- });
329
- case "failed":
330
- return runErrors.runnerFailed({ failure: runnerFailureFacts(outcome.failure), cleanup });
331
- case "aborted":
332
- return outcomes.canceled({ changed: abortedChanges(outcome, cleanup.runner) });
599
+ if (targets.length === 0)
600
+ return {
601
+ ok: false,
602
+ refusal: runners.some(({ runner: runner2 }) => runner2 !== void 0) ? outcomes.launchMachineHasNoSnapshot({ suite: null, configFile }) : runErrors.missingRunner({ configFile })
603
+ };
604
+ return { ok: true, settings: settings2, targets };
605
+ }
606
+ if (request.suite !== void 0) {
607
+ const suites = Object.keys(file.values?.suites ?? {});
608
+ if (file.values === void 0 || !Object.hasOwn(file.values.suites, request.suite)) {
609
+ return { ok: false, refusal: outcomes.suiteNotFound({ suite: request.suite, suites, configFile }) };
333
610
  }
334
611
  }
335
- });
612
+ const effective = effectiveConfig(file, request.suite ?? null);
613
+ const settings = fileSettings(effective, request);
614
+ const runner = settings.runner?.value;
615
+ if (runner === void 0) return { ok: false, refusal: runErrors.missingRunner({ configFile }) };
616
+ if (runner.kind === "launch-machine") {
617
+ return {
618
+ ok: false,
619
+ refusal: outcomes.launchMachineHasNoSnapshot({ suite: request.suite ?? null, configFile })
620
+ };
621
+ }
622
+ return { ok: true, settings, targets: [{ suite: request.suite ?? null, options: runner.options }] };
623
+ }
624
+ function mergedCleanup(cleanups) {
625
+ return {
626
+ kept: null,
627
+ notKept: null,
628
+ notStopped: cleanups.flatMap(({ notStopped }) => notStopped),
629
+ notDeleted: cleanups.flatMap(({ notDeleted }) => notDeleted)
630
+ };
631
+ }
336
632
  function abortedChanges(outcome, runner) {
337
633
  const { snapshot } = outcome;
338
634
  const problems = runner === null ? [] : [...runner.notStopped.map(notStoppedText), ...runner.notDeleted.map(notDeletedText)];
339
635
  return [
340
636
  "The build stopped.",
341
637
  ...snapshot === null ? [] : [
342
- snapshot.cached ? `It saved and cached ${snapshotText(snapshotOf(snapshot.entry))} first.` : `It saved ${snapshotText(snapshotOf(snapshot.entry))} first, but couldn't write its cache entry, so no run finds it.`
638
+ snapshot.indexed ? `It saved and indexed ${snapshotText(snapshotOf(snapshot.entry))} first.` : `It saved ${snapshotText(snapshotOf(snapshot.entry))} first, but couldn't write its local snapshot index entry, so no run finds it.`
343
639
  ],
344
640
  ...problems.length === 0 ? ["Every sandbox it started is stopped and deleted."] : problems
345
641
  ].join("\n");