@cnc-tools/storm 0.17.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 +37 -39
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-4WAMTUWZ.js → chunk-24UYAK4R.js} +88 -67
- package/dist/chunks/{chunk-RNAS7JHE.js → chunk-2JMWUKH3.js} +710 -102
- package/dist/chunks/{chunk-YEPFSLQR.js → chunk-3VXZONGE.js} +2 -2
- package/dist/chunks/{chunk-D27KILIA.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-JN3YY6ZH.js → chunk-AS37D43E.js} +27 -20
- package/dist/chunks/{chunk-2VP4GRJM.js → chunk-CQAY6GLP.js} +54 -13
- package/dist/chunks/{chunk-MR77L2GK.js → chunk-DZLU7BYK.js} +5 -5
- package/dist/chunks/{chunk-LKTZ5OXS.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-FNBB6V4R.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-RWIXDDCK.js → chunk-GUCCYCIO.js} +3 -3
- package/dist/chunks/{chunk-6UHIJXZG.js → chunk-HBI4LEMH.js} +2 -2
- package/dist/chunks/{chunk-CKGZA25H.js → chunk-K4MDQPLW.js} +1 -1
- package/dist/chunks/{chunk-F4MOYHRY.js → chunk-KK7PAWIZ.js} +1 -1
- package/dist/chunks/{chunk-GRT3UIBV.js → chunk-KQ5FXRUD.js} +1 -1
- package/dist/chunks/{chunk-WV3DP6NR.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-4O5C2XGJ.js → chunk-LOGHIUUB.js} +6 -6
- package/dist/chunks/{chunk-7DZE67QM.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-HWIQ2S7K.js → chunk-OI4AP6Z7.js} +3 -3
- package/dist/chunks/{chunk-DADEYJDW.js → chunk-PMBQWVTW.js} +6 -6
- package/dist/chunks/{chunk-HP3CURSZ.js → chunk-SZMYIIG2.js} +2 -2
- package/dist/chunks/{chunk-2RNDPDTJ.js → chunk-TXCOFC7N.js} +2 -2
- package/dist/chunks/{chunk-BCBKYOHW.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-M7EKRGVD.js → chunk-WNW2QXQK.js} +1 -1
- package/dist/chunks/{live-app-R76JQXZL.js → live-app-UY7BEDUN.js} +9 -7
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +1 -1
- package/dist/commands/exec/before-run.d.ts +1 -1
- package/dist/commands/exec/command.d.ts +36 -12
- package/dist/commands/exec/command.js +18 -18
- package/dist/commands/exec/execute-run.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +71 -15
- package/dist/commands/exec/outcomes.js +46 -6
- package/dist/commands/exec/plan-run.d.ts +1 -1
- package/dist/commands/exec/plan-run.js +8 -3
- package/dist/commands/exec/run-metadata.js +1 -1
- package/dist/commands/exec/run-summary.js +1 -1
- package/dist/commands/runs/facts.d.ts +1 -1
- package/dist/commands/runs/facts.js +2 -2
- package/dist/commands/runs/list/command.d.ts +2 -2
- package/dist/commands/runs/list/command.js +9 -9
- package/dist/commands/runs/list/outcomes.d.ts +1 -1
- package/dist/commands/runs/logs/command.js +9 -9
- package/dist/commands/runs/show/command.d.ts +2 -2
- package/dist/commands/runs/show/command.js +16 -16
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +1 -1
- package/dist/commands/runs/show/outcomes.js +1 -1
- package/dist/commands/snapshots/build/command.d.ts +22 -14
- package/dist/commands/snapshots/build/command.js +32 -30
- package/dist/commands/snapshots/build/metadata.js +1 -1
- package/dist/commands/snapshots/build/outcomes.d.ts +14 -10
- package/dist/commands/snapshots/build/outcomes.js +1 -1
- package/dist/commands/snapshots/list/command.d.ts +2 -2
- package/dist/commands/snapshots/list/command.js +19 -19
- package/dist/commands/snapshots/list/outcomes.d.ts +2 -2
- package/dist/commands/snapshots/list/outcomes.js +3 -3
- package/dist/commands/snapshots/prune/command.js +14 -14
- package/dist/commands/suites/list/command.js +10 -10
- package/dist/commands/test/command.d.ts +36 -12
- package/dist/commands/test/command.js +20 -20
- package/dist/commands/test/outcomes.d.ts +18 -6
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/toolchain.d.ts +13 -3
- package/dist/config-file/toolchain.js +41 -5
- package/dist/context.d.ts +3 -1
- package/dist/context.js +2 -1
- package/dist/core/outcomes.d.ts +1 -1
- package/dist/core/run.js +1 -1
- package/dist/extension-commands.d.ts +2 -7
- package/dist/extension-commands.js +3 -17
- package/dist/extensions/testserver/commands/pool/create/command.js +3 -3
- package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
- package/dist/run-directory/recording.js +1 -1
- package/dist/run-directory/run-record.d.ts +5 -5
- package/dist/run-directory/run-record.js +5 -5
- package/dist/runner/build-snapshots.d.ts +5 -0
- package/dist/runner/build-snapshots.js +11 -5
- package/dist/runner/gateways.d.ts +37 -4
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +5 -4
- package/dist/runner/index.js +3 -2
- 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-gateway.js +12 -2
- package/dist/runner/live/snapshot-records.js +10 -9
- package/dist/runner/local-snapshot-index.d.ts +11 -5
- package/dist/runner/local-snapshot-index.js +13 -14
- package/dist/runner/ready.d.ts +1 -1
- package/dist/runner/ready.js +1 -1
- package/dist/runner/scope.d.ts +5 -2
- package/dist/runner/scope.js +6 -2
- package/dist/runner/secrets.d.ts +37 -14
- package/dist/runner/secrets.js +218 -25
- package/dist/runner/session.js +3 -0
- package/dist/runner/shared-snapshot-entry.d.ts +3 -3
- package/dist/runner/shared-snapshot-entry.js +4 -4
- package/dist/runner/shared-snapshot-list.d.ts +1 -1
- package/dist/runner/shared-snapshot-list.js +1 -1
- package/dist/runner/shared-snapshot-lookup.d.ts +1 -1
- package/dist/runner/shared-snapshot-lookup.js +1 -1
- package/dist/runner/snapshot-build.js +54 -25
- package/dist/runner/snapshot-choice.js +1 -0
- package/dist/runner/snapshot-inspect.js +2 -5
- package/dist/runner/snapshot-key.d.ts +21 -7
- package/dist/runner/snapshot-key.js +31 -7
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- package/dist/runner/vercel-sandbox-check.d.ts +2 -0
- package/dist/runner/vercel-sandbox-check.js +6 -2
- package/dist/runner/vercel-sandbox-options.d.ts +36 -6
- package/dist/runner/vercel-sandbox-options.js +62 -19
- package/dist/runner/vercel-sandbox-secrets.d.ts +55 -6
- package/dist/runner/vercel-sandbox-secrets.js +142 -9
- package/dist/sdk/extension/commands.d.ts +3 -8
- package/dist/sdk/extension/commands.js +1 -3
- package/package.json +4 -3
- package/skills/overview.md +1 -1
- package/dist/application.d.ts +0 -30
- package/dist/application.js +0 -41
- package/dist/bin/run.d.ts +0 -18
- package/dist/bin/run.js +0 -31
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import { type SecretSource } from "../sdk/extension/index.ts";
|
|
2
|
+
import { type GhTokenFormat } from "./gh.ts";
|
|
2
3
|
import { type Report } from "./vercel-sandbox-check.ts";
|
|
4
|
+
export type { GhTokenFormat };
|
|
5
|
+
/**
|
|
6
|
+
* A Vercel-managed sandbox credential passed to `Sandbox.create({ credentials })`: Vercel Sandbox resolves the
|
|
7
|
+
* secret from the project's or team's Vercel environment variables and injects it through the Sandbox firewall, so the
|
|
8
|
+
* secret never sits on the launch machine or inside the sandbox.
|
|
9
|
+
*/
|
|
10
|
+
export type ManagedCredential = "npm";
|
|
11
|
+
/**
|
|
12
|
+
* Reads a GitHub credential on the launch machine from `gh auth token --hostname <host>`, or from an optional launcher
|
|
13
|
+
* environment variable `env` when set (such as `GITHUB_TOKEN` in CI). Always produces the `authorization` header
|
|
14
|
+
* (`Basic <base64(x-access-token:<token>)>` or `Bearer <token>`).
|
|
15
|
+
*/
|
|
16
|
+
export interface GhCredentialSource {
|
|
17
|
+
readonly kind: "gh";
|
|
18
|
+
/**
|
|
19
|
+
* Optional launcher environment variable override (such as `GITHUB_TOKEN` in CI). When set and non-empty, storm
|
|
20
|
+
* reads the raw token from it instead of invoking `gh auth token`.
|
|
21
|
+
*/
|
|
22
|
+
readonly env?: string;
|
|
23
|
+
/**
|
|
24
|
+
* GitHub hostname passed to `gh auth token --hostname <host>`. Bare hostname, defaulting to `"github.com"`.
|
|
25
|
+
*/
|
|
26
|
+
readonly host?: string;
|
|
27
|
+
/**
|
|
28
|
+
* How storm frames the token in the `authorization` header: `"basic"` (`Basic <base64(x-access-token:<token>)>`, for
|
|
29
|
+
* Git over HTTPS) or `"bearer"` (`Bearer <token>`, for REST and GraphQL APIs). Defaults to `"basic"` when `domain`
|
|
30
|
+
* matches `host` (such as `"github.com"`), and `"bearer"` otherwise (such as `"api.github.com"`).
|
|
31
|
+
*/
|
|
32
|
+
readonly format?: GhTokenFormat;
|
|
33
|
+
}
|
|
34
|
+
/** Where storm reads a sandbox credential's value on the launch machine (`runner.credentials`). */
|
|
35
|
+
export type SandboxCredentialSource = SecretSource | GhCredentialSource;
|
|
3
36
|
/**
|
|
4
37
|
* One sandbox credential declared in `runner.credentials`: a header the Sandbox firewall adds to a sandbox's requests
|
|
5
38
|
* to one domain while the runner's steps and the command run, with its value read from `source` as the run starts. The
|
|
@@ -13,14 +46,16 @@ export interface CredentialDeclaration {
|
|
|
13
46
|
readonly domain: string;
|
|
14
47
|
/**
|
|
15
48
|
* The header's name; `authorization` by default. storm matches it case-insensitively and sends it in lowercase. It
|
|
16
|
-
* can't be `host`, `content-length`, `transfer-encoding`, or `connection
|
|
49
|
+
* can't be `host`, `content-length`, `transfer-encoding`, or `connection`, and `{ kind: "gh" }` sources only set
|
|
50
|
+
* `authorization`.
|
|
17
51
|
*/
|
|
18
52
|
readonly header?: string;
|
|
19
53
|
/**
|
|
20
|
-
* Where storm reads the
|
|
21
|
-
*
|
|
54
|
+
* Where storm reads the credential on the launch machine: `{ kind: "env", name }` for a launcher environment variable
|
|
55
|
+
* holding the whole header value (such as `Bearer …` or `Basic …`), or `{ kind: "gh", env?, host?, format? }` for
|
|
56
|
+
* `gh auth token` (with an optional CI environment variable override).
|
|
22
57
|
*/
|
|
23
|
-
readonly source:
|
|
58
|
+
readonly source: SandboxCredentialSource;
|
|
24
59
|
/**
|
|
25
60
|
* Which requests to `domain` get the header: `read` (the default), `GET` and `HEAD` only, and the firewall answers
|
|
26
61
|
* every other request to `domain` with 403; or `all`, every request.
|
|
@@ -46,12 +81,26 @@ export interface UnsafeSecretEnvVar {
|
|
|
46
81
|
readonly source: SecretSource;
|
|
47
82
|
}
|
|
48
83
|
/**
|
|
49
|
-
*
|
|
50
|
-
* `"env
|
|
84
|
+
* A stable, value-free identity string for one `SandboxCredentialSource`, for hashing into runner snapshot keys:
|
|
85
|
+
* `"env:<name>"` for `{ kind: "env", name }`, and `"gh[:host=<host>][:env=<NAME>][:format=<format>]"` for
|
|
86
|
+
* `{ kind: "gh" }` (omitting `host` when it is the default `"github.com"`). Never contains secret values or file
|
|
87
|
+
* paths.
|
|
88
|
+
*/
|
|
89
|
+
export declare function sandboxCredentialSourceId(source: SandboxCredentialSource): string;
|
|
90
|
+
/**
|
|
91
|
+
* The sorted, unique sandbox credential source identities checked runner options' credentials and managed credentials
|
|
92
|
+
* read from (such as `"env:NPM_AUTH"`, `"gh"`, or `"managed:npm"`), for hashing into the runner snapshot key.
|
|
51
93
|
*/
|
|
52
94
|
export declare function credentialSourceIds(options: {
|
|
53
95
|
readonly credentials: readonly Required<CredentialDeclaration>[];
|
|
96
|
+
readonly managedCredentials?: readonly ManagedCredential[];
|
|
54
97
|
}): readonly string[];
|
|
98
|
+
/**
|
|
99
|
+
* Validates `runner.managedCredentials`: a list of distinct supported Vercel-managed credential providers (today
|
|
100
|
+
* `"npm"`). Refuses combining `"npm"` with a `runner.credentials` entry setting `authorization` on
|
|
101
|
+
* `registry.npmjs.org`, because a custom domain rule overrides the Vercel-managed npm header.
|
|
102
|
+
*/
|
|
103
|
+
export declare function checkManagedCredentials(value: unknown, credentials: readonly Required<CredentialDeclaration>[] | undefined, report: Report): readonly ManagedCredential[] | undefined;
|
|
55
104
|
/**
|
|
56
105
|
* The sandbox credentials: a list of `{ domain, header?, source, requests? }` (`checkCredential`), with no two going
|
|
57
106
|
* to the same domain and header, since the firewall sets each header once on a domain, and no two for one domain that
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
// `vercel-sandbox-options.ts` coordinates `checkVercelSandboxOptions` and delegates both secret keys here.
|
|
4
4
|
import { ENV_VAR_NAME_PATTERN, ENV_VAR_NAME_RULE, secretSourceId } from "../sdk/extension/index.js";
|
|
5
5
|
import { RUN_PAYLOAD_VARIABLE } from "../sdk/run/launcher.js";
|
|
6
|
+
import { DEFAULT_GH_HOST } from "./gh.js";
|
|
6
7
|
import { describeOptionValue, reportUnknownKeys } from "./vercel-sandbox-check.js";
|
|
7
8
|
const CREDENTIAL_KEYS = new Set(["domain", "header", "source", "requests"]);
|
|
9
|
+
const MANAGED_CREDENTIALS = new Set(["npm"]);
|
|
10
|
+
/** The default npm registry domain whose `authorization` header conflicts with Vercel-managed npm credentials. */
|
|
11
|
+
const MANAGED_NPM_DOMAIN = "registry.npmjs.org";
|
|
8
12
|
const UNSAFE_SECRET_ENV_VAR_KEYS = new Set(["name", "source"]);
|
|
9
13
|
const ENV_SOURCE_KEYS = new Set(["kind", "name"]);
|
|
14
|
+
const GH_SOURCE_KEYS = new Set(["kind", "env", "host", "format"]);
|
|
10
15
|
/** The header a credential goes to when it names none. */
|
|
11
16
|
const DEFAULT_CREDENTIAL_HEADER = "authorization";
|
|
12
17
|
/** A bare hostname: dot-separated labels of lowercase letters, digits, and inner hyphens, at least two of them. */
|
|
@@ -38,11 +43,78 @@ const RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES = new Set([
|
|
|
38
43
|
/** Prefixes of the dynamic loader's variables, which an unsafe secret environment variable's name can't start with. */
|
|
39
44
|
const RESERVED_UNSAFE_SECRET_ENV_VAR_PREFIXES = ["LD_", "DYLD_"];
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
42
|
-
* `"env
|
|
46
|
+
* A stable, value-free identity string for one `SandboxCredentialSource`, for hashing into runner snapshot keys:
|
|
47
|
+
* `"env:<name>"` for `{ kind: "env", name }`, and `"gh[:host=<host>][:env=<NAME>][:format=<format>]"` for
|
|
48
|
+
* `{ kind: "gh" }` (omitting `host` when it is the default `"github.com"`). Never contains secret values or file
|
|
49
|
+
* paths.
|
|
50
|
+
*/
|
|
51
|
+
export function sandboxCredentialSourceId(source) {
|
|
52
|
+
switch (source.kind) {
|
|
53
|
+
case "env":
|
|
54
|
+
return secretSourceId(source);
|
|
55
|
+
case "gh": {
|
|
56
|
+
const parts = ["gh"];
|
|
57
|
+
if (source.host !== undefined && source.host !== DEFAULT_GH_HOST)
|
|
58
|
+
parts.push(`host=${source.host}`);
|
|
59
|
+
if (source.env !== undefined)
|
|
60
|
+
parts.push(`env=${source.env}`);
|
|
61
|
+
if (source.format !== undefined)
|
|
62
|
+
parts.push(`format=${source.format}`);
|
|
63
|
+
return parts.join(":");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The sorted, unique sandbox credential source identities checked runner options' credentials and managed credentials
|
|
69
|
+
* read from (such as `"env:NPM_AUTH"`, `"gh"`, or `"managed:npm"`), for hashing into the runner snapshot key.
|
|
43
70
|
*/
|
|
44
71
|
export function credentialSourceIds(options) {
|
|
45
|
-
return [
|
|
72
|
+
return [
|
|
73
|
+
...new Set([
|
|
74
|
+
...options.credentials.map(({ source }) => sandboxCredentialSourceId(source)),
|
|
75
|
+
...(options.managedCredentials ?? []).map((provider) => `managed:${provider}`),
|
|
76
|
+
]),
|
|
77
|
+
].toSorted();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Validates `runner.managedCredentials`: a list of distinct supported Vercel-managed credential providers (today
|
|
81
|
+
* `"npm"`). Refuses combining `"npm"` with a `runner.credentials` entry setting `authorization` on
|
|
82
|
+
* `registry.npmjs.org`, because a custom domain rule overrides the Vercel-managed npm header.
|
|
83
|
+
*/
|
|
84
|
+
export function checkManagedCredentials(value, credentials, report) {
|
|
85
|
+
if (value === undefined)
|
|
86
|
+
return [];
|
|
87
|
+
if (!Array.isArray(value)) {
|
|
88
|
+
report(["managedCredentials"], `must be a list of Vercel-managed credentials, such as ["npm"], not ${describeOptionValue(value)}`);
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
let ok = true;
|
|
92
|
+
const checked = [];
|
|
93
|
+
const seen = new Set();
|
|
94
|
+
value.forEach((entry, index) => {
|
|
95
|
+
const path = ["managedCredentials", String(index)];
|
|
96
|
+
if (typeof entry !== "string" || !MANAGED_CREDENTIALS.has(entry)) {
|
|
97
|
+
report(path, `must be "npm", not ${describeOptionValue(entry)}`);
|
|
98
|
+
ok = false;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (seen.has(entry)) {
|
|
102
|
+
report(path, `names ${entry} again`);
|
|
103
|
+
ok = false;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
seen.add(entry);
|
|
107
|
+
checked.push(entry);
|
|
108
|
+
});
|
|
109
|
+
if (checked.includes("npm") && credentials !== undefined) {
|
|
110
|
+
credentials.forEach((credential, index) => {
|
|
111
|
+
if (credential.domain === MANAGED_NPM_DOMAIN && credential.header === DEFAULT_CREDENTIAL_HEADER) {
|
|
112
|
+
report(["credentials", String(index)], `can't set ${DEFAULT_CREDENTIAL_HEADER} on ${MANAGED_NPM_DOMAIN} when runner.managedCredentials includes "npm": a sandbox credential on ${MANAGED_NPM_DOMAIN} overrides the Vercel-managed npm token`);
|
|
113
|
+
ok = false;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return ok ? checked : undefined;
|
|
46
118
|
}
|
|
47
119
|
/**
|
|
48
120
|
* The sandbox credentials: a list of `{ domain, header?, source, requests? }` (`checkCredential`), with no two going
|
|
@@ -89,8 +161,9 @@ export function checkCredentials(value, report) {
|
|
|
89
161
|
}
|
|
90
162
|
/**
|
|
91
163
|
* One credential: `domain`, a bare hostname (`HOST_PATTERN`); `header`, an HTTP field name that neither the firewall
|
|
92
|
-
* nor HTTP sets (`REFUSED_HEADERS`), lowercased, `authorization` when absent
|
|
93
|
-
*
|
|
164
|
+
* nor HTTP sets (`REFUSED_HEADERS`), lowercased, `authorization` when absent (and required to be `authorization` for
|
|
165
|
+
* `{ kind: "gh" }`); `source`, a `SandboxCredentialSource` (`{ kind: "env", name }` or
|
|
166
|
+
* `{ kind: "gh", env?, host?, format? }`); and `requests`, `read` or `all`, `read` when absent.
|
|
94
167
|
*/
|
|
95
168
|
function checkCredential(value, path, report) {
|
|
96
169
|
if (!isPlainObject(value)) {
|
|
@@ -104,17 +177,24 @@ function checkCredential(value, path, report) {
|
|
|
104
177
|
ok = false;
|
|
105
178
|
}
|
|
106
179
|
const header = value["header"] === undefined ? DEFAULT_CREDENTIAL_HEADER : value["header"];
|
|
180
|
+
let headerValid = true;
|
|
107
181
|
if (typeof header !== "string" || !HEADER_PATTERN.test(header)) {
|
|
108
182
|
report([...path, "header"], `must be an HTTP header name, such as authorization, not ${describeOptionValue(header)}`);
|
|
109
183
|
ok = false;
|
|
184
|
+
headerValid = false;
|
|
110
185
|
}
|
|
111
186
|
else if (REFUSED_HEADERS.has(header.toLowerCase())) {
|
|
112
187
|
report([...path, "header"], `can't be ${header}: the firewall or HTTP sets it`);
|
|
113
188
|
ok = false;
|
|
189
|
+
headerValid = false;
|
|
114
190
|
}
|
|
115
|
-
const source =
|
|
191
|
+
const source = checkSandboxCredentialSource(value["source"], [...path, "source"], report);
|
|
116
192
|
if (source === undefined)
|
|
117
193
|
ok = false;
|
|
194
|
+
else if (headerValid && source.kind === "gh" && header.toLowerCase() !== DEFAULT_CREDENTIAL_HEADER) {
|
|
195
|
+
report([...path, "header"], `can't be ${header}: a gh credential always sets the authorization header`);
|
|
196
|
+
ok = false;
|
|
197
|
+
}
|
|
118
198
|
const requests = value["requests"] === undefined ? "read" : value["requests"];
|
|
119
199
|
if (requests !== "read" && requests !== "all") {
|
|
120
200
|
report([...path, "requests"], `must be "read" or "all", not ${describeOptionValue(requests)}`);
|
|
@@ -129,6 +209,49 @@ function checkCredential(value, path, report) {
|
|
|
129
209
|
}
|
|
130
210
|
: undefined;
|
|
131
211
|
}
|
|
212
|
+
/** One sandbox credential source: `{ kind: "env", name }` or `{ kind: "gh", env?, host?, format? }`. */
|
|
213
|
+
function checkSandboxCredentialSource(value, path, report) {
|
|
214
|
+
if (!isPlainObject(value)) {
|
|
215
|
+
report(path, `must be a sandbox credential source, { kind: "env", name } or { kind: "gh", env?, host?, format? }, not ${describeOptionValue(value)}`);
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
const kind = value["kind"];
|
|
219
|
+
if (kind === "env") {
|
|
220
|
+
return checkEnvSecretSource(value, path, report);
|
|
221
|
+
}
|
|
222
|
+
if (kind === "gh") {
|
|
223
|
+
return checkGhCredentialSource(value, path, report);
|
|
224
|
+
}
|
|
225
|
+
report([...path, "kind"], `must be "env" or "gh", not ${describeOptionValue(kind)}`);
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
/** Validates `{ kind: "gh", env?, host?, format? }`. */
|
|
229
|
+
function checkGhCredentialSource(value, path, report) {
|
|
230
|
+
let ok = reportUnknownKeys(value, GH_SOURCE_KEYS, path, "a sandbox credential source key", report);
|
|
231
|
+
const env = value["env"];
|
|
232
|
+
if (env !== undefined && (typeof env !== "string" || !ENV_VAR_NAME_PATTERN.test(env))) {
|
|
233
|
+
report([...path, "env"], `must be ${ENV_VAR_NAME_RULE}, not ${describeOptionValue(env)}`);
|
|
234
|
+
ok = false;
|
|
235
|
+
}
|
|
236
|
+
const host = value["host"];
|
|
237
|
+
if (host !== undefined && (typeof host !== "string" || !HOST_PATTERN.test(host))) {
|
|
238
|
+
report([...path, "host"], `must be a bare hostname, such as github.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, path, or wildcard, not ${describeOptionValue(host)}`);
|
|
239
|
+
ok = false;
|
|
240
|
+
}
|
|
241
|
+
const format = value["format"];
|
|
242
|
+
if (format !== undefined && format !== "basic" && format !== "bearer") {
|
|
243
|
+
report([...path, "format"], `must be "basic" or "bearer", not ${describeOptionValue(format)}`);
|
|
244
|
+
ok = false;
|
|
245
|
+
}
|
|
246
|
+
if (!ok)
|
|
247
|
+
return undefined;
|
|
248
|
+
return {
|
|
249
|
+
kind: "gh",
|
|
250
|
+
...(env === undefined ? {} : { env: env }),
|
|
251
|
+
...(host === undefined ? {} : { host: host }),
|
|
252
|
+
...(format === undefined ? {} : { format: format }),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
132
255
|
/** One secret source: a plain object with exact keys `{ kind: "env", name: <environment variable name> }`. */
|
|
133
256
|
function checkSecretSource(value, path, report) {
|
|
134
257
|
if (!isPlainObject(value)) {
|
|
@@ -141,7 +264,10 @@ function checkSecretSource(value, path, report) {
|
|
|
141
264
|
if (kind !== undefined)
|
|
142
265
|
return undefined;
|
|
143
266
|
}
|
|
144
|
-
|
|
267
|
+
return checkEnvSecretSource(value, path, report, kind === "env");
|
|
268
|
+
}
|
|
269
|
+
function checkEnvSecretSource(value, path, report, kindOk = true) {
|
|
270
|
+
let ok = kindOk;
|
|
145
271
|
if (!reportUnknownKeys(value, ENV_SOURCE_KEYS, path, "a secret source key", report))
|
|
146
272
|
ok = false;
|
|
147
273
|
const name = value["name"];
|
|
@@ -166,7 +292,14 @@ export function checkUnsafeSecretEnvVars(value, env, credentials, report) {
|
|
|
166
292
|
let ok = true;
|
|
167
293
|
const checked = [];
|
|
168
294
|
const seen = new Set();
|
|
169
|
-
const
|
|
295
|
+
const credentialEnvSources = new Set((credentials ?? []).flatMap(({ source }) => {
|
|
296
|
+
switch (source.kind) {
|
|
297
|
+
case "env":
|
|
298
|
+
return [secretSourceId(source)];
|
|
299
|
+
case "gh":
|
|
300
|
+
return source.env === undefined ? [] : [`env:${source.env}`];
|
|
301
|
+
}
|
|
302
|
+
}));
|
|
170
303
|
value.forEach((entry, index) => {
|
|
171
304
|
const path = ["unsafeSecretEnvVars", String(index)];
|
|
172
305
|
if (!isPlainObject(entry)) {
|
|
@@ -207,7 +340,7 @@ export function checkUnsafeSecretEnvVars(value, env, credentials, report) {
|
|
|
207
340
|
if (source === undefined) {
|
|
208
341
|
entryOk = false;
|
|
209
342
|
}
|
|
210
|
-
else if (
|
|
343
|
+
else if (credentialEnvSources.has(secretSourceId(source))) {
|
|
211
344
|
report([...path, "source"], `can't use ${secretSourceId(source)}: runner.credentials already reads it`);
|
|
212
345
|
entryOk = false;
|
|
213
346
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CommandTree, type
|
|
1
|
+
import { type CommandTree, type Mount } from "@vercel/clinkr";
|
|
2
2
|
export { type CommandMetadata, type CommandTree, commandTree, defineOutcomes, renderOutcome, type Row, type Warning, } from "@vercel/clinkr";
|
|
3
3
|
/**
|
|
4
4
|
* What an extension's author declares of its commands: its command tree, whose commands take `App`, the tree's own app;
|
|
@@ -33,17 +33,12 @@ export interface ExtensionCommands<LauncherApp> {
|
|
|
33
33
|
readonly mount: (placement: ExtensionCommandsPlacement) => Mount<LauncherApp>;
|
|
34
34
|
}
|
|
35
35
|
/** Where the launcher mounts an extension's commands: the launcher's choice, never the extension's. */
|
|
36
|
-
export
|
|
36
|
+
export interface ExtensionCommandsPlacement {
|
|
37
37
|
/** Where the tree's commands sit in `storm`, such as `["ext", "<name>"]`. */
|
|
38
38
|
readonly path: readonly string[];
|
|
39
39
|
/** Storm's code root (`src/` or `dist/`), which the tree's directory is under. */
|
|
40
40
|
readonly root: string;
|
|
41
|
-
}
|
|
42
|
-
/** Where the tree's commands sit in `storm`, such as `["ext", "<name>"]`. */
|
|
43
|
-
readonly path: readonly string[];
|
|
44
|
-
/** Pre-built static manifest entries for compiled or bundled builds. */
|
|
45
|
-
readonly manifest: Readonly<Record<string, ManifestEntry>>;
|
|
46
|
-
};
|
|
41
|
+
}
|
|
47
42
|
/** Declares an extension's commands. Only this function calls Clinkr's `mount`, since it knows the tree's app type. */
|
|
48
43
|
export declare function defineExtensionCommands<LauncherApp, App>(definition: ExtensionCommandsDefinition<LauncherApp, App>): ExtensionCommands<LauncherApp>;
|
|
49
44
|
/** A Clinkr example written as `{ argv, description? }`: the arguments after the command's name, and what it does. */
|
|
@@ -20,9 +20,7 @@ export function defineExtensionCommands(definition) {
|
|
|
20
20
|
return {
|
|
21
21
|
description,
|
|
22
22
|
directory,
|
|
23
|
-
mount: (
|
|
24
|
-
? mount(tree.manifest(placement.manifest), { path: placement.path, description, app })
|
|
25
|
-
: mount(tree.directory(join(placement.root, directory)), { path: placement.path, description, app }),
|
|
23
|
+
mount: ({ path, root }) => mount(tree.directory(join(root, directory)), { path, description, app }),
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
26
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnc-tools/storm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "A test orchestrator: run your tests in the inner loop of development, in the cloud, in a test environment that you define",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -127,10 +127,11 @@
|
|
|
127
127
|
"registry": "https://registry.npmjs.org/"
|
|
128
128
|
},
|
|
129
129
|
"dependencies": {
|
|
130
|
-
"@vercel/sandbox": "
|
|
130
|
+
"@vercel/sandbox": "5.0.0",
|
|
131
131
|
"zod": "^4.6.5"
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
|
+
"@cnc/vbx-clinkr-ts": "0.0.0",
|
|
134
135
|
"@playwright/test": "1.56.1",
|
|
135
136
|
"@types/node": "^24.19.1",
|
|
136
137
|
"@vercel/clinkr": "0.10.1",
|
|
@@ -159,7 +160,7 @@
|
|
|
159
160
|
},
|
|
160
161
|
"scripts": {
|
|
161
162
|
"build": "tsc -p tsconfig.build.json && node scripts/embed-testserver-sdk.js && node scripts/bundle.js && node scripts/write-build-info.js",
|
|
162
|
-
"build:bun-entry": "
|
|
163
|
+
"build:bun-entry": "vbx-clinkr entry --extras scripts/vbx-extras.ts",
|
|
163
164
|
"typecheck": "tsc --noEmit && tsc -p tsconfig.sdk.json",
|
|
164
165
|
"test": "pnpm run test:default && pnpm run test:integration",
|
|
165
166
|
"test:default": "vitest run --project default --project sanity",
|
package/skills/overview.md
CHANGED
|
@@ -21,7 +21,7 @@ storm finds `storm.config.ts` in the working directory or the nearest parent up
|
|
|
21
21
|
- A run is **active** while it goes on. A run is **finished** when it has ended and saved its test results. `runs show` shows test results only for a finished run.
|
|
22
22
|
- A **test result** is the final result of one test: `pass`, `fail`, or `skip`, with its errors. The command saves test results only with a storm reporter in the config of its test runner: `stormReporter` for vitest, `@vercel/storm/playwright/reporter` for Playwright. When the command of a `storm test` run exits 0 but reports no test result, the run warns `no_final_test_results`. The exit code does not change. Do the steps in its `next`: they name the config file and the code to add. Then run the same command again.
|
|
23
23
|
- **Test output** is what one test printed to the console, stdout and stderr together. storm keeps the last 8 MiB of the test output of each test. `droppedChars` counts the characters that storm did not keep.
|
|
24
|
-
- A **sandbox credential** is a secret that `credentials` in `vercelSandbox({ … })` declares, such as a token for a private npm registry: `credentials: [{ domain: "
|
|
24
|
+
- A **sandbox credential** is a secret that `credentials` in `vercelSandbox({ … })` declares, such as a token for a private npm registry or GitHub: `credentials: [{ domain: "github.com", requests: "all", source: { kind: "gh", env: "GITHUB_TOKEN" } }]` or `source: { kind: "env", name: "NPM_AUTH" }`. `source` is a `SandboxCredentialSource` plain object: `{ kind: "env", name }` reads the whole header value (such as `Bearer …` or `Basic …`) from a launcher environment variable, and `{ kind: "gh", env?, host?, format? }` reads a GitHub token from `gh auth token --hostname <host>` (`host` defaults to `"github.com"`) or from the optional `env` override (such as `GITHUB_TOKEN` in CI), framing it as `Basic <base64(x-access-token:<token>)>` when `domain` matches `host` and `Bearer <token>` otherwise (overridable via `format`). `header` is the name of the header, `authorization` by default (required for `{ kind: "gh" }`). `requests` is `read`, the default, for `GET` and `HEAD` only, or `all`. A run in a runner sandbox resolves the credential on the machine that starts the run. The run does not start, with `credentials_invalid`, when the source is missing, unreadable, unauthenticated, malformed, ambiguous, holds a line break, or has fewer than 8 characters. The value never goes into a sandbox: the firewall of the sandbox adds the header to the requests to the domain. Vercel calls this "credentials brokering". The credentials are in place for the toolchain and prebuild steps of a snapshot build, and from before the install step of a run until the command has ended. The upload and the apply step do not get them. A resource can give credentials too, for the command only. With `read`, the firewall refuses every other request to the domain. Code that runs while a credential is in place, the command included, can send requests with the header to the domain, but it cannot read the value. Each install must find the registry configuration that names the domain: `npm --prefix <dir>` reads the `.npmrc` of that directory, not the project's. storm shows the value (and every derived secret form) as `<token>` in all that it prints and writes, and does not write it to a file or a snapshot. A sandbox credential is not the credential that `--credential` picks, the Vercel OIDC token that storm uses for its own calls: the word has both uses until a rename.
|
|
25
25
|
- An **unsafe secret environment variable** is a secret declared in `unsafeSecretEnvVars` in `vercelSandbox({ … })` as `{ name, source: { kind: "env", name } }`, for a secret that cannot travel as an HTTPS header. A run in a runner sandbox reads `source` on the machine that starts the run and passes `name` into the command's environment alone, never into a step or a snapshot, and forbids keeping the runner sandbox. The run does not start, with `unsafe_secret_env_vars_invalid`, when the source variable is not set, is empty, holds a line break, or has fewer than 8 characters.
|
|
26
26
|
- An **allowed domain** is a domain that `allowedDomains` in `vercelSandbox({ … })` lists, such as `example.com` or `*.example.com`. With the list, the sandboxes of a run in a runner sandbox, every step and the command, reach only the allowed domains, and the domain of each sandbox credential while it is in place. A host outside them does not resolve: `curl` exits 6. A host that a resource gives the command must be in the list too. Without the list, every host is reachable.
|
|
27
27
|
- A **run log** is a log in the run directory. The **command log** (`command`) holds all the output of the command. It also holds output that no test owns: output from a `beforeAll`, a global setup, a raw `process.stdout.write`, or a child process. A **step log** (`install`, `build`, `apply`, `snapshot`) holds the output of one step of a run in a runner sandbox.
|
package/dist/application.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type ApplicationVersion, type ClinkrApplication, type Mount, type TreeGroup } from "@vercel/clinkr";
|
|
2
|
-
import type { StormApp } from "./context.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Where storm's commands, mounts, and skills come from: either resolved from `root` via `directoryStormSources`
|
|
5
|
-
* (`src/` from source, `dist/` built) for filesystem discovery, or pre-built static manifests and in-memory skills
|
|
6
|
-
* for a single-file compiled binary.
|
|
7
|
-
*/
|
|
8
|
-
export interface StormApplicationOptions {
|
|
9
|
-
/** Whether accessible mode is on (`VERCEL_ACCESSIBLE=1`), which leaves the help logo out of root help. */
|
|
10
|
-
readonly accessible: boolean;
|
|
11
|
-
/** Storm's own command tree: a directory group or a static manifest group. */
|
|
12
|
-
readonly commands: TreeGroup<StormApp>;
|
|
13
|
-
/** Each extension's mounted command tree. */
|
|
14
|
-
readonly mounts: readonly Mount<StormApp>[];
|
|
15
|
-
/** Storm's skill files: an absolute directory path, or an in-memory record of `<name>.md` to Markdown text. */
|
|
16
|
-
readonly skills: string | Readonly<Record<string, string>>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Resolves storm's command tree, extension mounts, and skills directory from `root`, storm's code root (`src/` from
|
|
20
|
-
* source, `dist/` built). The Node bin and source tests pass this to `loadStormApplication`, since a bundled build
|
|
21
|
-
* moves this module's code to another file, where `import.meta.dirname` names another directory.
|
|
22
|
-
*/
|
|
23
|
-
export declare function directoryStormSources(root: string): Omit<StormApplicationOptions, "accessible">;
|
|
24
|
-
/**
|
|
25
|
-
* Builds the `storm` Clinkr application from the given `commands`, `mounts`, and `skills` (from
|
|
26
|
-
* `directoryStormSources` for Node/source runs, or pre-built static manifests for compiled binaries). `version` is
|
|
27
|
-
* what root `--version` prints, the version and commit as a run's version line shows them (`versionText`), or a
|
|
28
|
-
* function Clinkr calls only to print it.
|
|
29
|
-
*/
|
|
30
|
-
export declare function loadStormApplication(version: ApplicationVersion, options: StormApplicationOptions): Promise<ClinkrApplication<StormApp>>;
|
package/dist/application.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { createApplication, } from "@vercel/clinkr";
|
|
3
|
-
import { stormCommands } from "./command-tree.js";
|
|
4
|
-
import { stormHelpLogo } from "./help-logo.js";
|
|
5
|
-
import { extensionMounts } from "./extension-commands.js";
|
|
6
|
-
const DESCRIPTION = [
|
|
7
|
-
"Run a project's tests in a test environment that storm sets up.",
|
|
8
|
-
"",
|
|
9
|
-
"Start with storm test, using the driver and suites declared in storm.config.ts, or storm exec to run any command.",
|
|
10
|
-
"",
|
|
11
|
-
"Docs: https://storm.playground-vercel.tools/",
|
|
12
|
-
].join("\n");
|
|
13
|
-
/**
|
|
14
|
-
* Resolves storm's command tree, extension mounts, and skills directory from `root`, storm's code root (`src/` from
|
|
15
|
-
* source, `dist/` built). The Node bin and source tests pass this to `loadStormApplication`, since a bundled build
|
|
16
|
-
* moves this module's code to another file, where `import.meta.dirname` names another directory.
|
|
17
|
-
*/
|
|
18
|
-
export function directoryStormSources(root) {
|
|
19
|
-
return {
|
|
20
|
-
commands: stormCommands.directory(join(root, "commands")),
|
|
21
|
-
mounts: extensionMounts(root),
|
|
22
|
-
skills: join(root, "../skills"),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Builds the `storm` Clinkr application from the given `commands`, `mounts`, and `skills` (from
|
|
27
|
-
* `directoryStormSources` for Node/source runs, or pre-built static manifests for compiled binaries). `version` is
|
|
28
|
-
* what root `--version` prints, the version and commit as a run's version line shows them (`versionText`), or a
|
|
29
|
-
* function Clinkr calls only to print it.
|
|
30
|
-
*/
|
|
31
|
-
export async function loadStormApplication(version, options) {
|
|
32
|
-
const { accessible, commands, mounts, skills } = options;
|
|
33
|
-
return await createApplication("storm", {
|
|
34
|
-
commands,
|
|
35
|
-
description: DESCRIPTION,
|
|
36
|
-
version,
|
|
37
|
-
helpLogo: (terminal) => stormHelpLogo(terminal, { accessible }),
|
|
38
|
-
mounts,
|
|
39
|
-
skills,
|
|
40
|
-
});
|
|
41
|
-
}
|
package/dist/bin/run.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ApplicationVersion } from "@vercel/clinkr";
|
|
2
|
-
import { type StormApplicationOptions } from "../application.ts";
|
|
3
|
-
/** Inputs for running the `storm` CLI from either the Node bin or the compiled Bun executable. */
|
|
4
|
-
export interface RunStormCliOptions {
|
|
5
|
-
readonly version: ApplicationVersion;
|
|
6
|
-
readonly buildInfo: () => Promise<{
|
|
7
|
-
readonly version: string;
|
|
8
|
-
readonly commit: string | null;
|
|
9
|
-
}>;
|
|
10
|
-
readonly sources: Omit<StormApplicationOptions, "accessible">;
|
|
11
|
-
}
|
|
12
|
-
/** Whether the global `--no-color` flag appears before a bare `--` in `argv`, matching Clinkr's global flag parse. */
|
|
13
|
-
export declare function hasNoColorFlag(argv: readonly string[]): boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Runs the `storm` CLI under Clinkr's `runNodeCli`, lazily loading `live-app.ts` only when a command runs, then exits
|
|
16
|
-
* with the status a command recorded past Clinkr's (the command's exit code), or else Clinkr's.
|
|
17
|
-
*/
|
|
18
|
-
export declare function runStormCli(options: RunStormCliOptions): Promise<void>;
|
package/dist/bin/run.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Shared CLI execution entry for both `src/bin/storm.ts` (Node) and `scripts/bun-runtime.ts` (compiled Bun
|
|
2
|
-
// executable). Keeps help, listings, and invocation errors light: `live-app.ts` is imported lazily inside Clinkr's
|
|
3
|
-
// `app` factory only when a command actually executes.
|
|
4
|
-
import { runNodeCli } from "@vercel/clinkr/node";
|
|
5
|
-
import { loadStormApplication } from "../application.js";
|
|
6
|
-
/** Whether the global `--no-color` flag appears before a bare `--` in `argv`, matching Clinkr's global flag parse. */
|
|
7
|
-
export function hasNoColorFlag(argv) {
|
|
8
|
-
for (const token of argv) {
|
|
9
|
-
if (token === "--")
|
|
10
|
-
return false;
|
|
11
|
-
if (token === "--no-color")
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Runs the `storm` CLI under Clinkr's `runNodeCli`, lazily loading `live-app.ts` only when a command runs, then exits
|
|
18
|
-
* with the status a command recorded past Clinkr's (the command's exit code), or else Clinkr's.
|
|
19
|
-
*/
|
|
20
|
-
export async function runStormCli(options) {
|
|
21
|
-
const exit = { status: undefined };
|
|
22
|
-
const accessible = process.env["VERCEL_ACCESSIBLE"] === "1";
|
|
23
|
-
const noColor = hasNoColorFlag(process.argv.slice(2));
|
|
24
|
-
const status = await runNodeCli(await loadStormApplication(options.version, { accessible, ...options.sources }), {
|
|
25
|
-
app: async (host) => {
|
|
26
|
-
const [{ liveStormApp }, buildInfo] = await Promise.all([import("../live-app.js"), options.buildInfo()]);
|
|
27
|
-
return liveStormApp(host, buildInfo, exit, { noColor });
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
process.exitCode = exit.status ?? status;
|
|
31
|
-
}
|