@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,6 @@
|
|
|
1
1
|
import type { Credential } from "../credential/index.ts";
|
|
2
2
|
import type { SandboxCredential } from "../sdk/extension/index.ts";
|
|
3
|
+
import type { ManagedCredential } from "./vercel-sandbox-secrets.ts";
|
|
3
4
|
/** Why a checkout operation failed: what git or tar said, and the command that failed when there was one. */
|
|
4
5
|
export interface CheckoutFailure {
|
|
5
6
|
readonly message: string;
|
|
@@ -132,6 +133,11 @@ export interface CheckoutGateway {
|
|
|
132
133
|
readonly repoRoot: string;
|
|
133
134
|
readonly base: string;
|
|
134
135
|
}): Promise<CheckoutResult<BaseArchive>>;
|
|
136
|
+
/** The URL configured for Git remote `remote` (`git remote get-url <remote>`). */
|
|
137
|
+
remoteUrl(request: {
|
|
138
|
+
readonly repoRoot: string;
|
|
139
|
+
readonly remote: string;
|
|
140
|
+
}): Promise<CheckoutResult<string>>;
|
|
135
141
|
}
|
|
136
142
|
/**
|
|
137
143
|
* One runner snapshot the local snapshot index records: who it belongs to, what it was built from, and when it expires.
|
|
@@ -141,7 +147,7 @@ export interface RunnerSnapshotEntry {
|
|
|
141
147
|
readonly teamId: string;
|
|
142
148
|
readonly projectId: string;
|
|
143
149
|
readonly region: string;
|
|
144
|
-
readonly
|
|
150
|
+
readonly image: string;
|
|
145
151
|
readonly runnerName: string;
|
|
146
152
|
/** The snapshot key at `base` (`snapshotKey`). */
|
|
147
153
|
readonly snapshotKey: string;
|
|
@@ -183,7 +189,7 @@ export type RunnerSnapshotIndexOperation = {
|
|
|
183
189
|
};
|
|
184
190
|
/**
|
|
185
191
|
* The per-machine local snapshot index: one record per runner snapshot, keyed by the entry's identity (team, project,
|
|
186
|
-
* region,
|
|
192
|
+
* region, image, runner name, snapshot key, and base).
|
|
187
193
|
* Every method returns its expected failures and never rejects. Which entries a run may use, and when one has
|
|
188
194
|
* expired, is the caller's.
|
|
189
195
|
*/
|
|
@@ -251,6 +257,8 @@ export interface RunnerSandboxPlacement {
|
|
|
251
257
|
/** At most 5: `purpose`, `user`, and `role`. */
|
|
252
258
|
readonly tags: Readonly<Record<string, string>>;
|
|
253
259
|
readonly networkPolicy: RunnerNetworkPolicy;
|
|
260
|
+
/** Vercel-managed sandbox credentials passed to `Sandbox.create({ credentials })`; omitted when empty. */
|
|
261
|
+
readonly managedCredentials?: readonly ManagedCredential[];
|
|
254
262
|
}
|
|
255
263
|
/**
|
|
256
264
|
* Why a Sandbox call failed.
|
|
@@ -363,11 +371,11 @@ export interface SavedSnapshot {
|
|
|
363
371
|
*/
|
|
364
372
|
export interface RunnerSandboxGateway {
|
|
365
373
|
/**
|
|
366
|
-
* Starts a fresh build sandbox
|
|
374
|
+
* Starts a fresh build sandbox from `image`, not persistent, optionally with an explicit `name`; answers
|
|
367
375
|
* `name-taken` when a sandbox with that `name` already exists in the project.
|
|
368
376
|
*/
|
|
369
377
|
startBuildSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
|
|
370
|
-
readonly
|
|
378
|
+
readonly image: string;
|
|
371
379
|
readonly name?: string;
|
|
372
380
|
}, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox, RunnerBuildStartFailure>>;
|
|
373
381
|
/** Starts a runner sandbox from runner snapshot `snapshotId`, not persistent; `snapshot-gone` when it is gone. */
|
|
@@ -484,3 +492,28 @@ export interface RunnerTerminal {
|
|
|
484
492
|
writeStdout(text: string): void;
|
|
485
493
|
writeStderr(text: string): void;
|
|
486
494
|
}
|
|
495
|
+
/** Why reading a GitHub token through `gh auth token` failed. */
|
|
496
|
+
export type GhTokenFailureKind = "not-installed" | "not-authenticated" | "timed-out" | "failed";
|
|
497
|
+
/** A safe diagnostic for a failed `gh auth token --hostname <host>` call (never contains a token). */
|
|
498
|
+
export interface GhTokenFailure {
|
|
499
|
+
readonly kind: GhTokenFailureKind;
|
|
500
|
+
readonly host: string;
|
|
501
|
+
readonly message: string;
|
|
502
|
+
}
|
|
503
|
+
/** What reading a GitHub token through `GhTokenGateway` answered. */
|
|
504
|
+
export type GhTokenRead = {
|
|
505
|
+
readonly ok: true;
|
|
506
|
+
readonly token: string;
|
|
507
|
+
} | {
|
|
508
|
+
readonly ok: false;
|
|
509
|
+
readonly failure: GhTokenFailure;
|
|
510
|
+
};
|
|
511
|
+
/**
|
|
512
|
+
* Reads a GitHub token on the launch machine via `gh auth token --hostname <host>`. Every method returns its expected
|
|
513
|
+
* failures and never rejects.
|
|
514
|
+
*/
|
|
515
|
+
export interface GhTokenGateway {
|
|
516
|
+
readToken(request: {
|
|
517
|
+
readonly host: string;
|
|
518
|
+
}): Promise<GhTokenRead>;
|
|
519
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** How a `{ kind: "gh" }` sandbox credential frames the raw token in the `authorization` header. */
|
|
2
|
+
export type GhTokenFormat = "basic" | "bearer";
|
|
3
|
+
/** Default GitHub hostname passed to `gh auth token --hostname <host>`. */
|
|
4
|
+
export declare const DEFAULT_GH_HOST = "github.com";
|
|
5
|
+
/** The result of validating and framing a raw GitHub token for a `{ kind: "gh" }` sandbox credential. */
|
|
6
|
+
export type GhTokenFraming = {
|
|
7
|
+
readonly ok: true;
|
|
8
|
+
readonly headerValue: string;
|
|
9
|
+
/** Every secret form (header value, base64 `x-access-token:<token>` when basic, raw token) to redact. */
|
|
10
|
+
readonly secrets: readonly string[];
|
|
11
|
+
} | {
|
|
12
|
+
readonly ok: false;
|
|
13
|
+
readonly problem: "multiline" | "short" | "gh-preframed";
|
|
14
|
+
};
|
|
15
|
+
/** Resolves the `gh auth token --hostname` target for a `{ kind: "gh" }` source (defaults to `"github.com"`). */
|
|
16
|
+
export declare function resolveGhHost(source: {
|
|
17
|
+
readonly host?: string;
|
|
18
|
+
}): string;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the `Authorization` framing for a `{ kind: "gh" }` source on `domain`:
|
|
21
|
+
* - Uses `source.format` when explicitly declared.
|
|
22
|
+
* - Defaults to `"basic"` (`Basic <base64(x-access-token:<token>)>`, for Git over HTTPS) when `domain` matches the
|
|
23
|
+
* source's GitHub host (such as `"github.com"` or a GitHub Enterprise host).
|
|
24
|
+
* - Defaults to `"bearer"` (`Bearer <token>`) for API and companion hosts (such as `"api.github.com"`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveGhFormat(domain: string, source: {
|
|
27
|
+
readonly host?: string;
|
|
28
|
+
readonly format?: GhTokenFormat;
|
|
29
|
+
}): GhTokenFormat;
|
|
30
|
+
/** Base64 of `x-access-token:<token>`, the `Basic` credential value Git over HTTPS sends to GitHub. */
|
|
31
|
+
export declare function ghBasicCredential(token: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Validates a raw GitHub token (single-line, not pre-framed with `Bearer`/`Basic`, and at least `SECRET_MIN_LENGTH`
|
|
34
|
+
* characters), frames it as `Bearer <token>` or `Basic <base64(x-access-token:<token>)>`, and returns every secret
|
|
35
|
+
* form for `<token>` redaction.
|
|
36
|
+
*/
|
|
37
|
+
export declare function frameGhToken(token: string, format: GhTokenFormat): GhTokenFraming;
|
|
38
|
+
/**
|
|
39
|
+
* Extracts unchecked redaction forms from a launcher environment variable configured as `env` on `{ kind: "gh", env }`
|
|
40
|
+
* for `declaredSecretValues` (redaction-only paths that never spawn `gh`).
|
|
41
|
+
*/
|
|
42
|
+
export declare function ghEnvRedactionForms(raw: string): readonly string[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Pure GitHub token framing and defaults for `{ kind: "gh" }` sandbox credentials. Never spawns `gh`: the live
|
|
2
|
+
// `GhTokenGateway` invokes `gh auth token --hostname <host>` when no `env` override is set, and this module resolves
|
|
3
|
+
// defaults, validates raw tokens, frames `Basic` or `Bearer` `Authorization` headers, and produces every secret form
|
|
4
|
+
// to redact as `<token>`.
|
|
5
|
+
import { SECRET_MIN_LENGTH } from "../sdk/extension/index.js";
|
|
6
|
+
/** Default GitHub hostname passed to `gh auth token --hostname <host>`. */
|
|
7
|
+
export const DEFAULT_GH_HOST = "github.com";
|
|
8
|
+
/** Resolves the `gh auth token --hostname` target for a `{ kind: "gh" }` source (defaults to `"github.com"`). */
|
|
9
|
+
export function resolveGhHost(source) {
|
|
10
|
+
return source.host ?? DEFAULT_GH_HOST;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the `Authorization` framing for a `{ kind: "gh" }` source on `domain`:
|
|
14
|
+
* - Uses `source.format` when explicitly declared.
|
|
15
|
+
* - Defaults to `"basic"` (`Basic <base64(x-access-token:<token>)>`, for Git over HTTPS) when `domain` matches the
|
|
16
|
+
* source's GitHub host (such as `"github.com"` or a GitHub Enterprise host).
|
|
17
|
+
* - Defaults to `"bearer"` (`Bearer <token>`) for API and companion hosts (such as `"api.github.com"`).
|
|
18
|
+
*/
|
|
19
|
+
export function resolveGhFormat(domain, source) {
|
|
20
|
+
if (source.format !== undefined)
|
|
21
|
+
return source.format;
|
|
22
|
+
return domain === resolveGhHost(source) ? "basic" : "bearer";
|
|
23
|
+
}
|
|
24
|
+
/** Base64 of `x-access-token:<token>`, the `Basic` credential value Git over HTTPS sends to GitHub. */
|
|
25
|
+
export function ghBasicCredential(token) {
|
|
26
|
+
return Buffer.from(`x-access-token:${token}`, "utf8").toString("base64");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validates a raw GitHub token (single-line, not pre-framed with `Bearer`/`Basic`, and at least `SECRET_MIN_LENGTH`
|
|
30
|
+
* characters), frames it as `Bearer <token>` or `Basic <base64(x-access-token:<token>)>`, and returns every secret
|
|
31
|
+
* form for `<token>` redaction.
|
|
32
|
+
*/
|
|
33
|
+
export function frameGhToken(token, format) {
|
|
34
|
+
if (/[\r\n]/.test(token))
|
|
35
|
+
return { ok: false, problem: "multiline" };
|
|
36
|
+
if (/^(?:bearer|basic)\s/i.test(token))
|
|
37
|
+
return { ok: false, problem: "gh-preframed" };
|
|
38
|
+
if (token.length < SECRET_MIN_LENGTH)
|
|
39
|
+
return { ok: false, problem: "short" };
|
|
40
|
+
if (format === "bearer") {
|
|
41
|
+
const headerValue = `Bearer ${token}`;
|
|
42
|
+
return { ok: true, headerValue, secrets: uniqueNonEmpty([headerValue, token]) };
|
|
43
|
+
}
|
|
44
|
+
const basic = ghBasicCredential(token);
|
|
45
|
+
const headerValue = `Basic ${basic}`;
|
|
46
|
+
return { ok: true, headerValue, secrets: uniqueNonEmpty([headerValue, basic, token]) };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Extracts unchecked redaction forms from a launcher environment variable configured as `env` on `{ kind: "gh", env }`
|
|
50
|
+
* for `declaredSecretValues` (redaction-only paths that never spawn `gh`).
|
|
51
|
+
*/
|
|
52
|
+
export function ghEnvRedactionForms(raw) {
|
|
53
|
+
const basic = ghBasicCredential(raw);
|
|
54
|
+
return uniqueNonEmpty([`Basic ${basic}`, basic, `Bearer ${raw}`, raw]);
|
|
55
|
+
}
|
|
56
|
+
function uniqueNonEmpty(values) {
|
|
57
|
+
return [...new Set(values.filter((value) => value.length > 0))];
|
|
58
|
+
}
|
package/dist/runner/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { type RunnerContext, snapshotIndexTags } from "./context.ts";
|
|
2
|
-
export { buildSnapshots, prepareSnapshotBuild, type PreparedSnapshotBuild, type PrepareSnapshotBuildOutcome, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
|
|
2
|
+
export { buildSnapshots, prepareSnapshotBuild, type PreparedSnapshotBuild, type PrepareSnapshotBuildOutcome, sameSnapshotBuild, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
|
|
3
3
|
export { type KeptSandbox, type RunnerEvent, type RunnerFailure, type RunnerProgress, type RunnerStepPhase, type SnapshotBuildReason, } from "./events.ts";
|
|
4
|
-
export type { CheckoutFailure, CheckoutGateway, NamedSandboxInfo, NamedSandboxLookup, NamedSandboxStatus, RunnerBuildStartFailure, RunnerSandboxGateway, SandboxAccess, RunnerSnapshotIndexFailure, RunnerSnapshotIndexGateway, RunnerSnapshotEntry, RunnerTerminal, RunnerTerminalColor, SnapshotInfo, SnapshotLookup, SnapshotStatus, } from "./gateways.ts";
|
|
4
|
+
export type { CheckoutFailure, CheckoutGateway, GhTokenFailure, GhTokenFailureKind, GhTokenGateway, GhTokenRead, NamedSandboxInfo, NamedSandboxLookup, NamedSandboxStatus, RunnerBuildStartFailure, RunnerSandboxGateway, SandboxAccess, RunnerSnapshotIndexFailure, RunnerSnapshotIndexGateway, RunnerSnapshotEntry, RunnerTerminal, RunnerTerminalColor, SnapshotInfo, SnapshotLookup, SnapshotStatus, } from "./gateways.ts";
|
|
5
5
|
export { liveCheckoutGateway } from "./live/checkout-gateway.ts";
|
|
6
|
+
export { liveGhTokenGateway } from "./live/gh-token-gateway.ts";
|
|
6
7
|
export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.ts";
|
|
7
8
|
export { liveRunnerTerminal } from "./live/terminal.ts";
|
|
8
9
|
export { localUserName } from "./live/user.ts";
|
|
@@ -10,11 +11,11 @@ export { liveRunnerSnapshotIndexGateway, unavailableRunnerSnapshotIndexGateway,
|
|
|
10
11
|
export { lineSplitter } from "./output.ts";
|
|
11
12
|
export { prepareRunner, type PrepareRunnerOutcome } from "./prepare.ts";
|
|
12
13
|
export type { ChosenSnapshot, ReadyRunnerOutcome } from "./ready.ts";
|
|
13
|
-
export { type CheckedVercelSandboxOptions, checkVercelSandboxOptions, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type RunnerSandboxCount, type ToolchainStep, type VcpuRun, } from "./vercel-sandbox-options.ts";
|
|
14
|
+
export { type CheckedVercelSandboxOptions, checkVercelSandboxOptions, type GhCredentialSource, type GhTokenFormat, type ManagedCredential, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type SandboxCredentialSource, type RunnerSandboxCount, type SnapshotSource, type ToolchainStep, type VcpuRun, } from "./vercel-sandbox-options.ts";
|
|
14
15
|
export { chooseSnapshotForRun, type SnapshotChoice, type SnapshotChoiceEnd } from "./snapshot-choice.ts";
|
|
15
16
|
export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.ts";
|
|
16
17
|
export type { RunnerFenceOutcome } from "./scope.ts";
|
|
17
|
-
export { declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, type UnsafeSecretEnvVarMap, } from "./secrets.ts";
|
|
18
|
+
export { CREDENTIAL_PROBLEM_KINDS, type CredentialProblem, type CredentialProblemKind, type CredentialReadContext, declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, type UnsafeSecretEnvVarMap, } from "./secrets.ts";
|
|
18
19
|
export { type RunnerCleanupFacts, openRunnerSession, type RunnerSession, type RunnerSessionCleanup, type RunnerSessionRequest, } from "./session.ts";
|
|
19
20
|
export { type InspectedSnapshot, inspectLocalSnapshotIndex, type LocalSnapshotIndexInspection, type UnpickedReason, } from "./snapshot-inspect.ts";
|
|
20
21
|
export { type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotIndexNote, type SnapshotRejectionReason, } from "./local-snapshot-index.ts";
|
package/dist/runner/index.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// modules import only from here, and it holds only what another module under `src/` imports; the runner's own tests
|
|
3
3
|
// import the files that declare the rest (`README.md`).
|
|
4
4
|
export { snapshotIndexTags } from "./context.js";
|
|
5
|
-
export { buildSnapshots, prepareSnapshotBuild, } from "./build-snapshots.js";
|
|
5
|
+
export { buildSnapshots, prepareSnapshotBuild, sameSnapshotBuild, } from "./build-snapshots.js";
|
|
6
6
|
export {} from "./events.js";
|
|
7
7
|
export { liveCheckoutGateway } from "./live/checkout-gateway.js";
|
|
8
|
+
export { liveGhTokenGateway } from "./live/gh-token-gateway.js";
|
|
8
9
|
export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.js";
|
|
9
10
|
export { liveRunnerTerminal } from "./live/terminal.js";
|
|
10
11
|
export { localUserName } from "./live/user.js";
|
|
@@ -14,7 +15,7 @@ export { prepareRunner } from "./prepare.js";
|
|
|
14
15
|
export { checkVercelSandboxOptions, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, } from "./vercel-sandbox-options.js";
|
|
15
16
|
export { chooseSnapshotForRun } from "./snapshot-choice.js";
|
|
16
17
|
export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.js";
|
|
17
|
-
export { declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, } from "./secrets.js";
|
|
18
|
+
export { CREDENTIAL_PROBLEM_KINDS, declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, } from "./secrets.js";
|
|
18
19
|
export { openRunnerSession, } from "./session.js";
|
|
19
20
|
export { inspectLocalSnapshotIndex, } from "./snapshot-inspect.js";
|
|
20
21
|
export { RUNNER_SNAPSHOTS_SUBPATH, } from "./local-snapshot-index.js";
|
|
@@ -26,6 +26,7 @@ export function liveCheckoutGateway() {
|
|
|
26
26
|
submodules: ({ repoRoot }) => submodules(repoRoot),
|
|
27
27
|
assembleUpload: ({ repoRoot, base }) => assembleUpload(repoRoot, base),
|
|
28
28
|
baseArchive: ({ repoRoot, base }) => baseArchive(repoRoot, base),
|
|
29
|
+
remoteUrl: ({ repoRoot, remote }) => remoteUrl(repoRoot, remote),
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
async function repositoryRoot(cwd) {
|
|
@@ -147,6 +148,12 @@ async function baseArchive(repoRoot, base) {
|
|
|
147
148
|
value: { tarball: tarball.stdout, fileList: fileList.stdout, files: splitNul(fileList.stdout).length },
|
|
148
149
|
};
|
|
149
150
|
}
|
|
151
|
+
async function remoteUrl(repoRoot, remote) {
|
|
152
|
+
const run = await git(repoRoot, ["remote", "get-url", "--", remote]);
|
|
153
|
+
// Strip only git's trailing line terminator so leading or trailing whitespace in the configured URL stays visible
|
|
154
|
+
// to validation rather than being silently dropped.
|
|
155
|
+
return run.ok ? { ok: true, value: run.stdout.toString("utf8").replace(/\r?\n$/, "") } : run;
|
|
156
|
+
}
|
|
150
157
|
/** `git -C <repoRoot> <args>`: its stdout, or its exit code and what it said on stderr. */
|
|
151
158
|
function git(repoRoot, args) {
|
|
152
159
|
const argv = ["-C", repoRoot, ...args];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GhTokenFailure } from "../gateways.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Strips a single trailing `\n` or `\r\n` from `gh auth token` stdout without trimming leading/trailing spaces or inner
|
|
4
|
+
* line breaks, so unexpected multiline output is still caught as `multiline`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function stripSingleTrailingLineBreak(stdout: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Classifies a failed `gh auth token --hostname <host>` invocation into a safe `GhTokenFailure` without echoing raw
|
|
9
|
+
* stderr or stdout.
|
|
10
|
+
*/
|
|
11
|
+
export declare function classifyGhTokenError(info: {
|
|
12
|
+
readonly host: string;
|
|
13
|
+
readonly code: string | number | undefined;
|
|
14
|
+
readonly killed: boolean;
|
|
15
|
+
readonly stderr: string;
|
|
16
|
+
readonly timeoutMs: number;
|
|
17
|
+
}): GhTokenFailure;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Pure stdout/error helpers for the live `gh auth token` gateway (`gh-token-gateway.ts`). Never echoes stdout or raw
|
|
2
|
+
// stderr into error messages so a token can never leak through a diagnostic.
|
|
3
|
+
/**
|
|
4
|
+
* Strips a single trailing `\n` or `\r\n` from `gh auth token` stdout without trimming leading/trailing spaces or inner
|
|
5
|
+
* line breaks, so unexpected multiline output is still caught as `multiline`.
|
|
6
|
+
*/
|
|
7
|
+
export function stripSingleTrailingLineBreak(stdout) {
|
|
8
|
+
if (stdout.endsWith("\r\n"))
|
|
9
|
+
return stdout.slice(0, -2);
|
|
10
|
+
if (stdout.endsWith("\n"))
|
|
11
|
+
return stdout.slice(0, -1);
|
|
12
|
+
return stdout;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Classifies a failed `gh auth token --hostname <host>` invocation into a safe `GhTokenFailure` without echoing raw
|
|
16
|
+
* stderr or stdout.
|
|
17
|
+
*/
|
|
18
|
+
export function classifyGhTokenError(info) {
|
|
19
|
+
const { host, code, killed, stderr, timeoutMs } = info;
|
|
20
|
+
if (code === "ENOENT") {
|
|
21
|
+
return { kind: "not-installed", host, message: "gh CLI is not installed or not on PATH" };
|
|
22
|
+
}
|
|
23
|
+
if (killed || code === "ETIMEDOUT") {
|
|
24
|
+
return { kind: "timed-out", host, message: `gh auth token --hostname ${host} timed out after ${timeoutMs}ms` };
|
|
25
|
+
}
|
|
26
|
+
if (NOT_AUTHENTICATED_PATTERN.test(stderr)) {
|
|
27
|
+
return { kind: "not-authenticated", host, message: `gh is not authenticated for ${host}` };
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
kind: "failed",
|
|
31
|
+
host,
|
|
32
|
+
message: typeof code === "number"
|
|
33
|
+
? `gh auth token --hostname ${host} exited ${code}`
|
|
34
|
+
: `gh auth token --hostname ${host} failed`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const NOT_AUTHENTICATED_PATTERN = /not logged in|no oauth token|no token|gh auth login|authentication failed|to get started with github cli/i;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GhTokenGateway } from "../gateways.ts";
|
|
2
|
+
/** Default time limit for `gh auth token --hostname <host>`. */
|
|
3
|
+
export declare const GH_TOKEN_TIMEOUT_MS = 10000;
|
|
4
|
+
export interface LiveGhTokenGatewayOptions {
|
|
5
|
+
/** Executable name or path to invoke; defaults to `"gh"`. */
|
|
6
|
+
readonly command?: string;
|
|
7
|
+
/** Bounded timeout in milliseconds; defaults to `GH_TOKEN_TIMEOUT_MS` (10 seconds). */
|
|
8
|
+
readonly timeoutMs?: number;
|
|
9
|
+
/** Process environment for `gh`; defaults to `process.env`. */
|
|
10
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
}
|
|
12
|
+
/** Live gateway reading a GitHub token from `gh auth token --hostname <host>`. */
|
|
13
|
+
export declare function liveGhTokenGateway(options?: LiveGhTokenGatewayOptions): GhTokenGateway;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Live `GhTokenGateway`: invokes `gh auth token --hostname <host>` on the launch machine with a bounded timeout and
|
|
2
|
+
// classifies failures without ever echoing stdout or raw stderr containing tokens.
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
4
|
+
import { classifyGhTokenError, stripSingleTrailingLineBreak } from "./gh-output.js";
|
|
5
|
+
/** Default time limit for `gh auth token --hostname <host>`. */
|
|
6
|
+
export const GH_TOKEN_TIMEOUT_MS = 10_000;
|
|
7
|
+
const GH_MAX_BUFFER = 64 * 1024;
|
|
8
|
+
/** Live gateway reading a GitHub token from `gh auth token --hostname <host>`. */
|
|
9
|
+
export function liveGhTokenGateway(options = {}) {
|
|
10
|
+
const command = options.command ?? "gh";
|
|
11
|
+
const timeoutMs = options.timeoutMs ?? GH_TOKEN_TIMEOUT_MS;
|
|
12
|
+
const env = options.env;
|
|
13
|
+
return {
|
|
14
|
+
readToken: ({ host }) => new Promise((resolve) => {
|
|
15
|
+
execFile(command, ["auth", "token", "--hostname", host], {
|
|
16
|
+
encoding: "utf8",
|
|
17
|
+
timeout: timeoutMs,
|
|
18
|
+
maxBuffer: GH_MAX_BUFFER,
|
|
19
|
+
...(env === undefined ? {} : { env: { ...env } }),
|
|
20
|
+
}, (error, stdout, stderr) => {
|
|
21
|
+
if (error === null) {
|
|
22
|
+
const token = stripSingleTrailingLineBreak(stdout);
|
|
23
|
+
if (token.length === 0) {
|
|
24
|
+
resolve({
|
|
25
|
+
ok: false,
|
|
26
|
+
failure: {
|
|
27
|
+
kind: "not-authenticated",
|
|
28
|
+
host,
|
|
29
|
+
message: `gh is not authenticated for ${host}`,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
resolve({ ok: true, token });
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const err = error;
|
|
38
|
+
resolve({
|
|
39
|
+
ok: false,
|
|
40
|
+
failure: classifyGhTokenError({
|
|
41
|
+
host,
|
|
42
|
+
code: err.code,
|
|
43
|
+
killed: err.killed === true,
|
|
44
|
+
stderr: typeof stderr === "string" ? stderr : "",
|
|
45
|
+
timeoutMs,
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -61,8 +61,7 @@ export function liveRunnerSandboxGateway() {
|
|
|
61
61
|
const { Sandbox } = await sdk();
|
|
62
62
|
const sandbox = await Sandbox.create({
|
|
63
63
|
...credentials(access),
|
|
64
|
-
|
|
65
|
-
runtime: request.runtime,
|
|
64
|
+
image: request.image,
|
|
66
65
|
...(request.name === undefined ? {} : { name: request.name }),
|
|
67
66
|
...placement(request),
|
|
68
67
|
...(signal === undefined ? {} : { signal }),
|
|
@@ -514,8 +513,19 @@ function placement(request) {
|
|
|
514
513
|
persistent: false,
|
|
515
514
|
tags: { ...request.tags },
|
|
516
515
|
networkPolicy: sdkNetworkPolicy(request.networkPolicy),
|
|
516
|
+
...(request.managedCredentials !== undefined && request.managedCredentials.length > 0
|
|
517
|
+
? { credentials: sdkManagedCredentials(request.managedCredentials) }
|
|
518
|
+
: {}),
|
|
517
519
|
};
|
|
518
520
|
}
|
|
521
|
+
function sdkManagedCredentials(providers) {
|
|
522
|
+
const result = {};
|
|
523
|
+
for (const provider of providers) {
|
|
524
|
+
if (provider === "npm")
|
|
525
|
+
result.npm = true;
|
|
526
|
+
}
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
519
529
|
/**
|
|
520
530
|
* storm's network policy as the SDK takes it. `allow-all` with no credential is the SDK's `allow-all`. With
|
|
521
531
|
* credentials, every domain stays reachable (`"*": []`). `custom` allows each allowed domain with no rule (`[]`), and
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
// The local snapshot index's file format: one JSON object per runner snapshot, carrying `version:
|
|
1
|
+
// The local snapshot index's file format: one JSON object per runner snapshot, carrying `version: 2`. A reader
|
|
2
2
|
// rejects a version it doesn't know, and drops keys it doesn't know. A file is named for its entry's identity
|
|
3
|
-
// (`snapshotEntryIdentity`), and the gateway lists a file whose name isn't as unreadable. Older files (such as
|
|
4
|
-
//
|
|
3
|
+
// (`snapshotEntryIdentity`), and the gateway lists a file whose name isn't as unreadable. Older files (such as
|
|
4
|
+
// version 1 entries carrying the retired `runtime` field) are listed as unreadable, and no run starts from them:
|
|
5
|
+
// there is no migration.
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
const isoTime = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "not a time" });
|
|
7
8
|
const nonEmpty = z.string().min(1);
|
|
8
9
|
const entrySchema = z.object({
|
|
9
|
-
version: z.literal(
|
|
10
|
+
version: z.literal(2),
|
|
10
11
|
teamId: nonEmpty,
|
|
11
12
|
projectId: nonEmpty,
|
|
12
13
|
region: nonEmpty,
|
|
13
|
-
|
|
14
|
+
image: nonEmpty,
|
|
14
15
|
runnerName: nonEmpty,
|
|
15
16
|
snapshotKey: nonEmpty,
|
|
16
17
|
base: nonEmpty,
|
|
@@ -28,7 +29,7 @@ export function parseSnapshotEntry(text) {
|
|
|
28
29
|
return { ok: false, reason: "not JSON" };
|
|
29
30
|
}
|
|
30
31
|
const version = typeof json === "object" && json !== null ? json.version : undefined;
|
|
31
|
-
if (version !==
|
|
32
|
+
if (version !== 2)
|
|
32
33
|
return { ok: false, reason: `unknown version ${JSON.stringify(version) ?? "(none)"}` };
|
|
33
34
|
const parsed = entrySchema.safeParse(json);
|
|
34
35
|
if (!parsed.success) {
|
|
@@ -41,14 +42,14 @@ export function parseSnapshotEntry(text) {
|
|
|
41
42
|
}
|
|
42
43
|
/** The text of the file that records `entry`. */
|
|
43
44
|
export function snapshotEntryText(entry) {
|
|
44
|
-
const { teamId, projectId, region,
|
|
45
|
+
const { teamId, projectId, region, image, runnerName, snapshotKey, base } = entry;
|
|
45
46
|
const { snapshotId, createdAt, expiresAt } = entry;
|
|
46
47
|
const record = {
|
|
47
|
-
version:
|
|
48
|
+
version: 2,
|
|
48
49
|
teamId,
|
|
49
50
|
projectId,
|
|
50
51
|
region,
|
|
51
|
-
|
|
52
|
+
image,
|
|
52
53
|
runnerName,
|
|
53
54
|
snapshotKey,
|
|
54
55
|
base,
|
|
@@ -7,8 +7,14 @@ export declare const RUNNER_SNAPSHOTS_SUBPATH: readonly string[];
|
|
|
7
7
|
export declare const SNAPSHOT_EXPIRATION_MS: number;
|
|
8
8
|
/** A run never picks a runner snapshot with this little left or less, 1 hour, so it can't expire before the start. */
|
|
9
9
|
export declare const SNAPSHOT_MIN_REMAINING_MS: number;
|
|
10
|
+
/** The runner fields that scope which snapshots belong to one runner target. */
|
|
11
|
+
export type RunnerSnapshotTarget = Pick<CheckedVercelSandboxOptions, "name" | "region" | "image">;
|
|
12
|
+
/** Whether two runner targets share the same snapshot scope (`name`, `region`, and `image`). */
|
|
13
|
+
export declare function sameRunnerTarget(a: RunnerSnapshotTarget, b: RunnerSnapshotTarget): boolean;
|
|
14
|
+
/** Whether local snapshot index `entry` belongs to runner `target`. */
|
|
15
|
+
export declare function matchesRunnerTarget(entry: Pick<RunnerSnapshotEntry, "runnerName" | "region" | "image">, target: RunnerSnapshotTarget): boolean;
|
|
10
16
|
/**
|
|
11
|
-
* An entry's identity: the first 32 hex characters of sha256 over its team id, project id, region,
|
|
17
|
+
* An entry's identity: the first 32 hex characters of sha256 over its team id, project id, region, image, runner
|
|
12
18
|
* name, snapshot key, and base, joined with NUL. Entries with one identity replace each other, so a team and project
|
|
13
19
|
* have one entry per runner, key, and base.
|
|
14
20
|
*/
|
|
@@ -70,7 +76,7 @@ export interface LocalSnapshotIndexRead {
|
|
|
70
76
|
}
|
|
71
77
|
/**
|
|
72
78
|
* What the classification says of one `entry` it was given: a candidate, a rejection with its reason, or that the
|
|
73
|
-
* entry is of another runner, region, or
|
|
79
|
+
* entry is of another runner, region, or image (`other-runner`), which no run of the runner looks at.
|
|
74
80
|
*/
|
|
75
81
|
export type SnapshotVerdict = {
|
|
76
82
|
readonly kind: "candidate";
|
|
@@ -131,13 +137,13 @@ export declare function removeExpiredEntries(context: Pick<LocalSnapshotIndexCon
|
|
|
131
137
|
export declare function resolveAncestorDistances(context: Pick<LocalSnapshotIndexContext, "checkout" | "clock">, request: {
|
|
132
138
|
readonly repoRoot: string;
|
|
133
139
|
readonly entries: readonly RunnerSnapshotEntry[];
|
|
134
|
-
readonly options:
|
|
140
|
+
readonly options: RunnerSnapshotTarget;
|
|
135
141
|
readonly mergeBase: string;
|
|
136
142
|
}): Promise<CheckoutResult<SnapshotAncestorDistanceMap>>;
|
|
137
143
|
/**
|
|
138
144
|
* Classifies `entries`, cache entries a caller listed, for a run of `options`: which ones it may start from, and why
|
|
139
145
|
* not from each other one of the runner's. It changes no file and asks Git nothing. Of the entries for the runner's
|
|
140
|
-
* region,
|
|
146
|
+
* region, image, and name, it keeps the ones with more than an hour left whose base is the run's merge-base (or an
|
|
141
147
|
* ancestor in `ancestorDistances`) and whose snapshot key is the run's. Candidates are sorted by
|
|
142
148
|
* `commitsBehindMergeBase` ascending, newest `createdAt` descending, and `snapshotId` ascending. Every other entry of
|
|
143
149
|
* the runner is `rejected`, with the first reason that rules it out, an expired one as `expired`. Each entry gets
|
|
@@ -145,7 +151,7 @@ export declare function resolveAncestorDistances(context: Pick<LocalSnapshotInde
|
|
|
145
151
|
*/
|
|
146
152
|
export declare function classifySnapshotEntries(context: Pick<LocalSnapshotIndexContext, "clock">, request: {
|
|
147
153
|
readonly entries: readonly RunnerSnapshotEntry[];
|
|
148
|
-
readonly options:
|
|
154
|
+
readonly options: RunnerSnapshotTarget;
|
|
149
155
|
/** The run's base, HEAD's merge-base with a base ref. */
|
|
150
156
|
readonly base: string;
|
|
151
157
|
/** The run's snapshot key, the runner's snapshot steps at `base`: a candidate's key is this one. */
|
|
@@ -9,22 +9,22 @@ export const RUNNER_SNAPSHOTS_SUBPATH = ["runner", "snapshots"];
|
|
|
9
9
|
export const SNAPSHOT_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1000;
|
|
10
10
|
/** A run never picks a runner snapshot with this little left or less, 1 hour, so it can't expire before the start. */
|
|
11
11
|
export const SNAPSHOT_MIN_REMAINING_MS = 60 * 60 * 1000;
|
|
12
|
+
/** Whether two runner targets share the same snapshot scope (`name`, `region`, and `image`). */
|
|
13
|
+
export function sameRunnerTarget(a, b) {
|
|
14
|
+
return a.name === b.name && a.region === b.region && a.image === b.image;
|
|
15
|
+
}
|
|
16
|
+
/** Whether local snapshot index `entry` belongs to runner `target`. */
|
|
17
|
+
export function matchesRunnerTarget(entry, target) {
|
|
18
|
+
return sameRunnerTarget({ name: entry.runnerName, region: entry.region, image: entry.image }, target);
|
|
19
|
+
}
|
|
12
20
|
/**
|
|
13
|
-
* An entry's identity: the first 32 hex characters of sha256 over its team id, project id, region,
|
|
21
|
+
* An entry's identity: the first 32 hex characters of sha256 over its team id, project id, region, image, runner
|
|
14
22
|
* name, snapshot key, and base, joined with NUL. Entries with one identity replace each other, so a team and project
|
|
15
23
|
* have one entry per runner, key, and base.
|
|
16
24
|
*/
|
|
17
25
|
export function snapshotEntryIdentity(entry) {
|
|
18
26
|
return createHash("sha256")
|
|
19
|
-
.update([
|
|
20
|
-
entry.teamId,
|
|
21
|
-
entry.projectId,
|
|
22
|
-
entry.region,
|
|
23
|
-
entry.runtime,
|
|
24
|
-
entry.runnerName,
|
|
25
|
-
entry.snapshotKey,
|
|
26
|
-
entry.base,
|
|
27
|
-
].join("\0"))
|
|
27
|
+
.update([entry.teamId, entry.projectId, entry.region, entry.image, entry.runnerName, entry.snapshotKey, entry.base].join("\0"))
|
|
28
28
|
.digest("hex")
|
|
29
29
|
.slice(0, 32);
|
|
30
30
|
}
|
|
@@ -77,9 +77,8 @@ export async function resolveAncestorDistances(context, request) {
|
|
|
77
77
|
const seen = new Set([mergeBase]);
|
|
78
78
|
const distances = {};
|
|
79
79
|
for (const entry of entries) {
|
|
80
|
-
if (entry
|
|
80
|
+
if (!matchesRunnerTarget(entry, options))
|
|
81
81
|
continue;
|
|
82
|
-
}
|
|
83
82
|
if (isExpiredEntry(entry, now) || !hasTimeLeft(entry, now))
|
|
84
83
|
continue;
|
|
85
84
|
if (seen.has(entry.base))
|
|
@@ -100,7 +99,7 @@ export async function resolveAncestorDistances(context, request) {
|
|
|
100
99
|
/**
|
|
101
100
|
* Classifies `entries`, cache entries a caller listed, for a run of `options`: which ones it may start from, and why
|
|
102
101
|
* not from each other one of the runner's. It changes no file and asks Git nothing. Of the entries for the runner's
|
|
103
|
-
* region,
|
|
102
|
+
* region, image, and name, it keeps the ones with more than an hour left whose base is the run's merge-base (or an
|
|
104
103
|
* ancestor in `ancestorDistances`) and whose snapshot key is the run's. Candidates are sorted by
|
|
105
104
|
* `commitsBehindMergeBase` ascending, newest `createdAt` descending, and `snapshotId` ascending. Every other entry of
|
|
106
105
|
* the runner is `rejected`, with the first reason that rules it out, an expired one as `expired`. Each entry gets
|
|
@@ -118,7 +117,7 @@ export function classifySnapshotEntries(context, request) {
|
|
|
118
117
|
verdicts.push({ kind: "rejected", entry, rejection });
|
|
119
118
|
};
|
|
120
119
|
for (const entry of entries) {
|
|
121
|
-
if (entry
|
|
120
|
+
if (!matchesRunnerTarget(entry, options)) {
|
|
122
121
|
verdicts.push({ kind: "other-runner", entry });
|
|
123
122
|
continue;
|
|
124
123
|
}
|
package/dist/runner/ready.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface ReadyRunner {
|
|
|
22
22
|
readonly buildMs: number;
|
|
23
23
|
readonly vcpus: number;
|
|
24
24
|
readonly region: string;
|
|
25
|
-
readonly
|
|
25
|
+
readonly image: string;
|
|
26
26
|
/** The checkout's root on this machine, which `/vercel/sandbox/` in output is rewritten to. */
|
|
27
27
|
readonly repoRoot: string;
|
|
28
28
|
/** The command's directory in the runner sandbox. */
|
package/dist/runner/ready.js
CHANGED
|
@@ -203,7 +203,7 @@ export async function readyFromSnapshot(context, request, control, progress) {
|
|
|
203
203
|
buildMs: builtOutputs.value,
|
|
204
204
|
vcpus: prepared.vcpus,
|
|
205
205
|
region: options.region,
|
|
206
|
-
|
|
206
|
+
image: options.image,
|
|
207
207
|
repoRoot,
|
|
208
208
|
cwd: posix.join(SANDBOX_ROOT, options.cwd),
|
|
209
209
|
env: options.env,
|
package/dist/runner/scope.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Clock, Timer } from "../time/index.ts";
|
|
|
3
3
|
import type { KeptSandbox, NotDeletedSandbox, NotKeptSandbox, NotStoppedSandbox, RunnerProgress } from "./events.ts";
|
|
4
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. */
|
|
@@ -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,7 +54,7 @@ export type ScopedSandboxPlacement = Omit<RunnerSandboxPlacement, "networkPolicy
|
|
|
53
54
|
*/
|
|
54
55
|
export interface RunnerSandboxScope {
|
|
55
56
|
startBuildSandbox(access: SandboxAccess, request: ScopedSandboxPlacement & {
|
|
56
|
-
readonly
|
|
57
|
+
readonly image: string;
|
|
57
58
|
readonly name?: string;
|
|
58
59
|
}): Promise<RunnerSandboxResult<RunnerSandbox, RunnerBuildStartFailure>>;
|
|
59
60
|
startRunnerSandbox(access: SandboxAccess, request: ScopedSandboxPlacement & {
|
|
@@ -129,6 +130,8 @@ export interface RunnerScopeSettings {
|
|
|
129
130
|
readonly keepMs: number;
|
|
130
131
|
/** The run's policy with no credential (`runnerNetworkPolicy`). */
|
|
131
132
|
readonly basePolicy: RunnerReachPolicy;
|
|
133
|
+
/** Vercel-managed credentials passed when starting sandboxes; forbids `keepMs` above 0. */
|
|
134
|
+
readonly managedCredentials?: readonly ManagedCredential[];
|
|
132
135
|
/** The storm command's signal: its abort cancels the command, which stops the scope's sandboxes. */
|
|
133
136
|
readonly signal: AbortSignal;
|
|
134
137
|
/** Whether the command runs now, for the `stopping` event; by default it never does. */
|