tubeless 0.1.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/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/abort.d.ts +12 -0
- package/dist/abort.d.ts.map +1 -0
- package/dist/abort.js +49 -0
- package/dist/abort.js.map +1 -0
- package/dist/batch.d.ts +22 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/batch.js +73 -0
- package/dist/batch.js.map +1 -0
- package/dist/checkpoint.d.ts +33 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +71 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/child-execution.d.ts +30 -0
- package/dist/child-execution.d.ts.map +1 -0
- package/dist/child-execution.js +270 -0
- package/dist/child-execution.js.map +1 -0
- package/dist/cli-command.d.ts +29 -0
- package/dist/cli-command.d.ts.map +1 -0
- package/dist/cli-command.js +314 -0
- package/dist/cli-command.js.map +1 -0
- package/dist/cli-parser.d.ts +28 -0
- package/dist/cli-parser.d.ts.map +1 -0
- package/dist/cli-parser.js +557 -0
- package/dist/cli-parser.js.map +1 -0
- package/dist/cli-pipeline-command.d.ts +84 -0
- package/dist/cli-pipeline-command.d.ts.map +1 -0
- package/dist/cli-pipeline-command.js +185 -0
- package/dist/cli-pipeline-command.js.map +1 -0
- package/dist/cli-types.d.ts +220 -0
- package/dist/cli-types.d.ts.map +1 -0
- package/dist/cli-types.js +19 -0
- package/dist/cli-types.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +8 -0
- package/dist/env.js.map +1 -0
- package/dist/file-utils.d.ts +4 -0
- package/dist/file-utils.d.ts.map +1 -0
- package/dist/file-utils.js +35 -0
- package/dist/file-utils.js.map +1 -0
- package/dist/interactive-reporter.d.ts +38 -0
- package/dist/interactive-reporter.d.ts.map +1 -0
- package/dist/interactive-reporter.js +308 -0
- package/dist/interactive-reporter.js.map +1 -0
- package/dist/lifecycle.d.ts +17 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +77 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/live-ticker.d.ts +21 -0
- package/dist/live-ticker.d.ts.map +1 -0
- package/dist/live-ticker.js +377 -0
- package/dist/live-ticker.js.map +1 -0
- package/dist/mapped-child-progress.d.ts +109 -0
- package/dist/mapped-child-progress.d.ts.map +1 -0
- package/dist/mapped-child-progress.js +133 -0
- package/dist/mapped-child-progress.js.map +1 -0
- package/dist/node.d.ts +5 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +5 -0
- package/dist/node.js.map +1 -0
- package/dist/paths.d.ts +9 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +19 -0
- package/dist/paths.js.map +1 -0
- package/dist/pipeline-command-marker.d.ts +5 -0
- package/dist/pipeline-command-marker.d.ts.map +1 -0
- package/dist/pipeline-command-marker.js +21 -0
- package/dist/pipeline-command-marker.js.map +1 -0
- package/dist/pipeline-diagnostics.d.ts +4 -0
- package/dist/pipeline-diagnostics.d.ts.map +1 -0
- package/dist/pipeline-diagnostics.js +17 -0
- package/dist/pipeline-diagnostics.js.map +1 -0
- package/dist/pipeline-module.d.ts +62 -0
- package/dist/pipeline-module.d.ts.map +1 -0
- package/dist/pipeline-module.js +157 -0
- package/dist/pipeline-module.js.map +1 -0
- package/dist/pipeline.d.ts +606 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +1444 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/progress.d.ts +4 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +8 -0
- package/dist/progress.js.map +1 -0
- package/dist/prompt-select.d.ts +81 -0
- package/dist/prompt-select.d.ts.map +1 -0
- package/dist/prompt-select.js +197 -0
- package/dist/prompt-select.js.map +1 -0
- package/dist/rate-limit.d.ts +7 -0
- package/dist/rate-limit.d.ts.map +1 -0
- package/dist/rate-limit.js +23 -0
- package/dist/rate-limit.js.map +1 -0
- package/dist/render.d.ts +21 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +60 -0
- package/dist/render.js.map +1 -0
- package/dist/reporter-entry.d.ts +3 -0
- package/dist/reporter-entry.d.ts.map +1 -0
- package/dist/reporter-entry.js +3 -0
- package/dist/reporter-entry.js.map +1 -0
- package/dist/reporter.d.ts +50 -0
- package/dist/reporter.d.ts.map +1 -0
- package/dist/reporter.js +167 -0
- package/dist/reporter.js.map +1 -0
- package/dist/retry.d.ts +28 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +59 -0
- package/dist/retry.js.map +1 -0
- package/dist/run-store-sqlite.d.ts +12 -0
- package/dist/run-store-sqlite.d.ts.map +1 -0
- package/dist/run-store-sqlite.js +187 -0
- package/dist/run-store-sqlite.js.map +1 -0
- package/dist/run-store-ui-http.d.ts +5 -0
- package/dist/run-store-ui-http.d.ts.map +1 -0
- package/dist/run-store-ui-http.js +19 -0
- package/dist/run-store-ui-http.js.map +1 -0
- package/dist/run-store-ui-page.d.ts +2 -0
- package/dist/run-store-ui-page.d.ts.map +1 -0
- package/dist/run-store-ui-page.js +759 -0
- package/dist/run-store-ui-page.js.map +1 -0
- package/dist/run-store-ui-protocol.d.ts +28 -0
- package/dist/run-store-ui-protocol.d.ts.map +1 -0
- package/dist/run-store-ui-protocol.js +84 -0
- package/dist/run-store-ui-protocol.js.map +1 -0
- package/dist/run-store-ui-state.d.ts +21 -0
- package/dist/run-store-ui-state.d.ts.map +1 -0
- package/dist/run-store-ui-state.js +65 -0
- package/dist/run-store-ui-state.js.map +1 -0
- package/dist/run-store-ui.d.ts +25 -0
- package/dist/run-store-ui.d.ts.map +1 -0
- package/dist/run-store-ui.js +217 -0
- package/dist/run-store-ui.js.map +1 -0
- package/dist/run-store.d.ts +109 -0
- package/dist/run-store.d.ts.map +1 -0
- package/dist/run-store.js +345 -0
- package/dist/run-store.js.map +1 -0
- package/dist/testing.d.ts +40 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +83 -0
- package/dist/testing.js.map +1 -0
- package/dist/tracing-internal.d.ts +21 -0
- package/dist/tracing-internal.d.ts.map +1 -0
- package/dist/tracing-internal.js +206 -0
- package/dist/tracing-internal.js.map +1 -0
- package/dist/tracing-json.d.ts +12 -0
- package/dist/tracing-json.d.ts.map +1 -0
- package/dist/tracing-json.js +8 -0
- package/dist/tracing-json.js.map +1 -0
- package/dist/tracing-otel.d.ts +36 -0
- package/dist/tracing-otel.d.ts.map +1 -0
- package/dist/tracing-otel.js +60 -0
- package/dist/tracing-otel.js.map +1 -0
- package/dist/tracing.d.ts +48 -0
- package/dist/tracing.d.ts.map +1 -0
- package/dist/tracing.js +2 -0
- package/dist/tracing.js.map +1 -0
- package/dist/workbench-bin.d.ts +3 -0
- package/dist/workbench-bin.d.ts.map +1 -0
- package/dist/workbench-bin.js +8 -0
- package/dist/workbench-bin.js.map +1 -0
- package/dist/workbench-graph.d.ts +3 -0
- package/dist/workbench-graph.d.ts.map +1 -0
- package/dist/workbench-graph.js +64 -0
- package/dist/workbench-graph.js.map +1 -0
- package/dist/workbench-inspect.d.ts +3 -0
- package/dist/workbench-inspect.d.ts.map +1 -0
- package/dist/workbench-inspect.js +65 -0
- package/dist/workbench-inspect.js.map +1 -0
- package/dist/workbench-plan.d.ts +3 -0
- package/dist/workbench-plan.d.ts.map +1 -0
- package/dist/workbench-plan.js +72 -0
- package/dist/workbench-plan.js.map +1 -0
- package/dist/workbench-run.d.ts +13 -0
- package/dist/workbench-run.d.ts.map +1 -0
- package/dist/workbench-run.js +115 -0
- package/dist/workbench-run.js.map +1 -0
- package/dist/workbench-shared.d.ts +67 -0
- package/dist/workbench-shared.d.ts.map +1 -0
- package/dist/workbench-shared.js +163 -0
- package/dist/workbench-shared.js.map +1 -0
- package/dist/workbench-studio.d.ts +26 -0
- package/dist/workbench-studio.d.ts.map +1 -0
- package/dist/workbench-studio.js +57 -0
- package/dist/workbench-studio.js.map +1 -0
- package/dist/workbench-ui.d.ts +3 -0
- package/dist/workbench-ui.d.ts.map +1 -0
- package/dist/workbench-ui.js +262 -0
- package/dist/workbench-ui.js.map +1 -0
- package/dist/workbench.d.ts +5 -0
- package/dist/workbench.d.ts.map +1 -0
- package/dist/workbench.js +43 -0
- package/dist/workbench.js.map +1 -0
- package/docs/README.md +31 -0
- package/docs/agent-guide.md +168 -0
- package/docs/api-reference.md +269 -0
- package/docs/api-report.json +298 -0
- package/docs/child-pipeline-composition.md +185 -0
- package/docs/cli.md +118 -0
- package/docs/concepts.md +502 -0
- package/docs/getting-started.md +162 -0
- package/docs/llms.txt +62 -0
- package/docs/recipes.md +51 -0
- package/docs/studio.md +86 -0
- package/examples/best-effort.ts +42 -0
- package/examples/cancellation-and-testing.ts +45 -0
- package/examples/child-pipeline.ts +51 -0
- package/examples/cli-job.ts +86 -0
- package/examples/conditional-step.ts +41 -0
- package/examples/fan-out-progress.ts +53 -0
- package/examples/local-observability.ts +80 -0
- package/examples/publish-with-gates.ts +56 -0
- package/examples/rendering.ts +34 -0
- package/examples/resumable-enrichment.ts +75 -0
- package/examples/tracing.ts +35 -0
- package/examples/tsconfig.json +15 -0
- package/examples/typed-import.ts +54 -0
- package/examples/validated-boundaries.ts +75 -0
- package/package.json +156 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import type { ToMappedChildStepProgressOptions } from "./mapped-child-progress.js";
|
|
2
|
+
import type { PipelineTraceAttributes, PipelineTraceContext, PipelineTracingOptions } from "./tracing.js";
|
|
3
|
+
export interface PipelineLogger {
|
|
4
|
+
error(message?: unknown, ...optionalParams: unknown[]): void;
|
|
5
|
+
log(message?: unknown, ...optionalParams: unknown[]): void;
|
|
6
|
+
warn(message?: unknown, ...optionalParams: unknown[]): void;
|
|
7
|
+
}
|
|
8
|
+
export interface PipelineContext {
|
|
9
|
+
cwd: string;
|
|
10
|
+
/** Hook sets run in order and failures are isolated per set. */
|
|
11
|
+
hooks?: PipelineHooks | readonly PipelineHooks[];
|
|
12
|
+
log: PipelineLogger;
|
|
13
|
+
/** Timestamp source for persisted run records. Defaults to `Date.now`. */
|
|
14
|
+
now?: () => number;
|
|
15
|
+
/** Optional caller-owned parent run identity for nested or resumed orchestration. */
|
|
16
|
+
parentRunId?: string;
|
|
17
|
+
/** Optional caller-owned run identity. A unique ID is generated when omitted. */
|
|
18
|
+
runId?: string;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
sleep?: (durationMs: number, signal?: AbortSignal) => Promise<void>;
|
|
21
|
+
/** Optional structured lifecycle tracing configuration for this run. */
|
|
22
|
+
tracing?: PipelineTracingOptions;
|
|
23
|
+
}
|
|
24
|
+
export interface PipelineRunControls<TStepId extends string = string, TTargetId extends string = string> {
|
|
25
|
+
continueOnError?: boolean;
|
|
26
|
+
dryRun?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Run only these steps; omitted or undefined runs every step. An empty array
|
|
29
|
+
* is invalid and fails planning/execution instead of silently running nothing.
|
|
30
|
+
*/
|
|
31
|
+
stepIds?: readonly TStepId[];
|
|
32
|
+
/**
|
|
33
|
+
* Run these declared pipeline targets and the upstream work required to
|
|
34
|
+
* reach them. Required inputs and failure gates are included recursively;
|
|
35
|
+
* optional-only inputs are not. Cannot be combined with exact `stepIds`
|
|
36
|
+
* filtering.
|
|
37
|
+
*/
|
|
38
|
+
targets?: readonly TTargetId[];
|
|
39
|
+
}
|
|
40
|
+
/** Domain input plus the built-in controls for one pipeline invocation. */
|
|
41
|
+
export type PipelineRunOptions<TOptions extends object = object, TStepId extends string = string, TTargetId extends string = string> = TOptions & PipelineRunControls<TStepId, TTargetId>;
|
|
42
|
+
export interface PipelineRuntime extends PipelineContext {
|
|
43
|
+
now: () => number;
|
|
44
|
+
sleep: (durationMs: number, signal?: AbortSignal) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface PipelineExecutionContext<TOptions extends object> extends PipelineRuntime {
|
|
47
|
+
dryRun: boolean;
|
|
48
|
+
options: TOptions;
|
|
49
|
+
/** Stable identity for this execution, whether or not tracing is configured. */
|
|
50
|
+
runId: string;
|
|
51
|
+
/** Parent execution identity when this run was started by another run. */
|
|
52
|
+
parentRunId?: string;
|
|
53
|
+
/** Stable identities for this traced run; absent unless `context.tracing` is configured. */
|
|
54
|
+
trace?: PipelineTraceContext;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Optional indented detail row under a parent step's progress.
|
|
58
|
+
* Domain-agnostic: mapped children, nested work units, per-file status, etc.
|
|
59
|
+
*/
|
|
60
|
+
export interface PipelineStepProgressDetail {
|
|
61
|
+
/** Stable identity for the row (item key, path, job id, …). */
|
|
62
|
+
id: string;
|
|
63
|
+
/** Short status text shown after the id. */
|
|
64
|
+
label?: string;
|
|
65
|
+
/** Controls the detail row symbol. Defaults to `running`. */
|
|
66
|
+
status?: "completed" | "failed" | "pending" | "running" | "skipped";
|
|
67
|
+
}
|
|
68
|
+
export interface PipelineStepProgress {
|
|
69
|
+
/** Work completed so far. Values outside the reported total are allowed but renderers may clamp them. */
|
|
70
|
+
completed: number;
|
|
71
|
+
/** Total work when known. Omit for indeterminate progress. */
|
|
72
|
+
total?: number;
|
|
73
|
+
/** Optional short status shown next to the step. Prefer one-line summaries. */
|
|
74
|
+
message?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Optional multi-line detail rows for capable reporters (interactive TTY).
|
|
77
|
+
* Keep the parent `message` as a summary; put per-item status here so high
|
|
78
|
+
* concurrency does not collapse onto one truncated line.
|
|
79
|
+
*/
|
|
80
|
+
details?: readonly PipelineStepProgressDetail[];
|
|
81
|
+
}
|
|
82
|
+
export interface PipelineStepContext<TOptions extends object> extends PipelineExecutionContext<TOptions> {
|
|
83
|
+
/** Stable identity for this execution of the current step. */
|
|
84
|
+
attemptId: string;
|
|
85
|
+
/** Emit a retry/attempt trace event for this step when tracing is enabled. */
|
|
86
|
+
reportAttempt(attempt: number, attributes?: PipelineTraceAttributes): void;
|
|
87
|
+
/** Publish the latest progress snapshot for this step. */
|
|
88
|
+
reportProgress(progress: PipelineStepProgress): void;
|
|
89
|
+
}
|
|
90
|
+
export type PipelineErrorPhase = "definition" | "execution" | "finalization" | "planning";
|
|
91
|
+
export type PipelineErrorKind = "cancellation" | "child" | "definition" | "finalization" | "selection" | "step" | "validation";
|
|
92
|
+
/** Stable package-owned codes for pipeline errors. */
|
|
93
|
+
export type PipelineErrorCode = "TUBELESS_CHILD_FAILED" | "TUBELESS_DEFINITION_DEPENDENCY_CONTRADICTORY" | "TUBELESS_DEFINITION_DEPENDENCY_CYCLE" | "TUBELESS_DEFINITION_DEPENDENCY_DUPLICATE" | "TUBELESS_DEFINITION_DEPENDENCY_NOT_IN_STEPS" | "TUBELESS_DEFINITION_DEPENDENCY_SELF_REFERENCE" | "TUBELESS_DEFINITION_FINALIZER_STEP_NOT_IN_STEPS" | "TUBELESS_DEFINITION_PIPELINE_ID_BLANK" | "TUBELESS_DEFINITION_OPTIONS_SCHEMA_CONFLICT" | "TUBELESS_DEFINITION_STEP_ID_BLANK" | "TUBELESS_DEFINITION_STEP_ID_RESERVED" | "TUBELESS_DEFINITION_STEP_IDS_DUPLICATE" | "TUBELESS_DEFINITION_STEP_NAME_BLANK" | "TUBELESS_DEFINITION_TARGET_FINALIZER_MISMATCH" | "TUBELESS_DEFINITION_TARGET_NOT_IN_STEPS" | "TUBELESS_DEFINITION_TARGETS_DUPLICATE" | "TUBELESS_FINALIZATION_CANCELLED" | "TUBELESS_FINALIZATION_FAILED" | "TUBELESS_FINAL_RESULT_VALIDATION_FAILED" | "TUBELESS_OPTIONS_VALIDATION_FAILED" | "TUBELESS_PLANNING_SELECTION_CONFLICT" | "TUBELESS_PLANNING_STEP_SELECTION_DUPLICATE" | "TUBELESS_PLANNING_STEP_SELECTION_EMPTY" | "TUBELESS_PLANNING_STEP_UNKNOWN" | "TUBELESS_PLANNING_TARGET_SELECTION_DUPLICATE" | "TUBELESS_PLANNING_TARGET_SELECTION_EMPTY" | "TUBELESS_PLANNING_TARGET_UNDECLARED" | "TUBELESS_PLANNING_TARGET_UNKNOWN" | "TUBELESS_RUN_CANCELLED" | "TUBELESS_STEP_OUTPUT_VALIDATION_FAILED" | "TUBELESS_STEP_FAILED";
|
|
94
|
+
/** One dependency-free Standard Schema issue normalized for reports and traces. */
|
|
95
|
+
export interface PipelineValidationIssue {
|
|
96
|
+
message: string;
|
|
97
|
+
path?: readonly (number | string)[];
|
|
98
|
+
}
|
|
99
|
+
export interface PipelineError {
|
|
100
|
+
/** Bounded, JSON-safe snapshot of the thrown error's cause chain. */
|
|
101
|
+
cause?: PipelineErrorCause;
|
|
102
|
+
code: PipelineErrorCode;
|
|
103
|
+
kind: PipelineErrorKind;
|
|
104
|
+
message: string;
|
|
105
|
+
phase: PipelineErrorPhase;
|
|
106
|
+
/** Present when a Standard Schema rejected a boundary value. */
|
|
107
|
+
issues?: readonly PipelineValidationIssue[];
|
|
108
|
+
stepId?: string;
|
|
109
|
+
/** Machine-readable code copied from the original thrown error, when present. */
|
|
110
|
+
sourceCode?: string;
|
|
111
|
+
stack?: string;
|
|
112
|
+
}
|
|
113
|
+
/** Dependency-free subset of the Standard Schema V1 protocol. */
|
|
114
|
+
export interface StandardSchemaV1<TInput = unknown, TOutput = TInput> {
|
|
115
|
+
readonly "~standard": StandardSchemaV1Props<TInput, TOutput>;
|
|
116
|
+
}
|
|
117
|
+
export interface StandardSchemaV1Props<TInput = unknown, TOutput = TInput> {
|
|
118
|
+
readonly types?: {
|
|
119
|
+
readonly input: TInput;
|
|
120
|
+
readonly output: TOutput;
|
|
121
|
+
};
|
|
122
|
+
readonly validate: (value: unknown, options?: {
|
|
123
|
+
readonly libraryOptions?: Record<string, unknown>;
|
|
124
|
+
}) => StandardSchemaV1Result<TOutput> | Promise<StandardSchemaV1Result<TOutput>>;
|
|
125
|
+
readonly vendor: string;
|
|
126
|
+
readonly version: 1;
|
|
127
|
+
}
|
|
128
|
+
export type StandardSchemaV1Result<TOutput> = {
|
|
129
|
+
readonly issues?: undefined;
|
|
130
|
+
readonly value: TOutput;
|
|
131
|
+
} | {
|
|
132
|
+
readonly issues: readonly StandardSchemaV1Issue[];
|
|
133
|
+
};
|
|
134
|
+
export interface StandardSchemaV1Issue {
|
|
135
|
+
readonly message: string;
|
|
136
|
+
readonly path?: readonly (PropertyKey | {
|
|
137
|
+
readonly key: PropertyKey;
|
|
138
|
+
})[];
|
|
139
|
+
}
|
|
140
|
+
/** Infer the accepted input type from a Standard Schema without importing its package. */
|
|
141
|
+
export type InferSchemaInput<TSchema extends StandardSchemaV1> = NonNullable<TSchema["~standard"]["types"]>["input"];
|
|
142
|
+
/** Infer the validated output type from a Standard Schema without importing its package. */
|
|
143
|
+
export type InferSchemaOutput<TSchema extends StandardSchemaV1> = NonNullable<TSchema["~standard"]["types"]>["output"];
|
|
144
|
+
export interface PipelineErrorCause {
|
|
145
|
+
cause?: PipelineErrorCause;
|
|
146
|
+
message: string;
|
|
147
|
+
name?: string;
|
|
148
|
+
/** Machine-readable code copied from this cause, when present. */
|
|
149
|
+
sourceCode?: string;
|
|
150
|
+
}
|
|
151
|
+
interface PipelineStepReportBase {
|
|
152
|
+
/** Present when the step started an execution attempt. */
|
|
153
|
+
attemptId?: string;
|
|
154
|
+
id: string;
|
|
155
|
+
/** Optional human-facing display name. Stable machine identity remains `id`. */
|
|
156
|
+
name?: string;
|
|
157
|
+
description?: string;
|
|
158
|
+
/** Wall-clock time when this terminal report was recorded. */
|
|
159
|
+
finishedAtMs: number;
|
|
160
|
+
/** Wall-clock time when execution began; absent when the step never started. */
|
|
161
|
+
startedAtMs?: number;
|
|
162
|
+
}
|
|
163
|
+
export interface PipelineStepCompleteReport extends PipelineStepReportBase {
|
|
164
|
+
attemptId: string;
|
|
165
|
+
startedAtMs: number;
|
|
166
|
+
status: "complete";
|
|
167
|
+
}
|
|
168
|
+
export interface PipelineStepSkippedReport extends PipelineStepReportBase {
|
|
169
|
+
/** Dependency that blocked this step, when applicable. */
|
|
170
|
+
dependencyId?: string;
|
|
171
|
+
/** Human-readable skip detail, especially for policy and fail-fast skips. */
|
|
172
|
+
message?: string;
|
|
173
|
+
reason: PipelineStepSkipReason;
|
|
174
|
+
status: "skipped";
|
|
175
|
+
}
|
|
176
|
+
export interface PipelineStepCancelledReport extends PipelineStepReportBase {
|
|
177
|
+
error: PipelineError;
|
|
178
|
+
status: "cancelled";
|
|
179
|
+
}
|
|
180
|
+
export interface PipelineStepFailedReport extends PipelineStepReportBase {
|
|
181
|
+
attemptId: string;
|
|
182
|
+
error: PipelineError;
|
|
183
|
+
startedAtMs: number;
|
|
184
|
+
status: "failed";
|
|
185
|
+
}
|
|
186
|
+
/** Terminal state recorded for one step after a run. */
|
|
187
|
+
export type PipelineStepReport = PipelineStepCancelledReport | PipelineStepFailedReport | PipelineStepSkippedReport | PipelineStepCompleteReport;
|
|
188
|
+
/** Current persisted run-record schema version. */
|
|
189
|
+
export declare const RUN_MODEL_VERSION: 1;
|
|
190
|
+
/** Terminal disposition of a completed run record. */
|
|
191
|
+
export type PipelineRunStatus = "cancelled" | "completed" | "failed";
|
|
192
|
+
/** Versioned public record returned for one pipeline execution. */
|
|
193
|
+
export interface PipelineRun<TResult = unknown> {
|
|
194
|
+
pipelineId: string;
|
|
195
|
+
dryRun: boolean;
|
|
196
|
+
errors: PipelineError[];
|
|
197
|
+
finalized: boolean;
|
|
198
|
+
finishedAtMs: number;
|
|
199
|
+
parentRunId?: string;
|
|
200
|
+
runId: string;
|
|
201
|
+
startedAtMs: number;
|
|
202
|
+
status: PipelineRunStatus;
|
|
203
|
+
steps: PipelineStepReport[];
|
|
204
|
+
value?: TResult;
|
|
205
|
+
version: typeof RUN_MODEL_VERSION;
|
|
206
|
+
}
|
|
207
|
+
export declare const PIPELINE_FINALIZE_STEP_ID = "__finalize__";
|
|
208
|
+
/**
|
|
209
|
+
* Why a step did not run. Built-in structural reasons keep dependency semantics;
|
|
210
|
+
* `"policy"` is an intentional skip from `step.skip()` (still unlocks dependents).
|
|
211
|
+
*/
|
|
212
|
+
export type PipelineStepSkipReason = "dry-run" | "failed-dependency" | "fail-fast" | "filtered" | "policy" | "unmet-dependency";
|
|
213
|
+
/**
|
|
214
|
+
* Decision from an optional `skip` predicate.
|
|
215
|
+
* - falsy / `false` → run the step
|
|
216
|
+
* - non-empty string → skip with that message (`reason: "policy"`); the step's
|
|
217
|
+
* published output is `undefined`
|
|
218
|
+
* - `{ reason, value? }` → skip and optionally publish `value` for dependents
|
|
219
|
+
* (`value` may be intentionally `undefined` if passed explicitly)
|
|
220
|
+
*
|
|
221
|
+
* Policy skips unlock required dependents. Because a bare-string skip (or a
|
|
222
|
+
* `{ reason }` without `value`) publishes `undefined`, any step that declares
|
|
223
|
+
* `skip` is typed so dependents see `TOut | undefined`. Prefer returning
|
|
224
|
+
* `{ reason, value }` on every skip path when dependents need a real output.
|
|
225
|
+
*/
|
|
226
|
+
export type StepSkipDecision<TOut = unknown> = false | null | undefined | string | {
|
|
227
|
+
reason: string;
|
|
228
|
+
value?: TOut;
|
|
229
|
+
};
|
|
230
|
+
/** One observable status in a step's planned → running → terminal lifecycle. */
|
|
231
|
+
export type PipelineStepStatus = {
|
|
232
|
+
pipelineId: string;
|
|
233
|
+
status: "planned";
|
|
234
|
+
step: PipelinePlanStep;
|
|
235
|
+
} | {
|
|
236
|
+
attemptId: string;
|
|
237
|
+
pipelineId: string;
|
|
238
|
+
progress?: PipelineStepProgress;
|
|
239
|
+
status: "running";
|
|
240
|
+
step: PipelinePlanStep;
|
|
241
|
+
} | ({
|
|
242
|
+
pipelineId: string;
|
|
243
|
+
step: PipelinePlanStep;
|
|
244
|
+
} & PipelineStepCancelledReport) | ({
|
|
245
|
+
pipelineId: string;
|
|
246
|
+
step: PipelinePlanStep;
|
|
247
|
+
} & PipelineStepFailedReport) | ({
|
|
248
|
+
pipelineId: string;
|
|
249
|
+
step: PipelinePlanStep;
|
|
250
|
+
} & PipelineStepSkippedReport) | ({
|
|
251
|
+
pipelineId: string;
|
|
252
|
+
step: PipelinePlanStep;
|
|
253
|
+
} & PipelineStepCompleteReport);
|
|
254
|
+
export type PipelineStepPlannedEvent = Extract<PipelineStepStatus, {
|
|
255
|
+
status: "planned";
|
|
256
|
+
}>;
|
|
257
|
+
type PipelineStepRunningStatus = Extract<PipelineStepStatus, {
|
|
258
|
+
status: "running";
|
|
259
|
+
}>;
|
|
260
|
+
export type PipelineStepStartEvent = Omit<PipelineStepRunningStatus, "progress"> & {
|
|
261
|
+
progress?: undefined;
|
|
262
|
+
};
|
|
263
|
+
export type PipelineStepProgressEvent = Omit<PipelineStepRunningStatus, "progress"> & {
|
|
264
|
+
progress: PipelineStepProgress;
|
|
265
|
+
};
|
|
266
|
+
export type PipelineStepCancelledEvent = Extract<PipelineStepStatus, {
|
|
267
|
+
status: "cancelled";
|
|
268
|
+
}>;
|
|
269
|
+
export type PipelineStepFailedEvent = Extract<PipelineStepStatus, {
|
|
270
|
+
status: "failed";
|
|
271
|
+
}>;
|
|
272
|
+
export type PipelineStepSkippedEvent = Extract<PipelineStepStatus, {
|
|
273
|
+
status: "skipped";
|
|
274
|
+
}>;
|
|
275
|
+
export type PipelineStepCompleteEvent = Extract<PipelineStepStatus, {
|
|
276
|
+
status: "complete";
|
|
277
|
+
}>;
|
|
278
|
+
export interface PipelineHooks<TResult = unknown> {
|
|
279
|
+
onFinalizeComplete?(event: {
|
|
280
|
+
durationMs: number;
|
|
281
|
+
pipelineId: string;
|
|
282
|
+
value: TResult;
|
|
283
|
+
}): void;
|
|
284
|
+
onFinalizeError?(event: {
|
|
285
|
+
durationMs: number;
|
|
286
|
+
error: PipelineError;
|
|
287
|
+
pipelineId: string;
|
|
288
|
+
}): void;
|
|
289
|
+
onFinalizeStart?(event: {
|
|
290
|
+
pipelineId: string;
|
|
291
|
+
}): void;
|
|
292
|
+
onPipelineComplete?(event: PipelineRun<TResult>): void;
|
|
293
|
+
onPipelineStart?(event: PipelinePlan): void;
|
|
294
|
+
onStepCancel?(event: PipelineStepCancelledEvent): void;
|
|
295
|
+
onStepFail?(event: PipelineStepFailedEvent): void;
|
|
296
|
+
onStepPlan?(event: PipelineStepPlannedEvent): void;
|
|
297
|
+
onStepProgress?(event: PipelineStepProgressEvent): void;
|
|
298
|
+
onStepSkip?(event: PipelineStepSkippedEvent): void;
|
|
299
|
+
onStepStart?(event: PipelineStepStartEvent): void;
|
|
300
|
+
onStepStatus?(event: PipelineStepStatus): void;
|
|
301
|
+
onStepComplete?(event: PipelineStepCompleteEvent): void;
|
|
302
|
+
}
|
|
303
|
+
/** Machine-readable explanation of why a planned step was included or omitted. */
|
|
304
|
+
export type PipelineStepSelectionReason = {
|
|
305
|
+
kind: "all";
|
|
306
|
+
} | {
|
|
307
|
+
kind: "exact";
|
|
308
|
+
} | {
|
|
309
|
+
kind: "target";
|
|
310
|
+
targetId: string;
|
|
311
|
+
} | {
|
|
312
|
+
dependentId: string;
|
|
313
|
+
kind: "required-dependency";
|
|
314
|
+
targetId: string;
|
|
315
|
+
} | {
|
|
316
|
+
dependentId: string;
|
|
317
|
+
kind: "failure-gate";
|
|
318
|
+
targetId: string;
|
|
319
|
+
} | {
|
|
320
|
+
dependentId: string;
|
|
321
|
+
kind: "optional-only";
|
|
322
|
+
targetId: string;
|
|
323
|
+
} | {
|
|
324
|
+
kind: "outside-target-closure";
|
|
325
|
+
} | {
|
|
326
|
+
kind: "not-selected";
|
|
327
|
+
};
|
|
328
|
+
export interface PipelinePlanStep {
|
|
329
|
+
dependencies: string[];
|
|
330
|
+
description?: string;
|
|
331
|
+
/** How this step behaves when the pipeline is run with `dryRun: true`. */
|
|
332
|
+
dryRun: "custom" | "run" | "skip";
|
|
333
|
+
id: string;
|
|
334
|
+
/** Optional human-facing display name. Stable machine identity remains `id`. */
|
|
335
|
+
name?: string;
|
|
336
|
+
/** Static child structure when this opaque step executes another pipeline. */
|
|
337
|
+
nestedPipeline?: {
|
|
338
|
+
/** One child execution or one child execution per runtime item. */
|
|
339
|
+
mode: "single" | "for-each";
|
|
340
|
+
pipelineId: string;
|
|
341
|
+
/** All declared child step ids; runtime selection may execute only a subset. */
|
|
342
|
+
stepIds: readonly string[];
|
|
343
|
+
};
|
|
344
|
+
optionalDependencies: string[];
|
|
345
|
+
/** True when the step's runtime policy may elect not to run it. */
|
|
346
|
+
runtimeSkipPossible: boolean;
|
|
347
|
+
selected: boolean;
|
|
348
|
+
/** Stable reasons for selection or omission; shared prerequisites can have several. */
|
|
349
|
+
selectionReasons: readonly PipelineStepSelectionReason[];
|
|
350
|
+
skipAfterFailureOf: string[];
|
|
351
|
+
skipReason?: PipelineStepSkipReason;
|
|
352
|
+
}
|
|
353
|
+
export interface PipelinePlan {
|
|
354
|
+
dryRun: boolean;
|
|
355
|
+
errors: PipelineError[];
|
|
356
|
+
ok: boolean;
|
|
357
|
+
pipelineId: string;
|
|
358
|
+
steps: PipelinePlanStep[];
|
|
359
|
+
}
|
|
360
|
+
/** Layout direction for generated Mermaid flowcharts. */
|
|
361
|
+
export type PipelineMermaidDirection = "BT" | "LR" | "RL" | "TB" | "TD";
|
|
362
|
+
export interface PipelineMermaidOptions {
|
|
363
|
+
/** Mermaid flowchart direction. Defaults to top-down (`TD`). */
|
|
364
|
+
direction?: PipelineMermaidDirection;
|
|
365
|
+
/** Append each operational description to its node label. Defaults to false. */
|
|
366
|
+
includeDescriptions?: boolean;
|
|
367
|
+
}
|
|
368
|
+
/** Create a dependency-free opaque ID suitable for a pipeline run record. */
|
|
369
|
+
export declare function createRunId(pipelineId: string): string;
|
|
370
|
+
export declare function defaultPipelineContext(): PipelineContext;
|
|
371
|
+
export declare class PipelineExecutionError extends Error {
|
|
372
|
+
readonly result: PipelineRun<unknown>;
|
|
373
|
+
constructor(result: PipelineRun<unknown>, message?: string);
|
|
374
|
+
}
|
|
375
|
+
/** Programmer error raised immediately when a pipeline graph is invalid. */
|
|
376
|
+
export declare class PipelineDefinitionError extends Error {
|
|
377
|
+
readonly pipelineId: string;
|
|
378
|
+
readonly errors: readonly PipelineError[];
|
|
379
|
+
constructor(pipelineId: string, errors: readonly PipelineError[]);
|
|
380
|
+
}
|
|
381
|
+
export interface Pipeline<TOptions extends object, TResult, TStepId extends string = string, TTargetId extends string = TStepId> {
|
|
382
|
+
readonly id: string;
|
|
383
|
+
/** Stable definition-order step ids for discovery surfaces such as CLI help. */
|
|
384
|
+
readonly stepIds: readonly TStepId[];
|
|
385
|
+
/** Stable declared goal ids that support dependency-aware target execution. */
|
|
386
|
+
readonly targetIds: readonly TTargetId[];
|
|
387
|
+
plan(controls?: PipelineRunControls<TStepId, TTargetId>): PipelinePlan;
|
|
388
|
+
run(options: PipelineRunOptions<TOptions, TStepId, TTargetId>, context?: Partial<PipelineContext>): Promise<PipelineRun<TResult>>;
|
|
389
|
+
runOrThrow(options: PipelineRunOptions<TOptions, TStepId, TTargetId>, context?: Partial<PipelineContext>): Promise<TResult>;
|
|
390
|
+
/** Generate a static Mermaid flowchart without running or planning the pipeline. */
|
|
391
|
+
toMermaid(options?: PipelineMermaidOptions): string;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* A step's dependencies are references to the dependency's own step object, not string ids
|
|
395
|
+
* into a hand-maintained output-type map. This buys two things no amount of extra generics
|
|
396
|
+
* on a string-keyed design could:
|
|
397
|
+
* - a step used before its dependency exists is a compile error (JS temporal dead zone on
|
|
398
|
+
* `const`), so out-of-order and self/cyclic dependencies are caught by the language, not
|
|
399
|
+
* a bespoke runtime check
|
|
400
|
+
* - each step only ever states its own id/deps; the output-type map is derived, never
|
|
401
|
+
* restated, and callers of `definePipeline`/`createSteps` never write out its generics
|
|
402
|
+
*/
|
|
403
|
+
type AnyStepDryRunHandler<TOptions extends object> = {
|
|
404
|
+
bivarianceHack(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown | Promise<unknown>;
|
|
405
|
+
}["bivarianceHack"];
|
|
406
|
+
declare const STEP_OPTIONS_SCHEMA: unique symbol;
|
|
407
|
+
declare const STEP_NESTED_PIPELINE: unique symbol;
|
|
408
|
+
export interface AnyStep<TOptions extends object = object> {
|
|
409
|
+
readonly [STEP_NESTED_PIPELINE]?: NonNullable<PipelinePlanStep["nestedPipeline"]>;
|
|
410
|
+
readonly [STEP_OPTIONS_SCHEMA]?: StandardSchemaV1;
|
|
411
|
+
readonly id: string;
|
|
412
|
+
readonly dependsOn?: readonly AnyStep<TOptions>[];
|
|
413
|
+
readonly optionalDependsOn?: readonly AnyStep<TOptions>[];
|
|
414
|
+
readonly skipAfterFailureOf?: readonly AnyStep<TOptions>[];
|
|
415
|
+
/** Optional human-facing display name. Stable machine identity remains `id`. */
|
|
416
|
+
readonly name?: string;
|
|
417
|
+
readonly description?: string;
|
|
418
|
+
/**
|
|
419
|
+
* Dry-run policy. Omitted runs the normal handler, `"skip"` structurally
|
|
420
|
+
* skips it, and a handler substitutes for `run` while preserving its output.
|
|
421
|
+
*/
|
|
422
|
+
readonly dryRun?: "skip" | AnyStepDryRunHandler<TOptions>;
|
|
423
|
+
/** Optional Standard Schema for values published by this step. */
|
|
424
|
+
readonly outputSchema?: StandardSchemaV1;
|
|
425
|
+
/**
|
|
426
|
+
* Optional runtime skip. Return a non-empty reason (or `{ reason, value }`) to
|
|
427
|
+
* skip without calling `run`. Policy skips unlock dependents; structural skips
|
|
428
|
+
* (dry-run, filtered, …) do not use this hook.
|
|
429
|
+
*/
|
|
430
|
+
skip?(inputs: Record<string, unknown>, context: PipelineExecutionContext<TOptions>): StepSkipDecision | Promise<StepSkipDecision>;
|
|
431
|
+
run(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): unknown;
|
|
432
|
+
}
|
|
433
|
+
export interface Step<TId extends string, TOut, TOptions extends object, TInputOptions extends object = TOptions, TRunOut = TOut> extends AnyStep<TOptions> {
|
|
434
|
+
readonly id: TId;
|
|
435
|
+
run(inputs: Record<string, unknown>, context: PipelineStepContext<TOptions>): TRunOut | Promise<TRunOut>;
|
|
436
|
+
/** Type-only: carries this step's output type for sibling inference. Never set at runtime. */
|
|
437
|
+
readonly __outputType?: TOut;
|
|
438
|
+
/** Type-only: carries pre-validation run options for pipeline call-site inference. */
|
|
439
|
+
readonly __inputOptionsType?: TInputOptions;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Extract a step's output type for dependency typing.
|
|
443
|
+
* Prefer matching `Step<…, TOut, …>` over `{ __outputType?: infer T }`: optional-property
|
|
444
|
+
* inference collapses `TOut | undefined` to `TOut`, which hides policy-skip widening.
|
|
445
|
+
*/
|
|
446
|
+
type StepOutput<S> = S extends Step<string, infer TOut, infer _TOptions, infer _TInputOptions, infer _TRunOut> ? TOut : never;
|
|
447
|
+
interface StepToken {
|
|
448
|
+
readonly id: string;
|
|
449
|
+
readonly __outputType?: unknown;
|
|
450
|
+
}
|
|
451
|
+
type RequiredInputs<TDeps extends readonly StepToken[]> = {
|
|
452
|
+
[S in TDeps[number] as S["id"]]: StepOutput<S>;
|
|
453
|
+
};
|
|
454
|
+
type OptionalInputs<TDeps extends readonly StepToken[]> = {
|
|
455
|
+
[S in TDeps[number] as S["id"]]?: StepOutput<S>;
|
|
456
|
+
};
|
|
457
|
+
type PipelineResultOf<TPipeline> = TPipeline extends Pipeline<object, infer TResult, infer _TStepId, infer _TTargetId> ? TResult : never;
|
|
458
|
+
type PipelineRunOptionsOf<TPipeline> = TPipeline extends Pipeline<infer TOptions, unknown, infer TStepId, infer TTargetId> ? PipelineRunOptions<TOptions, TStepId, TTargetId> : never;
|
|
459
|
+
type ChildPipelineStepDefinitionBase<TParentOptions extends object, TDeps extends readonly AnyStep<TParentOptions>[], TOptionalDeps extends readonly AnyStep<TParentOptions>[], TChildPipeline extends Pipeline<object, unknown>> = {
|
|
460
|
+
pipeline: TChildPipeline;
|
|
461
|
+
dependsOn?: TDeps;
|
|
462
|
+
optionalDependsOn?: TOptionalDeps;
|
|
463
|
+
skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];
|
|
464
|
+
name?: string;
|
|
465
|
+
description?: string;
|
|
466
|
+
dryRun?: "skip";
|
|
467
|
+
mapOptions(inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>): PipelineRunOptionsOf<TChildPipeline>;
|
|
468
|
+
};
|
|
469
|
+
/** Child step without policy skip (dependents see the full child result type). */
|
|
470
|
+
type ChildPipelineStepDefinition<TParentOptions extends object, TDeps extends readonly AnyStep<TParentOptions>[], TOptionalDeps extends readonly AnyStep<TParentOptions>[], TChildPipeline extends Pipeline<object, unknown>> = ChildPipelineStepDefinitionBase<TParentOptions, TDeps, TOptionalDeps, TChildPipeline>;
|
|
471
|
+
/**
|
|
472
|
+
* Presentation options for opaque `forEachPipeline` progress.
|
|
473
|
+
* Defaults are domain-neutral (`N/M items · K running · key/step`).
|
|
474
|
+
* Override `formatMessage` when a domain wants its own noun (images, shards, …).
|
|
475
|
+
*/
|
|
476
|
+
export type MappedChildProgressOptions = ToMappedChildStepProgressOptions;
|
|
477
|
+
type MappedChildPipelineStepDefinition<TParentOptions extends object, TDeps extends readonly AnyStep<TParentOptions>[], TOptionalDeps extends readonly AnyStep<TParentOptions>[], TChildPipeline extends Pipeline<object, unknown>, TItem> = {
|
|
478
|
+
pipeline: TChildPipeline;
|
|
479
|
+
dependsOn?: TDeps;
|
|
480
|
+
optionalDependsOn?: TOptionalDeps;
|
|
481
|
+
skipAfterFailureOf?: readonly AnyStep<TParentOptions>[];
|
|
482
|
+
name?: string;
|
|
483
|
+
description?: string;
|
|
484
|
+
dryRun?: "skip";
|
|
485
|
+
items(inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>): readonly TItem[] | Promise<readonly TItem[]>;
|
|
486
|
+
key(item: TItem, index: number): string;
|
|
487
|
+
concurrency?: number | ((inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>) => number);
|
|
488
|
+
/**
|
|
489
|
+
* How the opaque parent step reports live fan-out progress.
|
|
490
|
+
* Purely presentational — does not change scheduling or results.
|
|
491
|
+
*/
|
|
492
|
+
progress?: MappedChildProgressOptions;
|
|
493
|
+
mapOptions(item: TItem, index: number, inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TParentOptions>): PipelineRunOptionsOf<TChildPipeline>;
|
|
494
|
+
};
|
|
495
|
+
type StepSkipPredicate<TOptions extends object, TDeps extends readonly AnyStep<TOptions>[], TOptionalDeps extends readonly AnyStep<TOptions>[], TOut> = (inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineExecutionContext<TOptions>) => StepSkipDecision<TOut> | Promise<StepSkipDecision<TOut>>;
|
|
496
|
+
type StepDryRunPolicy<TOptions extends object, TDeps extends readonly AnyStep<TOptions>[], TOptionalDeps extends readonly AnyStep<TOptions>[], TOut> = "skip" | ((inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineStepContext<TOptions>) => TOut | Promise<TOut>);
|
|
497
|
+
type PlainStepFields<TOptions extends object, TDeps extends readonly AnyStep<TOptions>[], TOptionalDeps extends readonly AnyStep<TOptions>[], TOut> = {
|
|
498
|
+
dependsOn?: TDeps;
|
|
499
|
+
optionalDependsOn?: TOptionalDeps;
|
|
500
|
+
skipAfterFailureOf?: readonly AnyStep<TOptions>[];
|
|
501
|
+
name?: string;
|
|
502
|
+
description?: string;
|
|
503
|
+
dryRun?: StepDryRunPolicy<TOptions, TDeps, TOptionalDeps, TOut>;
|
|
504
|
+
outputSchema?: never;
|
|
505
|
+
run(inputs: RequiredInputs<TDeps> & OptionalInputs<TOptionalDeps>, context: PipelineStepContext<TOptions>): TOut | Promise<TOut>;
|
|
506
|
+
};
|
|
507
|
+
type SchemaStepFields<TOptions extends object, TDeps extends readonly AnyStep<TOptions>[], TOptionalDeps extends readonly AnyStep<TOptions>[], TSchema extends StandardSchemaV1> = Omit<PlainStepFields<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>>, "outputSchema"> & {
|
|
508
|
+
outputSchema: TSchema;
|
|
509
|
+
};
|
|
510
|
+
interface StepConstructor<TOptions extends object, TInputOptions extends object = TOptions> {
|
|
511
|
+
/** Ordinary steps never policy-skip, so dependents receive their full output. */
|
|
512
|
+
<TId extends string, TSchema extends StandardSchemaV1, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & {
|
|
513
|
+
skip?: never;
|
|
514
|
+
}): Step<TId, InferSchemaOutput<TSchema>, TOptions, TInputOptions, InferSchemaInput<TSchema>>;
|
|
515
|
+
<TId extends string, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = [], TOut = unknown>(id: TId, definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & {
|
|
516
|
+
skip?: never;
|
|
517
|
+
}): Step<TId, TOut, TOptions, TInputOptions>;
|
|
518
|
+
/** Explicit policy-skip constructor; dependents receive `TOut | undefined`. */
|
|
519
|
+
skippable: SkippableStepConstructor<TOptions, TInputOptions>;
|
|
520
|
+
}
|
|
521
|
+
interface SkippableStepConstructor<TOptions extends object, TInputOptions extends object = TOptions> {
|
|
522
|
+
<TId extends string, TSchema extends StandardSchemaV1, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: SchemaStepFields<TOptions, TDeps, TOptionalDeps, TSchema> & {
|
|
523
|
+
skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, InferSchemaInput<TSchema>> | undefined;
|
|
524
|
+
}): Step<TId, InferSchemaOutput<TSchema> | undefined, TOptions, TInputOptions, InferSchemaInput<TSchema>>;
|
|
525
|
+
<TId extends string, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = [], TOut = unknown>(id: TId, definition: PlainStepFields<TOptions, TDeps, TOptionalDeps, TOut> & {
|
|
526
|
+
skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, TOut> | undefined;
|
|
527
|
+
}): Step<TId, TOut | undefined, TOptions, TInputOptions>;
|
|
528
|
+
}
|
|
529
|
+
interface FromPipelineConstructor<TOptions extends object, TInputOptions extends object = TOptions> {
|
|
530
|
+
<TId extends string, TChildPipeline extends Pipeline<object, unknown>, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
|
|
531
|
+
skip?: never;
|
|
532
|
+
mapResult?: undefined;
|
|
533
|
+
}): Step<TId, PipelineResultOf<TChildPipeline>, TOptions, TInputOptions>;
|
|
534
|
+
<TId extends string, TChildPipeline extends Pipeline<object, unknown>, TOut, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
|
|
535
|
+
skip?: never;
|
|
536
|
+
mapResult(value: PipelineResultOf<TChildPipeline>, result: PipelineRun<PipelineResultOf<TChildPipeline>>, context: PipelineStepContext<TOptions>): TOut;
|
|
537
|
+
}): Step<TId, TOut, TOptions, TInputOptions>;
|
|
538
|
+
skippable: SkippableFromPipelineConstructor<TOptions, TInputOptions>;
|
|
539
|
+
}
|
|
540
|
+
interface SkippableFromPipelineConstructor<TOptions extends object, TInputOptions extends object = TOptions> {
|
|
541
|
+
<TId extends string, TChildPipeline extends Pipeline<object, unknown>, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
|
|
542
|
+
skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, PipelineResultOf<TChildPipeline>> | undefined;
|
|
543
|
+
mapResult?: undefined;
|
|
544
|
+
}): Step<TId, PipelineResultOf<TChildPipeline> | undefined, TOptions, TInputOptions>;
|
|
545
|
+
<TId extends string, TChildPipeline extends Pipeline<object, unknown>, TOut, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: ChildPipelineStepDefinitionBase<TOptions, TDeps, TOptionalDeps, TChildPipeline> & {
|
|
546
|
+
skip: StepSkipPredicate<TOptions, TDeps, TOptionalDeps, NoInfer<TOut>> | undefined;
|
|
547
|
+
mapResult(value: PipelineResultOf<TChildPipeline>, result: PipelineRun<PipelineResultOf<TChildPipeline>>, context: PipelineStepContext<TOptions>): TOut;
|
|
548
|
+
}): Step<TId, TOut | undefined, TOptions, TInputOptions>;
|
|
549
|
+
}
|
|
550
|
+
export interface StepFactory<TOptions extends object, TInputOptions extends object = TOptions> extends StepConstructor<TOptions, TInputOptions> {
|
|
551
|
+
fromPipeline: FromPipelineConstructor<TOptions, TInputOptions>;
|
|
552
|
+
forEachPipeline<TId extends string, TChildPipeline extends Pipeline<object, unknown>, TItem, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: MappedChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline, TItem> & {
|
|
553
|
+
mapResult?: undefined;
|
|
554
|
+
}): Step<TId, readonly PipelineResultOf<TChildPipeline>[], TOptions, TInputOptions>;
|
|
555
|
+
forEachPipeline<TId extends string, TChildPipeline extends Pipeline<object, unknown>, TItem, TOut, const TDeps extends readonly AnyStep<TOptions>[] = [], const TOptionalDeps extends readonly AnyStep<TOptions>[] = []>(id: TId, definition: MappedChildPipelineStepDefinition<TOptions, TDeps, TOptionalDeps, TChildPipeline, TItem> & {
|
|
556
|
+
mapResult(value: PipelineResultOf<TChildPipeline>, result: PipelineRun<PipelineResultOf<TChildPipeline>>, item: TItem, index: number, context: PipelineStepContext<TOptions>): TOut;
|
|
557
|
+
}): Step<TId, readonly TOut[], TOptions, TInputOptions>;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Returns a step factory scoped to one pipeline's domain options. Built-in run
|
|
561
|
+
* controls are accepted alongside those options when the pipeline is invoked.
|
|
562
|
+
*/
|
|
563
|
+
export declare function createSteps<TOptions extends object = {}>(): StepFactory<TOptions>;
|
|
564
|
+
export declare function createSteps<const TSchema extends StandardSchemaV1<object, object>>(optionsSchema: TSchema): StepFactory<InferSchemaOutput<TSchema>, InferSchemaInput<TSchema>>;
|
|
565
|
+
type PipelineOutputs<TSteps extends readonly AnyStep[]> = {
|
|
566
|
+
[S in TSteps[number] as S["id"]]: StepOutput<S>;
|
|
567
|
+
};
|
|
568
|
+
type RequiredPipelineOutputs<TSteps extends readonly AnyStep[]> = {
|
|
569
|
+
[S in TSteps[number] as S["id"]]-?: StepOutput<S>;
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* Recovers the options type from the steps themselves rather than taking it as its own
|
|
573
|
+
* generic parameter. A `TOptions` parameter constrained by `TSteps extends
|
|
574
|
+
* readonly AnyStep<TOptions>[]` is self-referential — TypeScript can't solve that at a
|
|
575
|
+
* `definePipeline(...)` call site and silently widens `TOptions` to its bare
|
|
576
|
+
* `object` constraint (context.options would lose every pipeline-specific
|
|
577
|
+
* field). Structuring it as "derive TOptions from TSteps" instead of "constrain TSteps by
|
|
578
|
+
* TOptions" avoids the cycle, so callers never write out any of these type parameters.
|
|
579
|
+
*/
|
|
580
|
+
type StepsOptions<TSteps extends readonly AnyStep[]> = TSteps[number] extends AnyStep<infer TOptions> ? TOptions : object;
|
|
581
|
+
type StepsInputOptions<TSteps extends readonly AnyStep[]> = TSteps[number] extends Step<string, unknown, object, infer TInputOptions, infer _TRunOut> ? TInputOptions : StepsOptions<TSteps>;
|
|
582
|
+
type StepIds<TSteps extends readonly AnyStep[]> = TSteps[number]["id"];
|
|
583
|
+
type TargetIds<TTargets extends readonly AnyStep[]> = TTargets[number]["id"];
|
|
584
|
+
type DuplicateStepIds<TSteps extends readonly AnyStep[], TSeen extends string = never> = TSteps extends readonly [infer THead, ...infer TTail] ? THead extends AnyStep ? TTail extends readonly AnyStep[] ? THead["id"] extends TSeen ? THead["id"] | DuplicateStepIds<TTail, TSeen> : DuplicateStepIds<TTail, TSeen | THead["id"]> : never : never : never;
|
|
585
|
+
type CheckedStepTuple<TSteps extends readonly AnyStep[]> = string extends StepIds<TSteps> ? unknown : DuplicateStepIds<TSteps> extends never ? unknown : {
|
|
586
|
+
/** Compile-time diagnostic: every literal step ID in a definition must be unique. */
|
|
587
|
+
readonly __duplicateStepIds: DuplicateStepIds<TSteps>;
|
|
588
|
+
};
|
|
589
|
+
/**
|
|
590
|
+
* Build a finalizer that only runs when every listed step published an output.
|
|
591
|
+
* Presence is checked by output slot, so a successfully published `undefined`
|
|
592
|
+
* remains distinct from a structural skip or failure.
|
|
593
|
+
*/
|
|
594
|
+
export declare function requireOutputs<const TRequiredSteps extends readonly AnyStep[], TResult>(requiredSteps: TRequiredSteps, finalize: (outputs: RequiredPipelineOutputs<TRequiredSteps>, context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>) => TResult | Promise<TResult>): (outputs: Partial<RequiredPipelineOutputs<TRequiredSteps>>, context: PipelineExecutionContext<StepsOptions<TRequiredSteps>>) => TResult | Promise<TResult>;
|
|
595
|
+
export interface PipelineDefinition<TSteps extends readonly AnyStep[], TResult, TTargets extends readonly TSteps[number][] = readonly [], TResultSchema extends StandardSchemaV1 | undefined = undefined> {
|
|
596
|
+
id: string;
|
|
597
|
+
steps: TSteps;
|
|
598
|
+
/** Public downstream goals that callers may select with `targets`. */
|
|
599
|
+
targets?: TTargets;
|
|
600
|
+
/** Optional Standard Schema for the finalized result. */
|
|
601
|
+
resultSchema?: TResultSchema;
|
|
602
|
+
finalize(outputs: Partial<PipelineOutputs<TSteps>>, context: PipelineExecutionContext<StepsOptions<TSteps>>): (TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult) | Promise<TResultSchema extends StandardSchemaV1 ? InferSchemaInput<TResultSchema> : TResult>;
|
|
603
|
+
}
|
|
604
|
+
export declare function definePipeline<const TSteps extends readonly AnyStep[], TResult = unknown, const TTargets extends readonly TSteps[number][] = readonly [], const TResultSchema extends StandardSchemaV1 | undefined = undefined>(definition: PipelineDefinition<TSteps, TResult, TTargets, TResultSchema> & CheckedStepTuple<TSteps>): Pipeline<StepsInputOptions<TSteps>, TResultSchema extends StandardSchemaV1 ? InferSchemaOutput<TResultSchema> : TResult, StepIds<TSteps>, TargetIds<TTargets>>;
|
|
605
|
+
export { formatMappedChildProgressMessage, mappedChildProgressDetails, mappedChildProgressUnits, toMappedChildStepProgress, type FormatMappedChildProgressOptions, type MappedChildProgressDetail, type MappedChildProgressSnapshot, type MappedChildProgressUnits, type ToMappedChildStepProgressOptions, } from "./mapped-child-progress.js";
|
|
606
|
+
//# sourceMappingURL=pipeline.d.ts.map
|