@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.
- package/dist/bin/storm.js +54 -40
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/chunk-AS37D43E.js +2173 -0
- package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
- package/dist/chunks/chunk-DZLU7BYK.js +340 -0
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
- package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
- package/dist/chunks/chunk-SZMYIIG2.js +88 -0
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
- package/dist/commands/exec/before-run.d.ts +123 -0
- package/dist/commands/exec/before-run.js +105 -0
- package/dist/commands/exec/command.d.ts +67 -14
- package/dist/commands/exec/command.js +31 -95
- package/dist/commands/exec/driver-plan.d.ts +9 -4
- package/dist/commands/exec/driver-plan.js +8 -8
- package/dist/commands/exec/exec-words.js +1 -1
- package/dist/commands/exec/execute-run.d.ts +39 -0
- package/dist/commands/exec/execute-run.js +325 -0
- package/dist/commands/exec/live-view.d.ts +3 -3
- package/dist/commands/exec/live-view.js +16 -15
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/mint-failed.d.ts +38 -0
- package/dist/commands/exec/mint-failed.js +27 -4
- package/dist/commands/exec/outcomes.d.ts +104 -22
- package/dist/commands/exec/outcomes.js +73 -26
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +239 -90
- package/dist/commands/exec/progress.d.ts +10 -6
- package/dist/commands/exec/progress.js +38 -25
- package/dist/commands/exec/run-bin.d.ts +11 -11
- package/dist/commands/exec/run-bin.js +9 -9
- package/dist/commands/exec/run-flags.d.ts +69 -0
- package/dist/commands/exec/run-flags.js +58 -0
- package/dist/commands/exec/run-metadata.js +4 -4
- package/dist/commands/exec/run-summary.d.ts +58 -0
- package/dist/commands/exec/run-summary.js +205 -0
- package/dist/commands/exec/runner-refusals.d.ts +82 -0
- package/dist/commands/exec/runner-refusals.js +71 -0
- package/dist/commands/exec/sandbox-progress.js +3 -0
- package/dist/commands/exec/stopped-outcome.d.ts +12 -0
- package/dist/commands/exec/stopped-outcome.js +77 -0
- package/dist/commands/exec/view.d.ts +20 -11
- package/dist/commands/exec/view.js +103 -47
- package/dist/commands/runs/facts.d.ts +8 -4
- package/dist/commands/runs/facts.js +19 -10
- package/dist/commands/runs/list/command.d.ts +16 -8
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -4
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +16 -8
- package/dist/commands/runs/show/command.js +31 -29
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +8 -4
- package/dist/commands/runs/show/outcomes.js +8 -6
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +376 -101
- package/dist/commands/snapshots/build/command.js +447 -149
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +368 -27
- package/dist/commands/snapshots/list/command.js +298 -68
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
- package/dist/commands/snapshots/list/outcomes.js +223 -52
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +67 -14
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +33 -7
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- package/dist/config/credential-resolver.d.ts +50 -5
- package/dist/config/credential-resolver.js +51 -19
- package/dist/config/credential-settle.d.ts +6 -2
- package/dist/config/credential-settle.js +11 -5
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +14 -4
- package/dist/config-file/toolchain.js +43 -7
- package/dist/context.d.ts +10 -6
- package/dist/context.js +8 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +107 -267
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +1 -1
- package/dist/extension-commands.js +2 -2
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/result.d.ts +1 -1
- package/dist/extensions/testserver/result.js +9 -4
- package/dist/planning/driver-file-lists.d.ts +0 -15
- package/dist/planning/driver-file-lists.js +2 -21
- package/dist/planning/plan-only.d.ts +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- package/dist/planning/run-plan.js +4 -3
- package/dist/planning/suites.d.ts +1 -1
- package/dist/planning/suites.js +2 -2
- package/dist/planning/test-plan.d.ts +9 -0
- package/dist/planning/test-plan.js +9 -0
- package/dist/run-directory/recording.js +3 -3
- package/dist/run-directory/run-record.d.ts +26 -11
- package/dist/run-directory/run-record.js +16 -13
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +60 -29
- package/dist/runner/build-snapshots.js +136 -29
- package/dist/runner/context.d.ts +15 -7
- package/dist/runner/context.js +19 -6
- package/dist/runner/events.d.ts +16 -10
- package/dist/runner/gateways.d.ts +122 -23
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +13 -8
- package/dist/runner/index.js +12 -6
- package/dist/runner/live/checkout-gateway.js +7 -0
- package/dist/runner/live/gh-output.d.ts +17 -0
- package/dist/runner/live/gh-output.js +37 -0
- package/dist/runner/live/gh-token-gateway.d.ts +13 -0
- package/dist/runner/live/gh-token-gateway.js +51 -0
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +140 -4
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +12 -12
- package/dist/runner/local-snapshot-index.d.ts +205 -0
- package/dist/runner/local-snapshot-index.js +210 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +19 -11
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +15 -8
- package/dist/runner/scope.js +16 -5
- package/dist/runner/secrets.d.ts +41 -18
- package/dist/runner/secrets.js +226 -30
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +6 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +79 -47
- package/dist/runner/snapshot-choice.js +2 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +52 -35
- package/dist/runner/snapshot-key.d.ts +32 -17
- package/dist/runner/snapshot-key.js +43 -18
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
- package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +1 -1
- package/dist/sdk/extension/secret-source.d.ts +1 -1
- package/dist/sdk/extension/secret-source.js +1 -1
- package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
- package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +5 -3
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/application.d.ts +0 -21
- package/dist/application.js +0 -30
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
- package/dist/commands/exec/across-sandboxes-run.js +0 -339
- package/dist/commands/exec/plan-only.d.ts +0 -10
- package/dist/commands/exec/plan-only.js +0 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- package/dist/commands/exec/run-planned.d.ts +0 -20
- package/dist/commands/exec/run-planned.js +0 -22
- package/dist/commands/exec/sandbox-view.d.ts +0 -19
- package/dist/commands/exec/sandbox-view.js +0 -72
- package/dist/commands/test/plan.d.ts +0 -92
- package/dist/commands/test/plan.js +0 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/recipe-secrets.d.ts +0 -67
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { CheckoutGateway } from "./gateways.ts";
|
|
2
|
-
import
|
|
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
|
|
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 =
|
|
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
|
|
35
|
-
*
|
|
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
|
|
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
|
|
44
|
-
*
|
|
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
|
|
47
|
-
* source builds another snapshot, and every machine with the same
|
|
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
|
|
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 `
|
|
68
|
-
*
|
|
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
|
|
75
|
-
readonly snapshot: Pick<
|
|
76
|
-
readonly 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
|
|
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 "./
|
|
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
|
|
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 =
|
|
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
|
|
49
|
-
*
|
|
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
|
|
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
|
|
76
|
-
*
|
|
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
|
|
79
|
-
* source builds another snapshot, and every machine with the same
|
|
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
|
-
|
|
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 `
|
|
99
|
-
*
|
|
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,
|
|
104
|
-
const { snapshot } =
|
|
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(
|
|
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
|
+
}
|
package/dist/runner/steps.d.ts
CHANGED
|
@@ -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
|
|
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
|
*/
|
package/dist/runner/steps.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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 `
|
|
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
|
|
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
|
|
3
|
-
|
|
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
|
|
35
|
-
/** Lowercase letters, digits and dashes. Names the
|
|
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
|
|
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
|
-
/**
|
|
117
|
-
|
|
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
|
|
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
|
|
167
|
-
export declare const
|
|
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
|
|
194
|
+
readonly image: "vercel/sandbox/node:al-24";
|
|
173
195
|
};
|
|
174
|
-
/**
|
|
175
|
-
export interface
|
|
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
|
|
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
|
|
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
|
|
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
|
|
229
|
+
readonly image: string;
|
|
200
230
|
}
|
|
201
231
|
/**
|
|
202
|
-
* One thing wrong with
|
|
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
|
|
235
|
+
export interface VercelSandboxOptionProblem {
|
|
206
236
|
readonly path: readonly string[];
|
|
207
237
|
readonly problem: string;
|
|
208
238
|
}
|
|
209
|
-
export type
|
|
239
|
+
export type VercelSandboxOptionsCheck = {
|
|
210
240
|
readonly ok: true;
|
|
211
|
-
readonly value:
|
|
241
|
+
readonly value: CheckedVercelSandboxOptions;
|
|
212
242
|
} | {
|
|
213
243
|
readonly ok: false;
|
|
214
|
-
readonly problems: readonly
|
|
244
|
+
readonly problems: readonly VercelSandboxOptionProblem[];
|
|
215
245
|
};
|
|
216
246
|
/**
|
|
217
|
-
* Checks
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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
|
*/
|