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