@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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* The live terminal command gateway: spawns `argv[0]` with the rest of `argv` in `cwd`, no shell, the given
|
|
4
|
+
* environment only, and storm's own stdin, stdout and stderr. The command runs in storm's process group, so Ctrl+C and
|
|
5
|
+
* a closed terminal reach it directly. Aborting `terminate` sends SIGTERM. It settles once the process has exited. An
|
|
6
|
+
* `error` before the process spawns (ENOENT, EACCES, a missing `cwd`) is `spawn-failed`.
|
|
7
|
+
*/
|
|
8
|
+
export function liveTerminalCommandGateway() {
|
|
9
|
+
return {
|
|
10
|
+
run: (request) => runInTerminal(request),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function runInTerminal(request) {
|
|
14
|
+
const [executable, ...args] = request.argv;
|
|
15
|
+
if (executable === undefined)
|
|
16
|
+
throw new Error("liveTerminalCommandGateway: the command's argv is empty");
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
let started = false;
|
|
19
|
+
let settled = false;
|
|
20
|
+
const settle = (outcome) => {
|
|
21
|
+
if (settled)
|
|
22
|
+
return;
|
|
23
|
+
settled = true;
|
|
24
|
+
request.terminate.removeEventListener("abort", onTerminate);
|
|
25
|
+
resolve(outcome);
|
|
26
|
+
};
|
|
27
|
+
const command = spawn(executable, args, {
|
|
28
|
+
cwd: request.cwd,
|
|
29
|
+
stdio: "inherit",
|
|
30
|
+
shell: false,
|
|
31
|
+
env: { ...request.env },
|
|
32
|
+
});
|
|
33
|
+
const onTerminate = () => {
|
|
34
|
+
if (started)
|
|
35
|
+
command.kill("SIGTERM");
|
|
36
|
+
};
|
|
37
|
+
command.once("spawn", () => {
|
|
38
|
+
started = true;
|
|
39
|
+
if (request.terminate.aborted)
|
|
40
|
+
command.kill("SIGTERM");
|
|
41
|
+
});
|
|
42
|
+
command.once("error", (error) => {
|
|
43
|
+
if (!started)
|
|
44
|
+
settle({ kind: "spawn-failed", message: error.message });
|
|
45
|
+
});
|
|
46
|
+
command.once("exit", (code, signal) => settle(signal !== null ? { kind: "signaled", signal } : { kind: "exited", code: code ?? 0 }));
|
|
47
|
+
request.terminate.addEventListener("abort", onTerminate, { once: true });
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { LaneDraw, LaneStates,
|
|
1
|
+
import type { LaneDraw, LaneStates, ResourceNotice, Span } from "../sdk/extension/index.ts";
|
|
2
|
+
import type { DefinitionLookup } from "./definition-lookup.ts";
|
|
2
3
|
import type { ResourceEvent } from "./resource.ts";
|
|
3
4
|
/**
|
|
4
5
|
* One resource instance's lane as the views draw it, bound to its resource key: each operation reads the lane's state
|
|
@@ -52,5 +53,5 @@ export interface ResourcePresentations {
|
|
|
52
53
|
readonly laneKinds: readonly LaneKind[];
|
|
53
54
|
lanes(instances: readonly PresentedInstance[]): readonly PresentedLane[];
|
|
54
55
|
}
|
|
55
|
-
/** Every one of `
|
|
56
|
-
export declare function resourcePresentations(
|
|
56
|
+
/** Every one of `lookup`'s definitions' presentations, each instance's from its definition. */
|
|
57
|
+
export declare function resourcePresentations(lookup: DefinitionLookup): ResourcePresentations;
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// resource instance to its definition, whose progress reads the run's maps by the resource key. It hands each
|
|
3
3
|
// progress's `plain` the launcher's `seconds` formatter. A resource without progress reports its lines itself
|
|
4
4
|
// (`resource-notice`), which the views print as they are, and every resource its warnings (`resource-warning`), which
|
|
5
|
-
// they mark as warnings.
|
|
6
|
-
import { resourceRegistry } from "./resource-registry.js";
|
|
5
|
+
// they mark as warnings. The registry builds the presentations once (`resourceRegistry`, `resource-registry.ts`).
|
|
7
6
|
import { secondsOf, secondsText } from "./timing.js";
|
|
8
7
|
/** `ms` as progress shows it: seconds to one decimal and `s`, the formatter each presentation's `plain` gets. */
|
|
9
8
|
function seconds(ms) {
|
|
10
9
|
return secondsText(secondsOf(ms));
|
|
11
10
|
}
|
|
12
|
-
/** Every one of `
|
|
13
|
-
export function resourcePresentations(
|
|
14
|
-
const { named } =
|
|
11
|
+
/** Every one of `lookup`'s definitions' presentations, each instance's from its definition. */
|
|
12
|
+
export function resourcePresentations(lookup) {
|
|
13
|
+
const { definitions: resources, named } = lookup;
|
|
15
14
|
return {
|
|
16
15
|
plain: (options) => {
|
|
17
16
|
// Each resource's plain progress, made once for the run, since it may remember earlier events.
|
|
@@ -1,54 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly named: (definition: string, key: string) => ResourceDefinition;
|
|
13
|
-
/** Each of `map`'s resource instances with its definition, in registry order, then the map's order. */
|
|
14
|
-
readonly inRegistryOrder: <R extends {
|
|
15
|
-
readonly definition: string;
|
|
16
|
-
}>(map: {
|
|
17
|
-
readonly [key: string]: R;
|
|
18
|
-
}) => readonly InstanceOf<R>[];
|
|
19
|
-
}
|
|
20
|
-
/** `list`, in registry order, looked up by each one's name. */
|
|
21
|
-
export declare function resourceRegistry(list: readonly ResourceDefinition[]): ResourceRegistry;
|
|
22
|
-
/**
|
|
23
|
-
* A map of resource instances, by resource key, each record naming its definition beside its warnings: what the run's
|
|
24
|
-
* cleanup reports of the instances it released.
|
|
25
|
-
*/
|
|
26
|
-
export interface InstanceWarnings {
|
|
27
|
-
readonly [key: string]: {
|
|
28
|
-
readonly definition: string;
|
|
29
|
-
readonly warnings: readonly Warning[];
|
|
30
|
-
};
|
|
31
|
-
}
|
|
1
|
+
import type { ResourceDefinition } from "../sdk/extension/index.ts";
|
|
2
|
+
import { type ResourceLifecycles } from "./before-run.ts";
|
|
3
|
+
import { type DefinitionLookup } from "./definition-lookup.ts";
|
|
4
|
+
import type { TimedRunEvent } from "./events.ts";
|
|
5
|
+
import { type ResourcePresentations } from "./presentations.ts";
|
|
6
|
+
import type { ResourceWorlds } from "./resource.ts";
|
|
7
|
+
import { type ResourceReports } from "./resource-reports.ts";
|
|
8
|
+
import { type RunState } from "./run-state.ts";
|
|
9
|
+
import { type Timeline } from "./timeline.ts";
|
|
10
|
+
/** Where the registry keeps its lookup, which only the core reads. */
|
|
11
|
+
export declare const LOOKUP: unique symbol;
|
|
32
12
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
13
|
+
* Resource definitions, in registry order, and everything the launcher derives from them, in that order.
|
|
14
|
+
*
|
|
15
|
+
* - `definitions`: the definitions, in registry order.
|
|
16
|
+
* - `reports`: every definition's reports, for each resource instance a run's maps hold.
|
|
17
|
+
* - `presentations`: how every definition's instances show in a run's progress.
|
|
18
|
+
* - `applyEvent`: the run's state after `timed`, through the definitions' progress. A run's final state is
|
|
19
|
+
* `events.reduce(registry.applyEvent, EMPTY_RUN_STATE)`. An event of a definition the registry lacks reaches no lane.
|
|
20
|
+
* - `timeline`: a run's waterfall, from its final state, with each resource lane's row.
|
|
21
|
+
* - `lifecycles`: every definition's lifecycle, over its world from `worlds`, by its name: what a run calls before it
|
|
22
|
+
* starts. Each call builds each definition's lifecycle once.
|
|
23
|
+
* - `worlds`: every definition's world, by its name, each built from what the launcher supplies it over `env`, with its
|
|
24
|
+
* own state directory.
|
|
35
25
|
*/
|
|
36
|
-
export interface
|
|
37
|
-
readonly
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
export interface ResourceRegistry {
|
|
27
|
+
readonly definitions: readonly ResourceDefinition[];
|
|
28
|
+
readonly reports: ResourceReports;
|
|
29
|
+
readonly presentations: ResourcePresentations;
|
|
30
|
+
readonly applyEvent: (state: RunState, timed: TimedRunEvent) => RunState;
|
|
31
|
+
readonly timeline: (state: RunState) => Timeline;
|
|
32
|
+
readonly lifecycles: (worlds: ResourceWorlds) => ResourceLifecycles;
|
|
33
|
+
readonly worlds: (env: Readonly<Record<string, string | undefined>>) => ResourceWorlds;
|
|
34
|
+
/** The lookup of a definition by its name, which `executeRun` binds each resource instance with. */
|
|
35
|
+
readonly [LOOKUP]: DefinitionLookup;
|
|
42
36
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
* each record is `{ definition: name, facts, warnings }` of one of them, `facts` by the schema it is given. The core
|
|
46
|
-
* gives every definition `z.unknown()`, so `--json-schema` shows each instance's result facts as unknown, and storm
|
|
47
|
-
* reads them as recorded. A map with no definitions to hold is empty.
|
|
48
|
-
*/
|
|
49
|
-
export declare function instanceSchema(records: readonly (readonly [string, z.ZodType])[]): z.ZodType<InstanceFacts, InstanceFacts>;
|
|
50
|
-
/**
|
|
51
|
-
* The schema of a map of resource instances, by resource key, as the run's cleanup reports them: each record is
|
|
52
|
-
* `{ definition, warnings }`, `definition` one of `names`. A map with no definitions to hold is empty.
|
|
53
|
-
*/
|
|
54
|
-
export declare function cleanupInstanceSchema(names: readonly string[]): z.ZodType<InstanceWarnings, InstanceWarnings>;
|
|
37
|
+
/** The registry of `definitions`, in their order, each looked up by its name. */
|
|
38
|
+
export declare function resourceRegistry(definitions: readonly ResourceDefinition[]): ResourceRegistry;
|
|
@@ -1,57 +1,30 @@
|
|
|
1
|
-
// The registry
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// `
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
// The registry: the one value the core builds from a list of resource definitions, in registry order
|
|
2
|
+
// (`resourceRegistry`), which the composition layer builds once (`src/extensions.ts`) and every caller shares. It holds
|
|
3
|
+
// the definitions, their reports (`resource-reports.ts`) and their presentations (`presentations.ts`), the run's state
|
|
4
|
+
// and waterfall through their progress (`run-state.ts`, `timeline.ts`), their lifecycles over given worlds
|
|
5
|
+
// (`before-run.ts`), and their worlds built from a launcher environment (`launcher-supplies.ts`). It builds the lookup
|
|
6
|
+
// of a definition by its name once (`definition-lookup.ts`) and hands it to what it builds; the lookup stays the
|
|
7
|
+
// core's: `executeRun` reads it from the registry under `LOOKUP`, which `index.ts` doesn't export. It names no resource.
|
|
8
|
+
import { bindLifecycles } from "./before-run.js";
|
|
9
|
+
import { definitionLookup } from "./definition-lookup.js";
|
|
10
|
+
import { worldsOf } from "./launcher-supplies.js";
|
|
11
|
+
import { resourcePresentations } from "./presentations.js";
|
|
12
|
+
import { resourceReports } from "./resource-reports.js";
|
|
13
|
+
import { applyRunEvent } from "./run-state.js";
|
|
14
|
+
import { timeline } from "./timeline.js";
|
|
15
|
+
/** Where the registry keeps its lookup, which only the core reads. */
|
|
16
|
+
export const LOOKUP = Symbol("definition lookup");
|
|
17
|
+
/** The registry of `definitions`, in their order, each looked up by its name. */
|
|
18
|
+
export function resourceRegistry(definitions) {
|
|
19
|
+
const lookup = definitionLookup(definitions);
|
|
18
20
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
21
|
+
definitions,
|
|
22
|
+
reports: resourceReports(lookup),
|
|
23
|
+
presentations: resourcePresentations(lookup),
|
|
24
|
+
applyEvent: (state, timed) => applyRunEvent(definitions, state, timed),
|
|
25
|
+
timeline: (state) => timeline(definitions, state),
|
|
26
|
+
lifecycles: (worlds) => bindLifecycles(lookup, worlds),
|
|
27
|
+
worlds: (env) => worldsOf(definitions, env),
|
|
28
|
+
[LOOKUP]: lookup,
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
/** One warning, as outcomes report it: its reason and its sentence. */
|
|
31
|
-
const warningSchema = z.object({
|
|
32
|
-
/** Its snake_case reason. */
|
|
33
|
-
reason: z.string(),
|
|
34
|
-
message: z.string(),
|
|
35
|
-
});
|
|
36
|
-
/**
|
|
37
|
-
* The schema of a map of resource instances, by resource key, whose records are each definition's `[name, schema]`:
|
|
38
|
-
* each record is `{ definition: name, facts, warnings }` of one of them, `facts` by the schema it is given. The core
|
|
39
|
-
* gives every definition `z.unknown()`, so `--json-schema` shows each instance's result facts as unknown, and storm
|
|
40
|
-
* reads them as recorded. A map with no definitions to hold is empty.
|
|
41
|
-
*/
|
|
42
|
-
export function instanceSchema(records) {
|
|
43
|
-
const [first, ...rest] = records.map(([name, facts]) => z.object({ definition: z.literal(name), facts, warnings: z.array(warningSchema) }));
|
|
44
|
-
const record = first === undefined ? z.never() : z.discriminatedUnion("definition", [first, ...rest]);
|
|
45
|
-
return z.record(z.string(), record);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The schema of a map of resource instances, by resource key, as the run's cleanup reports them: each record is
|
|
49
|
-
* `{ definition, warnings }`, `definition` one of `names`. A map with no definitions to hold is empty.
|
|
50
|
-
*/
|
|
51
|
-
export function cleanupInstanceSchema(names) {
|
|
52
|
-
const [first, ...rest] = names;
|
|
53
|
-
const record = first === undefined
|
|
54
|
-
? z.never()
|
|
55
|
-
: z.object({ definition: z.enum([first, ...rest]), warnings: z.array(warningSchema) });
|
|
56
|
-
return z.record(z.string(), record);
|
|
57
|
-
}
|
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
2
|
+
import type { Row, Warning } from "../sdk/extension/index.ts";
|
|
3
|
+
import type { DefinitionLookup } from "./definition-lookup.ts";
|
|
4
4
|
import type { ResourceCleanupRecords, ResourceRanRecords } from "./resource.ts";
|
|
5
|
+
/**
|
|
6
|
+
* A map of resource instances, by resource key, each record naming its definition beside its warnings: what the run's
|
|
7
|
+
* cleanup reports of the instances it released.
|
|
8
|
+
*/
|
|
9
|
+
export interface InstanceWarnings {
|
|
10
|
+
readonly [key: string]: {
|
|
11
|
+
readonly definition: string;
|
|
12
|
+
readonly warnings: readonly Warning[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A map of resource instances, by resource key, each record naming its definition beside its `facts` and its
|
|
17
|
+
* warnings: what a `ran` outcome reports of a run's resource instances.
|
|
18
|
+
*/
|
|
19
|
+
export interface InstanceFacts {
|
|
20
|
+
readonly [key: string]: {
|
|
21
|
+
readonly definition: string;
|
|
22
|
+
readonly facts: unknown;
|
|
23
|
+
readonly warnings: readonly Warning[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The schema of a map of resource instances, by resource key, whose records are each definition's `[name, schema]`:
|
|
28
|
+
* each record is `{ definition: name, facts, warnings }` of one of them, `facts` by the schema it is given. The core
|
|
29
|
+
* gives every definition `z.unknown()`, so `--json-schema` shows each instance's result facts as unknown, and storm
|
|
30
|
+
* reads them as recorded. A map with no definitions to hold is empty.
|
|
31
|
+
*/
|
|
32
|
+
export declare function instanceSchema(records: readonly (readonly [string, z.ZodType])[]): z.ZodType<InstanceFacts, InstanceFacts>;
|
|
33
|
+
/**
|
|
34
|
+
* The schema of a map of resource instances, by resource key, as the run's cleanup reports them: each record is
|
|
35
|
+
* `{ definition, warnings }`, `definition` one of `names`. A map with no definitions to hold is empty.
|
|
36
|
+
*/
|
|
37
|
+
export declare function cleanupInstanceSchema(names: readonly string[]): z.ZodType<InstanceWarnings, InstanceWarnings>;
|
|
5
38
|
/**
|
|
6
39
|
* Every resource definition's reports, for each resource instance a run's maps hold.
|
|
7
40
|
*
|
|
@@ -32,5 +65,5 @@ export interface ResourceReports {
|
|
|
32
65
|
ranRows(ran: ResourceRanRecords): readonly Row[];
|
|
33
66
|
canceledLines(cleanup: ResourceCleanupRecords): readonly string[];
|
|
34
67
|
}
|
|
35
|
-
/** Every one of `
|
|
36
|
-
export declare function resourceReports(
|
|
68
|
+
/** Every one of `lookup`'s definitions' reports, each instance's from its definition. */
|
|
69
|
+
export declare function resourceReports(lookup: DefinitionLookup): ResourceReports;
|
|
@@ -4,13 +4,42 @@
|
|
|
4
4
|
// the warnings it reported there (`ResourceRanRecords`, `ResourceCleanupRecords`); everything else here derives from
|
|
5
5
|
// those warnings, in the launcher, not the resource, in the same words for every resource: the rows an error lists,
|
|
6
6
|
// the outcome's warnings and a canceled run's text. The rows and warnings derive from an outcome's data, its JSON,
|
|
7
|
-
// which holds each warning
|
|
7
|
+
// which holds each warning, by the schemas of a map of instances: a `ran` outcome's (`instanceSchema`), each
|
|
8
|
+
// `{ definition, facts, warnings }`, discriminated by `definition`, and the cleanup's (`cleanupInstanceSchema`), each
|
|
9
|
+
// `{ definition, warnings }`. The registry builds the reports once (`resourceRegistry`, `resource-registry.ts`).
|
|
8
10
|
import { z } from "zod";
|
|
9
11
|
import { warningRows } from "./reports.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/** One warning, as outcomes report it: its reason and its sentence. */
|
|
13
|
+
const warningSchema = z.object({
|
|
14
|
+
/** Its snake_case reason. */
|
|
15
|
+
reason: z.string(),
|
|
16
|
+
message: z.string(),
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* The schema of a map of resource instances, by resource key, whose records are each definition's `[name, schema]`:
|
|
20
|
+
* each record is `{ definition: name, facts, warnings }` of one of them, `facts` by the schema it is given. The core
|
|
21
|
+
* gives every definition `z.unknown()`, so `--json-schema` shows each instance's result facts as unknown, and storm
|
|
22
|
+
* reads them as recorded. A map with no definitions to hold is empty.
|
|
23
|
+
*/
|
|
24
|
+
export function instanceSchema(records) {
|
|
25
|
+
const [first, ...rest] = records.map(([name, facts]) => z.object({ definition: z.literal(name), facts, warnings: z.array(warningSchema) }));
|
|
26
|
+
const record = first === undefined ? z.never() : z.discriminatedUnion("definition", [first, ...rest]);
|
|
27
|
+
return z.record(z.string(), record);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The schema of a map of resource instances, by resource key, as the run's cleanup reports them: each record is
|
|
31
|
+
* `{ definition, warnings }`, `definition` one of `names`. A map with no definitions to hold is empty.
|
|
32
|
+
*/
|
|
33
|
+
export function cleanupInstanceSchema(names) {
|
|
34
|
+
const [first, ...rest] = names;
|
|
35
|
+
const record = first === undefined
|
|
36
|
+
? z.never()
|
|
37
|
+
: z.object({ definition: z.enum([first, ...rest]), warnings: z.array(warningSchema) });
|
|
38
|
+
return z.record(z.string(), record);
|
|
39
|
+
}
|
|
40
|
+
/** Every one of `lookup`'s definitions' reports, each instance's from its definition. */
|
|
41
|
+
export function resourceReports(lookup) {
|
|
42
|
+
const { definitions: resources, inRegistryOrder } = lookup;
|
|
14
43
|
// Each warning of `facts`' instances, in order.
|
|
15
44
|
const warningsOf = (facts) => inRegistryOrder(facts).flatMap(({ record }) => record.warnings.map(({ reason, message }) => ({ reason, message })));
|
|
16
45
|
return {
|
package/dist/core/resources.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CredentialSource } from "../credential/index.ts";
|
|
2
|
-
import type { LaneOutcome
|
|
2
|
+
import type { LaneOutcome } from "../sdk/extension/index.ts";
|
|
3
3
|
import type { RunEvent, RunProgress } from "./events.ts";
|
|
4
|
+
import type { DefinitionLookup } from "./definition-lookup.ts";
|
|
4
5
|
import type { RunInstance, ResourceCleanupRecords, ResourcePayloads, ResourceRanRecords, ResourceRefusal, ResourceRequests, ResourceWorlds, RunLane } from "./resource.ts";
|
|
5
6
|
import type { RunStopped } from "./run.ts";
|
|
6
7
|
/**
|
|
@@ -60,9 +61,9 @@ export interface ResourceInstance {
|
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* Each resource `requests` holds, in its order, bound to this run as a resource instance of its definition from
|
|
63
|
-
* `
|
|
64
|
+
* `lookup`, over the definition's world from `worlds`.
|
|
64
65
|
*/
|
|
65
|
-
export declare function resourceInstances(
|
|
66
|
+
export declare function resourceInstances({ named }: DefinitionLookup, worlds: ResourceWorlds, requests: ResourceRequests): readonly ResourceInstance[];
|
|
66
67
|
/**
|
|
67
68
|
* A lane beside the resources: the runner sandbox, readied by the runner. `stopped` is the outcome its value ends the
|
|
68
69
|
* run with, which ranks above every resource's refusal; undefined when it doesn't end the run.
|
package/dist/core/resources.js
CHANGED
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
// which calls its definition's lifecycle itself, keeps what its acquire took, how acquiring it answered and the
|
|
5
5
|
// warnings it reported, reports what it reports under its key, and hands each its own back: the routing the core view
|
|
6
6
|
// of a resource rests on (`ResourceDefinition`).
|
|
7
|
-
import { resourceRegistry } from "./resource-registry.js";
|
|
8
7
|
/**
|
|
9
8
|
* Each resource `requests` holds, in its order, bound to this run as a resource instance of its definition from
|
|
10
|
-
* `
|
|
9
|
+
* `lookup`, over the definition's world from `worlds`.
|
|
11
10
|
*/
|
|
12
|
-
export function resourceInstances(
|
|
13
|
-
const { named } = resourceRegistry(resources);
|
|
11
|
+
export function resourceInstances({ named }, worlds, requests) {
|
|
14
12
|
return Object.entries(requests).map(([key, request]) => instanceOf(named(request.definition, key), key, worlds, request));
|
|
15
13
|
}
|
|
16
14
|
/**
|
package/dist/core/run-state.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export type RunnerSnapshotState = {
|
|
|
37
37
|
readonly summary: string;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* Saving the runner sandbox as a branch snapshot of `branch
|
|
40
|
+
* Saving the runner sandbox as a branch snapshot of `branch`: under way, saved as runner snapshot
|
|
41
41
|
* `id` at HEAD commit `head`, or not saved.
|
|
42
42
|
*/
|
|
43
43
|
export type BranchSnapshotSaveState = {
|
package/dist/core/run-state.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// (`timeline`) projects it once the run is done. Neither keeps a second copy of these rules. The core applies its own
|
|
4
4
|
// events; each resource's progress (`ResourceProgress`) applies its resource instance's own events, its acquire's
|
|
5
5
|
// `announce` among them, to its own lane state, which the run's state keeps by resource key, with its definition's
|
|
6
|
-
// name. It names no resource.
|
|
6
|
+
// name. Callers apply events through the registry (`applyEvent`, `resource-registry.ts`). It names no resource.
|
|
7
7
|
/** The runner lane's steps, in order. */
|
|
8
8
|
export const RUNNER_STEPS = ["snapshot", "start", "upload", "apply", "install", "build"];
|
|
9
9
|
/** The state before any event: what applying a run's events starts from. */
|
package/dist/core/run.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type CredentialGateway, type CredentialSourceChoice, type GitHubActionsTokenGateway, type MintFailure, type MintTarget } from "../credential/index.ts";
|
|
2
|
-
import { type
|
|
2
|
+
import { type RunnerCleanupFacts, type RunnerContext, type RunnerFailure, type RunnerSave, type RunnerSessionRequest, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
|
|
3
3
|
import type { Clock } from "../time/index.ts";
|
|
4
|
-
import type { ResourceDefinition } from "../sdk/extension/index.ts";
|
|
5
4
|
import type { RunProgress } from "./events.ts";
|
|
6
5
|
import type { CommandGateway } from "./gateways.ts";
|
|
6
|
+
import { type ResourceRegistry } from "./resource-registry.ts";
|
|
7
7
|
import type { ResourceCleanupRecords, ResourceRanRecords, ResourceRefusal, ResourceRequests, ResourceSkip, ResourceWorlds } from "./resource.ts";
|
|
8
8
|
import type { RanCommand } from "./timing.ts";
|
|
9
9
|
/**
|
|
@@ -19,26 +19,12 @@ export interface RunContext extends RunnerContext {
|
|
|
19
19
|
readonly githubActionsTokens: GitHubActionsTokenGateway;
|
|
20
20
|
readonly commands: CommandGateway;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/** The local user name, for each sandbox's `user` tag. */
|
|
29
|
-
readonly user: string;
|
|
30
|
-
/**
|
|
31
|
-
* The runner secrets' values, read from this machine's environment as the run started: each recipe step gets the
|
|
32
|
-
* ones it names, the command gets none, and storm writes none to the run directory, the snapshot cache or `run.json`.
|
|
33
|
-
*/
|
|
34
|
-
readonly secrets: RunnerSecrets;
|
|
35
|
-
/**
|
|
36
|
-
* What the run does with the runner sandbox once it ends, decided before it starts: keep it running for the keep time
|
|
37
|
-
* (0 stops and deletes it), or, under `--save-snapshot` on a branch, save it as a branch snapshot once the command
|
|
38
|
-
* ends on its own (`saveBranchSnapshot`), never keeping it.
|
|
39
|
-
*/
|
|
40
|
-
readonly sandbox: RunnerSandboxPlan;
|
|
41
|
-
}
|
|
22
|
+
/**
|
|
23
|
+
* What a sandboxed run needs beyond an unsandboxed run: what its runner session runs (`RunnerSessionRequest`), the
|
|
24
|
+
* runner checked on this machine, the team and project the run's credential is minted for, the local user, the runner
|
|
25
|
+
* secrets and what the run does with the runner sandbox once it ends.
|
|
26
|
+
*/
|
|
27
|
+
export type RunRunnerRequest = RunnerSessionRequest;
|
|
42
28
|
/** What every run was asked to do, unsandboxed or sandboxed. */
|
|
43
29
|
interface RunRequestBase {
|
|
44
30
|
/** The command. */
|
|
@@ -120,7 +106,7 @@ export interface RanRunner {
|
|
|
120
106
|
readonly runtime: string;
|
|
121
107
|
/** How long the build step took, in milliseconds. */
|
|
122
108
|
readonly buildMs: number;
|
|
123
|
-
/** How saving the runner sandbox as a branch snapshot ended; null
|
|
109
|
+
/** How saving the runner sandbox as a branch snapshot ended; null when the run started no save. */
|
|
124
110
|
readonly save: RunnerSave | null;
|
|
125
111
|
}
|
|
126
112
|
/**
|
|
@@ -147,12 +133,8 @@ export interface RanRunner {
|
|
|
147
133
|
* and deleted. `executeRun` sets both once.
|
|
148
134
|
*/
|
|
149
135
|
export type RunOutcome = RanRun | (RunStopped & RunCleanup);
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
*/
|
|
153
|
-
export interface RunnerCleanupFacts extends RunnerScopeFacts {
|
|
154
|
-
readonly target: MintTarget;
|
|
155
|
-
}
|
|
136
|
+
/** What closing a sandboxed run's sandbox scope left, and the team and project its sandboxes are in. */
|
|
137
|
+
export type { RunnerCleanupFacts };
|
|
156
138
|
/** What a run reports of its cleanup. */
|
|
157
139
|
export interface RunCleanup {
|
|
158
140
|
readonly runnerCleanup: RunnerCleanupFacts | null;
|
|
@@ -195,9 +177,9 @@ export type RunStopped = ResourceRefusal | {
|
|
|
195
177
|
readonly removal: RunnerSnapshotCacheFailure | undefined;
|
|
196
178
|
};
|
|
197
179
|
/**
|
|
198
|
-
* Runs `request.argv` with the resources it asks for, through `
|
|
199
|
-
*
|
|
200
|
-
*
|
|
180
|
+
* Runs `request.argv` with the resources it asks for, through `registry`'s resource definitions, in registry order.
|
|
181
|
+
* Each resource's `beforeRun` has run already, before the run started: the request holds what it answered. It says
|
|
182
|
+
* each resource `beforeRun` skipped right after it starts (`resource-skipped`), acquires the other resource
|
|
201
183
|
* instances all at once through their `acquireForRun` (`acquireResources`), says each acquired (`resource-acquired`),
|
|
202
184
|
* runs the command with the run payload in `STORM_RUN`, waits for it, and hands each instance what its acquire took to
|
|
203
185
|
* its `releaseAfterRun`. It reports each step to `progress`. What acquiring and releasing do is each resource
|
|
@@ -207,10 +189,10 @@ export type RunStopped = ResourceRefusal | {
|
|
|
207
189
|
* In a sandboxed run (`request.runner`), the command runs in a runner sandbox, readied beside the resources (see
|
|
208
190
|
* `runSandboxed`).
|
|
209
191
|
*
|
|
210
|
-
* Release happens
|
|
211
|
-
*
|
|
192
|
+
* Release happens however the run ended, a throw included: once the command has stopped and, in a sandboxed run, the
|
|
193
|
+
* runner session has closed its sandbox scope, each resource instance is released in reverse order, even when the
|
|
212
194
|
* `cleanup-started` event can't be reported. A sandboxed run that saves the runner sandbox as a branch snapshot
|
|
213
|
-
* releases them while the save runs, since the command is done with them.
|
|
195
|
+
* releases them while the save runs, since the command is done with them. An unsandboxed run releases them in
|
|
196
|
+
* `finally`; a sandboxed run's runner session does, as it finishes or closes.
|
|
214
197
|
*/
|
|
215
|
-
export declare function executeRun(
|
|
216
|
-
export {};
|
|
198
|
+
export declare function executeRun(registry: ResourceRegistry, context: RunContext, worlds: ResourceWorlds, request: RunRequest, control: RunControl, progress: RunProgress): Promise<RunOutcome>;
|