@cnc-tools/storm 0.16.0 → 0.17.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/application.d.ts +22 -13
- package/dist/application.js +21 -10
- package/dist/bin/run.d.ts +18 -0
- package/dist/bin/run.js +31 -0
- package/dist/bin/storm.js +42 -26
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
- package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
- package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/chunk-F4MOYHRY.js +198 -0
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
- package/dist/chunks/chunk-HP3CURSZ.js +88 -0
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
- package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
- package/dist/chunks/chunk-MR77L2GK.js +340 -0
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
- 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 +31 -2
- 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 +34 -8
- package/dist/commands/exec/outcomes.js +30 -23
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +232 -88
- 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 +7 -3
- package/dist/commands/runs/facts.js +17 -8
- package/dist/commands/runs/list/command.d.ts +14 -6
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +7 -3
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +14 -6
- package/dist/commands/runs/show/command.js +30 -28
- package/dist/commands/runs/show/outcomes.d.ts +7 -3
- package/dist/commands/runs/show/outcomes.js +7 -5
- 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 +360 -93
- package/dist/commands/snapshots/build/command.js +446 -150
- 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 +234 -43
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +366 -25
- package/dist/commands/snapshots/list/command.js +296 -66
- 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 +245 -13
- package/dist/commands/snapshots/list/outcomes.js +221 -50
- 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 +31 -2
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +15 -1
- 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 +1 -1
- package/dist/config-file/toolchain.js +2 -2
- package/dist/context.d.ts +8 -6
- package/dist/context.js +7 -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 +106 -266
- 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 +6 -1
- package/dist/extension-commands.js +15 -1
- 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 +2 -2
- package/dist/run-directory/run-record.d.ts +21 -6
- package/dist/run-directory/run-record.js +12 -9
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +55 -29
- package/dist/runner/build-snapshots.js +130 -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 +87 -21
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/index.d.ts +11 -7
- package/dist/runner/index.js +9 -4
- 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 +129 -3
- 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 +6 -7
- package/dist/runner/local-snapshot-index.d.ts +199 -0
- package/dist/runner/local-snapshot-index.js +211 -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 +18 -10
- 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 +10 -6
- package/dist/runner/scope.js +10 -3
- package/dist/runner/secrets.d.ts +13 -13
- package/dist/runner/secrets.js +18 -15
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +3 -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 +32 -29
- package/dist/runner/snapshot-choice.js +1 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +55 -35
- package/dist/runner/snapshot-key.d.ts +13 -12
- package/dist/runner/snapshot-key.js +13 -12
- 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} +2 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
- package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
- package/dist/sdk/extension/commands.d.ts +8 -3
- package/dist/sdk/extension/commands.js +3 -1
- 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 +3 -2
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- 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/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
package/dist/core/run.js
CHANGED
|
@@ -1,174 +1,52 @@
|
|
|
1
|
-
// A run, from its start to its outcome.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// unsandboxed run's request holds none, and its command runs on the launch machine (`runUnsandboxed`). Either way the
|
|
5
|
-
// core keeps the mint, acquiring the resources (with the runner lane beside them in a sandboxed run), saying each
|
|
6
|
-
// acquired, the run payload, the `command-started` and `command-ended` events, the test events and releasing the
|
|
7
|
-
// resources. This file is the one core module that tells the kinds apart. The rest of the core sees the runner, the
|
|
8
|
-
// runner lane and the runner's events, or nothing.
|
|
1
|
+
// A single run, from its start to its outcome (`executeRun`). Dispatches the peer runner (`launch-machine` or
|
|
2
|
+
// `vercel-sandbox`) directly in `executeRun` and delegates opening, credential obtainment, concurrent setup, sandbox
|
|
3
|
+
// command execution, and cleanup framing to `core/coordinator.ts`.
|
|
9
4
|
import { posix } from "node:path";
|
|
10
|
-
import { credentialSourceFor
|
|
5
|
+
import { credentialSourceFor } from "../credential/index.js";
|
|
11
6
|
import { lineSplitter, openRunnerSession, SANDBOX_TEST_EVENTS_PATH, } from "../runner/index.js";
|
|
12
|
-
import {
|
|
7
|
+
import { coordinateSetup, emitLanesStarted, emitRunOpening, obtainRunnerCredential, runCommandInSandbox, withResourceCleanup, } from "./coordinator.js";
|
|
8
|
+
import { canceledStop, runnerLaneOutcome, runnerStopped, } from "./outcomes.js";
|
|
13
9
|
import { colorEnvironment, commandEnvironment, runPayload } from "./payload.js";
|
|
14
10
|
import { LOOKUP } from "./resource-definition-set.js";
|
|
15
|
-
import { acquireResources, announceAcquired,
|
|
11
|
+
import { acquireResources, announceAcquired, resourceInstances, resourcesCredentials, resourcesPayload, resourcesRan, resourceWarnings, startResourceLanes, } from "./resources.js";
|
|
16
12
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* Runs `request.argv` with the resources it asks for, through `definitionSet`'s resource definitions, in definition
|
|
14
|
+
* order. Releases every resource instance in reverse order however the run ends, and reports cleanup completion.
|
|
19
15
|
*/
|
|
20
|
-
export async function
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
export async function executeRun(definitionSet, context, resourceContexts, request, control, progress) {
|
|
17
|
+
const instances = resourceInstances(definitionSet[LOOKUP], resourceContexts, request.resources);
|
|
18
|
+
await emitRunOpening(progress, {
|
|
23
19
|
version: request.version,
|
|
24
20
|
commit: request.commit,
|
|
25
21
|
configFile: request.configFile,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return { ok: false, outcome: { kind: "mint_failed", failure: minted.failure.failure, target, runner: true } };
|
|
53
|
-
const project = minted.credential.vercelProject();
|
|
54
|
-
if (project === undefined)
|
|
55
|
-
return {
|
|
56
|
-
ok: false,
|
|
57
|
-
outcome: { kind: "runner_failed", failure: { kind: "credential-claims-missing", target } },
|
|
58
|
-
};
|
|
59
|
-
if (signal.aborted)
|
|
60
|
-
return { ok: false, outcome: canceled() };
|
|
61
|
-
return { ok: true, mint, access: { credential: minted.credential, ...project } };
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Runs `request.argv` in `session` with `request.runPayload`, pumping test events in arrival order and mapping sandbox
|
|
65
|
-
* exit/kill/failure outcomes into `RanCommand` or `RunStopped`. Every run shares it, across runner sandboxes or not.
|
|
66
|
-
*/
|
|
67
|
-
export async function runCommandInSandbox(session, request, signal, progress, onStarted) {
|
|
68
|
-
await progress.emit({ kind: "command-started", argv: request.argv });
|
|
69
|
-
if (signal.aborted)
|
|
70
|
-
return { ok: false, outcome: { ...canceledStop(), commandStopped: false } };
|
|
71
|
-
onStarted?.();
|
|
72
|
-
// Test events arrive from a callback that can't wait, so they are emitted in order through a chain.
|
|
73
|
-
let testEvents = Promise.resolve();
|
|
74
|
-
const sandboxed = await session.runCommand({
|
|
75
|
-
argv: request.argv,
|
|
76
|
-
runPayload: request.runPayload,
|
|
77
|
-
...(request.credentials === undefined ? {} : { credentials: request.credentials }),
|
|
78
|
-
testEvents: {
|
|
79
|
-
onLine: (line) => {
|
|
80
|
-
const event = parseTestEvent(line);
|
|
81
|
-
testEvents = testEvents.then(() => progress.emit(event === undefined ? { kind: "test-event-unreadable" } : { kind: "test", event }));
|
|
82
|
-
},
|
|
83
|
-
onIncomplete: (message) => {
|
|
84
|
-
testEvents = testEvents.then(() => progress.emit({ kind: "test-events-incomplete", message }));
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
await testEvents;
|
|
89
|
-
// Closing on a signal can stop the runner sandbox under the command, so a failed call then is the stop too.
|
|
90
|
-
if (sandboxed.kind === "killed" || (sandboxed.kind === "failed" && signal.aborted))
|
|
91
|
-
return { ok: false, outcome: { ...canceledStop(), commandStopped: true } };
|
|
92
|
-
if (sandboxed.kind === "failed")
|
|
93
|
-
return { ok: false, outcome: { kind: "runner_failed", failure: sandboxed.failure } };
|
|
94
|
-
const command = sandboxed.exitCode === null ? { kind: "no-exit-code" } : { kind: "exited", code: sandboxed.exitCode };
|
|
95
|
-
await progress.emit({
|
|
96
|
-
kind: "command-ended",
|
|
97
|
-
command: posix.basename(request.argv[0] ?? ""),
|
|
98
|
-
outcome: command,
|
|
99
|
-
ms: sandboxed.ms,
|
|
100
|
-
});
|
|
101
|
-
return { ok: true, command };
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Runs `body` with idempotent `startCleanup` / `release` hooks, guarantees every acquired resource instance is
|
|
105
|
-
* released in `finally`, and returns both `body`'s result and the collected `resourceCleanup`.
|
|
106
|
-
*/
|
|
107
|
-
export async function withResourceCleanup(instances, keepMs, progress, body) {
|
|
108
|
-
let cleanupStarted = false;
|
|
109
|
-
// Said once, before the runner's sandboxes are fenced in a sandboxed run, else before the resources are released,
|
|
110
|
-
// with how long cleanup keeps the runner sandbox running, if the run has one (`keepMs`, null for a run with no runner).
|
|
111
|
-
const startCleanup = async () => {
|
|
112
|
-
if (cleanupStarted)
|
|
113
|
-
return;
|
|
114
|
-
cleanupStarted = true;
|
|
115
|
-
await progress.emit({ kind: "cleanup-started", keepMs, resources: releasedResources(instances) });
|
|
116
|
-
};
|
|
117
|
-
let resourceCleanup = {};
|
|
118
|
-
let releasing;
|
|
119
|
-
// Once: reporting cleanup's start can fail, and releasing what the acquires took must not depend on it. The first
|
|
120
|
-
// call's `runner` is the one every release gets: whether the launcher fenced the run's runner sandbox.
|
|
121
|
-
const release = (runner) => (releasing ??= (async () => {
|
|
122
|
-
try {
|
|
123
|
-
await startCleanup();
|
|
124
|
-
}
|
|
125
|
-
finally {
|
|
126
|
-
resourceCleanup = await releaseResources(instances, progress, runner);
|
|
22
|
+
...(request.skipped === undefined ? {} : { skipped: request.skipped }),
|
|
23
|
+
...(request.runner.kind === "vercel-sandbox" ? { runner: request.runner.session } : {}),
|
|
24
|
+
}, instances);
|
|
25
|
+
const keepMs = request.runner.kind === "vercel-sandbox" ? request.runner.session.keepMs : null;
|
|
26
|
+
const { value: { ended, runnerCleanup }, resourceCleanup, } = await withResourceCleanup(instances, keepMs, progress, async (cleanup) => {
|
|
27
|
+
switch (request.runner.kind) {
|
|
28
|
+
case "launch-machine":
|
|
29
|
+
return {
|
|
30
|
+
ended: await runOnLaunchMachine(context, request.runner, {
|
|
31
|
+
argv: request.argv,
|
|
32
|
+
verbose: request.verbose,
|
|
33
|
+
instances,
|
|
34
|
+
control,
|
|
35
|
+
progress,
|
|
36
|
+
}),
|
|
37
|
+
runnerCleanup: null,
|
|
38
|
+
};
|
|
39
|
+
case "vercel-sandbox":
|
|
40
|
+
return await runInVercelSandboxSession(context, request.runner, {
|
|
41
|
+
argv: request.argv,
|
|
42
|
+
verbose: request.verbose,
|
|
43
|
+
instances,
|
|
44
|
+
control,
|
|
45
|
+
progress,
|
|
46
|
+
cleanup,
|
|
47
|
+
});
|
|
127
48
|
}
|
|
128
|
-
})
|
|
129
|
-
let value;
|
|
130
|
-
try {
|
|
131
|
-
value = await body({ startCleanup, release });
|
|
132
|
-
}
|
|
133
|
-
finally {
|
|
134
|
-
// A run with no runner (`keepMs` null) has nothing to fence, so the release hears true. With a runner this is a
|
|
135
|
-
// no-op: its runner session released the resources once it fenced its sandboxes, saying whether it fenced the runner
|
|
136
|
-
// sandbox. Should a session ever end without releasing, nothing has confirmed the fence, so the release hears false.
|
|
137
|
-
await release({ runnerSandboxFenced: keepMs === null });
|
|
138
|
-
}
|
|
139
|
-
return { value, resourceCleanup };
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Runs `request.argv` with the resources it asks for, through `definitionSet`'s resource definitions, in definition
|
|
143
|
-
* order. Each resource's `beforeRun` has run already, before the run started: the request holds what it answered. It
|
|
144
|
-
* says each resource `beforeRun` skipped right after it starts (`resource-skipped`), acquires the other resource
|
|
145
|
-
* instances all at once through their `acquireForRun` (`acquireResources`), says each acquired (`resource-acquired`),
|
|
146
|
-
* runs the command with the run payload in `STORM_RUN`, waits for it, and hands each instance what its acquire took to
|
|
147
|
-
* its `releaseAfterRun`. It reports each step to `progress`. What acquiring and releasing do is each resource
|
|
148
|
-
* definition's own: see its lifecycle. A run that asks for no resource goes straight to its command. It calls each
|
|
149
|
-
* definition's lifecycle with its own Context from `resourceContexts`, and hands `context` to none.
|
|
150
|
-
*
|
|
151
|
-
* In a sandboxed run (`request.runner`), the command runs in a runner sandbox, readied beside the resources (see
|
|
152
|
-
* `runSandboxed`).
|
|
153
|
-
*
|
|
154
|
-
* Release happens however the run ended, a throw included: once the command has stopped and, in a sandboxed run, the
|
|
155
|
-
* runner session has fenced the run's sandboxes, each resource instance is released in reverse order, even when the
|
|
156
|
-
* `cleanup-started` event can't be reported. An unsandboxed run releases them in `finally`; a sandboxed run's runner
|
|
157
|
-
* session does, as it finishes or closes, between the fence and the scope's close: the fence stops every sandbox the
|
|
158
|
-
* run doesn't keep and leaves the runner sandbox it keeps with no network access; the close then deletes the stopped
|
|
159
|
-
* sandboxes and keeps the kept one running. Each release hears whether the launcher fenced the run's runner sandbox
|
|
160
|
-
* (`ReleaseAfterRunInput.runnerSandboxFenced`): what the runner session says once the fence answered, and true in an
|
|
161
|
-
* unsandboxed run, which has nothing to fence.
|
|
162
|
-
*/
|
|
163
|
-
export async function executeRun(definitionSet, context, resourceContexts, request, control, progress) {
|
|
164
|
-
const instances = resourceInstances(definitionSet[LOOKUP], resourceContexts, request.resources);
|
|
165
|
-
await emitRunOpening(progress, request, instances);
|
|
166
|
-
// Each instance keeps what its acquire took, as `acquireForRun` hands it over: the run releases all of it however
|
|
167
|
-
// it ends.
|
|
168
|
-
const keepMs = request.runner === undefined ? null : request.runner.keepMs;
|
|
169
|
-
const { value: { ended, runnerCleanup }, resourceCleanup, } = await withResourceCleanup(instances, keepMs, progress, async (cleanup) => request.runner === undefined
|
|
170
|
-
? { ended: await runUnsandboxed(context, request, instances, control, progress), runnerCleanup: null }
|
|
171
|
-
: await runSandboxed(context, request, instances, control, progress, cleanup));
|
|
49
|
+
});
|
|
172
50
|
await progress.emit({
|
|
173
51
|
kind: "cleanup-finished",
|
|
174
52
|
resourceWarnings: resourceWarnings(resourceCleanup),
|
|
@@ -185,42 +63,31 @@ export async function executeRun(definitionSet, context, resourceContexts, reque
|
|
|
185
63
|
resourceCleanup,
|
|
186
64
|
};
|
|
187
65
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
* all are. The credential source its request names is built once (`credentialSourceFor`), reporting each mint and token
|
|
192
|
-
* request as the run's own event, and handed to every instance; the mint is lazy, so a run mints only when a resource
|
|
193
|
-
* asks for a credential.
|
|
194
|
-
* The command's stdout and stderr reach `runnerTerminal` a line at a time per stream, and its environment says whether
|
|
195
|
-
* to color them (`colorEnvironment`), since the command writes to pipes. A run with no runner has no firewall, so a
|
|
196
|
-
* resource that answered sandbox credentials throws: the launcher refuses such a run before it starts.
|
|
197
|
-
*/
|
|
198
|
-
async function runUnsandboxed(context, request, instances, control, progress) {
|
|
66
|
+
async function runOnLaunchMachine(context, runner, input) {
|
|
67
|
+
const { argv, verbose, instances, control, progress } = input;
|
|
68
|
+
await startResourceLanes(instances, progress);
|
|
199
69
|
const acquisition = await acquireResources(instances, {
|
|
200
|
-
credential:
|
|
201
|
-
|
|
70
|
+
credential: runner.credential === undefined ? undefined : credentialSourceFor(runner.credential, context, progress),
|
|
71
|
+
cancelSignal: control.signal,
|
|
202
72
|
progress,
|
|
203
73
|
});
|
|
204
74
|
if (acquisition.kind === "stopped")
|
|
205
75
|
return acquisition.outcome;
|
|
206
|
-
|
|
207
|
-
|
|
76
|
+
if (acquisition.kind !== "acquired")
|
|
77
|
+
return canceledStop();
|
|
208
78
|
const crediting = resourcesCredentials(instances);
|
|
209
79
|
if (crediting.length > 0)
|
|
210
80
|
throw new Error(`resource ${crediting[0]?.resource ?? ""} answered sandbox credentials in a run with no runner sandbox; its beforeRun must say it needs one`);
|
|
211
81
|
await announceAcquired(instances, progress);
|
|
212
82
|
const terminal = context.runnerTerminal;
|
|
213
|
-
const env = commandEnvironment(colorEnvironment(
|
|
214
|
-
...(
|
|
215
|
-
...(
|
|
83
|
+
const env = commandEnvironment(colorEnvironment(runner.env, terminal.color), runPayload(resourcesPayload(instances), {
|
|
84
|
+
...(runner.testEvents === undefined ? {} : { testEvents: runner.testEvents }),
|
|
85
|
+
...(verbose === undefined ? {} : { verbose }),
|
|
216
86
|
}));
|
|
217
|
-
await progress.emit({ kind: "command-started", argv
|
|
218
|
-
// A signal during either progress write must still keep the command from starting.
|
|
87
|
+
await progress.emit({ kind: "command-started", argv });
|
|
219
88
|
if (control.signal.aborted)
|
|
220
89
|
return canceledStop();
|
|
221
90
|
const commandStartedAt = context.clock.now();
|
|
222
|
-
// The command's output reaches the terminal a line at a time per stream, as a sandboxed run's does, the rest once it
|
|
223
|
-
// ends.
|
|
224
91
|
const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
|
|
225
92
|
const write = (stream, text) => {
|
|
226
93
|
if (text === "")
|
|
@@ -231,7 +98,7 @@ async function runUnsandboxed(context, request, instances, control, progress) {
|
|
|
231
98
|
terminal.writeStderr(text);
|
|
232
99
|
};
|
|
233
100
|
const command = await context.commands.run({
|
|
234
|
-
argv
|
|
101
|
+
argv,
|
|
235
102
|
env,
|
|
236
103
|
terminate: control.terminate,
|
|
237
104
|
onOutput: ({ stream, data }) => write(stream, splitters[stream].push(data)),
|
|
@@ -240,43 +107,21 @@ async function runUnsandboxed(context, request, instances, control, progress) {
|
|
|
240
107
|
write("stdout", splitters.stdout.flush());
|
|
241
108
|
write("stderr", splitters.stderr.flush());
|
|
242
109
|
if (command.kind === "spawn-failed")
|
|
243
|
-
return { kind: "spawn_failed", executable:
|
|
110
|
+
return { kind: "spawn_failed", executable: argv[0] ?? "", message: command.message };
|
|
244
111
|
await progress.emit({
|
|
245
112
|
kind: "command-ended",
|
|
246
|
-
command: posix.basename(
|
|
113
|
+
command: posix.basename(argv[0] ?? ""),
|
|
247
114
|
outcome: command,
|
|
248
115
|
ms: commandEndedAt.getTime() - commandStartedAt.getTime(),
|
|
249
116
|
});
|
|
250
117
|
return { kind: "command-ended", resources: resourcesRan(instances), command, runner: undefined };
|
|
251
118
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
function runnerLaneOutcome(outcome) {
|
|
255
|
-
if (outcome.kind === "ready")
|
|
256
|
-
return "ready";
|
|
257
|
-
return outcome.kind === "aborted" ? "stopped" : "failed";
|
|
258
|
-
}
|
|
259
|
-
/** The outcome a runner that couldn't get ready ends the run with; undefined when it is ready or was stopped. */
|
|
260
|
-
function runnerStopped(outcome) {
|
|
261
|
-
if (outcome.kind === "failed")
|
|
262
|
-
return { kind: "runner_failed", failure: outcome.failure };
|
|
263
|
-
if (outcome.kind === "snapshot-gone")
|
|
264
|
-
return { kind: "snapshot_gone", entry: outcome.entry, removal: outcome.removal };
|
|
265
|
-
return undefined;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* In a sandboxed run, everything between the run's start and releasing its resources. It opens the run's runner session
|
|
269
|
-
* (`openRunnerSession`) before the mint, which owns the runner's sandbox scope and the order its stages run in, runs
|
|
270
|
-
* `runInSandbox` in it, and cleans up the session, which fences the run's sandboxes, releases the resources, saying
|
|
271
|
-
* whether it fenced the runner sandbox, and closes the scope. A run that throws cleans up the session in `finally`,
|
|
272
|
-
* which does the same. A sandboxed run always mints, whatever its resources are, so its request names no credential
|
|
273
|
-
* source: the command layer refuses `--credential github-actions` with it.
|
|
274
|
-
*/
|
|
275
|
-
async function runSandboxed(context, request, instances, control, progress, cleanup) {
|
|
119
|
+
async function runInVercelSandboxSession(context, runner, input) {
|
|
120
|
+
const { argv, verbose, instances, control, progress, cleanup } = input;
|
|
276
121
|
const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
|
|
277
|
-
const session = openRunnerSession(context,
|
|
122
|
+
const session = openRunnerSession(context, runner.session, { signal: control.signal, cleanup }, runnerProgress);
|
|
278
123
|
try {
|
|
279
|
-
const ended = await
|
|
124
|
+
const ended = await runInVercelSandbox(context, runner, { argv, verbose, instances, session, control, progress });
|
|
280
125
|
return { ended, runnerCleanup: await session.cleanUp() };
|
|
281
126
|
}
|
|
282
127
|
finally {
|
|
@@ -284,57 +129,71 @@ async function runSandboxed(context, request, instances, control, progress, clea
|
|
|
284
129
|
await session.cleanUp();
|
|
285
130
|
}
|
|
286
131
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
* once, and hands the same source to the resources, so one that asks for a credential gets the one mint's outcome and
|
|
291
|
-
* the run reports no other mint. Then it acquires the resources and readies the runner sandbox at once (`readyBoth`),
|
|
292
|
-
* and runs the command in the runner sandbox once all are ready, saying each resource acquired first. The sandbox
|
|
293
|
-
* credentials the acquired resources answered (`Acquired.credentials`) go to the runner session, which has the firewall
|
|
294
|
-
* add each to the requests to its domain for the length of the command, beside the run's own; two credentials, of two
|
|
295
|
-
* resources or of a resource and the run's config (`runner.credentials`), for the same domain and header, or for one
|
|
296
|
-
* domain with different `requests`, throw before the command starts (`resourcesCredentials`).
|
|
297
|
-
*/
|
|
298
|
-
async function runInSandbox(context, request, instances, session, control, progress) {
|
|
299
|
-
const { runner } = request;
|
|
300
|
-
// Canceled before a command started in the runner sandbox.
|
|
301
|
-
const canceled = () => ({ ...canceledStop(), commandStopped: false });
|
|
302
|
-
const credential = await mintCredential(context, runner.target, control.signal, progress);
|
|
132
|
+
async function runInVercelSandbox(context, runner, input) {
|
|
133
|
+
const { argv, verbose, instances, session, control, progress } = input;
|
|
134
|
+
const credential = await obtainRunnerCredential(context, runner.credential, control.signal, progress);
|
|
303
135
|
if (!credential.ok)
|
|
304
136
|
return credential.outcome;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
137
|
+
await emitLanesStarted(instances, progress);
|
|
138
|
+
const setup = await coordinateSetup({
|
|
139
|
+
cancelSignal: control.signal,
|
|
140
|
+
runResources: async (stopSignal) => {
|
|
141
|
+
const acquired = await acquireResources(instances, {
|
|
142
|
+
credential: credential.mint,
|
|
143
|
+
cancelSignal: control.signal,
|
|
144
|
+
stopSignal,
|
|
145
|
+
progress,
|
|
146
|
+
});
|
|
147
|
+
if (acquired.kind === "acquired")
|
|
148
|
+
return { kind: "ready", value: undefined };
|
|
149
|
+
return acquired;
|
|
150
|
+
},
|
|
151
|
+
runRunner: async (stopSignal) => {
|
|
152
|
+
let readied;
|
|
153
|
+
let laneOutcome;
|
|
154
|
+
try {
|
|
155
|
+
readied = await session.ready(credential.access, AbortSignal.any([control.signal, stopSignal]));
|
|
156
|
+
laneOutcome = runnerLaneOutcome(readied);
|
|
157
|
+
await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: laneOutcome });
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (laneOutcome === undefined)
|
|
161
|
+
await progress
|
|
162
|
+
.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: "failed" })
|
|
163
|
+
.catch(() => undefined);
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
if (readied.kind === "ready")
|
|
167
|
+
return { kind: "ready", value: readied.runner };
|
|
168
|
+
const stopped = runnerStopped(readied);
|
|
169
|
+
if (stopped !== undefined)
|
|
170
|
+
return { kind: "stopped", outcome: stopped };
|
|
171
|
+
return control.signal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
if (setup.kind === "threw")
|
|
175
|
+
throw setup.error;
|
|
176
|
+
if (setup.kind === "stopped") {
|
|
177
|
+
const { outcome } = setup;
|
|
312
178
|
return outcome.kind === "canceled" ? { ...outcome, commandStopped: false } : outcome;
|
|
313
179
|
}
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
if (readied?.kind !== "ready")
|
|
317
|
-
return canceled();
|
|
318
|
-
const ready = readied.runner;
|
|
319
|
-
// Each sandbox credential a resource gives the command, which the runner session puts on the requests to its domain
|
|
320
|
-
// while the command runs; a clash with another resource's or the config's throws here, before the command starts.
|
|
321
|
-
const credentials = resourcesCredentials(instances, runner.credentials).map(({ credential }) => credential);
|
|
180
|
+
const ready = setup.runner;
|
|
181
|
+
const credentials = resourcesCredentials(instances, runner.session.credentials).map(({ credential: c }) => c);
|
|
322
182
|
await announceAcquired(instances, progress);
|
|
323
183
|
const ran = await runCommandInSandbox(session, {
|
|
324
|
-
argv
|
|
184
|
+
argv,
|
|
325
185
|
runPayload: JSON.stringify(runPayload(resourcesPayload(instances), {
|
|
326
186
|
testEvents: SANDBOX_TEST_EVENTS_PATH,
|
|
327
|
-
...(
|
|
187
|
+
...(verbose === undefined ? {} : { verbose }),
|
|
328
188
|
})),
|
|
329
189
|
credentials,
|
|
330
190
|
}, control.signal, progress);
|
|
331
191
|
if (!ran.ok)
|
|
332
192
|
return ran.outcome;
|
|
333
|
-
const { command } = ran;
|
|
334
193
|
return {
|
|
335
194
|
kind: "command-ended",
|
|
336
195
|
resources: resourcesRan(instances),
|
|
337
|
-
command,
|
|
196
|
+
command: ran.command,
|
|
338
197
|
runner: {
|
|
339
198
|
snapshotId: ready.snapshotId,
|
|
340
199
|
base: ready.base,
|
|
@@ -348,22 +207,3 @@ async function runInSandbox(context, request, instances, session, control, progr
|
|
|
348
207
|
},
|
|
349
208
|
};
|
|
350
209
|
}
|
|
351
|
-
/**
|
|
352
|
-
* Acquires the resources and readies the runner sandbox at once, through `acquireResources` with the runner lane
|
|
353
|
-
* beside the resources (`ready`, the runner session's): a resource's refusal or throw stops readying the runner, and
|
|
354
|
-
* the runner's failure stops acquiring the resources. Without any resource, the runner lane runs alone.
|
|
355
|
-
*/
|
|
356
|
-
async function readyBoth(request, control, progress) {
|
|
357
|
-
await progress.emit({ kind: "lanes-started" });
|
|
358
|
-
return await acquireResources(request.instances, {
|
|
359
|
-
credential: request.credential,
|
|
360
|
-
signal: control.signal,
|
|
361
|
-
progress,
|
|
362
|
-
beside: {
|
|
363
|
-
lane: { lane: "runner", resource: null },
|
|
364
|
-
start: request.ready,
|
|
365
|
-
outcomeOf: runnerLaneOutcome,
|
|
366
|
-
stopped: runnerStopped,
|
|
367
|
-
},
|
|
368
|
-
});
|
|
369
|
-
}
|
|
@@ -6,7 +6,7 @@ export declare function stateDirectoryPattern(subpath: readonly string[]): strin
|
|
|
6
6
|
/**
|
|
7
7
|
* Where one kind of state storm keeps lives: `subpath` under `$XDG_STATE_HOME/storm` when
|
|
8
8
|
* `XDG_STATE_HOME` is absolute, else under `$HOME/.local/state/storm`, which needs an absolute `HOME`. Each
|
|
9
|
-
* kind gets its own subdirectory: the run directories `["runs"]`, the
|
|
9
|
+
* kind gets its own subdirectory: the run directories `["runs"]`, the local snapshot index `["runner", "snapshots"]`.
|
|
10
10
|
* A relative `XDG_STATE_HOME` is ignored, as the XDG spec says. Without either, the directory can't be found, and
|
|
11
11
|
* `reason` says why.
|
|
12
12
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Where storm keeps its state: one directory under XDG's state home, with a subdirectory for each kind of state, such
|
|
2
|
-
// as the run directories (`runs`), the
|
|
2
|
+
// as the run directories (`runs`), the local snapshot index (`runner/snapshots`) and each resource's own, named for
|
|
3
3
|
// the resource (`launcherContext`, `launcher-context.ts`). It names no resource; each kind names its own
|
|
4
4
|
// subpath.
|
|
5
5
|
import { isAbsolute, join } from "node:path";
|
|
@@ -13,7 +13,7 @@ export function stateDirectoryPattern(subpath) {
|
|
|
13
13
|
/**
|
|
14
14
|
* Where one kind of state storm keeps lives: `subpath` under `$XDG_STATE_HOME/storm` when
|
|
15
15
|
* `XDG_STATE_HOME` is absolute, else under `$HOME/.local/state/storm`, which needs an absolute `HOME`. Each
|
|
16
|
-
* kind gets its own subdirectory: the run directories `["runs"]`, the
|
|
16
|
+
* kind gets its own subdirectory: the run directories `["runs"]`, the local snapshot index `["runner", "snapshots"]`.
|
|
17
17
|
* A relative `XDG_STATE_HOME` is ignored, as the XDG spec says. Without either, the directory can't be found, and
|
|
18
18
|
* `reason` says why.
|
|
19
19
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Credential, MintFailure, MintTarget, TokenAttemptFailure } from "../sdk/extension/index.ts";
|
|
1
|
+
import type { Credential, MintFailure, MintTarget, TokenAttemptFailure, VercelOidcTokenFailure } from "../sdk/extension/index.ts";
|
|
2
2
|
export type MintOutcome = {
|
|
3
3
|
readonly ok: true;
|
|
4
4
|
readonly credential: Credential;
|
|
@@ -28,3 +28,17 @@ export type TokenAttemptOutcome = {
|
|
|
28
28
|
export interface GitHubActionsTokenGateway {
|
|
29
29
|
request(): Promise<TokenAttemptOutcome>;
|
|
30
30
|
}
|
|
31
|
+
export type VercelOidcTokenOutcome = {
|
|
32
|
+
readonly ok: true;
|
|
33
|
+
readonly credential: Credential;
|
|
34
|
+
} | {
|
|
35
|
+
readonly ok: false;
|
|
36
|
+
readonly failure: VercelOidcTokenFailure;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Reads a pre-minted Vercel project OIDC token from `VERCEL_OIDC_TOKEN`. Never rejects: every failure is a
|
|
40
|
+
* `VercelOidcTokenFailure`. Domain logic validates the JWT claims (`vercelOidcSource`).
|
|
41
|
+
*/
|
|
42
|
+
export interface VercelOidcTokenGateway {
|
|
43
|
+
read(): Promise<VercelOidcTokenOutcome>;
|
|
44
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { Credential, type CredentialDiagnosis, type CredentialFailure, type CredentialOrigin, type CredentialOutcome, type CredentialSource, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, type GitHubActionsClaims, type MintFailure, type MintStep, type MintTarget, type TokenAttemptFailure, type TokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, type TokenRequestVariable, type VercelProject, } from "../sdk/extension/index.ts";
|
|
2
|
-
export type { CredentialGateway, GitHubActionsTokenGateway, MintOutcome, TokenAttemptOutcome } from "./gateways.ts";
|
|
1
|
+
export { Credential, type CredentialDiagnosis, type CredentialFailure, type CredentialOrigin, type CredentialOutcome, type CredentialSource, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, describeVercelOidcTokenFailure, type GitHubActionsClaims, type MintFailure, type MintStep, type MintTarget, type TokenAttemptFailure, type TokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, type TokenRequestVariable, type VercelOidcTokenFailure, vercelOidcTokenFailureFacts, vercelOidcTokenFailureShape, type VercelProject, } from "../sdk/extension/index.ts";
|
|
2
|
+
export type { CredentialGateway, GitHubActionsTokenGateway, MintOutcome, TokenAttemptOutcome, VercelOidcTokenGateway, VercelOidcTokenOutcome, } from "./gateways.ts";
|
|
3
3
|
export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gateway.ts";
|
|
4
4
|
export { liveCredentialGateway } from "./live/vercel-cli-gateway.ts";
|
|
5
|
+
export { liveVercelOidcTokenGateway } from "./live/vercel-oidc-token-gateway.ts";
|
|
5
6
|
export type { CredentialEvent, CredentialProgress } from "./events.ts";
|
|
6
|
-
export { type CredentialContext, type CredentialSourceChoice, credentialSourceFor, type MintSource, REQUESTING_TOKEN_LINE, } from "./source.ts";
|
|
7
|
+
export { type CredentialContext, type CredentialSourceChoice, credentialSourceFor, type MintSource, REQUESTING_TOKEN_LINE, type VercelOidcFailed, type VercelOidcSource, type VercelProjectOutcome, type VercelProjectSource, vercelProjectSource, } from "./source.ts";
|
|
7
8
|
export { mintTargetText } from "./target.ts";
|
package/dist/credential/index.js
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// their failures and how those are worded, which this surface re-exports for the launcher. It loads no Clinkr, at run
|
|
5
5
|
// time or in its declarations: the credential launcher resolver and the errors a command refuses with live in `config`
|
|
6
6
|
// (`credential-resolver.ts`, `credential-settle.ts`).
|
|
7
|
-
export { Credential, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, tokenRequestFailureFacts, tokenRequestFailureShape, } from "../sdk/extension/index.js";
|
|
7
|
+
export { Credential, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, describeVercelOidcTokenFailure, tokenRequestFailureFacts, tokenRequestFailureShape, vercelOidcTokenFailureFacts, vercelOidcTokenFailureShape, } from "../sdk/extension/index.js";
|
|
8
8
|
export { liveGitHubActionsTokenGateway } from "./live/github-actions-token-gateway.js";
|
|
9
9
|
export { liveCredentialGateway } from "./live/vercel-cli-gateway.js";
|
|
10
|
-
export {
|
|
10
|
+
export { liveVercelOidcTokenGateway } from "./live/vercel-oidc-token-gateway.js";
|
|
11
|
+
export { credentialSourceFor, REQUESTING_TOKEN_LINE, vercelProjectSource, } from "./source.js";
|
|
11
12
|
export { mintTargetText } from "./target.js";
|
|
@@ -11,7 +11,7 @@ export declare function liveCredentialGateway(): CredentialGateway;
|
|
|
11
11
|
/**
|
|
12
12
|
* The environment of a `vercel` invocation: `host` without `VERCEL_TOKEN`, with color and the update notifier off.
|
|
13
13
|
* `vercel` reads `VERCEL_TOKEN` when there's no `--token`, and then ignores its saved login. An inherited token, such
|
|
14
|
-
* as a test account's token that `
|
|
14
|
+
* as a test account's token that `vctest teams run` hands its command, would make `vercel` mint the credential as that
|
|
15
15
|
* identity, and not as the person or CI job that runs storm.
|
|
16
16
|
*/
|
|
17
17
|
export declare function vercelEnvironment(host: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
@@ -57,7 +57,7 @@ function runVercel(args) {
|
|
|
57
57
|
/**
|
|
58
58
|
* The environment of a `vercel` invocation: `host` without `VERCEL_TOKEN`, with color and the update notifier off.
|
|
59
59
|
* `vercel` reads `VERCEL_TOKEN` when there's no `--token`, and then ignores its saved login. An inherited token, such
|
|
60
|
-
* as a test account's token that `
|
|
60
|
+
* as a test account's token that `vctest teams run` hands its command, would make `vercel` mint the credential as that
|
|
61
61
|
* identity, and not as the person or CI job that runs storm.
|
|
62
62
|
*/
|
|
63
63
|
export function vercelEnvironment(host) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VercelOidcTokenGateway } from "../gateways.ts";
|
|
2
|
+
export interface LiveVercelOidcTokenOptions {
|
|
3
|
+
/** The environment `VERCEL_OIDC_TOKEN` is read from when `read()` is called. */
|
|
4
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads a pre-minted Vercel project OIDC token from `VERCEL_OIDC_TOKEN` in `options.env`, wrapping it in a
|
|
8
|
+
* `Credential` immediately so the raw token never leaves the credential. Never auto-detected without
|
|
9
|
+
* `--credential vercel-oidc`. Never rejects.
|
|
10
|
+
*/
|
|
11
|
+
export declare function liveVercelOidcTokenGateway(options: LiveVercelOidcTokenOptions): VercelOidcTokenGateway;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Credential } from "../../sdk/extension/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reads a pre-minted Vercel project OIDC token from `VERCEL_OIDC_TOKEN` in `options.env`, wrapping it in a
|
|
4
|
+
* `Credential` immediately so the raw token never leaves the credential. Never auto-detected without
|
|
5
|
+
* `--credential vercel-oidc`. Never rejects.
|
|
6
|
+
*/
|
|
7
|
+
export function liveVercelOidcTokenGateway(options) {
|
|
8
|
+
return {
|
|
9
|
+
async read() {
|
|
10
|
+
const token = Object.hasOwn(options.env, "VERCEL_OIDC_TOKEN") ? options.env["VERCEL_OIDC_TOKEN"] : undefined;
|
|
11
|
+
if (token === undefined || token === "")
|
|
12
|
+
return { ok: false, failure: { kind: "missing-token" } };
|
|
13
|
+
return { ok: true, credential: new Credential(token) };
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|