@cnc-tools/storm 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/dist/bin/storm.js +54 -40
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
  4. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
  5. package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
  6. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
  7. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  8. package/dist/chunks/chunk-AS37D43E.js +2173 -0
  9. package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
  10. package/dist/chunks/chunk-DZLU7BYK.js +340 -0
  11. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  12. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
  13. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
  14. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
  15. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
  16. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
  17. package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
  18. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
  19. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
  20. package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
  21. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
  22. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
  23. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
  24. package/dist/chunks/chunk-SZMYIIG2.js +88 -0
  25. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
  26. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
  27. package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
  28. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  29. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
  30. package/dist/cli.d.ts +28 -0
  31. package/dist/cli.js +64 -0
  32. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
  33. package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
  34. package/dist/commands/exec/before-run.d.ts +123 -0
  35. package/dist/commands/exec/before-run.js +105 -0
  36. package/dist/commands/exec/command.d.ts +67 -14
  37. package/dist/commands/exec/command.js +31 -95
  38. package/dist/commands/exec/driver-plan.d.ts +9 -4
  39. package/dist/commands/exec/driver-plan.js +8 -8
  40. package/dist/commands/exec/exec-words.js +1 -1
  41. package/dist/commands/exec/execute-run.d.ts +39 -0
  42. package/dist/commands/exec/execute-run.js +325 -0
  43. package/dist/commands/exec/live-view.d.ts +3 -3
  44. package/dist/commands/exec/live-view.js +16 -15
  45. package/dist/commands/exec/metadata.js +1 -1
  46. package/dist/commands/exec/mint-failed.d.ts +38 -0
  47. package/dist/commands/exec/mint-failed.js +27 -4
  48. package/dist/commands/exec/outcomes.d.ts +104 -22
  49. package/dist/commands/exec/outcomes.js +73 -26
  50. package/dist/commands/exec/plan-run.d.ts +58 -150
  51. package/dist/commands/exec/plan-run.js +239 -90
  52. package/dist/commands/exec/progress.d.ts +10 -6
  53. package/dist/commands/exec/progress.js +38 -25
  54. package/dist/commands/exec/run-bin.d.ts +11 -11
  55. package/dist/commands/exec/run-bin.js +9 -9
  56. package/dist/commands/exec/run-flags.d.ts +69 -0
  57. package/dist/commands/exec/run-flags.js +58 -0
  58. package/dist/commands/exec/run-metadata.js +4 -4
  59. package/dist/commands/exec/run-summary.d.ts +58 -0
  60. package/dist/commands/exec/run-summary.js +205 -0
  61. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  62. package/dist/commands/exec/runner-refusals.js +71 -0
  63. package/dist/commands/exec/sandbox-progress.js +3 -0
  64. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  65. package/dist/commands/exec/stopped-outcome.js +77 -0
  66. package/dist/commands/exec/view.d.ts +20 -11
  67. package/dist/commands/exec/view.js +103 -47
  68. package/dist/commands/runs/facts.d.ts +8 -4
  69. package/dist/commands/runs/facts.js +19 -10
  70. package/dist/commands/runs/list/command.d.ts +16 -8
  71. package/dist/commands/runs/list/command.js +10 -10
  72. package/dist/commands/runs/list/outcomes.d.ts +8 -4
  73. package/dist/commands/runs/logs/command.js +10 -10
  74. package/dist/commands/runs/show/command.d.ts +16 -8
  75. package/dist/commands/runs/show/command.js +31 -29
  76. package/dist/commands/runs/show/metadata.js +1 -1
  77. package/dist/commands/runs/show/outcomes.d.ts +8 -4
  78. package/dist/commands/runs/show/outcomes.js +8 -6
  79. package/dist/commands/snapshots/access.d.ts +111 -0
  80. package/dist/commands/snapshots/access.js +96 -0
  81. package/dist/commands/snapshots/build/command.d.ts +376 -101
  82. package/dist/commands/snapshots/build/command.js +447 -149
  83. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  84. package/dist/commands/snapshots/build/metadata.js +31 -11
  85. package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
  86. package/dist/commands/snapshots/build/outcomes.js +200 -36
  87. package/dist/commands/snapshots/list/command.d.ts +368 -27
  88. package/dist/commands/snapshots/list/command.js +298 -68
  89. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  90. package/dist/commands/snapshots/list/metadata.js +29 -6
  91. package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
  92. package/dist/commands/snapshots/list/outcomes.js +223 -52
  93. package/dist/commands/snapshots/metadata.js +1 -1
  94. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  95. package/dist/commands/snapshots/prune/command.js +161 -0
  96. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  97. package/dist/commands/snapshots/prune/metadata.js +39 -0
  98. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  99. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  100. package/dist/commands/suites/list/command.js +17 -17
  101. package/dist/commands/suites/list/outcomes.js +2 -2
  102. package/dist/commands/test/command.d.ts +67 -14
  103. package/dist/commands/test/command.js +49 -252
  104. package/dist/commands/test/outcomes.d.ts +33 -7
  105. package/dist/config/check-runner.d.ts +3 -3
  106. package/dist/config/check-runner.js +8 -7
  107. package/dist/config/credential-resolver.d.ts +50 -5
  108. package/dist/config/credential-resolver.js +51 -19
  109. package/dist/config/credential-settle.d.ts +6 -2
  110. package/dist/config/credential-settle.js +11 -5
  111. package/dist/config/index.d.ts +2 -2
  112. package/dist/config/index.js +1 -1
  113. package/dist/config/runner.d.ts +5 -5
  114. package/dist/config/runner.js +1 -1
  115. package/dist/config/schema.d.ts +2 -2
  116. package/dist/config/schema.js +1 -1
  117. package/dist/config-file/define.d.ts +1 -1
  118. package/dist/config-file/define.js +1 -1
  119. package/dist/config-file/runner.d.ts +5 -5
  120. package/dist/config-file/toolchain.d.ts +14 -4
  121. package/dist/config-file/toolchain.js +43 -7
  122. package/dist/context.d.ts +10 -6
  123. package/dist/context.js +8 -6
  124. package/dist/core/across-sandboxes.d.ts +7 -6
  125. package/dist/core/across-sandboxes.js +123 -152
  126. package/dist/core/coordinator.d.ts +166 -0
  127. package/dist/core/coordinator.js +233 -0
  128. package/dist/core/events.d.ts +2 -2
  129. package/dist/core/index.d.ts +4 -2
  130. package/dist/core/index.js +1 -1
  131. package/dist/core/outcomes.d.ts +148 -0
  132. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  133. package/dist/core/resources.d.ts +31 -53
  134. package/dist/core/resources.js +32 -70
  135. package/dist/core/run-state.d.ts +7 -1
  136. package/dist/core/run-state.js +2 -0
  137. package/dist/core/run.d.ts +32 -236
  138. package/dist/core/run.js +107 -267
  139. package/dist/core/state-directory.d.ts +1 -1
  140. package/dist/core/state-directory.js +2 -2
  141. package/dist/credential/gateways.d.ts +15 -1
  142. package/dist/credential/index.d.ts +4 -3
  143. package/dist/credential/index.js +3 -2
  144. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  145. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  146. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  147. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  148. package/dist/credential/source.d.ts +73 -6
  149. package/dist/credential/source.js +55 -2
  150. package/dist/extension-commands.d.ts +1 -1
  151. package/dist/extension-commands.js +2 -2
  152. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  153. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  154. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  155. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  156. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  157. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  158. package/dist/extensions/testserver/credential-facts.js +29 -11
  159. package/dist/extensions/testserver/lifecycle.js +7 -1
  160. package/dist/extensions/testserver/limit.d.ts +3 -0
  161. package/dist/extensions/testserver/limit.js +3 -0
  162. package/dist/extensions/testserver/provision.d.ts +8 -1
  163. package/dist/extensions/testserver/provision.js +8 -3
  164. package/dist/extensions/testserver/refusals.d.ts +6 -1
  165. package/dist/extensions/testserver/refusals.js +16 -1
  166. package/dist/extensions/testserver/resource.d.ts +1 -1
  167. package/dist/extensions/testserver/resource.js +1 -1
  168. package/dist/extensions/testserver/result.d.ts +1 -1
  169. package/dist/extensions/testserver/result.js +9 -4
  170. package/dist/planning/driver-file-lists.d.ts +0 -15
  171. package/dist/planning/driver-file-lists.js +2 -21
  172. package/dist/planning/plan-only.d.ts +3 -14
  173. package/dist/planning/plan-only.js +11 -20
  174. package/dist/planning/run-kind-flags.js +2 -2
  175. package/dist/planning/run-plan.d.ts +45 -12
  176. package/dist/planning/run-plan.js +4 -3
  177. package/dist/planning/suites.d.ts +1 -1
  178. package/dist/planning/suites.js +2 -2
  179. package/dist/planning/test-plan.d.ts +9 -0
  180. package/dist/planning/test-plan.js +9 -0
  181. package/dist/run-directory/recording.js +3 -3
  182. package/dist/run-directory/run-record.d.ts +26 -11
  183. package/dist/run-directory/run-record.js +16 -13
  184. package/dist/runner/base.js +1 -1
  185. package/dist/runner/build-snapshots.d.ts +60 -29
  186. package/dist/runner/build-snapshots.js +136 -29
  187. package/dist/runner/context.d.ts +15 -7
  188. package/dist/runner/context.js +19 -6
  189. package/dist/runner/events.d.ts +16 -10
  190. package/dist/runner/gateways.d.ts +122 -23
  191. package/dist/runner/gateways.js +1 -1
  192. package/dist/runner/gh.d.ts +42 -0
  193. package/dist/runner/gh.js +58 -0
  194. package/dist/runner/index.d.ts +13 -8
  195. package/dist/runner/index.js +12 -6
  196. package/dist/runner/live/checkout-gateway.js +7 -0
  197. package/dist/runner/live/gh-output.d.ts +17 -0
  198. package/dist/runner/live/gh-output.js +37 -0
  199. package/dist/runner/live/gh-token-gateway.d.ts +13 -0
  200. package/dist/runner/live/gh-token-gateway.js +51 -0
  201. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  202. package/dist/runner/live/sandbox-errors.js +4 -0
  203. package/dist/runner/live/sandbox-gateway.js +140 -4
  204. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  205. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  206. package/dist/runner/live/snapshot-records.js +12 -12
  207. package/dist/runner/local-snapshot-index.d.ts +205 -0
  208. package/dist/runner/local-snapshot-index.js +210 -0
  209. package/dist/runner/network-policy.d.ts +6 -6
  210. package/dist/runner/network-policy.js +7 -7
  211. package/dist/runner/policy-writes.d.ts +1 -1
  212. package/dist/runner/policy-writes.js +1 -1
  213. package/dist/runner/prepare.d.ts +14 -14
  214. package/dist/runner/prepare.js +20 -11
  215. package/dist/runner/ready.d.ts +19 -11
  216. package/dist/runner/ready.js +104 -33
  217. package/dist/runner/sandboxed-command.d.ts +3 -3
  218. package/dist/runner/sandboxed-command.js +3 -3
  219. package/dist/runner/scope.d.ts +15 -8
  220. package/dist/runner/scope.js +16 -5
  221. package/dist/runner/secrets.d.ts +41 -18
  222. package/dist/runner/secrets.js +226 -30
  223. package/dist/runner/session.d.ts +8 -8
  224. package/dist/runner/session.js +6 -3
  225. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  226. package/dist/runner/shared-snapshot-entry.js +168 -0
  227. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  228. package/dist/runner/shared-snapshot-list.js +155 -0
  229. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  230. package/dist/runner/shared-snapshot-lookup.js +118 -0
  231. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  232. package/dist/runner/shared-snapshot-prune.js +133 -0
  233. package/dist/runner/snapshot-build.d.ts +42 -14
  234. package/dist/runner/snapshot-build.js +79 -47
  235. package/dist/runner/snapshot-choice.js +2 -1
  236. package/dist/runner/snapshot-inspect.d.ts +39 -40
  237. package/dist/runner/snapshot-inspect.js +52 -35
  238. package/dist/runner/snapshot-key.d.ts +32 -17
  239. package/dist/runner/snapshot-key.js +43 -18
  240. package/dist/runner/snapshot-source.d.ts +31 -0
  241. package/dist/runner/snapshot-source.js +122 -0
  242. package/dist/runner/steps.d.ts +1 -1
  243. package/dist/runner/steps.js +1 -1
  244. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
  245. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
  246. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
  247. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
  248. package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
  249. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
  250. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  251. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  252. package/dist/sdk/extension/credential-source.d.ts +20 -3
  253. package/dist/sdk/extension/credential-source.js +4 -4
  254. package/dist/sdk/extension/index.d.ts +3 -2
  255. package/dist/sdk/extension/index.js +2 -1
  256. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  257. package/dist/sdk/extension/secret-source.d.ts +1 -1
  258. package/dist/sdk/extension/secret-source.js +1 -1
  259. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  260. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  261. package/dist/shared/cleanup.d.ts +3 -3
  262. package/dist/shared/cleanup.js +15 -5
  263. package/dist/shared/snapshot-text.d.ts +4 -4
  264. package/dist/shared/snapshot-text.js +11 -11
  265. package/dist/time/duration.js +1 -1
  266. package/package.json +5 -3
  267. package/skills/overview.md +4 -4
  268. package/skills/plan-runs.md +1 -1
  269. package/skills/read-run-output.md +6 -6
  270. package/dist/application.d.ts +0 -21
  271. package/dist/application.js +0 -30
  272. package/dist/chunks/chunk-7EENF73W.js +0 -782
  273. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  274. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  275. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  276. package/dist/commands/exec/plan-only.d.ts +0 -10
  277. package/dist/commands/exec/plan-only.js +0 -45
  278. package/dist/commands/exec/run-command.d.ts +0 -475
  279. package/dist/commands/exec/run-command.js +0 -603
  280. package/dist/commands/exec/run-planned.d.ts +0 -20
  281. package/dist/commands/exec/run-planned.js +0 -22
  282. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  283. package/dist/commands/exec/sandbox-view.js +0 -72
  284. package/dist/commands/test/plan.d.ts +0 -92
  285. package/dist/commands/test/plan.js +0 -125
  286. package/dist/core/sandbox-end.d.ts +0 -64
  287. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  288. package/dist/runner/recipe-secrets.d.ts +0 -67
  289. package/dist/runner/snapshot-cache.d.ts +0 -148
  290. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,26 +1,27 @@
1
- // The runner recipe, the `runner` key of `storm.config.ts`: what a repository's runner snapshot holds and what
2
- // each run does on top of it. `checkRecipe` holds the recipe's static rules; `resolveVcpus` and
3
- // `resolveSandboxCountDefault` evaluate the declared scaling rules for a run. Every recipe value is plain data
1
+ // The Vercel Sandbox runner options, the `runner` key of `storm.config.ts`: what a repository's runner snapshot holds and what
2
+ // each run does on top of it. `checkVercelSandboxOptions` holds the runner's static rules; `resolveVcpus` and
3
+ // `resolveSandboxCountDefault` evaluate the declared scaling rules for a run. Every option value is plain data
4
4
  // (no functions), and the module names no resource.
5
5
  import { parseKeepTime, parseTtl } from "../time/index.js";
6
6
  import { RUN_PAYLOAD_VARIABLE } from "../sdk/run/launcher.js";
7
- import { describeRecipeValue, reportUnknownKeys } from "./recipe-check.js";
8
- import { checkCredentials, checkUnsafeSecretEnvVars, credentialSourceIds, } from "./recipe-secrets.js";
9
- export { credentialSourceIds };
7
+ import { checkSnapshotSource } from "./snapshot-source.js";
8
+ import { describeOptionValue, isRecord, reportUnknownKeys } from "./vercel-sandbox-check.js";
9
+ import { checkCredentials, checkManagedCredentials, checkUnsafeSecretEnvVars, credentialSourceIds, } from "./vercel-sandbox-secrets.js";
10
+ export { credentialSourceIds, };
10
11
  /**
11
12
  * storm's own limit on the number of runner sandboxes, which `runner.sandboxes.max` can't pass: a guard against a
12
13
  * typing mistake that would start hundreds of runner sandboxes, not a claim about what Vercel Sandbox holds.
13
14
  */
14
15
  export const MAX_RUNNER_SANDBOXES = 32;
15
- /** The defaults of a recipe's optional keys. */
16
- export const RECIPE_DEFAULTS = {
16
+ /** The defaults of a runner's optional keys. */
17
+ export const VERCEL_SANDBOX_DEFAULTS = {
17
18
  cwd: ".",
18
19
  timeout: "60m",
19
20
  baseRefs: ["main", "origin/main"],
20
21
  region: "iad1",
21
- runtime: "node22",
22
+ image: "vercel/sandbox/node:al-24",
22
23
  };
23
- const RECIPE_KEYS = new Set([
24
+ const VERCEL_SANDBOX_OPTION_KEYS = new Set([
24
25
  "name",
25
26
  "snapshot",
26
27
  "run",
@@ -28,70 +29,78 @@ const RECIPE_KEYS = new Set([
28
29
  "vcpus",
29
30
  "env",
30
31
  "credentials",
32
+ "managedCredentials",
31
33
  "unsafeSecretEnvVars",
32
34
  "allowedDomains",
33
35
  "timeout",
34
36
  "keepSandbox",
35
37
  "baseRefs",
36
38
  "region",
37
- "runtime",
39
+ "image",
38
40
  "sandboxes",
39
41
  ]);
40
42
  const SANDBOXES_KEYS = new Set(["max", "default"]);
41
43
  const SANDBOXES_DEFAULT_RULE_KEYS = new Set(["filesPerSandbox", "max"]);
42
44
  const VCPUS_RULE_KEYS = new Set(["resource", "option", "per", "min", "max"]);
43
- const SNAPSHOT_KEYS = new Set(["vcpus", "summary", "toolchains", "prebuild"]);
45
+ const SNAPSHOT_KEYS = new Set(["vcpus", "summary", "source", "toolchains", "prebuild"]);
44
46
  const RUN_KEYS = new Set(["install", "build"]);
45
47
  const STEP_KEYS = new Set(["label", "script"]);
46
48
  const TOOLCHAIN_STEP_KEYS = new Set(["label", "script", "baseFiles"]);
47
49
  const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
48
- /** A domain the recipe's `allowedDomains` lists: a bare hostname, or one with a leading `*.`. */
50
+ /** Optional VCR registry host prefix on a fully qualified image reference. */
51
+ const VCR_HOST_PREFIX = "vcr.vercel.com/";
52
+ /** Prefix for Vercel-managed sandbox images (with or without `VCR_HOST_PREFIX`). */
53
+ const MANAGED_IMAGE_PREFIX = "vercel/sandbox/";
54
+ /** Digest suffix on a pinned image reference: `sha256:` followed by 64 lowercase hex characters. */
55
+ const IMAGE_DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/;
56
+ /** A domain the runner's `allowedDomains` lists: a bare hostname, or one with a leading `*.`. */
49
57
  const 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])?)+$/;
50
58
  /**
51
- * Checks a recipe against its static rules: the keys it may hold and each value's shape. Every value must be plain
59
+ * Checks Vercel Sandbox runner options against their static rules: the keys they may hold and each value's shape.
60
+ * Every value must be plain
52
61
  * data; functions are refused with the declared form to use instead. Every problem is reported.
53
62
  */
54
- export function checkRecipe(value) {
63
+ export function checkVercelSandboxOptions(value) {
55
64
  const problems = [];
56
65
  const report = (path, problem) => problems.push({ path, problem });
57
66
  if (!isRecord(value)) {
58
- report([], `must be an object, not ${describeRecipeValue(value)}`);
67
+ report([], `must be an object, not ${describeOptionValue(value)}`);
59
68
  return { ok: false, problems };
60
69
  }
61
- reportUnknownKeys(value, RECIPE_KEYS, [], "a runner recipe key", report);
70
+ reportUnknownKeys(value, VERCEL_SANDBOX_OPTION_KEYS, [], "a vercelSandbox option key", report);
62
71
  const name = value["name"];
63
72
  if (typeof name !== "string" || !NAME_PATTERN.test(name))
64
- report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeRecipeValue(name)}`);
73
+ report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeOptionValue(name)}`);
65
74
  const snapshot = checkSnapshot(value["snapshot"], report);
66
75
  const run = checkRun(value["run"], report);
67
- const cwd = orDefault(value["cwd"], RECIPE_DEFAULTS.cwd);
76
+ const cwd = orDefault(value["cwd"], VERCEL_SANDBOX_DEFAULTS.cwd);
68
77
  if (!isRelativePath(cwd))
69
- report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeRecipeValue(cwd)}`);
78
+ report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeOptionValue(cwd)}`);
70
79
  const vcpus = checkVcpus(value["vcpus"], report);
71
80
  const env = checkEnv(value["env"], report);
72
81
  const credentials = checkCredentials(value["credentials"], report);
82
+ const managedCredentials = checkManagedCredentials(value["managedCredentials"], credentials, report);
73
83
  const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials, report);
74
84
  const allowedDomains = checkAllowedDomains(value["allowedDomains"], report);
75
- const timeout = orDefault(value["timeout"], RECIPE_DEFAULTS.timeout);
85
+ const timeout = orDefault(value["timeout"], VERCEL_SANDBOX_DEFAULTS.timeout);
76
86
  const timeoutMinutes = typeof timeout === "string" ? parseTtl(timeout) : undefined;
77
87
  if (timeoutMinutes === undefined)
78
- report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${describeRecipeValue(timeout)}`);
88
+ report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${describeOptionValue(timeout)}`);
79
89
  const keepSandbox = value["keepSandbox"];
80
90
  const keepSandboxMinutes = typeof keepSandbox === "string" ? parseKeepTime(keepSandbox) : undefined;
81
91
  if (keepSandbox !== undefined && keepSandboxMinutes === undefined)
82
- report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeRecipeValue(keepSandbox)}`);
83
- else if (unsafeSecretEnvVars !== undefined &&
84
- unsafeSecretEnvVars.length > 0 &&
85
- keepSandboxMinutes !== undefined &&
86
- keepSandboxMinutes > 0)
87
- report(["keepSandbox"], "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");
92
+ report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeOptionValue(keepSandbox)}`);
93
+ else if (keepSandboxMinutes !== undefined && keepSandboxMinutes > 0) {
94
+ if (unsafeSecretEnvVars !== undefined && unsafeSecretEnvVars.length > 0)
95
+ report(["keepSandbox"], "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");
96
+ if (managedCredentials !== undefined && managedCredentials.length > 0)
97
+ report(["keepSandbox"], "can't be above 0 when runner.managedCredentials is set: Vercel Sandbox rejects deny-all on a sandbox with managed credentials, so storm cannot fence a kept runner sandbox");
98
+ }
88
99
  const baseRefs = checkBaseRefs(value["baseRefs"], report);
89
- const region = orDefault(value["region"], RECIPE_DEFAULTS.region);
100
+ const region = orDefault(value["region"], VERCEL_SANDBOX_DEFAULTS.region);
90
101
  if (!isNonEmptyString(region))
91
- report(["region"], `must be a non-empty string, not ${describeRecipeValue(region)}`);
92
- const runtime = orDefault(value["runtime"], RECIPE_DEFAULTS.runtime);
93
- if (!isNonEmptyString(runtime))
94
- report(["runtime"], `must be a non-empty string, not ${describeRecipeValue(runtime)}`);
102
+ report(["region"], `must be a non-empty string, not ${describeOptionValue(region)}`);
103
+ const image = checkImage(orDefault(value["image"], VERCEL_SANDBOX_DEFAULTS.image), report);
95
104
  const sandboxes = checkSandboxes(value["sandboxes"], report);
96
105
  if (problems.length > 0 ||
97
106
  snapshot === undefined ||
@@ -99,10 +108,12 @@ export function checkRecipe(value) {
99
108
  vcpus === undefined ||
100
109
  env === undefined ||
101
110
  credentials === undefined ||
111
+ managedCredentials === undefined ||
102
112
  unsafeSecretEnvVars === undefined ||
103
113
  allowedDomains === null ||
104
114
  baseRefs === undefined ||
105
115
  timeoutMinutes === undefined ||
116
+ image === undefined ||
106
117
  sandboxes === false)
107
118
  return { ok: false, problems };
108
119
  return {
@@ -115,6 +126,7 @@ export function checkRecipe(value) {
115
126
  vcpus,
116
127
  env,
117
128
  credentials,
129
+ managedCredentials,
118
130
  unsafeSecretEnvVars,
119
131
  ...(allowedDomains === undefined ? {} : { allowedDomains }),
120
132
  timeout: timeout,
@@ -122,11 +134,44 @@ export function checkRecipe(value) {
122
134
  keepSandboxMinutes,
123
135
  baseRefs,
124
136
  region: region,
125
- runtime: runtime,
137
+ image,
126
138
  ...(sandboxes === undefined ? {} : { sandboxes }),
127
139
  },
128
140
  };
129
141
  }
142
+ /**
143
+ * Validates `runner.image`: a non-empty string with no whitespace, either a Vercel-managed image starting with
144
+ * `"vercel/sandbox/"` or `"vcr.vercel.com/vercel/sandbox/"` (with a non-empty suffix) or a custom VCR image reference
145
+ * pinned with `@sha256:<64 hex>`. A reference that names a digest, managed or custom, must name a well-formed one. The
146
+ * rest of the reference's grammar is Vercel Sandbox's to check when the build sandbox starts.
147
+ */
148
+ function checkImage(value, report) {
149
+ if (!isNonEmptyString(value)) {
150
+ report(["image"], `must be a non-empty string, not ${describeOptionValue(value)}`);
151
+ return undefined;
152
+ }
153
+ if (/\s/.test(value)) {
154
+ report(["image"], `must be an image reference with no whitespace, not ${describeOptionValue(value)}`);
155
+ return undefined;
156
+ }
157
+ const at = value.indexOf("@");
158
+ const name = at === -1 ? value : value.slice(0, at);
159
+ const digest = at === -1 ? undefined : value.slice(at + 1);
160
+ if (digest !== undefined && (name === "" || !IMAGE_DIGEST_PATTERN.test(digest))) {
161
+ report(["image"], `must be "<repository>@sha256:<64 lowercase hex characters>" when it names a digest, not ${describeOptionValue(value)}`);
162
+ return undefined;
163
+ }
164
+ const repo = name.startsWith(VCR_HOST_PREFIX) ? name.slice(VCR_HOST_PREFIX.length) : name;
165
+ if (repo === MANAGED_IMAGE_PREFIX) {
166
+ report(["image"], `must name a Vercel-managed image after "${MANAGED_IMAGE_PREFIX}", not ${describeOptionValue(value)}`);
167
+ return undefined;
168
+ }
169
+ if (digest === undefined && !repo.startsWith(MANAGED_IMAGE_PREFIX)) {
170
+ report(["image"], `must be a Vercel-managed image ("${MANAGED_IMAGE_PREFIX}...") or a digest-pinned custom VCR image ("<repository>@sha256:...") so runner snapshots cannot go stale, not ${describeOptionValue(value)}`);
171
+ return undefined;
172
+ }
173
+ return value;
174
+ }
130
175
  function checkVcpus(value, report) {
131
176
  if (isPositiveInteger(value))
132
177
  return value;
@@ -135,33 +180,33 @@ function checkVcpus(value, report) {
135
180
  return undefined;
136
181
  }
137
182
  if (!isRecord(value)) {
138
- report(["vcpus"], `must be a positive whole number, or { resource, option, per, min, max }, not ${describeRecipeValue(value)}`);
183
+ report(["vcpus"], `must be a positive whole number, or { resource, option, per, min, max }, not ${describeOptionValue(value)}`);
139
184
  return undefined;
140
185
  }
141
- let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a runner recipe vcpus rule key", report);
186
+ let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a vercelSandbox vcpus rule key", report);
142
187
  const resource = value["resource"];
143
188
  if (!isNonEmptyString(resource)) {
144
- report(["vcpus", "resource"], `must be a non-empty string, not ${describeRecipeValue(resource)}`);
189
+ report(["vcpus", "resource"], `must be a non-empty string, not ${describeOptionValue(resource)}`);
145
190
  ok = false;
146
191
  }
147
192
  const option = value["option"];
148
193
  if (!isNonEmptyString(option)) {
149
- report(["vcpus", "option"], `must be a non-empty string, not ${describeRecipeValue(option)}`);
194
+ report(["vcpus", "option"], `must be a non-empty string, not ${describeOptionValue(option)}`);
150
195
  ok = false;
151
196
  }
152
197
  const per = value["per"];
153
198
  if (!isPositiveInteger(per)) {
154
- report(["vcpus", "per"], `must be a positive whole number, not ${describeRecipeValue(per)}`);
199
+ report(["vcpus", "per"], `must be a positive whole number, not ${describeOptionValue(per)}`);
155
200
  ok = false;
156
201
  }
157
202
  const min = value["min"];
158
203
  if (!isPositiveInteger(min)) {
159
- report(["vcpus", "min"], `must be a positive whole number, not ${describeRecipeValue(min)}`);
204
+ report(["vcpus", "min"], `must be a positive whole number, not ${describeOptionValue(min)}`);
160
205
  ok = false;
161
206
  }
162
207
  const max = value["max"];
163
208
  if (!isPositiveInteger(max)) {
164
- report(["vcpus", "max"], `must be a positive whole number, not ${describeRecipeValue(max)}`);
209
+ report(["vcpus", "max"], `must be a positive whole number, not ${describeOptionValue(max)}`);
165
210
  ok = false;
166
211
  }
167
212
  else if (isPositiveInteger(min) && max < min) {
@@ -179,7 +224,7 @@ function checkVcpus(value, report) {
179
224
  : undefined;
180
225
  }
181
226
  /**
182
- * The recipe's `sandboxes`: an object whose `max` is a whole number from 1 to `MAX_RUNNER_SANDBOXES`, and whose
227
+ * The runner's `sandboxes`: an object whose `max` is a whole number from 1 to `MAX_RUNNER_SANDBOXES`, and whose
183
228
  * optional `default` is a whole number from 1 to `MAX_RUNNER_SANDBOXES` or a declared `{ filesPerSandbox, max? }` rule;
184
229
  * undefined when absent, and false when it is wrong, which is reported.
185
230
  */
@@ -187,13 +232,13 @@ function checkSandboxes(value, report) {
187
232
  if (value === undefined)
188
233
  return undefined;
189
234
  if (!isRecord(value)) {
190
- report(["sandboxes"], `must be an object with max, not ${describeRecipeValue(value)}`);
235
+ report(["sandboxes"], `must be an object with max, not ${describeOptionValue(value)}`);
191
236
  return false;
192
237
  }
193
- let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a runner recipe sandboxes key", report);
238
+ let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a vercelSandbox sandboxes key", report);
194
239
  const max = value["max"];
195
240
  if (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES) {
196
- report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeRecipeValue(max)}`);
241
+ report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeOptionValue(max)}`);
197
242
  ok = false;
198
243
  }
199
244
  const rawDefault = value["default"];
@@ -220,18 +265,18 @@ function checkSandboxesDefault(value, report) {
220
265
  return undefined;
221
266
  }
222
267
  if (!isRecord(value)) {
223
- report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${describeRecipeValue(value)}`);
268
+ report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${describeOptionValue(value)}`);
224
269
  return undefined;
225
270
  }
226
- let ok = reportUnknownKeys(value, SANDBOXES_DEFAULT_RULE_KEYS, ["sandboxes", "default"], "a runner recipe sandboxes default rule key", report);
271
+ let ok = reportUnknownKeys(value, SANDBOXES_DEFAULT_RULE_KEYS, ["sandboxes", "default"], "a vercelSandbox sandboxes default rule key", report);
227
272
  const filesPerSandbox = value["filesPerSandbox"];
228
273
  if (!isPositiveInteger(filesPerSandbox)) {
229
- report(["sandboxes", "default", "filesPerSandbox"], `must be a positive whole number, not ${describeRecipeValue(filesPerSandbox)}`);
274
+ report(["sandboxes", "default", "filesPerSandbox"], `must be a positive whole number, not ${describeOptionValue(filesPerSandbox)}`);
230
275
  ok = false;
231
276
  }
232
277
  const max = value["max"];
233
278
  if (max !== undefined && (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES)) {
234
- report(["sandboxes", "default", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeRecipeValue(max)}`);
279
+ report(["sandboxes", "default", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeOptionValue(max)}`);
235
280
  ok = false;
236
281
  }
237
282
  if (!ok)
@@ -243,37 +288,39 @@ function checkSandboxesDefault(value, report) {
243
288
  }
244
289
  function checkSnapshot(value, report) {
245
290
  if (!isRecord(value)) {
246
- report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${describeRecipeValue(value)}`);
291
+ report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${describeOptionValue(value)}`);
247
292
  return undefined;
248
293
  }
249
- let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a runner recipe snapshot key", report);
294
+ let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a vercelSandbox snapshot key", report);
250
295
  const vcpus = value["vcpus"];
251
296
  if (!isPositiveInteger(vcpus)) {
252
- report(["snapshot", "vcpus"], `must be a positive whole number, not ${describeRecipeValue(vcpus)}`);
297
+ report(["snapshot", "vcpus"], `must be a positive whole number, not ${describeOptionValue(vcpus)}`);
253
298
  ok = false;
254
299
  }
255
300
  const summary = value["summary"];
256
301
  if (summary !== undefined && !isNonEmptyString(summary)) {
257
- report(["snapshot", "summary"], `must be a non-empty string, not ${describeRecipeValue(summary)}`);
302
+ report(["snapshot", "summary"], `must be a non-empty string, not ${describeOptionValue(summary)}`);
258
303
  ok = false;
259
304
  }
305
+ const source = checkSnapshotSource(value["source"], report);
260
306
  const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], true, report);
261
307
  const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], false, report);
262
- if (!ok || toolchains === undefined || prebuild === undefined)
308
+ if (!ok || source === false || toolchains === undefined || prebuild === undefined)
263
309
  return undefined;
264
310
  return {
265
311
  vcpus: vcpus,
266
312
  ...(summary === undefined ? {} : { summary: summary }),
313
+ ...(source === undefined ? {} : { source }),
267
314
  toolchains,
268
315
  prebuild,
269
316
  };
270
317
  }
271
318
  function checkRun(value, report) {
272
319
  if (!isRecord(value)) {
273
- report(["run"], `must be an object of install and build steps, not ${describeRecipeValue(value)}`);
320
+ report(["run"], `must be an object of install and build steps, not ${describeOptionValue(value)}`);
274
321
  return undefined;
275
322
  }
276
- const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a runner recipe run key", report);
323
+ const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a vercelSandbox run key", report);
277
324
  const install = checkStep(value["install"], ["run", "install"], false, report);
278
325
  const build = checkStep(value["build"], ["run", "build"], false, report);
279
326
  return ok && install !== undefined && build !== undefined ? { install, build } : undefined;
@@ -286,7 +333,7 @@ function checkSteps(value, path, allowBaseFiles, report) {
286
333
  return undefined;
287
334
  }
288
335
  if (!Array.isArray(value)) {
289
- report(path, `must be a list of steps, not ${describeRecipeValue(value)}`);
336
+ report(path, `must be a list of steps, not ${describeOptionValue(value)}`);
290
337
  return undefined;
291
338
  }
292
339
  const steps = value.map((step, index) => allowBaseFiles
@@ -297,7 +344,7 @@ function checkSteps(value, path, allowBaseFiles, report) {
297
344
  function checkStep(value, path, allowBaseFiles, report) {
298
345
  if (!isRecord(value)) {
299
346
  const shape = allowBaseFiles ? "{ label, script, baseFiles? }" : "{ label, script }";
300
- report(path, `must be a step, ${shape}, not ${describeRecipeValue(value)}`);
347
+ report(path, `must be a step, ${shape}, not ${describeOptionValue(value)}`);
301
348
  return undefined;
302
349
  }
303
350
  const allowedKeys = allowBaseFiles ? TOOLCHAIN_STEP_KEYS : STEP_KEYS;
@@ -306,7 +353,7 @@ function checkStep(value, path, allowBaseFiles, report) {
306
353
  if (allowedKeys.has(key))
307
354
  continue;
308
355
  report([...path, key], key === "secrets"
309
- ? "is not a step key: every recipe step gets every credential runner.credentials declares"
356
+ ? "is not a step key: every step of the runner gets every credential runner.credentials declares"
310
357
  : key === "baseFiles"
311
358
  ? "is only allowed on snapshot.toolchains steps: this step already sees the base's files"
312
359
  : "is not a step key");
@@ -315,11 +362,11 @@ function checkStep(value, path, allowBaseFiles, report) {
315
362
  const label = value["label"];
316
363
  const script = value["script"];
317
364
  if (!isNonEmptyString(label)) {
318
- report([...path, "label"], `must be a non-empty string, not ${describeRecipeValue(label)}`);
365
+ report([...path, "label"], `must be a non-empty string, not ${describeOptionValue(label)}`);
319
366
  ok = false;
320
367
  }
321
368
  if (!isNonEmptyString(script)) {
322
- report([...path, "script"], `must be a non-empty string, not ${describeRecipeValue(script)}`);
369
+ report([...path, "script"], `must be a non-empty string, not ${describeOptionValue(script)}`);
323
370
  ok = false;
324
371
  }
325
372
  if (!allowBaseFiles)
@@ -339,7 +386,7 @@ function checkBaseFiles(value, path, report) {
339
386
  if (value === undefined)
340
387
  return undefined;
341
388
  if (!Array.isArray(value)) {
342
- report(path, `must be a list of relative file paths, not ${describeRecipeValue(value)}`);
389
+ report(path, `must be a list of relative file paths, not ${describeOptionValue(value)}`);
343
390
  return null;
344
391
  }
345
392
  let ok = true;
@@ -348,7 +395,7 @@ function checkBaseFiles(value, path, report) {
348
395
  value.forEach((entry, index) => {
349
396
  const at = [...path, String(index)];
350
397
  if (!isRelativeFilePath(entry)) {
351
- report(at, `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${describeRecipeValue(entry)}`);
398
+ report(at, `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${describeOptionValue(entry)}`);
352
399
  ok = false;
353
400
  }
354
401
  else if (seen.has(entry)) {
@@ -366,7 +413,7 @@ function checkEnv(value, report) {
366
413
  if (value === undefined)
367
414
  return {};
368
415
  if (!isRecord(value)) {
369
- report(["env"], `must be an object of strings, not ${describeRecipeValue(value)}`);
416
+ report(["env"], `must be an object of strings, not ${describeOptionValue(value)}`);
370
417
  return undefined;
371
418
  }
372
419
  let ok = true;
@@ -377,7 +424,7 @@ function checkEnv(value, report) {
377
424
  ok = false;
378
425
  }
379
426
  else if (typeof variable !== "string") {
380
- report(["env", key], `must be a string, not ${describeRecipeValue(variable)}`);
427
+ report(["env", key], `must be a string, not ${describeOptionValue(variable)}`);
381
428
  ok = false;
382
429
  }
383
430
  else
@@ -386,14 +433,14 @@ function checkEnv(value, report) {
386
433
  return ok ? env : undefined;
387
434
  }
388
435
  /**
389
- * The recipe's `allowedDomains`: a non-empty list of domains (`ALLOWED_DOMAIN_PATTERN`), none listed twice; undefined
436
+ * The runner's `allowedDomains`: a non-empty list of domains (`ALLOWED_DOMAIN_PATTERN`), none listed twice; undefined
390
437
  * when absent, for full access, and null when it is wrong.
391
438
  */
392
439
  function checkAllowedDomains(value, report) {
393
440
  if (value === undefined)
394
441
  return undefined;
395
442
  if (!Array.isArray(value)) {
396
- report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${describeRecipeValue(value)}`);
443
+ report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${describeOptionValue(value)}`);
397
444
  return null;
398
445
  }
399
446
  if (value.length === 0) {
@@ -409,7 +456,7 @@ function checkAllowedDomains(value, report) {
409
456
  ok = false;
410
457
  }
411
458
  else if (typeof domain !== "string" || !ALLOWED_DOMAIN_PATTERN.test(domain)) {
412
- report(at, `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)}`);
459
+ report(at, `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 ${describeOptionValue(domain)}`);
413
460
  ok = false;
414
461
  }
415
462
  else if (seen.has(domain)) {
@@ -423,15 +470,15 @@ function checkAllowedDomains(value, report) {
423
470
  }
424
471
  function checkBaseRefs(value, report) {
425
472
  if (value === undefined)
426
- return [...RECIPE_DEFAULTS.baseRefs];
473
+ return [...VERCEL_SANDBOX_DEFAULTS.baseRefs];
427
474
  if (!Array.isArray(value) || value.length === 0) {
428
- report(["baseRefs"], `must be a non-empty list of refs, not ${describeRecipeValue(value)}`);
475
+ report(["baseRefs"], `must be a non-empty list of refs, not ${describeOptionValue(value)}`);
429
476
  return undefined;
430
477
  }
431
478
  let ok = true;
432
479
  value.forEach((ref, index) => {
433
480
  if (!isNonEmptyString(ref)) {
434
- report(["baseRefs", String(index)], `must be a non-empty string, not ${describeRecipeValue(ref)}`);
481
+ report(["baseRefs", String(index)], `must be a non-empty string, not ${describeOptionValue(ref)}`);
435
482
  ok = false;
436
483
  }
437
484
  });
@@ -449,29 +496,29 @@ export function declaredBaseFilePaths(toolchains) {
449
496
  return [...paths].toSorted((a, b) => (a < b ? -1 : a > b ? 1 : 0));
450
497
  }
451
498
  /**
452
- * The runner sandbox's vCPUs for `run`: the recipe's number, or the declared resource-scaling rule evaluated against
499
+ * The runner sandbox's vCPUs for `run`: the runner's number, or the declared resource-scaling rule evaluated against
453
500
  * `run.resources` and `run.sandboxes`. When the named resource is absent from the run, `min` is used. When the named
454
501
  * resource is present and its named option is missing or not a non-negative finite number, returns a problem.
455
502
  */
456
- export function resolveVcpus(recipe, run) {
457
- if (typeof recipe.vcpus === "number")
458
- return { ok: true, vcpus: recipe.vcpus };
459
- const { resource, option, per, min, max } = recipe.vcpus;
460
- const options = Object.hasOwn(run.resources, resource) ? run.resources[resource] : undefined;
461
- if (options === undefined)
503
+ export function resolveVcpus(options, run) {
504
+ if (typeof options.vcpus === "number")
505
+ return { ok: true, vcpus: options.vcpus };
506
+ const { resource, option, per, min, max } = options.vcpus;
507
+ const resourceOptions = Object.hasOwn(run.resources, resource) ? run.resources[resource] : undefined;
508
+ if (resourceOptions === undefined)
462
509
  return { ok: true, vcpus: min };
463
- const raw = Object.hasOwn(options, option) ? options[option] : undefined;
510
+ const raw = Object.hasOwn(resourceOptions, option) ? resourceOptions[option] : undefined;
464
511
  if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) {
465
512
  return {
466
513
  ok: false,
467
- problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${describeRecipeValue(raw)}`,
514
+ problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${describeOptionValue(raw)}`,
468
515
  };
469
516
  }
470
517
  const perSandbox = Math.ceil(raw / Math.max(1, run.sandboxes));
471
518
  return { ok: true, vcpus: Math.min(max, Math.max(min, per * perSandbox)) };
472
519
  }
473
520
  /**
474
- * The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the recipe's number,
521
+ * The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the runner's number,
475
522
  * or the declared `{ filesPerSandbox, max? }` rule evaluated against `testPlan`. A number above `sandboxes.max` is not
476
523
  * a problem here: the run lowers it to `sandboxes.max` and says so.
477
524
  */
@@ -487,9 +534,6 @@ export function resolveSandboxCountDefault(sandboxesDefault, testPlan) {
487
534
  function orDefault(value, fallback) {
488
535
  return value === undefined ? fallback : value;
489
536
  }
490
- function isRecord(value) {
491
- return typeof value === "object" && value !== null && !Array.isArray(value);
492
- }
493
537
  function isNonEmptyString(value) {
494
538
  return typeof value === "string" && value.length > 0;
495
539
  }
@@ -0,0 +1,116 @@
1
+ import { type SecretSource } from "../sdk/extension/index.ts";
2
+ import { type GhTokenFormat } from "./gh.ts";
3
+ import { type Report } from "./vercel-sandbox-check.ts";
4
+ export type { GhTokenFormat };
5
+ /**
6
+ * A Vercel-managed sandbox credential passed to `Sandbox.create({ credentials })`: Vercel Sandbox resolves the
7
+ * secret from the project's or team's Vercel environment variables and injects it through the Sandbox firewall, so the
8
+ * secret never sits on the launch machine or inside the sandbox.
9
+ */
10
+ export type ManagedCredential = "npm";
11
+ /**
12
+ * Reads a GitHub credential on the launch machine from `gh auth token --hostname <host>`, or from an optional launcher
13
+ * environment variable `env` when set (such as `GITHUB_TOKEN` in CI). Always produces the `authorization` header
14
+ * (`Basic <base64(x-access-token:<token>)>` or `Bearer <token>`).
15
+ */
16
+ export interface GhCredentialSource {
17
+ readonly kind: "gh";
18
+ /**
19
+ * Optional launcher environment variable override (such as `GITHUB_TOKEN` in CI). When set and non-empty, storm
20
+ * reads the raw token from it instead of invoking `gh auth token`.
21
+ */
22
+ readonly env?: string;
23
+ /**
24
+ * GitHub hostname passed to `gh auth token --hostname <host>`. Bare hostname, defaulting to `"github.com"`.
25
+ */
26
+ readonly host?: string;
27
+ /**
28
+ * How storm frames the token in the `authorization` header: `"basic"` (`Basic <base64(x-access-token:<token>)>`, for
29
+ * Git over HTTPS) or `"bearer"` (`Bearer <token>`, for REST and GraphQL APIs). Defaults to `"basic"` when `domain`
30
+ * matches `host` (such as `"github.com"`), and `"bearer"` otherwise (such as `"api.github.com"`).
31
+ */
32
+ readonly format?: GhTokenFormat;
33
+ }
34
+ /** Where storm reads a sandbox credential's value on the launch machine (`runner.credentials`). */
35
+ export type SandboxCredentialSource = SecretSource | GhCredentialSource;
36
+ /**
37
+ * One sandbox credential declared in `runner.credentials`: a header the Sandbox firewall adds to a sandbox's requests
38
+ * to one domain while the runner's steps and the command run, with its value read from `source` as the run starts. The
39
+ * value never enters the sandbox.
40
+ */
41
+ export interface CredentialDeclaration {
42
+ /**
43
+ * A bare hostname, such as `registry.example.com`: lowercase letters, digits, dots, and hyphens, with at least one
44
+ * dot, and no scheme, port, path, or wildcard.
45
+ */
46
+ readonly domain: string;
47
+ /**
48
+ * The header's name; `authorization` by default. storm matches it case-insensitively and sends it in lowercase. It
49
+ * can't be `host`, `content-length`, `transfer-encoding`, or `connection`, and `{ kind: "gh" }` sources only set
50
+ * `authorization`.
51
+ */
52
+ readonly header?: string;
53
+ /**
54
+ * Where storm reads the credential on the launch machine: `{ kind: "env", name }` for a launcher environment variable
55
+ * holding the whole header value (such as `Bearer …` or `Basic …`), or `{ kind: "gh", env?, host?, format? }` for
56
+ * `gh auth token` (with an optional CI environment variable override).
57
+ */
58
+ readonly source: SandboxCredentialSource;
59
+ /**
60
+ * Which requests to `domain` get the header: `read` (the default), `GET` and `HEAD` only, and the firewall answers
61
+ * every other request to `domain` with 403; or `all`, every request.
62
+ */
63
+ readonly requests?: "read" | "all";
64
+ }
65
+ /**
66
+ * One unsafe secret environment variable declared in `runner.unsafeSecretEnvVars`: an environment variable `name`
67
+ * exposed to the command inside the runner sandbox, with its value read from `source` on the launch machine as the run
68
+ * starts.
69
+ */
70
+ export interface UnsafeSecretEnvVar {
71
+ /**
72
+ * The environment variable name exposed to the command inside the runner sandbox: letters, digits, and underscores,
73
+ * not starting with a digit, and none of `STORM_RUN`, the reserved shell or dynamic-loader variables, or a name set
74
+ * by `runner.env`.
75
+ */
76
+ readonly name: string;
77
+ /**
78
+ * Where storm reads the value on the launch machine, today `{ kind: "env", name }` for a launcher environment
79
+ * variable. Cannot share a source with any entry in `runner.credentials`.
80
+ */
81
+ readonly source: SecretSource;
82
+ }
83
+ /**
84
+ * A stable, value-free identity string for one `SandboxCredentialSource`, for hashing into runner snapshot keys:
85
+ * `"env:<name>"` for `{ kind: "env", name }`, and `"gh[:host=<host>][:env=<NAME>][:format=<format>]"` for
86
+ * `{ kind: "gh" }` (omitting `host` when it is the default `"github.com"`). Never contains secret values or file
87
+ * paths.
88
+ */
89
+ export declare function sandboxCredentialSourceId(source: SandboxCredentialSource): string;
90
+ /**
91
+ * The sorted, unique sandbox credential source identities checked runner options' credentials and managed credentials
92
+ * read from (such as `"env:NPM_AUTH"`, `"gh"`, or `"managed:npm"`), for hashing into the runner snapshot key.
93
+ */
94
+ export declare function credentialSourceIds(options: {
95
+ readonly credentials: readonly Required<CredentialDeclaration>[];
96
+ readonly managedCredentials?: readonly ManagedCredential[];
97
+ }): readonly string[];
98
+ /**
99
+ * Validates `runner.managedCredentials`: a list of distinct supported Vercel-managed credential providers (today
100
+ * `"npm"`). Refuses combining `"npm"` with a `runner.credentials` entry setting `authorization` on
101
+ * `registry.npmjs.org`, because a custom domain rule overrides the Vercel-managed npm header.
102
+ */
103
+ export declare function checkManagedCredentials(value: unknown, credentials: readonly Required<CredentialDeclaration>[] | undefined, report: Report): readonly ManagedCredential[] | undefined;
104
+ /**
105
+ * The sandbox credentials: a list of `{ domain, header?, source, requests? }` (`checkCredential`), with no two going
106
+ * to the same domain and header, since the firewall sets each header once on a domain, and no two for one domain that
107
+ * differ in `requests`, since the firewall has one rule set per domain. One `source` may serve several domains. The
108
+ * checked list holds each header in lowercase and each `requests` given.
109
+ */
110
+ export declare function checkCredentials(value: unknown, report: Report): readonly Required<CredentialDeclaration>[] | undefined;
111
+ /**
112
+ * The runner's `unsafeSecretEnvVars`: a list of `{ name, source }` plain objects, each exposing a distinct environment
113
+ * variable `name` that neither storm sets for the command (`STORM_RUN`, `RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES`,
114
+ * `LD_*`, `DYLD_*`) nor `runner.env` sets, read from a `SecretSource` that `runner.credentials` doesn't already read.
115
+ */
116
+ export declare function checkUnsafeSecretEnvVars(value: unknown, env: Readonly<Record<string, string>> | undefined, credentials: readonly Required<CredentialDeclaration>[] | undefined, report: Report): readonly UnsafeSecretEnvVar[] | undefined;