@cnc-tools/storm 0.14.2 → 0.15.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 (401) hide show
  1. package/dist/application.js +3 -1
  2. package/dist/bin/storm.js +9 -7
  3. package/dist/build-info.js +1 -1
  4. package/dist/chunks/chunk-4U4DZ7VG.js +40 -0
  5. package/dist/chunks/{chunk-GSC6SRTW.js → chunk-5CCP36QQ.js} +1 -1
  6. package/dist/chunks/chunk-5GBMR4HM.js +966 -0
  7. package/dist/chunks/{chunk-43MWZLJR.js → chunk-5VXBKPW6.js} +1 -1
  8. package/dist/chunks/{chunk-RA4L2ACU.js → chunk-AWBSONHB.js} +88 -34
  9. package/dist/chunks/{chunk-BRUIATTR.js → chunk-CN4EFA5J.js} +59 -12
  10. package/dist/chunks/{chunk-3HBPNQ4Y.js → chunk-CXAT7ZKP.js} +2 -2
  11. package/dist/chunks/chunk-E4PJNZVG.js +783 -0
  12. package/dist/chunks/{chunk-T6AZIDZD.js → chunk-F6N34UWB.js} +12 -244
  13. package/dist/chunks/{chunk-RUPD4TLT.js → chunk-KC4KDJ5K.js} +147 -26
  14. package/dist/chunks/{chunk-I7AN3DIJ.js → chunk-L36GBUBB.js} +1626 -676
  15. package/dist/chunks/{chunk-XZCDA5PE.js → chunk-OX7X4B2L.js} +7 -2
  16. package/dist/chunks/{chunk-UUBZTGLV.js → chunk-PN5ULTTH.js} +140 -130
  17. package/dist/chunks/chunk-QUHY6FGN.js +108 -0
  18. package/dist/chunks/chunk-QVS7HRU7.js +74 -0
  19. package/dist/chunks/{chunk-UC6DULWY.js → chunk-R7XVBZOY.js} +130 -39
  20. package/dist/chunks/{chunk-LUOHJ3LB.js → chunk-RAQEXKL6.js} +1120 -465
  21. package/dist/chunks/{chunk-GJOEPJJL.js → chunk-SZEURWRS.js} +446 -52
  22. package/dist/chunks/chunk-TJNFVNKR.js +246 -0
  23. package/dist/chunks/{chunk-BW2ADH7U.js → chunk-VUPZH7J2.js} +1 -1
  24. package/dist/chunks/{chunk-HDL4WKIB.js → chunk-XEVHP5ZW.js} +2 -2
  25. package/dist/chunks/{chunk-VH2POPW5.js → chunk-YV7GE6EV.js} +635 -79
  26. package/dist/chunks/{chunk-GQIL3AHY.js → chunk-ZG3WQ4UF.js} +1 -1
  27. package/dist/chunks/{live-app-SZGEILCQ.js → live-app-PI3BAN6Y.js} +28 -23
  28. package/dist/command-tree.d.ts +2 -2
  29. package/dist/command-tree.js +2 -2
  30. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +364 -0
  31. package/dist/commands/exec/across-sandboxes-outcomes.js +229 -0
  32. package/dist/commands/exec/across-sandboxes-run.d.ts +180 -0
  33. package/dist/commands/exec/across-sandboxes-run.js +339 -0
  34. package/dist/commands/exec/command.d.ts +577 -75
  35. package/dist/commands/exec/command.js +165 -32
  36. package/dist/commands/exec/driver-plan.d.ts +8 -2
  37. package/dist/commands/exec/driver-plan.js +13 -3
  38. package/dist/commands/exec/exec-words.d.ts +17 -3
  39. package/dist/commands/exec/exec-words.js +27 -16
  40. package/dist/commands/exec/live-view.d.ts +3 -4
  41. package/dist/commands/exec/live-view.js +37 -28
  42. package/dist/commands/exec/metadata.js +2 -2
  43. package/dist/commands/exec/mint-failed.d.ts +4 -4
  44. package/dist/commands/exec/mint-failed.js +6 -6
  45. package/dist/commands/exec/outcomes.d.ts +530 -73
  46. package/dist/commands/exec/outcomes.js +202 -66
  47. package/dist/commands/exec/plan-only.d.ts +10 -0
  48. package/dist/commands/exec/plan-only.js +46 -0
  49. package/dist/commands/exec/plan-run.d.ts +54 -35
  50. package/dist/commands/exec/plan-run.js +81 -38
  51. package/dist/commands/exec/planned-outcome.d.ts +15 -0
  52. package/dist/commands/exec/planned-outcome.js +35 -0
  53. package/dist/commands/exec/progress.d.ts +2 -2
  54. package/dist/commands/exec/progress.js +35 -18
  55. package/dist/commands/exec/resource-refusals.d.ts +2 -2
  56. package/dist/commands/exec/resource-refusals.js +3 -3
  57. package/dist/commands/exec/run-bin.d.ts +1 -1
  58. package/dist/commands/exec/run-bin.js +2 -2
  59. package/dist/commands/exec/run-command.d.ts +345 -63
  60. package/dist/commands/exec/run-command.js +308 -258
  61. package/dist/commands/exec/run-metadata.d.ts +42 -8
  62. package/dist/commands/exec/run-metadata.js +40 -21
  63. package/dist/commands/exec/run-planned.d.ts +20 -0
  64. package/dist/commands/exec/run-planned.js +22 -0
  65. package/dist/commands/exec/sandbox-lines.d.ts +42 -0
  66. package/dist/commands/exec/sandbox-lines.js +59 -0
  67. package/dist/commands/exec/sandbox-progress.d.ts +30 -0
  68. package/dist/commands/exec/sandbox-progress.js +232 -0
  69. package/dist/commands/exec/sandbox-view.d.ts +19 -0
  70. package/dist/commands/exec/sandbox-view.js +72 -0
  71. package/dist/commands/exec/view.d.ts +3 -2
  72. package/dist/commands/exec/view.js +10 -6
  73. package/dist/commands/runs/facts.d.ts +51 -9
  74. package/dist/commands/runs/facts.js +49 -29
  75. package/dist/commands/runs/list/command.d.ts +80 -4
  76. package/dist/commands/runs/list/command.js +11 -10
  77. package/dist/commands/runs/list/metadata.js +1 -1
  78. package/dist/commands/runs/list/outcomes.d.ts +40 -2
  79. package/dist/commands/runs/logs/command.d.ts +103 -8
  80. package/dist/commands/runs/logs/command.js +139 -24
  81. package/dist/commands/runs/logs/metadata.d.ts +4 -0
  82. package/dist/commands/runs/logs/metadata.js +14 -7
  83. package/dist/commands/runs/logs/outcomes.d.ts +49 -2
  84. package/dist/commands/runs/logs/outcomes.js +110 -6
  85. package/dist/commands/runs/past-run.d.ts +77 -6
  86. package/dist/commands/runs/past-run.js +133 -4
  87. package/dist/commands/runs/show/command.d.ts +568 -10
  88. package/dist/commands/runs/show/command.js +634 -119
  89. package/dist/commands/runs/show/metadata.d.ts +17 -0
  90. package/dist/commands/runs/show/metadata.js +48 -7
  91. package/dist/commands/runs/show/outcomes.d.ts +276 -5
  92. package/dist/commands/runs/show/outcomes.js +484 -96
  93. package/dist/commands/snapshots/build/command.d.ts +109 -18
  94. package/dist/commands/snapshots/build/command.js +72 -36
  95. package/dist/commands/snapshots/build/metadata.d.ts +4 -0
  96. package/dist/commands/snapshots/build/metadata.js +5 -1
  97. package/dist/commands/snapshots/build/outcomes.d.ts +53 -8
  98. package/dist/commands/snapshots/build/outcomes.js +26 -3
  99. package/dist/commands/snapshots/list/command.d.ts +72 -7
  100. package/dist/commands/snapshots/list/command.js +57 -24
  101. package/dist/commands/snapshots/list/metadata.d.ts +4 -0
  102. package/dist/commands/snapshots/list/metadata.js +4 -0
  103. package/dist/commands/snapshots/list/outcomes.d.ts +31 -0
  104. package/dist/commands/snapshots/list/outcomes.js +25 -2
  105. package/dist/commands/suites/list/command.d.ts +129 -0
  106. package/dist/commands/suites/list/command.js +162 -0
  107. package/dist/commands/suites/list/metadata.d.ts +11 -0
  108. package/dist/commands/suites/list/metadata.js +15 -0
  109. package/dist/commands/suites/list/outcomes.d.ts +91 -0
  110. package/dist/commands/suites/list/outcomes.js +122 -0
  111. package/dist/commands/suites/metadata.js +8 -0
  112. package/dist/commands/test/command.d.ts +1389 -0
  113. package/dist/commands/test/command.js +583 -0
  114. package/dist/commands/test/metadata.js +8 -0
  115. package/dist/commands/test/outcomes.d.ts +765 -0
  116. package/dist/commands/test/outcomes.js +140 -0
  117. package/dist/commands/test/plan.d.ts +92 -0
  118. package/dist/commands/test/plan.js +128 -0
  119. package/dist/commands/test/test-words.d.ts +12 -0
  120. package/dist/commands/test/test-words.js +42 -0
  121. package/dist/config/check-resources.d.ts +14 -0
  122. package/dist/config/check-resources.js +98 -0
  123. package/dist/config/check-runner.d.ts +13 -0
  124. package/dist/config/check-runner.js +54 -0
  125. package/dist/config/check-suites.d.ts +14 -0
  126. package/dist/config/check-suites.js +99 -0
  127. package/dist/config/gateways.d.ts +24 -0
  128. package/dist/config/index.d.ts +6 -3
  129. package/dist/config/index.js +3 -1
  130. package/dist/config/live/file-lists-file-gateway.d.ts +4 -0
  131. package/dist/config/live/file-lists-file-gateway.js +27 -0
  132. package/dist/config/load.d.ts +11 -10
  133. package/dist/config/load.js +35 -103
  134. package/dist/config/recipe-run.d.ts +8 -1
  135. package/dist/config/recipe-run.js +2 -1
  136. package/dist/config/resolve.d.ts +3 -2
  137. package/dist/config/resolve.js +6 -3
  138. package/dist/config/resolver.d.ts +20 -6
  139. package/dist/config/resolver.js +11 -8
  140. package/dist/config/runner.d.ts +24 -0
  141. package/dist/config/runner.js +4 -0
  142. package/dist/config/schema.d.ts +26 -18
  143. package/dist/config/schema.js +41 -9
  144. package/dist/config/settings-file.d.ts +9 -3
  145. package/dist/config/settings-file.js +41 -4
  146. package/dist/config/suite.d.ts +39 -0
  147. package/dist/config/suite.js +5 -0
  148. package/dist/config-file/define.d.ts +49 -18
  149. package/dist/config-file/define.js +9 -8
  150. package/dist/config-file/runner.d.ts +12 -0
  151. package/dist/config-file/runner.js +9 -0
  152. package/dist/context.d.ts +12 -8
  153. package/dist/context.js +9 -3
  154. package/dist/core/across-sandboxes.d.ts +43 -0
  155. package/dist/core/across-sandboxes.js +319 -0
  156. package/dist/core/before-run.d.ts +5 -3
  157. package/dist/core/before-run.js +12 -1
  158. package/dist/core/events.d.ts +62 -6
  159. package/dist/core/events.js +14 -0
  160. package/dist/core/index.d.ts +4 -2
  161. package/dist/core/index.js +3 -1
  162. package/dist/core/payload.d.ts +2 -1
  163. package/dist/core/payload.js +2 -1
  164. package/dist/core/presentations.js +1 -1
  165. package/dist/core/resource.d.ts +1 -1
  166. package/dist/core/resources.d.ts +56 -6
  167. package/dist/core/resources.js +81 -5
  168. package/dist/core/run-state.js +9 -0
  169. package/dist/core/run.d.ts +77 -15
  170. package/dist/core/run.js +150 -86
  171. package/dist/core/sandbox-end.d.ts +64 -0
  172. package/dist/core/sandbox-end.js +128 -0
  173. package/dist/core/timeline.d.ts +4 -4
  174. package/dist/core/timeline.js +3 -3
  175. package/dist/credential/live/vercel-cli-gateway.d.ts +7 -0
  176. package/dist/credential/live/vercel-cli-gateway.js +14 -1
  177. package/dist/extensions/github/context.d.ts +1 -1
  178. package/dist/extensions/github/definition.d.ts +11 -9
  179. package/dist/extensions/github/definition.js +8 -6
  180. package/dist/extensions/github/extension.d.ts +3 -3
  181. package/dist/extensions/github/fixture-repo.d.ts +21 -2
  182. package/dist/extensions/github/fixture-repo.js +31 -2
  183. package/dist/extensions/github/index.d.ts +2 -2
  184. package/dist/extensions/github/index.js +2 -2
  185. package/dist/extensions/github/lifecycle.d.ts +16 -6
  186. package/dist/extensions/github/lifecycle.js +42 -25
  187. package/dist/extensions/github/options.d.ts +17 -11
  188. package/dist/extensions/github/options.js +14 -13
  189. package/dist/extensions/github/refusals.d.ts +23 -6
  190. package/dist/extensions/github/refusals.js +34 -12
  191. package/dist/extensions/github/resource.d.ts +21 -12
  192. package/dist/extensions/github/resource.js +16 -8
  193. package/dist/extensions/github/run/payload.d.ts +6 -6
  194. package/dist/extensions/github/run/payload.js +3 -5
  195. package/dist/extensions/github/split.d.ts +10 -0
  196. package/dist/extensions/github/split.js +12 -0
  197. package/dist/extensions/playwright/driver.js +6 -26
  198. package/dist/extensions/playwright/extension.js +1 -1
  199. package/dist/extensions/testserver/commands/pool/create/command.js +8 -8
  200. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  201. package/dist/extensions/testserver/definition.d.ts +4 -4
  202. package/dist/extensions/testserver/definition.js +41 -31
  203. package/dist/extensions/testserver/extension.d.ts +4 -5
  204. package/dist/extensions/testserver/extension.js +14 -41
  205. package/dist/extensions/testserver/index.d.ts +1 -1
  206. package/dist/extensions/testserver/index.js +1 -1
  207. package/dist/extensions/testserver/lifecycle.d.ts +10 -2
  208. package/dist/extensions/testserver/lifecycle.js +29 -6
  209. package/dist/extensions/testserver/options/rules.d.ts +5 -5
  210. package/dist/extensions/testserver/options/rules.js +10 -8
  211. package/dist/extensions/testserver/options/sandboxes.d.ts +4 -2
  212. package/dist/extensions/testserver/options/sandboxes.js +8 -3
  213. package/dist/extensions/testserver/pool/gateways.d.ts +29 -4
  214. package/dist/extensions/testserver/pool/index.d.ts +2 -2
  215. package/dist/extensions/testserver/pool/index.js +1 -1
  216. package/dist/extensions/testserver/pool/lease.d.ts +10 -0
  217. package/dist/extensions/testserver/pool/lease.js +21 -0
  218. package/dist/extensions/testserver/pool/live/pool-store-gateway.js +38 -3
  219. package/dist/extensions/testserver/refusals.d.ts +12 -0
  220. package/dist/extensions/testserver/refusals.js +18 -0
  221. package/dist/extensions/testserver/release.d.ts +16 -0
  222. package/dist/extensions/testserver/release.js +56 -4
  223. package/dist/extensions/testserver/resource.d.ts +4 -4
  224. package/dist/extensions/testserver/resource.js +1 -1
  225. package/dist/extensions/testserver/split.d.ts +9 -0
  226. package/dist/extensions/testserver/split.js +22 -0
  227. package/dist/extensions/testserver/vitest/fixtures.d.ts +5 -5
  228. package/dist/extensions/testserver/vitest/fixtures.js +9 -38
  229. package/dist/extensions/vitest/driver.d.ts +7 -0
  230. package/dist/extensions/vitest/driver.js +33 -37
  231. package/dist/extensions/vitest/extension.js +1 -1
  232. package/dist/extensions/vitest/plan/plan-over.d.ts +8 -1
  233. package/dist/extensions/vitest/plan/plan-over.js +16 -2
  234. package/dist/extensions.d.ts +17 -16
  235. package/dist/extensions.js +5 -4
  236. package/dist/forward-sigterm.js +1 -1
  237. package/dist/launcher-resolvers/local-services.d.ts +1 -1
  238. package/dist/live-app.js +4 -3
  239. package/dist/local-services.js +1 -1
  240. package/dist/planning/driver-file-lists.d.ts +61 -0
  241. package/dist/planning/driver-file-lists.js +66 -0
  242. package/dist/{commands/exec → planning}/driver-refusals.d.ts +11 -10
  243. package/dist/{commands/exec → planning}/driver-refusals.js +18 -14
  244. package/dist/planning/file-lists-file.d.ts +58 -0
  245. package/dist/planning/file-lists-file.js +105 -0
  246. package/dist/planning/file-lists.d.ts +28 -0
  247. package/dist/planning/file-lists.js +52 -0
  248. package/dist/{commands/exec → planning}/final-results.d.ts +1 -1
  249. package/dist/{commands/exec → planning}/final-results.js +6 -6
  250. package/dist/planning/plan-only.d.ts +81 -0
  251. package/dist/planning/plan-only.js +83 -0
  252. package/dist/{commands/exec → planning}/redaction.d.ts +2 -2
  253. package/dist/{commands/exec → planning}/redaction.js +5 -4
  254. package/dist/{commands/exec → planning}/resource-flags.d.ts +5 -12
  255. package/dist/{commands/exec → planning}/resource-flags.js +6 -16
  256. package/dist/planning/run-kind-flags.d.ts +20 -0
  257. package/dist/planning/run-kind-flags.js +48 -0
  258. package/dist/planning/run-plan.d.ts +30 -0
  259. package/dist/planning/run-plan.js +4 -0
  260. package/dist/planning/sandbox-placeholders.d.ts +22 -0
  261. package/dist/planning/sandbox-placeholders.js +60 -0
  262. package/dist/planning/suite-not-found.d.ts +37 -0
  263. package/dist/planning/suite-not-found.js +36 -0
  264. package/dist/planning/suites.d.ts +43 -0
  265. package/dist/planning/suites.js +89 -0
  266. package/dist/{commands/exec → planning}/test-plan.d.ts +8 -3
  267. package/dist/{commands/exec → planning}/test-plan.js +32 -4
  268. package/dist/playwright/reporter.d.ts +20 -8
  269. package/dist/playwright/reporter.js +195 -15
  270. package/dist/presentation.d.ts +10 -6
  271. package/dist/presentation.js +13 -15
  272. package/dist/run-directory/gateways.d.ts +60 -4
  273. package/dist/run-directory/index.d.ts +4 -4
  274. package/dist/run-directory/index.js +2 -1
  275. package/dist/run-directory/live/run-directory-gateway.js +92 -16
  276. package/dist/run-directory/plan.d.ts +35 -2
  277. package/dist/run-directory/plan.js +44 -7
  278. package/dist/run-directory/reader.d.ts +26 -5
  279. package/dist/run-directory/reader.js +24 -1
  280. package/dist/run-directory/recording.d.ts +75 -49
  281. package/dist/run-directory/recording.js +214 -28
  282. package/dist/run-directory/run-directory.d.ts +22 -1
  283. package/dist/run-directory/run-directory.js +24 -0
  284. package/dist/run-directory/run-record.d.ts +144 -21
  285. package/dist/run-directory/run-record.js +118 -19
  286. package/dist/run-directory/timeline-facts.js +4 -4
  287. package/dist/runner/build-snapshots.d.ts +7 -7
  288. package/dist/runner/build-snapshots.js +12 -16
  289. package/dist/runner/events.d.ts +29 -8
  290. package/dist/runner/gateways.d.ts +49 -6
  291. package/dist/runner/index.d.ts +6 -4
  292. package/dist/runner/index.js +3 -2
  293. package/dist/runner/live/sandbox-gateway.js +161 -31
  294. package/dist/runner/network-policy.d.ts +55 -0
  295. package/dist/runner/network-policy.js +46 -0
  296. package/dist/runner/policy-writes.d.ts +40 -0
  297. package/dist/runner/policy-writes.js +124 -0
  298. package/dist/runner/prepare.d.ts +6 -7
  299. package/dist/runner/ready.d.ts +39 -10
  300. package/dist/runner/ready.js +59 -47
  301. package/dist/runner/recipe-check.d.ts +6 -0
  302. package/dist/runner/recipe-check.js +29 -0
  303. package/dist/runner/recipe-secrets.d.ts +67 -0
  304. package/dist/runner/recipe-secrets.js +230 -0
  305. package/dist/runner/recipe.d.ts +115 -26
  306. package/dist/runner/recipe.js +147 -154
  307. package/dist/runner/sandboxed-command.d.ts +22 -8
  308. package/dist/runner/sandboxed-command.js +33 -10
  309. package/dist/runner/scope.d.ts +107 -21
  310. package/dist/runner/scope.js +274 -54
  311. package/dist/runner/secrets.d.ts +42 -31
  312. package/dist/runner/secrets.js +62 -40
  313. package/dist/runner/session.d.ts +59 -26
  314. package/dist/runner/session.js +82 -41
  315. package/dist/runner/snapshot-build.d.ts +7 -4
  316. package/dist/runner/snapshot-build.js +48 -28
  317. package/dist/runner/snapshot-choice.d.ts +37 -0
  318. package/dist/runner/snapshot-choice.js +38 -0
  319. package/dist/runner/snapshot-key.d.ts +16 -14
  320. package/dist/runner/snapshot-key.js +24 -18
  321. package/dist/runner/steps.d.ts +13 -5
  322. package/dist/runner/steps.js +34 -4
  323. package/dist/runner/time-limit.d.ts +10 -0
  324. package/dist/runner/time-limit.js +43 -0
  325. package/dist/sdk/extension/commands.d.ts +1 -7
  326. package/dist/sdk/extension/driver.d.ts +39 -46
  327. package/dist/sdk/extension/driver.js +6 -6
  328. package/dist/sdk/extension/index.d.ts +3 -3
  329. package/dist/sdk/extension/index.js +3 -4
  330. package/dist/sdk/extension/lifecycle.d.ts +52 -9
  331. package/dist/sdk/extension/lifecycle.js +1 -1
  332. package/dist/sdk/extension/resource-definition.d.ts +13 -10
  333. package/dist/sdk/extension/resource-definition.js +7 -2
  334. package/dist/sdk/extension/resource.d.ts +2 -2
  335. package/dist/sdk/extension/secret-source.d.ts +58 -0
  336. package/dist/sdk/extension/secret-source.js +78 -0
  337. package/dist/sdk/index.d.ts +2 -2
  338. package/dist/sdk/index.js +1 -1
  339. package/dist/sdk/run/launcher.d.ts +1 -1
  340. package/dist/sdk/run/launcher.js +1 -1
  341. package/dist/sdk/run/payload.d.ts +16 -1
  342. package/dist/sdk/run/payload.js +17 -2
  343. package/dist/sdk/run/redact.js +2 -2
  344. package/dist/sdk/run/test-events.d.ts +23 -6
  345. package/dist/sdk/run/test-events.js +6 -4
  346. package/dist/sdk/run/test-result-writer.d.ts +8 -3
  347. package/dist/sdk/run/test-result-writer.js +22 -2
  348. package/dist/{commands/exec → shared}/cleanup.d.ts +3 -3
  349. package/dist/{commands/exec → shared}/cleanup.js +11 -6
  350. package/dist/shared/job-summary.d.ts +19 -0
  351. package/dist/{commands/exec → shared}/job-summary.js +17 -0
  352. package/dist/shared/sandbox-table.d.ts +48 -0
  353. package/dist/shared/sandbox-table.js +109 -0
  354. package/dist/{commands/exec → shared}/snapshot-text.d.ts +1 -1
  355. package/dist/{commands/exec → shared}/tests-summary.d.ts +22 -6
  356. package/dist/{commands/exec → shared}/tests-summary.js +74 -31
  357. package/dist/{commands/exec → shared}/text.d.ts +7 -2
  358. package/dist/{commands/exec → shared}/text.js +9 -1
  359. package/dist/{commands/exec → shared}/waterfall.d.ts +8 -6
  360. package/dist/{commands/exec → shared}/waterfall.js +71 -24
  361. package/dist/shared/worker-chart.d.ts +172 -0
  362. package/dist/shared/worker-chart.js +623 -0
  363. package/dist/vitest/config.d.ts +35 -11
  364. package/dist/vitest/config.js +47 -14
  365. package/dist/vitest/index.d.ts +1 -1
  366. package/dist/vitest/index.js +3 -3
  367. package/dist/vitest/sequencer.d.ts +23 -0
  368. package/dist/vitest/sequencer.js +73 -0
  369. package/dist/vitest/setup.d.ts +1 -0
  370. package/dist/vitest/setup.js +34 -0
  371. package/dist/vitest/test-events.d.ts +32 -6
  372. package/dist/vitest/test-events.js +25 -5
  373. package/dist/vitest/test-results.d.ts +8 -3
  374. package/dist/vitest/test-results.js +6 -0
  375. package/package.json +7 -2
  376. package/skills/overview.md +21 -17
  377. package/skills/plan-runs.md +67 -0
  378. package/skills/read-run-output.md +51 -19
  379. package/dist/chunks/chunk-E3QU74NX.js +0 -49
  380. package/dist/chunks/chunk-HP54VHGY.js +0 -201
  381. package/dist/chunks/chunk-NMVODY3P.js +0 -19
  382. package/dist/chunks/chunk-TVMEKVOW.js +0 -607
  383. package/dist/commands/exec/define-run-command.d.ts +0 -671
  384. package/dist/commands/exec/define-run-command.js +0 -91
  385. package/dist/commands/exec/job-summary.d.ts +0 -10
  386. package/dist/commands/exec/worker-chart.d.ts +0 -87
  387. package/dist/commands/exec/worker-chart.js +0 -343
  388. package/dist/commands/playwright/command.d.ts +0 -661
  389. package/dist/commands/playwright/command.js +0 -31
  390. package/dist/commands/playwright/metadata.js +0 -8
  391. package/dist/commands/vitest/command.d.ts +0 -662
  392. package/dist/commands/vitest/command.js +0 -31
  393. package/dist/commands/vitest/metadata.js +0 -8
  394. package/dist/sdk/extension/ci.d.ts +0 -2
  395. package/dist/sdk/extension/ci.js +0 -6
  396. package/dist/chunks/{chunk-YM6TZV4L.js → chunk-VL7WFTVQ.js} +52 -52
  397. package/dist/commands/{playwright → suites}/metadata.d.ts +1 -1
  398. package/dist/commands/{vitest → test}/metadata.d.ts +1 -1
  399. /package/dist/{commands → shared}/dashboard.d.ts +0 -0
  400. /package/dist/{commands → shared}/dashboard.js +0 -0
  401. /package/dist/{commands/exec → shared}/snapshot-text.js +0 -0
@@ -1,20 +1,26 @@
1
1
  import {
2
2
  Credential,
3
+ ENV_VAR_NAME_PATTERN,
4
+ ENV_VAR_NAME_RULE,
3
5
  NOT_COUNTED,
4
6
  booleanOption,
5
7
  defaultResourceKey,
6
8
  describeMintFailure,
9
+ describeSecretSource,
7
10
  describeValue,
8
11
  nonEmptyString,
9
12
  optionKeyPath,
13
+ readSecretSource,
14
+ readSecretSourceValue,
10
15
  resourceCall,
16
+ secretSourceId,
11
17
  tokenRequestFailureFacts,
12
18
  tokenRequestFailureShape
13
- } from "./chunk-RA4L2ACU.js";
19
+ } from "./chunk-AWBSONHB.js";
14
20
  import {
15
21
  defineErrors,
16
22
  refused
17
- } from "./chunk-YM6TZV4L.js";
23
+ } from "./chunk-VL7WFTVQ.js";
18
24
 
19
25
  // src/config/credential-settle.ts
20
26
  import { z } from "zod";
@@ -56,36 +62,6 @@ function settleCredential(source, scope, project) {
56
62
  return { ok: true, credential: { source, target: required.target } };
57
63
  }
58
64
 
59
- // src/runner/secrets.ts
60
- var RUNNER_SECRET_MIN_LENGTH = 8;
61
- function stepSecrets(values, names) {
62
- return Object.fromEntries(
63
- names.map((name) => {
64
- const value = ownValue(values, name);
65
- if (value === void 0) throw new Error(`stepSecrets: no value for runner secret ${name}`);
66
- return [name, value];
67
- })
68
- );
69
- }
70
- function declaredSecretValues(recipe, env) {
71
- return (recipe?.secrets ?? []).map((name) => ownValue(env, name)).filter((value) => value !== void 0 && value !== "");
72
- }
73
- function readRunnerSecrets(recipe, env) {
74
- const values = [];
75
- const variables = [];
76
- for (const name of recipe.secrets) {
77
- const value = ownValue(env, name);
78
- if (value === void 0 || value === "") variables.push({ name, problem: "missing" });
79
- else if (/[\r\n]/.test(value)) variables.push({ name, problem: "multiline" });
80
- else if (value.length < RUNNER_SECRET_MIN_LENGTH) variables.push({ name, problem: "short" });
81
- else values.push([name, value]);
82
- }
83
- return variables.length === 0 ? { ok: true, values: Object.fromEntries(values) } : { ok: false, variables };
84
- }
85
- function ownValue(map, name) {
86
- return Object.hasOwn(map, name) ? map[name] : void 0;
87
- }
88
-
89
65
  // src/runner/base.ts
90
66
  async function resolveBase(checkout, request2) {
91
67
  const { repoRoot } = request2;
@@ -126,94 +102,388 @@ function baseStepContext(checkout, request2) {
126
102
  };
127
103
  }
128
104
 
105
+ // src/runner/time-limit.ts
106
+ function callWithin(timer, ms, call) {
107
+ const abort = new AbortController();
108
+ const limit = new AbortController();
109
+ return new Promise((resolve, reject) => {
110
+ call(abort.signal).then(
111
+ (answer) => {
112
+ limit.abort();
113
+ resolve(answer);
114
+ },
115
+ (error) => {
116
+ limit.abort();
117
+ reject(error);
118
+ }
119
+ );
120
+ void timer.sleep(ms, limit.signal).then(() => {
121
+ if (limit.signal.aborted) return;
122
+ abort.abort();
123
+ resolve(null);
124
+ });
125
+ });
126
+ }
127
+ var ABORTED = /* @__PURE__ */ Symbol("aborted");
128
+ function untilAborted(promise, signal) {
129
+ if (signal.aborted) return Promise.resolve(ABORTED);
130
+ return new Promise((resolve, reject) => {
131
+ const onAbort = () => resolve(ABORTED);
132
+ signal.addEventListener("abort", onAbort, { once: true });
133
+ promise.then(
134
+ (answer) => {
135
+ signal.removeEventListener("abort", onAbort);
136
+ resolve(answer);
137
+ },
138
+ (error) => {
139
+ signal.removeEventListener("abort", onAbort);
140
+ reject(error);
141
+ }
142
+ );
143
+ });
144
+ }
145
+
146
+ // src/runner/network-policy.ts
147
+ var NETWORK_POLICY_WRITE_LIMIT_MS = 1e4;
148
+ function runnerNetworkPolicy(recipe) {
149
+ if (recipe.allowedDomains === void 0) return { kind: "allow-all", credentials: [] };
150
+ return { kind: "custom", allowedDomains: [...recipe.allowedDomains], credentials: [] };
151
+ }
152
+ function withCredentials(base, credentials2) {
153
+ return { ...base, credentials: credentials2 };
154
+ }
155
+ function denyAllPolicy() {
156
+ return { kind: "deny-all" };
157
+ }
158
+ function policyCredentials(policy) {
159
+ return policy.kind === "deny-all" ? [] : policy.credentials;
160
+ }
161
+ async function replaceNetworkPolicy(context, sandbox, policy) {
162
+ const answered = await callWithin(
163
+ context.timer,
164
+ NETWORK_POLICY_WRITE_LIMIT_MS,
165
+ (signal) => context.runnerSandboxes.writeNetworkPolicy(sandbox, policy, signal)
166
+ );
167
+ return answered ?? { ok: false, failure: { kind: "timed-out", limitMs: NETWORK_POLICY_WRITE_LIMIT_MS } };
168
+ }
169
+
170
+ // src/runner/policy-writes.ts
171
+ function sandboxPolicyWriter(context, basePolicy, onTimedOut) {
172
+ const states = /* @__PURE__ */ new Map();
173
+ const stateOf = (sandbox) => {
174
+ let state2 = states.get(sandbox);
175
+ if (state2 === void 0) {
176
+ state2 = { last: Promise.resolve(), mayInject: false, timedOut: false, removal: null };
177
+ states.set(sandbox, state2);
178
+ }
179
+ return state2;
180
+ };
181
+ const mayInject = (sandbox) => states.get(sandbox)?.mayInject === true;
182
+ const send = (sandbox, policy, signal) => {
183
+ if (signal?.aborted === true) return Promise.resolve({ ok: false, failure: { kind: "aborted" } });
184
+ const state2 = stateOf(sandbox);
185
+ const injects = policyCredentials(policy).length > 0;
186
+ if (injects) state2.mayInject = true;
187
+ const turn = state2.last;
188
+ let release = () => {
189
+ };
190
+ const mine = new Promise((resolve) => {
191
+ release = resolve;
192
+ });
193
+ state2.last = mine;
194
+ const answer = (async () => {
195
+ if (!await untilTurn(turn, signal)) {
196
+ void turn.then(release);
197
+ return { ok: false, failure: { kind: "aborted" } };
198
+ }
199
+ try {
200
+ if (state2.timedOut) return { ok: false, failure: timedOut() };
201
+ const answered = await replaceNetworkPolicy(context, sandbox, policy);
202
+ if (answered.ok) {
203
+ if (!injects && state2.last === mine) state2.mayInject = false;
204
+ } else if (answered.failure.kind === "timed-out") {
205
+ state2.timedOut = true;
206
+ onTimedOut(sandbox, answered.failure);
207
+ }
208
+ return answered;
209
+ } finally {
210
+ release();
211
+ }
212
+ })();
213
+ const removal = !injects && signal === void 0 ? answer : null;
214
+ state2.removal = removal;
215
+ if (removal !== null) {
216
+ const forget = () => {
217
+ if (state2.removal === removal) state2.removal = null;
218
+ };
219
+ void removal.then(forget, forget);
220
+ }
221
+ return answer;
222
+ };
223
+ return {
224
+ write: send,
225
+ removeInjections: (sandbox) => states.get(sandbox)?.removal ?? send(sandbox, basePolicy, void 0),
226
+ mayInject,
227
+ injectingSandboxes: () => [...states.keys()].filter(mayInject)
228
+ };
229
+ }
230
+ function notRemovedMessage(failure) {
231
+ return failure.kind === "timed-out" ? `its network policy may still hold a credential: a policy write had no answer within ${failure.limitMs / 1e3} seconds and may still take effect, so no write can remove the credential for certain` : `its network policy may still hold a credential: removing the credential failed (${writeFailureMessage(failure)})`;
232
+ }
233
+ function notFencedMessage(failure, injecting) {
234
+ return injecting ? notRemovedMessage(failure) : `giving it no network access failed (${writeFailureMessage(failure)})`;
235
+ }
236
+ function timedOut() {
237
+ return { kind: "timed-out", limitMs: NETWORK_POLICY_WRITE_LIMIT_MS };
238
+ }
239
+ async function untilTurn(turn, signal) {
240
+ if (signal === void 0) {
241
+ await turn;
242
+ return true;
243
+ }
244
+ return await untilAborted(turn, signal) !== ABORTED;
245
+ }
246
+ function writeFailureMessage(failure) {
247
+ if (failure.kind === "timed-out") return `no answer within ${failure.limitMs / 1e3} seconds`;
248
+ if (failure.kind === "aborted") return "aborted";
249
+ return failure.status === void 0 ? failure.message : `HTTP ${failure.status}: ${failure.message}`;
250
+ }
251
+
129
252
  // src/runner/scope.ts
130
253
  var CREATE_SETTLE_MS = 2e4;
131
254
  var SNAPSHOT_SETTLE_MS = 2 * 6e4;
132
- function runnerSandboxScope(context, progress, keep) {
255
+ var SANDBOX_CALL_LIMIT_MS = 3e4;
256
+ var KEEP_RUNNING_LIMIT_MS = 6e4;
257
+ function runnerSandboxScope(context, progress, settings) {
133
258
  const { runnerSandboxes: sandboxes, timer, clock } = context;
134
- const live = /* @__PURE__ */ new Set();
135
- const creating = /* @__PURE__ */ new Set();
259
+ let phase = { kind: "open", sandboxes: /* @__PURE__ */ new Map(), creating: /* @__PURE__ */ new Set() };
136
260
  const saving = /* @__PURE__ */ new Set();
137
261
  const notStopped = [];
138
262
  const notDeleted = [];
139
263
  let kept = null;
140
264
  let notKept = null;
141
- let closing;
265
+ let settling;
266
+ let stoppingOthers;
267
+ let stoppingUnkept;
268
+ let removingOnSignal;
269
+ let fencing;
270
+ let closingScope;
271
+ const stops = /* @__PURE__ */ new Map();
272
+ const isStopping = (sandbox) => stops.has(sandbox);
273
+ const currentPhase = () => phase;
274
+ const beginClosing = () => {
275
+ if (phase.kind === "open") phase = { kind: "settling", sandboxes: phase.sandboxes, creating: phase.creating };
276
+ };
142
277
  const track = (set, task) => {
143
278
  set.add(task);
144
279
  const forget = () => set.delete(task);
145
280
  void task.then(forget, forget);
146
281
  return task;
147
282
  };
148
- const remove = async (sandbox) => {
149
- const deleted = await sandboxes.delete(sandbox);
150
- if (!deleted.ok)
151
- notDeleted.push({ name: sandbox.name, role: sandbox.role, message: failureMessage(deleted.failure) });
283
+ const recordNotKept = (sandbox, message) => {
284
+ notKept ??= { name: sandbox.name, message };
152
285
  };
153
- const stopAndRemove = async (sandbox) => {
154
- const stopped = await sandboxes.stop(sandbox);
155
- if (!stopped.ok) {
156
- notStopped.push({
286
+ const deleteSandbox = async (sandbox) => {
287
+ const deleted = await callWithin(timer, SANDBOX_CALL_LIMIT_MS, (signal) => sandboxes.delete(sandbox, signal));
288
+ if (deleted === null || !deleted.ok)
289
+ notDeleted.push({
157
290
  name: sandbox.name,
158
291
  role: sandbox.role,
159
- timeoutMinutes: Math.round(sandbox.timeoutMs / 6e4),
160
- message: failureMessage(stopped.failure)
292
+ message: callFailureMessage(deleted, SANDBOX_CALL_LIMIT_MS)
161
293
  });
162
- return;
294
+ };
295
+ const stop = (sandbox) => {
296
+ let stopping = stops.get(sandbox);
297
+ if (stopping === void 0) {
298
+ stopping = (async () => {
299
+ const answer = await callWithin(timer, SANDBOX_CALL_LIMIT_MS, (signal) => sandboxes.stop(sandbox, signal));
300
+ if (answer !== null && answer.ok) return true;
301
+ notStopped.push({
302
+ name: sandbox.name,
303
+ role: sandbox.role,
304
+ timeoutMinutes: Math.round(sandbox.timeoutMs / 6e4),
305
+ message: callFailureMessage(answer, SANDBOX_CALL_LIMIT_MS)
306
+ });
307
+ return false;
308
+ })();
309
+ stops.set(sandbox, stopping);
310
+ }
311
+ return stopping;
312
+ };
313
+ const giveUp = (sandbox, message) => {
314
+ const entry = phase.sandboxes.get(sandbox);
315
+ if (entry?.keep === true) {
316
+ if (message !== void 0) recordNotKept(sandbox, message);
317
+ entry.keep = false;
318
+ }
319
+ return stop(sandbox);
320
+ };
321
+ const policies = sandboxPolicyWriter(context, settings.basePolicy, (sandbox, failure) => {
322
+ void giveUp(sandbox, notFencedMessage(failure, policies.mayInject(sandbox)));
323
+ });
324
+ const stopAndDelete = async (sandbox) => {
325
+ if (await stop(sandbox)) await deleteSandbox(sandbox);
326
+ };
327
+ const stopUnkeptSandbox = async (sandbox) => {
328
+ if (policies.mayInject(sandbox)) await revoke(sandbox);
329
+ await stop(sandbox);
330
+ };
331
+ const fenceKept = async (entry) => {
332
+ const { sandbox } = entry;
333
+ await removingOnSignal;
334
+ let message;
335
+ if (!isStopping(sandbox)) {
336
+ const injecting = policies.mayInject(sandbox);
337
+ const written = await policies.write(sandbox, denyAllPolicy());
338
+ if (!isStopping(sandbox)) {
339
+ if (written.ok) return;
340
+ message = notFencedMessage(written.failure, injecting);
341
+ }
163
342
  }
164
- await remove(sandbox);
343
+ await giveUp(sandbox, message);
165
344
  };
166
- const keepOrRemove = async (sandbox) => {
167
- const keepMs = sandbox.role === "runner" ? keep.keepMs : 0;
168
- if (keepMs <= 0) return await stopAndRemove(sandbox);
169
- const keeping = await sandboxes.keepRunning(sandbox, { until: new Date(clock.now().getTime() + keepMs) });
170
- if (!keeping.ok) {
171
- notKept = { name: sandbox.name, message: failureMessage(keeping.failure) };
172
- return await stopAndRemove(sandbox);
345
+ const revoke = async (sandbox) => {
346
+ let message;
347
+ if (!isStopping(sandbox)) {
348
+ const removed = await policies.removeInjections(sandbox);
349
+ if (removed.ok) return;
350
+ message = notRemovedMessage(removed.failure);
351
+ }
352
+ await giveUp(sandbox, message);
353
+ };
354
+ const revokeEach = async (injecting) => {
355
+ await Promise.allSettled(injecting.map(revoke));
356
+ };
357
+ const keepOrDelete = async (sandbox) => {
358
+ if (isStopping(sandbox)) return await stopAndDelete(sandbox);
359
+ const until = new Date(clock.now().getTime() + settings.keepMs);
360
+ const keeping = await callWithin(
361
+ timer,
362
+ KEEP_RUNNING_LIMIT_MS,
363
+ (signal) => sandboxes.keepRunning(sandbox, { until }, signal)
364
+ );
365
+ if (keeping === null || !keeping.ok) {
366
+ recordNotKept(sandbox, callFailureMessage(keeping, KEEP_RUNNING_LIMIT_MS));
367
+ return await stopAndDelete(sandbox);
173
368
  }
174
369
  kept = { name: sandbox.name, stopsAt: keeping.value.stopsAt.toISOString() };
175
370
  await progress.emit({ kind: "sandbox-kept", ...kept });
176
371
  };
177
- const owned = (start) => {
178
- if (closing !== void 0) return Promise.resolve({ ok: false, failure: { kind: "aborted" } });
372
+ const settle = () => {
373
+ beginClosing();
374
+ return settling ??= (async () => {
375
+ if (phase.kind === "closing") return phase.sandboxes;
376
+ const { creating, sandboxes: entries } = phase;
377
+ if (saving.size > 0) await progress.emit({ kind: "waiting-for-snapshot", settleMs: SNAPSHOT_SETTLE_MS });
378
+ await Promise.all([
379
+ settleWithin(timer, creating, CREATE_SETTLE_MS),
380
+ settleWithin(timer, saving, SNAPSHOT_SETTLE_MS)
381
+ ]);
382
+ phase = { kind: "closing", sandboxes: entries };
383
+ return entries;
384
+ })();
385
+ };
386
+ const stopOthers = () => {
387
+ const entries = settle();
388
+ return stoppingOthers ??= (async () => {
389
+ const unkept = [...(await entries).values()].filter((entry) => !entry.keep);
390
+ await Promise.all(unkept.map(({ sandbox }) => stopUnkeptSandbox(sandbox)));
391
+ })();
392
+ };
393
+ const stopUnkept = () => stoppingUnkept ??= (async () => {
394
+ beginClosing();
395
+ removingOnSignal = revokeEach(policies.injectingSandboxes());
396
+ await Promise.all([removingOnSignal, stopOthers()]);
397
+ })();
398
+ const fence = () => {
399
+ const settled = settle();
400
+ return fencing ??= (async () => {
401
+ const entries = await settled;
402
+ const keptEntry = [...entries.values()].find((entry) => entry.keep);
403
+ await Promise.all([stopOthers(), keptEntry === void 0 ? void 0 : fenceKept(keptEntry)]);
404
+ await removingOnSignal;
405
+ return { runnerSandboxFenced: !notStopped.some(({ role }) => role === "runner") };
406
+ })().finally(() => settings.signal.removeEventListener("abort", onSignal));
407
+ };
408
+ const writable = () => phase.kind === "open";
409
+ const refused2 = { ok: false, failure: { kind: "aborted" } };
410
+ const revokeCredentials = async (sandbox) => {
411
+ if (!writable()) return refused2;
412
+ if (!policies.mayInject(sandbox)) return { ok: true };
413
+ return await policies.removeInjections(sandbox);
414
+ };
415
+ const grantCredentials = async (sandbox, credentials2, signal) => {
416
+ if (!writable() || signal.aborted) return refused2;
417
+ const granted = await policies.write(sandbox, withCredentials(settings.basePolicy, credentials2), signal);
418
+ if (signal.aborted || !writable()) {
419
+ await revokeCredentials(sandbox);
420
+ return refused2;
421
+ }
422
+ if (!granted.ok) await revokeCredentials(sandbox);
423
+ return granted;
424
+ };
425
+ const owned = (start, canKeep = false) => {
426
+ if (phase.kind !== "open") return Promise.resolve({ ok: false, failure: { kind: "aborted" } });
179
427
  return track(
180
- creating,
428
+ phase.creating,
181
429
  (async () => {
182
430
  const started = await start();
183
431
  if (!started.ok) return started;
184
- if (closing !== void 0) {
185
- await stopAndRemove(started.value);
186
- return { ok: false, failure: { kind: "aborted" } };
432
+ const now = currentPhase();
433
+ switch (now.kind) {
434
+ case "open":
435
+ now.sandboxes.set(started.value, { sandbox: started.value, keep: canKeep && settings.keepMs > 0 });
436
+ return started;
437
+ case "settling":
438
+ now.sandboxes.set(started.value, { sandbox: started.value, keep: false });
439
+ return { ok: false, failure: { kind: "aborted" } };
440
+ case "closing":
441
+ await stopAndDelete(started.value);
442
+ return { ok: false, failure: { kind: "aborted" } };
187
443
  }
188
- live.add(started.value);
189
- return started;
190
444
  })()
191
445
  );
192
446
  };
447
+ function onSignal() {
448
+ const commandRunning = settings.commandRunning?.() ?? false;
449
+ void progress.emit({ kind: "stopping", commandRunning, keepMs: settings.keepMs }).catch(() => void 0);
450
+ void stopUnkept().catch(() => void 0);
451
+ }
452
+ if (settings.signal.aborted) onSignal();
453
+ else settings.signal.addEventListener("abort", onSignal, { once: true });
193
454
  return {
194
- startBuildSandbox: (access, request2) => owned(() => sandboxes.startBuildSandbox(access, request2)),
195
- startRunnerSandbox: (access, request2) => owned(() => sandboxes.startRunnerSandbox(access, request2)),
455
+ startBuildSandbox: (access, request2) => owned(() => sandboxes.startBuildSandbox(access, { ...request2, networkPolicy: settings.basePolicy })),
456
+ startRunnerSandbox: (access, request2) => owned(() => sandboxes.startRunnerSandbox(access, { ...request2, networkPolicy: settings.basePolicy }), true),
457
+ grantCredentials,
458
+ revokeCredentials,
196
459
  saveSnapshot: (sandbox, request2) => track(
197
460
  saving,
198
461
  (async () => {
462
+ if (policies.mayInject(sandbox)) {
463
+ const removed = await policies.removeInjections(sandbox);
464
+ if (!removed.ok)
465
+ return { ok: false, failure: { kind: "credential-not-revoked", failure: removed.failure } };
466
+ }
199
467
  const saved = await sandboxes.saveSnapshot(sandbox, request2);
200
- if (saved.ok && live.delete(sandbox)) await remove(sandbox);
468
+ const now = currentPhase();
469
+ if (saved.ok && now.kind !== "closing" && now.sandboxes.delete(sandbox)) await deleteSandbox(sandbox);
201
470
  return saved;
202
471
  })()
203
472
  ),
473
+ fence,
204
474
  close() {
205
- closing ??= (async () => {
206
- if (saving.size > 0) await progress.emit({ kind: "waiting-for-snapshot", settleMs: SNAPSHOT_SETTLE_MS });
207
- await Promise.all([
208
- settleWithin(timer, creating, CREATE_SETTLE_MS),
209
- settleWithin(timer, saving, SNAPSHOT_SETTLE_MS)
210
- ]);
211
- const held = [...live];
212
- live.clear();
213
- await Promise.all(held.map(keepOrRemove));
475
+ beginClosing();
476
+ closingScope ??= (async () => {
477
+ await fence();
478
+ const entries = await settle();
479
+ await Promise.all(
480
+ [...entries.values()].map(
481
+ (entry) => entry.keep ? keepOrDelete(entry.sandbox) : stopAndDelete(entry.sandbox)
482
+ )
483
+ );
214
484
  return { kept, notKept, notStopped: [...notStopped], notDeleted: [...notDeleted] };
215
485
  })();
216
- return closing;
486
+ return closingScope;
217
487
  }
218
488
  };
219
489
  }
@@ -226,6 +496,9 @@ async function settleWithin(timer, tasks, ms) {
226
496
  function failureMessage(failure) {
227
497
  return failure.message ?? failure.kind;
228
498
  }
499
+ function callFailureMessage(answer, limitMs) {
500
+ return answer === null ? `no answer within ${limitMs / 1e3} seconds` : failureMessage(answer.failure);
501
+ }
229
502
 
230
503
  // src/runner/context.ts
231
504
  function runnerPurpose(recipeName) {
@@ -365,26 +638,34 @@ var systemClock = {
365
638
  import { z as z2 } from "zod";
366
639
  var RUN_PAYLOAD_VARIABLE = "STORM_RUN";
367
640
  var RUN_PAYLOAD_VERSION = 3;
641
+ var runPayloadSandboxSchema = z2.object({
642
+ index: z2.number().int().nonnegative(),
643
+ count: z2.number().int().positive(),
644
+ files: z2.array(z2.string().min(1)).optional()
645
+ });
368
646
  var runPayloadSchema = z2.object({
369
647
  version: z2.literal(RUN_PAYLOAD_VERSION),
370
648
  resources: z2.record(z2.string(), z2.object({ definition: z2.string().min(1), payload: z2.unknown() })),
371
649
  testEvents: z2.string().min(1).optional(),
372
- verbose: z2.literal(true).optional()
650
+ verbose: z2.literal(true).optional(),
651
+ sandbox: runPayloadSandboxSchema.optional()
373
652
  });
374
653
 
375
654
  // src/sdk/run/test-events.ts
376
655
  import { z as z3 } from "zod";
377
656
  var where = { file: z3.string(), worker: z3.number().int().nonnegative(), at: z3.number() };
657
+ var fileWhere = { file: z3.string(), worker: z3.number().int().nonnegative().exactOptional(), at: z3.number() };
658
+ var attempt = { id: z3.string().min(1), test: z3.string() };
378
659
  var setup = { label: z3.string().min(1), resource: z3.string().min(1) };
379
660
  var state = z3.enum(["pass", "fail", "skip"]);
380
661
  var testEventSchema = z3.discriminatedUnion("kind", [
381
- z3.object({ kind: z3.literal("file-started"), ...where }),
382
- z3.object({ kind: z3.literal("file-finished"), ...where }),
383
- z3.object({ kind: z3.literal("test-started"), ...where, test: z3.string(), fileTests: z3.number().int().nonnegative() }),
662
+ z3.object({ kind: z3.literal("file-started"), ...fileWhere }),
663
+ z3.object({ kind: z3.literal("file-finished"), ...fileWhere }),
664
+ z3.object({ kind: z3.literal("test-started"), ...where, ...attempt, fileTests: z3.number().int().nonnegative() }),
384
665
  z3.object({
385
666
  kind: z3.literal("test-attempt-finished"),
386
667
  ...where,
387
- test: z3.string(),
668
+ ...attempt,
388
669
  state,
389
670
  ms: z3.number().nonnegative()
390
671
  }),
@@ -438,106 +719,230 @@ function redactSecrets(text, secrets) {
438
719
  return ordered.reduce((redacted, secret) => redacted.split(secret).join(REDACTED), text);
439
720
  }
440
721
 
441
- // src/runner/events.ts
442
- function progressQueue(progress) {
443
- let pending = Promise.resolve();
444
- return {
445
- add(event) {
446
- pending = pending.then(() => progress.emit(event));
447
- },
448
- flush: () => pending
449
- };
450
- }
451
-
452
- // src/runner/output.ts
453
- var OUTPUT_TAIL_LINES = 40;
454
- function lineSplitter() {
455
- let buffer = "";
456
- return {
457
- push(chunk) {
458
- const end = chunk.lastIndexOf("\n");
459
- if (end === -1) {
460
- buffer += chunk;
461
- return "";
462
- }
463
- const lines = buffer + chunk.slice(0, end + 1);
464
- buffer = chunk.slice(end + 1);
465
- return lines;
466
- },
467
- flush() {
468
- const rest = buffer;
469
- buffer = "";
470
- return rest;
722
+ // src/runner/recipe-check.ts
723
+ function reportUnknownKeys(value, known, path, what, report) {
724
+ let ok = true;
725
+ for (const key of Object.keys(value))
726
+ if (!known.has(key)) {
727
+ report([...path, key], `is not ${what}`);
728
+ ok = false;
471
729
  }
472
- };
730
+ return ok;
473
731
  }
474
- function rewritePaths(text, fromRoot, toRoot) {
475
- const from = `${fromRoot.replace(/\/+$/, "")}/`;
476
- const to = `${toRoot.replace(/\/+$/, "")}/`;
477
- return text.split(from).join(to);
732
+ function describeRecipeValue(value) {
733
+ if (typeof value === "string") return JSON.stringify(value);
734
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
735
+ if (value === null) return "null";
736
+ if (value === void 0) return "undefined";
737
+ if (typeof value === "function") return "a function";
738
+ if (Array.isArray(value)) return value.length === 0 ? "an empty array" : "an array";
739
+ if (typeof value === "object") return "an object";
740
+ return `a ${typeof value}`;
478
741
  }
479
- function outputTail(limit = OUTPUT_TAIL_LINES) {
480
- const kept = [];
481
- return {
482
- add(line) {
483
- kept.push(line);
484
- if (kept.length > limit) kept.shift();
485
- },
486
- lines: () => [...kept]
487
- };
742
+
743
+ // src/runner/recipe-secrets.ts
744
+ var CREDENTIAL_KEYS = /* @__PURE__ */ new Set(["domain", "header", "source", "requests"]);
745
+ var UNSAFE_SECRET_ENV_VAR_KEYS = /* @__PURE__ */ new Set(["name", "source"]);
746
+ var ENV_SOURCE_KEYS = /* @__PURE__ */ new Set(["kind", "name"]);
747
+ var DEFAULT_CREDENTIAL_HEADER = "authorization";
748
+ var HOST_PATTERN = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
749
+ var HEADER_PATTERN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
750
+ var REFUSED_HEADERS = /* @__PURE__ */ new Set(["host", "content-length", "transfer-encoding", "connection"]);
751
+ var RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES = /* @__PURE__ */ new Set([
752
+ "PATH",
753
+ "HOME",
754
+ "USER",
755
+ "LOGNAME",
756
+ "SHELL",
757
+ "PWD",
758
+ "TMPDIR",
759
+ "BASH_ENV",
760
+ "ENV",
761
+ "IFS",
762
+ "NODE_OPTIONS",
763
+ "NO_UPDATE_NOTIFIER",
764
+ "FORCE_COLOR",
765
+ "NO_COLOR"
766
+ ]);
767
+ var RESERVED_UNSAFE_SECRET_ENV_VAR_PREFIXES = ["LD_", "DYLD_"];
768
+ function credentialSourceIds(recipe) {
769
+ return [...new Set(recipe.credentials.map(({ source }) => secretSourceId(source)))].toSorted();
488
770
  }
489
- function splitLines(text) {
490
- if (text === "") return [];
491
- const lines = text.split("\n");
492
- if (lines.at(-1) === "") lines.pop();
493
- return lines;
771
+ function checkCredentials(value, report) {
772
+ if (value === void 0) return [];
773
+ if (!Array.isArray(value)) {
774
+ report(
775
+ ["credentials"],
776
+ `must be a list of credentials, each { domain, header?, source, requests? }, not ${describeRecipeValue(value)}`
777
+ );
778
+ return void 0;
779
+ }
780
+ let ok = true;
781
+ const checked = [];
782
+ const byTarget = /* @__PURE__ */ new Map();
783
+ const byDomain = /* @__PURE__ */ new Map();
784
+ value.forEach((entry, index) => {
785
+ const path = ["credentials", String(index)];
786
+ const credential = checkCredential(entry, path, report);
787
+ if (credential === void 0) {
788
+ ok = false;
789
+ return;
790
+ }
791
+ const target = `${credential.domain} ${credential.header}`;
792
+ const sameTarget = byTarget.get(target);
793
+ const sameDomain = byDomain.get(credential.domain);
794
+ if (sameTarget !== void 0) {
795
+ report(
796
+ path,
797
+ `goes to the same domain and header as runner.credentials.${sameTarget}: ${credential.header} on ${credential.domain}`
798
+ );
799
+ ok = false;
800
+ } else if (sameDomain !== void 0 && sameDomain.requests !== credential.requests) {
801
+ report(
802
+ [...path, "requests"],
803
+ `can't be ${credential.requests}: runner.credentials.${sameDomain.index} goes to ${credential.domain} with ${sameDomain.requests}, and every credential for one domain has the same requests`
804
+ );
805
+ ok = false;
806
+ }
807
+ if (sameTarget === void 0) byTarget.set(target, index);
808
+ if (sameDomain === void 0) byDomain.set(credential.domain, { index, requests: credential.requests });
809
+ checked.push(credential);
810
+ });
811
+ return ok ? checked : void 0;
494
812
  }
495
-
496
- // src/runner/steps.ts
497
- var STEP_ENV = {
498
- HUSKY: "0",
499
- COREPACK_ENABLE_DOWNLOAD_PROMPT: "0",
500
- COREPACK_ENABLE_STRICT: "0",
501
- npm_config_update_notifier: "false"
502
- };
503
- async function runStep(context, request2, progress, signal) {
504
- const { phase, label } = request2;
505
- const startedAt = context.clock.now().getTime();
506
- await progress.emit({ kind: "step-started", phase, label });
507
- const queue = progressQueue(progress);
508
- const tail = outputTail();
509
- const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
510
- const emit = (stream, text) => {
511
- for (const line of splitLines(text)) {
512
- tail.add(line);
513
- queue.add({ kind: "step-output", phase, stream, line });
813
+ function checkCredential(value, path, report) {
814
+ if (!isPlainObject(value)) {
815
+ report(path, `must be { domain, header?, source, requests? }, not ${describeRecipeValue(value)}`);
816
+ return void 0;
817
+ }
818
+ let ok = reportUnknownKeys(value, CREDENTIAL_KEYS, path, "a credential key", report);
819
+ const domain = value["domain"];
820
+ if (typeof domain !== "string" || !HOST_PATTERN.test(domain)) {
821
+ report(
822
+ [...path, "domain"],
823
+ `must be a bare hostname, such as registry.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, path, or wildcard, not ${describeRecipeValue(domain)}`
824
+ );
825
+ ok = false;
826
+ }
827
+ const header = value["header"] === void 0 ? DEFAULT_CREDENTIAL_HEADER : value["header"];
828
+ if (typeof header !== "string" || !HEADER_PATTERN.test(header)) {
829
+ report(
830
+ [...path, "header"],
831
+ `must be an HTTP header name, such as authorization, not ${describeRecipeValue(header)}`
832
+ );
833
+ ok = false;
834
+ } else if (REFUSED_HEADERS.has(header.toLowerCase())) {
835
+ report([...path, "header"], `can't be ${header}: the firewall or HTTP sets it`);
836
+ ok = false;
837
+ }
838
+ const source = checkSecretSource(value["source"], [...path, "source"], report);
839
+ if (source === void 0) ok = false;
840
+ const requests = value["requests"] === void 0 ? "read" : value["requests"];
841
+ if (requests !== "read" && requests !== "all") {
842
+ report([...path, "requests"], `must be "read" or "all", not ${describeRecipeValue(requests)}`);
843
+ ok = false;
844
+ }
845
+ return ok && source !== void 0 ? {
846
+ domain,
847
+ header: header.toLowerCase(),
848
+ source,
849
+ requests
850
+ } : void 0;
851
+ }
852
+ function checkSecretSource(value, path, report) {
853
+ if (!isPlainObject(value)) {
854
+ report(path, `must be a secret source, { kind: "env", name }, not ${describeRecipeValue(value)}`);
855
+ return void 0;
856
+ }
857
+ const kind2 = value["kind"];
858
+ if (kind2 !== "env") {
859
+ report([...path, "kind"], `must be "env", not ${describeRecipeValue(kind2)}`);
860
+ if (kind2 !== void 0) return void 0;
861
+ }
862
+ let ok = kind2 === "env";
863
+ if (!reportUnknownKeys(value, ENV_SOURCE_KEYS, path, "a secret source key", report)) ok = false;
864
+ const name = value["name"];
865
+ if (typeof name !== "string" || !ENV_VAR_NAME_PATTERN.test(name)) {
866
+ report([...path, "name"], `must be ${ENV_VAR_NAME_RULE}, not ${describeRecipeValue(name)}`);
867
+ ok = false;
868
+ }
869
+ return ok ? { kind: "env", name } : void 0;
870
+ }
871
+ function checkUnsafeSecretEnvVars(value, env, credentials2, report) {
872
+ if (value === void 0) return [];
873
+ if (!Array.isArray(value)) {
874
+ report(
875
+ ["unsafeSecretEnvVars"],
876
+ `must be a list of unsafe secret environment variables, each { name, source }, not ${describeRecipeValue(value)}`
877
+ );
878
+ return void 0;
879
+ }
880
+ let ok = true;
881
+ const checked = [];
882
+ const seen = /* @__PURE__ */ new Set();
883
+ const credentialSources = new Set((credentials2 ?? []).map(({ source }) => secretSourceId(source)));
884
+ value.forEach((entry, index) => {
885
+ const path = ["unsafeSecretEnvVars", String(index)];
886
+ if (!isPlainObject(entry)) {
887
+ report(path, `must be { name, source }, not ${describeRecipeValue(entry)}`);
888
+ ok = false;
889
+ return;
514
890
  }
515
- };
516
- const ran = await context.runnerSandboxes.runScript(
517
- request2.sandbox,
518
- { script: request2.script, env: { ...STEP_ENV, ...request2.secrets } },
519
- ({ stream, data }) => emit(stream, splitters[stream].push(data)),
520
- signal
521
- );
522
- emit("stdout", splitters.stdout.flush());
523
- emit("stderr", splitters.stderr.flush());
524
- await queue.flush();
525
- if (!ran.ok) return { kind: "sandbox-failed", failure: ran.failure };
526
- if (ran.value.exitCode !== 0) return { kind: "exited", exitCode: ran.value.exitCode, tail: tail.lines() };
527
- const ms = context.clock.now().getTime() - startedAt;
528
- await progress.emit({ kind: "step-finished", phase, label, ms });
529
- return { kind: "succeeded", ms };
891
+ let entryOk = reportUnknownKeys(
892
+ entry,
893
+ UNSAFE_SECRET_ENV_VAR_KEYS,
894
+ path,
895
+ "an unsafe secret environment variable key",
896
+ report
897
+ );
898
+ const name = entry["name"];
899
+ const namePath = [...path, "name"];
900
+ if (typeof name !== "string" || !ENV_VAR_NAME_PATTERN.test(name)) {
901
+ report(namePath, `must be ${ENV_VAR_NAME_RULE}, not ${describeRecipeValue(name)}`);
902
+ entryOk = false;
903
+ } else if (name === RUN_PAYLOAD_VARIABLE) {
904
+ report(namePath, `can't be ${name}: storm sets it for the command`);
905
+ entryOk = false;
906
+ } else if (RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES.has(name)) {
907
+ report(namePath, `can't be ${name}: it changes how the command's shell or programs run`);
908
+ entryOk = false;
909
+ } else if (reservedUnsafeSecretEnvVarPrefix(name) !== void 0) {
910
+ report(
911
+ namePath,
912
+ `can't be ${name}: a name starting with ${reservedUnsafeSecretEnvVarPrefix(name)} changes how the command's programs load`
913
+ );
914
+ entryOk = false;
915
+ } else if (env !== void 0 && Object.hasOwn(env, name)) {
916
+ report(namePath, `can't be ${name}: runner.env already sets it`);
917
+ entryOk = false;
918
+ } else if (seen.has(name)) {
919
+ report(namePath, `names ${name} again`);
920
+ entryOk = false;
921
+ }
922
+ if (typeof name === "string") seen.add(name);
923
+ const source = checkSecretSource(entry["source"], [...path, "source"], report);
924
+ if (source === void 0) {
925
+ entryOk = false;
926
+ } else if (credentialSources.has(secretSourceId(source))) {
927
+ report([...path, "source"], `can't use ${secretSourceId(source)}: runner.credentials already reads it`);
928
+ entryOk = false;
929
+ }
930
+ if (entryOk && source !== void 0) checked.push({ name, source });
931
+ else ok = false;
932
+ });
933
+ return ok ? checked : void 0;
530
934
  }
531
- function sandboxApiFailure(operation, failure) {
532
- if (failure.kind === "snapshot-gone")
533
- return { kind: "sandbox-api-failed", operation, status: 410, message: failure.message };
534
- return { kind: "sandbox-api-failed", operation, status: failure.status ?? null, message: failure.message };
935
+ function reservedUnsafeSecretEnvVarPrefix(name) {
936
+ return RESERVED_UNSAFE_SECRET_ENV_VAR_PREFIXES.find((prefix) => name.startsWith(prefix));
535
937
  }
536
- function sandboxStop(operation, failure) {
537
- return failure.kind === "aborted" ? { kind: "aborted" } : { kind: "failed", failure: sandboxApiFailure(operation, failure) };
938
+ function isPlainObject(value) {
939
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
940
+ const proto = Object.getPrototypeOf(value);
941
+ return proto === Object.prototype || proto === null;
538
942
  }
539
943
 
540
944
  // src/runner/recipe.ts
945
+ var MAX_RUNNER_SANDBOXES = 32;
541
946
  var RECIPE_DEFAULTS = {
542
947
  cwd: ".",
543
948
  timeout: "60m",
@@ -552,32 +957,22 @@ var RECIPE_KEYS = /* @__PURE__ */ new Set([
552
957
  "cwd",
553
958
  "vcpus",
554
959
  "env",
555
- "secrets",
960
+ "credentials",
961
+ "unsafeSecretEnvVars",
962
+ "allowedDomains",
556
963
  "timeout",
557
964
  "keepSandbox",
558
965
  "baseRefs",
559
966
  "region",
560
- "runtime"
967
+ "runtime",
968
+ "sandboxes"
561
969
  ]);
970
+ var SANDBOXES_KEYS = /* @__PURE__ */ new Set(["max", "default"]);
562
971
  var SNAPSHOT_KEYS = /* @__PURE__ */ new Set(["vcpus", "summary", "toolchains", "prebuild"]);
563
972
  var RUN_KEYS = /* @__PURE__ */ new Set(["install", "build"]);
564
- var STEP_KEYS = /* @__PURE__ */ new Set(["label", "script", "secrets"]);
973
+ var STEP_KEYS = /* @__PURE__ */ new Set(["label", "script"]);
565
974
  var NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
566
- var VARIABLE_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
567
- var RESERVED_SECRET_NAMES = /* @__PURE__ */ new Set([
568
- "PATH",
569
- "HOME",
570
- "USER",
571
- "LOGNAME",
572
- "SHELL",
573
- "PWD",
574
- "TMPDIR",
575
- "BASH_ENV",
576
- "ENV",
577
- "IFS",
578
- "NODE_OPTIONS"
579
- ]);
580
- var RESERVED_SECRET_PREFIXES = ["LD_", "DYLD_"];
975
+ var ALLOWED_DOMAIN_PATTERN = /^(?:\*\.)?(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
581
976
  function checkRecipe(value) {
582
977
  const problems = [];
583
978
  const report = (path, problem) => problems.push({ path, problem });
@@ -592,9 +987,8 @@ function checkRecipe(value) {
592
987
  ["name"],
593
988
  `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeRecipeValue(name)}`
594
989
  );
595
- const declared = declaredSecrets(value["secrets"]);
596
- const snapshot = checkSnapshot(value["snapshot"], declared, report);
597
- const run = checkRun(value["run"], declared, report);
990
+ const snapshot = checkSnapshot(value["snapshot"], report);
991
+ const run = checkRun(value["run"], report);
598
992
  const cwd = orDefault(value["cwd"], RECIPE_DEFAULTS.cwd);
599
993
  if (!isRelativePath(cwd))
600
994
  report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeRecipeValue(cwd)}`);
@@ -602,7 +996,9 @@ function checkRecipe(value) {
602
996
  if (typeof vcpus !== "function" && !isPositiveInteger(vcpus))
603
997
  report(["vcpus"], `must be a positive whole number, or a function of the run, not ${describeRecipeValue(vcpus)}`);
604
998
  const env = checkEnv(value["env"], report);
605
- const secrets = checkSecrets(value["secrets"], report);
999
+ const credentials2 = checkCredentials(value["credentials"], report);
1000
+ const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials2, report);
1001
+ const allowedDomains = checkAllowedDomains(value["allowedDomains"], report);
606
1002
  const timeout = orDefault(value["timeout"], RECIPE_DEFAULTS.timeout);
607
1003
  const timeoutMinutes = typeof timeout === "string" ? parseTtl(timeout) : void 0;
608
1004
  if (timeoutMinutes === void 0)
@@ -617,13 +1013,19 @@ function checkRecipe(value) {
617
1013
  ["keepSandbox"],
618
1014
  `must be 0, or a whole number of minutes or hours up to 5h, not ${describeRecipeValue(keepSandbox)}`
619
1015
  );
1016
+ else if (unsafeSecretEnvVars !== void 0 && unsafeSecretEnvVars.length > 0 && keepSandboxMinutes !== void 0 && keepSandboxMinutes > 0)
1017
+ report(
1018
+ ["keepSandbox"],
1019
+ "can't be above 0 when runner.unsafeSecretEnvVars is set: a run that passes secrets into the runner sandbox's environment never keeps its runner sandbox"
1020
+ );
620
1021
  const baseRefs = checkBaseRefs(value["baseRefs"], report);
621
1022
  const region = orDefault(value["region"], RECIPE_DEFAULTS.region);
622
1023
  if (!isNonEmptyString(region)) report(["region"], `must be a non-empty string, not ${describeRecipeValue(region)}`);
623
1024
  const runtime = orDefault(value["runtime"], RECIPE_DEFAULTS.runtime);
624
1025
  if (!isNonEmptyString(runtime))
625
1026
  report(["runtime"], `must be a non-empty string, not ${describeRecipeValue(runtime)}`);
626
- if (problems.length > 0 || snapshot === void 0 || run === void 0 || env === void 0 || secrets === void 0 || baseRefs === void 0 || timeoutMinutes === void 0)
1027
+ const sandboxes = checkSandboxes(value["sandboxes"], report);
1028
+ if (problems.length > 0 || snapshot === void 0 || run === void 0 || env === void 0 || credentials2 === void 0 || unsafeSecretEnvVars === void 0 || allowedDomains === null || baseRefs === void 0 || timeoutMinutes === void 0 || sandboxes === false)
627
1029
  return { ok: false, problems };
628
1030
  return {
629
1031
  ok: true,
@@ -634,22 +1036,49 @@ function checkRecipe(value) {
634
1036
  cwd,
635
1037
  vcpus,
636
1038
  env,
637
- secrets,
1039
+ credentials: credentials2,
1040
+ unsafeSecretEnvVars,
1041
+ ...allowedDomains === void 0 ? {} : { allowedDomains },
638
1042
  timeout,
639
1043
  timeoutMinutes,
640
1044
  keepSandboxMinutes,
641
1045
  baseRefs,
642
1046
  region,
643
- runtime
1047
+ runtime,
1048
+ ...sandboxes === void 0 ? {} : { sandboxes }
644
1049
  }
645
1050
  };
646
1051
  }
647
- function declaredSecrets(value) {
648
- if (value === void 0) return /* @__PURE__ */ new Set();
649
- if (!Array.isArray(value)) return void 0;
650
- return new Set(value.filter((name) => typeof name === "string"));
1052
+ function checkSandboxes(value, report) {
1053
+ if (value === void 0) return void 0;
1054
+ if (!isRecord(value)) {
1055
+ report(["sandboxes"], `must be an object with max, not ${describeRecipeValue(value)}`);
1056
+ return false;
1057
+ }
1058
+ let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a runner recipe sandboxes key", report);
1059
+ const max = value["max"];
1060
+ if (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES) {
1061
+ report(
1062
+ ["sandboxes", "max"],
1063
+ `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeRecipeValue(max)}`
1064
+ );
1065
+ ok = false;
1066
+ }
1067
+ const sandboxesDefault = value["default"];
1068
+ if (sandboxesDefault !== void 0 && typeof sandboxesDefault !== "function" && !(isPositiveInteger(sandboxesDefault) && sandboxesDefault <= MAX_RUNNER_SANDBOXES)) {
1069
+ report(
1070
+ ["sandboxes", "default"],
1071
+ `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or a function of the run's test plan, not ${describeRecipeValue(sandboxesDefault)}`
1072
+ );
1073
+ ok = false;
1074
+ }
1075
+ if (!ok) return false;
1076
+ return {
1077
+ max,
1078
+ ...sandboxesDefault === void 0 ? {} : { default: sandboxesDefault }
1079
+ };
651
1080
  }
652
- function checkSnapshot(value, declared, report) {
1081
+ function checkSnapshot(value, report) {
653
1082
  if (!isRecord(value)) {
654
1083
  report(
655
1084
  ["snapshot"],
@@ -668,8 +1097,8 @@ function checkSnapshot(value, declared, report) {
668
1097
  report(["snapshot", "summary"], `must be a non-empty string, not ${describeRecipeValue(summary)}`);
669
1098
  ok = false;
670
1099
  }
671
- const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], declared, report);
672
- const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], declared, report);
1100
+ const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], report);
1101
+ const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], report);
673
1102
  if (!ok || toolchains === void 0 || prebuild === void 0) return void 0;
674
1103
  return {
675
1104
  vcpus,
@@ -678,31 +1107,39 @@ function checkSnapshot(value, declared, report) {
678
1107
  prebuild
679
1108
  };
680
1109
  }
681
- function checkRun(value, declared, report) {
1110
+ function checkRun(value, report) {
682
1111
  if (!isRecord(value)) {
683
1112
  report(["run"], `must be an object of install and build steps, not ${describeRecipeValue(value)}`);
684
1113
  return void 0;
685
1114
  }
686
1115
  const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a runner recipe run key", report);
687
- const install = checkStep(value["install"], ["run", "install"], declared, report);
688
- const build = checkStep(value["build"], ["run", "build"], declared, report);
1116
+ const install = checkStep(value["install"], ["run", "install"], report);
1117
+ const build = checkStep(value["build"], ["run", "build"], report);
689
1118
  return ok && install !== void 0 && build !== void 0 ? { install, build } : void 0;
690
1119
  }
691
- function checkSteps(value, path, declared, report) {
1120
+ function checkSteps(value, path, report) {
692
1121
  if (typeof value === "function") return value;
693
1122
  if (!Array.isArray(value)) {
694
1123
  report(path, `must be a list of steps, or a function that returns one, not ${describeRecipeValue(value)}`);
695
1124
  return void 0;
696
1125
  }
697
- const steps = value.map((step, index) => checkStep(step, [...path, String(index)], declared, report));
1126
+ const steps = value.map((step, index) => checkStep(step, [...path, String(index)], report));
698
1127
  return steps.every((step) => step !== void 0) ? steps : void 0;
699
1128
  }
700
- function checkStep(value, path, declared, report) {
1129
+ function checkStep(value, path, report) {
701
1130
  if (!isRecord(value)) {
702
1131
  report(path, `must be a step, { label, script }, not ${describeRecipeValue(value)}`);
703
1132
  return void 0;
704
1133
  }
705
- let ok = reportUnknownKeys(value, STEP_KEYS, path, "a step key", report);
1134
+ let ok = true;
1135
+ for (const key of Object.keys(value)) {
1136
+ if (STEP_KEYS.has(key)) continue;
1137
+ report(
1138
+ [...path, key],
1139
+ key === "secrets" ? "is not a step key: every recipe step gets every credential runner.credentials declares" : "is not a step key"
1140
+ );
1141
+ ok = false;
1142
+ }
706
1143
  const label = value["label"];
707
1144
  const script = value["script"];
708
1145
  if (!isNonEmptyString(label)) {
@@ -713,33 +1150,7 @@ function checkStep(value, path, declared, report) {
713
1150
  report([...path, "script"], `must be a non-empty string, not ${describeRecipeValue(script)}`);
714
1151
  ok = false;
715
1152
  }
716
- const secrets = checkStepSecrets(value["secrets"], [...path, "secrets"], declared, report);
717
- if (secrets === void 0) ok = false;
718
- return ok && secrets !== void 0 ? { label, script, secrets } : void 0;
719
- }
720
- function checkStepSecrets(value, path, declared, report) {
721
- if (value === void 0) return [];
722
- if (!Array.isArray(value)) {
723
- report(path, `must be a list of names runner.secrets declares, not ${describeRecipeValue(value)}`);
724
- return void 0;
725
- }
726
- let ok = true;
727
- const seen = /* @__PURE__ */ new Set();
728
- value.forEach((name, index) => {
729
- const at = [...path, String(index)];
730
- if (typeof name !== "string") {
731
- report(at, `must be a name runner.secrets declares, not ${describeRecipeValue(name)}`);
732
- ok = false;
733
- } else if (declared !== void 0 && !declared.has(name)) {
734
- report(at, `names ${name}, which runner.secrets doesn't declare`);
735
- ok = false;
736
- } else if (seen.has(name)) {
737
- report(at, `names ${name} again`);
738
- ok = false;
739
- }
740
- if (typeof name === "string") seen.add(name);
741
- });
742
- return ok ? [...value] : void 0;
1153
+ return ok ? { label, script } : void 0;
743
1154
  }
744
1155
  function checkEnv(value, report) {
745
1156
  if (value === void 0) return {};
@@ -760,44 +1171,39 @@ function checkEnv(value, report) {
760
1171
  }
761
1172
  return ok ? env : void 0;
762
1173
  }
763
- function checkSecrets(value, report) {
764
- if (value === void 0) return [];
1174
+ function checkAllowedDomains(value, report) {
1175
+ if (value === void 0) return void 0;
765
1176
  if (!Array.isArray(value)) {
766
- report(["secrets"], `must be a list of environment variable names, not ${describeRecipeValue(value)}`);
767
- return void 0;
1177
+ report(
1178
+ ["allowedDomains"],
1179
+ `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${describeRecipeValue(value)}`
1180
+ );
1181
+ return null;
1182
+ }
1183
+ if (value.length === 0) {
1184
+ report(["allowedDomains"], "must list at least one domain: leave the key out for full access");
1185
+ return null;
768
1186
  }
769
1187
  let ok = true;
770
1188
  const seen = /* @__PURE__ */ new Set();
771
- value.forEach((name, index) => {
772
- const path = ["secrets", String(index)];
773
- if (typeof name !== "string" || !VARIABLE_PATTERN.test(name)) {
1189
+ value.forEach((domain, index) => {
1190
+ const at = ["allowedDomains", String(index)];
1191
+ if (domain === "*") {
1192
+ report(at, "can't be *, which would allow every domain: leave runner.allowedDomains out for full access");
1193
+ ok = false;
1194
+ } else if (typeof domain !== "string" || !ALLOWED_DOMAIN_PATTERN.test(domain)) {
774
1195
  report(
775
- path,
776
- `must be an environment variable name, letters, digits and underscores, not starting with a digit, not ${describeRecipeValue(name)}`
1196
+ at,
1197
+ `must be a hostname, such as example.com, or a wildcard with one leading *., such as *.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, or path, not ${describeRecipeValue(domain)}`
777
1198
  );
778
1199
  ok = false;
779
- } else if (name === RUN_PAYLOAD_VARIABLE) {
780
- report(path, `can't be ${name}: storm sets it for the command`);
781
- ok = false;
782
- } else if (Object.hasOwn(STEP_ENV, name)) {
783
- report(path, `can't be ${name}: storm sets it for every step`);
784
- ok = false;
785
- } else if (RESERVED_SECRET_NAMES.has(name)) {
786
- report(path, `can't be ${name}: it changes how a step's shell or programs run`);
787
- ok = false;
788
- } else if (reservedPrefix(name) !== void 0) {
789
- report(path, `can't be ${name}: a name starting with ${reservedPrefix(name)} changes how a step's programs load`);
790
- ok = false;
791
- } else if (seen.has(name)) {
792
- report(path, `names ${name} again`);
1200
+ } else if (seen.has(domain)) {
1201
+ report(at, `lists ${domain} again`);
793
1202
  ok = false;
794
1203
  }
795
- if (typeof name === "string") seen.add(name);
1204
+ if (typeof domain === "string") seen.add(domain);
796
1205
  });
797
- return ok ? [...value] : void 0;
798
- }
799
- function reservedPrefix(name) {
800
- return RESERVED_SECRET_PREFIXES.find((prefix) => name.startsWith(prefix));
1206
+ return ok ? [...value] : null;
801
1207
  }
802
1208
  function checkBaseRefs(value, report) {
803
1209
  if (value === void 0) return [...RECIPE_DEFAULTS.baseRefs];
@@ -814,21 +1220,8 @@ function checkBaseRefs(value, report) {
814
1220
  });
815
1221
  return ok ? [...value] : void 0;
816
1222
  }
817
- function reportUnknownKeys(value, known, path, what, report) {
818
- let ok = true;
819
- for (const key of Object.keys(value))
820
- if (!known.has(key)) {
821
- report([...path, key], `is not ${what}`);
822
- ok = false;
823
- }
824
- return ok;
825
- }
826
- async function resolveSteps(steps, context, declared) {
827
- if (typeof steps !== "function")
828
- return {
829
- ok: true,
830
- steps: steps.map(({ label, script, secrets }) => ({ label, script, secrets: [...secrets ?? []] }))
831
- };
1223
+ async function resolveSteps(steps, context) {
1224
+ if (typeof steps !== "function") return { ok: true, steps: steps.map(({ label, script }) => ({ label, script })) };
832
1225
  let returned;
833
1226
  try {
834
1227
  returned = await steps(context);
@@ -838,9 +1231,8 @@ async function resolveSteps(steps, context, declared) {
838
1231
  if (!Array.isArray(returned))
839
1232
  return { ok: false, problem: `must return a list of steps, not ${describeRecipeValue(returned)}` };
840
1233
  const problems = [];
841
- const names = new Set(declared);
842
1234
  const checked = returned.map(
843
- (step, index) => checkStep(step, [String(index)], names, (path, problem) => problems.push({ path, problem }))
1235
+ (step, index) => checkStep(step, [String(index)], (path, problem) => problems.push({ path, problem }))
844
1236
  );
845
1237
  const first = problems[0];
846
1238
  if (first !== void 0)
@@ -863,21 +1255,29 @@ function resolveVcpus(recipe, { run, resourceKeys }) {
863
1255
  problem: `must return a positive whole number, not ${describeRecipeValue(returned)} for ${describeResourceKeys(resourceKeys)}`
864
1256
  };
865
1257
  }
1258
+ function resolveSandboxCountDefault(sandboxesDefault, testPlan) {
1259
+ if (typeof sandboxesDefault !== "function") return { ok: true, sandboxes: sandboxesDefault };
1260
+ let returned;
1261
+ try {
1262
+ returned = sandboxesDefault(Object.freeze({ testPlan }));
1263
+ } catch (error) {
1264
+ return { ok: false, problem: `threw for ${describeTestPlan(testPlan)}: ${errorMessage(error)}` };
1265
+ }
1266
+ return isPositiveInteger(returned) ? { ok: true, sandboxes: returned } : {
1267
+ ok: false,
1268
+ problem: `must return a whole number from 1, not ${describeRecipeValue(returned)} for ${describeTestPlan(testPlan)}`
1269
+ };
1270
+ }
1271
+ function describeTestPlan(testPlan) {
1272
+ if (testPlan.kind !== "counted") return "a test plan that counted nothing";
1273
+ const files = `${testPlan.files} test ${testPlan.files === 1 ? "file" : "files"}`;
1274
+ return testPlan.tests === void 0 ? `a test plan of ${files}` : `a test plan of ${testPlan.tests} ${testPlan.tests === 1 ? "test" : "tests"} in ${files}`;
1275
+ }
866
1276
  function describeResourceKeys(names) {
867
1277
  const last = names.at(-1);
868
1278
  if (last === void 0) return "a run with no resource";
869
1279
  return `a run with ${names.length === 1 ? last : `${names.slice(0, -1).join(", ")} and ${last}`}`;
870
1280
  }
871
- function describeRecipeValue(value) {
872
- if (typeof value === "string") return JSON.stringify(value);
873
- if (typeof value === "number" || typeof value === "boolean") return String(value);
874
- if (value === null) return "null";
875
- if (value === void 0) return "undefined";
876
- if (typeof value === "function") return "a function";
877
- if (Array.isArray(value)) return value.length === 0 ? "an empty array" : "an array";
878
- if (typeof value === "object") return "an object";
879
- return `a ${typeof value}`;
880
- }
881
1281
  function errorMessage(error) {
882
1282
  return error instanceof Error ? error.message : String(error);
883
1283
  }
@@ -898,7 +1298,7 @@ function isRelativePath(value) {
898
1298
  }
899
1299
 
900
1300
  // src/runner/snapshot-key.ts
901
- var SNAPSHOT_FORMAT = 3;
1301
+ var SNAPSHOT_FORMAT = 4;
902
1302
  var SANDBOX_ROOT = "/vercel/sandbox";
903
1303
  var STAGED_FILES = {
904
1304
  baseTarball: "base.tgz",
@@ -946,10 +1346,11 @@ function applyScript(staging, root = SANDBOX_ROOT) {
946
1346
  );
947
1347
  }
948
1348
  function snapshotKey(steps) {
949
- const text = (list) => list.flatMap(({ label, script, secrets }) => [label, script, `secrets=${(secrets ?? []).toSorted().join(",")}`]);
1349
+ const text = (list) => list.flatMap(({ label, script }) => [label, script]);
950
1350
  return createHash2("sha256").update(
951
1351
  [
952
1352
  `format=${SNAPSHOT_FORMAT}`,
1353
+ `credentials=${[...new Set(steps.credentials)].toSorted().join(",")}`,
953
1354
  ...text(steps.toolchains),
954
1355
  baseIndexScript("<base>", "<staging>"),
955
1356
  ...text(steps.prebuild)
@@ -958,18 +1359,142 @@ function snapshotKey(steps) {
958
1359
  }
959
1360
  async function snapshotStepsAt(checkout, request2) {
960
1361
  const context = baseStepContext(checkout, request2);
961
- const { snapshot, secrets } = request2.recipe;
962
- const toolchains = await resolveSteps(snapshot.toolchains, context, secrets);
1362
+ const { snapshot } = request2.recipe;
1363
+ const toolchains = await resolveSteps(snapshot.toolchains, context);
963
1364
  if (!toolchains.ok) return { ok: false, path: ["snapshot", "toolchains"], problem: toolchains.problem };
964
- const prebuild = await resolveSteps(snapshot.prebuild, context, secrets);
1365
+ const prebuild = await resolveSteps(snapshot.prebuild, context);
965
1366
  if (!prebuild.ok) return { ok: false, path: ["snapshot", "prebuild"], problem: prebuild.problem };
966
1367
  return {
967
1368
  ok: true,
968
1369
  toolchains: toolchains.steps,
969
1370
  prebuild: prebuild.steps,
970
- key: snapshotKey({ toolchains: toolchains.steps, prebuild: prebuild.steps })
1371
+ key: snapshotKey({
1372
+ credentials: credentialSourceIds(request2.recipe),
1373
+ toolchains: toolchains.steps,
1374
+ prebuild: prebuild.steps
1375
+ })
1376
+ };
1377
+ }
1378
+
1379
+ // src/runner/events.ts
1380
+ function progressQueue(progress) {
1381
+ let pending = Promise.resolve();
1382
+ return {
1383
+ add(event) {
1384
+ pending = pending.then(() => progress.emit(event));
1385
+ },
1386
+ flush: () => pending
1387
+ };
1388
+ }
1389
+
1390
+ // src/runner/output.ts
1391
+ var OUTPUT_TAIL_LINES = 40;
1392
+ function lineSplitter() {
1393
+ let buffer = "";
1394
+ return {
1395
+ push(chunk) {
1396
+ const end = chunk.lastIndexOf("\n");
1397
+ if (end === -1) {
1398
+ buffer += chunk;
1399
+ return "";
1400
+ }
1401
+ const lines = buffer + chunk.slice(0, end + 1);
1402
+ buffer = chunk.slice(end + 1);
1403
+ return lines;
1404
+ },
1405
+ flush() {
1406
+ const rest = buffer;
1407
+ buffer = "";
1408
+ return rest;
1409
+ }
1410
+ };
1411
+ }
1412
+ function rewritePaths(text, fromRoot, toRoot) {
1413
+ const from = `${fromRoot.replace(/\/+$/, "")}/`;
1414
+ const to = `${toRoot.replace(/\/+$/, "")}/`;
1415
+ return text.split(from).join(to);
1416
+ }
1417
+ function outputTail(limit = OUTPUT_TAIL_LINES) {
1418
+ const kept = [];
1419
+ return {
1420
+ add(line) {
1421
+ kept.push(line);
1422
+ if (kept.length > limit) kept.shift();
1423
+ },
1424
+ lines: () => [...kept]
1425
+ };
1426
+ }
1427
+ function splitLines(text) {
1428
+ if (text === "") return [];
1429
+ const lines = text.split("\n");
1430
+ if (lines.at(-1) === "") lines.pop();
1431
+ return lines;
1432
+ }
1433
+
1434
+ // src/runner/steps.ts
1435
+ var STEP_ENV = {
1436
+ HUSKY: "0",
1437
+ COREPACK_ENABLE_DOWNLOAD_PROMPT: "0",
1438
+ COREPACK_ENABLE_STRICT: "0",
1439
+ npm_config_update_notifier: "false"
1440
+ };
1441
+ async function runStep(context, request2, progress, signal) {
1442
+ const { phase, label } = request2;
1443
+ const startedAt = context.clock.now().getTime();
1444
+ await progress.emit({ kind: "step-started", phase, label });
1445
+ const queue = progressQueue(progress);
1446
+ const tail = outputTail();
1447
+ const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
1448
+ const emit = (stream, text) => {
1449
+ for (const line of splitLines(text)) {
1450
+ tail.add(line);
1451
+ queue.add({ kind: "step-output", phase, stream, line });
1452
+ }
1453
+ };
1454
+ const ran = await context.runnerSandboxes.runScript(
1455
+ request2.sandbox,
1456
+ { script: request2.script, env: { ...STEP_ENV } },
1457
+ ({ stream, data }) => emit(stream, splitters[stream].push(data)),
1458
+ signal
1459
+ );
1460
+ emit("stdout", splitters.stdout.flush());
1461
+ emit("stderr", splitters.stderr.flush());
1462
+ await queue.flush();
1463
+ if (!ran.ok) return { kind: "sandbox-failed", failure: ran.failure };
1464
+ if (ran.value.exitCode !== 0) return { kind: "exited", exitCode: ran.value.exitCode, tail: tail.lines() };
1465
+ const ms = context.clock.now().getTime() - startedAt;
1466
+ await progress.emit({ kind: "step-finished", phase, label, ms });
1467
+ return { kind: "succeeded", ms };
1468
+ }
1469
+ function networkPolicyStop(operation, around, failure) {
1470
+ if (failure.kind === "aborted") return { kind: "aborted" };
1471
+ return {
1472
+ kind: "failed",
1473
+ failure: failure.kind === "timed-out" ? {
1474
+ kind: "network-policy-failed",
1475
+ operation,
1476
+ around,
1477
+ reason: "timed-out",
1478
+ status: null,
1479
+ message: `no answer within ${failure.limitMs / 1e3} seconds`
1480
+ } : {
1481
+ kind: "network-policy-failed",
1482
+ operation,
1483
+ around,
1484
+ reason: "api",
1485
+ status: failure.status ?? null,
1486
+ message: failure.message
1487
+ }
971
1488
  };
972
1489
  }
1490
+ function sandboxApiFailure(operation, failure) {
1491
+ if (failure.kind === "snapshot-gone")
1492
+ return { kind: "sandbox-api-failed", operation, status: 410, message: failure.message };
1493
+ return { kind: "sandbox-api-failed", operation, status: failure.status ?? null, message: failure.message };
1494
+ }
1495
+ function sandboxStop(operation, failure) {
1496
+ return failure.kind === "aborted" ? { kind: "aborted" } : { kind: "failed", failure: sandboxApiFailure(operation, failure) };
1497
+ }
973
1498
 
974
1499
  // src/runner/snapshot-build.ts
975
1500
  var BUILD_SANDBOX_TIMEOUT_MS = 30 * 6e4;
@@ -1016,36 +1541,48 @@ async function buildSnapshot(context, request2, control, progress) {
1016
1541
  signal
1017
1542
  );
1018
1543
  if (!staged.ok) return sandboxStop("upload", staged.failure);
1019
- const recipeStep = ({ label, script, secrets }) => ({
1020
- label,
1021
- script,
1022
- secrets: stepSecrets(request2.secrets, secrets)
1023
- });
1024
1544
  const steps = [
1025
- ...prepared.toolchains.map(recipeStep),
1545
+ ...prepared.toolchains,
1026
1546
  { label: BASE_INDEX_LABEL, script: baseIndexScript(base, staged.value.directory) },
1027
- ...prepared.prebuild.map(recipeStep)
1547
+ ...prepared.prebuild
1028
1548
  ];
1029
1549
  await progress.emit({ kind: "output-started", section: "snapshot", sandbox: sandbox.name, region: recipe.region });
1030
- for (const step of steps) {
1031
- const ran = await runStep(context, { sandbox, phase: "snapshot", ...step }, progress, signal);
1032
- if (ran.kind === "succeeded") continue;
1033
- const stop = ran.kind === "exited" ? {
1034
- kind: "failed",
1035
- failure: { kind: "snapshot-build-step-failed", label: step.label, exitCode: ran.exitCode, tail: ran.tail }
1036
- } : sandboxStop("run-script", ran.failure);
1037
- await progress.emit({
1038
- kind: "output-ended",
1039
- section: "snapshot",
1040
- outcome: stop.kind === "aborted" ? "stopped" : "failed"
1041
- });
1042
- return stop;
1550
+ let stop;
1551
+ if (request2.credentials.length > 0) {
1552
+ const granted = await scope.grantCredentials(sandbox, request2.credentials, signal);
1553
+ if (!granted.ok) stop = networkPolicyStop("inject", "snapshot-steps", granted.failure);
1554
+ }
1555
+ if (stop === void 0) {
1556
+ for (const step of steps) {
1557
+ if (signal.aborted) {
1558
+ stop = { kind: "aborted" };
1559
+ break;
1560
+ }
1561
+ const ran = await runStep(context, { sandbox, phase: "snapshot", ...step }, progress, signal);
1562
+ if (ran.kind === "succeeded") continue;
1563
+ stop = ran.kind === "exited" ? {
1564
+ kind: "failed",
1565
+ failure: {
1566
+ kind: "snapshot-build-step-failed",
1567
+ label: step.label,
1568
+ exitCode: ran.exitCode,
1569
+ tail: ran.tail
1570
+ }
1571
+ } : sandboxStop("run-script", ran.failure);
1572
+ break;
1573
+ }
1043
1574
  }
1044
- await progress.emit({ kind: "output-ended", section: "snapshot", outcome: "finished" });
1575
+ await progress.emit({
1576
+ kind: "output-ended",
1577
+ section: "snapshot",
1578
+ outcome: stop === void 0 ? "finished" : stop.kind === "aborted" ? "stopped" : "failed"
1579
+ });
1580
+ if (stop !== void 0) return stop;
1045
1581
  if (signal.aborted) return { kind: "aborted" };
1046
1582
  await progress.emit({ kind: "snapshot-saving" });
1047
1583
  const saved = await scope.saveSnapshot(sandbox, { expirationMs: SNAPSHOT_EXPIRATION_MS });
1048
- if (!saved.ok) return sandboxStop("save-snapshot", saved.failure);
1584
+ if (!saved.ok)
1585
+ return saved.failure.kind === "credential-not-revoked" ? networkPolicyStop("remove", "snapshot-save", saved.failure.failure) : sandboxStop("save-snapshot", saved.failure);
1049
1586
  const savedAt = context.clock.now();
1050
1587
  const entry = {
1051
1588
  teamId: access.teamId,
@@ -1138,25 +1675,21 @@ async function prepareSnapshotBuild(context, request2) {
1138
1675
  }
1139
1676
  async function buildSnapshots(context, request2, control, progress) {
1140
1677
  const { signal } = control;
1141
- const scope = runnerSandboxScope(context, progress, { keepMs: 0 });
1142
- const stop = () => {
1143
- void progress.emit({ kind: "stopping", commandRunning: false, keepMs: 0 }).catch(() => void 0);
1144
- void scope.close().catch(() => void 0);
1145
- };
1146
- if (signal.aborted) stop();
1147
- else signal.addEventListener("abort", stop, { once: true });
1678
+ const scope = runnerSandboxScope(context, progress, {
1679
+ keepMs: 0,
1680
+ basePolicy: runnerNetworkPolicy(request2.build.plan.recipe),
1681
+ signal
1682
+ });
1148
1683
  try {
1149
1684
  const ended = await buildIn(context, request2, { scope, signal }, progress);
1150
- signal.removeEventListener("abort", stop);
1151
1685
  return { ...ended, cleanup: await scope.close() };
1152
1686
  } catch (error) {
1153
- signal.removeEventListener("abort", stop);
1154
1687
  await scope.close();
1155
1688
  throw error;
1156
1689
  }
1157
1690
  }
1158
1691
  async function buildIn(context, request2, control, progress) {
1159
- const { build, access, user, secrets } = request2;
1692
+ const { build, access, user, credentials: credentials2 } = request2;
1160
1693
  const { signal } = control;
1161
1694
  if (signal.aborted) return { kind: "aborted", snapshot: null };
1162
1695
  const cached = build.cached.find((entry2) => entry2.teamId === access.teamId && entry2.projectId === access.projectId);
@@ -1168,7 +1701,7 @@ async function buildIn(context, request2, control, progress) {
1168
1701
  prepared: build.plan,
1169
1702
  access,
1170
1703
  user,
1171
- secrets,
1704
+ credentials: credentials2,
1172
1705
  why: why === "no-snapshot" ? { kind: why, rejected: [] } : { kind: why }
1173
1706
  },
1174
1707
  control,
@@ -1191,6 +1724,50 @@ function localUserName() {
1191
1724
  }
1192
1725
  }
1193
1726
 
1727
+ // src/runner/secrets.ts
1728
+ function declaredSecretValues(recipe, env) {
1729
+ if (recipe === void 0) return [];
1730
+ const seen = /* @__PURE__ */ new Set();
1731
+ const values = [];
1732
+ for (const { source } of [...recipe.credentials, ...recipe.unsafeSecretEnvVars]) {
1733
+ const id = secretSourceId(source);
1734
+ if (seen.has(id)) continue;
1735
+ seen.add(id);
1736
+ const value = readSecretSourceValue(source, env);
1737
+ if (value !== void 0) values.push(value);
1738
+ }
1739
+ return values;
1740
+ }
1741
+ function readCredentials(recipe, env) {
1742
+ const read = readUniqueSources(recipe.credentials, env, ({ domain, header, requests }, value) => ({
1743
+ domain,
1744
+ header,
1745
+ value,
1746
+ requests
1747
+ }));
1748
+ return read.ok ? { ok: true, credentials: read.items } : read;
1749
+ }
1750
+ function readUnsafeSecretEnvVars(recipe, env) {
1751
+ const read = readUniqueSources(recipe.unsafeSecretEnvVars, env, ({ name }, value) => [name, value]);
1752
+ return read.ok ? { ok: true, values: Object.fromEntries(read.items) } : read;
1753
+ }
1754
+ function readUniqueSources(entries, env, map) {
1755
+ const cache = /* @__PURE__ */ new Map();
1756
+ const variables = [];
1757
+ const items = [];
1758
+ for (const entry of entries) {
1759
+ const id = secretSourceId(entry.source);
1760
+ let read = cache.get(id);
1761
+ if (read === void 0) {
1762
+ read = readSecretSource(entry.source, env);
1763
+ cache.set(id, read);
1764
+ if (!read.ok) variables.push({ name: describeSecretSource(entry.source), problem: read.problem });
1765
+ }
1766
+ if (read.ok) items.push(map(entry, read.value));
1767
+ }
1768
+ return variables.length === 0 ? { ok: true, items } : { ok: false, variables };
1769
+ }
1770
+
1194
1771
  // src/runner/snapshot-inspect.ts
1195
1772
  async function inspectSnapshotCache(context, request2) {
1196
1773
  const { checkout, runnerSnapshots } = context;
@@ -1655,14 +2232,21 @@ function liveRunnerSandboxGateway() {
1655
2232
  const holder = holding(sandbox);
1656
2233
  if (kill.aborted) return { ok: false, failure: { kind: "aborted" } };
1657
2234
  try {
1658
- const cmd = await resolveExecutable(holder, request2);
1659
- if (kill.aborted) return { ok: false, failure: { kind: "aborted" } };
1660
- const command = await startDetached(holder, {
2235
+ const cmd = await untilAborted(resolveExecutable(holder, request2, kill), kill);
2236
+ if (cmd === ABORTED || kill.aborted) return { ok: false, failure: { kind: "aborted" } };
2237
+ const starting = startDetached(holder, {
1661
2238
  cmd: "setpriv",
1662
2239
  args: [...DROP_CAPABILITIES_ARGS, cmd, ...request2.args],
1663
2240
  cwd: request2.cwd,
1664
2241
  env: { ...request2.env }
1665
2242
  });
2243
+ const command = await untilAborted(starting, kill);
2244
+ if (command === ABORTED) {
2245
+ starting.then((late) => late?.kill("SIGTERM").catch(() => {
2246
+ })).catch(() => {
2247
+ });
2248
+ return { ok: false, failure: { kind: "aborted" } };
2249
+ }
1666
2250
  if (command === void 0) return { ok: false, failure: { kind: "aborted" } };
1667
2251
  const terminate = () => {
1668
2252
  command.kill("SIGTERM").catch(() => {
@@ -1759,6 +2343,19 @@ function liveRunnerSandboxGateway() {
1759
2343
  return { ok: false, failure: sandboxFailure(error, signal) };
1760
2344
  }
1761
2345
  },
2346
+ async writeNetworkPolicy(sandbox, policy, signal) {
2347
+ const holder = holding(sandbox);
2348
+ if (signal?.aborted === true) return { ok: false, failure: { kind: "aborted" } };
2349
+ const networkPolicy = sdkNetworkPolicy(policy);
2350
+ try {
2351
+ await holder.sandbox.update({ networkPolicy }, signal === void 0 ? void 0 : { signal });
2352
+ return { ok: true };
2353
+ } catch (error) {
2354
+ const failure = sandboxFailure(error, signal);
2355
+ if (failure.kind !== "api") return { ok: false, failure };
2356
+ return { ok: false, failure: { ...failure, message: hideCredentialValues(failure.message, policy) } };
2357
+ }
2358
+ },
1762
2359
  async saveSnapshot(sandbox, request2) {
1763
2360
  const holder = holding(sandbox);
1764
2361
  try {
@@ -1784,11 +2381,12 @@ function liveRunnerSandboxGateway() {
1784
2381
  return { ok: false, failure: sandboxFailure(error, void 0) };
1785
2382
  }
1786
2383
  },
1787
- async keepRunning(sandbox, request2) {
2384
+ async keepRunning(sandbox, request2, signal) {
1788
2385
  const holder = holding(sandbox);
1789
2386
  holder.keeping = true;
1790
- await Promise.allSettled(holder.starting);
1791
- const stillRunning = (await Promise.all([...holder.running].map((command) => endProcess(holder, command)))).filter((ended) => !ended).length;
2387
+ if (!await settledUnlessAborted(holder.starting, signal)) return { ok: false, failure: { kind: "aborted" } };
2388
+ const stillRunning = (await Promise.all([...holder.running].map((command) => endProcess(holder, command, signal)))).filter((ended) => !ended).length;
2389
+ if (isAborted(signal)) return { ok: false, failure: { kind: "aborted" } };
1792
2390
  if (stillRunning > 0)
1793
2391
  return {
1794
2392
  ok: false,
@@ -1801,28 +2399,32 @@ function liveRunnerSandboxGateway() {
1801
2399
  const stopsAt = holder.sandbox.expiresAt;
1802
2400
  const short = request2.until.getTime() - (stopsAt?.getTime() ?? Date.now());
1803
2401
  if (short <= 0 && stopsAt !== void 0) return { ok: true, value: { stopsAt } };
1804
- await holder.sandbox.extendTimeout(short);
2402
+ if (signal === void 0) await holder.sandbox.extendTimeout(short);
2403
+ else await holder.sandbox.extendTimeout(short, { signal });
1805
2404
  return { ok: true, value: { stopsAt: holder.sandbox.expiresAt ?? request2.until } };
1806
2405
  } catch (error) {
1807
- return { ok: false, failure: sandboxFailure(error, void 0) };
2406
+ return { ok: false, failure: sandboxFailure(error, signal) };
1808
2407
  }
1809
2408
  },
1810
- async stop(sandbox) {
2409
+ async stop(sandbox, signal) {
1811
2410
  const holder = holding(sandbox);
2411
+ if (isAborted(signal)) return { ok: false, failure: { kind: "aborted" } };
1812
2412
  try {
1813
- await holder.sandbox.stop();
2413
+ if (signal === void 0) await holder.sandbox.stop();
2414
+ else await holder.sandbox.stop({ signal });
1814
2415
  return { ok: true };
1815
2416
  } catch (error) {
1816
- return { ok: false, failure: sandboxFailure(error, void 0) };
2417
+ return { ok: false, failure: sandboxFailure(error, signal) };
1817
2418
  }
1818
2419
  },
1819
- async delete(sandbox) {
2420
+ async delete(sandbox, signal) {
1820
2421
  const holder = holding(sandbox);
2422
+ if (isAborted(signal)) return { ok: false, failure: { kind: "aborted" } };
1821
2423
  try {
1822
- await holder.sandbox.delete({ deleteOrphanSnapshots: false });
2424
+ await holder.sandbox.delete({ deleteOrphanSnapshots: false, ...signal === void 0 ? {} : { signal } });
1823
2425
  return { ok: true };
1824
2426
  } catch (error) {
1825
- return { ok: false, failure: sandboxFailure(error, void 0) };
2427
+ return { ok: false, failure: sandboxFailure(error, signal) };
1826
2428
  }
1827
2429
  }
1828
2430
  };
@@ -1836,9 +2438,45 @@ function placement(request2) {
1836
2438
  resources: { vcpus: request2.vcpus },
1837
2439
  timeout: request2.timeoutMs,
1838
2440
  persistent: false,
1839
- tags: { ...request2.tags }
2441
+ tags: { ...request2.tags },
2442
+ networkPolicy: sdkNetworkPolicy(request2.networkPolicy)
1840
2443
  };
1841
2444
  }
2445
+ function sdkNetworkPolicy(policy) {
2446
+ switch (policy.kind) {
2447
+ case "allow-all":
2448
+ if (policy.credentials.length === 0) return "allow-all";
2449
+ return { allow: { "*": [], ...injectionRules(policy.credentials) } };
2450
+ case "custom":
2451
+ return {
2452
+ allow: {
2453
+ ...Object.fromEntries(policy.allowedDomains.map((domain) => [domain, []])),
2454
+ ...injectionRules(policy.credentials)
2455
+ }
2456
+ };
2457
+ case "deny-all":
2458
+ return "deny-all";
2459
+ }
2460
+ }
2461
+ function injectionRules(credentials2) {
2462
+ const byDomain = /* @__PURE__ */ new Map();
2463
+ for (const { domain, header, value, requests } of credentials2) {
2464
+ const group = byDomain.get(domain) ?? { requests, headers: {} };
2465
+ if (group.requests !== requests)
2466
+ throw new Error(`writeNetworkPolicy: the credentials for ${domain} differ in requests`);
2467
+ group.headers[header] = value;
2468
+ byDomain.set(domain, group);
2469
+ }
2470
+ const rules = {};
2471
+ for (const [domain, { requests, headers }] of byDomain)
2472
+ rules[domain] = requests === "all" ? [{ transform: [{ headers }] }] : [{ match: { method: ["GET", "HEAD"] }, transform: [{ headers }] }, { response: { statusCode: 403 } }];
2473
+ return rules;
2474
+ }
2475
+ function hideCredentialValues(message, policy) {
2476
+ let hidden = message;
2477
+ for (const { value } of policyCredentials(policy)) if (value !== "") hidden = hidden.split(value).join("<token>");
2478
+ return hidden;
2479
+ }
1842
2480
  function writes(directory, files) {
1843
2481
  return files.map((file) => ({ path: `${directory}/${file.name}`, content: file.content }));
1844
2482
  }
@@ -1855,16 +2493,17 @@ async function stagingDirectory(holder, signal) {
1855
2493
  holder.staging = directory;
1856
2494
  return directory;
1857
2495
  }
1858
- async function resolveExecutable(holder, request2) {
2496
+ async function resolveExecutable(holder, request2, signal) {
1859
2497
  if (request2.cmd.includes("/")) return request2.cmd;
1860
2498
  const found = await holder.sandbox.runCommand({
1861
2499
  cmd: "bash",
1862
2500
  args: ["-c", 'command -v -- "$1"', "_", request2.cmd],
1863
2501
  cwd: request2.cwd,
1864
- env: { ...request2.env }
2502
+ env: { ...request2.env },
2503
+ signal
1865
2504
  });
1866
2505
  if (found.exitCode !== 0) return request2.cmd;
1867
- const path = (await found.stdout()).trim();
2506
+ const path = (await found.stdout({ signal })).trim();
1868
2507
  return path.startsWith("/") ? path : request2.cmd;
1869
2508
  }
1870
2509
  async function startDetached(holder, params) {
@@ -1886,30 +2525,53 @@ async function follow(holder, command, onOutput, signal) {
1886
2525
  holder.running.delete(command);
1887
2526
  return { exitCode: typeof finished.exitCode === "number" ? finished.exitCode : null };
1888
2527
  }
1889
- async function endProcess(holder, command) {
1890
- for (const [signal, graceMs] of [
2528
+ async function endProcess(holder, command, signal) {
2529
+ for (const [kill, graceMs] of [
1891
2530
  ["SIGTERM", TERMINATE_GRACE_MS],
1892
2531
  ["SIGKILL", KILL_GRACE_MS]
1893
2532
  ]) {
1894
- await command.kill(signal).catch(() => void 0);
1895
- if (await endsWithin(command, graceMs)) {
2533
+ if (isAborted(signal)) return false;
2534
+ await withinLimit(graceMs, signal, (limit) => command.kill(kill, { abortSignal: limit })).catch(() => void 0);
2535
+ if (await endsWithin(command, graceMs, signal)) {
1896
2536
  holder.running.delete(command);
1897
2537
  return true;
1898
2538
  }
1899
2539
  }
1900
2540
  return false;
1901
2541
  }
1902
- async function endsWithin(command, ms) {
1903
- const timeout = new AbortController();
1904
- const timer = setTimeout(() => timeout.abort(), ms);
2542
+ async function endsWithin(command, ms, signal) {
1905
2543
  try {
1906
- await command.wait({ signal: timeout.signal });
2544
+ await withinLimit(ms, signal, (limit) => command.wait({ signal: limit }));
1907
2545
  return true;
1908
2546
  } catch {
1909
2547
  return false;
2548
+ }
2549
+ }
2550
+ async function withinLimit(ms, signal, call) {
2551
+ if (isAborted(signal)) throw new DOMException("This operation was aborted", "AbortError");
2552
+ const limit = new AbortController();
2553
+ const timer = setTimeout(() => limit.abort(), ms);
2554
+ const onAbort = () => limit.abort();
2555
+ signal?.addEventListener("abort", onAbort, { once: true });
2556
+ const aborted = new Promise((_, reject) => {
2557
+ limit.signal.addEventListener("abort", () => reject(new DOMException("This operation was aborted", "AbortError")), {
2558
+ once: true
2559
+ });
2560
+ });
2561
+ try {
2562
+ return await Promise.race([call(limit.signal), aborted]);
1910
2563
  } finally {
1911
2564
  clearTimeout(timer);
2565
+ signal?.removeEventListener("abort", onAbort);
2566
+ }
2567
+ }
2568
+ async function settledUnlessAborted(tasks, signal) {
2569
+ if (isAborted(signal)) return false;
2570
+ if (signal === void 0 || tasks.size === 0) {
2571
+ await Promise.allSettled(tasks);
2572
+ return true;
1912
2573
  }
2574
+ return await untilAborted(Promise.allSettled(tasks), signal) !== ABORTED;
1913
2575
  }
1914
2576
  function isAborted(signal) {
1915
2577
  return signal?.aborted === true;
@@ -2150,141 +2812,44 @@ async function prepareRunner(context, request2) {
2150
2812
  };
2151
2813
  }
2152
2814
 
2153
- // src/runner/sandboxed-command.ts
2154
- import { posix } from "node:path";
2155
- function sandboxedCommand(request2) {
2156
- const [first = "", ...rest] = request2.argv.map((argument) => rewritePaths(argument, request2.repoRoot, SANDBOX_ROOT));
2157
- const cmd = first.includes("/") && !first.startsWith("/") ? posix.join(request2.cwd, first) : first;
2158
- return { cmd, args: rest };
2159
- }
2160
- function sandboxEnvironment(request2) {
2161
- const bins = [
2162
- .../* @__PURE__ */ new Set([posix.join(request2.cwd, "node_modules/.bin"), posix.join(SANDBOX_ROOT, "node_modules/.bin")])
2163
- ];
2164
- return {
2165
- PATH: [...bins, request2.loginPath].filter((part) => part !== "").join(":"),
2166
- NO_UPDATE_NOTIFIER: "1",
2167
- ...request2.env["FORCE_COLOR"] !== void 0 || request2.env["NO_COLOR"] !== void 0 ? {} : request2.color === "on" ? { FORCE_COLOR: "1" } : request2.color === "off" ? { NO_COLOR: "1" } : {},
2168
- ...request2.env,
2169
- [RUN_PAYLOAD_VARIABLE]: request2.runPayload
2170
- };
2171
- }
2172
- var SANDBOX_TEST_EVENTS_PATH = "/tmp/storm-test-events.jsonl";
2173
- async function runCommandInSandbox(context, request2, control, progress) {
2174
- const { runner } = request2;
2175
- const terminal = context.runnerTerminal;
2176
- const command = sandboxedCommand({ argv: request2.argv, repoRoot: runner.repoRoot, cwd: runner.cwd });
2177
- const env = sandboxEnvironment({
2178
- cwd: runner.cwd,
2179
- loginPath: runner.loginPath,
2180
- color: terminal.color,
2181
- env: runner.env,
2182
- runPayload: request2.runPayload
2183
- });
2184
- await progress.emit({ kind: "command-output-started", sandbox: runner.sandbox.name, region: runner.region });
2185
- const startedAt = context.clock.now().getTime();
2186
- const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
2187
- const write = (stream, text) => {
2188
- if (text === "") return;
2189
- const local = rewritePaths(text, SANDBOX_ROOT, runner.repoRoot);
2190
- if (stream === "stdout") terminal.writeStdout(local);
2191
- else terminal.writeStderr(local);
2192
- };
2193
- const following = followTestEvents(context, runner, request2.testEvents, control.kill);
2194
- const ran = await context.runnerSandboxes.runCommand(
2195
- runner.sandbox,
2196
- { cmd: command.cmd, args: command.args, cwd: runner.cwd, env },
2197
- ({ stream, data }) => write(stream, splitters[stream].push(data)),
2198
- control.kill
2199
- );
2200
- const ms = context.clock.now().getTime() - startedAt;
2201
- write("stdout", splitters.stdout.flush());
2202
- write("stderr", splitters.stderr.flush());
2203
- await following?.end(ran.ok && !control.kill.aborted);
2204
- if (!ran.ok) {
2205
- if (ran.failure.kind !== "aborted")
2206
- return { kind: "failed", failure: sandboxApiFailure("run-command", ran.failure) };
2207
- await progress.emit({ kind: "command-stopped", command: posix.basename(command.cmd) });
2208
- return { kind: "killed" };
2209
- }
2210
- return { kind: "exited", exitCode: ran.value.exitCode, ms };
2211
- }
2212
- function followTestEvents(context, runner, testEvents, kill) {
2213
- if (testEvents === void 0) return void 0;
2214
- const stop = new AbortController();
2215
- const splitter = lineSplitter();
2216
- let handed = 0;
2217
- const hand = (lines) => {
2218
- for (const line of lines) {
2219
- handed += 1;
2220
- testEvents.onLine(line);
2221
- }
2222
- };
2223
- const followed = context.runnerSandboxes.followTestEvents(
2224
- runner.sandbox,
2225
- { path: SANDBOX_TEST_EVENTS_PATH },
2226
- ({ data }) => hand(splitLines(splitter.push(data))),
2227
- stop.signal
2228
- );
2229
- return {
2230
- async end(complete) {
2231
- stop.abort();
2232
- await followed;
2233
- if (!complete) {
2234
- hand(splitLines(splitter.flush()));
2235
- return;
2236
- }
2237
- const reader = lineSplitter();
2238
- let read = false;
2239
- const result = await context.runnerSandboxes.readTestEvents(
2240
- runner.sandbox,
2241
- { path: SANDBOX_TEST_EVENTS_PATH, fromLine: handed + 1 },
2242
- ({ data }) => {
2243
- if (!read) {
2244
- splitter.flush();
2245
- read = true;
2246
- }
2247
- hand(splitLines(reader.push(data)));
2248
- },
2249
- kill
2250
- );
2251
- hand(splitLines(read ? reader.flush() : splitter.flush()));
2252
- if (!result.ok && result.failure.kind === "api") testEvents.onIncomplete(result.failure.message);
2253
- }
2254
- };
2255
- }
2256
-
2257
2815
  // src/runner/ready.ts
2258
- import { posix as posix2 } from "node:path";
2816
+ import { posix } from "node:path";
2259
2817
  var APPLY_LABEL = "Applying your changes";
2260
2818
  async function readyRunner(context, request2, control, progress) {
2819
+ const chosen = await chooseSnapshot(context, request2, control, progress);
2820
+ if (chosen.kind !== "ok") return chosen;
2821
+ return await readyFromSnapshot(context, { ...request2, snapshot: chosen.value }, control, progress);
2822
+ }
2823
+ async function chooseSnapshot(context, request2, control, progress) {
2261
2824
  const { prepared, access } = request2;
2262
- const { recipe, repoRoot } = prepared;
2263
- const { scope, signal } = control;
2264
- const now = () => context.clock.now().getTime();
2265
- if (signal.aborted) return { kind: "aborted" };
2825
+ if (control.signal.aborted) return { kind: "aborted" };
2266
2826
  const pick = pickSnapshot(prepared.candidates, access);
2267
- let entry;
2268
2827
  if (pick !== void 0) {
2269
- ({ entry } = pick);
2828
+ const { entry } = pick;
2270
2829
  await progress.emit({
2271
2830
  kind: "snapshot-reused",
2272
2831
  snapshotId: entry.snapshotId,
2273
2832
  base: entry.base,
2274
2833
  builtBehind: pick.builtBehind
2275
2834
  });
2276
- } else {
2277
- const why = { kind: "no-snapshot", rejected: snapshotRejections(prepared, access) };
2278
- const building = await buildSnapshot(
2279
- context,
2280
- { prepared, access, user: request2.user, secrets: request2.secrets, why },
2281
- control,
2282
- progress
2283
- );
2284
- if (building.kind !== "ok") return building;
2285
- ({ entry } = building.value);
2835
+ return { kind: "ok", value: { entry, built: false } };
2286
2836
  }
2287
- const built = pick === void 0;
2837
+ const why = { kind: "no-snapshot", rejected: snapshotRejections(prepared, access) };
2838
+ const building = await buildSnapshot(
2839
+ context,
2840
+ { prepared, access, user: request2.user, credentials: request2.credentials, why },
2841
+ control,
2842
+ progress
2843
+ );
2844
+ if (building.kind !== "ok") return building;
2845
+ return { kind: "ok", value: { entry: building.value.entry, built: true } };
2846
+ }
2847
+ async function readyFromSnapshot(context, request2, control, progress) {
2848
+ const { prepared, access } = request2;
2849
+ const { entry, built } = request2.snapshot;
2850
+ const { recipe, repoRoot } = prepared;
2851
+ const { scope, signal } = control;
2852
+ const now = () => context.clock.now().getTime();
2288
2853
  if (signal.aborted) return { kind: "aborted" };
2289
2854
  await progress.emit({ kind: "runner-sandbox-starting", snapshotId: entry.snapshotId });
2290
2855
  const startedAt = now();
@@ -2327,28 +2892,20 @@ async function readyRunner(context, request2, control, progress) {
2327
2892
  if (applied.kind !== "ok") return applied;
2328
2893
  const loginPath = await context.runnerSandboxes.loginPath(sandbox, signal);
2329
2894
  if (!loginPath.ok) return sandboxStop("login-path", loginPath.failure);
2895
+ if (request2.credentials.length > 0) {
2896
+ const granted = await scope.grantCredentials(sandbox, request2.credentials, signal);
2897
+ if (!granted.ok) return networkPolicyStop("inject", "run-steps", granted.failure);
2898
+ }
2330
2899
  const installed = await stage(
2331
2900
  context,
2332
- {
2333
- sandbox,
2334
- phase: "install",
2335
- step: recipe.run.install,
2336
- secrets: stepSecrets(request2.secrets, recipe.run.install.secrets),
2337
- region: recipe.region
2338
- },
2901
+ { sandbox, phase: "install", step: recipe.run.install, region: recipe.region },
2339
2902
  signal,
2340
2903
  progress
2341
2904
  );
2342
2905
  if (installed.kind !== "ok") return installed;
2343
2906
  const builtOutputs = await stage(
2344
2907
  context,
2345
- {
2346
- sandbox,
2347
- phase: "build",
2348
- step: recipe.run.build,
2349
- secrets: stepSecrets(request2.secrets, recipe.run.build.secrets),
2350
- region: recipe.region
2351
- },
2908
+ { sandbox, phase: "build", step: recipe.run.build, region: recipe.region },
2352
2909
  signal,
2353
2910
  progress
2354
2911
  );
@@ -2367,122 +2924,280 @@ async function readyRunner(context, request2, control, progress) {
2367
2924
  region: recipe.region,
2368
2925
  runtime: recipe.runtime,
2369
2926
  repoRoot,
2370
- cwd: posix2.join(SANDBOX_ROOT, recipe.cwd),
2927
+ cwd: posix.join(SANDBOX_ROOT, recipe.cwd),
2371
2928
  env: recipe.env,
2372
2929
  loginPath: loginPath.value
2373
2930
  }
2374
2931
  };
2375
2932
  }
2376
- async function uploadChanges(context, request2, signal, progress) {
2377
- await progress.emit({ kind: "uploading" });
2378
- const startedAt = context.clock.now().getTime();
2379
- const files = stagedChanges(request2.prepared.upload);
2380
- const staged = await context.runnerSandboxes.upload(request2.sandbox, files, signal);
2381
- if (!staged.ok) return sandboxStop("upload", staged.failure);
2382
- const bytes = files.reduce((sum, file) => sum + file.content.byteLength, 0);
2383
- await progress.emit({ kind: "uploaded", bytes, ms: context.clock.now().getTime() - startedAt });
2384
- return { kind: "ok", value: { directory: staged.value.directory, bytes } };
2385
- }
2386
- function stagedChanges(upload) {
2387
- const encoder = new TextEncoder();
2388
- return [
2389
- { name: STAGED_FILES.patch, content: upload.patch },
2390
- {
2391
- name: STAGED_FILES.untrackedFileList,
2392
- content: encoder.encode(upload.untracked.map((path) => `${path}\0`).join(""))
2393
- },
2394
- ...upload.untrackedTarball === void 0 ? [] : [{ name: STAGED_FILES.untrackedTarball, content: upload.untrackedTarball }]
2395
- ];
2396
- }
2397
- async function stage(context, request2, signal, progress) {
2398
- if (signal.aborted) return { kind: "aborted" };
2399
- const { sandbox, phase, step } = request2;
2400
- const section = phase === "apply" ? void 0 : phase;
2401
- if (section !== void 0)
2402
- await progress.emit({ kind: "output-started", section, sandbox: sandbox.name, region: request2.region });
2403
- const ran = await runStep(
2404
- context,
2405
- {
2406
- sandbox,
2407
- phase,
2408
- label: step.label,
2409
- script: step.script,
2410
- ...request2.secrets === void 0 ? {} : { secrets: request2.secrets }
2411
- },
2412
- progress,
2413
- signal
2414
- );
2415
- if (ran.kind === "succeeded") {
2416
- if (section !== void 0) await progress.emit({ kind: "output-ended", section, outcome: "finished" });
2417
- return { kind: "ok", value: ran.ms };
2418
- }
2419
- const stop = ran.kind === "exited" ? {
2420
- kind: "failed",
2421
- failure: { kind: `${phase}-failed`, label: step.label, exitCode: ran.exitCode, tail: ran.tail }
2422
- } : sandboxStop("run-script", ran.failure);
2423
- if (section !== void 0)
2424
- await progress.emit({ kind: "output-ended", section, outcome: stop.kind === "aborted" ? "stopped" : "failed" });
2425
- return stop;
2933
+ async function uploadChanges(context, request2, signal, progress) {
2934
+ await progress.emit({ kind: "uploading" });
2935
+ const startedAt = context.clock.now().getTime();
2936
+ const files = stagedChanges(request2.prepared.upload);
2937
+ const staged = await context.runnerSandboxes.upload(request2.sandbox, files, signal);
2938
+ if (!staged.ok) return sandboxStop("upload", staged.failure);
2939
+ const bytes = files.reduce((sum, file) => sum + file.content.byteLength, 0);
2940
+ await progress.emit({ kind: "uploaded", bytes, ms: context.clock.now().getTime() - startedAt });
2941
+ return { kind: "ok", value: { directory: staged.value.directory, bytes } };
2942
+ }
2943
+ function stagedChanges(upload) {
2944
+ const encoder = new TextEncoder();
2945
+ return [
2946
+ { name: STAGED_FILES.patch, content: upload.patch },
2947
+ {
2948
+ name: STAGED_FILES.untrackedFileList,
2949
+ content: encoder.encode(upload.untracked.map((path) => `${path}\0`).join(""))
2950
+ },
2951
+ ...upload.untrackedTarball === void 0 ? [] : [{ name: STAGED_FILES.untrackedTarball, content: upload.untrackedTarball }]
2952
+ ];
2953
+ }
2954
+ async function stage(context, request2, signal, progress) {
2955
+ if (signal.aborted) return { kind: "aborted" };
2956
+ const { sandbox, phase, step } = request2;
2957
+ const section = phase === "apply" ? void 0 : phase;
2958
+ if (section !== void 0)
2959
+ await progress.emit({ kind: "output-started", section, sandbox: sandbox.name, region: request2.region });
2960
+ const ran = await runStep(context, { sandbox, phase, label: step.label, script: step.script }, progress, signal);
2961
+ if (ran.kind === "succeeded") {
2962
+ if (section !== void 0) await progress.emit({ kind: "output-ended", section, outcome: "finished" });
2963
+ return { kind: "ok", value: ran.ms };
2964
+ }
2965
+ const stop = ran.kind === "exited" ? {
2966
+ kind: "failed",
2967
+ failure: { kind: `${phase}-failed`, label: step.label, exitCode: ran.exitCode, tail: ran.tail }
2968
+ } : sandboxStop("run-script", ran.failure);
2969
+ if (section !== void 0)
2970
+ await progress.emit({ kind: "output-ended", section, outcome: stop.kind === "aborted" ? "stopped" : "failed" });
2971
+ return stop;
2972
+ }
2973
+
2974
+ // src/runner/snapshot-choice.ts
2975
+ async function chooseSnapshotForRun(context, request2, control, progress) {
2976
+ const { signal, stop } = control;
2977
+ const stageSignal = stop === void 0 ? signal : AbortSignal.any([signal, stop]);
2978
+ const scope = runnerSandboxScope(context, progress, {
2979
+ keepMs: 0,
2980
+ basePolicy: runnerNetworkPolicy(request2.prepared.recipe),
2981
+ signal
2982
+ });
2983
+ try {
2984
+ const chosen = await chooseSnapshot(context, request2, { scope, signal: stageSignal }, progress);
2985
+ const cleanup = await scope.close();
2986
+ if (chosen.kind !== "ok") return { ...chosen, cleanup };
2987
+ if (stageSignal.aborted) return { kind: "aborted", cleanup };
2988
+ return { kind: "chosen", snapshot: chosen.value, cleanup };
2989
+ } catch (error) {
2990
+ await scope.close();
2991
+ throw error;
2992
+ }
2993
+ }
2994
+
2995
+ // src/runner/sandboxed-command.ts
2996
+ import { posix as posix2 } from "node:path";
2997
+ function sandboxedCommand(request2) {
2998
+ const [first = "", ...rest] = request2.argv.map((argument) => rewritePaths(argument, request2.repoRoot, SANDBOX_ROOT));
2999
+ const cmd = first.includes("/") && !first.startsWith("/") ? posix2.join(request2.cwd, first) : first;
3000
+ return { cmd, args: rest };
3001
+ }
3002
+ function sandboxEnvironment(request2) {
3003
+ const bins = [
3004
+ .../* @__PURE__ */ new Set([posix2.join(request2.cwd, "node_modules/.bin"), posix2.join(SANDBOX_ROOT, "node_modules/.bin")])
3005
+ ];
3006
+ return {
3007
+ PATH: [...bins, request2.loginPath].filter((part) => part !== "").join(":"),
3008
+ NO_UPDATE_NOTIFIER: "1",
3009
+ ...request2.env["FORCE_COLOR"] !== void 0 || request2.env["NO_COLOR"] !== void 0 ? {} : request2.color === "on" ? { FORCE_COLOR: "1" } : request2.color === "off" ? { NO_COLOR: "1" } : {},
3010
+ ...request2.env,
3011
+ ...request2.unsafeSecretEnvVars,
3012
+ [RUN_PAYLOAD_VARIABLE]: request2.runPayload
3013
+ };
3014
+ }
3015
+ var TEST_EVENTS_END_LIMIT_MS = 3e4;
3016
+ var SANDBOX_TEST_EVENTS_PATH = "/tmp/storm-test-events.jsonl";
3017
+ async function runCommandInSandbox(context, request2, control, progress) {
3018
+ const { runner } = request2;
3019
+ const terminal = context.runnerTerminal;
3020
+ const command = sandboxedCommand({ argv: request2.argv, repoRoot: runner.repoRoot, cwd: runner.cwd });
3021
+ const env = sandboxEnvironment({
3022
+ cwd: runner.cwd,
3023
+ loginPath: runner.loginPath,
3024
+ color: terminal.color,
3025
+ env: runner.env,
3026
+ ...request2.unsafeSecretEnvVars === void 0 ? {} : { unsafeSecretEnvVars: request2.unsafeSecretEnvVars },
3027
+ runPayload: request2.runPayload
3028
+ });
3029
+ await progress.emit({ kind: "command-output-started", sandbox: runner.sandbox.name, region: runner.region });
3030
+ const startedAt = context.clock.now().getTime();
3031
+ const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
3032
+ const write = (stream, text) => {
3033
+ if (text === "") return;
3034
+ const local = rewritePaths(text, SANDBOX_ROOT, runner.repoRoot);
3035
+ if (stream === "stdout") terminal.writeStdout(local);
3036
+ else terminal.writeStderr(local);
3037
+ };
3038
+ const following = followTestEvents(context, runner, request2.testEvents, control.kill);
3039
+ const ran = await context.runnerSandboxes.runCommand(
3040
+ runner.sandbox,
3041
+ { cmd: command.cmd, args: command.args, cwd: runner.cwd, env },
3042
+ ({ stream, data }) => write(stream, splitters[stream].push(data)),
3043
+ control.kill
3044
+ );
3045
+ const ms = context.clock.now().getTime() - startedAt;
3046
+ write("stdout", splitters.stdout.flush());
3047
+ write("stderr", splitters.stderr.flush());
3048
+ await following?.end(ran.ok && !control.kill.aborted);
3049
+ if (!ran.ok) {
3050
+ if (ran.failure.kind !== "aborted")
3051
+ return { kind: "failed", failure: sandboxApiFailure("run-command", ran.failure) };
3052
+ await progress.emit({ kind: "command-stopped", command: posix2.basename(command.cmd) });
3053
+ return { kind: "killed" };
3054
+ }
3055
+ return { kind: "exited", exitCode: ran.value.exitCode, ms };
3056
+ }
3057
+ function followTestEvents(context, runner, testEvents, kill) {
3058
+ if (testEvents === void 0) return void 0;
3059
+ const stop = new AbortController();
3060
+ const splitter = lineSplitter();
3061
+ let handed = 0;
3062
+ const hand = (lines) => {
3063
+ for (const line of lines) {
3064
+ handed += 1;
3065
+ testEvents.onLine(line);
3066
+ }
3067
+ };
3068
+ const followed = context.runnerSandboxes.followTestEvents(
3069
+ runner.sandbox,
3070
+ { path: SANDBOX_TEST_EVENTS_PATH },
3071
+ ({ data }) => hand(splitLines(splitter.push(data))),
3072
+ stop.signal
3073
+ );
3074
+ return {
3075
+ async end(complete) {
3076
+ stop.abort();
3077
+ const stopped = await callWithin(context.timer, TEST_EVENTS_END_LIMIT_MS, () => followed);
3078
+ if (stopped === null) {
3079
+ hand(splitLines(splitter.flush()));
3080
+ if (complete) testEvents.onIncomplete(`following the test events file didn't stop within ${limitWords()}`);
3081
+ return;
3082
+ }
3083
+ if (!complete) {
3084
+ hand(splitLines(splitter.flush()));
3085
+ return;
3086
+ }
3087
+ const reader = lineSplitter();
3088
+ let read = false;
3089
+ const result = await callWithin(
3090
+ context.timer,
3091
+ TEST_EVENTS_END_LIMIT_MS,
3092
+ (signal) => context.runnerSandboxes.readTestEvents(
3093
+ runner.sandbox,
3094
+ { path: SANDBOX_TEST_EVENTS_PATH, fromLine: handed + 1 },
3095
+ ({ data }) => {
3096
+ if (!read) {
3097
+ splitter.flush();
3098
+ read = true;
3099
+ }
3100
+ hand(splitLines(reader.push(data)));
3101
+ },
3102
+ AbortSignal.any([kill, signal])
3103
+ )
3104
+ );
3105
+ hand(splitLines(read ? reader.flush() : splitter.flush()));
3106
+ if (result === null)
3107
+ testEvents.onIncomplete(`the final read of the test events file had no answer within ${limitWords()}`);
3108
+ else if (!result.ok && result.failure.kind === "api") testEvents.onIncomplete(result.failure.message);
3109
+ }
3110
+ };
3111
+ }
3112
+ function limitWords() {
3113
+ return `${TEST_EVENTS_END_LIMIT_MS / 1e3} seconds`;
2426
3114
  }
2427
3115
 
2428
3116
  // src/runner/session.ts
2429
3117
  function openRunnerSession(context, request2, control, progress) {
2430
3118
  const { signal, cleanup } = control;
2431
- const scope = runnerSandboxScope(context, progress, { keepMs: request2.keepMs });
2432
- const closeScope = async () => ({ ...await scope.close(), target: request2.target });
3119
+ const unsafeSecretEnvVars = request2.unsafeSecretEnvVars ?? {};
3120
+ const hasUnsafeSecretEnvVars = Object.keys(unsafeSecretEnvVars).length > 0;
3121
+ if (hasUnsafeSecretEnvVars && request2.keepMs > 0)
3122
+ throw new Error("a runner session with unsafeSecretEnvVars can't keep its runner sandbox");
3123
+ let commandRunning = false;
3124
+ const scope = runnerSandboxScope(context, progress, {
3125
+ keepMs: request2.keepMs,
3126
+ basePolicy: runnerNetworkPolicy(request2.prepared.recipe),
3127
+ signal,
3128
+ commandRunning: () => commandRunning
3129
+ });
3130
+ let cleaning;
3131
+ const cleanUp = () => cleaning ??= (async () => {
3132
+ let runnerSandboxFenced = false;
3133
+ try {
3134
+ try {
3135
+ await cleanup.startCleanup();
3136
+ } finally {
3137
+ ({ runnerSandboxFenced } = await scope.fence());
3138
+ }
3139
+ } finally {
3140
+ try {
3141
+ await cleanup.release({ runnerSandboxFenced });
3142
+ } finally {
3143
+ await scope.close();
3144
+ }
3145
+ }
3146
+ return { ...await scope.close(), target: request2.target };
3147
+ })();
2433
3148
  let readying = false;
2434
3149
  let readied;
2435
- let commandRunning = false;
2436
- const stop = () => {
2437
- void progress.emit({ kind: "stopping", commandRunning, keepMs: request2.keepMs }).catch(() => void 0);
2438
- void scope.close().catch(() => void 0);
2439
- };
2440
- if (signal.aborted) stop();
2441
- else signal.addEventListener("abort", stop, { once: true });
2442
3150
  return {
2443
3151
  async ready(access, laneSignal) {
2444
3152
  if (readying) throw new Error("the runner session readies its runner sandbox once");
2445
3153
  readying = true;
2446
- const { prepared, user, secrets } = request2;
2447
- const outcome = await readyRunner(
2448
- context,
2449
- { prepared, access, user, secrets },
2450
- { scope, signal: laneSignal },
2451
- progress
2452
- );
3154
+ const { prepared, user, credentials: credentials2, snapshot } = request2;
3155
+ const stage2 = { scope, signal: laneSignal };
3156
+ const outcome = snapshot === void 0 ? await readyRunner(context, { prepared, access, user, credentials: credentials2 }, stage2, progress) : await readyFromSnapshot(context, { prepared, access, user, credentials: credentials2, snapshot }, stage2, progress);
2453
3157
  if (outcome.kind === "ready") readied = outcome.runner;
2454
3158
  return outcome;
2455
3159
  },
2456
3160
  async runCommand(command) {
2457
3161
  if (readied === void 0) throw new Error("the runner session's runner sandbox isn't ready");
3162
+ const runner = readied;
2458
3163
  commandRunning = true;
2459
- return await runCommandInSandbox(
2460
- context,
2461
- {
2462
- runner: readied,
2463
- argv: command.argv,
2464
- runPayload: command.runPayload,
2465
- ...command.testEvents === void 0 ? {} : { testEvents: command.testEvents }
2466
- },
2467
- { kill: signal },
2468
- progress
2469
- );
2470
- },
2471
- async finish() {
2472
- commandRunning = false;
2473
- await cleanup.startCleanup();
2474
- const facts = await closeScope();
2475
- signal.removeEventListener("abort", stop);
2476
- await cleanup.release();
2477
- return facts;
2478
- },
2479
- async close() {
2480
- signal.removeEventListener("abort", stop);
2481
3164
  try {
2482
- return await closeScope();
3165
+ const run = () => runCommandInSandbox(
3166
+ context,
3167
+ {
3168
+ runner,
3169
+ argv: command.argv,
3170
+ runPayload: command.runPayload,
3171
+ ...hasUnsafeSecretEnvVars ? { unsafeSecretEnvVars } : {},
3172
+ ...command.testEvents === void 0 ? {} : { testEvents: command.testEvents }
3173
+ },
3174
+ { kill: signal },
3175
+ progress
3176
+ );
3177
+ const resourceCredentials = command.credentials ?? [];
3178
+ const granted = request2.credentials.length > 0 || resourceCredentials.length > 0;
3179
+ try {
3180
+ if (resourceCredentials.length > 0) {
3181
+ const both = await scope.grantCredentials(
3182
+ runner.sandbox,
3183
+ [...request2.credentials, ...resourceCredentials],
3184
+ signal
3185
+ );
3186
+ if (!both.ok) {
3187
+ const stop = networkPolicyStop("inject", "command", both.failure);
3188
+ return stop.kind === "aborted" ? { kind: "killed" } : { kind: "failed", failure: stop.failure };
3189
+ }
3190
+ }
3191
+ return await run();
3192
+ } finally {
3193
+ if (granted) await scope.revokeCredentials(runner.sandbox);
3194
+ }
2483
3195
  } finally {
2484
- await cleanup.release();
3196
+ commandRunning = false;
2485
3197
  }
3198
+ },
3199
+ async cleanUp() {
3200
+ return await cleanUp();
2486
3201
  }
2487
3202
  };
2488
3203
  }
@@ -2490,6 +3205,45 @@ function openRunnerSession(context, request2, control, progress) {
2490
3205
  // src/config/load.ts
2491
3206
  import { dirname, join as join2 } from "node:path";
2492
3207
 
3208
+ // src/config/check-runner.ts
3209
+ var FACTORY_HINT = "must be made by vercelSandbox({ \u2026 }) or launchMachine()";
3210
+ function checkRunner(value, inherited) {
3211
+ if (!isRecord2(value)) {
3212
+ return { ok: false, problems: [{ path: [], problem: `${FACTORY_HINT}, not ${describeValue(value)}` }] };
3213
+ }
3214
+ const kind2 = value["kind"];
3215
+ if (kind2 === "launch-machine") {
3216
+ const extraKeys = Object.keys(value).filter((key) => key !== "kind");
3217
+ if (extraKeys.length > 0) {
3218
+ return { ok: false, problems: [{ path: [], problem: `${FACTORY_HINT}, not an object` }] };
3219
+ }
3220
+ return { ok: true, value: { kind: "launch-machine" } };
3221
+ }
3222
+ if (kind2 === "vercel-sandbox") {
3223
+ const extraKeys = Object.keys(value).filter((key) => key !== "kind" && key !== "options");
3224
+ const options = value["options"];
3225
+ if (extraKeys.length > 0 || !isRecord2(options)) {
3226
+ return { ok: false, problems: [{ path: [], problem: `${FACTORY_HINT}, not an object` }] };
3227
+ }
3228
+ const rawOptions = inherited === void 0 ? options : {
3229
+ ...inherited,
3230
+ ...Object.fromEntries(Object.entries(options).filter(([, entry]) => entry !== void 0))
3231
+ };
3232
+ const checked = checkRecipe(rawOptions);
3233
+ if (!checked.ok) return checked;
3234
+ return { ok: true, value: { kind: "vercel-sandbox", recipe: checked.value } };
3235
+ }
3236
+ return { ok: false, problems: [{ path: [], problem: `${FACTORY_HINT}, not ${describeValue(value)}` }] };
3237
+ }
3238
+ function rawVercelSandboxOptions(value) {
3239
+ if (!isRecord2(value) || value["kind"] !== "vercel-sandbox") return void 0;
3240
+ const options = value["options"];
3241
+ return isRecord2(options) ? options : void 0;
3242
+ }
3243
+ function isRecord2(value) {
3244
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3245
+ }
3246
+
2493
3247
  // src/config/schema.ts
2494
3248
  var CONFIG_FILE_NAME = "storm.config.ts";
2495
3249
  function checkWith(schema, value) {
@@ -2500,87 +3254,47 @@ function checkWith(schema, value) {
2500
3254
  problems: parsed.error.issues.map(({ path, message }) => ({ path: path.map(String), problem: message }))
2501
3255
  };
2502
3256
  }
3257
+ function checkStringList(value) {
3258
+ if (!Array.isArray(value)) {
3259
+ return { ok: false, problems: [{ path: [], problem: `must be a list of strings, not ${describeValue(value)}` }] };
3260
+ }
3261
+ const problems = [];
3262
+ for (let index = 0; index < value.length; index += 1) {
3263
+ if (typeof value[index] !== "string") {
3264
+ problems.push({ path: [String(index)], problem: `must be a string, not ${describeValue(value[index])}` });
3265
+ }
3266
+ }
3267
+ return problems.length === 0 ? { ok: true, value: [...value] } : { ok: false, problems };
3268
+ }
3269
+ function checkDriver(value, drivers) {
3270
+ const checked = checkWith(nonEmptyString, value);
3271
+ if (!checked.ok) return checked;
3272
+ if (!drivers.includes(checked.value)) {
3273
+ const available = drivers.length === 0 ? "none" : drivers.join(", ");
3274
+ return { ok: false, problems: [{ path: [], problem: `is not a driver; storm has ${available}` }] };
3275
+ }
3276
+ return checked;
3277
+ }
2503
3278
  var SETTING_CHECKS = {
2504
3279
  scope: (value) => checkWith(nonEmptyString, value),
2505
3280
  project: (value) => checkWith(nonEmptyString, value),
2506
- runner: checkRecipe,
3281
+ driver: (value, { drivers }) => checkDriver(value, drivers),
3282
+ args: checkStringList,
3283
+ runner: (value, { topLevelRunnerOptions }) => checkRunner(value, topLevelRunnerOptions),
2507
3284
  testPlan: (value) => checkWith(booleanOption, value)
2508
3285
  };
2509
3286
  function isConfigSettingKey(key) {
2510
3287
  return Object.hasOwn(SETTING_CHECKS, key);
2511
3288
  }
2512
- function checkSettingValue(key, value) {
2513
- return SETTING_CHECKS[key](value);
3289
+ function checkSettingValue(key, value, context) {
3290
+ return SETTING_CHECKS[key](value, context);
2514
3291
  }
2515
3292
 
2516
- // src/config/load.ts
2517
- async function findConfigFile(gateway, startDirectory) {
2518
- if (await gateway.hasConfigFile(startDirectory)) return join2(startDirectory, CONFIG_FILE_NAME);
2519
- const root = await worktreeRoot(gateway, startDirectory);
2520
- if (root === void 0) return void 0;
2521
- for (let directory = startDirectory; directory !== root; ) {
2522
- directory = dirname(directory);
2523
- if (await gateway.hasConfigFile(directory)) return join2(directory, CONFIG_FILE_NAME);
2524
- }
2525
- return void 0;
2526
- }
2527
- async function worktreeRoot(gateway, directory) {
2528
- for (let current = directory; ; current = dirname(current)) {
2529
- if (await gateway.isWorktreeRoot(current)) return current;
2530
- if (dirname(current) === current) return void 0;
2531
- }
2532
- }
2533
- async function loadConfig(gateway, startDirectory, definitions) {
2534
- const path = await findConfigFile(gateway, startDirectory);
2535
- if (path === void 0) return { kind: "none" };
2536
- const imported = await gateway.importConfig(path);
2537
- switch (imported.kind) {
2538
- case "import-failed":
2539
- return {
2540
- kind: "invalid",
2541
- path,
2542
- problems: [{ key: null, location: imported.location ?? null, problem: imported.message }]
2543
- };
2544
- case "no-default-export":
2545
- return {
2546
- kind: "invalid",
2547
- path,
2548
- problems: [fileProblem("has no default export; export default defineConfig({ \u2026 })")]
2549
- };
2550
- case "default-export":
2551
- return checkFile(path, imported.value, definitions);
2552
- }
2553
- }
2554
- function checkFile(path, value, definitions) {
2555
- if (!isRecord2(value))
2556
- return {
2557
- kind: "invalid",
2558
- path,
2559
- problems: [fileProblem(`must default-export an object, not ${describeValue(value)}`)]
2560
- };
2561
- const settings = {};
2562
- const problems = [];
2563
- let resources = {};
2564
- for (const [key, keyValue] of Object.entries(value)) {
2565
- if (key === "resources") resources = checkResources(keyValue, definitions, problems);
2566
- else if (isConfigSettingKey(key)) {
2567
- if (keyValue !== void 0) checkSetting(key, keyValue, settings, problems);
2568
- } else problems.push({ key, location: null, problem: `is not a ${CONFIG_FILE_NAME} key` });
2569
- }
2570
- if (problems.length > 0) return { kind: "invalid", path, problems };
2571
- return { kind: "loaded", path, values: { settings, resources } };
2572
- }
2573
- function checkSetting(key, value, settings, problems) {
2574
- const checked = checkSettingValue(key, value);
2575
- if (checked.ok) Object.assign(settings, { [key]: checked.value });
2576
- else
2577
- for (const { path: inside, problem } of checked.problems)
2578
- problems.push({ key: [key, ...inside].join("."), location: null, problem });
2579
- }
2580
- function checkResources(value, definitions, problems) {
3293
+ // src/config/check-resources.ts
3294
+ function checkResources(value, definitions, problems, at) {
2581
3295
  if (value === void 0) return {};
2582
- if (!isRecord2(value)) {
2583
- problems.push({ key: "resources", location: null, problem: `must be an object, not ${describeValue(value)}` });
3296
+ if (!isRecord3(value)) {
3297
+ problems.push({ key: at, location: null, problem: `must be an object, not ${describeValue(value)}` });
2584
3298
  return {};
2585
3299
  }
2586
3300
  const byName = new Map(definitions.map((definition) => [definition.name, definition]));
@@ -2591,7 +3305,7 @@ function checkResources(value, definitions, problems) {
2591
3305
  const definition = byName.get(named !== void 0 && byName.has(named) ? named : key);
2592
3306
  if (named !== void 0 && definition !== void 0 && key !== defaultResourceKey(definition)) {
2593
3307
  problems.push({
2594
- key: `resources.${key}`,
3308
+ key: `${at}.${key}`,
2595
3309
  location: null,
2596
3310
  problem: `holds a ${named} resource; for now a resource's key must be its definition's name: name its key ${defaultResourceKey(definition)}`
2597
3311
  });
@@ -2599,27 +3313,27 @@ function checkResources(value, definitions, problems) {
2599
3313
  }
2600
3314
  if (definition === void 0) {
2601
3315
  problems.push({
2602
- key: `resources.${key}`,
3316
+ key: `${at}.${key}`,
2603
3317
  location: null,
2604
3318
  problem: `is not a resource; resources holds ${holds}`
2605
3319
  });
2606
3320
  continue;
2607
3321
  }
2608
3322
  if (resource === void 0) continue;
2609
- const options = checkResource(definition, key, resource, problems);
3323
+ const options = checkResource(definition, `${at}.${key}`, resource, problems);
2610
3324
  if (options !== void 0) found[key] = { definition: definition.name, options };
2611
3325
  }
2612
3326
  return found;
2613
3327
  }
2614
3328
  function entryName(value) {
2615
- return isRecord2(value) && typeof value["name"] === "string" ? value["name"] : void 0;
3329
+ return isRecord3(value) && typeof value["name"] === "string" ? value["name"] : void 0;
2616
3330
  }
2617
- function checkResource(definition, key, value, problems) {
3331
+ function checkResource(definition, at, value, problems) {
2618
3332
  const { name } = definition;
2619
- const options = isRecord2(value) && value["name"] === name ? value["options"] : void 0;
2620
- if (!isRecord2(options)) {
3333
+ const options = isRecord3(value) && value["name"] === name ? value["options"] : void 0;
3334
+ if (!isRecord3(options)) {
2621
3335
  problems.push({
2622
- key: `resources.${key}`,
3336
+ key: at,
2623
3337
  location: null,
2624
3338
  problem: `must be made by ${resourceCall(name)}, not ${describeValue(value)}`
2625
3339
  });
@@ -2628,7 +3342,7 @@ function checkResource(definition, key, value, problems) {
2628
3342
  const checked = {};
2629
3343
  let valid = true;
2630
3344
  for (const [option, optionValue] of Object.entries(options)) {
2631
- const path = `resources.${key}.${option}`;
3345
+ const path = `${at}.${option}`;
2632
3346
  const rule = Object.hasOwn(definition.options, option) ? definition.options[option] : void 0;
2633
3347
  if (rule === void 0) {
2634
3348
  valid = false;
@@ -2646,7 +3360,178 @@ function checkResource(definition, key, value, problems) {
2646
3360
  }
2647
3361
  return valid ? checked : void 0;
2648
3362
  }
2649
- function isRecord2(value) {
3363
+ function isRecord3(value) {
3364
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3365
+ }
3366
+
3367
+ // src/config/suite.ts
3368
+ var SUITE_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/u;
3369
+
3370
+ // src/config/check-suites.ts
3371
+ var SUITE_KEYS = /* @__PURE__ */ new Set(["driver", "args", "runner", "resources"]);
3372
+ function checkSuites(value, options, problems) {
3373
+ if (value === void 0) return {};
3374
+ if (!isRecord4(value)) {
3375
+ problems.push({ key: "suites", location: null, problem: `must be an object, not ${describeValue(value)}` });
3376
+ return {};
3377
+ }
3378
+ const settingContext = {
3379
+ drivers: options.drivers,
3380
+ topLevelRunnerOptions: options.topLevelRunnerOptions
3381
+ };
3382
+ const checked = {};
3383
+ for (const [name, raw] of Object.entries(value)) {
3384
+ const at = `suites.${name}`;
3385
+ if (!SUITE_NAME_PATTERN.test(name)) {
3386
+ problems.push({
3387
+ key: at,
3388
+ location: null,
3389
+ problem: "must hold only lowercase letters, digits, and hyphens, starting with a letter or a digit"
3390
+ });
3391
+ }
3392
+ if (!isRecord4(raw)) {
3393
+ problems.push({ key: at, location: null, problem: `must be an object, not ${describeValue(raw)}` });
3394
+ continue;
3395
+ }
3396
+ let driver;
3397
+ let hasOwnDriverKey = false;
3398
+ let args;
3399
+ let runner;
3400
+ let resources = {};
3401
+ for (const [key, keyValue] of Object.entries(raw)) {
3402
+ if (!SUITE_KEYS.has(key)) {
3403
+ problems.push({ key: `${at}.${key}`, location: null, problem: "is not a suite key" });
3404
+ continue;
3405
+ }
3406
+ if (keyValue === void 0) continue;
3407
+ if (key === "driver") {
3408
+ hasOwnDriverKey = true;
3409
+ const result = checkSettingValue("driver", keyValue, settingContext);
3410
+ if (result.ok) driver = result.value;
3411
+ else
3412
+ for (const { path: inside, problem } of result.problems)
3413
+ problems.push({ key: [`${at}.driver`, ...inside].join("."), location: null, problem });
3414
+ } else if (key === "args") {
3415
+ const result = checkSettingValue("args", keyValue, settingContext);
3416
+ if (result.ok) args = result.value;
3417
+ else
3418
+ for (const { path: inside, problem } of result.problems)
3419
+ problems.push({ key: [`${at}.args`, ...inside].join("."), location: null, problem });
3420
+ } else if (key === "runner") {
3421
+ const result = checkSettingValue("runner", keyValue, settingContext);
3422
+ if (result.ok) runner = result.value;
3423
+ else
3424
+ for (const { path: inside, problem } of result.problems)
3425
+ problems.push({ key: [`${at}.runner`, ...inside].join("."), location: null, problem });
3426
+ } else if (key === "resources") {
3427
+ resources = checkResources(keyValue, options.definitions, problems, `${at}.resources`);
3428
+ }
3429
+ }
3430
+ if (!hasOwnDriverKey && !options.hasTopLevelDriver) {
3431
+ problems.push({
3432
+ key: `${at}.driver`,
3433
+ location: null,
3434
+ problem: "must name a driver when the top level names none"
3435
+ });
3436
+ }
3437
+ checked[name] = {
3438
+ ...driver === void 0 ? {} : { driver },
3439
+ ...args === void 0 ? {} : { args },
3440
+ ...runner === void 0 ? {} : { runner },
3441
+ resources
3442
+ };
3443
+ }
3444
+ return checked;
3445
+ }
3446
+ function isRecord4(value) {
3447
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3448
+ }
3449
+
3450
+ // src/config/load.ts
3451
+ async function findConfigFile(gateway, startDirectory) {
3452
+ if (await gateway.hasConfigFile(startDirectory)) return join2(startDirectory, CONFIG_FILE_NAME);
3453
+ const root = await worktreeRoot(gateway, startDirectory);
3454
+ if (root === void 0) return void 0;
3455
+ for (let directory = startDirectory; directory !== root; ) {
3456
+ directory = dirname(directory);
3457
+ if (await gateway.hasConfigFile(directory)) return join2(directory, CONFIG_FILE_NAME);
3458
+ }
3459
+ return void 0;
3460
+ }
3461
+ async function worktreeRoot(gateway, directory) {
3462
+ for (let current = directory; ; current = dirname(current)) {
3463
+ if (await gateway.isWorktreeRoot(current)) return current;
3464
+ if (dirname(current) === current) return void 0;
3465
+ }
3466
+ }
3467
+ async function loadConfig(gateway, startDirectory, definitions, drivers) {
3468
+ const path = await findConfigFile(gateway, startDirectory);
3469
+ if (path === void 0) return { kind: "none" };
3470
+ const imported = await gateway.importConfig(path);
3471
+ switch (imported.kind) {
3472
+ case "import-failed":
3473
+ return {
3474
+ kind: "invalid",
3475
+ path,
3476
+ problems: [{ key: null, location: imported.location ?? null, problem: imported.message }]
3477
+ };
3478
+ case "no-default-export":
3479
+ return {
3480
+ kind: "invalid",
3481
+ path,
3482
+ problems: [fileProblem("has no default export; export default defineConfig({ \u2026 })")]
3483
+ };
3484
+ case "default-export":
3485
+ return checkFile(path, imported.value, definitions, drivers);
3486
+ }
3487
+ }
3488
+ function checkFile(path, value, definitions, drivers) {
3489
+ if (!isRecord5(value))
3490
+ return {
3491
+ kind: "invalid",
3492
+ path,
3493
+ problems: [fileProblem(`must default-export an object, not ${describeValue(value)}`)]
3494
+ };
3495
+ const settings = {};
3496
+ const problems = [];
3497
+ let resources = {};
3498
+ let rawSuites;
3499
+ let hasSuitesKey = false;
3500
+ const settingContext = { drivers };
3501
+ const hasTopLevelDriver = value["driver"] !== void 0;
3502
+ for (const [key, keyValue] of Object.entries(value)) {
3503
+ if (key === "resources") resources = checkResources(keyValue, definitions, problems, "resources");
3504
+ else if (key === "suites") {
3505
+ hasSuitesKey = true;
3506
+ rawSuites = keyValue;
3507
+ } else if (isConfigSettingKey(key)) {
3508
+ if (keyValue !== void 0) checkSetting(key, keyValue, settings, settingContext, problems);
3509
+ } else problems.push({ key, location: null, problem: `is not a ${CONFIG_FILE_NAME} key` });
3510
+ }
3511
+ if (settings.args !== void 0 && !hasTopLevelDriver) {
3512
+ problems.push({ key: "args", location: null, problem: "requires a top-level driver" });
3513
+ }
3514
+ const suites = hasSuitesKey ? checkSuites(
3515
+ rawSuites,
3516
+ {
3517
+ definitions,
3518
+ drivers,
3519
+ hasTopLevelDriver,
3520
+ topLevelRunnerOptions: rawVercelSandboxOptions(value["runner"])
3521
+ },
3522
+ problems
3523
+ ) : {};
3524
+ if (problems.length > 0) return { kind: "invalid", path, problems };
3525
+ return { kind: "loaded", path, values: { settings, resources, suites } };
3526
+ }
3527
+ function checkSetting(key, value, settings, context, problems) {
3528
+ const checked = checkSettingValue(key, value, context);
3529
+ if (checked.ok) Object.assign(settings, { [key]: checked.value });
3530
+ else
3531
+ for (const { path: inside, problem } of checked.problems)
3532
+ problems.push({ key: [key, ...inside].join("."), location: null, problem });
3533
+ }
3534
+ function isRecord5(value) {
2650
3535
  return typeof value === "object" && value !== null && !Array.isArray(value);
2651
3536
  }
2652
3537
  function fileProblem(problem) {
@@ -2760,6 +3645,8 @@ function resolveSettings(flags, file) {
2760
3645
  return {
2761
3646
  scope: pick(flags.scope, file?.scope),
2762
3647
  project: pick(flags.project, file?.project),
3648
+ driver: pick(void 0, file?.driver),
3649
+ args: pick(void 0, file?.args),
2763
3650
  runner: pick(void 0, file?.runner),
2764
3651
  testPlan: pick(void 0, file?.testPlan)
2765
3652
  };
@@ -2844,7 +3731,7 @@ function planResources(resources, run) {
2844
3731
  const merged = settingsFor(run);
2845
3732
  const settings = merged;
2846
3733
  planned.push(...plannedOptions(definition, key, settings));
2847
- const refused2 = definition.check(merged);
3734
+ const refused2 = definition.check(merged, run);
2848
3735
  if (refused2.length === 0)
2849
3736
  resolved[key] = {
2850
3737
  definition: definition.name,
@@ -2897,11 +3784,37 @@ function plannedOptions(definition, key, settings) {
2897
3784
  }
2898
3785
 
2899
3786
  // src/config/settings-file.ts
2900
- async function loadSettingsFile(gateway, cwd, definitions) {
2901
- const loaded = await loadConfig(gateway, cwd, definitions);
3787
+ async function loadSettingsFile(gateway, cwd, definitions, drivers) {
3788
+ const loaded = await loadConfig(gateway, cwd, definitions, drivers);
2902
3789
  if (loaded.kind === "invalid") return refused(invalidConfig(loaded.path, loaded.problems));
2903
3790
  return loaded.kind === "loaded" ? { ok: true, path: loaded.path, values: loaded.values, definitions } : { ok: true, path: null, values: void 0, definitions };
2904
3791
  }
3792
+ function effectiveConfig(file, suite) {
3793
+ if (suite === null || file.values === void 0 || !Object.hasOwn(file.values.suites, suite)) return file;
3794
+ const suiteConfig = file.values.suites[suite];
3795
+ if (suiteConfig === void 0) return file;
3796
+ const resourceEntries = Object.entries(suiteConfig.resources);
3797
+ if (suiteConfig.runner === void 0 && resourceEntries.length === 0) return file;
3798
+ const baseResources = file.values.resources;
3799
+ let resources = baseResources;
3800
+ if (resourceEntries.length > 0) {
3801
+ const merged = { ...baseResources };
3802
+ for (const [key, suiteResource] of resourceEntries) {
3803
+ const top = baseResources[key];
3804
+ merged[key] = top !== void 0 && top.definition === suiteResource.definition ? { definition: suiteResource.definition, options: { ...top.options, ...suiteResource.options } } : { definition: suiteResource.definition, options: { ...suiteResource.options } };
3805
+ }
3806
+ resources = merged;
3807
+ }
3808
+ const settings = suiteConfig.runner === void 0 ? file.values.settings : { ...file.values.settings, runner: suiteConfig.runner };
3809
+ return {
3810
+ ...file,
3811
+ values: {
3812
+ settings,
3813
+ suites: file.values.suites,
3814
+ resources
3815
+ }
3816
+ };
3817
+ }
2905
3818
  function fileSettings(file, flags) {
2906
3819
  return resolveSettings(flags, file.values?.settings);
2907
3820
  }
@@ -3127,7 +4040,7 @@ function runVercel(args) {
3127
4040
  args,
3128
4041
  {
3129
4042
  cwd: tmpdir(),
3130
- env: { ...process.env, NO_COLOR: "1", NO_UPDATE_NOTIFIER: "1" },
4043
+ env: vercelEnvironment(process.env),
3131
4044
  timeout: VERCEL_TIMEOUT_MS,
3132
4045
  maxBuffer: 16 * 1024 * 1024,
3133
4046
  encoding: "utf8"
@@ -3141,6 +4054,11 @@ function runVercel(args) {
3141
4054
  }
3142
4055
  });
3143
4056
  }
4057
+ function vercelEnvironment(host) {
4058
+ const env = { ...host, NO_COLOR: "1", NO_UPDATE_NOTIFIER: "1" };
4059
+ delete env["VERCEL_TOKEN"];
4060
+ return env;
4061
+ }
3144
4062
  function failedRun(error, stdout, stderr) {
3145
4063
  const fields = typeof error === "object" && error !== null ? error : {};
3146
4064
  const out = typeof stdout === "string" ? stdout : "";
@@ -3190,7 +4108,7 @@ function githubActionsSource(context) {
3190
4108
  let inFlight;
3191
4109
  const request2 = async () => {
3192
4110
  await context.progress.emit({ kind: "requesting-token" });
3193
- for (let attempt = 1; ; attempt += 1) {
4111
+ for (let attempt2 = 1; ; attempt2 += 1) {
3194
4112
  const sentAt = context.clock.now().getTime();
3195
4113
  const outcome = await context.gateway.request();
3196
4114
  if (outcome.ok) {
@@ -3199,11 +4117,11 @@ function githubActionsSource(context) {
3199
4117
  }
3200
4118
  const { failure } = outcome;
3201
4119
  if (failure.kind === "variables-missing") return { ok: false, failure: { source: "github-actions", failure } };
3202
- const wait = RETRY_WAITS_MS[attempt - 1];
4120
+ const wait = RETRY_WAITS_MS[attempt2 - 1];
3203
4121
  if (wait === void 0 || !isRetryable(failure))
3204
4122
  return {
3205
4123
  ok: false,
3206
- failure: { source: "github-actions", failure: { kind: "request-failed", attempts: attempt, last: failure } }
4124
+ failure: { source: "github-actions", failure: { kind: "request-failed", attempts: attempt2, last: failure } }
3207
4125
  };
3208
4126
  await context.timer.sleep(wait);
3209
4127
  }
@@ -3343,10 +4261,36 @@ function errorLocation(error, name) {
3343
4261
  return void 0;
3344
4262
  }
3345
4263
 
4264
+ // src/config/live/file-lists-file-gateway.ts
4265
+ import { readFile as readFile2 } from "node:fs/promises";
4266
+ async function readStream(stream) {
4267
+ const chunks = [];
4268
+ for await (const chunk of stream) chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
4269
+ return Buffer.concat(chunks).toString("utf8");
4270
+ }
4271
+ function liveFileListsFileGateway(stdin = process.stdin) {
4272
+ return {
4273
+ readFileListsFile: async ({ path }) => {
4274
+ let text;
4275
+ try {
4276
+ text = path === "-" ? await readStream(stdin) : await readFile2(path, "utf8");
4277
+ } catch (error) {
4278
+ return { kind: "unreadable", message: error instanceof Error ? error.message : String(error) };
4279
+ }
4280
+ try {
4281
+ return { kind: "read", value: JSON.parse(text) };
4282
+ } catch (error) {
4283
+ return { kind: "not-json", message: error instanceof Error ? error.message : String(error) };
4284
+ }
4285
+ }
4286
+ };
4287
+ }
4288
+
3346
4289
  // src/config/recipe-run.ts
3347
4290
  var NOT_PRESENT = Object.freeze({ present: false });
3348
- function recipeRun(resources) {
4291
+ function recipeRun(resources, sandboxes = 1) {
3349
4292
  const run = {
4293
+ sandboxes,
3350
4294
  get: ({ definition }) => {
3351
4295
  const key = defaultResourceKey(definition);
3352
4296
  const resource = Object.hasOwn(resources, key) ? resources[key] : void 0;
@@ -3362,9 +4306,11 @@ function recipeRun(resources) {
3362
4306
 
3363
4307
  // src/config/resolver.ts
3364
4308
  function configResolver(launcher) {
4309
+ const loadFile = () => loadSettingsFile(launcher.gateway, launcher.cwd, launcher.definitions, launcher.drivers);
3365
4310
  return {
4311
+ loadFile,
3366
4312
  async load(definition, options, target) {
3367
- const file = await loadSettingsFile(launcher.gateway, launcher.cwd, launcher.definitions);
4313
+ const file = await loadFile();
3368
4314
  if (!file.ok) return file;
3369
4315
  const settings = fileSettings(file, target);
3370
4316
  const key = defaultResourceKey(definition);
@@ -3391,9 +4337,6 @@ export {
3391
4337
  credentialSourceErrors,
3392
4338
  credentialResolver,
3393
4339
  configErrors,
3394
- RUNNER_SECRET_MIN_LENGTH,
3395
- declaredSecretValues,
3396
- readRunnerSecrets,
3397
4340
  RUNNER_SNAPSHOTS_SUBPATH,
3398
4341
  parseKeepTime,
3399
4342
  systemTimer,
@@ -3402,6 +4345,8 @@ export {
3402
4345
  testEventLine,
3403
4346
  parseTestEvent,
3404
4347
  redactSecrets,
4348
+ MAX_RUNNER_SANDBOXES,
4349
+ resolveSandboxCountDefault,
3405
4350
  lineSplitter,
3406
4351
  prepareSnapshotBuild,
3407
4352
  buildSnapshots,
@@ -3412,14 +4357,19 @@ export {
3412
4357
  liveRunnerSnapshotCacheGateway,
3413
4358
  unavailableRunnerSnapshotCacheGateway,
3414
4359
  prepareRunner,
4360
+ chooseSnapshotForRun,
3415
4361
  SANDBOX_TEST_EVENTS_PATH,
4362
+ declaredSecretValues,
4363
+ readCredentials,
4364
+ readUnsafeSecretEnvVars,
3416
4365
  openRunnerSession,
3417
4366
  inspectSnapshotCache,
3418
4367
  CONFIG_FILE_NAME,
3419
4368
  liveConfigGateway,
4369
+ liveFileListsFileGateway,
3420
4370
  findConfigFile,
3421
4371
  recipeRun,
3422
- loadSettingsFile,
4372
+ effectiveConfig,
3423
4373
  fileSettings,
3424
4374
  settleRunResources,
3425
4375
  invalidConfig,