@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
package/dist/runner/ready.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// Readying the runner sandbox once the run's credential names its team and project, in two stages: choose the runner
|
|
2
2
|
// snapshot it starts from (pick the cached one, or build a base snapshot), then start the runner sandbox from it,
|
|
3
|
-
// upload and apply the run's changes, grant it the
|
|
3
|
+
// upload and apply the run's changes, grant it the runner's credentials, and install and build. A run does the first
|
|
4
4
|
// stage once, and the second once for each runner sandbox it starts. The credentials stay in place after the build, for
|
|
5
5
|
// the command: the runner session revokes them once the command has ended, and the scope's fence when the run ends
|
|
6
6
|
// first.
|
|
7
7
|
import { posix } from "node:path";
|
|
8
8
|
import { runnerTags } from "./context.js";
|
|
9
|
+
import { pickSnapshot, sharedBeatsLocal, snapshotRejections } from "./local-snapshot-index.js";
|
|
9
10
|
import { buildSnapshot } from "./snapshot-build.js";
|
|
10
|
-
import {
|
|
11
|
+
import { lookupSharedSnapshot } from "./shared-snapshot-lookup.js";
|
|
11
12
|
import { applyScript, SANDBOX_ROOT, STAGED_FILES } from "./snapshot-key.js";
|
|
12
13
|
import { networkPolicyStop, runStep, sandboxStop } from "./steps.js";
|
|
13
14
|
/** The label of the step that applies and commits the run's changes in the runner sandbox. */
|
|
@@ -23,35 +24,105 @@ export async function readyRunner(context, request, control, progress) {
|
|
|
23
24
|
return await readyFromSnapshot(context, { ...request, snapshot: chosen.value }, control, progress);
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
|
-
* Chooses the runner snapshot a prepared run starts from, and starts no runner sandbox. It
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Chooses the runner snapshot a prepared run starts from, and starts no runner sandbox. It checks the local snapshot
|
|
28
|
+
* index first: an exact merge-base hit is reused at once, with no call to the shared snapshot index. Otherwise it
|
|
29
|
+
* queries the shared snapshot index and compares any shared hit against any local ancestor candidate: the shared hit
|
|
30
|
+
* wins only when it is closer (`sharedBeatsLocal`), and a winning shared hit is written to the local snapshot index.
|
|
31
|
+
* Whenever the chosen snapshot's base differs from `prepared.base`, it assembles the checkout upload against that base
|
|
32
|
+
* once here; otherwise it reuses `prepared.upload`. With no fitting snapshot in either index, it builds a base snapshot
|
|
33
|
+
* at `prepared.base` into the local snapshot index.
|
|
30
34
|
*/
|
|
31
35
|
export async function chooseSnapshot(context, request, control, progress) {
|
|
32
36
|
const { prepared, access } = request;
|
|
33
|
-
|
|
37
|
+
const { signal } = control;
|
|
38
|
+
if (signal.aborted)
|
|
34
39
|
return { kind: "aborted" };
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
// The local snapshot index on this machine.
|
|
41
|
+
const localCandidate = pickSnapshot(prepared.candidates, access);
|
|
42
|
+
if (localCandidate !== undefined && localCandidate.commitsBehindMergeBase === 0) {
|
|
43
|
+
const { entry, builtBehind } = localCandidate;
|
|
38
44
|
await progress.emit({
|
|
39
45
|
kind: "snapshot-reused",
|
|
40
46
|
snapshotId: entry.snapshotId,
|
|
41
47
|
base: entry.base,
|
|
42
|
-
builtBehind
|
|
48
|
+
builtBehind,
|
|
49
|
+
source: "local",
|
|
43
50
|
});
|
|
44
|
-
return { kind: "ok", value: { entry, built: false } };
|
|
51
|
+
return { kind: "ok", value: { entry, built: false, builtBehind, upload: prepared.upload } };
|
|
52
|
+
}
|
|
53
|
+
// The shared snapshot index in the Vercel project.
|
|
54
|
+
const shared = await lookupSharedSnapshot(context, {
|
|
55
|
+
access,
|
|
56
|
+
repoRoot: prepared.repoRoot,
|
|
57
|
+
runner: prepared.options,
|
|
58
|
+
snapshotKey: prepared.snapshotKey,
|
|
59
|
+
mergeBase: prepared.base,
|
|
60
|
+
...(localCandidate === undefined ? {} : { maxCommitsBehindMergeBase: localCandidate.commitsBehindMergeBase }),
|
|
61
|
+
}, signal);
|
|
62
|
+
if (shared.kind === "aborted")
|
|
63
|
+
return { kind: "aborted" };
|
|
64
|
+
if (shared.kind === "unavailable") {
|
|
65
|
+
await progress.emit({ kind: "shared-snapshot-lookup-failed", message: shared.message });
|
|
66
|
+
}
|
|
67
|
+
const sharedHit = shared.kind === "hit" ? shared : undefined;
|
|
68
|
+
const useShared = sharedHit !== undefined &&
|
|
69
|
+
sharedBeatsLocal(sharedHit.commitsBehindMergeBase, localCandidate?.commitsBehindMergeBase);
|
|
70
|
+
const winner = useShared
|
|
71
|
+
? { source: "shared", hit: sharedHit }
|
|
72
|
+
: localCandidate !== undefined
|
|
73
|
+
? { source: "local", candidate: localCandidate }
|
|
74
|
+
: undefined;
|
|
75
|
+
if (winner !== undefined) {
|
|
76
|
+
let entry;
|
|
77
|
+
let builtBehind;
|
|
78
|
+
if (winner.source === "shared") {
|
|
79
|
+
entry = winner.hit.entry;
|
|
80
|
+
const written = await context.runnerSnapshots.writeEntry(entry);
|
|
81
|
+
if (!written.ok)
|
|
82
|
+
await progress.emit({ kind: "snapshot-entry-not-written", failure: written.failure });
|
|
83
|
+
builtBehind = prepared.commitsAfterBase + winner.hit.commitsBehindMergeBase;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
entry = winner.candidate.entry;
|
|
87
|
+
builtBehind = winner.candidate.builtBehind;
|
|
88
|
+
}
|
|
89
|
+
const upload = await uploadForBase(context, prepared, entry.base);
|
|
90
|
+
if (!upload.ok)
|
|
91
|
+
return { kind: "failed", failure: { kind: "checkout-failed", failure: upload.failure } };
|
|
92
|
+
if (signal.aborted)
|
|
93
|
+
return { kind: "aborted" };
|
|
94
|
+
await progress.emit({
|
|
95
|
+
kind: "snapshot-reused",
|
|
96
|
+
snapshotId: entry.snapshotId,
|
|
97
|
+
base: entry.base,
|
|
98
|
+
builtBehind,
|
|
99
|
+
source: winner.source,
|
|
100
|
+
});
|
|
101
|
+
return { kind: "ok", value: { entry, built: false, builtBehind, upload: upload.value } };
|
|
45
102
|
}
|
|
46
103
|
const why = { kind: "no-snapshot", rejected: snapshotRejections(prepared, access) };
|
|
47
104
|
const building = await buildSnapshot(context, { prepared, access, user: request.user, credentials: request.credentials, why }, control, progress);
|
|
48
105
|
if (building.kind !== "ok")
|
|
49
106
|
return building;
|
|
50
|
-
return {
|
|
107
|
+
return {
|
|
108
|
+
kind: "ok",
|
|
109
|
+
value: {
|
|
110
|
+
entry: building.value.entry,
|
|
111
|
+
built: true,
|
|
112
|
+
builtBehind: prepared.commitsAfterBase,
|
|
113
|
+
upload: prepared.upload,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/** Reuses `prepared.upload` when `base` is `prepared.base`, or assembles the upload against `base`. */
|
|
118
|
+
async function uploadForBase(context, prepared, base) {
|
|
119
|
+
if (base === prepared.base)
|
|
120
|
+
return { ok: true, value: prepared.upload };
|
|
121
|
+
return await context.checkout.assembleUpload({ repoRoot: prepared.repoRoot, base });
|
|
51
122
|
}
|
|
52
123
|
/**
|
|
53
124
|
* Readies a runner sandbox from the runner snapshot a run chose: it starts the runner sandbox from that snapshot,
|
|
54
|
-
* uploads what the checkout changes on top of the run's base, applies it, grants it the
|
|
125
|
+
* uploads what the checkout changes on top of the run's base, applies it, grants it the runner's credentials
|
|
55
126
|
* (`RunnerSandboxScope.grantCredentials`), and runs the install and the build. It doesn't revoke them: they stay in
|
|
56
127
|
* place for the command, and whoever ends the run revokes them, the runner session after the command, or the scope's
|
|
57
128
|
* fence when the run ends before it. A failed grant ends it with `network-policy-failed` (`operation: "inject"`,
|
|
@@ -61,8 +132,8 @@ export async function chooseSnapshot(context, request, control, progress) {
|
|
|
61
132
|
*/
|
|
62
133
|
export async function readyFromSnapshot(context, request, control, progress) {
|
|
63
134
|
const { prepared, access } = request;
|
|
64
|
-
const { entry, built } = request.snapshot;
|
|
65
|
-
const {
|
|
135
|
+
const { entry, built, builtBehind, upload } = request.snapshot;
|
|
136
|
+
const { options, repoRoot } = prepared;
|
|
66
137
|
const { scope, signal } = control;
|
|
67
138
|
const now = () => context.clock.now().getTime();
|
|
68
139
|
if (signal.aborted)
|
|
@@ -71,10 +142,10 @@ export async function readyFromSnapshot(context, request, control, progress) {
|
|
|
71
142
|
const startedAt = now();
|
|
72
143
|
const started = await scope.startRunnerSandbox(access, {
|
|
73
144
|
snapshotId: entry.snapshotId,
|
|
74
|
-
region:
|
|
145
|
+
region: options.region,
|
|
75
146
|
vcpus: prepared.vcpus,
|
|
76
|
-
timeoutMs:
|
|
77
|
-
tags: runnerTags(
|
|
147
|
+
timeoutMs: options.timeoutMinutes * 60_000,
|
|
148
|
+
tags: runnerTags(options.name, "runner", request.user),
|
|
78
149
|
});
|
|
79
150
|
if (!started.ok) {
|
|
80
151
|
if (started.failure.kind === "snapshot-gone") {
|
|
@@ -88,25 +159,25 @@ export async function readyFromSnapshot(context, request, control, progress) {
|
|
|
88
159
|
kind: "sandbox-started",
|
|
89
160
|
role: "runner",
|
|
90
161
|
name: sandbox.name,
|
|
91
|
-
region:
|
|
162
|
+
region: options.region,
|
|
92
163
|
vcpus: prepared.vcpus,
|
|
93
164
|
ms: now() - startedAt,
|
|
94
165
|
});
|
|
95
|
-
const changes = await uploadChanges(context, {
|
|
166
|
+
const changes = await uploadChanges(context, { upload, sandbox }, signal, progress);
|
|
96
167
|
if (changes.kind !== "ok")
|
|
97
168
|
return changes;
|
|
98
169
|
const applied = await stage(context, {
|
|
99
170
|
sandbox,
|
|
100
171
|
phase: "apply",
|
|
101
172
|
step: { label: APPLY_LABEL, script: applyScript(changes.value.directory) },
|
|
102
|
-
region:
|
|
173
|
+
region: options.region,
|
|
103
174
|
}, signal, progress);
|
|
104
175
|
if (applied.kind !== "ok")
|
|
105
176
|
return applied;
|
|
106
177
|
const loginPath = await context.runnerSandboxes.loginPath(sandbox, signal);
|
|
107
178
|
if (!loginPath.ok)
|
|
108
179
|
return sandboxStop("login-path", loginPath.failure);
|
|
109
|
-
// Every credential the
|
|
180
|
+
// Every credential the runner declares goes on the requests of the install, the build, and the command: the upload
|
|
110
181
|
// and the apply come before the grant. Nothing here revokes them; a run that ends before the command leaves that to
|
|
111
182
|
// the scope's fence.
|
|
112
183
|
if (request.credentials.length > 0) {
|
|
@@ -114,10 +185,10 @@ export async function readyFromSnapshot(context, request, control, progress) {
|
|
|
114
185
|
if (!granted.ok)
|
|
115
186
|
return networkPolicyStop("inject", "run-steps", granted.failure);
|
|
116
187
|
}
|
|
117
|
-
const installed = await stage(context, { sandbox, phase: "install", step:
|
|
188
|
+
const installed = await stage(context, { sandbox, phase: "install", step: options.run.install, region: options.region }, signal, progress);
|
|
118
189
|
if (installed.kind !== "ok")
|
|
119
190
|
return installed;
|
|
120
|
-
const builtOutputs = await stage(context, { sandbox, phase: "build", step:
|
|
191
|
+
const builtOutputs = await stage(context, { sandbox, phase: "build", step: options.run.build, region: options.region }, signal, progress);
|
|
121
192
|
if (builtOutputs.kind !== "ok")
|
|
122
193
|
return builtOutputs;
|
|
123
194
|
return {
|
|
@@ -127,26 +198,26 @@ export async function readyFromSnapshot(context, request, control, progress) {
|
|
|
127
198
|
snapshotId: entry.snapshotId,
|
|
128
199
|
base: entry.base,
|
|
129
200
|
built,
|
|
130
|
-
builtBehind
|
|
201
|
+
builtBehind,
|
|
131
202
|
uploadBytes: changes.value.bytes,
|
|
132
203
|
buildMs: builtOutputs.value,
|
|
133
204
|
vcpus: prepared.vcpus,
|
|
134
|
-
region:
|
|
135
|
-
|
|
205
|
+
region: options.region,
|
|
206
|
+
image: options.image,
|
|
136
207
|
repoRoot,
|
|
137
|
-
cwd: posix.join(SANDBOX_ROOT,
|
|
138
|
-
env:
|
|
208
|
+
cwd: posix.join(SANDBOX_ROOT, options.cwd),
|
|
209
|
+
env: options.env,
|
|
139
210
|
loginPath: loginPath.value,
|
|
140
211
|
},
|
|
141
212
|
};
|
|
142
213
|
}
|
|
143
214
|
/**
|
|
144
|
-
* Uploads what the checkout changes on top of the
|
|
215
|
+
* Uploads what the checkout changes on top of the chosen snapshot's base.
|
|
145
216
|
*/
|
|
146
217
|
async function uploadChanges(context, request, signal, progress) {
|
|
147
218
|
await progress.emit({ kind: "uploading" });
|
|
148
219
|
const startedAt = context.clock.now().getTime();
|
|
149
|
-
const files = stagedChanges(request.
|
|
220
|
+
const files = stagedChanges(request.upload);
|
|
150
221
|
const staged = await context.runnerSandboxes.upload(request.sandbox, files, signal);
|
|
151
222
|
if (!staged.ok)
|
|
152
223
|
return sandboxStop("upload", staged.failure);
|
|
@@ -170,7 +241,7 @@ export function stagedChanges(upload) {
|
|
|
170
241
|
}
|
|
171
242
|
/**
|
|
172
243
|
* Runs the apply, install, or build step, answering how long it took; the install and build get rule lines. The grant
|
|
173
|
-
* of the
|
|
244
|
+
* of the runner's credentials before the install is the caller's.
|
|
174
245
|
*/
|
|
175
246
|
async function stage(context, request, signal, progress) {
|
|
176
247
|
if (signal.aborted)
|
|
@@ -17,11 +17,11 @@ export declare function sandboxedCommand(request: {
|
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
19
|
* What the command's environment adds to the runner sandbox's own: `PATH` with the sandbox `cwd`'s and the
|
|
20
|
-
* repository's `node_modules/.bin` before the login shell's, no update checks, the
|
|
20
|
+
* repository's `node_modules/.bin` before the login shell's, no update checks, the runner's `env`, any
|
|
21
21
|
* `unsafeSecretEnvVars` values the run read on the launch machine, and `STORM_RUN` last, so nothing overrides it. When
|
|
22
|
-
* the
|
|
22
|
+
* the runner's `env` sets neither `FORCE_COLOR` nor `NO_COLOR`, it also gets `FORCE_COLOR=1` when the local terminal
|
|
23
23
|
* asks for color (`"on"`), `NO_COLOR=1` when the launcher explicitly opted out (`"off"`), and neither on a plain
|
|
24
|
-
* non-TTY launcher (`"auto"`), as a run with no runner does (`colorEnvironment` in `core/payload.ts`); a
|
|
24
|
+
* non-TTY launcher (`"auto"`), as a run with no runner does (`colorEnvironment` in `core/payload.ts`); a runner that
|
|
25
25
|
* sets either gets neither from storm. Nothing else comes from the local environment.
|
|
26
26
|
*/
|
|
27
27
|
export declare function sandboxEnvironment(request: {
|
|
@@ -17,11 +17,11 @@ export function sandboxedCommand(request) {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* What the command's environment adds to the runner sandbox's own: `PATH` with the sandbox `cwd`'s and the
|
|
20
|
-
* repository's `node_modules/.bin` before the login shell's, no update checks, the
|
|
20
|
+
* repository's `node_modules/.bin` before the login shell's, no update checks, the runner's `env`, any
|
|
21
21
|
* `unsafeSecretEnvVars` values the run read on the launch machine, and `STORM_RUN` last, so nothing overrides it. When
|
|
22
|
-
* the
|
|
22
|
+
* the runner's `env` sets neither `FORCE_COLOR` nor `NO_COLOR`, it also gets `FORCE_COLOR=1` when the local terminal
|
|
23
23
|
* asks for color (`"on"`), `NO_COLOR=1` when the launcher explicitly opted out (`"off"`), and neither on a plain
|
|
24
|
-
* non-TTY launcher (`"auto"`), as a run with no runner does (`colorEnvironment` in `core/payload.ts`); a
|
|
24
|
+
* non-TTY launcher (`"auto"`), as a run with no runner does (`colorEnvironment` in `core/payload.ts`); a runner that
|
|
25
25
|
* sets either gets neither from storm. Nothing else comes from the local environment.
|
|
26
26
|
*/
|
|
27
27
|
export function sandboxEnvironment(request) {
|
package/dist/runner/scope.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { SandboxCredential } from "../sdk/extension/index.ts";
|
|
2
2
|
import type { Clock, Timer } from "../time/index.ts";
|
|
3
3
|
import type { KeptSandbox, NotDeletedSandbox, NotKeptSandbox, NotStoppedSandbox, RunnerProgress } from "./events.ts";
|
|
4
|
-
import type { RunnerSandbox, RunnerSandboxFailure, RunnerSandboxGateway, RunnerSandboxPlacement, RunnerSandboxResult, RunnerStartFailure, SandboxAccess, SavedSnapshot } from "./gateways.ts";
|
|
4
|
+
import type { RunnerBuildStartFailure, RunnerSandbox, RunnerSandboxFailure, RunnerSandboxGateway, RunnerSandboxPlacement, RunnerSandboxResult, RunnerStartFailure, SandboxAccess, SavedSnapshot } from "./gateways.ts";
|
|
5
5
|
import { type NetworkPolicyWriteFailure, type NetworkPolicyWriteResult, type RunnerReachPolicy } from "./network-policy.ts";
|
|
6
|
+
import type { ManagedCredential } from "./vercel-sandbox-secrets.ts";
|
|
6
7
|
/** How long closing waits for a create in flight: 20 seconds. */
|
|
7
8
|
export declare const CREATE_SETTLE_MS = 20000;
|
|
8
9
|
/** How long closing waits for a runner snapshot still saving: 2 minutes. */
|
|
@@ -34,7 +35,7 @@ export interface RunnerScopeFacts {
|
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Why the scope saved no snapshot of a build sandbox: a Sandbox failure, or `credential-not-revoked` when its policy
|
|
37
|
-
* may hold a credential (the
|
|
38
|
+
* may hold a credential (the runner's or a resource's) and writing the policy without it failed (`failure`).
|
|
38
39
|
*/
|
|
39
40
|
export type ScopeSaveFailure = RunnerSandboxFailure | {
|
|
40
41
|
readonly kind: "credential-not-revoked";
|
|
@@ -44,7 +45,7 @@ export type ScopeSaveFailure = RunnerSandboxFailure | {
|
|
|
44
45
|
* What a sandbox the scope starts is created with: its placement, but for the network policy. The scope gives every
|
|
45
46
|
* sandbox it starts its base policy, the one it writes again whenever it revokes a credential.
|
|
46
47
|
*/
|
|
47
|
-
export type ScopedSandboxPlacement = Omit<RunnerSandboxPlacement, "networkPolicy">;
|
|
48
|
+
export type ScopedSandboxPlacement = Omit<RunnerSandboxPlacement, "networkPolicy" | "managedCredentials">;
|
|
48
49
|
/**
|
|
49
50
|
* Starts sandboxes, grants and revokes their credentials, and saves runner snapshots on the scope's behalf, so `close`
|
|
50
51
|
* knows about every one. It creates each sandbox with its base policy. A start once closing has begun answers `aborted`
|
|
@@ -53,8 +54,9 @@ export type ScopedSandboxPlacement = Omit<RunnerSandboxPlacement, "networkPolicy
|
|
|
53
54
|
*/
|
|
54
55
|
export interface RunnerSandboxScope {
|
|
55
56
|
startBuildSandbox(access: SandboxAccess, request: ScopedSandboxPlacement & {
|
|
56
|
-
readonly
|
|
57
|
-
|
|
57
|
+
readonly image: string;
|
|
58
|
+
readonly name?: string;
|
|
59
|
+
}): Promise<RunnerSandboxResult<RunnerSandbox, RunnerBuildStartFailure>>;
|
|
58
60
|
startRunnerSandbox(access: SandboxAccess, request: ScopedSandboxPlacement & {
|
|
59
61
|
readonly snapshotId: string;
|
|
60
62
|
}): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
|
|
@@ -85,12 +87,15 @@ export interface RunnerSandboxScope {
|
|
|
85
87
|
*/
|
|
86
88
|
revokeCredentials(sandbox: RunnerSandbox): Promise<NetworkPolicyWriteResult>;
|
|
87
89
|
/**
|
|
88
|
-
* Saves a build sandbox as a runner snapshot, then deletes it at once
|
|
89
|
-
*
|
|
90
|
-
*
|
|
90
|
+
* Saves a build sandbox as a runner snapshot, then deletes it at once unless `keepStopped` is true and the scope is
|
|
91
|
+
* still open (leaving the stopped named sandbox in the project as a shared snapshot index entry); a failed save or a
|
|
92
|
+
* cancel before the save completes leaves it to `close` to stop and delete. When the sandbox's policy may hold a
|
|
93
|
+
* credential, it first writes the policy without the injection, and saves nothing when that fails
|
|
94
|
+
* (`credential-not-revoked`).
|
|
91
95
|
*/
|
|
92
96
|
saveSnapshot(sandbox: RunnerSandbox, request: {
|
|
93
97
|
readonly expirationMs: number;
|
|
98
|
+
readonly keepStopped?: boolean;
|
|
94
99
|
}): Promise<RunnerSandboxResult<SavedSnapshot, ScopeSaveFailure>>;
|
|
95
100
|
/**
|
|
96
101
|
* Fences every sandbox the scope holds, before its owner releases the run's resources. It waits up to
|
|
@@ -125,6 +130,8 @@ export interface RunnerScopeSettings {
|
|
|
125
130
|
readonly keepMs: number;
|
|
126
131
|
/** The run's policy with no credential (`runnerNetworkPolicy`). */
|
|
127
132
|
readonly basePolicy: RunnerReachPolicy;
|
|
133
|
+
/** Vercel-managed credentials passed when starting sandboxes; forbids `keepMs` above 0. */
|
|
134
|
+
readonly managedCredentials?: readonly ManagedCredential[];
|
|
128
135
|
/** The storm command's signal: its abort cancels the command, which stops the scope's sandboxes. */
|
|
129
136
|
readonly signal: AbortSignal;
|
|
130
137
|
/** Whether the command runs now, for the `stopping` event; by default it never does. */
|
package/dist/runner/scope.js
CHANGED
|
@@ -25,6 +25,9 @@ export const KEEP_RUNNING_LIMIT_MS = 60_000;
|
|
|
25
25
|
* `RunnerSandboxScope` and `README.md` for each method's contract.
|
|
26
26
|
*/
|
|
27
27
|
export function runnerSandboxScope(context, progress, settings) {
|
|
28
|
+
const managedCredentials = settings.managedCredentials ?? [];
|
|
29
|
+
if (managedCredentials.length > 0 && settings.keepMs > 0)
|
|
30
|
+
throw new Error("a sandbox scope with managedCredentials can't keep its runner sandbox");
|
|
28
31
|
const { runnerSandboxes: sandboxes, timer, clock } = context;
|
|
29
32
|
let phase = { kind: "open", sandboxes: new Map(), creating: new Set() };
|
|
30
33
|
const saving = new Set();
|
|
@@ -288,9 +291,10 @@ export function runnerSandboxScope(context, progress, settings) {
|
|
|
288
291
|
onSignal();
|
|
289
292
|
else
|
|
290
293
|
settings.signal.addEventListener("abort", onSignal, { once: true });
|
|
294
|
+
const managed = managedCredentials.length === 0 ? {} : { managedCredentials };
|
|
291
295
|
return {
|
|
292
|
-
startBuildSandbox: (access, request) => owned(() => sandboxes.startBuildSandbox(access, { ...request, networkPolicy: settings.basePolicy })),
|
|
293
|
-
startRunnerSandbox: (access, request) => owned(() => sandboxes.startRunnerSandbox(access, { ...request, networkPolicy: settings.basePolicy }), true),
|
|
296
|
+
startBuildSandbox: (access, request) => owned(() => sandboxes.startBuildSandbox(access, { ...request, networkPolicy: settings.basePolicy, ...managed })),
|
|
297
|
+
startRunnerSandbox: (access, request) => owned(() => sandboxes.startRunnerSandbox(access, { ...request, networkPolicy: settings.basePolicy, ...managed }), true),
|
|
294
298
|
grantCredentials,
|
|
295
299
|
revokeCredentials,
|
|
296
300
|
saveSnapshot: (sandbox, request) => track(saving, (async () => {
|
|
@@ -299,10 +303,17 @@ export function runnerSandboxScope(context, progress, settings) {
|
|
|
299
303
|
if (!removed.ok)
|
|
300
304
|
return { ok: false, failure: { kind: "credential-not-revoked", failure: removed.failure } };
|
|
301
305
|
}
|
|
302
|
-
const saved = await sandboxes.saveSnapshot(sandbox, request);
|
|
306
|
+
const saved = await sandboxes.saveSnapshot(sandbox, { expirationMs: request.expirationMs });
|
|
303
307
|
const now = currentPhase();
|
|
304
|
-
if (saved.ok
|
|
305
|
-
|
|
308
|
+
if (saved.ok) {
|
|
309
|
+
if (request.keepStopped === true) {
|
|
310
|
+
if (now.kind === "open")
|
|
311
|
+
now.sandboxes.delete(sandbox);
|
|
312
|
+
}
|
|
313
|
+
else if (now.kind !== "closing" && now.sandboxes.delete(sandbox)) {
|
|
314
|
+
await deleteSandbox(sandbox);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
306
317
|
return saved;
|
|
307
318
|
})()),
|
|
308
319
|
fence,
|
package/dist/runner/secrets.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type SandboxCredential, SECRET_MIN_LENGTH, type SecretProblem } from "../sdk/extension/index.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { GhTokenGateway } from "./gateways.ts";
|
|
3
|
+
import type { CheckedVercelSandboxOptions } from "./vercel-sandbox-options.ts";
|
|
3
4
|
export { SECRET_MIN_LENGTH, type SecretProblem };
|
|
4
5
|
/**
|
|
5
6
|
* An unsafe secret environment variable's value by the variable name exposed to the command, each an own property
|
|
@@ -8,21 +9,41 @@ export { SECRET_MIN_LENGTH, type SecretProblem };
|
|
|
8
9
|
* or `__proto__`, so the map is read with `Object.hasOwn`, never by a plain lookup, which reaches `Object.prototype`.
|
|
9
10
|
*/
|
|
10
11
|
export type UnsafeSecretEnvVarMap = Readonly<Record<string, string>>;
|
|
11
|
-
/** One variable the run can't use, with its first problem. */
|
|
12
|
+
/** One launcher environment variable the run can't use, with its first problem. */
|
|
12
13
|
export interface SecretVariableProblem {
|
|
13
14
|
readonly name: string;
|
|
14
15
|
readonly problem: SecretProblem;
|
|
15
16
|
}
|
|
17
|
+
/** Machine-readable problem codes for `readCredentials` (`credentials_invalid`). */
|
|
18
|
+
export declare const CREDENTIAL_PROBLEM_KINDS: readonly ["missing", "multiline", "short", "gh-not-installed", "gh-not-authenticated", "gh-timed-out", "gh-failed", "gh-preframed"];
|
|
19
|
+
/** What keeps one declared sandbox credential from being used. */
|
|
20
|
+
export type CredentialProblemKind = (typeof CREDENTIAL_PROBLEM_KINDS)[number];
|
|
21
|
+
/** One declared sandbox credential the run can't use, with its machine-readable problem, detail, and next step. */
|
|
22
|
+
export interface CredentialProblem {
|
|
23
|
+
/** Human-readable label for the source (an env var name such as `NPM_AUTH`, or `gh (<host>)`). */
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly problem: CredentialProblemKind;
|
|
26
|
+
/** Actionable description of why the credential couldn't be used (never holds a secret value or file contents). */
|
|
27
|
+
readonly detail: string;
|
|
28
|
+
/** Actionable next step for fixing this problem (never holds a secret value). */
|
|
29
|
+
readonly hint: string;
|
|
30
|
+
}
|
|
31
|
+
/** Gateways `readCredentials` uses to resolve non-env sandbox credential sources. */
|
|
32
|
+
export interface CredentialReadContext {
|
|
33
|
+
readonly ghTokens: GhTokenGateway;
|
|
34
|
+
}
|
|
16
35
|
/**
|
|
17
|
-
* The
|
|
18
|
-
*
|
|
36
|
+
* The runner's credentials with their values, in the runner's order, and every secret form to redact as `<token>`, or
|
|
37
|
+
* what keeps the run from starting: each unusable credential source, in first-seen order.
|
|
19
38
|
*/
|
|
20
39
|
export type CredentialRead = {
|
|
21
40
|
readonly ok: true;
|
|
22
41
|
readonly credentials: readonly Required<SandboxCredential>[];
|
|
42
|
+
/** Every secret form (header values, raw tokens, passwords, base64 credentials, etc.) to redact as `<token>`. */
|
|
43
|
+
readonly secrets: readonly string[];
|
|
23
44
|
} | {
|
|
24
45
|
readonly ok: false;
|
|
25
|
-
readonly
|
|
46
|
+
readonly problems: readonly CredentialProblem[];
|
|
26
47
|
};
|
|
27
48
|
/**
|
|
28
49
|
* The unsafe secret environment variables' values keyed by each entry's target `name`, or what keeps the run from
|
|
@@ -36,24 +57,26 @@ export type UnsafeSecretEnvVarRead = {
|
|
|
36
57
|
readonly variables: readonly SecretVariableProblem[];
|
|
37
58
|
};
|
|
38
59
|
/**
|
|
39
|
-
* The value of each credential and unsafe secret environment variable `
|
|
40
|
-
* run would say of it: for
|
|
41
|
-
*
|
|
60
|
+
* The value of each env-backed credential and unsafe secret environment variable `options` declares that `env` sets,
|
|
61
|
+
* whatever a run would say of it: for commands and pure helpers that hide set environment values without doing file
|
|
62
|
+
* I/O or starting subprocesses, such as `storm snapshots list`, `storm snapshots build` (before reading credentials),
|
|
63
|
+
* and `storm test`'s pre-run line. A short or multiline value is kept, since hiding it there is safer than showing it.
|
|
42
64
|
*/
|
|
43
|
-
export declare function declaredSecretValues(
|
|
65
|
+
export declare function declaredSecretValues(options: Pick<CheckedVercelSandboxOptions, "credentials" | "unsafeSecretEnvVars"> | undefined, env: Readonly<Record<string, string | undefined>>): string[];
|
|
44
66
|
/**
|
|
45
|
-
* Reads each of `
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* order
|
|
67
|
+
* Reads each of `options`'s credentials' values on this machine:
|
|
68
|
+
* - `{ kind: "env", name }`: reads the whole header value from launcher `env` through `readSecretSource`.
|
|
69
|
+
* - `{ kind: "gh", env?, host?, format? }`: uses non-empty launcher `env[source.env]` when configured, otherwise
|
|
70
|
+
* reads a token through `context.ghTokens` (at most once per host per call) and frames it as `Basic` or `Bearer`.
|
|
71
|
+
*
|
|
72
|
+
* Returns normalized sandbox credentials in the runner's order plus every secret form to redact as `<token>`, or each
|
|
73
|
+
* problem in first-seen order.
|
|
51
74
|
*/
|
|
52
|
-
export declare function readCredentials(
|
|
75
|
+
export declare function readCredentials(options: Pick<CheckedVercelSandboxOptions, "credentials">, env: Readonly<Record<string, string | undefined>>, context: CredentialReadContext): Promise<CredentialRead>;
|
|
53
76
|
/**
|
|
54
|
-
* Reads each of `
|
|
77
|
+
* Reads each of `options`'s unsafe secret environment variables (`runner.unsafeSecretEnvVars`) from `env`, the
|
|
55
78
|
* environment of the machine the run starts on, through `readSecretSource`, and maps each value to `entry.name` for
|
|
56
79
|
* the command's environment. A source's problem is the first that holds of `missing`, `multiline`, and `short`, and a
|
|
57
80
|
* source two entries share is read and reported once in first-seen order. A value is used as it is, never trimmed.
|
|
58
81
|
*/
|
|
59
|
-
export declare function readUnsafeSecretEnvVars(
|
|
82
|
+
export declare function readUnsafeSecretEnvVars(options: Pick<CheckedVercelSandboxOptions, "unsafeSecretEnvVars">, env: Readonly<Record<string, string | undefined>>): UnsafeSecretEnvVarRead;
|