@cnc-tools/storm 0.10.0 → 0.11.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 +17 -9
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-YF3ICDBY.js → chunk-3ZZVZPMG.js} +1 -1
- package/dist/chunks/{chunk-JQ2HK4RN.js → chunk-4EU4AH7E.js} +141 -6
- package/dist/chunks/{chunk-ZJ2USLAT.js → chunk-4PRAB24Y.js} +2 -22
- package/dist/chunks/chunk-AMTYHUYB.js +257 -0
- package/dist/chunks/{chunk-WF4KJ7YG.js → chunk-ETCZ6WP7.js} +1 -1
- package/dist/chunks/chunk-FVMQKYTT.js +10 -0
- package/dist/chunks/{chunk-XHJGHJBW.js → chunk-GRMD7G4J.js} +33 -275
- package/dist/chunks/chunk-ICB4BZJX.js +22 -0
- package/dist/chunks/{chunk-AGWW3HDT.js → chunk-KR7WIYLG.js} +1826 -2201
- package/dist/chunks/{chunk-OVXD7GES.js → chunk-L4ZPMSKQ.js} +4 -37
- package/dist/chunks/chunk-NPPJ57W7.js +569 -0
- package/dist/chunks/{chunk-VJQLMGOH.js → chunk-O4BUT7BE.js} +361 -1716
- package/dist/chunks/chunk-OJOKQRM6.js +1457 -0
- package/dist/chunks/chunk-SLNKW4ZM.js +40 -0
- package/dist/chunks/{chunk-AKKNF3WZ.js → chunk-TRFEAYNC.js} +277 -348
- package/dist/chunks/chunk-VZZTHCBW.js +93 -0
- package/dist/chunks/chunk-WNIQA5J6.js +19 -0
- package/dist/chunks/chunk-WSIF7SR6.js +10 -0
- package/dist/chunks/{live-app-RIJM3QFD.js → live-app-LOGYUBKB.js} +52 -7
- package/dist/commands/exec/cleanup.d.ts +3 -3
- package/dist/commands/exec/cleanup.js +6 -2
- package/dist/commands/exec/command.d.ts +3 -3
- package/dist/commands/exec/command.js +17 -10
- package/dist/commands/exec/job-summary.d.ts +1 -1
- package/dist/commands/exec/job-summary.js +1 -1
- package/dist/commands/exec/live-view.js +5 -5
- package/dist/commands/exec/mint-failed.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +2 -2
- package/dist/commands/exec/outcomes.js +7 -8
- package/dist/commands/exec/plan-run.d.ts +3 -5
- package/dist/commands/exec/progress.d.ts +3 -3
- package/dist/commands/exec/progress.js +6 -6
- package/dist/commands/exec/resource-refusals.d.ts +1 -1
- package/dist/commands/exec/resource-refusals.js +1 -1
- package/dist/commands/exec/run-command.d.ts +14 -9
- package/dist/commands/exec/run-command.js +91 -202
- package/dist/commands/exec/run-metadata.d.ts +2 -2
- package/dist/commands/exec/run-metadata.js +3 -3
- package/dist/commands/exec/test-plan.d.ts +1 -35
- package/dist/commands/exec/test-plan.js +4 -24
- package/dist/commands/exec/view.js +3 -3
- package/dist/commands/exec/waterfall.d.ts +3 -1
- package/dist/commands/exec/waterfall.js +18 -1
- package/dist/commands/runs/facts.d.ts +2 -1
- package/dist/commands/runs/facts.js +1 -1
- package/dist/commands/runs/list/command.js +10 -9
- package/dist/commands/runs/logs/command.js +14 -12
- package/dist/commands/runs/past-run.d.ts +3 -27
- package/dist/commands/runs/past-run.js +3 -37
- package/dist/commands/runs/show/command.js +24 -21
- package/dist/commands/runs/show/outcomes.js +2 -2
- package/dist/commands/vitest/command.d.ts +3 -3
- package/dist/commands/vitest/command.js +24 -17
- package/dist/commands/vitest/outcomes.d.ts +1 -1
- package/dist/commands/vitest/outcomes.js +1 -1
- package/dist/config/credential-resolver.d.ts +6 -3
- package/dist/config/credential-resolver.js +6 -5
- package/dist/context.d.ts +27 -9
- package/dist/context.js +19 -8
- package/dist/core/before-run.d.ts +5 -4
- package/dist/core/before-run.js +6 -6
- package/dist/core/definition-lookup.d.ts +22 -0
- package/dist/core/definition-lookup.js +34 -0
- package/dist/core/events.d.ts +5 -19
- package/dist/core/gateways.d.ts +22 -162
- package/dist/core/index.d.ts +10 -11
- package/dist/core/index.js +9 -11
- package/dist/core/launcher-supplies.js +2 -2
- package/dist/core/live/terminal-command-gateway.d.ts +8 -0
- package/dist/core/live/terminal-command-gateway.js +49 -0
- package/dist/core/presentations.d.ts +4 -3
- package/dist/core/presentations.js +4 -5
- package/dist/core/resource-registry.d.ts +35 -51
- package/dist/core/resource-registry.js +27 -54
- package/dist/core/resource-reports.d.ts +37 -4
- package/dist/core/resource-reports.js +34 -5
- package/dist/core/resources.d.ts +4 -3
- package/dist/core/resources.js +2 -4
- package/dist/core/run-state.d.ts +1 -1
- package/dist/core/run-state.js +1 -1
- package/dist/core/run.d.ts +19 -37
- package/dist/core/run.js +59 -114
- package/dist/core/timeline.js +2 -1
- package/dist/credential/events.d.ts +20 -0
- package/dist/credential/events.js +4 -0
- package/dist/credential/index.d.ts +2 -1
- package/dist/credential/index.js +6 -5
- package/dist/credential/source.d.ts +38 -26
- package/dist/credential/source.js +25 -34
- package/dist/extension-commands.d.ts +12 -6
- package/dist/extension-commands.js +18 -11
- package/dist/extensions/story/command-tree.d.ts +6 -0
- package/dist/extensions/story/command-tree.js +21 -0
- package/dist/extensions/story/commands/app.d.ts +23 -0
- package/dist/extensions/story/commands/app.js +5 -0
- package/dist/extensions/story/commands/run/command.d.ts +211 -0
- package/dist/extensions/story/commands/run/command.js +259 -0
- package/dist/extensions/story/commands/run/metadata.d.ts +4 -0
- package/dist/extensions/story/commands/run/metadata.js +8 -0
- package/dist/extensions/story/commands/run/outcomes.d.ts +101 -0
- package/dist/extensions/story/commands/run/outcomes.js +73 -0
- package/dist/extensions/story/commands/tree.d.ts +2 -0
- package/dist/extensions/story/commands/tree.js +6 -0
- package/dist/extensions/story/extension.d.ts +2 -0
- package/dist/extensions/story/extension.js +8 -0
- package/dist/extensions/testserver/command-tree.d.ts +1 -1
- package/dist/extensions/testserver/command-tree.js +0 -1
- package/dist/extensions/testserver/commands/pool/create/command.js +14 -8
- package/dist/extensions/testserver/commands/pool/list/command.js +8 -4
- package/dist/extensions/testserver/vitest/config.d.ts +7 -5
- package/dist/extensions/testserver/vitest/config.js +7 -5
- package/dist/extensions/testserver/vitest/fixtures.d.ts +2 -0
- package/dist/extensions/testserver/vitest/fixtures.js +36 -5
- package/dist/extensions.d.ts +12 -21
- package/dist/extensions.js +22 -34
- package/dist/forward-sigterm.d.ts +8 -0
- package/dist/forward-sigterm.js +18 -0
- package/dist/launcher-resolvers/index.d.ts +1 -0
- package/dist/launcher-resolvers/index.js +2 -1
- package/dist/launcher-resolvers/local-services.d.ts +57 -0
- package/dist/launcher-resolvers/local-services.js +7 -0
- package/dist/live-app.js +2 -1
- package/dist/local-services.d.ts +19 -0
- package/dist/local-services.js +37 -0
- package/dist/run-directory/gateways.d.ts +167 -0
- package/dist/run-directory/gateways.js +2 -0
- package/dist/run-directory/index.d.ts +8 -0
- package/dist/run-directory/index.js +13 -0
- package/dist/run-directory/plan.d.ts +35 -0
- package/dist/run-directory/plan.js +24 -0
- package/dist/run-directory/reader.d.ts +70 -0
- package/dist/run-directory/reader.js +51 -0
- package/dist/run-directory/recording.d.ts +92 -0
- package/dist/run-directory/recording.js +85 -0
- package/dist/{commands/exec → run-directory}/run-collector.d.ts +9 -8
- package/dist/{commands/exec → run-directory}/run-collector.js +8 -10
- package/dist/{core → run-directory}/run-directory.d.ts +3 -3
- package/dist/{core → run-directory}/run-directory.js +2 -2
- package/dist/{commands/exec → run-directory}/run-record.d.ts +29 -7
- package/dist/{commands/exec → run-directory}/run-record.js +79 -5
- package/dist/{commands/exec → run-directory}/timeline-facts.d.ts +4 -8
- package/dist/{commands/exec → run-directory}/timeline-facts.js +8 -24
- package/dist/runner/events.d.ts +6 -5
- package/dist/runner/index.d.ts +13 -17
- package/dist/runner/index.js +10 -14
- package/dist/runner/prepare.d.ts +28 -6
- package/dist/runner/prepare.js +15 -9
- package/dist/runner/recipe.d.ts +14 -0
- package/dist/runner/recipe.js +12 -0
- package/dist/runner/scope.d.ts +18 -11
- package/dist/runner/scope.js +12 -10
- package/dist/runner/session.d.ts +100 -0
- package/dist/runner/session.js +109 -0
- package/dist/runner/snapshot-save.d.ts +3 -2
- package/dist/runner/snapshot-save.js +6 -5
- package/dist/sdk/extension/ci.d.ts +2 -0
- package/dist/sdk/extension/ci.js +6 -0
- package/dist/sdk/extension/commands.d.ts +11 -13
- package/dist/sdk/extension/commands.js +5 -5
- package/dist/sdk/extension/index.d.ts +1 -0
- package/dist/sdk/extension/index.js +1 -0
- package/dist/sdk/extension/lifecycle.d.ts +4 -3
- package/dist/sdk/extension/progress.js +2 -2
- package/dist/sdk/extension/resource.js +1 -1
- package/dist/story/align.d.ts +1 -1
- package/dist/story/align.js +1 -1
- package/dist/story/command-line.d.ts +6 -16
- package/dist/story/command-line.js +11 -23
- package/dist/story/errors.d.ts +1 -1
- package/dist/story/errors.js +1 -1
- package/dist/story/host.d.ts +1 -1
- package/dist/story/host.js +2 -2
- package/dist/story/index.d.ts +2 -2
- package/dist/story/index.js +4 -3
- package/dist/story/launch.d.ts +70 -0
- package/dist/story/launch.js +77 -0
- package/dist/story/report.d.ts +2 -2
- package/dist/story/report.js +3 -4
- package/dist/story/settle.d.ts +7 -7
- package/dist/story/settle.js +5 -5
- package/dist/story/start.d.ts +2 -2
- package/dist/vendor/testserver-sdk/container/container.d.ts +11 -6
- package/dist/vendor/testserver-sdk/container/container.js +38 -16
- package/dist/vendor/testserver-sdk/testserver/failure.d.ts +4 -3
- package/dist/vendor/testserver-sdk/testserver/failure.js +4 -3
- package/package.json +1 -1
- package/skills/overview.md +3 -0
- package/skills/read-run-output.md +2 -2
- package/dist/chunks/chunk-H2VCSNVU.js +0 -351
- package/dist/chunks/chunk-J6ZNYUDV.js +0 -21
- package/dist/core/mint.d.ts +0 -10
- package/dist/core/mint.js +0 -14
- package/dist/story/mode.d.ts +0 -17
- package/dist/story/mode.js +0 -21
- /package/dist/{core → run-directory}/live/run-directory-gateway.d.ts +0 -0
- /package/dist/{core → run-directory}/live/run-directory-gateway.js +0 -0
package/dist/runner/scope.d.ts
CHANGED
|
@@ -7,8 +7,11 @@ export declare const CREATE_SETTLE_MS = 20000;
|
|
|
7
7
|
export declare const SNAPSHOT_SETTLE_MS: number;
|
|
8
8
|
/**
|
|
9
9
|
* What the run does with its runner sandbox once it ends, decided before the run starts: keep it running `ms`
|
|
10
|
-
* (`keep`; 0 stops and deletes it), or save it as a branch snapshot of `branch` (`save`,
|
|
11
|
-
*
|
|
10
|
+
* (`keep`; 0 stops and deletes it), or save it as a branch snapshot of `branch` (`save`, a run on a branch). A save
|
|
11
|
+
* plan saves once the command ended on its own, and with `always` false only when the command exited 0 and the run
|
|
12
|
+
* didn't start from a branch snapshot HEAD's commit saved. A run whose save starts never keeps the runner sandbox,
|
|
13
|
+
* however the save ends; one whose save never starts keeps it running `otherwiseKeepMs`, as a `keep` plan of that time
|
|
14
|
+
* does.
|
|
12
15
|
*/
|
|
13
16
|
export type RunnerSandboxPlan = {
|
|
14
17
|
readonly kind: "keep";
|
|
@@ -16,9 +19,12 @@ export type RunnerSandboxPlan = {
|
|
|
16
19
|
} | {
|
|
17
20
|
readonly kind: "save";
|
|
18
21
|
readonly branch: string;
|
|
22
|
+
/** Save whatever the command's exit code and whatever runner snapshot the run started from (`--save-snapshot`). */
|
|
23
|
+
readonly always: boolean;
|
|
24
|
+
readonly otherwiseKeepMs: number;
|
|
19
25
|
};
|
|
20
|
-
/** How long `plan` keeps the runner sandbox running once the run ends
|
|
21
|
-
export declare function
|
|
26
|
+
/** How long `plan` keeps the runner sandbox running once the run ends without a save starting, in milliseconds. */
|
|
27
|
+
export declare function unsavedKeepMs(plan: RunnerSandboxPlan): number;
|
|
22
28
|
/**
|
|
23
29
|
* What closing a scope left: the runner sandbox it kept running (`kept`), or couldn't keep running and so stopped and
|
|
24
30
|
* deleted (`notKept`), each null otherwise, and the sandboxes it couldn't stop or delete.
|
|
@@ -52,23 +58,24 @@ export interface RunnerSandboxScope {
|
|
|
52
58
|
}): Promise<RunnerSandboxResult<SavedSnapshot>>;
|
|
53
59
|
/**
|
|
54
60
|
* Waits up to `CREATE_SETTLE_MS` for creates in flight and up to `SNAPSHOT_SETTLE_MS` for a snapshot saving, then
|
|
55
|
-
* stops and deletes every sandbox the scope holds, but for the runner sandbox when the keep time
|
|
56
|
-
* it keeps running at least the keep time from now, with nothing the run
|
|
57
|
-
* `sandbox-kept`, or stops and deletes when it can't. A
|
|
58
|
-
*
|
|
61
|
+
* stops and deletes every sandbox the scope holds, but for the runner sandbox when the keep time, read once the
|
|
62
|
+
* waits are over, is above 0: that one it keeps running at least the keep time from now, with nothing the run
|
|
63
|
+
* started still running in it, reporting `sandbox-kept`, or stops and deletes when it can't. A create that ends
|
|
64
|
+
* after closing began is stopped and deleted when it ends. Calling it again answers the first
|
|
59
65
|
* call's report.
|
|
60
66
|
*/
|
|
61
67
|
close(): Promise<RunnerScopeFacts>;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
70
|
* A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
|
|
65
|
-
* runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
|
|
66
|
-
* rest when `keepMs` is 0.
|
|
71
|
+
* runner sandbox running `keepMs()` past closing (`context.clock` says when that is), or stops and deletes it with the
|
|
72
|
+
* rest when `keepMs()` is 0. It asks for the keep time as it closes, once its waits are over, since a save that starts
|
|
73
|
+
* after the scope opened takes the runner sandbox's keep time away (`session.ts`).
|
|
67
74
|
*/
|
|
68
75
|
export declare function runnerSandboxScope(context: {
|
|
69
76
|
readonly runnerSandboxes: RunnerSandboxGateway;
|
|
70
77
|
readonly timer: Timer;
|
|
71
78
|
readonly clock: Clock;
|
|
72
79
|
}, progress: RunnerProgress, keep: {
|
|
73
|
-
readonly keepMs: number;
|
|
80
|
+
readonly keepMs: () => number;
|
|
74
81
|
}): RunnerSandboxScope;
|
package/dist/runner/scope.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
// The sandbox scope: owns every sandbox one run creates, so however the run ends, each one is stopped and deleted, but
|
|
2
|
-
// for the runner sandbox, which it keeps running for the
|
|
3
|
-
// to it. Closing waits briefly for work in flight first: a create, so the sandbox it returns
|
|
4
|
-
// until its timeout, and a snapshot save, so the build isn't thrown away.
|
|
2
|
+
// for the runner sandbox, which it keeps running for the keep time its owner gives as it closes, when that is above 0,
|
|
3
|
+
// so a person can connect to it. Closing waits briefly for work in flight first: a create, so the sandbox it returns
|
|
4
|
+
// doesn't outlive the run until its timeout, and a snapshot save, so the build isn't thrown away.
|
|
5
5
|
/** How long closing waits for a create in flight: 20 seconds. */
|
|
6
6
|
export const CREATE_SETTLE_MS = 20_000;
|
|
7
7
|
/** How long closing waits for a runner snapshot still saving: 2 minutes. */
|
|
8
8
|
export const SNAPSHOT_SETTLE_MS = 2 * 60_000;
|
|
9
|
-
/** How long `plan` keeps the runner sandbox running once the run ends
|
|
10
|
-
export function
|
|
11
|
-
return plan.kind === "keep" ? plan.ms :
|
|
9
|
+
/** How long `plan` keeps the runner sandbox running once the run ends without a save starting, in milliseconds. */
|
|
10
|
+
export function unsavedKeepMs(plan) {
|
|
11
|
+
return plan.kind === "keep" ? plan.ms : plan.otherwiseKeepMs;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
|
|
15
|
-
* runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
|
|
16
|
-
* rest when `keepMs` is 0.
|
|
15
|
+
* runner sandbox running `keepMs()` past closing (`context.clock` says when that is), or stops and deletes it with the
|
|
16
|
+
* rest when `keepMs()` is 0. It asks for the keep time as it closes, once its waits are over, since a save that starts
|
|
17
|
+
* after the scope opened takes the runner sandbox's keep time away (`session.ts`).
|
|
17
18
|
*/
|
|
18
19
|
export function runnerSandboxScope(context, progress, keep) {
|
|
19
20
|
const { runnerSandboxes: sandboxes, timer, clock } = context;
|
|
@@ -54,9 +55,10 @@ export function runnerSandboxScope(context, progress, keep) {
|
|
|
54
55
|
* when it can't, such as with a process that won't end, stops and deletes it as without a keep time.
|
|
55
56
|
*/
|
|
56
57
|
const keepOrRemove = async (sandbox) => {
|
|
57
|
-
|
|
58
|
+
const keepMs = sandbox.role === "runner" ? keep.keepMs() : 0;
|
|
59
|
+
if (keepMs <= 0)
|
|
58
60
|
return await stopAndRemove(sandbox);
|
|
59
|
-
const keeping = await sandboxes.keepRunning(sandbox, { until: new Date(clock.now().getTime() +
|
|
61
|
+
const keeping = await sandboxes.keepRunning(sandbox, { until: new Date(clock.now().getTime() + keepMs) });
|
|
60
62
|
if (!keeping.ok) {
|
|
61
63
|
notKept = { name: sandbox.name, message: failureMessage(keeping.failure) };
|
|
62
64
|
return await stopAndRemove(sandbox);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { MintTarget } from "../credential/index.ts";
|
|
2
|
+
import type { RunnerContext } from "./context.ts";
|
|
3
|
+
import type { RunnerProgress, RunnerSave } from "./events.ts";
|
|
4
|
+
import type { SandboxAccess } from "./gateways.ts";
|
|
5
|
+
import type { PreparedRunner } from "./prepare.ts";
|
|
6
|
+
import { type ReadyRunnerOutcome } from "./ready.ts";
|
|
7
|
+
import { type SandboxedCommandOutcome, type SandboxTestEvents } from "./sandboxed-command.ts";
|
|
8
|
+
import { type RunnerSandboxPlan, type RunnerScopeFacts } from "./scope.ts";
|
|
9
|
+
import type { RunnerSecrets } from "./secrets.ts";
|
|
10
|
+
/** What a run's runner session runs: the runner checked on this machine, where its sandboxes run, and what it keeps. */
|
|
11
|
+
export interface RunnerSessionRequest {
|
|
12
|
+
/** The runner checked on this machine (`prepareRunner`). */
|
|
13
|
+
readonly prepared: PreparedRunner;
|
|
14
|
+
/** The team and project the run's credential is minted for: the runner sandbox runs there. */
|
|
15
|
+
readonly target: MintTarget;
|
|
16
|
+
/** The local user name, for each sandbox's `user` tag. */
|
|
17
|
+
readonly user: string;
|
|
18
|
+
/**
|
|
19
|
+
* The runner secrets' values, read from this machine's environment as the run started: each recipe step gets the
|
|
20
|
+
* ones it names, the command gets none, and storm writes none to the run directory, the snapshot cache or `run.json`.
|
|
21
|
+
*/
|
|
22
|
+
readonly secrets: RunnerSecrets;
|
|
23
|
+
/**
|
|
24
|
+
* What the run does with the runner sandbox once it ends, decided before it starts: keep it running for the keep time
|
|
25
|
+
* (0 stops and deletes it), or, on a branch, save it as a branch snapshot once the command ends on its own (exiting 0,
|
|
26
|
+
* unless the plan saves always), and keep it running for the plan's other keep time when no save starts.
|
|
27
|
+
*/
|
|
28
|
+
readonly sandbox: RunnerSandboxPlan;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What the run hands its runner session for its cleanup. Each is the run's own, and each acts once, however often the
|
|
32
|
+
* session calls it: `startCleanup` reports cleanup's start, with what cleanup does with the runner sandbox, and
|
|
33
|
+
* `release` releases the run's resources, reporting cleanup's start first.
|
|
34
|
+
*/
|
|
35
|
+
export interface RunnerSessionCleanup {
|
|
36
|
+
readonly startCleanup: (runnerSandbox: RunnerSandboxPlan) => Promise<void>;
|
|
37
|
+
readonly release: (runnerSandbox: RunnerSandboxPlan) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** What closing a session's sandbox scope left, and the team and project its sandboxes are in: the run's target. */
|
|
40
|
+
export interface RunnerCleanupFacts extends RunnerScopeFacts {
|
|
41
|
+
readonly target: MintTarget;
|
|
42
|
+
}
|
|
43
|
+
/** How a session ended: how saving the runner sandbox as a branch snapshot did, and what closing left. */
|
|
44
|
+
export interface RunnerSessionEnd {
|
|
45
|
+
/**
|
|
46
|
+
* How the save ended; a detached HEAD's `skipped`, decided before the run, in a run that saves always; null when the
|
|
47
|
+
* run's plan saves nothing, or its save never started: the command didn't end on its own, or the plan doesn't save
|
|
48
|
+
* always and the command didn't exit 0 or the run started from a branch snapshot HEAD's commit saved.
|
|
49
|
+
*/
|
|
50
|
+
readonly save: RunnerSave | null;
|
|
51
|
+
readonly cleanup: RunnerCleanupFacts;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One run's runner session, open from before the run mints. Its stages run in this order: `ready`, then `runCommand`
|
|
55
|
+
* in the runner sandbox `ready` readied, then `finish`; `close` ends it however the run went. A signal stops the
|
|
56
|
+
* session in any stage: it says the run is stopping, then starts closing the scope at once.
|
|
57
|
+
*/
|
|
58
|
+
export interface RunnerSession {
|
|
59
|
+
/**
|
|
60
|
+
* Readies the runner sandbox: picks or builds a runner snapshot, starts the runner sandbox from it, uploads and
|
|
61
|
+
* applies the run's changes, and runs the install and build (`readyRunner`). `signal` stops it. Called once.
|
|
62
|
+
*/
|
|
63
|
+
ready(access: SandboxAccess, signal: AbortSignal): Promise<ReadyRunnerOutcome>;
|
|
64
|
+
/**
|
|
65
|
+
* Runs the command in the runner sandbox `ready` readied (`runCommandInSandbox`); the run's signal kills it. It
|
|
66
|
+
* throws when `ready` hasn't answered `ready`, a mistake in the caller.
|
|
67
|
+
*/
|
|
68
|
+
runCommand(request: {
|
|
69
|
+
readonly argv: readonly string[];
|
|
70
|
+
readonly runPayload: string;
|
|
71
|
+
readonly testEvents?: SandboxTestEvents;
|
|
72
|
+
}): Promise<SandboxedCommandOutcome>;
|
|
73
|
+
/**
|
|
74
|
+
* Ends the session once the run is done in the runner sandbox. Under a `save` plan, when the command ended on its own
|
|
75
|
+
* and no signal arrived, it saves the runner sandbox as a branch snapshot while the run's resources are released, and
|
|
76
|
+
* the save settles before the scope closes, even when releasing them throws; a plan that doesn't save always saves
|
|
77
|
+
* nothing when the command didn't exit 0, so a person can connect to the runner sandbox a failed command ran in, or
|
|
78
|
+
* when the run started from a branch snapshot HEAD's commit saved. Then it reports cleanup's start, with
|
|
79
|
+
* the plan it acted on, closes the scope, and releases the resources, which a run without a save does only once the
|
|
80
|
+
* scope is closed. A run whose save never started keeps its runner sandbox for the plan's other keep time.
|
|
81
|
+
*/
|
|
82
|
+
finish(): Promise<RunnerSessionEnd>;
|
|
83
|
+
/**
|
|
84
|
+
* Stops listening for the signal, closes the scope and releases the run's resources, with the keep time of a run
|
|
85
|
+
* whose save never started, even when closing throws. Closing is memoized: once `finish` closed the scope, it
|
|
86
|
+
* answers that close's report, and once the resources are released, releasing them does nothing. For a run that
|
|
87
|
+
* throws.
|
|
88
|
+
*/
|
|
89
|
+
close(): Promise<RunnerCleanupFacts>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Opens a run's runner session over `context`, reporting to `progress`: it opens the sandbox scope, which asks the
|
|
93
|
+
* session for the keep time as it closes, and listens for `signal`. The keep time is the plan's until a save starts,
|
|
94
|
+
* and 0 from then on, however the save ends: the save resets the runner sandbox's working tree. On its first abort,
|
|
95
|
+
* the session reports `stopping`, with whether the command runs and that keep time, before the scope starts to close.
|
|
96
|
+
*/
|
|
97
|
+
export declare function openRunnerSession(context: RunnerContext, request: RunnerSessionRequest, control: {
|
|
98
|
+
readonly signal: AbortSignal;
|
|
99
|
+
readonly cleanup: RunnerSessionCleanup;
|
|
100
|
+
}, progress: RunnerProgress): RunnerSession;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// A runner session: everything one run does in its runner sandbox, in order. It owns the run's sandbox scope from
|
|
2
|
+
// before the run mints to the run's end, readies the runner sandbox, runs the command in the sandbox it readied, saves
|
|
3
|
+
// that sandbox as a branch snapshot beside the release of the run's resources, and closes the scope before it
|
|
4
|
+
// releases them otherwise. The run hands it what releasing its resources and reporting cleanup's start take. It alone
|
|
5
|
+
// says whether the runner sandbox is kept: the scope and the stopping line both ask it.
|
|
6
|
+
import { readyRunner } from "./ready.js";
|
|
7
|
+
import { runCommandInSandbox } from "./sandboxed-command.js";
|
|
8
|
+
import { runnerSandboxScope, unsavedKeepMs } from "./scope.js";
|
|
9
|
+
import { isBranchEntry } from "./snapshot-cache.js";
|
|
10
|
+
import { saveBranchSnapshot } from "./snapshot-save.js";
|
|
11
|
+
/** Whether `runner` started from a branch snapshot a run at HEAD commit `head` saved. */
|
|
12
|
+
function savedAt(runner, head) {
|
|
13
|
+
const { startedFrom } = runner;
|
|
14
|
+
return isBranchEntry(startedFrom) && startedFrom.head === head;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Opens a run's runner session over `context`, reporting to `progress`: it opens the sandbox scope, which asks the
|
|
18
|
+
* session for the keep time as it closes, and listens for `signal`. The keep time is the plan's until a save starts,
|
|
19
|
+
* and 0 from then on, however the save ends: the save resets the runner sandbox's working tree. On its first abort,
|
|
20
|
+
* the session reports `stopping`, with whether the command runs and that keep time, before the scope starts to close.
|
|
21
|
+
*/
|
|
22
|
+
export function openRunnerSession(context, request, control, progress) {
|
|
23
|
+
const { signal, cleanup } = control;
|
|
24
|
+
const plan = request.sandbox;
|
|
25
|
+
// What cleanup does with the runner sandbox when no save starts: it keeps it for the plan's keep time.
|
|
26
|
+
const unsaved = { kind: "keep", ms: unsavedKeepMs(plan) };
|
|
27
|
+
// Set in the same turn as the checks that let a save start, so the stopping line and the scope, which both read
|
|
28
|
+
// `keepMs`, never disagree about the runner sandbox.
|
|
29
|
+
let saveStarted = false;
|
|
30
|
+
const keepMs = () => (saveStarted ? 0 : unsaved.ms);
|
|
31
|
+
const scope = runnerSandboxScope(context, progress, { keepMs });
|
|
32
|
+
const closeScope = async () => ({ ...(await scope.close()), target: request.target });
|
|
33
|
+
let readying = false;
|
|
34
|
+
let readied;
|
|
35
|
+
let commandRunning = false;
|
|
36
|
+
// The runner sandbox the command ended in on its own, the one a save saves, and the exit code it ended with.
|
|
37
|
+
let ended;
|
|
38
|
+
// Said before the close starts, so the stopping line comes before any line the close's waits print.
|
|
39
|
+
const stop = () => {
|
|
40
|
+
void progress.emit({ kind: "stopping", commandRunning, keepMs: keepMs() }).catch(() => undefined);
|
|
41
|
+
void scope.close().catch(() => undefined);
|
|
42
|
+
};
|
|
43
|
+
if (signal.aborted)
|
|
44
|
+
stop();
|
|
45
|
+
else
|
|
46
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
47
|
+
return {
|
|
48
|
+
async ready(access, laneSignal) {
|
|
49
|
+
if (readying)
|
|
50
|
+
throw new Error("the runner session readies its runner sandbox once");
|
|
51
|
+
readying = true;
|
|
52
|
+
const outcome = await readyRunner(context, { prepared: request.prepared, access, user: request.user, secrets: request.secrets }, { scope, signal: laneSignal }, progress);
|
|
53
|
+
if (outcome.kind === "ready")
|
|
54
|
+
readied = outcome.runner;
|
|
55
|
+
return outcome;
|
|
56
|
+
},
|
|
57
|
+
async runCommand(command) {
|
|
58
|
+
if (readied === undefined)
|
|
59
|
+
throw new Error("the runner session's runner sandbox isn't ready");
|
|
60
|
+
commandRunning = true;
|
|
61
|
+
const ran = await runCommandInSandbox(context, {
|
|
62
|
+
runner: readied,
|
|
63
|
+
argv: command.argv,
|
|
64
|
+
runPayload: command.runPayload,
|
|
65
|
+
...(command.testEvents === undefined ? {} : { testEvents: command.testEvents }),
|
|
66
|
+
}, { kill: signal }, progress);
|
|
67
|
+
if (ran.kind === "exited")
|
|
68
|
+
ended = { runner: readied, exitCode: ran.exitCode };
|
|
69
|
+
return ran;
|
|
70
|
+
},
|
|
71
|
+
async finish() {
|
|
72
|
+
commandRunning = false;
|
|
73
|
+
const { prepared } = request;
|
|
74
|
+
let save = prepared.save?.kind === "skipped" ? prepared.save : null;
|
|
75
|
+
let action = unsaved;
|
|
76
|
+
if (plan.kind === "save" &&
|
|
77
|
+
ended !== undefined &&
|
|
78
|
+
!signal.aborted &&
|
|
79
|
+
(plan.always || (ended.exitCode === 0 && !savedAt(ended.runner, prepared.head.commit)))) {
|
|
80
|
+
saveStarted = true;
|
|
81
|
+
action = plan;
|
|
82
|
+
const saving = saveBranchSnapshot(context, { ready: ended.runner, branch: plan.branch, head: prepared.head.commit }, { scope, signal }, progress);
|
|
83
|
+
// The save settles before the scope closes, even when releasing the resources threw.
|
|
84
|
+
try {
|
|
85
|
+
await cleanup.release(plan);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
save = await saving;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
await cleanup.startCleanup(action);
|
|
92
|
+
const facts = await closeScope();
|
|
93
|
+
signal.removeEventListener("abort", stop);
|
|
94
|
+
// A no-op after a save, which released the resources while it ran.
|
|
95
|
+
await cleanup.release(action);
|
|
96
|
+
return { save, cleanup: facts };
|
|
97
|
+
},
|
|
98
|
+
async close() {
|
|
99
|
+
signal.removeEventListener("abort", stop);
|
|
100
|
+
try {
|
|
101
|
+
// Memoized: a no-op once `finish` closed it, and the cleanup when the run threw.
|
|
102
|
+
return await closeScope();
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
await cleanup.release(unsaved);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -34,8 +34,9 @@ type BranchSnapshotSave = Exclude<RunnerSave, {
|
|
|
34
34
|
readonly kind: "skipped";
|
|
35
35
|
}>;
|
|
36
36
|
/**
|
|
37
|
-
* Saves the runner sandbox, once the command ended, as a branch snapshot of the run's branch. The
|
|
38
|
-
* scope no keep time (`
|
|
37
|
+
* Saves the runner sandbox, once the command ended, as a branch snapshot of the run's branch. The session gives the
|
|
38
|
+
* scope no keep time once a save starts (`session.ts`), so however the save ends, closing stops and deletes the
|
|
39
|
+
* sandbox. It resets
|
|
39
40
|
* the working tree to the base the sandbox started from, leaving `.git` alone, empties the temp directories, saves the
|
|
40
41
|
* sandbox as a runner snapshot, which the scope then deletes, and records the entry: the started-from entry's owner,
|
|
41
42
|
* recipe, snapshot key and base, with the branch, the HEAD commit and the checkout's root. Its entry replaces the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Saving the runner sandbox as a branch snapshot once its command ended
|
|
2
|
-
//
|
|
3
|
-
//
|
|
1
|
+
// Saving the runner sandbox as a branch snapshot once its command ended: reset the working tree to its base and empty
|
|
2
|
+
// the temp directories, save the sandbox as a runner snapshot, and record it in the cache for the run's branch in its
|
|
3
|
+
// checkout. The snapshot keeps the rest of what the command and the recipe's steps
|
|
4
4
|
// left, a resource's token or a runner secret they wrote included.
|
|
5
5
|
import { lineSplitter, outputTail, splitLines } from "./output.js";
|
|
6
6
|
import { SNAPSHOT_EXPIRATION_MS } from "./snapshot-cache.js";
|
|
@@ -42,8 +42,9 @@ export function scrubTempScript(directories = TEMP_DIRECTORIES) {
|
|
|
42
42
|
].join("\n");
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Saves the runner sandbox, once the command ended, as a branch snapshot of the run's branch. The
|
|
46
|
-
* scope no keep time (`
|
|
45
|
+
* Saves the runner sandbox, once the command ended, as a branch snapshot of the run's branch. The session gives the
|
|
46
|
+
* scope no keep time once a save starts (`session.ts`), so however the save ends, closing stops and deletes the
|
|
47
|
+
* sandbox. It resets
|
|
47
48
|
* the working tree to the base the sandbox started from, leaving `.git` alone, empties the temp directories, saves the
|
|
48
49
|
* sandbox as a runner snapshot, which the scope then deletes, and records the entry: the started-from entry's owner,
|
|
49
50
|
* recipe, snapshot key and base, with the branch, the HEAD commit and the checkout's root. Its entry replaces the
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Whether the launcher runs in CI, one rule for storm's own commands and an extension's.
|
|
2
|
+
/** Whether `env`'s `CI` is set, as CI services set it: to anything but empty, `0` or `false`. */
|
|
3
|
+
export function isCi(env) {
|
|
4
|
+
const ci = env["CI"];
|
|
5
|
+
return ci !== undefined && ci !== "" && ci !== "0" && ci.toLowerCase() !== "false";
|
|
6
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
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
|
-
* What an extension's author declares of its commands:
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* What an extension's author declares of its commands: its command tree, whose commands take `App`, the tree's own app;
|
|
5
|
+
* `app`, which projects it from `LauncherApp`, what the mount reads of the launcher's app; the help header of the group
|
|
6
|
+
* storm mounts it as; and the tree's directory. The path of that group is the registry's (`src/extension-commands.ts`),
|
|
7
|
+
* not the extension's.
|
|
7
8
|
*/
|
|
8
|
-
export interface ExtensionCommandsDefinition<
|
|
9
|
-
/**
|
|
10
|
-
readonly extension: Name;
|
|
11
|
-
/** What the extension adds, in a sentence: the help header of its `storm ext <name>` group. */
|
|
9
|
+
export interface ExtensionCommandsDefinition<LauncherApp, App> {
|
|
10
|
+
/** What the extension adds, in a sentence: the help header of the group storm mounts its commands as. */
|
|
12
11
|
readonly description: string;
|
|
13
12
|
readonly tree: CommandTree<App>;
|
|
14
13
|
/**
|
|
@@ -28,8 +27,7 @@ export interface ExtensionCommandsDefinition<Name extends string, LauncherApp, A
|
|
|
28
27
|
* gives, at the path the launcher gives, with the extension's description and the projection. A launcher that types its
|
|
29
28
|
* mounts with its own app compiles only while that app is a `LauncherApp`.
|
|
30
29
|
*/
|
|
31
|
-
export interface ExtensionCommands<
|
|
32
|
-
readonly extension: Name;
|
|
30
|
+
export interface ExtensionCommands<LauncherApp> {
|
|
33
31
|
readonly description: string;
|
|
34
32
|
readonly directory: string;
|
|
35
33
|
readonly mount: (placement: {
|
|
@@ -38,7 +36,7 @@ export interface ExtensionCommands<Name extends string, LauncherApp> {
|
|
|
38
36
|
}) => Mount<LauncherApp>;
|
|
39
37
|
}
|
|
40
38
|
/** Declares an extension's commands. Only this function calls Clinkr's `mount`, since it knows the tree's app type. */
|
|
41
|
-
export declare function defineExtensionCommands<
|
|
39
|
+
export declare function defineExtensionCommands<LauncherApp, App>(definition: ExtensionCommandsDefinition<LauncherApp, App>): ExtensionCommands<LauncherApp>;
|
|
42
40
|
/** A Clinkr example written as `{ argv, description? }`: the arguments after the command's name, and what it does. */
|
|
43
41
|
interface ClinkrExample {
|
|
44
42
|
readonly argv: string;
|
|
@@ -61,11 +59,11 @@ interface NamedResource {
|
|
|
61
59
|
export interface Extension<Name extends string, Resources extends readonly NamedResource[], LauncherApp> {
|
|
62
60
|
readonly name: Name;
|
|
63
61
|
readonly resources: Resources;
|
|
64
|
-
readonly commands?: ExtensionCommands<
|
|
62
|
+
readonly commands?: ExtensionCommands<LauncherApp>;
|
|
65
63
|
readonly examples?: RunExamples;
|
|
66
64
|
}
|
|
67
65
|
/**
|
|
68
|
-
* Declares an extension. Its name is
|
|
69
|
-
*
|
|
66
|
+
* Declares an extension. Its name is one command word. Each of its resources comes from `defineResource`, and it may
|
|
67
|
+
* have none, when it brings only commands. Where its commands go is the registry's choice (`src/extension-commands.ts`).
|
|
70
68
|
*/
|
|
71
69
|
export declare function defineExtension<const Name extends string, const Resources extends readonly NamedResource[], LauncherApp = unknown>(extension: Extension<Name, Resources, LauncherApp>): Extension<Name, Resources, LauncherApp>;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// which loads only Clinkr. An extension's `extension.ts` joins its resources with its command tree and its run
|
|
4
4
|
// examples here, so a published resource export, which loads only the resource, never reaches Clinkr. Its
|
|
5
5
|
// `command-tree.ts` declares its commands with `defineExtensionCommands`, and `src/extension-commands.ts` mounts them
|
|
6
|
-
// without loading the extension's resources, so help never loads the registry. The
|
|
6
|
+
// without loading the extension's resources, so help never loads the registry. The extension doesn't choose where its
|
|
7
|
+
// commands go: `src/extension-commands.ts` gives each tree its path. The registry (`src/extensions.ts`) lists
|
|
7
8
|
// the extensions and takes their resources in order, and `exec`'s and `vitest`'s help lists their run examples in that
|
|
8
9
|
// order. Its commands declare their tree, metadata and outcomes with what this entry re-exports of Clinkr
|
|
9
10
|
// (`commandTree`, `CommandMetadata`, `defineOutcomes`, `renderOutcome`, `Row`, `Warning`), so no extension folder
|
|
@@ -14,17 +15,16 @@ import { mount } from "@vercel/clinkr";
|
|
|
14
15
|
export { commandTree, defineOutcomes, renderOutcome, } from "@vercel/clinkr";
|
|
15
16
|
/** Declares an extension's commands. Only this function calls Clinkr's `mount`, since it knows the tree's app type. */
|
|
16
17
|
export function defineExtensionCommands(definition) {
|
|
17
|
-
const {
|
|
18
|
+
const { description, tree, directory, app } = definition;
|
|
18
19
|
return {
|
|
19
|
-
extension,
|
|
20
20
|
description,
|
|
21
21
|
directory,
|
|
22
22
|
mount: ({ path, root }) => mount(tree.directory(join(root, directory)), { path, description, app }),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* Declares an extension. Its name is
|
|
27
|
-
*
|
|
26
|
+
* Declares an extension. Its name is one command word. Each of its resources comes from `defineResource`, and it may
|
|
27
|
+
* have none, when it brings only commands. Where its commands go is the registry's choice (`src/extension-commands.ts`).
|
|
28
28
|
*/
|
|
29
29
|
export function defineExtension(extension) {
|
|
30
30
|
return extension;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { isCi } from "./ci.ts";
|
|
1
2
|
export { Credential, type GitHubActionsClaims, type VercelProject } from "./credential.ts";
|
|
2
3
|
export { type CredentialDiagnosis, describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, } from "./credential-diagnosis.ts";
|
|
3
4
|
export type { CredentialFailure, CredentialOrigin, CredentialOutcome, CredentialSource, MintFailure, MintStep, MintTarget, TokenAttemptFailure, TokenRequestFailure, TokenRequestVariable, } from "./credential-source.ts";
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
// launcher module, which `test/integration/extension-api-clinkr-free.integration.test.ts` holds, and nothing of
|
|
31
31
|
// `commands.ts`, even for types, so its declarations reach no Clinkr either
|
|
32
32
|
// (`test/integration/package-types.integration.test.ts`).
|
|
33
|
+
export { isCi } from "./ci.js";
|
|
33
34
|
export { Credential } from "./credential.js";
|
|
34
35
|
export { describeCredentialFailure, describeMintFailure, describeTokenRequestFailure, } from "./credential-diagnosis.js";
|
|
35
36
|
export { tokenRequestFailureFacts, tokenRequestFailureShape } from "./token-request-facts.js";
|
|
@@ -89,9 +89,10 @@ export type Report<Event = never> = [Event] extends [never] ? ReportLines : Repo
|
|
|
89
89
|
* What `acquireForRun` works from, beside its world: only what the launcher owns.
|
|
90
90
|
*
|
|
91
91
|
* - `options` and `secrets`: its resolved options, and the secrets its `beforeRun` handed the run.
|
|
92
|
-
* - `credential`: the run's credential source, which it calls `obtain()` on only when it needs a credential
|
|
93
|
-
*
|
|
94
|
-
*
|
|
92
|
+
* - `credential`: the run's credential source, which it calls `obtain()` on only when it needs a credential, and which
|
|
93
|
+
* the launcher builds once and reports (`minting`, `minted`, `requesting-token`): the mint the run already obtained
|
|
94
|
+
* for its runner sandbox, when it has one, which hands back that one mint's outcome; else the source the run's
|
|
95
|
+
* credential choice names.
|
|
95
96
|
* Undefined when the run chose no source, which it does only when it has no runner sandbox and no resource's
|
|
96
97
|
* `beforeRun` said it needs the Vercel credential (`ResourceUse.needsVercelCredential`).
|
|
97
98
|
* - `take`: what it calls with each thing it takes (`Taken`), as soon as it holds it and before any other await, so the
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
// waterfall, and draws itself: its live row, its final form, its waterfall label and steps, and its events as plain
|
|
4
4
|
// lines and as the live view's notices. A extension folder writes its progress against its own event, lane-state and
|
|
5
5
|
// step types, and its `defineResource` carries it; the core sees it with its defaults, `unknown` events over a span
|
|
6
|
-
// (`ResourceProgress`). The run's state applies every event through the resource definitions (
|
|
7
|
-
// resource instance's to its own lane state. It names no resource.
|
|
6
|
+
// (`ResourceProgress`). The run's state applies every event through the registry's resource definitions (its
|
|
7
|
+
// `applyEvent`), each resource instance's to its own lane state. It names no resource.
|
|
8
8
|
export {};
|
|
@@ -37,6 +37,6 @@ export function defineResource(spec) {
|
|
|
37
37
|
// The one cast: the core's view of the resource's own functions, whose parameters are the resource's types and
|
|
38
38
|
// which the core calls with `unknown`. It rests on the core's routing: the core hands each world, thing taken, event,
|
|
39
39
|
// lane state and record back only to the definition or resource instance that produced it, by its definition's name
|
|
40
|
-
// or its resource key (`core/
|
|
40
|
+
// or its resource key (`core/definition-lookup.ts`), which `test/unit/core/resource-events.test.ts` holds.
|
|
41
41
|
return definition;
|
|
42
42
|
}
|
package/dist/story/align.d.ts
CHANGED
|
@@ -32,6 +32,6 @@ export declare function callKey(call: Pick<StoryCall, "agent" | "tool" | "input"
|
|
|
32
32
|
* call followed by one unrecorded call.
|
|
33
33
|
*
|
|
34
34
|
* Calls too many to compare (`MAX_SEQUENCE_CELLS`) are a `RangeError`, not every call unmade and unrecorded: that
|
|
35
|
-
* would hide each divergence among them as a stale entry, which `
|
|
35
|
+
* would hide each divergence among them as a stale entry, which the answers level `add` rewrites.
|
|
36
36
|
*/
|
|
37
37
|
export declare function alignCalls(recorded: readonly StoryCall[], live: readonly StoryCall[]): readonly StoryAlignedCall[];
|
package/dist/story/align.js
CHANGED
|
@@ -13,7 +13,7 @@ export function callKey(call) {
|
|
|
13
13
|
* call followed by one unrecorded call.
|
|
14
14
|
*
|
|
15
15
|
* Calls too many to compare (`MAX_SEQUENCE_CELLS`) are a `RangeError`, not every call unmade and unrecorded: that
|
|
16
|
-
* would hide each divergence among them as a stale entry, which `
|
|
16
|
+
* would hide each divergence among them as a stale entry, which the answers level `add` rewrites.
|
|
17
17
|
*/
|
|
18
18
|
export function alignCalls(recorded, live) {
|
|
19
19
|
const diff = diffSequences(recorded.map(callKey), live.map(callKey));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** A command line the harness can't split into words: the story or
|
|
1
|
+
/** A command line the harness can't split into words, or one that names no program: the story or `--bin` wrote it. */
|
|
2
2
|
export declare class InvalidCommandLine extends Error {
|
|
3
3
|
readonly name = "InvalidCommandLine";
|
|
4
4
|
}
|
|
@@ -15,20 +15,10 @@ export interface StoryExecutable {
|
|
|
15
15
|
readonly file: string;
|
|
16
16
|
readonly args: readonly string[];
|
|
17
17
|
}
|
|
18
|
-
/** Where `storyExecutable` reads the executable a harness invokes. */
|
|
19
|
-
export interface StoryExecutableOptions {
|
|
20
|
-
/** The environment variable that names another executable, such as `SLOT_STORY_BIN`. */
|
|
21
|
-
readonly variable: string;
|
|
22
|
-
readonly env: Readonly<Record<string, string | undefined>>;
|
|
23
|
-
/** The executable when the variable is unset or empty: the package's own. */
|
|
24
|
-
readonly fallback: StoryExecutable;
|
|
25
|
-
/** The directory a relative program word resolves against: the one the tests run from, never a story's cwd. */
|
|
26
|
-
readonly base: string;
|
|
27
|
-
}
|
|
28
18
|
/**
|
|
29
|
-
* The executable `
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
19
|
+
* The executable `commandLine` names, split as `splitCommandLine` splits a story's command: its first word is the
|
|
20
|
+
* program, and the rest come before the story's arguments. A program word with a `/` that isn't absolute resolves
|
|
21
|
+
* against `base`; a word without one stays as it is, for `PATH` to find. A command line that doesn't split, or holds
|
|
22
|
+
* only whitespace, throws `InvalidCommandLine`.
|
|
33
23
|
*/
|
|
34
|
-
export declare function
|
|
24
|
+
export declare function resolveStoryExecutable(commandLine: string, base: string): StoryExecutable;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// Command lines a harness splits without a shell: a story's command, and the executable
|
|
2
|
-
// place of the package's own, such as a port of the tool to another language. Pure.
|
|
1
|
+
// Command lines a harness splits without a shell: a story's command, and the executable `storm story run --bin` names
|
|
2
|
+
// in place of the package's own, such as a port of the tool to another language. Pure. It loads only Node builtins,
|
|
3
|
+
// never vitest, so `storm story run` resolves `--bin` with `resolveStoryExecutable` once, before the stories run.
|
|
3
4
|
import { isAbsolute, resolve } from "node:path";
|
|
4
|
-
/** A command line the harness can't split into words: the story or
|
|
5
|
+
/** A command line the harness can't split into words, or one that names no program: the story or `--bin` wrote it. */
|
|
5
6
|
export class InvalidCommandLine extends Error {
|
|
6
7
|
name = "InvalidCommandLine";
|
|
7
8
|
}
|
|
@@ -73,28 +74,15 @@ export function splitCommandLine(command) {
|
|
|
73
74
|
return words;
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
|
-
* The executable `
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
77
|
+
* The executable `commandLine` names, split as `splitCommandLine` splits a story's command: its first word is the
|
|
78
|
+
* program, and the rest come before the story's arguments. A program word with a `/` that isn't absolute resolves
|
|
79
|
+
* against `base`; a word without one stays as it is, for `PATH` to find. A command line that doesn't split, or holds
|
|
80
|
+
* only whitespace, throws `InvalidCommandLine`.
|
|
80
81
|
*/
|
|
81
|
-
export function
|
|
82
|
-
const
|
|
83
|
-
if (commandLine === undefined || commandLine === "")
|
|
84
|
-
return fallback;
|
|
85
|
-
let words;
|
|
86
|
-
try {
|
|
87
|
-
words = splitCommandLine(commandLine);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
throw new Error(`${variable} ${errorText(error)}`, { cause: error });
|
|
91
|
-
}
|
|
92
|
-
const [program, ...args] = words;
|
|
82
|
+
export function resolveStoryExecutable(commandLine, base) {
|
|
83
|
+
const [program, ...args] = splitCommandLine(commandLine);
|
|
93
84
|
if (program === undefined)
|
|
94
|
-
throw new
|
|
85
|
+
throw new InvalidCommandLine(`${JSON.stringify(commandLine)} names no program`);
|
|
95
86
|
const file = program.includes("/") && !isAbsolute(program) ? resolve(base, program) : program;
|
|
96
87
|
return { file, args };
|
|
97
88
|
}
|
|
98
|
-
function errorText(error) {
|
|
99
|
-
return error instanceof Error ? error.message : String(error);
|
|
100
|
-
}
|
package/dist/story/errors.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class StoryDivergenceError extends Error {
|
|
|
6
6
|
readonly stale: readonly StoryStaleEntry[];
|
|
7
7
|
constructor(report: string, divergences: readonly StoryDivergence[], stale: readonly StoryStaleEntry[]);
|
|
8
8
|
}
|
|
9
|
-
/** A story's recording no longer fits it, and `
|
|
9
|
+
/** A story's recording no longer fits it, and the answers level `check` may not change it. */
|
|
10
10
|
export declare class StoryStaleError extends Error {
|
|
11
11
|
readonly name = "StoryStaleError";
|
|
12
12
|
readonly stale: readonly StoryStaleEntry[];
|