@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,12 +1,14 @@
1
1
  import type { CheckoutGateway } from "./gateways.ts";
2
- import { type CheckedRecipe, type RunnerStep } from "./recipe.ts";
2
+ import type { SnapshotSource } from "./snapshot-source.ts";
3
+ import { type CheckedVercelSandboxOptions, type RunnerStep } from "./vercel-sandbox-options.ts";
3
4
  /**
4
5
  * Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
5
6
  * uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
6
- * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the recipe's credential
7
- * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`).
7
+ * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the runner's credential
8
+ * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`). 6 switched
9
+ * Vercel Sandbox runners from legacy runtimes to VCR images (`image`).
8
10
  */
9
- export declare const SNAPSHOT_FORMAT = 5;
11
+ export declare const SNAPSHOT_FORMAT = 6;
10
12
  /** One declared base file read from the base commit, to stage into `/vercel/sandbox/<path>` before toolchain steps. */
11
13
  export interface DeclaredBaseFile {
12
14
  readonly path: string;
@@ -29,22 +31,33 @@ export declare function bashScript(lines: readonly string[], root?: string): str
29
31
  * (`<staging>/base-files`), before the prebuild steps. `git add -A` would drop tracked files `.gitignore` matches.
30
32
  */
31
33
  export declare function baseIndexScript(base: string, staging: string): string;
34
+ /**
35
+ * Fetches `base` alone from `url` (`normalizeGitFetchUrl`, `snapshot-source.ts`) into the repository at `root` and checks
36
+ * it out, for `snapshot.source: { kind: "git-fetch" }`, before the prebuild steps. The checkout's `--force` overwrites
37
+ * the declared base files already placed there, which hold the same text. `--depth 1` makes `base` the root commit, so
38
+ * `applyScript` resets to it as it resets to an archive snapshot's root commit. No credential helper or terminal prompt
39
+ * runs: a credential reaches the fetch's requests only through the firewall.
40
+ */
41
+ export declare function gitFetchBaseIndexScript(url: string, base: string, root?: string): string;
32
42
  /**
33
43
  * Applies and commits a run's patch and untracked files, uploaded to `staging`, in a runner sandbox. It first resets
34
- * the repository to its root commit, which holds the base's tracked files (`baseIndexScript`), since the real base
35
- * commit isn't in a sandbox's repository, and removes untracked files and nested Git repositories `.gitignore`
44
+ * the repository to its root commit, which holds the base's tracked files (`baseIndexScript`, or the base itself after
45
+ * `gitFetchBaseIndexScript`), since the base's history isn't in a sandbox's repository, and removes untracked files and nested Git repositories `.gitignore`
36
46
  * doesn't match, keeping ignored ones such as `node_modules` and build outputs. `root` is the repository, which an
37
47
  * integration test points at a temporary checkout.
38
48
  */
39
49
  export declare function applyScript(staging: string, root?: string): string;
40
50
  /**
41
- * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the recipe's
51
+ * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the runner's
42
52
  * credentials read, sorted, once each, joined with ",">`, `baseFiles=<count>` followed by each sorted declared base
43
- * file's path and text, each toolchain step's label and script, the base-index script with the placeholders `<base>`
44
- * and `<staging>`, and each prebuild step's label and script, joined with NUL. A recipe without credentials gives
53
+ * file's path and text, each toolchain step's label and script, the base-index script the build runs (`baseIndexScript`
54
+ * with the placeholders `<base>` and `<staging>`, or for `snapshot.source: { kind: "git-fetch" }`
55
+ * `gitFetchBaseIndexScript` with `<url>` and `<base>`, so the remote's URL and name stay out of the key and machines
56
+ * with SSH and HTTPS remotes share one), and each prebuild step's label and script, joined with NUL. A runner without credentials gives
45
57
  * `credentials=`, and one without declared base files gives `baseFiles=0`. Every snapshot step gets every credential,
46
- * so the source identities are in the key once, never the values, domains, or headers: a recipe that reads another
47
- * source builds another snapshot, and every machine with the same recipe shares one. The base isn't in the key: a
58
+ * so the source identities are in the key once, never the values, domains, or headers: a runner that reads another
59
+ * source builds another snapshot, and every machine with the same runner options shares one. The base isn't in the
60
+ * key: a
48
61
  * cache entry records it beside the key.
49
62
  */
50
63
  export declare function snapshotKey(steps: {
@@ -52,8 +65,9 @@ export declare function snapshotKey(steps: {
52
65
  readonly baseFiles: readonly DeclaredBaseFile[];
53
66
  readonly toolchains: readonly RunnerStep[];
54
67
  readonly prebuild: readonly RunnerStep[];
68
+ readonly source?: SnapshotSource | undefined;
55
69
  }): string;
56
- /** A recipe's snapshot inputs at one base and their key, or why a declared base file couldn't be read there. */
70
+ /** A runner's snapshot inputs at one base and their key, or why a declared base file couldn't be read there. */
57
71
  export type SnapshotInputsAt = {
58
72
  readonly ok: true;
59
73
  readonly baseFiles: readonly DeclaredBaseFile[];
@@ -64,15 +78,16 @@ export type SnapshotInputsAt = {
64
78
  readonly problem: string;
65
79
  };
66
80
  /**
67
- * Reads `recipe`'s declared base files at `base` and computes its snapshot key with the secret source identities the
68
- * recipe's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
81
+ * Reads `options`'s declared base files at `base` and computes its snapshot key with the secret source identities the
82
+ * runner's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
69
83
  * unreadable at `base`.
70
84
  */
71
85
  export declare function snapshotInputsAt(checkout: CheckoutGateway, request: {
72
86
  readonly repoRoot: string;
73
87
  readonly base: string;
74
- readonly recipe: {
75
- readonly snapshot: Pick<CheckedRecipe["snapshot"], "toolchains" | "prebuild">;
76
- readonly credentials: CheckedRecipe["credentials"];
88
+ readonly options: {
89
+ readonly snapshot: Pick<CheckedVercelSandboxOptions["snapshot"], "toolchains" | "prebuild" | "source">;
90
+ readonly credentials: CheckedVercelSandboxOptions["credentials"];
91
+ readonly managedCredentials?: CheckedVercelSandboxOptions["managedCredentials"];
77
92
  };
78
93
  }): Promise<SnapshotInputsAt>;
@@ -1,16 +1,17 @@
1
1
  // What a runner snapshot is built from, and the scripts that commit a base in a build sandbox and a run's changes in
2
2
  // a runner sandbox. The snapshot key hashes the declared base files' paths and contents, the steps' text, and the
3
- // secret source identities the recipe's credentials read, so editing a step or a declared base file means a new
3
+ // secret source identities the runner's credentials read, so editing a step or a declared base file means a new
4
4
  // snapshot.
5
5
  import { createHash } from "node:crypto";
6
- import { credentialSourceIds, declaredBaseFilePaths } from "./recipe.js";
6
+ import { credentialSourceIds, declaredBaseFilePaths, } from "./vercel-sandbox-options.js";
7
7
  /**
8
8
  * Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
9
9
  * uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
10
- * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the recipe's credential
11
- * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`).
10
+ * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the runner's credential
11
+ * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`). 6 switched
12
+ * Vercel Sandbox runners from legacy runtimes to VCR images (`image`).
12
13
  */
13
- export const SNAPSHOT_FORMAT = 5;
14
+ export const SNAPSHOT_FORMAT = 6;
14
15
  /** Where the repository lives in every runner and build sandbox. */
15
16
  export const SANDBOX_ROOT = "/vercel/sandbox";
16
17
  /** The names of the files uploaded to a sandbox's staging directory. */
@@ -23,6 +24,10 @@ export const STAGED_FILES = {
23
24
  };
24
25
  /** The identity of the commits the scripts make, with no hook or signing in the way. */
25
26
  const GIT_IDENTITY = "-c user.email=storm-runner@vercel.invalid -c user.name='storm runner' -c commit.gpgsign=false";
27
+ /** POSIX single-quotes `value` so it passes literally through bash without expansion. */
28
+ function shellQuote(value) {
29
+ return `'${value.replaceAll("'", "'\\''")}'`;
30
+ }
26
31
  /** A bash script that stops at the first failure and runs in the repository's root, `/vercel/sandbox` by default. */
27
32
  export function bashScript(lines, root = SANDBOX_ROOT) {
28
33
  return ["set -euo pipefail", `cd ${root}`, ...lines].join("\n");
@@ -43,10 +48,24 @@ export function baseIndexScript(base, staging) {
43
48
  `git ${GIT_IDENTITY} commit -q --no-verify -m 'base ${base}'`,
44
49
  ]);
45
50
  }
51
+ /**
52
+ * Fetches `base` alone from `url` (`normalizeGitFetchUrl`, `snapshot-source.ts`) into the repository at `root` and checks
53
+ * it out, for `snapshot.source: { kind: "git-fetch" }`, before the prebuild steps. The checkout's `--force` overwrites
54
+ * the declared base files already placed there, which hold the same text. `--depth 1` makes `base` the root commit, so
55
+ * `applyScript` resets to it as it resets to an archive snapshot's root commit. No credential helper or terminal prompt
56
+ * runs: a credential reaches the fetch's requests only through the firewall.
57
+ */
58
+ export function gitFetchBaseIndexScript(url, base, root = SANDBOX_ROOT) {
59
+ return bashScript([
60
+ "git -c init.defaultBranch=main init -q",
61
+ `GIT_TERMINAL_PROMPT=0 git -c credential.helper= -c core.autocrlf=false -c core.eol=lf fetch --depth 1 --no-tags -- ${shellQuote(url)} ${shellQuote(base)}`,
62
+ "git -c core.autocrlf=false -c core.eol=lf checkout --detach --force FETCH_HEAD",
63
+ ], root);
64
+ }
46
65
  /**
47
66
  * Applies and commits a run's patch and untracked files, uploaded to `staging`, in a runner sandbox. It first resets
48
- * the repository to its root commit, which holds the base's tracked files (`baseIndexScript`), since the real base
49
- * commit isn't in a sandbox's repository, and removes untracked files and nested Git repositories `.gitignore`
67
+ * the repository to its root commit, which holds the base's tracked files (`baseIndexScript`, or the base itself after
68
+ * `gitFetchBaseIndexScript`), since the base's history isn't in a sandbox's repository, and removes untracked files and nested Git repositories `.gitignore`
50
69
  * doesn't match, keeping ignored ones such as `node_modules` and build outputs. `root` is the repository, which an
51
70
  * integration test points at a temporary checkout.
52
71
  */
@@ -70,13 +89,16 @@ export function applyScript(staging, root = SANDBOX_ROOT) {
70
89
  ], root);
71
90
  }
72
91
  /**
73
- * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the recipe's
92
+ * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the runner's
74
93
  * credentials read, sorted, once each, joined with ",">`, `baseFiles=<count>` followed by each sorted declared base
75
- * file's path and text, each toolchain step's label and script, the base-index script with the placeholders `<base>`
76
- * and `<staging>`, and each prebuild step's label and script, joined with NUL. A recipe without credentials gives
94
+ * file's path and text, each toolchain step's label and script, the base-index script the build runs (`baseIndexScript`
95
+ * with the placeholders `<base>` and `<staging>`, or for `snapshot.source: { kind: "git-fetch" }`
96
+ * `gitFetchBaseIndexScript` with `<url>` and `<base>`, so the remote's URL and name stay out of the key and machines
97
+ * with SSH and HTTPS remotes share one), and each prebuild step's label and script, joined with NUL. A runner without credentials gives
77
98
  * `credentials=`, and one without declared base files gives `baseFiles=0`. Every snapshot step gets every credential,
78
- * so the source identities are in the key once, never the values, domains, or headers: a recipe that reads another
79
- * source builds another snapshot, and every machine with the same recipe shares one. The base isn't in the key: a
99
+ * so the source identities are in the key once, never the values, domains, or headers: a runner that reads another
100
+ * source builds another snapshot, and every machine with the same runner options shares one. The base isn't in the
101
+ * key: a
80
102
  * cache entry records it beside the key.
81
103
  */
82
104
  export function snapshotKey(steps) {
@@ -89,19 +111,21 @@ export function snapshotKey(steps) {
89
111
  `baseFiles=${baseFiles.length}`,
90
112
  ...baseFiles.flatMap(({ path, text: content }) => [path, content]),
91
113
  ...text(steps.toolchains),
92
- baseIndexScript("<base>", "<staging>"),
114
+ steps.source === undefined
115
+ ? baseIndexScript("<base>", "<staging>")
116
+ : gitFetchBaseIndexScript("<url>", "<base>"),
93
117
  ...text(steps.prebuild),
94
118
  ].join("\0"))
95
119
  .digest("hex");
96
120
  }
97
121
  /**
98
- * Reads `recipe`'s declared base files at `base` and computes its snapshot key with the secret source identities the
99
- * recipe's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
122
+ * Reads `options`'s declared base files at `base` and computes its snapshot key with the secret source identities the
123
+ * runner's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
100
124
  * unreadable at `base`.
101
125
  */
102
126
  export async function snapshotInputsAt(checkout, request) {
103
- const { repoRoot, base, recipe } = request;
104
- const { snapshot } = recipe;
127
+ const { repoRoot, base, options } = request;
128
+ const { snapshot } = options;
105
129
  const baseFiles = [];
106
130
  for (const path of declaredBaseFilePaths(snapshot.toolchains)) {
107
131
  const file = await checkout.readFileAt({ repoRoot, commit: base, path });
@@ -125,10 +149,11 @@ export async function snapshotInputsAt(checkout, request) {
125
149
  ok: true,
126
150
  baseFiles,
127
151
  key: snapshotKey({
128
- credentials: credentialSourceIds(recipe),
152
+ credentials: credentialSourceIds(options),
129
153
  baseFiles,
130
154
  toolchains: snapshot.toolchains,
131
155
  prebuild: snapshot.prebuild,
156
+ source: snapshot.source,
132
157
  }),
133
158
  };
134
159
  }
@@ -0,0 +1,31 @@
1
+ import { type Report } from "./vercel-sandbox-check.ts";
2
+ /**
3
+ * How a build sandbox gets the base commit's tracked files: `{ kind: "git-fetch", remote? }` runs a shallow
4
+ * `git fetch --depth 1` of the base commit inside the build sandbox, from the HTTPS form of the URL that the local
5
+ * checkout's Git `remote` (`"origin"` by default) names, instead of archiving the base on the launch machine and
6
+ * uploading it. The remote must hold the base commit.
7
+ */
8
+ export interface SnapshotSource {
9
+ readonly kind: "git-fetch";
10
+ /** The Git remote whose URL storm reads locally and turns into an HTTPS URL; `"origin"` by default. */
11
+ readonly remote?: string;
12
+ }
13
+ /** `snapshot.source` with its default filled in; `undefined` when absent, `false` after reporting a problem. */
14
+ export declare function checkSnapshotSource(value: unknown, report: Report): Required<SnapshotSource> | undefined | false;
15
+ /** The HTTPS URL a build sandbox fetches from, or what is wrong with the remote URL, worded to follow "the URL". */
16
+ export type GitFetchUrl = {
17
+ readonly ok: true;
18
+ readonly url: string;
19
+ } | {
20
+ readonly ok: false;
21
+ readonly problem: string;
22
+ };
23
+ /**
24
+ * Turns a local Git remote URL into the HTTPS URL a build sandbox fetches from: SCP-style SSH (`[user@]host:path`) and
25
+ * `ssh://[user@]host[:port]/path` become `https://host/path` (an SSH port is dropped, since it isn't the HTTPS port),
26
+ * and `https://host[:port]/path` stays as it is, with the host lowercased and port 443 dropped. It refuses any other
27
+ * scheme (`http`, `file`, `git`), a local path, user info on an HTTPS URL or a password on an SSH one, a query or
28
+ * fragment, whitespace, control characters, quotes, shell metacharacters, and a path with an empty, `.`, or `..`
29
+ * segment, `@`, or `:`. A problem never holds any part of the URL but its scheme, so a credential in it can't leak.
30
+ */
31
+ export declare function normalizeGitFetchUrl(raw: string): GitFetchUrl;
@@ -0,0 +1,122 @@
1
+ // `snapshot.source` on a Vercel Sandbox runner: how a build sandbox gets the base commit's tracked files. This file holds
2
+ // the published type, its check (called from `checkVercelSandboxOptions`), and the normalization of the local Git
3
+ // remote's URL to the HTTPS URL the build sandbox fetches from. The fetch script is `gitFetchBaseIndexScript`
4
+ // (`snapshot-key.ts`), beside the archive's base-index script.
5
+ import { describeOptionValue, isRecord, reportUnknownKeys } from "./vercel-sandbox-check.js";
6
+ const SNAPSHOT_SOURCE_KEYS = new Set(["kind", "remote"]);
7
+ const DEFAULT_REMOTE = "origin";
8
+ /** A Git remote name storm accepts: letters, digits, `.`, `_`, `-`, and `/`, starting with a letter, digit, or `_`. */
9
+ const REMOTE_NAME_PATTERN = /^[A-Za-z0-9_][A-Za-z0-9._/-]*$/;
10
+ /** `snapshot.source` with its default filled in; `undefined` when absent, `false` after reporting a problem. */
11
+ export function checkSnapshotSource(value, report) {
12
+ if (value === undefined)
13
+ return undefined;
14
+ const path = ["snapshot", "source"];
15
+ if (!isRecord(value)) {
16
+ // Do not echo string values: a user may mistakenly pass a clone URL that embeds credentials.
17
+ const actual = typeof value === "string" ? "a string" : describeOptionValue(value);
18
+ report(path, `must be { kind: "git-fetch", remote? }, not ${actual}`);
19
+ return false;
20
+ }
21
+ let ok = reportUnknownKeys(value, SNAPSHOT_SOURCE_KEYS, path, "a vercelSandbox snapshot source key", report);
22
+ const kind = value["kind"];
23
+ if (kind !== "git-fetch") {
24
+ report([...path, "kind"], `must be "git-fetch", not ${describeOptionValue(kind)}`);
25
+ ok = false;
26
+ }
27
+ const remote = value["remote"] === undefined ? DEFAULT_REMOTE : value["remote"];
28
+ if (typeof remote !== "string" || !REMOTE_NAME_PATTERN.test(remote)) {
29
+ // Do not echo string values: a user may mistakenly pass a clone URL that embeds credentials.
30
+ const rule = 'must be a Git remote name such as "origin" (letters, digits, ".", "_", "-", and "/", starting with a letter, digit, or "_")';
31
+ report([...path, "remote"], typeof remote === "string" ? rule : `${rule}, not ${describeOptionValue(remote)}`);
32
+ ok = false;
33
+ }
34
+ return ok ? { kind: "git-fetch", remote: remote } : false;
35
+ }
36
+ /** Whitespace, quotes, shell metacharacters, and the URL query and fragment marks. */
37
+ const UNSAFE_URL_CHARS = /[\s'"`$\\;|&<>(){}[\]*?!#~]/;
38
+ /** `scheme://authority/path`. */
39
+ const SCHEME_URL_PATTERN = /^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/]*)(.*)$/;
40
+ /** SCP-style SSH, `[user@]host:path`, with no `/` before the colon, as Git reads it. */
41
+ const SCP_URL_PATTERN = /^(?:([^@/]*)@)?([^@/:]+):(.*)$/;
42
+ /** A schemed URL's host and optional port, `host[:port]`. */
43
+ const HOST_PORT_PATTERN = /^([^:]+)(?::(\d{1,5}))?$/;
44
+ /** A bare hostname with at least one dot: lowercase letters, digits, and inner hyphens. */
45
+ const 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])?)+$/;
46
+ const CREDENTIALS_PROBLEM = "holds credentials; remove them from the remote URL and declare a sandbox credential in runner.credentials instead";
47
+ /**
48
+ * Turns a local Git remote URL into the HTTPS URL a build sandbox fetches from: SCP-style SSH (`[user@]host:path`) and
49
+ * `ssh://[user@]host[:port]/path` become `https://host/path` (an SSH port is dropped, since it isn't the HTTPS port),
50
+ * and `https://host[:port]/path` stays as it is, with the host lowercased and port 443 dropped. It refuses any other
51
+ * scheme (`http`, `file`, `git`), a local path, user info on an HTTPS URL or a password on an SSH one, a query or
52
+ * fragment, whitespace, control characters, quotes, shell metacharacters, and a path with an empty, `.`, or `..`
53
+ * segment, `@`, or `:`. A problem never holds any part of the URL but its scheme, so a credential in it can't leak.
54
+ */
55
+ export function normalizeGitFetchUrl(raw) {
56
+ if (raw.length === 0)
57
+ return { ok: false, problem: "is empty" };
58
+ if (hasControlChar(raw) || UNSAFE_URL_CHARS.test(raw))
59
+ return { ok: false, problem: "holds whitespace, a control character, a quote, or a shell metacharacter" };
60
+ let https;
61
+ let userInfo;
62
+ let hostPort;
63
+ let host;
64
+ let port;
65
+ let path;
66
+ const schemed = SCHEME_URL_PATTERN.exec(raw);
67
+ if (schemed !== null) {
68
+ const scheme = (schemed[1] ?? "").toLowerCase();
69
+ if (scheme !== "https" && scheme !== "ssh")
70
+ return { ok: false, problem: `uses ${scheme}://; git-fetch takes an HTTPS or SSH remote` };
71
+ https = scheme === "https";
72
+ const authority = schemed[2] ?? "";
73
+ const at = authority.lastIndexOf("@");
74
+ userInfo = at === -1 ? undefined : authority.slice(0, at);
75
+ hostPort = at === -1 ? authority : authority.slice(at + 1);
76
+ host = "";
77
+ path = schemed[3] ?? "";
78
+ }
79
+ else {
80
+ const scp = SCP_URL_PATTERN.exec(raw);
81
+ if (scp === null)
82
+ return { ok: false, problem: "is not an HTTPS or SSH Git URL" };
83
+ https = false;
84
+ [, userInfo, host = "", path = ""] = scp;
85
+ if (!path.startsWith("/"))
86
+ path = `/${path}`;
87
+ }
88
+ if (userInfo !== undefined && (https || userInfo.includes(":") || userInfo.includes("@")))
89
+ return { ok: false, problem: CREDENTIALS_PROBLEM };
90
+ if (hostPort !== undefined) {
91
+ const parsed = HOST_PORT_PATTERN.exec(hostPort);
92
+ if (parsed === null)
93
+ return { ok: false, problem: "names no valid host or port" };
94
+ [, host = "", port] = parsed;
95
+ }
96
+ host = host.toLowerCase();
97
+ if (!HOST_PATTERN.test(host))
98
+ return { ok: false, problem: "names no valid host" };
99
+ if (port !== undefined && (Number(port) < 1 || Number(port) > 65_535))
100
+ return { ok: false, problem: "names no valid port" };
101
+ if (!isRepositoryPath(path))
102
+ return { ok: false, problem: "names no valid repository path" };
103
+ const httpsPort = https && port !== undefined && Number(port) !== 443 ? `:${Number(port)}` : "";
104
+ return { ok: true, url: `https://${host}${httpsPort}${path}` };
105
+ }
106
+ function hasControlChar(value) {
107
+ for (let index = 0; index < value.length; index += 1) {
108
+ const code = value.charCodeAt(index);
109
+ if (code <= 0x1f || code === 0x7f)
110
+ return true;
111
+ }
112
+ return false;
113
+ }
114
+ /** `/a/b`: one or more segments, none empty, `.`, or `..`, and no `@` or `:`. */
115
+ function isRepositoryPath(path) {
116
+ if (!path.startsWith("/") || path.includes("@") || path.includes(":"))
117
+ return false;
118
+ return path
119
+ .slice(1)
120
+ .split("/")
121
+ .every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
122
+ }
@@ -37,7 +37,7 @@ export declare function runStep(context: {
37
37
  readonly script: string;
38
38
  }, progress: RunnerProgress, signal: AbortSignal): Promise<StepOutcome>;
39
39
  /**
40
- * How a stage ends on a failed network policy write at `around`: granting credentials before the recipe's snapshot
40
+ * How a stage ends on a failed network policy write at `around`: granting credentials before the runner's snapshot
41
41
  * steps, its run steps, or the command, or revoking them before a snapshot save. A stop when the run was canceled, or
42
42
  * closing the scope began, a failure otherwise.
43
43
  */
@@ -40,7 +40,7 @@ export async function runStep(context, request, progress, signal) {
40
40
  return { kind: "succeeded", ms };
41
41
  }
42
42
  /**
43
- * How a stage ends on a failed network policy write at `around`: granting credentials before the recipe's snapshot
43
+ * How a stage ends on a failed network policy write at `around`: granting credentials before the runner's snapshot
44
44
  * steps, its run steps, or the command, or revoking them before a snapshot save. A stop when the run was canceled, or
45
45
  * closing the scope began, a failure otherwise.
46
46
  */
@@ -1,6 +1,8 @@
1
- /** Records one static problem at `path` inside a runner recipe, worded to follow the key. */
1
+ /** Records one static problem at `path` inside Vercel Sandbox runner options, worded to follow the key. */
2
2
  export type Report = (path: readonly string[], problem: string) => void;
3
3
  /** Reports each key of `value` not in `known`; whether there were none. */
4
4
  export declare function reportUnknownKeys(value: Readonly<Record<string, unknown>>, known: ReadonlySet<string>, path: readonly string[], what: string, report: Report): boolean;
5
5
  /** A value as a problem names it: a string or number as written, otherwise its kind. */
6
- export declare function describeRecipeValue(value: unknown): string;
6
+ export declare function describeOptionValue(value: unknown): string;
7
+ /** Whether `value` is an object that isn't an array or null, the shape every option object takes. */
8
+ export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
@@ -1,4 +1,5 @@
1
- // Pure problem-reporting helpers shared by `recipe.ts` and `recipe-secrets.ts` during `checkRecipe`.
1
+ // Pure problem-reporting helpers shared by `vercel-sandbox-options.ts`, `vercel-sandbox-secrets.ts`, and
2
+ // `snapshot-source.ts` during `checkVercelSandboxOptions`.
2
3
  /** Reports each key of `value` not in `known`; whether there were none. */
3
4
  export function reportUnknownKeys(value, known, path, what, report) {
4
5
  let ok = true;
@@ -10,7 +11,7 @@ export function reportUnknownKeys(value, known, path, what, report) {
10
11
  return ok;
11
12
  }
12
13
  /** A value as a problem names it: a string or number as written, otherwise its kind. */
13
- export function describeRecipeValue(value) {
14
+ export function describeOptionValue(value) {
14
15
  if (typeof value === "string")
15
16
  return JSON.stringify(value);
16
17
  if (typeof value === "number" || typeof value === "boolean")
@@ -27,3 +28,7 @@ export function describeRecipeValue(value) {
27
28
  return "an object";
28
29
  return `a ${typeof value}`;
29
30
  }
31
+ /** Whether `value` is an object that isn't an array or null, the shape every option object takes. */
32
+ export function isRecord(value) {
33
+ return typeof value === "object" && value !== null && !Array.isArray(value);
34
+ }
@@ -1,6 +1,7 @@
1
1
  import type { RunTestPlan } from "../sdk/extension/index.ts";
2
- import { type CredentialDeclaration, credentialSourceIds, type UnsafeSecretEnvVar } from "./recipe-secrets.ts";
3
- export { type CredentialDeclaration, credentialSourceIds, type UnsafeSecretEnvVar };
2
+ import { type SnapshotSource } from "./snapshot-source.ts";
3
+ import { type CredentialDeclaration, credentialSourceIds, type GhCredentialSource, type GhTokenFormat, type ManagedCredential, type SandboxCredentialSource, type UnsafeSecretEnvVar } from "./vercel-sandbox-secrets.ts";
4
+ export { type CredentialDeclaration, credentialSourceIds, type GhCredentialSource, type GhTokenFormat, type ManagedCredential, type SandboxCredentialSource, type SnapshotSource, type UnsafeSecretEnvVar, };
4
5
  /** A bash script, run with `bash -lc` in the repository's root, and the label that names it in progress and errors. */
5
6
  export interface RunnerStep {
6
7
  readonly label: string;
@@ -31,14 +32,20 @@ export type RunnerVcpuCount = number | RunnerVcpuRule;
31
32
  /**
32
33
  * What a repository declares about its runner snapshot and what each run does on top of it.
33
34
  */
34
- export interface RunnerRecipe {
35
- /** Lowercase letters, digits and dashes. Names the recipe's sandboxes (`storm-runner-<name>`) and cache entries. */
35
+ export interface VercelSandboxOptions {
36
+ /** Lowercase letters, digits and dashes. Names the runner's sandboxes (`storm-runner-<name>`) and cache entries. */
36
37
  readonly name: string;
37
38
  readonly snapshot: {
38
39
  /** The build sandbox's vCPUs. */
39
40
  readonly vcpus: number;
40
41
  /** A few words on what a snapshot build does; by default the steps' labels. */
41
42
  readonly summary?: string;
43
+ /**
44
+ * How the build sandbox gets the base commit's tracked files. When omitted, storm archives the base on the launch
45
+ * machine and uploads it; with `{ kind: "git-fetch", remote? }`, the build sandbox fetches the base commit over
46
+ * HTTPS from the URL of the local checkout's Git `remote` (`"origin"` by default), with the runner's credentials.
47
+ */
48
+ readonly source?: SnapshotSource;
42
49
  /** Steps run before the base's files are committed in the build sandbox. They must put `git` on `PATH`. */
43
50
  readonly toolchains: readonly ToolchainStep[];
44
51
  /**
@@ -61,7 +68,7 @@ export interface RunnerRecipe {
61
68
  * Extra environment variables for the command. It can't set `STORM_RUN`. When it sets neither `FORCE_COLOR` nor
62
69
  * `NO_COLOR`, storm sets `FORCE_COLOR=1` when the local terminal asks for color (a TTY or `FORCE_COLOR`),
63
70
  * `NO_COLOR=1` when the launcher explicitly opted out (`--no-color` or a non-empty `NO_COLOR`), and neither on a
64
- * plain non-TTY launcher; when the recipe sets either, storm sets neither.
71
+ * plain non-TTY launcher; when the runner options set either, storm sets neither.
65
72
  */
66
73
  readonly env?: Readonly<Record<string, string>>;
67
74
  /**
@@ -75,6 +82,17 @@ export interface RunnerRecipe {
75
82
  * several domains.
76
83
  */
77
84
  readonly credentials?: readonly CredentialDeclaration[];
85
+ /**
86
+ * Vercel-managed sandbox credentials passed to `Sandbox.create({ credentials })` for both build and runner
87
+ * sandboxes: `"npm"` passes `{ npm: true }`, so Vercel Sandbox resolves `NPM_RC` or `NPM_TOKEN` from the project's
88
+ * or team's Vercel environment variables, writes a credential-free `~/.npmrc` inside the sandbox, and injects the
89
+ * read-only auth header at the firewall without any token ever sitting on the launch machine or inside the sandbox.
90
+ * Included in the snapshot key (`managed:npm`). Cannot be combined with a `runner.credentials` entry setting
91
+ * `authorization` on `registry.npmjs.org` (which overrides the managed token), and refuses `keepSandbox` or
92
+ * `--keep-sandbox` above `0` because Vercel Sandbox rejects `deny-all` on a sandbox with managed credentials. When
93
+ * `allowedDomains` is set, it must allow the managed npm registries (such as `registry.npmjs.org`).
94
+ */
95
+ readonly managedCredentials?: readonly ManagedCredential[];
78
96
  /**
79
97
  * An escape hatch for credentials that cannot travel as HTTPS headers, such as a database password, a client key,
80
98
  * or a token a tool reads from an environment variable. Each entry (`UnsafeSecretEnvVar`) pairs the environment
@@ -113,8 +131,12 @@ export interface RunnerRecipe {
113
131
  readonly baseRefs?: readonly string[];
114
132
  /** The Vercel region of the runner sandbox and its snapshots; `iad1` by default. */
115
133
  readonly region?: string;
116
- /** The Vercel Sandbox runtime; `node22` by default. */
117
- readonly runtime?: string;
134
+ /**
135
+ * The Vercel Sandbox VCR image to build and run in; `"vercel/sandbox/node:al-24"` by default.
136
+ * Accepts Vercel-managed images (`"vercel/sandbox/..."`, with or without a leading `"vcr.vercel.com/"`) or
137
+ * digest-pinned custom VCR image references (`"<repository>@sha256:<64 lowercase hex characters>"`).
138
+ */
139
+ readonly image?: string;
118
140
  /**
119
141
  * How many runner sandboxes a run from this config file can have. Without it, no run is across runner sandboxes:
120
142
  * `--sandboxes` and `--file-lists` refuse and name this key. A run with no runner ignores it.
@@ -122,7 +144,7 @@ export interface RunnerRecipe {
122
144
  readonly sandboxes?: RunnerSandboxCount;
123
145
  }
124
146
  /**
125
- * How many runner sandboxes a run can have, the runner recipe's `sandboxes` key: `max`, the limit, a whole number from
147
+ * How many runner sandboxes a run can have, the Vercel Sandbox runner options' `sandboxes` key: `max`, the limit, a whole number from
126
148
  * 1 to `MAX_RUNNER_SANDBOXES`, and `default`, the number of runner sandboxes of a run with no `--sandboxes` or
127
149
  * `--file-lists`. No run from the config file has more runner sandboxes than `max`.
128
150
  */
@@ -163,16 +185,19 @@ export type SandboxCountDefault = number | SandboxCountDefaultRule;
163
185
  * typing mistake that would start hundreds of runner sandboxes, not a claim about what Vercel Sandbox holds.
164
186
  */
165
187
  export declare const MAX_RUNNER_SANDBOXES = 32;
166
- /** The defaults of a recipe's optional keys. */
167
- export declare const RECIPE_DEFAULTS: {
188
+ /** The defaults of a runner's optional keys. */
189
+ export declare const VERCEL_SANDBOX_DEFAULTS: {
168
190
  readonly cwd: ".";
169
191
  readonly timeout: "60m";
170
192
  readonly baseRefs: readonly ["main", "origin/main"];
171
193
  readonly region: "iad1";
172
- readonly runtime: "node22";
194
+ readonly image: "vercel/sandbox/node:al-24";
173
195
  };
174
- /** A recipe that passed `checkRecipe`, with every optional key's default filled in. */
175
- export interface CheckedRecipe extends RunnerRecipe {
196
+ /** Vercel Sandbox runner options that passed `checkVercelSandboxOptions`, with every optional key's default filled in. */
197
+ export interface CheckedVercelSandboxOptions extends VercelSandboxOptions {
198
+ readonly snapshot: Omit<VercelSandboxOptions["snapshot"], "source"> & {
199
+ readonly source?: Required<SnapshotSource>;
200
+ };
176
201
  readonly run: {
177
202
  readonly install: RunnerStep;
178
203
  readonly build: RunnerStep;
@@ -180,44 +205,50 @@ export interface CheckedRecipe extends RunnerRecipe {
180
205
  readonly cwd: string;
181
206
  readonly env: Readonly<Record<string, string>>;
182
207
  /**
183
- * The sandbox credentials, in the recipe's order, each header in lowercase and each `requests` given; empty when
208
+ * The sandbox credentials, in the runner's order, each header in lowercase and each `requests` given; empty when
184
209
  * absent. `credentialSourceIds` gives their sorted, unique source identities.
185
210
  */
186
211
  readonly credentials: readonly Required<CredentialDeclaration>[];
187
212
  /**
188
- * The unsafe secret environment variables passed into the command's environment, in the recipe's order; empty when
213
+ * The Vercel-managed sandbox credentials passed when creating build and runner sandboxes, in the runner's order;
214
+ * empty when absent.
215
+ */
216
+ readonly managedCredentials: readonly ManagedCredential[];
217
+ /**
218
+ * The unsafe secret environment variables passed into the command's environment, in the runner's order; empty when
189
219
  * absent.
190
220
  */
191
221
  readonly unsafeSecretEnvVars: readonly UnsafeSecretEnvVar[];
192
222
  readonly timeout: string;
193
223
  /** `timeout` in minutes. */
194
224
  readonly timeoutMinutes: number;
195
- /** `keepSandbox` in minutes; undefined when the recipe doesn't set it. */
225
+ /** `keepSandbox` in minutes; undefined when the runner options don't set it. */
196
226
  readonly keepSandboxMinutes: number | undefined;
197
227
  readonly baseRefs: readonly string[];
198
228
  readonly region: string;
199
- readonly runtime: string;
229
+ readonly image: string;
200
230
  }
201
231
  /**
202
- * One thing wrong with a recipe: the key path inside the recipe (`["snapshot", "vcpus"]`; empty for the recipe
203
- * itself), and what is wrong, worded to follow the key (`must be …, not …`).
232
+ * One thing wrong with Vercel Sandbox runner options: the key path inside them (`["snapshot", "vcpus"]`; empty for
233
+ * the options object itself), and what is wrong, worded to follow the key (`must be …, not …`).
204
234
  */
205
- export interface RecipeProblem {
235
+ export interface VercelSandboxOptionProblem {
206
236
  readonly path: readonly string[];
207
237
  readonly problem: string;
208
238
  }
209
- export type RecipeCheck = {
239
+ export type VercelSandboxOptionsCheck = {
210
240
  readonly ok: true;
211
- readonly value: CheckedRecipe;
241
+ readonly value: CheckedVercelSandboxOptions;
212
242
  } | {
213
243
  readonly ok: false;
214
- readonly problems: readonly RecipeProblem[];
244
+ readonly problems: readonly VercelSandboxOptionProblem[];
215
245
  };
216
246
  /**
217
- * Checks a recipe against its static rules: the keys it may hold and each value's shape. Every value must be plain
247
+ * Checks Vercel Sandbox runner options against their static rules: the keys they may hold and each value's shape.
248
+ * Every value must be plain
218
249
  * data; functions are refused with the declared form to use instead. Every problem is reported.
219
250
  */
220
- export declare function checkRecipe(value: unknown): RecipeCheck;
251
+ export declare function checkVercelSandboxOptions(value: unknown): VercelSandboxOptionsCheck;
221
252
  /** The sorted, unique repository-relative base file paths declared across `toolchains`. */
222
253
  export declare function declaredBaseFilePaths(toolchains: readonly ToolchainStep[]): readonly string[];
223
254
  /**
@@ -231,11 +262,11 @@ export interface VcpuRun {
231
262
  readonly sandboxes: number;
232
263
  }
233
264
  /**
234
- * The runner sandbox's vCPUs for `run`: the recipe's number, or the declared resource-scaling rule evaluated against
265
+ * The runner sandbox's vCPUs for `run`: the runner's number, or the declared resource-scaling rule evaluated against
235
266
  * `run.resources` and `run.sandboxes`. When the named resource is absent from the run, `min` is used. When the named
236
267
  * resource is present and its named option is missing or not a non-negative finite number, returns a problem.
237
268
  */
238
- export declare function resolveVcpus(recipe: Pick<RunnerRecipe, "vcpus">, run: VcpuRun): {
269
+ export declare function resolveVcpus(options: Pick<VercelSandboxOptions, "vcpus">, run: VcpuRun): {
239
270
  readonly ok: true;
240
271
  readonly vcpus: number;
241
272
  } | {
@@ -243,7 +274,7 @@ export declare function resolveVcpus(recipe: Pick<RunnerRecipe, "vcpus">, run: V
243
274
  readonly problem: string;
244
275
  };
245
276
  /**
246
- * The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the recipe's number,
277
+ * The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the runner's number,
247
278
  * or the declared `{ filesPerSandbox, max? }` rule evaluated against `testPlan`. A number above `sandboxes.max` is not
248
279
  * a problem here: the run lowers it to `sandboxes.max` and says so.
249
280
  */