@cnc-tools/storm 0.16.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 (281) 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-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
  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-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-DWEAHX4T.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-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
  29. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
  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-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-WECQOQ4C.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 +2 -2
  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 +31 -2
  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 +34 -8
  51. package/dist/commands/exec/outcomes.js +30 -23
  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/progress.d.ts +10 -6
  55. package/dist/commands/exec/progress.js +38 -25
  56. package/dist/commands/exec/run-bin.d.ts +11 -11
  57. package/dist/commands/exec/run-bin.js +9 -9
  58. package/dist/commands/exec/run-flags.d.ts +69 -0
  59. package/dist/commands/exec/run-flags.js +58 -0
  60. package/dist/commands/exec/run-metadata.js +4 -4
  61. package/dist/commands/exec/run-summary.d.ts +58 -0
  62. package/dist/commands/exec/run-summary.js +205 -0
  63. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  64. package/dist/commands/exec/runner-refusals.js +71 -0
  65. package/dist/commands/exec/sandbox-progress.js +3 -0
  66. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  67. package/dist/commands/exec/stopped-outcome.js +77 -0
  68. package/dist/commands/exec/view.d.ts +20 -11
  69. package/dist/commands/exec/view.js +103 -47
  70. package/dist/commands/runs/facts.d.ts +7 -3
  71. package/dist/commands/runs/facts.js +17 -8
  72. package/dist/commands/runs/list/command.d.ts +14 -6
  73. package/dist/commands/runs/list/command.js +10 -10
  74. package/dist/commands/runs/list/outcomes.d.ts +7 -3
  75. package/dist/commands/runs/logs/command.js +10 -10
  76. package/dist/commands/runs/show/command.d.ts +14 -6
  77. package/dist/commands/runs/show/command.js +30 -28
  78. package/dist/commands/runs/show/outcomes.d.ts +7 -3
  79. package/dist/commands/runs/show/outcomes.js +7 -5
  80. package/dist/commands/snapshots/access.d.ts +111 -0
  81. package/dist/commands/snapshots/access.js +96 -0
  82. package/dist/commands/snapshots/build/command.d.ts +360 -93
  83. package/dist/commands/snapshots/build/command.js +446 -150
  84. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  85. package/dist/commands/snapshots/build/metadata.js +31 -11
  86. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  87. package/dist/commands/snapshots/build/outcomes.js +200 -36
  88. package/dist/commands/snapshots/list/command.d.ts +366 -25
  89. package/dist/commands/snapshots/list/command.js +296 -66
  90. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  91. package/dist/commands/snapshots/list/metadata.js +29 -6
  92. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  93. package/dist/commands/snapshots/list/outcomes.js +221 -50
  94. package/dist/commands/snapshots/metadata.js +1 -1
  95. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  96. package/dist/commands/snapshots/prune/command.js +161 -0
  97. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  98. package/dist/commands/snapshots/prune/metadata.js +39 -0
  99. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  100. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  101. package/dist/commands/suites/list/command.js +17 -17
  102. package/dist/commands/suites/list/outcomes.js +2 -2
  103. package/dist/commands/test/command.d.ts +31 -2
  104. package/dist/commands/test/command.js +49 -252
  105. package/dist/commands/test/outcomes.d.ts +15 -1
  106. package/dist/config/check-runner.d.ts +3 -3
  107. package/dist/config/check-runner.js +8 -7
  108. package/dist/config/credential-resolver.d.ts +50 -5
  109. package/dist/config/credential-resolver.js +51 -19
  110. package/dist/config/credential-settle.d.ts +6 -2
  111. package/dist/config/credential-settle.js +11 -5
  112. package/dist/config/index.d.ts +2 -2
  113. package/dist/config/index.js +1 -1
  114. package/dist/config/runner.d.ts +5 -5
  115. package/dist/config/runner.js +1 -1
  116. package/dist/config/schema.d.ts +2 -2
  117. package/dist/config/schema.js +1 -1
  118. package/dist/config-file/define.d.ts +1 -1
  119. package/dist/config-file/define.js +1 -1
  120. package/dist/config-file/runner.d.ts +5 -5
  121. package/dist/config-file/toolchain.d.ts +1 -1
  122. package/dist/config-file/toolchain.js +2 -2
  123. package/dist/context.d.ts +8 -6
  124. package/dist/context.js +7 -6
  125. package/dist/core/across-sandboxes.d.ts +7 -6
  126. package/dist/core/across-sandboxes.js +123 -152
  127. package/dist/core/coordinator.d.ts +166 -0
  128. package/dist/core/coordinator.js +233 -0
  129. package/dist/core/events.d.ts +2 -2
  130. package/dist/core/index.d.ts +4 -2
  131. package/dist/core/index.js +1 -1
  132. package/dist/core/outcomes.d.ts +148 -0
  133. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  134. package/dist/core/resources.d.ts +31 -53
  135. package/dist/core/resources.js +32 -70
  136. package/dist/core/run-state.d.ts +7 -1
  137. package/dist/core/run-state.js +2 -0
  138. package/dist/core/run.d.ts +32 -236
  139. package/dist/core/run.js +106 -266
  140. package/dist/core/state-directory.d.ts +1 -1
  141. package/dist/core/state-directory.js +2 -2
  142. package/dist/credential/gateways.d.ts +15 -1
  143. package/dist/credential/index.d.ts +4 -3
  144. package/dist/credential/index.js +3 -2
  145. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  146. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  147. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  148. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  149. package/dist/credential/source.d.ts +73 -6
  150. package/dist/credential/source.js +55 -2
  151. package/dist/extension-commands.d.ts +6 -1
  152. package/dist/extension-commands.js +15 -1
  153. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  154. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  155. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  156. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  157. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  158. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  159. package/dist/extensions/testserver/credential-facts.js +29 -11
  160. package/dist/extensions/testserver/lifecycle.js +7 -1
  161. package/dist/extensions/testserver/limit.d.ts +3 -0
  162. package/dist/extensions/testserver/limit.js +3 -0
  163. package/dist/extensions/testserver/provision.d.ts +8 -1
  164. package/dist/extensions/testserver/provision.js +8 -3
  165. package/dist/extensions/testserver/refusals.d.ts +6 -1
  166. package/dist/extensions/testserver/refusals.js +16 -1
  167. package/dist/extensions/testserver/resource.d.ts +1 -1
  168. package/dist/extensions/testserver/resource.js +1 -1
  169. package/dist/extensions/testserver/result.d.ts +1 -1
  170. package/dist/extensions/testserver/result.js +9 -4
  171. package/dist/planning/driver-file-lists.d.ts +0 -15
  172. package/dist/planning/driver-file-lists.js +2 -21
  173. package/dist/planning/plan-only.d.ts +3 -14
  174. package/dist/planning/plan-only.js +11 -20
  175. package/dist/planning/run-kind-flags.js +2 -2
  176. package/dist/planning/run-plan.d.ts +45 -12
  177. package/dist/planning/run-plan.js +4 -3
  178. package/dist/planning/suites.d.ts +1 -1
  179. package/dist/planning/suites.js +2 -2
  180. package/dist/planning/test-plan.d.ts +9 -0
  181. package/dist/planning/test-plan.js +9 -0
  182. package/dist/run-directory/recording.js +2 -2
  183. package/dist/run-directory/run-record.d.ts +21 -6
  184. package/dist/run-directory/run-record.js +12 -9
  185. package/dist/runner/base.js +1 -1
  186. package/dist/runner/build-snapshots.d.ts +55 -29
  187. package/dist/runner/build-snapshots.js +130 -29
  188. package/dist/runner/context.d.ts +15 -7
  189. package/dist/runner/context.js +19 -6
  190. package/dist/runner/events.d.ts +16 -10
  191. package/dist/runner/gateways.d.ts +87 -21
  192. package/dist/runner/gateways.js +1 -1
  193. package/dist/runner/index.d.ts +11 -7
  194. package/dist/runner/index.js +9 -4
  195. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  196. package/dist/runner/live/sandbox-errors.js +4 -0
  197. package/dist/runner/live/sandbox-gateway.js +129 -3
  198. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  199. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  200. package/dist/runner/live/snapshot-records.js +6 -7
  201. package/dist/runner/local-snapshot-index.d.ts +199 -0
  202. package/dist/runner/local-snapshot-index.js +211 -0
  203. package/dist/runner/network-policy.d.ts +6 -6
  204. package/dist/runner/network-policy.js +7 -7
  205. package/dist/runner/policy-writes.d.ts +1 -1
  206. package/dist/runner/policy-writes.js +1 -1
  207. package/dist/runner/prepare.d.ts +14 -14
  208. package/dist/runner/prepare.js +20 -11
  209. package/dist/runner/ready.d.ts +18 -10
  210. package/dist/runner/ready.js +104 -33
  211. package/dist/runner/sandboxed-command.d.ts +3 -3
  212. package/dist/runner/sandboxed-command.js +3 -3
  213. package/dist/runner/scope.d.ts +10 -6
  214. package/dist/runner/scope.js +10 -3
  215. package/dist/runner/secrets.d.ts +13 -13
  216. package/dist/runner/secrets.js +18 -15
  217. package/dist/runner/session.d.ts +8 -8
  218. package/dist/runner/session.js +3 -3
  219. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  220. package/dist/runner/shared-snapshot-entry.js +168 -0
  221. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  222. package/dist/runner/shared-snapshot-list.js +155 -0
  223. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  224. package/dist/runner/shared-snapshot-lookup.js +118 -0
  225. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  226. package/dist/runner/shared-snapshot-prune.js +133 -0
  227. package/dist/runner/snapshot-build.d.ts +42 -14
  228. package/dist/runner/snapshot-build.js +32 -29
  229. package/dist/runner/snapshot-choice.js +1 -1
  230. package/dist/runner/snapshot-inspect.d.ts +39 -40
  231. package/dist/runner/snapshot-inspect.js +55 -35
  232. package/dist/runner/snapshot-key.d.ts +13 -12
  233. package/dist/runner/snapshot-key.js +13 -12
  234. package/dist/runner/steps.d.ts +1 -1
  235. package/dist/runner/steps.js +1 -1
  236. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  237. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  238. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
  239. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
  240. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  241. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  242. package/dist/sdk/extension/commands.d.ts +8 -3
  243. package/dist/sdk/extension/commands.js +3 -1
  244. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  245. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  246. package/dist/sdk/extension/credential-source.d.ts +20 -3
  247. package/dist/sdk/extension/credential-source.js +4 -4
  248. package/dist/sdk/extension/index.d.ts +3 -2
  249. package/dist/sdk/extension/index.js +2 -1
  250. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  251. package/dist/sdk/extension/secret-source.d.ts +1 -1
  252. package/dist/sdk/extension/secret-source.js +1 -1
  253. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  254. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  255. package/dist/shared/cleanup.d.ts +3 -3
  256. package/dist/shared/cleanup.js +15 -5
  257. package/dist/shared/snapshot-text.d.ts +4 -4
  258. package/dist/shared/snapshot-text.js +11 -11
  259. package/dist/time/duration.js +1 -1
  260. package/package.json +3 -2
  261. package/skills/overview.md +4 -4
  262. package/skills/plan-runs.md +1 -1
  263. package/skills/read-run-output.md +6 -6
  264. package/dist/chunks/chunk-7EENF73W.js +0 -782
  265. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  266. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  267. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  268. package/dist/commands/exec/plan-only.d.ts +0 -10
  269. package/dist/commands/exec/plan-only.js +0 -45
  270. package/dist/commands/exec/run-command.d.ts +0 -475
  271. package/dist/commands/exec/run-command.js +0 -603
  272. package/dist/commands/exec/run-planned.d.ts +0 -20
  273. package/dist/commands/exec/run-planned.js +0 -22
  274. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  275. package/dist/commands/exec/sandbox-view.js +0 -72
  276. package/dist/commands/test/plan.d.ts +0 -92
  277. package/dist/commands/test/plan.js +0 -125
  278. package/dist/core/sandbox-end.d.ts +0 -64
  279. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  280. package/dist/runner/snapshot-cache.d.ts +0 -148
  281. package/dist/runner/snapshot-cache.js +0 -126
@@ -0,0 +1,2166 @@
1
+ import {
2
+ criticalPathStep,
3
+ hasPoorParallelism,
4
+ testsChart,
5
+ testsSummaryLines,
6
+ waterfallLines
7
+ } from "./chunk-RWIXDDCK.js";
8
+ import {
9
+ LANE_WIDTH,
10
+ commandEnd,
11
+ droppingWriter,
12
+ lineProgress,
13
+ localIndexWriteFailureText,
14
+ plainRenderer,
15
+ preparedNoteTexts,
16
+ progressLine,
17
+ resourceWarningText,
18
+ sharedSnapshotLookupFailedText,
19
+ skippedText,
20
+ snapshotBuildTexts
21
+ } from "./chunk-MR77L2GK.js";
22
+ import {
23
+ versionText
24
+ } from "./chunk-I5GZLOLQ.js";
25
+ import {
26
+ RUN_CLEANUP,
27
+ buildPlannedFacts,
28
+ canceledBeforeStart,
29
+ checkoutFailedRefusal,
30
+ fileListErrors,
31
+ keptText,
32
+ lacksFinalResults,
33
+ mintFailedErrors,
34
+ notDeletedText,
35
+ notKeptText,
36
+ notStoppedText,
37
+ outcomes,
38
+ plannedSecrets,
39
+ prepareRefusal,
40
+ readFileListsFile,
41
+ resolveCallerFileLists,
42
+ resourceRefused,
43
+ resourceRefusedBeforeRun,
44
+ runErrors,
45
+ runnerFailureFacts,
46
+ sandboxesDefaultErrors,
47
+ sandboxesErrors,
48
+ vcpuResources
49
+ } from "./chunk-2VP4GRJM.js";
50
+ import {
51
+ redactStrings,
52
+ redactingObserver,
53
+ redactingTerminal,
54
+ redactor
55
+ } from "./chunk-FNBB6V4R.js";
56
+ import {
57
+ builtAtText
58
+ } from "./chunk-M7EKRGVD.js";
59
+ import {
60
+ RESOURCE_FLAG_HELP,
61
+ RESOURCE_USAGE_FLAGS,
62
+ dealFileLists,
63
+ fileListMismatchText,
64
+ fileListMismatches,
65
+ plannedTestPlan,
66
+ resourceFlagFields,
67
+ resourceFlagProblems,
68
+ resourceFlagValues,
69
+ resourceRunExamples,
70
+ testPlanLine
71
+ } from "./chunk-F4MOYHRY.js";
72
+ import {
73
+ DEFINITION_SET
74
+ } from "./chunk-HWIQ2S7K.js";
75
+ import {
76
+ NodeSignalCancellation
77
+ } from "./chunk-BCBKYOHW.js";
78
+ import {
79
+ SANDBOX_TABLE_HEADER,
80
+ sandboxStateText,
81
+ sandboxTableLines,
82
+ sandboxTableRows,
83
+ sandboxTotalsLine,
84
+ sandboxesText
85
+ } from "./chunk-CKGZA25H.js";
86
+ import {
87
+ isoSecondsText,
88
+ keepTimeText,
89
+ orderText,
90
+ paint,
91
+ releaseText,
92
+ sandboxConnectPage,
93
+ seconds,
94
+ short,
95
+ shortFile,
96
+ spread,
97
+ truncate,
98
+ visibleLength,
99
+ withArticle
100
+ } from "./chunk-GRT3UIBV.js";
101
+ import {
102
+ recordAcrossSandboxes,
103
+ recordRun
104
+ } from "./chunk-4O5C2XGJ.js";
105
+ import {
106
+ EMPTY_RUN_STATE,
107
+ acrossSandboxesExitStatus,
108
+ cleanupProblems,
109
+ commandExitStatus,
110
+ executeAcrossSandboxes,
111
+ executeRun,
112
+ megabytesText,
113
+ setupPhaseKey,
114
+ setupPhaseWords,
115
+ timedProgress
116
+ } from "./chunk-YEPFSLQR.js";
117
+ import {
118
+ fileSettings,
119
+ givenTarget,
120
+ mintTargetText,
121
+ parseKeepTime,
122
+ prepareRunner,
123
+ readCredentials,
124
+ readUnsafeSecretEnvVars,
125
+ resolveSandboxCountDefault,
126
+ settleCredential,
127
+ settleRunResources
128
+ } from "./chunk-RNAS7JHE.js";
129
+ import {
130
+ NOT_COUNTED,
131
+ SECRET_MIN_LENGTH,
132
+ describeMintFailure,
133
+ vercelOidcTokenFailureFacts
134
+ } from "./chunk-XBDRVFEV.js";
135
+ import {
136
+ refused
137
+ } from "./chunk-4WAMTUWZ.js";
138
+
139
+ // src/planning/sandbox-placeholders.ts
140
+ var PLACEHOLDER = /(?<!\$)\{(sandbox\+1|sandbox(?:es)?)\}/g;
141
+ function placeholdersOf(argv) {
142
+ return new Set(
143
+ argv.flatMap((argument) => [...argument.matchAll(PLACEHOLDER)].map(([, name]) => name))
144
+ );
145
+ }
146
+ function commandForSandbox(argv, sandbox, count) {
147
+ return argv.map(
148
+ (argument) => argument.replace(
149
+ PLACEHOLDER,
150
+ (_match, name) => String(name === "sandbox" ? sandbox : name === "sandbox+1" ? sandbox + 1 : count)
151
+ )
152
+ );
153
+ }
154
+ function commandsForSandboxes(argv, count) {
155
+ return Array.from({ length: count }, (_, index) => commandForSandbox(argv, index, count));
156
+ }
157
+ function placeholderListText(names) {
158
+ const words = names.map((name) => `{${name}}`);
159
+ if (words.length <= 2) return words.join(" and ");
160
+ return `${words.slice(0, -1).join(", ")}, and ${words.at(-1) ?? ""}`;
161
+ }
162
+ function placeholderProblems(request) {
163
+ const { sandboxes, command } = request;
164
+ const held = placeholdersOf(command);
165
+ if (sandboxes === void 0)
166
+ return held.size === 0 ? [] : [
167
+ {
168
+ field: "command",
169
+ message: `The command holds ${placeholderListText([...held])}, which only --sandboxes replaces. Add --sandboxes <n>, or write $ before the brace to keep it as it is.`
170
+ }
171
+ ];
172
+ return [
173
+ ...Number.isInteger(sandboxes) && sandboxes >= 1 ? [] : [{ field: "sandboxes", message: `--sandboxes takes a whole number from 1, not ${sandboxes}.` }],
174
+ ...held.has("sandbox") || held.has("sandbox+1") ? [] : [
175
+ {
176
+ field: "command",
177
+ message: "--sandboxes needs {sandbox} or {sandbox+1} in an argument of the command, such as -g {sandbox+1}/{sandboxes}: without it, every runner sandbox runs the same command."
178
+ }
179
+ ]
180
+ ];
181
+ }
182
+
183
+ // src/forward-sigterm.ts
184
+ function forwardSigterm(signal) {
185
+ const terminate = new AbortController();
186
+ const forward = () => {
187
+ const reason = signal.reason;
188
+ if (reason instanceof NodeSignalCancellation && reason.signal === "SIGTERM") terminate.abort(reason);
189
+ };
190
+ if (signal.aborted) forward();
191
+ else signal.addEventListener("abort", forward, { once: true });
192
+ return { terminate: terminate.signal, release: () => signal.removeEventListener("abort", forward) };
193
+ }
194
+
195
+ // src/commands/exec/before-run.ts
196
+ async function resourcesBeforeRun(lifecycles, plan, request) {
197
+ const { configFile, resources, settings } = plan;
198
+ const used = await lifecycles.beforeRun(resources);
199
+ if (!used.ok) return refused(resourceRefusedBeforeRun(used.resource, used.refusal, configFile));
200
+ if (plan.runner.kind === "launch-machine" && request.credential !== void 0 && !used.needsVercelCredential)
201
+ return refused(runErrors.credentialUnused({ flags: ["--credential"], configFile }));
202
+ if (plan.runner.kind === "launch-machine" && used.needRunnerSandbox.length > 0)
203
+ return refused(runErrors.resourceNeedsRunnerSandbox({ resources: [...used.needRunnerSandbox], configFile }));
204
+ let runner;
205
+ if (plan.runner.kind === "vercel-sandbox") runner = plan.runner;
206
+ else if (used.needsVercelCredential) {
207
+ const chosen = settleCredential(request.credential ?? "mint", settings.scope, settings.project);
208
+ if (!chosen.ok) return chosen;
209
+ runner = { kind: "launch-machine", credential: chosen.credential };
210
+ } else runner = { kind: "launch-machine", credential: void 0 };
211
+ return { ok: true, runner, used };
212
+ }
213
+ function resolveKeepMs(flag, options, mode) {
214
+ const fromFlag = flag === void 0 ? void 0 : parseKeepTime(flag);
215
+ const minutes = mode === "single" ? fromFlag ?? options.keepSandboxMinutes ?? 0 : fromFlag ?? 0;
216
+ return minutes * 6e4;
217
+ }
218
+ async function prepareRunnerForRun(app, runner, input) {
219
+ const prepared = await prepareRunner(app.context, {
220
+ cwd: app.cwd,
221
+ options: runner.options,
222
+ vcpuRun: { resources: vcpuResources(input.resources), sandboxes: input.sandboxes }
223
+ });
224
+ if (prepared.kind === "ok") return { ok: true, prepared: prepared.prepared };
225
+ const refusal = prepareRefusal(prepared, input.configFile);
226
+ return {
227
+ ok: false,
228
+ refusal: input.secrets.length === 0 ? refusal : redactStrings(refusal, redactor(input.secrets))
229
+ };
230
+ }
231
+ async function beforeRunStarts({ ui, signal }, lifecycles, planned, request, plan) {
232
+ const before = await resourcesBeforeRun(lifecycles, planned, request);
233
+ if (!before.ok) return before;
234
+ if (signal.aborted) return { ok: false, refusal: canceledBeforeStart() };
235
+ if (plan !== void 0) await ui.progress?.(testPlanLine(plan));
236
+ return before;
237
+ }
238
+ async function runnerRequestFor(app, runner, used, options) {
239
+ const secrets = [...used.secrets, ...runner.secrets];
240
+ const prepared = await prepareRunnerForRun(app, runner, {
241
+ configFile: options.configFile,
242
+ resources: used.requests,
243
+ sandboxes: options.sandboxes,
244
+ secrets
245
+ });
246
+ if (!prepared.ok) return prepared;
247
+ const session = {
248
+ prepared: prepared.prepared,
249
+ target: runner.target,
250
+ user: app.user,
251
+ credentials: runner.credentials,
252
+ ...Object.keys(runner.unsafeSecretEnvVars).length === 0 ? {} : { unsafeSecretEnvVars: runner.unsafeSecretEnvVars },
253
+ keepMs: options.keepMs
254
+ };
255
+ return { ok: true, runner: session };
256
+ }
257
+
258
+ // src/shared/job-summary.ts
259
+ function jobSummaryMarkdown(timeline, extras) {
260
+ const lines = [`### storm ${extras.command}`, ""];
261
+ if (timeline.rows.length > 0) {
262
+ lines.push("| Lane | Start | Duration | Idle | Steps |", "| --- | ---: | ---: | ---: | --- |");
263
+ for (const row of timeline.rows) lines.push(tableRow(row));
264
+ lines.push("");
265
+ }
266
+ if (timeline.criticalPath.length > 0) {
267
+ const path = timeline.criticalPath.map((step) => criticalPathStep(step, timeline));
268
+ lines.push(`Critical path: ${path.join(" \u2192 ")}`, "");
269
+ }
270
+ for (const detail of extras.details ?? []) lines.push(`${detail.trim()} `);
271
+ if ((extras.details ?? []).length > 0) lines.push("");
272
+ if (extras.logs !== void 0) lines.push(`Run directory: \`${extras.logs}\``, "");
273
+ return lines.join("\n");
274
+ }
275
+ function tableRow(row) {
276
+ const outcome = row.outcome === "done" ? "" : ` (${row.outcome})`;
277
+ const steps = row.steps.map((step) => `${step.name} ${seconds(step.endMs - step.startMs)}`).join(" \xB7 ");
278
+ const idle = row.idleMs > 0 ? seconds(row.idleMs) : "";
279
+ return `| ${row.label}${outcome} | +${seconds(row.startMs)} | ${seconds(row.endMs - row.startMs)} | ${idle} | ${steps} |`;
280
+ }
281
+ function acrossSandboxesJobSummaryMarkdown(records, extras) {
282
+ const lines = [`### storm ${extras.command}`, ""];
283
+ const rows = sandboxTableRows(records);
284
+ lines.push(
285
+ `| ${SANDBOX_TABLE_HEADER.join(" | ")} |`,
286
+ `| ${SANDBOX_TABLE_HEADER.map((_, column) => column >= 2 && column <= 4 ? "---:" : "---").join(" | ")} |`,
287
+ ...rows.map((row) => `| ${row.map((cell) => cell.replaceAll("|", "\\|")).join(" | ")} |`),
288
+ "",
289
+ sandboxTotalsLine(records),
290
+ ""
291
+ );
292
+ for (const detail of extras.details ?? []) lines.push(`${detail.trim()} `);
293
+ if ((extras.details ?? []).length > 0) lines.push("");
294
+ if (extras.logs !== void 0) lines.push(`Run directory: \`${extras.logs}\``, "");
295
+ return lines.join("\n");
296
+ }
297
+
298
+ // src/commands/exec/sandbox-lines.ts
299
+ function sandboxLine(elapsedMs, sandbox, text) {
300
+ return `${`[+${seconds(elapsedMs)}]`.padEnd(8)} runner sandbox ${sandbox} ${text}`;
301
+ }
302
+ function shellWord(argument) {
303
+ return /^[\w@%+=:,./{}-]+$/.test(argument) ? argument : `'${argument.replaceAll("'", `'\\''`)}'`;
304
+ }
305
+ function acrossSandboxesHeaderLines(run) {
306
+ return [
307
+ `storm ${versionText(run.version, run.commit)} \xB7 ${sandboxesText(run.count)} \xB7 ${run.argv.map(shellWord).join(" ")}`,
308
+ `run directory ${run.runDirectory}`
309
+ ];
310
+ }
311
+ function sandboxTestsText(totals) {
312
+ if (totals === null || totals === void 0) return void 0;
313
+ const { passed, failed, skipped } = totals;
314
+ if (failed === 0 && skipped === 0) return `${passed} ${passed === 1 ? "test" : "tests"} passed`;
315
+ return [
316
+ ...passed > 0 ? [`${passed} passed`] : [],
317
+ ...failed > 0 ? [`${failed} failed`] : [],
318
+ ...skipped > 0 ? [`${skipped} skipped`] : []
319
+ ].join(", ");
320
+ }
321
+ function acrossSandboxesEndLines(input) {
322
+ const style = input.paint ?? paint(false);
323
+ const { records } = input;
324
+ return [
325
+ ...input.sandboxes.flatMap(({ sandbox, waterfall }) => [
326
+ "",
327
+ style.strong(` runner sandbox ${sandbox}`),
328
+ ...waterfall
329
+ ]),
330
+ "",
331
+ ...input.tests,
332
+ ...sandboxTableLines(records, style),
333
+ ` ${sandboxTotalsLine(records)}`,
334
+ ...(input.mismatches ?? []).map(
335
+ (mismatch) => style.stopped(
336
+ ` ${fileListMismatchText(
337
+ mismatch,
338
+ input.extraMismatchHint === void 0 ? {} : { extraHint: input.extraMismatchHint }
339
+ )}`
340
+ )
341
+ ),
342
+ ...showsFailed(records, input.runId) ? [` storm runs show ${input.runId ?? ""} --failed`] : [],
343
+ ` logs ${input.logs}`
344
+ ];
345
+ }
346
+ function showsFailed(records, runId) {
347
+ return runId !== void 0 && records.some(({ state }) => state !== "passed");
348
+ }
349
+
350
+ // src/commands/exec/run-summary.ts
351
+ function countFinalResults(tests) {
352
+ return {
353
+ finalResults: tests.events.filter((event) => event.kind === "test-result").length,
354
+ partial: tests.unreadable > 0 || tests.incomplete !== void 0
355
+ };
356
+ }
357
+ function displayPath(path, env) {
358
+ const home = env["HOME"];
359
+ if (home === void 0 || home === "" || !path.startsWith(`${home}/`)) return path;
360
+ return `~${path.slice(home.length)}`;
361
+ }
362
+ async function summarizeSingle(app, run) {
363
+ const { view, recording } = run;
364
+ const recorded = await recording.end(run.outcome);
365
+ const { timeline, tests } = recorded;
366
+ const logs = recording.opened.ok ? recording.opened.path : void 0;
367
+ const failed = tests.events.some((event) => event.kind === "test-result" && event.state === "fail");
368
+ const testsLines = testsSummaryLines(tests.events, run.hints, tests.unreadable, tests.incomplete);
369
+ const stepLogs = failedStepLogs(timeline, recording, app.env);
370
+ const clock = workerClock(recorded);
371
+ const charted = clock === void 0 ? void 0 : testsChart(tests.events, run.hints, tests.unreadable, clock, tests.incomplete);
372
+ const workersHint = charted !== void 0 && hasPoorParallelism(charted.parallelism);
373
+ const summarized = await app.context.jobSummary.appendJobSummary(
374
+ jobSummaryMarkdown(timeline, {
375
+ command: run.command,
376
+ logs,
377
+ details: [...testsLines, ...stepLogs]
378
+ })
379
+ );
380
+ await view.finish(
381
+ waterfallLines(timeline, {
382
+ width: view.width,
383
+ colorDepth: view.colorDepth,
384
+ logs: logsText(recording, recorded.writeFailure, app.env, failed, workersHint),
385
+ ...charted === void 0 ? {} : { workers: charted.lanes },
386
+ details: [...charted?.notes ?? testsLines, ...stepLogs, ...jobSummaryFailureLines(summarized)]
387
+ })
388
+ );
389
+ return { timeline, finalResults: countFinalResults(tests) };
390
+ }
391
+ function listMismatches(recorded) {
392
+ return fileListMismatches(
393
+ recorded.sandboxes.map(({ record, tests }) => ({
394
+ sandbox: record.sandbox,
395
+ files: record.files,
396
+ exitCode: record.exitCode,
397
+ reported: tests.events.map((event) => event.file),
398
+ whole: tests.unreadable === 0 && tests.incomplete === void 0
399
+ }))
400
+ );
401
+ }
402
+ async function summarizeAcrossSandboxes(app, run) {
403
+ const { view, recording, recorded, hints } = run;
404
+ const style = paint(view.colorDepth !== "none");
405
+ const events = recorded.sandboxes.flatMap(
406
+ (sandbox) => sandbox.tests.events.map((event) => ({ ...event, sandbox: sandbox.record.sandbox }))
407
+ );
408
+ const testsLines = testsSummaryLines(events, hints, recorded.tests.unreadable, recorded.tests.incomplete);
409
+ const failed = events.some((event) => event.kind === "test-result" && event.state === "fail");
410
+ const opened = recording.opened;
411
+ const summarized = await app.context.jobSummary.appendJobSummary(
412
+ acrossSandboxesJobSummaryMarkdown(
413
+ recorded.sandboxes.map(({ record }) => record),
414
+ { command: run.command, logs: opened.ok ? opened.path : void 0, details: testsLines }
415
+ )
416
+ );
417
+ const ranSandboxes = run.outcome.kind === "sandboxes_ran" || run.outcome.kind === "canceled";
418
+ const sandboxes = recorded.sandboxes.map((sandbox) => {
419
+ const tests = sandbox.timeline.rows.find((row) => row.name === "command");
420
+ const charted = tests === void 0 ? void 0 : testsChart(
421
+ sandbox.tests.events,
422
+ hints,
423
+ sandbox.tests.unreadable,
424
+ { runStartedAt: Date.parse(sandbox.timeline.startedAt), offsetMs: sandbox.workerOffsetMs, tests },
425
+ sandbox.tests.incomplete
426
+ );
427
+ return {
428
+ sandbox: sandbox.record.sandbox,
429
+ waterfall: waterfallLines(sandbox.timeline, {
430
+ width: view.width,
431
+ colorDepth: view.colorDepth,
432
+ logs: void 0,
433
+ ...charted === void 0 ? {} : { workers: charted.lanes, details: charted.notes }
434
+ })
435
+ };
436
+ });
437
+ const [first] = sandboxes;
438
+ const runId = opened.ok ? opened.id : void 0;
439
+ const records = recorded.sandboxes.map(({ record }) => record);
440
+ const lines = acrossSandboxesEndLines({
441
+ sandboxes: ranSandboxes ? sandboxes : [],
442
+ records,
443
+ tests: testsLines,
444
+ runId,
445
+ logs: logsText(recording, recorded.writeFailure, app.env, failed && !showsFailed(records, runId), false),
446
+ mismatches: run.mismatches,
447
+ ...run.extraMismatchHint === void 0 ? {} : { extraMismatchHint: run.extraMismatchHint },
448
+ paint: style
449
+ });
450
+ const once = ranSandboxes || first === void 0 ? [] : first.waterfall;
451
+ await view.finish([...once, ...lines, ...jobSummaryFailureLines(summarized)]);
452
+ }
453
+ function sandboxesRanFacts(app, run) {
454
+ const { outcome, recorded, recording, plan, runner } = run;
455
+ const records = recorded.sandboxes.map(({ record }) => record);
456
+ const count = (state) => records.filter((record) => record.state === state).length;
457
+ const totals = records.flatMap(({ tests }) => tests === null ? [] : [tests]);
458
+ const snapshotState = recorded.state.runner?.snapshot;
459
+ const { entry } = outcome.snapshot;
460
+ return {
461
+ version: app.version,
462
+ commit: app.commit,
463
+ configFile: run.configFile,
464
+ runId: recording.opened.ok ? recording.opened.id : null,
465
+ runDirectory: recording.opened.ok ? recording.opened.path : null,
466
+ sandboxes: records,
467
+ states: {
468
+ passed: count("passed"),
469
+ failed: count("failed"),
470
+ "not-started": count("not-started"),
471
+ canceled: count("canceled")
472
+ },
473
+ tests: totals.length === 0 ? null : {
474
+ passed: totals.reduce((sum, { passed }) => sum + passed, 0),
475
+ failed: totals.reduce((sum, { failed }) => sum + failed, 0),
476
+ skipped: totals.reduce((sum, { skipped }) => sum + skipped, 0)
477
+ },
478
+ plan: {
479
+ ...plan,
480
+ options: plan.options.map((option) => ({ ...option })),
481
+ ...plan.sandboxes === void 0 ? {} : { sandboxes: { ...plan.sandboxes } }
482
+ },
483
+ resources: DEFINITION_SET.reports.ranFacts(outcome.resources),
484
+ wallMs: recorded.wallMs,
485
+ runner: {
486
+ snapshotId: entry.snapshotId,
487
+ base: entry.base,
488
+ builtBehind: snapshotState !== void 0 && snapshotState.kind !== "building" ? snapshotState.builtBehind : null,
489
+ built: outcome.snapshot.built,
490
+ vcpus: runner.prepared.vcpus,
491
+ region: entry.region,
492
+ runtime: entry.runtime,
493
+ uploadBytes: recorded.uploadBytes
494
+ },
495
+ cleanup: RUN_CLEANUP.facts(outcome),
496
+ kept: outcome.sandboxes.flatMap(({ sandbox, runnerCleanup }) => {
497
+ const kept = runnerCleanup?.kept ?? null;
498
+ return kept === null ? [] : [
499
+ {
500
+ sandbox,
501
+ name: kept.name,
502
+ stopsAt: kept.stopsAt,
503
+ url: runner.target === null ? null : sandboxConnectPage(runner.target, kept.name)
504
+ }
505
+ ];
506
+ }),
507
+ notKept: outcome.sandboxes.flatMap(({ sandbox, runnerCleanup }) => {
508
+ const notKept = runnerCleanup?.notKept ?? null;
509
+ return notKept === null ? [] : [{ sandbox, name: notKept.name, message: notKept.message }];
510
+ }),
511
+ fileListMismatches: run.mismatches.map(({ sandbox, missing, extra }) => ({
512
+ sandbox,
513
+ missing: [...missing],
514
+ extra: [...extra]
515
+ }))
516
+ };
517
+ }
518
+ function jobSummaryFailureLines(summarized) {
519
+ return summarized.kind === "failed" ? [` couldn't append to the job summary at ${summarized.failure.path}: ${summarized.failure.message}`] : [];
520
+ }
521
+ function workerClock({ timeline, workerOffsetMs }) {
522
+ const tests = timeline.rows.find((row) => row.name === "command");
523
+ if (tests === void 0) return void 0;
524
+ return { runStartedAt: Date.parse(timeline.startedAt), offsetMs: workerOffsetMs, tests };
525
+ }
526
+ function logsText({ opened }, writeFailure, env, failed, workersHint) {
527
+ if (!opened.ok) return `none: couldn't make ${opened.failure.path}: ${opened.failure.message}`;
528
+ const path = `${displayPath(opened.path, env)}/`;
529
+ const problems = [
530
+ ...writeFailure === void 0 ? [] : [`couldn't write ${writeFailure.path}: ${writeFailure.message}`],
531
+ ...opened.pruneFailures.slice(0, 1).map((failure) => `couldn't remove ${failure.path}: ${failure.message}`)
532
+ ];
533
+ const flags = `${failed ? " --failed" : ""}${workersHint ? " --workers" : ""}`;
534
+ const show = `storm runs show ${opened.id}${flags}`;
535
+ return `${problems.length === 0 ? path : `${path} (${problems.join("; ")})`} \xB7 ${show}`;
536
+ }
537
+ function failedStepLogs(timeline, recording, env) {
538
+ const runner = timeline.rows.find((row) => row.name === "runner");
539
+ return (runner?.steps ?? []).filter((step) => step.outcome === "failed").flatMap((step) => {
540
+ const log = recording.stepLog(step.name);
541
+ return log === void 0 ? [] : [` failed ${step.name}, whole output: ${displayPath(log, env)}`];
542
+ });
543
+ }
544
+
545
+ // src/commands/exec/sandbox-progress.ts
546
+ var PROGRESS_INTERVAL_MS = 1e4;
547
+ var FAILED_TEST_LINES = 5;
548
+ var NAMED_RUNNING_FILES = 2;
549
+ var STEP_TEXT = {
550
+ snapshot: "building the runner snapshot",
551
+ apply: "applying the changes",
552
+ install: "installing",
553
+ build: "building"
554
+ };
555
+ function wholeSeconds(ms) {
556
+ return `${Math.max(0, Math.floor(ms / 1e3))}s`;
557
+ }
558
+ function runningFilesText(running, now, named = NAMED_RUNNING_FILES) {
559
+ if (running.size === 0) return void 0;
560
+ const longest = [...running].toSorted(([, a], [, b]) => a - b);
561
+ const shown = longest.slice(0, named).map(([file, since]) => `${file} ${wholeSeconds(now - since)}`);
562
+ const more = longest.length - shown.length;
563
+ return `waiting on ${[...shown, ...more > 0 ? [`${more} more`] : []].join(", ")}`;
564
+ }
565
+ function sandboxProgressText(progress) {
566
+ const { finishedFiles, listed, runningFiles } = progress;
567
+ const files = listed !== null && (finishedFiles > 0 || runningFiles !== void 0) ? [`${finishedFiles} of ${listed} files`] : finishedFiles > 0 ? [`${finishedFiles} ${finishedFiles === 1 ? "file" : "files"} done`] : [];
568
+ const tests = sandboxTestsText(progress.totals);
569
+ const countParts = [...files, ...tests === void 0 ? [] : [tests]];
570
+ const parts = [...countParts, ...runningFiles === void 0 ? [] : [runningFiles]];
571
+ if (parts.length === 0) return void 0;
572
+ return { parts, counts: countParts.join(" \xB7 ") };
573
+ }
574
+ function endedText(ended) {
575
+ const state = sandboxStateText(ended.state);
576
+ if (ended.state === "canceled") return state;
577
+ if (ended.exitCode !== null) return `${state}: exit ${ended.exitCode}`;
578
+ return ended.cause === null ? state : `${state}: ${ended.cause}`;
579
+ }
580
+ function endTone(state, style) {
581
+ if (state === "passed") return style.done;
582
+ return state === "canceled" ? style.stopped : style.failed;
583
+ }
584
+ function sandboxProgress(options) {
585
+ const { count } = options;
586
+ const own = plainRenderer({ github: false });
587
+ let origin;
588
+ let started = false;
589
+ let stopping = false;
590
+ const activities = /* @__PURE__ */ new Map();
591
+ const listed = (sandbox) => options.listed?.[sandbox] ?? null;
592
+ const activity = (sandbox) => {
593
+ const known = activities.get(sandbox);
594
+ if (known !== void 0) return known;
595
+ const fresh = {
596
+ phase: { kind: "waiting" },
597
+ finished: /* @__PURE__ */ new Set(),
598
+ running: /* @__PURE__ */ new Map(),
599
+ totals: void 0,
600
+ failedLines: 0,
601
+ lastLineAt: 0,
602
+ lastCounts: void 0
603
+ };
604
+ activities.set(sandbox, fresh);
605
+ return fresh;
606
+ };
607
+ const progressOf = (sandbox, now, namedRunning) => {
608
+ const current = activity(sandbox);
609
+ return sandboxProgressText({
610
+ finishedFiles: current.finished.size,
611
+ listed: listed(sandbox),
612
+ totals: current.totals,
613
+ runningFiles: runningFilesText(current.running, now, namedRunning)
614
+ });
615
+ };
616
+ const lines = (timed) => {
617
+ const { event, at } = timed;
618
+ const now = at.getTime();
619
+ origin ??= now;
620
+ const elapsed2 = now - origin;
621
+ const line = (sandbox2, text) => sandboxLine(elapsed2, sandbox2, text);
622
+ if (event.kind === "sandboxes-started") {
623
+ started = true;
624
+ return options.header;
625
+ }
626
+ if (event.kind === "sandbox-ended") {
627
+ const current2 = activity(event.sandbox);
628
+ if (current2.phase.kind === "ended" && current2.phase.state === event.state) return [];
629
+ const text = endedText(event);
630
+ if (current2.phase.kind !== "ended") current2.phase = { kind: "ended", text, state: event.state };
631
+ return [line(event.sandbox, text)];
632
+ }
633
+ if (event.kind === "cleanup-started" || event.kind === "cleanup-finished") return [];
634
+ if (event.kind === "runner" && event.event.kind === "step-output") return [];
635
+ if (event.kind !== "sandbox") return own(timed);
636
+ const { sandbox, event: inner } = event;
637
+ const current = activity(sandbox);
638
+ if (inner.kind === "command-started") {
639
+ current.phase = { kind: "running", since: now };
640
+ current.lastLineAt = now;
641
+ return [line(sandbox, "command started")];
642
+ }
643
+ if (inner.kind === "command-ended") {
644
+ const { outcome } = inner;
645
+ const state = outcome.kind === "exited" && outcome.code === 0 ? "passed" : "failed";
646
+ const how = state === "passed" ? "passed" : `failed: ${outcome.kind === "exited" ? `exit ${outcome.code}` : commandEnd(outcome)}`;
647
+ const tests = sandboxTestsText(current.totals);
648
+ const text = `${how} after ${seconds(inner.ms)}${tests === void 0 ? "" : ` \xB7 ${tests}`}`;
649
+ current.phase = { kind: "ended", text, state };
650
+ current.running.clear();
651
+ return [line(sandbox, text)];
652
+ }
653
+ if (inner.kind === "test") {
654
+ const test = inner.event;
655
+ const runs = current.phase.kind === "running";
656
+ if (test.kind === "file-started" && runs) current.running.set(test.file, now);
657
+ if (test.kind === "file-finished") {
658
+ current.running.delete(test.file);
659
+ current.finished.add(test.file);
660
+ }
661
+ if (test.kind !== "test-result") return [];
662
+ const counted = current.totals ?? { passed: 0, failed: 0, skipped: 0 };
663
+ if (test.state === "pass") counted.passed += 1;
664
+ else if (test.state === "fail") counted.failed += 1;
665
+ else counted.skipped += 1;
666
+ current.totals = counted;
667
+ if (test.state !== "fail" || !runs) return [];
668
+ current.failedLines += 1;
669
+ if (current.failedLines <= FAILED_TEST_LINES) return [line(sandbox, `test failed: ${test.file} > ${test.test}`)];
670
+ return current.failedLines === FAILED_TEST_LINES + 1 ? [line(sandbox, "more tests failed; its end line counts them")] : [];
671
+ }
672
+ if (inner.kind !== "runner") return [];
673
+ const runner = inner.event;
674
+ if (current.phase.kind === "waiting" || current.phase.kind === "preparing") {
675
+ if (runner.kind === "runner-sandbox-starting")
676
+ current.phase = { kind: "preparing", text: "starting its runner sandbox", since: now };
677
+ if (runner.kind === "uploading") current.phase = { kind: "preparing", text: "uploading the changes", since: now };
678
+ if (runner.kind === "step-started")
679
+ current.phase = { kind: "preparing", text: STEP_TEXT[runner.phase], since: now };
680
+ }
681
+ if (runner.kind === "sandbox-started" && runner.role === "runner")
682
+ return [line(sandbox, `runner sandbox ${runner.name} started (${seconds(runner.ms)})`)];
683
+ if (runner.kind === "sandbox-kept")
684
+ return [line(sandbox, `runner sandbox ${runner.name} kept until ${isoSecondsText(runner.stopsAt)}`)];
685
+ if (runner.kind !== "stopping" || stopping) return [];
686
+ stopping = true;
687
+ const then = runner.keepMs > 0 ? `keeping each runner sandbox running ${keepTimeText(runner.keepMs)}` : "stopping and deleting the runner's sandboxes";
688
+ return [
689
+ progressLine(elapsed2, "cleanup", `stopping: killing each runner sandbox's command that runs, then ${then}\u2026`)
690
+ ];
691
+ };
692
+ const tick = (now) => {
693
+ if (origin === void 0) return [];
694
+ const due = [];
695
+ for (const [sandbox, current] of [...activities].toSorted(([a], [b]) => a - b)) {
696
+ const { phase } = current;
697
+ if (phase.kind !== "running" || now - current.lastLineAt < PROGRESS_INTERVAL_MS) continue;
698
+ const progress = progressOf(sandbox, now);
699
+ if (progress === void 0) continue;
700
+ if (progress.counts === current.lastCounts && current.running.size === 0) continue;
701
+ current.lastLineAt = now;
702
+ current.lastCounts = progress.counts;
703
+ due.push(
704
+ sandboxLine(now - origin, sandbox, [`running ${seconds(now - phase.since)}`, ...progress.parts].join(" \xB7 "))
705
+ );
706
+ }
707
+ return due;
708
+ };
709
+ const rows = (now, style = paint(false)) => {
710
+ if (!started) return [];
711
+ return Array.from({ length: count }, (_, index) => {
712
+ const sandbox = index;
713
+ const label = style.strong(` runner sandbox ${sandbox}`);
714
+ const { phase } = activity(sandbox);
715
+ switch (phase.kind) {
716
+ case "waiting":
717
+ return `${label} ${style.faint("waiting")}`;
718
+ case "preparing":
719
+ return `${label} ${style.active(`${phase.text} ${wholeSeconds(now - phase.since)}`)}`;
720
+ case "running": {
721
+ const progress = progressOf(sandbox, now, 1);
722
+ return `${label} ${[seconds(now - phase.since), ...progress?.parts ?? []].join(" \xB7 ")}`;
723
+ }
724
+ case "ended":
725
+ return `${label} ${endTone(phase.state, style)(phase.text)}`;
726
+ }
727
+ });
728
+ };
729
+ return { lines, tick, rows };
730
+ }
731
+
732
+ // src/commands/exec/stopped-outcome.ts
733
+ function mapStoppedOutcome(outcome, canceledOptions) {
734
+ switch (outcome.kind) {
735
+ case "resource_refused":
736
+ return resourceRefused(outcome, RUN_CLEANUP.facts(outcome));
737
+ case "mint_failed":
738
+ return mintFailedErrors.mintFailed({
739
+ ...outcome.target,
740
+ ...describeMintFailure(outcome.failure, outcome.target),
741
+ runner: outcome.runner,
742
+ cleanup: RUN_CLEANUP.facts(outcome)
743
+ });
744
+ case "vercel_oidc_token_failed":
745
+ return mintFailedErrors.vercelOidcTokenFailed({
746
+ ...vercelOidcTokenFailureFacts(outcome.failure),
747
+ runner: outcome.runner,
748
+ cleanup: RUN_CLEANUP.facts(outcome)
749
+ });
750
+ case "spawn_failed":
751
+ return runErrors.spawnFailed({
752
+ executable: outcome.executable,
753
+ message: outcome.message,
754
+ cleanup: RUN_CLEANUP.facts({ runnerCleanup: null, resourceCleanup: outcome.resourceCleanup })
755
+ });
756
+ case "canceled":
757
+ return outcomes.canceled({ changed: canceledChanges(outcome, canceledOptions) });
758
+ case "runner_failed":
759
+ return runErrors.runnerFailed({
760
+ failure: runnerFailureFacts(outcome.failure),
761
+ cleanup: RUN_CLEANUP.facts(outcome)
762
+ });
763
+ case "snapshot_gone":
764
+ return runErrors.snapshotGone({
765
+ snapshotId: outcome.entry.snapshotId,
766
+ base: outcome.entry.base,
767
+ removal: outcome.removal === void 0 ? null : { ...outcome.removal },
768
+ cleanup: RUN_CLEANUP.facts(outcome)
769
+ });
770
+ }
771
+ }
772
+ function canceledChanges(outcome, options = {}) {
773
+ const { commandStopped } = outcome;
774
+ const lines = [
775
+ options.commandLine ?? (commandStopped === true ? "The command was stopped in the runner sandbox." : "The command didn't run.")
776
+ ];
777
+ const cleanup = RUN_CLEANUP.facts(outcome).runner;
778
+ if (cleanup !== null) lines.push(...runnerCleanupLines(cleanup, options.keptLines));
779
+ else if (options.keptLines !== void 0) lines.push(...options.keptLines);
780
+ lines.push(...DEFINITION_SET.reports.canceledLines(outcome.resourceCleanup));
781
+ return lines.join("\n");
782
+ }
783
+ function runnerCleanupLines({ kept, notKept, notStopped, notDeleted }, keptLines) {
784
+ const problems = [
785
+ ...notKept === null ? [] : [notKeptText(notKept)],
786
+ ...notStopped.map(notStoppedText),
787
+ ...notDeleted.map(notDeletedText)
788
+ ];
789
+ const allKept = [...kept === null ? [] : [keptText(kept)], ...keptLines ?? []];
790
+ if (allKept.length === 0)
791
+ return problems.length === 0 ? ["Every sandbox the runner started is stopped and deleted."] : problems;
792
+ return [
793
+ ...allKept,
794
+ ...problems.length === 0 ? ["Every other sandbox the runner started is stopped and deleted."] : problems
795
+ ];
796
+ }
797
+
798
+ // src/commands/exec/live-view.ts
799
+ var SPINNER = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
800
+ var INDENT = " ".repeat(LANE_WIDTH + 5);
801
+ function laneHead(glyph, lane) {
802
+ return ` ${glyph} ${lane.padEnd(LANE_WIDTH)} `;
803
+ }
804
+ function activePhase(state) {
805
+ if (state.cleanup !== void 0) return "cleanup";
806
+ if (state.command !== void 0) return "command";
807
+ if (state.lanesStartedAt !== void 0 && state.runner !== void 0) return "lanes";
808
+ if (Object.keys(state.resources).length > 0 && state.runner === void 0) return "resources";
809
+ if (state.mint !== void 0) return "credential";
810
+ return void 0;
811
+ }
812
+ function instanceLanes(state) {
813
+ return DEFINITION_SET.presentations.lanes(state.instances ?? []);
814
+ }
815
+ function startedLanes(state) {
816
+ return DEFINITION_SET.presentations.lanes(
817
+ Object.entries(state.resources).map(([resource, { definition }]) => ({ resource, definition }))
818
+ );
819
+ }
820
+ function headerLine(state, paint2) {
821
+ const version = state.version === void 0 ? "" : versionText(state.version.version, state.version.commit);
822
+ const header = [
823
+ `storm ${version}`.trimEnd(),
824
+ ...state.base === void 0 ? [] : [`merge-base ${short(state.base.sha)} (with ${state.base.ref})`]
825
+ ].join(" \xB7 ");
826
+ return paint2.strong(header);
827
+ }
828
+ function phaseFrame(state, phase, now, width, paint2) {
829
+ const view = {
830
+ now,
831
+ width,
832
+ paint: paint2,
833
+ glyph: (status) => statusGlyph(status, now, paint2),
834
+ // A live row is cut to the width: one that wrapped would take a row the next redraw doesn't erase.
835
+ row: (left, right) => spread(left, right, width),
836
+ line: (text) => truncate(text, width)
837
+ };
838
+ switch (phase) {
839
+ case "credential":
840
+ return state.mint === void 0 ? [] : [credentialLine(state.mint, view)];
841
+ case "lanes":
842
+ return lanesFrame(state, view);
843
+ case "resources":
844
+ return resourceLanesFrame(state, view);
845
+ case "command":
846
+ return commandFrame(state, view);
847
+ case "cleanup":
848
+ return state.cleanup === void 0 ? [] : [cleanupLine(state.cleanup, state.runner, view, false)];
849
+ }
850
+ }
851
+ function phaseRecord(state, phase, width, paint2) {
852
+ const view = {
853
+ now: void 0,
854
+ width,
855
+ paint: paint2,
856
+ glyph: (status) => statusGlyph(status === "running" ? "stopped" : status, 0, paint2),
857
+ row: (left, right) => visibleLength(left) + visibleLength(right) + 1 <= width ? spread(left, right, width) : `${left}${right === "" ? "" : ` ${right}`}`,
858
+ line: (text) => text
859
+ };
860
+ switch (phase) {
861
+ case "credential":
862
+ return state.mint === void 0 ? [] : [credentialLine(state.mint, view)];
863
+ case "lanes":
864
+ return lanesRecord(state, view);
865
+ case "resources":
866
+ return resourceLanesRecord(state, view);
867
+ case "command":
868
+ return state.command === void 0 ? [] : [commandLine(state, state.command, view, false)];
869
+ case "cleanup":
870
+ return state.cleanup === void 0 ? [] : [cleanupLine(state.cleanup, state.runner, view, true)];
871
+ }
872
+ }
873
+ function laneDraw(view) {
874
+ return {
875
+ now: view.now,
876
+ paint: view.paint,
877
+ glyph: view.glyph,
878
+ line: view.line,
879
+ elapsed: (from, to) => elapsed(view, from, to),
880
+ seconds
881
+ };
882
+ }
883
+ function elapsed(view, from, to) {
884
+ const end = to ?? view.now;
885
+ return from === void 0 || end === void 0 ? "" : seconds(end - from);
886
+ }
887
+ function credentialLine(mint, view) {
888
+ return view.row(
889
+ ` ${view.glyph(mint.status)} credential ${mintTargetText(mint.target)}`,
890
+ elapsed(view, mint.startedAt, mint.endedAt)
891
+ );
892
+ }
893
+ function lanesFrame(state, view) {
894
+ const { runner } = state;
895
+ if (runner === void 0) return [];
896
+ const { paint: paint2 } = view;
897
+ const stopping = (status) => state.stopping && status === "running";
898
+ const draw = laneDraw(view);
899
+ const resourceRows = instanceLanes(state).map((lane) => {
900
+ const live = lane.live(state.resources, draw);
901
+ if (live === void 0) return view.row(laneHead(view.glyph("running"), lane.lane), "");
902
+ const { span } = live;
903
+ const text = stopping(span.status) ? "stopping" : live.detail ?? live.text;
904
+ const waiting = span.status === "done" && runner.status === "running" && span.endedAt !== void 0 && view.now !== void 0 ? `${paint2.faint(`waiting for runner +${seconds(view.now - span.endedAt)}`)} ` : "";
905
+ return view.row(
906
+ `${laneHead(view.glyph(span.status), lane.lane)}${text}`,
907
+ `${waiting}${elapsed(view, span.startedAt, span.endedAt)}`
908
+ );
909
+ });
910
+ const current = runner.steps.find(({ status }) => status === "running") ?? [...runner.steps].filter((step) => step.status !== "pending" && step.endedAt !== void 0).toSorted((a, b) => (a.endedAt ?? 0) - (b.endedAt ?? 0)).at(-1);
911
+ const currentText = current === void 0 ? "" : [
912
+ `${current.name}${stepLabel(current, runner) === "" ? "" : ` \xB7 ${stepLabel(current, runner)}`}`,
913
+ current.startedAt === current.endedAt ? "" : elapsed(view, current.startedAt, current.endedAt),
914
+ current.status === "failed" || current.status === "stopped" ? view.glyph(current.status) : ""
915
+ ].filter((part) => part !== "").join(" ");
916
+ const crumbs = stepsText(
917
+ runner.steps.filter((step) => step !== current),
918
+ view,
919
+ void 0
920
+ );
921
+ const runnerText = stopping(runner.status) ? `stopping \xB7 ${currentText}` : currentText;
922
+ const runnerRow = view.row(
923
+ `${laneHead(runnerGlyph(runner, view), "runner")}${runnerText}${crumbs === "" ? "" : ` ${paint2.faint(crumbs)}`}`,
924
+ elapsed(view, runner.startedAt, runner.endedAt)
925
+ );
926
+ const running = runner.steps.find(({ status }) => status === "running");
927
+ const latest = running === void 0 ? void 0 : latestLine(running, runner);
928
+ const output = activityText(runner) ?? (latest === "" ? void 0 : latest);
929
+ return [...resourceRows, runnerRow, output === void 0 ? "" : view.line(`${INDENT}${paint2.faint(output)}`)];
930
+ }
931
+ function lanesRecord(state, view) {
932
+ const { runner } = state;
933
+ const lines = [];
934
+ const draw = laneDraw(view);
935
+ for (const lane of startedLanes(state)) {
936
+ const record = lane.record(state.resources, draw);
937
+ if (record === void 0) continue;
938
+ const { span } = record;
939
+ const waited = span.status === "done" && span.endedAt !== void 0 && runner?.endedAt !== void 0 && runner.endedAt > span.endedAt ? ` \xB7 waited ${seconds(runner.endedAt - span.endedAt)}` : "";
940
+ lines.push(
941
+ view.row(
942
+ `${laneHead(view.glyph(span.status), lane.lane)}${record.text}`,
943
+ `${elapsed(view, span.startedAt, span.endedAt)}${waited}`
944
+ ),
945
+ ...record.lines
946
+ );
947
+ }
948
+ if (runner !== void 0) {
949
+ const snapshot = runner.steps.find(({ name }) => name === "snapshot");
950
+ const parts = [
951
+ ...runner.sandbox === void 0 ? [] : [`${runner.sandbox.name} \xB7 ${runner.sandbox.region} \xB7 ${runner.sandbox.vcpus} vCPU`],
952
+ ...snapshot === void 0 || snapshot.status === "pending" ? [] : [snapshotText(snapshot, runner, state.base?.sha)],
953
+ ...runner.status === "failed" || runner.status === "stopped" ? [runner.status] : []
954
+ ];
955
+ lines.push(
956
+ view.row(
957
+ `${laneHead(runnerGlyph(runner, view), "runner")}${parts.join(" \xB7 ")}`,
958
+ elapsed(view, runner.startedAt, runner.endedAt)
959
+ )
960
+ );
961
+ const steps = stepsText(runner.steps, view, runner.uploadBytes);
962
+ if (steps !== "") lines.push(view.line(`${INDENT}${steps}`));
963
+ }
964
+ return lines;
965
+ }
966
+ function runnerGlyph(runner, view) {
967
+ return view.glyph(runner.steps.some(({ status }) => status === "failed") ? "failed" : runner.status);
968
+ }
969
+ function snapshotText(step, runner, mergeBase) {
970
+ if (runner.snapshot?.kind === "built") return "snapshot built";
971
+ if (runner.snapshot?.kind === "reused") {
972
+ const { base, builtBehind, source } = runner.snapshot;
973
+ const from = source === "shared" ? ", from the shared snapshot index" : "";
974
+ return `snapshot ${builtAtText({ base, builtBehind, mergeBase })}${from}`;
975
+ }
976
+ return `snapshot build ${step.status === "running" ? "stopped" : step.status}`;
977
+ }
978
+ function stepLabel(step, runner) {
979
+ if (step.name === "snapshot") {
980
+ const { snapshot } = runner;
981
+ if (snapshot === void 0) return step.label;
982
+ if (snapshot.kind !== "building") return `${snapshot.id} ${snapshot.kind}`;
983
+ return step.label === "" ? `building: ${snapshot.summary}` : step.label;
984
+ }
985
+ if (step.name === "upload" && runner.uploadBytes !== void 0) return megabytesText(runner.uploadBytes);
986
+ return step.label;
987
+ }
988
+ function latestLine(step, runner) {
989
+ if (step.latest !== void 0) return step.latest.trim();
990
+ if (step.name === "snapshot" && step.label === "" && runner.buildSandbox !== void 0)
991
+ return `build sandbox ${runner.buildSandbox} started`;
992
+ return void 0;
993
+ }
994
+ function activityText(runner) {
995
+ switch (runner.activity) {
996
+ case "saving-snapshot":
997
+ return "saving the build sandbox as a runner snapshot";
998
+ case "waiting-for-snapshot":
999
+ return WAITING_FOR_SNAPSHOT;
1000
+ case void 0:
1001
+ return void 0;
1002
+ }
1003
+ }
1004
+ var WAITING_FOR_SNAPSHOT = "waiting for the runner snapshot still saving";
1005
+ function stepsText(steps, view, uploadBytes) {
1006
+ return steps.filter(
1007
+ (step) => step.status !== "pending" && step.status !== "running" && step.startedAt !== void 0 && step.endedAt !== void 0 && (step.endedAt > step.startedAt || step.status !== "done")
1008
+ ).map((step) => {
1009
+ const mark = step.status === "done" ? "" : ` ${view.glyph(step.status)}`;
1010
+ const size = step.name === "upload" && uploadBytes !== void 0 ? ` (${megabytesText(uploadBytes)})` : "";
1011
+ return `${step.name} ${seconds((step.endedAt ?? 0) - (step.startedAt ?? 0))}${size}${mark}`;
1012
+ }).join(" \xB7 ");
1013
+ }
1014
+ function resourceLanesFrame(state, view) {
1015
+ const { mint } = state;
1016
+ const draw = laneDraw(view);
1017
+ const mintRow = mint !== void 0 && mint.status === "running" ? view.row(
1018
+ ` ${view.glyph("running")} minting a credential for ${mintTargetText(mint.target)}`,
1019
+ elapsed(view, mint.startedAt, mint.endedAt)
1020
+ ) : void 0;
1021
+ const rows = startedLanes(state).flatMap((lane) => {
1022
+ const row = lane.live(state.resources, draw);
1023
+ return row === void 0 ? [] : [{ lane: lane.lane, ...row }];
1024
+ });
1025
+ return rows.flatMap(({ lane, span, text, detail }, index) => [
1026
+ view.row(`${laneHead(view.glyph(span.status), lane)}${text}`, elapsed(view, span.startedAt, span.endedAt)),
1027
+ index === 0 && mintRow !== void 0 ? mintRow : detail !== void 0 ? view.line(` ${view.glyph("running")} ${detail}`) : ""
1028
+ ]);
1029
+ }
1030
+ function resourceLanesRecord(state, view) {
1031
+ const { mint } = state;
1032
+ const draw = laneDraw(view);
1033
+ const lanes = startedLanes(state).flatMap((lane) => {
1034
+ const record = lane.record(state.resources, draw);
1035
+ if (record === void 0) return [];
1036
+ const { span } = record;
1037
+ return [
1038
+ view.row(
1039
+ `${laneHead(view.glyph(span.status), lane.lane)}${record.text}`,
1040
+ elapsed(view, span.startedAt, span.endedAt)
1041
+ ),
1042
+ ...record.lines
1043
+ ];
1044
+ });
1045
+ if (lanes.length === 0) return [];
1046
+ return [...mint === void 0 ? [] : [credentialLine(mint, view)], ...lanes];
1047
+ }
1048
+ function commandFrame(state, view) {
1049
+ return state.command === void 0 ? [] : [commandLine(state, state.command, view, true)];
1050
+ }
1051
+ var LONG_FILE_MS = 1e4;
1052
+ function commandLine(state, command, view, live) {
1053
+ const { tests } = state;
1054
+ const end = command.outcome === void 0 ? void 0 : endText(command.outcome);
1055
+ const parts = [command.argv.join(" ")];
1056
+ if (end !== void 0) parts.push(end);
1057
+ else if (live && state.stopping) parts.push("stopping");
1058
+ const head = laneHead(view.glyph(command.status), "command");
1059
+ const time = elapsed(view, command.startedAt, command.endedAt);
1060
+ const text = live && end === void 0 && !state.stopping && tests !== void 0 ? testsProgress(tests, view, view.width - visibleLength(head) - visibleLength(time) - 1) : parts.join(" ");
1061
+ return view.row(`${head}${text}`, time);
1062
+ }
1063
+ function testsProgress(tests, view, room) {
1064
+ const { paint: paint2, now } = view;
1065
+ const running = tests.workers.filter((worker) => worker.file !== void 0 || worker.settingUp.length > 0);
1066
+ const waiting = waitingText(tests.workers.map(({ settingUp }) => settingUp));
1067
+ const longest = [...running].toSorted((a, b) => (a.fileStartedAt ?? 0) - (b.fileStartedAt ?? 0))[0];
1068
+ const longestMs = longest?.fileStartedAt === void 0 || now === void 0 ? void 0 : now - longest.fileStartedAt;
1069
+ const text = (showWaiting) => [
1070
+ `${tests.passed} passed`,
1071
+ ...tests.failed === 0 ? [] : [paint2.failed(`${tests.failed} failed`)],
1072
+ `${tests.filesDone} ${tests.filesDone === 1 ? "file" : "files"} done`,
1073
+ `${running.length} running${waiting === void 0 || !showWaiting ? "" : ` (${waiting})`}`,
1074
+ ...longest?.file === void 0 || longestMs === void 0 || longestMs < LONG_FILE_MS ? [] : [`longest: ${shortFile(longest.file)} ${seconds(longestMs)}`]
1075
+ ].join(" \xB7 ");
1076
+ const full = text(true);
1077
+ return visibleLength(full) <= room ? full : text(false);
1078
+ }
1079
+ function waitingText(waiting) {
1080
+ const words = setupPhaseWords(waiting.flat());
1081
+ const counts = /* @__PURE__ */ new Map();
1082
+ for (const phases of waiting)
1083
+ for (const phase of phases) {
1084
+ const key = setupPhaseKey(phase);
1085
+ const group = counts.get(key) ?? { text: words(phase), count: 0 };
1086
+ counts.set(key, group);
1087
+ group.count += 1;
1088
+ }
1089
+ if (counts.size === 0) return void 0;
1090
+ return [...counts.values()].map(({ text, count }) => `${count} waiting on ${withArticle(text)}`).join(", ");
1091
+ }
1092
+ function cleanupLine(cleanup, runner, view, record) {
1093
+ const done = record || cleanup.status !== "running";
1094
+ const { keepMs, resources } = cleanup;
1095
+ const text = !done && cleanup.waiting ? `${WAITING_FOR_SNAPSHOT}\u2026` : keepMs === null ? releaseText(resources, done) ?? "nothing to release" : orderText(runnerSandboxSteps(keepMs, resources, runner, done));
1096
+ const leftBehind = cleanupProblems(cleanup);
1097
+ const ending = done ? leftBehind === 0 ? "" : `: ${leftBehind} left behind` : "\u2026";
1098
+ return view.row(
1099
+ ` ${view.glyph(cleanup.status)} cleanup ${text}${!done && cleanup.waiting ? "" : ending}`,
1100
+ elapsed(view, cleanup.startedAt, cleanup.endedAt)
1101
+ );
1102
+ }
1103
+ function runnerSandboxSteps(keepMs, resources, runner, done) {
1104
+ const kept = runner?.kept;
1105
+ const release = releaseText(resources, done || kept !== void 0);
1106
+ const released = release === void 0 ? [] : [release];
1107
+ if (kept !== void 0)
1108
+ return [...released, `kept the runner sandbox until ${isoSecondsText(kept.stopsAt)}, with no network access`];
1109
+ if (!done && keepMs > 0)
1110
+ return ["giving the runner sandbox no network access", ...released, `keeping it running ${keepTimeText(keepMs)}`];
1111
+ if (release === void 0) return [`${done ? "stopped and deleted" : "stopping and deleting"} the runner sandbox`];
1112
+ return done ? ["stopped the runner sandbox", release, "deleted it"] : ["stopping the runner sandbox", release, "deleting it"];
1113
+ }
1114
+ function statusGlyph(status, now, paint2) {
1115
+ switch (status) {
1116
+ case "pending":
1117
+ return paint2.faint("\xB7");
1118
+ case "running":
1119
+ return paint2.active(SPINNER[Math.floor(now / 90) % SPINNER.length] ?? "\xB7");
1120
+ case "done":
1121
+ return paint2.done("\u2713");
1122
+ case "failed":
1123
+ return paint2.failed("\u2717");
1124
+ case "stopped":
1125
+ return paint2.stopped("\u25A0");
1126
+ }
1127
+ }
1128
+ function endText(outcome) {
1129
+ return outcome === "stopped" ? "stopped" : commandEnd(outcome);
1130
+ }
1131
+
1132
+ // src/commands/exec/view.ts
1133
+ var PROGRESS_TICK_MS = 1e3;
1134
+ var PLAIN_WIDTH = 80;
1135
+ function runView(options) {
1136
+ const { presentation, progress, context, mode } = options;
1137
+ if (progress === void 0) {
1138
+ return {
1139
+ observer: { observe: async () => {
1140
+ } },
1141
+ runnerTerminal: context.runnerTerminal,
1142
+ width: PLAIN_WIDTH,
1143
+ colorDepth: "none",
1144
+ finish: async () => {
1145
+ }
1146
+ };
1147
+ }
1148
+ const plainWidth = Math.min(Math.max(presentation.columns ?? PLAIN_WIDTH, 60), 120);
1149
+ if (mode.kind === "sandboxes") {
1150
+ const writer = droppingWriter(progress);
1151
+ const writeLines = async (lines) => {
1152
+ for (const line of lines) await writer(line);
1153
+ };
1154
+ if (presentation.kind === "live") {
1155
+ return sandboxesLiveView(context, presentation.colorDepth, plainWidth, mode.progress, writeLines);
1156
+ }
1157
+ return sandboxesPlainView(context, presentation.colorDepth, plainWidth, mode.progress, writeLines);
1158
+ }
1159
+ if (presentation.kind === "plain") {
1160
+ const writer = droppingWriter(progress);
1161
+ return {
1162
+ observer: lineProgress(writer, { github: presentation.github, verbose: mode.verbose }),
1163
+ runnerTerminal: context.runnerTerminal,
1164
+ width: plainWidth,
1165
+ colorDepth: presentation.colorDepth,
1166
+ finish: async (summary = []) => {
1167
+ for (const line of summary) await writer(line);
1168
+ }
1169
+ };
1170
+ }
1171
+ return singleLiveView(context, presentation.colorDepth, {
1172
+ showOutput: mode.showOutput || mode.verbose,
1173
+ verbose: mode.verbose
1174
+ });
1175
+ }
1176
+ function sandboxesLiveView(context, colorDepth, width, status, writeSummary) {
1177
+ const terminal = context.progressTerminal;
1178
+ const style = paint(colorDepth !== "none");
1179
+ let shown = false;
1180
+ let finished = false;
1181
+ return {
1182
+ observer: {
1183
+ observe: async (timed) => {
1184
+ if (finished) return;
1185
+ const lines = status.lines(timed);
1186
+ if (lines.length > 0) terminal.print("stderr", lines.map((line) => `${line}
1187
+ `).join(""));
1188
+ if (!shown && timed.event.kind === "sandboxes-started") {
1189
+ shown = true;
1190
+ terminal.show(() => finished ? [] : status.rows(context.clock.now().getTime(), style));
1191
+ }
1192
+ }
1193
+ },
1194
+ runnerTerminal: context.runnerTerminal,
1195
+ width,
1196
+ colorDepth,
1197
+ finish: async (summary = []) => {
1198
+ if (finished) return;
1199
+ finished = true;
1200
+ if (shown) terminal.settle();
1201
+ await writeSummary(summary);
1202
+ }
1203
+ };
1204
+ }
1205
+ function sandboxesPlainView(context, colorDepth, width, status, writeLines) {
1206
+ const abort = new AbortController();
1207
+ if (context.timer !== void 0) {
1208
+ const { timer, clock } = context;
1209
+ const tick = async () => {
1210
+ for (; ; ) {
1211
+ await timer.sleep(PROGRESS_TICK_MS, abort.signal);
1212
+ if (abort.signal.aborted) return;
1213
+ await writeLines(status.tick(clock.now().getTime()));
1214
+ }
1215
+ };
1216
+ void tick();
1217
+ }
1218
+ let finished = false;
1219
+ return {
1220
+ observer: {
1221
+ observe: async (timed) => {
1222
+ if (finished) return;
1223
+ await writeLines(status.lines(timed));
1224
+ }
1225
+ },
1226
+ runnerTerminal: context.runnerTerminal,
1227
+ width,
1228
+ colorDepth,
1229
+ finish: async (summary = []) => {
1230
+ if (finished) return;
1231
+ finished = true;
1232
+ abort.abort();
1233
+ await writeLines(summary);
1234
+ }
1235
+ };
1236
+ }
1237
+ function singleLiveView(context, colorDepth, options) {
1238
+ const { showOutput } = options;
1239
+ const colors = paint(colorDepth !== "none");
1240
+ const terminal = context.progressTerminal;
1241
+ let state = EMPTY_RUN_STATE;
1242
+ let phase;
1243
+ let headerPrinted = false;
1244
+ let live = false;
1245
+ let finished = false;
1246
+ const width = () => terminal.columns() - 1;
1247
+ const frame = () => phase === void 0 || finished ? [] : phaseFrame(state, phase, context.clock.now().getTime(), width(), colors);
1248
+ const print = (lines) => {
1249
+ if (lines.length > 0) terminal.print("stderr", lines.map((line) => `${line}
1250
+ `).join(""));
1251
+ };
1252
+ const header = () => {
1253
+ if (headerPrinted) return [];
1254
+ headerPrinted = true;
1255
+ return [headerLine(state, colors)];
1256
+ };
1257
+ return {
1258
+ observer: {
1259
+ observe: async (timed) => {
1260
+ if (finished) return;
1261
+ state = DEFINITION_SET.applyEvent(state, timed);
1262
+ const next = activePhase(state);
1263
+ if (next !== phase) {
1264
+ print([
1265
+ ...next === void 0 ? [] : header(),
1266
+ ...phase === void 0 ? [] : phaseRecord(state, phase, width(), colors)
1267
+ ]);
1268
+ phase = next;
1269
+ }
1270
+ print(noticeLines(timed, state.origin ?? timed.at.getTime(), options.verbose));
1271
+ const { event } = timed;
1272
+ if (showOutput && event.kind === "runner" && event.event.kind === "step-output") print([event.event.line]);
1273
+ if (!live) {
1274
+ terminal.show(frame);
1275
+ live = true;
1276
+ }
1277
+ }
1278
+ },
1279
+ runnerTerminal: {
1280
+ color: context.runnerTerminal.color,
1281
+ writeStdout: (text) => terminal.print("stdout", text),
1282
+ writeStderr: (text) => terminal.print("stderr", text)
1283
+ },
1284
+ get width() {
1285
+ return terminal.columns();
1286
+ },
1287
+ colorDepth,
1288
+ finish: async (summary = []) => {
1289
+ if (finished) return;
1290
+ finished = true;
1291
+ print([...header(), ...phase === void 0 ? [] : phaseRecord(state, phase, width(), colors), ...summary]);
1292
+ terminal.settle();
1293
+ }
1294
+ };
1295
+ }
1296
+ function noticeLines(timed, origin, verbose) {
1297
+ const line = (lane, text) => progressLine(timed.at.getTime() - origin, lane, text);
1298
+ const { event } = timed;
1299
+ switch (event.kind) {
1300
+ case "runner-prepared":
1301
+ return preparedNoteTexts(event).map((text) => line("runner", text));
1302
+ case "runner":
1303
+ return runnerNoticeLines(event.event, line);
1304
+ case "resource":
1305
+ return DEFINITION_SET.presentations.notices(event, { verbose }).map(({ lane, text }) => line(lane, text));
1306
+ case "resource-notice":
1307
+ return [line(event.lane, event.text)];
1308
+ case "resource-warning":
1309
+ return [line(event.lane, resourceWarningText(event))];
1310
+ case "resource-skipped":
1311
+ return [line("run", skippedText(event))];
1312
+ case "resource-acquired":
1313
+ case "started":
1314
+ case "requesting-token":
1315
+ case "minting":
1316
+ case "minted":
1317
+ case "cleanup-started":
1318
+ case "cleanup-finished":
1319
+ case "command-started":
1320
+ case "command-ended":
1321
+ case "lanes-started":
1322
+ case "lane-started":
1323
+ case "lane-ended":
1324
+ case "test":
1325
+ case "test-event-unreadable":
1326
+ case "test-events-incomplete":
1327
+ case "sandboxes-started":
1328
+ case "sandbox":
1329
+ case "sandbox-ended":
1330
+ return [];
1331
+ }
1332
+ }
1333
+ function runnerNoticeLines(event, line) {
1334
+ switch (event.kind) {
1335
+ case "snapshot-entry-not-written":
1336
+ return [line("runner", localIndexWriteFailureText(event.failure))];
1337
+ case "shared-snapshot-lookup-failed":
1338
+ return [line("runner", sharedSnapshotLookupFailedText(event.message))];
1339
+ case "snapshot-build-started":
1340
+ return event.why.kind === "no-snapshot" && event.why.rejected.length > 0 ? snapshotBuildTexts(event).map((text) => line("runner", text)) : [];
1341
+ case "snapshot-reused":
1342
+ case "runner-sandbox-starting":
1343
+ case "sandbox-started":
1344
+ case "output-started":
1345
+ case "output-ended":
1346
+ case "step-started":
1347
+ case "step-output":
1348
+ case "step-finished":
1349
+ case "snapshot-saving":
1350
+ case "snapshot-built":
1351
+ case "uploading":
1352
+ case "uploaded":
1353
+ case "command-output-started":
1354
+ case "command-stopped":
1355
+ case "stopping":
1356
+ case "waiting-for-snapshot":
1357
+ case "sandbox-kept":
1358
+ return [];
1359
+ }
1360
+ }
1361
+
1362
+ // src/commands/exec/execute-run.ts
1363
+ async function executePlannedRun(context, request, spec, plan) {
1364
+ const { planned, lifecycles } = plan;
1365
+ if (request.planOnly) return await runPlanOnly(context.app, planned, lifecycles, spec);
1366
+ if (planned.sandboxes === void 0) return await runSingle(context, request, spec, planned, lifecycles);
1367
+ return await runAcrossSandboxes(context, request, spec, planned, lifecycles);
1368
+ }
1369
+ async function runPlanOnly(app, plan, lifecycles, spec) {
1370
+ let vcpus = null;
1371
+ if (plan.runner.kind === "vercel-sandbox") {
1372
+ const prepared = await prepareRunnerForRun(app, plan.runner, {
1373
+ configFile: plan.configFile,
1374
+ resources: plan.resources,
1375
+ sandboxes: plan.sandboxes?.sandboxes.length ?? 1,
1376
+ secrets: plannedSecrets(lifecycles, plan.runner, plan.resources)
1377
+ });
1378
+ if (!prepared.ok) return prepared.refusal;
1379
+ vcpus = prepared.prepared.vcpus;
1380
+ }
1381
+ return spec.planned(
1382
+ buildPlannedFacts({
1383
+ version: app.version,
1384
+ commit: app.commit,
1385
+ plan,
1386
+ lifecycles,
1387
+ vcpus
1388
+ })
1389
+ );
1390
+ }
1391
+ async function runSingle(context, request, spec, planned, lifecycles) {
1392
+ const { app, ui, signal } = context;
1393
+ const { configFile, argv } = planned;
1394
+ const plan = plannedTestPlan(planned);
1395
+ const before = await beforeRunStarts(context, lifecycles, planned, request, plan);
1396
+ if (!before.ok) return before.refusal;
1397
+ const { runner: resolvedRunner, used } = before;
1398
+ const base = {
1399
+ argv,
1400
+ version: app.version,
1401
+ commit: app.commit,
1402
+ configFile,
1403
+ verbose: request.verbose,
1404
+ resources: used.requests,
1405
+ skipped: used.skipped
1406
+ };
1407
+ let run;
1408
+ if (resolvedRunner.kind === "vercel-sandbox") {
1409
+ const keepMs = resolveKeepMs(request.keepSandbox, resolvedRunner.options, "single");
1410
+ const requested = await runnerRequestFor(app, resolvedRunner, used, { configFile, sandboxes: 1, keepMs });
1411
+ if (!requested.ok) return requested.refusal;
1412
+ run = {
1413
+ ...base,
1414
+ runner: { kind: "vercel-sandbox", session: requested.runner, credential: resolvedRunner.credential }
1415
+ };
1416
+ } else {
1417
+ const env = Object.fromEntries(Object.entries(app.env).filter(([name]) => !used.hiddenVariables.includes(name)));
1418
+ run = {
1419
+ ...base,
1420
+ runner: {
1421
+ kind: "launch-machine",
1422
+ env,
1423
+ ...resolvedRunner.credential === void 0 ? {} : { credential: resolvedRunner.credential }
1424
+ }
1425
+ };
1426
+ }
1427
+ const secrets = [...used.secrets, ...resolvedRunner.kind === "vercel-sandbox" ? resolvedRunner.secrets : []];
1428
+ const redact = redactor(secrets);
1429
+ const git = await checkoutGit(app.context.checkout, app.cwd);
1430
+ const sigterm = resolvedRunner.kind === "launch-machine" ? forwardSigterm(signal) : void 0;
1431
+ const terminate = sigterm?.terminate ?? new AbortController().signal;
1432
+ const view = runView({
1433
+ presentation: app.presentation,
1434
+ progress: ui.progress,
1435
+ context: app.context,
1436
+ mode: { kind: "single", showOutput: request.showOutput, verbose: request.verbose }
1437
+ });
1438
+ const recording = await recordRun(app.context.runDirectories, {
1439
+ definitionSet: DEFINITION_SET,
1440
+ clock: app.context.clock,
1441
+ cwd: app.cwd,
1442
+ configFile,
1443
+ argv,
1444
+ ...spec.test === void 0 ? {} : { test: spec.test },
1445
+ plan,
1446
+ run,
1447
+ git,
1448
+ redact: (value) => redactStrings(value, redact)
1449
+ });
1450
+ const observer = recording.observer(view.observer);
1451
+ const terminal = recording.terminal(view.runnerTerminal);
1452
+ const collected = run.runner.kind === "vercel-sandbox" || recording.testEvents !== void 0;
1453
+ const runRequest = run.runner.kind === "launch-machine" && recording.testEvents !== void 0 ? { ...run, runner: { ...run.runner, testEvents: recording.testEvents } } : run;
1454
+ let outcome;
1455
+ try {
1456
+ outcome = await runLifecycle({
1457
+ execute: async () => await executeRun(
1458
+ DEFINITION_SET,
1459
+ { ...app.context, runnerTerminal: secrets.length === 0 ? terminal : redactingTerminal(terminal, redact) },
1460
+ app.resourceContexts,
1461
+ runRequest,
1462
+ { signal, terminate },
1463
+ timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact))
1464
+ ),
1465
+ redact,
1466
+ hasSecrets: secrets.length > 0,
1467
+ finishView: async () => await view.finish(),
1468
+ abandonRecording: async () => await recording.abandon()
1469
+ });
1470
+ } finally {
1471
+ sigterm?.release();
1472
+ }
1473
+ const { timeline: ran, finalResults } = await summarizeSingle(app, {
1474
+ command: spec.name,
1475
+ hints: spec.hints,
1476
+ view,
1477
+ recording,
1478
+ outcome
1479
+ });
1480
+ if (outcome.kind !== "ran") return mapStoppedOutcome(outcome);
1481
+ const { command } = outcome;
1482
+ const runId = recording.opened.ok ? recording.opened.id : null;
1483
+ app.exit.status = commandExitStatus(outcome.command);
1484
+ const facts = {
1485
+ version: app.version,
1486
+ commit: app.commit,
1487
+ configFile,
1488
+ resources: DEFINITION_SET.reports.ranFacts(outcome.resources),
1489
+ cleanup: RUN_CLEANUP.facts(outcome),
1490
+ command: command.kind === "exited" ? { exitCode: command.code, signal: null } : command.kind === "signaled" ? { exitCode: null, signal: command.signal } : { exitCode: null, signal: null },
1491
+ runner: outcome.runner === void 0 ? null : {
1492
+ snapshotId: outcome.runner.snapshotId,
1493
+ base: outcome.runner.base,
1494
+ builtBehind: outcome.runner.builtBehind,
1495
+ uploadBytes: outcome.runner.uploadBytes,
1496
+ built: outcome.runner.built,
1497
+ vcpus: outcome.runner.vcpus,
1498
+ region: outcome.runner.region,
1499
+ runtime: outcome.runner.runtime,
1500
+ buildMs: outcome.runner.buildMs
1501
+ },
1502
+ timeline: ran,
1503
+ runId
1504
+ };
1505
+ return spec.ran(
1506
+ secrets.length === 0 ? facts : redactStrings(facts, redact),
1507
+ plan,
1508
+ lacksFinalResults(command.kind === "exited" ? command.code : null, {
1509
+ ...finalResults,
1510
+ collected
1511
+ })
1512
+ );
1513
+ }
1514
+ async function runAcrossSandboxes(context, request, spec, planned, lifecycles) {
1515
+ const { app, ui, signal } = context;
1516
+ const { configFile, argv, runner: plannedRunner } = planned;
1517
+ const sandboxes = planned.sandboxes.sandboxes;
1518
+ const count = sandboxes.length;
1519
+ const plan = plannedTestPlan(planned);
1520
+ const before = await beforeRunStarts(context, lifecycles, planned, request, plan);
1521
+ if (!before.ok) return before.refusal;
1522
+ const { used } = before;
1523
+ const requested = await runnerRequestFor(app, plannedRunner, used, {
1524
+ configFile,
1525
+ sandboxes: count,
1526
+ keepMs: resolveKeepMs(request.keepSandbox, plannedRunner.options, "sandboxes")
1527
+ });
1528
+ if (!requested.ok) return requested.refusal;
1529
+ const { runner } = requested;
1530
+ const secrets = [...used.secrets, ...plannedRunner.secrets];
1531
+ const redact = redactor(secrets);
1532
+ const git = await checkoutGit(app.context.checkout, app.cwd);
1533
+ const recording = await recordAcrossSandboxes(app.context.runDirectories, {
1534
+ definitionSet: DEFINITION_SET,
1535
+ clock: app.context.clock,
1536
+ cwd: app.cwd,
1537
+ configFile,
1538
+ argv,
1539
+ ...spec.test === void 0 ? {} : { test: spec.test },
1540
+ plan,
1541
+ runner,
1542
+ sandboxes,
1543
+ git,
1544
+ redact: (value) => redactStrings(value, redact)
1545
+ });
1546
+ const runDirectory = recording.opened.ok ? `${displayPath(recording.opened.path, app.env)}/` : `none: couldn't make ${recording.opened.failure.path}: ${recording.opened.failure.message}`;
1547
+ const view = runView({
1548
+ presentation: app.presentation,
1549
+ progress: ui.progress,
1550
+ context: app.context,
1551
+ mode: {
1552
+ kind: "sandboxes",
1553
+ progress: sandboxProgress({
1554
+ count,
1555
+ listed: sandboxes.map(({ files }) => files === null ? null : files.length),
1556
+ header: acrossSandboxesHeaderLines({
1557
+ version: app.version,
1558
+ commit: app.commit,
1559
+ argv: argv.map(redact),
1560
+ count,
1561
+ runDirectory
1562
+ }).map(redact)
1563
+ })
1564
+ }
1565
+ });
1566
+ const observer = recording.observer(view.observer);
1567
+ const outcome = await runLifecycle({
1568
+ execute: async () => await executeAcrossSandboxes(
1569
+ DEFINITION_SET,
1570
+ {
1571
+ ...app.context,
1572
+ sandboxTerminal: (sandbox) => {
1573
+ const terminal = recording.terminal(sandbox, app.context.runnerTerminal);
1574
+ return secrets.length === 0 ? terminal : redactingTerminal(terminal, redact);
1575
+ }
1576
+ },
1577
+ app.resourceContexts,
1578
+ {
1579
+ version: app.version,
1580
+ commit: app.commit,
1581
+ configFile,
1582
+ verbose: request.verbose,
1583
+ runner,
1584
+ credential: plannedRunner.credential,
1585
+ sandboxes: sandboxes.map((sandbox) => ({
1586
+ argv: sandbox.argv,
1587
+ ...sandbox.files === null ? {} : { files: sandbox.files }
1588
+ })),
1589
+ resources: used.requests,
1590
+ skipped: used.skipped
1591
+ },
1592
+ { signal },
1593
+ timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact))
1594
+ ),
1595
+ redact,
1596
+ hasSecrets: secrets.length > 0,
1597
+ finishView: async () => await view.finish(),
1598
+ abandonRecording: async () => await recording.abandon()
1599
+ });
1600
+ const recorded = await recording.end(outcome);
1601
+ const mismatches = outcome.kind === "sandboxes_ran" ? listMismatches(recorded) : [];
1602
+ await summarizeAcrossSandboxes(app, {
1603
+ command: spec.name,
1604
+ hints: spec.hints,
1605
+ ...spec.extraMismatchHint === void 0 ? {} : { extraMismatchHint: spec.extraMismatchHint },
1606
+ view,
1607
+ recording,
1608
+ recorded,
1609
+ outcome,
1610
+ mismatches
1611
+ });
1612
+ if (outcome.kind === "sandboxes_ran") {
1613
+ app.exit.status = acrossSandboxesExitStatus(outcome.sandboxes);
1614
+ const facts = sandboxesRanFacts(app, { outcome, recorded, recording, plan, runner, configFile, mismatches });
1615
+ const everyExited0 = outcome.sandboxes.every(({ state, exitCode }) => state === "passed" && exitCode === 0);
1616
+ const noFinalTestResults = lacksFinalResults(everyExited0 ? 0 : null, {
1617
+ ...countFinalResults(recorded.tests),
1618
+ collected: true
1619
+ });
1620
+ return spec.sandboxesRan(secrets.length === 0 ? facts : redactStrings(facts, redact), noFinalTestResults);
1621
+ }
1622
+ const keptLines = recorded.sandboxes.flatMap(
1623
+ ({ record }) => record.name === null || record.keptUntil === null ? [] : [`Kept runner sandbox ${record.sandbox}, ${record.name}, running until ${isoSecondsText(record.keptUntil)}.`]
1624
+ );
1625
+ return mapStoppedOutcome(outcome, {
1626
+ commandLine: outcome.kind === "canceled" && outcome.commandStopped === true ? "Each command that was running was stopped in its runner sandbox." : "The command didn't run.",
1627
+ keptLines
1628
+ });
1629
+ }
1630
+ async function runLifecycle(options) {
1631
+ try {
1632
+ const ended = await options.execute();
1633
+ return options.hasSecrets ? redactStrings(ended, options.redact) : ended;
1634
+ } catch (error) {
1635
+ await options.finishView();
1636
+ await options.abandonRecording();
1637
+ throw error;
1638
+ }
1639
+ }
1640
+ async function checkoutGit(checkout, cwd) {
1641
+ const root = await checkout.repositoryRoot({ cwd });
1642
+ if (!root.ok) return null;
1643
+ const head = await checkout.head({ repoRoot: root.value });
1644
+ return head.ok ? { ...head.value } : null;
1645
+ }
1646
+
1647
+ // src/commands/exec/run-flags.ts
1648
+ import { z } from "zod";
1649
+ var SHOW_OUTPUT_ACROSS_SANDBOXES_DETAIL = "prints status lines and no step output, and each runner sandbox entry of its run directory keeps its step logs; drop --show-output.";
1650
+ var OWN_RUN_FIELDS = {
1651
+ scope: z.string().min(1).optional(),
1652
+ project: z.string().min(1).optional(),
1653
+ credential: z.enum(["mint", "github-actions", "vercel-oidc"]).optional(),
1654
+ showOutput: z.boolean().default(false),
1655
+ keepSandbox: z.string().optional(),
1656
+ verbose: z.boolean().default(false),
1657
+ planOnly: z.boolean().default(false)
1658
+ };
1659
+ var RUN_REQUEST_FIELDS = { ...OWN_RUN_FIELDS, ...resourceFlagFields(Object.keys(OWN_RUN_FIELDS)) };
1660
+ var RUN_CLI_OPTIONS = { project: { short: "p" } };
1661
+ var runRequestSchema = z.object(RUN_REQUEST_FIELDS);
1662
+ function sandboxesFlagProblems(request) {
1663
+ const flag = request.sandboxes !== void 0 ? "--sandboxes" : request.fileLists !== void 0 ? "--file-lists" : void 0;
1664
+ if (flag === void 0) return [];
1665
+ return request.showOutput ? [
1666
+ {
1667
+ field: "showOutput",
1668
+ message: `A run with ${flag} ${SHOW_OUTPUT_ACROSS_SANDBOXES_DETAIL}`
1669
+ }
1670
+ ] : [];
1671
+ }
1672
+ function runFlagProblems(request) {
1673
+ const { keepSandbox } = request;
1674
+ return [
1675
+ ...resourceFlagProblems(request),
1676
+ ...keepSandbox !== void 0 && parseKeepTime(keepSandbox) === void 0 ? [
1677
+ {
1678
+ field: "keepSandbox",
1679
+ message: `--keep-sandbox takes 0, or a whole number of minutes or hours up to 5h, such as 30m or 2h, not ${JSON.stringify(keepSandbox)}.`
1680
+ }
1681
+ ] : []
1682
+ ];
1683
+ }
1684
+
1685
+ // src/planning/driver-file-lists.ts
1686
+ function driverSandboxesRun(run) {
1687
+ const asked = run.asked.from === "flag" ? run.asked.count : Math.min(run.asked.default, run.max);
1688
+ const lists = dealFileLists(run.testFiles, asked);
1689
+ return {
1690
+ count: {
1691
+ count: lists.length,
1692
+ from: run.asked.from,
1693
+ max: run.max,
1694
+ ...run.asked.from === "default" ? { default: run.asked.default } : {},
1695
+ ...lists.length < asked ? { requested: asked } : {}
1696
+ },
1697
+ sandboxes: lists.map((files) => ({ argv: run.argv, files }))
1698
+ };
1699
+ }
1700
+ function driverCallerFileListsRun(run) {
1701
+ const resolved = resolveCallerFileLists(run.testFiles, run.lists);
1702
+ if (!resolved.ok) return resolved;
1703
+ return {
1704
+ ok: true,
1705
+ sandboxes: {
1706
+ count: {
1707
+ count: resolved.lists.length,
1708
+ from: "file-lists",
1709
+ max: run.max,
1710
+ ...resolved.leftOut > 0 ? { leftOut: resolved.leftOut } : {}
1711
+ },
1712
+ sandboxes: resolved.lists.map((files) => ({ argv: run.argv, files }))
1713
+ }
1714
+ };
1715
+ }
1716
+
1717
+ // src/planning/run-kind-flags.ts
1718
+ function unfitRunFlags(runner, flags) {
1719
+ if (runner === "vercel-sandbox") return flags.credential === "github-actions" ? ["credential"] : [];
1720
+ return [
1721
+ ...flags.showOutput ? ["showOutput"] : [],
1722
+ ...flags.keepSandbox === void 0 ? [] : ["keepSandbox"],
1723
+ ...flags.sandboxes === void 0 ? [] : ["sandboxes"],
1724
+ ...flags.fileLists === void 0 ? [] : ["fileLists"]
1725
+ ];
1726
+ }
1727
+ function runKindFlagName(flag) {
1728
+ switch (flag) {
1729
+ case "credential":
1730
+ return "--credential github-actions";
1731
+ case "showOutput":
1732
+ return "--show-output";
1733
+ case "keepSandbox":
1734
+ return "--keep-sandbox";
1735
+ case "sandboxes":
1736
+ return "--sandboxes";
1737
+ case "fileLists":
1738
+ return "--file-lists";
1739
+ }
1740
+ }
1741
+ function runKindFlagMessage(flag) {
1742
+ switch (flag) {
1743
+ case "credential":
1744
+ return "The Vercel Sandbox runner needs a Vercel credential (mint or vercel-oidc), so it can't use --credential github-actions.";
1745
+ case "showOutput":
1746
+ return "--show-output prints the Vercel Sandbox runner's step output, and this run uses the launch machine runner.";
1747
+ case "keepSandbox":
1748
+ return "--keep-sandbox keeps a Vercel Sandbox runner's sandbox, and this run uses the launch machine runner.";
1749
+ case "sandboxes":
1750
+ return "--sandboxes runs the command in several Vercel Sandbox runner sandboxes, and this run uses the launch machine runner.";
1751
+ case "fileLists":
1752
+ return "--file-lists runs each file list in its own Vercel Sandbox runner sandbox, and this run uses the launch machine runner.";
1753
+ }
1754
+ }
1755
+
1756
+ // src/commands/exec/run-bin.ts
1757
+ import { join } from "node:path";
1758
+ async function findRunBin(app, name, runner) {
1759
+ if (runner.kind === "launch-machine") {
1760
+ const cwd2 = app.cwd;
1761
+ const found2 = await app.packageBins.find(name, cwd2);
1762
+ return found2.ok ? { kind: "found", cwd: cwd2, counts: found2.path, runs: found2.path } : { kind: "not-found", cwd: cwd2, searched: found2.searched };
1763
+ }
1764
+ const root = await app.context.checkout.repositoryRoot({ cwd: app.cwd });
1765
+ if (!root.ok) return { kind: "checkout-failed", failure: root.failure };
1766
+ const cwd = join(root.value, runner.options.cwd);
1767
+ const found = await app.context.packageBins.find({ name, from: cwd, root: root.value });
1768
+ return found.ok ? { kind: "found", cwd, counts: found.path, runs: name } : { kind: "not-found", cwd, searched: found.searched };
1769
+ }
1770
+
1771
+ // src/commands/exec/driver-plan.ts
1772
+ function driverCount(driver, testPlan, countTests) {
1773
+ if (!testPlan && !countTests) return void 0;
1774
+ return { countTests: driver.countsFilesOnly !== true || countTests };
1775
+ }
1776
+ async function planDriverCommand(app, driver, errors, args, count, runner, signal) {
1777
+ const { bin: name } = driver.program;
1778
+ if (count === void 0 && runner.kind === "vercel-sandbox")
1779
+ return { ok: true, argv: driver.launch(name, args), testPlan: NOT_COUNTED.testPlan };
1780
+ const bin = await findRunBin(app, name, runner);
1781
+ if (bin.kind === "checkout-failed") return refused(checkoutFailedRefusal(bin.failure));
1782
+ const planned = { args, cwd: bin.cwd };
1783
+ if (bin.kind === "not-found")
1784
+ return refused(
1785
+ errors.planFailed(
1786
+ driver.name,
1787
+ { kind: "start-failed", message: `found no ${name} in node_modules/.bin of ${bin.searched.join(", ")}` },
1788
+ planned
1789
+ )
1790
+ );
1791
+ if (count === void 0) return { ok: true, argv: driver.launch(bin.runs, args), testPlan: NOT_COUNTED.testPlan };
1792
+ const contexts = app.driverContexts;
1793
+ const answer = await driver.plan(contexts[driver.name])({
1794
+ ...planned,
1795
+ bin: bin.counts,
1796
+ countTests: count.countTests,
1797
+ signal
1798
+ });
1799
+ if (!answer.ok) {
1800
+ const { kind, message } = answer;
1801
+ if (kind === "canceled") return refused(canceledBeforeStart());
1802
+ return refused(errors.planFailed(driver.name, { kind, message }, planned));
1803
+ }
1804
+ const { tests, files } = answer.plan;
1805
+ if ((tests ?? files) === 0) return refused(errors.noMatchingTests(driver.name, planned));
1806
+ return {
1807
+ ok: true,
1808
+ argv: driver.launch(bin.runs, args),
1809
+ testPlan: { kind: "counted", ...tests === void 0 ? {} : { tests }, files },
1810
+ ...answer.testFiles === void 0 ? {} : { testFiles: answer.testFiles }
1811
+ };
1812
+ }
1813
+
1814
+ // src/commands/exec/plan-run.ts
1815
+ var SANDBOXES_MAX_KEY = "runner.sandboxes.max";
1816
+ var SANDBOXES_DEFAULT_KEY = "runner.sandboxes.default";
1817
+ function checkDriverFileLists(driver, args) {
1818
+ if (driver.fileLists === void 0) {
1819
+ return {
1820
+ ok: false,
1821
+ kind: "unsupported",
1822
+ problem: `The ${driver.name} driver has no file list support, so storm test can't run it across runner sandboxes.`
1823
+ };
1824
+ }
1825
+ const checked = driver.fileLists.validate(args);
1826
+ return checked.ok ? { ok: true } : { ok: false, kind: "args", problem: checked.problem };
1827
+ }
1828
+ function driverSandboxesProblem(driver, args, asks) {
1829
+ const flag = asks.fileLists !== void 0 ? "--file-lists" : asks.sandboxes !== void 0 ? "--sandboxes" : void 0;
1830
+ if (flag === void 0) return void 0;
1831
+ const checked = checkDriverFileLists(driver, args);
1832
+ return checked.ok ? void 0 : { kind: checked.kind, flag, problem: checked.problem };
1833
+ }
1834
+ function checkSandboxesMax(runner, asked, configFile) {
1835
+ if (runner.kind !== "vercel-sandbox") throw new Error("a run across runner sandboxes uses the Vercel Sandbox runner");
1836
+ const policy = runner.options.sandboxes;
1837
+ if (policy === void 0)
1838
+ return refused(sandboxesErrors.missingSandboxesMax({ flag: asked.flag, key: SANDBOXES_MAX_KEY, configFile }));
1839
+ if (asked.count > policy.max)
1840
+ return refused(
1841
+ sandboxesErrors.sandboxesOverMax({
1842
+ flag: asked.flag,
1843
+ sandboxes: asked.count,
1844
+ key: SANDBOXES_MAX_KEY,
1845
+ max: policy.max,
1846
+ configFile
1847
+ })
1848
+ );
1849
+ return { ok: true, runner, max: policy.max };
1850
+ }
1851
+ async function planRun(app, request, target, signal) {
1852
+ const lifecycles = DEFINITION_SET.lifecycles(app.resourceContexts);
1853
+ const given = resourceFlagValues(request);
1854
+ const file = request.settingsFile;
1855
+ const configFile = file.path;
1856
+ const settings = fileSettings(file, request);
1857
+ const runner = request.runner === "launch-machine" ? { kind: "launch-machine" } : settings.runner?.value;
1858
+ if (runner === void 0) return refused(runErrors.missingRunner({ configFile }));
1859
+ const unfit = unfitRunFlags(runner.kind, request);
1860
+ if (unfit.length > 0) {
1861
+ return refused(
1862
+ runErrors.conflictingOptions({
1863
+ conflicts: unfit.map((flag) => ({ flag: runKindFlagName(flag), message: runKindFlagMessage(flag) })),
1864
+ runner: runner.kind,
1865
+ suite: request.suite,
1866
+ configFile
1867
+ })
1868
+ );
1869
+ }
1870
+ let plannedRunner;
1871
+ if (runner.kind === "launch-machine") plannedRunner = { kind: "launch-machine" };
1872
+ else {
1873
+ if (configFile === null) throw new Error("planRun: the Vercel Sandbox runner comes from a config file");
1874
+ const chosen = settleCredential(request.credential ?? "mint", settings.scope, settings.project);
1875
+ if (!chosen.ok) return chosen;
1876
+ if (chosen.credential.source === "github-actions")
1877
+ throw new Error("planRun: --credential github-actions should have been refused for vercel-sandbox");
1878
+ const targetConfig = givenTarget(settings.scope, settings.project);
1879
+ const { options } = runner;
1880
+ const credentials = readCredentials(options, app.env);
1881
+ if (!credentials.ok)
1882
+ return refused(
1883
+ runErrors.credentialsInvalid({
1884
+ variables: credentials.variables.map(({ name, problem }) => ({ name, problem })),
1885
+ minLength: SECRET_MIN_LENGTH,
1886
+ configFile
1887
+ })
1888
+ );
1889
+ const keepFlagMinutes = request.keepSandbox === void 0 ? 0 : parseKeepTime(request.keepSandbox) ?? 0;
1890
+ if (options.unsafeSecretEnvVars.length > 0 && keepFlagMinutes > 0)
1891
+ return refused(
1892
+ runErrors.keepSandboxUnsafeSecretEnvVars({
1893
+ variables: options.unsafeSecretEnvVars.map(({ name }) => name),
1894
+ configFile
1895
+ })
1896
+ );
1897
+ const unsafeSecretEnvVars = readUnsafeSecretEnvVars(options, app.env);
1898
+ if (!unsafeSecretEnvVars.ok)
1899
+ return refused(
1900
+ runErrors.unsafeSecretEnvVarsInvalid({
1901
+ variables: unsafeSecretEnvVars.variables.map(({ name, problem }) => ({ name, problem })),
1902
+ minLength: SECRET_MIN_LENGTH,
1903
+ configFile
1904
+ })
1905
+ );
1906
+ plannedRunner = {
1907
+ kind: "vercel-sandbox",
1908
+ configFile,
1909
+ options,
1910
+ credential: chosen.credential,
1911
+ target: targetConfig,
1912
+ credentials: credentials.credentials,
1913
+ unsafeSecretEnvVars: unsafeSecretEnvVars.values,
1914
+ secrets: [...credentials.credentials.map(({ value }) => value), ...Object.values(unsafeSecretEnvVars.values)]
1915
+ };
1916
+ }
1917
+ const merged = settleRunResources(file, given);
1918
+ if (!merged.ok) return merged;
1919
+ const command = await planTarget(
1920
+ app,
1921
+ request,
1922
+ target,
1923
+ plannedRunner,
1924
+ settings.testPlan?.value === true,
1925
+ configFile,
1926
+ signal
1927
+ );
1928
+ if (signal.aborted) return refused(canceledBeforeStart());
1929
+ if (!command.ok) {
1930
+ const secrets = [
1931
+ ...plannedRunner.kind === "vercel-sandbox" ? plannedRunner.secrets : [],
1932
+ ...lifecycles.secrets(merged.options)
1933
+ ];
1934
+ return refused(secrets.length === 0 ? command.refusal : redactStrings(command.refusal, redactor(secrets)));
1935
+ }
1936
+ const run = Object.freeze({
1937
+ testPlan: command.testPlan,
1938
+ sandboxes: command.sandboxes?.sandboxes.length ?? 1
1939
+ });
1940
+ const resolved = merged.plan(run);
1941
+ if (!resolved.ok) return resolved;
1942
+ if (command.sandboxes?.count.from === "default" && request.showOutput) {
1943
+ return refused(
1944
+ sandboxesDefaultErrors.sandboxesDefaultRefused({
1945
+ key: SANDBOXES_DEFAULT_KEY,
1946
+ sandboxes: command.sandboxes.sandboxes.length,
1947
+ field: "showOutput",
1948
+ problem: `a run across runner sandboxes ${SHOW_OUTPUT_ACROSS_SANDBOXES_DETAIL}`,
1949
+ configFile
1950
+ })
1951
+ );
1952
+ }
1953
+ const basePlan = {
1954
+ configFile,
1955
+ settings,
1956
+ argv: command.argv,
1957
+ testPlan: command.testPlan,
1958
+ testFiles: command.testFiles,
1959
+ resources: resolved.resources,
1960
+ planOptions: resolved.planned.map(planOption)
1961
+ };
1962
+ const planned = command.sandboxes === void 0 ? { ...basePlan, runner: plannedRunner, sandboxes: void 0 } : { ...basePlan, runner: command.runner, sandboxes: command.sandboxes };
1963
+ return { ok: true, planned, lifecycles };
1964
+ }
1965
+ async function planDriverFiles(app, target, runner, signal) {
1966
+ const { driver, args, countTests, errors } = target;
1967
+ const planned = await planDriverCommand(
1968
+ app,
1969
+ driver,
1970
+ errors,
1971
+ args,
1972
+ { countTests: driver.countsFilesOnly !== true || countTests },
1973
+ runner,
1974
+ signal
1975
+ );
1976
+ if (!planned.ok) return planned;
1977
+ const { argv, testPlan, testFiles } = planned;
1978
+ if (testFiles === void 0) {
1979
+ throw new Error(`planRun: driver ${driver.name} has file list support, and its plan step answered no test files`);
1980
+ }
1981
+ return { ok: true, argv, testPlan, testFiles };
1982
+ }
1983
+ async function planTarget(app, request, target, runner, testPlanSetting, configFile, signal) {
1984
+ if (target.kind === "exec") {
1985
+ const { command } = target;
1986
+ if (request.sandboxes === void 0) {
1987
+ return { ok: true, argv: command, testPlan: NOT_COUNTED.testPlan, runner };
1988
+ }
1989
+ const checked = checkSandboxesMax(runner, { count: request.sandboxes, flag: "--sandboxes" }, configFile);
1990
+ if (!checked.ok) return checked;
1991
+ return {
1992
+ ok: true,
1993
+ argv: command,
1994
+ testPlan: NOT_COUNTED.testPlan,
1995
+ runner: checked.runner,
1996
+ sandboxes: {
1997
+ count: { count: request.sandboxes, from: "flag", max: checked.max },
1998
+ sandboxes: commandsForSandboxes(command, request.sandboxes).map((argv) => ({ argv, files: null }))
1999
+ }
2000
+ };
2001
+ }
2002
+ const { driver, args, countTests, errors } = target;
2003
+ let lists;
2004
+ if (request.fileLists !== void 0) {
2005
+ const read = await readFileListsFile(app.context.fileListsFiles, {
2006
+ path: request.fileLists,
2007
+ cwd: app.cwd,
2008
+ sandboxes: request.sandboxes
2009
+ });
2010
+ if (!read.ok) {
2011
+ return refused(
2012
+ read.kind === "unreadable" ? fileListErrors.fileListsUnreadable({ path: read.path, problem: read.problem, message: read.message }) : fileListErrors.invalidFileLists({
2013
+ path: read.path,
2014
+ problems: read.problems.map(
2015
+ (problem) => problem.kind === "in-two-lists" ? { ...problem, sandboxes: [...problem.sandboxes] } : { ...problem }
2016
+ )
2017
+ })
2018
+ );
2019
+ }
2020
+ lists = read.lists;
2021
+ }
2022
+ const asked = lists !== void 0 ? { count: lists.lists.length, flag: "--file-lists" } : request.sandboxes === void 0 ? void 0 : { count: request.sandboxes, flag: "--sandboxes" };
2023
+ if (asked !== void 0) {
2024
+ const checked = checkSandboxesMax(runner, asked, configFile);
2025
+ if (!checked.ok) return checked;
2026
+ const planned = await planDriverFiles(app, target, checked.runner, signal);
2027
+ if (!planned.ok) return planned;
2028
+ const { argv, testPlan, testFiles } = planned;
2029
+ if (lists === void 0) {
2030
+ return {
2031
+ ok: true,
2032
+ argv,
2033
+ testPlan,
2034
+ testFiles,
2035
+ runner: checked.runner,
2036
+ sandboxes: driverSandboxesRun({
2037
+ argv,
2038
+ testFiles,
2039
+ asked: { from: "flag", count: asked.count },
2040
+ max: checked.max
2041
+ })
2042
+ };
2043
+ }
2044
+ const resolved = driverCallerFileListsRun({ argv, testFiles, lists, max: checked.max });
2045
+ if (!resolved.ok) {
2046
+ return refused(
2047
+ fileListErrors.fileListsUnlisted({
2048
+ path: lists.path,
2049
+ files: [...resolved.unlisted],
2050
+ listed: resolved.listed
2051
+ })
2052
+ );
2053
+ }
2054
+ return { ok: true, argv, testPlan, testFiles, runner: checked.runner, sandboxes: resolved.sandboxes };
2055
+ }
2056
+ const policy = runner.kind === "vercel-sandbox" ? runner.options.sandboxes : void 0;
2057
+ if (driver.fileLists !== void 0 && runner.kind === "vercel-sandbox" && policy?.default !== void 0) {
2058
+ const planned = await planDriverFiles(app, target, runner, signal);
2059
+ if (!planned.ok) return planned;
2060
+ const { argv, testPlan, testFiles } = planned;
2061
+ const resolved = resolveSandboxCountDefault(policy.default, testPlan);
2062
+ const checked = checkDriverFileLists(driver, args);
2063
+ if (!checked.ok) {
2064
+ return refused(
2065
+ sandboxesDefaultErrors.sandboxesDefaultRefused({
2066
+ key: SANDBOXES_DEFAULT_KEY,
2067
+ sandboxes: Math.min(resolved, policy.max, testFiles.length),
2068
+ field: "args",
2069
+ problem: checked.problem,
2070
+ configFile
2071
+ })
2072
+ );
2073
+ }
2074
+ return {
2075
+ ok: true,
2076
+ argv,
2077
+ testPlan,
2078
+ testFiles,
2079
+ runner,
2080
+ sandboxes: driverSandboxesRun({
2081
+ argv,
2082
+ testFiles,
2083
+ asked: { from: "default", default: resolved },
2084
+ max: policy.max
2085
+ })
2086
+ };
2087
+ }
2088
+ const single = await planDriverCommand(
2089
+ app,
2090
+ driver,
2091
+ errors,
2092
+ args,
2093
+ driverCount(driver, testPlanSetting, countTests),
2094
+ runner,
2095
+ signal
2096
+ );
2097
+ if (!single.ok) return single;
2098
+ return { ...single, runner };
2099
+ }
2100
+ function planOption({ path, value, source }) {
2101
+ return { path, value, from: source };
2102
+ }
2103
+
2104
+ // src/commands/exec/run-metadata.ts
2105
+ var RUN_USAGE_FLAGS = `${RESOURCE_USAGE_FLAGS} [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--show-output] [--keep-sandbox <DURATION>] [--verbose] [--plan-only]`;
2106
+ var EXEC_USAGE_FLAGS = `${RESOURCE_USAGE_FLAGS} [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--runner <KIND> | [--show-output] [--keep-sandbox <DURATION>]] [--verbose] [--plan-only]`;
2107
+ var ownRunFields = (verbose) => ({
2108
+ credential: {
2109
+ valueLabel: "SOURCE",
2110
+ description: "The credential source: mint, the default, mints one with the vercel CLI for --scope and --project; vercel-oidc reads a pre-minted Vercel project OIDC token from VERCEL_OIDC_TOKEN and needs no --scope or --project; github-actions requests a GitHub Actions OIDC token, in a GitHub Actions job with permissions id-token: write, anew once it is 4 minutes old, and needs no --scope or --project. The Vercel Sandbox runner accepts mint and vercel-oidc, and refuses github-actions. On the launch machine, only a run with a resource that takes a credential takes it, as that resource's options decide; otherwise it is credential_unused. This credential is the Vercel OIDC token storm uses for its own calls, not a sandbox credential that runner.credentials declares: the word has both uses until a rename. No config key."
2111
+ },
2112
+ keepSandbox: {
2113
+ valueLabel: "DURATION",
2114
+ description: "Keep the runner sandbox running this long once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). A run keeps its runner sandbox only when this flag or keepSandbox in vercelSandbox({ \u2026 }) asks; by default it stops and deletes it, after a failure too. A kept runner sandbox holds the checkout, the installed packages, and everything the command wrote, including its test output; storm removes nothing from it, and it holds no credential, the runner's or a resource's, since storm revokes every sandbox credential before it keeps the sandbox. Anyone who can update the Vercel project can connect to it. Refused when vercelSandbox({ \u2026 }) sets unsafeSecretEnvVars, because a run that passes secrets into the runner sandbox's environment never keeps its runner sandbox. storm gives the kept runner sandbox no network access before it releases the run's resources: once the run releases its resources, another run can take them. Before it keeps the sandbox, the run ends every process it started there. The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in vercelSandbox({ \u2026 }), else 0; a run across runner sandboxes keeps each runner sandbox only with --keep-sandbox and ignores keepSandbox in vercelSandbox({ \u2026 }). Fits the Vercel Sandbox runner only."
2115
+ },
2116
+ showOutput: {
2117
+ description: "With the Vercel Sandbox runner on a terminal, print the runner's step output (a snapshot build, the install, the build) above the live view instead of keeping only each step's last line there. Plain output always prints it. Either way, the run directory keeps it whole. Fits the Vercel Sandbox runner only. No config key."
2118
+ },
2119
+ verbose: {
2120
+ description: `Print more as it happens: each resource's detailed progress, the runner's step output as with --show-output, and verbose in the run payload, ${verbose}. No config key.`
2121
+ },
2122
+ planOnly: {
2123
+ description: "Plan the run and print the planned run, then exit 0, with nothing started: storm loads storm.config.ts, does the local checks, and runs the plan step, which may list the test files on this machine, and mints nothing, acquires no resource, starts no sandbox, and opens no run directory. It prints the plan line, one line for each runner sandbox with the number of its test files (or its command, for storm exec), and the vCPUs of the runner sandbox; under --json, the planned result holds the test files, the plan with the number of runner sandboxes, where it came from, and its max, runner.sandboxes, each runner sandbox's command and file list, each resource option with its value and where it came from, and the vCPUs. With --sandboxes or --file-lists it shows the plan of those, and a refusal a run gets before it mints, it gets too. It calls no resource's own checks before the run, and needs no credential. No config key."
2124
+ },
2125
+ scope: {
2126
+ valueLabel: "TEAM",
2127
+ description: "The control plane team: the Vercel team whose project the credential is minted for and the Vercel Sandbox runner's sandboxes run in. Required, from this flag or scope in storm.config.ts, unless the run takes --credential vercel-oidc or --credential github-actions, or is a launch machine run with no resource that takes a credential."
2128
+ },
2129
+ project: {
2130
+ valueLabel: "PROJECT",
2131
+ description: "The control plane project: the Vercel project, within the team, to mint the credential for. Required, from this flag or project in storm.config.ts, unless the run takes --credential vercel-oidc or --credential github-actions, or is a launch machine run with no resource that takes a credential."
2132
+ }
2133
+ });
2134
+ function runFields(verbose) {
2135
+ return { ...RESOURCE_FLAG_HELP, ...ownRunFields(verbose) };
2136
+ }
2137
+ function runHelp(words, field, options = {}) {
2138
+ const usageFlags = options.runnerFlag === true ? EXEC_USAGE_FLAGS : RUN_USAGE_FLAGS;
2139
+ return {
2140
+ usages: [`${usageFlags} ${words.usage}`],
2141
+ fields: { ...runFields(words.verbose), [field]: { valueLabel: field, description: words.args } },
2142
+ examples: [...words.examples, ...options.includeResourceExamples === true ? resourceRunExamples() : []]
2143
+ };
2144
+ }
2145
+ var DRIVER_SANDBOXES_HELP = {
2146
+ valueLabel: "N",
2147
+ description: "Run in N runner sandboxes at once, a run across runner sandboxes, with a driver that has file list support, else driver_sandboxes_refused: storm lists the run's test files on this machine, whether or not storm.config.ts sets testPlan, sorts them, deals them in turn into N file lists, the first file to runner sandbox 0's list, the second to runner sandbox 1's, and so on, and runs each file list in its own runner sandbox, all started from one runner snapshot, with the run's arguments unchanged and each runner sandbox's file list in STORM_RUN. With fewer test files than N, the run has one runner sandbox for each test file, and the plan line says so. N is a whole number from 1 to runner.sandboxes.max in storm.config.ts, and a config file without runner.sandboxes takes no --sandboxes. Each runner sandbox's command output goes only to its command.log in the run directory, under sandboxes/<index>/, and the run prints one status line for each runner sandbox's step, then each runner sandbox's waterfall, a table of the runner sandboxes, and a warning, file_list_mismatch, for each runner sandbox that reported nothing for a test file of its list or reported a test file not in its list; storm exits 0 when every runner sandbox passed, else 1, warning or not. The run keeps each runner sandbox only with --keep-sandbox. To give your own lists, use --file-lists. Fits the Vercel Sandbox runner only. Not with --show-output. Config key: runner.sandboxes.default, the number of runner sandboxes of a run with neither --sandboxes nor --file-lists, a whole number or a declared { filesPerSandbox, max? } rule, lowered to runner.sandboxes.max when it is above it; with it, every such run is a run across runner sandboxes, also with one runner sandbox."
2148
+ };
2149
+ var DRIVER_FILE_LISTS_HELP = {
2150
+ valueLabel: "PATH",
2151
+ description: `Run with your own file lists, a run across runner sandboxes, with a driver that has file list support, else driver_sandboxes_refused: PATH is a JSON file (or - to read from stdin) that holds an array with one array of test file paths for each runner sandbox, in order of runner sandbox index, such as [["test/a.test.ts", "test/b.test.ts"], ["test/c.test.ts"]], each path relative to the project, as the planned result's testFiles under --plan-only --json names it. The number of lists is the number of runner sandboxes, at most runner.sandboxes.max in storm.config.ts; with --sandboxes too, the two numbers must agree. storm lists the run's test files on this machine with the run's arguments, so a file filter among them limits which paths a list can hold, passes each runner sandbox's assigned file list in STORM_RUN while keeping the run's arguments unchanged, and refuses before it mints a file it can't read or that isn't that shape (file_lists_unreadable), an empty list, a test file in two lists, or a number of lists that differs from --sandboxes (invalid_file_lists), a path the listing doesn't have (file_lists_unlisted), and more lists than the max (sandboxes_over_max). A test file in no list is left out of the run, and the plan line says how many it runs: Running 12 of 57 test files in 2 runner sandboxes (--file-lists, max 4). The rest is as with --sandboxes. Fits the Vercel Sandbox runner only. Not with --show-output. It overrides runner.sandboxes.default. No config key.`
2152
+ };
2153
+
2154
+ export {
2155
+ placeholderProblems,
2156
+ executePlannedRun,
2157
+ RUN_REQUEST_FIELDS,
2158
+ RUN_CLI_OPTIONS,
2159
+ sandboxesFlagProblems,
2160
+ runFlagProblems,
2161
+ driverSandboxesProblem,
2162
+ planRun,
2163
+ runHelp,
2164
+ DRIVER_SANDBOXES_HELP,
2165
+ DRIVER_FILE_LISTS_HELP
2166
+ };